@dereekb/firebase 7.1.0 → 7.4.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/package.json +6 -6
  3. package/src/lib/common/auth/auth.context.d.ts +15 -3
  4. package/src/lib/common/firestore/collection/collection.d.ts +8 -8
  5. package/src/lib/common/firestore/collection/collection.js +2 -8
  6. package/src/lib/common/firestore/collection/collection.js.map +1 -1
  7. package/src/lib/common/firestore/collection/collection.key.d.ts +53 -0
  8. package/src/lib/common/firestore/collection/collection.key.js +3 -0
  9. package/src/lib/common/firestore/collection/collection.key.js.map +1 -0
  10. package/src/lib/common/firestore/collection/index.d.ts +1 -0
  11. package/src/lib/common/firestore/collection/index.js +1 -0
  12. package/src/lib/common/firestore/collection/index.js.map +1 -1
  13. package/src/lib/common/firestore/query/constraint.d.ts +1 -2
  14. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +74 -1
  15. package/src/lib/common/firestore/snapshot/snapshot.field.js +83 -1
  16. package/src/lib/common/firestore/snapshot/snapshot.field.js.map +1 -1
  17. package/src/lib/common/firestore/snapshot/snapshot.js.map +1 -1
  18. package/src/lib/common/model/context.d.ts +0 -6
  19. package/src/lib/common/model/permission/permission.service.d.ts +45 -2
  20. package/src/lib/common/model/permission/permission.service.js +55 -15
  21. package/src/lib/common/model/permission/permission.service.js.map +1 -1
  22. package/test/CHANGELOG.md +17 -0
  23. package/test/package.json +8 -8
  24. package/test/src/lib/common/firestore.mock.item.d.ts +23 -27
  25. package/test/src/lib/common/firestore.mock.item.fixture.d.ts +2 -2
  26. package/test/src/lib/common/firestore.mock.item.fixture.js +4 -4
  27. package/test/src/lib/common/firestore.mock.item.js +27 -31
  28. package/test/src/lib/common/firestore.mock.item.js.map +1 -1
  29. package/test/src/lib/common/firestore.mock.item.query.d.ts +1 -1
  30. package/test/src/lib/common/firestore.mock.item.query.js +3 -3
  31. package/test/src/lib/common/firestore.mock.item.service.d.ts +6 -6
  32. package/test/src/lib/common/firestore.mock.item.service.js +6 -6
  33. package/test/src/lib/common/firestore.mock.item.service.js.map +1 -1
  34. package/test/src/lib/common/test.driver.query.js +4 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * added grantModelRolesIfFunction and related types ([5432fab](https://github.com/dereekb/dbx-components/commit/5432fab1677c29e24eac4015c35821aba2d64e10))
11
+ * updated FirebaseServerAuthUserContext to be synchronous ([92bfd84](https://github.com/dereekb/dbx-components/commit/92bfd849b4a6d6773c616069c3085b686938ef4d))
12
+
13
+
14
+
15
+ # [7.3.0](https://github.com/dereekb/dbx-components/compare/v7.2.0-dev...v7.3.0) (2022-06-08)
16
+
17
+
18
+ ### Features
19
+
20
+ * added FirestoreMap, FirestoreArrayMap snapshot fields ([bd23fd3](https://github.com/dereekb/dbx-components/commit/bd23fd372e3f2180980d7aec9c1b6ee1ec2bb3c7))
21
+
22
+
23
+
24
+ # [7.2.0](https://github.com/dereekb/dbx-components/compare/v7.1.0-dev...v7.2.0) (2022-06-06)
25
+
26
+
27
+ ### Features
28
+
29
+ * firestoreModeIdentity can now accept a collection name ([1e0646e](https://github.com/dereekb/dbx-components/commit/1e0646e598a0834d8b4c3d264bb5ee42626e9fc7))
30
+
31
+
32
+
5
33
  # [7.1.0](https://github.com/dereekb/dbx-components/compare/v7.0.1-dev...v7.1.0) (2022-06-06)
6
34
 
7
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "7.1.0",
3
+ "version": "7.4.0",
4
4
  "devDependencies": {
5
5
  "@firebase/rules-unit-testing": "^2.0.0"
6
6
  },
@@ -22,19 +22,19 @@
22
22
  "rxjs": "^7.0.0",
23
23
  "rxfire": "^6.0.3",
24
24
  "firebase": "^9.8.0",
25
- "@dereekb/util": "7.1.0",
25
+ "@dereekb/util": "7.4.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.1.0",
29
+ "@dereekb/rxjs": "7.4.0",
30
30
  "ms": "^3.0.0-canary.1",
31
- "@dereekb/date": "7.1.0",
31
+ "@dereekb/model": "7.4.0",
32
32
  "class-transformer": "^0.5.1",
33
- "date-fns": "^2.28.0",
34
33
  "class-validator": "^0.13.2",
34
+ "@dereekb/date": "7.4.0",
35
+ "date-fns": "^2.28.0",
35
36
  "date-fns-tz": "^1.3.0",
36
37
  "rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
37
- "@dereekb/model": "7.1.0",
38
38
  "tslib": "^2.0.0"
39
39
  }
40
40
  }
@@ -1,4 +1,4 @@
1
- import { AuthClaims, AuthRoleSet, Maybe } from '@dereekb/util';
1
+ import { AuthClaims, AuthClaimsObject, AuthRoleSet, Maybe } from '@dereekb/util';
2
2
  import { FirebaseAuthToken } from './auth';
3
3
  /**
4
4
  * Provides a context containing FirebaseAuthContextInfo
@@ -17,14 +17,26 @@ export interface FirebaseAuthContextInfo {
17
17
  /**
18
18
  * Returns true if the user is considered a system admin.
19
19
  */
20
- isAdmin?(): boolean;
20
+ isAdmin(): boolean;
21
21
  /**
22
22
  * Retrieves the claims in the context.
23
23
  */
24
- loadClaims(): Promise<AuthClaims>;
24
+ getClaims<T extends AuthClaimsObject = AuthClaimsObject>(): AuthClaims<T>;
25
25
  /**
26
26
  * The auth roles provided by the token in this context.
27
27
  */
28
+ getAuthRoles(): AuthRoleSet;
29
+ /**
30
+ * Retrieves the claims in the context.
31
+ *
32
+ * @deprecated Claims are now available synchronously.
33
+ */
34
+ loadClaims<T extends AuthClaimsObject = AuthClaimsObject>(): Promise<AuthClaims<T>>;
35
+ /**
36
+ * The auth roles provided by the token in this context.
37
+ *
38
+ * @deprecated Auth role set is now available synchronously.
39
+ */
28
40
  loadAuthRoles(): Promise<AuthRoleSet>;
29
41
  /**
30
42
  * The token in the context.
@@ -17,18 +17,17 @@ export declare type FirestoreModelName = ModelTypeString;
17
17
  * Each collection name in the app should be unique, as usage of CollectionGroups would cause collections with the same name to be returned.
18
18
  */
19
19
  export declare type FirestoreCollectionName = string;
20
- /**
21
- * FirestoreCollectionName derived from a FirestoreModelName
22
- */
23
- export declare type FirestoreModelCollectionName<M extends FirestoreModelName> = `${Lowercase<M>}`;
24
20
  /**
25
21
  * A firestore model's identity
26
22
  */
27
- export declare type FirestoreModelIdentity<M extends FirestoreModelName = FirestoreModelName> = {
23
+ export declare type FirestoreModelIdentity<M extends FirestoreModelName = FirestoreModelName, C extends FirestoreCollectionName = FirestoreCollectionName> = {
28
24
  readonly model: M;
29
- readonly collection: FirestoreModelCollectionName<M>;
25
+ readonly collection: C;
30
26
  };
31
- export declare type FirestoreCollectionNames<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? FirestoreModelCollectionName<M> : never;
27
+ /**
28
+ * A default collection name derived from the model name.
29
+ */
30
+ export declare type FirestoreModelDefaultCollectionName<M extends FirestoreModelName> = `${Lowercase<M>}`;
32
31
  export declare type FirestoreModelNames<I extends FirestoreModelIdentity> = I extends FirestoreModelIdentity<infer M> ? M : never;
33
32
  /**
34
33
  * Creates a FirestoreModelIdentity value.
@@ -36,7 +35,8 @@ export declare type FirestoreModelNames<I extends FirestoreModelIdentity> = I ex
36
35
  * @param modelName
37
36
  * @returns
38
37
  */
39
- export declare function firestoreModelIdentity<M extends FirestoreModelName>(modelName: M): FirestoreModelIdentity<M>;
38
+ export declare function firestoreModelIdentity<M extends FirestoreModelName>(modelName: M): FirestoreModelIdentity<M, FirestoreModelDefaultCollectionName<M>>;
39
+ export declare function firestoreModelIdentity<M extends FirestoreModelName, C extends FirestoreCollectionName = FirestoreCollectionName>(modelName: M, collectionName: C): FirestoreModelIdentity<M, C>;
40
40
  /**
41
41
  * Reference to a FirestoreCollectionName
42
42
  */
@@ -5,15 +5,9 @@ const document_1 = require("../accessor/document");
5
5
  const iterator_1 = require("../query/iterator");
6
6
  const query_1 = require("../query/query");
7
7
  const collection_query_1 = require("./collection.query");
8
- /**
9
- * Creates a FirestoreModelIdentity value.
10
- *
11
- * @param modelName
12
- * @returns
13
- */
14
- function firestoreModelIdentity(modelName) {
8
+ function firestoreModelIdentity(modelName, collectionName) {
15
9
  return {
16
- collection: modelName.toLowerCase(),
10
+ collection: collectionName !== null && collectionName !== void 0 ? collectionName : modelName.toLowerCase(),
17
11
  model: modelName
18
12
  };
19
13
  }
@@ -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;AAiCtG;;;;;GAKG;AACH,SAAgB,sBAAsB,CAA+B,SAAY;IAC/E,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,WAAW,EAAqC;QACtE,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC;AALD,wDAKC;AA6GD;;GAEG;AACH,SAAgB,uBAAuB,CAAoC,WAA4C;IACrH,MAAM,MAAM,GAAG,WAAyE,CAAC;IAEzF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IACxE,MAAwD,CAAC,SAAS,GAAG,UAAU,CAAC;IAEjF,MAAM,kBAAkB,GAAiD,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnH,MAAM,gBAAgB,GAAmD,IAAA,2CAAgC,EAAC,MAAM,CAAC,CAAC;IAClH,MAAM,YAAY,GAA6B,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;IAE7E,MAAM,yBAAyB,GAAG,IAAA,oDAAyC,EAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC3H,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,kDAA+B,EAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACnG,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IAE/B,qCACE,MAAM;QACN,UAAU,EACV,SAAS,EAAE,UAAU,EACrB,gBAAgB,IACb,yBAAyB,KAC5B,kBAAkB;QAClB,KAAK;QACL,aAAa,IACb;AACJ,CAAC;AAxBD,0DAwBC"}
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;AAwCtG,SAAgB,sBAAsB,CAA4F,SAAY,EAAE,cAAkB;IAChK,OAAO;QACL,UAAU,EAAE,cAAc,aAAd,cAAc,cAAd,cAAc,GAAK,SAAS,CAAC,WAAW,EAAQ;QAC5D,KAAK,EAAE,SAAS;KACjB,CAAC;AACJ,CAAC;AALD,wDAKC;AA6GD;;GAEG;AACH,SAAgB,uBAAuB,CAAoC,WAA4C;IACrH,MAAM,MAAM,GAAG,WAAyE,CAAC;IAEzF,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,GAAG,MAAM,CAAC;IACxE,MAAwD,CAAC,SAAS,GAAG,UAAU,CAAC;IAEjF,MAAM,kBAAkB,GAAiD,IAAA,4CAAiC,EAAC,MAAM,CAAC,CAAC;IACnH,MAAM,gBAAgB,GAAmD,IAAA,2CAAgC,EAAC,MAAM,CAAC,CAAC;IAClH,MAAM,YAAY,GAA6B,IAAA,6BAAqB,EAAC,MAAM,CAAC,CAAC;IAE7E,MAAM,yBAAyB,GAAG,IAAA,oDAAyC,EAAC,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,CAAC,CAAC;IAC3H,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,kDAA+B,EAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;IACnG,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IAE/B,qCACE,MAAM;QACN,UAAU,EACV,SAAS,EAAE,UAAU,EACrB,gBAAgB,IACb,yBAAyB,KAC5B,kBAAkB;QAClB,KAAK;QACL,aAAa,IACb;AACJ,CAAC;AAxBD,0DAwBC"}
@@ -0,0 +1,53 @@
1
+ import { GrantedRole } from '@dereekb/model';
2
+ import { FirebaseAuthUserId } from '../../auth';
3
+ import { FirestoreModelId, FirestoreModelKey } from './collection';
4
+ export declare type FirestoreModelKeyMap<T> = {
5
+ [key: FirestoreModelKey]: T;
6
+ };
7
+ /**
8
+ * Array of FirestoreModelKey values.
9
+ */
10
+ export declare type FirestoreModelKeyArray = FirestoreModelKey[];
11
+ /**
12
+ * A map with a single GrantedRole provided for a given model.
13
+ */
14
+ export declare type FirestoreModelKeyGrantedRoleMap<R extends GrantedRole> = {
15
+ [key: FirestoreModelKey]: R;
16
+ };
17
+ /**
18
+ * A map with multiple GrantedRoles provided for a given model.
19
+ */
20
+ export declare type FirestoreModelKeyGrantedRoleArrayMap<R extends GrantedRole> = {
21
+ [key: FirestoreModelKey]: R[];
22
+ };
23
+ export declare type FirestoreModelIdMap<T> = {
24
+ [key: FirestoreModelId]: T;
25
+ };
26
+ /**
27
+ * Array of FirestoreModelId values.
28
+ */
29
+ export declare type FirestoreModelIdArray = FirestoreModelId[];
30
+ /**
31
+ * A map with a single GrantedRole provided for a given model.
32
+ */
33
+ export declare type FirestoreModelIdGrantedRoleMap<R extends GrantedRole> = {
34
+ [key: FirestoreModelId]: R;
35
+ };
36
+ /**
37
+ * A map with multiple GrantedRoles provided for a given model.
38
+ */
39
+ export declare type FirestoreModelIdGrantedRoleArrayMap<R extends GrantedRole> = {
40
+ [key: FirestoreModelId]: R[];
41
+ };
42
+ /**
43
+ * A map with a single GrantedRole provided for a given user.
44
+ */
45
+ export declare type FirebaseAuthUserGrantedRoleMap<R extends GrantedRole> = {
46
+ [key: FirebaseAuthUserId]: R;
47
+ };
48
+ /**
49
+ * A map with multiple GrantedRoles provided for a given user.
50
+ */
51
+ export declare type FirebaseAuthUserRoleArrayMap<R extends GrantedRole> = {
52
+ [key: FirestoreModelKey]: R[];
53
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=collection.key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.key.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/collection.key.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  export * from './collection';
2
+ export * from './collection.key';
2
3
  export * from './collection.group';
3
4
  export * from './subcollection';
4
5
  export * from './subcollection.single';
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./collection"), exports);
5
+ tslib_1.__exportStar(require("./collection.key"), exports);
5
6
  tslib_1.__exportStar(require("./collection.group"), exports);
6
7
  tslib_1.__exportStar(require("./subcollection"), exports);
7
8
  tslib_1.__exportStar(require("./subcollection.single"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,6DAAmC;AACnC,0DAAgC;AAChC,iEAAuC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/collection/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,2DAAiC;AACjC,6DAAmC;AACnC,0DAAgC;AAChC,iEAAuC"}
@@ -47,8 +47,7 @@ export interface WhereQueryConstraintData {
47
47
  export declare function where<T>(fieldPath: keyof T, opStr: WhereFilterOp, value: unknown): FirestoreQueryConstraint<WhereQueryConstraintData>;
48
48
  export declare function where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): FirestoreQueryConstraint<WhereQueryConstraintData>;
49
49
  export declare const FIRESTORE_WHERE_DOCUMENT_ID_QUERY_CONSTRAINT_TYPE = "where_doc_id";
50
- export interface WhereDocumentIdQueryConstraintData extends Omit<WhereQueryConstraintData, 'fieldPath'> {
51
- }
50
+ export declare type WhereDocumentIdQueryConstraintData = Omit<WhereQueryConstraintData, 'fieldPath'>;
52
51
  export declare function whereDocumentId(opStr: WhereFilterOp, value: unknown): FirestoreQueryConstraint<WhereDocumentIdQueryConstraintData>;
53
52
  export declare const FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE = "order_by";
54
53
  export declare type OrderByDirection = SortingOrder;
@@ -1,4 +1,5 @@
1
- import { ModelFieldMapFunctionsConfig, GetterOrValue, Maybe, ModelFieldMapConvertFunction, PrimativeKey, ReadKeyFunction, ModelFieldMapFunctionsWithDefaultsConfig, FindUniqueFunction, FindUniqueStringsTransformConfig, MapFunction } from '@dereekb/util';
1
+ import { GrantedRole } from '@dereekb/model';
2
+ import { ModelFieldMapFunctionsConfig, GetterOrValue, Maybe, ModelFieldMapConvertFunction, PrimativeKey, ReadKeyFunction, ModelFieldMapFunctionsWithDefaultsConfig, FindUniqueFunction, FindUniqueStringsTransformConfig, MapFunction, FilterKeyValueTuplesInput, ModelKey } from '@dereekb/util';
2
3
  export interface BaseFirestoreFieldConfig<V, D = unknown> {
3
4
  fromData: ModelFieldMapConvertFunction<D, V>;
4
5
  toData: ModelFieldMapConvertFunction<V, D>;
@@ -33,6 +34,8 @@ export declare function firestoreString(config?: FirestoreStringConfig): Firesto
33
34
  export declare function optionalFirestoreString(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
34
35
  export declare function firestoreUID(): FirestoreModelFieldMapFunctionsConfig<string, string>;
35
36
  export declare function optionalFirestoreUID(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
37
+ export declare const firestoreModelKey: FirestoreModelFieldMapFunctionsConfig<string, string>;
38
+ export declare const firestoreModelId: FirestoreModelFieldMapFunctionsConfig<string, string>;
36
39
  export declare type FirestoreDateFieldConfig = DefaultMapConfiguredFirestoreFieldConfig<Date, string> & {
37
40
  saveDefaultAsNow?: boolean;
38
41
  };
@@ -57,6 +60,18 @@ export declare type FirestoreUniqueKeyedArrayFieldConfig<T, K extends PrimativeK
57
60
  export declare function firestoreUniqueKeyedArray<T, K extends PrimativeKey = PrimativeKey>(config: FirestoreUniqueKeyedArrayFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<T[], T[]>;
58
61
  export declare type FirestoreUniqueStringArrayFieldConfig = Omit<FirestoreUniqueArrayFieldConfig<string>, 'findUnique'> & FindUniqueStringsTransformConfig;
59
62
  export declare function firestoreUniqueStringArray(config: FirestoreUniqueStringArrayFieldConfig): FirestoreModelFieldMapFunctionsConfig<string[], string[]>;
63
+ /**
64
+ * FirestoreField configuration for an array of ModelKey values.
65
+ *
66
+ * @returns
67
+ */
68
+ export declare function firestoreModelKeyArray(): FirestoreModelFieldMapFunctionsConfig<string[], string[]>;
69
+ /**
70
+ * FirestoreField configuration for an array of ModelId values.
71
+ *
72
+ * @returns
73
+ */
74
+ export declare const firestoreModelIdArray: typeof firestoreModelKeyArray;
60
75
  export declare type FirestoreEncodedArrayFieldConfig<T, E extends string | number> = DefaultMapConfiguredFirestoreFieldConfig<T[], E[]> & {
61
76
  readonly convert: {
62
77
  fromData: MapFunction<E, T>;
@@ -70,6 +85,64 @@ export declare type FirestoreEncodedArrayFieldConfig<T, E extends string | numbe
70
85
  * @returns
71
86
  */
72
87
  export declare function firestoreEncodedArray<T, E extends string | number>(config: FirestoreEncodedArrayFieldConfig<T, E>): FirestoreModelFieldMapFunctionsConfig<T[], E[]>;
88
+ /**
89
+ * Firestore/JSON maps only have string keys.
90
+ */
91
+ export declare type FirestoreMapFieldType<T, K extends string = string> = Record<K, T>;
92
+ export declare type FirestoreMapFieldConfig<T, K extends string = string> = DefaultMapConfiguredFirestoreFieldConfig<FirestoreMapFieldType<T, K>, FirestoreMapFieldType<T, K>> & Partial<FirestoreFieldDefault<FirestoreMapFieldType<T, K>>> & {
93
+ /**
94
+ * Optional filter to apply when saving to data.
95
+ *
96
+ * By default will filter all null/undefined values from maps.
97
+ */
98
+ mapFilter?: FilterKeyValueTuplesInput<FirestoreMapFieldType<K>>;
99
+ /**
100
+ * Optional map function to apply to each input value before
101
+ */
102
+ mapFieldValues?: MapFunction<Maybe<T>, Maybe<T>>;
103
+ };
104
+ /**
105
+ * FirestoreField configuration for a map-type object.
106
+ *
107
+ * By default it will remove all null/undefined keys from objects before saving.
108
+ *
109
+ * @param config
110
+ * @returns
111
+ */
112
+ export declare function firestoreMap<T, K extends string = string>(config?: FirestoreMapFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<T, K>, FirestoreMapFieldType<T, K>>;
113
+ /**
114
+ * FirestoreField configuration for a map of granted roles, keyed by model keys.
115
+ *
116
+ * Filters out models with no/null roles by default.
117
+ */
118
+ export declare function firestoreModelKeyGrantedRoleMap<R extends GrantedRole>(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<R, string>, FirestoreMapFieldType<R, string>>;
119
+ /**
120
+ * FirestoreField configuration for a map of granted roles, keyed by model ids.
121
+ *
122
+ * Filters out models with no/null roles by default.
123
+ */
124
+ export declare const firestoreModelIdGrantedRoleMap: () => FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<ModelKey, string>, FirestoreMapFieldType<ModelKey, string>>;
125
+ /**
126
+ * FirestoreField configuration for a map-type object with array values.
127
+ *
128
+ * @param config
129
+ * @returns
130
+ */
131
+ export declare type FirestoreArrayMapFieldType<T, K extends string = string> = FirestoreMapFieldType<T[], K>;
132
+ export declare type FirestoreArrayMapFieldConfig<T, K extends string = string> = FirestoreMapFieldConfig<T[], K>;
133
+ export declare function firestoreArrayMap<T, K extends string = string>(config?: FirestoreArrayMapFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<T[], K>, FirestoreMapFieldType<T[], K>>;
134
+ /**
135
+ * FirestoreField configuration for a map of granted roles, keyed by models keys.
136
+ *
137
+ * Filters empty roles/arrays by default.
138
+ */
139
+ export declare function firestoreModelKeyGrantedRoleArrayMap<R extends GrantedRole>(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<R[], string>, FirestoreMapFieldType<R[], string>>;
140
+ /**
141
+ * FirestoreField configuration for a map of granted roles, keyed by models ids.
142
+ *
143
+ * Filters empty roles/arrays by default.
144
+ */
145
+ export declare const firestoreModelIdGrantedRoleArrayMap: () => FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<ModelKey[], string>, FirestoreMapFieldType<ModelKey[], string>>;
73
146
  export declare type FirestoreSetFieldConfig<T extends string | number> = DefaultMapConfiguredFirestoreFieldConfig<Set<T>, T[]>;
74
147
  /**
75
148
  * Do not use.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.firestoreSet = exports.firestoreEncodedArray = exports.firestoreUniqueStringArray = exports.firestoreUniqueKeyedArray = exports.firestoreUniqueArray = exports.optionalFirestoreArray = exports.firestoreArray = exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = 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.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;
4
4
  const date_1 = require("@dereekb/date");
5
5
  const util_1 = require("@dereekb/util");
6
6
  const snapshot_1 = require("./snapshot");
@@ -50,6 +50,8 @@ function optionalFirestoreUID() {
50
50
  return optionalFirestoreString();
51
51
  }
52
52
  exports.optionalFirestoreUID = optionalFirestoreUID;
53
+ exports.firestoreModelKey = firestoreString();
54
+ exports.firestoreModelId = firestoreString();
53
55
  function firestoreDate(config = {}) {
54
56
  var _a, _b;
55
57
  return firestoreField({
@@ -124,6 +126,22 @@ function firestoreUniqueStringArray(config) {
124
126
  return firestoreUniqueArray(Object.assign(Object.assign({}, config), { findUnique }));
125
127
  }
126
128
  exports.firestoreUniqueStringArray = firestoreUniqueStringArray;
129
+ /**
130
+ * FirestoreField configuration for an array of ModelKey values.
131
+ *
132
+ * @returns
133
+ */
134
+ function firestoreModelKeyArray() {
135
+ // firestore model key paths are case-sensitive, so don't transform them.
136
+ return firestoreUniqueStringArray({});
137
+ }
138
+ exports.firestoreModelKeyArray = firestoreModelKeyArray;
139
+ /**
140
+ * FirestoreField configuration for an array of ModelId values.
141
+ *
142
+ * @returns
143
+ */
144
+ exports.firestoreModelIdArray = firestoreModelKeyArray;
127
145
  /**
128
146
  * A Firestore array that encodes values to either string or number values using another FirestoreModelField config for encoding/decoding.
129
147
  *
@@ -140,6 +158,70 @@ function firestoreEncodedArray(config) {
140
158
  });
141
159
  }
142
160
  exports.firestoreEncodedArray = firestoreEncodedArray;
161
+ /**
162
+ * FirestoreField configuration for a map-type object.
163
+ *
164
+ * By default it will remove all null/undefined keys from objects before saving.
165
+ *
166
+ * @param config
167
+ * @returns
168
+ */
169
+ function firestoreMap(config = {}) {
170
+ var _a;
171
+ const { mapFilter: filter = util_1.KeyValueTypleValueFilter.NULL, mapFieldValues } = config;
172
+ const filterFinalMapValuesFn = (0, util_1.filterFromPOJOFunction)({
173
+ copy: false,
174
+ filter
175
+ });
176
+ const makeCopy = (mapFieldValues ? (0, util_1.mapObjectMapFunction)(mapFieldValues) : util_1.copyObject);
177
+ return firestoreField({
178
+ default: (_a = config.default) !== null && _a !== void 0 ? _a : {},
179
+ fromData: util_1.passThrough,
180
+ toData: (model) => {
181
+ const copy = makeCopy(model);
182
+ return filterFinalMapValuesFn(copy);
183
+ }
184
+ });
185
+ }
186
+ exports.firestoreMap = firestoreMap;
187
+ /**
188
+ * FirestoreField configuration for a map of granted roles, keyed by model keys.
189
+ *
190
+ * Filters out models with no/null roles by default.
191
+ */
192
+ function firestoreModelKeyGrantedRoleMap() {
193
+ return firestoreMap({
194
+ mapFilter: util_1.KeyValueTypleValueFilter.EMPTY
195
+ });
196
+ }
197
+ exports.firestoreModelKeyGrantedRoleMap = firestoreModelKeyGrantedRoleMap;
198
+ /**
199
+ * FirestoreField configuration for a map of granted roles, keyed by model ids.
200
+ *
201
+ * Filters out models with no/null roles by default.
202
+ */
203
+ exports.firestoreModelIdGrantedRoleMap = firestoreModelKeyGrantedRoleMap;
204
+ function firestoreArrayMap(config = {}) {
205
+ return firestoreMap(Object.assign({ mapFilter: util_1.KeyValueTypleValueFilter.EMPTY, mapFieldValues: util_1.filterMaybeValues }, config));
206
+ }
207
+ exports.firestoreArrayMap = firestoreArrayMap;
208
+ /**
209
+ * FirestoreField configuration for a map of granted roles, keyed by models keys.
210
+ *
211
+ * Filters empty roles/arrays by default.
212
+ */
213
+ function firestoreModelKeyGrantedRoleArrayMap() {
214
+ return firestoreArrayMap({
215
+ mapFieldValues: util_1.filterEmptyValues
216
+ });
217
+ }
218
+ exports.firestoreModelKeyGrantedRoleArrayMap = firestoreModelKeyGrantedRoleArrayMap;
219
+ /**
220
+ * FirestoreField configuration for a map of granted roles, keyed by models ids.
221
+ *
222
+ * Filters empty roles/arrays by default.
223
+ */
224
+ exports.firestoreModelIdGrantedRoleArrayMap = firestoreModelKeyGrantedRoleArrayMap;
143
225
  /**
144
226
  * Do not use.
145
227
  *
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAAA,wCAA4E;AAC5E,wCAAyY;AACzY,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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C;AACL,CAAC;AAND,gEAMC;AASD;;;;;GAKG;AACH,SAAgB,qBAAqB,CAA+B,MAA8C;;IAChH,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;IAC5C,OAAO,cAAc,CAAW;QAC9B,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE;QAC7B,QAAQ,EAAE,CAAC,KAAU,EAAE,EAAE,CAAE,KAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC/D,MAAM,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,IAAA,wBAAiB,EAAE,KAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAC/E,CAAC,CAAC;AACL,CAAC;AAPD,sDAOC;AAKD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAA4B,MAAkC;;IACxF,OAAO,cAAc,CAAc;QACjC,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAND,oCAMC"}
1
+ {"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAEA,wCAA4E;AAC5E,wCAAmf;AACnf,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,E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uB;QAC7C,cAAc,EAAE,wBAAiB;KAClC,CAAC,CAAC;AACL,CAAC;AAJD,oFAIC;AAED;;;;GAIG;AACU,QAAA,mCAAmC,GAAsI,oCAAoC,CAAC;AAK3N;;;;;;;GAOG;AACH,SAAgB,YAAY,CAA4B,MAAkC;;IACxF,OAAO,cAAc,CAAc;QACjC,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAND,oCAMC"}
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.ts"],"names":[],"mappings":";;;AAAA,wCAAgV;AAChV,oCAAyN;AAEzN,aAAa;AACb;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAqE1C,SAAgB,0BAA0B,CAA6D,MAAqC;;IAC1I,MAAM,WAAW,GAAgC,MAAC,MAAuD,CAAC,gBAAgB,mCAAI,IAAA,4BAAqB,EAAQ,MAAkD,CAAC,MAAM,CAAC,CAAC;IACtN,MAAM,YAAY,GAAG,IAAA,4BAAqB,EAAO,WAAW,CAAC,CAAC;IAC9D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,8BAAuB,EAAC,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAEhJ,MAAM,IAAI,GAAwC,CAAC,KAAuB,EAAE,MAA0B,EAAE,EAAE;QACxG,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC,IAAS,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,EAAE,GAAsC,CAAC,KAAQ,EAAE,MAA0B,EAAE,OAA2B,EAAE,EAAE;QAClH,IAAI,SAA2C,CAAC;QAEhD,IAAI,OAAO,EAAE;YACX,MAAM,WAAW,GAAI,OAAiC,CAAC,WAAW,CAAC;YAEnE,IAAK,OAA2B,CAAC,KAAK,EAAE;gBACtC,SAAS,GAAG;oBACV,WAAW,EAAE,IAAI;iBAClB,CAAC;aACH;YAED,IAAI,WAAW,EAAE;gBACf,SAAS,mCACJ,SAAS,KACZ,MAAM,EAAE,IAAA,4BAAoB,EAAC,WAAW,CAAgB,GACzD,CAAC;aACH;SACF;QAED,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,EAAE;QACF,aAAa,EAAE,CAAC,QAA6B,EAAE,OAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;QAC/G,WAAW,EAAE,CAAC,WAAyD,EAAE,OAAoB,EAAE,EAAE,CAAC,EAAE,CAAC,WAAgB,EAAE,SAAS,EAAE,OAAO,CAAC;KAC3I,CAAC;AACJ,CAAC;AAvCD,gEAuCC"}
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.ts"],"names":[],"mappings":";;;AAAA,wCAA0R;AAC1R,oCAAsM;AAEtM,aAAa;AACb;;GAEG;AACU,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAqE1C,SAAgB,0BAA0B,CAA6D,MAAqC;;IAC1I,MAAM,WAAW,GAAgC,MAAC,MAAuD,CAAC,gBAAgB,mCAAI,IAAA,4BAAqB,EAAQ,MAAkD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OAAO,CAAC;KAC3I,CAAC;AACJ,CAAC;AAvCD,gEAuCC"}
@@ -4,12 +4,6 @@ import { FirebasePermissionContext, FirebasePermissionErrorContext } from './per
4
4
  * A base model context that contains info about what is current occuring.
5
5
  */
6
6
  export interface FirebaseModelContext extends FirebasePermissionContext, FirebasePermissionErrorContext, FirebaseAuthContext {
7
- /**
8
- * Whether or not to return all role checks for models as true if the auth context shows the current user as an admin.
9
- *
10
- * Is false by default.
11
- */
12
- readonly adminGetsAllowAllRoles?: boolean;
13
7
  }
14
8
  export interface FirebaseAppModelContext<C> extends FirebaseModelContext {
15
9
  readonly app: C;
@@ -1,6 +1,6 @@
1
1
  import { FirestoreDocument } from './../../firestore';
2
2
  import { AbstractModelPermissionService, GrantedRoleMap, InContextModelPermissionService, InModelContextModelPermissionService, ModelPermissionService } from '@dereekb/model';
3
- import { Maybe, PromiseOrValue } from '@dereekb/util';
3
+ import { DecisionFunction, Getter, GetterOrValue, 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';
@@ -16,9 +16,52 @@ export declare class FirebaseModelPermissionServiceInstance<C extends FirebaseMo
16
16
  constructor(delegate: FirebasePermissionServiceInstanceDelegate<C, T, D, R>);
17
17
  roleMapForModel(output: FirebasePermissionServiceModel<T, D>, context: C, model: D): PromiseOrValue<GrantedRoleMap<R>>;
18
18
  protected outputForModel(document: D): Promise<Maybe<FirebasePermissionServiceModel<T, D>>>;
19
- protected getRoleMapForOutput(output: FirebasePermissionServiceModel<T, D>, context: C, model: D): Promise<import("@dereekb/model").ContextGrantedModelRoles<FirebasePermissionServiceModel<T, D>, C, R>>;
20
19
  protected isUsableOutputForRoles(output: FirebasePermissionServiceModel<T, D>): boolean;
21
20
  }
22
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>;
23
22
  export declare type InContextFirebaseModelPermissionService<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string> = InContextModelPermissionService<C, D, R, FirebasePermissionServiceModel<T, D>>;
24
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>;