@dereekb/firebase 7.4.0 → 7.5.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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * updated GrantRolesOtherwiseFunction to allow returning Maybe ([552bb9c](https://github.com/dereekb/dbx-components/commit/552bb9c488c0f11aa1aca885d00c5a7c2a199591))
11
+
12
+
13
+ ### Features
14
+
15
+ * added UseFunction, MappedUseFunction ([84b6cbe](https://github.com/dereekb/dbx-components/commit/84b6cbe23b7e020ad7de49633642429d7e32f7d4))
16
+
17
+
18
+
5
19
  # [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
6
20
 
7
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "7.4.0",
3
+ "version": "7.5.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.4.0",
25
+ "@dereekb/util": "7.5.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.4.0",
29
+ "@dereekb/rxjs": "7.5.0",
30
30
  "ms": "^3.0.0-canary.1",
31
- "@dereekb/model": "7.4.0",
31
+ "@dereekb/model": "7.5.0",
32
32
  "class-transformer": "^0.5.1",
33
33
  "class-validator": "^0.13.2",
34
- "@dereekb/date": "7.4.0",
34
+ "@dereekb/date": "7.5.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,4 +1,4 @@
1
- import { AuthClaims, AuthClaimsObject, AuthRoleSet, Maybe } from '@dereekb/util';
1
+ import { AuthClaims, AuthClaimsObject, AuthRoleSet, MappedUseFunction, Maybe, UseValue } from '@dereekb/util';
2
2
  import { FirebaseAuthToken } from './auth';
3
3
  /**
4
4
  * Provides a context containing FirebaseAuthContextInfo
@@ -43,3 +43,5 @@ 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>;
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useContextAuth = void 0;
4
+ const util_1 = require("@dereekb/util");
5
+ exports.useContextAuth = (0, util_1.mappedUseFunction)((x) => x.auth);
3
6
  //# 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"}
@@ -22,7 +22,7 @@ export declare function firebaseModelPermissionService<C extends FirebaseModelCo
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
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>;
25
+ export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): GrantedRoleMap<R>;
26
26
  /**
27
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
28
  *
@@ -55,8 +55,14 @@ export declare function grantModelRolesOnlyIfFunction<C extends FirebaseModelCon
55
55
  /**
56
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
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>;
58
+ export declare type GrantRolesIfFunction<R extends string = string, C extends FirebaseModelContext = FirebaseModelContext> = (context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => GrantedRoleMap<R>;
59
+ export declare type GeneralGrantRolesIfFunction = <R extends string = string, C extends FirebaseModelContext = FirebaseModelContext>(context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => GrantedRoleMap<R>;
60
+ /**
61
+ * Used as the "else" statement for grantModelRolesIfFunction.
62
+ *
63
+ * If no roles are returned, the grantModelRolesIfFunction() will return a NoAccessRoleMap.
64
+ */
65
+ export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<GrantedRoleMap<R>>>;
60
66
  /**
61
67
  * Creates a GrantRolesIfFunction.
62
68
  *
@@ -79,8 +79,9 @@ exports.grantModelRolesOnlyIfFunction = grantModelRolesOnlyIfFunction;
79
79
  */
80
80
  function grantModelRolesIfFunction(grantIf, grantedRoles) {
81
81
  return (context, otherwise = model_1.noAccessRoleMap) => {
82
+ var _a;
82
83
  const decision = grantIf(context);
83
- const results = decision ? (0, util_1.getValueFromGetter)(grantedRoles) : otherwise();
84
+ const results = decision ? (0, util_1.getValueFromGetter)(grantedRoles) : (_a = otherwise()) !== null && _a !== void 0 ? _a : (0, model_1.noAccessRoleMap)();
84
85
  return results;
85
86
  };
86
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAAmN;AACnN,wCAAmH;AAWnH;;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,M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MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAA,yBAAkB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;QAC1E,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAND,8DAMC"}
1
+ {"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAAmN;AACnN,wCAAmH;AAWnH;;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;AAQD,gBAAgB;AACH,QAAA,sBAAsB,GA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generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
6
+
7
+
8
+
5
9
  # [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
6
10
 
7
11
 
package/test/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "7.4.0",
3
+ "version": "7.5.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.4.0",
9
- "@dereekb/util": "7.4.0",
8
+ "@dereekb/util/test": "7.5.0",
9
+ "@dereekb/util": "7.5.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.4.0",
13
+ "@dereekb/firebase": "7.5.0",
14
14
  "rxjs": "^7.0.0",
15
15
  "rxfire": "^6.0.3",
16
16
  "firebase": "^9.8.0",
17
- "@dereekb/rxjs": "7.4.0",
17
+ "@dereekb/rxjs": "7.5.0",
18
18
  "ms": "^3.0.0-canary.1",
19
- "@dereekb/model": "7.4.0",
19
+ "@dereekb/model": "7.5.0",
20
20
  "class-transformer": "^0.5.1",
21
21
  "class-validator": "^0.13.2",
22
- "@dereekb/date": "7.4.0",
22
+ "@dereekb/date": "7.5.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",