Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"type":"module"}

View file

@ -0,0 +1,115 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
import { LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types';
/**
*
* @param app - The {@link @firebase/app#FirebaseApp} instance.
* @returns A {@link RemoteConfig} instance.
*
* @public
*/
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
/**
* Makes the last fetched config available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Ensures the last activated config are available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` that resolves when the last activated config is available to the getters.
* @public
*/
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
/**
* Fetches and caches configuration from the Remote Config service.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @public
*/
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
/**
* Gets all config.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns All config.
*
* @public
*/
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
/**
* Gets the value for the given key as a boolean.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a boolean.
* @public
*/
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
/**
* Gets the value for the given key as a number.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a number.
*
* @public
*/
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
/**
* Gets the value for the given key as a string.
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a string.
*
* @public
*/
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
/**
* Gets the {@link Value} for the given key.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key.
*
* @public
*/
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
/**
* Defines the log level to use.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param logLevel - The log level to set.
*
* @public
*/
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;

View file

@ -0,0 +1,40 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { RemoteConfig } from './public_types';
/**
*
* Performs fetch and activate operations, as a convenience.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* This method provides two different checks:
*
* 1. Check if IndexedDB exists in the browser environment.
* 2. Check if the current browser context allows IndexedDB `open()` calls.
*
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
* can be initialized in this environment, or false if it cannot.
* @public
*/
export declare function isSupported(): Promise<boolean>;

View file

@ -0,0 +1,45 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { StorageCache } from '../storage/storage_cache';
import { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
import { Storage } from '../storage/storage';
import { Logger } from '@firebase/logger';
/**
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
*
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
* Cache API doesn't support matching entries by time.
*/
export declare class CachingClient implements RemoteConfigFetchClient {
private readonly client;
private readonly storage;
private readonly storageCache;
private readonly logger;
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
/**
* Returns true if the age of the cached fetched configs is less than or equal to
* {@link Settings#minimumFetchIntervalInSeconds}.
*
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
* native Fetch API.
*
* <p>Visible for testing.
*/
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
fetch(request: FetchRequest): Promise<FetchResponse>;
}

View file

@ -0,0 +1,123 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/**
* Defines a client, as in https://en.wikipedia.org/wiki/Client%E2%80%93server_model, for the
* Remote Config server (https://firebase.google.com/docs/reference/remote-config/rest).
*
* <p>Abstracts throttle, response cache and network implementation details.
*
* <p>Modeled after the native {@link GlobalFetch} interface, which is relatively modern and
* convenient, but simplified for Remote Config's use case.
*
* Disambiguation: {@link GlobalFetch} interface and the Remote Config service define "fetch"
* methods. The RestClient uses the former to make HTTP calls. This interface abstracts the latter.
*/
export interface RemoteConfigFetchClient {
/**
* @throws if response status is not 200 or 304.
*/
fetch(request: FetchRequest): Promise<FetchResponse>;
}
/**
* Defines a self-descriptive reference for config key-value pairs.
*/
export interface FirebaseRemoteConfigObject {
[key: string]: string;
}
/**
* Shims a minimal AbortSignal.
*
* <p>AbortController's AbortSignal conveniently decouples fetch timeout logic from other aspects
* of networking, such as retries. Firebase doesn't use AbortController enough to justify a
* polyfill recommendation, like we do with the Fetch API, but this minimal shim can easily be
* swapped out if/when we do.
*/
export declare class RemoteConfigAbortSignal {
listeners: Array<() => void>;
addEventListener(listener: () => void): void;
abort(): void;
}
/**
* Defines per-request inputs for the Remote Config fetch request.
*
* <p>Modeled after the native {@link Request} interface, but simplified for Remote Config's
* use case.
*/
export interface FetchRequest {
/**
* Uses cached config if it is younger than this age.
*
* <p>Required because it's defined by settings, which always have a value.
*
* <p>Comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the native
* Fetch API.
*/
cacheMaxAgeMillis: number;
/**
* An event bus for the signal to abort a request.
*
* <p>Required because all requests should be abortable.
*
* <p>Comparable to the native
* Fetch API's "signal" field on its request configuration object
* https://fetch.spec.whatwg.org/#dom-requestinit-signal.
*
* <p>Disambiguation: Remote Config commonly refers to API inputs as
* "signals". See the private ConfigFetchRequestBody interface for those:
* http://google3/firebase/remote_config/web/src/core/rest_client.ts?l=14&rcl=255515243.
*/
signal: RemoteConfigAbortSignal;
/**
* The ETag header value from the last response.
*
* <p>Optional in case this is the first request.
*
* <p>Comparable to passing `headers = { 'If-None-Match': <eTag> }` to the native Fetch API.
*/
eTag?: string;
}
/**
* Defines a successful response (200 or 304).
*
* <p>Modeled after the native {@link Response} interface, but simplified for Remote Config's
* use case.
*/
export interface FetchResponse {
/**
* The HTTP status, which is useful for differentiating success responses with data from
* those without.
*
* <p>{@link RemoteConfigClient} is modeled after the native {@link GlobalFetch} interface, so
* HTTP status is first-class.
*
* <p>Disambiguation: the fetch response returns a legacy "state" value that is redundant with the
* HTTP status code. The former is normalized into the latter.
*/
status: number;
/**
* Defines the ETag response header value.
*
* <p>Only defined for 200 and 304 responses.
*/
eTag?: string;
/**
* Defines the map of parameters returned as "entries" in the fetch response body.
*
* <p>Only defined for 200 responses.
*/
config?: FirebaseRemoteConfigObject;
}

View file

@ -0,0 +1,40 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
import { _FirebaseInstallationsInternal } from '@firebase/installations';
/**
* Implements the Client abstraction for the Remote Config REST API.
*/
export declare class RestClient implements RemoteConfigFetchClient {
private readonly firebaseInstallations;
private readonly sdkVersion;
private readonly namespace;
private readonly projectId;
private readonly apiKey;
private readonly appId;
constructor(firebaseInstallations: _FirebaseInstallationsInternal, sdkVersion: string, namespace: string, projectId: string, apiKey: string, appId: string);
/**
* Fetches from the Remote Config REST API.
*
* @throws a {@link ErrorCode.FETCH_NETWORK} error if {@link GlobalFetch#fetch} can't
* connect to the network.
* @throws a {@link ErrorCode.FETCH_PARSE} error if {@link Response#json} can't parse the
* fetch response.
* @throws a {@link ErrorCode.FETCH_STATUS} error if the service returns an HTTP error status.
*/
fetch(request: FetchRequest): Promise<FetchResponse>;
}

View file

@ -0,0 +1,49 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { RemoteConfigAbortSignal, RemoteConfigFetchClient, FetchResponse, FetchRequest } from './remote_config_fetch_client';
import { ThrottleMetadata, Storage } from '../storage/storage';
/**
* Supports waiting on a backoff by:
*
* <ul>
* <li>Promisifying setTimeout, so we can set a timeout in our Promise chain</li>
* <li>Listening on a signal bus for abort events, just like the Fetch API</li>
* <li>Failing in the same way the Fetch API fails, so timing out a live request and a throttled
* request appear the same.</li>
* </ul>
*
* <p>Visible for testing.
*/
export declare function setAbortableTimeout(signal: RemoteConfigAbortSignal, throttleEndTimeMillis: number): Promise<void>;
/**
* Decorates a Client with retry logic.
*
* <p>Comparable to CachingClient, but uses backoff logic instead of cache max age and doesn't cache
* responses (because the SDK has no use for error responses).
*/
export declare class RetryingClient implements RemoteConfigFetchClient {
private readonly client;
private readonly storage;
constructor(client: RemoteConfigFetchClient, storage: Storage);
fetch(request: FetchRequest): Promise<FetchResponse>;
/**
* A recursive helper for attempting a fetch request repeatedly.
*
* @throws any non-retriable errors.
*/
attemptFetch(request: FetchRequest, { throttleEndTimeMillis, backoffCount }: ThrottleMetadata): Promise<FetchResponse>;
}

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 declare const RC_COMPONENT_NAME = "remote-config";

View file

@ -0,0 +1,62 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { ErrorFactory } from '@firebase/util';
export declare const enum ErrorCode {
REGISTRATION_WINDOW = "registration-window",
REGISTRATION_PROJECT_ID = "registration-project-id",
REGISTRATION_API_KEY = "registration-api-key",
REGISTRATION_APP_ID = "registration-app-id",
STORAGE_OPEN = "storage-open",
STORAGE_GET = "storage-get",
STORAGE_SET = "storage-set",
STORAGE_DELETE = "storage-delete",
FETCH_NETWORK = "fetch-client-network",
FETCH_TIMEOUT = "fetch-timeout",
FETCH_THROTTLE = "fetch-throttle",
FETCH_PARSE = "fetch-client-parse",
FETCH_STATUS = "fetch-status",
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable"
}
interface ErrorParams {
[ErrorCode.STORAGE_OPEN]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_GET]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_SET]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_DELETE]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.FETCH_NETWORK]: {
originalErrorMessage: string;
};
[ErrorCode.FETCH_THROTTLE]: {
throttleEndTimeMillis: number;
};
[ErrorCode.FETCH_PARSE]: {
originalErrorMessage: string;
};
[ErrorCode.FETCH_STATUS]: {
httpStatus: number;
};
}
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
export declare function hasErrorCode(e: Error, errorCode: ErrorCode): boolean;
export {};

View file

@ -0,0 +1,14 @@
/**
* The Firebase Remote Config Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
declare global {
interface Window {
FIREBASE_REMOTE_CONFIG_URL_BASE: string;
}
}
export * from './api';
export * from './api2';
export * from './public_types';

View file

@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/**
* Attempts to get the most accurate browser language setting.
*
* <p>Adapted from getUserLanguage in packages/auth/src/utils.js for TypeScript.
*
* <p>Defers default language specification to server logic for consistency.
*
* @param navigatorLanguage Enables tests to override read-only {@link NavigatorLanguage}.
*/
export declare function getUserLanguage(navigatorLanguage?: NavigatorLanguage): string;

View file

@ -0,0 +1,128 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
/**
* The Firebase Remote Config service interface.
*
* @public
*/
export interface RemoteConfig {
/**
* The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
*/
app: FirebaseApp;
/**
* Defines configuration for the Remote Config SDK.
*/
settings: RemoteConfigSettings;
/**
* Object containing default values for configs.
*/
defaultConfig: {
[key: string]: string | number | boolean;
};
/**
* The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
* the {@link RemoteConfig} instance either hasn't fetched or initialization
* is incomplete.
*/
fetchTimeMillis: number;
/**
* The status of the last fetch <i>attempt</i>.
*/
lastFetchStatus: FetchStatus;
}
/**
* 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 fetched config.</li>
* </ul>
*
* @public
*/
export declare type ValueSource = 'static' | 'default' | 'remote';
/**
* Wraps a value with metadata and type-safe getters.
*
* @public
*/
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;
}
/**
* Defines configuration options for the Remote Config SDK.
*
* @public
*/
export interface RemoteConfigSettings {
/**
* Defines the maximum age in milliseconds of an entry in the config cache before
* it is considered stale. Defaults to 43200000 (Twelve hours).
*/
minimumFetchIntervalMillis: number;
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching
* configuration from the Remote Config server. Defaults to 60000 (One minute).
*/
fetchTimeoutMillis: number;
}
/**
* Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
*
* <ul>
* <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
* to fetch config, or that SDK initialization is incomplete.</li>
* <li>"success" indicates the last attempt succeeded.</li>
* <li>"failure" indicates the last attempt failed.</li>
* <li>"throttle" indicates the last attempt was rate-limited.</li>
* </ul>
*
* @public
*/
export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
/**
* Defines levels of Remote Config logging.
*
* @public
*/
export declare type LogLevel = 'debug' | 'error' | 'silent';
declare module '@firebase/component' {
interface NameServiceMapping {
'remote-config': RemoteConfig;
}
}

View file

@ -0,0 +1,2 @@
import '@firebase/installations';
export declare function registerRemoteConfig(): void;

View file

@ -0,0 +1,79 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
import { RemoteConfig as RemoteConfigType, FetchStatus, RemoteConfigSettings } from './public_types';
import { StorageCache } from './storage/storage_cache';
import { RemoteConfigFetchClient } from './client/remote_config_fetch_client';
import { Storage } from './storage/storage';
import { Logger } from '@firebase/logger';
/**
* Encapsulates business logic mapping network and storage dependencies to the public SDK API.
*
* See {@link https://github.com/firebase/firebase-js-sdk/blob/main/packages/firebase/index.d.ts|interface documentation} for method descriptions.
*/
export declare class RemoteConfig implements RemoteConfigType {
readonly app: FirebaseApp;
/**
* @internal
*/
readonly _client: RemoteConfigFetchClient;
/**
* @internal
*/
readonly _storageCache: StorageCache;
/**
* @internal
*/
readonly _storage: Storage;
/**
* @internal
*/
readonly _logger: Logger;
/**
* Tracks completion of initialization promise.
* @internal
*/
_isInitializationComplete: boolean;
/**
* De-duplicates initialization calls.
* @internal
*/
_initializePromise?: Promise<void>;
settings: RemoteConfigSettings;
defaultConfig: {
[key: string]: string | number | boolean;
};
get fetchTimeMillis(): number;
get lastFetchStatus(): FetchStatus;
constructor(app: FirebaseApp,
/**
* @internal
*/
_client: RemoteConfigFetchClient,
/**
* @internal
*/
_storageCache: StorageCache,
/**
* @internal
*/
_storage: Storage,
/**
* @internal
*/
_logger: Logger);
}

View file

@ -0,0 +1,76 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchStatus } from '@firebase/remote-config-types';
import { FetchResponse, FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client';
/**
* A general-purpose store keyed by app + namespace + {@link
* ProjectNamespaceKeyFieldValue}.
*
* <p>The Remote Config SDK can be used with multiple app installations, and each app can interact
* with multiple namespaces, so this store uses app (ID + name) and namespace as common parent keys
* for a set of key-value pairs. See {@link Storage#createCompositeKey}.
*
* <p>Visible for testing.
*/
export declare const APP_NAMESPACE_STORE = "app_namespace_store";
/**
* Encapsulates metadata concerning throttled fetch requests.
*/
export interface ThrottleMetadata {
backoffCount: number;
throttleEndTimeMillis: number;
}
/**
* Provides type-safety for the "key" field used by {@link APP_NAMESPACE_STORE}.
*
* <p>This seems like a small price to avoid potentially subtle bugs caused by a typo.
*/
declare type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata';
export declare function openDatabase(): Promise<IDBDatabase>;
/**
* Abstracts data persistence.
*/
export declare class Storage {
private readonly appId;
private readonly appName;
private readonly namespace;
private readonly openDbPromise;
/**
* @param appId enables storage segmentation by app (ID + name).
* @param appName enables storage segmentation by app (ID + name).
* @param namespace enables storage segmentation by namespace.
*/
constructor(appId: string, appName: string, namespace: string, openDbPromise?: Promise<IDBDatabase>);
getLastFetchStatus(): Promise<FetchStatus | undefined>;
setLastFetchStatus(status: FetchStatus): Promise<void>;
getLastSuccessfulFetchTimestampMillis(): Promise<number | undefined>;
setLastSuccessfulFetchTimestampMillis(timestamp: number): Promise<void>;
getLastSuccessfulFetchResponse(): Promise<FetchResponse | undefined>;
setLastSuccessfulFetchResponse(response: FetchResponse): Promise<void>;
getActiveConfig(): Promise<FirebaseRemoteConfigObject | undefined>;
setActiveConfig(config: FirebaseRemoteConfigObject): Promise<void>;
getActiveConfigEtag(): Promise<string | undefined>;
setActiveConfigEtag(etag: string): Promise<void>;
getThrottleMetadata(): Promise<ThrottleMetadata | undefined>;
setThrottleMetadata(metadata: ThrottleMetadata): Promise<void>;
deleteThrottleMetadata(): Promise<void>;
get<T>(key: ProjectNamespaceKeyFieldValue): Promise<T | undefined>;
set<T>(key: ProjectNamespaceKeyFieldValue, value: T): Promise<void>;
delete(key: ProjectNamespaceKeyFieldValue): Promise<void>;
createCompositeKey(key: ProjectNamespaceKeyFieldValue): string;
}
export {};

View file

@ -0,0 +1,48 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchStatus } from '@firebase/remote-config-types';
import { FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client';
import { Storage } from './storage';
/**
* A memory cache layer over storage to support the SDK's synchronous read requirements.
*/
export declare class StorageCache {
private readonly storage;
constructor(storage: Storage);
/**
* Memory caches.
*/
private lastFetchStatus?;
private lastSuccessfulFetchTimestampMillis?;
private activeConfig?;
/**
* Memory-only getters
*/
getLastFetchStatus(): FetchStatus | undefined;
getLastSuccessfulFetchTimestampMillis(): number | undefined;
getActiveConfig(): FirebaseRemoteConfigObject | undefined;
/**
* Read-ahead getter
*/
loadFromStorage(): Promise<void>;
/**
* Write-through setters
*/
setLastFetchStatus(status: FetchStatus): Promise<void>;
setLastSuccessfulFetchTimestampMillis(timestampMillis: number): Promise<void>;
setActiveConfig(activeConfig: FirebaseRemoteConfigObject): Promise<void>;
}

View file

@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Value as ValueType, ValueSource } from '@firebase/remote-config-types';
export declare class Value implements ValueType {
private readonly _source;
private readonly _value;
constructor(_source: ValueSource, _value?: string);
asString(): string;
asBoolean(): boolean;
asNumber(): number;
getSource(): ValueSource;
}

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 {};

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

1248
node_modules/@firebase/remote-config/dist/index.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,254 @@
/**
* The Firebase Remote Config Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
import { FirebaseApp } from '@firebase/app';
/**
* Makes the last fetched config available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Ensures the last activated config are available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` that resolves when the last activated config is available to the getters.
* @public
*/
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
/**
*
* Performs fetch and activate operations, as a convenience.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Fetches and caches configuration from the Remote Config service.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @public
*/
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
/**
* Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
*
* <ul>
* <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
* to fetch config, or that SDK initialization is incomplete.</li>
* <li>"success" indicates the last attempt succeeded.</li>
* <li>"failure" indicates the last attempt failed.</li>
* <li>"throttle" indicates the last attempt was rate-limited.</li>
* </ul>
*
* @public
*/
export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
/**
* Gets all config.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns All config.
*
* @public
*/
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
/**
* Gets the value for the given key as a boolean.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a boolean.
* @public
*/
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
/**
* Gets the value for the given key as a number.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a number.
*
* @public
*/
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
/**
*
* @param app - The {@link @firebase/app#FirebaseApp} instance.
* @returns A {@link RemoteConfig} instance.
*
* @public
*/
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
/**
* Gets the value for the given key as a string.
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a string.
*
* @public
*/
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
/**
* Gets the {@link Value} for the given key.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key.
*
* @public
*/
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
/**
* This method provides two different checks:
*
* 1. Check if IndexedDB exists in the browser environment.
* 2. Check if the current browser context allows IndexedDB `open()` calls.
*
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
* can be initialized in this environment, or false if it cannot.
* @public
*/
export declare function isSupported(): Promise<boolean>;
/**
* Defines levels of Remote Config logging.
*
* @public
*/
export declare type LogLevel = 'debug' | 'error' | 'silent';
/**
* The Firebase Remote Config service interface.
*
* @public
*/
export declare interface RemoteConfig {
/**
* The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
*/
app: FirebaseApp;
/**
* Defines configuration for the Remote Config SDK.
*/
settings: RemoteConfigSettings;
/**
* Object containing default values for configs.
*/
defaultConfig: {
[key: string]: string | number | boolean;
};
/**
* The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
* the {@link RemoteConfig} instance either hasn't fetched or initialization
* is incomplete.
*/
fetchTimeMillis: number;
/**
* The status of the last fetch <i>attempt</i>.
*/
lastFetchStatus: FetchStatus;
}
/**
* Defines configuration options for the Remote Config SDK.
*
* @public
*/
export declare interface RemoteConfigSettings {
/**
* Defines the maximum age in milliseconds of an entry in the config cache before
* it is considered stale. Defaults to 43200000 (Twelve hours).
*/
minimumFetchIntervalMillis: number;
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching
* configuration from the Remote Config server. Defaults to 60000 (One minute).
*/
fetchTimeoutMillis: number;
}
/**
* Defines the log level to use.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param logLevel - The log level to set.
*
* @public
*/
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;
/**
* Wraps a value with metadata and type-safe getters.
*
* @public
*/
export declare 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 fetched config.</li>
* </ul>
*
* @public
*/
export declare type ValueSource = 'static' | 'default' | 'remote';
export { }

View file

@ -0,0 +1,254 @@
/**
* The Firebase Remote Config Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
import { FirebaseApp } from '@firebase/app';
/**
* Makes the last fetched config available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Ensures the last activated config are available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` that resolves when the last activated config is available to the getters.
* @public
*/
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
/**
*
* Performs fetch and activate operations, as a convenience.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Fetches and caches configuration from the Remote Config service.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @public
*/
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
/**
* Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
*
* <ul>
* <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
* to fetch config, or that SDK initialization is incomplete.</li>
* <li>"success" indicates the last attempt succeeded.</li>
* <li>"failure" indicates the last attempt failed.</li>
* <li>"throttle" indicates the last attempt was rate-limited.</li>
* </ul>
*
* @public
*/
export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
/**
* Gets all config.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns All config.
*
* @public
*/
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
/**
* Gets the value for the given key as a boolean.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a boolean.
* @public
*/
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
/**
* Gets the value for the given key as a number.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a number.
*
* @public
*/
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
/**
*
* @param app - The {@link @firebase/app#FirebaseApp} instance.
* @returns A {@link RemoteConfig} instance.
*
* @public
*/
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
/**
* Gets the value for the given key as a string.
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a string.
*
* @public
*/
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
/**
* Gets the {@link Value} for the given key.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key.
*
* @public
*/
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
/**
* This method provides two different checks:
*
* 1. Check if IndexedDB exists in the browser environment.
* 2. Check if the current browser context allows IndexedDB `open()` calls.
*
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
* can be initialized in this environment, or false if it cannot.
* @public
*/
export declare function isSupported(): Promise<boolean>;
/**
* Defines levels of Remote Config logging.
*
* @public
*/
export declare type LogLevel = 'debug' | 'error' | 'silent';
/**
* The Firebase Remote Config service interface.
*
* @public
*/
export declare interface RemoteConfig {
/**
* The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
*/
app: FirebaseApp;
/**
* Defines configuration for the Remote Config SDK.
*/
settings: RemoteConfigSettings;
/**
* Object containing default values for configs.
*/
defaultConfig: {
[key: string]: string | number | boolean;
};
/**
* The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
* the {@link RemoteConfig} instance either hasn't fetched or initialization
* is incomplete.
*/
fetchTimeMillis: number;
/**
* The status of the last fetch <i>attempt</i>.
*/
lastFetchStatus: FetchStatus;
}
/**
* Defines configuration options for the Remote Config SDK.
*
* @public
*/
export declare interface RemoteConfigSettings {
/**
* Defines the maximum age in milliseconds of an entry in the config cache before
* it is considered stale. Defaults to 43200000 (Twelve hours).
*/
minimumFetchIntervalMillis: number;
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching
* configuration from the Remote Config server. Defaults to 60000 (One minute).
*/
fetchTimeoutMillis: number;
}
/**
* Defines the log level to use.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param logLevel - The log level to set.
*
* @public
*/
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: LogLevel): void;
/**
* Wraps a value with metadata and type-safe getters.
*
* @public
*/
export declare 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 fetched config.</li>
* </ul>
*
* @public
*/
export declare type ValueSource = 'static' | 'default' | 'remote';
export { }

115
node_modules/@firebase/remote-config/dist/src/api.d.ts generated vendored Normal file
View file

@ -0,0 +1,115 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
import { LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types';
/**
*
* @param app - The {@link @firebase/app#FirebaseApp} instance.
* @returns A {@link RemoteConfig} instance.
*
* @public
*/
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
/**
* Makes the last fetched config available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* Ensures the last activated config are available to the getters.
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` that resolves when the last activated config is available to the getters.
* @public
*/
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
/**
* Fetches and caches configuration from the Remote Config service.
* @param remoteConfig - The {@link RemoteConfig} instance.
* @public
*/
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
/**
* Gets all config.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @returns All config.
*
* @public
*/
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
/**
* Gets the value for the given key as a boolean.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a boolean.
* @public
*/
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
/**
* Gets the value for the given key as a number.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a number.
*
* @public
*/
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
/**
* Gets the value for the given key as a string.
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key as a string.
*
* @public
*/
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
/**
* Gets the {@link Value} for the given key.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param key - The name of the parameter.
*
* @returns The value for the given key.
*
* @public
*/
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
/**
* Defines the log level to use.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
* @param logLevel - The log level to set.
*
* @public
*/
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;

View file

@ -0,0 +1,40 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { RemoteConfig } from './public_types';
/**
*
* Performs fetch and activate operations, as a convenience.
*
* @param remoteConfig - The {@link RemoteConfig} instance.
*
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the `Promise` will resolve to false.
*
* @public
*/
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
/**
* This method provides two different checks:
*
* 1. Check if IndexedDB exists in the browser environment.
* 2. Check if the current browser context allows IndexedDB `open()` calls.
*
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
* can be initialized in this environment, or false if it cannot.
* @public
*/
export declare function isSupported(): Promise<boolean>;

View file

@ -0,0 +1,45 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { StorageCache } from '../storage/storage_cache';
import { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
import { Storage } from '../storage/storage';
import { Logger } from '@firebase/logger';
/**
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
*
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
* Cache API doesn't support matching entries by time.
*/
export declare class CachingClient implements RemoteConfigFetchClient {
private readonly client;
private readonly storage;
private readonly storageCache;
private readonly logger;
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
/**
* Returns true if the age of the cached fetched configs is less than or equal to
* {@link Settings#minimumFetchIntervalInSeconds}.
*
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
* native Fetch API.
*
* <p>Visible for testing.
*/
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
fetch(request: FetchRequest): Promise<FetchResponse>;
}

View file

@ -0,0 +1,123 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/**
* Defines a client, as in https://en.wikipedia.org/wiki/Client%E2%80%93server_model, for the
* Remote Config server (https://firebase.google.com/docs/reference/remote-config/rest).
*
* <p>Abstracts throttle, response cache and network implementation details.
*
* <p>Modeled after the native {@link GlobalFetch} interface, which is relatively modern and
* convenient, but simplified for Remote Config's use case.
*
* Disambiguation: {@link GlobalFetch} interface and the Remote Config service define "fetch"
* methods. The RestClient uses the former to make HTTP calls. This interface abstracts the latter.
*/
export interface RemoteConfigFetchClient {
/**
* @throws if response status is not 200 or 304.
*/
fetch(request: FetchRequest): Promise<FetchResponse>;
}
/**
* Defines a self-descriptive reference for config key-value pairs.
*/
export interface FirebaseRemoteConfigObject {
[key: string]: string;
}
/**
* Shims a minimal AbortSignal.
*
* <p>AbortController's AbortSignal conveniently decouples fetch timeout logic from other aspects
* of networking, such as retries. Firebase doesn't use AbortController enough to justify a
* polyfill recommendation, like we do with the Fetch API, but this minimal shim can easily be
* swapped out if/when we do.
*/
export declare class RemoteConfigAbortSignal {
listeners: Array<() => void>;
addEventListener(listener: () => void): void;
abort(): void;
}
/**
* Defines per-request inputs for the Remote Config fetch request.
*
* <p>Modeled after the native {@link Request} interface, but simplified for Remote Config's
* use case.
*/
export interface FetchRequest {
/**
* Uses cached config if it is younger than this age.
*
* <p>Required because it's defined by settings, which always have a value.
*
* <p>Comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the native
* Fetch API.
*/
cacheMaxAgeMillis: number;
/**
* An event bus for the signal to abort a request.
*
* <p>Required because all requests should be abortable.
*
* <p>Comparable to the native
* Fetch API's "signal" field on its request configuration object
* https://fetch.spec.whatwg.org/#dom-requestinit-signal.
*
* <p>Disambiguation: Remote Config commonly refers to API inputs as
* "signals". See the private ConfigFetchRequestBody interface for those:
* http://google3/firebase/remote_config/web/src/core/rest_client.ts?l=14&rcl=255515243.
*/
signal: RemoteConfigAbortSignal;
/**
* The ETag header value from the last response.
*
* <p>Optional in case this is the first request.
*
* <p>Comparable to passing `headers = { 'If-None-Match': <eTag> }` to the native Fetch API.
*/
eTag?: string;
}
/**
* Defines a successful response (200 or 304).
*
* <p>Modeled after the native {@link Response} interface, but simplified for Remote Config's
* use case.
*/
export interface FetchResponse {
/**
* The HTTP status, which is useful for differentiating success responses with data from
* those without.
*
* <p>{@link RemoteConfigClient} is modeled after the native {@link GlobalFetch} interface, so
* HTTP status is first-class.
*
* <p>Disambiguation: the fetch response returns a legacy "state" value that is redundant with the
* HTTP status code. The former is normalized into the latter.
*/
status: number;
/**
* Defines the ETag response header value.
*
* <p>Only defined for 200 and 304 responses.
*/
eTag?: string;
/**
* Defines the map of parameters returned as "entries" in the fetch response body.
*
* <p>Only defined for 200 responses.
*/
config?: FirebaseRemoteConfigObject;
}

View file

@ -0,0 +1,40 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
import { _FirebaseInstallationsInternal } from '@firebase/installations';
/**
* Implements the Client abstraction for the Remote Config REST API.
*/
export declare class RestClient implements RemoteConfigFetchClient {
private readonly firebaseInstallations;
private readonly sdkVersion;
private readonly namespace;
private readonly projectId;
private readonly apiKey;
private readonly appId;
constructor(firebaseInstallations: _FirebaseInstallationsInternal, sdkVersion: string, namespace: string, projectId: string, apiKey: string, appId: string);
/**
* Fetches from the Remote Config REST API.
*
* @throws a {@link ErrorCode.FETCH_NETWORK} error if {@link GlobalFetch#fetch} can't
* connect to the network.
* @throws a {@link ErrorCode.FETCH_PARSE} error if {@link Response#json} can't parse the
* fetch response.
* @throws a {@link ErrorCode.FETCH_STATUS} error if the service returns an HTTP error status.
*/
fetch(request: FetchRequest): Promise<FetchResponse>;
}

View file

@ -0,0 +1,49 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { RemoteConfigAbortSignal, RemoteConfigFetchClient, FetchResponse, FetchRequest } from './remote_config_fetch_client';
import { ThrottleMetadata, Storage } from '../storage/storage';
/**
* Supports waiting on a backoff by:
*
* <ul>
* <li>Promisifying setTimeout, so we can set a timeout in our Promise chain</li>
* <li>Listening on a signal bus for abort events, just like the Fetch API</li>
* <li>Failing in the same way the Fetch API fails, so timing out a live request and a throttled
* request appear the same.</li>
* </ul>
*
* <p>Visible for testing.
*/
export declare function setAbortableTimeout(signal: RemoteConfigAbortSignal, throttleEndTimeMillis: number): Promise<void>;
/**
* Decorates a Client with retry logic.
*
* <p>Comparable to CachingClient, but uses backoff logic instead of cache max age and doesn't cache
* responses (because the SDK has no use for error responses).
*/
export declare class RetryingClient implements RemoteConfigFetchClient {
private readonly client;
private readonly storage;
constructor(client: RemoteConfigFetchClient, storage: Storage);
fetch(request: FetchRequest): Promise<FetchResponse>;
/**
* A recursive helper for attempting a fetch request repeatedly.
*
* @throws any non-retriable errors.
*/
attemptFetch(request: FetchRequest, { throttleEndTimeMillis, backoffCount }: ThrottleMetadata): Promise<FetchResponse>;
}

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 declare const RC_COMPONENT_NAME = "remote-config";

View file

@ -0,0 +1,62 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { ErrorFactory } from '@firebase/util';
export declare const enum ErrorCode {
REGISTRATION_WINDOW = "registration-window",
REGISTRATION_PROJECT_ID = "registration-project-id",
REGISTRATION_API_KEY = "registration-api-key",
REGISTRATION_APP_ID = "registration-app-id",
STORAGE_OPEN = "storage-open",
STORAGE_GET = "storage-get",
STORAGE_SET = "storage-set",
STORAGE_DELETE = "storage-delete",
FETCH_NETWORK = "fetch-client-network",
FETCH_TIMEOUT = "fetch-timeout",
FETCH_THROTTLE = "fetch-throttle",
FETCH_PARSE = "fetch-client-parse",
FETCH_STATUS = "fetch-status",
INDEXED_DB_UNAVAILABLE = "indexed-db-unavailable"
}
interface ErrorParams {
[ErrorCode.STORAGE_OPEN]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_GET]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_SET]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.STORAGE_DELETE]: {
originalErrorMessage: string | undefined;
};
[ErrorCode.FETCH_NETWORK]: {
originalErrorMessage: string;
};
[ErrorCode.FETCH_THROTTLE]: {
throttleEndTimeMillis: number;
};
[ErrorCode.FETCH_PARSE]: {
originalErrorMessage: string;
};
[ErrorCode.FETCH_STATUS]: {
httpStatus: number;
};
}
export declare const ERROR_FACTORY: ErrorFactory<ErrorCode, ErrorParams>;
export declare function hasErrorCode(e: Error, errorCode: ErrorCode): boolean;
export {};

View file

@ -0,0 +1,14 @@
/**
* The Firebase Remote Config Web SDK.
* This SDK does not work in a Node.js environment.
*
* @packageDocumentation
*/
declare global {
interface Window {
FIREBASE_REMOTE_CONFIG_URL_BASE: string;
}
}
export * from './api';
export * from './api2';
export * from './public_types';

View file

@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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.
*/
/**
* Attempts to get the most accurate browser language setting.
*
* <p>Adapted from getUserLanguage in packages/auth/src/utils.js for TypeScript.
*
* <p>Defers default language specification to server logic for consistency.
*
* @param navigatorLanguage Enables tests to override read-only {@link NavigatorLanguage}.
*/
export declare function getUserLanguage(navigatorLanguage?: NavigatorLanguage): string;

View file

@ -0,0 +1,128 @@
/**
* @license
* Copyright 2020 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
/**
* The Firebase Remote Config service interface.
*
* @public
*/
export interface RemoteConfig {
/**
* The {@link @firebase/app#FirebaseApp} this `RemoteConfig` instance is associated with.
*/
app: FirebaseApp;
/**
* Defines configuration for the Remote Config SDK.
*/
settings: RemoteConfigSettings;
/**
* Object containing default values for configs.
*/
defaultConfig: {
[key: string]: string | number | boolean;
};
/**
* The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
* the {@link RemoteConfig} instance either hasn't fetched or initialization
* is incomplete.
*/
fetchTimeMillis: number;
/**
* The status of the last fetch <i>attempt</i>.
*/
lastFetchStatus: FetchStatus;
}
/**
* 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 fetched config.</li>
* </ul>
*
* @public
*/
export declare type ValueSource = 'static' | 'default' | 'remote';
/**
* Wraps a value with metadata and type-safe getters.
*
* @public
*/
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;
}
/**
* Defines configuration options for the Remote Config SDK.
*
* @public
*/
export interface RemoteConfigSettings {
/**
* Defines the maximum age in milliseconds of an entry in the config cache before
* it is considered stale. Defaults to 43200000 (Twelve hours).
*/
minimumFetchIntervalMillis: number;
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching
* configuration from the Remote Config server. Defaults to 60000 (One minute).
*/
fetchTimeoutMillis: number;
}
/**
* Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
*
* <ul>
* <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
* to fetch config, or that SDK initialization is incomplete.</li>
* <li>"success" indicates the last attempt succeeded.</li>
* <li>"failure" indicates the last attempt failed.</li>
* <li>"throttle" indicates the last attempt was rate-limited.</li>
* </ul>
*
* @public
*/
export declare type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
/**
* Defines levels of Remote Config logging.
*
* @public
*/
export declare type LogLevel = 'debug' | 'error' | 'silent';
declare module '@firebase/component' {
interface NameServiceMapping {
'remote-config': RemoteConfig;
}
}

View file

@ -0,0 +1,2 @@
import '@firebase/installations';
export declare function registerRemoteConfig(): void;

View file

@ -0,0 +1,79 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FirebaseApp } from '@firebase/app';
import { RemoteConfig as RemoteConfigType, FetchStatus, RemoteConfigSettings } from './public_types';
import { StorageCache } from './storage/storage_cache';
import { RemoteConfigFetchClient } from './client/remote_config_fetch_client';
import { Storage } from './storage/storage';
import { Logger } from '@firebase/logger';
/**
* Encapsulates business logic mapping network and storage dependencies to the public SDK API.
*
* See {@link https://github.com/firebase/firebase-js-sdk/blob/main/packages/firebase/index.d.ts|interface documentation} for method descriptions.
*/
export declare class RemoteConfig implements RemoteConfigType {
readonly app: FirebaseApp;
/**
* @internal
*/
readonly _client: RemoteConfigFetchClient;
/**
* @internal
*/
readonly _storageCache: StorageCache;
/**
* @internal
*/
readonly _storage: Storage;
/**
* @internal
*/
readonly _logger: Logger;
/**
* Tracks completion of initialization promise.
* @internal
*/
_isInitializationComplete: boolean;
/**
* De-duplicates initialization calls.
* @internal
*/
_initializePromise?: Promise<void>;
settings: RemoteConfigSettings;
defaultConfig: {
[key: string]: string | number | boolean;
};
get fetchTimeMillis(): number;
get lastFetchStatus(): FetchStatus;
constructor(app: FirebaseApp,
/**
* @internal
*/
_client: RemoteConfigFetchClient,
/**
* @internal
*/
_storageCache: StorageCache,
/**
* @internal
*/
_storage: Storage,
/**
* @internal
*/
_logger: Logger);
}

View file

@ -0,0 +1,76 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchStatus } from '@firebase/remote-config-types';
import { FetchResponse, FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client';
/**
* A general-purpose store keyed by app + namespace + {@link
* ProjectNamespaceKeyFieldValue}.
*
* <p>The Remote Config SDK can be used with multiple app installations, and each app can interact
* with multiple namespaces, so this store uses app (ID + name) and namespace as common parent keys
* for a set of key-value pairs. See {@link Storage#createCompositeKey}.
*
* <p>Visible for testing.
*/
export declare const APP_NAMESPACE_STORE = "app_namespace_store";
/**
* Encapsulates metadata concerning throttled fetch requests.
*/
export interface ThrottleMetadata {
backoffCount: number;
throttleEndTimeMillis: number;
}
/**
* Provides type-safety for the "key" field used by {@link APP_NAMESPACE_STORE}.
*
* <p>This seems like a small price to avoid potentially subtle bugs caused by a typo.
*/
declare type ProjectNamespaceKeyFieldValue = 'active_config' | 'active_config_etag' | 'last_fetch_status' | 'last_successful_fetch_timestamp_millis' | 'last_successful_fetch_response' | 'settings' | 'throttle_metadata';
export declare function openDatabase(): Promise<IDBDatabase>;
/**
* Abstracts data persistence.
*/
export declare class Storage {
private readonly appId;
private readonly appName;
private readonly namespace;
private readonly openDbPromise;
/**
* @param appId enables storage segmentation by app (ID + name).
* @param appName enables storage segmentation by app (ID + name).
* @param namespace enables storage segmentation by namespace.
*/
constructor(appId: string, appName: string, namespace: string, openDbPromise?: Promise<IDBDatabase>);
getLastFetchStatus(): Promise<FetchStatus | undefined>;
setLastFetchStatus(status: FetchStatus): Promise<void>;
getLastSuccessfulFetchTimestampMillis(): Promise<number | undefined>;
setLastSuccessfulFetchTimestampMillis(timestamp: number): Promise<void>;
getLastSuccessfulFetchResponse(): Promise<FetchResponse | undefined>;
setLastSuccessfulFetchResponse(response: FetchResponse): Promise<void>;
getActiveConfig(): Promise<FirebaseRemoteConfigObject | undefined>;
setActiveConfig(config: FirebaseRemoteConfigObject): Promise<void>;
getActiveConfigEtag(): Promise<string | undefined>;
setActiveConfigEtag(etag: string): Promise<void>;
getThrottleMetadata(): Promise<ThrottleMetadata | undefined>;
setThrottleMetadata(metadata: ThrottleMetadata): Promise<void>;
deleteThrottleMetadata(): Promise<void>;
get<T>(key: ProjectNamespaceKeyFieldValue): Promise<T | undefined>;
set<T>(key: ProjectNamespaceKeyFieldValue, value: T): Promise<void>;
delete(key: ProjectNamespaceKeyFieldValue): Promise<void>;
createCompositeKey(key: ProjectNamespaceKeyFieldValue): string;
}
export {};

View file

@ -0,0 +1,48 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { FetchStatus } from '@firebase/remote-config-types';
import { FirebaseRemoteConfigObject } from '../client/remote_config_fetch_client';
import { Storage } from './storage';
/**
* A memory cache layer over storage to support the SDK's synchronous read requirements.
*/
export declare class StorageCache {
private readonly storage;
constructor(storage: Storage);
/**
* Memory caches.
*/
private lastFetchStatus?;
private lastSuccessfulFetchTimestampMillis?;
private activeConfig?;
/**
* Memory-only getters
*/
getLastFetchStatus(): FetchStatus | undefined;
getLastSuccessfulFetchTimestampMillis(): number | undefined;
getActiveConfig(): FirebaseRemoteConfigObject | undefined;
/**
* Read-ahead getter
*/
loadFromStorage(): Promise<void>;
/**
* Write-through setters
*/
setLastFetchStatus(status: FetchStatus): Promise<void>;
setLastSuccessfulFetchTimestampMillis(timestampMillis: number): Promise<void>;
setActiveConfig(activeConfig: FirebaseRemoteConfigObject): Promise<void>;
}

View file

@ -0,0 +1,11 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "0.1.2"
}
]
}

View file

@ -0,0 +1,26 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 { Value as ValueType, ValueSource } from '@firebase/remote-config-types';
export declare class Value implements ValueType {
private readonly _source;
private readonly _value;
constructor(_source: ValueSource, _value?: string);
asString(): string;
asBoolean(): boolean;
asNumber(): number;
getSource(): ValueSource;
}

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 {};

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 '../setup';

View file

@ -0,0 +1,17 @@
/**
* @license
* Copyright 2019 Google LLC
*
* 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 './setup';