@carlonicora/nestjs-neo4jsonapi 1.63.0 → 1.64.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 (56) hide show
  1. package/dist/bootstrap/bootstrap.options.d.ts +7 -0
  2. package/dist/bootstrap/bootstrap.options.d.ts.map +1 -1
  3. package/dist/foundations/rbac/controllers/rbac-dev.controller.d.ts +50 -0
  4. package/dist/foundations/rbac/controllers/rbac-dev.controller.d.ts.map +1 -0
  5. package/dist/foundations/rbac/controllers/rbac-dev.controller.js +172 -0
  6. package/dist/foundations/rbac/controllers/rbac-dev.controller.js.map +1 -0
  7. package/dist/foundations/rbac/dsl/define-rbac.d.ts +15 -0
  8. package/dist/foundations/rbac/dsl/define-rbac.d.ts.map +1 -0
  9. package/dist/foundations/rbac/dsl/define-rbac.js +19 -0
  10. package/dist/foundations/rbac/dsl/define-rbac.js.map +1 -0
  11. package/dist/foundations/rbac/dsl/index.d.ts +6 -0
  12. package/dist/foundations/rbac/dsl/index.d.ts.map +1 -0
  13. package/dist/foundations/rbac/dsl/index.js +30 -0
  14. package/dist/foundations/rbac/dsl/index.js.map +1 -0
  15. package/dist/foundations/rbac/dsl/perm.d.ts +15 -0
  16. package/dist/foundations/rbac/dsl/perm.d.ts.map +1 -0
  17. package/dist/foundations/rbac/dsl/perm.js +24 -0
  18. package/dist/foundations/rbac/dsl/perm.js.map +1 -0
  19. package/dist/foundations/rbac/dsl/resolver.d.ts +24 -0
  20. package/dist/foundations/rbac/dsl/resolver.d.ts.map +1 -0
  21. package/dist/foundations/rbac/dsl/resolver.js +55 -0
  22. package/dist/foundations/rbac/dsl/resolver.js.map +1 -0
  23. package/dist/foundations/rbac/dsl/to-permissions-json.d.ts +13 -0
  24. package/dist/foundations/rbac/dsl/to-permissions-json.d.ts.map +1 -0
  25. package/dist/foundations/rbac/dsl/to-permissions-json.js +43 -0
  26. package/dist/foundations/rbac/dsl/to-permissions-json.js.map +1 -0
  27. package/dist/foundations/rbac/dsl/types.d.ts +55 -0
  28. package/dist/foundations/rbac/dsl/types.d.ts.map +1 -0
  29. package/dist/foundations/rbac/dsl/types.js +6 -0
  30. package/dist/foundations/rbac/dsl/types.js.map +1 -0
  31. package/dist/foundations/rbac/dump.d.ts +116 -0
  32. package/dist/foundations/rbac/dump.d.ts.map +1 -0
  33. package/dist/foundations/rbac/dump.js +154 -0
  34. package/dist/foundations/rbac/dump.js.map +1 -0
  35. package/dist/foundations/rbac/index.d.ts +6 -0
  36. package/dist/foundations/rbac/index.d.ts.map +1 -1
  37. package/dist/foundations/rbac/index.js +23 -1
  38. package/dist/foundations/rbac/index.js.map +1 -1
  39. package/dist/foundations/rbac/rbac.module.d.ts +4 -1
  40. package/dist/foundations/rbac/rbac.module.d.ts.map +1 -1
  41. package/dist/foundations/rbac/rbac.module.js +25 -11
  42. package/dist/foundations/rbac/rbac.module.js.map +1 -1
  43. package/dist/foundations/rbac/rbac.tokens.d.ts +11 -0
  44. package/dist/foundations/rbac/rbac.tokens.d.ts.map +1 -0
  45. package/dist/foundations/rbac/rbac.tokens.js +14 -0
  46. package/dist/foundations/rbac/rbac.tokens.js.map +1 -0
  47. package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts +13 -0
  48. package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts.map +1 -0
  49. package/dist/foundations/rbac/serializer/matrix-to-ts.js +74 -0
  50. package/dist/foundations/rbac/serializer/matrix-to-ts.js.map +1 -0
  51. package/dist/foundations/rbac/services/rbac-reconciler.service.d.ts +30 -0
  52. package/dist/foundations/rbac/services/rbac-reconciler.service.d.ts.map +1 -0
  53. package/dist/foundations/rbac/services/rbac-reconciler.service.js +192 -0
  54. package/dist/foundations/rbac/services/rbac-reconciler.service.js.map +1 -0
  55. package/dist/tools/generate-rbac-paths/index.js +24 -19
  56. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { DynamicModule, Type } from "@nestjs/common";
2
2
  import { EntityDescriptor, RelationshipDef } from "../common/interfaces/entity.schema.interface";
3
3
  import { ContentExtensionConfig } from "../foundations/content/interfaces/content.extension.interface";
4
+ import type { RbacMatrix } from "../foundations/rbac/dsl/types";
4
5
  import { ReferralModuleConfig } from "../foundations/referral/interfaces/referral.config.interface";
5
6
  /**
6
7
  * i18n configuration options
@@ -85,6 +86,12 @@ export interface BootstrapOptions {
85
86
  * ```
86
87
  */
87
88
  openApi?: OpenApiOptions;
89
+ /**
90
+ * Declarative RBAC matrix.
91
+ * When provided, the RbacReconciler reconciles Neo4j to match this matrix
92
+ * on application bootstrap. See docs for `defineRbac()`.
93
+ */
94
+ rbac?: RbacMatrix;
88
95
  }
89
96
  /**
90
97
  * OpenAPI documentation options
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.options.d.ts","sourceRoot":"","sources":["../../src/bootstrap/bootstrap.options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,+DAA+D,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AAEpG;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC;IAE1C;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEnC;;;;;;;;;;;;;OAaG;IACH,gBAAgB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AC,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC;CAC9E"}
@@ -0,0 +1,50 @@
1
+ import type { RbacMatrix } from "../dsl/types";
2
+ interface RbacMatrixPutBody {
3
+ data: {
4
+ type: string;
5
+ id?: string;
6
+ attributes: {
7
+ matrix: RbacMatrix;
8
+ roleNames: Record<string, string>;
9
+ moduleNames: Record<string, string>;
10
+ outputPath: string;
11
+ };
12
+ };
13
+ }
14
+ /**
15
+ * Dev-only endpoints for editing the rbac matrix.
16
+ *
17
+ * Registered ONLY when `devMode` is enabled on RbacModule.register (see
18
+ * `apps/api/src/features/features.modules.ts`).
19
+ *
20
+ * Both endpoints speak JSON:API (single-resource envelopes) so the frontend
21
+ * can consume them via the standard `callApi()` pipeline instead of a
22
+ * bespoke raw-fetch escape hatch.
23
+ */
24
+ export declare class RbacDevController {
25
+ private readonly matrix;
26
+ private readonly moduleUserPaths;
27
+ constructor(matrix: RbacMatrix | null, moduleUserPaths: Record<string, readonly string[]> | null);
28
+ getMatrix(): {
29
+ data: {
30
+ type: string;
31
+ id: string;
32
+ attributes: {
33
+ matrix: RbacMatrix<Record<string, readonly string[]>>;
34
+ modulePaths: Record<string, readonly string[]>;
35
+ };
36
+ };
37
+ };
38
+ putMatrix(body: RbacMatrixPutBody): Promise<{
39
+ data: {
40
+ type: string;
41
+ id: string;
42
+ attributes: {
43
+ bytesWritten: number;
44
+ path: string;
45
+ };
46
+ };
47
+ }>;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=rbac-dev.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rbac-dev.controller.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/controllers/rbac-dev.controller.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,cAAc,CAAC;AA8C1D,UAAU,iBAAiB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE;YACV,MAAM,EAAE,UAAU,CAAC;YACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAClC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACpC,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;KACH,CAAC;CACH;AAED;;;;;;;;;GASG;AACH,qBACa,iBAAiB;IAEa,OAAO,CAAC,QAAQ,CAAC,MAAM;IAG9D,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAHwB,MAAM,EAAE,UAAU,GAAG,IAAI,EAGhE,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GAAG,IAAI;IAI5E,SAAS;;;;;;;;;;IAcH,SAAS,CAAS,IAAI,EAAE,iBAAiB;;;;;;;;;;CA8BhD"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.RbacDevController = void 0;
49
+ const common_1 = require("@nestjs/common");
50
+ const fs = __importStar(require("fs"));
51
+ const path = __importStar(require("path"));
52
+ const rbac_tokens_1 = require("../rbac.tokens");
53
+ const rbac_constants_1 = require("../rbac.constants");
54
+ const matrix_to_ts_1 = require("../serializer/matrix-to-ts");
55
+ /**
56
+ * Walk up from `startDir` looking for `pnpm-workspace.yaml`. Returns that
57
+ * directory, or `startDir` as a fallback. Used to resolve relative
58
+ * `outputPath` arguments from the frontend consistently regardless of where
59
+ * the API process was started from (its `cwd` is `apps/api` in dev).
60
+ */
61
+ function findMonorepoRoot(startDir) {
62
+ let current = startDir;
63
+ while (true) {
64
+ if (fs.existsSync(path.join(current, "pnpm-workspace.yaml"))) {
65
+ return current;
66
+ }
67
+ const parent = path.dirname(current);
68
+ if (parent === current)
69
+ return startDir;
70
+ current = parent;
71
+ }
72
+ }
73
+ /**
74
+ * perm.* tokens are callable hybrids (function + attached `action`/`scope` own
75
+ * properties). JSON.stringify drops functions, producing `null` inside arrays.
76
+ * Normalise to plain `{ action, scope }` objects before envelope wrapping.
77
+ */
78
+ function normaliseMatrix(matrix) {
79
+ const out = {};
80
+ for (const [moduleId, block] of Object.entries(matrix)) {
81
+ if (!block)
82
+ continue;
83
+ const newBlock = { default: [] };
84
+ for (const [key, tokens] of Object.entries(block)) {
85
+ newBlock[key] = tokens.map((t) => ({ action: t.action, scope: t.scope }));
86
+ }
87
+ out[moduleId] = newBlock;
88
+ }
89
+ return out;
90
+ }
91
+ /**
92
+ * JSON:API type emitted / expected by the dev RBAC matrix endpoints.
93
+ * Kebab-case to match the rest of the codebase (e.g. "permission-mappings").
94
+ */
95
+ const RBAC_MATRIX_TYPE = "rbac-matrix";
96
+ const RBAC_MATRIX_ID = "singleton";
97
+ /**
98
+ * Dev-only endpoints for editing the rbac matrix.
99
+ *
100
+ * Registered ONLY when `devMode` is enabled on RbacModule.register (see
101
+ * `apps/api/src/features/features.modules.ts`).
102
+ *
103
+ * Both endpoints speak JSON:API (single-resource envelopes) so the frontend
104
+ * can consume them via the standard `callApi()` pipeline instead of a
105
+ * bespoke raw-fetch escape hatch.
106
+ */
107
+ let RbacDevController = class RbacDevController {
108
+ constructor(matrix, moduleUserPaths) {
109
+ this.matrix = matrix;
110
+ this.moduleUserPaths = moduleUserPaths;
111
+ }
112
+ getMatrix() {
113
+ return {
114
+ data: {
115
+ type: RBAC_MATRIX_TYPE,
116
+ id: RBAC_MATRIX_ID,
117
+ attributes: {
118
+ matrix: this.matrix ? normaliseMatrix(this.matrix) : {},
119
+ modulePaths: this.moduleUserPaths ?? {},
120
+ },
121
+ },
122
+ };
123
+ }
124
+ async putMatrix(body) {
125
+ const attributes = body?.data?.attributes;
126
+ if (!attributes) {
127
+ throw new Error("Invalid JSON:API body: missing data.attributes");
128
+ }
129
+ const { matrix, roleNames, moduleNames, outputPath } = attributes;
130
+ const source = await (0, matrix_to_ts_1.serializeMatrixToTs)(matrix, {
131
+ roleNames,
132
+ moduleNames,
133
+ });
134
+ const outPath = path.isAbsolute(outputPath)
135
+ ? outputPath
136
+ : path.resolve(findMonorepoRoot(process.cwd()), outputPath);
137
+ fs.writeFileSync(outPath, source);
138
+ return {
139
+ data: {
140
+ type: RBAC_MATRIX_TYPE,
141
+ id: RBAC_MATRIX_ID,
142
+ attributes: {
143
+ bytesWritten: Buffer.byteLength(source),
144
+ path: outPath,
145
+ },
146
+ },
147
+ };
148
+ }
149
+ };
150
+ exports.RbacDevController = RbacDevController;
151
+ __decorate([
152
+ (0, common_1.Get)("matrix"),
153
+ __metadata("design:type", Function),
154
+ __metadata("design:paramtypes", []),
155
+ __metadata("design:returntype", void 0)
156
+ ], RbacDevController.prototype, "getMatrix", null);
157
+ __decorate([
158
+ (0, common_1.Put)("matrix"),
159
+ __param(0, (0, common_1.Body)()),
160
+ __metadata("design:type", Function),
161
+ __metadata("design:paramtypes", [Object]),
162
+ __metadata("design:returntype", Promise)
163
+ ], RbacDevController.prototype, "putMatrix", null);
164
+ exports.RbacDevController = RbacDevController = __decorate([
165
+ (0, common_1.Controller)("_dev/rbac"),
166
+ __param(0, (0, common_1.Optional)()),
167
+ __param(0, (0, common_1.Inject)(rbac_tokens_1.RBAC_MATRIX_TOKEN)),
168
+ __param(1, (0, common_1.Optional)()),
169
+ __param(1, (0, common_1.Inject)(rbac_constants_1.MODULE_USER_PATHS_TOKEN)),
170
+ __metadata("design:paramtypes", [Object, Object])
171
+ ], RbacDevController);
172
+ //# sourceMappingURL=rbac-dev.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rbac-dev.controller.js","sourceRoot":"","s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EAAE,UAAU,CAAC,CAAC;QAE9D,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAElC,OAAO;YACL,IAAI,EAAE;gBACJ,IAAI,EAAE,gBAAgB;gBACtB,EAAE,EAAE,cAAc;gBAClB,UAAU,EAAE;oBACV,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;oBACvC,IAAI,EAAE,OAAO;iBACd;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AArDY,8CAAiB;AAS5B;IADC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;kDAYb;AAGK;IADL,IAAA,YAAG,EAAC,QAAQ,CAAC;IACG,WAAA,IAAA,aAAI,GAAE,CAAA;;;;kDA6BtB;4BApDU,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,WAAW,CAAC;IAGnB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,+BAAiB,CAAC,CAAA;IACrC,WAAA,IAAA,iBAAQ,GAAE,CAAA;IACV,WAAA,IAAA,eAAM,EAAC,wCAAuB,CAAC,CAAA;;GAJvB,iBAAiB,CAqD7B"}
@@ -0,0 +1,15 @@
1
+ import type { RbacMatrix } from "./types";
2
+ /**
3
+ * Identity function used to attach typing to an rbac matrix literal.
4
+ *
5
+ * The generic parameter binds the matrix to a concrete `MODULE_USER_PATHS`
6
+ * shape so that scoped-path arguments in `perm.update("...")` etc. are
7
+ * type-checked against the module they are declared under.
8
+ *
9
+ * Usage:
10
+ * export const rbac = defineRbac<typeof MODULE_USER_PATHS>({
11
+ * [ModuleId.Part]: { default: [perm.read], ... },
12
+ * });
13
+ */
14
+ export declare function defineRbac<ModuleUserPaths extends Record<string, readonly string[]>>(matrix: RbacMatrix<ModuleUserPaths>): RbacMatrix<ModuleUserPaths>;
15
+ //# sourceMappingURL=define-rbac.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-rbac.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/define-rbac.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAClF,MAAM,EAAE,UAAU,CAAC,eAAe,CAAC,GAClC,UAAU,CAAC,eAAe,CAAC,CAE7B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineRbac = defineRbac;
4
+ /**
5
+ * Identity function used to attach typing to an rbac matrix literal.
6
+ *
7
+ * The generic parameter binds the matrix to a concrete `MODULE_USER_PATHS`
8
+ * shape so that scoped-path arguments in `perm.update("...")` etc. are
9
+ * type-checked against the module they are declared under.
10
+ *
11
+ * Usage:
12
+ * export const rbac = defineRbac<typeof MODULE_USER_PATHS>({
13
+ * [ModuleId.Part]: { default: [perm.read], ... },
14
+ * });
15
+ */
16
+ function defineRbac(matrix) {
17
+ return matrix;
18
+ }
19
+ //# sourceMappingURL=define-rbac.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-rbac.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/define-rbac.ts"],"names":[],"mappings":";;AAeA,gCAIC;AAhBD;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CACxB,MAAmC;IAEnC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./types";
2
+ export { perm } from "./perm";
3
+ export { defineRbac } from "./define-rbac";
4
+ export { toPermissionsJson } from "./to-permissions-json";
5
+ export { resolveForRole, resolveDefault, iterateDeclaredEdges, iterateDeclaredModules } from "./resolver";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.iterateDeclaredModules = exports.iterateDeclaredEdges = exports.resolveDefault = exports.resolveForRole = exports.toPermissionsJson = exports.defineRbac = exports.perm = void 0;
18
+ __exportStar(require("./types"), exports);
19
+ var perm_1 = require("./perm");
20
+ Object.defineProperty(exports, "perm", { enumerable: true, get: function () { return perm_1.perm; } });
21
+ var define_rbac_1 = require("./define-rbac");
22
+ Object.defineProperty(exports, "defineRbac", { enumerable: true, get: function () { return define_rbac_1.defineRbac; } });
23
+ var to_permissions_json_1 = require("./to-permissions-json");
24
+ Object.defineProperty(exports, "toPermissionsJson", { enumerable: true, get: function () { return to_permissions_json_1.toPermissionsJson; } });
25
+ var resolver_1 = require("./resolver");
26
+ Object.defineProperty(exports, "resolveForRole", { enumerable: true, get: function () { return resolver_1.resolveForRole; } });
27
+ Object.defineProperty(exports, "resolveDefault", { enumerable: true, get: function () { return resolver_1.resolveDefault; } });
28
+ Object.defineProperty(exports, "iterateDeclaredEdges", { enumerable: true, get: function () { return resolver_1.iterateDeclaredEdges; } });
29
+ Object.defineProperty(exports, "iterateDeclaredModules", { enumerable: true, get: function () { return resolver_1.iterateDeclaredModules; } });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA;AAC1B,uCAA0G;AAAjG,0GAAA,cAAc,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAAE,kHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,15 @@
1
+ import { Action, PermToken } from "./types";
2
+ type Scoped<A extends Action> = (path: string) => PermToken;
3
+ type PermFn<A extends Action> = {
4
+ action: A;
5
+ scope: true;
6
+ } & Scoped<A>;
7
+ export declare const perm: {
8
+ read: PermFn<"read">;
9
+ create: PermFn<"create">;
10
+ update: PermFn<"update">;
11
+ delete: PermFn<"delete">;
12
+ full: PermToken<never>[];
13
+ };
14
+ export {};
15
+ //# sourceMappingURL=perm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perm.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/perm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,CAAC;AAE5D,KAAK,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAYvE,eAAO,MAAM,IAAI;;;;;UAUV,SAAS,CAAC,KAAK,CAAC,EAAE;CACxB,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.perm = void 0;
4
+ function build(action) {
5
+ const fn = (path) => ({ action, scope: path });
6
+ return Object.assign(fn, { action, scope: true });
7
+ }
8
+ const readT = build("read");
9
+ const createT = build("create");
10
+ const updateT = build("update");
11
+ const deleteT = build("delete");
12
+ exports.perm = {
13
+ read: readT,
14
+ create: createT,
15
+ update: updateT,
16
+ delete: deleteT,
17
+ full: [
18
+ { action: "read", scope: true },
19
+ { action: "create", scope: true },
20
+ { action: "update", scope: true },
21
+ { action: "delete", scope: true },
22
+ ],
23
+ };
24
+ //# sourceMappingURL=perm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perm.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/perm.ts"],"names":[],"mappings":";;;AAOA,SAAS,KAAK,CAAmB,MAAS;IACxC,MAAM,EAAE,GAAG,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAW,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5B,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnB,QAAA,IAAI,GAAG;IAClB,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,OAAO;IACf,IAAI,EAAE;QACJ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE;QAC/B,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;QACjC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;QACjC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;KACZ;CACxB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { RbacMatrix } from "./types";
2
+ /**
3
+ * Compute the canonical edge JSON for a given (role, module) pair.
4
+ * Union of module defaults and role-specific tokens, serialised.
5
+ * Returns undefined if the role or module is not declared.
6
+ */
7
+ export declare function resolveForRole(matrix: RbacMatrix, roleId: string, moduleId: string): string | undefined;
8
+ /**
9
+ * Compute the canonical defaults JSON for a module.
10
+ * Returns undefined if the module is not declared.
11
+ */
12
+ export declare function resolveDefault(matrix: RbacMatrix, moduleId: string): string | undefined;
13
+ /**
14
+ * Yield every (role, module) pair declared in the matrix.
15
+ */
16
+ export declare function iterateDeclaredEdges(matrix: RbacMatrix): Iterable<{
17
+ roleId: string;
18
+ moduleId: string;
19
+ }>;
20
+ /**
21
+ * Yield every module declared in the matrix.
22
+ */
23
+ export declare function iterateDeclaredModules(matrix: RbacMatrix): Iterable<string>;
24
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMvG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIvF;AAED;;GAEG;AACH,wBAAiB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAQxG;AAED;;GAEG;AACH,wBAAiB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAI5E"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveForRole = resolveForRole;
4
+ exports.resolveDefault = resolveDefault;
5
+ exports.iterateDeclaredEdges = iterateDeclaredEdges;
6
+ exports.iterateDeclaredModules = iterateDeclaredModules;
7
+ const to_permissions_json_1 = require("./to-permissions-json");
8
+ /**
9
+ * Compute the canonical edge JSON for a given (role, module) pair.
10
+ * Union of module defaults and role-specific tokens, serialised.
11
+ * Returns undefined if the role or module is not declared.
12
+ */
13
+ function resolveForRole(matrix, roleId, moduleId) {
14
+ const block = matrix[moduleId];
15
+ if (!block)
16
+ return undefined;
17
+ const roleTokens = block[roleId];
18
+ if (roleTokens === undefined)
19
+ return undefined;
20
+ return (0, to_permissions_json_1.toPermissionsJson)([...block.default, ...roleTokens]);
21
+ }
22
+ /**
23
+ * Compute the canonical defaults JSON for a module.
24
+ * Returns undefined if the module is not declared.
25
+ */
26
+ function resolveDefault(matrix, moduleId) {
27
+ const block = matrix[moduleId];
28
+ if (!block)
29
+ return undefined;
30
+ return (0, to_permissions_json_1.toPermissionsJson)(block.default);
31
+ }
32
+ /**
33
+ * Yield every (role, module) pair declared in the matrix.
34
+ */
35
+ function* iterateDeclaredEdges(matrix) {
36
+ for (const [moduleId, block] of Object.entries(matrix)) {
37
+ if (!block)
38
+ continue;
39
+ for (const key of Object.keys(block)) {
40
+ if (key === "default")
41
+ continue;
42
+ yield { roleId: key, moduleId };
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * Yield every module declared in the matrix.
48
+ */
49
+ function* iterateDeclaredModules(matrix) {
50
+ for (const moduleId of Object.keys(matrix)) {
51
+ if (matrix[moduleId])
52
+ yield moduleId;
53
+ }
54
+ }
55
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/resolver.ts"],"names":[],"mappings":";;AAQA,wCAMC;AAMD,wCAIC;AAKD,oDAQC;AAKD,wDAIC;AA7CD,+DAA0D;AAE1D;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAkB,EAAE,MAAc,EAAE,QAAgB;IACjF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/C,OAAO,IAAA,uCAAiB,EAAC,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAAC,MAAkB,EAAE,QAAgB;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,IAAA,uCAAiB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,QAAe,CAAC,CAAC,oBAAoB,CAAC,MAAkB;IACtD,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,GAAG,KAAK,SAAS;gBAAE,SAAS;YAChC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,QAAe,CAAC,CAAC,sBAAsB,CAAC,MAAkB;IACxD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3C,IAAI,MAAM,CAAC,QAAQ,CAAC;YAAE,MAAM,QAAQ,CAAC;IACvC,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { PermToken } from "./types";
2
+ /**
3
+ * Serialise a PermToken[] to the JSON-string shape stored on
4
+ * `Module.permissions` and `HAS_PERMISSIONS.permissions` edges.
5
+ *
6
+ * Format: a JSON-stringified array of `{ type: Action, value: boolean | string }`
7
+ * in fixed action order (read, create, update, delete).
8
+ *
9
+ * Merge rule within the input: unconditional `true` beats scoped path string;
10
+ * scoped path string beats default `false`. (Matches auth.repository merge.)
11
+ */
12
+ export declare function toPermissionsJson(tokens: PermToken[]): string;
13
+ //# sourceMappingURL=to-permissions-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-permissions-json.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/to-permissions-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CA4B7D"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPermissionsJson = toPermissionsJson;
4
+ const types_1 = require("./types");
5
+ /**
6
+ * Serialise a PermToken[] to the JSON-string shape stored on
7
+ * `Module.permissions` and `HAS_PERMISSIONS.permissions` edges.
8
+ *
9
+ * Format: a JSON-stringified array of `{ type: Action, value: boolean | string }`
10
+ * in fixed action order (read, create, update, delete).
11
+ *
12
+ * Merge rule within the input: unconditional `true` beats scoped path string;
13
+ * scoped path string beats default `false`. (Matches auth.repository merge.)
14
+ */
15
+ function toPermissionsJson(tokens) {
16
+ const perAction = {
17
+ read: false,
18
+ create: false,
19
+ update: false,
20
+ delete: false,
21
+ };
22
+ for (const token of tokens) {
23
+ const existing = perAction[token.action];
24
+ const incoming = token.scope;
25
+ // Precedence: true > string > false
26
+ if (existing === true)
27
+ continue;
28
+ if (incoming === true) {
29
+ perAction[token.action] = true;
30
+ continue;
31
+ }
32
+ if (typeof existing === "string")
33
+ continue; // keep earlier string
34
+ if (typeof incoming === "string") {
35
+ perAction[token.action] = incoming;
36
+ continue;
37
+ }
38
+ // both false — no change
39
+ }
40
+ const array = types_1.ACTION_ORDER.map((action) => ({ type: action, value: perAction[action] }));
41
+ return JSON.stringify(array);
42
+ }
43
+ //# sourceMappingURL=to-permissions-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-permissions-json.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/to-permissions-json.ts"],"names":[],"mappings":";;AAYA,8CA4BC;AAxCD,mCAA0D;AAE1D;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAAC,MAAmB;IACnD,MAAM,SAAS,GAAqC;QAClD,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;KACd,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;QAE7B,oCAAoC;QACpC,IAAI,QAAQ,KAAK,IAAI;YAAE,SAAS;QAChC,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YACtB,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;YAC/B,SAAS;QACX,CAAC;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,SAAS,CAAC,sBAAsB;QAClE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;YACnC,SAAS;QACX,CAAC;QACD,yBAAyB;IAC3B,CAAC;IAED,MAAM,KAAK,GAAG,oBAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACzF,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,55 @@
1
+ export type Action = "read" | "create" | "update" | "delete";
2
+ /**
3
+ * A single permission token. Either unconditional (`scope: true`) or scoped to
4
+ * a dotted path into the frontend model (`scope: "warehouse.managedBy"`).
5
+ *
6
+ * The `M` type parameter constrains scoped paths to those valid for the
7
+ * module the token is declared under. Unconditional tokens are any-module
8
+ * (scope: true) so they have no module constraint.
9
+ */
10
+ export type PermToken<PathSet extends string = string> = {
11
+ action: Action;
12
+ scope: true;
13
+ } | {
14
+ action: Action;
15
+ scope: PathSet;
16
+ };
17
+ /**
18
+ * Permissions block for a single module in the matrix.
19
+ *
20
+ * `default` applies to every role for this module (the floor).
21
+ * Each role key declares *additions* on top of defaults.
22
+ */
23
+ export type ModuleBlock<PathSet extends string = string> = {
24
+ default: PermToken<PathSet>[];
25
+ } & Record<string, PermToken<PathSet>[]>;
26
+ /**
27
+ * The full RBAC matrix.
28
+ *
29
+ * Keys are module UUIDs (values of `ModuleId`). The `ModuleUserPaths` generic
30
+ * constrains the key set to known modules; scoped paths are typed as `string`
31
+ * (not narrowed per-module), because:
32
+ * 1. Many modules legitimately have no BFS-discovered relationship paths, so
33
+ * per-module narrowing would collapse their scope type to `never` and
34
+ * reject any scoped token.
35
+ * 2. Self-scope paths (e.g. `"id"` on User) and attribute paths are not part
36
+ * of the relationship-based `MODULE_USER_PATHS` set, but are valid at
37
+ * runtime.
38
+ * Action names remain strictly typed.
39
+ */
40
+ export type RbacMatrix<ModuleUserPaths extends Record<string, readonly string[]> = Record<string, readonly string[]>> = {
41
+ [M in keyof ModuleUserPaths]?: ModuleBlock<string>;
42
+ };
43
+ /**
44
+ * Effective permissions for a single role on a single module, after union of
45
+ * default and role-specific tokens. Matches the shape that the existing
46
+ * permissionQuery writes to Neo4j.
47
+ */
48
+ export interface ResolvedPermissions {
49
+ create: boolean | string;
50
+ read: boolean | string;
51
+ update: boolean | string;
52
+ delete: boolean | string;
53
+ }
54
+ export declare const ACTION_ORDER: readonly Action[];
55
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IACjD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAC/B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,IAAI;IACzD,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;CAC/B,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,CAAC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,IAClH;KACG,CAAC,IAAI,MAAM,eAAe,CAAC,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;CACnD,CAAC;AAEJ;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAoD,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // packages/nestjs-neo4jsonapi/src/foundations/rbac/dsl/types.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ACTION_ORDER = void 0;
5
+ exports.ACTION_ORDER = ["read", "create", "update", "delete"];
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/foundations/rbac/dsl/types.ts"],"names":[],"mappings":";AAAA,gEAAgE;;;AAyDnD,QAAA,YAAY,GAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC"}