@decaf-ts/for-nest 0.1.3 → 0.1.5
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 +1 -1
- 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/constants.cjs +3 -1
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js.map +1 -1
- package/lib/decaf-model/DecafModelModule.cjs +22 -3
- package/lib/decaf-model/DecafModelModule.d.ts +3 -2
- package/lib/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/decaf-model/FromModelController.cjs +80 -20
- package/lib/decaf-model/FromModelController.d.ts +49 -0
- package/lib/decaf-model/FromModelController.js.map +1 -1
- package/lib/esm/constants.d.ts +2 -0
- package/lib/esm/constants.js +2 -0
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/decaf-model/DecafModelModule.d.ts +3 -2
- package/lib/esm/decaf-model/DecafModelModule.js +22 -3
- package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/esm/decaf-model/FromModelController.d.ts +49 -0
- package/lib/esm/decaf-model/FromModelController.js +81 -21
- package/lib/esm/decaf-model/FromModelController.js.map +1 -1
- package/lib/esm/index.d.ts +3 -2
- package/lib/esm/index.js +3 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.d.ts +53 -0
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js +73 -0
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js.map +1 -0
- package/lib/esm/interceptors/index.d.ts +1 -0
- package/lib/esm/interceptors/index.js +2 -0
- package/lib/esm/interceptors/index.js.map +1 -0
- package/lib/esm/module.js +1 -1
- package/lib/esm/module.js.map +1 -1
- package/lib/esm/request/DecafHandlerExecutor.d.ts +52 -0
- package/lib/esm/request/DecafHandlerExecutor.js +77 -0
- package/lib/esm/request/DecafHandlerExecutor.js.map +1 -0
- package/lib/esm/request/DecafRequestContext.d.ts +26 -0
- package/lib/esm/request/DecafRequestContext.js +44 -0
- package/lib/esm/request/DecafRequestContext.js.map +1 -0
- package/lib/esm/request/index.d.ts +2 -0
- package/lib/esm/request/index.js +3 -0
- package/lib/esm/request/index.js.map +1 -0
- package/lib/esm/types.d.ts +9 -0
- package/lib/index.cjs +3 -2
- package/lib/index.d.ts +3 -2
- package/lib/index.js.map +1 -1
- package/lib/interceptors/DecafRequestHandlerInterceptor.cjs +76 -0
- package/lib/interceptors/DecafRequestHandlerInterceptor.d.ts +53 -0
- package/lib/interceptors/DecafRequestHandlerInterceptor.js.map +1 -0
- package/lib/interceptors/index.cjs +18 -0
- package/lib/interceptors/index.d.ts +1 -0
- package/lib/interceptors/index.js.map +1 -0
- package/lib/module.cjs +1 -1
- package/lib/module.js.map +1 -1
- package/lib/request/DecafHandlerExecutor.cjs +80 -0
- package/lib/request/DecafHandlerExecutor.d.ts +52 -0
- package/lib/request/DecafHandlerExecutor.js.map +1 -0
- package/lib/request/DecafRequestContext.cjs +47 -0
- package/lib/request/DecafRequestContext.d.ts +26 -0
- package/lib/request/DecafRequestContext.js.map +1 -0
- package/lib/request/index.cjs +19 -0
- package/lib/request/index.d.ts +2 -0
- package/lib/request/index.js.map +1 -0
- package/lib/types.d.ts +9 -0
- package/package.json +1 -1
- package/lib/RepoFactory.cjs +0 -27
- package/lib/RepoFactory.d.ts +0 -6
- package/lib/RepoFactory.js.map +0 -1
- package/lib/esm/RepoFactory.d.ts +0 -6
- package/lib/esm/RepoFactory.js +0 -24
- package/lib/esm/RepoFactory.js.map +0 -1
|
@@ -15,12 +15,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.FromModelController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const core_1 = require("@decaf-ts/core");
|
|
18
19
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
19
20
|
const logging_1 = require("@decaf-ts/logging");
|
|
20
21
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
21
22
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
22
23
|
const decorators_1 = require("./decorators/index.cjs");
|
|
23
|
-
const
|
|
24
|
+
const request_1 = require("./../request/index.cjs");
|
|
25
|
+
const constants_1 = require("./../constants.cjs");
|
|
26
|
+
/**
|
|
27
|
+
* @description
|
|
28
|
+
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
29
|
+
*
|
|
30
|
+
* @summary
|
|
31
|
+
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
32
|
+
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
33
|
+
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
34
|
+
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
35
|
+
*
|
|
36
|
+
* @template T The {@link Model} type associated with the generated controller.
|
|
37
|
+
*
|
|
38
|
+
* @param ModelClazz The model class to generate the controller from.
|
|
39
|
+
*
|
|
40
|
+
* @class FromModelController
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* // Given a Decaf Model:
|
|
45
|
+
* class User extends Model<User> {
|
|
46
|
+
* id!: string;
|
|
47
|
+
* name!: string;
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* // Register controller:
|
|
51
|
+
* const UserController = FromModelController.create(User);
|
|
52
|
+
*
|
|
53
|
+
* // NestJS will expose:
|
|
54
|
+
* // POST /user
|
|
55
|
+
* // GET /user/:id
|
|
56
|
+
* // GET /user/query/:method
|
|
57
|
+
* // PUT /user/:id
|
|
58
|
+
* // DELETE /user/:id
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @mermaid
|
|
62
|
+
* sequenceDiagram
|
|
63
|
+
* participant Client
|
|
64
|
+
* participant Controller
|
|
65
|
+
* participant Repo
|
|
66
|
+
* participant DB
|
|
67
|
+
*
|
|
68
|
+
* Client->>Controller: HTTP Request
|
|
69
|
+
* Controller->>Repo: Resolve repository for Model
|
|
70
|
+
* Repo->>DB: Execute DB operation
|
|
71
|
+
* DB-->>Repo: DB Result
|
|
72
|
+
* Repo-->>Controller: Model Instance(s)
|
|
73
|
+
* Controller-->>Client: JSON Response
|
|
74
|
+
*/
|
|
24
75
|
class FromModelController {
|
|
25
76
|
static { this.log = logging_1.Logging.for(FromModelController.name); }
|
|
26
77
|
static create(ModelClazz) {
|
|
@@ -32,24 +83,26 @@ class FromModelController {
|
|
|
32
83
|
const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
33
84
|
log.debug(`Creating controller for model: ${modelClazzName}`);
|
|
34
85
|
let DynamicModelController = class DynamicModelController extends logging_1.LoggedClass {
|
|
35
|
-
constructor(
|
|
86
|
+
constructor(clientContext) {
|
|
36
87
|
super();
|
|
37
|
-
this.
|
|
88
|
+
this.clientContext = clientContext;
|
|
89
|
+
this.pk = decorator_validation_1.Model.pk(ModelClazz);
|
|
38
90
|
log.info(`Registering dynamic controller for model: ${modelClazzName} route: /${routePath}`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
91
|
+
}
|
|
92
|
+
get repository() {
|
|
93
|
+
if (!this._repo)
|
|
94
|
+
this._repo = core_1.Repository.forModel(ModelClazz);
|
|
95
|
+
const adapterOptions = this.clientContext.get(constants_1.DECAF_ADAPTER_OPTIONS);
|
|
96
|
+
if (adapterOptions)
|
|
97
|
+
return this._repo.for(adapterOptions);
|
|
98
|
+
return this._repo;
|
|
46
99
|
}
|
|
47
100
|
async create(data) {
|
|
48
101
|
const log = this.log.for(this.create);
|
|
49
102
|
log.verbose(`creating new ${modelClazzName}`);
|
|
50
103
|
let created;
|
|
51
104
|
try {
|
|
52
|
-
created = await this.
|
|
105
|
+
created = await this.repository.create(data);
|
|
53
106
|
}
|
|
54
107
|
catch (e) {
|
|
55
108
|
log.error(`Failed to create new ${modelClazzName}`, e);
|
|
@@ -59,12 +112,14 @@ class FromModelController {
|
|
|
59
112
|
return created;
|
|
60
113
|
}
|
|
61
114
|
async read(pathParams) {
|
|
62
|
-
const
|
|
115
|
+
const id = pathParams[this.pk];
|
|
116
|
+
if (typeof id === "undefined")
|
|
117
|
+
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
63
118
|
const log = this.log.for(this.read);
|
|
64
119
|
let read;
|
|
65
120
|
try {
|
|
66
121
|
log.debug(`reading ${modelClazzName} with ${this.pk} ${id}`);
|
|
67
|
-
read = await this.
|
|
122
|
+
read = await this.repository.read(id);
|
|
68
123
|
}
|
|
69
124
|
catch (e) {
|
|
70
125
|
log.error(`Failed to read ${modelClazzName} with id ${id}`, e);
|
|
@@ -78,7 +133,7 @@ class FromModelController {
|
|
|
78
133
|
let results;
|
|
79
134
|
try {
|
|
80
135
|
log.debug(`Querying ${modelClazzName} using method "${method}"`);
|
|
81
|
-
results = await this.
|
|
136
|
+
results = await this.repository[method]();
|
|
82
137
|
}
|
|
83
138
|
catch (e) {
|
|
84
139
|
log.error(`Failed to query ${modelClazzName} using method "${method}"`, e);
|
|
@@ -92,7 +147,7 @@ class FromModelController {
|
|
|
92
147
|
let updated;
|
|
93
148
|
try {
|
|
94
149
|
log.info(`updating ${modelClazzName} with ${this.pk} ${body[this.pk]}`);
|
|
95
|
-
updated = await this.
|
|
150
|
+
updated = await this.repository.create(body);
|
|
96
151
|
}
|
|
97
152
|
catch (e) {
|
|
98
153
|
log.error(e);
|
|
@@ -100,12 +155,17 @@ class FromModelController {
|
|
|
100
155
|
}
|
|
101
156
|
return updated;
|
|
102
157
|
}
|
|
103
|
-
async delete(
|
|
158
|
+
async delete(pathParams) {
|
|
159
|
+
const id = pathParams[this.pk];
|
|
160
|
+
if (typeof id === "undefined")
|
|
161
|
+
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
104
162
|
const log = this.log.for(this.delete);
|
|
163
|
+
if (typeof id === "undefined")
|
|
164
|
+
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
105
165
|
let read;
|
|
106
166
|
try {
|
|
107
|
-
log.debug(`deleting ${modelClazzName} with ${this.pk} ${
|
|
108
|
-
read = await this.
|
|
167
|
+
log.debug(`deleting ${modelClazzName} with ${this.pk} ${pathParams}`);
|
|
168
|
+
read = await this.repository.delete("id");
|
|
109
169
|
}
|
|
110
170
|
catch (e) {
|
|
111
171
|
log.error(`Failed to delete ${modelClazzName} with id ${"id"}`, e);
|
|
@@ -197,7 +257,7 @@ class FromModelController {
|
|
|
197
257
|
(0, swagger_1.ApiNotFoundResponse)({
|
|
198
258
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
199
259
|
}),
|
|
200
|
-
__param(0, (0,
|
|
260
|
+
__param(0, (0, common_1.Param)()),
|
|
201
261
|
__metadata("design:type", Function),
|
|
202
262
|
__metadata("design:paramtypes", [Object]),
|
|
203
263
|
__metadata("design:returntype", Promise)
|
|
@@ -206,7 +266,7 @@ class FromModelController {
|
|
|
206
266
|
(0, common_1.Controller)(routePath),
|
|
207
267
|
(0, swagger_1.ApiTags)(modelClazzName),
|
|
208
268
|
(0, swagger_1.ApiExtraModels)(ModelClazz),
|
|
209
|
-
__metadata("design:paramtypes", [
|
|
269
|
+
__metadata("design:paramtypes", [request_1.DecafRequestContext])
|
|
210
270
|
], DynamicModelController);
|
|
211
271
|
return DynamicModelController;
|
|
212
272
|
}
|
|
@@ -1,4 +1,53 @@
|
|
|
1
1
|
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
5
|
+
*
|
|
6
|
+
* @summary
|
|
7
|
+
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
8
|
+
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
9
|
+
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
10
|
+
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
11
|
+
*
|
|
12
|
+
* @template T The {@link Model} type associated with the generated controller.
|
|
13
|
+
*
|
|
14
|
+
* @param ModelClazz The model class to generate the controller from.
|
|
15
|
+
*
|
|
16
|
+
* @class FromModelController
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Given a Decaf Model:
|
|
21
|
+
* class User extends Model<User> {
|
|
22
|
+
* id!: string;
|
|
23
|
+
* name!: string;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Register controller:
|
|
27
|
+
* const UserController = FromModelController.create(User);
|
|
28
|
+
*
|
|
29
|
+
* // NestJS will expose:
|
|
30
|
+
* // POST /user
|
|
31
|
+
* // GET /user/:id
|
|
32
|
+
* // GET /user/query/:method
|
|
33
|
+
* // PUT /user/:id
|
|
34
|
+
* // DELETE /user/:id
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @mermaid
|
|
38
|
+
* sequenceDiagram
|
|
39
|
+
* participant Client
|
|
40
|
+
* participant Controller
|
|
41
|
+
* participant Repo
|
|
42
|
+
* participant DB
|
|
43
|
+
*
|
|
44
|
+
* Client->>Controller: HTTP Request
|
|
45
|
+
* Controller->>Repo: Resolve repository for Model
|
|
46
|
+
* Repo->>DB: Execute DB operation
|
|
47
|
+
* DB-->>Repo: DB Result
|
|
48
|
+
* Repo-->>Controller: Model Instance(s)
|
|
49
|
+
* Controller-->>Client: JSON Response
|
|
50
|
+
*/
|
|
2
51
|
export declare class FromModelController {
|
|
3
52
|
private static readonly log;
|
|
4
53
|
static create<T extends Model<any>>(ModelClazz: ModelConstructor<T>): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromModelController.js","sourceRoot":"","sources":["../../src/decaf-model/FromModelController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,6CAYyB;
|
|
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,2DAAkE;AAClE,qDAAgD;AAChD,uDAKsB;AACtB,oDAAiD;AACjD,kDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,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,4BAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC9C,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,cAAc,EAAE,CAAC,CAAC;QAE9D,IAGM,sBAAsB,GAH5B,MAGM,sBAAuB,SAAQ,qBAAW;YAI9C,YAAoB,aAAkC;gBACpD,KAAK,EAAE,CAAC;gBADU,kBAAa,GAAb,aAAa,CAAqB;gBAFrC,OAAE,GAAW,4BAAK,CAAC,EAAE,CAAC,UAAU,CAAW,CAAC;gBAI3D,GAA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AC,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,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;;AAnOH,kDAoOC"}
|
package/lib/esm/constants.d.ts
CHANGED
package/lib/esm/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export const DECAF_MODULE_OPTIONS = "DecafModuleOptions";
|
|
2
2
|
export const DECAF_ADAPTER_ID = "DecafAdapter";
|
|
3
|
+
export const DECAF_HANDLERS = Symbol("DecafHandlers");
|
|
4
|
+
export const DECAF_ADAPTER_OPTIONS = Symbol("DecafAdapterForOptions");
|
|
3
5
|
//# sourceMappingURL=constants.js.map
|
package/lib/esm/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DynamicModule } from "@nestjs/common";
|
|
1
|
+
import { DynamicModule, Type } from "@nestjs/common";
|
|
2
|
+
import { type DecafRequestHandler } from "../types";
|
|
2
3
|
export declare class DecafModelModule {
|
|
3
4
|
private static readonly log;
|
|
4
|
-
static forRoot(flavour: string): DynamicModule;
|
|
5
|
+
static forRoot(flavour: string, handlers?: Type<DecafRequestHandler>[]): DynamicModule;
|
|
5
6
|
}
|
|
@@ -8,12 +8,15 @@ var DecafModelModule_1;
|
|
|
8
8
|
import { Module } from "@nestjs/common";
|
|
9
9
|
import { Adapter } from "@decaf-ts/core";
|
|
10
10
|
import { Logging } from "@decaf-ts/logging";
|
|
11
|
-
import { RepoFactory } from "./../RepoFactory.js";
|
|
12
11
|
import { FromModelController } from "./FromModelController.js";
|
|
12
|
+
import { DecafRequestHandlerInterceptor } from "./../interceptors/index.js";
|
|
13
|
+
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
14
|
+
import { DecafHandlerExecutor, DecafRequestContext } from "./../request/index.js";
|
|
15
|
+
import { DECAF_HANDLERS } from "./../constants.js";
|
|
13
16
|
let DecafModelModule = class DecafModelModule {
|
|
14
17
|
static { DecafModelModule_1 = this; }
|
|
15
18
|
static { this.log = Logging.for(DecafModelModule_1.name); }
|
|
16
|
-
static forRoot(flavour) {
|
|
19
|
+
static forRoot(flavour, handlers = []) {
|
|
17
20
|
const log = this.log.for(this.forRoot);
|
|
18
21
|
log.info(`Generating controllers for flavour...`);
|
|
19
22
|
const trackedModels = Adapter.models(flavour);
|
|
@@ -22,7 +25,23 @@ let DecafModelModule = class DecafModelModule {
|
|
|
22
25
|
return {
|
|
23
26
|
module: DecafModelModule_1,
|
|
24
27
|
controllers,
|
|
25
|
-
providers: [
|
|
28
|
+
providers: [
|
|
29
|
+
{
|
|
30
|
+
provide: DECAF_HANDLERS,
|
|
31
|
+
useFactory: () => {
|
|
32
|
+
return handlers.map((H) => {
|
|
33
|
+
log.info(`Registered request handler: ${H.name}`);
|
|
34
|
+
return new H();
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
DecafRequestContext,
|
|
39
|
+
DecafHandlerExecutor,
|
|
40
|
+
{
|
|
41
|
+
provide: APP_INTERCEPTOR,
|
|
42
|
+
useClass: DecafRequestHandlerInterceptor,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
26
45
|
};
|
|
27
46
|
}
|
|
28
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafModelModule.js","sourceRoot":"","sources":["../../../src/decaf-model/DecafModelModule.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAiB,MAAM,
|
|
1
|
+
{"version":3,"file":"DecafModelModule.js","sourceRoot":"","sources":["../../../src/decaf-model/DecafModelModule.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAiB,MAAM,EAAQ,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,OAAO,EAAE,8BAA8B,EAAE,mCAAwB;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,8BAAmB;AACvE,OAAO,EAAE,cAAc,EAAE,0BAAqB;AAGvC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;;aACH,QAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAgB,CAAC,IAAI,CAAC,AAArC,CAAsC;IAEjE,MAAM,CAAC,OAAO,CACZ,OAAe,EACf,WAAwC,EAAE;QAE1C,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;gBACT;oBACE,OAAO,EAAE,cAAc;oBACvB,UAAU,EAAE,GAAG,EAAE;wBACf,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;4BACxB,GAAG,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;4BAClD,OAAO,IAAI,CAAC,EAAE,CAAC;wBACjB,CAAC,CAAC,CAAC;oBACL,CAAC;iBACF;gBACD,mBAAmB;gBACnB,oBAAoB;gBACpB;oBACE,OAAO,EAAE,eAAe;oBACxB,QAAQ,EAAE,8BAA8B;iBACzC;aACF;SACF,CAAC;IACJ,CAAC;;AApCU,gBAAgB;IAD5B,MAAM,CAAC,EAAE,CAAC;GACE,gBAAgB,CAqC5B"}
|
|
@@ -1,4 +1,53 @@
|
|
|
1
1
|
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
5
|
+
*
|
|
6
|
+
* @summary
|
|
7
|
+
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
8
|
+
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
9
|
+
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
10
|
+
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
11
|
+
*
|
|
12
|
+
* @template T The {@link Model} type associated with the generated controller.
|
|
13
|
+
*
|
|
14
|
+
* @param ModelClazz The model class to generate the controller from.
|
|
15
|
+
*
|
|
16
|
+
* @class FromModelController
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* // Given a Decaf Model:
|
|
21
|
+
* class User extends Model<User> {
|
|
22
|
+
* id!: string;
|
|
23
|
+
* name!: string;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Register controller:
|
|
27
|
+
* const UserController = FromModelController.create(User);
|
|
28
|
+
*
|
|
29
|
+
* // NestJS will expose:
|
|
30
|
+
* // POST /user
|
|
31
|
+
* // GET /user/:id
|
|
32
|
+
* // GET /user/query/:method
|
|
33
|
+
* // PUT /user/:id
|
|
34
|
+
* // DELETE /user/:id
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @mermaid
|
|
38
|
+
* sequenceDiagram
|
|
39
|
+
* participant Client
|
|
40
|
+
* participant Controller
|
|
41
|
+
* participant Repo
|
|
42
|
+
* participant DB
|
|
43
|
+
*
|
|
44
|
+
* Client->>Controller: HTTP Request
|
|
45
|
+
* Controller->>Repo: Resolve repository for Model
|
|
46
|
+
* Repo->>DB: Execute DB operation
|
|
47
|
+
* DB-->>Repo: DB Result
|
|
48
|
+
* Repo-->>Controller: Model Instance(s)
|
|
49
|
+
* Controller-->>Client: JSON Response
|
|
50
|
+
*/
|
|
2
51
|
export declare class FromModelController {
|
|
3
52
|
private static readonly log;
|
|
4
53
|
static create<T extends Model<any>>(ModelClazz: ModelConstructor<T>): any;
|
|
@@ -12,12 +12,63 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { Body, Controller, Param } from "@nestjs/common";
|
|
14
14
|
import { ApiBadRequestResponse, ApiBody, ApiCreatedResponse, ApiExtraModels, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiParam, ApiTags, ApiUnprocessableEntityResponse, getSchemaPath, } from "@nestjs/swagger";
|
|
15
|
+
import { Repository } from "@decaf-ts/core";
|
|
15
16
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
16
17
|
import { LoggedClass, Logging, toKebabCase } from "@decaf-ts/logging";
|
|
17
|
-
import { DBKeys } from "@decaf-ts/db-decorators";
|
|
18
|
+
import { DBKeys, ValidationError } from "@decaf-ts/db-decorators";
|
|
18
19
|
import { Metadata } from "@decaf-ts/decoration";
|
|
19
20
|
import { ApiOperationFromModel, ApiParamsFromModel, DecafParams, } from "./decorators/index.js";
|
|
20
|
-
import {
|
|
21
|
+
import { DecafRequestContext } from "./../request/index.js";
|
|
22
|
+
import { DECAF_ADAPTER_OPTIONS } from "./../constants.js";
|
|
23
|
+
/**
|
|
24
|
+
* @description
|
|
25
|
+
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
26
|
+
*
|
|
27
|
+
* @summary
|
|
28
|
+
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
29
|
+
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
30
|
+
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
31
|
+
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
32
|
+
*
|
|
33
|
+
* @template T The {@link Model} type associated with the generated controller.
|
|
34
|
+
*
|
|
35
|
+
* @param ModelClazz The model class to generate the controller from.
|
|
36
|
+
*
|
|
37
|
+
* @class FromModelController
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Given a Decaf Model:
|
|
42
|
+
* class User extends Model<User> {
|
|
43
|
+
* id!: string;
|
|
44
|
+
* name!: string;
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* // Register controller:
|
|
48
|
+
* const UserController = FromModelController.create(User);
|
|
49
|
+
*
|
|
50
|
+
* // NestJS will expose:
|
|
51
|
+
* // POST /user
|
|
52
|
+
* // GET /user/:id
|
|
53
|
+
* // GET /user/query/:method
|
|
54
|
+
* // PUT /user/:id
|
|
55
|
+
* // DELETE /user/:id
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @mermaid
|
|
59
|
+
* sequenceDiagram
|
|
60
|
+
* participant Client
|
|
61
|
+
* participant Controller
|
|
62
|
+
* participant Repo
|
|
63
|
+
* participant DB
|
|
64
|
+
*
|
|
65
|
+
* Client->>Controller: HTTP Request
|
|
66
|
+
* Controller->>Repo: Resolve repository for Model
|
|
67
|
+
* Repo->>DB: Execute DB operation
|
|
68
|
+
* DB-->>Repo: DB Result
|
|
69
|
+
* Repo-->>Controller: Model Instance(s)
|
|
70
|
+
* Controller-->>Client: JSON Response
|
|
71
|
+
*/
|
|
21
72
|
export class FromModelController {
|
|
22
73
|
static { this.log = Logging.for(FromModelController.name); }
|
|
23
74
|
static create(ModelClazz) {
|
|
@@ -29,24 +80,26 @@ export class FromModelController {
|
|
|
29
80
|
const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
30
81
|
log.debug(`Creating controller for model: ${modelClazzName}`);
|
|
31
82
|
let DynamicModelController = class DynamicModelController extends LoggedClass {
|
|
32
|
-
constructor(
|
|
83
|
+
constructor(clientContext) {
|
|
33
84
|
super();
|
|
34
|
-
this.
|
|
85
|
+
this.clientContext = clientContext;
|
|
86
|
+
this.pk = Model.pk(ModelClazz);
|
|
35
87
|
log.info(`Registering dynamic controller for model: ${modelClazzName} route: /${routePath}`);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
88
|
+
}
|
|
89
|
+
get repository() {
|
|
90
|
+
if (!this._repo)
|
|
91
|
+
this._repo = Repository.forModel(ModelClazz);
|
|
92
|
+
const adapterOptions = this.clientContext.get(DECAF_ADAPTER_OPTIONS);
|
|
93
|
+
if (adapterOptions)
|
|
94
|
+
return this._repo.for(adapterOptions);
|
|
95
|
+
return this._repo;
|
|
43
96
|
}
|
|
44
97
|
async create(data) {
|
|
45
98
|
const log = this.log.for(this.create);
|
|
46
99
|
log.verbose(`creating new ${modelClazzName}`);
|
|
47
100
|
let created;
|
|
48
101
|
try {
|
|
49
|
-
created = await this.
|
|
102
|
+
created = await this.repository.create(data);
|
|
50
103
|
}
|
|
51
104
|
catch (e) {
|
|
52
105
|
log.error(`Failed to create new ${modelClazzName}`, e);
|
|
@@ -56,12 +109,14 @@ export class FromModelController {
|
|
|
56
109
|
return created;
|
|
57
110
|
}
|
|
58
111
|
async read(pathParams) {
|
|
59
|
-
const
|
|
112
|
+
const id = pathParams[this.pk];
|
|
113
|
+
if (typeof id === "undefined")
|
|
114
|
+
throw new ValidationError(`No ${this.pk} provided`);
|
|
60
115
|
const log = this.log.for(this.read);
|
|
61
116
|
let read;
|
|
62
117
|
try {
|
|
63
118
|
log.debug(`reading ${modelClazzName} with ${this.pk} ${id}`);
|
|
64
|
-
read = await this.
|
|
119
|
+
read = await this.repository.read(id);
|
|
65
120
|
}
|
|
66
121
|
catch (e) {
|
|
67
122
|
log.error(`Failed to read ${modelClazzName} with id ${id}`, e);
|
|
@@ -75,7 +130,7 @@ export class FromModelController {
|
|
|
75
130
|
let results;
|
|
76
131
|
try {
|
|
77
132
|
log.debug(`Querying ${modelClazzName} using method "${method}"`);
|
|
78
|
-
results = await this.
|
|
133
|
+
results = await this.repository[method]();
|
|
79
134
|
}
|
|
80
135
|
catch (e) {
|
|
81
136
|
log.error(`Failed to query ${modelClazzName} using method "${method}"`, e);
|
|
@@ -89,7 +144,7 @@ export class FromModelController {
|
|
|
89
144
|
let updated;
|
|
90
145
|
try {
|
|
91
146
|
log.info(`updating ${modelClazzName} with ${this.pk} ${body[this.pk]}`);
|
|
92
|
-
updated = await this.
|
|
147
|
+
updated = await this.repository.create(body);
|
|
93
148
|
}
|
|
94
149
|
catch (e) {
|
|
95
150
|
log.error(e);
|
|
@@ -97,12 +152,17 @@ export class FromModelController {
|
|
|
97
152
|
}
|
|
98
153
|
return updated;
|
|
99
154
|
}
|
|
100
|
-
async delete(
|
|
155
|
+
async delete(pathParams) {
|
|
156
|
+
const id = pathParams[this.pk];
|
|
157
|
+
if (typeof id === "undefined")
|
|
158
|
+
throw new ValidationError(`No ${this.pk} provided`);
|
|
101
159
|
const log = this.log.for(this.delete);
|
|
160
|
+
if (typeof id === "undefined")
|
|
161
|
+
throw new ValidationError(`No ${this.pk} provided`);
|
|
102
162
|
let read;
|
|
103
163
|
try {
|
|
104
|
-
log.debug(`deleting ${modelClazzName} with ${this.pk} ${
|
|
105
|
-
read = await this.
|
|
164
|
+
log.debug(`deleting ${modelClazzName} with ${this.pk} ${pathParams}`);
|
|
165
|
+
read = await this.repository.delete("id");
|
|
106
166
|
}
|
|
107
167
|
catch (e) {
|
|
108
168
|
log.error(`Failed to delete ${modelClazzName} with id ${"id"}`, e);
|
|
@@ -194,7 +254,7 @@ export class FromModelController {
|
|
|
194
254
|
ApiNotFoundResponse({
|
|
195
255
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
196
256
|
}),
|
|
197
|
-
__param(0,
|
|
257
|
+
__param(0, Param()),
|
|
198
258
|
__metadata("design:type", Function),
|
|
199
259
|
__metadata("design:paramtypes", [Object]),
|
|
200
260
|
__metadata("design:returntype", Promise)
|
|
@@ -203,7 +263,7 @@ export class FromModelController {
|
|
|
203
263
|
Controller(routePath),
|
|
204
264
|
ApiTags(modelClazzName),
|
|
205
265
|
ApiExtraModels(ModelClazz),
|
|
206
|
-
__metadata("design:paramtypes", [
|
|
266
|
+
__metadata("design:paramtypes", [DecafRequestContext])
|
|
207
267
|
], DynamicModelController);
|
|
208
268
|
return DynamicModelController;
|
|
209
269
|
}
|
|
@@ -1 +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;
|
|
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,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAElB,WAAW,GACZ,8BAAqB;AACtB,OAAO,EAAE,mBAAmB,EAAE,8BAAmB;AACjD,OAAO,EAAE,qBAAqB,EAAE,0BAAqB;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAM,OAAO,mBAAmB;aACN,QAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAE7D,AAAP,MAA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Y,CAAC,EAAE,IAAI;YACrE,EAAE,CAAC;QAEL,MAAM,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"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -23,16 +23,17 @@ import "./decoration";
|
|
|
23
23
|
export * from "./constants";
|
|
24
24
|
export * from "./decoration";
|
|
25
25
|
export * from "./module";
|
|
26
|
-
export * from "./RepoFactory";
|
|
27
26
|
export * from "./types";
|
|
28
27
|
export * from "./utils";
|
|
29
28
|
export * from "./factory";
|
|
30
29
|
export * from "./decaf-model";
|
|
30
|
+
export * from "./interceptors";
|
|
31
|
+
export * from "./request";
|
|
31
32
|
/**
|
|
32
33
|
* Represents the current version of the ts-workspace module.
|
|
33
34
|
* The actual version number is replaced during the build process.
|
|
34
35
|
* @constant
|
|
35
36
|
* @type {string}
|
|
36
37
|
*/
|
|
37
|
-
export declare const VERSION = "0.1.
|
|
38
|
+
export declare const VERSION = "0.1.4";
|
|
38
39
|
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|