@decaf-ts/for-nest 0.0.7 → 0.0.9

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 (95) hide show
  1. package/README.md +22 -2
  2. package/dist/for-nest.cjs +1 -1
  3. package/dist/for-nest.cjs.map +1 -1
  4. package/dist/for-nest.js +1 -1
  5. package/dist/for-nest.js.map +1 -1
  6. package/lib/decaf-model/DecafModelModule.cjs +36 -0
  7. package/lib/decaf-model/DecafModelModule.d.ts +5 -0
  8. package/lib/decaf-model/DecafModelModule.js.map +1 -0
  9. package/lib/{model-module.cjs → decaf-model/FromModelController.cjs} +58 -52
  10. package/lib/decaf-model/FromModelController.d.ts +15 -0
  11. package/lib/decaf-model/FromModelController.js.map +1 -0
  12. package/lib/decaf-model/decorators/ApiOperationFromModel.cjs +44 -0
  13. package/lib/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
  14. package/lib/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
  15. package/lib/decaf-model/decorators/ApiParamsFromModel.cjs +27 -0
  16. package/lib/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
  17. package/lib/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
  18. package/lib/decaf-model/decorators/DecafParams.cjs +34 -0
  19. package/lib/decaf-model/decorators/DecafParams.d.ts +8 -0
  20. package/lib/decaf-model/decorators/DecafParams.js.map +1 -0
  21. package/lib/decaf-model/decorators/index.cjs +21 -0
  22. package/lib/decaf-model/decorators/index.d.ts +4 -0
  23. package/lib/decaf-model/decorators/index.js.map +1 -0
  24. package/lib/decaf-model/decorators/types.cjs +3 -0
  25. package/lib/decaf-model/decorators/types.d.ts +12 -0
  26. package/lib/decaf-model/decorators/types.js.map +1 -0
  27. package/lib/{decorators → decaf-model}/index.cjs +3 -2
  28. package/lib/decaf-model/index.d.ts +3 -0
  29. package/lib/decaf-model/index.js.map +1 -0
  30. package/lib/decoration.cjs +10 -10
  31. package/lib/decoration.js.map +1 -1
  32. package/lib/esm/decaf-model/DecafModelModule.d.ts +5 -0
  33. package/lib/esm/decaf-model/DecafModelModule.js +33 -0
  34. package/lib/esm/decaf-model/DecafModelModule.js.map +1 -0
  35. package/lib/esm/decaf-model/FromModelController.d.ts +15 -0
  36. package/lib/esm/{model-module.js → decaf-model/FromModelController.js} +58 -53
  37. package/lib/esm/decaf-model/FromModelController.js.map +1 -0
  38. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
  39. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js +40 -0
  40. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
  41. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
  42. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js +24 -0
  43. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
  44. package/lib/esm/decaf-model/decorators/DecafParams.d.ts +8 -0
  45. package/lib/esm/decaf-model/decorators/DecafParams.js +31 -0
  46. package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -0
  47. package/lib/esm/decaf-model/decorators/index.d.ts +4 -0
  48. package/lib/esm/decaf-model/decorators/index.js +5 -0
  49. package/lib/esm/decaf-model/decorators/index.js.map +1 -0
  50. package/lib/esm/decaf-model/decorators/types.d.ts +12 -0
  51. package/lib/esm/decaf-model/decorators/types.js +2 -0
  52. package/lib/esm/decaf-model/decorators/types.js.map +1 -0
  53. package/lib/esm/decaf-model/index.d.ts +3 -0
  54. package/lib/esm/decaf-model/index.js +4 -0
  55. package/lib/esm/decaf-model/index.js.map +1 -0
  56. package/lib/esm/decoration.js +1 -1
  57. package/lib/esm/decoration.js.map +1 -1
  58. package/lib/esm/index.d.ts +3 -3
  59. package/lib/esm/index.js +3 -3
  60. package/lib/esm/index.js.map +1 -1
  61. package/lib/esm/module.js +1 -1
  62. package/lib/esm/module.js.map +1 -1
  63. package/lib/index.cjs +3 -3
  64. package/lib/index.d.ts +3 -3
  65. package/lib/index.js.map +1 -1
  66. package/lib/module.cjs +2 -2
  67. package/lib/module.js.map +1 -1
  68. package/package.json +2 -3
  69. package/lib/decorators/ApiProperty.cjs +0 -63
  70. package/lib/decorators/ApiProperty.d.ts +0 -27
  71. package/lib/decorators/ApiProperty.js.map +0 -1
  72. package/lib/decorators/helpers.cjs +0 -140
  73. package/lib/decorators/helpers.d.ts +0 -8
  74. package/lib/decorators/helpers.js.map +0 -1
  75. package/lib/decorators/index.d.ts +0 -2
  76. package/lib/decorators/index.js.map +0 -1
  77. package/lib/decorators.cjs +0 -33
  78. package/lib/decorators.d.ts +0 -10
  79. package/lib/decorators.js.map +0 -1
  80. package/lib/esm/decorators/ApiProperty.d.ts +0 -27
  81. package/lib/esm/decorators/ApiProperty.js +0 -57
  82. package/lib/esm/decorators/ApiProperty.js.map +0 -1
  83. package/lib/esm/decorators/helpers.d.ts +0 -8
  84. package/lib/esm/decorators/helpers.js +0 -132
  85. package/lib/esm/decorators/helpers.js.map +0 -1
  86. package/lib/esm/decorators/index.d.ts +0 -2
  87. package/lib/esm/decorators/index.js +0 -3
  88. package/lib/esm/decorators/index.js.map +0 -1
  89. package/lib/esm/decorators.d.ts +0 -10
  90. package/lib/esm/decorators.js +0 -29
  91. package/lib/esm/decorators.js.map +0 -1
  92. package/lib/esm/model-module.d.ts +0 -8
  93. package/lib/esm/model-module.js.map +0 -1
  94. package/lib/model-module.d.ts +0 -8
  95. package/lib/model-module.js.map +0 -1
@@ -11,28 +11,26 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
- var DecafModelModule_1;
15
14
  Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.DecafModelModule = void 0;
15
+ exports.FromModelController = void 0;
17
16
  const common_1 = require("@nestjs/common");
18
17
  const swagger_1 = require("@nestjs/swagger");
19
18
  const core_1 = require("@decaf-ts/core");
20
19
  const decorator_validation_1 = require("@decaf-ts/decorator-validation");
21
20
  const logging_1 = require("@decaf-ts/logging");
22
- const RepoFactory_1 = require("./RepoFactory.cjs");
23
- const decorators_1 = require("./decorators.cjs");
24
- let DecafModelModule = class DecafModelModule {
25
- static { DecafModelModule_1 = this; }
26
- static get log() {
27
- if (!this._logger)
28
- this._logger = logging_1.Logging.for(DecafModelModule_1);
29
- return this._logger;
30
- }
31
- static toModelController(ModelClazz) {
32
- const log = this.log.for(this.toModelController);
21
+ const db_decorators_1 = require("@decaf-ts/db-decorators");
22
+ const decoration_1 = require("@decaf-ts/decoration");
23
+ const decorators_1 = require("./decorators/index.cjs");
24
+ const RepoFactory_1 = require("./../RepoFactory.cjs");
25
+ class FromModelController {
26
+ static { this.log = logging_1.Logging.for(FromModelController.name); }
27
+ static create(ModelClazz) {
28
+ const log = FromModelController.log.for(FromModelController.create);
33
29
  const tableName = core_1.Repository.table(ModelClazz);
34
30
  const routePath = (0, logging_1.toKebabCase)(tableName);
35
31
  const modelClazzName = ModelClazz.name;
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
36
34
  log.debug(`Creating controller for model: ${modelClazzName}`);
37
35
  let DynamicModelController = class DynamicModelController extends logging_1.LoggedClass {
38
36
  constructor(repoFactory) {
@@ -61,7 +59,8 @@ let DecafModelModule = class DecafModelModule {
61
59
  log.info(`created new ${modelClazzName} with id ${created[this.pk]}`);
62
60
  return created;
63
61
  }
64
- async read(id) {
62
+ async read(pathParams) {
63
+ const { id } = pathParams;
65
64
  const log = this.log.for(this.read);
66
65
  let read;
67
66
  try {
@@ -89,12 +88,12 @@ let DecafModelModule = class DecafModelModule {
89
88
  log.info(`Successfully queried ${modelClazzName} using method "${method}"`);
90
89
  return results;
91
90
  }
92
- async update(data) {
91
+ async update(routeParams, body) {
93
92
  const log = this.log.for(this.update);
94
93
  let updated;
95
94
  try {
96
- log.info(`updating ${modelClazzName} with ${this.pk} ${data[this.pk]}`);
97
- updated = await this.repo.create(data);
95
+ log.info(`updating ${modelClazzName} with ${this.pk} ${body[this.pk]}`);
96
+ updated = await this.repo.create(body);
98
97
  }
99
98
  catch (e) {
100
99
  log.error(e);
@@ -102,15 +101,15 @@ let DecafModelModule = class DecafModelModule {
102
101
  }
103
102
  return updated;
104
103
  }
105
- async delete(id) {
104
+ async delete(routeParams) {
106
105
  const log = this.log.for(this.delete);
107
106
  let read;
108
107
  try {
109
- log.debug(`deleting ${modelClazzName} with ${this.pk} ${id}`);
110
- read = await this.repo.read(id);
108
+ log.debug(`deleting ${modelClazzName} with ${this.pk} ${routeParams}`);
109
+ read = await this.repo.read("id");
111
110
  }
112
111
  catch (e) {
113
- log.error(`Failed to delete ${modelClazzName} with id ${id}`, e);
112
+ log.error(`Failed to delete ${modelClazzName} with id ${"id"}`, e);
114
113
  throw e;
115
114
  }
116
115
  log.info(`deleted ${modelClazzName} with id ${read[this.pk]}`);
@@ -137,18 +136,18 @@ let DecafModelModule = class DecafModelModule {
137
136
  __metadata("design:returntype", Promise)
138
137
  ], DynamicModelController.prototype, "create", null);
139
138
  __decorate([
140
- (0, decorators_1.ApiOperationFromModel)(ModelClazz, "GET", ":id"),
139
+ (0, decorators_1.ApiOperationFromModel)(ModelClazz, "GET", path),
140
+ (0, decorators_1.ApiParamsFromModel)(apiProperties),
141
141
  (0, swagger_1.ApiOperation)({ summary: `Retrieve a ${modelClazzName} record by id.` }),
142
- (0, swagger_1.ApiParam)({ name: "id", description: "Primary key" }),
143
142
  (0, swagger_1.ApiOkResponse)({
144
143
  description: `${modelClazzName} retrieved successfully.`,
145
144
  }),
146
145
  (0, swagger_1.ApiNotFoundResponse)({
147
146
  description: `No ${modelClazzName} record matches the provided identifier.`,
148
147
  }),
149
- __param(0, (0, common_1.Param)("id")),
148
+ __param(0, (0, common_1.Param)()),
150
149
  __metadata("design:type", Function),
151
- __metadata("design:paramtypes", [String]),
150
+ __metadata("design:paramtypes", [Object]),
152
151
  __metadata("design:returntype", Promise)
153
152
  ], DynamicModelController.prototype, "read", null);
154
153
  __decorate([
@@ -167,7 +166,8 @@ let DecafModelModule = class DecafModelModule {
167
166
  __metadata("design:returntype", Promise)
168
167
  ], DynamicModelController.prototype, "query", null);
169
168
  __decorate([
170
- (0, decorators_1.ApiOperationFromModel)(ModelClazz, "PUT", ":id"),
169
+ (0, decorators_1.ApiOperationFromModel)(ModelClazz, "PUT", path),
170
+ (0, decorators_1.ApiParamsFromModel)(apiProperties),
171
171
  (0, swagger_1.ApiOperation)({
172
172
  summary: `Replace an existing ${modelClazzName} record with a new payload.`,
173
173
  }),
@@ -182,27 +182,25 @@ let DecafModelModule = class DecafModelModule {
182
182
  description: `No ${modelClazzName} record matches the provided identifier.`,
183
183
  }),
184
184
  (0, swagger_1.ApiBadRequestResponse)({ description: "Payload validation failed." }),
185
- __param(0, (0, common_1.Body)()),
185
+ __param(0, (0, decorators_1.DecafParams)(apiProperties)),
186
+ __param(1, (0, common_1.Body)()),
186
187
  __metadata("design:type", Function),
187
- __metadata("design:paramtypes", [decorator_validation_1.Model]),
188
+ __metadata("design:paramtypes", [Object, decorator_validation_1.Model]),
188
189
  __metadata("design:returntype", Promise)
189
190
  ], DynamicModelController.prototype, "update", null);
190
191
  __decorate([
191
- (0, decorators_1.ApiOperationFromModel)(ModelClazz, "DELETE", ":id"),
192
+ (0, decorators_1.ApiOperationFromModel)(ModelClazz, "DELETE", path),
193
+ (0, decorators_1.ApiParamsFromModel)(apiProperties),
192
194
  (0, swagger_1.ApiOperation)({ summary: `Delete a ${modelClazzName} record by id.` }),
193
- (0, swagger_1.ApiParam)({
194
- name: "id",
195
- description: `Primary key value of the ${modelClazzName} record to delete.`,
196
- }),
197
195
  (0, swagger_1.ApiOkResponse)({
198
196
  description: `${modelClazzName} record deleted successfully.`,
199
197
  }),
200
198
  (0, swagger_1.ApiNotFoundResponse)({
201
199
  description: `No ${modelClazzName} record matches the provided identifier.`,
202
200
  }),
203
- __param(0, (0, common_1.Param)("id")),
201
+ __param(0, (0, decorators_1.DecafParams)(apiProperties)),
204
202
  __metadata("design:type", Function),
205
- __metadata("design:paramtypes", [String]),
203
+ __metadata("design:paramtypes", [Object]),
206
204
  __metadata("design:returntype", Promise)
207
205
  ], DynamicModelController.prototype, "delete", null);
208
206
  DynamicModelController = __decorate([
@@ -213,21 +211,29 @@ let DecafModelModule = class DecafModelModule {
213
211
  ], DynamicModelController);
214
212
  return DynamicModelController;
215
213
  }
216
- static forRoot(flavour) {
217
- const log = this.log.for(this.forRoot);
218
- log.info(`Generating controllers for flavour...`);
219
- const trackedModels = core_1.Adapter.models(flavour);
220
- const controllers = trackedModels.map(this.toModelController.bind(this));
221
- log.info(`Generated ${controllers.length} controllers`);
222
- return {
223
- module: DecafModelModule_1,
224
- controllers,
225
- providers: [RepoFactory_1.RepoFactory],
226
- };
214
+ static getRouteParametersFromModel(ModelClazz) {
215
+ const instance = new ModelClazz({});
216
+ const pk = ((0, db_decorators_1.findPrimaryKey)(instance)?.id || "id");
217
+ const composedKeyMetaKey = core_1.Repository.key(db_decorators_1.DBKeys.COMPOSED);
218
+ const composedKeys = Reflect.getMetadata(composedKeyMetaKey, instance, pk)?.args ??
219
+ [];
220
+ const keysToReturn = Array.isArray(composedKeys) && composedKeys.length > 0
221
+ ? [...composedKeys]
222
+ : [pk];
223
+ const description = decoration_1.Metadata.description(ModelClazz);
224
+ // remove duplicates while preserving order
225
+ const uniqueKeys = Array.from(new Set(keysToReturn));
226
+ const path = uniqueKeys.map((key) => `:${key}`).join("/");
227
+ const apiProperties = uniqueKeys.map((key) => {
228
+ return {
229
+ name: key,
230
+ description: decoration_1.Metadata.description(ModelClazz, key),
231
+ required: true,
232
+ type: String,
233
+ };
234
+ });
235
+ return { description, apiProperties, path };
227
236
  }
228
- };
229
- exports.DecafModelModule = DecafModelModule;
230
- exports.DecafModelModule = DecafModelModule = DecafModelModule_1 = __decorate([
231
- (0, common_1.Module)({})
232
- ], DecafModelModule);
233
- //# sourceMappingURL=model-module.js.map
237
+ }
238
+ exports.FromModelController = FromModelController;
239
+ //# sourceMappingURL=FromModelController.js.map
@@ -0,0 +1,15 @@
1
+ import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
2
+ export declare class FromModelController {
3
+ private static readonly log;
4
+ static create<T extends Model<any>>(ModelClazz: ModelConstructor<T>): any;
5
+ static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>): {
6
+ description: string | undefined;
7
+ apiProperties: {
8
+ name: any;
9
+ description: string | undefined;
10
+ required: boolean;
11
+ type: StringConstructor;
12
+ }[];
13
+ path: string;
14
+ };
15
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FromModelController.js","sourceRoot":"","sources":["../../src/decaf-model/FromModelController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,6CAYyB;AACzB,yCAAkD;AAClD,yEAAyE;AACzE,+CAAsE;AACtE,2DAAiE;AACjE,qDAAgD;AAChD,uDAKsB;AACtB,sDAA6C;AAE7C,MAAa,mBAAmB;aACN,QAAG,GAAG,iBAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE7D,AAAP,MAAM,CAAC,MAAM,CAAuB,UAA+B;QACjE,MAAM,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpE,MAAM,SAAS,GAAG,iBAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,IAAA,qBAAW,EAAC,SAAS,CAAC,CAAC;QACzC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;QACvC,6DAA6D;QAC7D,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,GACxC,mBAAmB,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;QAE9D,GAAG,CAAC,KAAK,CAAC,kCAAkC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O;gBACL,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,qBAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC;gBAClD,QAAQ,EAAE,IAAI;gBACd,IAAI,EAAE,MAAM;aACb,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IAC9C,CAAC;;AA9NH,kDA+NC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isOperationBlocked = isOperationBlocked;
4
+ exports.ApiOperationFromModel = ApiOperationFromModel;
5
+ const decoration_1 = require("@decaf-ts/decoration");
6
+ const common_1 = require("@nestjs/common");
7
+ const swagger_1 = require("@nestjs/swagger");
8
+ const reflection_1 = require("@decaf-ts/reflection");
9
+ const db_decorators_1 = require("@decaf-ts/db-decorators");
10
+ /**
11
+ * @description Determines if a given CRUD operation is blocked for a specific model constructor.
12
+ * @summary Retrieves the operation-blocking handler metadata stored on the provided model constructor (under `OperationKeys.REFLECT + OperationKeys.BLOCK`), executes it (if present) with its persisted arguments plus the requested operation, and returns whether the operation is blocked. If no handler exists, the operation is considered allowed (returns `false`).
13
+ * @param {ModelConstructor<any>} ModelConstructor - The target model constructor whose metadata may include a blocking handler.
14
+ * @param {CrudOperations} op - The CRUD operation to evaluate (e.g., `OperationKeys.CREATE`, `OperationKeys.READ`, `OperationKeys.UPDATE`, `OperationKeys.DELETE`).
15
+ * @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
16
+ * @function isOperationBlocked
17
+ */
18
+ function isOperationBlocked(ModelConstructor, op) {
19
+ const { handler, args } = (decoration_1.Metadata.get(ModelConstructor, db_decorators_1.OperationKeys.REFLECT + db_decorators_1.OperationKeys.BLOCK) || {});
20
+ // @ts-expect-error TODO @pedro
21
+ return !handler ? false : (handler(...args, op) ?? false);
22
+ }
23
+ /**
24
+ * @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
25
+ * @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
26
+ * @param {ModelConstructor<any>} ModelConstructor - The model constructor used to resolve operation-blocking rules.
27
+ * @param {HttpVerbs} verb - The HTTP verb to map (e.g., `"GET" | "POST" | "PUT" | "PATCH" | "DELETE"`).
28
+ * @param {string} [path] - Optional route path passed through to the corresponding Nest HTTP method decorator.
29
+ * @return {MethodDecorator} A method decorator that either excludes the endpoint from Swagger (and route registration) or applies the correct HTTP decorator.
30
+ */
31
+ function ApiOperationFromModel(ModelConstructor, verb, path) {
32
+ const httpToCrud = {
33
+ GET: [db_decorators_1.OperationKeys.READ, common_1.Get],
34
+ POST: [db_decorators_1.OperationKeys.CREATE, common_1.Post],
35
+ PUT: [db_decorators_1.OperationKeys.UPDATE, common_1.Put],
36
+ PATCH: [db_decorators_1.OperationKeys.UPDATE, common_1.Patch],
37
+ DELETE: [db_decorators_1.OperationKeys.DELETE, common_1.Delete],
38
+ };
39
+ const [crudOp, HttpMethodDecorator] = httpToCrud[verb];
40
+ return isOperationBlocked(ModelConstructor, crudOp)
41
+ ? (0, reflection_1.apply)((0, swagger_1.ApiExcludeEndpoint)())
42
+ : (0, reflection_1.apply)(HttpMethodDecorator(path));
43
+ }
44
+ //# sourceMappingURL=ApiOperationFromModel.js.map
@@ -0,0 +1,21 @@
1
+ import { CrudOperations } from "@decaf-ts/db-decorators";
2
+ import { ModelConstructor } from "@decaf-ts/decorator-validation";
3
+ import { HttpVerbs } from "./types";
4
+ /**
5
+ * @description Determines if a given CRUD operation is blocked for a specific model constructor.
6
+ * @summary Retrieves the operation-blocking handler metadata stored on the provided model constructor (under `OperationKeys.REFLECT + OperationKeys.BLOCK`), executes it (if present) with its persisted arguments plus the requested operation, and returns whether the operation is blocked. If no handler exists, the operation is considered allowed (returns `false`).
7
+ * @param {ModelConstructor<any>} ModelConstructor - The target model constructor whose metadata may include a blocking handler.
8
+ * @param {CrudOperations} op - The CRUD operation to evaluate (e.g., `OperationKeys.CREATE`, `OperationKeys.READ`, `OperationKeys.UPDATE`, `OperationKeys.DELETE`).
9
+ * @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
10
+ * @function isOperationBlocked
11
+ */
12
+ export declare function isOperationBlocked(ModelConstructor: ModelConstructor<any>, op: CrudOperations): boolean;
13
+ /**
14
+ * @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
15
+ * @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
16
+ * @param {ModelConstructor<any>} ModelConstructor - The model constructor used to resolve operation-blocking rules.
17
+ * @param {HttpVerbs} verb - The HTTP verb to map (e.g., `"GET" | "POST" | "PUT" | "PATCH" | "DELETE"`).
18
+ * @param {string} [path] - Optional route path passed through to the corresponding Nest HTTP method decorator.
19
+ * @return {MethodDecorator} A method decorator that either excludes the endpoint from Swagger (and route registration) or applies the correct HTTP decorator.
20
+ */
21
+ export declare function ApiOperationFromModel(ModelConstructor: ModelConstructor<any>, verb: HttpVerbs, path?: string): MethodDecorator;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiOperationFromModel.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/ApiOperationFromModel.ts"],"names":[],"mappings":";;AAgBA,gDAiBC;AAUD,sDAoBC;AA/DD,qDAAgD;AAChD,2CAA+D;AAC/D,6CAAqD;AACrD,qDAA6C;AAC7C,2DAAwE;AAIxE;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,gBAAuC,EACvC,EAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,qBAAQ,CAAC,GAAG,CACrC,gBAAuB,EACvB,6BAAa,CAAC,OAAO,GAAG,6BAAa,CAAC,KAAK,CAC5C,IAAI,EAAE,CAMN,CAAC;IAEF,+BAA+B;IAC/B,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,gBAAuC,EACvC,IAAe,EACf,IAAa;IAEb,MAAM,UAAU,GAGZ;QACF,GAAG,EAAE,CAAC,6BAAa,CAAC,IAAI,EAAE,YAAG,CAAC;QAC9B,IAAI,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,aAAI,CAAC;QAClC,GAAG,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,YAAG,CAAC;QAChC,KAAK,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,cAAK,CAAC;QACpC,MAAM,EAAE,CAAC,6BAAa,CAAC,MAAM,EAAE,eAAM,CAAC;KACvC,CAAC;IAEF,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,CAAC;QACjD,CAAC,CAAC,IAAA,kBAAK,EAAC,IAAA,4BAAkB,GAAE,CAAC;QAC7B,CAAC,CAAC,IAAA,kBAAK,EAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiParamsFromModel = ApiParamsFromModel;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ /**
7
+ * @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
8
+ * @summary Transforms each entry of the provided `ApiParam[]` into a corresponding `@ApiParam()` decorator (defaulting `description`, `required`, and `type` when omitted) and composes them into a single decorator via Nest's `applyDecorators`. Useful for synchronizing runtime route params with OpenAPI documentation in a concise, declarative way.
9
+ * @param {ApiParam[]} [props=[]] Array describing path parameters to be documented.
10
+ * @param {string} props[].name The parameter's name as it appears in the route template (e.g., `:id`).
11
+ * @param {string} [props[].description] Human-readable explanation of the parameter; defaults to `"Path parameter: <name>"`.
12
+ * @param {boolean} [props[].required=true] Whether the parameter is required; defaults to `true`.
13
+ * @param {Constructor<any>} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
14
+ * @return {any} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
15
+ * @function ApiParamsFromModel
16
+ */
17
+ function ApiParamsFromModel(props = []) {
18
+ const decorators = props.map((p) => (0, swagger_1.ApiParam)({
19
+ name: p.name,
20
+ description: p.description ?? `Path parameter: ${p.name}`,
21
+ required: p.required ?? true,
22
+ // schema: { type: 'string' },
23
+ type: p.type ?? String,
24
+ }));
25
+ return (0, common_1.applyDecorators)(...decorators);
26
+ }
27
+ //# sourceMappingURL=ApiParamsFromModel.js.map
@@ -0,0 +1,13 @@
1
+ import { ApiParam } from "./types";
2
+ /**
3
+ * @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
4
+ * @summary Transforms each entry of the provided `ApiParam[]` into a corresponding `@ApiParam()` decorator (defaulting `description`, `required`, and `type` when omitted) and composes them into a single decorator via Nest's `applyDecorators`. Useful for synchronizing runtime route params with OpenAPI documentation in a concise, declarative way.
5
+ * @param {ApiParam[]} [props=[]] Array describing path parameters to be documented.
6
+ * @param {string} props[].name The parameter's name as it appears in the route template (e.g., `:id`).
7
+ * @param {string} [props[].description] Human-readable explanation of the parameter; defaults to `"Path parameter: <name>"`.
8
+ * @param {boolean} [props[].required=true] Whether the parameter is required; defaults to `true`.
9
+ * @param {Constructor<any>} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
10
+ * @return {any} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
11
+ * @function ApiParamsFromModel
12
+ */
13
+ export declare function ApiParamsFromModel(props?: ApiParam[]): MethodDecorator & ClassDecorator;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiParamsFromModel.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/ApiParamsFromModel.ts"],"names":[],"mappings":";;AAeA,gDAaC;AA5BD,2CAAiD;AACjD,6CAA0D;AAG1D;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,QAAoB,EAAE;IAEtB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACjC,IAAA,kBAAW,EAAC;QACV,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC,IAAI,EAAE;QACzD,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI;QAC5B,8BAA8B;QAC9B,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM;KACvB,CAAC,CACH,CAAC;IACF,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecafParams = DecafParams;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * @description Creates a custom NestJS parameter decorator that extracts and returns route parameters ordered by a specific key sequence.
7
+ * @summary The `OrderedParams` decorator reads the incoming HTTP request's `params` object, optionally orders it according to a provided list of parameter names, and returns an object containing the original params, the ordered values, and the applied order list. This ensures deterministic parameter access for routes with multiple path parameters.
8
+ * @template {string[]} TOrder - Represents the expected sequence of parameter names.
9
+ * @param {TOrder | undefined} order An optional array specifying the parameter names' desired order. If not provided, the decorator will preserve the order of the keys as they appear in the original `req.params` object.
10
+ * @param {ExecutionContext} ctx The NestJS execution context, used to retrieve the current HTTP request object.
11
+ * @return {DecafParamProps} An object containing:
12
+ * - `original`: the raw parameter map from `req.params`;
13
+ * - `ordered`: an array of parameter values in the requested order;
14
+ * - `order`: the effective order list used.
15
+ * @function OrderedParams
16
+ */
17
+ const OrderedParams = (0, common_1.createParamDecorator)((order, ctx) => {
18
+ const req = ctx.switchToHttp().getRequest();
19
+ const original = (req?.params ?? {});
20
+ const orderList = order ?? Object.keys(original);
21
+ const ordered = orderList.map((k) => original[k]);
22
+ return { original, ordered, order: orderList };
23
+ });
24
+ /**
25
+ * @description A higher-level decorator factory that leverages `OrderedParams` to extract route parameters in a specific order derived from a list of `ApiParam` definitions.
26
+ * @summary `DecafParams` computes the order of route parameters based on the provided `ApiParam[]` specification (using each element’s `name`), then applies `OrderedParams(order)` as a parameter decorator. This enables parameter-level binding that remains consistent with the documented API parameter metadata.
27
+ * @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
28
+ * @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
29
+ */
30
+ function DecafParams(props = []) {
31
+ const order = props.map((p) => p.name);
32
+ return OrderedParams(order);
33
+ }
34
+ //# sourceMappingURL=DecafParams.js.map
@@ -0,0 +1,8 @@
1
+ import { ApiParam } from "./types";
2
+ /**
3
+ * @description A higher-level decorator factory that leverages `OrderedParams` to extract route parameters in a specific order derived from a list of `ApiParam` definitions.
4
+ * @summary `DecafParams` computes the order of route parameters based on the provided `ApiParam[]` specification (using each element’s `name`), then applies `OrderedParams(order)` as a parameter decorator. This enables parameter-level binding that remains consistent with the documented API parameter metadata.
5
+ * @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
6
+ * @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
7
+ */
8
+ export declare function DecafParams(props?: ApiParam[]): ParameterDecorator;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecafParams.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/DecafParams.ts"],"names":[],"mappings":";;AA+BA,kCAGC;AAlCD,2CAAwE;AAGxE;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAAG,IAAA,6BAAoB,EACxC,CAAC,KAA2B,EAAE,GAAqB,EAAmB,EAAE;IACtE,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,CAAwB,CAAC;IAC5D,MAAM,SAAS,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACjD,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,QAAoB,EAAE;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,21 @@
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
+ __exportStar(require("./types.cjs"), exports);
18
+ __exportStar(require("./ApiOperationFromModel.cjs"), exports);
19
+ __exportStar(require("./ApiParamsFromModel.cjs"), exports);
20
+ __exportStar(require("./DecafParams.cjs"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./ApiOperationFromModel";
3
+ export * from "./ApiParamsFromModel";
4
+ export * from "./DecafParams";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB;AACxB,8DAAwC;AACxC,2DAAqC;AACrC,oDAA8B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,12 @@
1
+ export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
+ export type ApiParam = {
3
+ name: string;
4
+ description?: string;
5
+ required?: boolean;
6
+ type?: any;
7
+ };
8
+ export type DecafParamProps = {
9
+ original: Record<string, any>;
10
+ ordered: any[];
11
+ order: string[];
12
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/types.ts"],"names":[],"mappings":""}
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ApiProperty.cjs"), exports);
18
- __exportStar(require("./helpers.cjs"), exports);
17
+ __exportStar(require("./decorators/index.cjs"), exports);
18
+ __exportStar(require("./DecafModelModule.cjs"), exports);
19
+ __exportStar(require("./FromModelController.cjs"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export * from "./decorators";
2
+ export * from "./DecafModelModule";
3
+ export * from "./FromModelController";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decaf-model/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAA6B;AAC7B,yDAAmC;AACnC,4DAAsC"}
@@ -4,8 +4,8 @@ const injectable_decorators_1 = require("@decaf-ts/injectable-decorators");
4
4
  const common_1 = require("@nestjs/common");
5
5
  const decoration_1 = require("@decaf-ts/decoration");
6
6
  const decorator_validation_1 = require("@decaf-ts/decorator-validation");
7
- const ApiProperty_1 = require("./decorators/ApiProperty.cjs");
8
7
  const core_1 = require("@decaf-ts/core");
8
+ const swagger_1 = require("@nestjs/swagger");
9
9
  decoration_1.Decoration.for(injectable_decorators_1.InjectablesKeys.INJECTABLE)
10
10
  .extend({
11
11
  decorator: function nestInjectable(category, cfg) {
@@ -28,35 +28,35 @@ decoration_1.Decoration.for(injectable_decorators_1.InjectablesKeys.INJECT)
28
28
  })
29
29
  .apply();
30
30
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.REQUIRED)
31
- .extend((0, ApiProperty_1.ApiProperty)({
31
+ .extend((0, swagger_1.ApiProperty)({
32
32
  required: true,
33
33
  }))
34
34
  .apply();
35
35
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MAX)
36
36
  .extend({
37
37
  decorator: function maxDec(max) {
38
- return (0, ApiProperty_1.ApiProperty)({ maximum: max });
38
+ return (0, swagger_1.ApiProperty)({ maximum: max });
39
39
  },
40
40
  })
41
41
  .apply();
42
42
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MIN)
43
43
  .extend({
44
44
  decorator: function minDec(min) {
45
- return (0, ApiProperty_1.ApiProperty)({ minimum: min });
45
+ return (0, swagger_1.ApiProperty)({ minimum: min });
46
46
  },
47
47
  })
48
48
  .apply();
49
49
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MAX_LENGTH)
50
50
  .extend({
51
51
  decorator: function maxLengthDec(max) {
52
- return (0, ApiProperty_1.ApiProperty)({ maxLength: max });
52
+ return (0, swagger_1.ApiProperty)({ maxLength: max });
53
53
  },
54
54
  })
55
55
  .apply();
56
56
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.MIN_LENGTH)
57
57
  .extend({
58
58
  decorator: function minLengthDec(min) {
59
- return (0, ApiProperty_1.ApiProperty)({ minLength: min });
59
+ return (0, swagger_1.ApiProperty)({ minLength: min });
60
60
  },
61
61
  })
62
62
  .apply();
@@ -80,7 +80,7 @@ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.LIST)
80
80
  .extend({
81
81
  decorator: function listDec(clazz) {
82
82
  const c = Array.isArray(clazz) ? clazz[0] : clazz;
83
- return (0, ApiProperty_1.ApiProperty)({ type: [c] });
83
+ return (0, swagger_1.ApiProperty)({ type: [c] });
84
84
  },
85
85
  })
86
86
  .apply();
@@ -96,7 +96,7 @@ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.LIST)
96
96
  decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.PATTERN)
97
97
  .extend({
98
98
  decorator: function patternDec(pat) {
99
- return (0, ApiProperty_1.ApiProperty)({
99
+ return (0, swagger_1.ApiProperty)({
100
100
  pattern: typeof pat === "string" ? pat : pat.source,
101
101
  });
102
102
  },
@@ -105,7 +105,7 @@ decoration_1.Decoration.for(decorator_validation_1.ValidationKeys.PATTERN)
105
105
  decoration_1.Decoration.for(core_1.PersistenceKeys.COLUMN)
106
106
  .extend({
107
107
  decorator: function columnDec(name) {
108
- return (0, ApiProperty_1.ApiProperty)({
108
+ return (0, swagger_1.ApiProperty)({
109
109
  name: name,
110
110
  });
111
111
  },
@@ -114,7 +114,7 @@ decoration_1.Decoration.for(core_1.PersistenceKeys.COLUMN)
114
114
  decoration_1.Decoration.for(decoration_1.DecorationKeys.DESCRIPTION)
115
115
  .extend({
116
116
  decorator: function descriptionDec(description) {
117
- return (0, ApiProperty_1.ApiProperty)({
117
+ return (0, swagger_1.ApiProperty)({
118
118
  description: description,
119
119
  });
120
120
  },
@@ -1 +1 @@
1
- {"version":3,"file":"decoration.js","sourceRoot":"","sources":["../src/decoration.ts"],"names":[],"mappings":";;AAAA,2EAIyC;AACzC,2CAA2D;AAC3D,qDAA+E;AAC/E,yEAAgE;AAChE,8DAAuD;AACvD,yCAAiD;AAEjD,uBAAU,CAAC,GAAG,CAAC,uCAAe,CAAC,UAAU,CAAC;KACvC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,cAAc,CAChC,QAA8B,EAC9B,GAAqB;QAErB,OAAO,IAAA,mBAAU,EAAC;YAChB,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,cAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAK,CAAC,OAAO;YACpD,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;SAC1C,CAAC,CAAC;IACL,CAAC;CACF,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,uBAAU,CAAC,GAAG,CAAC,uCAAe,CAAC,MAAM,CAAC;KACnC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,UAAU,CAC5B,QAAuC;IACvC,6DAA6D;IAC7D,GAAkB;QAElB,OAAO,SAAS,eAAe,CAC7B,MAAc,EACd,WAAiB,EACjB,UAAgB;YAEhB,OAAO,IAAA,eAAM,EAAC,QAAQ,IAAK,MAAsB,CAAC,CAChD,MAAM,EACN,WAAW,EACX,UAAU,CACX,CAAC;QACJ,CAA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 -0,0 +1,5 @@
1
+ import { DynamicModule } from "@nestjs/common";
2
+ export declare class DecafModelModule {
3
+ private static readonly log;
4
+ static forRoot(flavour: string): DynamicModule;
5
+ }
@@ -0,0 +1,33 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var DecafModelModule_1;
8
+ import { Module } from "@nestjs/common";
9
+ import { Adapter } from "@decaf-ts/core";
10
+ import { Logging } from "@decaf-ts/logging";
11
+ import { RepoFactory } from "./../RepoFactory.js";
12
+ import { FromModelController } from "./FromModelController.js";
13
+ let DecafModelModule = class DecafModelModule {
14
+ static { DecafModelModule_1 = this; }
15
+ static { this.log = Logging.for(DecafModelModule_1.name); }
16
+ static forRoot(flavour) {
17
+ const log = this.log.for(this.forRoot);
18
+ log.info(`Generating controllers for flavour...`);
19
+ const trackedModels = Adapter.models(flavour);
20
+ const controllers = trackedModels.map(FromModelController.create);
21
+ log.info(`Generated ${controllers.length} controllers`);
22
+ return {
23
+ module: DecafModelModule_1,
24
+ controllers,
25
+ providers: [RepoFactory],
26
+ };
27
+ }
28
+ };
29
+ DecafModelModule = DecafModelModule_1 = __decorate([
30
+ Module({})
31
+ ], DecafModelModule);
32
+ export { DecafModelModule };
33
+ //# sourceMappingURL=DecafModelModule.js.map