@firebase/remote-config 0.4.10 → 0.4.11-canary.0755a723d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.esm2017.js +1299 -1194
- package/dist/esm/index.esm2017.js.map +1 -1
- package/dist/esm/src/api.d.ts +126 -115
- package/dist/esm/src/api2.d.ts +40 -40
- package/dist/esm/src/client/caching_client.d.ts +45 -45
- package/dist/esm/src/client/remote_config_fetch_client.d.ts +129 -123
- package/dist/esm/src/client/rest_client.d.ts +40 -40
- package/dist/esm/src/client/retrying_client.d.ts +49 -49
- package/dist/esm/src/constants.d.ts +20 -17
- package/dist/esm/src/errors.d.ts +66 -62
- package/dist/esm/src/index.d.ts +14 -14
- package/dist/esm/src/language.d.ts +26 -26
- package/dist/esm/src/public_types.d.ts +144 -128
- package/dist/esm/src/register.d.ts +2 -2
- package/dist/esm/src/remote_config.d.ts +79 -79
- package/dist/esm/src/storage/storage.d.ts +95 -76
- package/dist/esm/src/storage/storage_cache.d.ts +51 -48
- package/dist/esm/src/value.d.ts +26 -26
- package/dist/esm/test/client/caching_client.test.d.ts +17 -17
- package/dist/esm/test/client/rest_client.test.d.ts +17 -17
- package/dist/esm/test/client/retrying_client.test.d.ts +17 -17
- package/dist/esm/test/errors.test.d.ts +17 -17
- package/dist/esm/test/language.test.d.ts +17 -17
- package/dist/esm/test/remote_config.test.d.ts +17 -17
- package/dist/esm/test/setup.d.ts +17 -17
- package/dist/esm/test/storage/storage.test.d.ts +17 -17
- package/dist/esm/test/storage/storage_cache.test.d.ts +17 -17
- package/dist/esm/test/value.test.d.ts +17 -17
- package/dist/index.cjs.js +1299 -1193
- package/dist/index.cjs.js.map +1 -1
- package/dist/remote-config-public.d.ts +29 -0
- package/dist/remote-config.d.ts +29 -0
- package/dist/src/api.d.ts +126 -115
- package/dist/src/api2.d.ts +40 -40
- package/dist/src/client/caching_client.d.ts +45 -45
- package/dist/src/client/remote_config_fetch_client.d.ts +129 -123
- package/dist/src/client/rest_client.d.ts +40 -40
- package/dist/src/client/retrying_client.d.ts +49 -49
- package/dist/src/constants.d.ts +20 -17
- package/dist/src/errors.d.ts +66 -62
- package/dist/src/index.d.ts +14 -14
- package/dist/src/language.d.ts +26 -26
- package/dist/src/public_types.d.ts +144 -128
- package/dist/src/register.d.ts +2 -2
- package/dist/src/remote_config.d.ts +79 -79
- package/dist/src/storage/storage.d.ts +95 -76
- package/dist/src/storage/storage_cache.d.ts +51 -48
- package/dist/src/value.d.ts +26 -26
- package/dist/test/client/caching_client.test.d.ts +17 -17
- package/dist/test/client/rest_client.test.d.ts +17 -17
- package/dist/test/client/retrying_client.test.d.ts +17 -17
- package/dist/test/errors.test.d.ts +17 -17
- package/dist/test/language.test.d.ts +17 -17
- package/dist/test/remote_config.test.d.ts +17 -17
- package/dist/test/setup.d.ts +17 -17
- package/dist/test/storage/storage.test.d.ts +17 -17
- package/dist/test/storage/storage_cache.test.d.ts +17 -17
- package/dist/test/value.test.d.ts +17 -17
- package/package.json +8 -8
package/dist/esm/src/api.d.ts
CHANGED
|
@@ -1,115 +1,126 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { FirebaseApp } from '@firebase/app';
|
|
18
|
-
import { LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types';
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param app - The {@link @firebase/app#FirebaseApp} instance.
|
|
22
|
-
* @returns A {@link RemoteConfig} instance.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
|
|
27
|
-
/**
|
|
28
|
-
* Makes the last fetched config available to the getters.
|
|
29
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
30
|
-
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
31
|
-
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
32
|
-
*
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
36
|
-
/**
|
|
37
|
-
* Ensures the last activated config are available to the getters.
|
|
38
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
39
|
-
*
|
|
40
|
-
* @returns A `Promise` that resolves when the last activated config is available to the getters.
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
43
|
-
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Fetches and caches configuration from the Remote Config service.
|
|
46
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
47
|
-
* @public
|
|
48
|
-
*/
|
|
49
|
-
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
|
|
50
|
-
/**
|
|
51
|
-
* Gets all config.
|
|
52
|
-
*
|
|
53
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
54
|
-
* @returns All config.
|
|
55
|
-
*
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
|
|
59
|
-
/**
|
|
60
|
-
* Gets the value for the given key as a boolean.
|
|
61
|
-
*
|
|
62
|
-
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
|
|
63
|
-
*
|
|
64
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
65
|
-
* @param key - The name of the parameter.
|
|
66
|
-
*
|
|
67
|
-
* @returns The value for the given key as a boolean.
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
|
-
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Gets the value for the given key as a number.
|
|
73
|
-
*
|
|
74
|
-
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
|
|
75
|
-
*
|
|
76
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
77
|
-
* @param key - The name of the parameter.
|
|
78
|
-
*
|
|
79
|
-
* @returns The value for the given key as a number.
|
|
80
|
-
*
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
|
|
84
|
-
/**
|
|
85
|
-
* Gets the value for the given key as a string.
|
|
86
|
-
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
|
|
87
|
-
*
|
|
88
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
89
|
-
* @param key - The name of the parameter.
|
|
90
|
-
*
|
|
91
|
-
* @returns The value for the given key as a string.
|
|
92
|
-
*
|
|
93
|
-
* @public
|
|
94
|
-
*/
|
|
95
|
-
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
|
|
96
|
-
/**
|
|
97
|
-
* Gets the {@link Value} for the given key.
|
|
98
|
-
*
|
|
99
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
100
|
-
* @param key - The name of the parameter.
|
|
101
|
-
*
|
|
102
|
-
* @returns The value for the given key.
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
|
-
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
|
|
107
|
-
/**
|
|
108
|
-
* Defines the log level to use.
|
|
109
|
-
*
|
|
110
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
111
|
-
* @param logLevel - The log level to set.
|
|
112
|
-
*
|
|
113
|
-
* @public
|
|
114
|
-
*/
|
|
115
|
-
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { CustomSignals, LogLevel as RemoteConfigLogLevel, RemoteConfig, Value } from './public_types';
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param app - The {@link @firebase/app#FirebaseApp} instance.
|
|
22
|
+
* @returns A {@link RemoteConfig} instance.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Makes the last fetched config available to the getters.
|
|
29
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
30
|
+
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
31
|
+
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function activate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Ensures the last activated config are available to the getters.
|
|
38
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
39
|
+
*
|
|
40
|
+
* @returns A `Promise` that resolves when the last activated config is available to the getters.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches and caches configuration from the Remote Config service.
|
|
46
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Gets all config.
|
|
52
|
+
*
|
|
53
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
54
|
+
* @returns All config.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare function getAll(remoteConfig: RemoteConfig): Record<string, Value>;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the value for the given key as a boolean.
|
|
61
|
+
*
|
|
62
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
|
|
63
|
+
*
|
|
64
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
65
|
+
* @param key - The name of the parameter.
|
|
66
|
+
*
|
|
67
|
+
* @returns The value for the given key as a boolean.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the value for the given key as a number.
|
|
73
|
+
*
|
|
74
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
|
|
75
|
+
*
|
|
76
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
77
|
+
* @param key - The name of the parameter.
|
|
78
|
+
*
|
|
79
|
+
* @returns The value for the given key as a number.
|
|
80
|
+
*
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
export declare function getNumber(remoteConfig: RemoteConfig, key: string): number;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the value for the given key as a string.
|
|
86
|
+
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
|
|
87
|
+
*
|
|
88
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
89
|
+
* @param key - The name of the parameter.
|
|
90
|
+
*
|
|
91
|
+
* @returns The value for the given key as a string.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare function getString(remoteConfig: RemoteConfig, key: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the {@link Value} for the given key.
|
|
98
|
+
*
|
|
99
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
100
|
+
* @param key - The name of the parameter.
|
|
101
|
+
*
|
|
102
|
+
* @returns The value for the given key.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare function getValue(remoteConfig: RemoteConfig, key: string): Value;
|
|
107
|
+
/**
|
|
108
|
+
* Defines the log level to use.
|
|
109
|
+
*
|
|
110
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
111
|
+
* @param logLevel - The log level to set.
|
|
112
|
+
*
|
|
113
|
+
* @public
|
|
114
|
+
*/
|
|
115
|
+
export declare function setLogLevel(remoteConfig: RemoteConfig, logLevel: RemoteConfigLogLevel): void;
|
|
116
|
+
/**
|
|
117
|
+
* Sets the custom signals for the app instance.
|
|
118
|
+
*
|
|
119
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
120
|
+
* @param customSignals - Map (key, value) of the custom signals to be set for the app instance. If
|
|
121
|
+
* a key already exists, the value is overwritten. Setting the value of a custom signal to null
|
|
122
|
+
* unsets the signal. The signals will be persisted locally on the client.
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export declare function setCustomSignals(remoteConfig: RemoteConfig, customSignals: CustomSignals): Promise<void>;
|
package/dist/esm/src/api2.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { RemoteConfig } from './public_types';
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* Performs fetch and activate operations, as a convenience.
|
|
21
|
-
*
|
|
22
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
23
|
-
*
|
|
24
|
-
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
25
|
-
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
30
|
-
/**
|
|
31
|
-
* This method provides two different checks:
|
|
32
|
-
*
|
|
33
|
-
* 1. Check if IndexedDB exists in the browser environment.
|
|
34
|
-
* 2. Check if the current browser context allows IndexedDB `open()` calls.
|
|
35
|
-
*
|
|
36
|
-
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
|
|
37
|
-
* can be initialized in this environment, or false if it cannot.
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export declare function isSupported(): Promise<boolean>;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { RemoteConfig } from './public_types';
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Performs fetch and activate operations, as a convenience.
|
|
21
|
+
*
|
|
22
|
+
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
23
|
+
*
|
|
24
|
+
* @returns A `Promise` which resolves to true if the current call activated the fetched configs.
|
|
25
|
+
* If the fetched configs were already activated, the `Promise` will resolve to false.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* This method provides two different checks:
|
|
32
|
+
*
|
|
33
|
+
* 1. Check if IndexedDB exists in the browser environment.
|
|
34
|
+
* 2. Check if the current browser context allows IndexedDB `open()` calls.
|
|
35
|
+
*
|
|
36
|
+
* @returns A `Promise` which resolves to true if a {@link RemoteConfig} instance
|
|
37
|
+
* can be initialized in this environment, or false if it cannot.
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSupported(): Promise<boolean>;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { StorageCache } from '../storage/storage_cache';
|
|
18
|
-
import { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
19
|
-
import { Storage } from '../storage/storage';
|
|
20
|
-
import { Logger } from '@firebase/logger';
|
|
21
|
-
/**
|
|
22
|
-
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
|
|
23
|
-
*
|
|
24
|
-
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
|
|
25
|
-
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
|
|
26
|
-
* Cache API doesn't support matching entries by time.
|
|
27
|
-
*/
|
|
28
|
-
export declare class CachingClient implements RemoteConfigFetchClient {
|
|
29
|
-
private readonly client;
|
|
30
|
-
private readonly storage;
|
|
31
|
-
private readonly storageCache;
|
|
32
|
-
private readonly logger;
|
|
33
|
-
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
|
|
34
|
-
/**
|
|
35
|
-
* Returns true if the age of the cached fetched configs is less than or equal to
|
|
36
|
-
* {@link Settings#minimumFetchIntervalInSeconds}.
|
|
37
|
-
*
|
|
38
|
-
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
|
|
39
|
-
* native Fetch API.
|
|
40
|
-
*
|
|
41
|
-
* <p>Visible for testing.
|
|
42
|
-
*/
|
|
43
|
-
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
|
|
44
|
-
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
45
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { StorageCache } from '../storage/storage_cache';
|
|
18
|
+
import { FetchResponse, RemoteConfigFetchClient, FetchRequest } from './remote_config_fetch_client';
|
|
19
|
+
import { Storage } from '../storage/storage';
|
|
20
|
+
import { Logger } from '@firebase/logger';
|
|
21
|
+
/**
|
|
22
|
+
* Implements the {@link RemoteConfigClient} abstraction with success response caching.
|
|
23
|
+
*
|
|
24
|
+
* <p>Comparable to the browser's Cache API for responses, but the Cache API requires a Service
|
|
25
|
+
* Worker, which requires HTTPS, which would significantly complicate SDK installation. Also, the
|
|
26
|
+
* Cache API doesn't support matching entries by time.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CachingClient implements RemoteConfigFetchClient {
|
|
29
|
+
private readonly client;
|
|
30
|
+
private readonly storage;
|
|
31
|
+
private readonly storageCache;
|
|
32
|
+
private readonly logger;
|
|
33
|
+
constructor(client: RemoteConfigFetchClient, storage: Storage, storageCache: StorageCache, logger: Logger);
|
|
34
|
+
/**
|
|
35
|
+
* Returns true if the age of the cached fetched configs is less than or equal to
|
|
36
|
+
* {@link Settings#minimumFetchIntervalInSeconds}.
|
|
37
|
+
*
|
|
38
|
+
* <p>This is comparable to passing `headers = { 'Cache-Control': max-age <maxAge> }` to the
|
|
39
|
+
* native Fetch API.
|
|
40
|
+
*
|
|
41
|
+
* <p>Visible for testing.
|
|
42
|
+
*/
|
|
43
|
+
isCachedDataFresh(cacheMaxAgeMillis: number, lastSuccessfulFetchTimestampMillis: number | undefined): boolean;
|
|
44
|
+
fetch(request: FetchRequest): Promise<FetchResponse>;
|
|
45
|
+
}
|