@decaf-ts/for-nest 0.6.0 → 0.8.0
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/lib/cjs/bin/cli.cjs +3 -2
- package/lib/cjs/bin/cli.cjs.map +1 -0
- package/lib/cjs/cli-module.cjs +2 -1
- package/lib/cjs/cli-module.cjs.map +1 -0
- package/lib/cjs/constants.cjs +1 -0
- package/lib/cjs/constants.cjs.map +1 -0
- package/lib/cjs/controllers.cjs +3 -2
- package/lib/cjs/controllers.cjs.map +1 -0
- package/lib/cjs/core-module.cjs +31 -25
- package/lib/cjs/core-module.cjs.map +1 -0
- package/lib/cjs/decaf-model/DecafModelModule.cjs +11 -6
- package/lib/cjs/decaf-model/DecafModelModule.cjs.map +1 -0
- package/lib/cjs/decaf-model/FromModelController.cjs +69 -63
- package/lib/cjs/decaf-model/FromModelController.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/decorators.cjs +5 -4
- package/lib/cjs/decaf-model/decorators/decorators.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/index.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/index.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/types.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/types.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/utils.cjs +1 -0
- package/lib/cjs/decaf-model/decorators/utils.cjs.map +1 -0
- package/lib/cjs/decaf-model/index.cjs +1 -0
- package/lib/cjs/decaf-model/index.cjs.map +1 -0
- package/lib/cjs/decaf-model/types.cjs +1 -0
- package/lib/cjs/decaf-model/types.cjs.map +1 -0
- package/lib/cjs/decaf-model/utils.cjs +5 -4
- package/lib/cjs/decaf-model/utils.cjs.map +1 -0
- package/lib/cjs/decoration.cjs +15 -14
- package/lib/cjs/decoration.cjs.map +1 -0
- package/lib/cjs/events-module/DecafStreamModule.cjs +15 -10
- package/lib/cjs/events-module/DecafStreamModule.cjs.map +1 -0
- package/lib/cjs/events-module/EventsController.cjs +20 -14
- package/lib/cjs/events-module/EventsController.cjs.map +1 -0
- package/lib/cjs/events-module/constant.cjs +1 -0
- package/lib/cjs/events-module/constant.cjs.map +1 -0
- package/lib/cjs/events-module/index.cjs +1 -0
- package/lib/cjs/events-module/index.cjs.map +1 -0
- package/lib/cjs/events-module/utils.cjs +1 -0
- package/lib/cjs/events-module/utils.cjs.map +1 -0
- package/lib/cjs/factory/NestBootstraper.cjs +7 -6
- package/lib/cjs/factory/NestBootstraper.cjs.map +1 -0
- package/lib/cjs/factory/errors/cors.cjs +1 -0
- package/lib/cjs/factory/errors/cors.cjs.map +1 -0
- package/lib/cjs/factory/errors/index.cjs +1 -0
- package/lib/cjs/factory/errors/index.cjs.map +1 -0
- package/lib/cjs/factory/errors/throttling.cjs +1 -0
- package/lib/cjs/factory/errors/throttling.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs +11 -6
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/decorators.cjs +5 -4
- package/lib/cjs/factory/exceptions/decorators.cjs.map +1 -0
- package/lib/cjs/factory/exceptions/index.cjs +1 -0
- package/lib/cjs/factory/exceptions/index.cjs.map +1 -0
- package/lib/cjs/factory/index.cjs +1 -0
- package/lib/cjs/factory/index.cjs.map +1 -0
- package/lib/cjs/factory/openapi/DtoBuilder.cjs +8 -7
- package/lib/cjs/factory/openapi/DtoBuilder.cjs.map +1 -0
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs +7 -6
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs.map +1 -0
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs +3 -2
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs.map +1 -0
- package/lib/cjs/factory/openapi/constants.cjs +1 -0
- package/lib/cjs/factory/openapi/constants.cjs.map +1 -0
- package/lib/cjs/factory/openapi/index.cjs +1 -0
- package/lib/cjs/factory/openapi/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +18 -17
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/interceptors/AuthInterceptor.cjs +16 -10
- package/lib/cjs/interceptors/AuthInterceptor.cjs.map +1 -0
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs +14 -8
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs.map +1 -0
- package/lib/cjs/interceptors/context.cjs +1 -0
- package/lib/cjs/interceptors/context.cjs.map +1 -0
- package/lib/cjs/interceptors/index.cjs +1 -0
- package/lib/cjs/interceptors/index.cjs.map +1 -0
- package/lib/cjs/module.cjs +16 -11
- package/lib/cjs/module.cjs.map +1 -0
- package/lib/cjs/overrides/Adapter.cjs +1 -0
- package/lib/cjs/overrides/Adapter.cjs.map +1 -0
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs +3 -2
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs.map +1 -0
- package/lib/cjs/overrides/constants.cjs +1 -0
- package/lib/cjs/overrides/constants.cjs.map +1 -0
- package/lib/cjs/overrides/decoration.cjs +8 -7
- package/lib/cjs/overrides/decoration.cjs.map +1 -0
- package/lib/cjs/overrides/helpers.cjs +8 -7
- package/lib/cjs/overrides/helpers.cjs.map +1 -0
- package/lib/cjs/overrides/index.cjs +1 -0
- package/lib/cjs/overrides/index.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +1 -0
- package/lib/cjs/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/ram/RamRequestTransformer.cjs +1 -0
- package/lib/cjs/ram/RamRequestTransformer.cjs.map +1 -0
- package/lib/cjs/ram/index.cjs +1 -0
- package/lib/cjs/ram/index.cjs.map +1 -0
- package/lib/cjs/request/DecafAuthHandler.cjs +1 -0
- package/lib/cjs/request/DecafAuthHandler.cjs.map +1 -0
- package/lib/cjs/request/DecafHandlerExecutor.cjs +16 -10
- package/lib/cjs/request/DecafHandlerExecutor.cjs.map +1 -0
- package/lib/cjs/request/DecafRequestContext.cjs +12 -6
- package/lib/cjs/request/DecafRequestContext.cjs.map +1 -0
- package/lib/cjs/request/DecafResponseInterceptor.cjs +13 -7
- package/lib/cjs/request/DecafResponseInterceptor.cjs.map +1 -0
- package/lib/cjs/request/index.cjs +1 -0
- package/lib/cjs/request/index.cjs.map +1 -0
- package/lib/cjs/types.cjs +1 -0
- package/lib/cjs/types.cjs.map +1 -0
- package/lib/cjs/utils.cjs +1 -0
- package/lib/cjs/utils.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/bin/cli.d.cts +1 -0
- package/lib/types/bin/cli.d.mts +1 -0
- package/lib/types/cli-module.d.cts +11 -0
- package/lib/types/cli-module.d.mts +11 -0
- package/lib/types/constants.d.cts +15 -0
- package/lib/types/constants.d.mts +15 -0
- package/lib/types/controllers.d.cts +22 -0
- package/lib/types/controllers.d.mts +22 -0
- package/lib/types/core-module.d.cts +17 -0
- package/lib/types/core-module.d.mts +17 -0
- package/lib/types/decaf-model/DecafModelModule.d.cts +9 -0
- package/lib/types/decaf-model/DecafModelModule.d.mts +9 -0
- package/lib/types/decaf-model/FromModelController.d.cts +61 -0
- package/lib/types/decaf-model/FromModelController.d.mts +61 -0
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.cts +30 -0
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.mts +30 -0
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.cts +13 -0
- package/lib/types/decaf-model/decorators/ApiParamsFromModel.d.mts +13 -0
- package/lib/types/decaf-model/decorators/DecafBody.d.cts +5 -0
- package/lib/types/decaf-model/decorators/DecafBody.d.mts +5 -0
- package/lib/types/decaf-model/decorators/DecafParams.d.cts +9 -0
- package/lib/types/decaf-model/decorators/DecafParams.d.mts +9 -0
- package/lib/types/decaf-model/decorators/decorators.d.cts +29 -0
- package/lib/types/decaf-model/decorators/decorators.d.mts +29 -0
- package/lib/types/decaf-model/decorators/index.d.cts +7 -0
- package/lib/types/decaf-model/decorators/index.d.mts +7 -0
- package/lib/types/decaf-model/decorators/types.d.cts +23 -0
- package/lib/types/decaf-model/decorators/types.d.mts +23 -0
- package/lib/types/decaf-model/decorators/utils.d.cts +11 -0
- package/lib/types/decaf-model/decorators/utils.d.mts +11 -0
- package/lib/types/decaf-model/index.d.cts +3 -0
- package/lib/types/decaf-model/index.d.mts +3 -0
- package/lib/types/decaf-model/types.d.cts +7 -0
- package/lib/types/decaf-model/types.d.mts +7 -0
- package/lib/types/decaf-model/utils.d.cts +10 -0
- package/lib/types/decaf-model/utils.d.mts +10 -0
- package/lib/types/decoration.d.cts +1 -0
- package/lib/types/decoration.d.mts +1 -0
- package/lib/types/events-module/DecafStreamModule.d.cts +4 -0
- package/lib/types/events-module/DecafStreamModule.d.mts +4 -0
- package/lib/types/events-module/EventsController.d.cts +11 -0
- package/lib/types/events-module/EventsController.d.mts +11 -0
- package/lib/types/events-module/constant.d.cts +1 -0
- package/lib/types/events-module/constant.d.mts +1 -0
- package/lib/types/events-module/index.d.cts +2 -0
- package/lib/types/events-module/index.d.mts +2 -0
- package/lib/types/events-module/utils.d.cts +1 -0
- package/lib/types/events-module/utils.d.mts +1 -0
- package/lib/types/factory/NestBootstraper.d.cts +224 -0
- package/lib/types/factory/NestBootstraper.d.mts +224 -0
- package/lib/types/factory/errors/cors.d.cts +4 -0
- package/lib/types/factory/errors/cors.d.mts +4 -0
- package/lib/types/factory/errors/index.d.cts +1 -0
- package/lib/types/factory/errors/index.d.mts +1 -0
- package/lib/types/factory/errors/throttling.d.cts +4 -0
- package/lib/types/factory/errors/throttling.d.mts +4 -0
- package/lib/types/factory/exceptions/DecafErrorFilter.d.cts +4 -0
- package/lib/types/factory/exceptions/DecafErrorFilter.d.mts +4 -0
- package/lib/types/factory/exceptions/decorators.d.cts +2 -0
- package/lib/types/factory/exceptions/decorators.d.mts +2 -0
- package/lib/types/factory/exceptions/index.d.cts +2 -0
- package/lib/types/factory/exceptions/index.d.mts +2 -0
- package/lib/types/factory/index.d.cts +4 -0
- package/lib/types/factory/index.d.mts +4 -0
- package/lib/types/factory/openapi/DtoBuilder.d.cts +25 -0
- package/lib/types/factory/openapi/DtoBuilder.d.mts +25 -0
- package/lib/types/factory/openapi/SwaggerBuilder.d.cts +10 -0
- package/lib/types/factory/openapi/SwaggerBuilder.d.mts +10 -0
- package/lib/types/factory/openapi/SwaggerCustomUI.d.cts +22 -0
- package/lib/types/factory/openapi/SwaggerCustomUI.d.mts +22 -0
- package/lib/types/factory/openapi/constants.d.cts +27 -0
- package/lib/types/factory/openapi/constants.d.mts +27 -0
- package/lib/types/factory/openapi/index.d.cts +2 -0
- package/lib/types/factory/openapi/index.d.mts +2 -0
- package/lib/types/index.d.cts +43 -0
- package/lib/types/index.d.mts +43 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interceptors/AuthInterceptor.d.cts +10 -0
- package/lib/types/interceptors/AuthInterceptor.d.mts +10 -0
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.cts +57 -0
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.mts +57 -0
- package/lib/types/interceptors/context.d.cts +6 -0
- package/lib/types/interceptors/context.d.mts +6 -0
- package/lib/types/interceptors/index.d.cts +3 -0
- package/lib/types/interceptors/index.d.mts +3 -0
- package/lib/types/module.d.cts +8 -0
- package/lib/types/module.d.mts +8 -0
- package/lib/types/overrides/Adapter.d.cts +13 -0
- package/lib/types/overrides/Adapter.d.mts +13 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.cts +8 -0
- package/lib/types/overrides/ModelBuilderExtensions.d.mts +8 -0
- package/lib/types/overrides/constants.d.cts +21 -0
- package/lib/types/overrides/constants.d.mts +21 -0
- package/lib/types/overrides/decoration.d.cts +30 -0
- package/lib/types/overrides/decoration.d.mts +30 -0
- package/lib/types/overrides/helpers.d.cts +11 -0
- package/lib/types/overrides/helpers.d.mts +11 -0
- package/lib/types/overrides/index.d.cts +6 -0
- package/lib/types/overrides/index.d.mts +6 -0
- package/lib/types/overrides/overrides.d.cts +1 -0
- package/lib/types/overrides/overrides.d.mts +1 -0
- package/lib/types/ram/RamRequestTransformer.d.cts +5 -0
- package/lib/types/ram/RamRequestTransformer.d.mts +5 -0
- package/lib/types/ram/index.d.cts +1 -0
- package/lib/types/ram/index.d.mts +1 -0
- package/lib/types/request/DecafAuthHandler.d.cts +10 -0
- package/lib/types/request/DecafAuthHandler.d.mts +10 -0
- package/lib/types/request/DecafHandlerExecutor.d.cts +52 -0
- package/lib/types/request/DecafHandlerExecutor.d.mts +52 -0
- package/lib/types/request/DecafRequestContext.d.cts +11 -0
- package/lib/types/request/DecafRequestContext.d.mts +11 -0
- package/lib/types/request/DecafResponseInterceptor.d.cts +8 -0
- package/lib/types/request/DecafResponseInterceptor.d.mts +8 -0
- package/lib/types/request/index.d.cts +4 -0
- package/lib/types/request/index.d.mts +4 -0
- package/lib/types/types.d.cts +88 -0
- package/lib/types/types.d.mts +88 -0
- package/lib/types/utils.d.cts +2 -0
- package/lib/types/utils.d.mts +2 -0
- package/package.json +4 -4
- package/lib/cjs/bin/cli.js.map +0 -1
- package/lib/cjs/cli-module.js.map +0 -1
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/controllers.js.map +0 -1
- package/lib/cjs/core-module.js.map +0 -1
- package/lib/cjs/decaf-model/DecafModelModule.js.map +0 -1
- package/lib/cjs/decaf-model/FromModelController.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/DecafBody.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/DecafParams.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/decorators.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/index.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/types.js.map +0 -1
- package/lib/cjs/decaf-model/decorators/utils.js.map +0 -1
- package/lib/cjs/decaf-model/index.js.map +0 -1
- package/lib/cjs/decaf-model/types.js.map +0 -1
- package/lib/cjs/decaf-model/utils.js.map +0 -1
- package/lib/cjs/decoration.js.map +0 -1
- package/lib/cjs/events-module/DecafStreamModule.js.map +0 -1
- package/lib/cjs/events-module/EventsController.js.map +0 -1
- package/lib/cjs/events-module/constant.js.map +0 -1
- package/lib/cjs/events-module/index.js.map +0 -1
- package/lib/cjs/events-module/utils.js.map +0 -1
- package/lib/cjs/factory/NestBootstraper.js.map +0 -1
- package/lib/cjs/factory/errors/cors.js.map +0 -1
- package/lib/cjs/factory/errors/index.js.map +0 -1
- package/lib/cjs/factory/errors/throttling.js.map +0 -1
- package/lib/cjs/factory/exceptions/DecafErrorFilter.js.map +0 -1
- package/lib/cjs/factory/exceptions/decorators.js.map +0 -1
- package/lib/cjs/factory/exceptions/index.js.map +0 -1
- package/lib/cjs/factory/index.js.map +0 -1
- package/lib/cjs/factory/openapi/DtoBuilder.js.map +0 -1
- package/lib/cjs/factory/openapi/SwaggerBuilder.js.map +0 -1
- package/lib/cjs/factory/openapi/SwaggerCustomUI.js.map +0 -1
- package/lib/cjs/factory/openapi/constants.js.map +0 -1
- package/lib/cjs/factory/openapi/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interceptors/AuthInterceptor.js.map +0 -1
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.js.map +0 -1
- package/lib/cjs/interceptors/context.js.map +0 -1
- package/lib/cjs/interceptors/index.js.map +0 -1
- package/lib/cjs/module.js.map +0 -1
- package/lib/cjs/overrides/Adapter.js.map +0 -1
- package/lib/cjs/overrides/ModelBuilderExtensions.js.map +0 -1
- package/lib/cjs/overrides/constants.js.map +0 -1
- package/lib/cjs/overrides/decoration.js.map +0 -1
- package/lib/cjs/overrides/helpers.js.map +0 -1
- package/lib/cjs/overrides/index.js.map +0 -1
- package/lib/cjs/overrides/overrides.js.map +0 -1
- package/lib/cjs/ram/RamRequestTransformer.js.map +0 -1
- package/lib/cjs/ram/index.js.map +0 -1
- package/lib/cjs/request/DecafAuthHandler.js.map +0 -1
- package/lib/cjs/request/DecafHandlerExecutor.js.map +0 -1
- package/lib/cjs/request/DecafRequestContext.js.map +0 -1
- package/lib/cjs/request/DecafResponseInterceptor.js.map +0 -1
- package/lib/cjs/request/index.js.map +0 -1
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/utils.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DecafApiProperty } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* @description A higher-level decorator factory that leverages `OrderedParams` to extract route parameters in a specific order derived from a list of `ApiParam` definitions.
|
|
4
|
+
* @summary `DecafParams` computes the order of route parameters based on the provided `ApiParam[]` specification (using each element’s `name`), then applies `OrderedParams(order)` as a parameter decorator. This enables parameter-level binding that remains consistent with the documented API parameter metadata.
|
|
5
|
+
* @param {ApiParam[]} [props=[]] Array of `ApiParam` definitions whose `name` fields determine the parameter extraction order.
|
|
6
|
+
* @return {ParameterDecorator} A NestJS parameter decorator that injects an ordered list of parameters and metadata into the controller method argument.
|
|
7
|
+
*/
|
|
8
|
+
export declare function DecafParams(props?: DecafApiProperty[]): ParameterDecorator;
|
|
9
|
+
export declare const DecafQuery: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
+
/**
|
|
3
|
+
* A decorator function that applies authentication and authorization metadata to a NestJS controller or method.
|
|
4
|
+
*
|
|
5
|
+
* @param model - The model name or constructor function for the resource being accessed.
|
|
6
|
+
* If a string is provided, it is used as the resource name.
|
|
7
|
+
* If a constructor function is provided, its name is used as the resource name.
|
|
8
|
+
*
|
|
9
|
+
* @returns - A function that applies the authentication and authorization decorators to the target.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Controller('users')
|
|
14
|
+
* @Auth('User')
|
|
15
|
+
* export class UsersController {
|
|
16
|
+
* // ...
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Controller('users')
|
|
23
|
+
* @Auth(User)
|
|
24
|
+
* export class UsersController {
|
|
25
|
+
* // ...
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function Auth(model?: string | Constructor): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
+
/**
|
|
3
|
+
* A decorator function that applies authentication and authorization metadata to a NestJS controller or method.
|
|
4
|
+
*
|
|
5
|
+
* @param model - The model name or constructor function for the resource being accessed.
|
|
6
|
+
* If a string is provided, it is used as the resource name.
|
|
7
|
+
* If a constructor function is provided, its name is used as the resource name.
|
|
8
|
+
*
|
|
9
|
+
* @returns - A function that applies the authentication and authorization decorators to the target.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @Controller('users')
|
|
14
|
+
* @Auth('User')
|
|
15
|
+
* export class UsersController {
|
|
16
|
+
* // ...
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Controller('users')
|
|
23
|
+
* @Auth(User)
|
|
24
|
+
* export class UsersController {
|
|
25
|
+
* // ...
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function Auth(model?: string | Constructor): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
+
export type DecafApiProperty = {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
type?: any;
|
|
7
|
+
};
|
|
8
|
+
export type DecafModelRoute = {
|
|
9
|
+
path: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
apiProperties: DecafApiProperty[];
|
|
12
|
+
getPK: (...args: Array<string | number>) => string;
|
|
13
|
+
};
|
|
14
|
+
export type DecafParamProps = {
|
|
15
|
+
raw: Record<string, string | number>;
|
|
16
|
+
keysInOrder: Array<string>;
|
|
17
|
+
valuesInOrder: Array<string | number>;
|
|
18
|
+
};
|
|
19
|
+
export interface DecafRouteDecOptions {
|
|
20
|
+
path: string;
|
|
21
|
+
httpMethod: HttpVerbs;
|
|
22
|
+
handler: PropertyDescriptor;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type HttpVerbs = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
2
|
+
export type DecafApiProperty = {
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
type?: any;
|
|
7
|
+
};
|
|
8
|
+
export type DecafModelRoute = {
|
|
9
|
+
path: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
apiProperties: DecafApiProperty[];
|
|
12
|
+
getPK: (...args: Array<string | number>) => string;
|
|
13
|
+
};
|
|
14
|
+
export type DecafParamProps = {
|
|
15
|
+
raw: Record<string, string | number>;
|
|
16
|
+
keysInOrder: Array<string>;
|
|
17
|
+
valuesInOrder: Array<string | number>;
|
|
18
|
+
};
|
|
19
|
+
export interface DecafRouteDecOptions {
|
|
20
|
+
path: string;
|
|
21
|
+
httpMethod: HttpVerbs;
|
|
22
|
+
handler: PropertyDescriptor;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpVerbs } from "./types.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Maps an HTTP verb to its corresponding NestJS method decorator.
|
|
4
|
+
*
|
|
5
|
+
* @param verb - HTTP verb to be converted (e.g. GET, POST, PUT, PATCH, DELETE).
|
|
6
|
+
* @returns A NestJS method decorator matching the provided HTTP verb.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} If the provided HTTP verb is not supported or not mapped
|
|
9
|
+
* to a NestJS decorator.
|
|
10
|
+
*/
|
|
11
|
+
export declare function HttpVerbToDecorator(verb: HttpVerbs): (path?: string) => MethodDecorator;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpVerbs } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Maps an HTTP verb to its corresponding NestJS method decorator.
|
|
4
|
+
*
|
|
5
|
+
* @param verb - HTTP verb to be converted (e.g. GET, POST, PUT, PATCH, DELETE).
|
|
6
|
+
* @returns A NestJS method decorator matching the provided HTTP verb.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} If the provided HTTP verb is not supported or not mapped
|
|
9
|
+
* to a NestJS decorator.
|
|
10
|
+
*/
|
|
11
|
+
export declare function HttpVerbToDecorator(verb: HttpVerbs): (path?: string) => MethodDecorator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DecafModelController } from "../controllers.cjs";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
export type ControllerConstructor<T extends Model<boolean>> = new (...args: any[]) => DecafModelController<T>;
|
|
4
|
+
export type DecoratorBundle = {
|
|
5
|
+
method: MethodDecorator[];
|
|
6
|
+
params?: ParameterDecorator[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DecafModelController } from "../controllers.js";
|
|
2
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
+
export type ControllerConstructor<T extends Model<boolean>> = new (...args: any[]) => DecafModelController<T>;
|
|
4
|
+
export type DecoratorBundle = {
|
|
5
|
+
method: MethodDecorator[];
|
|
6
|
+
params?: ParameterDecorator[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DecoratorBundle } from "./types.cjs";
|
|
2
|
+
import { type DecafParamProps, HttpVerbs } from "./decorators/index.cjs";
|
|
3
|
+
import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
import { DecafModelController } from "../controllers.cjs";
|
|
6
|
+
export declare function getApiDecorators(methodName: string, routePath: string, httpVerb: HttpVerbs, includeQueryParams?: boolean): DecoratorBundle;
|
|
7
|
+
export declare function applyApiDecorators(target: any, methodName: string, descriptor: PropertyDescriptor, decorators: DecoratorBundle): void;
|
|
8
|
+
export declare function resolvePersistenceMethod<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, methodName: string, ...args: any[]): any;
|
|
9
|
+
export declare function createRouteHandler<T>(methodName: string): (this: DecafModelController<any>, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
|
|
10
|
+
export declare function defineRouteMethod(ControllerClass: new (...args: any[]) => any, methodName: string, handler: (...args: any[]) => any): PropertyDescriptor | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DecoratorBundle } from "./types.js";
|
|
2
|
+
import { type DecafParamProps, HttpVerbs } from "./decorators/index.js";
|
|
3
|
+
import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
|
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
+
import { DecafModelController } from "../controllers.js";
|
|
6
|
+
export declare function getApiDecorators(methodName: string, routePath: string, httpVerb: HttpVerbs, includeQueryParams?: boolean): DecoratorBundle;
|
|
7
|
+
export declare function applyApiDecorators(target: any, methodName: string, descriptor: PropertyDescriptor, decorators: DecoratorBundle): void;
|
|
8
|
+
export declare function resolvePersistenceMethod<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, methodName: string, ...args: any[]): any;
|
|
9
|
+
export declare function createRouteHandler<T>(methodName: string): (this: DecafModelController<any>, pathParams: DecafParamProps, queryParams: DirectionLimitOffset) => Promise<T>;
|
|
10
|
+
export declare function defineRouteMethod(ControllerClass: new (...args: any[]) => any, methodName: string, handler: (...args: any[]) => any): PropertyDescriptor | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DecafController } from "../controllers.cjs";
|
|
2
|
+
import { DecafRequestContext } from "../request/index.cjs";
|
|
3
|
+
import { MessageEvent } from "@nestjs/common";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
5
|
+
import { DecafServerCtx } from "../constants.cjs";
|
|
6
|
+
export declare class EventsController extends DecafController<DecafServerCtx> {
|
|
7
|
+
private readonly adapters;
|
|
8
|
+
constructor(clientContext: DecafRequestContext, flavours: string[]);
|
|
9
|
+
listen(): Observable<MessageEvent>;
|
|
10
|
+
listenForModel(model: string): Observable<MessageEvent>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DecafController } from "../controllers.js";
|
|
2
|
+
import { DecafRequestContext } from "../request/index.js";
|
|
3
|
+
import { MessageEvent } from "@nestjs/common";
|
|
4
|
+
import { Observable } from "rxjs";
|
|
5
|
+
import { DecafServerCtx } from "../constants.js";
|
|
6
|
+
export declare class EventsController extends DecafController<DecafServerCtx> {
|
|
7
|
+
private readonly adapters;
|
|
8
|
+
constructor(clientContext: DecafRequestContext, flavours: string[]);
|
|
9
|
+
listen(): Observable<MessageEvent>;
|
|
10
|
+
listenForModel(model: string): Observable<MessageEvent>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LISTENING_ADAPTERS_FLAVOURS: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LISTENING_ADAPTERS_FLAVOURS: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeEventResponse(args: any[]): unknown[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeEventResponse(args: any[]): unknown[];
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { INestApplication, Logger, NestInterceptor, PipeTransform } from "@nestjs/common";
|
|
2
|
+
/**
|
|
3
|
+
* @description
|
|
4
|
+
* Defines all customizable parameters for Swagger setup.
|
|
5
|
+
*
|
|
6
|
+
* @summary
|
|
7
|
+
* This interface allows developers to customize how Swagger UI is configured
|
|
8
|
+
* within the NestJS application. It includes parameters for titles, paths,
|
|
9
|
+
* color schemes, and asset paths to tailor the API documentation experience.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} title - Title displayed in Swagger UI.
|
|
12
|
+
* @param {string} description - Description shown below the title.
|
|
13
|
+
* @param {string} version - API version displayed in the documentation.
|
|
14
|
+
* @param {string} [path] - Optional path where Swagger will be available.
|
|
15
|
+
* @param {boolean} [persistAuthorization] - Whether authorization tokens persist across reloads.
|
|
16
|
+
* @param {string} [assetsPath] - Path to custom assets for Swagger UI.
|
|
17
|
+
* @param {string} [topbarBgColor] - Custom background color for the Swagger top bar.
|
|
18
|
+
* @param {string} [topbarIconPath] - Path to a custom icon displayed in the top bar.
|
|
19
|
+
* @param {string} [faviconPath] - Path to a custom favicon.
|
|
20
|
+
*/
|
|
21
|
+
export interface SwaggerSetupOptions {
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
version: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
persistAuthorization?: boolean;
|
|
27
|
+
assetsPath?: string;
|
|
28
|
+
topbarBgColor?: string;
|
|
29
|
+
topbarIconPath?: string;
|
|
30
|
+
faviconPath?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Path to expose the OpenAPI specification in JSON format.
|
|
33
|
+
* Example: /api/openapi.json
|
|
34
|
+
*/
|
|
35
|
+
openApiJsonPath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Path to expose the OpenAPI specification in YAML format.
|
|
38
|
+
* Requires 'yaml' package as peer dependency.
|
|
39
|
+
* Example: /api/openapi.yaml
|
|
40
|
+
*/
|
|
41
|
+
openApiYamlPath?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @description
|
|
45
|
+
* A fluent, static bootstrap class for initializing and configuring a NestJS application.
|
|
46
|
+
*
|
|
47
|
+
* @summary
|
|
48
|
+
* The `NestBootstraper` class provides a chainable API for configuring
|
|
49
|
+
* a NestJS application instance. It includes built-in methods for enabling
|
|
50
|
+
* CORS, Helmet security, Swagger documentation, global pipes, filters,
|
|
51
|
+
* interceptors, and starting the server.
|
|
52
|
+
*
|
|
53
|
+
* This class promotes consistency and reduces repetitive setup code
|
|
54
|
+
* across multiple NestJS projects.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { NestFactory } from "@nestjs/core";
|
|
59
|
+
* import { AppModule } from "./app.module.cjs";
|
|
60
|
+
* import { MyLogger } from "./MyLogger.cjs";
|
|
61
|
+
* import { NestBootstraper } from "@decaf-ts/for-nest";
|
|
62
|
+
*
|
|
63
|
+
* async function bootstrap() {
|
|
64
|
+
* const app = await NestFactory.create(AppModule);
|
|
65
|
+
*
|
|
66
|
+
* await NestBootstraper
|
|
67
|
+
* .initialize(app)
|
|
68
|
+
* .enableLogger(new MyLogger())
|
|
69
|
+
* .enableCors(["http://localhost:4200"])
|
|
70
|
+
* .useHelmet()
|
|
71
|
+
* .setupSwagger({
|
|
72
|
+
* title: "OpenAPI by TradeMark™",
|
|
73
|
+
* description: "TradeMark™ API documentation",
|
|
74
|
+
* version: "1.0.0",
|
|
75
|
+
* path: "api",
|
|
76
|
+
* persistAuthorization: true,
|
|
77
|
+
* topbarBgColor: "#2C3E50",
|
|
78
|
+
* topbarIconPath: "/assets/logo.svg",
|
|
79
|
+
* faviconPath: "/assets/favicon.ico"
|
|
80
|
+
* })
|
|
81
|
+
* .useGlobalFilters()
|
|
82
|
+
* .useGlobalPipes(...)
|
|
83
|
+
* .useGlobalInterceptors(...)
|
|
84
|
+
* .start(3000);
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* bootstrap();
|
|
88
|
+
* ```
|
|
89
|
+
* @class
|
|
90
|
+
*/
|
|
91
|
+
export declare class NestBootstraper {
|
|
92
|
+
private static app;
|
|
93
|
+
private static _logger;
|
|
94
|
+
/**
|
|
95
|
+
* @description
|
|
96
|
+
* Returns the current logger instance, creating a default one if not set.
|
|
97
|
+
*
|
|
98
|
+
* @summary
|
|
99
|
+
* Ensures that a valid `Logger` instance is always available
|
|
100
|
+
* for logging bootstrap-related messages.
|
|
101
|
+
*
|
|
102
|
+
* @return {Logger} The active logger instance.
|
|
103
|
+
*/
|
|
104
|
+
private static get logger();
|
|
105
|
+
/**
|
|
106
|
+
* @description
|
|
107
|
+
* Initializes the bootstrapper with a given NestJS application.
|
|
108
|
+
*
|
|
109
|
+
* @summary
|
|
110
|
+
* Binds the provided NestJS app instance to the bootstrapper, enabling
|
|
111
|
+
* chained configuration methods.
|
|
112
|
+
*
|
|
113
|
+
* @param {INestApplication} app - The NestJS application instance to initialize.
|
|
114
|
+
* @return {NestBootstraper} Returns the class for chaining configuration methods.
|
|
115
|
+
*/
|
|
116
|
+
static initialize(app: INestApplication): typeof NestBootstraper;
|
|
117
|
+
/**
|
|
118
|
+
* @description
|
|
119
|
+
* Enables or replaces the global logger for the NestJS application.
|
|
120
|
+
*
|
|
121
|
+
* @summary
|
|
122
|
+
* If a custom logger is provided, it replaces the default logger. Otherwise,
|
|
123
|
+
* a new logger named `"NestBootstrap"` is used. This logger is also registered
|
|
124
|
+
* with the NestJS application.
|
|
125
|
+
*
|
|
126
|
+
* @param {Logger} [customLogger] - Optional custom logger instance.
|
|
127
|
+
* @return {NestBootstraper} Returns the class for chaining.
|
|
128
|
+
*/
|
|
129
|
+
static enableLogger(customLogger?: Logger): typeof NestBootstraper;
|
|
130
|
+
/**
|
|
131
|
+
* @description
|
|
132
|
+
* Enables Cross-Origin Resource Sharing (CORS) for the application.
|
|
133
|
+
*
|
|
134
|
+
* @summary
|
|
135
|
+
* Allows defining either a wildcard origin (`"*"`) or a list of allowed origins.
|
|
136
|
+
* Automatically accepts local development requests and those without origin headers.
|
|
137
|
+
* Throws a `CorsError` for unauthorized origins.
|
|
138
|
+
*
|
|
139
|
+
* @param {'*' | string[]} [origins=[]] - List of allowed origins or `"*"` to allow all.
|
|
140
|
+
* @param {string[]} [allowMethods=['GET', 'POST', 'PUT', 'DELETE']] - Allowed HTTP methods.
|
|
141
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
static enableCors(origins?: "*" | string[], allowMethods?: string[]): typeof NestBootstraper;
|
|
145
|
+
/**
|
|
146
|
+
* @description
|
|
147
|
+
* Applies the Helmet middleware for enhanced security.
|
|
148
|
+
*
|
|
149
|
+
* @summary
|
|
150
|
+
* Dynamically loads the `helmet` package if available and registers it
|
|
151
|
+
* as middleware to improve HTTP header security. If not installed, logs a warning
|
|
152
|
+
* and continues execution without throwing errors.
|
|
153
|
+
*
|
|
154
|
+
* @param {Record<string, any>} [options] - Optional configuration passed to Helmet.
|
|
155
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
156
|
+
*/
|
|
157
|
+
static useHelmet(options?: Record<string, any>): typeof NestBootstraper;
|
|
158
|
+
/**
|
|
159
|
+
* @description
|
|
160
|
+
* Configures and initializes Swagger UI for API documentation.
|
|
161
|
+
*
|
|
162
|
+
* @summary
|
|
163
|
+
* Uses the `SwaggerBuilder` utility to configure API documentation
|
|
164
|
+
* with detailed customization for title, version, paths, and colors.
|
|
165
|
+
* Swagger is automatically exposed at the configured path.
|
|
166
|
+
*
|
|
167
|
+
* @param {SwaggerSetupOptions} options - Swagger configuration options.
|
|
168
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
169
|
+
*/
|
|
170
|
+
static setupSwagger(options: SwaggerSetupOptions): typeof NestBootstraper;
|
|
171
|
+
/**
|
|
172
|
+
* @description
|
|
173
|
+
* Registers one or more global validation pipes.
|
|
174
|
+
*
|
|
175
|
+
* @summary
|
|
176
|
+
* Enables request payload validation and transformation globally across
|
|
177
|
+
* the entire NestJS application. Multiple pipes can be chained together
|
|
178
|
+
* for modular input validation.
|
|
179
|
+
*
|
|
180
|
+
* @param {...PipeTransform[]} pipes - Pipe instances to register globally.
|
|
181
|
+
* @return {NestBootstraper} Returns the class for chaining.
|
|
182
|
+
*/
|
|
183
|
+
static useGlobalPipes(...pipes: PipeTransform[]): typeof NestBootstraper;
|
|
184
|
+
/**
|
|
185
|
+
* @description
|
|
186
|
+
* Registers one or more global exception filters.
|
|
187
|
+
*
|
|
188
|
+
* @summary
|
|
189
|
+
* If no filters are provided, it automatically registers a default
|
|
190
|
+
* set of standard exception filters for common error types like
|
|
191
|
+
* `HttpException`, `ValidationException`, `ConflictException`, and others.
|
|
192
|
+
*
|
|
193
|
+
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
194
|
+
*/
|
|
195
|
+
static useGlobalFilters(...filters: any[]): typeof NestBootstraper;
|
|
196
|
+
/**
|
|
197
|
+
* @description
|
|
198
|
+
* Registers global interceptors for request and response transformation.
|
|
199
|
+
*
|
|
200
|
+
* @summary
|
|
201
|
+
* Interceptors allow advanced request/response manipulation such as
|
|
202
|
+
* serialization, logging, or transformation. Multiple interceptors
|
|
203
|
+
* can be added for modular configuration.
|
|
204
|
+
*
|
|
205
|
+
* @param {...NestInterceptor[]} interceptors - Interceptor instances to register.
|
|
206
|
+
* @return {NestBootstraper} Returns the class for chaining configuration.
|
|
207
|
+
*/
|
|
208
|
+
static useGlobalInterceptors(...interceptors: NestInterceptor[]): typeof NestBootstraper;
|
|
209
|
+
/**
|
|
210
|
+
* @description
|
|
211
|
+
* Starts the NestJS application and binds it to the given port and host.
|
|
212
|
+
*
|
|
213
|
+
* @summary
|
|
214
|
+
* Listens on the specified port and optionally a host. Once started,
|
|
215
|
+
* logs the application URL for easy access. The startup process resolves
|
|
216
|
+
* once the application is successfully running.
|
|
217
|
+
*
|
|
218
|
+
* @param {number} [port=3000] - Port number to listen on.
|
|
219
|
+
* @param {string} [host] - Optional host or IP address to bind to.
|
|
220
|
+
* @param {boolean} [log=true] - Whether to log the application URL upon startup.
|
|
221
|
+
* @return {Promise<void>} Resolves once the application starts successfully.
|
|
222
|
+
*/
|
|
223
|
+
static start(port?: number, host?: string | undefined, log?: boolean): Promise<void>;
|
|
224
|
+
}
|