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
63 changes: 62 additions & 1 deletion src/remote-config/remote-config-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,73 @@ export interface InAppDefaultValue {
useInAppDefault: boolean;
}

/**
* Represents a Rollout value.
*/
export interface RolloutValue {
rolloutId: string;
value: string;
percent: number; // Numeric value between 1-100
}

/**
* Represents a Personalization value.
*/
export interface PersonalizationValue {
personalizationId: string;
}

/**
* Represents a specific variant value within an Experiment.
*/
export interface ExperimentVariantExplicitValue {
variantId: string;
value: string;
noChange?: never;
}

/**
* Represents a no-change variant value within an Experiment.
*/
export interface ExperimentVariantNoChange {
variantId: string;
value?: never;
noChange: true;
}

export type ExperimentVariantValue = ExperimentVariantExplicitValue | ExperimentVariantNoChange;

/**
* Represents an Experiment value.
*/
export interface ExperimentValue {
experimentId: string;
variantValue: ExperimentVariantValue[];
}

export interface RolloutParameterValue {
rolloutValue: RolloutValue;
}

export interface PersonalizationParameterValue {
personalizationValue: PersonalizationValue;
}

export interface ExperimentParameterValue {
experimentValue: ExperimentValue;
}

/**
* 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
| RolloutParameterValue
| PersonalizationParameterValue
| ExperimentParameterValue;

/**
* Interface representing a Remote Config parameter.
Expand Down
54 changes: 54 additions & 0 deletions src/remote-config/remote-config-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ import { App } from '../app';
import {
ExplicitParameterValue as TExplicitParameterValue,
InAppDefaultValue as TInAppDefaultValue,
RolloutValue as TRolloutValue,
PersonalizationValue as TPersonalizationValue,
ExperimentVariantExplicitValue as TExperimentVariantExplicitValue,
ExperimentVariantNoChange as TExperimentVariantNoChange,
ExperimentVariantValue as TExperimentVariantValue,
ExperimentValue as TExperimentValue,
RolloutParameterValue as TRolloutParameterValue,
PersonalizationParameterValue as TPersonalizationParameterValue,
ExperimentParameterValue as TExperimentParameterValue,
ListVersionsOptions as TListVersionsOptions,
ListVersionsResult as TListVersionsResult,
ParameterValueType as TParameterValueType,
Expand Down Expand Up @@ -73,6 +82,51 @@ export namespace remoteConfig {
*/
export type InAppDefaultValue = TInAppDefaultValue;

/**
* Type alias to {@link firebase-admin.remote-config#RolloutValue}.
*/
export type RolloutValue = TRolloutValue;

/**
* Type alias to {@link firebase-admin.remote-config#PersonalizationValue}.
*/
export type PersonalizationValue = TPersonalizationValue;

/**
* Type alias to {@link firebase-admin.remote-config#ExperimentVariantExplicitValue}.
*/
export type ExperimentVariantExplicitValue = TExperimentVariantExplicitValue;

/**
* Type alias to {@link firebase-admin.remote-config#ExperimentVariantNoChange}.
*/
export type ExperimentVariantNoChange = TExperimentVariantNoChange;

/**
* Type alias to {@link firebase-admin.remote-config#ExperimentVariantValue}.
*/
export type ExperimentVariantValue = TExperimentVariantValue;

/**
* Type alias to {@link firebase-admin.remote-config#ExperimentValue}.
*/
export type ExperimentValue = TExperimentValue;

/**
* Type alias to {@link firebase-admin.remote-config#RolloutParameterValue}.
*/
export type RolloutParameterValue = TRolloutParameterValue;

/**
* Type alias to {@link firebase-admin.remote-config#PersonalizationParameterValue}.
*/
export type PersonalizationParameterValue = TPersonalizationParameterValue;

/**
* Type alias to {@link firebase-admin.remote-config#ExperimentParameterValue}.
*/
export type ExperimentParameterValue = TExperimentParameterValue;

/**
* Type alias to {@link firebase-admin.remote-config#ListVersionsOptions}.
*/
Expand Down
84 changes: 84 additions & 0 deletions test/unit/remote-config/remote-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,48 @@ describe('RemoteConfig', () => {
description: 'this is a promo',
valueType: 'BOOLEAN',
},
new_ui_enabled: {
defaultValue: { value: 'false' },
conditionalValues: {
ios: {
rolloutValue: {
rolloutId: 'rollout_1',
value: 'true',
percent: 50,
}
}
},
description: 'New UI Rollout',
valueType: 'BOOLEAN',
},
personalized_welcome_message: {
defaultValue: { value: 'Welcome!' },
conditionalValues: {
ios: {
personalizationValue: {
personalizationId: 'personalization_1',
}
}
},
description: 'Personalized Welcome Message',
valueType: 'STRING',
},
experiment_enabled: {
defaultValue: { value: 'false' },
conditionalValues: {
ios: {
experimentValue: {
experimentId: 'experiment_1',
variantValue: [
{ variantId: 'variant_A', value: 'true' },
{ variantId: 'variant_B', noChange: true }
]
}
}
},
description: 'Experiment Enabled',
valueType: 'BOOLEAN',
}
},
parameterGroups: PARAMETER_GROUPS,
etag: 'etag-123456789012-5',
Expand Down Expand Up @@ -153,6 +195,48 @@ describe('RemoteConfig', () => {
description: 'this is a promo',
valueType: 'BOOLEAN',
},
new_ui_enabled: {
defaultValue: { value: 'false' },
conditionalValues: {
ios: {
rolloutValue: {
rolloutId: 'rollout_1',
value: 'true',
percent: 50,
}
}
},
description: 'New UI Rollout',
valueType: 'BOOLEAN',
},
personalized_welcome_message: {
defaultValue: { value: 'Welcome!' },
conditionalValues: {
ios: {
personalizationValue: {
personalizationId: 'personalization_1',
}
}
},
description: 'Personalized Welcome Message',
valueType: 'STRING',
},
experiment_enabled: {
defaultValue: { value: 'false' },
conditionalValues: {
ios: {
experimentValue: {
experimentId: 'experiment_1',
variantValue: [
{ variantId: 'variant_A', value: 'true' },
{ variantId: 'variant_B', noChange: true }
]
}
}
},
description: 'Experiment Enabled',
valueType: 'BOOLEAN',
}
},
parameterGroups: PARAMETER_GROUPS,
etag: 'etag-123456789012-6',
Expand Down