@ddd-ts-kit/http 0.90.0 → 0.92.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.fr.md +231 -2
- package/README.md +225 -1
- package/dist/controller/controller-request.d.ts +10 -1
- package/dist/controller/controller-request.d.ts.map +1 -1
- package/dist/controller/controller-response.d.ts +6 -0
- package/dist/controller/controller-response.d.ts.map +1 -1
- package/dist/controller/controller-result.d.ts +22 -4
- package/dist/controller/controller-result.d.ts.map +1 -1
- package/dist/controller/controller-routes.d.ts.map +1 -1
- package/dist/controller/controller-routes.js +29 -4
- package/dist/controller/controller-routes.js.map +1 -1
- package/dist/controller/controller-spec.d.ts +7 -0
- package/dist/controller/controller-spec.d.ts.map +1 -1
- package/dist/controller/declared-route.d.ts.map +1 -1
- package/dist/controller/declared-route.js +10 -0
- package/dist/controller/declared-route.js.map +1 -1
- package/dist/controller/http-controller.d.ts +4 -5
- package/dist/controller/http-controller.d.ts.map +1 -1
- package/dist/controller/http-request.d.ts +10 -1
- package/dist/controller/http-request.d.ts.map +1 -1
- package/dist/error/refusal-codes-by-status.d.ts +11 -0
- package/dist/error/refusal-codes-by-status.d.ts.map +1 -0
- package/dist/error/refusal-codes-by-status.js +48 -0
- package/dist/error/refusal-codes-by-status.js.map +1 -0
- package/dist/express/mount-express.d.ts +2 -1
- package/dist/express/mount-express.d.ts.map +1 -1
- package/dist/express/mount-express.js +12 -2
- package/dist/express/mount-express.js.map +1 -1
- package/dist/nest/controllers/arguments-of.d.ts +7 -0
- package/dist/nest/controllers/arguments-of.d.ts.map +1 -0
- package/dist/nest/controllers/arguments-of.js +26 -0
- package/dist/nest/controllers/arguments-of.js.map +1 -0
- package/dist/nest/controllers/assert-not-routed-by-nest.d.ts +8 -0
- package/dist/nest/controllers/assert-not-routed-by-nest.d.ts.map +1 -0
- package/dist/nest/controllers/assert-not-routed-by-nest.js +19 -0
- package/dist/nest/controllers/assert-not-routed-by-nest.js.map +1 -0
- package/dist/nest/controllers/controllers-binder.d.ts +6 -0
- package/dist/nest/controllers/controllers-binder.d.ts.map +1 -0
- package/dist/nest/controllers/controllers-binder.js +5 -0
- package/dist/nest/controllers/controllers-binder.js.map +1 -0
- package/dist/nest/controllers/controllers-module-options.d.ts +8 -0
- package/dist/nest/controllers/controllers-module-options.d.ts.map +1 -0
- package/dist/nest/controllers/controllers-module-options.js +2 -0
- package/dist/nest/controllers/controllers-module-options.js.map +1 -0
- package/dist/nest/controllers/create-controllers-module.d.ts +10 -0
- package/dist/nest/controllers/create-controllers-module.d.ts.map +1 -0
- package/dist/nest/controllers/create-controllers-module.js +28 -0
- package/dist/nest/controllers/create-controllers-module.js.map +1 -0
- package/dist/nest/controllers/current-actor.d.ts +6 -0
- package/dist/nest/controllers/current-actor.d.ts.map +1 -0
- package/dist/nest/controllers/current-actor.js +9 -0
- package/dist/nest/controllers/current-actor.js.map +1 -0
- package/dist/nest/controllers/dto-type.d.ts +3 -0
- package/dist/nest/controllers/dto-type.d.ts.map +1 -0
- package/dist/nest/controllers/dto-type.js +2 -0
- package/dist/nest/controllers/dto-type.js.map +1 -0
- package/dist/nest/controllers/injected-parameter.d.ts +4 -0
- package/dist/nest/controllers/injected-parameter.d.ts.map +1 -0
- package/dist/nest/controllers/injected-parameter.js +17 -0
- package/dist/nest/controllers/injected-parameter.js.map +1 -0
- package/dist/nest/controllers/is-nest-controller.d.ts +4 -0
- package/dist/nest/controllers/is-nest-controller.d.ts.map +1 -0
- package/dist/nest/controllers/is-nest-controller.js +7 -0
- package/dist/nest/controllers/is-nest-controller.js.map +1 -0
- package/dist/nest/controllers/keyed-schema.d.ts +8 -0
- package/dist/nest/controllers/keyed-schema.d.ts.map +1 -0
- package/dist/nest/controllers/keyed-schema.js +33 -0
- package/dist/nest/controllers/keyed-schema.js.map +1 -0
- package/dist/nest/controllers/kit-route-spec.d.ts +71 -0
- package/dist/nest/controllers/kit-route-spec.d.ts.map +1 -0
- package/dist/nest/controllers/kit-route-spec.js +2 -0
- package/dist/nest/controllers/kit-route-spec.js.map +1 -0
- package/dist/nest/controllers/kit-route.d.ts +18 -0
- package/dist/nest/controllers/kit-route.d.ts.map +1 -0
- package/dist/nest/controllers/kit-route.js +29 -0
- package/dist/nest/controllers/kit-route.js.map +1 -0
- package/dist/nest/controllers/kit-routes-options.d.ts +15 -0
- package/dist/nest/controllers/kit-routes-options.d.ts.map +1 -0
- package/dist/nest/controllers/kit-routes-options.js +2 -0
- package/dist/nest/controllers/kit-routes-options.js.map +1 -0
- package/dist/nest/controllers/kit-routes.d.ts +5 -0
- package/dist/nest/controllers/kit-routes.d.ts.map +1 -0
- package/dist/nest/controllers/kit-routes.js +8 -0
- package/dist/nest/controllers/kit-routes.js.map +1 -0
- package/dist/nest/controllers/nest-controller-class.d.ts +3 -0
- package/dist/nest/controllers/nest-controller-class.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controller-class.js +2 -0
- package/dist/nest/controllers/nest-controller-class.js.map +1 -0
- package/dist/nest/controllers/nest-controller-route.d.ts +6 -0
- package/dist/nest/controllers/nest-controller-route.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controller-route.js +12 -0
- package/dist/nest/controllers/nest-controller-route.js.map +1 -0
- package/dist/nest/controllers/nest-controller-routes-options.d.ts +14 -0
- package/dist/nest/controllers/nest-controller-routes-options.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controller-routes-options.js +2 -0
- package/dist/nest/controllers/nest-controller-routes-options.js.map +1 -0
- package/dist/nest/controllers/nest-controller-routes.d.ts +12 -0
- package/dist/nest/controllers/nest-controller-routes.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controller-routes.js +159 -0
- package/dist/nest/controllers/nest-controller-routes.js.map +1 -0
- package/dist/nest/controllers/nest-controllers-options.d.ts +7 -0
- package/dist/nest/controllers/nest-controllers-options.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controllers-options.js +2 -0
- package/dist/nest/controllers/nest-controllers-options.js.map +1 -0
- package/dist/nest/controllers/nest-controllers.d.ts +21 -0
- package/dist/nest/controllers/nest-controllers.d.ts.map +1 -0
- package/dist/nest/controllers/nest-controllers.js +31 -0
- package/dist/nest/controllers/nest-controllers.js.map +1 -0
- package/dist/nest/controllers/nest-method.d.ts +20 -0
- package/dist/nest/controllers/nest-method.d.ts.map +1 -0
- package/dist/nest/controllers/nest-method.js +2 -0
- package/dist/nest/controllers/nest-method.js.map +1 -0
- package/dist/nest/controllers/nest-parameter.d.ts +10 -0
- package/dist/nest/controllers/nest-parameter.d.ts.map +1 -0
- package/dist/nest/controllers/nest-parameter.js +2 -0
- package/dist/nest/controllers/nest-parameter.js.map +1 -0
- package/dist/nest/controllers/nest-route-metadata.d.ts +22 -0
- package/dist/nest/controllers/nest-route-metadata.d.ts.map +1 -0
- package/dist/nest/controllers/nest-route-metadata.js +121 -0
- package/dist/nest/controllers/nest-route-metadata.js.map +1 -0
- package/dist/nest/controllers/nest-route-methods.d.ts +4 -0
- package/dist/nest/controllers/nest-route-methods.d.ts.map +1 -0
- package/dist/nest/controllers/nest-route-methods.js +12 -0
- package/dist/nest/controllers/nest-route-methods.js.map +1 -0
- package/dist/nest/controllers/nest-routes-registry.d.ts +17 -0
- package/dist/nest/controllers/nest-routes-registry.d.ts.map +1 -0
- package/dist/nest/controllers/nest-routes-registry.js +23 -0
- package/dist/nest/controllers/nest-routes-registry.js.map +1 -0
- package/dist/nest/controllers/nest-signature.d.ts +15 -0
- package/dist/nest/controllers/nest-signature.d.ts.map +1 -0
- package/dist/nest/controllers/nest-signature.js +2 -0
- package/dist/nest/controllers/nest-signature.js.map +1 -0
- package/dist/nest/controllers/prototype-of.d.ts +4 -0
- package/dist/nest/controllers/prototype-of.d.ts.map +1 -0
- package/dist/nest/controllers/prototype-of.js +10 -0
- package/dist/nest/controllers/prototype-of.js.map +1 -0
- package/dist/nest/controllers/provide-controllers.d.ts +12 -0
- package/dist/nest/controllers/provide-controllers.d.ts.map +1 -0
- package/dist/nest/controllers/provide-controllers.js +33 -0
- package/dist/nest/controllers/provide-controllers.js.map +1 -0
- package/dist/nest/controllers/reflected-metadata.d.ts +3 -0
- package/dist/nest/controllers/reflected-metadata.d.ts.map +1 -0
- package/dist/nest/controllers/reflected-metadata.js +11 -0
- package/dist/nest/controllers/reflected-metadata.js.map +1 -0
- package/dist/nest/controllers/request-schemas-of.d.ts +14 -0
- package/dist/nest/controllers/request-schemas-of.d.ts.map +1 -0
- package/dist/nest/controllers/request-schemas-of.js +50 -0
- package/dist/nest/controllers/request-schemas-of.js.map +1 -0
- package/dist/nest/controllers/route-context.d.ts +3 -0
- package/dist/nest/controllers/route-context.d.ts.map +1 -0
- package/dist/nest/controllers/route-context.js +6 -0
- package/dist/nest/controllers/route-context.js.map +1 -0
- package/dist/nest/controllers/schema-of.d.ts +6 -0
- package/dist/nest/controllers/schema-of.d.ts.map +1 -0
- package/dist/nest/controllers/schema-of.js +12 -0
- package/dist/nest/controllers/schema-of.js.map +1 -0
- package/dist/nest/controllers/summary-of.d.ts +3 -0
- package/dist/nest/controllers/summary-of.d.ts.map +1 -0
- package/dist/nest/controllers/summary-of.js +6 -0
- package/dist/nest/controllers/summary-of.js.map +1 -0
- package/dist/nest/controllers/upload.d.ts +6 -0
- package/dist/nest/controllers/upload.d.ts.map +1 -0
- package/dist/nest/controllers/upload.js +9 -0
- package/dist/nest/controllers/upload.js.map +1 -0
- package/dist/nest/controllers/with-signatures.d.ts +10 -0
- package/dist/nest/controllers/with-signatures.d.ts.map +1 -0
- package/dist/nest/controllers/with-signatures.js +12 -0
- package/dist/nest/controllers/with-signatures.js.map +1 -0
- package/dist/nest.d.ts +20 -0
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +12 -0
- package/dist/nest.js.map +1 -1
- package/dist/openapi/request-body.d.ts.map +1 -1
- package/dist/openapi/request-body.js +11 -0
- package/dist/openapi/request-body.js.map +1 -1
- package/dist/openapi/responses.d.ts.map +1 -1
- package/dist/openapi/responses.js +12 -42
- package/dist/openapi/responses.js.map +1 -1
- package/dist/orpc/orpc-protocol.d.ts +7 -0
- package/dist/orpc/orpc-protocol.d.ts.map +1 -0
- package/dist/orpc/orpc-protocol.js +13 -0
- package/dist/orpc/orpc-protocol.js.map +1 -0
- package/dist/orpc/orpc-router.d.ts +22 -0
- package/dist/orpc/orpc-router.d.ts.map +1 -0
- package/dist/orpc/orpc-router.js +43 -0
- package/dist/orpc/orpc-router.js.map +1 -0
- package/dist/orpc.d.ts +4 -0
- package/dist/orpc.d.ts.map +1 -0
- package/dist/orpc.js +2 -0
- package/dist/orpc.js.map +1 -0
- package/dist/pipeline/primed.d.ts +2 -1
- package/dist/pipeline/primed.d.ts.map +1 -1
- package/dist/pipeline/primed.js +14 -11
- package/dist/pipeline/primed.js.map +1 -1
- package/dist/route/response-spec.d.ts +2 -0
- package/dist/route/response-spec.d.ts.map +1 -1
- package/dist/rpc/rpc-answer.d.ts +18 -0
- package/dist/rpc/rpc-answer.d.ts.map +1 -0
- package/dist/rpc/rpc-answer.js +61 -0
- package/dist/rpc/rpc-answer.js.map +1 -0
- package/dist/rpc/rpc-context.d.ts +15 -0
- package/dist/rpc/rpc-context.d.ts.map +1 -0
- package/dist/rpc/rpc-context.js +2 -0
- package/dist/rpc/rpc-context.js.map +1 -0
- package/dist/rpc/rpc-input.d.ts +11 -0
- package/dist/rpc/rpc-input.d.ts.map +1 -0
- package/dist/rpc/rpc-input.js +2 -0
- package/dist/rpc/rpc-input.js.map +1 -0
- package/dist/rpc/rpc-refusal.d.ts +14 -0
- package/dist/rpc/rpc-refusal.d.ts.map +1 -0
- package/dist/rpc/rpc-refusal.js +2 -0
- package/dist/rpc/rpc-refusal.js.map +1 -0
- package/dist/rpc/rpc-request.d.ts +9 -0
- package/dist/rpc/rpc-request.d.ts.map +1 -0
- package/dist/rpc/rpc-request.js +28 -0
- package/dist/rpc/rpc-request.js.map +1 -0
- package/dist/trpc/route-refusal.d.ts +8 -0
- package/dist/trpc/route-refusal.d.ts.map +1 -0
- package/dist/trpc/route-refusal.js +10 -0
- package/dist/trpc/route-refusal.js.map +1 -0
- package/dist/trpc/trpc-error-shape.d.ts +17 -0
- package/dist/trpc/trpc-error-shape.d.ts.map +1 -0
- package/dist/trpc/trpc-error-shape.js +2 -0
- package/dist/trpc/trpc-error-shape.js.map +1 -0
- package/dist/trpc/trpc-protocol.d.ts +8 -0
- package/dist/trpc/trpc-protocol.d.ts.map +1 -0
- package/dist/trpc/trpc-protocol.js +43 -0
- package/dist/trpc/trpc-protocol.js.map +1 -0
- package/dist/trpc/trpc-router.d.ts +38 -0
- package/dist/trpc/trpc-router.d.ts.map +1 -0
- package/dist/trpc/trpc-router.js +44 -0
- package/dist/trpc/trpc-router.js.map +1 -0
- package/dist/trpc.d.ts +5 -0
- package/dist/trpc.d.ts.map +1 -0
- package/dist/trpc.js +2 -0
- package/dist/trpc.js.map +1 -0
- package/package.json +30 -7
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Provider, Type } from '@nestjs/common';
|
|
2
|
+
import type { ModuleRef } from '@nestjs/core';
|
|
3
|
+
import type { Route } from '../../route/route.js';
|
|
4
|
+
import type { NestControllersOptions } from './nest-controllers-options.js';
|
|
5
|
+
/** The Nest controllers of an application, their routes built now and their instances built by Nest at its start. */
|
|
6
|
+
export interface NestControllers {
|
|
7
|
+
readonly controllers: readonly Type<unknown>[];
|
|
8
|
+
readonly providers: readonly Provider[];
|
|
9
|
+
/** For the server, the contract and the procedures, as every route of the application. */
|
|
10
|
+
readonly routes: readonly Route[];
|
|
11
|
+
/** Hands the routes the instances Nest's container built: `provideControllers` calls it at the start. */
|
|
12
|
+
bind(references: ModuleRef): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The routes of Nest controllers, built before Nest starts, for an application that composes its
|
|
16
|
+
* routes itself: they join its other routes, and `provideControllers` lets Nest build each
|
|
17
|
+
* controller with what it injects. A guard a route names is a value here (`Authenticated`,
|
|
18
|
+
* `HasRole(...)`): one given as a class is built by `createControllersModule`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function nestControllers(controllers: readonly Type<unknown>[], options?: NestControllersOptions): NestControllers;
|
|
21
|
+
//# sourceMappingURL=nest-controllers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-controllers.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGzE,qHAAqH;AACrH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;IACxC,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,yGAAyG;IACzG,IAAI,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,EAAE,EACrC,OAAO,GAAE,sBAA2B,GACnC,eAAe,CA0BjB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import { nestControllerRoutes } from './nest-controller-routes.js';
|
|
3
|
+
/**
|
|
4
|
+
* The routes of Nest controllers, built before Nest starts, for an application that composes its
|
|
5
|
+
* routes itself: they join its other routes, and `provideControllers` lets Nest build each
|
|
6
|
+
* controller with what it injects. A guard a route names is a value here (`Authenticated`,
|
|
7
|
+
* `HasRole(...)`): one given as a class is built by `createControllersModule`.
|
|
8
|
+
*/
|
|
9
|
+
export function nestControllers(controllers, options = {}) {
|
|
10
|
+
const { providers = [], schemaOfClass, security } = options;
|
|
11
|
+
let references;
|
|
12
|
+
const routes = nestControllerRoutes(controllers, {
|
|
13
|
+
instanceOf: (controller) => {
|
|
14
|
+
if (references === undefined) {
|
|
15
|
+
throw new DeclarationError(`${controller.name} is called before Nest started: give the controllers to provideControllers in the Nest application.`);
|
|
16
|
+
}
|
|
17
|
+
return references.get(controller, { strict: false });
|
|
18
|
+
},
|
|
19
|
+
...(schemaOfClass === undefined ? {} : { schemaOfClass }),
|
|
20
|
+
...(security === undefined ? {} : { security }),
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
controllers,
|
|
24
|
+
providers,
|
|
25
|
+
routes,
|
|
26
|
+
bind: (built) => {
|
|
27
|
+
references = built;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=nest-controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-controllers.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-controllers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAYhE;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,WAAqC,EACrC,OAAO,GAA2B,EAAE;IAEpC,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC5D,IAAI,UAAiC,CAAC;IAEtC,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,EAAE;QAC/C,UAAU,EAAE,CAAC,UAAU,EAAE,EAAE;YACzB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,MAAM,IAAI,gBAAgB,CACxB,GAAG,UAAU,CAAC,IAAI,qGAAqG,CACxH,CAAC;YACJ,CAAC;YAED,OAAO,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;QACzD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,OAAO;QACL,WAAW;QACX,SAAS;QACT,MAAM;QACN,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACd,UAAU,GAAG,KAAK,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KitRouteSpec } from './kit-route-spec.js';
|
|
2
|
+
import type { NestControllerClass } from './nest-controller-class.js';
|
|
3
|
+
import type { NestRouteMetadata } from './nest-route-metadata.js';
|
|
4
|
+
import type { Injected } from './nest-routes-registry.js';
|
|
5
|
+
import type { NestSignature } from './nest-signature.js';
|
|
6
|
+
/** One method of a Nest controller the kit serves: what Nest's decorators say, and what the kit's say. */
|
|
7
|
+
export interface NestMethod {
|
|
8
|
+
readonly controller: NestControllerClass;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** `InvoicesController.issue`, for the messages. */
|
|
11
|
+
readonly where: string;
|
|
12
|
+
/** What @KitRoute says, its name and its summary given when it said none. */
|
|
13
|
+
readonly spec: KitRouteSpec & Required<Pick<KitRouteSpec, 'operationId' | 'summary'>>;
|
|
14
|
+
readonly read: NestRouteMetadata;
|
|
15
|
+
/** By index, what a parameter decorator of the kit asks for. */
|
|
16
|
+
readonly injected: ReadonlyMap<number, Injected>;
|
|
17
|
+
/** What its signature says, as `ddd-ts-kit` read it into the generated list of its context. */
|
|
18
|
+
readonly signature: NestSignature;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=nest-method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-method.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,0GAA0G;AAC1G,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC,CAAC;IACtF,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjD,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-method.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-method.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** One parameter of a method of a Nest controller, read from Nest's `@Body`, `@Query`, `@Param` or `@Headers`. */
|
|
2
|
+
export interface NestParameter {
|
|
3
|
+
readonly index: number;
|
|
4
|
+
readonly source: 'body' | 'query' | 'params' | 'headers';
|
|
5
|
+
/** The name it reads, as `@Param('invoiceId')` gives it; left out, the whole part. */
|
|
6
|
+
readonly key?: string;
|
|
7
|
+
/** The class TypeScript recorded for it, with `emitDecoratorMetadata`. */
|
|
8
|
+
readonly type: unknown;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=nest-parameter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-parameter.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-parameter.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzD,sFAAsF;IACtF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-parameter.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-parameter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HttpMethod } from '../../route/http-method.js';
|
|
2
|
+
import type { NestControllerClass } from './nest-controller-class.js';
|
|
3
|
+
import type { NestParameter } from './nest-parameter.js';
|
|
4
|
+
/**
|
|
5
|
+
* What the decorators of Nest wrote on a controller and its methods, read in this file alone. The
|
|
6
|
+
* keys are those `@nestjs/common/constants` exports, which Nest's own router reads; their shape is
|
|
7
|
+
* checked on each read, so that a release of Nest that changes it stops the start with a message
|
|
8
|
+
* instead of serving a route read wrong (`test/nest-metadata-contract.spec.ts` holds it on the
|
|
9
|
+
* installed Nest).
|
|
10
|
+
*/
|
|
11
|
+
export interface NestRouteMetadata {
|
|
12
|
+
readonly method: HttpMethod;
|
|
13
|
+
/** The path of the controller and of the method, as Nest joins them: `invoices/:invoiceId/issue`. */
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly httpCode: number | undefined;
|
|
16
|
+
readonly parameters: readonly NestParameter[];
|
|
17
|
+
/** What TypeScript recorded the method returns, with `emitDecoratorMetadata`: `undefined` for `void` or without it. */
|
|
18
|
+
readonly returnType: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** The route Nest's decorators declare on one method of a controller. */
|
|
21
|
+
export declare function nestRouteMetadata(controller: NestControllerClass, method: string): NestRouteMetadata;
|
|
22
|
+
//# sourceMappingURL=nest-route-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-route-metadata.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-route-metadata.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,qGAAqG;IACrG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,uHAAuH;IACvH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAmCD,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAmBpG"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import { RequestMethod } from '@nestjs/common';
|
|
3
|
+
import { EXCEPTION_FILTERS_METADATA, GUARDS_METADATA, HEADERS_METADATA, HTTP_CODE_METADATA, INTERCEPTORS_METADATA, METHOD_METADATA, PARAMTYPES_METADATA, PATH_METADATA, PIPES_METADATA, REDIRECT_METADATA, RENDER_METADATA, ROUTE_ARGS_METADATA, SSE_METADATA, VERSION_METADATA, } from '@nestjs/common/constants';
|
|
4
|
+
import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
|
|
5
|
+
import { isRecord } from '../../support/is-record.js';
|
|
6
|
+
import { prototypeOf } from './prototype-of.js';
|
|
7
|
+
import { reflectedMetadata as metadata } from './reflected-metadata.js';
|
|
8
|
+
/** Written by TypeScript itself under `emitDecoratorMetadata`, next to `design:paramtypes`. */
|
|
9
|
+
const RETURN_TYPE_METADATA = 'design:returntype';
|
|
10
|
+
const METHODS = new Map([
|
|
11
|
+
[RequestMethod.GET, 'GET'],
|
|
12
|
+
[RequestMethod.POST, 'POST'],
|
|
13
|
+
[RequestMethod.PUT, 'PUT'],
|
|
14
|
+
[RequestMethod.PATCH, 'PATCH'],
|
|
15
|
+
[RequestMethod.DELETE, 'DELETE'],
|
|
16
|
+
[RequestMethod.HEAD, 'HEAD'],
|
|
17
|
+
[RequestMethod.OPTIONS, 'OPTIONS'],
|
|
18
|
+
]);
|
|
19
|
+
const SOURCES = new Map([
|
|
20
|
+
[RouteParamtypes.BODY, 'body'],
|
|
21
|
+
[RouteParamtypes.QUERY, 'query'],
|
|
22
|
+
[RouteParamtypes.PARAM, 'params'],
|
|
23
|
+
[RouteParamtypes.HEADERS, 'headers'],
|
|
24
|
+
]);
|
|
25
|
+
/** Nest features the pipeline of the kit does not run: a route that declares one would silently lose it. */
|
|
26
|
+
const NOT_RUN = [
|
|
27
|
+
[GUARDS_METADATA, '@UseGuards: name the guards of the kit in `guards` of @KitRoute or @KitRoutes'],
|
|
28
|
+
[PIPES_METADATA, '@UsePipes: the schemas of the route validate its input'],
|
|
29
|
+
[INTERCEPTORS_METADATA, '@UseInterceptors: a bus middleware or an aspect does that work'],
|
|
30
|
+
[EXCEPTION_FILTERS_METADATA, '@UseFilters: the error mapper answers every refusal'],
|
|
31
|
+
[HEADERS_METADATA, '@Header: a route of the kit declares its answer, its cache headers in `cache`'],
|
|
32
|
+
[REDIRECT_METADATA, '@Redirect'],
|
|
33
|
+
[RENDER_METADATA, '@Render'],
|
|
34
|
+
[SSE_METADATA, '@Sse'],
|
|
35
|
+
[VERSION_METADATA, '@Version: give the version in the path'],
|
|
36
|
+
];
|
|
37
|
+
/** The route Nest's decorators declare on one method of a controller. */
|
|
38
|
+
export function nestRouteMetadata(controller, method) {
|
|
39
|
+
const where = `${controller.name}.${method}`;
|
|
40
|
+
const handler = Reflect.get(prototypeOf(controller), method);
|
|
41
|
+
if (typeof handler !== 'function') {
|
|
42
|
+
throw new DeclarationError(`${where} carries @KitRoute and is no method.`);
|
|
43
|
+
}
|
|
44
|
+
assertNothingNotRun(where, [controller, handler]);
|
|
45
|
+
return {
|
|
46
|
+
method: methodOf(where, metadata(METHOD_METADATA, handler)),
|
|
47
|
+
path: [pathOf(where, metadata(PATH_METADATA, controller)), pathOf(where, metadata(PATH_METADATA, handler))]
|
|
48
|
+
.filter((part) => part !== '')
|
|
49
|
+
.join('/'),
|
|
50
|
+
httpCode: httpCodeOf(where, metadata(HTTP_CODE_METADATA, handler)),
|
|
51
|
+
parameters: parametersOf(where, controller, method),
|
|
52
|
+
returnType: metadata(RETURN_TYPE_METADATA, prototypeOf(controller), method),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function assertNothingNotRun(where, targets) {
|
|
56
|
+
for (const [key, feature] of NOT_RUN) {
|
|
57
|
+
const declared = targets.map((target) => metadata(key, target));
|
|
58
|
+
if (declared.some((value) => value !== undefined && !(Array.isArray(value) && value.length === 0))) {
|
|
59
|
+
throw new DeclarationError(`${where} declares ${feature}. The kit serves the route through its own pipeline, where Nest's does not run.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function methodOf(where, value) {
|
|
64
|
+
const method = typeof value === 'number' ? METHODS.get(value) : undefined;
|
|
65
|
+
if (method === undefined) {
|
|
66
|
+
throw new DeclarationError(`${where} carries @KitRoute and no @Get, @Post, @Put, @Patch, @Delete, @Head or @Options of Nest that the kit reads.`);
|
|
67
|
+
}
|
|
68
|
+
return method;
|
|
69
|
+
}
|
|
70
|
+
function pathOf(where, value) {
|
|
71
|
+
if (value === undefined) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
if (typeof value !== 'string') {
|
|
75
|
+
throw new DeclarationError(`${where}: a route of the kit has one path, and Nest declares several.`);
|
|
76
|
+
}
|
|
77
|
+
return value.replace(/^\/+|\/+$/g, '');
|
|
78
|
+
}
|
|
79
|
+
function httpCodeOf(where, value) {
|
|
80
|
+
if (value === undefined || (typeof value === 'number' && Number.isInteger(value))) {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
throw new DeclarationError(`${where}: @HttpCode of Nest holds no status.`);
|
|
84
|
+
}
|
|
85
|
+
function parametersOf(where, controller, method) {
|
|
86
|
+
const written = metadata(ROUTE_ARGS_METADATA, controller, method) ?? {};
|
|
87
|
+
const types = metadata(PARAMTYPES_METADATA, prototypeOf(controller), method);
|
|
88
|
+
if (!isRecord(written)) {
|
|
89
|
+
throw new DeclarationError(`${where}: the parameters Nest declares are not read as the kit expects them.`);
|
|
90
|
+
}
|
|
91
|
+
return Object.entries(written).map(([slot, argument]) => parameterOf({ where, types }, slot, argument));
|
|
92
|
+
}
|
|
93
|
+
/** One entry `<type>:<index>` of what Nest's parameter decorators write: `{ index, data, pipes }`. */
|
|
94
|
+
function parameterOf({ where, types }, slot, argument) {
|
|
95
|
+
const type = Number(slot.split(':')[0]);
|
|
96
|
+
const { index, data } = writtenArgument(where, slot, argument);
|
|
97
|
+
const source = SOURCES.get(type);
|
|
98
|
+
if (source === undefined) {
|
|
99
|
+
throw new DeclarationError(`${where}: parameter ${String(index)} is @${RouteParamtypes[type] ?? slot} of Nest; a route of the kit reads @Body, @Query, @Param and @Headers, @CurrentActor and @RouteContext.`);
|
|
100
|
+
}
|
|
101
|
+
return { index, source, ...(data === undefined ? {} : { key: data }), type: typeAt(types, index) };
|
|
102
|
+
}
|
|
103
|
+
/** What one parameter decorator of Nest wrote, checked: its index, the name it reads, and no pipe. */
|
|
104
|
+
function writtenArgument(where, slot, argument) {
|
|
105
|
+
if (!isRecord(argument) || typeof argument['index'] !== 'number') {
|
|
106
|
+
throw new DeclarationError(`${where}: the parameter ${slot} Nest declares is not read as the kit expects it.`);
|
|
107
|
+
}
|
|
108
|
+
const { index, data, pipes } = argument;
|
|
109
|
+
if (Array.isArray(pipes) && pipes.length > 0) {
|
|
110
|
+
throw new DeclarationError(`${where}: parameter ${String(index)} has pipes of Nest, which the kit does not run.`);
|
|
111
|
+
}
|
|
112
|
+
if (data !== undefined && typeof data !== 'string') {
|
|
113
|
+
throw new DeclarationError(`${where}: parameter ${String(index)} is read by something else than a name.`);
|
|
114
|
+
}
|
|
115
|
+
return data === undefined ? { index } : { index, data };
|
|
116
|
+
}
|
|
117
|
+
/** The class TypeScript recorded for a parameter, when it was compiled with `emitDecoratorMetadata`. */
|
|
118
|
+
function typeAt(types, index) {
|
|
119
|
+
return Array.isArray(types) ? types[index] : undefined;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=nest-route-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-route-metadata.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-route-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,q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C,CAAC,CAAC;IAC5G,CAAC;IAED,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC1D,CAAC;AAED,wGAAwG;AACxG,SAAS,MAAM,CAAC,KAAc,EAAE,KAAa;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NestControllerClass } from './nest-controller-class.js';
|
|
2
|
+
/** The methods of a controller that carry a route decorator of Nest (`@Get`, `@Post`...), in the order of the class. */
|
|
3
|
+
export declare function nestRouteMethods(controller: NestControllerClass): string[];
|
|
4
|
+
//# sourceMappingURL=nest-route-methods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-route-methods.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-route-methods.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,wHAAwH;AACxH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,mBAAmB,GAAG,MAAM,EAAE,CAQ1E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { METHOD_METADATA } from '@nestjs/common/constants';
|
|
2
|
+
import { prototypeOf } from './prototype-of.js';
|
|
3
|
+
import { reflectedMetadata } from './reflected-metadata.js';
|
|
4
|
+
/** The methods of a controller that carry a route decorator of Nest (`@Get`, `@Post`...), in the order of the class. */
|
|
5
|
+
export function nestRouteMethods(controller) {
|
|
6
|
+
const prototype = prototypeOf(controller);
|
|
7
|
+
return Object.getOwnPropertyNames(prototype).filter((name) => {
|
|
8
|
+
const member = name === 'constructor' ? undefined : Reflect.get(prototype, name);
|
|
9
|
+
return typeof member === 'function' && reflectedMetadata(METHOD_METADATA, member) !== undefined;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=nest-route-methods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-route-methods.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-route-methods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,wHAAwH;AACxH,MAAM,UAAU,gBAAgB,CAAC,UAA+B;IAC9D,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAE1C,OAAO,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAC3D,MAAM,MAAM,GAAY,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE1F,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,iBAAiB,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,SAAS,CAAC;IAClG,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KitRouteSpec } from './kit-route-spec.js';
|
|
2
|
+
import type { KitRoutesOptions } from './kit-routes-options.js';
|
|
3
|
+
import type { NestSignature } from './nest-signature.js';
|
|
4
|
+
/** What a parameter decorator of the kit asks for: the caller, the context of the request, or the file it streams. */
|
|
5
|
+
export type Injected = 'actor' | 'context' | 'upload';
|
|
6
|
+
export interface NestRoutesRegistry {
|
|
7
|
+
/** By prototype of a controller, the routes of its methods. */
|
|
8
|
+
readonly routes: WeakMap<object, Map<string, KitRouteSpec>>;
|
|
9
|
+
/** By controller class, what its routes share. */
|
|
10
|
+
readonly controllers: WeakMap<object, KitRoutesOptions>;
|
|
11
|
+
/** By prototype, method and index, what the kit hands a parameter. */
|
|
12
|
+
readonly injected: WeakMap<object, Map<string, Map<number, Injected>>>;
|
|
13
|
+
/** By controller class and method, what its signature says, read by `ddd-ts-kit`. */
|
|
14
|
+
readonly signatures: WeakMap<object, ReadonlyMap<string, NestSignature>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function nestRoutesRegistry(): NestRoutesRegistry;
|
|
17
|
+
//# sourceMappingURL=nest-routes-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-routes-registry.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-routes-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,sHAAsH;AACtH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAC5D,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACxD,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACvE,qFAAqF;IACrF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;CAC1E;AAKD,wBAAgB,kBAAkB,IAAI,kBAAkB,CAiBvD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* One registry per process, whatever the number of copies of this package it loaded, as the registry of the presentation. */
|
|
2
|
+
const REGISTRY = Symbol.for('@ddd-ts-kit/http/nest-controllers/v3');
|
|
3
|
+
export function nestRoutesRegistry() {
|
|
4
|
+
const existing = Reflect.get(globalThis, REGISTRY);
|
|
5
|
+
if (isRegistry(existing)) {
|
|
6
|
+
return existing;
|
|
7
|
+
}
|
|
8
|
+
const created = {
|
|
9
|
+
routes: new WeakMap(),
|
|
10
|
+
controllers: new WeakMap(),
|
|
11
|
+
injected: new WeakMap(),
|
|
12
|
+
signatures: new WeakMap(),
|
|
13
|
+
};
|
|
14
|
+
Reflect.set(globalThis, REGISTRY, created);
|
|
15
|
+
return created;
|
|
16
|
+
}
|
|
17
|
+
function isRegistry(value) {
|
|
18
|
+
if (typeof value !== 'object' || value === null) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return ['routes', 'controllers', 'injected', 'signatures'].every((key) => Reflect.get(value, key) instanceof WeakMap);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=nest-routes-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-routes-registry.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-routes-registry.ts"],"names":[],"mappings":"AAkBA,6HAA6H;AAC7H,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;AAEpE,MAAM,UAAU,kBAAkB;IAChC,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE5D,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAuB;QAClC,MAAM,EAAE,IAAI,OAAO,EAAE;QACrB,WAAW,EAAE,IAAI,OAAO,EAAE;QAC1B,QAAQ,EAAE,IAAI,OAAO,EAAE;QACvB,UAAU,EAAE,IAAI,OAAO,EAAE;KAC1B,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,YAAY,OAAO,CAAC,CAAC;AACxH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { DtoType } from './dto-type.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the signature of a route method says, as `ddd-ts-kit` reads it from its source: the DTO
|
|
5
|
+
* class of each part of the request a parameter takes whole (`@Body() body: IssueInvoiceBody`), and
|
|
6
|
+
* what it answers (`Promise<IssuedInvoice>`), `null` when it answers nothing.
|
|
7
|
+
*/
|
|
8
|
+
export interface NestSignature {
|
|
9
|
+
readonly params?: DtoType;
|
|
10
|
+
readonly query?: DtoType;
|
|
11
|
+
readonly headers?: DtoType;
|
|
12
|
+
readonly body?: DtoType;
|
|
13
|
+
readonly answer?: Schema<unknown> | DtoType | null;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=nest-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-signature.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/nest-signature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;CACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest-signature.js","sourceRoot":"","sources":["../../../src/nest/controllers/nest-signature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NestControllerClass } from './nest-controller-class.js';
|
|
2
|
+
/** Where the decorators of the methods of a controller wrote: its prototype. */
|
|
3
|
+
export declare function prototypeOf(controller: NestControllerClass): object;
|
|
4
|
+
//# sourceMappingURL=prototype-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype-of.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/prototype-of.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,UAAU,EAAE,mBAAmB,GAAG,MAAM,CAQnE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
/** Where the decorators of the methods of a controller wrote: its prototype. */
|
|
3
|
+
export function prototypeOf(controller) {
|
|
4
|
+
const prototype = controller.prototype;
|
|
5
|
+
if (typeof prototype !== 'object' || prototype === null) {
|
|
6
|
+
throw new DeclarationError(`${controller.name} has no prototype: it is no class.`);
|
|
7
|
+
}
|
|
8
|
+
return prototype;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=prototype-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype-of.js","sourceRoot":"","sources":["../../../src/nest/controllers/prototype-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,UAA+B;IACzD,MAAM,SAAS,GAAY,UAAU,CAAC,SAAS,CAAC;IAEhD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACxD,MAAM,IAAI,gBAAgB,CAAC,GAAG,UAAU,CAAC,IAAI,oCAAoC,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DynamicModule, ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import type { NestControllers } from './nest-controllers.js';
|
|
3
|
+
/**
|
|
4
|
+
* The Nest module that builds the controllers `nestControllers` read, with what they inject, and
|
|
5
|
+
* hands their routes the instances at the start. It mounts nothing: the routes are mounted with the
|
|
6
|
+
* other routes of the application. A controller also among the `controllers` of a Nest module
|
|
7
|
+
* stops the start.
|
|
8
|
+
*/
|
|
9
|
+
export declare function provideControllers(served: NestControllers, options?: {
|
|
10
|
+
readonly imports?: ModuleMetadata['imports'];
|
|
11
|
+
}): DynamicModule;
|
|
12
|
+
//# sourceMappingURL=provide-controllers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide-controllers.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/provide-controllers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;CAAO,GAC7D,aAAa,CAsBf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModuleRef, ModulesContainer } from '@nestjs/core';
|
|
2
|
+
import { assertNotRoutedByNest } from './assert-not-routed-by-nest.js';
|
|
3
|
+
import { ControllersBinder } from './controllers-binder.js';
|
|
4
|
+
/**
|
|
5
|
+
* The Nest module that builds the controllers `nestControllers` read, with what they inject, and
|
|
6
|
+
* hands their routes the instances at the start. It mounts nothing: the routes are mounted with the
|
|
7
|
+
* other routes of the application. A controller also among the `controllers` of a Nest module
|
|
8
|
+
* stops the start.
|
|
9
|
+
*/
|
|
10
|
+
export function provideControllers(served, options = {}) {
|
|
11
|
+
// One class per call: Nest identifies a module by its class.
|
|
12
|
+
class ControllersModule {
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
module: ControllersModule,
|
|
16
|
+
imports: options.imports ?? [],
|
|
17
|
+
providers: [
|
|
18
|
+
...served.controllers,
|
|
19
|
+
...served.providers,
|
|
20
|
+
{
|
|
21
|
+
provide: ControllersBinder,
|
|
22
|
+
inject: [ModuleRef, ModulesContainer],
|
|
23
|
+
useFactory: (references, modules) => ({
|
|
24
|
+
onModuleInit() {
|
|
25
|
+
assertNotRoutedByNest(modules);
|
|
26
|
+
served.bind(references);
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=provide-controllers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provide-controllers.js","sourceRoot":"","sources":["../../../src/nest/controllers/provide-controllers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAuB,EACvB,OAAO,GAAqD,EAAE;IAE9D,6DAA6D;IAC7D,MAAM,iBAAiB;KAAG;IAE1B,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,SAAS,EAAE;YACT,GAAG,MAAM,CAAC,WAAW;YACrB,GAAG,MAAM,CAAC,SAAS;YACnB;gBACE,OAAO,EAAE,iBAAiB;gBAC1B,MAAM,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC;gBACrC,UAAU,EAAE,CAAC,UAAqB,EAAE,OAAyB,EAAqB,EAAE,CAAC,CAAC;oBACpF,YAAY;wBACV,qBAAqB,CAAC,OAAO,CAAC,CAAC;wBAC/B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC1B,CAAC;iBACF,CAAC;aACH;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflected-metadata.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/reflected-metadata.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAYzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
/** What a decorator recorded through reflect-metadata, which every Nest application loads first. */
|
|
3
|
+
export function reflectedMetadata(key, target, property) {
|
|
4
|
+
const read = Reflect.get(Reflect, 'getMetadata');
|
|
5
|
+
if (typeof read !== 'function') {
|
|
6
|
+
throw new DeclarationError('Nest controllers are read through reflect-metadata: import it first, as a Nest application does.');
|
|
7
|
+
}
|
|
8
|
+
const value = Reflect.apply(read, Reflect, property === undefined ? [key, target] : [key, target, property]);
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=reflected-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflected-metadata.js","sourceRoot":"","sources":["../../../src/nest/controllers/reflected-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,oGAAoG;AACpG,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,MAAc,EAAE,QAAiB;IAC9E,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE1D,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,gBAAgB,CACxB,kGAAkG,CACnG,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAY,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEtH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { NestControllerRoutesOptions } from './nest-controller-routes-options.js';
|
|
3
|
+
import type { NestMethod } from './nest-method.js';
|
|
4
|
+
import type { NestParameter } from './nest-parameter.js';
|
|
5
|
+
type Source = NestParameter['source'];
|
|
6
|
+
type RequestSchemas = Partial<Record<Source, Schema<unknown>>>;
|
|
7
|
+
/**
|
|
8
|
+
* The schemas of the parts of the request: those @KitRoute gives, else the class of a parameter
|
|
9
|
+
* that takes a part whole (as `ddd-ts-kit` read it from the source, else as `emitDecoratorMetadata`
|
|
10
|
+
* recorded it), else the names its parameters read one by one, each a text.
|
|
11
|
+
*/
|
|
12
|
+
export declare function requestSchemasOf(method: NestMethod, options: NestControllerRoutesOptions): RequestSchemas;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=request-schemas-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-schemas-of.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/request-schemas-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,KAAK,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAM/D;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,2BAA2B,GAAG,cAAc,CAUzG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
|
+
import { keyedSchema } from './keyed-schema.js';
|
|
3
|
+
import { schemaOf } from './schema-of.js';
|
|
4
|
+
const SOURCES = ['params', 'query', 'headers', 'body'];
|
|
5
|
+
/** What `emitDecoratorMetadata` records for a parameter that has no class of its own. */
|
|
6
|
+
const NO_CLASS = [undefined, Object, String, Number, Boolean, Array];
|
|
7
|
+
/**
|
|
8
|
+
* The schemas of the parts of the request: those @KitRoute gives, else the class of a parameter
|
|
9
|
+
* that takes a part whole (as `ddd-ts-kit` read it from the source, else as `emitDecoratorMetadata`
|
|
10
|
+
* recorded it), else the names its parameters read one by one, each a text.
|
|
11
|
+
*/
|
|
12
|
+
export function requestSchemasOf(method, options) {
|
|
13
|
+
const given = method.spec.request ?? {};
|
|
14
|
+
return Object.fromEntries(SOURCES.flatMap((source) => {
|
|
15
|
+
const schema = given[source] ?? derived(method, source, options);
|
|
16
|
+
return schema === undefined ? [] : [[source, schema]];
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function derived({ where, read, signature }, source, options) {
|
|
20
|
+
const taking = read.parameters.filter((parameter) => parameter.source === source);
|
|
21
|
+
const whole = taking.find(({ key }) => key === undefined);
|
|
22
|
+
if (whole !== undefined) {
|
|
23
|
+
return schemaOf(where, signature[source] ?? dtoOf(where, whole), options);
|
|
24
|
+
}
|
|
25
|
+
if (taking.length === 0) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
if (source === 'body') {
|
|
29
|
+
throw new DeclarationError(`${where}: the body is read one field at a time; type it whole by a DTO class, or give request.body in @KitRoute.`);
|
|
30
|
+
}
|
|
31
|
+
return keyedSchema(keysOf(where, taking), source === 'params');
|
|
32
|
+
}
|
|
33
|
+
function dtoOf(where, { index, source, type }) {
|
|
34
|
+
if (NO_CLASS.includes(type) || !isDto(type)) {
|
|
35
|
+
throw new DeclarationError(`${where}: parameter ${String(index)} takes the whole ${source} and has no class: type it by a DTO class, which ddd-ts-kit reads into the generated list of the context, or give request.${source} in @KitRoute.`);
|
|
36
|
+
}
|
|
37
|
+
return type;
|
|
38
|
+
}
|
|
39
|
+
function keysOf(where, taking) {
|
|
40
|
+
return taking.flatMap(({ index, source, key, type }) => {
|
|
41
|
+
if (type !== undefined && type !== String) {
|
|
42
|
+
throw new DeclarationError(`${where}: parameter ${String(index)} is one ${source} part, a text; a number or a date is read by a DTO class of the whole ${source}.`);
|
|
43
|
+
}
|
|
44
|
+
return key === undefined ? [] : [source === 'headers' ? key.toLowerCase() : key];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function isDto(type) {
|
|
48
|
+
return typeof type === 'function' && 'prototype' in type;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=request-schemas-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-schemas-of.js","sourceRoot":"","sources":["../../../src/nest/controllers/request-schemas-of.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,MAAM,OAAO,GAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAC1E,yFAAyF;AACzF,MAAM,QAAQ,GAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEzF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAkB,EAAE,OAAoC;IACvF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IAExC,OAAO,MAAM,CAAC,WAAW,CACvB,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEjE,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CACd,EAAE,KA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CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;QACrD,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1C,MAAM,IAAI,gBAAgB,CACxB,GAAG,KAAK,eAAe,MAAM,CAAC,KAAK,CAAC,WAAW,MAAM,yEAAyE,MAAM,GAAG,CACxI,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,IAAa;IAC1B,OAAO,OAAO,IAAI,KAAK,UAAU,IAAI,WAAW,IAAI,IAAI,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-context.d.ts","sourceRoot":"","sources":["../../../src/nest/controllers/route-context.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,wBAAgB,YAAY,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAE3G"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { injectedParameter } from './injected-parameter.js';
|
|
2
|
+
/** The context of the request: its execution context, the version `If-Match` expects, its raw headers. */
|
|
3
|
+
export function RouteContext() {
|
|
4
|
+
return injectedParameter('context');
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=route-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-context.js","sourceRoot":"","sources":["../../../src/nest/controllers/route-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,0GAA0G;AAC1G,MAAM,UAAU,YAAY;IAC1B,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Schema } from '@ddd-ts-kit/validation';
|
|
2
|
+
import type { DtoType } from './dto-type.js';
|
|
3
|
+
import type { NestControllerRoutesOptions } from './nest-controller-routes-options.js';
|
|
4
|
+
/** A schema as it is given, or the one `schemaOfClass` reads from a DTO class. */
|
|
5
|
+
export declare function schemaOf(where: string, described: Schema<unknown> | DtoType, { schemaOfClass }: NestControllerRoutesOptions): Schema<unknown>;
|
|
6
|
+
//# sourceMappingURL=schema-of.d.ts.map
|