Skip to content

Commit 69c1262

Browse files
authored
Differentiate options for sync and async SSRC initialization (#2506)
1 parent ef4b2df commit 69c1262

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

etc/firebase-admin.remote-config.api.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,21 @@ export interface ExplicitParameterValue {
2828
// @public
2929
export function getRemoteConfig(app?: App): RemoteConfig;
3030

31+
// @public
32+
export interface GetServerTemplateOptions {
33+
defaultConfig?: ServerConfig;
34+
}
35+
3136
// @public
3237
export interface InAppDefaultValue {
3338
useInAppDefault: boolean;
3439
}
3540

41+
// @public
42+
export interface InitServerTemplateOptions extends GetServerTemplateOptions {
43+
template?: ServerTemplateData;
44+
}
45+
3646
// @public
3747
export interface ListVersionsOptions {
3848
endTime?: Date | string;
@@ -98,10 +108,10 @@ export class RemoteConfig {
98108
// (undocumented)
99109
readonly app: App;
100110
createTemplateFromJSON(json: string): RemoteConfigTemplate;
101-
getServerTemplate(options?: ServerTemplateOptions): Promise<ServerTemplate>;
111+
getServerTemplate(options?: GetServerTemplateOptions): Promise<ServerTemplate>;
102112
getTemplate(): Promise<RemoteConfigTemplate>;
103113
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
104-
initServerTemplate(options?: ServerTemplateOptions): ServerTemplate;
114+
initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate;
105115
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
106116
publishTemplate(template: RemoteConfigTemplate, options?: {
107117
force: boolean;
@@ -180,12 +190,6 @@ export interface ServerTemplateData {
180190
version?: Version;
181191
}
182192

183-
// @public
184-
export interface ServerTemplateOptions {
185-
defaultConfig?: ServerConfig;
186-
template?: ServerTemplateData;
187-
}
188-
189193
// @public
190194
export type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' | 'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';
191195

src/remote-config/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export {
2828
AndCondition,
2929
EvaluationContext,
3030
ExplicitParameterValue,
31+
GetServerTemplateOptions,
3132
InAppDefaultValue,
33+
InitServerTemplateOptions,
3234
ListVersionsOptions,
3335
ListVersionsResult,
3436
MicroPercentRange,
@@ -47,7 +49,6 @@ export {
4749
ServerConfig,
4850
ServerTemplate,
4951
ServerTemplateData,
50-
ServerTemplateOptions,
5152
TagColor,
5253
Version,
5354
} from './remote-config-api';

src/remote-config/remote-config-api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,21 @@ export interface ServerTemplateData {
354354
/**
355355
* Represents optional arguments that can be used when instantiating {@link ServerTemplate}.
356356
*/
357-
export interface ServerTemplateOptions {
357+
export interface GetServerTemplateOptions {
358358

359359
/**
360360
* Defines in-app default parameter values, so that your app behaves as
361361
* intended before it connects to the Remote Config backend, and so that
362362
* default values are available if none are set on the backend.
363363
*/
364364
defaultConfig?: ServerConfig,
365+
}
366+
367+
/**
368+
* Represents optional arguments that can be used when instantiating
369+
* {@link ServerTemplate} synchonously.
370+
*/
371+
export interface InitServerTemplateOptions extends GetServerTemplateOptions {
365372

366373
/**
367374
* Enables integrations to use template data loaded independently. For

src/remote-config/remote-config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import {
3535
RemoteConfigParameterValue,
3636
EvaluationContext,
3737
ServerTemplateData,
38-
ServerTemplateOptions,
3938
NamedCondition,
39+
GetServerTemplateOptions,
40+
InitServerTemplateOptions,
4041
} from './remote-config-api';
4142

4243
/**
@@ -184,7 +185,7 @@ export class RemoteConfig {
184185
* Instantiates {@link ServerTemplate} and then fetches and caches the latest
185186
* template version of the project.
186187
*/
187-
public async getServerTemplate(options?: ServerTemplateOptions): Promise<ServerTemplate> {
188+
public async getServerTemplate(options?: GetServerTemplateOptions): Promise<ServerTemplate> {
188189
const template = this.initServerTemplate(options);
189190
await template.load();
190191
return template;
@@ -193,7 +194,7 @@ export class RemoteConfig {
193194
/**
194195
* Synchronously instantiates {@link ServerTemplate}.
195196
*/
196-
public initServerTemplate(options?: ServerTemplateOptions): ServerTemplate {
197+
public initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate {
197198
const template = new ServerTemplateImpl(
198199
this.client, new ConditionEvaluator(), options?.defaultConfig);
199200
if (options?.template) {

0 commit comments

Comments
 (0)