@dereekb/firebase 8.1.0 → 8.1.1
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 +4 -0
- package/package.json +5 -5
- package/src/lib/client/function/model.function.factory.d.ts +3 -3
- package/src/lib/common/firestore/accessor/document.js +2 -2
- package/src/lib/common/firestore/accessor/document.js.map +1 -1
- package/src/lib/common/firestore/collection/collection.d.ts +35 -16
- package/src/lib/common/firestore/collection/collection.js +19 -3
- package/src/lib/common/firestore/collection/collection.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/test/CHANGELOG.md +4 -0
- package/test/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [8.1.1](https://github.com/dereekb/dbx-components/compare/v8.1.0-dev...v8.1.1) (2022-06-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
# [8.1.0](https://github.com/dereekb/dbx-components/compare/v8.0.1-dev...v8.1.0) (2022-06-18)
|
|
6
10
|
|
|
7
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@firebase/rules-unit-testing": "^2.0.0"
|
|
6
6
|
},
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"rxfire": "^6.0.3",
|
|
24
24
|
"rxjs": "^7.0.0",
|
|
25
25
|
"firebase": "^9.8.0",
|
|
26
|
-
"@dereekb/util": "8.1.
|
|
26
|
+
"@dereekb/util": "8.1.1",
|
|
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.1.
|
|
30
|
+
"@dereekb/rxjs": "8.1.1",
|
|
31
31
|
"ms": "^3.0.0-canary.1",
|
|
32
|
-
"@dereekb/model": "8.1.
|
|
32
|
+
"@dereekb/model": "8.1.1",
|
|
33
33
|
"class-transformer": "^0.5.1",
|
|
34
34
|
"class-validator": "^0.13.2",
|
|
35
|
-
"@dereekb/date": "8.1.
|
|
35
|
+
"@dereekb/date": "8.1.1",
|
|
36
36
|
"date-fns": "^2.28.0",
|
|
37
37
|
"date-fns-tz": "^1.3.0",
|
|
38
38
|
"rrule": "2.7.0",
|
|
@@ -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<{
|
|
@@ -16,7 +16,7 @@ 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
20
|
}
|
|
21
21
|
get id() {
|
|
22
22
|
return this.documentRef.id;
|
|
@@ -64,7 +64,7 @@ function limitedFirestoreDocumentAccessorFactory(config) {
|
|
|
64
64
|
var _a;
|
|
65
65
|
const ref = firestoreAccessorDriver.docAtPath(firestoreContext.firestore, fullPath);
|
|
66
66
|
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.collection}"/"${modelIdentity.
|
|
67
|
+
throw new Error(`unexpected key/path "${fullPath}" for expected type "${modelIdentity.collection}"/"${modelIdentity.modelType}".`);
|
|
68
68
|
}
|
|
69
69
|
return ref.withConverter(converter);
|
|
70
70
|
}
|
|
@@ -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,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,
|
|
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,SAAS,CAAC;IACtC,CAAC;IAED,IAAI,E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'../driver/driver';
|
|
|
6
6
|
import { FirestoreCollectionQueryFactory } from './collection.query';
|
|
7
7
|
import { 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,48 +21,58 @@ 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> & {
|
|
25
25
|
readonly type: FirestoreModelIdentityType;
|
|
26
|
-
readonly model: M;
|
|
27
26
|
readonly collection: C;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use modelType instead.
|
|
29
|
+
*/
|
|
30
|
+
readonly model: M;
|
|
28
31
|
};
|
|
29
32
|
/**
|
|
30
33
|
* A root-level FirestoreModelIdentity
|
|
31
34
|
*/
|
|
32
|
-
export declare type RootFirestoreModelIdentity<M extends
|
|
35
|
+
export declare type RootFirestoreModelIdentity<M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> = FirestoreModelIdentity<M, C> & {
|
|
33
36
|
readonly type: 'root';
|
|
34
37
|
};
|
|
35
38
|
/**
|
|
36
39
|
* A nested FirestoreModelIdentity with a parent.
|
|
37
40
|
*/
|
|
38
|
-
export declare type FirestoreModelIdentityWithParent<P extends FirestoreModelIdentity<string, string>, M extends
|
|
41
|
+
export declare type FirestoreModelIdentityWithParent<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType = FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName> = FirestoreModelIdentity<M, C> & {
|
|
39
42
|
readonly type: 'nested';
|
|
40
43
|
readonly parent: P;
|
|
41
44
|
};
|
|
42
45
|
/**
|
|
43
46
|
* A default collection name derived from the model name.
|
|
44
47
|
*/
|
|
45
|
-
export declare type FirestoreModelDefaultCollectionName<M extends
|
|
46
|
-
export declare type
|
|
48
|
+
export declare type FirestoreModelDefaultCollectionName<M extends FirestoreModelType> = `${Lowercase<M>}`;
|
|
49
|
+
export declare type FirestoreModelTypes<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? M : never;
|
|
47
50
|
/**
|
|
48
51
|
* Creates a FirestoreModelIdentity value.
|
|
49
52
|
*
|
|
50
53
|
* @param modelName
|
|
51
54
|
* @returns
|
|
52
55
|
*/
|
|
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
|
|
56
|
+
export declare function firestoreModelIdentity<M extends FirestoreModelType>(modelName: M): RootFirestoreModelIdentity<M, FirestoreModelDefaultCollectionName<M>>;
|
|
57
|
+
export declare function firestoreModelIdentity<P extends FirestoreModelIdentity<string, string>, M extends FirestoreModelType>(parent: P, modelName: M): FirestoreModelIdentityWithParent<P, M, FirestoreModelDefaultCollectionName<M>>;
|
|
58
|
+
export declare function firestoreModelIdentity<M extends FirestoreModelType, C extends FirestoreCollectionName = FirestoreCollectionName>(modelName: M, collectionName: C): RootFirestoreModelIdentity<M, C>;
|
|
59
|
+
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
60
|
/**
|
|
58
61
|
* Reference to a FirestoreCollectionName
|
|
59
62
|
*/
|
|
60
|
-
export interface
|
|
63
|
+
export interface FirestoreModelTypeRef<M extends FirestoreModelType = FirestoreModelType> {
|
|
61
64
|
/**
|
|
62
|
-
* Returns the
|
|
65
|
+
* Returns the FirestoreModelType for this context.
|
|
63
66
|
*/
|
|
64
67
|
readonly modelType: M;
|
|
65
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Reads the FirestoreModelType from a FirestoreModelType or FirestoreModelTypeRef.
|
|
71
|
+
*
|
|
72
|
+
* @param modelTypeInput
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
export declare function firestoreModelType(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef): FirestoreModelType;
|
|
66
76
|
/**
|
|
67
77
|
* Reference to a FirestoreCollectionName
|
|
68
78
|
*/
|
|
@@ -75,7 +85,7 @@ export interface FirestoreCollectionNameRef {
|
|
|
75
85
|
/**
|
|
76
86
|
* Reference to a FirestoreModelIdentity
|
|
77
87
|
*/
|
|
78
|
-
export interface FirestoreModelIdentityRef<M extends
|
|
88
|
+
export interface FirestoreModelIdentityRef<M extends FirestoreModelType = FirestoreModelType> {
|
|
79
89
|
/**
|
|
80
90
|
* Returns the FirestoreModelIdentity for this context.
|
|
81
91
|
*/
|
|
@@ -154,3 +164,12 @@ export interface FirestoreCollectionRef<T, D extends FirestoreDocument<T> = Fire
|
|
|
154
164
|
* Creates a new FirestoreCollection from the input config.
|
|
155
165
|
*/
|
|
156
166
|
export declare function makeFirestoreCollection<T, D extends FirestoreDocument<T>>(inputConfig: FirestoreCollectionConfig<T, D>): FirestoreCollection<T, D>;
|
|
167
|
+
/**
|
|
168
|
+
* Alternative name for FirestoreModelType.
|
|
169
|
+
*/
|
|
170
|
+
export declare type FirestoreModelName = FirestoreModelType;
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated replaced by FirestoreModelTypeRef
|
|
173
|
+
*/
|
|
174
|
+
export declare type FirestoreModelNameRef<M extends FirestoreModelType = FirestoreModelType> = FirestoreModelTypeRef<M>;
|
|
175
|
+
export declare type FirestoreModelNames<I extends FirestoreModelIdentity> = FirestoreModelTypes<I>;
|
|
@@ -1,6 +1,6 @@
|
|
|
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.firestoreModelKey = 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");
|
|
@@ -12,18 +12,34 @@ function firestoreModelIdentity(parentOrModelName, collectionNameOrModelName, co
|
|
|
12
12
|
type: 'nested',
|
|
13
13
|
parent: parentOrModelName,
|
|
14
14
|
collection: (_a = collectionName) !== null && _a !== void 0 ? _a : collectionNameOrModelName.toLowerCase(),
|
|
15
|
-
model: collectionNameOrModelName
|
|
15
|
+
model: collectionNameOrModelName,
|
|
16
|
+
modelType: collectionNameOrModelName
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
else {
|
|
19
20
|
return {
|
|
20
21
|
type: 'root',
|
|
21
22
|
collection: (_b = collectionNameOrModelName) !== null && _b !== void 0 ? _b : parentOrModelName.toLowerCase(),
|
|
22
|
-
model: parentOrModelName
|
|
23
|
+
model: parentOrModelName,
|
|
24
|
+
modelType: parentOrModelName
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
exports.firestoreModelIdentity = firestoreModelIdentity;
|
|
29
|
+
/**
|
|
30
|
+
* Reads the FirestoreModelType from a FirestoreModelType or FirestoreModelTypeRef.
|
|
31
|
+
*
|
|
32
|
+
* @param modelTypeInput
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
function firestoreModelType(modelTypeInput) {
|
|
36
|
+
const modelType = typeof modelTypeInput === 'string' ? modelTypeInput : modelTypeInput.modelType;
|
|
37
|
+
if (!modelType) {
|
|
38
|
+
throw new Error('modelType is required.');
|
|
39
|
+
}
|
|
40
|
+
return modelType;
|
|
41
|
+
}
|
|
42
|
+
exports.firestoreModelType = firestoreModelType;
|
|
27
43
|
/**
|
|
28
44
|
* Creates a firestoreModelKey for root identities.
|
|
29
45
|
*
|
|
@@ -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;AA+DtG,SAAgB,sBAAsB,CAA8I,iBAAwB,EAAE,yBAAiC,EAAE,cAAkB;;IACjQ,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,iBAAsB;YAC9B,UAAU,EAAE,MAAC,cAAoB,mCAAM,yBAA+B,CAAC,WAAW,EAAQ;YAC1F,KAAK,EAAE,yBAA8B;YACrC,SAAS,EAAE,yBAA8B;SAC1C,CAAC;KACH;SAAM;QACL,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,MAAC,yBAA+B,mCAAK,iBAAiB,CAAC,WAAW,EAAQ;YACtF,KAAK,EAAE,iBAAiB;YACxB,SAAS,EAAE,iBAAiB;SAC7B,CAAC;KACH;AACH,CAAC;AAjBD,wDAiBC;AAYD;;;;;GAKG;AACH,SAAgB,kBAAkB,CAA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|
|
|
1
1
|
import { ArrayOrValue } from '@dereekb/util';
|
|
2
2
|
import { DocumentReferenceRef } from '../firestore/reference';
|
|
3
|
-
import { FirestoreModelKey,
|
|
4
|
-
export interface OnCallTypedModelParams<T = unknown> extends
|
|
3
|
+
import { FirestoreModelKey, FirestoreModelType, FirestoreModelTypeRef } from '../firestore/collection/collection';
|
|
4
|
+
export interface OnCallTypedModelParams<T = unknown> extends FirestoreModelTypeRef {
|
|
5
5
|
data: T;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
@@ -11,7 +11,7 @@ export interface OnCallTypedModelParams<T = unknown> extends FirestoreModelNameR
|
|
|
11
11
|
* @param data
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
export declare function onCallTypedModelParams<T>(
|
|
14
|
+
export declare function onCallTypedModelParams<T>(modelTypeInput: FirestoreModelType | FirestoreModelTypeRef, data: T): OnCallTypedModelParams<T>;
|
|
15
15
|
/**
|
|
16
16
|
* Key used on the front-end and backend that refers to a specific function for creating models.
|
|
17
17
|
*/
|
|
@@ -9,7 +9,11 @@ const util_1 = require("@dereekb/util");
|
|
|
9
9
|
* @param data
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
function onCallTypedModelParams(
|
|
12
|
+
function onCallTypedModelParams(modelTypeInput, data) {
|
|
13
|
+
const modelType = typeof modelTypeInput === 'string' ? modelTypeInput : modelTypeInput.modelType;
|
|
14
|
+
if (!modelType) {
|
|
15
|
+
throw new Error('modelType is required.');
|
|
16
|
+
}
|
|
13
17
|
return {
|
|
14
18
|
modelType,
|
|
15
19
|
data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/model/function.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AAQtD;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAI,
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/model/function.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AAQtD;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAI,cAA0D,EAAE,IAAO;IAC3G,MAAM,SAAS,GAAG,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC;IAEjG,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;IAED,OAAO;QACL,SAAS;QACT,IAAI;KACL,CAAC;AACJ,CAAC;AAXD,wDAWC;AAED;;GAEG;AACU,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAI3D;;GAEG;AACU,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAG3D;;GAEG;AACU,QAAA,6BAA6B,GAAG,aAAa,CAAC;AAY3D,SAAgB,+BAA+B,CAAC,MAAmD;IACjG,OAAO,uBAAuB,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACjF,CAAC;AAFD,0EAEC;AAED,SAAgB,uBAAuB,CAAC,SAA0C;IAChF,OAAO;QACL,SAAS,EAAE,IAAA,cAAO,EAAC,SAAS,CAAC;KAC9B,CAAC;AACJ,CAAC;AAJD,0DAIC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GrantedRole } from '@dereekb/model';
|
|
2
2
|
import { Getter, SetIncludesMode, ArrayOrValue, UseAsync, UsePromiseFunction } from '@dereekb/util';
|
|
3
3
|
import { FirestoreDocument } from '../firestore/accessor/document';
|
|
4
|
-
import { FirestoreModelIdentity, FirestoreModelKey,
|
|
4
|
+
import { FirestoreModelIdentity, FirestoreModelKey, FirestoreModelTypes } from '../firestore/collection/collection';
|
|
5
5
|
import { FirebaseModelCollectionLoader, FirebaseModelLoader, InContextFirebaseModelLoader } from './model/model.loader';
|
|
6
6
|
import { InContextFirebaseModelPermissionService, FirebasePermissionContext, FirebaseModelPermissionService, FirebasePermissionServiceInstanceDelegate, InModelContextFirebaseModelPermissionService, FirebasePermissionErrorContext } from './permission';
|
|
7
7
|
import { ContextGrantedModelRolesReader } from './permission/permission.service.role';
|
|
@@ -29,7 +29,7 @@ export declare type InModelContextFirebaseModelService<C, T, D extends Firestore
|
|
|
29
29
|
export declare type InModelContextFirebaseModelServiceUseFunction<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends GrantedRole = GrantedRole> = (roles: ArrayOrValue<R>, setIncludes?: SetIncludesMode) => UsePromiseFunction<ContextGrantedModelRolesReader<C, T, D, R>>;
|
|
30
30
|
export declare function inContextFirebaseModelServiceFactory<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends GrantedRole = GrantedRole>(factory: FirebaseModelServiceGetter<C, T, D, R>): InContextFirebaseModelServiceFactory<C, T, D, R>;
|
|
31
31
|
export declare type FirebaseModelsServiceFactory<C extends FirebaseModelServiceContext, I extends FirestoreModelIdentity = FirestoreModelIdentity> = {
|
|
32
|
-
[J in
|
|
32
|
+
[J in FirestoreModelTypes<I>]: FirebaseModelServiceGetter<C, any>;
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
35
|
* Function that returns a configured service corresponding with the requested function, and for that context.
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [8.1.1](https://github.com/dereekb/dbx-components/compare/v8.1.0-dev...v8.1.1) (2022-06-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
# [8.1.0](https://github.com/dereekb/dbx-components/compare/v8.0.1-dev...v8.1.0) (2022-06-18)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.1",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util/test": "8.1.
|
|
9
|
-
"@dereekb/util": "8.1.
|
|
8
|
+
"@dereekb/util/test": "8.1.1",
|
|
9
|
+
"@dereekb/util": "8.1.1",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"ts-essentials": "^9.1.2",
|
|
12
12
|
"extra-set": "^2.2.11",
|
|
13
|
-
"@dereekb/firebase": "8.1.
|
|
13
|
+
"@dereekb/firebase": "8.1.1",
|
|
14
14
|
"rxfire": "^6.0.3",
|
|
15
15
|
"rxjs": "^7.0.0",
|
|
16
16
|
"firebase": "^9.8.0",
|
|
17
|
-
"@dereekb/rxjs": "8.1.
|
|
17
|
+
"@dereekb/rxjs": "8.1.1",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "8.1.
|
|
19
|
+
"@dereekb/model": "8.1.1",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "8.1.
|
|
22
|
+
"@dereekb/date": "8.1.1",
|
|
23
23
|
"date-fns": "^2.28.0",
|
|
24
24
|
"date-fns-tz": "^1.3.0",
|
|
25
25
|
"rrule": "2.7.0",
|