@dereekb/firebase 9.5.2 → 9.5.3

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,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [9.5.3](https://github.com/dereekb/dbx-components/compare/v9.5.2-dev...v9.5.3) (2022-08-29)
6
+
7
+
8
+
5
9
  ## [9.5.2](https://github.com/dereekb/dbx-components/compare/v9.5.1-dev...v9.5.2) (2022-08-29)
6
10
 
7
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "9.5.2",
3
+ "version": "9.5.3",
4
4
  "devDependencies": {
5
5
  "@firebase/rules-unit-testing": "^2.0.0"
6
6
  },
@@ -22,17 +22,17 @@
22
22
  "peerDependencies": {
23
23
  "rxjs": "^7.5.0",
24
24
  "firebase": "^9.9.2",
25
- "@dereekb/util": "9.5.2",
25
+ "@dereekb/util": "9.5.3",
26
26
  "lodash.isequal": "^4.5.0",
27
27
  "make-error": "^1.3.0",
28
28
  "ts-essentials": "^9.1.2",
29
29
  "extra-set": "^2.2.11",
30
- "@dereekb/rxjs": "9.5.2",
30
+ "@dereekb/rxjs": "9.5.3",
31
31
  "ms": "^3.0.0-canary.1",
32
- "@dereekb/model": "9.5.2",
32
+ "@dereekb/model": "9.5.3",
33
33
  "class-transformer": "^0.5.1",
34
34
  "class-validator": "^0.13.2",
35
- "@dereekb/date": "9.5.2",
35
+ "@dereekb/date": "9.5.3",
36
36
  "date-fns": "^2.29.0",
37
37
  "date-fns-tz": "^1.3.0",
38
38
  "rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",
@@ -1,6 +1,6 @@
1
1
  import { FirestoreDocument } from './../../firestore/accessor/document';
2
2
  import { GrantedRoleMap } from '@dereekb/model';
3
- import { AsyncDecisionFunction, Getter, GetterOrValue, Maybe, PromiseOrValue } from '@dereekb/util';
3
+ import { AsyncDecisionFunction, AuthRole, Getter, GetterOrValue, Maybe, PromiseOrValue, IterableOrValue } from '@dereekb/util';
4
4
  import { FirebaseModelContext } from '../context';
5
5
  import { UserRelated } from '../../../model/user';
6
6
  /**
@@ -24,6 +24,17 @@ export declare function grantModelRolesIfAdminFunction<R extends string = string
24
24
  */
25
25
  export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction<FirebaseModelContext>;
26
26
  export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): PromiseOrValue<GrantedRoleMap<R>>;
27
+ /**
28
+ * Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
29
+ *
30
+ * @param context
31
+ * @param rolesToGrantToAdmin
32
+ * @param otherwise
33
+ * @returns
34
+ */
35
+ export declare function grantModelRolesIfHasAuthRolesFunction<R extends string = string>(authRoles: AuthRole[], rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<FirebaseModelContext, R>;
36
+ export declare type GrantModelRolesIfHasAuthRolesFactory = <R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>) => PromiseOrValue<GrantedRoleMap<R>>;
37
+ export declare function grantModelRolesIfHasAuthRolesFactory(authRoles: IterableOrValue<AuthRole>): GrantModelRolesIfHasAuthRolesFactory;
27
38
  export declare type UserRelatedModelFirebaseModelContext<T extends UserRelated = UserRelated> = UserRelatedModelFirebaseModelContextModelInput<T> | UserRelatedModelFirebaseModelContextDocumentInput<T>;
28
39
  export declare type UserRelatedModelFirebaseModelContextModelInput<T extends UserRelated = UserRelated> = {
29
40
  model: T;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.grantModelRolesIfFunction = exports.grantModelRolesOnlyIfFunction = exports.grantFullAccessIfAuthUserRelated = exports.grantModelRolesIfAuthUserRelatedModelFunction = exports.isOwnerOfUserRelatedModelInFirebaseModelContext = exports.grantModelRolesIfAdmin = exports.grantFullAccessIfAdmin = exports.grantModelRolesIfAdminFunction = exports.isAdminInFirebaseModelContext = void 0;
3
+ exports.grantModelRolesIfFunction = exports.grantModelRolesOnlyIfFunction = exports.grantFullAccessIfAuthUserRelated = exports.grantModelRolesIfAuthUserRelatedModelFunction = exports.isOwnerOfUserRelatedModelInFirebaseModelContext = exports.grantModelRolesIfHasAuthRolesFactory = exports.grantModelRolesIfHasAuthRolesFunction = exports.grantModelRolesIfAdmin = exports.grantFullAccessIfAdmin = exports.grantModelRolesIfAdminFunction = exports.isAdminInFirebaseModelContext = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const model_1 = require("@dereekb/model");
6
6
  const util_1 = require("@dereekb/util");
@@ -33,6 +33,35 @@ function grantModelRolesIfAdmin(context, rolesToGrantToAdmin, otherwise) {
33
33
  return grantModelRolesIfAdminFunction(rolesToGrantToAdmin)(context, otherwise);
34
34
  }
35
35
  exports.grantModelRolesIfAdmin = grantModelRolesIfAdmin;
36
+ // MARK: Auth Roles
37
+ /**
38
+ * Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
39
+ *
40
+ * @param context
41
+ * @param rolesToGrantToAdmin
42
+ * @param otherwise
43
+ * @returns
44
+ */
45
+ function grantModelRolesIfHasAuthRolesFunction(authRoles, rolesToGrantToAdmin) {
46
+ return grantModelRolesIfFunction((context) => {
47
+ var _a;
48
+ const currentAuthRoles = (_a = context.auth) === null || _a === void 0 ? void 0 : _a.getAuthRoles();
49
+ if (currentAuthRoles) {
50
+ return (0, util_1.setContainsAllValues)(currentAuthRoles, authRoles);
51
+ }
52
+ else {
53
+ return authRoles.length === 0;
54
+ }
55
+ }, rolesToGrantToAdmin);
56
+ }
57
+ exports.grantModelRolesIfHasAuthRolesFunction = grantModelRolesIfHasAuthRolesFunction;
58
+ function grantModelRolesIfHasAuthRolesFactory(authRoles) {
59
+ const authRolesToHave = (0, util_1.iterableToArray)(authRoles);
60
+ return (context, rolesToGrantToMatch, otherwise) => {
61
+ return grantModelRolesIfHasAuthRolesFunction(authRolesToHave, rolesToGrantToMatch)(context, otherwise);
62
+ };
63
+ }
64
+ exports.grantModelRolesIfHasAuthRolesFactory = grantModelRolesIfHasAuthRolesFactory;
36
65
  /**
37
66
  * DecisionFunction for a FirebaseModelContext that checks if the user is related to the model by uid.
38
67
  *
@@ -1 +1 @@
1
- {"version":3,"file":"permission.service.grant.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.grant.ts"],"names":[],"mappings":";;;;AACA,0CAAoF;AACpF,wCAAwH;AAIxH,cAAc;AACd;;;;;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;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAA4B,mBAAqD;IAC7H,OAAO,yBAAyB,CAAC,qCAA6B,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAFD,wEAEC;AAED;;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;;;;;GAKG;AACI,MAAM,+CAA+C,GAA6E,CAAO,OAA6C,EAAE,EAAE;IAC/L,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MA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C,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAsB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAkB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC,MAAM,SAAS,EAAE,CAAC,mCAAI,IAAA,uBAAe,GAAE,CAAC;QAChI,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAVD,8DAUC"}
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,wCAA0O;AAI1O,cAAc;AACd;;;;;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;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAA4B,mBAAqD;IAC7H,OAAO,yBAAyB,CAAC,qCAA6B,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;AAFD,wEAEC;AAED;;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,mBAAmB;AACnB;;;;;;;GAOG;AACH,SAAgB,qCAAqC,CAA4B,SAAqB,EAAE,mBAAqD;IAC3J,OAAO,yBAAyB,CAAC,CAAC,OAA6B,EAAE,EAAE;;QACjE,MAAM,gBAAgB,GAAG,MAAA,OAAO,CAAC,IAAI,0CAAE,YAAY,EAAE,CAAC;QAEtD,IAAI,gBAAgB,E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+C,EAAE,YAAY,CAAC,CAAC;AAClG,CAAC;AAFD,sGAEC;AAED;;GAEG;AACU,QAAA,gCAAgC,GAAmF,6CAA6C,CAAC,yBAAiB,CAAC,CAAC;AASjM;;;;;;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,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IAED,OAAO,CAAO,OAAU,EAAE,YAA4C,uBAAe,EAAE,EAAE;;QACvF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAsB,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAkB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC,MAAM,SAAS,EAAE,CAAC,mCAAI,IAAA,uBAAe,GAAE,CAAC;QAChI,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAVD,8DAUC"}
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [9.5.3](https://github.com/dereekb/dbx-components/compare/v9.5.2-dev...v9.5.3) (2022-08-29)
6
+
7
+
8
+
5
9
  ## [9.5.2](https://github.com/dereekb/dbx-components/compare/v9.5.1-dev...v9.5.2) (2022-08-29)
6
10
 
7
11
 
package/test/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "9.5.2",
3
+ "version": "9.5.3",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
7
7
  "dependencies": {},
8
8
  "peerDependencies": {
9
- "@dereekb/util/test": "9.5.2",
10
- "@dereekb/util": "9.5.2",
9
+ "@dereekb/util/test": "9.5.3",
10
+ "@dereekb/util": "9.5.3",
11
11
  "lodash.isequal": "^4.5.0",
12
12
  "make-error": "^1.3.0",
13
13
  "ts-essentials": "^9.1.2",
14
14
  "extra-set": "^2.2.11",
15
- "@dereekb/firebase": "9.5.2",
15
+ "@dereekb/firebase": "9.5.3",
16
16
  "rxjs": "^7.5.0",
17
17
  "firebase": "^9.9.2",
18
- "@dereekb/rxjs": "9.5.2",
18
+ "@dereekb/rxjs": "9.5.3",
19
19
  "ms": "^3.0.0-canary.1",
20
- "@dereekb/model": "9.5.2",
20
+ "@dereekb/model": "9.5.3",
21
21
  "class-transformer": "^0.5.1",
22
22
  "class-validator": "^0.13.2",
23
- "@dereekb/date": "9.5.2",
23
+ "@dereekb/date": "9.5.3",
24
24
  "date-fns": "^2.29.0",
25
25
  "date-fns-tz": "^1.3.0",
26
26
  "rrule": "git+https://git@github.com/dereekb/rrule#2b13b1ea881059ba2ecfec380e12ef244ef54570",