Skip to content

API Extractor support for Firestore Exp and Lite #4095

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

Merged
merged 32 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1e359b5
Script to Prune .dts files (with tests)
schmidt-sebastian Nov 19, 2020
8a081c3
Merge branch 'master' into mrschmidt/standalonescript
schmidt-sebastian Nov 19, 2020
f3f24da
API Extractor for Firestore
schmidt-sebastian Nov 19, 2020
1cb26d3
Add API Reports
schmidt-sebastian Nov 20, 2020
a782916
Ignore missing release and @Hideconstructor warning
schmidt-sebastian Nov 20, 2020
db711f5
s/return/returns
schmidt-sebastian Nov 20, 2020
8161362
Add Hyphen
schmidt-sebastian Nov 20, 2020
c1ac88d
Update API Extractor configuration
schmidt-sebastian Nov 20, 2020
6ba806e
Add Lite configuration
schmidt-sebastian Nov 20, 2020
0b6a18e
Lint fix
schmidt-sebastian Nov 20, 2020
299d267
Fix parenthesis
schmidt-sebastian Nov 20, 2020
1f2ac1f
HTML escape
schmidt-sebastian Nov 20, 2020
6d5b216
Ignore ae-unresolved-link
schmidt-sebastian Nov 20, 2020
ef6d871
Add ESLint type
schmidt-sebastian Nov 20, 2020
dbfaba7
yarn.lock
schmidt-sebastian Nov 20, 2020
c28b5f2
Misc fixes
schmidt-sebastian Nov 20, 2020
fcd5d3c
Move to /repo-scripts
schmidt-sebastian Nov 20, 2020
f4d4952
Update package.json
schmidt-sebastian Nov 20, 2020
9a286f4
Add TODO/test
schmidt-sebastian Nov 20, 2020
d7909d5
Update yarn.lock
schmidt-sebastian Nov 21, 2020
3f8bbf2
Fix JSON
schmidt-sebastian Nov 21, 2020
821a6da
Merge
schmidt-sebastian Nov 24, 2020
873b9ea
Merge
schmidt-sebastian Nov 24, 2020
d98ca33
Merge branch 'master' into mrschmidt/standalonescript
schmidt-sebastian Nov 24, 2020
6eaa0ac
Merge
schmidt-sebastian Nov 24, 2020
4911012
Cleanup
schmidt-sebastian Nov 24, 2020
c1d89d0
WIP
schmidt-sebastian Nov 24, 2020
3c2dd19
Fix yarn.lock
schmidt-sebastian Nov 24, 2020
d94c544
Merge branch 'mrschmidt/standalonescript' into mrschmidt/apiextract
schmidt-sebastian Nov 24, 2020
89a574b
Update package.json
schmidt-sebastian Nov 24, 2020
5fa16b2
Merge
schmidt-sebastian Nov 25, 2020
decc324
Prettier/Cleanup
schmidt-sebastian Nov 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
551 changes: 551 additions & 0 deletions common/api-review/firestore-exp.api.md

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@
"repo-scripts/*"
],
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"@babel/preset-env": "7.12.1",
"@changesets/changelog-github": "0.2.7",
"@changesets/cli": "2.11.2",
"api-documenter-me": "0.1.0",
"api-extractor-me": "0.1.0",
"@types/chai": "4.2.14",
"@types/chai-as-promised": "7.1.3",
"@types/child-process-promise": "2.2.1",
"@types/clone": "2.1.0",
"@types/eslint": "7.2.5",
"@types/inquirer": "7.3.1",
"@types/listr": "0.14.2",
"@types/long": "4.0.1",
Expand All @@ -86,10 +88,9 @@
"@typescript-eslint/eslint-plugin": "4.8.1",
"@typescript-eslint/eslint-plugin-tslint": "4.8.1",
"@typescript-eslint/parser": "4.8.1",
"api-documenter-me": "0.1.0",
"api-extractor-me": "0.1.0",
"babel-loader": "8.2.1",
"@babel/core": "7.12.3",
"@babel/preset-env": "7.12.1",
"@babel/plugin-transform-modules-commonjs": "7.12.1",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"chalk": "4.1.0",
Expand All @@ -100,6 +101,7 @@
"dependency-graph": "0.9.0",
"eslint": "7.13.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-unused-imports": "1.0.0",
"express": "4.17.1",
"find-free-port": "2.0.0",
"firebase-functions": "3.11.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/firestore/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ module.exports = {
]
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'camelcase': 'off',
'import/no-duplicates': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
},
{
files: ['**/*.test.ts', '**/test/**/*.ts'],
rules: {
Expand Down
23 changes: 23 additions & 0 deletions packages/firestore/exp/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "../../../config/api-extractor.json",
"mainEntryPointFilePath": "../dist/firestore/exp/index.d.ts",
"dtsRollup": {
"enabled": true,
"publicTrimmedFilePath": "../dist/exp/private.d.ts"
},
"messages": {
"extractorMessageReporting": {
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "none"
}
},
"tsdocMessageReporting": {
"tsdoc-undefined-tag": {
"logLevel": "none"
Copy link
Member

Choose a reason for hiding this comment

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

Do you not want to get warned about APIs that don't have documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This hides the warning for @hideconstructor.

}
}
}
}
11 changes: 8 additions & 3 deletions packages/firestore/exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export {
waitForPendingWrites,
disableNetwork,
enableNetwork,
terminate
terminate,
Settings,
PersistenceSettings
} from './src/api/database';

export {
Expand Down Expand Up @@ -68,9 +70,12 @@ export {
QueryConstraintType,
DocumentData,
UpdateData,
OrderByDirection
OrderByDirection,
WhereFilterOp
} from '../lite/src/api/reference';

export { Unsubscribe } from '../src/api/observer';

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

export {
Expand All @@ -97,7 +102,7 @@ export {
serverTimestamp
} from '../lite/src/api/field_value';

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

export { Bytes } from '../lite/src/api/bytes';

Expand Down
4 changes: 2 additions & 2 deletions packages/firestore/exp/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"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",
"module": "../dist/exp/index.browser.esm2017.js",
"browser": "../dist/exp/index.browser.esm2017.js",
"react-native": "../dist/exp/index.rn.esm2017.js",
"typings": "../exp-types/index.d.ts",
"typings": "../dist/exp/index.d.ts",
"private": true
}
6 changes: 6 additions & 0 deletions packages/firestore/exp/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import { Component, ComponentType } from '@firebase/component';
import { FirebaseFirestore } from './src/api/database';
import { version } from '../package.json';

declare module '@firebase/component' {
interface NameServiceMapping {
'firestore-exp': FirebaseFirestore;
}
}

export function registerFirestore(): void {
_registerComponent(
new Component(
Expand Down
61 changes: 32 additions & 29 deletions packages/firestore/exp/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
import { _FirebaseService, FirebaseApp } from '@firebase/app-types-exp';
import { FirebaseApp } from '@firebase/app-types-exp';
import { Provider } from '@firebase/component';

import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
Expand Down Expand Up @@ -52,30 +52,33 @@ import {
indexedDbClearPersistence,
indexedDbStoragePrefix
} from '../../../src/local/indexeddb_persistence';
import { PersistenceSettings } from '../../../exp-types';

/** DOMException error code constants. */
const DOM_EXCEPTION_INVALID_STATE = 11;
const DOM_EXCEPTION_ABORTED = 20;
const DOM_EXCEPTION_QUOTA_EXCEEDED = 22;

export interface PersistenceSettings {
forceOwnership?: boolean;
}

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

/**
* The Cloud Firestore service interface.
*
* Do not call this constructor directly. Instead, use {@link getFirestore()}.
* Do not call this constructor directly. Instead, use {@link getFirestore}.
*/
export class FirebaseFirestore
extends LiteFirestore
implements _FirebaseService {
extends LiteFirestore {
readonly _queue = new AsyncQueue();
readonly _persistenceKey: string;

_firestoreClient: FirestoreClient | undefined;

/** @hideconstructor */
constructor(
databaseIdOrApp: DatabaseId | FirebaseApp,
authProvider: Provider<FirebaseAuthInternalName>
Expand All @@ -98,13 +101,13 @@ export class FirebaseFirestore
/**
* Initializes a new instance of Cloud Firestore with the provided settings.
* Can only be called before any other function, including
* {@link getFirestore()}. If the custom settings are empty, this function is
* equivalent to calling {@link getFirestore()}.
* {@link getFirestore}. If the custom settings are empty, this function is
* equivalent to calling {@link getFirestore}.
*
* @param app The {@link FirebaseApp} with which the `Firestore` instance will
* @param app - The {@link FirebaseApp} with which the `Firestore` instance will
* be associated.
* @param settings A settings object to configure the `Firestore` instance.
* @return A newly initialized `Firestore` instance.
* @param settings - A settings object to configure the `Firestore` instance.
* @returns A newly initialized `Firestore` instance.
*/
export function initializeFirestore(
app: FirebaseApp,
Expand Down Expand Up @@ -135,9 +138,9 @@ export function initializeFirestore(
* provided {@link FirebaseApp}. If no instance exists, initializes a new
* instance with default settings.
*
* @param app The {@link FirebaseApp} instance that the returned Firestore
* @param app - The {@link FirebaseApp} instance that the returned Firestore
* instance is associated with.
* @return The `Firestore` instance of the provided app.
* @returns The `Firestore` instance of the provided app.
*/
export function getFirestore(app: FirebaseApp): FirebaseFirestore {
return _getProvider(app, 'firestore-exp').getImmediate() as FirebaseFirestore;
Expand All @@ -147,8 +150,8 @@ export function getFirestore(app: FirebaseApp): FirebaseFirestore {
* Attempts to enable persistent storage, if possible.
*
* Must be called before any other functions (other than
* {@link initializeFirestore()}, {@link getFirestore()} or
* {@link clearIndexedDbPersistence()}.
* {@link initializeFirestore}, {@link getFirestore} or
* {@link clearIndexedDbPersistence}.
*
* If this fails, `enableIndexedDbPersistence()` will reject the promise it
* returns. Note that even after this failure, the `Firestore` instance will
Expand All @@ -161,9 +164,9 @@ export function getFirestore(app: FirebaseApp): FirebaseFirestore {
* * unimplemented: The browser is incompatible with the offline
* persistence implementation.
*
* @param firestore The `Firestore` instance to enable persistence for.
* @param persistenceSettings Optional settings object to configure persistence.
* @return A promise that represents successfully enabling persistent storage.
* @param firestore - The `Firestore` instance to enable persistence for.
* @param persistenceSettings - Optional settings object to configure persistence.
* @returns A promise that represents successfully enabling persistent storage.
*/
export function enableIndexedDbPersistence(
firestore: FirebaseFirestore,
Expand Down Expand Up @@ -205,8 +208,8 @@ export function enableIndexedDbPersistence(
* * unimplemented: The browser is incompatible with the offline
* persistence implementation.
*
* @param firestore The `Firestore` instance to enable persistence for.
* @return A promise that represents successfully enabling persistent
* @param firestore - The `Firestore` instance to enable persistence for.
* @returns A promise that represents successfully enabling persistent
* storage.
*/
export function enableMultiTabIndexedDbPersistence(
Expand Down Expand Up @@ -307,7 +310,7 @@ function canFallbackFromIndexedDbError(
* Must be called while the `Firestore` instance is not started (after the app is
* terminated or when the app is first initialized). On startup, this function
* must be called before other functions (other than {@link
* initializeFirestore()} or {@link getFirestore()})). If the `Firestore`
* initializeFirestore} or {@link getFirestore})). If the `Firestore`
* instance is still running, the promise will be rejected with the error code
* of `failed-precondition`.
*
Expand All @@ -318,8 +321,8 @@ function canFallbackFromIndexedDbError(
* to the disclosure of cached data in between user sessions, we strongly
* recommend not enabling persistence at all.
*
* @param firestore The `Firestore` instance to clear persistence for.
* @return A promise that is resolved when the persistent storage is
* @param firestore - The `Firestore` instance to clear persistence for.
* @returns A promise that is resolved when the persistent storage is
* cleared. Otherwise, the promise is rejected with an error.
*/
export function clearIndexedDbPersistence(
Expand Down Expand Up @@ -360,7 +363,7 @@ export function clearIndexedDbPersistence(
* Any outstanding `waitForPendingWrites()` Promises are rejected during user
* changes.
*
* @return A Promise which resolves when all currently pending writes have been
* @returns A Promise which resolves when all currently pending writes have been
* acknowledged by the backend.
*/
export function waitForPendingWrites(
Expand All @@ -372,9 +375,9 @@ export function waitForPendingWrites(

/**
* Re-enables use of the network for this Firestore instance after a prior
* call to {@link disableNetwork()}.
* call to {@link disableNetwork}.
*
* @return A promise that is resolved once the network has been enabled.
* @returns A promise that is resolved once the network has been enabled.
*/
export function enableNetwork(firestore: FirebaseFirestore): Promise<void> {
const client = ensureFirestoreConfigured(firestore);
Expand All @@ -383,11 +386,11 @@ export function enableNetwork(firestore: FirebaseFirestore): Promise<void> {

/**
* Disables network usage for this instance. It can be re-enabled via {@link
* enableNetwork()}. While the network is disabled, any snapshot listeners,
* enableNetwork}. While the network is disabled, any snapshot listeners,
* `getDoc()` or `getDocs()` calls will return results from cache, and any write
* operations will be queued until the network is restored.
*
* @return A promise that is resolved once the network has been disabled.
* @returns A promise that is resolved once the network has been disabled.
*/
export function disableNetwork(firestore: FirebaseFirestore): Promise<void> {
const client = ensureFirestoreConfigured(firestore);
Expand All @@ -401,7 +404,7 @@ export function disableNetwork(firestore: FirebaseFirestore): Promise<void> {
* may be used. Any other function will throw a `FirestoreError`.
*
* To restart after termination, create a new instance of FirebaseFirestore with
* {@link getFirestore()}.
* {@link getFirestore}.
*
* Termination does not cancel any pending writes, and any promises that are
* awaiting a response from the server will not be resolved. If you have
Expand All @@ -413,7 +416,7 @@ export function disableNetwork(firestore: FirebaseFirestore): Promise<void> {
* of its resources or in combination with `clearIndexedDbPersistence()` to
* ensure that all local state is destroyed between test runs.
*
* @return A promise that is resolved when the instance has been successfully
* @returns A promise that is resolved when the instance has been successfully
* terminated.
*/
export function terminate(firestore: FirebaseFirestore): Promise<void> {
Expand Down
Loading