Skip to content

Commit 1dfec9a

Browse files
Add Api Extractor for @firestore/lite
1 parent e8b950f commit 1dfec9a

37 files changed

+1197
-574
lines changed

common/api-review/firestore-lite.api.md

Lines changed: 454 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"@changesets/cli": "2.9.2",
6868
"@microsoft/api-documenter": "7.8.21",
6969
"@microsoft/api-extractor": "7.9.2",
70-
"@types/mz": "2.7.1",
7170
"@types/chai": "4.2.12",
7271
"@types/chai-as-promised": "7.1.3",
7372
"@types/child-process-promise": "2.2.1",
@@ -136,6 +135,7 @@
136135
"ora": "4.0.5",
137136
"prettier": "2.0.5",
138137
"protractor": "5.4.2",
138+
"rollup-plugin-copy": "3.3.0",
139139
"rxjs": "6.6.2",
140140
"semver": "7.3.2",
141141
"simple-git": "1.132.0",
@@ -157,4 +157,4 @@
157157
"pre-commit": "node tools/gitHooks/precommit.js"
158158
}
159159
}
160-
}
160+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../../config/api-extractor.json",
3+
"mainEntryPointFilePath": "../dist/lite/firestore/lite/index.d.ts",
4+
"dtsRollup": {
5+
"enabled": true,
6+
"publicTrimmedFilePath": "../dist/lite/index.d.ts"
7+
}
8+
}

packages/firestore/lite/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@ import { registerFirestore } from './register';
2020
registerFirestore();
2121

2222
export {
23+
Settings,
2324
Firestore as FirebaseFirestore,
2425
initializeFirestore,
2526
getFirestore,
2627
terminate
2728
} from './src/api/database';
2829

2930
export {
31+
DocumentData,
32+
UpdateData,
3033
DocumentReference,
3134
Query,
3235
QueryConstraint,
36+
QueryConstraintType,
3337
CollectionReference,
38+
OrderByDirection,
39+
WhereFilterOp,
3440
collection,
3541
collectionGroup,
3642
doc,

packages/firestore/lite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@firebase/firestore/lite",
2+
"name": "@firebase/firestore-lite",
33
"description": "A lite version of the Firestore SDK",
44
"main": "../dist/lite/index.node.umd.js",
55
"main-esm": "../dist/lite/index.node.esm2017.js",

packages/firestore/lite/src/api/database.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '../../../lite-types';
19-
2018
import { _getProvider, _removeServiceInstance } from '@firebase/app-exp';
2119
import { FirebaseApp, _FirebaseService } from '@firebase/app-types-exp';
2220
import { Provider } from '@firebase/component';
@@ -31,17 +29,22 @@ import {
3129
import { cast } from './util';
3230
import { removeComponents } from './components';
3331

32+
export interface Settings {
33+
host?: string;
34+
ssl?: boolean;
35+
ignoreUndefinedProperties?: boolean;
36+
}
37+
3438
/**
3539
* The root reference to the Firestore Lite database.
3640
*/
37-
export class Firestore
38-
implements firestore.FirebaseFirestore, _FirebaseService {
41+
export class Firestore implements _FirebaseService {
3942
readonly _databaseId: DatabaseId;
4043
readonly _credentials: CredentialsProvider;
4144
readonly _persistenceKey: string = '(lite)';
4245

4346
// Assigned via _configureClient()
44-
protected _settings?: firestore.Settings;
47+
protected _settings?: Settings;
4548
private _settingsFrozen = false;
4649

4750
// A task that is assigned when the terminate() is invoked and resolved when
@@ -64,7 +67,7 @@ export class Firestore
6467
return this._terminateTask !== undefined;
6568
}
6669

67-
_configureClient(settings: firestore.Settings): void {
70+
_configureClient(settings: Settings): void {
6871
if (this._settingsFrozen) {
6972
throw new FirestoreError(
7073
Code.FAILED_PRECONDITION,
@@ -76,7 +79,7 @@ export class Firestore
7679
this._settings = settings;
7780
}
7881

79-
_getSettings(): firestore.Settings {
82+
_getSettings(): Settings {
8083
if (!this._settings) {
8184
this._settings = {};
8285
}
@@ -123,7 +126,7 @@ export class Firestore
123126

124127
export function initializeFirestore(
125128
app: FirebaseApp,
126-
settings: firestore.Settings
129+
settings: Settings
127130
): Firestore {
128131
const firestore = _getProvider(
129132
app,
@@ -137,9 +140,7 @@ export function getFirestore(app: FirebaseApp): Firestore {
137140
return _getProvider(app, 'firestore/lite').getImmediate() as Firestore;
138141
}
139142

140-
export function terminate(
141-
firestore: firestore.FirebaseFirestore
142-
): Promise<void> {
143+
export function terminate(firestore: Firestore): Promise<void> {
143144
_removeServiceInstance(firestore.app, 'firestore/lite');
144145
const firestoreClient = cast(firestore, Firestore);
145146
return firestoreClient.delete();

packages/firestore/lite/src/api/field_path.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '../../../lite-types';
19-
2018
import { BaseFieldPath } from '../../../src/api/field_path';
2119
import { cast } from './util';
2220
import { DOCUMENT_KEY_NAME } from '../../../src/model/path';
@@ -26,7 +24,7 @@ import { DOCUMENT_KEY_NAME } from '../../../src/model/path';
2624
* field name (referring to a top-level field in the document), or a list of
2725
* field names (referring to a nested field in the document).
2826
*/
29-
export class FieldPath extends BaseFieldPath implements firestore.FieldPath {
27+
export class FieldPath extends BaseFieldPath {
3028
// Note: This class is stripped down a copy of the FieldPath class in the
3129
// legacy SDK. The changes are:
3230
// - The `documentId()` static method has been removed
@@ -43,12 +41,12 @@ export class FieldPath extends BaseFieldPath implements firestore.FieldPath {
4341
super(fieldNames);
4442
}
4543

46-
isEqual(other: firestore.FieldPath): boolean {
44+
isEqual(other: FieldPath): boolean {
4745
const path = cast(other, FieldPath);
4846
return this._internalPath.isEqual(path._internalPath);
4947
}
5048
}
5149

52-
export function documentId(): firestore.FieldPath {
50+
export function documentId(): FieldPath {
5351
return new FieldPath(DOCUMENT_KEY_NAME);
5452
}

packages/firestore/lite/src/api/field_value.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* limitations under the License.
1616
*/
1717

18-
import * as firestore from '../../../lite-types';
19-
2018
import { validateAtLeastNumberOfArgs } from '../../../src/util/input_validation';
2119
import {
2220
ArrayRemoveFieldValueImpl,
@@ -30,8 +28,7 @@ import { ParseContext } from '../../../src/api/user_data_reader';
3028
import { FieldTransform } from '../../../src/model/mutation';
3129

3230
/** The public FieldValue class of the lite API. */
33-
export abstract class FieldValue extends SerializableFieldValue
34-
implements firestore.FieldValue {}
31+
export abstract class FieldValue extends SerializableFieldValue {}
3532

3633
/**
3734
* A delegate class that allows the FieldValue implementations returned by
@@ -42,7 +39,7 @@ export abstract class FieldValue extends SerializableFieldValue
4239
* implementations as the base FieldValue class differs between the lite, full
4340
* and legacy SDK.
4441
*/
45-
class FieldValueDelegate extends FieldValue implements firestore.FieldValue {
42+
class FieldValueDelegate extends FieldValue {
4643
readonly _methodName: string;
4744

4845
constructor(readonly _delegate: SerializableFieldValue) {
@@ -54,25 +51,25 @@ class FieldValueDelegate extends FieldValue implements firestore.FieldValue {
5451
return this._delegate._toFieldTransform(context);
5552
}
5653

57-
isEqual(other: firestore.FieldValue): boolean {
54+
isEqual(other: FieldValue): boolean {
5855
if (!(other instanceof FieldValueDelegate)) {
5956
return false;
6057
}
6158
return this._delegate.isEqual(other._delegate);
6259
}
6360
}
6461

65-
export function deleteField(): firestore.FieldValue {
62+
export function deleteField(): FieldValue {
6663
return new FieldValueDelegate(new DeleteFieldValueImpl('deleteField'));
6764
}
6865

69-
export function serverTimestamp(): firestore.FieldValue {
66+
export function serverTimestamp(): FieldValue {
7067
return new FieldValueDelegate(
7168
new ServerTimestampFieldValueImpl('serverTimestamp')
7269
);
7370
}
7471

75-
export function arrayUnion(...elements: unknown[]): firestore.FieldValue {
72+
export function arrayUnion(...elements: unknown[]): FieldValue {
7673
validateAtLeastNumberOfArgs('arrayUnion()', arguments, 1);
7774
// NOTE: We don't actually parse the data until it's used in set() or
7875
// update() since we'd need the Firestore instance to do this.
@@ -81,7 +78,7 @@ export function arrayUnion(...elements: unknown[]): firestore.FieldValue {
8178
);
8279
}
8380

84-
export function arrayRemove(...elements: unknown[]): firestore.FieldValue {
81+
export function arrayRemove(...elements: unknown[]): FieldValue {
8582
validateAtLeastNumberOfArgs('arrayRemove()', arguments, 1);
8683
// NOTE: We don't actually parse the data until it's used in set() or
8784
// update() since we'd need the Firestore instance to do this.
@@ -90,7 +87,7 @@ export function arrayRemove(...elements: unknown[]): firestore.FieldValue {
9087
);
9188
}
9289

93-
export function increment(n: number): firestore.FieldValue {
90+
export function increment(n: number): FieldValue {
9491
return new FieldValueDelegate(
9592
new NumericIncrementFieldValueImpl('increment', n)
9693
);

0 commit comments

Comments
 (0)