@decaf-ts/for-nest 0.11.2 → 0.12.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/README.md +274 -2
- package/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/cjs/auth/AuthInterceptor.cjs +93 -0
- package/lib/cjs/auth/AuthInterceptor.cjs.map +1 -0
- package/lib/cjs/auth/DecafAuthHandler.cjs +37 -0
- package/lib/cjs/auth/DecafAuthHandler.cjs.map +1 -0
- package/lib/cjs/auth/DecafAuthModule.cjs +50 -0
- package/lib/cjs/auth/DecafAuthModule.cjs.map +1 -0
- package/lib/cjs/auth/constants.cjs +10 -0
- package/lib/cjs/auth/constants.cjs.map +1 -0
- package/lib/cjs/auth/decorators.cjs +28 -0
- package/lib/cjs/auth/decorators.cjs.map +1 -0
- package/lib/cjs/{ram → auth}/index.cjs +6 -2
- package/lib/cjs/auth/index.cjs.map +1 -0
- package/lib/cjs/bin/cli.cjs +1 -1
- package/lib/cjs/bin/cli.cjs.map +1 -1
- package/lib/cjs/cli-module.cjs +63 -6
- package/lib/cjs/cli-module.cjs.map +1 -1
- package/lib/cjs/constants.cjs +4 -5
- package/lib/cjs/constants.cjs.map +1 -1
- package/lib/cjs/controllers.cjs +15 -112
- package/lib/cjs/controllers.cjs.map +1 -1
- package/lib/cjs/core-module.cjs +7 -7
- package/lib/cjs/core-module.cjs.map +1 -1
- package/lib/cjs/decaf-model/DecafModelModule.cjs +27 -3
- package/lib/cjs/decaf-model/DecafModelModule.cjs.map +1 -1
- package/lib/cjs/decaf-model/FromModelController.cjs +618 -792
- package/lib/cjs/decaf-model/FromModelController.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs +52 -15
- package/lib/cjs/decaf-model/decorators/ApiOperationFromModel.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs +1 -1
- package/lib/cjs/decaf-model/decorators/ApiParamsFromModel.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs +1 -1
- package/lib/cjs/decaf-model/decorators/DecafBody.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs +1 -1
- package/lib/cjs/decaf-model/decorators/DecafParams.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/controller-config.cjs +29 -0
- package/lib/cjs/decaf-model/decorators/controller-config.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/decorators.cjs +4 -44
- package/lib/cjs/decaf-model/decorators/decorators.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/expose.cjs +13 -0
- package/lib/cjs/decaf-model/decorators/expose.cjs.map +1 -0
- package/lib/cjs/decaf-model/decorators/index.cjs +2 -1
- package/lib/cjs/decaf-model/decorators/index.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/types.cjs +1 -1
- package/lib/cjs/decaf-model/decorators/types.cjs.map +1 -1
- package/lib/cjs/decaf-model/decorators/utils.cjs +3 -2
- package/lib/cjs/decaf-model/decorators/utils.cjs.map +1 -1
- package/lib/cjs/decaf-model/index.cjs +27 -18
- package/lib/cjs/decaf-model/index.cjs.map +1 -1
- package/lib/cjs/decaf-model/types.cjs +1 -1
- package/lib/cjs/decaf-model/types.cjs.map +1 -1
- package/lib/cjs/decaf-model/utils.cjs +10 -4
- package/lib/cjs/decaf-model/utils.cjs.map +1 -1
- package/lib/cjs/decoration.cjs +1 -1
- package/lib/cjs/decoration.cjs.map +1 -1
- package/lib/cjs/decorators.cjs +93 -0
- package/lib/cjs/decorators.cjs.map +1 -0
- package/lib/cjs/events-module/DecafStreamModule.cjs +1 -1
- package/lib/cjs/events-module/DecafStreamModule.cjs.map +1 -1
- package/lib/cjs/events-module/EventsController.cjs +1 -1
- package/lib/cjs/events-module/EventsController.cjs.map +1 -1
- package/lib/cjs/events-module/constant.cjs +1 -1
- package/lib/cjs/events-module/constant.cjs.map +1 -1
- package/lib/cjs/events-module/index.cjs +1 -1
- package/lib/cjs/events-module/index.cjs.map +1 -1
- package/lib/cjs/events-module/utils.cjs +1 -1
- package/lib/cjs/events-module/utils.cjs.map +1 -1
- package/lib/cjs/factory/NestBootstraper.cjs +11 -4
- package/lib/cjs/factory/NestBootstraper.cjs.map +1 -1
- package/lib/cjs/factory/errors/cors.cjs +1 -1
- package/lib/cjs/factory/errors/cors.cjs.map +1 -1
- package/lib/cjs/factory/errors/index.cjs +1 -1
- package/lib/cjs/factory/errors/index.cjs.map +1 -1
- package/lib/cjs/factory/errors/throttling.cjs +1 -1
- package/lib/cjs/factory/errors/throttling.cjs.map +1 -1
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs +105 -6
- package/lib/cjs/factory/exceptions/DecafErrorFilter.cjs.map +1 -1
- package/lib/cjs/factory/exceptions/decorators.cjs +4 -1
- package/lib/cjs/factory/exceptions/decorators.cjs.map +1 -1
- package/lib/cjs/factory/exceptions/index.cjs +1 -1
- package/lib/cjs/factory/exceptions/index.cjs.map +1 -1
- package/lib/cjs/factory/index.cjs +1 -1
- package/lib/cjs/factory/index.cjs.map +1 -1
- package/lib/cjs/factory/openapi/DtoBuilder.cjs +36 -5
- package/lib/cjs/factory/openapi/DtoBuilder.cjs.map +1 -1
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs +1 -1
- package/lib/cjs/factory/openapi/SwaggerBuilder.cjs.map +1 -1
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs +1 -1
- package/lib/cjs/factory/openapi/SwaggerCustomUI.cjs.map +1 -1
- package/lib/cjs/factory/openapi/constants.cjs +1 -1
- package/lib/cjs/factory/openapi/constants.cjs.map +1 -1
- package/lib/cjs/factory/openapi/index.cjs +1 -1
- package/lib/cjs/factory/openapi/index.cjs.map +1 -1
- package/lib/cjs/index.cjs +6 -5
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs +24 -20
- package/lib/cjs/interceptors/DecafRequestHandlerInterceptor.cjs.map +1 -1
- package/lib/cjs/interceptors/index.cjs +2 -3
- package/lib/cjs/interceptors/index.cjs.map +1 -1
- package/lib/cjs/module.cjs +4 -1
- package/lib/cjs/module.cjs.map +1 -1
- package/lib/cjs/overrides/Adapter.cjs +1 -1
- package/lib/cjs/overrides/Adapter.cjs.map +1 -1
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs +1 -1
- package/lib/cjs/overrides/ModelBuilderExtensions.cjs.map +1 -1
- package/lib/cjs/overrides/constants.cjs +1 -1
- package/lib/cjs/overrides/constants.cjs.map +1 -1
- package/lib/cjs/overrides/decoration.cjs +1 -1
- package/lib/cjs/overrides/decoration.cjs.map +1 -1
- package/lib/cjs/overrides/helpers.cjs +1 -1
- package/lib/cjs/overrides/helpers.cjs.map +1 -1
- package/lib/cjs/overrides/index.cjs +2 -1
- package/lib/cjs/overrides/index.cjs.map +1 -1
- package/lib/cjs/overrides/logging.cjs +5 -0
- package/lib/cjs/overrides/logging.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +1 -1
- package/lib/cjs/overrides/overrides.cjs.map +1 -1
- package/lib/cjs/request/DecafAuthHandler.cjs +4 -38
- package/lib/cjs/request/DecafAuthHandler.cjs.map +1 -1
- package/lib/cjs/request/DecafHandlerExecutor.cjs +1 -1
- package/lib/cjs/request/DecafHandlerExecutor.cjs.map +1 -1
- package/lib/cjs/request/DecafRequestContext.cjs +12 -19
- package/lib/cjs/request/DecafRequestContext.cjs.map +1 -1
- package/lib/cjs/request/DecafResponseInterceptor.cjs +5 -3
- package/lib/cjs/request/DecafResponseInterceptor.cjs.map +1 -1
- package/lib/cjs/request/index.cjs +1 -1
- package/lib/cjs/request/index.cjs.map +1 -1
- package/lib/cjs/swagger-types.cjs +1 -1
- package/lib/cjs/swagger-types.cjs.map +1 -1
- package/lib/cjs/types.cjs +1 -1
- package/lib/cjs/types.cjs.map +1 -1
- package/lib/cjs/utils.cjs +1 -1
- package/lib/cjs/utils.cjs.map +1 -1
- package/lib/cjs/webhooks/DecafWebhookModule.cjs +4 -3
- package/lib/cjs/webhooks/DecafWebhookModule.cjs.map +1 -1
- package/lib/cjs/webhooks/controllers.cjs +49 -54
- package/lib/cjs/webhooks/controllers.cjs.map +1 -1
- package/lib/cjs/webhooks/index.cjs +1 -1
- package/lib/cjs/webhooks/index.cjs.map +1 -1
- package/lib/cjs/webhooks/types.cjs +1 -1
- package/lib/cjs/webhooks/types.cjs.map +1 -1
- package/lib/esm/auth/AuthInterceptor.js +84 -0
- package/lib/esm/auth/AuthInterceptor.js.map +1 -0
- package/lib/esm/auth/DecafAuthHandler.js +31 -0
- package/lib/esm/auth/DecafAuthHandler.js.map +1 -0
- package/lib/esm/auth/DecafAuthModule.js +42 -0
- package/lib/esm/auth/DecafAuthModule.js.map +1 -0
- package/lib/esm/auth/constants.js +6 -0
- package/lib/esm/auth/constants.js.map +1 -0
- package/lib/esm/auth/decorators.js +22 -0
- package/lib/esm/auth/decorators.js.map +1 -0
- package/lib/esm/auth/index.js +6 -0
- package/lib/esm/auth/index.js.map +1 -0
- package/lib/esm/cli-module.js +62 -5
- package/lib/esm/cli-module.js.map +1 -1
- package/lib/esm/constants.js +2 -3
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/controllers.js +15 -112
- package/lib/esm/controllers.js.map +1 -1
- package/lib/esm/core-module.js +6 -6
- package/lib/esm/core-module.js.map +1 -1
- package/lib/esm/decaf-model/DecafModelModule.js +26 -2
- package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
- package/lib/esm/decaf-model/FromModelController.js +622 -796
- package/lib/esm/decaf-model/FromModelController.js.map +1 -1
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js +52 -14
- package/lib/esm/decaf-model/decorators/ApiOperationFromModel.js.map +1 -1
- package/lib/esm/decaf-model/decorators/controller-config.js +25 -0
- package/lib/esm/decaf-model/decorators/controller-config.js.map +1 -0
- package/lib/esm/decaf-model/decorators/decorators.js +1 -42
- package/lib/esm/decaf-model/decorators/decorators.js.map +1 -1
- package/lib/esm/decaf-model/decorators/expose.js +9 -0
- package/lib/esm/decaf-model/decorators/expose.js.map +1 -0
- package/lib/esm/decaf-model/decorators/index.js +1 -0
- package/lib/esm/decaf-model/decorators/index.js.map +1 -1
- package/lib/esm/decaf-model/decorators/utils.js +2 -1
- package/lib/esm/decaf-model/decorators/utils.js.map +1 -1
- package/lib/esm/decaf-model/index.js +10 -3
- package/lib/esm/decaf-model/index.js.map +1 -1
- package/lib/esm/decaf-model/utils.js +9 -3
- package/lib/esm/decaf-model/utils.js.map +1 -1
- package/lib/esm/decorators.js +87 -0
- package/lib/esm/decorators.js.map +1 -0
- package/lib/esm/events-module/utils.js.map +1 -1
- package/lib/esm/factory/NestBootstraper.js +10 -3
- package/lib/esm/factory/NestBootstraper.js.map +1 -1
- package/lib/esm/factory/exceptions/DecafErrorFilter.js +105 -7
- package/lib/esm/factory/exceptions/DecafErrorFilter.js.map +1 -1
- package/lib/esm/factory/exceptions/decorators.js +3 -0
- package/lib/esm/factory/exceptions/decorators.js.map +1 -1
- package/lib/esm/factory/openapi/DtoBuilder.js +35 -4
- package/lib/esm/factory/openapi/DtoBuilder.js.map +1 -1
- package/lib/esm/index.js +5 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js +24 -20
- package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js.map +1 -1
- package/lib/esm/interceptors/index.js +1 -2
- package/lib/esm/interceptors/index.js.map +1 -1
- package/lib/esm/module.js +3 -0
- package/lib/esm/module.js.map +1 -1
- package/lib/esm/overrides/index.js +1 -0
- package/lib/esm/overrides/index.js.map +1 -1
- package/lib/esm/overrides/logging.js +2 -0
- package/lib/esm/overrides/logging.js.map +1 -0
- package/lib/esm/request/DecafAuthHandler.js +1 -35
- package/lib/esm/request/DecafAuthHandler.js.map +1 -1
- package/lib/esm/request/DecafRequestContext.js +11 -18
- package/lib/esm/request/DecafRequestContext.js.map +1 -1
- package/lib/esm/request/DecafResponseInterceptor.js +4 -2
- package/lib/esm/request/DecafResponseInterceptor.js.map +1 -1
- package/lib/esm/webhooks/DecafWebhookModule.js +2 -1
- package/lib/esm/webhooks/DecafWebhookModule.js.map +1 -1
- package/lib/esm/webhooks/controllers.js +48 -53
- package/lib/esm/webhooks/controllers.js.map +1 -1
- package/lib/types/{interceptors → auth}/AuthInterceptor.d.cts +4 -1
- package/lib/types/{interceptors → auth}/AuthInterceptor.d.mts +4 -1
- package/lib/types/auth/DecafAuthHandler.d.cts +22 -0
- package/lib/types/auth/DecafAuthHandler.d.mts +22 -0
- package/lib/types/auth/DecafAuthModule.d.cts +9 -0
- package/lib/types/auth/DecafAuthModule.d.mts +9 -0
- package/lib/types/auth/constants.d.cts +5 -0
- package/lib/types/auth/constants.d.mts +5 -0
- package/lib/types/auth/decorators.d.cts +4 -0
- package/lib/types/auth/decorators.d.mts +4 -0
- package/lib/types/auth/index.d.cts +6 -0
- package/lib/types/auth/index.d.mts +6 -0
- package/lib/types/cli-module.d.cts +1 -4
- package/lib/types/cli-module.d.mts +1 -4
- package/lib/types/constants.d.cts +2 -3
- package/lib/types/constants.d.mts +2 -3
- package/lib/types/controllers.d.cts +7 -12
- package/lib/types/controllers.d.mts +7 -12
- package/lib/types/decaf-model/DecafModelModule.d.cts +1 -0
- package/lib/types/decaf-model/DecafModelModule.d.mts +1 -0
- package/lib/types/decaf-model/FromModelController.d.cts +32 -52
- package/lib/types/decaf-model/FromModelController.d.mts +32 -52
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.cts +0 -2
- package/lib/types/decaf-model/decorators/ApiOperationFromModel.d.mts +0 -2
- package/lib/types/decaf-model/decorators/controller-config.d.cts +18 -0
- package/lib/types/decaf-model/decorators/controller-config.d.mts +18 -0
- package/lib/types/decaf-model/decorators/decorators.d.cts +1 -29
- package/lib/types/decaf-model/decorators/decorators.d.mts +1 -29
- package/lib/types/decaf-model/decorators/expose.d.cts +1 -0
- package/lib/types/decaf-model/decorators/expose.d.mts +1 -0
- package/lib/types/decaf-model/decorators/index.d.cts +1 -0
- package/lib/types/decaf-model/decorators/index.d.mts +1 -0
- package/lib/types/decaf-model/decorators/types.d.cts +8 -21
- package/lib/types/decaf-model/decorators/types.d.mts +8 -21
- package/lib/types/decaf-model/index.d.cts +11 -3
- package/lib/types/decaf-model/index.d.mts +11 -3
- package/lib/types/decaf-model/utils.d.cts +2 -1
- package/lib/types/decaf-model/utils.d.mts +2 -1
- package/lib/types/decorators.d.cts +35 -0
- package/lib/types/decorators.d.mts +35 -0
- package/lib/types/factory/NestBootstraper.d.cts +5 -0
- package/lib/types/factory/NestBootstraper.d.mts +5 -0
- package/lib/types/factory/exceptions/DecafErrorFilter.d.cts +33 -1
- package/lib/types/factory/exceptions/DecafErrorFilter.d.mts +33 -1
- package/lib/types/factory/openapi/DtoBuilder.d.cts +7 -3
- package/lib/types/factory/openapi/DtoBuilder.d.mts +7 -3
- package/lib/types/index.d.cts +5 -4
- package/lib/types/index.d.mts +5 -4
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.cts +1 -2
- package/lib/types/interceptors/DecafRequestHandlerInterceptor.d.mts +1 -2
- package/lib/types/interceptors/index.d.cts +1 -2
- package/lib/types/interceptors/index.d.mts +1 -2
- package/lib/types/overrides/Adapter.d.cts +1 -1
- package/lib/types/overrides/Adapter.d.mts +1 -1
- package/lib/types/overrides/index.d.cts +1 -0
- package/lib/types/overrides/index.d.mts +1 -0
- package/lib/types/overrides/logging.d.cts +1 -0
- package/lib/types/overrides/logging.d.mts +1 -0
- package/lib/types/request/DecafAuthHandler.d.cts +1 -10
- package/lib/types/request/DecafAuthHandler.d.mts +1 -10
- package/lib/types/request/DecafRequestContext.d.cts +5 -5
- package/lib/types/request/DecafRequestContext.d.mts +5 -5
- package/lib/types/types.d.cts +12 -24
- package/lib/types/types.d.mts +12 -24
- package/package.json +12 -13
- package/lib/cjs/interceptors/AuthInterceptor.cjs +0 -52
- package/lib/cjs/interceptors/AuthInterceptor.cjs.map +0 -1
- package/lib/cjs/interceptors/context.cjs +0 -18
- package/lib/cjs/interceptors/context.cjs.map +0 -1
- package/lib/cjs/migrations/index.cjs +0 -35
- package/lib/cjs/migrations/index.cjs.map +0 -1
- package/lib/cjs/migrations/migration-module.cjs +0 -60
- package/lib/cjs/migrations/migration-module.cjs.map +0 -1
- package/lib/cjs/migrations/migration-options.cjs +0 -4
- package/lib/cjs/migrations/migration-options.cjs.map +0 -1
- package/lib/cjs/ram/RamRequestTransformer.cjs +0 -26
- package/lib/cjs/ram/RamRequestTransformer.cjs.map +0 -1
- package/lib/cjs/ram/index.cjs.map +0 -1
- package/lib/esm/interceptors/AuthInterceptor.js +0 -43
- package/lib/esm/interceptors/AuthInterceptor.js.map +0 -1
- package/lib/esm/interceptors/context.js +0 -12
- package/lib/esm/interceptors/context.js.map +0 -1
- package/lib/esm/migrations/index.js +0 -18
- package/lib/esm/migrations/index.js.map +0 -1
- package/lib/esm/migrations/migration-module.js +0 -52
- package/lib/esm/migrations/migration-module.js.map +0 -1
- package/lib/esm/migrations/migration-options.js +0 -7
- package/lib/esm/migrations/migration-options.js.map +0 -1
- package/lib/esm/ram/RamRequestTransformer.js +0 -21
- package/lib/esm/ram/RamRequestTransformer.js.map +0 -1
- package/lib/esm/ram/index.js +0 -2
- package/lib/esm/ram/index.js.map +0 -1
- package/lib/types/interceptors/context.d.cts +0 -6
- package/lib/types/interceptors/context.d.mts +0 -6
- package/lib/types/migrations/index.d.cts +0 -17
- package/lib/types/migrations/index.d.mts +0 -17
- package/lib/types/migrations/migration-module.d.cts +0 -15
- package/lib/types/migrations/migration-module.d.mts +0 -15
- package/lib/types/migrations/migration-options.d.cts +0 -11
- package/lib/types/migrations/migration-options.d.mts +0 -11
- package/lib/types/ram/RamRequestTransformer.d.cts +0 -5
- package/lib/types/ram/RamRequestTransformer.d.mts +0 -5
- package/lib/types/ram/index.d.cts +0 -1
- package/lib/types/ram/index.d.mts +0 -1
|
@@ -1,61 +1,41 @@
|
|
|
1
1
|
import { ModelService, type Repo } from "@decaf-ts/core";
|
|
2
2
|
import { Model, ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { type
|
|
3
|
+
import { type DecafApiProperty } from "./decorators/index.d.mts";
|
|
4
4
|
import { ControllerConstructor } from "./types.d.mts";
|
|
5
5
|
import "../overrides";
|
|
6
|
-
|
|
7
|
-
* @description
|
|
8
|
-
* Factory and utilities for generating dynamic NestJS controllers from Decaf {@link Model} definitions.
|
|
9
|
-
*
|
|
10
|
-
* @summary
|
|
11
|
-
* The `FromModelController` class provides the infrastructure necessary to automatically generate
|
|
12
|
-
* strongly-typed CRUD controllers based on a given {@link ModelConstructor}. It inspects metadata from
|
|
13
|
-
* the model, derives route paths, parameters, and generates a dynamic controller class at runtime with
|
|
14
|
-
* full support for querying, creation, update, and deletion of model entities through a {@link Repo}.
|
|
15
|
-
*
|
|
16
|
-
* @template T The {@link Model} type associated with the generated controller.
|
|
17
|
-
*
|
|
18
|
-
* @param ModelClazz The model class to generate the controller from.
|
|
19
|
-
*
|
|
20
|
-
* @class FromModelController
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* // Given a Decaf Model:
|
|
25
|
-
* class User extends Model<User> {
|
|
26
|
-
* id!: string;
|
|
27
|
-
* name!: string;
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* // Register controller:
|
|
31
|
-
* const UserController = FromModelController.create(User);
|
|
32
|
-
*
|
|
33
|
-
* // NestJS will expose:
|
|
34
|
-
* // POST /user
|
|
35
|
-
* // GET /user/:id
|
|
36
|
-
* // GET /user/query/:method
|
|
37
|
-
* // PUT /user/:id
|
|
38
|
-
* // DELETE /user/:id
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @mermaid
|
|
42
|
-
* sequenceDiagram
|
|
43
|
-
* participant Client
|
|
44
|
-
* participant Controller
|
|
45
|
-
* participant Repo
|
|
46
|
-
* participant DB
|
|
47
|
-
*
|
|
48
|
-
* Client->>Controller: HTTP Request
|
|
49
|
-
* Controller->>Repo: Resolve repository for Model
|
|
50
|
-
* Repo->>DB: Execute DB operation
|
|
51
|
-
* DB-->>Repo: DB Result
|
|
52
|
-
* Repo-->>Controller: Model Instance(s)
|
|
53
|
-
* Controller-->>Client: JSON Response
|
|
54
|
-
*/
|
|
6
|
+
import { type ModelControllerFactoryConfig } from "@decaf-ts/for-http/server";
|
|
55
7
|
export declare class FromModelController {
|
|
56
8
|
private static readonly log;
|
|
9
|
+
private static toDecafError;
|
|
57
10
|
static getPersistence<T extends Model<boolean>>(ModelClazz: ModelConstructor<T>): Repo<T> | ModelService<T>;
|
|
58
11
|
static createQueryRoutesFromRepository<T extends Model<boolean>>(persistence: Repo<T> | ModelService<T>, prefix?: string): ControllerConstructor<T>;
|
|
59
|
-
static create<T extends Model<any>>(ModelConstr: ModelConstructor<T>):
|
|
60
|
-
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>):
|
|
12
|
+
static create<T extends Model<any>>(ModelConstr: ModelConstructor<T>, moduleConfigOverrides?: Record<string, ModelControllerFactoryConfig>, globalDefaults?: Partial<ModelControllerFactoryConfig>): ControllerConstructor<T>;
|
|
13
|
+
static getRouteParametersFromModel<T extends Model<any>>(ModelClazz: ModelConstructor<T>): {
|
|
14
|
+
path: string;
|
|
15
|
+
description: string;
|
|
16
|
+
apiProperties: DecafApiProperty[];
|
|
17
|
+
getPK: (...params: Array<string | number>) => string;
|
|
18
|
+
};
|
|
19
|
+
private static routeParamDecorators;
|
|
20
|
+
private static defineMethod;
|
|
21
|
+
private static applyDecorators;
|
|
22
|
+
private static matchRoute;
|
|
23
|
+
private static createRegistration;
|
|
24
|
+
private static statementMethodName;
|
|
25
|
+
private static statementShortcutParams;
|
|
26
|
+
private static complexQueryParams;
|
|
27
|
+
private static createComplexQueryHandler;
|
|
28
|
+
private static extractQueryArgs;
|
|
29
|
+
private static normalizeQueryArgs;
|
|
30
|
+
private static createCreateDecorators;
|
|
31
|
+
private static bulkCreateDecorators;
|
|
32
|
+
private static bulkReadDecorators;
|
|
33
|
+
private static bulkUpdateDecorators;
|
|
34
|
+
private static bulkDeleteDecorators;
|
|
35
|
+
private static readDecorators;
|
|
36
|
+
private static updateDecorators;
|
|
37
|
+
private static deleteDecorators;
|
|
38
|
+
private static statementDecorators;
|
|
39
|
+
private static statementShortcutDecorators;
|
|
40
|
+
private static getQueryDecorators;
|
|
61
41
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CrudOperations } from "@decaf-ts/db-decorators";
|
|
2
1
|
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
3
2
|
import { HttpVerbs } from "./types.d.cts";
|
|
4
3
|
/**
|
|
@@ -9,7 +8,6 @@ import { HttpVerbs } from "./types.d.cts";
|
|
|
9
8
|
* @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
|
|
10
9
|
* @function isOperationBlocked
|
|
11
10
|
*/
|
|
12
|
-
export declare function isOperationBlocked(ModelConstructor: ModelConstructor<any>, op: CrudOperations): boolean;
|
|
13
11
|
/**
|
|
14
12
|
* @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
|
|
15
13
|
* @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CrudOperations } from "@decaf-ts/db-decorators";
|
|
2
1
|
import { ModelConstructor } from "@decaf-ts/decorator-validation";
|
|
3
2
|
import { HttpVerbs } from "./types.d.mts";
|
|
4
3
|
/**
|
|
@@ -9,7 +8,6 @@ import { HttpVerbs } from "./types.d.mts";
|
|
|
9
8
|
* @return {boolean} `true` when the operation is explicitly blocked by the model's handler; otherwise `false`.
|
|
10
9
|
* @function isOperationBlocked
|
|
11
10
|
*/
|
|
12
|
-
export declare function isOperationBlocked(ModelConstructor: ModelConstructor<any>, op: CrudOperations): boolean;
|
|
13
11
|
/**
|
|
14
12
|
* @description Conditionally applies an HTTP method decorator for a given model and verb, hiding the endpoint in Swagger (and not registering the route) when the model blocks that CRUD operation.
|
|
15
13
|
* @summary Maps an HTTP verb to its corresponding `CrudOperations` key and Nest HTTP decorator (`@Get`, `@Post`, etc.). It checks `isOperationBlocked(ModelConstructor, crudOp)` and, if blocked, applies only `@ApiExcludeEndpoint()` (Swagger-hidden, no Nest route). If permitted, it applies the appropriate HTTP decorator with the optional `path`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModelControllerFactoryConfig } from "@decaf-ts/for-http/server";
|
|
2
|
+
/**
|
|
3
|
+
* Class decorator that attaches a {@link ModelControllerFactoryConfig} to a Model,
|
|
4
|
+
* so `FromModelController.create()` can pass it to `ModelControllerFactory.create()`.
|
|
5
|
+
*
|
|
6
|
+
* The per-model config can be overridden by the module-level `controllerConfig`
|
|
7
|
+
* option in `DecafModuleOptions`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* @controllerConfig({ allowGroupingQueries: true, allowBulkStatement: { create: true, read: true, update: false, delete: true } })
|
|
12
|
+
* @model()
|
|
13
|
+
* class Order extends Model<Order> { ... }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param config - Factory configuration knobs (allowStatementlessQuery, allowGroupingQueries, allowBulkStatement).
|
|
17
|
+
*/
|
|
18
|
+
export declare function controllerConfig(config: ModelControllerFactoryConfig): (target: any) => any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ModelControllerFactoryConfig } from "@decaf-ts/for-http/server";
|
|
2
|
+
/**
|
|
3
|
+
* Class decorator that attaches a {@link ModelControllerFactoryConfig} to a Model,
|
|
4
|
+
* so `FromModelController.create()` can pass it to `ModelControllerFactory.create()`.
|
|
5
|
+
*
|
|
6
|
+
* The per-model config can be overridden by the module-level `controllerConfig`
|
|
7
|
+
* option in `DecafModuleOptions`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* @controllerConfig({ allowGroupingQueries: true, allowBulkStatement: { create: true, read: true, update: false, delete: true } })
|
|
12
|
+
* @model()
|
|
13
|
+
* class Order extends Model<Order> { ... }
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param config - Factory configuration knobs (allowStatementlessQuery, allowGroupingQueries, allowBulkStatement).
|
|
17
|
+
*/
|
|
18
|
+
export declare function controllerConfig(config: ModelControllerFactoryConfig): (target: any) => any;
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
export { Auth } from "../../auth/decorators.d.cts";
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
export { Auth } from "../../auth/decorators.d.mts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function expose(...flavours: string[]): (target: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function expose(...flavours: string[]): (target: any) => any;
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
1
|
+
import type { HttpVerbs as ServerHttpVerbs, ServerApiProperty, ServerModelRoute, ServerParamProps, ServerRouteDecOptions } from "@decaf-ts/for-http/server";
|
|
2
|
+
export type HttpVerbs = ServerHttpVerbs;
|
|
3
|
+
export type DecafApiProperty = ServerApiProperty;
|
|
4
|
+
export type DecafModelRoute = ServerModelRoute;
|
|
5
|
+
export type DecafParamProps = ServerParamProps;
|
|
19
6
|
export interface DecafRouteDecOptions {
|
|
20
|
-
path:
|
|
21
|
-
httpMethod:
|
|
22
|
-
handler:
|
|
7
|
+
path: ServerRouteDecOptions["path"];
|
|
8
|
+
httpMethod: ServerRouteDecOptions["httpMethod"];
|
|
9
|
+
handler: ServerRouteDecOptions["handler"];
|
|
23
10
|
}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
1
|
+
import type { HttpVerbs as ServerHttpVerbs, ServerApiProperty, ServerModelRoute, ServerParamProps, ServerRouteDecOptions } from "@decaf-ts/for-http/server";
|
|
2
|
+
export type HttpVerbs = ServerHttpVerbs;
|
|
3
|
+
export type DecafApiProperty = ServerApiProperty;
|
|
4
|
+
export type DecafModelRoute = ServerModelRoute;
|
|
5
|
+
export type DecafParamProps = ServerParamProps;
|
|
19
6
|
export interface DecafRouteDecOptions {
|
|
20
|
-
path:
|
|
21
|
-
httpMethod:
|
|
22
|
-
handler:
|
|
7
|
+
path: ServerRouteDecOptions["path"];
|
|
8
|
+
httpMethod: ServerRouteDecOptions["httpMethod"];
|
|
9
|
+
handler: ServerRouteDecOptions["handler"];
|
|
23
10
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { ApiOperationFromModel, BulkApiOperationFromModel, } from "./decorators/ApiOperationFromModel.d.cts";
|
|
2
|
+
export { ApiParamsFromModel } from "./decorators/ApiParamsFromModel.d.cts";
|
|
3
|
+
export { DecafBody } from "./decorators/DecafBody.d.cts";
|
|
4
|
+
export { DecafParams } from "./decorators/DecafParams.d.cts";
|
|
5
|
+
export type { DecafParamProps } from "./decorators/types.d.cts";
|
|
6
|
+
export { expose } from "./decorators/expose.d.cts";
|
|
7
|
+
export { controllerConfig } from "./decorators/controller-config.d.cts";
|
|
8
|
+
export { Auth } from "./decorators/decorators.d.cts";
|
|
9
|
+
export { applyApiDecorators, createRouteHandler, defineRouteMethod, getApiDecorators, resolvePersistenceMethod, } from "./utils.d.cts";
|
|
10
|
+
export { getModuleFor } from "./DecafModelModule.d.cts";
|
|
11
|
+
export { FromModelController } from "./FromModelController.d.cts";
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { ApiOperationFromModel, BulkApiOperationFromModel, } from "./decorators/ApiOperationFromModel.d.mts";
|
|
2
|
+
export { ApiParamsFromModel } from "./decorators/ApiParamsFromModel.d.mts";
|
|
3
|
+
export { DecafBody } from "./decorators/DecafBody.d.mts";
|
|
4
|
+
export { DecafParams } from "./decorators/DecafParams.d.mts";
|
|
5
|
+
export type { DecafParamProps } from "./decorators/types.d.mts";
|
|
6
|
+
export { expose } from "./decorators/expose.d.mts";
|
|
7
|
+
export { controllerConfig } from "./decorators/controller-config.d.mts";
|
|
8
|
+
export { Auth } from "./decorators/decorators.d.mts";
|
|
9
|
+
export { applyApiDecorators, createRouteHandler, defineRouteMethod, getApiDecorators, resolvePersistenceMethod, } from "./utils.d.mts";
|
|
10
|
+
export { getModuleFor } from "./DecafModelModule.d.mts";
|
|
11
|
+
export { FromModelController } from "./FromModelController.d.mts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DecoratorBundle } from "./types.d.cts";
|
|
2
|
-
import { type DecafParamProps
|
|
2
|
+
import { type DecafParamProps } from "./decorators/index.d.cts";
|
|
3
|
+
import type { HttpVerbs } from "./decorators/types.d.cts";
|
|
3
4
|
import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
|
|
4
5
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
6
|
import { DecafModelController } from "../controllers.d.cts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type DecoratorBundle } from "./types.d.mts";
|
|
2
|
-
import { type DecafParamProps
|
|
2
|
+
import { type DecafParamProps } from "./decorators/index.d.mts";
|
|
3
|
+
import type { HttpVerbs } from "./decorators/types.d.mts";
|
|
3
4
|
import { DirectionLimitOffset, ModelService, Repo } from "@decaf-ts/core";
|
|
4
5
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
6
|
import { DecafModelController } from "../controllers.d.mts";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
+
export type DecafFactoryProvider = {
|
|
3
|
+
provide: string;
|
|
4
|
+
useFactory: () => unknown;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @description Drains the providers registered by {@link Service}/{@link Repository} usages.
|
|
8
|
+
* @summary Consumed by {@link DecafCoreModule.forRoot} to wire the tokens that those parameter
|
|
9
|
+
* decorators reference back into Nest's DI container, since a parameter decorator alone cannot
|
|
10
|
+
* supply a provider.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRegisteredDecafProviders(): DecafFactoryProvider[];
|
|
13
|
+
/**
|
|
14
|
+
* @description Constructor parameter decorator that injects a decaf service.
|
|
15
|
+
* @summary Translates decaf's service resolution APIs into a Nest `@Inject()` call:
|
|
16
|
+
* - `@Service(SomeModel)` injects the matching `@service(SomeModel)` decaf service when one is
|
|
17
|
+
* registered; otherwise it falls back to the `ModelService<SomeModel>` singleton
|
|
18
|
+
* (via {@link ModelService.forModel}).
|
|
19
|
+
* - `@Service(SomeServiceClass)` or `@Service("alias")` injects the matching `@service()`-decorated
|
|
20
|
+
* decaf {@link CoreService} (via {@link CoreService.get}).
|
|
21
|
+
* - `@Service()` infers the parameter's type from emitted constructor metadata and resolves it the
|
|
22
|
+
* same way, provided the parameter is typed as a concrete class (generics like `ModelService<X>`
|
|
23
|
+
* are erased at runtime, so the model-service form always requires an explicit argument).
|
|
24
|
+
* @param key the model class, service class, or alias to resolve. Omit to infer from the parameter type.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Service(key?: string | Constructor<any>): ParameterDecorator;
|
|
27
|
+
/**
|
|
28
|
+
* @description Constructor parameter decorator that injects a decaf {@link CoreRepository} for `model`.
|
|
29
|
+
* @summary Unlike {@link Service}, `model` is always treated as a Model class: the same class passed
|
|
30
|
+
* to `@Service(model)` and `@Repository(model)` resolves to two different injected objects (a
|
|
31
|
+
* `ModelService<M>` vs a `Repository<M>` respectively), via {@link CoreRepository.forModel}.
|
|
32
|
+
* @param model the model class to resolve a repository for.
|
|
33
|
+
* @param flavour optional adapter flavour/alias, forwarded to {@link CoreRepository.forModel}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Repository(model: Constructor<any>, flavour?: string): ParameterDecorator;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
+
export type DecafFactoryProvider = {
|
|
3
|
+
provide: string;
|
|
4
|
+
useFactory: () => unknown;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @description Drains the providers registered by {@link Service}/{@link Repository} usages.
|
|
8
|
+
* @summary Consumed by {@link DecafCoreModule.forRoot} to wire the tokens that those parameter
|
|
9
|
+
* decorators reference back into Nest's DI container, since a parameter decorator alone cannot
|
|
10
|
+
* supply a provider.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRegisteredDecafProviders(): DecafFactoryProvider[];
|
|
13
|
+
/**
|
|
14
|
+
* @description Constructor parameter decorator that injects a decaf service.
|
|
15
|
+
* @summary Translates decaf's service resolution APIs into a Nest `@Inject()` call:
|
|
16
|
+
* - `@Service(SomeModel)` injects the matching `@service(SomeModel)` decaf service when one is
|
|
17
|
+
* registered; otherwise it falls back to the `ModelService<SomeModel>` singleton
|
|
18
|
+
* (via {@link ModelService.forModel}).
|
|
19
|
+
* - `@Service(SomeServiceClass)` or `@Service("alias")` injects the matching `@service()`-decorated
|
|
20
|
+
* decaf {@link CoreService} (via {@link CoreService.get}).
|
|
21
|
+
* - `@Service()` infers the parameter's type from emitted constructor metadata and resolves it the
|
|
22
|
+
* same way, provided the parameter is typed as a concrete class (generics like `ModelService<X>`
|
|
23
|
+
* are erased at runtime, so the model-service form always requires an explicit argument).
|
|
24
|
+
* @param key the model class, service class, or alias to resolve. Omit to infer from the parameter type.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Service(key?: string | Constructor<any>): ParameterDecorator;
|
|
27
|
+
/**
|
|
28
|
+
* @description Constructor parameter decorator that injects a decaf {@link CoreRepository} for `model`.
|
|
29
|
+
* @summary Unlike {@link Service}, `model` is always treated as a Model class: the same class passed
|
|
30
|
+
* to `@Service(model)` and `@Repository(model)` resolves to two different injected objects (a
|
|
31
|
+
* `ModelService<M>` vs a `Repository<M>` respectively), via {@link CoreRepository.forModel}.
|
|
32
|
+
* @param model the model class to resolve a repository for.
|
|
33
|
+
* @param flavour optional adapter flavour/alias, forwarded to {@link CoreRepository.forModel}.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Repository(model: Constructor<any>, flavour?: string): ParameterDecorator;
|
|
@@ -190,6 +190,11 @@ export declare class NestBootstraper {
|
|
|
190
190
|
* set of standard exception filters for common error types like
|
|
191
191
|
* `HttpException`, `ValidationException`, `ConflictException`, and others.
|
|
192
192
|
*
|
|
193
|
+
* The default `DecafExceptionFilter` is constructed with the application's
|
|
194
|
+
* `ModuleRef` so it can resolve the request-scoped `DecafRequestContext` (and
|
|
195
|
+
* its client-bound logger) for the request that threw, instead of logging
|
|
196
|
+
* through the generic global logger.
|
|
197
|
+
*
|
|
193
198
|
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
194
199
|
*/
|
|
195
200
|
static useGlobalFilters(...filters: any[]): typeof NestBootstraper;
|
|
@@ -190,6 +190,11 @@ export declare class NestBootstraper {
|
|
|
190
190
|
* set of standard exception filters for common error types like
|
|
191
191
|
* `HttpException`, `ValidationException`, `ConflictException`, and others.
|
|
192
192
|
*
|
|
193
|
+
* The default `DecafExceptionFilter` is constructed with the application's
|
|
194
|
+
* `ModuleRef` so it can resolve the request-scoped `DecafRequestContext` (and
|
|
195
|
+
* its client-bound logger) for the request that threw, instead of logging
|
|
196
|
+
* through the generic global logger.
|
|
197
|
+
*
|
|
193
198
|
* @param {...ExceptionFilter[]} filters - Optional filters to apply globally.
|
|
194
199
|
*/
|
|
195
200
|
static useGlobalFilters(...filters: any[]): typeof NestBootstraper;
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import { ArgumentsHost, ExceptionFilter } from "@nestjs/common";
|
|
2
|
+
import { ModuleRef } from "@nestjs/core";
|
|
3
|
+
import { BaseError } from "@decaf-ts/db-decorators";
|
|
4
|
+
import type { RequestLogger } from "@decaf-ts/for-http/server";
|
|
2
5
|
export declare class DecafExceptionFilter implements ExceptionFilter {
|
|
3
|
-
|
|
6
|
+
protected readonly moduleRef?: ModuleRef | undefined;
|
|
7
|
+
constructor(moduleRef?: ModuleRef | undefined);
|
|
8
|
+
catch(exception: Error, host: ArgumentsHost): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* @description Finds the decaf-ts `BaseError` constructor mapped to this exception's type, if any.
|
|
11
|
+
* @summary Walks `HTTP_EXCEPTION_TO_DECAF_ERROR` with `instanceof` (rather than a straight
|
|
12
|
+
* `Map.get`) so subclasses of a mapped exception are matched too.
|
|
13
|
+
*/
|
|
14
|
+
protected decafErrorFor(exception: Error): ((msg: string) => BaseError) | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @description Logs the exception without ever letting logging failures block the response.
|
|
17
|
+
* @summary A guard (or middleware/CORS check) can throw before any decaf-aware provider ran,
|
|
18
|
+
* so the request-bound Context may not exist yet — or the resolved logger's `.error()` itself
|
|
19
|
+
* could throw (broken transport, formatter bug, etc.). Either way the client-facing error
|
|
20
|
+
* response below must still go out, so every failure mode here is swallowed, falling back to
|
|
21
|
+
* the plain `Logging.get()` logger and, as a last resort, doing nothing at all.
|
|
22
|
+
*/
|
|
23
|
+
protected logError(request: Record<string, any>, exception: Error): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* @description Resolves the logger bound to the originating request's decaf-ts Context.
|
|
26
|
+
* @summary Global filters are singletons, so the request-scoped {@link DecafRequestContext}
|
|
27
|
+
* (and the client/user-bound logger it carries) can't be constructor-injected. Instead, this
|
|
28
|
+
* looks up the same request's context id and re-resolves the already-accumulated instance
|
|
29
|
+
* through `ModuleRef`. Falls back to the generic `Logging.get()` logger when the filter wasn't
|
|
30
|
+
* constructed with a `ModuleRef` (e.g. manually `new`'d) or no request-scoped context exists
|
|
31
|
+
* for this request (e.g. the error happened before any decaf-aware provider ran, as is the
|
|
32
|
+
* case when a guard rejects the request before interceptors get to bind the client-scoped
|
|
33
|
+
* logger onto the Context).
|
|
34
|
+
*/
|
|
35
|
+
protected resolveLogger(request: Record<string, any>): Promise<RequestLogger>;
|
|
4
36
|
}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import { ArgumentsHost, ExceptionFilter } from "@nestjs/common";
|
|
2
|
+
import { ModuleRef } from "@nestjs/core";
|
|
3
|
+
import { BaseError } from "@decaf-ts/db-decorators";
|
|
4
|
+
import type { RequestLogger } from "@decaf-ts/for-http/server";
|
|
2
5
|
export declare class DecafExceptionFilter implements ExceptionFilter {
|
|
3
|
-
|
|
6
|
+
protected readonly moduleRef?: ModuleRef | undefined;
|
|
7
|
+
constructor(moduleRef?: ModuleRef | undefined);
|
|
8
|
+
catch(exception: Error, host: ArgumentsHost): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* @description Finds the decaf-ts `BaseError` constructor mapped to this exception's type, if any.
|
|
11
|
+
* @summary Walks `HTTP_EXCEPTION_TO_DECAF_ERROR` with `instanceof` (rather than a straight
|
|
12
|
+
* `Map.get`) so subclasses of a mapped exception are matched too.
|
|
13
|
+
*/
|
|
14
|
+
protected decafErrorFor(exception: Error): ((msg: string) => BaseError) | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @description Logs the exception without ever letting logging failures block the response.
|
|
17
|
+
* @summary A guard (or middleware/CORS check) can throw before any decaf-aware provider ran,
|
|
18
|
+
* so the request-bound Context may not exist yet — or the resolved logger's `.error()` itself
|
|
19
|
+
* could throw (broken transport, formatter bug, etc.). Either way the client-facing error
|
|
20
|
+
* response below must still go out, so every failure mode here is swallowed, falling back to
|
|
21
|
+
* the plain `Logging.get()` logger and, as a last resort, doing nothing at all.
|
|
22
|
+
*/
|
|
23
|
+
protected logError(request: Record<string, any>, exception: Error): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* @description Resolves the logger bound to the originating request's decaf-ts Context.
|
|
26
|
+
* @summary Global filters are singletons, so the request-scoped {@link DecafRequestContext}
|
|
27
|
+
* (and the client/user-bound logger it carries) can't be constructor-injected. Instead, this
|
|
28
|
+
* looks up the same request's context id and re-resolves the already-accumulated instance
|
|
29
|
+
* through `ModuleRef`. Falls back to the generic `Logging.get()` logger when the filter wasn't
|
|
30
|
+
* constructed with a `ModuleRef` (e.g. manually `new`'d) or no request-scoped context exists
|
|
31
|
+
* for this request (e.g. the error happened before any decaf-aware provider ran, as is the
|
|
32
|
+
* case when a guard rejects the request before interceptors get to bind the client-scoped
|
|
33
|
+
* logger onto the Context).
|
|
34
|
+
*/
|
|
35
|
+
protected resolveLogger(request: Record<string, any>): Promise<RequestLogger>;
|
|
4
36
|
}
|
|
@@ -14,12 +14,16 @@ import { Model } from "@decaf-ts/decorator-validation";
|
|
|
14
14
|
* • CREATE – included only when the pk is NOT auto-generated
|
|
15
15
|
* (checked via Model.pkProps().generated AND Model.generated()).
|
|
16
16
|
* - Relation properties (@oneToOne, @oneToMany, …):
|
|
17
|
-
* • CREATE – nested as DtoFor(CREATE, RelatedModel).
|
|
17
|
+
* • CREATE – nested as DtoFor(CREATE, RelatedModel). When the relation
|
|
18
|
+
* creates a circular reference (model A → model B → model A),
|
|
19
|
+
* the back-reference uses the related model's PK type
|
|
20
|
+
* (string/integer) instead of the full DTO to break the cycle.
|
|
18
21
|
* • UPDATE – union of DtoFor(UPDATE, RelatedModel) **or** the
|
|
19
22
|
* related model's primary-key type (string / integer),
|
|
20
|
-
* expressed as a Swagger oneOf.
|
|
23
|
+
* expressed as a Swagger oneOf. Circular back-references
|
|
24
|
+
* omit the DTO $ref and only include the PK type.
|
|
21
25
|
*
|
|
22
26
|
* Metadata.properties() now returns ALL properties across the prototype chain,
|
|
23
27
|
* so DTO inheritance is no longer needed; every DTO is a flat class.
|
|
24
28
|
*/
|
|
25
|
-
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M
|
|
29
|
+
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M>, stack?: Set<Constructor<any>>): Constructor<any>;
|
|
@@ -14,12 +14,16 @@ import { Model } from "@decaf-ts/decorator-validation";
|
|
|
14
14
|
* • CREATE – included only when the pk is NOT auto-generated
|
|
15
15
|
* (checked via Model.pkProps().generated AND Model.generated()).
|
|
16
16
|
* - Relation properties (@oneToOne, @oneToMany, …):
|
|
17
|
-
* • CREATE – nested as DtoFor(CREATE, RelatedModel).
|
|
17
|
+
* • CREATE – nested as DtoFor(CREATE, RelatedModel). When the relation
|
|
18
|
+
* creates a circular reference (model A → model B → model A),
|
|
19
|
+
* the back-reference uses the related model's PK type
|
|
20
|
+
* (string/integer) instead of the full DTO to break the cycle.
|
|
18
21
|
* • UPDATE – union of DtoFor(UPDATE, RelatedModel) **or** the
|
|
19
22
|
* related model's primary-key type (string / integer),
|
|
20
|
-
* expressed as a Swagger oneOf.
|
|
23
|
+
* expressed as a Swagger oneOf. Circular back-references
|
|
24
|
+
* omit the DTO $ref and only include the PK type.
|
|
21
25
|
*
|
|
22
26
|
* Metadata.properties() now returns ALL properties across the prototype chain,
|
|
23
27
|
* so DTO inheritance is no longer needed; every DTO is a flat class.
|
|
24
28
|
*/
|
|
25
|
-
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M
|
|
29
|
+
export declare function DtoFor<M extends Model>(op: OperationKeys, model: Constructor<M>, stack?: Set<Constructor<any>>): Constructor<any>;
|
package/lib/types/index.d.cts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import "./decoration";
|
|
23
23
|
export * from "./decoration.d.cts";
|
|
24
24
|
export * from "./decaf-model/index.d.cts";
|
|
25
|
+
export * from "./auth/index.d.cts";
|
|
25
26
|
export * from "./factory/index.d.cts";
|
|
26
27
|
export * from "./interceptors/index.d.cts";
|
|
27
28
|
export * from "./overrides/index.d.cts";
|
|
@@ -30,8 +31,8 @@ export * from "./constants.d.cts";
|
|
|
30
31
|
export * from "./controllers.d.cts";
|
|
31
32
|
export * from "./module.d.cts";
|
|
32
33
|
export * from "./core-module.d.cts";
|
|
33
|
-
export * from "./migrations/index.d.cts";
|
|
34
34
|
export * from "./types.d.cts";
|
|
35
|
+
export * from "./decorators.d.cts";
|
|
35
36
|
export * from "./utils.d.cts";
|
|
36
37
|
export * from "./events-module/index.d.cts";
|
|
37
38
|
/**
|
|
@@ -40,19 +41,19 @@ export * from "./events-module/index.d.cts";
|
|
|
40
41
|
* @constant
|
|
41
42
|
* @type {string}
|
|
42
43
|
*/
|
|
43
|
-
export declare const VERSION = "0.11.
|
|
44
|
+
export declare const VERSION = "0.11.2-refactor.9";
|
|
44
45
|
/**
|
|
45
46
|
* @description Represents the current commit hash of the module build.
|
|
46
47
|
* @summary Stores the current git commit hash for the package. The build replaces
|
|
47
48
|
* the placeholder with the actual commit hash at publish time.
|
|
48
49
|
* @const COMMIT
|
|
49
50
|
*/
|
|
50
|
-
export declare const COMMIT = "
|
|
51
|
+
export declare const COMMIT = "00a7d73";
|
|
51
52
|
/**
|
|
52
53
|
* @description Represents the full version string of the module.
|
|
53
54
|
* @summary Stores the semver version and commit hash for the package.
|
|
54
55
|
* The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
|
|
55
56
|
* @const FULL_VERSION
|
|
56
57
|
*/
|
|
57
|
-
export declare const FULL_VERSION = "0.11.
|
|
58
|
+
export declare const FULL_VERSION = "0.11.2-refactor.9-00a7d73";
|
|
58
59
|
export declare const PACKAGE_NAME = "@decaf-ts/for-nest";
|