Skip to content

Commit

Permalink
feat(rc): Add server side Remote Config support (#2529)
Browse files Browse the repository at this point in the history
Currently, Remote Config doesn't provide a way for servers to obtain
configuration, and the Admin SDK has historically been used only for
managing Remote Config. This change updates the Admin SDK with
functionality for evaluating a template to produce configuration for a
given context.
  • Loading branch information
erikeldridge committed Apr 15, 2024
1 parent a00de0c commit a833f4e
Show file tree
Hide file tree
Showing 14 changed files with 4,253 additions and 1,297 deletions.
109 changes: 109 additions & 0 deletions etc/firebase-admin.remote-config.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@

import { Agent } from 'http';

// @public
export interface AndCondition {
conditions?: Array<OneOfCondition>;
}

// @public
export type DefaultConfig = {
[key: string]: string | number | boolean;
};

// @public
export type EvaluationContext = {
randomizationId?: string;
};

// @public
export interface ExplicitParameterValue {
value: string;
Expand All @@ -18,11 +33,21 @@ export interface ExplicitParameterValue {
// @public
export function getRemoteConfig(app?: App): RemoteConfig;

// @public
export interface GetServerTemplateOptions {
defaultConfig?: DefaultConfig;
}

// @public
export interface InAppDefaultValue {
useInAppDefault: boolean;
}

// @public
export interface InitServerTemplateOptions extends GetServerTemplateOptions {
template?: ServerTemplateDataType;
}

// @public
export interface ListVersionsOptions {
endTime?: Date | string;
Expand All @@ -38,16 +63,60 @@ export interface ListVersionsResult {
versions: Version[];
}

// @public
export interface MicroPercentRange {
microPercentLowerBound?: number;
microPercentUpperBound?: number;
}

// @public
export interface NamedCondition {
condition: OneOfCondition;
name: string;
}

// @public
export interface OneOfCondition {
andCondition?: AndCondition;
false?: Record<string, never>;
orCondition?: OrCondition;
percent?: PercentCondition;
true?: Record<string, never>;
}

// @public
export interface OrCondition {
conditions?: Array<OneOfCondition>;
}

// @public
export type ParameterValueType = 'STRING' | 'BOOLEAN' | 'NUMBER' | 'JSON';

// @public
export interface PercentCondition {
microPercent?: number;
microPercentRange?: MicroPercentRange;
percentOperator?: PercentConditionOperator;
seed?: string;
}

// @public
export enum PercentConditionOperator {
BETWEEN = "BETWEEN",
GREATER_THAN = "GREATER_THAN",
LESS_OR_EQUAL = "LESS_OR_EQUAL",
UNKNOWN = "UNKNOWN"
}

// @public
export class RemoteConfig {
// (undocumented)
readonly app: App;
createTemplateFromJSON(json: string): RemoteConfigTemplate;
getServerTemplate(options?: GetServerTemplateOptions): Promise<ServerTemplate>;
getTemplate(): Promise<RemoteConfigTemplate>;
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate;
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
publishTemplate(template: RemoteConfigTemplate, options?: {
force: boolean;
Expand Down Expand Up @@ -104,9 +173,49 @@ export interface RemoteConfigUser {
name?: string;
}

// @public
export interface ServerConfig {
getBoolean(key: string): boolean;
getNumber(key: string): number;
getString(key: string): string;
getValue(key: string): Value;
}

// @public
export interface ServerTemplate {
evaluate(context?: EvaluationContext): ServerConfig;
load(): Promise<void>;
set(template: ServerTemplateDataType): void;
toJSON(): ServerTemplateData;
}

// @public
export interface ServerTemplateData {
conditions: NamedCondition[];
readonly etag: string;
parameters: {
[key: string]: RemoteConfigParameter;
};
version?: Version;
}

// @public
export type ServerTemplateDataType = ServerTemplateData | string;

// @public
export type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' | 'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';

// @public
export interface Value {
asBoolean(): boolean;
asNumber(): number;
asString(): string;
getSource(): ValueSource;
}

// @public
export type ValueSource = 'static' | 'default' | 'remote';

// @public
export interface Version {
description?: string;
Expand Down
Loading

0 comments on commit a833f4e

Please sign in to comment.