@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.
- package/README.md +22 -2
- package/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/decaf-model/DecafModelModule.cjs +36 -0
- package/lib/decaf-model/DecafModelModule.d.ts +5 -0
- package/lib/decaf-model/DecafModelModule.js.map +1 -0
- package/lib/{model-module.cjs → decaf-model/FromModelController.cjs} +58 -52
- package/lib/decaf-model/FromModelController.d.ts +15 -0
- package/lib/decaf-model/FromModelController.js.map +1 -0
- package/lib/decaf-model/decorators/ApiOperationFromModel.cjs +44 -0
- package/lib/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
- package/lib/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
- package/lib/decaf-model/decorators/ApiParamsFromModel.cjs +27 -0
- package/lib/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
- package/lib/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
- package/lib/decaf-model/decorators/DecafParams.cjs +34 -0
- package/lib/decaf-model/decorators/DecafParams.d.ts +8 -0
- package/lib/decaf-model/decorators/DecafParams.js.map +1 -0
- package/lib/decaf-model/decorators/index.cjs +21 -0
- package/lib/decaf-model/decorators/index.d.ts +4 -0
- package/lib/decaf-model/decorators/index.js.map +1 -0
- package/lib/decaf-model/decorators/types.cjs +3 -0
- package/lib/decaf-model/decorators/types.d.ts +12 -0
- package/lib/decaf-model/decorators/types.js.map +1 -0
- package/lib/{decorators → decaf-model}/index.cjs +3 -2
- package/lib/decaf-model/index.d.ts +3 -0
- package/lib/decaf-model/index.js.map +1 -0
- package/lib/decoration.cjs +10 -10
- package/lib/decoration.js.map +1 -1
- package/lib/esm/decaf-model/DecafModelModule.d.ts +5 -0
- package/lib/esm/decaf-model/DecafModelModule.js +33 -0
- package/lib/esm/decaf-model/DecafModelModule.js.map +1 -0
- package/lib/esm/decaf-model/FromModelController.d.ts +15 -0
- package/lib/esm/{model-module.js → decaf-model/FromModelController.js} +58 -53
- package/lib/esm/decaf-model/FromModelController.js.map +1 -0
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.d.ts +21 -0
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js +40 -0
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js.map +1 -0
- package/lib/esm/decaf-model/decorators/ApiParamsFromModel.d.ts +13 -0
- package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js +24 -0
- package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js.map +1 -0
- package/lib/esm/decaf-model/decorators/DecafParams.d.ts +8 -0
- package/lib/esm/decaf-model/decorators/DecafParams.js +31 -0
- package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -0
- package/lib/esm/decaf-model/decorators/index.d.ts +4 -0
- package/lib/esm/decaf-model/decorators/index.js +5 -0
- package/lib/esm/decaf-model/decorators/index.js.map +1 -0
- package/lib/esm/decaf-model/decorators/types.d.ts +12 -0
- package/lib/esm/decaf-model/decorators/types.js +2 -0
- package/lib/esm/decaf-model/decorators/types.js.map +1 -0
- package/lib/esm/decaf-model/index.d.ts +3 -0
- package/lib/esm/decaf-model/index.js +4 -0
- package/lib/esm/decaf-model/index.js.map +1 -0
- package/lib/esm/decoration.js +1 -1
- package/lib/esm/decoration.js.map +1 -1
- package/lib/esm/index.d.ts +3 -3
- package/lib/esm/index.js +3 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/module.js +1 -1
- package/lib/esm/module.js.map +1 -1
- package/lib/index.cjs +3 -3
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/lib/module.cjs +2 -2
- package/lib/module.js.map +1 -1
- package/package.json +2 -3
- package/lib/decorators/ApiProperty.cjs +0 -63
- package/lib/decorators/ApiProperty.d.ts +0 -27
- package/lib/decorators/ApiProperty.js.map +0 -1
- package/lib/decorators/helpers.cjs +0 -140
- package/lib/decorators/helpers.d.ts +0 -8
- package/lib/decorators/helpers.js.map +0 -1
- package/lib/decorators/index.d.ts +0 -2
- package/lib/decorators/index.js.map +0 -1
- package/lib/decorators.cjs +0 -33
- package/lib/decorators.d.ts +0 -10
- package/lib/decorators.js.map +0 -1
- package/lib/esm/decorators/ApiProperty.d.ts +0 -27
- package/lib/esm/decorators/ApiProperty.js +0 -57
- package/lib/esm/decorators/ApiProperty.js.map +0 -1
- package/lib/esm/decorators/helpers.d.ts +0 -8
- package/lib/esm/decorators/helpers.js +0 -132
- package/lib/esm/decorators/helpers.js.map +0 -1
- package/lib/esm/decorators/index.d.ts +0 -2
- package/lib/esm/decorators/index.js +0 -3
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/decorators.d.ts +0 -10
- package/lib/esm/decorators.js +0 -29
- package/lib/esm/decorators.js.map +0 -1
- package/lib/esm/model-module.d.ts +0 -8
- package/lib/esm/model-module.js.map +0 -1
- package/lib/model-module.d.ts +0 -8
- package/lib/model-module.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecafModelModule.js","sourceRoot":"","sources":["../../../src/decaf-model/DecafModelModule.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,4BAAuB;AAC7C,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;;aACH,QAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,CAAC,AAArC,CAAsC;IAEjE,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,GAAG,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QAElD,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAElE,GAAG,CAAC,IAAI,CAAC,aAAa,WAAW,CAAC,MAAM,cAAc,CAAC,CAAC;QAExD,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,WAAW;YACX,SAAS,EAAE,CAAC,WAAW,CAAC;SACzB,CAAC;IACJ,CAAC;;AAjBU,gBAAgB;IAD5B,MAAM,CAAC,EAAE,CAAC;GACE,gBAAgB,CAkB5B"}
|
|
@@ -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
|
+
}
|
|
@@ -10,26 +10,24 @@ 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
|
-
|
|
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 {
|
|
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 {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
33
31
|
log.debug(`Creating controller for model: ${modelClazzName}`);
|
|
34
32
|
let DynamicModelController = class DynamicModelController extends LoggedClass {
|
|
35
33
|
constructor(repoFactory) {
|
|
@@ -58,7 +56,8 @@ let DecafModelModule = class DecafModelModule {
|
|
|
58
56
|
log.info(`created new ${modelClazzName} with id ${created[this.pk]}`);
|
|
59
57
|
return created;
|
|
60
58
|
}
|
|
61
|
-
async read(
|
|
59
|
+
async read(pathParams) {
|
|
60
|
+
const { id } = pathParams;
|
|
62
61
|
const log = this.log.for(this.read);
|
|
63
62
|
let read;
|
|
64
63
|
try {
|
|
@@ -86,12 +85,12 @@ let DecafModelModule = class DecafModelModule {
|
|
|
86
85
|
log.info(`Successfully queried ${modelClazzName} using method "${method}"`);
|
|
87
86
|
return results;
|
|
88
87
|
}
|
|
89
|
-
async update(
|
|
88
|
+
async update(routeParams, body) {
|
|
90
89
|
const log = this.log.for(this.update);
|
|
91
90
|
let updated;
|
|
92
91
|
try {
|
|
93
|
-
log.info(`updating ${modelClazzName} with ${this.pk} ${
|
|
94
|
-
updated = await this.repo.create(
|
|
92
|
+
log.info(`updating ${modelClazzName} with ${this.pk} ${body[this.pk]}`);
|
|
93
|
+
updated = await this.repo.create(body);
|
|
95
94
|
}
|
|
96
95
|
catch (e) {
|
|
97
96
|
log.error(e);
|
|
@@ -99,15 +98,15 @@ let DecafModelModule = class DecafModelModule {
|
|
|
99
98
|
}
|
|
100
99
|
return updated;
|
|
101
100
|
}
|
|
102
|
-
async delete(
|
|
101
|
+
async delete(routeParams) {
|
|
103
102
|
const log = this.log.for(this.delete);
|
|
104
103
|
let read;
|
|
105
104
|
try {
|
|
106
|
-
log.debug(`deleting ${modelClazzName} with ${this.pk} ${
|
|
107
|
-
read = await this.repo.read(id);
|
|
105
|
+
log.debug(`deleting ${modelClazzName} with ${this.pk} ${routeParams}`);
|
|
106
|
+
read = await this.repo.read("id");
|
|
108
107
|
}
|
|
109
108
|
catch (e) {
|
|
110
|
-
log.error(`Failed to delete ${modelClazzName} with id ${id}`, e);
|
|
109
|
+
log.error(`Failed to delete ${modelClazzName} with id ${"id"}`, e);
|
|
111
110
|
throw e;
|
|
112
111
|
}
|
|
113
112
|
log.info(`deleted ${modelClazzName} with id ${read[this.pk]}`);
|
|
@@ -134,18 +133,18 @@ let DecafModelModule = class DecafModelModule {
|
|
|
134
133
|
__metadata("design:returntype", Promise)
|
|
135
134
|
], DynamicModelController.prototype, "create", null);
|
|
136
135
|
__decorate([
|
|
137
|
-
ApiOperationFromModel(ModelClazz, "GET",
|
|
136
|
+
ApiOperationFromModel(ModelClazz, "GET", path),
|
|
137
|
+
ApiParamsFromModel(apiProperties),
|
|
138
138
|
ApiOperation({ summary: `Retrieve a ${modelClazzName} record by id.` }),
|
|
139
|
-
ApiParam({ name: "id", description: "Primary key" }),
|
|
140
139
|
ApiOkResponse({
|
|
141
140
|
description: `${modelClazzName} retrieved successfully.`,
|
|
142
141
|
}),
|
|
143
142
|
ApiNotFoundResponse({
|
|
144
143
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
145
144
|
}),
|
|
146
|
-
__param(0, Param(
|
|
145
|
+
__param(0, Param()),
|
|
147
146
|
__metadata("design:type", Function),
|
|
148
|
-
__metadata("design:paramtypes", [
|
|
147
|
+
__metadata("design:paramtypes", [Object]),
|
|
149
148
|
__metadata("design:returntype", Promise)
|
|
150
149
|
], DynamicModelController.prototype, "read", null);
|
|
151
150
|
__decorate([
|
|
@@ -164,7 +163,8 @@ let DecafModelModule = class DecafModelModule {
|
|
|
164
163
|
__metadata("design:returntype", Promise)
|
|
165
164
|
], DynamicModelController.prototype, "query", null);
|
|
166
165
|
__decorate([
|
|
167
|
-
ApiOperationFromModel(ModelClazz, "PUT",
|
|
166
|
+
ApiOperationFromModel(ModelClazz, "PUT", path),
|
|
167
|
+
ApiParamsFromModel(apiProperties),
|
|
168
168
|
ApiOperation({
|
|
169
169
|
summary: `Replace an existing ${modelClazzName} record with a new payload.`,
|
|
170
170
|
}),
|
|
@@ -179,27 +179,25 @@ let DecafModelModule = class DecafModelModule {
|
|
|
179
179
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
180
180
|
}),
|
|
181
181
|
ApiBadRequestResponse({ description: "Payload validation failed." }),
|
|
182
|
-
__param(0,
|
|
182
|
+
__param(0, DecafParams(apiProperties)),
|
|
183
|
+
__param(1, Body()),
|
|
183
184
|
__metadata("design:type", Function),
|
|
184
|
-
__metadata("design:paramtypes", [Model]),
|
|
185
|
+
__metadata("design:paramtypes", [Object, Model]),
|
|
185
186
|
__metadata("design:returntype", Promise)
|
|
186
187
|
], DynamicModelController.prototype, "update", null);
|
|
187
188
|
__decorate([
|
|
188
|
-
ApiOperationFromModel(ModelClazz, "DELETE",
|
|
189
|
+
ApiOperationFromModel(ModelClazz, "DELETE", path),
|
|
190
|
+
ApiParamsFromModel(apiProperties),
|
|
189
191
|
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
192
|
ApiOkResponse({
|
|
195
193
|
description: `${modelClazzName} record deleted successfully.`,
|
|
196
194
|
}),
|
|
197
195
|
ApiNotFoundResponse({
|
|
198
196
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
199
197
|
}),
|
|
200
|
-
__param(0,
|
|
198
|
+
__param(0, DecafParams(apiProperties)),
|
|
201
199
|
__metadata("design:type", Function),
|
|
202
|
-
__metadata("design:paramtypes", [
|
|
200
|
+
__metadata("design:paramtypes", [Object]),
|
|
203
201
|
__metadata("design:returntype", Promise)
|
|
204
202
|
], DynamicModelController.prototype, "delete", null);
|
|
205
203
|
DynamicModelController = __decorate([
|
|
@@ -210,21 +208,28 @@ let DecafModelModule = class DecafModelModule {
|
|
|
210
208
|
], DynamicModelController);
|
|
211
209
|
return DynamicModelController;
|
|
212
210
|
}
|
|
213
|
-
static
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
211
|
+
static getRouteParametersFromModel(ModelClazz) {
|
|
212
|
+
const instance = new ModelClazz({});
|
|
213
|
+
const pk = (findPrimaryKey(instance)?.id || "id");
|
|
214
|
+
const composedKeyMetaKey = Repository.key(DBKeys.COMPOSED);
|
|
215
|
+
const composedKeys = Reflect.getMetadata(composedKeyMetaKey, instance, pk)?.args ??
|
|
216
|
+
[];
|
|
217
|
+
const keysToReturn = Array.isArray(composedKeys) && composedKeys.length > 0
|
|
218
|
+
? [...composedKeys]
|
|
219
|
+
: [pk];
|
|
220
|
+
const description = Metadata.description(ModelClazz);
|
|
221
|
+
// remove duplicates while preserving order
|
|
222
|
+
const uniqueKeys = Array.from(new Set(keysToReturn));
|
|
223
|
+
const path = uniqueKeys.map((key) => `:${key}`).join("/");
|
|
224
|
+
const apiProperties = uniqueKeys.map((key) => {
|
|
225
|
+
return {
|
|
226
|
+
name: key,
|
|
227
|
+
description: Metadata.description(ModelClazz, key),
|
|
228
|
+
required: true,
|
|
229
|
+
type: String,
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
return { description, apiProperties, path };
|
|
224
233
|
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
Module({})
|
|
228
|
-
], DecafModelModule);
|
|
229
|
-
export { DecafModelModule };
|
|
230
|
-
//# sourceMappingURL=model-module.js.map
|
|
234
|
+
}
|
|
235
|
+
//# 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,EA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AM,YAAY,GAChB,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;YACpD,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC;YACnB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAEX,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAErD,2CAA2C;QAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;QAErD,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;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-expect-error TODO @pedro
|
|
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,+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,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 {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,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 {Constructor<any>} [props[].type=String] Constructor/type used by Swagger to infer schema (e.g., `String`, `Number`, `UUID`, custom class).
|
|
11
|
+
* @return {any} 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 @@
|
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decaf-model/index.ts"],"names":[],"mappings":"AAAA,sCAA6B;AAC7B,sCAAmC;AACnC,yCAAsC"}
|
package/lib/esm/decoration.js
CHANGED
|
@@ -2,8 +2,8 @@ import { InjectablesKeys, } from "@decaf-ts/injectable-decorators";
|
|
|
2
2
|
import { Inject, Injectable, Scope } from "@nestjs/common";
|
|
3
3
|
import { Decoration, DecorationKeys } from "@decaf-ts/decoration";
|
|
4
4
|
import { ValidationKeys } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { ApiProperty } from "./decorators/ApiProperty.js";
|
|
6
5
|
import { PersistenceKeys } from "@decaf-ts/core";
|
|
6
|
+
import { ApiProperty } from "@nestjs/swagger";
|
|
7
7
|
Decoration.for(InjectablesKeys.INJECTABLE)
|
|
8
8
|
.extend({
|
|
9
9
|
decorator: function nestInjectable(category, cfg) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoration.js","sourceRoot":"","sources":["../../src/decoration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAe,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"decoration.js","sourceRoot":"","sources":["../../src/decoration.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAEhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAe,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC;KACvC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,cAAc,CAChC,QAA8B,EAC9B,GAAqB;QAErB,OAAO,UAAU,CAAC;YAChB,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,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,UAAU,CAAC,GAAG,CAAC,eAAe,CAAC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S,CAAC,IAAY;QACxC,OAAO,WAAW,CAAC;YACjB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;CACF,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,UAAU,CAAC,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC;KACvC,MAAM,CAAC;IACN,SAAS,EAAE,SAAS,cAAc,CAAC,WAAmB;QACpD,OAAO,WAAW,CAAC;YACjB,WAAW,EAAE,WAAW;SACzB,CAAC,CAAC;IACL,CAAC;CACF,CAAC;KACD,KAAK,EAAE,CAAC"}
|
package/lib/esm/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.
|
|
38
|
-
export declare const PACKAGE_NAME = "
|
|
37
|
+
export declare const VERSION = "0.0.8";
|
|
38
|
+
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
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.
|
|
39
|
-
export const PACKAGE_NAME = "
|
|
38
|
+
export const VERSION = "0.0.8";
|
|
39
|
+
export const PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
40
40
|
Metadata.registerLibrary(PACKAGE_NAME, VERSION);
|
|
41
41
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -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
|
|
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,aAAa,CAAC;AAE1C,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
|
|
10
|
+
import { DecafModelModule } from "./decaf-model/index.js";
|
|
11
11
|
/**
|
|
12
12
|
* @publicApi
|
|
13
13
|
*/
|
package/lib/esm/module.js.map
CHANGED
|
@@ -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
|
|
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.
|
|
56
|
-
exports.PACKAGE_NAME = "
|
|
55
|
+
exports.VERSION = "0.0.8";
|
|
56
|
+
exports.PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
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.
|
|
38
|
-
export declare const PACKAGE_NAME = "
|
|
37
|
+
export declare const VERSION = "0.0.8";
|
|
38
|
+
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|
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,
|
|
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,aAAa,CAAC;AAE1C,qBAAQ,CAAC,eAAe,CAAC,oBAAY,EAAE,eAAO,CAAC,CAAC"}
|