@nestia/core 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adaptors/McpAdaptor.d.ts +24 -3
- package/lib/adaptors/McpAdaptor.js +72 -34
- package/lib/adaptors/McpAdaptor.js.map +1 -1
- package/lib/adaptors/WebSocketAdaptor.d.ts +37 -0
- package/lib/adaptors/WebSocketAdaptor.js +60 -16
- package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
- package/lib/adaptors/internal/external_context.js +18 -5
- package/lib/adaptors/internal/external_context.js.map +1 -1
- package/lib/decorators/DynamicModule.d.ts +12 -0
- package/lib/decorators/DynamicModule.js +12 -0
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.d.ts +14 -6
- package/lib/decorators/EncryptedBody.js +37 -14
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedController.d.ts +6 -1
- package/lib/decorators/EncryptedController.js +6 -1
- package/lib/decorators/EncryptedController.js.map +1 -1
- package/lib/decorators/EncryptedModule.d.ts +18 -3
- package/lib/decorators/EncryptedModule.js +18 -3
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +20 -11
- package/lib/decorators/EncryptedRoute.js +20 -11
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/HumanRoute.d.ts +5 -0
- package/lib/decorators/HumanRoute.js +5 -0
- package/lib/decorators/HumanRoute.js.map +1 -1
- package/lib/decorators/McpRoute.d.ts +31 -19
- package/lib/decorators/McpRoute.js +12 -1
- package/lib/decorators/McpRoute.js.map +1 -1
- package/lib/decorators/PlainBody.d.ts +7 -1
- package/lib/decorators/PlainBody.js +16 -8
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/SwaggerCustomizer.d.ts +15 -0
- package/lib/decorators/SwaggerCustomizer.js +5 -0
- package/lib/decorators/SwaggerCustomizer.js.map +1 -1
- package/lib/decorators/SwaggerExample.d.ts +51 -22
- package/lib/decorators/SwaggerExample.js +35 -22
- package/lib/decorators/SwaggerExample.js.map +1 -1
- package/lib/decorators/TypedBody.d.ts +9 -2
- package/lib/decorators/TypedBody.js +19 -9
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedException.d.ts +10 -0
- package/lib/decorators/TypedFormData.d.ts +59 -1
- package/lib/decorators/TypedFormData.js +5 -0
- package/lib/decorators/TypedFormData.js.map +1 -1
- package/lib/decorators/TypedHeaders.d.ts +5 -0
- package/lib/decorators/TypedHeaders.js +5 -0
- package/lib/decorators/TypedHeaders.js.map +1 -1
- package/lib/decorators/TypedParam.d.ts +9 -0
- package/lib/decorators/TypedParam.js +9 -0
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedQuery.d.ts +16 -0
- package/lib/decorators/TypedQuery.js +16 -0
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.d.ts +25 -10
- package/lib/decorators/TypedRoute.js +19 -10
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/WebSocketRoute.d.ts +18 -1
- package/lib/decorators/WebSocketRoute.js +18 -1
- package/lib/decorators/WebSocketRoute.js.map +1 -1
- package/lib/decorators/doNotThrowTransformError.d.ts +14 -0
- package/lib/decorators/doNotThrowTransformError.js +14 -0
- package/lib/decorators/doNotThrowTransformError.js.map +1 -1
- package/lib/decorators/internal/IRequestBodyValidation.d.ts +66 -0
- package/lib/decorators/internal/IRequestBodyValidation.js +3 -0
- package/lib/decorators/internal/IRequestBodyValidation.js.map +1 -0
- package/lib/decorators/internal/IWebSocketRouteReflect.d.ts +93 -1
- package/lib/decorators/internal/get_path_and_querify.js +3 -7
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +3 -7
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/load_controller.d.ts +14 -0
- package/lib/decorators/internal/load_controller.js +14 -0
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/split_route_arguments.d.ts +1 -0
- package/lib/decorators/internal/split_route_arguments.js +22 -0
- package/lib/decorators/internal/split_route_arguments.js.map +1 -0
- package/lib/decorators/internal/validate_request_body.js +68 -25
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/options/IRequestBodyValidator.d.ts +71 -0
- package/lib/options/IRequestFormDataProps.d.ts +80 -0
- package/lib/options/IRequestHeadersValidator.d.ts +67 -0
- package/lib/options/IRequestQueryValidator.d.ts +68 -0
- package/lib/options/IResponseBodyQuerifier.d.ts +120 -0
- package/lib/options/IResponseBodyStringifier.d.ts +107 -0
- package/lib/typings/Creator.d.ts +10 -0
- package/lib/utils/ArrayUtil.d.ts +21 -0
- package/lib/utils/ArrayUtil.js +22 -1
- package/lib/utils/ArrayUtil.js.map +1 -1
- package/lib/utils/ExceptionManager.d.ts +40 -0
- package/lib/utils/ExceptionManager.js +34 -0
- package/lib/utils/ExceptionManager.js.map +1 -1
- package/lib/utils/SourceFinder.d.ts +22 -0
- package/lib/utils/SourceFinder.js +34 -7
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +36 -1
- package/lib/utils/VersioningStrategy.js +30 -9
- package/lib/utils/VersioningStrategy.js.map +1 -1
- package/native/go.mod +1 -1
- package/native/go.sum +2 -2
- package/native/plugin/plan.go +68 -2
- package/native/transform/ast.go +19 -1
- package/native/transform/build.go +51 -57
- package/native/transform/buildoutput/output.go +147 -0
- package/native/transform/contributor.go +9 -0
- package/native/transform/core_querify.go +37 -3
- package/native/transform/core_transform.go +105 -98
- package/native/transform/core_websocket.go +21 -5
- package/native/transform/node_transform.go +11 -8
- package/native/transform/package.go +55 -0
- package/native/transform/printer.go +1 -3
- package/native/transform/run.go +18 -0
- package/native/transform/schemaprojection/project.go +213 -0
- package/native/transform/transform.go +21 -0
- package/package.json +5 -4
- package/src/adaptors/McpAdaptor.ts +86 -26
- package/src/adaptors/WebSocketAdaptor.ts +66 -14
- package/src/adaptors/internal/external_context.ts +37 -6
- package/src/decorators/DynamicModule.ts +12 -0
- package/src/decorators/EncryptedBody.ts +37 -13
- package/src/decorators/EncryptedController.ts +6 -1
- package/src/decorators/EncryptedModule.ts +18 -3
- package/src/decorators/EncryptedRoute.ts +20 -11
- package/src/decorators/HumanRoute.ts +5 -0
- package/src/decorators/McpRoute.ts +31 -19
- package/src/decorators/PlainBody.ts +20 -10
- package/src/decorators/SwaggerCustomizer.ts +15 -0
- package/src/decorators/SwaggerExample.ts +51 -22
- package/src/decorators/TypedBody.ts +17 -8
- package/src/decorators/TypedException.ts +10 -0
- package/src/decorators/TypedFormData.ts +59 -1
- package/src/decorators/TypedHeaders.ts +5 -0
- package/src/decorators/TypedParam.ts +9 -0
- package/src/decorators/TypedQuery.ts +16 -0
- package/src/decorators/TypedRoute.ts +25 -10
- package/src/decorators/WebSocketRoute.ts +18 -1
- package/src/decorators/doNotThrowTransformError.ts +14 -0
- package/src/decorators/internal/IMcpRouteReflect.ts +7 -1
- package/src/decorators/internal/IRequestBodyValidation.ts +65 -0
- package/src/decorators/internal/IWebSocketRouteReflect.ts +95 -1
- package/src/decorators/internal/get_path_and_querify.ts +3 -9
- package/src/decorators/internal/get_path_and_stringify.ts +3 -9
- package/src/decorators/internal/load_controller.ts +14 -0
- package/src/decorators/internal/split_route_arguments.ts +20 -0
- package/src/decorators/internal/validate_request_body.ts +87 -34
- package/src/options/IRequestBodyValidator.ts +71 -0
- package/src/options/IRequestFormDataProps.ts +80 -0
- package/src/options/IRequestHeadersValidator.ts +67 -0
- package/src/options/IRequestQueryValidator.ts +68 -0
- package/src/options/IResponseBodyQuerifier.ts +120 -0
- package/src/options/IResponseBodyStringifier.ts +107 -0
- package/src/typings/Creator.ts +10 -0
- package/src/utils/ArrayUtil.ts +22 -3
- package/src/utils/ExceptionManager.ts +40 -0
- package/src/utils/SourceFinder.ts +38 -7
- package/src/utils/VersioningStrategy.ts +43 -13
|
@@ -1,20 +1,55 @@
|
|
|
1
1
|
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the URI versions of a controller method the way NestJS does.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/common.md#principled-implementation The namespace turns the version metadata of a controller and a method, with the default version of the application, into the version path segments, following NestJS's precedence.
|
|
7
|
+
* @evidence contracts/common.md#clear-and-simple-design Two functions and one configuration type.
|
|
8
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The precedence follows NestJS; no version string is special-cased.
|
|
9
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
10
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Version precedence and prefix concatenation produce HTTP URI segments and never resolve native filesystem paths.
|
|
11
|
+
*/
|
|
3
12
|
export namespace VersioningStrategy {
|
|
13
|
+
/**
|
|
14
|
+
* The URI versioning options the adapter reads: the prefix and the default
|
|
15
|
+
* version.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation The two fields are what NestJS's URI versioning uses to build a version segment.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-field record.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the two fields.
|
|
21
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Version precedence and prefix concatenation produce HTTP URI segments and never resolve native filesystem paths.
|
|
22
|
+
*/
|
|
4
23
|
export interface IConfig {
|
|
5
24
|
prefix: string;
|
|
6
25
|
defaultVersion?: VersionValue;
|
|
7
26
|
}
|
|
8
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Casts version metadata to a list: a missing value stays absent and a single
|
|
30
|
+
* value is a one-element list.
|
|
31
|
+
*
|
|
32
|
+
* @evidence contracts/common.md#principled-implementation One version becomes a list while absence and an explicit empty list remain distinct, because Nest treats an empty version list as no registered paths rather than inherited versions.
|
|
33
|
+
* @evidence contracts/common.md#clear-and-simple-design One conditional expression.
|
|
34
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It adds nothing to the values.
|
|
35
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the three cases.
|
|
36
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Version precedence and prefix concatenation produce HTTP URI segments and never resolve native filesystem paths.
|
|
37
|
+
*/
|
|
9
38
|
export const cast = (
|
|
10
39
|
value: VersionValue | undefined,
|
|
11
|
-
): Array<string | typeof VERSION_NEUTRAL> =>
|
|
12
|
-
value === undefined ?
|
|
40
|
+
): Array<string | typeof VERSION_NEUTRAL> | undefined =>
|
|
41
|
+
value === undefined ? undefined : Array.isArray(value) ? value : [value];
|
|
13
42
|
|
|
14
43
|
/**
|
|
15
44
|
* Version path segments of a route, resolved as NestJS resolves them: the
|
|
16
45
|
* method's versions, else the controller's, else the default version, and no
|
|
17
46
|
* version at all is the unversioned path (#1735).
|
|
47
|
+
*
|
|
48
|
+
* @evidence contracts/common.md#principled-implementation The first present method, controller or default version list wins, including an empty list that registers no paths. Duplicates are dropped, a neutral version maps to no segment, and absent metadata also maps to no segment; with versioning off the only path has no version.
|
|
49
|
+
* @evidence contracts/common.md#clear-and-simple-design One function returning the segments, curried on the configuration so a caller can compute the segments per method.
|
|
50
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The precedence is NestJS's, and no version is special-cased.
|
|
51
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the precedence and the neutral version rule.
|
|
52
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Version precedence and prefix concatenation produce HTTP URI segments and never resolve native filesystem paths.
|
|
18
53
|
*/
|
|
19
54
|
export const merge =
|
|
20
55
|
(config: IConfig | undefined) =>
|
|
@@ -23,19 +58,14 @@ export namespace VersioningStrategy {
|
|
|
23
58
|
method: Array<string | typeof VERSION_NEUTRAL> | undefined;
|
|
24
59
|
}): string[] => {
|
|
25
60
|
if (config === undefined) return [""];
|
|
26
|
-
const chosen: Array<string | typeof VERSION_NEUTRAL> =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: props.controller?.length
|
|
30
|
-
? props.controller
|
|
31
|
-
: cast(config.defaultVersion);
|
|
61
|
+
const chosen: Array<string | typeof VERSION_NEUTRAL> | undefined =
|
|
62
|
+
props.method ?? props.controller ?? cast(config.defaultVersion);
|
|
63
|
+
if (chosen === undefined) return [""];
|
|
32
64
|
const unique: Array<string | typeof VERSION_NEUTRAL> = [
|
|
33
65
|
...new Set(chosen),
|
|
34
66
|
];
|
|
35
|
-
return unique.
|
|
36
|
-
?
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
: [""];
|
|
67
|
+
return unique.map((x) =>
|
|
68
|
+
typeof x === "symbol" ? "" : `${config.prefix}${x}`,
|
|
69
|
+
);
|
|
40
70
|
};
|
|
41
71
|
}
|