@decaf-ts/for-nest 0.1.8 → 0.1.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 +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/decaf-model/DecafModelModule.cjs +9 -4
- package/lib/decaf-model/DecafModelModule.d.ts +3 -3
- package/lib/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/decaf-model/FromModelController.cjs +355 -53
- package/lib/decaf-model/FromModelController.d.ts +6 -2
- package/lib/decaf-model/FromModelController.js.map +1 -1
- package/lib/decaf-model/decorators/ApiOperationFromModel.cjs +22 -0
- package/lib/decaf-model/decorators/ApiOperationFromModel.d.ts +9 -0
- package/lib/decaf-model/decorators/ApiOperationFromModel.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.cjs +9 -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 +5 -5
- package/lib/decaf-model/types.cjs +15 -0
- package/lib/decaf-model/types.d.ts +18 -0
- package/lib/decaf-model/types.js.map +1 -0
- package/lib/decaf-model/utils.cjs +67 -0
- package/lib/decaf-model/utils.d.ts +7 -0
- package/lib/decaf-model/utils.js.map +1 -0
- package/lib/esm/decaf-model/DecafModelModule.d.ts +3 -3
- package/lib/esm/decaf-model/DecafModelModule.js +9 -4
- package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/esm/decaf-model/FromModelController.d.ts +6 -2
- package/lib/esm/decaf-model/FromModelController.js +359 -57
- package/lib/esm/decaf-model/FromModelController.js.map +1 -1
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.d.ts +9 -0
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js +22 -1
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.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 +9 -1
- package/lib/esm/decaf-model/decorators/DecafParams.js.map +1 -1
- package/lib/esm/decaf-model/decorators/types.d.ts +5 -5
- package/lib/esm/decaf-model/types.d.ts +18 -0
- package/lib/esm/decaf-model/types.js +11 -0
- package/lib/esm/decaf-model/types.js.map +1 -0
- package/lib/esm/decaf-model/utils.d.ts +7 -0
- package/lib/esm/decaf-model/utils.js +61 -0
- package/lib/esm/decaf-model/utils.js.map +1 -0
- package/lib/esm/factory/NestBootstraper.js +2 -10
- package/lib/esm/factory/NestBootstraper.js.map +1 -1
- package/lib/esm/factory/context.d.ts +0 -0
- package/lib/esm/factory/context.js +2 -0
- package/lib/esm/factory/context.js.map +1 -0
- package/lib/esm/factory/exceptions/DecafErrorFilter.d.ts +4 -0
- package/lib/esm/factory/exceptions/DecafErrorFilter.js +32 -0
- package/lib/esm/factory/exceptions/DecafErrorFilter.js.map +1 -0
- package/lib/esm/factory/exceptions/decorators.d.ts +1 -0
- package/lib/esm/factory/exceptions/decorators.js +6 -0
- package/lib/esm/factory/exceptions/decorators.js.map +1 -0
- package/lib/esm/factory/exceptions/index.d.ts +2 -7
- package/lib/esm/factory/exceptions/index.js +2 -7
- package/lib/esm/factory/exceptions/index.js.map +1 -1
- package/lib/esm/module.js +5 -2
- package/lib/esm/module.js.map +1 -1
- package/lib/esm/types.d.ts +1 -0
- package/lib/factory/NestBootstraper.cjs +1 -9
- package/lib/factory/NestBootstraper.js.map +1 -1
- package/lib/factory/context.cjs +2 -0
- package/lib/factory/context.d.ts +0 -0
- package/lib/factory/context.js.map +1 -0
- package/lib/factory/exceptions/DecafErrorFilter.cjs +35 -0
- package/lib/factory/exceptions/DecafErrorFilter.d.ts +4 -0
- package/lib/factory/exceptions/DecafErrorFilter.js.map +1 -0
- package/lib/factory/exceptions/decorators.cjs +9 -0
- package/lib/factory/exceptions/decorators.d.ts +1 -0
- package/lib/factory/exceptions/decorators.js.map +1 -0
- package/lib/factory/exceptions/index.cjs +2 -7
- package/lib/factory/exceptions/index.d.ts +2 -7
- package/lib/factory/exceptions/index.js.map +1 -1
- package/lib/module.cjs +5 -2
- package/lib/module.js.map +1 -1
- package/lib/types.d.ts +1 -0
- package/package.json +3 -3
- package/lib/esm/factory/exceptions/AuthorizationExceptionFilter.d.ts +0 -9
- package/lib/esm/factory/exceptions/AuthorizationExceptionFilter.js +0 -35
- package/lib/esm/factory/exceptions/AuthorizationExceptionFilter.js.map +0 -1
- package/lib/esm/factory/exceptions/ConflictExceptionFilter.d.ts +0 -9
- package/lib/esm/factory/exceptions/ConflictExceptionFilter.js +0 -35
- package/lib/esm/factory/exceptions/ConflictExceptionFilter.js.map +0 -1
- package/lib/esm/factory/exceptions/GlobalExceptionFilter.d.ts +0 -4
- package/lib/esm/factory/exceptions/GlobalExceptionFilter.js +0 -39
- package/lib/esm/factory/exceptions/GlobalExceptionFilter.js.map +0 -1
- package/lib/esm/factory/exceptions/HttpExceptionFilter.d.ts +0 -4
- package/lib/esm/factory/exceptions/HttpExceptionFilter.js +0 -27
- package/lib/esm/factory/exceptions/HttpExceptionFilter.js.map +0 -1
- package/lib/esm/factory/exceptions/HttpResponseError.d.ts +0 -13
- package/lib/esm/factory/exceptions/HttpResponseError.js +0 -21
- package/lib/esm/factory/exceptions/HttpResponseError.js.map +0 -1
- package/lib/esm/factory/exceptions/NotFoundExceptionFilter.d.ts +0 -9
- package/lib/esm/factory/exceptions/NotFoundExceptionFilter.js +0 -35
- package/lib/esm/factory/exceptions/NotFoundExceptionFilter.js.map +0 -1
- package/lib/esm/factory/exceptions/ValidationExceptionFilter.d.ts +0 -9
- package/lib/esm/factory/exceptions/ValidationExceptionFilter.js +0 -35
- package/lib/esm/factory/exceptions/ValidationExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/AuthorizationExceptionFilter.cjs +0 -39
- package/lib/factory/exceptions/AuthorizationExceptionFilter.d.ts +0 -9
- package/lib/factory/exceptions/AuthorizationExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/ConflictExceptionFilter.cjs +0 -39
- package/lib/factory/exceptions/ConflictExceptionFilter.d.ts +0 -9
- package/lib/factory/exceptions/ConflictExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/GlobalExceptionFilter.cjs +0 -42
- package/lib/factory/exceptions/GlobalExceptionFilter.d.ts +0 -4
- package/lib/factory/exceptions/GlobalExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/HttpExceptionFilter.cjs +0 -30
- package/lib/factory/exceptions/HttpExceptionFilter.d.ts +0 -4
- package/lib/factory/exceptions/HttpExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/HttpResponseError.cjs +0 -25
- package/lib/factory/exceptions/HttpResponseError.d.ts +0 -13
- package/lib/factory/exceptions/HttpResponseError.js.map +0 -1
- package/lib/factory/exceptions/NotFoundExceptionFilter.cjs +0 -39
- package/lib/factory/exceptions/NotFoundExceptionFilter.d.ts +0 -9
- package/lib/factory/exceptions/NotFoundExceptionFilter.js.map +0 -1
- package/lib/factory/exceptions/ValidationExceptionFilter.cjs +0 -39
- package/lib/factory/exceptions/ValidationExceptionFilter.d.ts +0 -9
- package/lib/factory/exceptions/ValidationExceptionFilter.js.map +0 -1
|
@@ -1 +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,GAA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|
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 type { DecafApiProperties } 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?: DecafApiProperty[]): 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,QAA4B,EAAE;IAE9B,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 { DecafApiProperty } 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?: DecafApiProperty[]): ParameterDecorator;
|
|
@@ -16,7 +16,7 @@ const OrderedParams = createParamDecorator((order, ctx) => {
|
|
|
16
16
|
const original = (req?.params ?? {});
|
|
17
17
|
const orderList = order ?? Object.keys(original);
|
|
18
18
|
const ordered = orderList.map((k) => original[k]);
|
|
19
|
-
return { original, ordered,
|
|
19
|
+
return { raw: original, valuesInOrder: ordered, keysInOrder: orderList };
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
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.
|
|
@@ -28,4 +28,12 @@ export function DecafParams(props = []) {
|
|
|
28
28
|
const order = props.map((p) => p.name);
|
|
29
29
|
return OrderedParams(order);
|
|
30
30
|
}
|
|
31
|
+
//
|
|
32
|
+
// export function Ctx(){
|
|
33
|
+
// return createParamDecorator((data: unknown, ctx: ExecutionContext) => {
|
|
34
|
+
// const req = ctx.switchToHttp().getRequest();
|
|
35
|
+
//
|
|
36
|
+
// const Context.args
|
|
37
|
+
// })
|
|
38
|
+
// }
|
|
31
39
|
//# sourceMappingURL=DecafParams.js.map
|
|
@@ -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;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,
|
|
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,GAAG,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAC3E,CAAC,CACF,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CACzB,QAA4B,EAAE;IAE9B,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;AACD,EAAE;AACF,yBAAyB;AACzB,4EAA4E;AAC5E,mDAAmD;AACnD,EAAE;AACF,yBAAyB;AACzB,OAAO;AACP,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
-
export type
|
|
2
|
+
export type DecafApiProperty = {
|
|
3
3
|
name: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
required?: boolean;
|
|
@@ -8,11 +8,11 @@ export type DecafApiProperties = {
|
|
|
8
8
|
export type DecafModelRoute = {
|
|
9
9
|
path: string;
|
|
10
10
|
description?: string;
|
|
11
|
-
apiProperties:
|
|
11
|
+
apiProperties: DecafApiProperty[];
|
|
12
12
|
getPK: (...args: Array<string | number>) => string;
|
|
13
13
|
};
|
|
14
14
|
export type DecafParamProps = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
raw: Record<string, string | number>;
|
|
16
|
+
keysInOrder: Array<string>;
|
|
17
|
+
valuesInOrder: Array<string | number>;
|
|
18
18
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModelService, Repo } from "@decaf-ts/core";
|
|
2
|
+
import { LoggedClass, Logger } from "@decaf-ts/logging";
|
|
3
|
+
import { DecafRequestContext } from "../request/index";
|
|
4
|
+
export interface Controller {
|
|
5
|
+
log: Logger;
|
|
6
|
+
persistence: Repo<any> | ModelService<any>;
|
|
7
|
+
}
|
|
8
|
+
export declare abstract class AbstractQueryController extends LoggedClass {
|
|
9
|
+
protected readonly clientContext: DecafRequestContext;
|
|
10
|
+
protected _persistence: Repo<any> | ModelService<any>;
|
|
11
|
+
protected constructor(clientContext: DecafRequestContext);
|
|
12
|
+
get persistence(): Repo<any> | ModelService<any>;
|
|
13
|
+
}
|
|
14
|
+
export type ControllerConstructor<T> = new (...args: any[]) => T;
|
|
15
|
+
export type DecoratorBundle = {
|
|
16
|
+
method: MethodDecorator[];
|
|
17
|
+
params?: ParameterDecorator[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
2
|
+
export class AbstractQueryController extends LoggedClass {
|
|
3
|
+
constructor(clientContext) {
|
|
4
|
+
super();
|
|
5
|
+
this.clientContext = clientContext;
|
|
6
|
+
}
|
|
7
|
+
get persistence() {
|
|
8
|
+
throw new Error("Not implemented");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/decaf-model/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAQxD,MAAM,OAAgB,uBAAwB,SAAQ,WAAW;IAI/D,YAAsB,aAAkC;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED,IAAI,WAAW;QACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Controller, type DecoratorBundle } from "./types";
|
|
2
|
+
import { type DecafParamProps } from "./decorators";
|
|
3
|
+
import { DirectionLimitOffset } from "@decaf-ts/core";
|
|
4
|
+
export declare function getApiDecorators(methodName: string, routePath: string): DecoratorBundle;
|
|
5
|
+
export declare function applyApiDecorators(target: any, methodName: string, descriptor: PropertyDescriptor, decorators: DecoratorBundle): void;
|
|
6
|
+
export declare function createRouteHandler<T>(methodName: string): (this: Controller, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
|
|
7
|
+
export declare function defineRouteMethod(ControllerClass: new (...args: any[]) => any, methodName: string, handler: (...args: any[]) => any): PropertyDescriptor | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Get, Query } from "@nestjs/common";
|
|
2
|
+
import { ApiNoContentResponse, ApiOkResponse, ApiOperation, ApiParam, } from "@nestjs/swagger";
|
|
3
|
+
import { DecafParams, } from "./decorators/index.js";
|
|
4
|
+
const extractPathParams = (routePath) => {
|
|
5
|
+
return routePath
|
|
6
|
+
.split("/")
|
|
7
|
+
.filter((p) => p.startsWith(":"))
|
|
8
|
+
.map((p) => p.slice(1));
|
|
9
|
+
};
|
|
10
|
+
const apiParamSpec = (name) => ({
|
|
11
|
+
name,
|
|
12
|
+
description: `${name} parameter for the query`,
|
|
13
|
+
required: true,
|
|
14
|
+
type: String,
|
|
15
|
+
});
|
|
16
|
+
export function getApiDecorators(methodName, routePath) {
|
|
17
|
+
const apiPathParams = extractPathParams(routePath).map(apiParamSpec);
|
|
18
|
+
return {
|
|
19
|
+
method: [
|
|
20
|
+
Get(routePath),
|
|
21
|
+
...apiPathParams.map(ApiParam),
|
|
22
|
+
ApiOperation({
|
|
23
|
+
summary: `Retrieve records using custom query "${methodName}".`,
|
|
24
|
+
}),
|
|
25
|
+
ApiOkResponse({
|
|
26
|
+
description: `Results successfully retrieved.`,
|
|
27
|
+
}),
|
|
28
|
+
ApiNoContentResponse({
|
|
29
|
+
description: `No content returned by the query.`,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
params: [DecafParams(apiPathParams), Query()],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function applyApiDecorators(target, methodName, descriptor, decorators) {
|
|
36
|
+
const proto = target?.prototype ?? target;
|
|
37
|
+
decorators.method.forEach((d) => d(proto, methodName, descriptor));
|
|
38
|
+
decorators.params?.forEach((d, index) => d(proto, methodName, index));
|
|
39
|
+
}
|
|
40
|
+
export function createRouteHandler(methodName) {
|
|
41
|
+
return async function (pathParams, queryParams) {
|
|
42
|
+
const log = this.log.for(methodName);
|
|
43
|
+
try {
|
|
44
|
+
log.debug(`Invoking persistence method "${methodName}" given parameters: ${JSON.stringify(pathParams.valuesInOrder)}`);
|
|
45
|
+
const { direction, limit, offset } = queryParams;
|
|
46
|
+
return (await this.persistence[methodName](...pathParams.valuesInOrder, direction, limit, offset));
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
log.error(`Custom query "${methodName}" failed`, e);
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function defineRouteMethod(ControllerClass, methodName, handler) {
|
|
55
|
+
Object.defineProperty(ControllerClass.prototype || ControllerClass, methodName, {
|
|
56
|
+
value: handler,
|
|
57
|
+
writable: false,
|
|
58
|
+
});
|
|
59
|
+
return Object.getOwnPropertyDescriptor(ControllerClass.prototype || ControllerClass, methodName);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/decaf-model/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EACL,oBAAoB,EACpB,aAA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,wBAAwB,CACpC,eAAe,CAAC,SAAS,IAAI,eAAe,EAC5C,UAAU,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger, } from "@nestjs/common";
|
|
2
|
-
import {
|
|
2
|
+
import { DecafExceptionFilter } from "./exceptions/index.js";
|
|
3
3
|
import { SwaggerBuilder } from "./openapi/index.js";
|
|
4
4
|
import { CorsError } from "./errors/index.js";
|
|
5
5
|
/**
|
|
@@ -215,15 +215,7 @@ export class NestBootstraper {
|
|
|
215
215
|
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
216
216
|
*/
|
|
217
217
|
static useGlobalFilters(...filters) {
|
|
218
|
-
|
|
219
|
-
new HttpExceptionFilter(),
|
|
220
|
-
new ValidationExceptionFilter(),
|
|
221
|
-
new NotFoundExceptionFilter(),
|
|
222
|
-
new ConflictExceptionFilter(),
|
|
223
|
-
new AuthorizationExceptionFilter(),
|
|
224
|
-
new GlobalExceptionFilter(),
|
|
225
|
-
];
|
|
226
|
-
this.app.useGlobalFilters(...(filters.length > 0 ? filters : defaultFilters));
|
|
218
|
+
this.app.useGlobalFilters(...(filters.length > 0 ? filters : [new DecafExceptionFilter()]));
|
|
227
219
|
return this;
|
|
228
220
|
}
|
|
229
221
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestBootstraper.js","sourceRoot":"","sources":["../../../src/factory/NestBootstraper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,GAGP,MAAM,gBAAgB,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"NestBootstraper.js","sourceRoot":"","sources":["../../../src/factory/NestBootstraper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,GAGP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,8BAAqB;AACpD,OAAO,EAAE,cAAc,EAAE,2BAAkB;AAE3C,OAAO,EAAE,SAAS,EAAE,0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E,IAAW,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACjD,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/factory/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Catch } from "@nestjs/common";
|
|
8
|
+
import { BaseError, InternalError } from "@decaf-ts/db-decorators";
|
|
9
|
+
import { LoggedEnvironment } from "@decaf-ts/logging";
|
|
10
|
+
let DecafExceptionFilter = class DecafExceptionFilter {
|
|
11
|
+
catch(exception, host) {
|
|
12
|
+
const ctx = host.switchToHttp();
|
|
13
|
+
const response = ctx.getResponse();
|
|
14
|
+
const request = ctx.getRequest();
|
|
15
|
+
const isProduction = LoggedEnvironment.env === "production";
|
|
16
|
+
if (!(exception instanceof BaseError)) {
|
|
17
|
+
exception = new InternalError(exception.message);
|
|
18
|
+
}
|
|
19
|
+
response.status(exception.code).json({
|
|
20
|
+
status: exception.code,
|
|
21
|
+
error: isProduction ? exception.name : exception.message,
|
|
22
|
+
timestamp: new Date().toISOString(),
|
|
23
|
+
path: request.url,
|
|
24
|
+
method: request.method,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
DecafExceptionFilter = __decorate([
|
|
29
|
+
Catch()
|
|
30
|
+
], DecafExceptionFilter);
|
|
31
|
+
export { DecafExceptionFilter };
|
|
32
|
+
//# sourceMappingURL=DecafErrorFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecafErrorFilter.js","sourceRoot":"","sources":["../../../../src/factory/exceptions/DecafErrorFilter.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAiB,KAAK,EAAmB,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG/C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,KAAK,CAAC,SAAgB,EAAE,IAAmB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,MAAM,YAAY,GAAG,iBAAiB,CAAC,GAAG,KAAK,YAAY,CAAC;QAC5D,IAAI,CAAC,CAAC,SAAS,YAAY,SAAS,CAAC,EAAE,CAAC;YACtC,SAAS,GAAG,IAAI,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QAED,QAAQ,CAAC,MAAM,CAAE,SAAuB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;YAClD,MAAM,EAAG,SAAuB,CAAC,IAAI;YACrC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO;YACxD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnBY,oBAAoB;IADhC,KAAK,EAAE;GACK,oBAAoB,CAmBhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UseDecafFilter(): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../src/factory/exceptions/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,8BAA2B;AAE1D,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./GlobalExceptionFilter";
|
|
4
|
-
export * from "./HttpExceptionFilter";
|
|
5
|
-
export * from "./HttpResponseError";
|
|
6
|
-
export * from "./NotFoundExceptionFilter";
|
|
7
|
-
export * from "./ValidationExceptionFilter";
|
|
1
|
+
export * from "./DecafErrorFilter";
|
|
2
|
+
export * from "./decorators";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./GlobalExceptionFilter.js";
|
|
4
|
-
export * from "./HttpExceptionFilter.js";
|
|
5
|
-
export * from "./HttpResponseError.js";
|
|
6
|
-
export * from "./NotFoundExceptionFilter.js";
|
|
7
|
-
export * from "./ValidationExceptionFilter.js";
|
|
1
|
+
export * from "./DecafErrorFilter.js";
|
|
2
|
+
export * from "./decorators.js";
|
|
8
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factory/exceptions/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/factory/exceptions/index.ts"],"names":[],"mappings":"AAAA,sCAAmC;AACnC,gCAA6B"}
|
package/lib/esm/module.js
CHANGED
|
@@ -13,12 +13,15 @@ import { DecafModelModule } from "./decaf-model/index.js";
|
|
|
13
13
|
*/
|
|
14
14
|
let DecafModule = DecafModule_1 = class DecafModule {
|
|
15
15
|
static async forRootAsync(options) {
|
|
16
|
-
const { autoControllers } = options;
|
|
16
|
+
const { autoControllers, autoServices, handlers } = options;
|
|
17
17
|
const adapter = await DecafCoreModule.createAdapter(options);
|
|
18
18
|
const flavour = adapter.flavour;
|
|
19
19
|
const imports = [DecafCoreModule.forRoot(options)];
|
|
20
20
|
if (autoControllers) {
|
|
21
|
-
imports.push(DecafModelModule.forRoot(flavour,
|
|
21
|
+
imports.push(DecafModelModule.forRoot(flavour, {
|
|
22
|
+
autoServices,
|
|
23
|
+
handlers,
|
|
24
|
+
}));
|
|
22
25
|
}
|
|
23
26
|
return {
|
|
24
27
|
module: DecafModule_1,
|
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,+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;
|
|
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,YAAY,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAE5D,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,CACV,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE;gBAChC,YAAY;gBACZ,QAAQ;aACT,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,WAAW;IADvB,MAAM,CAAC,EAAE,CAAC;GACE,WAAW,CAgCvB"}
|
package/lib/esm/types.d.ts
CHANGED
|
@@ -218,15 +218,7 @@ class NestBootstraper {
|
|
|
218
218
|
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
219
219
|
*/
|
|
220
220
|
static useGlobalFilters(...filters) {
|
|
221
|
-
|
|
222
|
-
new exceptions_1.HttpExceptionFilter(),
|
|
223
|
-
new exceptions_1.ValidationExceptionFilter(),
|
|
224
|
-
new exceptions_1.NotFoundExceptionFilter(),
|
|
225
|
-
new exceptions_1.ConflictExceptionFilter(),
|
|
226
|
-
new exceptions_1.AuthorizationExceptionFilter(),
|
|
227
|
-
new exceptions_1.GlobalExceptionFilter(),
|
|
228
|
-
];
|
|
229
|
-
this.app.useGlobalFilters(...(filters.length > 0 ? filters : defaultFilters));
|
|
221
|
+
this.app.useGlobalFilters(...(filters.length > 0 ? filters : [new exceptions_1.DecafExceptionFilter()]));
|
|
230
222
|
return this;
|
|
231
223
|
}
|
|
232
224
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestBootstraper.js","sourceRoot":"","sources":["../../src/factory/NestBootstraper.ts"],"names":[],"mappings":";;;AAAA,2CAKwB;AACxB,
|
|
1
|
+
{"version":3,"file":"NestBootstraper.js","sourceRoot":"","sources":["../../src/factory/NestBootstraper.ts"],"names":[],"mappings":";;;AAAA,2CAKwB;AACxB,uDAAoD;AACpD,iDAA2C;AAE3C,+CAAqC;AAiCrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAa,eAAe;IAI1B;;;;;;;;;OASG;IACK,MAAM,KAAK,MAAM;QACvB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,WAAW;YACX,IAAI,CAAC,OAAO,GAAG,IAAI,eAAM,CAAC,eAAe,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,UAAU,CAAC,GAAqB;QACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,YAAY,CAAC,YAAqB;QACvC,IAAI,CAAC,OAAO,GAAG,YAAY,IAAI,IAAI,eAAM,CAAC,eAAe,CAAC,CAAC;QAC3D,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH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CAAC,CAAC,CACjE,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,qBAAqB,CAAC,GAAG,YAA+B;QAC7D,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC;YACzB,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,GAAG,YAAY,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,KAAK,CAChB,OAAe,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAC/C,OAA2B,SAAS,EACpC,MAAe,IAAI;QAEnB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YACjD,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzOD,0CAyOC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/factory/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DecafExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
12
|
+
const logging_1 = require("@decaf-ts/logging");
|
|
13
|
+
let DecafExceptionFilter = class DecafExceptionFilter {
|
|
14
|
+
catch(exception, host) {
|
|
15
|
+
const ctx = host.switchToHttp();
|
|
16
|
+
const response = ctx.getResponse();
|
|
17
|
+
const request = ctx.getRequest();
|
|
18
|
+
const isProduction = logging_1.LoggedEnvironment.env === "production";
|
|
19
|
+
if (!(exception instanceof db_decorators_1.BaseError)) {
|
|
20
|
+
exception = new db_decorators_1.InternalError(exception.message);
|
|
21
|
+
}
|
|
22
|
+
response.status(exception.code).json({
|
|
23
|
+
status: exception.code,
|
|
24
|
+
error: isProduction ? exception.name : exception.message,
|
|
25
|
+
timestamp: new Date().toISOString(),
|
|
26
|
+
path: request.url,
|
|
27
|
+
method: request.method,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.DecafExceptionFilter = DecafExceptionFilter;
|
|
32
|
+
exports.DecafExceptionFilter = DecafExceptionFilter = __decorate([
|
|
33
|
+
(0, common_1.Catch)()
|
|
34
|
+
], DecafExceptionFilter);
|
|
35
|
+
//# sourceMappingURL=DecafErrorFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DecafErrorFilter.js","sourceRoot":"","sources":["../../../src/factory/exceptions/DecafErrorFilter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAuE;AACvE,2DAAmE;AACnE,+CAAsD;AAG/C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,KAAK,CAAC,SAAgB,EAAE,IAAmB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC;QAEjC,MAAM,YAAY,GAAG,2BAAiB,CAAC,GAAG,KAAK,YAAY,CAAC;QAC5D,IAAI,CAAC,CAAC,SAAS,YAAY,yBAAS,CAAC,EAAE,CAAC;YACtC,SAAS,GAAG,IAAI,6BAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QAED,QAAQ,CAAC,MAAM,CAAE,SAAuB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;YAClD,MAAM,EAAG,SAAuB,CAAC,IAAI;YACrC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO;YACxD,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,OAAO,CAAC,GAAG;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnBY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,cAAK,GAAE;GACK,oBAAoB,CAmBhC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseDecafFilter = UseDecafFilter;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const DecafErrorFilter_1 = require("./DecafErrorFilter.cjs");
|
|
6
|
+
function UseDecafFilter() {
|
|
7
|
+
return (0, common_1.UseFilters)(new DecafErrorFilter_1.DecafExceptionFilter());
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UseDecafFilter(): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/factory/exceptions/decorators.ts"],"names":[],"mappings":";;AAGA,wCAEC;AALD,2CAA4C;AAC5C,6DAA0D;AAE1D,SAAgB,cAAc;IAC5B,OAAO,IAAA,mBAAU,EAAC,IAAI,uCAAoB,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -14,11 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./GlobalExceptionFilter.cjs"), exports);
|
|
20
|
-
__exportStar(require("./HttpExceptionFilter.cjs"), exports);
|
|
21
|
-
__exportStar(require("./HttpResponseError.cjs"), exports);
|
|
22
|
-
__exportStar(require("./NotFoundExceptionFilter.cjs"), exports);
|
|
23
|
-
__exportStar(require("./ValidationExceptionFilter.cjs"), exports);
|
|
17
|
+
__exportStar(require("./DecafErrorFilter.cjs"), exports);
|
|
18
|
+
__exportStar(require("./decorators.cjs"), exports);
|
|
24
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./GlobalExceptionFilter";
|
|
4
|
-
export * from "./HttpExceptionFilter";
|
|
5
|
-
export * from "./HttpResponseError";
|
|
6
|
-
export * from "./NotFoundExceptionFilter";
|
|
7
|
-
export * from "./ValidationExceptionFilter";
|
|
1
|
+
export * from "./DecafErrorFilter";
|
|
2
|
+
export * from "./decorators";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/factory/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/factory/exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAmC;AACnC,mDAA6B"}
|
package/lib/module.cjs
CHANGED
|
@@ -16,12 +16,15 @@ const decaf_model_1 = require("./decaf-model/index.cjs");
|
|
|
16
16
|
*/
|
|
17
17
|
let DecafModule = DecafModule_1 = class DecafModule {
|
|
18
18
|
static async forRootAsync(options) {
|
|
19
|
-
const { autoControllers } = options;
|
|
19
|
+
const { autoControllers, autoServices, handlers } = options;
|
|
20
20
|
const adapter = await core_module_1.DecafCoreModule.createAdapter(options);
|
|
21
21
|
const flavour = adapter.flavour;
|
|
22
22
|
const imports = [core_module_1.DecafCoreModule.forRoot(options)];
|
|
23
23
|
if (autoControllers) {
|
|
24
|
-
imports.push(decaf_model_1.DecafModelModule.forRoot(flavour,
|
|
24
|
+
imports.push(decaf_model_1.DecafModelModule.forRoot(flavour, {
|
|
25
|
+
autoServices,
|
|
26
|
+
handlers,
|
|
27
|
+
}));
|
|
25
28
|
}
|
|
26
29
|
return {
|
|
27
30
|
module: DecafModule_1,
|
package/lib/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+E;AAE/E,mDAAgD;AAChD,yDAAiD;AAEjD;;GAEG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,OAA2B;QAE3B,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+E;AAE/E,mDAAgD;AAChD,yDAAiD;AAEjD;;GAEG;AAEI,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,KAAK,CAAC,YAAY,CACvB,OAA2B;QAE3B,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAE5D,MAAM,OAAO,GAAG,MAAM,6BAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAEhC,MAAM,OAAO,GAOG,CAAC,6BAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnD,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CACV,8BAAgB,CAAC,OAAO,CAAC,OAAO,EAAE;gBAChC,YAAY;gBACZ,QAAQ;aACT,CAAC,CACH,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CAgCvB"}
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/for-nest",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "NestJS decaf integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -75,7 +75,8 @@
|
|
|
75
75
|
},
|
|
76
76
|
"homepage": "https://github.com/decaf-ts/for-nest#readme",
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@decaf-ts/for-fabric": "
|
|
78
|
+
"@decaf-ts/for-fabric": "latest",
|
|
79
|
+
"@decaf-ts/for-http": "latest",
|
|
79
80
|
"@decaf-ts/utils": "latest",
|
|
80
81
|
"@eslint/js": "^9.25.1",
|
|
81
82
|
"@nestjs/cli": "^11.0.0",
|
|
@@ -93,7 +94,6 @@
|
|
|
93
94
|
"@decaf-ts/decorator-validation": "latest",
|
|
94
95
|
"@decaf-ts/injectable-decorators": "latest",
|
|
95
96
|
"@decaf-ts/logging": "latest",
|
|
96
|
-
"@decaf-ts/reflection": "latest",
|
|
97
97
|
"@decaf-ts/transactional-decorators": "latest",
|
|
98
98
|
"@nestjs/common": "^11.0.1"
|
|
99
99
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ArgumentsHost, ExceptionFilter } from "@nestjs/common";
|
|
2
|
-
export declare class AuthorizationError extends Error {
|
|
3
|
-
readonly status: number;
|
|
4
|
-
readonly code: string;
|
|
5
|
-
constructor(message?: string);
|
|
6
|
-
}
|
|
7
|
-
export declare class AuthorizationExceptionFilter implements ExceptionFilter {
|
|
8
|
-
catch(exception: AuthorizationError, host: ArgumentsHost): void;
|
|
9
|
-
}
|