@dereekb/firebase 7.4.0 → 7.7.0
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 +39 -0
- package/package.json +5 -5
- package/src/lib/common/auth/auth.context.d.ts +5 -2
- package/src/lib/common/auth/auth.context.js +4 -0
- 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/model/model.service.d.ts +2 -2
- package/src/lib/common/model/model.service.js.map +1 -1
- package/src/lib/common/model/permission/index.d.ts +1 -0
- package/src/lib/common/model/permission/index.js +1 -0
- package/src/lib/common/model/permission/index.js.map +1 -1
- package/src/lib/common/model/permission/permission.service.d.ts +1 -45
- package/src/lib/common/model/permission/permission.service.grant.d.ts +87 -0
- package/src/lib/common/model/permission/permission.service.grant.js +104 -0
- package/src/lib/common/model/permission/permission.service.grant.js.map +1 -0
- package/src/lib/common/model/permission/permission.service.js +1 -55
- 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,45 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [7.7.0](https://github.com/dereekb/dbx-components/compare/v7.6.0-dev...v7.7.0) (2022-06-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* documentAccessorForTransaction/WriteBatch now accepts a Maybe value ([beb1737](https://github.com/dereekb/dbx-components/commit/beb173794ce2cf60b41e43ccfc2b4e4eeda53224))
|
|
11
|
+
* fixed grantFullAccessIfAuthUserRelated typings ([f83af85](https://github.com/dereekb/dbx-components/commit/f83af852f1fbad20ba86eb477d18f54e936dd41c))
|
|
12
|
+
* grantFullAccessIfAuthUserRelated() now takes in a document or model ([53563dd](https://github.com/dereekb/dbx-components/commit/53563dd93a9ae25e84b6ef7f3e9d7ce857254bc6))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* added useDocumentSnapshotData ([aa329f2](https://github.com/dereekb/dbx-components/commit/aa329f25cb105c871bc0fb22001abb7a98979b14))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* added grantFullAccessIfAuthUserRelated() ([be05e09](https://github.com/dereekb/dbx-components/commit/be05e0939939e9e0d1c8d1d8afbcab1fb15e060b))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* updated GrantRolesOtherwiseFunction to allow returning Maybe ([552bb9c](https://github.com/dereekb/dbx-components/commit/552bb9c488c0f11aa1aca885d00c5a7c2a199591))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* added UseFunction, MappedUseFunction ([84b6cbe](https://github.com/dereekb/dbx-components/commit/84b6cbe23b7e020ad7de49633642429d7e32f7d4))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
5
44
|
# [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
|
|
6
45
|
|
|
7
46
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
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.7.0",
|
|
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.7.0",
|
|
30
30
|
"ms": "^3.0.0-canary.1",
|
|
31
|
-
"@dereekb/model": "7.
|
|
31
|
+
"@dereekb/model": "7.7.0",
|
|
32
32
|
"class-transformer": "^0.5.1",
|
|
33
33
|
"class-validator": "^0.13.2",
|
|
34
|
-
"@dereekb/date": "7.
|
|
34
|
+
"@dereekb/date": "7.7.0",
|
|
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
|
-
import { AuthClaims, AuthClaimsObject, AuthRoleSet, Maybe } from '@dereekb/util';
|
|
2
|
-
import { FirebaseAuthToken } from './auth';
|
|
1
|
+
import { AuthClaims, AuthClaimsObject, AuthRoleSet, MappedUseFunction, Maybe, UseValue } from '@dereekb/util';
|
|
2
|
+
import { FirebaseAuthToken, FirebaseAuthUserId } from './auth';
|
|
3
3
|
/**
|
|
4
4
|
* Provides a context containing FirebaseAuthContextInfo
|
|
5
5
|
*/
|
|
@@ -43,3 +43,6 @@ export interface FirebaseAuthContextInfo {
|
|
|
43
43
|
*/
|
|
44
44
|
readonly token: FirebaseAuthToken;
|
|
45
45
|
}
|
|
46
|
+
export declare type UseFirebaseAuthContextInfo<I extends FirebaseAuthContextInfo = FirebaseAuthContextInfo> = UseValue<I>;
|
|
47
|
+
export declare const useContextAuth: MappedUseFunction<FirebaseAuthContext, FirebaseAuthContextInfo>;
|
|
48
|
+
export declare const useContextAuthUid: MappedUseFunction<FirebaseAuthContext, FirebaseAuthUserId>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useContextAuthUid = exports.useContextAuth = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
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; });
|
|
3
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":""}
|
|
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,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI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D;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,CAAS,EAAE,EAAE;YACxB,MAAM,QAAQ,GAAM,aAAa,CAAC,gBAAgB,CAA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,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"}
|
|
@@ -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,OAAO,CAAC;QAC5F,eAAe,EAAE,yBAAyB,CAAC,eAAe;KAC3D,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAjBD,oDAiBC;AAID,SAAgB,2BAA2B,CAAuI,MAA8C;IAC9N,OAAO,IAAA,mBAAY,EAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC;AAFD,kEAEC;AAoBD,SAAgB,oCAAoC,CAAmG,OAA+C;IACpM,OAAO,CAAC,OAAU,EAAE,EAAE;QACpB,MAAM,oBAAoB,GAAG,OAAO,EAAE,CAAC;QAEvC,MAAM,IAAI,GAA0D,CAAC,UAAiC,EAAE,EAAE;YACxG,MAAM,KAAK,GAAG,OAAO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AMC;AAsBD,SAAgB,+BAA+B,CAAqF,OAAU,EAAE,IAAO,EAAE,MAA4C;IACnM,OAAO,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAA+C,CAAC;AACxG,CAAC;AAFD,0EAEC;AAED,SAAgB,wBAAwB,CAAqF,OAAU,EAAE,IAAO,EAAE,MAA+C;IAC/L,MAAM,qBAAqB,GAAG,+BAA+B,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACrF,IAAI,MAAqD,CAAC;IAE1D,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE;QACvC,MAAM,GAAG,qBAAqB,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAkD,CAAC;KACnI;SAAM;QACL,MAAM,GAAG,qBAAqB,CAAC,GAAoD,CAAC;KACrF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,4DAWC"}
|
|
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./permission"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./permission.context"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./permission.service"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./permission.service.role"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./permission.service.grant"), exports);
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,+DAAqC;AACrC,+DAAqC;AACrC,oEAA0C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,+DAAqC;AACrC,+DAAqC;AACrC,oEAA0C;AAC1C,qEAA2C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FirestoreDocument } from './../../firestore';
|
|
2
2
|
import { AbstractModelPermissionService, GrantedRoleMap, InContextModelPermissionService, InModelContextModelPermissionService, ModelPermissionService } from '@dereekb/model';
|
|
3
|
-
import {
|
|
3
|
+
import { Maybe, PromiseOrValue } from '@dereekb/util';
|
|
4
4
|
import { FirebaseModelLoader, InModelContextFirebaseModelLoader } from '../model/model.loader';
|
|
5
5
|
import { FirebaseModelContext } from '../context';
|
|
6
6
|
import { FirebasePermissionServiceModel } from './permission';
|
|
@@ -21,47 +21,3 @@ export declare class FirebaseModelPermissionServiceInstance<C extends FirebaseMo
|
|
|
21
21
|
export declare function firebaseModelPermissionService<C extends FirebaseModelContext, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string>(delegate: FirebasePermissionServiceInstanceDelegate<C, T, D, R>): FirebaseModelPermissionServiceInstance<C, T, D, R>;
|
|
22
22
|
export declare type InContextFirebaseModelPermissionService<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string> = InContextModelPermissionService<C, D, R, FirebasePermissionServiceModel<T, D>>;
|
|
23
23
|
export declare type InModelContextFirebaseModelPermissionService<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string> = InModelContextModelPermissionService<C, D, R, FirebasePermissionServiceModel<T, D>> & InModelContextFirebaseModelLoader<T, D>;
|
|
24
|
-
export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction;
|
|
25
|
-
export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: () => GrantedRoleMap<R>): GrantedRoleMap<R>;
|
|
26
|
-
/**
|
|
27
|
-
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
28
|
-
*
|
|
29
|
-
* @param context
|
|
30
|
-
* @param rolesToGrantToAdmin
|
|
31
|
-
* @param otherwise
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export declare function grantModelRolesIfAdminFunction<R extends string = string>(rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<R>;
|
|
35
|
-
/**
|
|
36
|
-
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
37
|
-
*
|
|
38
|
-
* @param context
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
export declare const isAdminInFirebaseModelContext: DecisionFunction<FirebaseModelContext>;
|
|
42
|
-
/**
|
|
43
|
-
* Grants the configured roles if the decision is made about the context. Otherwise, returns a NoAccessRoleMap.
|
|
44
|
-
*/
|
|
45
|
-
export declare type GrantRolesOnlyIfFunction<R extends string = string, C extends FirebaseModelContext = FirebaseModelContext> = (context: C) => GrantedRoleMap<R>;
|
|
46
|
-
export declare type GeneralGrantRolesOnlyIfFunction = <R extends string = string, C extends FirebaseModelContext = FirebaseModelContext>(context: C) => GrantedRoleMap<R>;
|
|
47
|
-
/**
|
|
48
|
-
* Creates a GrantRolesOnlyIfFunction
|
|
49
|
-
*
|
|
50
|
-
* @param grantIf
|
|
51
|
-
* @param grantedRoles
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
export declare function grantModelRolesOnlyIfFunction<C extends FirebaseModelContext, R extends string = string>(grantIf: DecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesOnlyIfFunction<R, C>;
|
|
55
|
-
/**
|
|
56
|
-
* Grants the configured roles if the decision is made about the context. Otherwise, invokes the otherwise function if available, or returns a NoAccessRoleMap.
|
|
57
|
-
*/
|
|
58
|
-
export declare type GrantRolesIfFunction<R extends string = string, C extends FirebaseModelContext = FirebaseModelContext> = (context: C, otherwise?: Getter<GrantedRoleMap<R>>) => GrantedRoleMap<R>;
|
|
59
|
-
export declare type GeneralGrantRolesIfFunction = <R extends string = string, C extends FirebaseModelContext = FirebaseModelContext>(context: C, otherwise?: Getter<GrantedRoleMap<R>>) => GrantedRoleMap<R>;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a GrantRolesIfFunction.
|
|
62
|
-
*
|
|
63
|
-
* @param grantIf
|
|
64
|
-
* @param grantedRoles
|
|
65
|
-
* @returns
|
|
66
|
-
*/
|
|
67
|
-
export declare function grantModelRolesIfFunction<C extends FirebaseModelContext, R extends string = string>(grantIf: DecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<R, C>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { FirestoreDocument } from './../../firestore/accessor/document';
|
|
2
|
+
import { GrantedRoleMap } from '@dereekb/model';
|
|
3
|
+
import { AsyncDecisionFunction, Getter, GetterOrValue, Maybe, PromiseOrValue } from '@dereekb/util';
|
|
4
|
+
import { FirebaseModelContext } from '../context';
|
|
5
|
+
import { UserRelated } from '../../../model/user';
|
|
6
|
+
/**
|
|
7
|
+
* Convenience function that checks the input context if the user is an admin or grants all roles.
|
|
8
|
+
*/
|
|
9
|
+
export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction<FirebaseModelContext>;
|
|
10
|
+
export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): PromiseOrValue<GrantedRoleMap<R>>;
|
|
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.
|
|
13
|
+
*
|
|
14
|
+
* @param context
|
|
15
|
+
* @param rolesToGrantToAdmin
|
|
16
|
+
* @param otherwise
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function grantModelRolesIfAdminFunction<R extends string = string>(rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<FirebaseModelContext, R>;
|
|
20
|
+
/**
|
|
21
|
+
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
22
|
+
*
|
|
23
|
+
* @param context
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare const isAdminInFirebaseModelContext: AsyncDecisionFunction<FirebaseModelContext>;
|
|
27
|
+
export declare type UserRelatedModelFirebaseModelContext<T extends UserRelated = UserRelated> = UserRelatedModelFirebaseModelContextModelInput<T> | UserRelatedModelFirebaseModelContextDocumentInput<T>;
|
|
28
|
+
export declare type UserRelatedModelFirebaseModelContextModelInput<T extends UserRelated = UserRelated> = {
|
|
29
|
+
model: T;
|
|
30
|
+
context: FirebaseModelContext;
|
|
31
|
+
};
|
|
32
|
+
export declare type UserRelatedModelFirebaseModelContextDocumentInput<T extends UserRelated = UserRelated> = {
|
|
33
|
+
document: FirestoreDocument<T>;
|
|
34
|
+
context: FirebaseModelContext;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Convenience function that checks the input context if the user is related to the model by uid.
|
|
38
|
+
*/
|
|
39
|
+
export declare const grantFullAccessIfAuthUserRelated: GeneralGrantRolesIfFunction<UserRelatedModelFirebaseModelContext<UserRelated>>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
|
|
42
|
+
*
|
|
43
|
+
* @param context
|
|
44
|
+
* @param rolesToGrant
|
|
45
|
+
* @param otherwise
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function grantModelRolesIfAuthUserRelatedModelFunction<T extends UserRelated, R extends string = string>(rolesToGrant: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<UserRelatedModelFirebaseModelContext<T>, R>;
|
|
49
|
+
/**
|
|
50
|
+
* DecisionFunction for a FirebaseModelContext that checks if the user is related to the model by uid.
|
|
51
|
+
*
|
|
52
|
+
* @param context
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare const isOwnerOfUserRelatedModelInFirebaseModelContext: AsyncDecisionFunction<UserRelatedModelFirebaseModelContext<UserRelated>>;
|
|
56
|
+
/**
|
|
57
|
+
* Grants the configured roles if the decision is made about the context. Otherwise, returns a NoAccessRoleMap.
|
|
58
|
+
*/
|
|
59
|
+
export declare type GrantRolesOnlyIfFunction<C, R extends string = string> = (context: C) => Promise<GrantedRoleMap<R>>;
|
|
60
|
+
export declare type GeneralGrantRolesOnlyIfFunction<C> = <R extends string = string>(context: C) => Promise<GrantedRoleMap<R>>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a GrantRolesOnlyIfFunction
|
|
63
|
+
*
|
|
64
|
+
* @param grantIf
|
|
65
|
+
* @param grantedRoles
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
export declare function grantModelRolesOnlyIfFunction<C, R extends string = string>(grantIf: AsyncDecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesOnlyIfFunction<C, R>;
|
|
69
|
+
/**
|
|
70
|
+
* Grants the configured roles if the decision is made about the context. Otherwise, invokes the otherwise function if available, or returns a NoAccessRoleMap.
|
|
71
|
+
*/
|
|
72
|
+
export declare type GrantRolesIfFunction<C, R extends string = string> = (context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
|
|
73
|
+
export declare type GeneralGrantRolesIfFunction<C> = <R extends string = string>(context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
|
|
74
|
+
/**
|
|
75
|
+
* Used as the "else" statement for grantModelRolesIfFunction.
|
|
76
|
+
*
|
|
77
|
+
* If no roles are returned, the grantModelRolesIfFunction() will return a NoAccessRoleMap.
|
|
78
|
+
*/
|
|
79
|
+
export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<PromiseOrValue<GrantedRoleMap<R>>>>;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a GrantRolesIfFunction.
|
|
82
|
+
*
|
|
83
|
+
* @param grantIf
|
|
84
|
+
* @param grantedRoles
|
|
85
|
+
* @returns
|
|
86
|
+
*/
|
|
87
|
+
export declare function grantModelRolesIfFunction<C, R extends string = string>(grantIf: AsyncDecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<C, R>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.grantModelRolesIfFunction = exports.grantModelRolesOnlyIfFunction = exports.isOwnerOfUserRelatedModelInFirebaseModelContext = exports.grantModelRolesIfAuthUserRelatedModelFunction = exports.grantFullAccessIfAuthUserRelated = exports.isAdminInFirebaseModelContext = exports.grantModelRolesIfAdminFunction = exports.grantModelRolesIfAdmin = exports.grantFullAccessIfAdmin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const model_1 = require("@dereekb/model");
|
|
6
|
+
const util_1 = require("@dereekb/util");
|
|
7
|
+
// MARK: Admin
|
|
8
|
+
/**
|
|
9
|
+
* Convenience function that checks the input context if the user is an admin or grants all roles.
|
|
10
|
+
*/
|
|
11
|
+
exports.grantFullAccessIfAdmin = grantModelRolesIfAdminFunction(model_1.fullAccessRoleMap);
|
|
12
|
+
function grantModelRolesIfAdmin(context, rolesToGrantToAdmin, otherwise) {
|
|
13
|
+
return grantModelRolesIfAdminFunction(rolesToGrantToAdmin)(context, otherwise);
|
|
14
|
+
}
|
|
15
|
+
exports.grantModelRolesIfAdmin = grantModelRolesIfAdmin;
|
|
16
|
+
/**
|
|
17
|
+
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
18
|
+
*
|
|
19
|
+
* @param context
|
|
20
|
+
* @param rolesToGrantToAdmin
|
|
21
|
+
* @param otherwise
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
function grantModelRolesIfAdminFunction(rolesToGrantToAdmin) {
|
|
25
|
+
return grantModelRolesIfFunction(exports.isAdminInFirebaseModelContext, rolesToGrantToAdmin);
|
|
26
|
+
}
|
|
27
|
+
exports.grantModelRolesIfAdminFunction = grantModelRolesIfAdminFunction;
|
|
28
|
+
/**
|
|
29
|
+
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
30
|
+
*
|
|
31
|
+
* @param context
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
const isAdminInFirebaseModelContext = (context) => { var _a, _b; return (_b = (_a = context.auth) === null || _a === void 0 ? void 0 : _a.isAdmin()) !== null && _b !== void 0 ? _b : false; };
|
|
35
|
+
exports.isAdminInFirebaseModelContext = isAdminInFirebaseModelContext;
|
|
36
|
+
/**
|
|
37
|
+
* Convenience function that checks the input context if the user is related to the model by uid.
|
|
38
|
+
*/
|
|
39
|
+
exports.grantFullAccessIfAuthUserRelated = grantModelRolesIfAuthUserRelatedModelFunction(model_1.fullAccessRoleMap);
|
|
40
|
+
/**
|
|
41
|
+
* Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
|
|
42
|
+
*
|
|
43
|
+
* @param context
|
|
44
|
+
* @param rolesToGrant
|
|
45
|
+
* @param otherwise
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
function grantModelRolesIfAuthUserRelatedModelFunction(rolesToGrant) {
|
|
49
|
+
return grantModelRolesIfFunction(exports.isOwnerOfUserRelatedModelInFirebaseModelContext, rolesToGrant);
|
|
50
|
+
}
|
|
51
|
+
exports.grantModelRolesIfAuthUserRelatedModelFunction = grantModelRolesIfAuthUserRelatedModelFunction;
|
|
52
|
+
/**
|
|
53
|
+
* DecisionFunction for a FirebaseModelContext that checks if the user is related to the model by uid.
|
|
54
|
+
*
|
|
55
|
+
* @param context
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
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
|
+
});
|
|
75
|
+
exports.isOwnerOfUserRelatedModelInFirebaseModelContext = isOwnerOfUserRelatedModelInFirebaseModelContext;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a GrantRolesOnlyIfFunction
|
|
78
|
+
*
|
|
79
|
+
* @param grantIf
|
|
80
|
+
* @param grantedRoles
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
function grantModelRolesOnlyIfFunction(grantIf, grantedRoles) {
|
|
84
|
+
const fn = grantModelRolesIfFunction(grantIf, grantedRoles);
|
|
85
|
+
return (context) => fn(context);
|
|
86
|
+
}
|
|
87
|
+
exports.grantModelRolesOnlyIfFunction = grantModelRolesOnlyIfFunction;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a GrantRolesIfFunction.
|
|
90
|
+
*
|
|
91
|
+
* @param grantIf
|
|
92
|
+
* @param grantedRoles
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
function grantModelRolesIfFunction(grantIf, grantedRoles) {
|
|
96
|
+
return (context, otherwise = model_1.noAccessRoleMap) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
var _a;
|
|
98
|
+
const decision = yield grantIf(context);
|
|
99
|
+
const results = decision ? yield (0, util_1.getValueFromGetter)(grantedRoles) : (_a = (yield otherwise())) !== null && _a !== void 0 ? _a : (0, model_1.noAccessRoleMap)();
|
|
100
|
+
return results;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.grantModelRolesIfFunction = grantModelRolesIfFunction;
|
|
104
|
+
//# sourceMappingURL=permission.service.grant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IAElC,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,IAAI,KAAK,GAAwB,OAA0D,CAAC,KAAK,CAAC;QAElG,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,QAAQ,GAAI,OAA6D,CAAC,QAAQ,CAAC;YAEzF,IAAI,QAAQ,EAAE;gBACZ,KAAK,GAAG,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;aAChD;SACF;QAED,IAAI,KAAK,EAAE;YACT,QAAQ,GAAG,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC;SACnC;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AArBW,QAAA,+CAA+C,mDAqB1D;AASF;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAA+B,OAAiC,EAAE,YAA8C;IAC3J,MAAM,EAAE,GAAG,yBAAyB,CAAO,OAAO,EAAE,YAAY,CAAC,CAAC;IAClE,OAAO,CAAC,OAAU,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAHD,sEAGC;AAeD;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAA+B,OAAiC,EAAE,YAA8C;IACvJ,OAAO,CAAO,OAAU,EAAE,YAA4C,uBAAe,EAAE,EAAE;;QACvF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAkB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC,MAAM,SAAS,EAAE,CAAC,mCAAI,IAAA,uBAAe,GAAE,CAAC;QAC7G,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAND,8DAMC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.firebaseModelPermissionService = exports.FirebaseModelPermissionServiceInstance = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const model_1 = require("@dereekb/model");
|
|
6
|
-
const util_1 = require("@dereekb/util");
|
|
7
6
|
/**
|
|
8
7
|
* Abstract AbstractModelPermissionService implementation for FirebaseModelsPermissionService.
|
|
9
8
|
*/
|
|
@@ -32,57 +31,4 @@ function firebaseModelPermissionService(delegate) {
|
|
|
32
31
|
return new FirebaseModelPermissionServiceInstance(delegate);
|
|
33
32
|
}
|
|
34
33
|
exports.firebaseModelPermissionService = firebaseModelPermissionService;
|
|
35
|
-
// MARK: Utility
|
|
36
|
-
exports.grantFullAccessIfAdmin = grantModelRolesIfAdminFunction(model_1.fullAccessRoleMap);
|
|
37
|
-
function grantModelRolesIfAdmin(context, rolesToGrantToAdmin, otherwise) {
|
|
38
|
-
return grantModelRolesIfAdminFunction(rolesToGrantToAdmin)(context, otherwise);
|
|
39
|
-
}
|
|
40
|
-
exports.grantModelRolesIfAdmin = grantModelRolesIfAdmin;
|
|
41
|
-
/**
|
|
42
|
-
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
43
|
-
*
|
|
44
|
-
* @param context
|
|
45
|
-
* @param rolesToGrantToAdmin
|
|
46
|
-
* @param otherwise
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
function grantModelRolesIfAdminFunction(rolesToGrantToAdmin) {
|
|
50
|
-
return grantModelRolesIfFunction(exports.isAdminInFirebaseModelContext, rolesToGrantToAdmin);
|
|
51
|
-
}
|
|
52
|
-
exports.grantModelRolesIfAdminFunction = grantModelRolesIfAdminFunction;
|
|
53
|
-
/**
|
|
54
|
-
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
55
|
-
*
|
|
56
|
-
* @param context
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
const isAdminInFirebaseModelContext = (context) => { var _a, _b; return (_b = (_a = context.auth) === null || _a === void 0 ? void 0 : _a.isAdmin()) !== null && _b !== void 0 ? _b : false; };
|
|
60
|
-
exports.isAdminInFirebaseModelContext = isAdminInFirebaseModelContext;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a GrantRolesOnlyIfFunction
|
|
63
|
-
*
|
|
64
|
-
* @param grantIf
|
|
65
|
-
* @param grantedRoles
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
function grantModelRolesOnlyIfFunction(grantIf, grantedRoles) {
|
|
69
|
-
const fn = grantModelRolesIfFunction(grantIf, grantedRoles);
|
|
70
|
-
return (context) => fn(context);
|
|
71
|
-
}
|
|
72
|
-
exports.grantModelRolesOnlyIfFunction = grantModelRolesOnlyIfFunction;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a GrantRolesIfFunction.
|
|
75
|
-
*
|
|
76
|
-
* @param grantIf
|
|
77
|
-
* @param grantedRoles
|
|
78
|
-
* @returns
|
|
79
|
-
*/
|
|
80
|
-
function grantModelRolesIfFunction(grantIf, grantedRoles) {
|
|
81
|
-
return (context, otherwise = model_1.noAccessRoleMap) => {
|
|
82
|
-
const decision = grantIf(context);
|
|
83
|
-
const results = decision ? (0, util_1.getValueFromGetter)(grantedRoles) : otherwise();
|
|
84
|
-
return results;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
exports.grantModelRolesIfFunction = grantModelRolesIfFunction;
|
|
88
34
|
//# sourceMappingURL=permission.service.js.map
|
|
@@ -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.7.0](https://github.com/dereekb/dbx-components/compare/v7.6.0-dev...v7.7.0) (2022-06-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
# [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
|
|
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.7.0",
|
|
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.7.0",
|
|
9
|
+
"@dereekb/util": "7.7.0",
|
|
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.7.0",
|
|
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.7.0",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "7.
|
|
19
|
+
"@dereekb/model": "7.7.0",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "7.
|
|
22
|
+
"@dereekb/date": "7.7.0",
|
|
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",
|