initial commit
This commit is contained in:
17
server/node_modules/firebase-admin/lib/remote-config/condition-evaluator-internal.d.ts
generated
vendored
Normal file
17
server/node_modules/firebase-admin/lib/remote-config/condition-evaluator-internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2024 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
230
server/node_modules/firebase-admin/lib/remote-config/condition-evaluator-internal.js
generated
vendored
Normal file
230
server/node_modules/firebase-admin/lib/remote-config/condition-evaluator-internal.js
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2024 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConditionEvaluator = void 0;
|
||||
const remote_config_api_1 = require("./remote-config-api");
|
||||
const crypto_1 = require("crypto");
|
||||
/**
|
||||
* Encapsulates condition evaluation logic to simplify organization and
|
||||
* facilitate testing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConditionEvaluator {
|
||||
evaluateConditions(namedConditions, context) {
|
||||
// The order of the conditions is significant.
|
||||
// A JS Map preserves the order of insertion ("Iteration happens in insertion order"
|
||||
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#description).
|
||||
const evaluatedConditions = new Map();
|
||||
for (const namedCondition of namedConditions) {
|
||||
evaluatedConditions.set(namedCondition.name, this.evaluateCondition(namedCondition.condition, context));
|
||||
}
|
||||
return evaluatedConditions;
|
||||
}
|
||||
evaluateCondition(condition, context, nestingLevel = 0) {
|
||||
if (nestingLevel >= ConditionEvaluator.MAX_CONDITION_RECURSION_DEPTH) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
if (condition.orCondition) {
|
||||
return this.evaluateOrCondition(condition.orCondition, context, nestingLevel + 1);
|
||||
}
|
||||
if (condition.andCondition) {
|
||||
return this.evaluateAndCondition(condition.andCondition, context, nestingLevel + 1);
|
||||
}
|
||||
if (condition.true) {
|
||||
return true;
|
||||
}
|
||||
if (condition.false) {
|
||||
return false;
|
||||
}
|
||||
if (condition.percent) {
|
||||
return this.evaluatePercentCondition(condition.percent, context);
|
||||
}
|
||||
if (condition.customSignal) {
|
||||
return this.evaluateCustomSignalCondition(condition.customSignal, context);
|
||||
}
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
evaluateOrCondition(orCondition, context, nestingLevel) {
|
||||
const subConditions = orCondition.conditions || [];
|
||||
for (const subCondition of subConditions) {
|
||||
// Recursive call.
|
||||
const result = this.evaluateCondition(subCondition, context, nestingLevel + 1);
|
||||
// Short-circuit the evaluation result for true.
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
evaluateAndCondition(andCondition, context, nestingLevel) {
|
||||
const subConditions = andCondition.conditions || [];
|
||||
for (const subCondition of subConditions) {
|
||||
// Recursive call.
|
||||
const result = this.evaluateCondition(subCondition, context, nestingLevel + 1);
|
||||
// Short-circuit the evaluation result for false.
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
evaluatePercentCondition(percentCondition, context) {
|
||||
if (!context.randomizationId) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
// This is the entry point for processing percent condition data from the response.
|
||||
// We're not using a proto library, so we can't assume undefined fields have
|
||||
// default values.
|
||||
const { seed, percentOperator, microPercent, microPercentRange } = percentCondition;
|
||||
if (!percentOperator) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
const normalizedMicroPercent = microPercent || 0;
|
||||
const normalizedMicroPercentUpperBound = microPercentRange?.microPercentUpperBound || 0;
|
||||
const normalizedMicroPercentLowerBound = microPercentRange?.microPercentLowerBound || 0;
|
||||
const seedPrefix = seed && seed.length > 0 ? `${seed}.` : '';
|
||||
const stringToHash = `${seedPrefix}${context.randomizationId}`;
|
||||
const hash = ConditionEvaluator.hashSeededRandomizationId(stringToHash);
|
||||
const instanceMicroPercentile = hash % BigInt(100 * 1000000);
|
||||
switch (percentOperator) {
|
||||
case remote_config_api_1.PercentConditionOperator.LESS_OR_EQUAL:
|
||||
return instanceMicroPercentile <= normalizedMicroPercent;
|
||||
case remote_config_api_1.PercentConditionOperator.GREATER_THAN:
|
||||
return instanceMicroPercentile > normalizedMicroPercent;
|
||||
case remote_config_api_1.PercentConditionOperator.BETWEEN:
|
||||
return instanceMicroPercentile > normalizedMicroPercentLowerBound
|
||||
&& instanceMicroPercentile <= normalizedMicroPercentUpperBound;
|
||||
case remote_config_api_1.PercentConditionOperator.UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
static hashSeededRandomizationId(seededRandomizationId) {
|
||||
const hex = (0, crypto_1.createHash)('sha256').update(seededRandomizationId).digest('hex');
|
||||
return BigInt(`0x${hex}`);
|
||||
}
|
||||
evaluateCustomSignalCondition(customSignalCondition, context) {
|
||||
const { customSignalOperator, customSignalKey, targetCustomSignalValues, } = customSignalCondition;
|
||||
if (!customSignalOperator || !customSignalKey || !targetCustomSignalValues) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
if (!targetCustomSignalValues.length) {
|
||||
return false;
|
||||
}
|
||||
// Extract the value of the signal from the evaluation context.
|
||||
const actualCustomSignalValue = context[customSignalKey];
|
||||
if (actualCustomSignalValue == undefined) {
|
||||
return false;
|
||||
}
|
||||
switch (customSignalOperator) {
|
||||
case remote_config_api_1.CustomSignalOperator.STRING_CONTAINS:
|
||||
return compareStrings(targetCustomSignalValues, actualCustomSignalValue, (target, actual) => actual.includes(target));
|
||||
case remote_config_api_1.CustomSignalOperator.STRING_DOES_NOT_CONTAIN:
|
||||
return !compareStrings(targetCustomSignalValues, actualCustomSignalValue, (target, actual) => actual.includes(target));
|
||||
case remote_config_api_1.CustomSignalOperator.STRING_EXACTLY_MATCHES:
|
||||
return compareStrings(targetCustomSignalValues, actualCustomSignalValue, (target, actual) => actual.trim() === target.trim());
|
||||
case remote_config_api_1.CustomSignalOperator.STRING_CONTAINS_REGEX:
|
||||
return compareStrings(targetCustomSignalValues, actualCustomSignalValue, (target, actual) => new RegExp(target).test(actual));
|
||||
// For numeric operators only one target value is allowed.
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_LESS_THAN:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r < 0);
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_LESS_EQUAL:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r <= 0);
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_EQUAL:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r === 0);
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_NOT_EQUAL:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r !== 0);
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_GREATER_THAN:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r > 0);
|
||||
case remote_config_api_1.CustomSignalOperator.NUMERIC_GREATER_EQUAL:
|
||||
return compareNumbers(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r >= 0);
|
||||
// For semantic operators only one target value is allowed.
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_LESS_THAN:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r < 0);
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_LESS_EQUAL:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r <= 0);
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_EQUAL:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r === 0);
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_NOT_EQUAL:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r !== 0);
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_GREATER_THAN:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r > 0);
|
||||
case remote_config_api_1.CustomSignalOperator.SEMANTIC_VERSION_GREATER_EQUAL:
|
||||
return compareSemanticVersions(actualCustomSignalValue, targetCustomSignalValues[0], (r) => r >= 0);
|
||||
}
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.ConditionEvaluator = ConditionEvaluator;
|
||||
ConditionEvaluator.MAX_CONDITION_RECURSION_DEPTH = 10;
|
||||
// Compares the actual string value of a signal against a list of target
|
||||
// values. If any of the target values are a match, returns true.
|
||||
function compareStrings(targetValues, actualValue, predicateFn) {
|
||||
const actual = String(actualValue);
|
||||
return targetValues.some((target) => predicateFn(target, actual));
|
||||
}
|
||||
// Compares two numbers against each other.
|
||||
// Calls the predicate function with -1, 0, 1 if actual is less than, equal to, or greater than target.
|
||||
function compareNumbers(actualValue, targetValue, predicateFn) {
|
||||
const target = Number(targetValue);
|
||||
const actual = Number(actualValue);
|
||||
if (isNaN(target) || isNaN(actual)) {
|
||||
return false;
|
||||
}
|
||||
return predicateFn(actual < target ? -1 : actual > target ? 1 : 0);
|
||||
}
|
||||
// Max number of segments a numeric version can have. This is enforced by the server as well.
|
||||
const MAX_LENGTH = 5;
|
||||
// Compares semantic version strings against each other.
|
||||
// Calls the predicate function with -1, 0, 1 if actual is less than, equal to, or greater than target.
|
||||
function compareSemanticVersions(actualValue, targetValue, predicateFn) {
|
||||
const version1 = String(actualValue).split('.').map(Number);
|
||||
const version2 = targetValue.split('.').map(Number);
|
||||
if (version1.length > MAX_LENGTH || version2.length > MAX_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < MAX_LENGTH; i++) {
|
||||
// Check to see if segments are present. Note that these may be present and be NaN.
|
||||
const version1HasSegment = version1[i] !== undefined;
|
||||
const version2HasSegment = version2[i] !== undefined;
|
||||
// Insert zeros if undefined for easier comparison.
|
||||
if (!version1HasSegment)
|
||||
version1[i] = 0;
|
||||
if (!version2HasSegment)
|
||||
version2[i] = 0;
|
||||
// At this point, if either segment is NaN, we return false directly.
|
||||
if (isNaN(version1[i]) || isNaN(version2[i]))
|
||||
return false;
|
||||
// Check if we have a difference in segments. Otherwise continue to next segment.
|
||||
if (version1[i] < version2[i])
|
||||
return predicateFn(-1);
|
||||
if (version1[i] > version2[i])
|
||||
return predicateFn(1);
|
||||
}
|
||||
// If this point is reached, the semantic versions are equal.
|
||||
return predicateFn(0);
|
||||
}
|
||||
52
server/node_modules/firebase-admin/lib/remote-config/index.d.ts
generated
vendored
Normal file
52
server/node_modules/firebase-admin/lib/remote-config/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Firebase Remote Config.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
import { App } from '../app';
|
||||
import { RemoteConfig } from './remote-config';
|
||||
export { AndCondition, CustomSignalCondition, CustomSignalOperator, DefaultConfig, EvaluationContext, ExplicitParameterValue, FetchResponseData, GetServerTemplateOptions, InAppDefaultValue, InitServerTemplateOptions, ListVersionsOptions, ListVersionsResult, MicroPercentRange, NamedCondition, OneOfCondition, OrCondition, ParameterValueType, PercentConditionOperator, PercentCondition, PredefinedSignals, RemoteConfigCondition, RemoteConfigParameter, RemoteConfigParameterGroup, RemoteConfigParameterValue, RemoteConfigTemplate, RemoteConfigUser, ServerConfig, ServerTemplate, ServerTemplateData, ServerTemplateDataType, TagColor, UserProvidedSignals, Value, ValueSource, Version, } from './remote-config-api';
|
||||
export { RemoteConfig, RemoteConfigFetchResponse } from './remote-config';
|
||||
/**
|
||||
* Gets the {@link RemoteConfig} service for the default app or a given app.
|
||||
*
|
||||
* `getRemoteConfig()` can be called with no arguments to access the default
|
||||
* app's `RemoteConfig` service or as `getRemoteConfig(app)` to access the
|
||||
* `RemoteConfig` service associated with a specific app.
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for the default app
|
||||
* const defaultRemoteConfig = getRemoteConfig();
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for a given app
|
||||
* const otherRemoteConfig = getRemoteConfig(otherApp);
|
||||
* ```
|
||||
*
|
||||
* @param app - Optional app for which to return the `RemoteConfig` service.
|
||||
* If not provided, the default `RemoteConfig` service is returned.
|
||||
*
|
||||
* @returns The default `RemoteConfig` service if no
|
||||
* app is provided, or the `RemoteConfig` service associated with the provided
|
||||
* app.
|
||||
*/
|
||||
export declare function getRemoteConfig(app?: App): RemoteConfig;
|
||||
66
server/node_modules/firebase-admin/lib/remote-config/index.js
generated
vendored
Normal file
66
server/node_modules/firebase-admin/lib/remote-config/index.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoteConfigFetchResponse = exports.RemoteConfig = exports.PercentConditionOperator = exports.CustomSignalOperator = void 0;
|
||||
exports.getRemoteConfig = getRemoteConfig;
|
||||
/**
|
||||
* Firebase Remote Config.
|
||||
*
|
||||
* @packageDocumentation
|
||||
*/
|
||||
const app_1 = require("../app");
|
||||
const remote_config_1 = require("./remote-config");
|
||||
var remote_config_api_1 = require("./remote-config-api");
|
||||
Object.defineProperty(exports, "CustomSignalOperator", { enumerable: true, get: function () { return remote_config_api_1.CustomSignalOperator; } });
|
||||
Object.defineProperty(exports, "PercentConditionOperator", { enumerable: true, get: function () { return remote_config_api_1.PercentConditionOperator; } });
|
||||
var remote_config_2 = require("./remote-config");
|
||||
Object.defineProperty(exports, "RemoteConfig", { enumerable: true, get: function () { return remote_config_2.RemoteConfig; } });
|
||||
Object.defineProperty(exports, "RemoteConfigFetchResponse", { enumerable: true, get: function () { return remote_config_2.RemoteConfigFetchResponse; } });
|
||||
/**
|
||||
* Gets the {@link RemoteConfig} service for the default app or a given app.
|
||||
*
|
||||
* `getRemoteConfig()` can be called with no arguments to access the default
|
||||
* app's `RemoteConfig` service or as `getRemoteConfig(app)` to access the
|
||||
* `RemoteConfig` service associated with a specific app.
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for the default app
|
||||
* const defaultRemoteConfig = getRemoteConfig();
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for a given app
|
||||
* const otherRemoteConfig = getRemoteConfig(otherApp);
|
||||
* ```
|
||||
*
|
||||
* @param app - Optional app for which to return the `RemoteConfig` service.
|
||||
* If not provided, the default `RemoteConfig` service is returned.
|
||||
*
|
||||
* @returns The default `RemoteConfig` service if no
|
||||
* app is provided, or the `RemoteConfig` service associated with the provided
|
||||
* app.
|
||||
*/
|
||||
function getRemoteConfig(app) {
|
||||
if (typeof app === 'undefined') {
|
||||
app = (0, app_1.getApp)();
|
||||
}
|
||||
const firebaseApp = app;
|
||||
return firebaseApp.getOrInitService('remoteConfig', (app) => new remote_config_1.RemoteConfig(app));
|
||||
}
|
||||
17
server/node_modules/firebase-admin/lib/remote-config/internal/value-impl.d.ts
generated
vendored
Normal file
17
server/node_modules/firebase-admin/lib/remote-config/internal/value-impl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2024 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export {};
|
||||
59
server/node_modules/firebase-admin/lib/remote-config/internal/value-impl.js
generated
vendored
Normal file
59
server/node_modules/firebase-admin/lib/remote-config/internal/value-impl.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2024 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ValueImpl = void 0;
|
||||
/**
|
||||
* Implements type-safe getters for parameter values.
|
||||
*
|
||||
* Visible for testing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ValueImpl {
|
||||
constructor(source, value = ValueImpl.DEFAULT_VALUE_FOR_STRING) {
|
||||
this.source = source;
|
||||
this.value = value;
|
||||
}
|
||||
asString() {
|
||||
return this.value;
|
||||
}
|
||||
asBoolean() {
|
||||
if (this.source === 'static') {
|
||||
return ValueImpl.DEFAULT_VALUE_FOR_BOOLEAN;
|
||||
}
|
||||
return ValueImpl.BOOLEAN_TRUTHY_VALUES.indexOf(this.value.toLowerCase()) >= 0;
|
||||
}
|
||||
asNumber() {
|
||||
if (this.source === 'static') {
|
||||
return ValueImpl.DEFAULT_VALUE_FOR_NUMBER;
|
||||
}
|
||||
const num = Number(this.value);
|
||||
if (isNaN(num)) {
|
||||
return ValueImpl.DEFAULT_VALUE_FOR_NUMBER;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
getSource() {
|
||||
return this.source;
|
||||
}
|
||||
}
|
||||
exports.ValueImpl = ValueImpl;
|
||||
ValueImpl.DEFAULT_VALUE_FOR_BOOLEAN = false;
|
||||
ValueImpl.DEFAULT_VALUE_FOR_STRING = '';
|
||||
ValueImpl.DEFAULT_VALUE_FOR_NUMBER = 0;
|
||||
ValueImpl.BOOLEAN_TRUTHY_VALUES = ['1', 'true', 't', 'yes', 'y', 'on'];
|
||||
28
server/node_modules/firebase-admin/lib/remote-config/remote-config-api-client-internal.d.ts
generated
vendored
Normal file
28
server/node_modules/firebase-admin/lib/remote-config/remote-config-api-client-internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { PrefixedFirebaseError } from '../utils/error';
|
||||
export type RemoteConfigErrorCode = 'aborted' | 'already-exists' | 'failed-precondition' | 'internal-error' | 'invalid-argument' | 'not-found' | 'out-of-range' | 'permission-denied' | 'resource-exhausted' | 'unauthenticated' | 'unknown-error';
|
||||
/**
|
||||
* Firebase Remote Config error code structure. This extends PrefixedFirebaseError.
|
||||
*
|
||||
* @param {RemoteConfigErrorCode} code The error code.
|
||||
* @param {string} message The error message.
|
||||
* @constructor
|
||||
*/
|
||||
export declare class FirebaseRemoteConfigError extends PrefixedFirebaseError {
|
||||
constructor(code: RemoteConfigErrorCode, message: string);
|
||||
}
|
||||
407
server/node_modules/firebase-admin/lib/remote-config/remote-config-api-client-internal.js
generated
vendored
Normal file
407
server/node_modules/firebase-admin/lib/remote-config/remote-config-api-client-internal.js
generated
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FirebaseRemoteConfigError = exports.RemoteConfigApiClient = void 0;
|
||||
const api_request_1 = require("../utils/api-request");
|
||||
const error_1 = require("../utils/error");
|
||||
const utils = require("../utils/index");
|
||||
const validator = require("../utils/validator");
|
||||
const deep_copy_1 = require("../utils/deep-copy");
|
||||
// Remote Config backend constants
|
||||
/**
|
||||
* Allows the `FIREBASE_REMOTE_CONFIG_URL_BASE` environment
|
||||
* variable to override the default API endpoint URL.
|
||||
*/
|
||||
const FIREBASE_REMOTE_CONFIG_URL_BASE = process.env.FIREBASE_REMOTE_CONFIG_URL_BASE || 'https://firebaseremoteconfig.googleapis.com';
|
||||
const FIREBASE_REMOTE_CONFIG_HEADERS = {
|
||||
'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`,
|
||||
// There is a known issue in which the ETag is not properly returned in cases where the request
|
||||
// does not specify a compression type. Currently, it is required to include the header
|
||||
// `Accept-Encoding: gzip` or equivalent in all requests.
|
||||
// https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
|
||||
'Accept-Encoding': 'gzip',
|
||||
};
|
||||
/**
|
||||
* Class that facilitates sending requests to the Firebase Remote Config backend API.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class RemoteConfigApiClient {
|
||||
constructor(app) {
|
||||
this.app = app;
|
||||
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'First argument passed to admin.remoteConfig() must be a valid Firebase app instance.');
|
||||
}
|
||||
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
|
||||
}
|
||||
getTemplate() {
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'GET',
|
||||
url: `${url}/remoteConfig`,
|
||||
headers: FIREBASE_REMOTE_CONFIG_HEADERS
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
})
|
||||
.then((resp) => {
|
||||
return this.toRemoteConfigTemplate(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
getTemplateAtVersion(versionNumber) {
|
||||
const data = { versionNumber: this.validateVersionNumber(versionNumber) };
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'GET',
|
||||
url: `${url}/remoteConfig`,
|
||||
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
|
||||
data
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
})
|
||||
.then((resp) => {
|
||||
return this.toRemoteConfigTemplate(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
validateTemplate(template) {
|
||||
template = this.validateInputRemoteConfigTemplate(template);
|
||||
return this.sendPutRequest(template, template.etag, true)
|
||||
.then((resp) => {
|
||||
// validating a template returns an etag with the suffix -0 means that your update
|
||||
// was successfully validated. We set the etag back to the original etag of the template
|
||||
// to allow future operations.
|
||||
this.validateEtag(resp.headers['etag']);
|
||||
return this.toRemoteConfigTemplate(resp, template.etag);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
publishTemplate(template, options) {
|
||||
template = this.validateInputRemoteConfigTemplate(template);
|
||||
let ifMatch = template.etag;
|
||||
if (options && options.force === true) {
|
||||
// setting `If-Match: *` forces the Remote Config template to be updated
|
||||
// and circumvent the ETag, and the protection from that it provides.
|
||||
ifMatch = '*';
|
||||
}
|
||||
return this.sendPutRequest(template, ifMatch)
|
||||
.then((resp) => {
|
||||
return this.toRemoteConfigTemplate(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
rollback(versionNumber) {
|
||||
const data = { versionNumber: this.validateVersionNumber(versionNumber) };
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'POST',
|
||||
url: `${url}/remoteConfig:rollback`,
|
||||
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
|
||||
data
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
})
|
||||
.then((resp) => {
|
||||
return this.toRemoteConfigTemplate(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
listVersions(options) {
|
||||
if (typeof options !== 'undefined') {
|
||||
options = this.validateListVersionsOptions(options);
|
||||
}
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'GET',
|
||||
url: `${url}/remoteConfig:listVersions`,
|
||||
headers: FIREBASE_REMOTE_CONFIG_HEADERS,
|
||||
data: options
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
getServerTemplate() {
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'GET',
|
||||
url: `${url}/namespaces/firebase-server/serverRemoteConfig`,
|
||||
headers: FIREBASE_REMOTE_CONFIG_HEADERS
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
})
|
||||
.then((resp) => {
|
||||
return this.toRemoteConfigServerTemplate(resp);
|
||||
})
|
||||
.catch((err) => {
|
||||
throw this.toFirebaseError(err);
|
||||
});
|
||||
}
|
||||
sendPutRequest(template, etag, validateOnly) {
|
||||
let path = 'remoteConfig';
|
||||
if (validateOnly) {
|
||||
path += '?validate_only=true';
|
||||
}
|
||||
return this.getUrl()
|
||||
.then((url) => {
|
||||
const request = {
|
||||
method: 'PUT',
|
||||
url: `${url}/${path}`,
|
||||
headers: { ...FIREBASE_REMOTE_CONFIG_HEADERS, 'If-Match': etag },
|
||||
data: {
|
||||
conditions: template.conditions,
|
||||
parameters: template.parameters,
|
||||
parameterGroups: template.parameterGroups,
|
||||
version: template.version,
|
||||
}
|
||||
};
|
||||
return this.httpClient.send(request);
|
||||
});
|
||||
}
|
||||
getUrl() {
|
||||
return this.getProjectIdPrefix()
|
||||
.then((projectIdPrefix) => {
|
||||
return `${FIREBASE_REMOTE_CONFIG_URL_BASE}/v1/${projectIdPrefix}`;
|
||||
});
|
||||
}
|
||||
getProjectIdPrefix() {
|
||||
if (this.projectIdPrefix) {
|
||||
return Promise.resolve(this.projectIdPrefix);
|
||||
}
|
||||
return utils.findProjectId(this.app)
|
||||
.then((projectId) => {
|
||||
if (!validator.isNonEmptyString(projectId)) {
|
||||
throw new FirebaseRemoteConfigError('unknown-error', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
|
||||
+ 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
|
||||
+ 'environment variable.');
|
||||
}
|
||||
this.projectIdPrefix = `projects/${projectId}`;
|
||||
return this.projectIdPrefix;
|
||||
});
|
||||
}
|
||||
toFirebaseError(err) {
|
||||
if (err instanceof error_1.PrefixedFirebaseError) {
|
||||
return err;
|
||||
}
|
||||
const response = err.response;
|
||||
if (!response.isJson()) {
|
||||
return new FirebaseRemoteConfigError('unknown-error', `Unexpected response with status: ${response.status} and body: ${response.text}`);
|
||||
}
|
||||
const error = response.data.error || {};
|
||||
let code = 'unknown-error';
|
||||
if (error.status && error.status in ERROR_CODE_MAPPING) {
|
||||
code = ERROR_CODE_MAPPING[error.status];
|
||||
}
|
||||
const message = error.message || `Unknown server error: ${response.text}`;
|
||||
return new FirebaseRemoteConfigError(code, message);
|
||||
}
|
||||
/**
|
||||
* Creates a RemoteConfigTemplate from the API response.
|
||||
* If provided, customEtag is used instead of the etag returned in the API response.
|
||||
*
|
||||
* @param {HttpResponse} resp API response object.
|
||||
* @param {string} customEtag A custom etag to replace the etag fom the API response (Optional).
|
||||
*/
|
||||
toRemoteConfigTemplate(resp, customEtag) {
|
||||
const etag = (typeof customEtag === 'undefined') ? resp.headers['etag'] : customEtag;
|
||||
this.validateEtag(etag);
|
||||
return {
|
||||
conditions: resp.data.conditions,
|
||||
parameters: resp.data.parameters,
|
||||
parameterGroups: resp.data.parameterGroups,
|
||||
etag,
|
||||
version: resp.data.version,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates a RemoteConfigServerTemplate from the API response.
|
||||
* If provided, customEtag is used instead of the etag returned in the API response.
|
||||
*
|
||||
* @param {HttpResponse} resp API response object.
|
||||
* @param {string} customEtag A custom etag to replace the etag fom the API response (Optional).
|
||||
*/
|
||||
toRemoteConfigServerTemplate(resp, customEtag) {
|
||||
const etag = (typeof customEtag === 'undefined') ? resp.headers['etag'] : customEtag;
|
||||
this.validateEtag(etag);
|
||||
return {
|
||||
conditions: resp.data.conditions,
|
||||
parameters: resp.data.parameters,
|
||||
etag,
|
||||
version: resp.data.version,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Checks if the given RemoteConfigTemplate object is valid.
|
||||
* The object must have valid parameters, parameter groups, conditions, and an etag.
|
||||
* Removes output only properties from version metadata.
|
||||
*
|
||||
* @param {RemoteConfigTemplate} template A RemoteConfigTemplate object to be validated.
|
||||
*
|
||||
* @returns {RemoteConfigTemplate} The validated RemoteConfigTemplate object.
|
||||
*/
|
||||
validateInputRemoteConfigTemplate(template) {
|
||||
const templateCopy = (0, deep_copy_1.deepCopy)(template);
|
||||
if (!validator.isNonNullObject(templateCopy)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(templateCopy)}`);
|
||||
}
|
||||
if (!validator.isNonEmptyString(templateCopy.etag)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'ETag must be a non-empty string.');
|
||||
}
|
||||
if (!validator.isNonNullObject(templateCopy.parameters)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
|
||||
}
|
||||
if (!validator.isNonNullObject(templateCopy.parameterGroups)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
|
||||
}
|
||||
if (!validator.isArray(templateCopy.conditions)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
|
||||
}
|
||||
if (typeof templateCopy.version !== 'undefined') {
|
||||
// exclude output only properties and keep the only input property: description
|
||||
templateCopy.version = { description: templateCopy.version.description };
|
||||
}
|
||||
return templateCopy;
|
||||
}
|
||||
/**
|
||||
* Checks if a given version number is valid.
|
||||
* A version number must be an integer or a string in int64 format.
|
||||
* If valid, returns the string representation of the provided version number.
|
||||
*
|
||||
* @param {string|number} versionNumber A version number to be validated.
|
||||
*
|
||||
* @returns {string} The validated version number as a string.
|
||||
*/
|
||||
validateVersionNumber(versionNumber, propertyName = 'versionNumber') {
|
||||
if (!validator.isNonEmptyString(versionNumber) &&
|
||||
!validator.isNumber(versionNumber)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', `${propertyName} must be a non-empty string in int64 format or a number`);
|
||||
}
|
||||
if (!Number.isInteger(Number(versionNumber))) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', `${propertyName} must be an integer or a string in int64 format`);
|
||||
}
|
||||
return versionNumber.toString();
|
||||
}
|
||||
validateEtag(etag) {
|
||||
if (!validator.isNonEmptyString(etag)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'ETag header is not present in the server response.');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Checks if a given `ListVersionsOptions` object is valid. If successful, creates a copy of the
|
||||
* options object and convert `startTime` and `endTime` to RFC3339 UTC "Zulu" format, if present.
|
||||
*
|
||||
* @param {ListVersionsOptions} options An options object to be validated.
|
||||
*
|
||||
* @returns {ListVersionsOptions} A copy of the provided options object with timestamps converted
|
||||
* to UTC Zulu format.
|
||||
*/
|
||||
validateListVersionsOptions(options) {
|
||||
const optionsCopy = (0, deep_copy_1.deepCopy)(options);
|
||||
if (!validator.isNonNullObject(optionsCopy)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'ListVersionsOptions must be a non-null object.');
|
||||
}
|
||||
if (typeof optionsCopy.pageSize !== 'undefined') {
|
||||
if (!validator.isNumber(optionsCopy.pageSize)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'pageSize must be a number.');
|
||||
}
|
||||
if (optionsCopy.pageSize < 1 || optionsCopy.pageSize > 300) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'pageSize must be a number between 1 and 300 (inclusive).');
|
||||
}
|
||||
}
|
||||
if (typeof optionsCopy.pageToken !== 'undefined' && !validator.isNonEmptyString(optionsCopy.pageToken)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'pageToken must be a string value.');
|
||||
}
|
||||
if (typeof optionsCopy.endVersionNumber !== 'undefined') {
|
||||
optionsCopy.endVersionNumber = this.validateVersionNumber(optionsCopy.endVersionNumber, 'endVersionNumber');
|
||||
}
|
||||
if (typeof optionsCopy.startTime !== 'undefined') {
|
||||
if (!(optionsCopy.startTime instanceof Date) && !validator.isUTCDateString(optionsCopy.startTime)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'startTime must be a valid Date object or a UTC date string.');
|
||||
}
|
||||
// Convert startTime to RFC3339 UTC "Zulu" format.
|
||||
if (optionsCopy.startTime instanceof Date) {
|
||||
optionsCopy.startTime = optionsCopy.startTime.toISOString();
|
||||
}
|
||||
else {
|
||||
optionsCopy.startTime = new Date(optionsCopy.startTime).toISOString();
|
||||
}
|
||||
}
|
||||
if (typeof optionsCopy.endTime !== 'undefined') {
|
||||
if (!(optionsCopy.endTime instanceof Date) && !validator.isUTCDateString(optionsCopy.endTime)) {
|
||||
throw new FirebaseRemoteConfigError('invalid-argument', 'endTime must be a valid Date object or a UTC date string.');
|
||||
}
|
||||
// Convert endTime to RFC3339 UTC "Zulu" format.
|
||||
if (optionsCopy.endTime instanceof Date) {
|
||||
optionsCopy.endTime = optionsCopy.endTime.toISOString();
|
||||
}
|
||||
else {
|
||||
optionsCopy.endTime = new Date(optionsCopy.endTime).toISOString();
|
||||
}
|
||||
}
|
||||
// Remove undefined fields from optionsCopy
|
||||
Object.keys(optionsCopy).forEach(key => (typeof optionsCopy[key] === 'undefined') && delete optionsCopy[key]);
|
||||
return optionsCopy;
|
||||
}
|
||||
}
|
||||
exports.RemoteConfigApiClient = RemoteConfigApiClient;
|
||||
const ERROR_CODE_MAPPING = {
|
||||
ABORTED: 'aborted',
|
||||
ALREADY_EXISTS: 'already-exists',
|
||||
INVALID_ARGUMENT: 'invalid-argument',
|
||||
INTERNAL: 'internal-error',
|
||||
FAILED_PRECONDITION: 'failed-precondition',
|
||||
NOT_FOUND: 'not-found',
|
||||
OUT_OF_RANGE: 'out-of-range',
|
||||
PERMISSION_DENIED: 'permission-denied',
|
||||
RESOURCE_EXHAUSTED: 'resource-exhausted',
|
||||
UNAUTHENTICATED: 'unauthenticated',
|
||||
UNKNOWN: 'unknown-error',
|
||||
};
|
||||
/**
|
||||
* Firebase Remote Config error code structure. This extends PrefixedFirebaseError.
|
||||
*
|
||||
* @param {RemoteConfigErrorCode} code The error code.
|
||||
* @param {string} message The error message.
|
||||
* @constructor
|
||||
*/
|
||||
class FirebaseRemoteConfigError extends error_1.PrefixedFirebaseError {
|
||||
constructor(code, message) {
|
||||
super('remote-config', code, message);
|
||||
}
|
||||
}
|
||||
exports.FirebaseRemoteConfigError = FirebaseRemoteConfigError;
|
||||
708
server/node_modules/firebase-admin/lib/remote-config/remote-config-api.d.ts
generated
vendored
Normal file
708
server/node_modules/firebase-admin/lib/remote-config/remote-config-api.d.ts
generated
vendored
Normal file
@@ -0,0 +1,708 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2021 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Colors that are associated with conditions for display purposes.
|
||||
*/
|
||||
export type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' | 'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';
|
||||
/**
|
||||
* Type representing a Remote Config parameter value data type.
|
||||
* Defaults to `STRING` if unspecified.
|
||||
*/
|
||||
export type ParameterValueType = 'STRING' | 'BOOLEAN' | 'NUMBER' | 'JSON';
|
||||
/**
|
||||
* Interface representing a Remote Config condition.
|
||||
* A condition targets a specific group of users. A list of these conditions make up
|
||||
* part of a Remote Config template.
|
||||
*/
|
||||
export interface RemoteConfigCondition {
|
||||
/**
|
||||
* A non-empty and unique name of this condition.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The logic of this condition.
|
||||
* See the documentation on
|
||||
* {@link https://firebase.google.com/docs/remote-config/condition-reference | condition expressions}
|
||||
* for the expected syntax of this field.
|
||||
*/
|
||||
expression: string;
|
||||
/**
|
||||
* The color associated with this condition for display purposes in the Firebase Console.
|
||||
* Not specifying this value results in the console picking an arbitrary color to associate
|
||||
* with the condition.
|
||||
*/
|
||||
tagColor?: TagColor;
|
||||
}
|
||||
/**
|
||||
* Represents a Remote Config condition in the dataplane.
|
||||
* A condition targets a specific group of users. A list of these conditions
|
||||
* comprise part of a Remote Config template.
|
||||
*/
|
||||
export interface NamedCondition {
|
||||
/**
|
||||
* A non-empty and unique name of this condition.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The logic of this condition.
|
||||
* See the documentation on
|
||||
* {@link https://firebase.google.com/docs/remote-config/condition-reference | condition expressions}
|
||||
* for the expected syntax of this field.
|
||||
*/
|
||||
condition: OneOfCondition;
|
||||
}
|
||||
/**
|
||||
* Represents a condition that may be one of several types.
|
||||
* Only the first defined field will be processed.
|
||||
*/
|
||||
export interface OneOfCondition {
|
||||
/**
|
||||
* Makes this condition an OR condition.
|
||||
*/
|
||||
orCondition?: OrCondition;
|
||||
/**
|
||||
* Makes this condition an AND condition.
|
||||
*/
|
||||
andCondition?: AndCondition;
|
||||
/**
|
||||
* Makes this condition a constant true.
|
||||
*/
|
||||
true?: Record<string, never>;
|
||||
/**
|
||||
* Makes this condition a constant false.
|
||||
*/
|
||||
false?: Record<string, never>;
|
||||
/**
|
||||
* Makes this condition a percent condition.
|
||||
*/
|
||||
percent?: PercentCondition;
|
||||
/**
|
||||
* Makes this condition a custom signal condition.
|
||||
*/
|
||||
customSignal?: CustomSignalCondition;
|
||||
}
|
||||
/**
|
||||
* Represents a collection of conditions that evaluate to true if all are true.
|
||||
*/
|
||||
export interface AndCondition {
|
||||
/**
|
||||
* The collection of conditions.
|
||||
*/
|
||||
conditions?: Array<OneOfCondition>;
|
||||
}
|
||||
/**
|
||||
* Represents a collection of conditions that evaluate to true if any are true.
|
||||
*/
|
||||
export interface OrCondition {
|
||||
/**
|
||||
* The collection of conditions.
|
||||
*/
|
||||
conditions?: Array<OneOfCondition>;
|
||||
}
|
||||
/**
|
||||
* Defines supported operators for percent conditions.
|
||||
*/
|
||||
export declare enum PercentConditionOperator {
|
||||
/**
|
||||
* A catchall error case.
|
||||
*/
|
||||
UNKNOWN = "UNKNOWN",
|
||||
/**
|
||||
* Target percentiles less than or equal to the target percent.
|
||||
* A condition using this operator must specify microPercent.
|
||||
*/
|
||||
LESS_OR_EQUAL = "LESS_OR_EQUAL",
|
||||
/**
|
||||
* Target percentiles greater than the target percent.
|
||||
* A condition using this operator must specify microPercent.
|
||||
*/
|
||||
GREATER_THAN = "GREATER_THAN",
|
||||
/**
|
||||
* Target percentiles within an interval defined by a lower bound and an
|
||||
* upper bound. The lower bound is an exclusive (open) bound and the
|
||||
* micro_percent_range_upper_bound is an inclusive (closed) bound.
|
||||
* A condition using this operator must specify microPercentRange.
|
||||
*/
|
||||
BETWEEN = "BETWEEN"
|
||||
}
|
||||
/**
|
||||
* Represents the limit of percentiles to target in micro-percents.
|
||||
* The value must be in the range [0 and 100000000]
|
||||
*/
|
||||
export interface MicroPercentRange {
|
||||
/**
|
||||
* The lower limit of percentiles to target in micro-percents.
|
||||
* The value must be in the range [0 and 100000000].
|
||||
*/
|
||||
microPercentLowerBound?: number;
|
||||
/**
|
||||
* The upper limit of percentiles to target in micro-percents.
|
||||
* The value must be in the range [0 and 100000000].
|
||||
*/
|
||||
microPercentUpperBound?: number;
|
||||
}
|
||||
/**
|
||||
* Represents a condition that compares the instance pseudo-random
|
||||
* percentile to a given limit.
|
||||
*/
|
||||
export interface PercentCondition {
|
||||
/**
|
||||
* The choice of percent operator to determine how to compare targets
|
||||
* to percent(s).
|
||||
*/
|
||||
percentOperator?: PercentConditionOperator;
|
||||
/**
|
||||
* The limit of percentiles to target in micro-percents when
|
||||
* using the LESS_OR_EQUAL and GREATER_THAN operators. The value must
|
||||
* be in the range [0 and 100000000].
|
||||
*/
|
||||
microPercent?: number;
|
||||
/**
|
||||
* The seed used when evaluating the hash function to map an instance to
|
||||
* a value in the hash space. This is a string which can have 0 - 32
|
||||
* characters and can contain ASCII characters [-_.0-9a-zA-Z].The string
|
||||
* is case-sensitive.
|
||||
*/
|
||||
seed?: string;
|
||||
/**
|
||||
* The micro-percent interval to be used with the
|
||||
* BETWEEN operator.
|
||||
*/
|
||||
microPercentRange?: MicroPercentRange;
|
||||
}
|
||||
/**
|
||||
* Defines supported operators for custom signal conditions.
|
||||
*/
|
||||
export declare enum CustomSignalOperator {
|
||||
/**
|
||||
* A catchall error case.
|
||||
*/
|
||||
UNKNOWN = "UNKNOWN",
|
||||
/**
|
||||
* Matches a numeric value less than the target value.
|
||||
*/
|
||||
NUMERIC_LESS_THAN = "NUMERIC_LESS_THAN",
|
||||
/**
|
||||
* Matches a numeric value less than or equal to the target value.
|
||||
*/
|
||||
NUMERIC_LESS_EQUAL = "NUMERIC_LESS_EQUAL",
|
||||
/**
|
||||
* Matches a numeric value equal to the target value.
|
||||
*/
|
||||
NUMERIC_EQUAL = "NUMERIC_EQUAL",
|
||||
/**
|
||||
* Matches a numeric value not equal to the target value.
|
||||
*/
|
||||
NUMERIC_NOT_EQUAL = "NUMERIC_NOT_EQUAL",
|
||||
/**
|
||||
* Matches a numeric value greater than the target value.
|
||||
*/
|
||||
NUMERIC_GREATER_THAN = "NUMERIC_GREATER_THAN",
|
||||
/**
|
||||
* Matches a numeric value greater than or equal to the target value.
|
||||
*/
|
||||
NUMERIC_GREATER_EQUAL = "NUMERIC_GREATER_EQUAL",
|
||||
/**
|
||||
* Matches if at least one of the target values is a substring of the actual custom
|
||||
* signal value (e.g. "abc" contains the string "a", "bc").
|
||||
*/
|
||||
STRING_CONTAINS = "STRING_CONTAINS",
|
||||
/**
|
||||
* Matches if none of the target values is a substring of the actual custom signal value.
|
||||
*/
|
||||
STRING_DOES_NOT_CONTAIN = "STRING_DOES_NOT_CONTAIN",
|
||||
/**
|
||||
* Matches if the actual value exactly matches at least one of the target values.
|
||||
*/
|
||||
STRING_EXACTLY_MATCHES = "STRING_EXACTLY_MATCHES",
|
||||
/**
|
||||
* The target regular expression matches at least one of the actual values.
|
||||
* The regex conforms to RE2 format. See https://github.com/google/re2/wiki/Syntax
|
||||
*/
|
||||
STRING_CONTAINS_REGEX = "STRING_CONTAINS_REGEX",
|
||||
/**
|
||||
* Matches if the actual version value is less than the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_LESS_THAN = "SEMANTIC_VERSION_LESS_THAN",
|
||||
/**
|
||||
* Matches if the actual version value is less than or equal to the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_LESS_EQUAL = "SEMANTIC_VERSION_LESS_EQUAL",
|
||||
/**
|
||||
* Matches if the actual version value is equal to the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_EQUAL = "SEMANTIC_VERSION_EQUAL",
|
||||
/**
|
||||
* Matches if the actual version value is not equal to the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_NOT_EQUAL = "SEMANTIC_VERSION_NOT_EQUAL",
|
||||
/**
|
||||
* Matches if the actual version value is greater than the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_GREATER_THAN = "SEMANTIC_VERSION_GREATER_THAN",
|
||||
/**
|
||||
* Matches if the actual version value is greater than or equal to the target value.
|
||||
*/
|
||||
SEMANTIC_VERSION_GREATER_EQUAL = "SEMANTIC_VERSION_GREATER_EQUAL"
|
||||
}
|
||||
/**
|
||||
* Represents a condition that compares provided signals against a target value.
|
||||
*/
|
||||
export interface CustomSignalCondition {
|
||||
/**
|
||||
* The choice of custom signal operator to determine how to compare targets
|
||||
* to value(s).
|
||||
*/
|
||||
customSignalOperator?: CustomSignalOperator;
|
||||
/**
|
||||
* The key of the signal set in the EvaluationContext
|
||||
*/
|
||||
customSignalKey?: string;
|
||||
/**
|
||||
* A list of at most 100 target custom signal values. For numeric operators,
|
||||
* this will have exactly ONE target value.
|
||||
*/
|
||||
targetCustomSignalValues?: string[];
|
||||
}
|
||||
/**
|
||||
* Interface representing an explicit parameter value.
|
||||
*/
|
||||
export interface ExplicitParameterValue {
|
||||
/**
|
||||
* The `string` value that the parameter is set to.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing an in-app-default value.
|
||||
*/
|
||||
export interface InAppDefaultValue {
|
||||
/**
|
||||
* If `true`, the parameter is omitted from the parameter values returned to a client.
|
||||
*/
|
||||
useInAppDefault: boolean;
|
||||
}
|
||||
/**
|
||||
* Type representing a Remote Config parameter value.
|
||||
* A `RemoteConfigParameterValue` could be either an `ExplicitParameterValue` or
|
||||
* an `InAppDefaultValue`.
|
||||
*/
|
||||
export type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
|
||||
/**
|
||||
* Interface representing a Remote Config parameter.
|
||||
* At minimum, a `defaultValue` or a `conditionalValues` entry must be present for the
|
||||
* parameter to have any effect.
|
||||
*/
|
||||
export interface RemoteConfigParameter {
|
||||
/**
|
||||
* The value to set the parameter to, when none of the named conditions evaluate to `true`.
|
||||
*/
|
||||
defaultValue?: RemoteConfigParameterValue;
|
||||
/**
|
||||
* A `(condition name, value)` map. The condition name of the highest priority
|
||||
* (the one listed first in the Remote Config template's conditions list) determines the value of
|
||||
* this parameter.
|
||||
*/
|
||||
conditionalValues?: {
|
||||
[key: string]: RemoteConfigParameterValue;
|
||||
};
|
||||
/**
|
||||
* A description for this parameter. Should not be over 100 characters and may contain any
|
||||
* Unicode characters.
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* The data type for all values of this parameter in the current version of the template.
|
||||
* Defaults to `ParameterValueType.STRING` if unspecified.
|
||||
*/
|
||||
valueType?: ParameterValueType;
|
||||
}
|
||||
/**
|
||||
* Interface representing a Remote Config parameter group.
|
||||
* Grouping parameters is only for management purposes and does not affect client-side
|
||||
* fetching of parameter values.
|
||||
*/
|
||||
export interface RemoteConfigParameterGroup {
|
||||
/**
|
||||
* A description for the group. Its length must be less than or equal to 256 characters.
|
||||
* A description may contain any Unicode characters.
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Map of parameter keys to their optional default values and optional conditional values for
|
||||
* parameters that belong to this group. A parameter only appears once per
|
||||
* Remote Config template. An ungrouped parameter appears at the top level, whereas a
|
||||
* parameter organized within a group appears within its group's map of parameters.
|
||||
*/
|
||||
parameters: {
|
||||
[key: string]: RemoteConfigParameter;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Represents a Remote Config client template.
|
||||
*/
|
||||
export interface RemoteConfigTemplate {
|
||||
/**
|
||||
* A list of conditions in descending order by priority.
|
||||
*/
|
||||
conditions: RemoteConfigCondition[];
|
||||
/**
|
||||
* Map of parameter keys to their optional default values and optional conditional values.
|
||||
*/
|
||||
parameters: {
|
||||
[key: string]: RemoteConfigParameter;
|
||||
};
|
||||
/**
|
||||
* Map of parameter group names to their parameter group objects.
|
||||
* A group's name is mutable but must be unique among groups in the Remote Config template.
|
||||
* The name is limited to 256 characters and intended to be human-readable. Any Unicode
|
||||
* characters are allowed.
|
||||
*/
|
||||
parameterGroups: {
|
||||
[key: string]: RemoteConfigParameterGroup;
|
||||
};
|
||||
/**
|
||||
* ETag of the current Remote Config template (readonly).
|
||||
*/
|
||||
readonly etag: string;
|
||||
/**
|
||||
* Version information for the current Remote Config template.
|
||||
*/
|
||||
version?: Version;
|
||||
}
|
||||
/**
|
||||
* Represents the data in a Remote Config server template.
|
||||
*/
|
||||
export interface ServerTemplateData {
|
||||
/**
|
||||
* A list of conditions in descending order by priority.
|
||||
*/
|
||||
conditions: NamedCondition[];
|
||||
/**
|
||||
* Map of parameter keys to their optional default values and optional conditional values.
|
||||
*/
|
||||
parameters: {
|
||||
[key: string]: RemoteConfigParameter;
|
||||
};
|
||||
/**
|
||||
* Current Remote Config template ETag (read-only).
|
||||
*/
|
||||
readonly etag: string;
|
||||
/**
|
||||
* Version information for the current Remote Config template.
|
||||
*/
|
||||
version?: Version;
|
||||
}
|
||||
/**
|
||||
* Represents optional arguments that can be used when instantiating {@link ServerTemplate}.
|
||||
*/
|
||||
export interface GetServerTemplateOptions {
|
||||
/**
|
||||
* Defines in-app default parameter values, so that your app behaves as
|
||||
* intended before it connects to the Remote Config backend, and so that
|
||||
* default values are available if none are set on the backend.
|
||||
*/
|
||||
defaultConfig?: DefaultConfig;
|
||||
}
|
||||
/**
|
||||
* Represents the type of a Remote Config server template that can be set on
|
||||
* {@link ServerTemplate}. This can either be a {@link ServerTemplateData} object
|
||||
* or a template JSON string.
|
||||
*/
|
||||
export type ServerTemplateDataType = ServerTemplateData | string;
|
||||
/**
|
||||
* Represents optional arguments that can be used when instantiating
|
||||
* {@link ServerTemplate} synchronously.
|
||||
*/
|
||||
export interface InitServerTemplateOptions extends GetServerTemplateOptions {
|
||||
/**
|
||||
* Enables integrations to use template data loaded independently. For
|
||||
* example, customers can reduce initialization latency by pre-fetching and
|
||||
* caching template data and then using this option to initialize the SDK with
|
||||
* that data.
|
||||
*/
|
||||
template?: ServerTemplateDataType;
|
||||
}
|
||||
/**
|
||||
* Represents a stateful abstraction for a Remote Config server template.
|
||||
*/
|
||||
export interface ServerTemplate {
|
||||
/**
|
||||
* Evaluates the current template to produce a {@link ServerConfig}.
|
||||
*/
|
||||
evaluate(context?: EvaluationContext): ServerConfig;
|
||||
/**
|
||||
* Fetches and caches the current active version of the
|
||||
* project's {@link ServerTemplate}.
|
||||
*/
|
||||
load(): Promise<void>;
|
||||
/**
|
||||
* Sets and caches a {@link ServerTemplateData} or a JSON string representing
|
||||
* the server template
|
||||
*/
|
||||
set(template: ServerTemplateDataType): void;
|
||||
/**
|
||||
* Returns a JSON representation of {@link ServerTemplateData}
|
||||
*/
|
||||
toJSON(): ServerTemplateData;
|
||||
}
|
||||
/**
|
||||
* Generic map of developer-defined signals used as evaluation input signals.
|
||||
*/
|
||||
export type UserProvidedSignals = {
|
||||
[key: string]: string | number;
|
||||
};
|
||||
/**
|
||||
* Predefined template evaluation input signals.
|
||||
*/
|
||||
export type PredefinedSignals = {
|
||||
/**
|
||||
* Defines the identifier to use when splitting a group. For example,
|
||||
* this is used by the percent condition.
|
||||
*/
|
||||
randomizationId?: string;
|
||||
};
|
||||
/**
|
||||
* Represents template evaluation input signals.
|
||||
*/
|
||||
export type EvaluationContext = UserProvidedSignals & PredefinedSignals;
|
||||
/**
|
||||
* Interface representing a Remote Config user.
|
||||
*/
|
||||
export interface RemoteConfigUser {
|
||||
/**
|
||||
* Email address. Output only.
|
||||
*/
|
||||
email: string;
|
||||
/**
|
||||
* Display name. Output only.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Image URL. Output only.
|
||||
*/
|
||||
imageUrl?: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing a Remote Config template version.
|
||||
* Output only, except for the version description. Contains metadata about a particular
|
||||
* version of the Remote Config template. All fields are set at the time the specified Remote
|
||||
* Config template is published. A version's description field may be specified in
|
||||
* `publishTemplate` calls.
|
||||
*/
|
||||
export interface Version {
|
||||
/**
|
||||
* The version number of a Remote Config template.
|
||||
*/
|
||||
versionNumber?: string;
|
||||
/**
|
||||
* The timestamp of when this version of the Remote Config template was written to the
|
||||
* Remote Config backend.
|
||||
*/
|
||||
updateTime?: string;
|
||||
/**
|
||||
* The origin of the template update action.
|
||||
*/
|
||||
updateOrigin?: ('REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED' | 'CONSOLE' | 'REST_API' | 'ADMIN_SDK_NODE');
|
||||
/**
|
||||
* The type of the template update action.
|
||||
*/
|
||||
updateType?: ('REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED' | 'INCREMENTAL_UPDATE' | 'FORCED_UPDATE' | 'ROLLBACK');
|
||||
/**
|
||||
* Aggregation of all metadata fields about the account that performed the update.
|
||||
*/
|
||||
updateUser?: RemoteConfigUser;
|
||||
/**
|
||||
* The user-provided description of the corresponding Remote Config template.
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* The version number of the Remote Config template that has become the current version
|
||||
* due to a rollback. Only present if this version is the result of a rollback.
|
||||
*/
|
||||
rollbackSource?: string;
|
||||
/**
|
||||
* Indicates whether this Remote Config template was published before version history was
|
||||
* supported.
|
||||
*/
|
||||
isLegacy?: boolean;
|
||||
}
|
||||
/**
|
||||
* Interface representing a list of Remote Config template versions.
|
||||
*/
|
||||
export interface ListVersionsResult {
|
||||
/**
|
||||
* A list of version metadata objects, sorted in reverse chronological order.
|
||||
*/
|
||||
versions: Version[];
|
||||
/**
|
||||
* Token to retrieve the next page of results, or empty if there are no more results
|
||||
* in the list.
|
||||
*/
|
||||
nextPageToken?: string;
|
||||
}
|
||||
/**
|
||||
* Interface representing options for Remote Config list versions operation.
|
||||
*/
|
||||
export interface ListVersionsOptions {
|
||||
/**
|
||||
* The maximum number of items to return per page.
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* The `nextPageToken` value returned from a previous list versions request, if any.
|
||||
*/
|
||||
pageToken?: string;
|
||||
/**
|
||||
* Specifies the newest version number to include in the results.
|
||||
* If specified, must be greater than zero. Defaults to the newest version.
|
||||
*/
|
||||
endVersionNumber?: string | number;
|
||||
/**
|
||||
* Specifies the earliest update time to include in the results. Any entries updated before this
|
||||
* time are omitted.
|
||||
*/
|
||||
startTime?: Date | string;
|
||||
/**
|
||||
* Specifies the latest update time to include in the results. Any entries updated on or after
|
||||
* this time are omitted.
|
||||
*/
|
||||
endTime?: Date | string;
|
||||
}
|
||||
/**
|
||||
* Represents the configuration produced by evaluating a server template.
|
||||
*/
|
||||
export interface ServerConfig {
|
||||
/**
|
||||
* Gets the value for the given key as a boolean.
|
||||
*
|
||||
* Convenience method for calling <code>serverConfig.getValue(key).asBoolean()</code>.
|
||||
*
|
||||
* @param key - The name of the parameter.
|
||||
*
|
||||
* @returns The value for the given key as a boolean.
|
||||
*/
|
||||
getBoolean(key: string): boolean;
|
||||
/**
|
||||
* Gets the value for the given key as a number.
|
||||
*
|
||||
* Convenience method for calling <code>serverConfig.getValue(key).asNumber()</code>.
|
||||
*
|
||||
* @param key - The name of the parameter.
|
||||
*
|
||||
* @returns The value for the given key as a number.
|
||||
*/
|
||||
getNumber(key: string): number;
|
||||
/**
|
||||
* Gets the value for the given key as a string.
|
||||
* Convenience method for calling <code>serverConfig.getValue(key).asString()</code>.
|
||||
*
|
||||
* @param key - The name of the parameter.
|
||||
*
|
||||
* @returns The value for the given key as a string.
|
||||
*/
|
||||
getString(key: string): string;
|
||||
/**
|
||||
* Gets the {@link Value} for the given key.
|
||||
*
|
||||
* Ensures application logic will always have a type-safe reference,
|
||||
* even if the parameter is removed remotely.
|
||||
*
|
||||
* @param key - The name of the parameter.
|
||||
*
|
||||
* @returns The value for the given key.
|
||||
*/
|
||||
getValue(key: string): Value;
|
||||
/**
|
||||
* Returns all config values.
|
||||
*
|
||||
* @returns A map of all config keys to their values.
|
||||
*/
|
||||
getAll(): {
|
||||
[key: string]: Value;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* JSON-serializable representation of evaluated config values. This can be consumed by
|
||||
* Remote Config web client SDKs.
|
||||
*/
|
||||
export interface FetchResponseData {
|
||||
/**
|
||||
* The HTTP status, which is useful for differentiating success responses with data from
|
||||
* those without.
|
||||
*
|
||||
* This use of 200 and 304 response codes is consistent with Remote Config's server
|
||||
* implementation.
|
||||
*/
|
||||
status: number;
|
||||
/**
|
||||
* Defines the ETag response header value. Only defined for 200 and 304 responses.
|
||||
*
|
||||
* This is consistent with Remote Config's server eTag implementation.
|
||||
*/
|
||||
eTag?: string;
|
||||
/**
|
||||
* Defines the map of parameters returned as "entries" in the fetch response body.
|
||||
*/
|
||||
config?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Wraps a parameter value with metadata and type-safe getters.
|
||||
*
|
||||
* Type-safe getters insulate application logic from remote
|
||||
* changes to parameter names and types.
|
||||
*/
|
||||
export interface Value {
|
||||
/**
|
||||
* Gets the value as a boolean.
|
||||
*
|
||||
* The following values (case insensitive) are interpreted as true:
|
||||
* "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
|
||||
*/
|
||||
asBoolean(): boolean;
|
||||
/**
|
||||
* Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
|
||||
*/
|
||||
asNumber(): number;
|
||||
/**
|
||||
* Gets the value as a string.
|
||||
*/
|
||||
asString(): string;
|
||||
/**
|
||||
* Gets the {@link ValueSource} for the given key.
|
||||
*/
|
||||
getSource(): ValueSource;
|
||||
}
|
||||
/**
|
||||
* Indicates the source of a value.
|
||||
*
|
||||
* <ul>
|
||||
* <li>"static" indicates the value was defined by a static constant.</li>
|
||||
* <li>"default" indicates the value was defined by default config.</li>
|
||||
* <li>"remote" indicates the value was defined by config produced by
|
||||
* evaluating a template.</li>
|
||||
* </ul>
|
||||
*/
|
||||
export type ValueSource = 'static' | 'default' | 'remote';
|
||||
/**
|
||||
* Defines the format for in-app default parameter values.
|
||||
*/
|
||||
export type DefaultConfig = {
|
||||
[key: string]: string | number | boolean;
|
||||
};
|
||||
122
server/node_modules/firebase-admin/lib/remote-config/remote-config-api.js
generated
vendored
Normal file
122
server/node_modules/firebase-admin/lib/remote-config/remote-config-api.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2021 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CustomSignalOperator = exports.PercentConditionOperator = void 0;
|
||||
/**
|
||||
* Defines supported operators for percent conditions.
|
||||
*/
|
||||
var PercentConditionOperator;
|
||||
(function (PercentConditionOperator) {
|
||||
/**
|
||||
* A catchall error case.
|
||||
*/
|
||||
PercentConditionOperator["UNKNOWN"] = "UNKNOWN";
|
||||
/**
|
||||
* Target percentiles less than or equal to the target percent.
|
||||
* A condition using this operator must specify microPercent.
|
||||
*/
|
||||
PercentConditionOperator["LESS_OR_EQUAL"] = "LESS_OR_EQUAL";
|
||||
/**
|
||||
* Target percentiles greater than the target percent.
|
||||
* A condition using this operator must specify microPercent.
|
||||
*/
|
||||
PercentConditionOperator["GREATER_THAN"] = "GREATER_THAN";
|
||||
/**
|
||||
* Target percentiles within an interval defined by a lower bound and an
|
||||
* upper bound. The lower bound is an exclusive (open) bound and the
|
||||
* micro_percent_range_upper_bound is an inclusive (closed) bound.
|
||||
* A condition using this operator must specify microPercentRange.
|
||||
*/
|
||||
PercentConditionOperator["BETWEEN"] = "BETWEEN";
|
||||
})(PercentConditionOperator || (exports.PercentConditionOperator = PercentConditionOperator = {}));
|
||||
/**
|
||||
* Defines supported operators for custom signal conditions.
|
||||
*/
|
||||
var CustomSignalOperator;
|
||||
(function (CustomSignalOperator) {
|
||||
/**
|
||||
* A catchall error case.
|
||||
*/
|
||||
CustomSignalOperator["UNKNOWN"] = "UNKNOWN";
|
||||
/**
|
||||
* Matches a numeric value less than the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_LESS_THAN"] = "NUMERIC_LESS_THAN";
|
||||
/**
|
||||
* Matches a numeric value less than or equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_LESS_EQUAL"] = "NUMERIC_LESS_EQUAL";
|
||||
/**
|
||||
* Matches a numeric value equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_EQUAL"] = "NUMERIC_EQUAL";
|
||||
/**
|
||||
* Matches a numeric value not equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_NOT_EQUAL"] = "NUMERIC_NOT_EQUAL";
|
||||
/**
|
||||
* Matches a numeric value greater than the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_GREATER_THAN"] = "NUMERIC_GREATER_THAN";
|
||||
/**
|
||||
* Matches a numeric value greater than or equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["NUMERIC_GREATER_EQUAL"] = "NUMERIC_GREATER_EQUAL";
|
||||
/**
|
||||
* Matches if at least one of the target values is a substring of the actual custom
|
||||
* signal value (e.g. "abc" contains the string "a", "bc").
|
||||
*/
|
||||
CustomSignalOperator["STRING_CONTAINS"] = "STRING_CONTAINS";
|
||||
/**
|
||||
* Matches if none of the target values is a substring of the actual custom signal value.
|
||||
*/
|
||||
CustomSignalOperator["STRING_DOES_NOT_CONTAIN"] = "STRING_DOES_NOT_CONTAIN";
|
||||
/**
|
||||
* Matches if the actual value exactly matches at least one of the target values.
|
||||
*/
|
||||
CustomSignalOperator["STRING_EXACTLY_MATCHES"] = "STRING_EXACTLY_MATCHES";
|
||||
/**
|
||||
* The target regular expression matches at least one of the actual values.
|
||||
* The regex conforms to RE2 format. See https://github.com/google/re2/wiki/Syntax
|
||||
*/
|
||||
CustomSignalOperator["STRING_CONTAINS_REGEX"] = "STRING_CONTAINS_REGEX";
|
||||
/**
|
||||
* Matches if the actual version value is less than the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_LESS_THAN"] = "SEMANTIC_VERSION_LESS_THAN";
|
||||
/**
|
||||
* Matches if the actual version value is less than or equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_LESS_EQUAL"] = "SEMANTIC_VERSION_LESS_EQUAL";
|
||||
/**
|
||||
* Matches if the actual version value is equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_EQUAL"] = "SEMANTIC_VERSION_EQUAL";
|
||||
/**
|
||||
* Matches if the actual version value is not equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_NOT_EQUAL"] = "SEMANTIC_VERSION_NOT_EQUAL";
|
||||
/**
|
||||
* Matches if the actual version value is greater than the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_GREATER_THAN"] = "SEMANTIC_VERSION_GREATER_THAN";
|
||||
/**
|
||||
* Matches if the actual version value is greater than or equal to the target value.
|
||||
*/
|
||||
CustomSignalOperator["SEMANTIC_VERSION_GREATER_EQUAL"] = "SEMANTIC_VERSION_GREATER_EQUAL";
|
||||
})(CustomSignalOperator || (exports.CustomSignalOperator = CustomSignalOperator = {}));
|
||||
105
server/node_modules/firebase-admin/lib/remote-config/remote-config-namespace.d.ts
generated
vendored
Normal file
105
server/node_modules/firebase-admin/lib/remote-config/remote-config-namespace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2021 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { App } from '../app';
|
||||
import { ExplicitParameterValue as TExplicitParameterValue, InAppDefaultValue as TInAppDefaultValue, ListVersionsOptions as TListVersionsOptions, ListVersionsResult as TListVersionsResult, ParameterValueType as TParameterValueType, RemoteConfigCondition as TRemoteConfigCondition, RemoteConfigParameter as TRemoteConfigParameter, RemoteConfigParameterGroup as TRemoteConfigParameterGroup, RemoteConfigParameterValue as TRemoteConfigParameterValue, RemoteConfigTemplate as TRemoteConfigTemplate, RemoteConfigUser as TRemoteConfigUser, TagColor as TTagColor, Version as TVersion } from './remote-config-api';
|
||||
import { RemoteConfig as TRemoteConfig } from './remote-config';
|
||||
/**
|
||||
* Gets the {@link firebase-admin.remote-config#RemoteConfig} service for the
|
||||
* default app or a given app.
|
||||
*
|
||||
* `admin.remoteConfig()` can be called with no arguments to access the default
|
||||
* app's `RemoteConfig` service or as `admin.remoteConfig(app)` to access the
|
||||
* `RemoteConfig` service associated with a specific app.
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for the default app
|
||||
* var defaultRemoteConfig = admin.remoteConfig();
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```javascript
|
||||
* // Get the `RemoteConfig` service for a given app
|
||||
* var otherRemoteConfig = admin.remoteConfig(otherApp);
|
||||
* ```
|
||||
*
|
||||
* @param app - Optional app for which to return the `RemoteConfig` service.
|
||||
* If not provided, the default `RemoteConfig` service is returned.
|
||||
*
|
||||
* @returns The default `RemoteConfig` service if no
|
||||
* app is provided, or the `RemoteConfig` service associated with the provided
|
||||
* app.
|
||||
*/
|
||||
export declare function remoteConfig(app?: App): remoteConfig.RemoteConfig;
|
||||
export declare namespace remoteConfig {
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#ExplicitParameterValue}.
|
||||
*/
|
||||
type ExplicitParameterValue = TExplicitParameterValue;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#InAppDefaultValue}.
|
||||
*/
|
||||
type InAppDefaultValue = TInAppDefaultValue;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#ListVersionsOptions}.
|
||||
*/
|
||||
type ListVersionsOptions = TListVersionsOptions;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#ListVersionsResult}.
|
||||
*/
|
||||
type ListVersionsResult = TListVersionsResult;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#ParameterValueType}.
|
||||
*/
|
||||
type ParameterValueType = TParameterValueType;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfig}.
|
||||
*/
|
||||
type RemoteConfig = TRemoteConfig;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigCondition}.
|
||||
*/
|
||||
type RemoteConfigCondition = TRemoteConfigCondition;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigParameter}.
|
||||
*/
|
||||
type RemoteConfigParameter = TRemoteConfigParameter;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigParameterGroup}.
|
||||
*/
|
||||
type RemoteConfigParameterGroup = TRemoteConfigParameterGroup;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigParameterValue}.
|
||||
*/
|
||||
type RemoteConfigParameterValue = TRemoteConfigParameterValue;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigTemplate}.
|
||||
*/
|
||||
type RemoteConfigTemplate = TRemoteConfigTemplate;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#RemoteConfigUser}.
|
||||
*/
|
||||
type RemoteConfigUser = TRemoteConfigUser;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#TagColor}.
|
||||
*/
|
||||
type TagColor = TTagColor;
|
||||
/**
|
||||
* Type alias to {@link firebase-admin.remote-config#Version}.
|
||||
*/
|
||||
type Version = TVersion;
|
||||
}
|
||||
18
server/node_modules/firebase-admin/lib/remote-config/remote-config-namespace.js
generated
vendored
Normal file
18
server/node_modules/firebase-admin/lib/remote-config/remote-config-namespace.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2021 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
121
server/node_modules/firebase-admin/lib/remote-config/remote-config.d.ts
generated
vendored
Normal file
121
server/node_modules/firebase-admin/lib/remote-config/remote-config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { App } from '../app';
|
||||
import { ListVersionsOptions, ListVersionsResult, ServerTemplate, RemoteConfigTemplate, ServerConfig, GetServerTemplateOptions, InitServerTemplateOptions, FetchResponseData } from './remote-config-api';
|
||||
/**
|
||||
* The Firebase `RemoteConfig` service interface.
|
||||
*/
|
||||
export declare class RemoteConfig {
|
||||
readonly app: App;
|
||||
private readonly client;
|
||||
/**
|
||||
* Gets the current active version of the {@link RemoteConfigTemplate} of the project.
|
||||
*
|
||||
* @returns A promise that fulfills with a `RemoteConfigTemplate`.
|
||||
*/
|
||||
getTemplate(): Promise<RemoteConfigTemplate>;
|
||||
/**
|
||||
* Gets the requested version of the {@link RemoteConfigTemplate} of the project.
|
||||
*
|
||||
* @param versionNumber - Version number of the Remote Config template to look up.
|
||||
*
|
||||
* @returns A promise that fulfills with a `RemoteConfigTemplate`.
|
||||
*/
|
||||
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
|
||||
/**
|
||||
* Validates a {@link RemoteConfigTemplate}.
|
||||
*
|
||||
* @param template - The Remote Config template to be validated.
|
||||
* @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
|
||||
*/
|
||||
validateTemplate(template: RemoteConfigTemplate): Promise<RemoteConfigTemplate>;
|
||||
/**
|
||||
* Publishes a Remote Config template.
|
||||
*
|
||||
* @param template - The Remote Config template to be published.
|
||||
* @param options - Optional options object when publishing a Remote Config template:
|
||||
* - `force`: Setting this to `true` forces the Remote Config template to
|
||||
* be updated and circumvent the ETag. This approach is not recommended
|
||||
* because it risks causing the loss of updates to your Remote Config
|
||||
* template if multiple clients are updating the Remote Config template.
|
||||
* See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates |
|
||||
* ETag usage and forced updates}.
|
||||
*
|
||||
* @returns A Promise that fulfills with the published `RemoteConfigTemplate`.
|
||||
*/
|
||||
publishTemplate(template: RemoteConfigTemplate, options?: {
|
||||
force: boolean;
|
||||
}): Promise<RemoteConfigTemplate>;
|
||||
/**
|
||||
* Rolls back a project's published Remote Config template to the specified version.
|
||||
* A rollback is equivalent to getting a previously published Remote Config
|
||||
* template and re-publishing it using a force update.
|
||||
*
|
||||
* @param versionNumber - The version number of the Remote Config template to roll back to.
|
||||
* The specified version number must be lower than the current version number, and not have
|
||||
* been deleted due to staleness. Only the last 300 versions are stored.
|
||||
* All versions that correspond to non-active Remote Config templates (that is, all except the
|
||||
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
|
||||
* @returns A promise that fulfills with the published `RemoteConfigTemplate`.
|
||||
*/
|
||||
rollback(versionNumber: number | string): Promise<RemoteConfigTemplate>;
|
||||
/**
|
||||
* Gets a list of Remote Config template versions that have been published, sorted in reverse
|
||||
* chronological order. Only the last 300 versions are stored.
|
||||
* All versions that correspond to non-active Remote Config templates (i.e., all except the
|
||||
* template that is being fetched by clients) are also deleted if they are older than 90 days.
|
||||
*
|
||||
* @param options - Optional options object for getting a list of versions.
|
||||
* @returns A promise that fulfills with a `ListVersionsResult`.
|
||||
*/
|
||||
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
|
||||
/**
|
||||
* Creates and returns a new Remote Config template from a JSON string.
|
||||
*
|
||||
* @param json - The JSON string to populate a Remote Config template.
|
||||
*
|
||||
* @returns A new template instance.
|
||||
*/
|
||||
createTemplateFromJSON(json: string): RemoteConfigTemplate;
|
||||
/**
|
||||
* Instantiates {@link ServerTemplate} and then fetches and caches the latest
|
||||
* template version of the project.
|
||||
*/
|
||||
getServerTemplate(options?: GetServerTemplateOptions): Promise<ServerTemplate>;
|
||||
/**
|
||||
* Synchronously instantiates {@link ServerTemplate}.
|
||||
*/
|
||||
initServerTemplate(options?: InitServerTemplateOptions): ServerTemplate;
|
||||
}
|
||||
/**
|
||||
* Represents a fetch response that can be used to interact with RC's client SDK.
|
||||
*/
|
||||
export declare class RemoteConfigFetchResponse {
|
||||
private response;
|
||||
/**
|
||||
* @param app - The app for this RemoteConfig service.
|
||||
* @param serverConfig - The server config for which to generate a fetch response.
|
||||
* @param requestEtag - A request eTag with which to compare the current response.
|
||||
*/
|
||||
constructor(app: App, serverConfig: ServerConfig, requestEtag?: string);
|
||||
/**
|
||||
* @returns JSON representation of the fetch response that can be consumed
|
||||
* by the RC client SDK.
|
||||
*/
|
||||
toJSON(): FetchResponseData;
|
||||
private processEtag;
|
||||
}
|
||||
529
server/node_modules/firebase-admin/lib/remote-config/remote-config.js
generated
vendored
Normal file
529
server/node_modules/firebase-admin/lib/remote-config/remote-config.js
generated
vendored
Normal file
@@ -0,0 +1,529 @@
|
||||
/*! firebase-admin v13.5.0 */
|
||||
"use strict";
|
||||
/*!
|
||||
* Copyright 2020 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoteConfigFetchResponse = exports.RemoteConfig = void 0;
|
||||
const utils = require("../utils/index");
|
||||
const validator = require("../utils/validator");
|
||||
const remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
|
||||
const condition_evaluator_internal_1 = require("./condition-evaluator-internal");
|
||||
const value_impl_1 = require("./internal/value-impl");
|
||||
/**
|
||||
* The Firebase `RemoteConfig` service interface.
|
||||
*/
|
||||
class RemoteConfig {
|
||||
/**
|
||||
* @param app - The app for this RemoteConfig service.
|
||||
* @constructor
|
||||
* @internal
|
||||
*/
|
||||
constructor(app) {
|
||||
this.app = app;
|
||||
this.client = new remote_config_api_client_internal_1.RemoteConfigApiClient(app);
|
||||
}
|
||||
/**
|
||||
* Gets the current active version of the {@link RemoteConfigTemplate} of the project.
|
||||
*
|
||||
* @returns A promise that fulfills with a `RemoteConfigTemplate`.
|
||||
*/
|
||||
getTemplate() {
|
||||
return this.client.getTemplate()
|
||||
.then((templateResponse) => {
|
||||
return new RemoteConfigTemplateImpl(templateResponse);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets the requested version of the {@link RemoteConfigTemplate} of the project.
|
||||
*
|
||||
* @param versionNumber - Version number of the Remote Config template to look up.
|
||||
*
|
||||
* @returns A promise that fulfills with a `RemoteConfigTemplate`.
|
||||
*/
|
||||
getTemplateAtVersion(versionNumber) {
|
||||
return this.client.getTemplateAtVersion(versionNumber)
|
||||
.then((templateResponse) => {
|
||||
return new RemoteConfigTemplateImpl(templateResponse);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Validates a {@link RemoteConfigTemplate}.
|
||||
*
|
||||
* @param template - The Remote Config template to be validated.
|
||||
* @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
|
||||
*/
|
||||
validateTemplate(template) {
|
||||
return this.client.validateTemplate(template)
|
||||
.then((templateResponse) => {
|
||||
return new RemoteConfigTemplateImpl(templateResponse);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Publishes a Remote Config template.
|
||||
*
|
||||
* @param template - The Remote Config template to be published.
|
||||
* @param options - Optional options object when publishing a Remote Config template:
|
||||
* - `force`: Setting this to `true` forces the Remote Config template to
|
||||
* be updated and circumvent the ETag. This approach is not recommended
|
||||
* because it risks causing the loss of updates to your Remote Config
|
||||
* template if multiple clients are updating the Remote Config template.
|
||||
* See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates |
|
||||
* ETag usage and forced updates}.
|
||||
*
|
||||
* @returns A Promise that fulfills with the published `RemoteConfigTemplate`.
|
||||
*/
|
||||
publishTemplate(template, options) {
|
||||
return this.client.publishTemplate(template, options)
|
||||
.then((templateResponse) => {
|
||||
return new RemoteConfigTemplateImpl(templateResponse);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Rolls back a project's published Remote Config template to the specified version.
|
||||
* A rollback is equivalent to getting a previously published Remote Config
|
||||
* template and re-publishing it using a force update.
|
||||
*
|
||||
* @param versionNumber - The version number of the Remote Config template to roll back to.
|
||||
* The specified version number must be lower than the current version number, and not have
|
||||
* been deleted due to staleness. Only the last 300 versions are stored.
|
||||
* All versions that correspond to non-active Remote Config templates (that is, all except the
|
||||
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
|
||||
* @returns A promise that fulfills with the published `RemoteConfigTemplate`.
|
||||
*/
|
||||
rollback(versionNumber) {
|
||||
return this.client.rollback(versionNumber)
|
||||
.then((templateResponse) => {
|
||||
return new RemoteConfigTemplateImpl(templateResponse);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Gets a list of Remote Config template versions that have been published, sorted in reverse
|
||||
* chronological order. Only the last 300 versions are stored.
|
||||
* All versions that correspond to non-active Remote Config templates (i.e., all except the
|
||||
* template that is being fetched by clients) are also deleted if they are older than 90 days.
|
||||
*
|
||||
* @param options - Optional options object for getting a list of versions.
|
||||
* @returns A promise that fulfills with a `ListVersionsResult`.
|
||||
*/
|
||||
listVersions(options) {
|
||||
return this.client.listVersions(options)
|
||||
.then((listVersionsResponse) => {
|
||||
return {
|
||||
versions: listVersionsResponse.versions?.map(version => new VersionImpl(version)) ?? [],
|
||||
nextPageToken: listVersionsResponse.nextPageToken,
|
||||
};
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates and returns a new Remote Config template from a JSON string.
|
||||
*
|
||||
* @param json - The JSON string to populate a Remote Config template.
|
||||
*
|
||||
* @returns A new template instance.
|
||||
*/
|
||||
createTemplateFromJSON(json) {
|
||||
if (!validator.isNonEmptyString(json)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
|
||||
}
|
||||
let template;
|
||||
try {
|
||||
template = JSON.parse(json);
|
||||
}
|
||||
catch (e) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${json}. ` + e);
|
||||
}
|
||||
return new RemoteConfigTemplateImpl(template);
|
||||
}
|
||||
/**
|
||||
* Instantiates {@link ServerTemplate} and then fetches and caches the latest
|
||||
* template version of the project.
|
||||
*/
|
||||
async getServerTemplate(options) {
|
||||
const template = this.initServerTemplate(options);
|
||||
await template.load();
|
||||
return template;
|
||||
}
|
||||
/**
|
||||
* Synchronously instantiates {@link ServerTemplate}.
|
||||
*/
|
||||
initServerTemplate(options) {
|
||||
const template = new ServerTemplateImpl(this.client, new condition_evaluator_internal_1.ConditionEvaluator(), options?.defaultConfig);
|
||||
if (options?.template) {
|
||||
template.set(options?.template);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
}
|
||||
exports.RemoteConfig = RemoteConfig;
|
||||
/**
|
||||
* Remote Config template internal implementation.
|
||||
*/
|
||||
class RemoteConfigTemplateImpl {
|
||||
constructor(config) {
|
||||
if (!validator.isNonNullObject(config) ||
|
||||
!validator.isNonEmptyString(config.etag)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(config)}`);
|
||||
}
|
||||
this.etagInternal = config.etag;
|
||||
if (typeof config.parameters !== 'undefined') {
|
||||
if (!validator.isNonNullObject(config.parameters)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
|
||||
}
|
||||
this.parameters = config.parameters;
|
||||
}
|
||||
else {
|
||||
this.parameters = {};
|
||||
}
|
||||
if (typeof config.parameterGroups !== 'undefined') {
|
||||
if (!validator.isNonNullObject(config.parameterGroups)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
|
||||
}
|
||||
this.parameterGroups = config.parameterGroups;
|
||||
}
|
||||
else {
|
||||
this.parameterGroups = {};
|
||||
}
|
||||
if (typeof config.conditions !== 'undefined') {
|
||||
if (!validator.isArray(config.conditions)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
|
||||
}
|
||||
this.conditions = config.conditions;
|
||||
}
|
||||
else {
|
||||
this.conditions = [];
|
||||
}
|
||||
if (typeof config.version !== 'undefined') {
|
||||
this.version = new VersionImpl(config.version);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the ETag of the template.
|
||||
*
|
||||
* @returns The ETag of the Remote Config template.
|
||||
*/
|
||||
get etag() {
|
||||
return this.etagInternal;
|
||||
}
|
||||
/**
|
||||
* Returns a JSON-serializable representation of this object.
|
||||
*
|
||||
* @returns A JSON-serializable representation of this object.
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
conditions: this.conditions,
|
||||
parameters: this.parameters,
|
||||
parameterGroups: this.parameterGroups,
|
||||
etag: this.etag,
|
||||
version: this.version,
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Remote Config dataplane template data implementation.
|
||||
*/
|
||||
class ServerTemplateImpl {
|
||||
constructor(apiClient, conditionEvaluator, defaultConfig = {}) {
|
||||
this.apiClient = apiClient;
|
||||
this.conditionEvaluator = conditionEvaluator;
|
||||
this.defaultConfig = defaultConfig;
|
||||
this.stringifiedDefaultConfig = {};
|
||||
// RC stores all remote values as string, but it's more intuitive
|
||||
// to declare default values with specific types, so this converts
|
||||
// the external declaration to an internal string representation.
|
||||
for (const key in defaultConfig) {
|
||||
this.stringifiedDefaultConfig[key] = String(defaultConfig[key]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Fetches and caches the current active version of the project's {@link ServerTemplate}.
|
||||
*/
|
||||
load() {
|
||||
return this.apiClient.getServerTemplate()
|
||||
.then((template) => {
|
||||
this.cache = new ServerTemplateDataImpl(template);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Parses a {@link ServerTemplateDataType} and caches it.
|
||||
*/
|
||||
set(template) {
|
||||
let parsed;
|
||||
if (validator.isString(template)) {
|
||||
try {
|
||||
parsed = JSON.parse(template);
|
||||
}
|
||||
catch (e) {
|
||||
// Transforms JSON parse errors to Firebase error.
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${template}. ` + e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
parsed = template;
|
||||
}
|
||||
// Throws template parse errors.
|
||||
this.cache = new ServerTemplateDataImpl(parsed);
|
||||
}
|
||||
/**
|
||||
* Evaluates the current template in cache to produce a {@link ServerConfig}.
|
||||
*/
|
||||
evaluate(context = {}) {
|
||||
if (!this.cache) {
|
||||
// This is the only place we should throw during evaluation, since it's under the
|
||||
// control of application logic. To preserve forward-compatibility, we should only
|
||||
// return false in cases where the SDK is unsure how to evaluate the fetched template.
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('failed-precondition', 'No Remote Config Server template in cache. Call load() before calling evaluate().');
|
||||
}
|
||||
const evaluatedConditions = this.conditionEvaluator.evaluateConditions(this.cache.conditions, context);
|
||||
const configValues = {};
|
||||
// Initializes config Value objects with default values.
|
||||
for (const key in this.stringifiedDefaultConfig) {
|
||||
configValues[key] = new value_impl_1.ValueImpl('default', this.stringifiedDefaultConfig[key]);
|
||||
}
|
||||
// Overlays config Value objects derived by evaluating the template.
|
||||
for (const [key, parameter] of Object.entries(this.cache.parameters)) {
|
||||
const { conditionalValues, defaultValue } = parameter;
|
||||
// Supports parameters with no conditional values.
|
||||
const normalizedConditionalValues = conditionalValues || {};
|
||||
let parameterValueWrapper = undefined;
|
||||
// Iterates in order over condition list. If there is a value associated
|
||||
// with a condition, this checks if the condition is true.
|
||||
for (const [conditionName, conditionEvaluation] of evaluatedConditions) {
|
||||
if (normalizedConditionalValues[conditionName] && conditionEvaluation) {
|
||||
parameterValueWrapper = normalizedConditionalValues[conditionName];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (parameterValueWrapper && parameterValueWrapper.useInAppDefault) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
continue;
|
||||
}
|
||||
if (parameterValueWrapper) {
|
||||
const parameterValue = parameterValueWrapper.value;
|
||||
configValues[key] = new value_impl_1.ValueImpl('remote', parameterValue);
|
||||
continue;
|
||||
}
|
||||
if (!defaultValue) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
continue;
|
||||
}
|
||||
if (defaultValue.useInAppDefault) {
|
||||
// TODO: add logging once we have a wrapped logger.
|
||||
continue;
|
||||
}
|
||||
const parameterDefaultValue = defaultValue.value;
|
||||
configValues[key] = new value_impl_1.ValueImpl('remote', parameterDefaultValue);
|
||||
}
|
||||
return new ServerConfigImpl(configValues);
|
||||
}
|
||||
/**
|
||||
* @returns JSON representation of the server template
|
||||
*/
|
||||
toJSON() {
|
||||
return this.cache;
|
||||
}
|
||||
}
|
||||
class ServerConfigImpl {
|
||||
constructor(configValues) {
|
||||
this.configValues = configValues;
|
||||
}
|
||||
getBoolean(key) {
|
||||
return this.getValue(key).asBoolean();
|
||||
}
|
||||
getNumber(key) {
|
||||
return this.getValue(key).asNumber();
|
||||
}
|
||||
getString(key) {
|
||||
return this.getValue(key).asString();
|
||||
}
|
||||
getValue(key) {
|
||||
return this.configValues[key] || new value_impl_1.ValueImpl('static');
|
||||
}
|
||||
getAll() {
|
||||
return { ...this.configValues };
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Remote Config dataplane template data implementation.
|
||||
*/
|
||||
class ServerTemplateDataImpl {
|
||||
constructor(template) {
|
||||
if (!validator.isNonNullObject(template) ||
|
||||
!validator.isNonEmptyString(template.etag)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(template)}`);
|
||||
}
|
||||
this.etag = template.etag;
|
||||
if (typeof template.parameters !== 'undefined') {
|
||||
if (!validator.isNonNullObject(template.parameters)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
|
||||
}
|
||||
this.parameters = template.parameters;
|
||||
}
|
||||
else {
|
||||
this.parameters = {};
|
||||
}
|
||||
if (typeof template.conditions !== 'undefined') {
|
||||
if (!validator.isArray(template.conditions)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
|
||||
}
|
||||
this.conditions = template.conditions;
|
||||
}
|
||||
else {
|
||||
this.conditions = [];
|
||||
}
|
||||
if (typeof template.version !== 'undefined') {
|
||||
this.version = new VersionImpl(template.version);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Remote Config Version internal implementation.
|
||||
*/
|
||||
class VersionImpl {
|
||||
constructor(version) {
|
||||
if (!validator.isNonNullObject(version)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config version instance: ${JSON.stringify(version)}`);
|
||||
}
|
||||
if (typeof version.versionNumber !== 'undefined') {
|
||||
if (!validator.isNonEmptyString(version.versionNumber) &&
|
||||
!validator.isNumber(version.versionNumber)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be a non-empty string in int64 format or a number');
|
||||
}
|
||||
if (!Number.isInteger(Number(version.versionNumber))) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be an integer or a string in int64 format');
|
||||
}
|
||||
this.versionNumber = version.versionNumber;
|
||||
}
|
||||
if (typeof version.updateOrigin !== 'undefined') {
|
||||
if (!validator.isNonEmptyString(version.updateOrigin)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update origin must be a non-empty string');
|
||||
}
|
||||
this.updateOrigin = version.updateOrigin;
|
||||
}
|
||||
if (typeof version.updateType !== 'undefined') {
|
||||
if (!validator.isNonEmptyString(version.updateType)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update type must be a non-empty string');
|
||||
}
|
||||
this.updateType = version.updateType;
|
||||
}
|
||||
if (typeof version.updateUser !== 'undefined') {
|
||||
if (!validator.isNonNullObject(version.updateUser)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update user must be a non-null object');
|
||||
}
|
||||
this.updateUser = version.updateUser;
|
||||
}
|
||||
if (typeof version.description !== 'undefined') {
|
||||
if (!validator.isNonEmptyString(version.description)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version description must be a non-empty string');
|
||||
}
|
||||
this.description = version.description;
|
||||
}
|
||||
if (typeof version.rollbackSource !== 'undefined') {
|
||||
if (!validator.isNonEmptyString(version.rollbackSource)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version rollback source must be a non-empty string');
|
||||
}
|
||||
this.rollbackSource = version.rollbackSource;
|
||||
}
|
||||
if (typeof version.isLegacy !== 'undefined') {
|
||||
if (!validator.isBoolean(version.isLegacy)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version.isLegacy must be a boolean');
|
||||
}
|
||||
this.isLegacy = version.isLegacy;
|
||||
}
|
||||
// The backend API provides timestamps in ISO date strings. The Admin SDK exposes timestamps
|
||||
// in UTC date strings. If a developer uses a previously obtained template with UTC timestamps
|
||||
// we could still validate it below.
|
||||
if (typeof version.updateTime !== 'undefined') {
|
||||
if (!this.isValidTimestamp(version.updateTime)) {
|
||||
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
|
||||
}
|
||||
this.updateTime = new Date(version.updateTime).toUTCString();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @returns A JSON-serializable representation of this object.
|
||||
*/
|
||||
toJSON() {
|
||||
return {
|
||||
versionNumber: this.versionNumber,
|
||||
updateOrigin: this.updateOrigin,
|
||||
updateType: this.updateType,
|
||||
updateUser: this.updateUser,
|
||||
description: this.description,
|
||||
rollbackSource: this.rollbackSource,
|
||||
isLegacy: this.isLegacy,
|
||||
updateTime: this.updateTime,
|
||||
};
|
||||
}
|
||||
isValidTimestamp(timestamp) {
|
||||
// This validation fails for timestamps earlier than January 1, 1970 and considers strings
|
||||
// such as "1.2" as valid timestamps.
|
||||
return validator.isNonEmptyString(timestamp) && (new Date(timestamp)).getTime() > 0;
|
||||
}
|
||||
}
|
||||
const HTTP_NOT_MODIFIED = 304;
|
||||
const HTTP_OK = 200;
|
||||
/**
|
||||
* Represents a fetch response that can be used to interact with RC's client SDK.
|
||||
*/
|
||||
class RemoteConfigFetchResponse {
|
||||
/**
|
||||
* @param app - The app for this RemoteConfig service.
|
||||
* @param serverConfig - The server config for which to generate a fetch response.
|
||||
* @param requestEtag - A request eTag with which to compare the current response.
|
||||
*/
|
||||
constructor(app, serverConfig, requestEtag) {
|
||||
const config = {};
|
||||
for (const [param, value] of Object.entries(serverConfig.getAll())) {
|
||||
config[param] = value.asString();
|
||||
}
|
||||
const currentEtag = this.processEtag(config, app);
|
||||
if (currentEtag === requestEtag) {
|
||||
this.response = {
|
||||
status: HTTP_NOT_MODIFIED,
|
||||
eTag: currentEtag,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.response = {
|
||||
status: HTTP_OK,
|
||||
eTag: currentEtag,
|
||||
config,
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @returns JSON representation of the fetch response that can be consumed
|
||||
* by the RC client SDK.
|
||||
*/
|
||||
toJSON() {
|
||||
return this.response;
|
||||
}
|
||||
processEtag(config, app) {
|
||||
const configJson = JSON.stringify(config);
|
||||
let hash = 0;
|
||||
// Mimics Java's `String.hashCode()` which is used in RC's servers.
|
||||
for (let i = 0; i < configJson.length; i++) {
|
||||
const char = configJson.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + char;
|
||||
hash |= 0;
|
||||
}
|
||||
const projectId = utils.getExplicitProjectId(app);
|
||||
const parts = ['etag', projectId, 'firebase-server', 'fetch', hash];
|
||||
return parts.filter(a => !!a).join('-');
|
||||
}
|
||||
}
|
||||
exports.RemoteConfigFetchResponse = RemoteConfigFetchResponse;
|
||||
Reference in New Issue
Block a user