@dereekb/firebase 8.0.2 → 8.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/package.json +6 -6
- package/src/lib/client/firestore/driver.accessor.batch.js.map +1 -1
- package/src/lib/client/function/model.function.factory.d.ts +3 -3
- package/src/lib/client/function/model.function.factory.js +2 -0
- package/src/lib/client/function/model.function.factory.js.map +1 -1
- package/src/lib/common/firestore/accessor/document.d.ts +11 -10
- package/src/lib/common/firestore/accessor/document.js +6 -3
- package/src/lib/common/firestore/accessor/document.js.map +1 -1
- package/src/lib/common/firestore/accessor/document.utility.d.ts +1 -1
- package/src/lib/common/firestore/collection/collection.d.ts +105 -24
- package/src/lib/common/firestore/collection/collection.js +75 -10
- package/src/lib/common/firestore/collection/collection.js.map +1 -1
- package/src/lib/common/firestore/error.d.ts +1 -0
- package/src/lib/common/firestore/error.js +8 -0
- package/src/lib/common/firestore/error.js.map +1 -0
- package/src/lib/common/firestore/index.d.ts +1 -0
- package/src/lib/common/firestore/index.js +1 -0
- package/src/lib/common/firestore/index.js.map +1 -1
- package/src/lib/common/firestore/query/constraint.js.map +1 -1
- package/src/lib/common/firestore/snapshot/snapshot.field.js +1 -1
- package/src/lib/common/firestore/snapshot/snapshot.field.js.map +1 -1
- package/src/lib/common/model/function.d.ts +3 -3
- package/src/lib/common/model/function.js +5 -1
- package/src/lib/common/model/function.js.map +1 -1
- package/src/lib/common/model/model.service.d.ts +2 -2
- package/src/lib/common/model/model.service.js +2 -0
- package/src/lib/common/model/model.service.js.map +1 -1
- package/test/CHANGELOG.md +14 -1
- package/test/package.json +8 -8
- package/test/src/lib/common/firestore.mock.item.d.ts +7 -7
- package/test/src/lib/common/firestore.mock.item.js +7 -7
- package/test/src/lib/common/firestore.mock.item.js.map +1 -1
- package/test/src/lib/common/test.driver.accessor.js +46 -58
- package/test/src/lib/common/test.driver.accessor.js.map +1 -1
- package/test/src/lib/common/test.driver.query.js +5 -16
- package/test/src/lib/common/test.driver.query.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
-
## [8.
|
|
5
|
+
## [8.1.2](https://github.com/dereekb/dbx-components/compare/v8.1.1-dev...v8.1.2) (2022-06-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [8.1.1](https://github.com/dereekb/dbx-components/compare/v8.1.0-dev...v8.1.1) (2022-06-18)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# [8.1.0](https://github.com/dereekb/dbx-components/compare/v8.0.1-dev...v8.1.0) (2022-06-18)
|
|
6
14
|
|
|
7
15
|
|
|
8
16
|
### Bug Fixes
|
|
@@ -10,6 +18,11 @@ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/s
|
|
|
10
18
|
* fixed issue with snapshot falsy default values being ignored ([b433bc4](https://github.com/dereekb/dbx-components/commit/b433bc4a63b04d5aab99e1cf67b058cf20e7cc6a))
|
|
11
19
|
|
|
12
20
|
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* added jest fail test utilities ([#13](https://github.com/dereekb/dbx-components/issues/13)) ([5891777](https://github.com/dereekb/dbx-components/commit/5891777470a339892c8e7045c24b5dea174b1736))
|
|
24
|
+
|
|
25
|
+
|
|
13
26
|
|
|
14
27
|
## [8.0.1](https://github.com/dereekb/dbx-components/compare/v8.0.0-dev...v8.0.1) (2022-06-17)
|
|
15
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.2",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@firebase/rules-unit-testing": "^2.0.0"
|
|
6
6
|
},
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"typings": "./src/index.d.ts",
|
|
21
21
|
"dependencies": {},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"rxjs": "^7.0.0",
|
|
24
23
|
"rxfire": "^6.0.3",
|
|
24
|
+
"rxjs": "^7.0.0",
|
|
25
25
|
"firebase": "^9.8.0",
|
|
26
|
-
"@dereekb/util": "8.
|
|
26
|
+
"@dereekb/util": "8.1.2",
|
|
27
27
|
"make-error": "^1.3.0",
|
|
28
28
|
"ts-essentials": "^9.1.2",
|
|
29
29
|
"extra-set": "^2.2.11",
|
|
30
|
-
"@dereekb/rxjs": "8.
|
|
30
|
+
"@dereekb/rxjs": "8.1.2",
|
|
31
31
|
"ms": "^3.0.0-canary.1",
|
|
32
|
-
"@dereekb/model": "8.
|
|
32
|
+
"@dereekb/model": "8.1.2",
|
|
33
33
|
"class-transformer": "^0.5.1",
|
|
34
34
|
"class-validator": "^0.13.2",
|
|
35
|
-
"@dereekb/date": "8.
|
|
35
|
+
"@dereekb/date": "8.1.2",
|
|
36
36
|
"date-fns": "^2.28.0",
|
|
37
37
|
"date-fns-tz": "^1.3.0",
|
|
38
38
|
"rrule": "2.7.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.accessor.batch.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.accessor.batch.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"driver.accessor.batch.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/firestore/driver.accessor.batch.ts"],"names":[],"mappings":";;;AACA,sDAA6M;AAC7M,uEAAiF;AAEjF,iBAAiB;AACjB;;GAEG;AACH,MAAa,uCAA2C,SAAQ,8DAAuC;IACrG,YAAqB,KAAkC,EAAE,WAAiC;QACxF,KAAK,CAAC,WAAW,CAAC,CAAC;QADA,UAAK,GAAL,KAAK,CAA6B;IAEvD,CAAC;IAEQ,MAAM;QACb,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEQ,GAAG,CAAC,IAAuB,EAAE,OAAoB;QACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAqB,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM,CAAC,IAAyB;QACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAA8B,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAnBD,0FAmBC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAI,UAAuC;IAClF,OAAO;QACL,WAAW,EAAE,CAAC,GAAyB,EAAE,EAAE,CAAC,IAAI,uCAAuC,CAAC,UAAU,EAAE,GAAG,CAAC;KACzG,CAAC;AACJ,CAAC;AAJD,8DAIC;AAED,gBAAgB;AAChB,MAAa,kCAAkC;IAI7C,YAAqB,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAH9C,gBAAW,GAAG,wCAA4B,CAAC,KAAK,CAAC;QACjD,oBAAe,GAAG,yBAAyB,CAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAEV,CAAC;CAC5D;AALD,gFAKC;AAED,SAAgB,yBAAyB,CAAI,KAAkC;IAC7E,OAAO,IAAI,kCAAkC,CAAI,KAAK,CAAC,CAAC;AAC1D,CAAC;AAFD,8DAEC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MaybeNot } from '@dereekb/util';
|
|
2
2
|
import { Functions } from 'firebase/functions';
|
|
3
3
|
import { NonNever } from 'ts-essentials';
|
|
4
|
-
import { FirestoreModelIdentity,
|
|
4
|
+
import { FirestoreModelIdentity, FirestoreModelTypes, OnCallCreateModelResult } from '../../common';
|
|
5
5
|
import { FirebaseFunctionTypeMap, FirebaseFunctionMap, FirebaseFunction } from './function';
|
|
6
6
|
import { FirebaseFunctionTypeConfigMap } from './function.factory';
|
|
7
7
|
export declare type ModelFirebaseCrudFunction<I> = FirebaseFunction<I, void>;
|
|
@@ -9,7 +9,7 @@ export declare type ModelFirebaseCreateFunction<I, O extends OnCallCreateModelRe
|
|
|
9
9
|
export declare type ModelFirebaseUpdateFunction<I> = ModelFirebaseCrudFunction<I>;
|
|
10
10
|
export declare type ModelFirebaseDeleteFunction<I> = ModelFirebaseCrudFunction<I>;
|
|
11
11
|
export declare type ModelFirebaseCrudFunctionTypeMap<T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
12
|
-
[K in
|
|
12
|
+
[K in FirestoreModelTypes<T>]: ModelFirebaseCrudFunctionTypeMapEntry;
|
|
13
13
|
};
|
|
14
14
|
export declare type ModelFirebaseCrudFunctionTypeMapEntry = MaybeNot | Partial<ModelFirebaseCrudFunctionCreateTypeConfig & ModelFirebaseCrudFunctionUpdateTypeConfig & ModelFirebaseCrudFunctionDeleteTypeConfig>;
|
|
15
15
|
export declare type ModelFirebaseCrudFunctionCreateTypeConfig<I = unknown> = {
|
|
@@ -27,7 +27,7 @@ export declare type ModelFirebaseCrudFunctionDeleteTypeConfig<I = unknown> = {
|
|
|
27
27
|
* The FirestoreModelIdentities that are allowed are passed too which add type checking to make sure we're passing the expected identities.
|
|
28
28
|
*/
|
|
29
29
|
export declare type ModelFirebaseCrudFunctionConfigMap<C extends ModelFirebaseCrudFunctionTypeMap<T>, T extends FirestoreModelIdentity> = NonNever<{
|
|
30
|
-
[K in
|
|
30
|
+
[K in FirestoreModelTypes<T>]: C[K] extends null ? never : (keyof C[K])[];
|
|
31
31
|
}>;
|
|
32
32
|
export declare type ModelFirebaseCrudFunctionMap<C extends ModelFirebaseCrudFunctionTypeMap> = ModelFirebaseCrudFunctionRawMap<C>;
|
|
33
33
|
export declare type ModelFirebaseCrudFunctionRawMap<C extends ModelFirebaseCrudFunctionTypeMap> = NonNever<{
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
// The use of any here does not degrade the type-safety. The correct type is inferred in most cases.
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.modelFirebaseFunctionMapFactory = void 0;
|
|
4
6
|
const firebase_1 = require("@dereekb/firebase");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.function.factory.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/model.function.factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.function.factory.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/client/function/model.function.factory.ts"],"names":[],"mappings":";AAAA,uDAAuD;AACvD,oGAAoG;;;AAEpG,gDAA+D;AAC/D,wCAAqF;AACrF,kDAA8D;AAE9D,yCAA2Q;AAE3Q,2DAAuD;AAwDvD,SAAgB,+BAA+B,CAAgF,SAA2C,EAAE,aAA4E;IACtP,MAAM,eAAe,GAAG,IAAA,qCAA0B,EAAC,SAAS,CAAC,CAAC;IAE9D,OAAO,CAAC,iBAA4B,EAAE,EAAE;QACtC,MAAM,WAAW,GAA2B,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAE/E,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAa,EAAC,iBAAiB,EAAE,sCAA6B,CAAC,CAAC,CAAC;QACtG,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAa,EAAC,iBAAiB,EAAE,sCAA6B,CAAC,CAAC,CAAC;QACtG,MAAM,SAAS,GAAG,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,IAAA,yBAAa,EAAC,iBAAiB,EAAE,sCAA6B,CAAC,CAAC,CAAC;Q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GAAG,cAAc,CAAC;gBACzC,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAtCD,0EAsCC"}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { FirestoreAccessorDriverRef } from '../driver/accessor';
|
|
3
|
-
import { FirestoreModelId, FirestoreModelIdRef, FirestoreModelKey, FirestoreModelKeyRef
|
|
3
|
+
import { FirestoreCollectionNameRef, FirestoreModelId, FirestoreModelIdentityCollectionName, FirestoreModelIdentityModelType, FirestoreModelIdentityRef, FirestoreModelIdRef, FirestoreModelKey, FirestoreModelKeyRef } from './../collection/collection';
|
|
4
4
|
import { DocumentReference, CollectionReference, Transaction, WriteBatch, DocumentSnapshot, SnapshotOptions, WriteResult } from '../types';
|
|
5
5
|
import { FirestoreDocumentDataAccessor } from './accessor';
|
|
6
6
|
import { CollectionReferenceRef, DocumentReferenceRef, FirestoreContextReference, FirestoreDataConverterRef } from '../reference';
|
|
7
7
|
import { FirestoreDocumentContext } from './context';
|
|
8
8
|
import { Maybe } from '@dereekb/util';
|
|
9
|
-
import {
|
|
9
|
+
import { FirestoreModelTypeRef, FirestoreModelIdentity, FirestoreModelTypeModelIdentityRef } from '../collection/collection';
|
|
10
10
|
import { InterceptAccessorFactoryFunction } from './accessor.wrap';
|
|
11
|
-
export interface FirestoreDocument<T,
|
|
11
|
+
export interface FirestoreDocument<T, I extends FirestoreModelIdentity = FirestoreModelIdentity> extends DocumentReferenceRef<T>, CollectionReferenceRef<T>, FirestoreModelIdentityRef<I>, FirestoreModelTypeRef<FirestoreModelIdentityModelType<I>>, FirestoreCollectionNameRef<FirestoreModelIdentityCollectionName<I>>, FirestoreModelKeyRef, FirestoreModelIdRef {
|
|
12
12
|
readonly accessor: FirestoreDocumentDataAccessor<T>;
|
|
13
13
|
readonly id: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Abstract FirestoreDocument implementation that extends a FirestoreDocumentDataAccessor.
|
|
17
17
|
*/
|
|
18
|
-
export declare abstract class AbstractFirestoreDocument<T, D extends AbstractFirestoreDocument<T, any,
|
|
18
|
+
export declare abstract class AbstractFirestoreDocument<T, D extends AbstractFirestoreDocument<T, any, I>, I extends FirestoreModelIdentity = FirestoreModelIdentity> implements FirestoreDocument<T>, LimitedFirestoreDocumentAccessorRef<T, D>, CollectionReferenceRef<T> {
|
|
19
19
|
readonly accessor: FirestoreDocumentDataAccessor<T>;
|
|
20
20
|
readonly documentAccessor: LimitedFirestoreDocumentAccessor<T, D>;
|
|
21
21
|
readonly stream$: Observable<DocumentSnapshot<T>>;
|
|
22
22
|
readonly data$: Observable<T>;
|
|
23
23
|
constructor(accessor: FirestoreDocumentDataAccessor<T>, documentAccessor: LimitedFirestoreDocumentAccessor<T, D>);
|
|
24
|
-
abstract get modelIdentity():
|
|
25
|
-
get modelType():
|
|
24
|
+
abstract get modelIdentity(): I;
|
|
25
|
+
get modelType(): FirestoreModelIdentityModelType<I>;
|
|
26
|
+
get collectionName(): FirestoreModelIdentityCollectionName<I>;
|
|
26
27
|
get id(): FirestoreModelId;
|
|
27
28
|
get key(): FirestoreModelKey;
|
|
28
29
|
get documentRef(): DocumentReference<T>;
|
|
@@ -41,7 +42,7 @@ export interface LimitedFirestoreDocumentAccessorRef<T, D extends FirestoreDocum
|
|
|
41
42
|
readonly documentAccessor: A;
|
|
42
43
|
}
|
|
43
44
|
export declare type FirestoreDocumentAccessorRef<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> = LimitedFirestoreDocumentAccessorRef<T, D, FirestoreDocumentAccessor<T, D>>;
|
|
44
|
-
export interface LimitedFirestoreDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends
|
|
45
|
+
export interface LimitedFirestoreDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreModelTypeModelIdentityRef, FirestoreAccessorDriverRef {
|
|
45
46
|
readonly databaseContext: FirestoreDocumentContext<T>;
|
|
46
47
|
/**
|
|
47
48
|
* Loads a document from the datastore.
|
|
@@ -110,7 +111,7 @@ export interface LimitedFirestoreDocumentAccessorFactory<T, D extends FirestoreD
|
|
|
110
111
|
/**
|
|
111
112
|
* FirestoreDocumentAccessor configuration.
|
|
112
113
|
*/
|
|
113
|
-
export interface LimitedFirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreDataConverterRef<T>,
|
|
114
|
+
export interface LimitedFirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreDataConverterRef<T>, FirestoreModelTypeModelIdentityRef, FirestoreContextReference, FirestoreAccessorDriverRef {
|
|
114
115
|
/**
|
|
115
116
|
* Optional InterceptAccessorFactoryFunction to intercept/return a modified accessor factory.
|
|
116
117
|
*/
|
|
@@ -159,10 +160,10 @@ export interface FirestoreDocumentAccessorContextExtension<T, D extends Firestor
|
|
|
159
160
|
}
|
|
160
161
|
export declare function firestoreDocumentAccessorContextExtension<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>({ documentAccessor, firestoreAccessorDriver }: FirestoreDocumentAccessorContextExtensionConfig<T, D>): FirestoreDocumentAccessorContextExtension<T, D>;
|
|
161
162
|
export declare function firestoreDocumentAccessorContextExtension<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>({ documentAccessor, firestoreAccessorDriver }: LimitedFirestoreDocumentAccessorContextExtensionConfig<T, D>): LimitedFirestoreDocumentAccessorContextExtension<T, D>;
|
|
162
|
-
export interface FirestoreDocumentWithParent<P, T> extends FirestoreDocument<T> {
|
|
163
|
+
export interface FirestoreDocumentWithParent<P, T, I extends FirestoreModelIdentity = FirestoreModelIdentity> extends FirestoreDocument<T, I> {
|
|
163
164
|
readonly parent: DocumentReference<P>;
|
|
164
165
|
}
|
|
165
|
-
export declare abstract class AbstractFirestoreDocumentWithParent<P, T, D extends AbstractFirestoreDocument<T, any
|
|
166
|
+
export declare abstract class AbstractFirestoreDocumentWithParent<P, T, D extends AbstractFirestoreDocument<T, any, I>, I extends FirestoreModelIdentity = FirestoreModelIdentity> extends AbstractFirestoreDocument<T, D, I> implements FirestoreDocumentWithParent<P, T> {
|
|
166
167
|
get parent(): DocumentReference<P>;
|
|
167
168
|
constructor(accessor: FirestoreDocumentDataAccessor<T>, documentAccessor: LimitedFirestoreDocumentAccessor<T, D>);
|
|
168
169
|
}
|
|
@@ -16,7 +16,10 @@ class AbstractFirestoreDocument {
|
|
|
16
16
|
this.data$ = (0, accessor_1.dataFromSnapshotStream)(this.stream$);
|
|
17
17
|
}
|
|
18
18
|
get modelType() {
|
|
19
|
-
return this.modelIdentity.
|
|
19
|
+
return this.modelIdentity.modelType;
|
|
20
|
+
}
|
|
21
|
+
get collectionName() {
|
|
22
|
+
return this.modelIdentity.collectionName;
|
|
20
23
|
}
|
|
21
24
|
get id() {
|
|
22
25
|
return this.documentRef.id;
|
|
@@ -49,7 +52,7 @@ class AbstractFirestoreDocument {
|
|
|
49
52
|
exports.AbstractFirestoreDocument = AbstractFirestoreDocument;
|
|
50
53
|
function limitedFirestoreDocumentAccessorFactory(config) {
|
|
51
54
|
const { firestoreContext, firestoreAccessorDriver, makeDocument, accessorFactory: interceptAccessorFactory, converter, modelIdentity } = config;
|
|
52
|
-
const expectedCollectionName = firestoreAccessorDriver.fuzzedPathForPath ? firestoreAccessorDriver.fuzzedPathForPath(modelIdentity.
|
|
55
|
+
const expectedCollectionName = firestoreAccessorDriver.fuzzedPathForPath ? firestoreAccessorDriver.fuzzedPathForPath(modelIdentity.collectionName) : modelIdentity.collectionName;
|
|
53
56
|
return (context) => {
|
|
54
57
|
const databaseContext = context !== null && context !== void 0 ? context : config.firestoreAccessorDriver.defaultContextFactory();
|
|
55
58
|
const dataAccessorFactory = interceptAccessorFactory ? interceptAccessorFactory(databaseContext.accessorFactory) : databaseContext.accessorFactory;
|
|
@@ -64,7 +67,7 @@ function limitedFirestoreDocumentAccessorFactory(config) {
|
|
|
64
67
|
var _a;
|
|
65
68
|
const ref = firestoreAccessorDriver.docAtPath(firestoreContext.firestore, fullPath);
|
|
66
69
|
if (((_a = ref.parent) === null || _a === void 0 ? void 0 : _a.id) !== expectedCollectionName) {
|
|
67
|
-
throw new Error(`unexpected key/path "${fullPath}" for expected type "${modelIdentity.
|
|
70
|
+
throw new Error(`unexpected key/path "${fullPath}" for expected type "${modelIdentity.collectionName}"/"${modelIdentity.modelType}".`);
|
|
68
71
|
}
|
|
69
72
|
return ref.withConverter(converter);
|
|
70
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,0GAA0G;;;AAM1G,yCAAkH;AAGlH,
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.ts"],"names":[],"mappings":";AAAA,mDAAmD;AACnD,0GAA0G;;;AAM1G,yCAAkH;AAGlH,wCAA6C;AAS7C;;GAEG;AACH,MAAsB,yBAAyB;IAI7C,YAAqB,QAA0C,EAAW,gBAAwD;QAA7G,aAAQ,GAAR,QAAQ,CAAkC;QAAW,qBAAgB,GAAhB,gBAAgB,CAAwC;QAHzH,YAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACjC,UAAK,GAAkB,IAAA,iCAAsB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEgE,CAAC;IAItI,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,aAAa,CAAC,SAA+C,CAAC;IAC5E,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,cAAyD,CAAC;IACtF,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,C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
58
|
* MappedUseAsyncFunction to load snapshot data from the input document and use it.
|
|
59
59
|
*/
|
|
60
|
-
export declare const useDocumentSnapshotData: import("@dereekb/util").MappedUseAsyncFunction<FirestoreDocument<unknown, string
|
|
60
|
+
export declare const useDocumentSnapshotData: import("@dereekb/util").MappedUseAsyncFunction<FirestoreDocument<unknown, import("..").FirestoreModelIdentity<string, string>>, unknown>;
|
|
@@ -4,13 +4,13 @@ import { FirestoreItemPageIterationBaseConfig, FirestoreItemPageIterationFactory
|
|
|
4
4
|
import { FirestoreQueryFactory } from '../query/query';
|
|
5
5
|
import { FirestoreDrivers } from '../driver/driver';
|
|
6
6
|
import { FirestoreCollectionQueryFactory } from './collection.query';
|
|
7
|
-
import { ModelKey, ModelTypeString } from '@dereekb/util';
|
|
7
|
+
import { ArrayOrValue, ModelKey, ModelTypeString } from '@dereekb/util';
|
|
8
8
|
/**
|
|
9
|
-
* The camelCase model name.
|
|
9
|
+
* The camelCase model name/type.
|
|
10
10
|
*/
|
|
11
|
-
export declare type
|
|
11
|
+
export declare type FirestoreModelType = ModelTypeString;
|
|
12
12
|
/**
|
|
13
|
-
* An all lowercase name that references a collection. Is usually the lowercase version of the
|
|
13
|
+
* An all lowercase name that references a collection. Is usually the lowercase version of the FirestoreModelType.
|
|
14
14
|
*
|
|
15
15
|
* This is the part of the path that says what the collection is.
|
|
16
16
|
*
|
|
@@ -21,65 +21,93 @@ export declare type FirestoreModelIdentityType = 'root' | 'nested';
|
|
|
21
21
|
/**
|
|
22
22
|
* A firestore model's identity
|
|
23
23
|
*/
|
|
24
|
-
export declare type FirestoreModelIdentity<M extends
|
|
24
|
+
export declare type FirestoreModelIdentity<M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> = FirestoreModelTypeRef<M> & FirestoreCollectionNameRef<C> & {
|
|
25
25
|
readonly type: FirestoreModelIdentityType;
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated use collectionName instead.
|
|
28
|
+
*
|
|
29
|
+
* Will be removed in the future.
|
|
30
|
+
*/
|
|
27
31
|
readonly collection: C;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated use modelType instead.
|
|
34
|
+
*
|
|
35
|
+
* Will be removed in the future.
|
|
36
|
+
*/
|
|
37
|
+
readonly model: M;
|
|
28
38
|
};
|
|
39
|
+
export declare type FirestoreModelIdentityModelType<I> = I extends FirestoreModelIdentity<infer M> ? M : never;
|
|
40
|
+
export declare type FirestoreModelIdentityCollectionName<I> = I extends FirestoreModelIdentity<infer M, infer C> ? C : never;
|
|
29
41
|
/**
|
|
30
42
|
* A root-level FirestoreModelIdentity
|
|
31
43
|
*/
|
|
32
|
-
export declare type RootFirestoreModelIdentity<M extends
|
|
44
|
+
export declare type RootFirestoreModelIdentity<M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> = FirestoreModelIdentity<M, C> & {
|
|
33
45
|
readonly type: 'root';
|
|
34
46
|
};
|
|
35
47
|
/**
|
|
36
48
|
* A nested FirestoreModelIdentity with a parent.
|
|
37
49
|
*/
|
|
38
|
-
export declare type FirestoreModelIdentityWithParent<P extends FirestoreModelIdentity<string, string>, M extends
|
|
50
|
+
export declare type FirestoreModelIdentityWithParent<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> = FirestoreModelIdentity<M, C> & {
|
|
39
51
|
readonly type: 'nested';
|
|
40
52
|
readonly parent: P;
|
|
41
53
|
};
|
|
42
54
|
/**
|
|
43
55
|
* A default collection name derived from the model name.
|
|
44
56
|
*/
|
|
45
|
-
export declare type FirestoreModelDefaultCollectionName<M extends
|
|
46
|
-
export declare type
|
|
57
|
+
export declare type FirestoreModelDefaultCollectionName<M extends FirestoreModelType> = `${Lowercase<M>}`;
|
|
58
|
+
export declare type FirestoreModelTypes<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? M : never;
|
|
47
59
|
/**
|
|
48
60
|
* Creates a FirestoreModelIdentity value.
|
|
49
61
|
*
|
|
50
62
|
* @param modelName
|
|
51
63
|
* @returns
|
|
52
64
|
*/
|
|
53
|
-
export declare function firestoreModelIdentity<M extends
|
|
54
|
-
export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends
|
|
55
|
-
export declare function firestoreModelIdentity<M extends
|
|
56
|
-
export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends
|
|
65
|
+
export declare function firestoreModelIdentity<M extends FirestoreModelType>(modelName: M): RootFirestoreModelIdentity<M, FirestoreModelDefaultCollectionName<M>>;
|
|
66
|
+
export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType>(parent: P, modelName: M): FirestoreModelIdentityWithParent<P, M, FirestoreModelDefaultCollectionName<M>>;
|
|
67
|
+
export declare function firestoreModelIdentity<M extends FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName>(modelName: M, collectionName: C): RootFirestoreModelIdentity<M, C>;
|
|
68
|
+
export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName>(parent: P, modelName: M, collectionName: C): FirestoreModelIdentityWithParent<P, M, C>;
|
|
57
69
|
/**
|
|
58
|
-
* Reference to a
|
|
70
|
+
* Reference to a FirestoreModelType
|
|
59
71
|
*/
|
|
60
|
-
export interface
|
|
72
|
+
export interface FirestoreModelTypeRef<M extends FirestoreModelType = FirestoreModelType> {
|
|
61
73
|
/**
|
|
62
|
-
* Returns the
|
|
74
|
+
* Returns the FirestoreModelType for this context.
|
|
63
75
|
*/
|
|
64
76
|
readonly modelType: M;
|
|
65
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Reads the FirestoreModelType from a FirestoreModelType or FirestoreModelTypeRef.
|
|
80
|
+
*
|
|
81
|
+
* @param modelTypeInput
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
export declare function firestoreModelType(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef): FirestoreModelType;
|
|
66
85
|
/**
|
|
67
86
|
* Reference to a FirestoreCollectionName
|
|
68
87
|
*/
|
|
69
|
-
export interface FirestoreCollectionNameRef {
|
|
88
|
+
export interface FirestoreCollectionNameRef<C extends FirestoreCollectionName = FirestoreCollectionName> {
|
|
70
89
|
/**
|
|
71
90
|
* Returns the FirestoreCollectionName for this context.
|
|
72
91
|
*/
|
|
73
|
-
readonly collectionName:
|
|
92
|
+
readonly collectionName: C;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reference to a FirestoreModelIdentity via the FirestoreModelType and FirestoreCollectionName
|
|
96
|
+
*/
|
|
97
|
+
export interface FirestoreModelTypeModelIdentityRef<M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> {
|
|
98
|
+
/**
|
|
99
|
+
* Returns the FirestoreModelIdentity for this context.
|
|
100
|
+
*/
|
|
101
|
+
readonly modelIdentity: FirestoreModelIdentity<M, C>;
|
|
74
102
|
}
|
|
75
103
|
/**
|
|
76
104
|
* Reference to a FirestoreModelIdentity
|
|
77
105
|
*/
|
|
78
|
-
export interface FirestoreModelIdentityRef<
|
|
106
|
+
export interface FirestoreModelIdentityRef<I extends FirestoreModelIdentity> {
|
|
79
107
|
/**
|
|
80
108
|
* Returns the FirestoreModelIdentity for this context.
|
|
81
109
|
*/
|
|
82
|
-
readonly modelIdentity:
|
|
110
|
+
readonly modelIdentity: I;
|
|
83
111
|
}
|
|
84
112
|
/**
|
|
85
113
|
* The model's id within a collection.
|
|
@@ -108,15 +136,54 @@ export interface FirestoreModelIdRef {
|
|
|
108
136
|
* collection/12345/subcollection/67890
|
|
109
137
|
*/
|
|
110
138
|
export declare type FirestoreModelKey = ModelKey;
|
|
111
|
-
export declare type FirestoreIdentityModelKey<I extends RootFirestoreModelIdentity, K extends FirestoreModelId = FirestoreModelId> = I extends RootFirestoreModelIdentity<infer M, infer C> ? `${C}/${K}` : never;
|
|
112
139
|
/**
|
|
113
|
-
*
|
|
140
|
+
* A part of a FirestoreModelKey.
|
|
141
|
+
*/
|
|
142
|
+
export declare type FirestoreModelKeyPart<C extends FirestoreCollectionName = FirestoreCollectionName, K extends FirestoreModelId = FirestoreModelId> = `${C}/${K}`;
|
|
143
|
+
/**
|
|
144
|
+
* One part of a FirestoreModelKe
|
|
145
|
+
*/
|
|
146
|
+
export declare type FirestoreCollectionModelKeyPart<N extends FirestoreCollectionNameRef = FirestoreCollectionNameRef, K extends FirestoreModelId = FirestoreModelId> = N extends FirestoreCollectionNameRef<infer C> ? FirestoreModelKeyPart<C, K> : never;
|
|
147
|
+
export declare type FirestoreCollectionModelKey<N extends FirestoreCollectionNameRef = FirestoreCollectionNameRef, K extends FirestoreModelId = FirestoreModelId> = FirestoreCollectionModelKeyPart<N, K>;
|
|
148
|
+
/**
|
|
149
|
+
* Creates a firestoreModelKeyPart
|
|
114
150
|
*
|
|
115
151
|
* @param identity
|
|
116
152
|
* @param id
|
|
117
153
|
* @returns
|
|
118
154
|
*/
|
|
119
|
-
export declare function
|
|
155
|
+
export declare function firestoreModelKeyPart<N extends FirestoreCollectionNameRef, K extends FirestoreModelId = FirestoreModelId>(identity: N, id: K): FirestoreCollectionModelKeyPart<N, K>;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a firestoreModelKey for RootFirestoreModelIdentity values.
|
|
158
|
+
*
|
|
159
|
+
* @param identity
|
|
160
|
+
* @param id
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
export declare const firestoreModelKey: <I extends RootFirestoreModelIdentity<string, string>, K extends string = string>(identity: I, id: K) => FirestoreCollectionModelKeyPart<I, K>;
|
|
164
|
+
/**
|
|
165
|
+
* Creates an array of FirestoreCollectionModelKey values from the input ids.
|
|
166
|
+
*
|
|
167
|
+
* @param identity
|
|
168
|
+
* @param ids
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
export declare function firestoreModelKeys<I extends RootFirestoreModelIdentity, K extends FirestoreModelId = FirestoreModelId>(identity: I, ids: K[]): FirestoreCollectionModelKey<I, K>[];
|
|
172
|
+
/**
|
|
173
|
+
* Joins together a number of FirestoreModelKeyPart values.
|
|
174
|
+
*
|
|
175
|
+
* @param parts
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
export declare function firestoreModelKeyPath(...parts: FirestoreModelKeyPart[]): FirestoreModelKey;
|
|
179
|
+
/**
|
|
180
|
+
* Creates a number of child paths from the parent path.
|
|
181
|
+
*
|
|
182
|
+
* @param parent
|
|
183
|
+
* @param children
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
export declare function childFirestoreModelKeyPath(parent: FirestoreModelKeyPart, children: ArrayOrValue<FirestoreModelKeyPart>): FirestoreModelKey[];
|
|
120
187
|
/**
|
|
121
188
|
* Reference to a FirestoreModelKey
|
|
122
189
|
*/
|
|
@@ -154,3 +221,17 @@ export interface FirestoreCollectionRef<T, D extends FirestoreDocument<T> = Fire
|
|
|
154
221
|
* Creates a new FirestoreCollection from the input config.
|
|
155
222
|
*/
|
|
156
223
|
export declare function makeFirestoreCollection<T, D extends FirestoreDocument<T>>(inputConfig: FirestoreCollectionConfig<T, D>): FirestoreCollection<T, D>;
|
|
224
|
+
/**
|
|
225
|
+
* Alternative name for FirestoreModelType.
|
|
226
|
+
*
|
|
227
|
+
* @deprecated replaced by FirestoreModelType
|
|
228
|
+
*/
|
|
229
|
+
export declare type FirestoreModelName = FirestoreModelType;
|
|
230
|
+
/**
|
|
231
|
+
* @deprecated replaced by FirestoreModelTypeRef
|
|
232
|
+
*/
|
|
233
|
+
export declare type FirestoreModelNameRef<M extends FirestoreModelType = FirestoreModelType> = FirestoreModelTypeRef<M>;
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated replaced by FirestoreModelTypes
|
|
236
|
+
*/
|
|
237
|
+
export declare type FirestoreModelNames<I extends FirestoreModelIdentity> = FirestoreModelTypes<I>;
|
|
@@ -1,40 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeFirestoreCollection = exports.firestoreModelKey = exports.firestoreModelIdentity = void 0;
|
|
3
|
+
exports.makeFirestoreCollection = exports.childFirestoreModelKeyPath = exports.firestoreModelKeyPath = exports.firestoreModelKeys = exports.firestoreModelKey = exports.firestoreModelKeyPart = exports.firestoreModelType = exports.firestoreModelIdentity = void 0;
|
|
4
4
|
const document_1 = require("../accessor/document");
|
|
5
5
|
const iterator_1 = require("../query/iterator");
|
|
6
6
|
const query_1 = require("../query/query");
|
|
7
7
|
const collection_query_1 = require("./collection.query");
|
|
8
|
-
function firestoreModelIdentity(parentOrModelName, collectionNameOrModelName,
|
|
8
|
+
function firestoreModelIdentity(parentOrModelName, collectionNameOrModelName, inputCollectionName) {
|
|
9
9
|
var _a, _b;
|
|
10
10
|
if (typeof parentOrModelName === 'object') {
|
|
11
|
+
const collectionName = (_a = inputCollectionName) !== null && _a !== void 0 ? _a : collectionNameOrModelName.toLowerCase();
|
|
11
12
|
return {
|
|
12
13
|
type: 'nested',
|
|
13
14
|
parent: parentOrModelName,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
collectionName,
|
|
16
|
+
collection: collectionName,
|
|
17
|
+
model: collectionNameOrModelName,
|
|
18
|
+
modelType: collectionNameOrModelName
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
else {
|
|
22
|
+
const collectionName = (_b = collectionNameOrModelName) !== null && _b !== void 0 ? _b : parentOrModelName.toLowerCase();
|
|
19
23
|
return {
|
|
20
24
|
type: 'root',
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
collectionName,
|
|
26
|
+
collection: collectionName,
|
|
27
|
+
model: parentOrModelName,
|
|
28
|
+
modelType: parentOrModelName
|
|
23
29
|
};
|
|
24
30
|
}
|
|
25
31
|
}
|
|
26
32
|
exports.firestoreModelIdentity = firestoreModelIdentity;
|
|
27
33
|
/**
|
|
28
|
-
*
|
|
34
|
+
* Reads the FirestoreModelType from a FirestoreModelType or FirestoreModelTypeRef.
|
|
35
|
+
*
|
|
36
|
+
* @param modelTypeInput
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
function firestoreModelType(modelTypeInput) {
|
|
40
|
+
const modelType = typeof modelTypeInput === 'string' ? modelTypeInput : modelTypeInput.modelType;
|
|
41
|
+
if (!modelType) {
|
|
42
|
+
throw new Error('modelType is required.');
|
|
43
|
+
}
|
|
44
|
+
return modelType;
|
|
45
|
+
}
|
|
46
|
+
exports.firestoreModelType = firestoreModelType;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a firestoreModelKeyPart
|
|
49
|
+
*
|
|
50
|
+
* @param identity
|
|
51
|
+
* @param id
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
function firestoreModelKeyPart(identity, id) {
|
|
55
|
+
return `${identity.collectionName}/${id}`;
|
|
56
|
+
}
|
|
57
|
+
exports.firestoreModelKeyPart = firestoreModelKeyPart;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a firestoreModelKey for RootFirestoreModelIdentity values.
|
|
29
60
|
*
|
|
30
61
|
* @param identity
|
|
31
62
|
* @param id
|
|
32
63
|
* @returns
|
|
33
64
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
65
|
+
exports.firestoreModelKey = firestoreModelKeyPart;
|
|
66
|
+
/**
|
|
67
|
+
* Creates an array of FirestoreCollectionModelKey values from the input ids.
|
|
68
|
+
*
|
|
69
|
+
* @param identity
|
|
70
|
+
* @param ids
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
function firestoreModelKeys(identity, ids) {
|
|
74
|
+
return ids.map((x) => (0, exports.firestoreModelKey)(identity, x));
|
|
75
|
+
}
|
|
76
|
+
exports.firestoreModelKeys = firestoreModelKeys;
|
|
77
|
+
/**
|
|
78
|
+
* Joins together a number of FirestoreModelKeyPart values.
|
|
79
|
+
*
|
|
80
|
+
* @param parts
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
function firestoreModelKeyPath(...parts) {
|
|
84
|
+
return parts.join('/');
|
|
85
|
+
}
|
|
86
|
+
exports.firestoreModelKeyPath = firestoreModelKeyPath;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a number of child paths from the parent path.
|
|
89
|
+
*
|
|
90
|
+
* @param parent
|
|
91
|
+
* @param children
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
function childFirestoreModelKeyPath(parent, children) {
|
|
95
|
+
if (Array.isArray(children)) {
|
|
96
|
+
return children.map((childPath) => `${parent}/${childPath}`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return [`${parent}/${children}`];
|
|
100
|
+
}
|
|
36
101
|
}
|
|
37
|
-
exports.
|
|
102
|
+
exports.childFirestoreModelKeyPath = childFirestoreModelKeyPath;
|
|
38
103
|
/**
|
|
39
104
|
* Creates a new FirestoreCollection from the input config.
|
|
40
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/collection.ts"],"names":[],"mappings":";;;AACA,mDAc8B;AAC9B,gDAA0L;AAC1L,0CAA8E;AAE9E,yDAAsG;
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/collection.ts"],"names":[],"mappings":";;;AACA,mDAc8B;AAC9B,gDAA0L;AAC1L,0CAA8E;AAE9E,yDAAsG;AA0EtG,SAAgB,sBAAsB,CAA8I,iBAAwB,EAAE,yBAAiC,EAAE,mBAAuB;;IACtQ,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;QACzC,MAAM,cAAc,GAAG,MAAC,mBAAyB,mCAAM,yBAA+B,CAAC,WAAW,EAAQ,CAAC;QAC3G,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,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|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unsupportedFirestoreDriverFunctionError = void 0;
|
|
4
|
+
function unsupportedFirestoreDriverFunctionError(message) {
|
|
5
|
+
throw new Error(message !== null && message !== void 0 ? message : 'This function is not supported by this Firestore driver.');
|
|
6
|
+
}
|
|
7
|
+
exports.unsupportedFirestoreDriverFunctionError = unsupportedFirestoreDriverFunctionError;
|
|
8
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/firestore/error.ts"],"names":[],"mappings":";;;AAAA,SAAgB,uCAAuC,CAAC,OAAgB;IACtE,MAAM,IAAI,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,0DAA0D,CAAC,CAAC;AACzF,CAAC;AAFD,0FAEC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./accessor"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./snapshot"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./error"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./query"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./context"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./driver"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/firestore/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,qDAA2B;AAC3B,kDAAwB;AACxB,oDAA0B;AAC1B,mDAAyB;AACzB,uDAA6B;AAC7B,kDAAwB;AACxB,sDAA4B;AAC5B,iDAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/firestore/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,qDAA2B;AAC3B,kDAAwB;AACxB,kDAAwB;AACxB,oDAA0B;AAC1B,mDAAyB;AACzB,uDAA6B;AAC7B,kDAAwB;AACxB,sDAA4B;AAC5B,iDAAuB"}
|