Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API Extractor for @firestore/lite + exp #3657

Closed
wants to merge 13 commits into from
582 changes: 582 additions & 0 deletions common/api-review/firestore-exp.api.md

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions common/api-review/firestore-lite.api.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"ora": "4.0.5",
"prettier": "2.0.5",
"protractor": "5.4.2",
"rollup-plugin-copy": "3.3.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollup-plugin-copy-asset doesn't allow me to move the proto files to dist/lite/src/proto

"rxjs": "6.6.2",
"semver": "7.3.2",
"simple-git": "1.132.0",
Expand All @@ -157,4 +158,4 @@
"pre-commit": "node tools/gitHooks/precommit.js"
}
}
}
}
8 changes: 8 additions & 0 deletions packages/firestore/exp/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../../config/api-extractor.json",
"mainEntryPointFilePath": "../dist/exp/firestore/exp/index.d.ts",
"dtsRollup": {
"enabled": true,
"publicTrimmedFilePath": "../dist/exp/index.d.ts"
}
}
23 changes: 19 additions & 4 deletions packages/firestore/exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ export {
waitForPendingWrites,
disableNetwork,
enableNetwork,
terminate
terminate,
Settings
} from './src/api/database';

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

export { SnapshotMetadata } from '../src/api/database';
Expand All @@ -60,12 +64,19 @@ export {
limit,
limitToLast,
where,
orderBy
orderBy,
SetOptions,
QueryConstraintType,
DocumentData,
UpdateData,
OrderByDirection
} from '../lite/src/api/reference';

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

export {
FirestoreErrorCode,
FirestoreError,
getDoc,
getDocFromCache,
getDocFromServer,
Expand All @@ -89,7 +100,7 @@ export {
serverTimestamp
} from '../lite/src/api/field_value';

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

export { Blob } from '../src/api/blob';

Expand All @@ -102,3 +113,7 @@ export { GeoPoint } from '../src/api/geo_point';
export { Timestamp } from '../src/api/timestamp';

export { refEqual, queryEqual } from '../lite/src/api/reference';

export { SnapshotListenOptions } from './src/api/reference';

export { CACHE_SIZE_UNLIMITED } from '../src/api/database';
2 changes: 1 addition & 1 deletion packages/firestore/exp/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@firebase/firestore/exp",
"name": "@firebase/firestore-exp",
"description": "A tree-shakeable version of the Firestore SDK",
"main": "../dist/exp/index.node.umd.js",
"main-esm": "../dist/exp/index.node.esm2017.js",
Expand Down
44 changes: 19 additions & 25 deletions packages/firestore/exp/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

import * as firestore from '../../../exp-types';

import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
import { _FirebaseService, FirebaseApp } from '@firebase/app-types-exp';
import { Provider } from '@firebase/component';
Expand All @@ -37,7 +35,10 @@ import {
MultiTabOfflineComponentProvider,
OnlineComponentProvider
} from '../../../src/core/component_provider';
import { Firestore as LiteFirestore } from '../../../lite/src/api/database';
import {
Firestore as LiteFirestore,
Settings as LiteSettings
} from '../../../lite/src/api/database';
import { cast } from '../../../lite/src/api/util';
import { Code, FirestoreError } from '../../../src/util/error';
import { Deferred } from '../../../src/util/promise';
Expand Down Expand Up @@ -65,12 +66,15 @@ import { logDebug } from '../../../src/util/log';

const LOG_TAG = 'Firestore';

export interface Settings extends LiteSettings {
cacheSizeBytes?: number;
}

/**
* The root reference to the Firestore database and the entry point for the
* tree-shakeable SDK.
*/
export class Firestore extends LiteFirestore
implements firestore.FirebaseFirestore, _FirebaseService {
export class Firestore extends LiteFirestore implements _FirebaseService {
readonly _queue = new AsyncQueue();
readonly _persistenceKey: string;
readonly _clientId = AutoId.newId();
Expand All @@ -81,7 +85,7 @@ export class Firestore extends LiteFirestore

// We override the Settings property of the Lite SDK since the full Firestore
// SDK supports more settings.
protected _settings?: firestore.Settings;
protected _settings?: Settings;

constructor(
app: FirebaseApp,
Expand Down Expand Up @@ -128,7 +132,7 @@ export class Firestore extends LiteFirestore
};
}

_getSettings(): firestore.Settings {
_getSettings(): Settings {
return super._getSettings();
}

Expand Down Expand Up @@ -160,7 +164,7 @@ export class Firestore extends LiteFirestore

export function initializeFirestore(
app: FirebaseApp,
settings: firestore.Settings
settings: Settings
): Firestore {
const firestore = _getProvider(
app,
Expand All @@ -187,7 +191,7 @@ export function getFirestore(app: FirebaseApp): Firestore {
}

export function enableIndexedDbPersistence(
firestore: firestore.FirebaseFirestore
firestore: Firestore
): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
verifyNotInitialized(firestoreImpl);
Expand All @@ -213,7 +217,7 @@ export function enableIndexedDbPersistence(
}

export function enableMultiTabIndexedDbPersistence(
firestore: firestore.FirebaseFirestore
firestore: Firestore
): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
verifyNotInitialized(firestoreImpl);
Expand Down Expand Up @@ -243,9 +247,7 @@ export function enableMultiTabIndexedDbPersistence(
);
}

export function clearIndexedDbPersistence(
firestore: firestore.FirebaseFirestore
): Promise<void> {
export function clearIndexedDbPersistence(firestore: Firestore): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
if (firestoreImpl._initialized && !firestoreImpl._terminated) {
throw new FirestoreError(
Expand All @@ -272,18 +274,14 @@ export function clearIndexedDbPersistence(
return deferred.promise;
}

export function waitForPendingWrites(
firestore: firestore.FirebaseFirestore
): Promise<void> {
export function waitForPendingWrites(firestore: Firestore): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
return getSyncEngine(firestoreImpl).then(syncEngine =>
enqueueWaitForPendingWrites(firestoreImpl._queue, syncEngine)
);
}

export function enableNetwork(
firestore: firestore.FirebaseFirestore
): Promise<void> {
export function enableNetwork(firestore: Firestore): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
return Promise.all([
getRemoteStore(firestoreImpl),
Expand All @@ -298,9 +296,7 @@ export function enableNetwork(
);
}

export function disableNetwork(
firestore: firestore.FirebaseFirestore
): Promise<void> {
export function disableNetwork(firestore: Firestore): Promise<void> {
const firestoreImpl = cast(firestore, Firestore);
return Promise.all([
getRemoteStore(firestoreImpl),
Expand All @@ -315,9 +311,7 @@ export function disableNetwork(
);
}

export function terminate(
firestore: firestore.FirebaseFirestore
): Promise<void> {
export function terminate(firestore: Firestore): Promise<void> {
_removeServiceInstance(firestore.app, 'firestore-exp');
const firestoreImpl = cast(firestore, Firestore);
return firestoreImpl.delete();
Expand Down
Loading