@decaf-ts/for-nest 0.1.5 → 0.1.6
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/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 +8 -0
- package/lib/decaf-model/DecafModelModule.d.ts +1 -0
- package/lib/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/decaf-model/FromModelController.cjs +40 -30
- package/lib/decaf-model/FromModelController.d.ts +2 -10
- package/lib/decaf-model/FromModelController.js.map +1 -1
- package/lib/decaf-model/decorators/ApiParamsFromModel.d.ts +2 -2
- package/lib/decaf-model/decorators/ApiParamsFromModel.js.map +1 -1
- package/lib/decaf-model/decorators/DecafParams.d.ts +2 -2
- package/lib/decaf-model/decorators/DecafParams.js.map +1 -1
- package/lib/decaf-model/decorators/types.d.ts +7 -1
- package/lib/esm/decaf-model/DecafModelModule.d.ts +1 -0
- package/lib/esm/decaf-model/DecafModelModule.js +9 -1
- package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/esm/decaf-model/FromModelController.d.ts +2 -10
- package/lib/esm/decaf-model/FromModelController.js +41 -31
- package/lib/esm/decaf-model/FromModelController.js.map +1 -1
- package/lib/esm/decaf-model/decorators/ApiParamsFromModel.d.ts +2 -2
- package/lib/esm/decaf-model/decorators/ApiParamsFromModel.js.map +1 -1
- package/lib/esm/decaf-model/decorators/DecafParams.d.ts +2 -2
- package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -1
- package/lib/esm/decaf-model/decorators/types.d.ts +7 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js +2 -1
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js.map +1 -1
- package/lib/esm/request/DecafHandlerExecutor.d.ts +1 -1
- package/lib/esm/request/DecafHandlerExecutor.js +2 -2
- package/lib/esm/request/DecafHandlerExecutor.js.map +1 -1
- package/lib/esm/types.d.ts +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interceptors/DecafRequestHandlerInterceptor.cjs +2 -1
- package/lib/interceptors/DecafRequestHandlerInterceptor.js.map +1 -1
- package/lib/request/DecafHandlerExecutor.cjs +2 -2
- package/lib/request/DecafHandlerExecutor.d.ts +1 -1
- package/lib/request/DecafHandlerExecutor.js.map +1 -1
- package/lib/types.d.ts +1 -1
- package/package.json +5 -2
|
@@ -80,7 +80,7 @@ class FromModelController {
|
|
|
80
80
|
const routePath = (0, logging_1.toKebabCase)(tableName);
|
|
81
81
|
const modelClazzName = ModelClazz.name;
|
|
82
82
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
|
-
const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
83
|
+
const { description, getPK, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
84
84
|
log.debug(`Creating controller for model: ${modelClazzName}`);
|
|
85
85
|
let DynamicModelController = class DynamicModelController extends logging_1.LoggedClass {
|
|
86
86
|
constructor(clientContext) {
|
|
@@ -89,20 +89,22 @@ class FromModelController {
|
|
|
89
89
|
this.pk = decorator_validation_1.Model.pk(ModelClazz);
|
|
90
90
|
log.info(`Registering dynamic controller for model: ${modelClazzName} route: /${routePath}`);
|
|
91
91
|
}
|
|
92
|
-
get
|
|
93
|
-
if (!this.
|
|
94
|
-
this.
|
|
92
|
+
get persistence() {
|
|
93
|
+
if (!this._persistence)
|
|
94
|
+
this._persistence =
|
|
95
|
+
core_1.ModelService.getService(ModelClazz) ||
|
|
96
|
+
core_1.Repository.forModel(ModelClazz);
|
|
95
97
|
const adapterOptions = this.clientContext.get(constants_1.DECAF_ADAPTER_OPTIONS);
|
|
96
98
|
if (adapterOptions)
|
|
97
|
-
return this.
|
|
98
|
-
return this.
|
|
99
|
+
return this._persistence.for(adapterOptions);
|
|
100
|
+
return this._persistence;
|
|
99
101
|
}
|
|
100
102
|
async create(data) {
|
|
101
103
|
const log = this.log.for(this.create);
|
|
102
104
|
log.verbose(`creating new ${modelClazzName}`);
|
|
103
105
|
let created;
|
|
104
106
|
try {
|
|
105
|
-
created = await this.
|
|
107
|
+
created = await this.persistence.create(data);
|
|
106
108
|
}
|
|
107
109
|
catch (e) {
|
|
108
110
|
log.error(`Failed to create new ${modelClazzName}`, e);
|
|
@@ -111,15 +113,15 @@ class FromModelController {
|
|
|
111
113
|
log.info(`created new ${modelClazzName} with id ${created[this.pk]}`);
|
|
112
114
|
return created;
|
|
113
115
|
}
|
|
114
|
-
async read(
|
|
115
|
-
const id =
|
|
116
|
+
async read(routeParams) {
|
|
117
|
+
const id = getPK(...routeParams.ordered);
|
|
116
118
|
if (typeof id === "undefined")
|
|
117
119
|
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
118
120
|
const log = this.log.for(this.read);
|
|
119
121
|
let read;
|
|
120
122
|
try {
|
|
121
123
|
log.debug(`reading ${modelClazzName} with ${this.pk} ${id}`);
|
|
122
|
-
read = await this.
|
|
124
|
+
read = await this.persistence.read(id);
|
|
123
125
|
}
|
|
124
126
|
catch (e) {
|
|
125
127
|
log.error(`Failed to read ${modelClazzName} with id ${id}`, e);
|
|
@@ -133,7 +135,8 @@ class FromModelController {
|
|
|
133
135
|
let results;
|
|
134
136
|
try {
|
|
135
137
|
log.debug(`Querying ${modelClazzName} using method "${method}"`);
|
|
136
|
-
|
|
138
|
+
const args = [method];
|
|
139
|
+
results = await this.persistence.query(...args);
|
|
137
140
|
}
|
|
138
141
|
catch (e) {
|
|
139
142
|
log.error(`Failed to query ${modelClazzName} using method "${method}"`, e);
|
|
@@ -144,10 +147,16 @@ class FromModelController {
|
|
|
144
147
|
}
|
|
145
148
|
async update(routeParams, body) {
|
|
146
149
|
const log = this.log.for(this.update);
|
|
150
|
+
const id = getPK(...routeParams.ordered);
|
|
151
|
+
if (typeof id === "undefined")
|
|
152
|
+
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
147
153
|
let updated;
|
|
148
154
|
try {
|
|
149
|
-
log.info(`updating ${modelClazzName} with ${this.pk} ${
|
|
150
|
-
updated = await this.
|
|
155
|
+
log.info(`updating ${modelClazzName} with ${this.pk} ${id}`);
|
|
156
|
+
updated = await this.persistence.update(new ModelClazz({
|
|
157
|
+
...body,
|
|
158
|
+
[this.pk]: id,
|
|
159
|
+
}));
|
|
151
160
|
}
|
|
152
161
|
catch (e) {
|
|
153
162
|
log.error(e);
|
|
@@ -155,24 +164,22 @@ class FromModelController {
|
|
|
155
164
|
}
|
|
156
165
|
return updated;
|
|
157
166
|
}
|
|
158
|
-
async delete(
|
|
159
|
-
const id = pathParams[this.pk];
|
|
160
|
-
if (typeof id === "undefined")
|
|
161
|
-
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
167
|
+
async delete(routeParams) {
|
|
162
168
|
const log = this.log.for(this.delete);
|
|
169
|
+
const id = getPK(...routeParams.ordered);
|
|
163
170
|
if (typeof id === "undefined")
|
|
164
171
|
throw new db_decorators_1.ValidationError(`No ${this.pk} provided`);
|
|
165
|
-
let
|
|
172
|
+
let del;
|
|
166
173
|
try {
|
|
167
|
-
log.debug(`deleting ${modelClazzName} with ${this.pk} ${
|
|
168
|
-
|
|
174
|
+
log.debug(`deleting ${modelClazzName} with ${this.pk} ${id}`);
|
|
175
|
+
del = await this.persistence.delete(id);
|
|
169
176
|
}
|
|
170
177
|
catch (e) {
|
|
171
|
-
log.error(`Failed to delete ${modelClazzName} with id ${
|
|
178
|
+
log.error(`Failed to delete ${modelClazzName} with id ${id}`, e);
|
|
172
179
|
throw e;
|
|
173
180
|
}
|
|
174
|
-
log.info(`deleted ${modelClazzName} with id ${
|
|
175
|
-
return
|
|
181
|
+
log.info(`deleted ${modelClazzName} with id ${id}`);
|
|
182
|
+
return del;
|
|
176
183
|
}
|
|
177
184
|
};
|
|
178
185
|
__decorate([
|
|
@@ -204,7 +211,7 @@ class FromModelController {
|
|
|
204
211
|
(0, swagger_1.ApiNotFoundResponse)({
|
|
205
212
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
206
213
|
}),
|
|
207
|
-
__param(0, (0,
|
|
214
|
+
__param(0, (0, decorators_1.DecafParams)(apiProperties)),
|
|
208
215
|
__metadata("design:type", Function),
|
|
209
216
|
__metadata("design:paramtypes", [Object]),
|
|
210
217
|
__metadata("design:returntype", Promise)
|
|
@@ -257,7 +264,7 @@ class FromModelController {
|
|
|
257
264
|
(0, swagger_1.ApiNotFoundResponse)({
|
|
258
265
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
259
266
|
}),
|
|
260
|
-
__param(0, (0,
|
|
267
|
+
__param(0, (0, decorators_1.DecafParams)(apiProperties)),
|
|
261
268
|
__metadata("design:type", Function),
|
|
262
269
|
__metadata("design:paramtypes", [Object]),
|
|
263
270
|
__metadata("design:returntype", Promise)
|
|
@@ -271,11 +278,9 @@ class FromModelController {
|
|
|
271
278
|
return DynamicModelController;
|
|
272
279
|
}
|
|
273
280
|
static getRouteParametersFromModel(ModelClazz) {
|
|
274
|
-
const instance = new ModelClazz({});
|
|
275
281
|
const pk = decorator_validation_1.Model.pk(ModelClazz);
|
|
276
|
-
const
|
|
277
|
-
const composedKeys =
|
|
278
|
-
[];
|
|
282
|
+
const composed = decoration_1.Metadata.get(ModelClazz, decoration_1.Metadata.key(db_decorators_1.DBKeys.COMPOSED, pk));
|
|
283
|
+
const composedKeys = composed?.args ?? [];
|
|
279
284
|
const keysToReturn = Array.isArray(composedKeys) && composedKeys.length > 0
|
|
280
285
|
? [...composedKeys]
|
|
281
286
|
: [pk];
|
|
@@ -291,7 +296,12 @@ class FromModelController {
|
|
|
291
296
|
type: String,
|
|
292
297
|
};
|
|
293
298
|
});
|
|
294
|
-
return {
|
|
299
|
+
return {
|
|
300
|
+
path,
|
|
301
|
+
description,
|
|
302
|
+
apiProperties,
|
|
303
|
+
getPK: (...params) => composed?.separator ? params.join(composed.separator) : params.join(""),
|
|
304
|
+
};
|
|
295
305
|
}
|
|
296
306
|
}
|
|
297
307
|
exports.FromModelController = FromModelController;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import type { DecafModelRoute } from "./decorators";
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
4
5
|
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
@@ -51,14 +52,5 @@ import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
|
51
52
|
export declare class FromModelController {
|
|
52
53
|
private static readonly log;
|
|
53
54
|
static create<T extends Model<any>>(ModelClazz: ModelConstructor<T>): any;
|
|
54
|
-
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>):
|
|
55
|
-
description: string | undefined;
|
|
56
|
-
apiProperties: {
|
|
57
|
-
name: any;
|
|
58
|
-
description: string | undefined;
|
|
59
|
-
required: boolean;
|
|
60
|
-
type: StringConstructor;
|
|
61
|
-
}[];
|
|
62
|
-
path: string;
|
|
63
|
-
};
|
|
55
|
+
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>): DecafModelRoute;
|
|
64
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromModelController.js","sourceRoot":"","sources":["../../src/decaf-model/FromModelController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,6CAYyB;AACzB,
|
|
1
|
+
{"version":3,"file":"FromModelController.js","sourceRoot":"","sources":["../../src/decaf-model/FromModelController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyD;AACzD,6CAYyB;AACzB,yCAAgE;AAChE,yEAAyE;AACzE,+CAAsE;AACtE,2DAAkE;AAClE,qDAAgD;AAMhD,uDAIsB;AACtB,oDAAiD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AAC,CAAC;QAC1D,MAAM,aAAa,GAAyB,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACjE,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;QAEH,OAAO;YACL,IAAI;YACJ,WAAW;YACX,aAAa;YACb,KAAK,EAAE,CAAC,GAAG,MAA8B,EAAE,EAAE,CAC3C,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;SAC1E,CAAC;IACJ,CAAC;;AArPH,kDAsPC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DecafApiProperties } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
|
|
4
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.
|
|
@@ -10,4 +10,4 @@ import { ApiParam } from "./types";
|
|
|
10
10
|
* @return {any} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
|
|
11
11
|
* @function ApiParamsFromModel
|
|
12
12
|
*/
|
|
13
|
-
export declare function ApiParamsFromModel(props?:
|
|
13
|
+
export declare function ApiParamsFromModel(props?: DecafApiProperties[]): MethodDecorator & ClassDecorator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiParamsFromModel.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/ApiParamsFromModel.ts"],"names":[],"mappings":";;AAeA,gDAaC;AA5BD,2CAAiD;AACjD,6CAA0D;AAG1D;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,
|
|
1
|
+
{"version":3,"file":"ApiParamsFromModel.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/ApiParamsFromModel.ts"],"names":[],"mappings":";;AAeA,gDAaC;AA5BD,2CAAiD;AACjD,6CAA0D;AAG1D;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,QAA8B,EAAE;IAEhC,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACjC,IAAA,kBAAW,EAAC;QACV,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAC,IAAI,EAAE;QACzD,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI;QAC5B,8BAA8B;QAC9B,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,MAAM;KACvB,CAAC,CACH,CAAC;IACF,OAAO,IAAA,wBAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecafApiProperties } from "./types";
|
|
2
2
|
/**
|
|
3
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
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
5
|
* @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
|
|
6
6
|
* @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
|
|
7
7
|
*/
|
|
8
|
-
export declare function DecafParams(props?:
|
|
8
|
+
export declare function DecafParams(props?: DecafApiProperties[]): ParameterDecorator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafParams.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/DecafParams.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DecafParams.js","sourceRoot":"","sources":["../../../src/decaf-model/decorators/DecafParams.ts"],"names":[],"mappings":";;AA8BA,kCAKC;AAnCD,2CAAwE;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAAG,IAAA,6BAAoB,EACxC,CAAC,KAA2B,EAAE,GAAqB,EAAmB,EAAE;IACtE,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,MAAM,IAAI,EAAE,CAAwB,CAAC;IAC5D,MAAM,SAAS,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACjD,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,QAA8B,EAAE;IAEhC,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"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
-
export type
|
|
2
|
+
export type DecafApiProperties = {
|
|
3
3
|
name: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
required?: boolean;
|
|
6
6
|
type?: any;
|
|
7
7
|
};
|
|
8
|
+
export type DecafModelRoute = {
|
|
9
|
+
path: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
apiProperties: DecafApiProperties[];
|
|
12
|
+
getPK: (...args: Array<string | number>) => string;
|
|
13
|
+
};
|
|
8
14
|
export type DecafParamProps = {
|
|
9
15
|
original: Record<string, any>;
|
|
10
16
|
ordered: any[];
|
|
@@ -2,5 +2,6 @@ import { DynamicModule, Type } from "@nestjs/common";
|
|
|
2
2
|
import { type DecafRequestHandler } from "../types";
|
|
3
3
|
export declare class DecafModelModule {
|
|
4
4
|
private static readonly log;
|
|
5
|
+
private static createModelServices;
|
|
5
6
|
static forRoot(flavour: string, handlers?: Type<DecafRequestHandler>[]): DynamicModule;
|
|
6
7
|
}
|
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
var DecafModelModule_1;
|
|
8
8
|
import { Module } from "@nestjs/common";
|
|
9
|
-
import { Adapter } from "@decaf-ts/core";
|
|
9
|
+
import { Adapter, ModelService } from "@decaf-ts/core";
|
|
10
10
|
import { Logging } from "@decaf-ts/logging";
|
|
11
11
|
import { FromModelController } from "./FromModelController.js";
|
|
12
12
|
import { DecafRequestHandlerInterceptor } from "./../interceptors/index.js";
|
|
@@ -16,10 +16,17 @@ import { DECAF_HANDLERS } from "./../constants.js";
|
|
|
16
16
|
let DecafModelModule = class DecafModelModule {
|
|
17
17
|
static { DecafModelModule_1 = this; }
|
|
18
18
|
static { this.log = Logging.for(DecafModelModule_1.name); }
|
|
19
|
+
static createModelServices(models) {
|
|
20
|
+
return models.map((model) => ({
|
|
21
|
+
provide: `${model.name}Service`,
|
|
22
|
+
useFactory: () => ModelService.forModel(model),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
19
25
|
static forRoot(flavour, handlers = []) {
|
|
20
26
|
const log = this.log.for(this.forRoot);
|
|
21
27
|
log.info(`Generating controllers for flavour...`);
|
|
22
28
|
const trackedModels = Adapter.models(flavour);
|
|
29
|
+
const modelServices = this.createModelServices(trackedModels);
|
|
23
30
|
const controllers = trackedModels.map(FromModelController.create);
|
|
24
31
|
log.info(`Generated ${controllers.length} controllers`);
|
|
25
32
|
return {
|
|
@@ -41,6 +48,7 @@ let DecafModelModule = class DecafModelModule {
|
|
|
41
48
|
provide: APP_INTERCEPTOR,
|
|
42
49
|
useClass: DecafRequestHandlerInterceptor,
|
|
43
50
|
},
|
|
51
|
+
...modelServices,
|
|
44
52
|
],
|
|
45
53
|
};
|
|
46
54
|
}
|
|
@@ -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,EAAkB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAW,MAAM,gBAAgB,CAAC;AAChE,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;IAEzD,MAAM,CAAC,mBAAmB,CAAC,MAAa;QAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE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@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import type { DecafModelRoute } from "./decorators";
|
|
2
3
|
/**
|
|
3
4
|
* @description
|
|
4
5
|
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
@@ -51,14 +52,5 @@ import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
|
51
52
|
export declare class FromModelController {
|
|
52
53
|
private static readonly log;
|
|
53
54
|
static create<T extends Model<any>>(ModelClazz: ModelConstructor<T>): any;
|
|
54
|
-
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>):
|
|
55
|
-
description: string | undefined;
|
|
56
|
-
apiProperties: {
|
|
57
|
-
name: any;
|
|
58
|
-
description: string | undefined;
|
|
59
|
-
required: boolean;
|
|
60
|
-
type: StringConstructor;
|
|
61
|
-
}[];
|
|
62
|
-
path: string;
|
|
63
|
-
};
|
|
55
|
+
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>): DecafModelRoute;
|
|
64
56
|
}
|
|
@@ -12,7 +12,7 @@ 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
|
+
import { ModelService, Repository } from "@decaf-ts/core";
|
|
16
16
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
17
17
|
import { LoggedClass, Logging, toKebabCase } from "@decaf-ts/logging";
|
|
18
18
|
import { DBKeys, ValidationError } from "@decaf-ts/db-decorators";
|
|
@@ -77,7 +77,7 @@ export class FromModelController {
|
|
|
77
77
|
const routePath = toKebabCase(tableName);
|
|
78
78
|
const modelClazzName = ModelClazz.name;
|
|
79
79
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
80
|
-
const { description, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
80
|
+
const { description, getPK, apiProperties, path } = FromModelController.getRouteParametersFromModel(ModelClazz);
|
|
81
81
|
log.debug(`Creating controller for model: ${modelClazzName}`);
|
|
82
82
|
let DynamicModelController = class DynamicModelController extends LoggedClass {
|
|
83
83
|
constructor(clientContext) {
|
|
@@ -86,20 +86,22 @@ export class FromModelController {
|
|
|
86
86
|
this.pk = Model.pk(ModelClazz);
|
|
87
87
|
log.info(`Registering dynamic controller for model: ${modelClazzName} route: /${routePath}`);
|
|
88
88
|
}
|
|
89
|
-
get
|
|
90
|
-
if (!this.
|
|
91
|
-
this.
|
|
89
|
+
get persistence() {
|
|
90
|
+
if (!this._persistence)
|
|
91
|
+
this._persistence =
|
|
92
|
+
ModelService.getService(ModelClazz) ||
|
|
93
|
+
Repository.forModel(ModelClazz);
|
|
92
94
|
const adapterOptions = this.clientContext.get(DECAF_ADAPTER_OPTIONS);
|
|
93
95
|
if (adapterOptions)
|
|
94
|
-
return this.
|
|
95
|
-
return this.
|
|
96
|
+
return this._persistence.for(adapterOptions);
|
|
97
|
+
return this._persistence;
|
|
96
98
|
}
|
|
97
99
|
async create(data) {
|
|
98
100
|
const log = this.log.for(this.create);
|
|
99
101
|
log.verbose(`creating new ${modelClazzName}`);
|
|
100
102
|
let created;
|
|
101
103
|
try {
|
|
102
|
-
created = await this.
|
|
104
|
+
created = await this.persistence.create(data);
|
|
103
105
|
}
|
|
104
106
|
catch (e) {
|
|
105
107
|
log.error(`Failed to create new ${modelClazzName}`, e);
|
|
@@ -108,15 +110,15 @@ export class FromModelController {
|
|
|
108
110
|
log.info(`created new ${modelClazzName} with id ${created[this.pk]}`);
|
|
109
111
|
return created;
|
|
110
112
|
}
|
|
111
|
-
async read(
|
|
112
|
-
const id =
|
|
113
|
+
async read(routeParams) {
|
|
114
|
+
const id = getPK(...routeParams.ordered);
|
|
113
115
|
if (typeof id === "undefined")
|
|
114
116
|
throw new ValidationError(`No ${this.pk} provided`);
|
|
115
117
|
const log = this.log.for(this.read);
|
|
116
118
|
let read;
|
|
117
119
|
try {
|
|
118
120
|
log.debug(`reading ${modelClazzName} with ${this.pk} ${id}`);
|
|
119
|
-
read = await this.
|
|
121
|
+
read = await this.persistence.read(id);
|
|
120
122
|
}
|
|
121
123
|
catch (e) {
|
|
122
124
|
log.error(`Failed to read ${modelClazzName} with id ${id}`, e);
|
|
@@ -130,7 +132,8 @@ export class FromModelController {
|
|
|
130
132
|
let results;
|
|
131
133
|
try {
|
|
132
134
|
log.debug(`Querying ${modelClazzName} using method "${method}"`);
|
|
133
|
-
|
|
135
|
+
const args = [method];
|
|
136
|
+
results = await this.persistence.query(...args);
|
|
134
137
|
}
|
|
135
138
|
catch (e) {
|
|
136
139
|
log.error(`Failed to query ${modelClazzName} using method "${method}"`, e);
|
|
@@ -141,10 +144,16 @@ export class FromModelController {
|
|
|
141
144
|
}
|
|
142
145
|
async update(routeParams, body) {
|
|
143
146
|
const log = this.log.for(this.update);
|
|
147
|
+
const id = getPK(...routeParams.ordered);
|
|
148
|
+
if (typeof id === "undefined")
|
|
149
|
+
throw new ValidationError(`No ${this.pk} provided`);
|
|
144
150
|
let updated;
|
|
145
151
|
try {
|
|
146
|
-
log.info(`updating ${modelClazzName} with ${this.pk} ${
|
|
147
|
-
updated = await this.
|
|
152
|
+
log.info(`updating ${modelClazzName} with ${this.pk} ${id}`);
|
|
153
|
+
updated = await this.persistence.update(new ModelClazz({
|
|
154
|
+
...body,
|
|
155
|
+
[this.pk]: id,
|
|
156
|
+
}));
|
|
148
157
|
}
|
|
149
158
|
catch (e) {
|
|
150
159
|
log.error(e);
|
|
@@ -152,24 +161,22 @@ export class FromModelController {
|
|
|
152
161
|
}
|
|
153
162
|
return updated;
|
|
154
163
|
}
|
|
155
|
-
async delete(
|
|
156
|
-
const id = pathParams[this.pk];
|
|
157
|
-
if (typeof id === "undefined")
|
|
158
|
-
throw new ValidationError(`No ${this.pk} provided`);
|
|
164
|
+
async delete(routeParams) {
|
|
159
165
|
const log = this.log.for(this.delete);
|
|
166
|
+
const id = getPK(...routeParams.ordered);
|
|
160
167
|
if (typeof id === "undefined")
|
|
161
168
|
throw new ValidationError(`No ${this.pk} provided`);
|
|
162
|
-
let
|
|
169
|
+
let del;
|
|
163
170
|
try {
|
|
164
|
-
log.debug(`deleting ${modelClazzName} with ${this.pk} ${
|
|
165
|
-
|
|
171
|
+
log.debug(`deleting ${modelClazzName} with ${this.pk} ${id}`);
|
|
172
|
+
del = await this.persistence.delete(id);
|
|
166
173
|
}
|
|
167
174
|
catch (e) {
|
|
168
|
-
log.error(`Failed to delete ${modelClazzName} with id ${
|
|
175
|
+
log.error(`Failed to delete ${modelClazzName} with id ${id}`, e);
|
|
169
176
|
throw e;
|
|
170
177
|
}
|
|
171
|
-
log.info(`deleted ${modelClazzName} with id ${
|
|
172
|
-
return
|
|
178
|
+
log.info(`deleted ${modelClazzName} with id ${id}`);
|
|
179
|
+
return del;
|
|
173
180
|
}
|
|
174
181
|
};
|
|
175
182
|
__decorate([
|
|
@@ -201,7 +208,7 @@ export class FromModelController {
|
|
|
201
208
|
ApiNotFoundResponse({
|
|
202
209
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
203
210
|
}),
|
|
204
|
-
__param(0,
|
|
211
|
+
__param(0, DecafParams(apiProperties)),
|
|
205
212
|
__metadata("design:type", Function),
|
|
206
213
|
__metadata("design:paramtypes", [Object]),
|
|
207
214
|
__metadata("design:returntype", Promise)
|
|
@@ -254,7 +261,7 @@ export class FromModelController {
|
|
|
254
261
|
ApiNotFoundResponse({
|
|
255
262
|
description: `No ${modelClazzName} record matches the provided identifier.`,
|
|
256
263
|
}),
|
|
257
|
-
__param(0,
|
|
264
|
+
__param(0, DecafParams(apiProperties)),
|
|
258
265
|
__metadata("design:type", Function),
|
|
259
266
|
__metadata("design:paramtypes", [Object]),
|
|
260
267
|
__metadata("design:returntype", Promise)
|
|
@@ -268,11 +275,9 @@ export class FromModelController {
|
|
|
268
275
|
return DynamicModelController;
|
|
269
276
|
}
|
|
270
277
|
static getRouteParametersFromModel(ModelClazz) {
|
|
271
|
-
const instance = new ModelClazz({});
|
|
272
278
|
const pk = Model.pk(ModelClazz);
|
|
273
|
-
const
|
|
274
|
-
const composedKeys =
|
|
275
|
-
[];
|
|
279
|
+
const composed = Metadata.get(ModelClazz, Metadata.key(DBKeys.COMPOSED, pk));
|
|
280
|
+
const composedKeys = composed?.args ?? [];
|
|
276
281
|
const keysToReturn = Array.isArray(composedKeys) && composedKeys.length > 0
|
|
277
282
|
? [...composedKeys]
|
|
278
283
|
: [pk];
|
|
@@ -288,7 +293,12 @@ export class FromModelController {
|
|
|
288
293
|
type: String,
|
|
289
294
|
};
|
|
290
295
|
});
|
|
291
|
-
return {
|
|
296
|
+
return {
|
|
297
|
+
path,
|
|
298
|
+
description,
|
|
299
|
+
apiProperties,
|
|
300
|
+
getPK: (...params) => composed?.separator ? params.join(composed.separator) : params.join(""),
|
|
301
|
+
};
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
//# sourceMappingURL=FromModelController.js.map
|
|
@@ -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;AACzB,OAAO,EAAQ,UAAU,EAAE,MAAM,gBAAgB,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,EAAE,YAAY,EAAQ,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAChE,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;AAMhD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,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,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,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;QACzC,M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IAAI,EAAE,CAAC;QAE1C,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,GAAyB,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACjE,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;QAEH,OAAO;YACL,IAAI;YACJ,WAAW;YACX,aAAa;YACb,KAAK,EAAE,CAAC,GAAG,MAA8B,EAAE,EAAE,CAC3C,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;SAC1E,CAAC;IACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DecafApiProperties } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* @description Applies a set of Swagger `@ApiParam` decorators generated from a typed specification array.
|
|
4
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.
|
|
@@ -10,4 +10,4 @@ import { ApiParam } from "./types";
|
|
|
10
10
|
* @return {any} A composed decorator applying all generated `@ApiParam` decorators to the target method or controller.
|
|
11
11
|
* @function ApiParamsFromModel
|
|
12
12
|
*/
|
|
13
|
-
export declare function ApiParamsFromModel(props?:
|
|
13
|
+
export declare function ApiParamsFromModel(props?: DecafApiProperties[]): MethodDecorator & ClassDecorator;
|
|
@@ -1 +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,
|
|
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,QAA8B,EAAE;IAEhC,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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecafApiProperties } from "./types";
|
|
2
2
|
/**
|
|
3
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
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
5
|
* @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
|
|
6
6
|
* @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
|
|
7
7
|
*/
|
|
8
|
-
export declare function DecafParams(props?:
|
|
8
|
+
export declare function DecafParams(props?: DecafApiProperties[]): ParameterDecorator;
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"DecafParams.js","sourceRoot":"","sources":["../../../../src/decaf-model/decorators/DecafParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,gBAAgB,CAAC;AAExE;;;;;;;;;;;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,CACzB,QAA8B,EAAE;IAEhC,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"}
|