@decaf-ts/for-nest 0.0.6 → 0.0.8

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 (73) hide show
  1. package/dist/for-nest.cjs +1 -1
  2. package/dist/for-nest.cjs.map +1 -1
  3. package/dist/for-nest.js +1 -1
  4. package/dist/for-nest.js.map +1 -1
  5. package/lib/decaf-model/DecafModelModule.cjs +36 -0
  6. package/lib/decaf-model/DecafModelModule.d.ts +5 -0
  7. package/lib/decaf-model/DecafModelModule.js.map +1 -0
  8. package/lib/{model-module.cjs → decaf-model/FromModelController.cjs} +57 -52
  9. package/lib/decaf-model/FromModelController.d.ts +15 -0
  10. package/lib/decaf-model/FromModelController.js.map +1 -0
  11. package/lib/decaf-model/decorators/ApiOperationFromModel.cjs +44 -0
  12. package/lib/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
  13. package/lib/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
  14. package/lib/decaf-model/decorators/ApiParamsFromModel.cjs +27 -0
  15. package/lib/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
  16. package/lib/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
  17. package/lib/decaf-model/decorators/DecafParams.cjs +34 -0
  18. package/lib/decaf-model/decorators/DecafParams.d.ts +8 -0
  19. package/lib/decaf-model/decorators/DecafParams.js.map +1 -0
  20. package/lib/decaf-model/decorators/index.cjs +21 -0
  21. package/lib/decaf-model/decorators/index.d.ts +4 -0
  22. package/lib/decaf-model/decorators/index.js.map +1 -0
  23. package/lib/decaf-model/decorators/types.cjs +3 -0
  24. package/lib/decaf-model/decorators/types.d.ts +12 -0
  25. package/lib/decaf-model/decorators/types.js.map +1 -0
  26. package/lib/decaf-model/index.cjs +20 -0
  27. package/lib/decaf-model/index.d.ts +3 -0
  28. package/lib/decaf-model/index.js.map +1 -0
  29. package/lib/esm/decaf-model/DecafModelModule.d.ts +5 -0
  30. package/lib/esm/decaf-model/DecafModelModule.js +33 -0
  31. package/lib/esm/decaf-model/DecafModelModule.js.map +1 -0
  32. package/lib/esm/decaf-model/FromModelController.d.ts +15 -0
  33. package/lib/esm/{model-module.js → decaf-model/FromModelController.js} +57 -53
  34. package/lib/esm/decaf-model/FromModelController.js.map +1 -0
  35. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
  36. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js +40 -0
  37. package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
  38. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
  39. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js +24 -0
  40. package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
  41. package/lib/esm/decaf-model/decorators/DecafParams.d.ts +8 -0
  42. package/lib/esm/decaf-model/decorators/DecafParams.js +31 -0
  43. package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -0
  44. package/lib/esm/decaf-model/decorators/index.d.ts +4 -0
  45. package/lib/esm/decaf-model/decorators/index.js +5 -0
  46. package/lib/esm/decaf-model/decorators/index.js.map +1 -0
  47. package/lib/esm/decaf-model/decorators/types.d.ts +12 -0
  48. package/lib/esm/decaf-model/decorators/types.js +2 -0
  49. package/lib/esm/decaf-model/decorators/types.js.map +1 -0
  50. package/lib/esm/decaf-model/index.d.ts +3 -0
  51. package/lib/esm/decaf-model/index.js +4 -0
  52. package/lib/esm/decaf-model/index.js.map +1 -0
  53. package/lib/esm/index.d.ts +2 -2
  54. package/lib/esm/index.js +2 -2
  55. package/lib/esm/index.js.map +1 -1
  56. package/lib/esm/module.js +1 -1
  57. package/lib/esm/module.js.map +1 -1
  58. package/lib/index.cjs +2 -2
  59. package/lib/index.d.ts +2 -2
  60. package/lib/index.js.map +1 -1
  61. package/lib/module.cjs +2 -2
  62. package/lib/module.js.map +1 -1
  63. package/package.json +1 -1
  64. package/lib/decorators.cjs +0 -32
  65. package/lib/decorators.d.ts +0 -8
  66. package/lib/decorators.js.map +0 -1
  67. package/lib/esm/decorators.d.ts +0 -8
  68. package/lib/esm/decorators.js +0 -29
  69. package/lib/esm/decorators.js.map +0 -1
  70. package/lib/esm/model-module.d.ts +0 -8
  71. package/lib/esm/model-module.js.map +0 -1
  72. package/lib/model-module.d.ts +0 -8
  73. package/lib/model-module.js.map +0 -1
@@ -10,26 +10,23 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- var DecafModelModule_1;
14
- import { Body, Controller, Module, Param } from "@nestjs/common";
13
+ import { Body, Controller, Param } from "@nestjs/common";
15
14
  import { ApiBadRequestResponse, ApiBody, ApiCreatedResponse, ApiExtraModels, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiParam, ApiTags, ApiUnprocessableEntityResponse, getSchemaPath, } from "@nestjs/swagger";
16
- import { Adapter, Repository } from "@decaf-ts/core";
15
+ import { Repository } from "@decaf-ts/core";
17
16
  import { Model } from "@decaf-ts/decorator-validation";
18
17
  import { LoggedClass, Logging, toKebabCase } from "@decaf-ts/logging";
19
- import { RepoFactory } from "./RepoFactory.js";
20
- import { ApiOperationFromModel } from "./decorators.js";
21
- let DecafModelModule = class DecafModelModule {
22
- static { DecafModelModule_1 = this; }
23
- static get log() {
24
- if (!this._logger)
25
- this._logger = Logging.for(DecafModelModule_1);
26
- return this._logger;
27
- }
28
- static toModelController(ModelClazz) {
29
- const log = this.log.for(this.toModelController);
18
+ import { DBKeys, findPrimaryKey } from "@decaf-ts/db-decorators";
19
+ import { Metadata } from "@decaf-ts/decoration";
20
+ import { ApiOperationFromModel, ApiParamsFromModel, DecafParams, } from "./decorators/index.js";
21
+ import { RepoFactory } from "./../RepoFactory.js";
22
+ export class FromModelController {
23
+ static { this.log = Logging.for(FromModelController.name); }
24
+ static create(ModelClazz) {
25
+ const log = FromModelController.log.for(FromModelController.create);
30
26
  const tableName = Repository.table(ModelClazz);
31
27
  const routePath = toKebabCase(tableName);
32
28
  const modelClazzName = ModelClazz.name;
29
+ const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
33
30
  log.debug(`Creating controller for model: ${modelClazzName}`);
34
31
  let DynamicModelController = class DynamicModelController extends LoggedClass {
35
32
  constructor(repoFactory) {
@@ -58,7 +55,8 @@ let DecafModelModule = class DecafModelModule {
58
55
  log.info(`created new ${modelClazzName} with id ${created[this.pk]}`);
59
56
  return created;
60
57
  }
61
- async read(id) {
58
+ async read(pathParams) {
59
+ const { id } = pathParams;
62
60
  const log = this.log.for(this.read);
63
61
  let read;
64
62
  try {
@@ -86,12 +84,12 @@ let DecafModelModule = class DecafModelModule {
86
84
  log.info(`Successfully queried ${modelClazzName} using method "${method}"`);
87
85
  return results;
88
86
  }
89
- async update(data) {
87
+ async update(routeParams, body) {
90
88
  const log = this.log.for(this.update);
91
89
  let updated;
92
90
  try {
93
- log.info(`updating ${modelClazzName} with ${this.pk} ${data[this.pk]}`);
94
- updated = await this.repo.create(data);
91
+ log.info(`updating ${modelClazzName} with ${this.pk} ${body[this.pk]}`);
92
+ updated = await this.repo.create(body);
95
93
  }
96
94
  catch (e) {
97
95
  log.error(e);
@@ -99,15 +97,15 @@ let DecafModelModule = class DecafModelModule {
99
97
  }
100
98
  return updated;
101
99
  }
102
- async delete(id) {
100
+ async delete(routeParams) {
103
101
  const log = this.log.for(this.delete);
104
102
  let read;
105
103
  try {
106
- log.debug(`deleting ${modelClazzName} with ${this.pk} ${id}`);
107
- read = await this.repo.read(id);
104
+ log.debug(`deleting ${modelClazzName} with ${this.pk} ${routeParams}`);
105
+ read = await this.repo.read("id");
108
106
  }
109
107
  catch (e) {
110
- log.error(`Failed to delete ${modelClazzName} with id ${id}`, e);
108
+ log.error(`Failed to delete ${modelClazzName} with id ${"id"}`, e);
111
109
  throw e;
112
110
  }
113
111
  log.info(`deleted ${modelClazzName} with id ${read[this.pk]}`);
@@ -134,18 +132,18 @@ let DecafModelModule = class DecafModelModule {
134
132
  __metadata("design:returntype", Promise)
135
133
  ], DynamicModelController.prototype, "create", null);
136
134
  __decorate([
137
- ApiOperationFromModel(ModelClazz, "GET", ":id"),
135
+ ApiOperationFromModel(ModelClazz, "GET", path),
136
+ ApiParamsFromModel(apiProperties),
138
137
  ApiOperation({ summary: `Retrieve a ${modelClazzName} record by id.` }),
139
- ApiParam({ name: "id", description: "Primary key" }),
140
138
  ApiOkResponse({
141
139
  description: `${modelClazzName} retrieved successfully.`,
142
140
  }),
143
141
  ApiNotFoundResponse({
144
142
  description: `No ${modelClazzName} record matches the provided identifier.`,
145
143
  }),
146
- __param(0, Param("id")),
144
+ __param(0, Param()),
147
145
  __metadata("design:type", Function),
148
- __metadata("design:paramtypes", [String]),
146
+ __metadata("design:paramtypes", [Object]),
149
147
  __metadata("design:returntype", Promise)
150
148
  ], DynamicModelController.prototype, "read", null);
151
149
  __decorate([
@@ -164,7 +162,8 @@ let DecafModelModule = class DecafModelModule {
164
162
  __metadata("design:returntype", Promise)
165
163
  ], DynamicModelController.prototype, "query", null);
166
164
  __decorate([
167
- ApiOperationFromModel(ModelClazz, "PUT", ":id"),
165
+ ApiOperationFromModel(ModelClazz, "PUT", path),
166
+ ApiParamsFromModel(apiProperties),
168
167
  ApiOperation({
169
168
  summary: `Replace an existing ${modelClazzName} record with a new payload.`,
170
169
  }),
@@ -179,27 +178,25 @@ let DecafModelModule = class DecafModelModule {
179
178
  description: `No ${modelClazzName} record matches the provided identifier.`,
180
179
  }),
181
180
  ApiBadRequestResponse({ description: "Payload validation failed." }),
182
- __param(0, Body()),
181
+ __param(0, DecafParams(apiProperties)),
182
+ __param(1, Body()),
183
183
  __metadata("design:type", Function),
184
- __metadata("design:paramtypes", [Model]),
184
+ __metadata("design:paramtypes", [Object, Model]),
185
185
  __metadata("design:returntype", Promise)
186
186
  ], DynamicModelController.prototype, "update", null);
187
187
  __decorate([
188
- ApiOperationFromModel(ModelClazz, "DELETE", ":id"),
188
+ ApiOperationFromModel(ModelClazz, "DELETE", path),
189
+ ApiParamsFromModel(apiProperties),
189
190
  ApiOperation({ summary: `Delete a ${modelClazzName} record by id.` }),
190
- ApiParam({
191
- name: "id",
192
- description: `Primary key value of the ${modelClazzName} record to delete.`,
193
- }),
194
191
  ApiOkResponse({
195
192
  description: `${modelClazzName} record deleted successfully.`,
196
193
  }),
197
194
  ApiNotFoundResponse({
198
195
  description: `No ${modelClazzName} record matches the provided identifier.`,
199
196
  }),
200
- __param(0, Param("id")),
197
+ __param(0, DecafParams(apiProperties)),
201
198
  __metadata("design:type", Function),
202
- __metadata("design:paramtypes", [String]),
199
+ __metadata("design:paramtypes", [Object]),
203
200
  __metadata("design:returntype", Promise)
204
201
  ], DynamicModelController.prototype, "delete", null);
205
202
  DynamicModelController = __decorate([
@@ -210,21 +207,28 @@ let DecafModelModule = class DecafModelModule {
210
207
  ], DynamicModelController);
211
208
  return DynamicModelController;
212
209
  }
213
- static forRoot(flavour) {
214
- const log = this.log.for(this.forRoot);
215
- log.info(`Generating controllers for flavour...`);
216
- const trackedModels = Adapter.models(flavour);
217
- const controllers = trackedModels.map(this.toModelController.bind(this));
218
- log.info(`Generated ${controllers.length} controllers`);
219
- return {
220
- module: DecafModelModule_1,
221
- controllers,
222
- providers: [RepoFactory],
223
- };
210
+ static getRouteParametersFromModel(ModelClazz) {
211
+ const instance = new ModelClazz({});
212
+ const pk = (findPrimaryKey(instance)?.id || "id");
213
+ const composedKeyMetaKey = Repository.key(DBKeys.COMPOSED);
214
+ const composedKeys = Reflect.getMetadata(composedKeyMetaKey, instance, pk)?.args ??
215
+ [];
216
+ const keysToReturn = Array.isArray(composedKeys) && composedKeys.length > 0
217
+ ? [...composedKeys]
218
+ : [pk];
219
+ const description = Metadata.description(ModelClazz);
220
+ // remove duplicates while preserving order
221
+ const uniqueKeys = Array.from(new Set(keysToReturn));
222
+ const path = uniqueKeys.map((key) => `:${key}`).join("/");
223
+ const apiProperties = uniqueKeys.map((key) => {
224
+ return {
225
+ name: key,
226
+ description: Metadata.description(ModelClazz, key),
227
+ required: true,
228
+ type: String,
229
+ };
230
+ });
231
+ return { description, apiProperties, path };
224
232
  }
225
- };
226
- DecafModelModule = DecafModelModule_1 = __decorate([
227
- Module({})
228
- ], DecafModelModule);
229
- export { DecafModelModule };
230
- //# sourceMappingURL=model-module.js.map
233
+ }
234
+ //# sourceMappingURL=FromModelController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FromModelController.js","sourceRoot":"","sources":["../../../src/decaf-model/FromModelController.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,8BAA8B,EAC9B,aAAa,GACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAQ,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAoB,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAElB,WAAW,GACZ,8BAAqB;AACtB,OAAO,EAAE,WAAW,EAAE,4BAAuB;AAE7C,MAAM,OAAO,mBAAmB;aACN,QAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE7D,AAAP,MAAM,CAAC,MAAM,CAAuB,UAA+B;QACjE,MAAM,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC,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AC;QAC1D,MAAM,aAAa,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3C,OAAO;gBACL,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,QAAQ,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"}
@@ -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,40 @@
1
+ import { Metadata } from "@decaf-ts/decoration";
2
+ import { Delete, Get, Patch, Post, Put } from "@nestjs/common";
3
+ import { ApiExcludeEndpoint } from "@nestjs/swagger";
4
+ import { apply } from "@decaf-ts/reflection";
5
+ import { OperationKeys } from "@decaf-ts/db-decorators";
6
+ /**
7
+ * @description Determines if a given CRUD operation is blocked for a specific model constructor.
8
+ * @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`).
9
+ * @param {ModelConstructor<any>} ModelConstructor - The target model constructor whose metadata may include a blocking handler.
10
+ * @param {CrudOperations} op - The CRUD operation to evaluate (e.g., `OperationKeys.CREATE`, `OperationKeys.READ`, `OperationKeys.UPDATE`, `OperationKeys.DELETE`).
11
+ * @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
12
+ * @function isOperationBlocked
13
+ */
14
+ export function isOperationBlocked(ModelConstructor, op) {
15
+ const { handler, args } = (Metadata.get(ModelConstructor, OperationKeys.REFLECT + OperationKeys.BLOCK) || {});
16
+ // @ts-ignore
17
+ return !handler ? false : (handler(...args, op) ?? false);
18
+ }
19
+ /**
20
+ * @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.
21
+ * @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`.
22
+ * @param {ModelConstructor<any>} ModelConstructor - The model constructor used to resolve operation-blocking rules.
23
+ * @param {HttpVerbs} verb - The HTTP verb to map (e.g., `"GET" | "POST" | "PUT" | "PATCH" | "DELETE"`).
24
+ * @param {string} [path] - Optional route path passed through to the corresponding Nest HTTP method decorator.
25
+ * @return {MethodDecorator} A method decorator that either excludes the endpoint from Swagger (and route registration) or applies the correct HTTP decorator.
26
+ */
27
+ export function ApiOperationFromModel(ModelConstructor, verb, path) {
28
+ const httpToCrud = {
29
+ GET: [OperationKeys.READ, Get],
30
+ POST: [OperationKeys.CREATE, Post],
31
+ PUT: [OperationKeys.UPDATE, Put],
32
+ PATCH: [OperationKeys.UPDATE, Patch],
33
+ DELETE: [OperationKeys.DELETE, Delete],
34
+ };
35
+ const [crudOp, HttpMethodDecorator] = httpToCrud[verb];
36
+ return isOperationBlocked(ModelConstructor, crudOp)
37
+ ? apply(ApiExcludeEndpoint())
38
+ : apply(HttpMethodDecorator(path));
39
+ }
40
+ //# sourceMappingURL=ApiOperationFromModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiOperationFromModel.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/ApiOperationFromModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAkB,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAIxE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,gBAAuC,EACvC,EAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CACrC,gBAAuB,EACvB,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,KAAK,CAC5C,IAAI,EAAE,CAMN,CAAC;IAEF,aAAa;IACb,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,MAAM,UAAU,qBAAqB,CACnC,gBAAuC,EACvC,IAAe,EACf,IAAa;IAEb,MAAM,UAAU,GAGZ;QACF,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC;QAC9B,IAAI,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC;QAClC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC;QAChC,KAAK,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC;QACpC,MAAM,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,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,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAC7B,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -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 {new (...args:any[]) => any} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
10
+ * @return {MethodDecorator & ClassDecorator} 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,24 @@
1
+ import { applyDecorators } from "@nestjs/common";
2
+ import { ApiParam as ApiParamDec } from "@nestjs/swagger";
3
+ /**
4
+ * @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
5
+ * @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.
6
+ * @param {ApiParam[]} [props=[]] Array describing path parameters to be documented.
7
+ * @param {string} props[].name The parameter's name as it appears in the route template (e.g., `:id`).
8
+ * @param {string} [props[].description] Human-readable explanation of the parameter; defaults to `"Path parameter: <name>"`.
9
+ * @param {boolean} [props[].required=true] Whether the parameter is required; defaults to `true`.
10
+ * @param {new (...args:any[]) => any} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
11
+ * @return {MethodDecorator & ClassDecorator} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
12
+ * @function ApiParamsFromModel
13
+ */
14
+ export function ApiParamsFromModel(props = []) {
15
+ const decorators = props.map((p) => ApiParamDec({
16
+ name: p.name,
17
+ description: p.description ?? `Path parameter: ${p.name}`,
18
+ required: p.required ?? true,
19
+ // schema: { type: 'string' },
20
+ type: p.type ?? String,
21
+ }));
22
+ return applyDecorators(...decorators);
23
+ }
24
+ //# sourceMappingURL=ApiParamsFromModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiParamsFromModel.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/ApiParamsFromModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG1D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAoB,EAAE;IAEtB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACjC,WAAW,CAAC;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,eAAe,CAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
@@ -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,31 @@
1
+ import { createParamDecorator } from "@nestjs/common";
2
+ /**
3
+ * @description Creates a custom NestJS parameter decorator that extracts and returns route parameters ordered by a specific key sequence.
4
+ * @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.
5
+ * @template {string[]} TOrder - Represents the expected sequence of parameter names.
6
+ * @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.
7
+ * @param {ExecutionContext} ctx The NestJS execution context, used to retrieve the current HTTP request object.
8
+ * @return {DecafParamProps} An object containing:
9
+ * - `original`: the raw parameter map from `req.params`;
10
+ * - `ordered`: an array of parameter values in the requested order;
11
+ * - `order`: the effective order list used.
12
+ * @function OrderedParams
13
+ */
14
+ const OrderedParams = createParamDecorator((order, ctx) => {
15
+ const req = ctx.switchToHttp().getRequest();
16
+ const original = (req?.params ?? {});
17
+ const orderList = order ?? Object.keys(original);
18
+ const ordered = orderList.map((k) => original[k]);
19
+ return { original, ordered, order: orderList };
20
+ });
21
+ /**
22
+ * @description A higher-level decorator factory that leverages `OrderedParams` to extract route parameters in a specific order derived from a list of `ApiParam` definitions.
23
+ * @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.
24
+ * @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
25
+ * @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
26
+ */
27
+ export function DecafParams(props = []) {
28
+ const order = props.map((p) => p.name);
29
+ return OrderedParams(order);
30
+ }
31
+ //# sourceMappingURL=DecafParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecafParams.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/DecafParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AAGxE;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAAG,oBAAoB,CACxC,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,MAAM,UAAU,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,4 @@
1
+ export * from "./types";
2
+ export * from "./ApiOperationFromModel";
3
+ export * from "./ApiParamsFromModel";
4
+ export * from "./DecafParams";
@@ -0,0 +1,5 @@
1
+ export * from "./types.js";
2
+ export * from "./ApiOperationFromModel.js";
3
+ export * from "./ApiParamsFromModel.js";
4
+ export * from "./DecafParams.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/index.ts"],"names":[],"mappings":"AAAA,2BAAwB;AACxB,2CAAwC;AACxC,wCAAqC;AACrC,iCAA8B"}
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from "./decorators";
2
+ export * from "./DecafModelModule";
3
+ export * from "./FromModelController";
@@ -0,0 +1,4 @@
1
+ export * from "./decorators/index.js";
2
+ export * from "./DecafModelModule.js";
3
+ export * from "./FromModelController.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decaf-model/index.ts"],"names":[],"mappings":"AAAA,sCAA6B;AAC7B,sCAAmC;AACnC,yCAAsC"}
@@ -20,7 +20,6 @@
20
20
  * to easily import and use specific parts of the library as needed.
21
21
  */
22
22
  import "./decoration";
23
- export * from "./decorators";
24
23
  export * from "./constants";
25
24
  export * from "./decoration";
26
25
  export * from "./module";
@@ -28,11 +27,12 @@ export * from "./RepoFactory";
28
27
  export * from "./types";
29
28
  export * from "./utils";
30
29
  export * from "./factory";
30
+ export * from "./decaf-model";
31
31
  /**
32
32
  * Represents the current version of the ts-workspace module.
33
33
  * The actual version number is replaced during the build process.
34
34
  * @constant
35
35
  * @type {string}
36
36
  */
37
- export declare const VERSION = "0.0.6";
37
+ export declare const VERSION = "0.0.8";
38
38
  export declare const PACKAGE_NAME = "##PACKAGE_NAME##";
package/lib/esm/index.js CHANGED
@@ -21,7 +21,6 @@
21
21
  */
22
22
  import { Metadata } from "@decaf-ts/decoration";
23
23
  import "./decoration.js";
24
- export * from "./decorators.js";
25
24
  export * from "./constants.js";
26
25
  export * from "./decoration.js";
27
26
  export * from "./module.js";
@@ -29,13 +28,14 @@ export * from "./RepoFactory.js";
29
28
  export * from "./types.js";
30
29
  export * from "./utils.js";
31
30
  export * from "./factory/index.js";
31
+ export * from "./decaf-model/index.js";
32
32
  /**
33
33
  * Represents the current version of the ts-workspace module.
34
34
  * The actual version number is replaced during the build process.
35
35
  * @constant
36
36
  * @type {string}
37
37
  */
38
- export const VERSION = "0.0.6";
38
+ export const VERSION = "0.0.8";
39
39
  export const PACKAGE_NAME = "##PACKAGE_NAME##";
40
40
  Metadata.registerLibrary(PACKAGE_NAME, VERSION);
41
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,yBAAsB;AAEtB,gCAA6B;AAC7B,+BAA4B;AAC5B,gCAA6B;AAC7B,4BAAyB;AACzB,iCAA8B;AAC9B,2BAAwB;AACxB,2BAAwB;AACxB,mCAA0B;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,yBAAsB;AAEtB,+BAA4B;AAC5B,gCAA6B;AAC7B,4BAAyB;AACzB,iCAA8B;AAC9B,2BAAwB;AACxB,2BAAwB;AACxB,mCAA0B;AAC1B,uCAA8B;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAE/C,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
package/lib/esm/module.js CHANGED
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var DecafModule_1;
8
8
  import { Module } from "@nestjs/common";
9
9
  import { DecafCoreModule } from "./core-module.js";
10
- import { DecafModelModule } from "./model-module.js";
10
+ import { DecafModelModule } from "./decaf-model/index.js";
11
11
  /**
12
12
  * @publicApi
13
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAmC,MAAM,EAAQ,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,yBAAsB;AAChD,OAAO,EAAE,gBAAgB,EAAE,0BAAuB;AAElD;;GAEG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,OAA2B;QAE3B,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QAEpC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAOG,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnD,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,WAAW;IADvB,MAAM,CAAC,EAAE,CAAC;GACE,WAAW,CA2BvB"}
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAmC,MAAM,EAAQ,MAAM,gBAAgB,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,yBAAsB;AAChD,OAAO,EAAE,gBAAgB,EAAE,+BAAsB;AAEjD;;GAEG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,OAA2B;QAE3B,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;QAEpC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAOG,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnD,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,WAAW;IADvB,MAAM,CAAC,EAAE,CAAC;GACE,WAAW,CA2BvB"}
package/lib/index.cjs CHANGED
@@ -38,7 +38,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.PACKAGE_NAME = exports.VERSION = void 0;
39
39
  const decoration_1 = require("@decaf-ts/decoration");
40
40
  require("./decoration.cjs");
41
- __exportStar(require("./decorators.cjs"), exports);
42
41
  __exportStar(require("./constants.cjs"), exports);
43
42
  __exportStar(require("./decoration.cjs"), exports);
44
43
  __exportStar(require("./module.cjs"), exports);
@@ -46,13 +45,14 @@ __exportStar(require("./RepoFactory.cjs"), exports);
46
45
  __exportStar(require("./types.cjs"), exports);
47
46
  __exportStar(require("./utils.cjs"), exports);
48
47
  __exportStar(require("./factory/index.cjs"), exports);
48
+ __exportStar(require("./decaf-model/index.cjs"), exports);
49
49
  /**
50
50
  * Represents the current version of the ts-workspace module.
51
51
  * The actual version number is replaced during the build process.
52
52
  * @constant
53
53
  * @type {string}
54
54
  */
55
- exports.VERSION = "0.0.6";
55
+ exports.VERSION = "0.0.8";
56
56
  exports.PACKAGE_NAME = "##PACKAGE_NAME##";
57
57
  decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
58
58
  //# sourceMappingURL=index.js.map
package/lib/index.d.ts CHANGED
@@ -20,7 +20,6 @@
20
20
  * to easily import and use specific parts of the library as needed.
21
21
  */
22
22
  import "./decoration";
23
- export * from "./decorators";
24
23
  export * from "./constants";
25
24
  export * from "./decoration";
26
25
  export * from "./module";
@@ -28,11 +27,12 @@ export * from "./RepoFactory";
28
27
  export * from "./types";
29
28
  export * from "./utils";
30
29
  export * from "./factory";
30
+ export * from "./decaf-model";
31
31
  /**
32
32
  * Represents the current version of the ts-workspace module.
33
33
  * The actual version number is replaced during the build process.
34
34
  * @constant
35
35
  * @type {string}
36
36
  */
37
- export declare const VERSION = "0.0.6";
37
+ export declare const VERSION = "0.0.8";
38
38
  export declare const PACKAGE_NAME = "##PACKAGE_NAME##";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH,qDAAgD;AAChD,4BAAsB;AAEtB,mDAA6B;AAC7B,kDAA4B;AAC5B,mDAA6B;AAC7B,+CAAyB;AACzB,oDAA8B;AAC9B,8CAAwB;AACxB,8CAAwB;AACxB,sDAA0B;AAE1B;;;;;GAKG;AACU,QAAA,OAAO,GAAG,aAAa,CAAC;AACxB,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAE/C,qBAAQ,CAAC,eAAe,CAAC,oBAAY,EAAE,eAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH,qDAAgD;AAChD,4BAAsB;AAEtB,kDAA4B;AAC5B,mDAA6B;AAC7B,+CAAyB;AACzB,oDAA8B;AAC9B,8CAAwB;AACxB,8CAAwB;AACxB,sDAA0B;AAC1B,0DAA8B;AAE9B;;;;;GAKG;AACU,QAAA,OAAO,GAAG,aAAa,CAAC;AACxB,QAAA,YAAY,GAAG,kBAAkB,CAAC;AAE/C,qBAAQ,CAAC,eAAe,CAAC,oBAAY,EAAE,eAAO,CAAC,CAAC"}
package/lib/module.cjs CHANGED
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.DecafModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const core_module_1 = require("./core-module.cjs");
13
- const model_module_1 = require("./model-module.cjs");
13
+ const decaf_model_1 = require("./decaf-model/index.cjs");
14
14
  /**
15
15
  * @publicApi
16
16
  */
@@ -21,7 +21,7 @@ let DecafModule = DecafModule_1 = class DecafModule {
21
21
  const flavour = adapter.flavour;
22
22
  const imports = [core_module_1.DecafCoreModule.forRoot(options)];
23
23
  if (autoControllers) {
24
- imports.push(model_module_1.DecafModelModule.forRoot(flavour));
24
+ imports.push(decaf_model_1.DecafModelModule.forRoot(flavour));
25
25
  }
26
26
  return {
27
27
  module: DecafModule_1,
package/lib/module.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+E;AAE/E,mDAAgD;AAChD,qDA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C,CAAC,CAAC;QAClD,CAAC;QAED,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CA2BvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/for-nest",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "NestJS decaf integration",
5
5
  "type": "module",
6
6
  "exports": {