@firebase/remote-config
Advanced tools
Comparing version 0.4.11-canary.cbec4b985 to 0.4.11-canary.d16a4874b
@@ -8,3 +8,3 @@ import { _getProvider, getApp, _registerComponent, registerVersion, SDK_VERSION } from '@firebase/app'; | ||
const name = "@firebase/remote-config"; | ||
const version = "0.4.11-canary.cbec4b985"; | ||
const version = "0.4.11-canary.d16a4874b"; | ||
@@ -64,2 +64,5 @@ /** | ||
const RC_COMPONENT_NAME = 'remote-config'; | ||
const RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = 100; | ||
const RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH = 250; | ||
const RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH = 500; | ||
@@ -101,3 +104,4 @@ /** | ||
["fetch-status" /* ErrorCode.FETCH_STATUS */]: 'Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.', | ||
["indexed-db-unavailable" /* ErrorCode.INDEXED_DB_UNAVAILABLE */]: 'Indexed DB is not supported by current browser' | ||
["indexed-db-unavailable" /* ErrorCode.INDEXED_DB_UNAVAILABLE */]: 'Indexed DB is not supported by current browser', | ||
["custom-signal-max-allowed-signals" /* ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS */]: 'Setting more than {$maxSignals} custom signals is not supported.' | ||
}; | ||
@@ -253,2 +257,6 @@ const ERROR_FACTORY = new ErrorFactory('remoteconfig' /* service */, 'Remote Config' /* service name */, ERROR_DESCRIPTION_MAP); | ||
}, rc.settings.fetchTimeoutMillis); | ||
const customSignals = rc._storageCache.getCustomSignals(); | ||
if (customSignals) { | ||
rc._logger.debug(`Fetching config with custom signals: ${JSON.stringify(customSignals)}`); | ||
} | ||
// Catches *all* errors thrown by client so status can be set consistently. | ||
@@ -258,3 +266,4 @@ try { | ||
cacheMaxAgeMillis: rc.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
signal: abortSignal, | ||
customSignals | ||
}); | ||
@@ -383,2 +392,37 @@ await rc._storageCache.setLastFetchStatus('success'); | ||
} | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
async function setCustomSignals(remoteConfig, customSignals) { | ||
const rc = getModularInstance(remoteConfig); | ||
if (Object.keys(customSignals).length === 0) { | ||
return; | ||
} | ||
// eslint-disable-next-line guard-for-in | ||
for (const key in customSignals) { | ||
if (key.length > RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH) { | ||
rc._logger.error(`Custom signal key ${key} is too long, max allowed length is ${RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH}.`); | ||
return; | ||
} | ||
const value = customSignals[key]; | ||
if (typeof value === 'string' && | ||
value.length > RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH) { | ||
rc._logger.error(`Value supplied for custom signal ${key} is too long, max allowed length is ${RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH}.`); | ||
return; | ||
} | ||
} | ||
try { | ||
await rc._storageCache.setCustomSignals(customSignals); | ||
} | ||
catch (error) { | ||
rc._logger.error(`Error encountered while setting custom signals: ${error}`); | ||
} | ||
} | ||
@@ -564,3 +608,4 @@ /** | ||
app_id: this.appId, | ||
language_code: getUserLanguage() | ||
language_code: getUserLanguage(), | ||
custom_signals: request.customSignals | ||
/* eslint-enable camelcase */ | ||
@@ -946,6 +991,39 @@ }; | ||
} | ||
async get(key) { | ||
getCustomSignals() { | ||
return this.get('custom_signals'); | ||
} | ||
async setCustomSignals(customSignals) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
const storedSignals = await this.getWithTransaction('custom_signals', transaction); | ||
const combinedSignals = Object.assign(Object.assign({}, storedSignals), customSignals); | ||
// Filter out key-value assignments with null values since they are signals being unset | ||
const updatedSignals = Object.fromEntries(Object.entries(combinedSignals) | ||
.filter(([_, v]) => v !== null) | ||
.map(([k, v]) => { | ||
// Stringify numbers to store a map of string keys and values which can be sent | ||
// as-is in a fetch call. | ||
if (typeof v === 'number') { | ||
return [k, v.toString()]; | ||
} | ||
return [k, v]; | ||
})); | ||
// Throw an error if the number of custom signals to be stored exceeds the limit | ||
if (Object.keys(updatedSignals).length > RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS) { | ||
throw ERROR_FACTORY.create("custom-signal-max-allowed-signals" /* ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS */, { | ||
maxSignals: RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS | ||
}); | ||
} | ||
await this.setWithTransaction('custom_signals', updatedSignals, transaction); | ||
return updatedSignals; | ||
} | ||
/** | ||
* Gets a value from the database using the provided transaction. | ||
* | ||
* @param key The key of the value to get. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns The value associated with the key, or undefined if no such value exists. | ||
*/ | ||
async getWithTransaction(key, transaction) { | ||
return new Promise((resolve, reject) => { | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readonly'); | ||
const objectStore = transaction.objectStore(APP_NAMESPACE_STORE); | ||
@@ -975,6 +1053,12 @@ const compositeKey = this.createCompositeKey(key); | ||
} | ||
async set(key, value) { | ||
const db = await this.openDbPromise; | ||
/** | ||
* Sets a value in the database using the provided transaction. | ||
* | ||
* @param key The key of the value to set. | ||
* @param value The value to set. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns A promise that resolves when the operation is complete. | ||
*/ | ||
async setWithTransaction(key, value, transaction) { | ||
return new Promise((resolve, reject) => { | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
const objectStore = transaction.objectStore(APP_NAMESPACE_STORE); | ||
@@ -1001,2 +1085,12 @@ const compositeKey = this.createCompositeKey(key); | ||
} | ||
async get(key) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readonly'); | ||
return this.getWithTransaction(key, transaction); | ||
} | ||
async set(key, value) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
return this.setWithTransaction(key, value, transaction); | ||
} | ||
async delete(key) { | ||
@@ -1065,2 +1159,5 @@ const db = await this.openDbPromise; | ||
} | ||
getCustomSignals() { | ||
return this.customSignals; | ||
} | ||
/** | ||
@@ -1073,2 +1170,3 @@ * Read-ahead getter | ||
const activeConfigPromise = this.storage.getActiveConfig(); | ||
const customSignalsPromise = this.storage.getCustomSignals(); | ||
// Note: | ||
@@ -1092,2 +1190,6 @@ // 1. we consistently check for undefined to avoid clobbering defined values | ||
} | ||
const customSignals = await customSignalsPromise; | ||
if (customSignals) { | ||
this.customSignals = customSignals; | ||
} | ||
} | ||
@@ -1109,2 +1211,5 @@ /** | ||
} | ||
async setCustomSignals(customSignals) { | ||
this.customSignals = await this.storage.setCustomSignals(customSignals); | ||
} | ||
} | ||
@@ -1246,3 +1351,3 @@ | ||
export { activate, ensureInitialized, fetchAndActivate, fetchConfig, getAll, getBoolean, getNumber, getRemoteConfig, getString, getValue, isSupported, setLogLevel }; | ||
export { activate, ensureInitialized, fetchAndActivate, fetchConfig, getAll, getBoolean, getNumber, getRemoteConfig, getString, getValue, isSupported, setCustomSignals, setLogLevel }; | ||
//# sourceMappingURL=index.esm2017.js.map |
@@ -18,3 +18,3 @@ /** | ||
import { FirebaseApp } from '@firebase/app'; | ||
import { LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types'; | ||
import { CustomSignals, LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types'; | ||
/** | ||
@@ -117,1 +117,12 @@ * | ||
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void; | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>; |
@@ -17,2 +17,3 @@ /** | ||
*/ | ||
import { CustomSignals } from '../public_types'; | ||
/** | ||
@@ -93,2 +94,7 @@ * Defines a client, as in https://en.wikipedia.org/wiki/Client%E2%80%93server_model, for the | ||
eTag?: string; | ||
/** The custom signals stored for the app instance. | ||
* | ||
* <p>Optional in case no custom signals are set for the instance. | ||
*/ | ||
customSignals?: CustomSignals; | ||
} | ||
@@ -95,0 +101,0 @@ /** |
@@ -18,1 +18,4 @@ /** | ||
export declare const RC_COMPONENT_NAME = "remote-config"; | ||
export declare const RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = 100; | ||
export declare const RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH = 250; | ||
export declare const RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH = 500; |
@@ -32,3 +32,4 @@ /** | ||
FETCH_STATUS = "fetch-status", | ||
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable" | ||
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable", | ||
CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = "custom-signal-max-allowed-signals" | ||
} | ||
@@ -60,2 +61,5 @@ interface ErrorParams { | ||
}; | ||
[ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS]: { | ||
maxSignals: number; | ||
}; | ||
} | ||
@@ -62,0 +66,0 @@ export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>; |
@@ -124,2 +124,18 @@ /** | ||
export type LogLevel = 'debug' | 'error' | 'silent'; | ||
/** | ||
* Defines the type for representing custom signals and their values. | ||
* | ||
* <p>The values in CustomSignals must be one of the following types: | ||
* | ||
* <ul> | ||
* <li><code>string</code> | ||
* <li><code>number</code> | ||
* <li><code>null</code> | ||
* </ul> | ||
* | ||
* @public | ||
*/ | ||
export interface CustomSignals { | ||
[key: string]: string | number | null; | ||
} | ||
declare module '@firebase/component' { | ||
@@ -126,0 +142,0 @@ interface NameServiceMapping { |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FetchStatus } from '@firebase/remote-config-types'; | ||
import { FetchStatus, CustomSignals } from '@firebase/remote-config-types'; | ||
import { FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client'; | ||
@@ -33,2 +33,3 @@ import { Storage } from './storage'; | ||
private activeConfig?; | ||
private customSignals?; | ||
/** | ||
@@ -40,2 +41,3 @@ * Memory-only getters | ||
getActiveConfig(): FirebaseRemoteConfigObject | undefined; | ||
getCustomSignals(): CustomSignals | undefined; | ||
/** | ||
@@ -51,2 +53,3 @@ * Read-ahead getter | ||
setActiveConfig(activeConfig: FirebaseRemoteConfigObject): Promise<void>; | ||
setCustomSignals(customSignals: CustomSignals): Promise<void>; | ||
} |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FetchStatus } from '@firebase/remote-config-types'; | ||
import { FetchStatus, CustomSignals } from '@firebase/remote-config-types'; | ||
import { FetchResponse, FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client'; | ||
@@ -43,3 +43,3 @@ /** | ||
*/ | ||
type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata'; | ||
type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata' | 'custom_signals'; | ||
export declare function openDatabase(): Promise<IDBDatabase>; | ||
@@ -73,2 +73,21 @@ /** | ||
deleteThrottleMetadata(): Promise<void>; | ||
getCustomSignals(): Promise<CustomSignals | undefined>; | ||
setCustomSignals(customSignals: CustomSignals): Promise<CustomSignals>; | ||
/** | ||
* Gets a value from the database using the provided transaction. | ||
* | ||
* @param key The key of the value to get. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns The value associated with the key, or undefined if no such value exists. | ||
*/ | ||
getWithTransaction<T>(key: ProjectNamespaceKeyFieldValue, transaction: IDBTransaction): Promise<T | undefined>; | ||
/** | ||
* Sets a value in the database using the provided transaction. | ||
* | ||
* @param key The key of the value to set. | ||
* @param value The value to set. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns A promise that resolves when the operation is complete. | ||
*/ | ||
setWithTransaction<T>(key: ProjectNamespaceKeyFieldValue, value: T, transaction: IDBTransaction): Promise<void>; | ||
get<T>(key: ProjectNamespaceKeyFieldValue): Promise<T | undefined>; | ||
@@ -75,0 +94,0 @@ set<T>(key: ProjectNamespaceKeyFieldValue, value: T): Promise<void>; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
const name = "@firebase/remote-config"; | ||
const version = "0.4.11-canary.cbec4b985"; | ||
const version = "0.4.11-canary.d16a4874b"; | ||
@@ -68,2 +68,5 @@ /** | ||
const RC_COMPONENT_NAME = 'remote-config'; | ||
const RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = 100; | ||
const RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH = 250; | ||
const RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH = 500; | ||
@@ -105,3 +108,4 @@ /** | ||
["fetch-status" /* ErrorCode.FETCH_STATUS */]: 'Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.', | ||
["indexed-db-unavailable" /* ErrorCode.INDEXED_DB_UNAVAILABLE */]: 'Indexed DB is not supported by current browser' | ||
["indexed-db-unavailable" /* ErrorCode.INDEXED_DB_UNAVAILABLE */]: 'Indexed DB is not supported by current browser', | ||
["custom-signal-max-allowed-signals" /* ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS */]: 'Setting more than {$maxSignals} custom signals is not supported.' | ||
}; | ||
@@ -257,2 +261,6 @@ const ERROR_FACTORY = new util.ErrorFactory('remoteconfig' /* service */, 'Remote Config' /* service name */, ERROR_DESCRIPTION_MAP); | ||
}, rc.settings.fetchTimeoutMillis); | ||
const customSignals = rc._storageCache.getCustomSignals(); | ||
if (customSignals) { | ||
rc._logger.debug(`Fetching config with custom signals: ${JSON.stringify(customSignals)}`); | ||
} | ||
// Catches *all* errors thrown by client so status can be set consistently. | ||
@@ -262,3 +270,4 @@ try { | ||
cacheMaxAgeMillis: rc.settings.minimumFetchIntervalMillis, | ||
signal: abortSignal | ||
signal: abortSignal, | ||
customSignals | ||
}); | ||
@@ -387,2 +396,37 @@ await rc._storageCache.setLastFetchStatus('success'); | ||
} | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
async function setCustomSignals(remoteConfig, customSignals) { | ||
const rc = util.getModularInstance(remoteConfig); | ||
if (Object.keys(customSignals).length === 0) { | ||
return; | ||
} | ||
// eslint-disable-next-line guard-for-in | ||
for (const key in customSignals) { | ||
if (key.length > RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH) { | ||
rc._logger.error(`Custom signal key ${key} is too long, max allowed length is ${RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH}.`); | ||
return; | ||
} | ||
const value = customSignals[key]; | ||
if (typeof value === 'string' && | ||
value.length > RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH) { | ||
rc._logger.error(`Value supplied for custom signal ${key} is too long, max allowed length is ${RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH}.`); | ||
return; | ||
} | ||
} | ||
try { | ||
await rc._storageCache.setCustomSignals(customSignals); | ||
} | ||
catch (error) { | ||
rc._logger.error(`Error encountered while setting custom signals: ${error}`); | ||
} | ||
} | ||
@@ -568,3 +612,4 @@ /** | ||
app_id: this.appId, | ||
language_code: getUserLanguage() | ||
language_code: getUserLanguage(), | ||
custom_signals: request.customSignals | ||
/* eslint-enable camelcase */ | ||
@@ -950,6 +995,39 @@ }; | ||
} | ||
async get(key) { | ||
getCustomSignals() { | ||
return this.get('custom_signals'); | ||
} | ||
async setCustomSignals(customSignals) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
const storedSignals = await this.getWithTransaction('custom_signals', transaction); | ||
const combinedSignals = Object.assign(Object.assign({}, storedSignals), customSignals); | ||
// Filter out key-value assignments with null values since they are signals being unset | ||
const updatedSignals = Object.fromEntries(Object.entries(combinedSignals) | ||
.filter(([_, v]) => v !== null) | ||
.map(([k, v]) => { | ||
// Stringify numbers to store a map of string keys and values which can be sent | ||
// as-is in a fetch call. | ||
if (typeof v === 'number') { | ||
return [k, v.toString()]; | ||
} | ||
return [k, v]; | ||
})); | ||
// Throw an error if the number of custom signals to be stored exceeds the limit | ||
if (Object.keys(updatedSignals).length > RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS) { | ||
throw ERROR_FACTORY.create("custom-signal-max-allowed-signals" /* ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS */, { | ||
maxSignals: RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS | ||
}); | ||
} | ||
await this.setWithTransaction('custom_signals', updatedSignals, transaction); | ||
return updatedSignals; | ||
} | ||
/** | ||
* Gets a value from the database using the provided transaction. | ||
* | ||
* @param key The key of the value to get. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns The value associated with the key, or undefined if no such value exists. | ||
*/ | ||
async getWithTransaction(key, transaction) { | ||
return new Promise((resolve, reject) => { | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readonly'); | ||
const objectStore = transaction.objectStore(APP_NAMESPACE_STORE); | ||
@@ -979,6 +1057,12 @@ const compositeKey = this.createCompositeKey(key); | ||
} | ||
async set(key, value) { | ||
const db = await this.openDbPromise; | ||
/** | ||
* Sets a value in the database using the provided transaction. | ||
* | ||
* @param key The key of the value to set. | ||
* @param value The value to set. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns A promise that resolves when the operation is complete. | ||
*/ | ||
async setWithTransaction(key, value, transaction) { | ||
return new Promise((resolve, reject) => { | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
const objectStore = transaction.objectStore(APP_NAMESPACE_STORE); | ||
@@ -1005,2 +1089,12 @@ const compositeKey = this.createCompositeKey(key); | ||
} | ||
async get(key) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readonly'); | ||
return this.getWithTransaction(key, transaction); | ||
} | ||
async set(key, value) { | ||
const db = await this.openDbPromise; | ||
const transaction = db.transaction([APP_NAMESPACE_STORE], 'readwrite'); | ||
return this.setWithTransaction(key, value, transaction); | ||
} | ||
async delete(key) { | ||
@@ -1069,2 +1163,5 @@ const db = await this.openDbPromise; | ||
} | ||
getCustomSignals() { | ||
return this.customSignals; | ||
} | ||
/** | ||
@@ -1077,2 +1174,3 @@ * Read-ahead getter | ||
const activeConfigPromise = this.storage.getActiveConfig(); | ||
const customSignalsPromise = this.storage.getCustomSignals(); | ||
// Note: | ||
@@ -1096,2 +1194,6 @@ // 1. we consistently check for undefined to avoid clobbering defined values | ||
} | ||
const customSignals = await customSignalsPromise; | ||
if (customSignals) { | ||
this.customSignals = customSignals; | ||
} | ||
} | ||
@@ -1113,2 +1215,5 @@ /** | ||
} | ||
async setCustomSignals(customSignals) { | ||
this.customSignals = await this.storage.setCustomSignals(customSignals); | ||
} | ||
} | ||
@@ -1261,3 +1366,4 @@ | ||
exports.isSupported = isSupported; | ||
exports.setCustomSignals = setCustomSignals; | ||
exports.setLogLevel = setLogLevel; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -21,2 +21,19 @@ /** | ||
/** | ||
* Defines the type for representing custom signals and their values. | ||
* | ||
* <p>The values in CustomSignals must be one of the following types: | ||
* | ||
* <ul> | ||
* <li><code>string</code> | ||
* <li><code>number</code> | ||
* <li><code>null</code> | ||
* </ul> | ||
* | ||
* @public | ||
*/ | ||
export declare interface CustomSignals { | ||
[key: string]: string | number | null; | ||
} | ||
/** | ||
* Ensures the last activated config are available to the getters. | ||
@@ -206,2 +223,14 @@ * @param remoteConfig - The {@link RemoteConfig} instance. | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>; | ||
/** | ||
* Defines the log level to use. | ||
@@ -208,0 +237,0 @@ * |
@@ -21,2 +21,19 @@ /** | ||
/** | ||
* Defines the type for representing custom signals and their values. | ||
* | ||
* <p>The values in CustomSignals must be one of the following types: | ||
* | ||
* <ul> | ||
* <li><code>string</code> | ||
* <li><code>number</code> | ||
* <li><code>null</code> | ||
* </ul> | ||
* | ||
* @public | ||
*/ | ||
export declare interface CustomSignals { | ||
[key: string]: string | number | null; | ||
} | ||
/** | ||
* Ensures the last activated config are available to the getters. | ||
@@ -206,2 +223,14 @@ * @param remoteConfig - The {@link RemoteConfig} instance. | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>; | ||
/** | ||
* Defines the log level to use. | ||
@@ -208,0 +237,0 @@ * |
@@ -18,3 +18,3 @@ /** | ||
import { FirebaseApp } from '@firebase/app'; | ||
import { LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types'; | ||
import { CustomSignals, LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types'; | ||
/** | ||
@@ -117,1 +117,12 @@ * | ||
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void; | ||
/** | ||
* Sets the custom signals for the app instance. | ||
* | ||
* @param remoteConfig - The {@link RemoteConfig} instance. | ||
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If | ||
* a key already exists, the value is overwritten. Setting the value of a custom signal to null | ||
* unsets the signal. The signals will be persisted locally on the client. | ||
* | ||
* @public | ||
*/ | ||
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>; |
@@ -17,2 +17,3 @@ /** | ||
*/ | ||
import { CustomSignals } from '../public_types'; | ||
/** | ||
@@ -93,2 +94,7 @@ * Defines a client, as in https://en.wikipedia.org/wiki/Client%E2%80%93server_model, for the | ||
eTag?: string; | ||
/** The custom signals stored for the app instance. | ||
* | ||
* <p>Optional in case no custom signals are set for the instance. | ||
*/ | ||
customSignals?: CustomSignals; | ||
} | ||
@@ -95,0 +101,0 @@ /** |
@@ -18,1 +18,4 @@ /** | ||
export declare const RC_COMPONENT_NAME = "remote-config"; | ||
export declare const RC_CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = 100; | ||
export declare const RC_CUSTOM_SIGNAL_KEY_MAX_LENGTH = 250; | ||
export declare const RC_CUSTOM_SIGNAL_VALUE_MAX_LENGTH = 500; |
@@ -32,3 +32,4 @@ /** | ||
FETCH_STATUS = "fetch-status", | ||
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable" | ||
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable", | ||
CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS = "custom-signal-max-allowed-signals" | ||
} | ||
@@ -60,2 +61,5 @@ interface ErrorParams { | ||
}; | ||
[ErrorCode.CUSTOM_SIGNAL_MAX_ALLOWED_SIGNALS]: { | ||
maxSignals: number; | ||
}; | ||
} | ||
@@ -62,0 +66,0 @@ export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>; |
@@ -124,2 +124,18 @@ /** | ||
export type LogLevel = 'debug' | 'error' | 'silent'; | ||
/** | ||
* Defines the type for representing custom signals and their values. | ||
* | ||
* <p>The values in CustomSignals must be one of the following types: | ||
* | ||
* <ul> | ||
* <li><code>string</code> | ||
* <li><code>number</code> | ||
* <li><code>null</code> | ||
* </ul> | ||
* | ||
* @public | ||
*/ | ||
export interface CustomSignals { | ||
[key: string]: string | number | null; | ||
} | ||
declare module '@firebase/component' { | ||
@@ -126,0 +142,0 @@ interface NameServiceMapping { |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FetchStatus } from '@firebase/remote-config-types'; | ||
import { FetchStatus, CustomSignals } from '@firebase/remote-config-types'; | ||
import { FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client'; | ||
@@ -33,2 +33,3 @@ import { Storage } from './storage'; | ||
private activeConfig?; | ||
private customSignals?; | ||
/** | ||
@@ -40,2 +41,3 @@ * Memory-only getters | ||
getActiveConfig(): FirebaseRemoteConfigObject | undefined; | ||
getCustomSignals(): CustomSignals | undefined; | ||
/** | ||
@@ -51,2 +53,3 @@ * Read-ahead getter | ||
setActiveConfig(activeConfig: FirebaseRemoteConfigObject): Promise<void>; | ||
setCustomSignals(customSignals: CustomSignals): Promise<void>; | ||
} |
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
import { FetchStatus } from '@firebase/remote-config-types'; | ||
import { FetchStatus, CustomSignals } from '@firebase/remote-config-types'; | ||
import { FetchResponse, FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client'; | ||
@@ -43,3 +43,3 @@ /** | ||
*/ | ||
type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata'; | ||
type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata' | 'custom_signals'; | ||
export declare function openDatabase(): Promise<IDBDatabase>; | ||
@@ -73,2 +73,21 @@ /** | ||
deleteThrottleMetadata(): Promise<void>; | ||
getCustomSignals(): Promise<CustomSignals | undefined>; | ||
setCustomSignals(customSignals: CustomSignals): Promise<CustomSignals>; | ||
/** | ||
* Gets a value from the database using the provided transaction. | ||
* | ||
* @param key The key of the value to get. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns The value associated with the key, or undefined if no such value exists. | ||
*/ | ||
getWithTransaction<T>(key: ProjectNamespaceKeyFieldValue, transaction: IDBTransaction): Promise<T | undefined>; | ||
/** | ||
* Sets a value in the database using the provided transaction. | ||
* | ||
* @param key The key of the value to set. | ||
* @param value The value to set. | ||
* @param transaction The transaction to use for the operation. | ||
* @returns A promise that resolves when the operation is complete. | ||
*/ | ||
setWithTransaction<T>(key: ProjectNamespaceKeyFieldValue, value: T, transaction: IDBTransaction): Promise<void>; | ||
get<T>(key: ProjectNamespaceKeyFieldValue): Promise<T | undefined>; | ||
@@ -75,0 +94,0 @@ set<T>(key: ProjectNamespaceKeyFieldValue, value: T): Promise<void>; |
{ | ||
"name": "@firebase/remote-config", | ||
"version": "0.4.11-canary.cbec4b985", | ||
"version": "0.4.11-canary.d16a4874b", | ||
"description": "The Remote Config package of the Firebase JS SDK", | ||
@@ -40,9 +40,9 @@ "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)", | ||
"peerDependencies": { | ||
"@firebase/app": "0.10.16-canary.cbec4b985" | ||
"@firebase/app": "0.10.17-canary.d16a4874b" | ||
}, | ||
"dependencies": { | ||
"@firebase/installations": "0.6.11-canary.cbec4b985", | ||
"@firebase/logger": "0.4.4-canary.cbec4b985", | ||
"@firebase/util": "1.10.2-canary.cbec4b985", | ||
"@firebase/component": "0.6.11-canary.cbec4b985", | ||
"@firebase/installations": "0.6.11-canary.d16a4874b", | ||
"@firebase/logger": "0.4.4-canary.d16a4874b", | ||
"@firebase/util": "1.10.2-canary.d16a4874b", | ||
"@firebase/component": "0.6.11-canary.d16a4874b", | ||
"tslib": "^2.1.0" | ||
@@ -52,3 +52,3 @@ }, | ||
"devDependencies": { | ||
"@firebase/app": "0.10.16-canary.cbec4b985", | ||
"@firebase/app": "0.10.17-canary.d16a4874b", | ||
"rollup": "2.79.1", | ||
@@ -55,0 +55,0 @@ "rollup-plugin-typescript2": "0.31.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
395718
5433
+ Added@firebase/app@0.10.17-canary.d16a4874b(transitive)
+ Added@firebase/component@0.6.11-canary.d16a4874b(transitive)
+ Added@firebase/installations@0.6.11-canary.d16a4874b(transitive)
+ Added@firebase/logger@0.4.4-canary.d16a4874b(transitive)
+ Added@firebase/util@1.10.2-canary.d16a4874b(transitive)
- Removed@firebase/app@0.10.16-canary.cbec4b985(transitive)
- Removed@firebase/component@0.6.11-canary.cbec4b985(transitive)
- Removed@firebase/installations@0.6.11-canary.cbec4b985(transitive)
- Removed@firebase/logger@0.4.4-canary.cbec4b985(transitive)
- Removed@firebase/util@1.10.2-canary.cbec4b985(transitive)