Skip to content

Commit 129888c

Browse files
authored
Fix platform logging for exp packages (#4740)
1 parent bd7277d commit 129888c

File tree

20 files changed

+310
-187
lines changed

20 files changed

+310
-187
lines changed

packages-exp/app-exp/src/constants.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ import { name as analyticsCompatName } from '../../../packages-exp/analytics-com
2121
import { name as analyticsName } from '../../../packages-exp/analytics-exp/package.json';
2222
import { name as authName } from '../../../packages-exp/auth-exp/package.json';
2323
import { name as authCompatName } from '../../../packages-exp/auth-compat-exp/package.json';
24-
import { name as databaseName } from '../../../packages/database/package.json';
24+
import { name as databaseName } from '../../../packages/database/exp/package.json';
2525
import { name as functionsName } from '../../../packages-exp/functions-exp/package.json';
2626
import { name as functionsCompatName } from '../../../packages-exp/functions-compat/package.json';
2727
import { name as installationsName } from '../../../packages-exp/installations-exp/package.json';
2828
import { name as installationsCompatName } from '../../../packages-exp/installations-compat/package.json';
2929
import { name as messagingName } from '../../../packages-exp/messaging-exp/package.json';
30+
import { name as messagingCompatName } from '../../../packages-exp/messaging-compat/package.json';
3031
import { name as performanceName } from '../../../packages-exp/performance-exp/package.json';
32+
import { name as performanceCompatName } from '../../../packages-exp/performance-compat/package.json';
3133
import { name as remoteConfigName } from '../../../packages-exp/remote-config-exp/package.json';
3234
import { name as remoteConfigCompatName } from '../../../packages-exp/remote-config-compat/package.json';
3335
import { name as storageName } from '../../../packages/storage/package.json';
34-
import { name as firestoreName } from '../../../packages/firestore/package.json';
36+
import { name as storageCompatName } from '../../../packages/storage/compat/package.json';
37+
import { name as firestoreName } from '../../../packages/firestore/exp/package.json';
38+
import { name as firestoreCompatName } from '../../../packages/firestore/compat/package.json';
3539
import { name as packageName } from '../../../packages-exp/firebase-exp/package.json';
3640

3741
/**
@@ -54,11 +58,15 @@ export const PLATFORM_LOG_STRING = {
5458
[installationsName]: 'fire-iid',
5559
[installationsCompatName]: 'fire-iid-compat',
5660
[messagingName]: 'fire-fcm',
61+
[messagingCompatName]: 'fire-fcm-compat',
5762
[performanceName]: 'fire-perf',
63+
[performanceCompatName]: 'fire-perf-compat',
5864
[remoteConfigName]: 'fire-rc',
5965
[remoteConfigCompatName]: 'fire-rc-compat',
6066
[storageName]: 'fire-gcs',
67+
[storageCompatName]: 'fire-gcs-compat',
6168
[firestoreName]: 'fire-fst',
69+
[firestoreCompatName]: 'fire-fst-compat',
6270
'fire-js': 'fire-js', // Platform identifier for JS SDK.
6371
[packageName]: 'fire-js-all'
6472
} as const;

packages-exp/auth-compat-exp/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
} from '@firebase/component';
2828

2929
import * as types from '@firebase/auth-types';
30-
import { version } from './package.json';
30+
import { name, version } from './package.json';
3131
import { Auth } from './src/auth';
3232
import { Persistence } from './src/persistence';
3333
import { PhoneAuthProvider as CompatAuthProvider } from './src/phone_auth_provider';
@@ -117,7 +117,7 @@ function registerAuthCompat(instance: _FirebaseNamespace): void {
117117
.setMultipleInstances(false)
118118
);
119119

120-
instance.registerVersion('auth-compat', version);
120+
instance.registerVersion(name, version);
121121
}
122122

123123
registerAuthCompat(firebase as _FirebaseNamespace);

packages-exp/auth-exp/src/core/auth/register.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
InstantiationMode
2323
} from '@firebase/component';
2424

25-
import { version } from '../../../package.json';
25+
import { name, version } from '../../../package.json';
2626
import { AuthErrorCode } from '../errors';
2727
import { _assert } from '../util/assert';
2828
import { _getClientVersion, ClientPlatform } from '../util/version';
@@ -122,9 +122,5 @@ export function registerAuth(clientPlatform: ClientPlatform): void {
122122
).setInstantiationMode(InstantiationMode.EXPLICIT)
123123
);
124124

125-
registerVersion(
126-
_ComponentName.AUTH,
127-
version,
128-
getVersionForPlatform(clientPlatform)
129-
);
125+
registerVersion(name, version, getVersionForPlatform(clientPlatform));
130126
}

packages/database/exp/index.node.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
18+
import { registerDatabase } from './register';
19+
20+
export { getDatabase, ServerValue } from '../src/exp/Database';
21+
export { enableLogging } from '../src/core/util/util';
22+
23+
registerDatabase('node');

packages/database/exp/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
// eslint-disable-next-line import/no-extraneous-dependencies
19-
import { _registerComponent, registerVersion } from '@firebase/app-exp';
20-
import { Component, ComponentType } from '@firebase/component';
21-
22-
import { version } from '../package.json';
23-
import { FirebaseDatabase } from '../src/exp/Database';
18+
import { registerDatabase } from './register';
2419

2520
export { getDatabase, ServerValue } from '../src/exp/Database';
2621
export { enableLogging } from '../src/core/util/util';
2722

28-
declare module '@firebase/component' {
29-
interface NameServiceMapping {
30-
'database-exp': FirebaseDatabase;
31-
}
32-
}
33-
34-
function registerDatabase(): void {
35-
_registerComponent(
36-
new Component(
37-
'database-exp',
38-
(container, { instanceIdentifier: url }) => {
39-
const app = container.getProvider('app-exp').getImmediate()!;
40-
const authProvider = container.getProvider('auth-internal');
41-
return new FirebaseDatabase(app, authProvider, url);
42-
},
43-
ComponentType.PUBLIC
44-
).setMultipleInstances(true)
45-
);
46-
registerVersion('database-exp', version, 'node');
47-
}
48-
4923
registerDatabase();

packages/database/exp/register.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
18+
// eslint-disable-next-line import/no-extraneous-dependencies
19+
import { _registerComponent, registerVersion } from '@firebase/app-exp';
20+
import { Component, ComponentType } from '@firebase/component';
21+
22+
import { name, version } from '../package.json';
23+
import { FirebaseDatabase } from '../src/exp/Database';
24+
25+
export { getDatabase, ServerValue } from '../src/exp/Database';
26+
export { enableLogging } from '../src/core/util/util';
27+
28+
declare module '@firebase/component' {
29+
interface NameServiceMapping {
30+
'database-exp': FirebaseDatabase;
31+
}
32+
}
33+
34+
export function registerDatabase(variant?: string): void {
35+
_registerComponent(
36+
new Component(
37+
'database-exp',
38+
(container, { instanceIdentifier: url }) => {
39+
const app = container.getProvider('app-exp').getImmediate()!;
40+
const authProvider = container.getProvider('auth-internal');
41+
return new FirebaseDatabase(app, authProvider, url);
42+
},
43+
ComponentType.PUBLIC
44+
).setMultipleInstances(true)
45+
);
46+
registerVersion(name, version, variant);
47+
}

packages/database/rollup.config.exp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const es5Builds = [
5353
* Node.js Build
5454
*/
5555
{
56-
input: 'exp/index.ts',
56+
input: 'exp/index.node.ts',
5757
output: [
5858
{ file: path.resolve('exp', expPkg.main), format: 'cjs', sourcemap: true }
5959
],

packages/firestore/compat/index.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import firebase from '@firebase/app-compat';
2020
import { FirebaseNamespace } from '@firebase/app-types';
2121

22-
import { name, version } from '../package.json';
2322
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database';
2423

2524
import { registerBundle } from './bundle';
2625
import { configureForFirebase } from './config';
26+
import { name, version } from './package.json';
2727

2828
/**
2929
* Registers the main Firestore Node build with the components framework.

packages/firestore/compat/index.rn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import firebase from '@firebase/app-compat';
2020
import { FirebaseNamespace } from '@firebase/app-types';
2121

22-
import { name, version } from '../package.json';
2322
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database';
2423

2524
import { registerBundle } from './bundle';
2625
import { configureForFirebase } from './config';
26+
import { name, version } from './package.json';
2727

2828
/**
2929
* Registers the main Firestore ReactNative build with the components framework.

packages/firestore/compat/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import firebase from '@firebase/app-compat';
2020
import { FirebaseNamespace } from '@firebase/app-types';
2121
import * as types from '@firebase/firestore-types';
2222

23-
import { name, version } from '../package.json';
2423
import { Firestore, IndexedDbPersistenceProvider } from '../src/api/database';
2524

2625
import { registerBundle } from './bundle';
2726
import { configureForFirebase } from './config';
27+
import { name, version } from './package.json';
2828

2929
import '../register-module';
3030

packages/firestore/exp/api.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
18+
export { FieldPath, documentId } from '../src/exp/field_path';
19+
20+
export {
21+
FirebaseFirestore,
22+
initializeFirestore,
23+
getFirestore,
24+
enableIndexedDbPersistence,
25+
enableMultiTabIndexedDbPersistence,
26+
clearIndexedDbPersistence,
27+
waitForPendingWrites,
28+
disableNetwork,
29+
enableNetwork,
30+
terminate,
31+
useFirestoreEmulator,
32+
loadBundle,
33+
namedQuery,
34+
ensureFirestoreConfigured
35+
} from '../src/exp/database';
36+
37+
export {
38+
LoadBundleTask,
39+
LoadBundleTaskProgress,
40+
TaskState
41+
} from '../src/exp/bundle';
42+
43+
export { Settings, PersistenceSettings } from '../src/exp/settings';
44+
45+
export {
46+
DocumentChange,
47+
DocumentSnapshot,
48+
QueryDocumentSnapshot,
49+
QuerySnapshot,
50+
snapshotEqual,
51+
SnapshotOptions,
52+
FirestoreDataConverter,
53+
DocumentChangeType,
54+
SnapshotMetadata
55+
} from '../src/exp/snapshot';
56+
57+
export {
58+
DocumentReference,
59+
CollectionReference,
60+
Query,
61+
doc,
62+
collection,
63+
collectionGroup,
64+
SetOptions,
65+
DocumentData,
66+
UpdateData,
67+
refEqual,
68+
queryEqual
69+
} from '../src/exp/reference';
70+
71+
export {
72+
endAt,
73+
endBefore,
74+
startAt,
75+
startAfter,
76+
limit,
77+
limitToLast,
78+
where,
79+
orderBy,
80+
query,
81+
QueryConstraint,
82+
QueryConstraintType,
83+
OrderByDirection,
84+
WhereFilterOp
85+
} from '../src/exp/query';
86+
87+
export { Unsubscribe, SnapshotListenOptions } from '../src/exp/reference_impl';
88+
89+
export { runTransaction, Transaction } from '../src/exp/transaction';
90+
91+
export {
92+
getDoc,
93+
getDocFromCache,
94+
getDocFromServer,
95+
getDocs,
96+
getDocsFromCache,
97+
getDocsFromServer,
98+
onSnapshot,
99+
onSnapshotsInSync,
100+
setDoc,
101+
updateDoc,
102+
deleteDoc,
103+
addDoc,
104+
executeWrite
105+
} from '../src/exp/reference_impl';
106+
107+
export { FieldValue } from '../src/exp/field_value';
108+
109+
export {
110+
increment,
111+
arrayRemove,
112+
arrayUnion,
113+
serverTimestamp,
114+
deleteField
115+
} from '../src/exp/field_value_impl';
116+
117+
export { setLogLevel, LogLevelString as LogLevel } from '../src/util/log';
118+
119+
export { Bytes } from '../src/exp/bytes';
120+
121+
export { WriteBatch, writeBatch } from '../src/exp/write_batch';
122+
123+
export { GeoPoint } from '../src/exp/geo_point';
124+
125+
export { Timestamp } from '../src/exp/timestamp';
126+
127+
export { CACHE_SIZE_UNLIMITED } from '../src/exp/database';
128+
129+
export { FirestoreErrorCode, FirestoreError } from '../src/util/error';
130+
131+
export { AbstractUserDataWriter } from '../src/lite/user_data_writer';

packages/firestore/exp/index.node.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @license
3+
* Copyright 2021 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+
18+
import { registerFirestore } from './register';
19+
20+
registerFirestore('node');
21+
22+
export * from './api';

0 commit comments

Comments
 (0)