Skip to content

Commit 872be7f

Browse files
author
kjelko
committed
run formatter
1 parent 2255b79 commit 872be7f

File tree

6 files changed

+82
-45
lines changed

6 files changed

+82
-45
lines changed

packages/remote-config/src/api.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ import { LogLevel as FirebaseLogLevel } from '@firebase/logger';
4242
*
4343
* @public
4444
*/
45-
export function getRemoteConfig(app: FirebaseApp = getApp(), options: RemoteConfigOptions = {}): RemoteConfig {
45+
export function getRemoteConfig(
46+
app: FirebaseApp = getApp(),
47+
options: RemoteConfigOptions = {}
48+
): RemoteConfig {
4649
app = getModularInstance(app);
4750
const rcProvider = _getProvider(app, RC_COMPONENT_NAME);
4851
if (rcProvider.isInitialized()) {
@@ -63,7 +66,9 @@ export function getRemoteConfig(app: FirebaseApp = getApp(), options: RemoteConf
6366
rc._storage.setActiveConfigEtag(options.initialFetchResponse?.eTag || ''),
6467
rc._storageCache.setLastSuccessfulFetchTimestampMillis(Date.now()),
6568
rc._storageCache.setLastFetchStatus('success'),
66-
rc._storageCache.setActiveConfig(options.initialFetchResponse?.config || {})
69+
rc._storageCache.setActiveConfig(
70+
options.initialFetchResponse?.config || {}
71+
)
6772
]).then();
6873
// The storageCache methods above set their in-memory fields sycnhronously, so it's
6974
// safe to declare our initialization complete at this point.
@@ -249,7 +254,7 @@ export function getValue(remoteConfig: RemoteConfig, key: string): Value {
249254
if (!rc._isInitializationComplete) {
250255
rc._logger.debug(
251256
`A value was requested for key "${key}" before SDK initialization completed.` +
252-
' Await on ensureInitialized if the intent was to get a previously activated value.'
257+
' Await on ensureInitialized if the intent was to get a previously activated value.'
253258
);
254259
}
255260
const activeConfig = rc._storageCache.getActiveConfig();
@@ -260,7 +265,7 @@ export function getValue(remoteConfig: RemoteConfig, key: string): Value {
260265
}
261266
rc._logger.debug(
262267
`Returning static value for key "${key}".` +
263-
' Define a default or remote value if this is unintentional.'
268+
' Define a default or remote value if this is unintentional.'
264269
);
265270
return new ValueImpl('static');
266271
}

packages/remote-config/src/public_types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
import { FirebaseApp } from '@firebase/app';
1919
import { FetchResponse } from './client/remote_config_fetch_client';
2020

21-
export { FetchResponse, FirebaseRemoteConfigObject } from './client/remote_config_fetch_client';
21+
export {
22+
FetchResponse,
23+
FirebaseRemoteConfigObject
24+
} from './client/remote_config_fetch_client';
2225

2326
/**
2427
* Options for Remote Config initialization.
25-
*
28+
*
2629
* @public
2730
*/
2831
export interface RemoteConfigOptions {

packages/remote-config/src/register.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { isIndexedDBAvailable } from '@firebase/util';
2323
import {
2424
Component,
2525
ComponentType,
26-
ComponentContainer,
26+
ComponentContainer
2727
} from '@firebase/component';
2828
import { Logger, LogLevel as FirebaseLogLevel } from '@firebase/logger';
2929
import { RemoteConfig, RemoteConfigOptions } from './public_types';
@@ -79,9 +79,9 @@ export function registerRemoteConfig(): void {
7979
}
8080
const namespace = options?.templateId || 'firebase';
8181

82-
const storage = isIndexedDBAvailable() ?
83-
new IndexedDbStorage(appId, app.name, namespace) :
84-
new InMemoryStorage();
82+
const storage = isIndexedDBAvailable()
83+
? new IndexedDbStorage(appId, app.name, namespace)
84+
: new InMemoryStorage();
8585
const storageCache = new StorageCache(storage);
8686

8787
const logger = new Logger(packageName);

packages/remote-config/src/storage/storage.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ export abstract class Storage {
175175
return this.get<CustomSignals>('custom_signals');
176176
}
177177

178-
abstract setCustomSignals(customSignals: CustomSignals): Promise<CustomSignals>;
178+
abstract setCustomSignals(
179+
customSignals: CustomSignals
180+
): Promise<CustomSignals>;
179181
abstract get<T>(key: ProjectNamespaceKeyFieldValue): Promise<T | undefined>;
180182
abstract set<T>(key: ProjectNamespaceKeyFieldValue, value: T): Promise<void>;
181183
abstract delete(key: ProjectNamespaceKeyFieldValue): Promise<void>;
@@ -373,8 +375,8 @@ export class InMemoryStorage extends Storage {
373375

374376
async setCustomSignals(customSignals: CustomSignals): Promise<CustomSignals> {
375377
const combinedSignals = {
376-
...this.storage['custom_signals'] as CustomSignals,
377-
...customSignals,
378+
...(this.storage['custom_signals'] as CustomSignals),
379+
...customSignals
378380
};
379381

380382
const updatedSignals = Object.fromEntries(

packages/remote-config/test/api.test.ts

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright 2025 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+
118
import { expect } from 'chai';
2-
import { ensureInitialized, fetchAndActivate, getRemoteConfig, getString } from '../src/index';
19+
import {
20+
ensureInitialized,
21+
fetchAndActivate,
22+
getRemoteConfig,
23+
getString
24+
} from '../src/index';
325
import '../test/setup';
4-
import { deleteApp, FirebaseApp, initializeApp, _addOrOverwriteComponent } from '@firebase/app';
26+
import {
27+
deleteApp,
28+
FirebaseApp,
29+
initializeApp,
30+
_addOrOverwriteComponent
31+
} from '@firebase/app';
532
import * as sinon from 'sinon';
633
import { FetchResponse } from '../src/client/remote_config_fetch_client';
7-
import {
8-
Component,
9-
ComponentType
10-
} from '@firebase/component';
34+
import { Component, ComponentType } from '@firebase/component';
1135
import { FirebaseInstallations } from '@firebase/installations-types';
12-
import {
13-
openDatabase,
14-
APP_NAMESPACE_STORE,
15-
} from '../src/storage/storage';
36+
import { openDatabase, APP_NAMESPACE_STORE } from '../src/storage/storage';
1637

1738
const fakeFirebaseConfig = {
1839
apiKey: 'api-key',
@@ -36,7 +57,7 @@ describe('Remote Config API', () => {
3657
const STUB_FETCH_RESPONSE: FetchResponse = {
3758
status: 200,
3859
eTag: 'asdf',
39-
config: { 'foobar': 'hello world' },
60+
config: { 'foobar': 'hello world' }
4061
};
4162
let fetchStub: sinon.SinonStub;
4263

@@ -50,11 +71,11 @@ describe('Remote Config API', () => {
5071
() => {
5172
return {
5273
getId: () => Promise.resolve('fis-id'),
53-
getToken: () => Promise.resolve('fis-token'),
74+
getToken: () => Promise.resolve('fis-token')
5475
} as any as FirebaseInstallations;
5576
},
5677
ComponentType.PUBLIC
57-
) as any,
78+
) as any
5879
);
5980
});
6081

@@ -65,16 +86,18 @@ describe('Remote Config API', () => {
6586
});
6687

6788
function setFetchResponse(response: FetchResponse = { status: 200 }): void {
68-
fetchStub.returns(Promise.resolve({
69-
ok: response.status === 200,
70-
status: response.status,
71-
headers: new Headers({ ETag: response.eTag || '' }),
72-
json: () =>
73-
Promise.resolve({
74-
entries: response.config,
75-
state: 'OK'
76-
})
77-
} as Response));
89+
fetchStub.returns(
90+
Promise.resolve({
91+
ok: response.status === 200,
92+
status: response.status,
93+
headers: new Headers({ ETag: response.eTag || '' }),
94+
json: () =>
95+
Promise.resolve({
96+
entries: response.config,
97+
state: 'OK'
98+
})
99+
} as Response)
100+
);
78101
}
79102

80103
it('allows multiple initializations if options are same', () => {
@@ -115,11 +138,14 @@ describe('Remote Config API', () => {
115138
await fetchAndActivate(rc);
116139
expect(fetchStub).to.be.calledOnceWith(
117140
'https://firebaseremoteconfig.googleapis.com/v1/projects/project-id/namespaces/altTemplate:fetch?key=api-key',
118-
sinon.match.object);
141+
sinon.match.object
142+
);
119143
});
120144

121145
it('hydrates with initialFetchResponse', async () => {
122-
const rc = getRemoteConfig(app, { initialFetchResponse: STUB_FETCH_RESPONSE });
146+
const rc = getRemoteConfig(app, {
147+
initialFetchResponse: STUB_FETCH_RESPONSE
148+
});
123149
await ensureInitialized(rc);
124150
expect(getString(rc, 'foobar')).to.equal('hello world');
125151
});

packages/remote-config/test/storage/storage.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ async function clearDatabase(): Promise<void> {
3636
}
3737

3838
describe('Storage', () => {
39-
4039
const indexedDbTestCase = {
4140
getStorage: () => new IndexedDbStorage('appId', 'appName', 'namespace'),
42-
name: 'IndexedDbStorage',
41+
name: 'IndexedDbStorage'
4342
};
4443

4544
const inMemoryStorage = {
4645
getStorage: () => new InMemoryStorage(),
47-
name: 'InMemoryStorage',
46+
name: 'InMemoryStorage'
4847
};
4948

5049
beforeEach(async () => {
@@ -53,9 +52,9 @@ describe('Storage', () => {
5352

5453
it(`${indexedDbTestCase.name} constructs a composite key`, async () => {
5554
// This is defensive, but the cost of accidentally changing the key composition is high.
56-
expect(indexedDbTestCase.getStorage().createCompositeKey('throttle_metadata')).to.eq(
57-
'appId,appName,namespace,throttle_metadata'
58-
);
55+
expect(
56+
indexedDbTestCase.getStorage().createCompositeKey('throttle_metadata')
57+
).to.eq('appId,appName,namespace,throttle_metadata');
5958
});
6059

6160
for (const { name, getStorage } of [indexedDbTestCase, inMemoryStorage]) {
@@ -92,7 +91,9 @@ describe('Storage', () => {
9291
it('sets and gets last successful fetch response', async () => {
9392
const lastSuccessfulFetchResponse = { status: 200 } as FetchResponse;
9493

95-
await storage.setLastSuccessfulFetchResponse(lastSuccessfulFetchResponse);
94+
await storage.setLastSuccessfulFetchResponse(
95+
lastSuccessfulFetchResponse
96+
);
9697

9798
const actualConfig = await storage.getLastSuccessfulFetchResponse();
9899

0 commit comments

Comments
 (0)