firebase-admin 12.0.0 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/lib/app/core.d.ts +1 -1
  2. package/lib/app/core.js +1 -1
  3. package/lib/app/credential-factory.d.ts +1 -1
  4. package/lib/app/credential-factory.js +1 -1
  5. package/lib/app/credential-internal.d.ts +1 -1
  6. package/lib/app/credential-internal.js +1 -1
  7. package/lib/app/credential.d.ts +1 -1
  8. package/lib/app/credential.js +1 -1
  9. package/lib/app/firebase-app.d.ts +1 -1
  10. package/lib/app/firebase-app.js +1 -1
  11. package/lib/app/firebase-namespace.d.ts +1 -1
  12. package/lib/app/firebase-namespace.js +1 -1
  13. package/lib/app/index.d.ts +1 -1
  14. package/lib/app/index.js +1 -1
  15. package/lib/app/lifecycle.d.ts +1 -1
  16. package/lib/app/lifecycle.js +1 -1
  17. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  18. package/lib/app-check/app-check-api-client-internal.js +1 -1
  19. package/lib/app-check/app-check-api.d.ts +1 -1
  20. package/lib/app-check/app-check-api.js +1 -1
  21. package/lib/app-check/app-check-namespace.d.ts +1 -1
  22. package/lib/app-check/app-check-namespace.js +1 -1
  23. package/lib/app-check/app-check.d.ts +1 -1
  24. package/lib/app-check/app-check.js +1 -1
  25. package/lib/app-check/index.d.ts +1 -1
  26. package/lib/app-check/index.js +1 -1
  27. package/lib/app-check/token-generator.d.ts +1 -1
  28. package/lib/app-check/token-generator.js +1 -1
  29. package/lib/app-check/token-verifier.d.ts +1 -1
  30. package/lib/app-check/token-verifier.js +1 -1
  31. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  32. package/lib/auth/action-code-settings-builder.js +1 -1
  33. package/lib/auth/auth-api-request.d.ts +1 -1
  34. package/lib/auth/auth-api-request.js +1 -1
  35. package/lib/auth/auth-config.d.ts +1 -1
  36. package/lib/auth/auth-config.js +1 -1
  37. package/lib/auth/auth-namespace.d.ts +1 -1
  38. package/lib/auth/auth-namespace.js +1 -1
  39. package/lib/auth/auth.d.ts +1 -1
  40. package/lib/auth/auth.js +1 -1
  41. package/lib/auth/base-auth.d.ts +1 -1
  42. package/lib/auth/base-auth.js +1 -1
  43. package/lib/auth/identifier.d.ts +1 -1
  44. package/lib/auth/identifier.js +1 -1
  45. package/lib/auth/index.d.ts +1 -1
  46. package/lib/auth/index.js +1 -1
  47. package/lib/auth/project-config-manager.d.ts +1 -1
  48. package/lib/auth/project-config-manager.js +1 -1
  49. package/lib/auth/project-config.d.ts +1 -1
  50. package/lib/auth/project-config.js +1 -1
  51. package/lib/auth/tenant-manager.d.ts +1 -1
  52. package/lib/auth/tenant-manager.js +1 -1
  53. package/lib/auth/tenant.d.ts +1 -1
  54. package/lib/auth/tenant.js +1 -1
  55. package/lib/auth/token-generator.d.ts +1 -1
  56. package/lib/auth/token-generator.js +1 -1
  57. package/lib/auth/token-verifier.d.ts +1 -1
  58. package/lib/auth/token-verifier.js +16 -10
  59. package/lib/auth/user-import-builder.d.ts +1 -1
  60. package/lib/auth/user-import-builder.js +1 -1
  61. package/lib/auth/user-record.d.ts +1 -1
  62. package/lib/auth/user-record.js +1 -1
  63. package/lib/credential/index.d.ts +1 -1
  64. package/lib/credential/index.js +1 -1
  65. package/lib/database/database-namespace.d.ts +17 -17
  66. package/lib/database/database-namespace.js +1 -1
  67. package/lib/database/database.d.ts +3 -3
  68. package/lib/database/database.js +1 -1
  69. package/lib/database/index.d.ts +5 -5
  70. package/lib/database/index.js +5 -5
  71. package/lib/default-namespace.d.ts +1 -1
  72. package/lib/default-namespace.js +1 -1
  73. package/lib/esm/remote-config/index.js +1 -0
  74. package/lib/eventarc/cloudevent.d.ts +1 -1
  75. package/lib/eventarc/cloudevent.js +1 -1
  76. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  77. package/lib/eventarc/eventarc-client-internal.js +1 -1
  78. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  79. package/lib/eventarc/eventarc-utils.js +1 -1
  80. package/lib/eventarc/eventarc.d.ts +1 -1
  81. package/lib/eventarc/eventarc.js +1 -1
  82. package/lib/eventarc/index.d.ts +1 -1
  83. package/lib/eventarc/index.js +1 -1
  84. package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
  85. package/lib/extensions/extensions-api-client-internal.js +1 -1
  86. package/lib/extensions/extensions-api.d.ts +1 -1
  87. package/lib/extensions/extensions-api.js +1 -1
  88. package/lib/extensions/extensions.d.ts +1 -1
  89. package/lib/extensions/extensions.js +1 -1
  90. package/lib/extensions/index.d.ts +1 -1
  91. package/lib/extensions/index.js +1 -1
  92. package/lib/firebase-namespace-api.d.ts +1 -1
  93. package/lib/firebase-namespace-api.js +1 -1
  94. package/lib/firestore/firestore-internal.d.ts +1 -1
  95. package/lib/firestore/firestore-internal.js +1 -1
  96. package/lib/firestore/firestore-namespace.d.ts +1 -1
  97. package/lib/firestore/firestore-namespace.js +1 -1
  98. package/lib/firestore/index.d.ts +1 -1
  99. package/lib/firestore/index.js +1 -1
  100. package/lib/functions/functions-api-client-internal.d.ts +1 -1
  101. package/lib/functions/functions-api-client-internal.js +1 -1
  102. package/lib/functions/functions-api.d.ts +1 -1
  103. package/lib/functions/functions-api.js +1 -1
  104. package/lib/functions/functions.d.ts +1 -1
  105. package/lib/functions/functions.js +1 -1
  106. package/lib/functions/index.d.ts +1 -1
  107. package/lib/functions/index.js +1 -1
  108. package/lib/index.d.ts +1 -1
  109. package/lib/index.js +1 -1
  110. package/lib/installations/index.d.ts +1 -1
  111. package/lib/installations/index.js +1 -1
  112. package/lib/installations/installations-namespace.d.ts +1 -1
  113. package/lib/installations/installations-namespace.js +1 -1
  114. package/lib/installations/installations-request-handler.d.ts +1 -1
  115. package/lib/installations/installations-request-handler.js +1 -1
  116. package/lib/installations/installations.d.ts +1 -1
  117. package/lib/installations/installations.js +1 -1
  118. package/lib/instance-id/index.d.ts +1 -1
  119. package/lib/instance-id/index.js +1 -1
  120. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  121. package/lib/instance-id/instance-id-namespace.js +1 -1
  122. package/lib/instance-id/instance-id.d.ts +1 -1
  123. package/lib/instance-id/instance-id.js +1 -1
  124. package/lib/machine-learning/index.d.ts +1 -1
  125. package/lib/machine-learning/index.js +1 -1
  126. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  127. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  128. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  129. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  130. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  131. package/lib/machine-learning/machine-learning-utils.js +1 -1
  132. package/lib/machine-learning/machine-learning.d.ts +1 -1
  133. package/lib/machine-learning/machine-learning.js +1 -1
  134. package/lib/messaging/batch-request-internal.d.ts +1 -1
  135. package/lib/messaging/batch-request-internal.js +1 -1
  136. package/lib/messaging/index.d.ts +1 -1
  137. package/lib/messaging/index.js +1 -1
  138. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  139. package/lib/messaging/messaging-api-request-internal.js +1 -1
  140. package/lib/messaging/messaging-api.d.ts +1 -1
  141. package/lib/messaging/messaging-api.js +1 -1
  142. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  143. package/lib/messaging/messaging-errors-internal.js +1 -1
  144. package/lib/messaging/messaging-internal.d.ts +1 -1
  145. package/lib/messaging/messaging-internal.js +1 -1
  146. package/lib/messaging/messaging-namespace.d.ts +1 -1
  147. package/lib/messaging/messaging-namespace.js +1 -1
  148. package/lib/messaging/messaging.d.ts +1 -1
  149. package/lib/messaging/messaging.js +2 -2
  150. package/lib/project-management/android-app.d.ts +1 -1
  151. package/lib/project-management/android-app.js +1 -1
  152. package/lib/project-management/app-metadata.d.ts +1 -1
  153. package/lib/project-management/app-metadata.js +1 -1
  154. package/lib/project-management/index.d.ts +1 -1
  155. package/lib/project-management/index.js +1 -1
  156. package/lib/project-management/ios-app.d.ts +1 -1
  157. package/lib/project-management/ios-app.js +1 -1
  158. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  159. package/lib/project-management/project-management-api-request-internal.js +1 -1
  160. package/lib/project-management/project-management-namespace.d.ts +1 -1
  161. package/lib/project-management/project-management-namespace.js +1 -1
  162. package/lib/project-management/project-management.d.ts +1 -1
  163. package/lib/project-management/project-management.js +1 -1
  164. package/lib/remote-config/condition-evaluator-internal.d.ts +17 -0
  165. package/lib/remote-config/condition-evaluator-internal.js +130 -0
  166. package/lib/remote-config/index.d.ts +2 -2
  167. package/lib/remote-config/index.js +4 -2
  168. package/lib/remote-config/internal/value-impl.d.ts +17 -0
  169. package/lib/remote-config/internal/value-impl.js +59 -0
  170. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  171. package/lib/remote-config/remote-config-api-client-internal.js +41 -3
  172. package/lib/remote-config/remote-config-api.d.ts +310 -2
  173. package/lib/remote-config/remote-config-api.js +29 -1
  174. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  175. package/lib/remote-config/remote-config-namespace.js +1 -1
  176. package/lib/remote-config/remote-config.d.ts +11 -2
  177. package/lib/remote-config/remote-config.js +176 -1
  178. package/lib/security-rules/index.d.ts +1 -1
  179. package/lib/security-rules/index.js +1 -1
  180. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  181. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  182. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  183. package/lib/security-rules/security-rules-internal.js +1 -1
  184. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  185. package/lib/security-rules/security-rules-namespace.js +1 -1
  186. package/lib/security-rules/security-rules.d.ts +1 -1
  187. package/lib/security-rules/security-rules.js +1 -1
  188. package/lib/storage/index.d.ts +1 -1
  189. package/lib/storage/index.js +1 -1
  190. package/lib/storage/storage-namespace.d.ts +1 -1
  191. package/lib/storage/storage-namespace.js +1 -1
  192. package/lib/storage/storage.d.ts +1 -1
  193. package/lib/storage/storage.js +1 -1
  194. package/lib/storage/utils.d.ts +1 -1
  195. package/lib/storage/utils.js +1 -1
  196. package/lib/utils/api-request.d.ts +1 -1
  197. package/lib/utils/api-request.js +1 -1
  198. package/lib/utils/crypto-signer.d.ts +1 -1
  199. package/lib/utils/crypto-signer.js +1 -1
  200. package/lib/utils/deep-copy.d.ts +1 -1
  201. package/lib/utils/deep-copy.js +1 -1
  202. package/lib/utils/error.d.ts +1 -1
  203. package/lib/utils/error.js +1 -1
  204. package/lib/utils/index.d.ts +1 -1
  205. package/lib/utils/index.js +1 -1
  206. package/lib/utils/jwt.d.ts +1 -1
  207. package/lib/utils/jwt.js +1 -1
  208. package/lib/utils/validator.d.ts +1 -1
  209. package/lib/utils/validator.js +1 -1
  210. package/package.json +6 -4
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -47,6 +47,139 @@ export interface RemoteConfigCondition {
47
47
  */
48
48
  tagColor?: TagColor;
49
49
  }
50
+ /**
51
+ * Represents a Remote Config condition in the dataplane.
52
+ * A condition targets a specific group of users. A list of these conditions
53
+ * comprise part of a Remote Config template.
54
+ */
55
+ export interface NamedCondition {
56
+ /**
57
+ * A non-empty and unique name of this condition.
58
+ */
59
+ name: string;
60
+ /**
61
+ * The logic of this condition.
62
+ * See the documentation on
63
+ * {@link https://firebase.google.com/docs/remote-config/condition-reference | condition expressions}
64
+ * for the expected syntax of this field.
65
+ */
66
+ condition: OneOfCondition;
67
+ }
68
+ /**
69
+ * Represents a condition that may be one of several types.
70
+ * Only the first defined field will be processed.
71
+ */
72
+ export interface OneOfCondition {
73
+ /**
74
+ * Makes this condition an OR condition.
75
+ */
76
+ orCondition?: OrCondition;
77
+ /**
78
+ * Makes this condition an AND condition.
79
+ */
80
+ andCondition?: AndCondition;
81
+ /**
82
+ * Makes this condition a constant true.
83
+ */
84
+ true?: Record<string, never>;
85
+ /**
86
+ * Makes this condition a constant false.
87
+ */
88
+ false?: Record<string, never>;
89
+ /**
90
+ * Makes this condition a percent condition.
91
+ */
92
+ percent?: PercentCondition;
93
+ }
94
+ /**
95
+ * Represents a collection of conditions that evaluate to true if all are true.
96
+ */
97
+ export interface AndCondition {
98
+ /**
99
+ * The collection of conditions.
100
+ */
101
+ conditions?: Array<OneOfCondition>;
102
+ }
103
+ /**
104
+ * Represents a collection of conditions that evaluate to true if any are true.
105
+ */
106
+ export interface OrCondition {
107
+ /**
108
+ * The collection of conditions.
109
+ */
110
+ conditions?: Array<OneOfCondition>;
111
+ }
112
+ /**
113
+ * Defines supported operators for percent conditions.
114
+ */
115
+ export declare enum PercentConditionOperator {
116
+ /**
117
+ * A catchall error case.
118
+ */
119
+ UNKNOWN = "UNKNOWN",
120
+ /**
121
+ * Target percentiles less than or equal to the target percent.
122
+ * A condition using this operator must specify microPercent.
123
+ */
124
+ LESS_OR_EQUAL = "LESS_OR_EQUAL",
125
+ /**
126
+ * Target percentiles greater than the target percent.
127
+ * A condition using this operator must specify microPercent.
128
+ */
129
+ GREATER_THAN = "GREATER_THAN",
130
+ /**
131
+ * Target percentiles within an interval defined by a lower bound and an
132
+ * upper bound. The lower bound is an exclusive (open) bound and the
133
+ * micro_percent_range_upper_bound is an inclusive (closed) bound.
134
+ * A condition using this operator must specify microPercentRange.
135
+ */
136
+ BETWEEN = "BETWEEN"
137
+ }
138
+ /**
139
+ * Represents the limit of percentiles to target in micro-percents.
140
+ * The value must be in the range [0 and 100000000]
141
+ */
142
+ export interface MicroPercentRange {
143
+ /**
144
+ * The lower limit of percentiles to target in micro-percents.
145
+ * The value must be in the range [0 and 100000000].
146
+ */
147
+ microPercentLowerBound?: number;
148
+ /**
149
+ * The upper limit of percentiles to target in micro-percents.
150
+ * The value must be in the range [0 and 100000000].
151
+ */
152
+ microPercentUpperBound?: number;
153
+ }
154
+ /**
155
+ * Represents a condition that compares the instance pseudo-random
156
+ * percentile to a given limit.
157
+ */
158
+ export interface PercentCondition {
159
+ /**
160
+ * The choice of percent operator to determine how to compare targets
161
+ * to percent(s).
162
+ */
163
+ percentOperator?: PercentConditionOperator;
164
+ /**
165
+ * The limit of percentiles to target in micro-percents when
166
+ * using the LESS_OR_EQUAL and GREATER_THAN operators. The value must
167
+ * be in the range [0 and 100000000].
168
+ */
169
+ microPercent?: number;
170
+ /**
171
+ * The seed used when evaluating the hash function to map an instance to
172
+ * a value in the hash space. This is a string which can have 0 - 32
173
+ * characters and can contain ASCII characters [-_.0-9a-zA-Z].The string
174
+ * is case-sensitive.
175
+ */
176
+ seed?: string;
177
+ /**
178
+ * The micro-percent interval to be used with the
179
+ * BETWEEN operator.
180
+ */
181
+ microPercentRange?: MicroPercentRange;
182
+ }
50
183
  /**
51
184
  * Interface representing an explicit parameter value.
52
185
  */
@@ -122,7 +255,7 @@ export interface RemoteConfigParameterGroup {
122
255
  };
123
256
  }
124
257
  /**
125
- * Interface representing a Remote Config template.
258
+ * Represents a Remote Config client template.
126
259
  */
127
260
  export interface RemoteConfigTemplate {
128
261
  /**
@@ -153,6 +286,92 @@ export interface RemoteConfigTemplate {
153
286
  */
154
287
  version?: Version;
155
288
  }
289
+ /**
290
+ * Represents the data in a Remote Config server template.
291
+ */
292
+ export interface ServerTemplateData {
293
+ /**
294
+ * A list of conditions in descending order by priority.
295
+ */
296
+ conditions: NamedCondition[];
297
+ /**
298
+ * Map of parameter keys to their optional default values and optional conditional values.
299
+ */
300
+ parameters: {
301
+ [key: string]: RemoteConfigParameter;
302
+ };
303
+ /**
304
+ * Current Remote Config template ETag (read-only).
305
+ */
306
+ readonly etag: string;
307
+ /**
308
+ * Version information for the current Remote Config template.
309
+ */
310
+ version?: Version;
311
+ }
312
+ /**
313
+ * Represents optional arguments that can be used when instantiating {@link ServerTemplate}.
314
+ */
315
+ export interface GetServerTemplateOptions {
316
+ /**
317
+ * Defines in-app default parameter values, so that your app behaves as
318
+ * intended before it connects to the Remote Config backend, and so that
319
+ * default values are available if none are set on the backend.
320
+ */
321
+ defaultConfig?: DefaultConfig;
322
+ }
323
+ /**
324
+ * Represents the type of a Remote Config server template that can be set on
325
+ * {@link ServerTemplate}. This can either be a {@link ServerTemplateData} object
326
+ * or a template JSON string.
327
+ */
328
+ export type ServerTemplateDataType = ServerTemplateData | string;
329
+ /**
330
+ * Represents optional arguments that can be used when instantiating
331
+ * {@link ServerTemplate} synchronously.
332
+ */
333
+ export interface InitServerTemplateOptions extends GetServerTemplateOptions {
334
+ /**
335
+ * Enables integrations to use template data loaded independently. For
336
+ * example, customers can reduce initialization latency by pre-fetching and
337
+ * caching template data and then using this option to initialize the SDK with
338
+ * that data.
339
+ */
340
+ template?: ServerTemplateDataType;
341
+ }
342
+ /**
343
+ * Represents a stateful abstraction for a Remote Config server template.
344
+ */
345
+ export interface ServerTemplate {
346
+ /**
347
+ * Evaluates the current template to produce a {@link ServerConfig}.
348
+ */
349
+ evaluate(context?: EvaluationContext): ServerConfig;
350
+ /**
351
+ * Fetches and caches the current active version of the
352
+ * project's {@link ServerTemplate}.
353
+ */
354
+ load(): Promise<void>;
355
+ /**
356
+ * Sets and caches a {@link ServerTemplateData} or a JSON string representing
357
+ * the server template
358
+ */
359
+ set(template: ServerTemplateDataType): void;
360
+ /**
361
+ * Returns a JSON representation of {@link ServerTemplateData}
362
+ */
363
+ toJSON(): ServerTemplateData;
364
+ }
365
+ /**
366
+ * Represents template evaluation input signals.
367
+ */
368
+ export type EvaluationContext = {
369
+ /**
370
+ * Defines the identifier to use when splitting a group. For example,
371
+ * this is used by the percent condition.
372
+ */
373
+ randomizationId?: string;
374
+ };
156
375
  /**
157
376
  * Interface representing a Remote Config user.
158
377
  */
@@ -256,3 +475,92 @@ export interface ListVersionsOptions {
256
475
  */
257
476
  endTime?: Date | string;
258
477
  }
478
+ /**
479
+ * Represents the configuration produced by evaluating a server template.
480
+ */
481
+ export interface ServerConfig {
482
+ /**
483
+ * Gets the value for the given key as a boolean.
484
+ *
485
+ * Convenience method for calling <code>serverConfig.getValue(key).asBoolean()</code>.
486
+ *
487
+ * @param key - The name of the parameter.
488
+ *
489
+ * @returns The value for the given key as a boolean.
490
+ */
491
+ getBoolean(key: string): boolean;
492
+ /**
493
+ * Gets the value for the given key as a number.
494
+ *
495
+ * Convenience method for calling <code>serverConfig.getValue(key).asNumber()</code>.
496
+ *
497
+ * @param key - The name of the parameter.
498
+ *
499
+ * @returns The value for the given key as a number.
500
+ */
501
+ getNumber(key: string): number;
502
+ /**
503
+ * Gets the value for the given key as a string.
504
+ * Convenience method for calling <code>serverConfig.getValue(key).asString()</code>.
505
+ *
506
+ * @param key - The name of the parameter.
507
+ *
508
+ * @returns The value for the given key as a string.
509
+ */
510
+ getString(key: string): string;
511
+ /**
512
+ * Gets the {@link Value} for the given key.
513
+ *
514
+ * Ensures application logic will always have a type-safe reference,
515
+ * even if the parameter is removed remotely.
516
+ *
517
+ * @param key - The name of the parameter.
518
+ *
519
+ * @returns The value for the given key.
520
+ */
521
+ getValue(key: string): Value;
522
+ }
523
+ /**
524
+ * Wraps a parameter value with metadata and type-safe getters.
525
+ *
526
+ * Type-safe getters insulate application logic from remote
527
+ * changes to parameter names and types.
528
+ */
529
+ export interface Value {
530
+ /**
531
+ * Gets the value as a boolean.
532
+ *
533
+ * The following values (case insensitive) are interpreted as true:
534
+ * "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
535
+ */
536
+ asBoolean(): boolean;
537
+ /**
538
+ * Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
539
+ */
540
+ asNumber(): number;
541
+ /**
542
+ * Gets the value as a string.
543
+ */
544
+ asString(): string;
545
+ /**
546
+ * Gets the {@link ValueSource} for the given key.
547
+ */
548
+ getSource(): ValueSource;
549
+ }
550
+ /**
551
+ * Indicates the source of a value.
552
+ *
553
+ * <ul>
554
+ * <li>"static" indicates the value was defined by a static constant.</li>
555
+ * <li>"default" indicates the value was defined by default config.</li>
556
+ * <li>"remote" indicates the value was defined by config produced by
557
+ * evaluating a template.</li>
558
+ * </ul>
559
+ */
560
+ export type ValueSource = 'static' | 'default' | 'remote';
561
+ /**
562
+ * Defines the format for in-app default parameter values.
563
+ */
564
+ export type DefaultConfig = {
565
+ [key: string]: string | number | boolean;
566
+ };
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -16,3 +16,31 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.PercentConditionOperator = void 0;
20
+ /**
21
+ * Defines supported operators for percent conditions.
22
+ */
23
+ var PercentConditionOperator;
24
+ (function (PercentConditionOperator) {
25
+ /**
26
+ * A catchall error case.
27
+ */
28
+ PercentConditionOperator["UNKNOWN"] = "UNKNOWN";
29
+ /**
30
+ * Target percentiles less than or equal to the target percent.
31
+ * A condition using this operator must specify microPercent.
32
+ */
33
+ PercentConditionOperator["LESS_OR_EQUAL"] = "LESS_OR_EQUAL";
34
+ /**
35
+ * Target percentiles greater than the target percent.
36
+ * A condition using this operator must specify microPercent.
37
+ */
38
+ PercentConditionOperator["GREATER_THAN"] = "GREATER_THAN";
39
+ /**
40
+ * Target percentiles within an interval defined by a lower bound and an
41
+ * upper bound. The lower bound is an exclusive (open) bound and the
42
+ * micro_percent_range_upper_bound is an inclusive (closed) bound.
43
+ * A condition using this operator must specify microPercentRange.
44
+ */
45
+ PercentConditionOperator["BETWEEN"] = "BETWEEN";
46
+ })(PercentConditionOperator || (exports.PercentConditionOperator = PercentConditionOperator = {}));
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { App } from '../app';
18
- import { ListVersionsOptions, ListVersionsResult, RemoteConfigTemplate } from './remote-config-api';
18
+ import { ListVersionsOptions, ListVersionsResult, ServerTemplate, RemoteConfigTemplate, GetServerTemplateOptions, InitServerTemplateOptions } from './remote-config-api';
19
19
  /**
20
20
  * The Firebase `RemoteConfig` service interface.
21
21
  */
@@ -91,4 +91,13 @@ export declare class RemoteConfig {
91
91
  * @returns A new template instance.
92
92
  */
93
93
  createTemplateFromJSON(json: string): RemoteConfigTemplate;
94
+ /**
95
+ * Instantiates {@link ServerTemplate} and then fetches and caches the latest
96
+ * template version of the project.
97
+ */
98
+ getServerTemplate(options?: GetServerTemplateOptions): Promise<ServerTemplate>;
99
+ /**
100
+ * Synchronously instantiates {@link ServerTemplate}.
101
+ */
102
+ initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate;
94
103
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -19,6 +19,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.RemoteConfig = void 0;
20
20
  const validator = require("../utils/validator");
21
21
  const remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
22
+ const condition_evaluator_internal_1 = require("./condition-evaluator-internal");
23
+ const value_impl_1 = require("./internal/value-impl");
22
24
  /**
23
25
  * The Firebase `RemoteConfig` service interface.
24
26
  */
@@ -144,6 +146,25 @@ class RemoteConfig {
144
146
  }
145
147
  return new RemoteConfigTemplateImpl(template);
146
148
  }
149
+ /**
150
+ * Instantiates {@link ServerTemplate} and then fetches and caches the latest
151
+ * template version of the project.
152
+ */
153
+ async getServerTemplate(options) {
154
+ const template = this.initServerTemplate(options);
155
+ await template.load();
156
+ return template;
157
+ }
158
+ /**
159
+ * Synchronously instantiates {@link ServerTemplate}.
160
+ */
161
+ initServerTemplate(options) {
162
+ const template = new ServerTemplateImpl(this.client, new condition_evaluator_internal_1.ConditionEvaluator(), options?.defaultConfig);
163
+ if (options?.template) {
164
+ template.set(options?.template);
165
+ }
166
+ return template;
167
+ }
147
168
  }
148
169
  exports.RemoteConfig = RemoteConfig;
149
170
  /**
@@ -210,6 +231,160 @@ class RemoteConfigTemplateImpl {
210
231
  };
211
232
  }
212
233
  }
234
+ /**
235
+ * Remote Config dataplane template data implementation.
236
+ */
237
+ class ServerTemplateImpl {
238
+ constructor(apiClient, conditionEvaluator, defaultConfig = {}) {
239
+ this.apiClient = apiClient;
240
+ this.conditionEvaluator = conditionEvaluator;
241
+ this.defaultConfig = defaultConfig;
242
+ this.stringifiedDefaultConfig = {};
243
+ // RC stores all remote values as string, but it's more intuitive
244
+ // to declare default values with specific types, so this converts
245
+ // the external declaration to an internal string representation.
246
+ for (const key in defaultConfig) {
247
+ this.stringifiedDefaultConfig[key] = String(defaultConfig[key]);
248
+ }
249
+ }
250
+ /**
251
+ * Fetches and caches the current active version of the project's {@link ServerTemplate}.
252
+ */
253
+ load() {
254
+ return this.apiClient.getServerTemplate()
255
+ .then((template) => {
256
+ this.cache = new ServerTemplateDataImpl(template);
257
+ });
258
+ }
259
+ /**
260
+ * Parses a {@link ServerTemplateDataType} and caches it.
261
+ */
262
+ set(template) {
263
+ let parsed;
264
+ if (validator.isString(template)) {
265
+ try {
266
+ parsed = JSON.parse(template);
267
+ }
268
+ catch (e) {
269
+ // Transforms JSON parse errors to Firebase error.
270
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${template}. ` + e);
271
+ }
272
+ }
273
+ else {
274
+ parsed = template;
275
+ }
276
+ // Throws template parse errors.
277
+ this.cache = new ServerTemplateDataImpl(parsed);
278
+ }
279
+ /**
280
+ * Evaluates the current template in cache to produce a {@link ServerConfig}.
281
+ */
282
+ evaluate(context = {}) {
283
+ if (!this.cache) {
284
+ // This is the only place we should throw during evaluation, since it's under the
285
+ // control of application logic. To preserve forward-compatibility, we should only
286
+ // return false in cases where the SDK is unsure how to evaluate the fetched template.
287
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('failed-precondition', 'No Remote Config Server template in cache. Call load() before calling evaluate().');
288
+ }
289
+ const evaluatedConditions = this.conditionEvaluator.evaluateConditions(this.cache.conditions, context);
290
+ const configValues = {};
291
+ // Initializes config Value objects with default values.
292
+ for (const key in this.stringifiedDefaultConfig) {
293
+ configValues[key] = new value_impl_1.ValueImpl('default', this.stringifiedDefaultConfig[key]);
294
+ }
295
+ // Overlays config Value objects derived by evaluating the template.
296
+ for (const [key, parameter] of Object.entries(this.cache.parameters)) {
297
+ const { conditionalValues, defaultValue } = parameter;
298
+ // Supports parameters with no conditional values.
299
+ const normalizedConditionalValues = conditionalValues || {};
300
+ let parameterValueWrapper = undefined;
301
+ // Iterates in order over condition list. If there is a value associated
302
+ // with a condition, this checks if the condition is true.
303
+ for (const [conditionName, conditionEvaluation] of evaluatedConditions) {
304
+ if (normalizedConditionalValues[conditionName] && conditionEvaluation) {
305
+ parameterValueWrapper = normalizedConditionalValues[conditionName];
306
+ break;
307
+ }
308
+ }
309
+ if (parameterValueWrapper && parameterValueWrapper.useInAppDefault) {
310
+ // TODO: add logging once we have a wrapped logger.
311
+ continue;
312
+ }
313
+ if (parameterValueWrapper) {
314
+ const parameterValue = parameterValueWrapper.value;
315
+ configValues[key] = new value_impl_1.ValueImpl('remote', parameterValue);
316
+ continue;
317
+ }
318
+ if (!defaultValue) {
319
+ // TODO: add logging once we have a wrapped logger.
320
+ continue;
321
+ }
322
+ if (defaultValue.useInAppDefault) {
323
+ // TODO: add logging once we have a wrapped logger.
324
+ continue;
325
+ }
326
+ const parameterDefaultValue = defaultValue.value;
327
+ configValues[key] = new value_impl_1.ValueImpl('remote', parameterDefaultValue);
328
+ }
329
+ return new ServerConfigImpl(configValues);
330
+ }
331
+ /**
332
+ * @returns JSON representation of the server template
333
+ */
334
+ toJSON() {
335
+ return this.cache;
336
+ }
337
+ }
338
+ class ServerConfigImpl {
339
+ constructor(configValues) {
340
+ this.configValues = configValues;
341
+ }
342
+ getBoolean(key) {
343
+ return this.getValue(key).asBoolean();
344
+ }
345
+ getNumber(key) {
346
+ return this.getValue(key).asNumber();
347
+ }
348
+ getString(key) {
349
+ return this.getValue(key).asString();
350
+ }
351
+ getValue(key) {
352
+ return this.configValues[key] || new value_impl_1.ValueImpl('static');
353
+ }
354
+ }
355
+ /**
356
+ * Remote Config dataplane template data implementation.
357
+ */
358
+ class ServerTemplateDataImpl {
359
+ constructor(template) {
360
+ if (!validator.isNonNullObject(template) ||
361
+ !validator.isNonEmptyString(template.etag)) {
362
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(template)}`);
363
+ }
364
+ this.etag = template.etag;
365
+ if (typeof template.parameters !== 'undefined') {
366
+ if (!validator.isNonNullObject(template.parameters)) {
367
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
368
+ }
369
+ this.parameters = template.parameters;
370
+ }
371
+ else {
372
+ this.parameters = {};
373
+ }
374
+ if (typeof template.conditions !== 'undefined') {
375
+ if (!validator.isArray(template.conditions)) {
376
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
377
+ }
378
+ this.conditions = template.conditions;
379
+ }
380
+ else {
381
+ this.conditions = [];
382
+ }
383
+ if (typeof template.version !== 'undefined') {
384
+ this.version = new VersionImpl(template.version);
385
+ }
386
+ }
387
+ }
213
388
  /**
214
389
  * Remote Config Version internal implementation.
215
390
  */
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.0.0 */
1
+ /*! firebase-admin v12.1.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.