Skip to content

Commit

Permalink
Fix platform logging for exp packages (#4740)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Apr 7, 2021
1 parent bd7277d commit 129888c
Show file tree
Hide file tree
Showing 20 changed files with 310 additions and 187 deletions.
12 changes: 10 additions & 2 deletions packages-exp/app-exp/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ import { name as analyticsCompatName } from '../../../packages-exp/analytics-com
import { name as analyticsName } from '../../../packages-exp/analytics-exp/package.json';
import { name as authName } from '../../../packages-exp/auth-exp/package.json';
import { name as authCompatName } from '../../../packages-exp/auth-compat-exp/package.json';
import { name as databaseName } from '../../../packages/database/package.json';
import { name as databaseName } from '../../../packages/database/exp/package.json';
import { name as functionsName } from '../../../packages-exp/functions-exp/package.json';
import { name as functionsCompatName } from '../../../packages-exp/functions-compat/package.json';
import { name as installationsName } from '../../../packages-exp/installations-exp/package.json';
import { name as installationsCompatName } from '../../../packages-exp/installations-compat/package.json';
import { name as messagingName } from '../../../packages-exp/messaging-exp/package.json';
import { name as messagingCompatName } from '../../../packages-exp/messaging-compat/package.json';
import { name as performanceName } from '../../../packages-exp/performance-exp/package.json';
import { name as performanceCompatName } from '../../../packages-exp/performance-compat/package.json';
import { name as remoteConfigName } from '../../../packages-exp/remote-config-exp/package.json';
import { name as remoteConfigCompatName } from '../../../packages-exp/remote-config-compat/package.json';
import { name as storageName } from '../../../packages/storage/package.json';
import { name as firestoreName } from '../../../packages/firestore/package.json';
import { name as storageCompatName } from '../../../packages/storage/compat/package.json';
import { name as firestoreName } from '../../../packages/firestore/exp/package.json';
import { name as firestoreCompatName } from '../../../packages/firestore/compat/package.json';
import { name as packageName } from '../../../packages-exp/firebase-exp/package.json';

/**
Expand All @@ -54,11 +58,15 @@ export const PLATFORM_LOG_STRING = {
[installationsName]: 'fire-iid',
[installationsCompatName]: 'fire-iid-compat',
[messagingName]: 'fire-fcm',
[messagingCompatName]: 'fire-fcm-compat',
[performanceName]: 'fire-perf',
[performanceCompatName]: 'fire-perf-compat',
[remoteConfigName]: 'fire-rc',
[remoteConfigCompatName]: 'fire-rc-compat',
[storageName]: 'fire-gcs',
[storageCompatName]: 'fire-gcs-compat',
[firestoreName]: 'fire-fst',
[firestoreCompatName]: 'fire-fst-compat',
'fire-js': 'fire-js', // Platform identifier for JS SDK.
[packageName]: 'fire-js-all'
} as const;
4 changes: 2 additions & 2 deletions packages-exp/auth-compat-exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@firebase/component';

import * as types from '@firebase/auth-types';
import { version } from './package.json';
import { name, version } from './package.json';
import { Auth } from './src/auth';
import { Persistence } from './src/persistence';
import { PhoneAuthProvider as CompatAuthProvider } from './src/phone_auth_provider';
Expand Down Expand Up @@ -117,7 +117,7 @@ function registerAuthCompat(instance: _FirebaseNamespace): void {
.setMultipleInstances(false)
);

instance.registerVersion('auth-compat', version);
instance.registerVersion(name, version);
}

registerAuthCompat(firebase as _FirebaseNamespace);
8 changes: 2 additions & 6 deletions packages-exp/auth-exp/src/core/auth/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
InstantiationMode
} from '@firebase/component';

import { version } from '../../../package.json';
import { name, version } from '../../../package.json';
import { AuthErrorCode } from '../errors';
import { _assert } from '../util/assert';
import { _getClientVersion, ClientPlatform } from '../util/version';
Expand Down Expand Up @@ -122,9 +122,5 @@ export function registerAuth(clientPlatform: ClientPlatform): void {
).setInstantiationMode(InstantiationMode.EXPLICIT)
);

registerVersion(
_ComponentName.AUTH,
version,
getVersionForPlatform(clientPlatform)
);
registerVersion(name, version, getVersionForPlatform(clientPlatform));
}
23 changes: 23 additions & 0 deletions packages/database/exp/index.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license
* Copyright 2021 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 { registerDatabase } from './register';

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

registerDatabase('node');
28 changes: 1 addition & 27 deletions packages/database/exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,9 @@
* limitations under the License.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { _registerComponent, registerVersion } from '@firebase/app-exp';
import { Component, ComponentType } from '@firebase/component';

import { version } from '../package.json';
import { FirebaseDatabase } from '../src/exp/Database';
import { registerDatabase } from './register';

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

declare module '@firebase/component' {
interface NameServiceMapping {
'database-exp': FirebaseDatabase;
}
}

function registerDatabase(): void {
_registerComponent(
new Component(
'database-exp',
(container, { instanceIdentifier: url }) => {
const app = container.getProvider('app-exp').getImmediate()!;
const authProvider = container.getProvider('auth-internal');
return new FirebaseDatabase(app, authProvider, url);
},
ComponentType.PUBLIC
).setMultipleInstances(true)
);
registerVersion('database-exp', version, 'node');
}

registerDatabase();
47 changes: 47 additions & 0 deletions packages/database/exp/register.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @license
* Copyright 2021 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.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { _registerComponent, registerVersion } from '@firebase/app-exp';
import { Component, ComponentType } from '@firebase/component';

import { name, version } from '../package.json';
import { FirebaseDatabase } from '../src/exp/Database';

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

declare module '@firebase/component' {
interface NameServiceMapping {
'database-exp': FirebaseDatabase;
}
}

export function registerDatabase(variant?: string): void {
_registerComponent(
new Component(
'database-exp',
(container, { instanceIdentifier: url }) => {
const app = container.getProvider('app-exp').getImmediate()!;
const authProvider = container.getProvider('auth-internal');
return new FirebaseDatabase(app, authProvider, url);
},
ComponentType.PUBLIC
).setMultipleInstances(true)
);
registerVersion(name, version, variant);
}
2 changes: 1 addition & 1 deletion packages/database/rollup.config.exp.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const es5Builds = [
* Node.js Build
*/
{
input: 'exp/index.ts',
input: 'exp/index.node.ts',
output: [
{ file: path.resolve('exp', expPkg.main), format: 'cjs', sourcemap: true }
],
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/compat/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import firebase from '@firebase/app-compat';
import { FirebaseNamespace } from '@firebase/app-types';

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

import { registerBundle } from './bundle';
import { configureForFirebase } from './config';
import { name, version } from './package.json';

/**
* Registers the main Firestore Node build with the components framework.
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/compat/index.rn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import firebase from '@firebase/app-compat';
import { FirebaseNamespace } from '@firebase/app-types';

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

import { registerBundle } from './bundle';
import { configureForFirebase } from './config';
import { name, version } from './package.json';

/**
* Registers the main Firestore ReactNative build with the components framework.
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/compat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import firebase from '@firebase/app-compat';
import { FirebaseNamespace } from '@firebase/app-types';
import * as types from '@firebase/firestore-types';

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

import { registerBundle } from './bundle';
import { configureForFirebase } from './config';
import { name, version } from './package.json';

import '../register-module';

Expand Down
131 changes: 131 additions & 0 deletions packages/firestore/exp/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/**
* @license
* Copyright 2021 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 { FieldPath, documentId } from '../src/exp/field_path';

export {
FirebaseFirestore,
initializeFirestore,
getFirestore,
enableIndexedDbPersistence,
enableMultiTabIndexedDbPersistence,
clearIndexedDbPersistence,
waitForPendingWrites,
disableNetwork,
enableNetwork,
terminate,
useFirestoreEmulator,
loadBundle,
namedQuery,
ensureFirestoreConfigured
} from '../src/exp/database';

export {
LoadBundleTask,
LoadBundleTaskProgress,
TaskState
} from '../src/exp/bundle';

export { Settings, PersistenceSettings } from '../src/exp/settings';

export {
DocumentChange,
DocumentSnapshot,
QueryDocumentSnapshot,
QuerySnapshot,
snapshotEqual,
SnapshotOptions,
FirestoreDataConverter,
DocumentChangeType,
SnapshotMetadata
} from '../src/exp/snapshot';

export {
DocumentReference,
CollectionReference,
Query,
doc,
collection,
collectionGroup,
SetOptions,
DocumentData,
UpdateData,
refEqual,
queryEqual
} from '../src/exp/reference';

export {
endAt,
endBefore,
startAt,
startAfter,
limit,
limitToLast,
where,
orderBy,
query,
QueryConstraint,
QueryConstraintType,
OrderByDirection,
WhereFilterOp
} from '../src/exp/query';

export { Unsubscribe, SnapshotListenOptions } from '../src/exp/reference_impl';

export { runTransaction, Transaction } from '../src/exp/transaction';

export {
getDoc,
getDocFromCache,
getDocFromServer,
getDocs,
getDocsFromCache,
getDocsFromServer,
onSnapshot,
onSnapshotsInSync,
setDoc,
updateDoc,
deleteDoc,
addDoc,
executeWrite
} from '../src/exp/reference_impl';

export { FieldValue } from '../src/exp/field_value';

export {
increment,
arrayRemove,
arrayUnion,
serverTimestamp,
deleteField
} from '../src/exp/field_value_impl';

export { setLogLevel, LogLevelString as LogLevel } from '../src/util/log';

export { Bytes } from '../src/exp/bytes';

export { WriteBatch, writeBatch } from '../src/exp/write_batch';

export { GeoPoint } from '../src/exp/geo_point';

export { Timestamp } from '../src/exp/timestamp';

export { CACHE_SIZE_UNLIMITED } from '../src/exp/database';

export { FirestoreErrorCode, FirestoreError } from '../src/util/error';

export { AbstractUserDataWriter } from '../src/lite/user_data_writer';
22 changes: 22 additions & 0 deletions packages/firestore/exp/index.node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @license
* Copyright 2021 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 { registerFirestore } from './register';

registerFirestore('node');

export * from './api';
Loading

0 comments on commit 129888c

Please sign in to comment.