@dereekb/firebase 7.6.0 → 7.8.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 +40 -0
- package/package.json +5 -5
- package/src/lib/common/auth/auth.context.d.ts +2 -1
- package/src/lib/common/auth/auth.context.js +2 -1
- package/src/lib/common/auth/auth.context.js.map +1 -1
- package/src/lib/common/firestore/accessor/document.d.ts +7 -6
- package/src/lib/common/firestore/accessor/document.js +4 -2
- package/src/lib/common/firestore/accessor/document.js.map +1 -1
- package/src/lib/common/firestore/accessor/document.utility.d.ts +14 -1
- package/src/lib/common/firestore/accessor/document.utility.js +20 -1
- package/src/lib/common/firestore/accessor/document.utility.js.map +1 -1
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +11 -0
- package/src/lib/common/firestore/snapshot/snapshot.field.js +19 -1
- package/src/lib/common/firestore/snapshot/snapshot.field.js.map +1 -1
- package/src/lib/common/model/model.service.d.ts +2 -2
- package/src/lib/common/model/model.service.js.map +1 -1
- package/src/lib/common/model/permission/permission.service.grant.d.ts +12 -6
- package/src/lib/common/model/permission/permission.service.grant.js +18 -2
- package/src/lib/common/model/permission/permission.service.grant.js.map +1 -1
- package/src/lib/common/model/permission/permission.service.js.map +1 -1
- package/test/CHANGELOG.md +12 -0
- package/test/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [7.8.1](https://github.com/dereekb/dbx-components/compare/v7.8.0-dev...v7.8.1) (2022-06-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* useAsync typings fixes with Maybe ([68f38a4](https://github.com/dereekb/dbx-components/commit/68f38a46559e48c61e8449622e69f2e610aeb1b4))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [7.8.0](https://github.com/dereekb/dbx-components/compare/v7.7.0-dev...v7.8.0) (2022-06-09)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* firestoreEnum test fix ([5996b79](https://github.com/dereekb/dbx-components/commit/5996b79c292aaed67137738ac95652dce81060c7))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* added firestoreEnum() ([28e6704](https://github.com/dereekb/dbx-components/commit/28e670414f87eb538e996c5d823b5f79e9d9ae97))
|
|
25
|
+
* added firestoreEnumArray() ([5f9e1b1](https://github.com/dereekb/dbx-components/commit/5f9e1b14237ff229a4a832b8fbd5f13a21f753a6))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# [7.7.0](https://github.com/dereekb/dbx-components/compare/v7.6.0-dev...v7.7.0) (2022-06-09)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Bug Fixes
|
|
33
|
+
|
|
34
|
+
* documentAccessorForTransaction/WriteBatch now accepts a Maybe value ([beb1737](https://github.com/dereekb/dbx-components/commit/beb173794ce2cf60b41e43ccfc2b4e4eeda53224))
|
|
35
|
+
* fixed grantFullAccessIfAuthUserRelated typings ([f83af85](https://github.com/dereekb/dbx-components/commit/f83af852f1fbad20ba86eb477d18f54e936dd41c))
|
|
36
|
+
* grantFullAccessIfAuthUserRelated() now takes in a document or model ([53563dd](https://github.com/dereekb/dbx-components/commit/53563dd93a9ae25e84b6ef7f3e9d7ce857254bc6))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* added useDocumentSnapshotData ([aa329f2](https://github.com/dereekb/dbx-components/commit/aa329f25cb105c871bc0fb22001abb7a98979b14))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
5
45
|
# [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
|
|
6
46
|
|
|
7
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.1",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@firebase/rules-unit-testing": "^2.0.0"
|
|
6
6
|
},
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"rxjs": "^7.0.0",
|
|
23
23
|
"rxfire": "^6.0.3",
|
|
24
24
|
"firebase": "^9.8.0",
|
|
25
|
-
"@dereekb/util": "7.
|
|
25
|
+
"@dereekb/util": "7.8.1",
|
|
26
26
|
"make-error": "^1.3.0",
|
|
27
27
|
"ts-essentials": "^9.1.2",
|
|
28
28
|
"extra-set": "^2.2.11",
|
|
29
|
-
"@dereekb/rxjs": "7.
|
|
29
|
+
"@dereekb/rxjs": "7.8.1",
|
|
30
30
|
"ms": "^3.0.0-canary.1",
|
|
31
|
-
"@dereekb/model": "7.
|
|
31
|
+
"@dereekb/model": "7.8.1",
|
|
32
32
|
"class-transformer": "^0.5.1",
|
|
33
33
|
"class-validator": "^0.13.2",
|
|
34
|
-
"@dereekb/date": "7.
|
|
34
|
+
"@dereekb/date": "7.8.1",
|
|
35
35
|
"date-fns": "^2.28.0",
|
|
36
36
|
"date-fns-tz": "^1.3.0",
|
|
37
37
|
"rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthClaims, AuthClaimsObject, AuthRoleSet, MappedUseFunction, Maybe, UseValue } from '@dereekb/util';
|
|
2
|
-
import { FirebaseAuthToken } from './auth';
|
|
2
|
+
import { FirebaseAuthToken, FirebaseAuthUserId } from './auth';
|
|
3
3
|
/**
|
|
4
4
|
* Provides a context containing FirebaseAuthContextInfo
|
|
5
5
|
*/
|
|
@@ -45,3 +45,4 @@ export interface FirebaseAuthContextInfo {
|
|
|
45
45
|
}
|
|
46
46
|
export declare type UseFirebaseAuthContextInfo<I extends FirebaseAuthContextInfo = FirebaseAuthContextInfo> = UseValue<I>;
|
|
47
47
|
export declare const useContextAuth: MappedUseFunction<FirebaseAuthContext, FirebaseAuthContextInfo>;
|
|
48
|
+
export declare const useContextAuthUid: MappedUseFunction<FirebaseAuthContext, FirebaseAuthUserId>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useContextAuth = void 0;
|
|
3
|
+
exports.useContextAuthUid = exports.useContextAuth = void 0;
|
|
4
4
|
const util_1 = require("@dereekb/util");
|
|
5
5
|
exports.useContextAuth = (0, util_1.mappedUseFunction)((x) => x.auth);
|
|
6
|
+
exports.useContextAuthUid = (0, util_1.mappedUseFunction)((x) => { var _a; return (_a = x.auth) === null || _a === void 0 ? void 0 : _a.uid; });
|
|
6
7
|
//# sourceMappingURL=auth.context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/auth.context.ts"],"names":[],"mappings":";;;AAAA,wCAAiI;AAwDpH,QAAA,cAAc,GAAoE,IAAA,wBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"auth.context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/auth.context.ts"],"names":[],"mappings":";;;AAAA,wCAAiI;AAwDpH,QAAA,cAAc,GAAoE,IAAA,wBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACnH,QAAA,iBAAiB,GAA+D,IAAA,wBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,CAAC,CAAC,IAAI,0CAAE,GAAG,CAAA,EAAA,CAAC,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { DocumentReference, CollectionReference, Transaction, WriteBatch, Docume
|
|
|
5
5
|
import { FirestoreDocumentDataAccessor } from './accessor';
|
|
6
6
|
import { CollectionReferenceRef, DocumentReferenceRef, FirestoreContextReference } from '../reference';
|
|
7
7
|
import { FirestoreDocumentContext } from './context';
|
|
8
|
+
import { Maybe } from '@dereekb/util';
|
|
8
9
|
import { FirestoreModelNameRef, FirestoreModelIdentity, FirestoreModelIdentityRef } from '../collection/collection';
|
|
9
10
|
import { InterceptAccessorFactoryFunction } from './accessor.wrap';
|
|
10
11
|
export interface FirestoreDocument<T, M extends FirestoreModelName = FirestoreModelName> extends DocumentReferenceRef<T>, CollectionReferenceRef<T>, FirestoreModelIdentityRef<M>, FirestoreModelNameRef<M>, FirestoreModelKeyRef, FirestoreModelIdRef {
|
|
@@ -149,16 +150,16 @@ export interface FirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDo
|
|
|
149
150
|
export declare function firestoreDocumentAccessorFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: FirestoreDocumentAccessorFactoryConfig<T, D>): FirestoreDocumentAccessorFactoryFunction<T, D>;
|
|
150
151
|
export interface LimitedFirestoreDocumentAccessorForTransactionFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>, A extends LimitedFirestoreDocumentAccessor<T, D> = LimitedFirestoreDocumentAccessor<T, D>> {
|
|
151
152
|
/**
|
|
152
|
-
* Creates a new FirestoreDocumentAccessor for a Transaction.
|
|
153
|
+
* Creates a new FirestoreDocumentAccessor for a Transaction. If transaction is null/undefined, an accessor with a default context is returned.
|
|
153
154
|
*/
|
|
154
|
-
documentAccessorForTransaction(transaction: Transaction): A;
|
|
155
|
+
documentAccessorForTransaction(transaction: Maybe<Transaction>): A;
|
|
155
156
|
}
|
|
156
157
|
export declare type FirestoreDocumentAccessorForTransactionFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> = LimitedFirestoreDocumentAccessorForTransactionFactory<T, D, FirestoreDocumentAccessor<T, D>>;
|
|
157
158
|
export interface LimitedFirestoreDocumentAccessorForWriteBatchFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>, A extends LimitedFirestoreDocumentAccessor<T, D> = LimitedFirestoreDocumentAccessor<T, D>> {
|
|
158
159
|
/**
|
|
159
|
-
* Creates a new FirestoreDocumentAccessor for a WriteBatch.
|
|
160
|
+
* Creates a new FirestoreDocumentAccessor for a WriteBatch. If writeBatch is null/undefined an accessor with a default context is returned.
|
|
160
161
|
*/
|
|
161
|
-
documentAccessorForWriteBatch(writeBatch: WriteBatch): A;
|
|
162
|
+
documentAccessorForWriteBatch(writeBatch: Maybe<WriteBatch>): A;
|
|
162
163
|
}
|
|
163
164
|
export declare type FirestoreDocumentAccessorForWriteBatchFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> = LimitedFirestoreDocumentAccessorForWriteBatchFactory<T, D, FirestoreDocumentAccessor<T, D>>;
|
|
164
165
|
export interface LimitedFirestoreDocumentAccessorContextExtensionConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> extends FirestoreAccessorDriverRef {
|
|
@@ -182,8 +183,8 @@ export declare abstract class AbstractFirestoreDocumentWithParent<P, T, D extend
|
|
|
182
183
|
}
|
|
183
184
|
export interface FirestoreSingleDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
|
|
184
185
|
loadDocument(): D;
|
|
185
|
-
loadDocumentForTransaction(transaction: Transaction): D;
|
|
186
|
-
loadDocumentForWriteBatch(writeBatch: WriteBatch): D;
|
|
186
|
+
loadDocumentForTransaction(transaction: Maybe<Transaction>): D;
|
|
187
|
+
loadDocumentForWriteBatch(writeBatch: Maybe<WriteBatch>): D;
|
|
187
188
|
}
|
|
188
189
|
export interface FirestoreSingleDocumentAccessorConfig<T, D extends FirestoreDocument<T> = FirestoreDocument<T>> {
|
|
189
190
|
readonly singleItemIdentifier: string;
|
|
@@ -112,10 +112,12 @@ function firestoreDocumentAccessorContextExtension({ documentAccessor, firestore
|
|
|
112
112
|
return {
|
|
113
113
|
documentAccessor,
|
|
114
114
|
documentAccessorForTransaction(transaction) {
|
|
115
|
-
|
|
115
|
+
const context = transaction ? firestoreAccessorDriver.transactionContextFactory(transaction) : undefined;
|
|
116
|
+
return documentAccessor(context);
|
|
116
117
|
},
|
|
117
118
|
documentAccessorForWriteBatch(writeBatch) {
|
|
118
|
-
|
|
119
|
+
const context = writeBatch ? firestoreAccessorDriver.writeBatchContextFactory(writeBatch) : undefined;
|
|
120
|
+
return documentAccessor(context);
|
|
119
121
|
}
|
|
120
122
|
};
|
|
121
123
|
}
|
|
@@ -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,KAAK,CAAC;IAClC,CAAC;IAED,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,WAA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AiC,CAAC,MAA8B,CAAC;IACrG,CAAC;IAED,YAAY,QAA0C,EAAE,gBAAwD;QAC9G,KAAK,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IACpC,CAAC;CACF;AARD,kFAQC;AAcD,SAAgB,+BAA+B,CAA2D,MAAmD;IAC3J,MAAM,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAE/D,OAAO;QACL,YAAY;YACV,OAAO,SAAS,CAAC,gBAAgB,EAAE,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACpE,CAAC;QACD,0BAA0B,CAAC,WAA+B;YACxD,OAAO,SAAS,CAAC,8BAA8B,CAAC,WAAW,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC7F,CAAC;QACD,yBAAyB,CAAC,UAA6B;YACrD,OAAO,SAAS,CAAC,6BAA6B,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC3F,CAAC;KACF,CAAC;AACJ,CAAC;AAdD,0EAcC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Maybe } from '@dereekb/util';
|
|
1
|
+
import { AsyncGetterOrValue, Maybe, UseAsync } from '@dereekb/util';
|
|
2
2
|
import { DocumentDataWithId, DocumentReference, DocumentSnapshot, QuerySnapshot, Transaction } from '../types';
|
|
3
3
|
import { FirestoreDocument, FirestoreDocumentAccessor, LimitedFirestoreDocumentAccessor, LimitedFirestoreDocumentAccessorContextExtension } from './document';
|
|
4
4
|
export declare function newDocuments<T, D extends FirestoreDocument<T>>(documentAccessor: FirestoreDocumentAccessor<T, D>, count: number): D[];
|
|
@@ -45,3 +45,16 @@ export declare function firestoreDocumentLoader<T, D extends FirestoreDocument<T
|
|
|
45
45
|
* @returns
|
|
46
46
|
*/
|
|
47
47
|
export declare function documentDataWithId<T>(snapshot: DocumentSnapshot<T>): Maybe<DocumentDataWithId<T>>;
|
|
48
|
+
/**
|
|
49
|
+
* MappedUseAsyncFunction to load a snapshot from the input document and use it.
|
|
50
|
+
*
|
|
51
|
+
* @param document
|
|
52
|
+
* @param use
|
|
53
|
+
* @param defaultValue
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
export declare function useDocumentSnapshot<T, D extends FirestoreDocument<T>, O = void>(document: Maybe<D>, use: UseAsync<DocumentSnapshot<T>, O>, defaultValue?: Maybe<AsyncGetterOrValue<O>>): Promise<Maybe<O>>;
|
|
57
|
+
/**
|
|
58
|
+
* MappedUseAsyncFunction to load snapshot data from the input document and use it.
|
|
59
|
+
*/
|
|
60
|
+
export declare const useDocumentSnapshotData: import("@dereekb/util").MappedUseAsyncFunction<FirestoreDocument<unknown, string>, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.documentDataWithId = exports.firestoreDocumentLoader = exports.loadDocumentsForValues = exports.loadDocumentsForDocumentReferences = exports.loadDocumentsForSnapshots = exports.getDocumentSnapshots = exports.makeDocuments = exports.newDocuments = void 0;
|
|
3
|
+
exports.useDocumentSnapshotData = exports.useDocumentSnapshot = exports.documentDataWithId = exports.firestoreDocumentLoader = exports.loadDocumentsForValues = exports.loadDocumentsForDocumentReferences = exports.loadDocumentsForSnapshots = exports.getDocumentSnapshots = exports.makeDocuments = exports.newDocuments = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const util_1 = require("@dereekb/util");
|
|
6
6
|
function newDocuments(documentAccessor, count) {
|
|
@@ -73,4 +73,23 @@ function documentDataWithId(snapshot) {
|
|
|
73
73
|
return data;
|
|
74
74
|
}
|
|
75
75
|
exports.documentDataWithId = documentDataWithId;
|
|
76
|
+
/**
|
|
77
|
+
* MappedUseAsyncFunction to load a snapshot from the input document and use it.
|
|
78
|
+
*
|
|
79
|
+
* @param document
|
|
80
|
+
* @param use
|
|
81
|
+
* @param defaultValue
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
function useDocumentSnapshot(document, use, defaultValue) {
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const snapshot = yield (document === null || document === void 0 ? void 0 : document.accessor.get());
|
|
87
|
+
return (0, util_1.useAsync)(snapshot, use, defaultValue);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.useDocumentSnapshot = useDocumentSnapshot;
|
|
91
|
+
/**
|
|
92
|
+
* MappedUseAsyncFunction to load snapshot data from the input document and use it.
|
|
93
|
+
*/
|
|
94
|
+
exports.useDocumentSnapshotData = (0, util_1.wrapUseAsyncFunction)(useDocumentSnapshot, (x) => x.data());
|
|
76
95
|
//# sourceMappingURL=document.utility.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.utility.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.utility.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"document.utility.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/accessor/document.utility.ts"],"names":[],"mappings":";;;;AAAA,wCAAgJ;AAIhJ,SAAgB,YAAY,CAAoC,gBAAiD,EAAE,KAAa;IAC9H,OAAO,IAAA,gBAAS,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAFD,oCAEC;AAkBD;;;;;;GAMG;AACH,SAAgB,aAAa,CAAoC,gBAAiD,EAAE,IAA+B;;IACjJ,MAAM,aAAa,GAAG,MAAA,IAAI,CAAC,WAAW,mCAAI,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,CAAC,CAAC;IACjF,OAAO,IAAA,sBAAe,EAAC;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,CAAO,C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AO,CAAC,UAAkC,EAAE,WAAyB,EAAE,EAAE;QACvE,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,8BAA8B,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;QAChI,OAAO,kCAAkC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AALD,0DAKC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAI,QAA6B;IACjE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAA2B,CAAC;IAEtD,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,wBAAwB;KAChD;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AARD,gDAQC;AAED;;;;;;;GAOG;AACH,SAAsB,mBAAmB,CAA8C,QAAkB,EAAE,GAAqC,EAAE,YAA2C;;QAC3L,MAAM,QAAQ,GAAG,MAAM,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC,GAAG,EAAE,CAAA,CAAC;QAChD,OAAO,IAAA,eAAQ,EAAC,QAAQ,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;CAAA;AAHD,kDAGC;AAED;;GAEG;AACU,QAAA,uBAAuB,GAAG,IAAA,2BAAoB,EAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC"}
|
|
@@ -32,6 +32,9 @@ export declare type OptionalMapConfiguredFirestoreFieldConfig<V, D = unknown> =
|
|
|
32
32
|
export declare type FirestoreStringConfig = DefaultMapConfiguredFirestoreFieldConfig<string, string>;
|
|
33
33
|
export declare function firestoreString(config?: FirestoreStringConfig): FirestoreModelFieldMapFunctionsConfig<string, string>;
|
|
34
34
|
export declare function optionalFirestoreString(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
|
|
35
|
+
export declare type FirestoreEnumConfig<S extends string | number> = MapConfiguredFirestoreFieldConfigWithDefault<S, S>;
|
|
36
|
+
export declare function firestoreEnum<S extends string | number>(config: FirestoreEnumConfig<S>): FirestoreModelFieldMapFunctionsConfig<S, S>;
|
|
37
|
+
export declare function optionalFirestoreEnum<S extends string | number>(): ModelFieldMapFunctionsConfig<Maybe<S>, Maybe<S>>;
|
|
35
38
|
export declare function firestoreUID(): FirestoreModelFieldMapFunctionsConfig<string, string>;
|
|
36
39
|
export declare function optionalFirestoreUID(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
|
|
37
40
|
export declare const firestoreModelKey: FirestoreModelFieldMapFunctionsConfig<string, string>;
|
|
@@ -58,6 +61,14 @@ export declare type FirestoreUniqueKeyedArrayFieldConfig<T, K extends PrimativeK
|
|
|
58
61
|
readonly readKey: ReadKeyFunction<T, K>;
|
|
59
62
|
};
|
|
60
63
|
export declare function firestoreUniqueKeyedArray<T, K extends PrimativeKey = PrimativeKey>(config: FirestoreUniqueKeyedArrayFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<T[], T[]>;
|
|
64
|
+
export declare type FirestoreEnumArrayFieldConfig<S extends string | number> = Omit<FirestoreUniqueArrayFieldConfig<S>, 'findUnique'>;
|
|
65
|
+
/**
|
|
66
|
+
* FirestoreField configuration for an array of unique enum values.
|
|
67
|
+
*
|
|
68
|
+
* @param config
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
export declare function firestoreEnumArray<S extends string | number>(config?: FirestoreEnumArrayFieldConfig<S>): FirestoreModelFieldMapFunctionsConfig<S[], S[]>;
|
|
61
72
|
export declare type FirestoreUniqueStringArrayFieldConfig = Omit<FirestoreUniqueArrayFieldConfig<string>, 'findUnique'> & FindUniqueStringsTransformConfig;
|
|
62
73
|
export declare function firestoreUniqueStringArray(config: FirestoreUniqueStringArrayFieldConfig): FirestoreModelFieldMapFunctionsConfig<string[], string[]>;
|
|
63
74
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firestoreSet = exports.firestoreModelIdGrantedRoleArrayMap = exports.firestoreModelKeyGrantedRoleArrayMap = exports.firestoreArrayMap = exports.firestoreModelIdGrantedRoleMap = exports.firestoreModelKeyGrantedRoleMap = exports.firestoreMap = exports.firestoreEncodedArray = exports.firestoreModelIdArray = exports.firestoreModelKeyArray = exports.firestoreUniqueStringArray = exports.firestoreUniqueKeyedArray = exports.firestoreUniqueArray = exports.optionalFirestoreArray = exports.firestoreArray = exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = exports.firestoreModelId = exports.firestoreModelKey = exports.optionalFirestoreUID = exports.firestoreUID = exports.optionalFirestoreString = exports.firestoreString = exports.firestorePassThroughField = exports.FIRESTORE_PASSTHROUGH_FIELD = exports.firestoreField = void 0;
|
|
3
|
+
exports.firestoreSet = exports.firestoreModelIdGrantedRoleArrayMap = exports.firestoreModelKeyGrantedRoleArrayMap = exports.firestoreArrayMap = exports.firestoreModelIdGrantedRoleMap = exports.firestoreModelKeyGrantedRoleMap = exports.firestoreMap = exports.firestoreEncodedArray = exports.firestoreModelIdArray = exports.firestoreModelKeyArray = exports.firestoreUniqueStringArray = exports.firestoreEnumArray = exports.firestoreUniqueKeyedArray = exports.firestoreUniqueArray = exports.optionalFirestoreArray = exports.firestoreArray = exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = exports.firestoreModelId = exports.firestoreModelKey = exports.optionalFirestoreUID = exports.firestoreUID = exports.optionalFirestoreEnum = exports.firestoreEnum = exports.optionalFirestoreString = exports.firestoreString = exports.firestorePassThroughField = exports.FIRESTORE_PASSTHROUGH_FIELD = exports.firestoreField = void 0;
|
|
4
4
|
const date_1 = require("@dereekb/date");
|
|
5
5
|
const util_1 = require("@dereekb/util");
|
|
6
6
|
const snapshot_1 = require("./snapshot");
|
|
@@ -40,6 +40,14 @@ function optionalFirestoreString() {
|
|
|
40
40
|
return firestorePassThroughField();
|
|
41
41
|
}
|
|
42
42
|
exports.optionalFirestoreString = optionalFirestoreString;
|
|
43
|
+
function firestoreEnum(config) {
|
|
44
|
+
return firestoreField(Object.assign(Object.assign({}, config), { fromData: util_1.passThrough, toData: util_1.passThrough }));
|
|
45
|
+
}
|
|
46
|
+
exports.firestoreEnum = firestoreEnum;
|
|
47
|
+
function optionalFirestoreEnum() {
|
|
48
|
+
return firestorePassThroughField();
|
|
49
|
+
}
|
|
50
|
+
exports.optionalFirestoreEnum = optionalFirestoreEnum;
|
|
43
51
|
function firestoreUID() {
|
|
44
52
|
return firestoreString({
|
|
45
53
|
default: ''
|
|
@@ -121,6 +129,16 @@ function firestoreUniqueKeyedArray(config) {
|
|
|
121
129
|
return firestoreUniqueArray(Object.assign(Object.assign({}, config), { findUnique: (0, util_1.makeFindUniqueFunction)(config.readKey) }));
|
|
122
130
|
}
|
|
123
131
|
exports.firestoreUniqueKeyedArray = firestoreUniqueKeyedArray;
|
|
132
|
+
/**
|
|
133
|
+
* FirestoreField configuration for an array of unique enum values.
|
|
134
|
+
*
|
|
135
|
+
* @param config
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
function firestoreEnumArray(config = {}) {
|
|
139
|
+
return firestoreUniqueArray(Object.assign(Object.assign({}, config), { findUnique: util_1.unique }));
|
|
140
|
+
}
|
|
141
|
+
exports.firestoreEnumArray = firestoreEnumArray;
|
|
124
142
|
function firestoreUniqueStringArray(config) {
|
|
125
143
|
const findUnique = (0, util_1.findUniqueTransform)(config);
|
|
126
144
|
return firestoreUniqueArray(Object.assign(Object.assign({}, config), { findUnique }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAEA,wCAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAEA,wCAA4E;AAC5E,wCAyBuB;AACvB,yCAAmD;AA4BnD,SAAgB,cAAc,CAAiB,MAAkC;;IAC/E,OAAO;QACL,IAAI,EAAG,MAAgD,CAAC,OAAO;YAC7D,CAAC,CAAC;gBACE,OAAO,EAAG,MAAgD,CAAC,OAAO;gBAClE,OAAO,EAAE,MAAM,CAAC,QAAQ;aACzB;YACH,CAAC,CAAC;gBACE,YAAY,EAAG,MAAoD,CAAC,WAAW;gBAC/E,OAAO,EAAE,MAAM,CAAC,QAAQ;aACzB;QACL,EAAE,EAAE;YACF,OAAO,EAAE,CAAC,MAAA,MAAM,CAAC,iBAAiB,mCAAI,gCAAqB,CAAqB;YAChF,OAAO,EAAE,MAAM,CAAC,MAAM;SACvB;KAC6C,CAAC;AACnD,CAAC;AAhBD,wCAgBC;AAEY,QAAA,2BAA2B,GAAG,cAAc,CAAmB;IAC1E,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,kBAAW;IACrB,MAAM,EAAE,kBAAW;CACpB,CAAC,CAAC;AAEH,SAAgB,yBAAyB;IACvC,OAAO,mCAAiE,CAAC;AAC3E,CAAC;AAFD,8DAEC;AAWD,SAAgB,eAAe,CAAC,MAA8B;IAC5D,OAAO,cAAc,+BACnB,OAAO,EAAE,EAAE,IACR,MAAM,KACT,QAAQ,EAAE,kBAAW,EACrB,MAAM,EAAE,kBAAW,IACnB,CAAC;AACL,CAAC;AAPD,0CAOC;AAED,SAAgB,uBAAuB;IACrC,OAAO,yBAAyB,EAAiB,CAAC;AACpD,CAAC;AAFD,0DAEC;AAID,SAAgB,aAAa,CAA4B,MAA8B;IACrF,OA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AAC,IAAI,CAAC;QACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAND,oCAMC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GrantedRole } from '@dereekb/model';
|
|
2
|
-
import { Getter, SetIncludesMode, ArrayOrValue,
|
|
2
|
+
import { Getter, SetIncludesMode, ArrayOrValue, UseAsync, UsePromiseFunction } from '@dereekb/util';
|
|
3
3
|
import { FirestoreDocument } from '../firestore/accessor/document';
|
|
4
4
|
import { FirestoreModelIdentity, FirestoreModelKey, FirestoreModelNames } from '../firestore/collection/collection';
|
|
5
5
|
import { FirebaseModelCollectionLoader, FirebaseModelLoader, InContextFirebaseModelLoader } from './model/model.loader';
|
|
@@ -72,6 +72,6 @@ export declare type UseFirebaseModelsServiceSelection<Y extends FirebaseModelsSe
|
|
|
72
72
|
rolesSetIncludes?: SetIncludesMode;
|
|
73
73
|
} : never : never;
|
|
74
74
|
export declare type UseFirebaseModelsServiceSelectionResult<Y extends FirebaseModelsService<any, any>, T extends FirebaseModelsServiceTypes<Y>> = Y extends FirebaseModelsService<infer X, infer C> ? (T extends keyof X ? (X[T] extends FirebaseModelServiceGetter<C, infer T, infer D, infer R> ? UsePromiseFunction<ContextGrantedModelRolesReader<C, T, D, R>> : never) : never) : never;
|
|
75
|
-
export declare type UseFirebaseModelsServiceSelectionUseFunction<Y extends FirebaseModelsService<any, any>, T extends FirebaseModelsServiceTypes<Y>, O> = Y extends FirebaseModelsService<infer X, infer C> ? (T extends keyof X ? (X[T] extends FirebaseModelServiceGetter<C, infer T, infer D, infer R> ?
|
|
75
|
+
export declare type UseFirebaseModelsServiceSelectionUseFunction<Y extends FirebaseModelsService<any, any>, T extends FirebaseModelsServiceTypes<Y>, O> = Y extends FirebaseModelsService<infer X, infer C> ? (T extends keyof X ? (X[T] extends FirebaseModelServiceGetter<C, infer T, infer D, infer R> ? UseAsync<ContextGrantedModelRolesReader<C, T, D, R>, O> : never) : never) : never;
|
|
76
76
|
export declare function selectFromFirebaseModelsService<Y extends FirebaseModelsService<any, any>, T extends FirebaseModelsServiceTypes<Y>>(service: Y, type: T, select: FirebaseModelsServiceSelection<Y, T>): FirebaseModelsServiceSelectionResult<Y, T>;
|
|
77
77
|
export declare function useFirebaseModelsService<Y extends FirebaseModelsService<any, any>, T extends FirebaseModelsServiceTypes<Y>>(service: Y, type: T, select: UseFirebaseModelsServiceSelection<Y, T>): UseFirebaseModelsServiceSelectionResult<Y, T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.service.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/model/model.service.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"model.service.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/model/model.service.ts"],"names":[],"mappings":";;;AACA,wCAAqI;AAGrI,uDAA6I;AAC7I,6CAA2R;AAC3R,kFAAsH;AAStH,SAAgB,oBAAoB,CAAuI,MAA8C;IACvN,MAAM,yBAAyB,GAAG,IAAA,YAAK,EAAwD;QAC7F,IAAI,EAAE,IAAA,kCAAmB,EAAC,MAAM,CAAC,sBAAsB,CAAC;QACxD,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE;YACX,CAAC,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;QAC7C,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,IAAA,2CAA8B,EAAC,yBAAyB,CAAC,CAAC;IAEpF,MAAM,OAAO,GAAqC;QAChD,sBAAsB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;QACpG,oBAAoB,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,GAAG,EAAE,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
|
|
2
3
|
import { AsyncDecisionFunction, Getter, GetterOrValue, Maybe, PromiseOrValue } from '@dereekb/util';
|
|
3
4
|
import { FirebaseModelContext } from '../context';
|
|
@@ -5,7 +6,7 @@ import { UserRelated } from '../../../model/user';
|
|
|
5
6
|
/**
|
|
6
7
|
* Convenience function that checks the input context if the user is an admin or grants all roles.
|
|
7
8
|
*/
|
|
8
|
-
export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction
|
|
9
|
+
export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction<FirebaseModelContext>;
|
|
9
10
|
export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): PromiseOrValue<GrantedRoleMap<R>>;
|
|
10
11
|
/**
|
|
11
12
|
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
@@ -23,14 +24,19 @@ export declare function grantModelRolesIfAdminFunction<R extends string = string
|
|
|
23
24
|
* @returns
|
|
24
25
|
*/
|
|
25
26
|
export declare const isAdminInFirebaseModelContext: AsyncDecisionFunction<FirebaseModelContext>;
|
|
26
|
-
export declare type UserRelatedModelFirebaseModelContext<T extends UserRelated = UserRelated> =
|
|
27
|
+
export declare type UserRelatedModelFirebaseModelContext<T extends UserRelated = UserRelated> = UserRelatedModelFirebaseModelContextModelInput<T> | UserRelatedModelFirebaseModelContextDocumentInput<T>;
|
|
28
|
+
export declare type UserRelatedModelFirebaseModelContextModelInput<T extends UserRelated = UserRelated> = {
|
|
27
29
|
model: T;
|
|
28
30
|
context: FirebaseModelContext;
|
|
29
31
|
};
|
|
32
|
+
export declare type UserRelatedModelFirebaseModelContextDocumentInput<T extends UserRelated = UserRelated> = {
|
|
33
|
+
document: FirestoreDocument<T>;
|
|
34
|
+
context: FirebaseModelContext;
|
|
35
|
+
};
|
|
30
36
|
/**
|
|
31
37
|
* Convenience function that checks the input context if the user is related to the model by uid.
|
|
32
38
|
*/
|
|
33
|
-
export declare const grantFullAccessIfAuthUserRelated: GeneralGrantRolesIfFunction
|
|
39
|
+
export declare const grantFullAccessIfAuthUserRelated: GeneralGrantRolesIfFunction<UserRelatedModelFirebaseModelContext<UserRelated>>;
|
|
34
40
|
/**
|
|
35
41
|
* Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
|
|
36
42
|
*
|
|
@@ -51,7 +57,7 @@ export declare const isOwnerOfUserRelatedModelInFirebaseModelContext: AsyncDecis
|
|
|
51
57
|
* Grants the configured roles if the decision is made about the context. Otherwise, returns a NoAccessRoleMap.
|
|
52
58
|
*/
|
|
53
59
|
export declare type GrantRolesOnlyIfFunction<C, R extends string = string> = (context: C) => Promise<GrantedRoleMap<R>>;
|
|
54
|
-
export declare type GeneralGrantRolesOnlyIfFunction = <
|
|
60
|
+
export declare type GeneralGrantRolesOnlyIfFunction<C> = <R extends string = string>(context: C) => Promise<GrantedRoleMap<R>>;
|
|
55
61
|
/**
|
|
56
62
|
* Creates a GrantRolesOnlyIfFunction
|
|
57
63
|
*
|
|
@@ -64,13 +70,13 @@ export declare function grantModelRolesOnlyIfFunction<C, R extends string = stri
|
|
|
64
70
|
* Grants the configured roles if the decision is made about the context. Otherwise, invokes the otherwise function if available, or returns a NoAccessRoleMap.
|
|
65
71
|
*/
|
|
66
72
|
export declare type GrantRolesIfFunction<C, R extends string = string> = (context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
|
|
67
|
-
export declare type GeneralGrantRolesIfFunction = <
|
|
73
|
+
export declare type GeneralGrantRolesIfFunction<C> = <R extends string = string>(context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
|
|
68
74
|
/**
|
|
69
75
|
* Used as the "else" statement for grantModelRolesIfFunction.
|
|
70
76
|
*
|
|
71
77
|
* If no roles are returned, the grantModelRolesIfFunction() will return a NoAccessRoleMap.
|
|
72
78
|
*/
|
|
73
|
-
export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<PromiseOrValue<GrantedRoleMap<R
|
|
79
|
+
export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<PromiseOrValue<Maybe<GrantedRoleMap<R>>>>>;
|
|
74
80
|
/**
|
|
75
81
|
* Creates a GrantRolesIfFunction.
|
|
76
82
|
*
|
|
@@ -36,7 +36,7 @@ exports.isAdminInFirebaseModelContext = isAdminInFirebaseModelContext;
|
|
|
36
36
|
/**
|
|
37
37
|
* Convenience function that checks the input context if the user is related to the model by uid.
|
|
38
38
|
*/
|
|
39
|
-
exports.grantFullAccessIfAuthUserRelated =
|
|
39
|
+
exports.grantFullAccessIfAuthUserRelated = grantModelRolesIfAuthUserRelatedModelFunction(model_1.fullAccessRoleMap);
|
|
40
40
|
/**
|
|
41
41
|
* Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
|
|
42
42
|
*
|
|
@@ -55,7 +55,23 @@ exports.grantModelRolesIfAuthUserRelatedModelFunction = grantModelRolesIfAuthUse
|
|
|
55
55
|
* @param context
|
|
56
56
|
* @returns
|
|
57
57
|
*/
|
|
58
|
-
const isOwnerOfUserRelatedModelInFirebaseModelContext = (
|
|
58
|
+
const isOwnerOfUserRelatedModelInFirebaseModelContext = (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
let decision = false;
|
|
60
|
+
const auth = context.context.auth;
|
|
61
|
+
if (auth != null) {
|
|
62
|
+
let model = context.model;
|
|
63
|
+
if (!model) {
|
|
64
|
+
const document = context.document;
|
|
65
|
+
if (document) {
|
|
66
|
+
model = (yield document.accessor.get()).data();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (model) {
|
|
70
|
+
decision = auth.uid === model.uid;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return decision;
|
|
74
|
+
});
|
|
59
75
|
exports.isOwnerOfUserRelatedModelInFirebaseModelContext = isOwnerOfUserRelatedModelInFirebaseModelContext;
|
|
60
76
|
/**
|
|
61
77
|
* Creates a GrantRolesOnlyIfFunction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.service.grant.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.grant.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"permission.service.grant.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.grant.ts"],"names":[],"mappings":";;;;AACA,0CAAoF;AACpF,wCAAwH;AAIxH,cAAc;AACd;;GAEG;AACU,QAAA,sBAAsB,GAAsD,8BAA8B,CAAC,yBAAiB,CAAC,CAAC;AAE3I,SAAgB,sBAAsB,CAA4B,OAA6B,EAAE,mBAAqD,EAAE,SAA0C;IAChM,OAAO,8BAA8B,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACjF,CAAC;AAFD,wDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAA4B,mBAAqD;IAC7H,OAAO,yBAAyB,CAAC,qCAA6B,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAFD,wEAEC;AAED;;;;;GAKG;AACI,MAAM,6BAA6B,GAAgD,CAAC,OAA6B,EAAE,EAAE,eAAC,OAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,OAAO,EAAE,mCAAI,KAAK,CAAA,EAAA,CAAC;AAAjJ,QAAA,6BAA6B,iCAAoH;AAe9J;;GAEG;AACU,QAAA,gCAAgC,GAAmF,6CAA6C,CAAC,yBAAiB,CAAC,CAAC;AAEjM;;;;;;;GAOG;AACH,SAAgB,6CAA6C,CAAmD,YAA8C;IAC5J,OAAO,yBAAyB,CAAC,uDAA+C,EAAE,YAAY,CAAC,CAAC;AAClG,CAAC;AAFD,sGAEC;AAED;;;;;GAKG;AACI,MAAM,+CAA+C,GAA6E,CAAO,OAA6C,EAAE,EAAE;IAC/L,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,8DAMC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAA+K;AAY/K;;GAEG;AACH,MAAa,sCAA4J,SAAQ,sCAA6E;IAC5P,YAAqB,QAA+D;QAClF,KAAK,CAAC,QAAQ,CAAC,CAAC;QADG,aAAQ,GAAR,QAAQ,CAAuD;IAEpF,CAAC;IAED,eAAe,CAAC,MAA4C,EAAE,OAAU,EAAE,KAAQ;QAChF,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAEe,cAAc,CAAC,QAAW;;YACxC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE7B,MAAM,KAAK,GAAgD,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9G,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;IAEkB,sBAAsB,CAAC,MAA4C;QACpF,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF;AApBD,wFAoBC;AAED,SAAgB,8BAA8B,CAAsH,QAA+D;IACjO,OAAO,IAAI,sCAAsC,CAAC,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAFD,wEAEC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [7.8.1](https://github.com/dereekb/dbx-components/compare/v7.8.0-dev...v7.8.1) (2022-06-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# [7.8.0](https://github.com/dereekb/dbx-components/compare/v7.7.0-dev...v7.8.0) (2022-06-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# [7.7.0](https://github.com/dereekb/dbx-components/compare/v7.6.0-dev...v7.7.0) (2022-06-09)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
# [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
|
|
6
18
|
|
|
7
19
|
|
package/test/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.1",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util/test": "7.
|
|
9
|
-
"@dereekb/util": "7.
|
|
8
|
+
"@dereekb/util/test": "7.8.1",
|
|
9
|
+
"@dereekb/util": "7.8.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": "7.
|
|
13
|
+
"@dereekb/firebase": "7.8.1",
|
|
14
14
|
"rxjs": "^7.0.0",
|
|
15
15
|
"rxfire": "^6.0.3",
|
|
16
16
|
"firebase": "^9.8.0",
|
|
17
|
-
"@dereekb/rxjs": "7.
|
|
17
|
+
"@dereekb/rxjs": "7.8.1",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "7.
|
|
19
|
+
"@dereekb/model": "7.8.1",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "7.
|
|
22
|
+
"@dereekb/date": "7.8.1",
|
|
23
23
|
"date-fns": "^2.28.0",
|
|
24
24
|
"date-fns-tz": "^1.3.0",
|
|
25
25
|
"rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
|