Skip to content
Closed
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
7 changes: 6 additions & 1 deletion etc/firebase-admin.remote-config.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export interface InAppDefaultValue {
useInAppDefault: boolean;
}

// @public
export interface InServerDefaultValue {
useInServerDefault: boolean;
}

// @public
export interface ListVersionsOptions {
endTime?: Date | string;
Expand Down Expand Up @@ -84,7 +89,7 @@ export interface RemoteConfigParameterGroup {
}

// @public
export type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
export type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue | InServerDefaultValue;

// @public
export interface RemoteConfigServerCondition {
Expand Down
1 change: 1 addition & 0 deletions src/remote-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { RemoteConfig } from './remote-config';
export {
ExplicitParameterValue,
InAppDefaultValue,
InServerDefaultValue,
ListVersionsOptions,
ListVersionsResult,
ParameterValueType,
Expand Down
12 changes: 11 additions & 1 deletion src/remote-config/remote-config-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,22 @@ export interface InAppDefaultValue {
useInAppDefault: boolean;
}

/**
* Represents an in-server-default value.
*/
export interface InServerDefaultValue {
/**
* If `true`, `RemoteConfigServerTemplate` will use the parameter's default value.
*/
useInServerDefault: boolean;
}

/**
* Type representing a Remote Config parameter value.
* A `RemoteConfigParameterValue` could be either an `ExplicitParameterValue` or
* an `InAppDefaultValue`.
*/
export type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
export type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue | InServerDefaultValue;

/**
* Interface representing a Remote Config parameter.
Expand Down
6 changes: 3 additions & 3 deletions src/remote-config/remote-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
RemoteConfigUser,
Version,
ExplicitParameterValue,
InAppDefaultValue,
InServerDefaultValue,
ParameterValueType,
RemoteConfigServerConfig,
RemoteConfigServerTemplateData,
Expand Down Expand Up @@ -323,8 +323,8 @@ class RemoteConfigServerTemplateImpl implements RemoteConfigServerTemplate {
continue;
}

if ((defaultValue as InAppDefaultValue).useInAppDefault) {
console.log(`Filtering out parameter ${key} with "use in-app default" value`);
if ((defaultValue as InServerDefaultValue).useInServerDefault) {
console.log(`Filtering out parameter ${key} with "use in-server default" value`);
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/remote-config/remote-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('RemoteConfig', () => {
parameters: {
holiday_promo_enabled: {
defaultValue: { value: 'true' },
conditionalValues: { ios: { useInAppDefault: true } },
conditionalValues: { ios: { useInServerDefault: true } },
description: 'this is a promo',
valueType: 'BOOLEAN',
},
Expand Down Expand Up @@ -580,7 +580,7 @@ describe('RemoteConfig', () => {
const key = 'holiday_promo_enabled';
const p1 = template.cache.parameters[key];
expect(p1.defaultValue).deep.equals({ value: 'true' });
expect(p1.conditionalValues).deep.equals({ ios: { useInAppDefault: true } });
expect(p1.conditionalValues).deep.equals({ ios: { useInServerDefault: true } });
expect(p1.description).equals('this is a promo');
expect(p1.valueType).equals('BOOLEAN');

Expand Down Expand Up @@ -791,7 +791,7 @@ describe('RemoteConfig', () => {
const key = 'holiday_promo_enabled';
const p1 = template.cache.parameters[key];
expect(p1.defaultValue).deep.equals({ value: 'true' });
expect(p1.conditionalValues).deep.equals({ ios: { useInAppDefault: true } });
expect(p1.conditionalValues).deep.equals({ ios: { useInServerDefault: true } });
expect(p1.description).equals('this is a promo');
expect(p1.valueType).equals('BOOLEAN');

Expand Down