Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,23 @@ declare namespace admin.projectManagement {

declare namespace admin.remoteConfig {

/**
* Colors that are associated with conditions for display purposes.
*/
enum TagColor {
BLUE = "Blue",
BROWN = "Brown",
CYAN = "Cyan",
DEEP_ORANGE = "Red Orange",
GREEN = "Green",
INDIGO = "Indigo",
LIME = "Lime",
ORANGE = "Orange",
PINK = "Pink",
PURPLE = "Purple",
TEAL = "Teal",
}

/**
* Interface representing a Remote Config template.
*/
Expand Down Expand Up @@ -885,7 +902,7 @@ declare namespace admin.remoteConfig {
* Not specifying this value results in the console picking an arbitrary color to associate
* with the condition.
*/
tagColor?: string;
tagColor?: TagColor;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/remote-config/remote-config-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FIREBASE_REMOTE_CONFIG_HEADERS = {
'Accept-Encoding': 'gzip',
};

export enum RemoteConfigConditionDisplayColor {
export enum TagColor {
BLUE = "Blue",
BROWN = "Brown",
CYAN = "Cyan",
Expand Down Expand Up @@ -69,7 +69,7 @@ export interface RemoteConfigParameter {
export interface RemoteConfigCondition {
name: string;
expression: string;
tagColor?: RemoteConfigConditionDisplayColor;
tagColor?: TagColor;
}

/** Interface representing a Remote Config template. */
Expand Down
4 changes: 2 additions & 2 deletions test/unit/remote-config/remote-config-api-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as sinon from 'sinon';
import {
RemoteConfigApiClient,
RemoteConfigTemplate,
RemoteConfigConditionDisplayColor
TagColor,
} from '../../../src/remote-config/remote-config-api-client';
import { FirebaseRemoteConfigError } from '../../../src/remote-config/remote-config-utils';
import { HttpClient } from '../../../src/utils/api-request';
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('RemoteConfigApiClient', () => {
conditions: [{
name: 'ios',
expression: 'device.os == \'ios\'',
tagColor: RemoteConfigConditionDisplayColor.PINK,
tagColor: TagColor.PINK,
}],
parameters: {
// eslint-disable-next-line @typescript-eslint/camelcase
Expand Down
24 changes: 12 additions & 12 deletions test/unit/remote-config/remote-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
RemoteConfigApiClient,
RemoteConfigTemplate,
RemoteConfigCondition,
RemoteConfigConditionDisplayColor,
TagColor,
} from '../../../src/remote-config/remote-config-api-client';
import { FirebaseRemoteConfigError } from '../../../src/remote-config/remote-config-utils';
import { deepCopy } from '../../../src/utils/deep-copy';
Expand All @@ -41,14 +41,14 @@ describe('RemoteConfig', () => {
// to allow easier use from within the tests. An improvement would be to
// alter this into a helper that creates customized RemoteConfigTemplateContent based
// on the needs of the test, as that would ensure type-safety.
conditions?: Array<{ name: string; expression: string; tagColor: string }>;
conditions?: Array<{ name: string; expression: string; tagColor: TagColor }>;
parameters?: object | null;
etag: string;
} = {
conditions: [{
name: 'ios',
expression: 'device.os == \'ios\'',
tagColor: 'BLUE',
tagColor: TagColor.BLUE,
}],
parameters: {
// eslint-disable-next-line @typescript-eslint/camelcase
Expand All @@ -65,7 +65,7 @@ describe('RemoteConfig', () => {
conditions: [{
name: 'ios',
expression: 'device.os == \'ios\'',
tagColor: RemoteConfigConditionDisplayColor.PINK,
tagColor: TagColor.PINK,
}],
parameters: {
// eslint-disable-next-line @typescript-eslint/camelcase
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('RemoteConfig', () => {
expect(template.conditions.length).to.equal(1);
expect(template.conditions[0].name).to.equal('ios');
expect(template.conditions[0].expression).to.equal('device.os == \'ios\'');
expect(template.conditions[0].tagColor).to.equal('BLUE');
expect(template.conditions[0].tagColor).to.equal(TagColor.BLUE);
expect(template.etag).to.equal('etag-123456789012-5');
// verify that etag is read-only
expect(() => {
Expand All @@ -234,7 +234,7 @@ describe('RemoteConfig', () => {
const cond = c as RemoteConfigCondition;
expect(cond.name).to.equal('ios');
expect(cond.expression).to.equal('device.os == \'ios\'');
expect(cond.tagColor).to.equal('BLUE');
expect(cond.tagColor).to.equal(TagColor.BLUE);
});
});
});
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('RemoteConfig', () => {
expect(template.conditions.length).to.equal(1);
expect(template.conditions[0].name).to.equal('ios');
expect(template.conditions[0].expression).to.equal('device.os == \'ios\'');
expect(template.conditions[0].tagColor).to.equal('Pink');
expect(template.conditions[0].tagColor).to.equal(TagColor.PINK);
// verify that the etag is unchanged
expect(template.etag).to.equal('etag-123456789012-6');
// verify that the etag is read-only
Expand All @@ -325,7 +325,7 @@ describe('RemoteConfig', () => {
const cond = c as RemoteConfigCondition;
expect(cond.name).to.equal('ios');
expect(cond.expression).to.equal('device.os == \'ios\'');
expect(cond.tagColor).to.equal('Pink');
expect(cond.tagColor).to.equal(TagColor.PINK);
});
});
});
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('RemoteConfig', () => {
expect(template.conditions.length).to.equal(1);
expect(template.conditions[0].name).to.equal('ios');
expect(template.conditions[0].expression).to.equal('device.os == \'ios\'');
expect(template.conditions[0].tagColor).to.equal('BLUE');
expect(template.conditions[0].tagColor).to.equal(TagColor.BLUE);
expect(template.etag).to.equal('etag-123456789012-5');
// verify that the etag is read-only
expect(() => {
Expand All @@ -415,7 +415,7 @@ describe('RemoteConfig', () => {
const cond = c as RemoteConfigCondition;
expect(cond.name).to.equal('ios');
expect(cond.expression).to.equal('device.os == \'ios\'');
expect(cond.tagColor).to.equal('BLUE');
expect(cond.tagColor).to.equal(TagColor.BLUE);
});
});
});
Expand Down Expand Up @@ -477,7 +477,7 @@ describe('RemoteConfig', () => {
expect(newTemplate.conditions.length).to.equal(1);
expect(newTemplate.conditions[0].name).to.equal('ios');
expect(newTemplate.conditions[0].expression).to.equal('device.os == \'ios\'');
expect(newTemplate.conditions[0].tagColor).to.equal('BLUE');
expect(newTemplate.conditions[0].tagColor).to.equal(TagColor.BLUE);
// verify that the etag is unchanged
expect(newTemplate.etag).to.equal('etag-123456789012-5');
// verify that the etag is read-only
Expand All @@ -496,7 +496,7 @@ describe('RemoteConfig', () => {
const cond = c as RemoteConfigCondition;
expect(cond.name).to.equal('ios');
expect(cond.expression).to.equal('device.os == \'ios\'');
expect(cond.tagColor).to.equal('BLUE');
expect(cond.tagColor).to.equal(TagColor.BLUE);
});
});
});