Skip to content

Commit 82391d5

Browse files
feat(rc): Add Remote Config Parameter Value Type Support (#1424)
go/admin-sdk-rc-parameter-value-types Add RC Parameter Value Type. Update unit tests. - Integration tests will be added following the REST API launch. Added release:stage to trigger existing integration tests (to test backward compatibility). - Do not merge until the BE is updated. Update: - Integration tests are updated. RELEASE NOTE: Added Remote Config Parameter Value Type Support.
1 parent bb1fb6f commit 82391d5

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

etc/firebase-admin.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ export namespace remoteConfig {
10141014
nextPageToken?: string;
10151015
versions: Version[];
10161016
}
1017+
export type ParameterValueType = 'STRING' | 'BOOLEAN' | 'NUMBER' | 'JSON';
10171018
export interface RemoteConfig {
10181019
// (undocumented)
10191020
app: app.App;
@@ -1038,6 +1039,7 @@ export namespace remoteConfig {
10381039
};
10391040
defaultValue?: RemoteConfigParameterValue;
10401041
description?: string;
1042+
valueType?: ParameterValueType;
10411043
}
10421044
export interface RemoteConfigParameterGroup {
10431045
description?: string;

src/remote-config/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ export namespace remoteConfig {
150150
* Unicode characters.
151151
*/
152152
description?: string;
153+
154+
/**
155+
* The data type for all values of this parameter in the current version of the template.
156+
* Defaults to `ParameterValueType.STRING` if unspecified.
157+
*/
158+
valueType?: ParameterValueType;
153159
}
154160

155161
/**
@@ -259,6 +265,12 @@ export namespace remoteConfig {
259265
export type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' |
260266
'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';
261267

268+
/**
269+
* Type representing a Remote Config parameter value data type.
270+
* Defaults to `STRING` if unspecified.
271+
*/
272+
export type ParameterValueType = 'STRING' | 'BOOLEAN' | 'NUMBER' | 'JSON'
273+
262274
/**
263275
* Interface representing a Remote Config template version.
264276
* Output only, except for the version description. Contains metadata about a particular

test/integration/remote-config.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ const VALID_PARAMETERS = {
2828
// eslint-disable-next-line @typescript-eslint/camelcase
2929
holiday_promo_enabled: {
3030
defaultValue: { useInAppDefault: true },
31-
description: 'promo indicator'
31+
description: 'promo indicator',
32+
valueType: 'STRING' as admin.remoteConfig.ParameterValueType,
3233
},
3334
// eslint-disable-next-line @typescript-eslint/camelcase
3435
welcome_message: {
3536
defaultValue: { value: `welcome text ${Date.now()}` },
37+
valueType: 'STRING' as admin.remoteConfig.ParameterValueType,
3638
conditionalValues: {
3739
ios: { value: 'welcome ios text' },
3840
android: { value: 'welcome android text' },
@@ -52,6 +54,7 @@ const VALID_PARAMETER_GROUPS = {
5254
'android': { value: 'A Droid must love a pumpkin spice latte.' },
5355
},
5456
description: 'Description of the parameter.',
57+
valueType: 'STRING' as admin.remoteConfig.ParameterValueType,
5558
},
5659
},
5760
},

test/unit/remote-config/remote-config-api-client.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('RemoteConfigApiClient', () => {
7373

7474
const TEST_RESPONSE = {
7575
conditions: [{ name: 'ios', expression: 'exp' }],
76-
parameters: { param: { defaultValue: { value: 'true' } } },
76+
parameters: { param: { defaultValue: { value: 'true' }, valueType: 'BOOLEAN' } },
7777
parameterGroups: { group: { parameters: { paramabc: { defaultValue: { value: 'true' } } }, } },
7878
version: VERSION_INFO,
7979
};
@@ -132,6 +132,7 @@ describe('RemoteConfigApiClient', () => {
132132
defaultValue: { value: 'true' },
133133
conditionalValues: { ios: { useInAppDefault: true } },
134134
description: 'this is a promo',
135+
valueType: 'BOOLEAN'
135136
},
136137
},
137138
parameterGroups: {
@@ -429,7 +430,7 @@ describe('RemoteConfigApiClient', () => {
429430
});
430431

431432
VALIDATION_ERROR_MESSAGES.forEach((message) => {
432-
it('should reject with failed-precondition when a validation error occurres', () => {
433+
it('should reject with failed-precondition when a validation error occurs', () => {
433434
const stub = sinon
434435
.stub(HttpClient.prototype, 'send')
435436
.rejects(utils.errorFrom({

test/unit/remote-config/remote-config.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('RemoteConfig', () => {
5151
'android_en': { value: 'A Droid must love a pumpkin spice latte.' },
5252
},
5353
description: 'Description of the parameter.',
54+
valueType: 'STRING' as remoteConfig.ParameterValueType,
5455
},
5556
},
5657
},
@@ -91,6 +92,7 @@ describe('RemoteConfig', () => {
9192
defaultValue: { value: 'true' },
9293
conditionalValues: { ios: { useInAppDefault: true } },
9394
description: 'this is a promo',
95+
valueType: 'BOOLEAN',
9496
},
9597
},
9698
parameterGroups: PARAMETER_GROUPS,
@@ -110,6 +112,7 @@ describe('RemoteConfig', () => {
110112
defaultValue: { value: 'true' },
111113
conditionalValues: { ios: { useInAppDefault: true } },
112114
description: 'this is a promo',
115+
valueType: 'BOOLEAN',
113116
},
114117
},
115118
parameterGroups: PARAMETER_GROUPS,
@@ -383,7 +386,7 @@ describe('RemoteConfig', () => {
383386
});
384387
});
385388

386-
it('should resolve with an empty versions list if the no results are availble for requested list options', () => {
389+
it('should resolve with an empty versions list if no results are available for requested list options', () => {
387390
const stub = sinon
388391
.stub(RemoteConfigApiClient.prototype, 'listVersions')
389392
.resolves({} as any);
@@ -498,6 +501,7 @@ describe('RemoteConfig', () => {
498501
expect(p1.defaultValue).deep.equals({ value: 'true' });
499502
expect(p1.conditionalValues).deep.equals({ ios: { useInAppDefault: true } });
500503
expect(p1.description).equals('this is a promo');
504+
expect(p1.valueType).equals('BOOLEAN');
501505

502506
expect(newTemplate.parameterGroups).deep.equals(PARAMETER_GROUPS);
503507

@@ -662,6 +666,7 @@ describe('RemoteConfig', () => {
662666
expect(p1.defaultValue).deep.equals({ value: 'true' });
663667
expect(p1.conditionalValues).deep.equals({ ios: { useInAppDefault: true } });
664668
expect(p1.description).equals('this is a promo');
669+
expect(p1.valueType).equals('BOOLEAN');
665670

666671
expect(template.parameterGroups).deep.equals(PARAMETER_GROUPS);
667672

0 commit comments

Comments
 (0)