@nestia/core 14.0.0 → 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/MIGRATION.md +20 -0
- package/README.md +1 -1
- package/lib/adaptors/McpAdaptor.d.ts +29 -3
- package/lib/adaptors/McpAdaptor.js +150 -24
- package/lib/adaptors/McpAdaptor.js.map +1 -1
- package/lib/adaptors/WebSocketAdaptor.d.ts +37 -0
- package/lib/adaptors/WebSocketAdaptor.js +184 -48
- package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
- package/lib/adaptors/internal/RoutePathMatcher.d.ts +1 -0
- package/lib/adaptors/internal/RoutePathMatcher.js +88 -0
- package/lib/adaptors/internal/RoutePathMatcher.js.map +1 -0
- package/lib/adaptors/internal/external_context.d.ts +1 -0
- package/lib/adaptors/internal/external_context.js +56 -0
- package/lib/adaptors/internal/external_context.js.map +1 -0
- 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 +39 -16
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedController.d.ts +6 -1
- package/lib/decorators/EncryptedController.js +7 -2
- package/lib/decorators/EncryptedController.js.map +1 -1
- package/lib/decorators/EncryptedModule.d.ts +25 -6
- package/lib/decorators/EncryptedModule.js +87 -18
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +20 -11
- package/lib/decorators/EncryptedRoute.js +27 -13
- 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 +10 -3
- package/lib/decorators/TypedBody.js +20 -10
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedException.d.ts +10 -0
- package/lib/decorators/TypedFormData.d.ts +81 -9
- package/lib/decorators/TypedFormData.js +121 -31
- 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 +12 -3
- package/lib/decorators/TypedParam.js +12 -3
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedQuery.d.ts +17 -1
- package/lib/decorators/TypedQuery.js +25 -4
- 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/EncryptedConstant.js +13 -2
- package/lib/decorators/internal/EncryptedConstant.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_encryption_password.d.ts +1 -0
- package/lib/decorators/internal/get_encryption_password.js +14 -0
- package/lib/decorators/internal/get_encryption_password.js.map +1 -0
- package/lib/decorators/internal/get_path_and_querify.js +23 -9
- 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/get_text_body.js +9 -3
- package/lib/decorators/internal/get_text_body.js.map +1 -1
- package/lib/decorators/internal/group_entries.d.ts +1 -0
- package/lib/decorators/internal/group_entries.js +19 -0
- package/lib/decorators/internal/group_entries.js.map +1 -0
- 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/decorators/internal/validate_request_form_data.js +3 -1
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
- package/lib/decorators/internal/validate_request_headers.js +2 -1
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.js +3 -1
- package/lib/decorators/internal/validate_request_query.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 +125 -1
- 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 +43 -4
- package/lib/utils/ExceptionManager.js +44 -6
- package/lib/utils/ExceptionManager.js.map +1 -1
- package/lib/utils/SourceFinder.d.ts +22 -0
- package/lib/utils/SourceFinder.js +60 -10
- package/lib/utils/SourceFinder.js.map +1 -1
- package/lib/utils/VersioningStrategy.d.ts +45 -2
- package/lib/utils/VersioningStrategy.js +40 -7
- 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 +23 -3
- 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 +63 -9
- package/native/transform/core_transform.go +180 -98
- package/native/transform/core_websocket.go +111 -14
- package/native/transform/node_transform.go +17 -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 +29 -18
- package/native/transform/typia_fast.go +6 -0
- package/native/transform.cjs +49 -0
- package/package.json +13 -15
- package/src/adaptors/McpAdaptor.ts +215 -33
- package/src/adaptors/WebSocketAdaptor.ts +202 -52
- package/src/adaptors/internal/RoutePathMatcher.ts +91 -0
- package/src/adaptors/internal/external_context.ts +81 -0
- package/src/decorators/DynamicModule.ts +12 -0
- package/src/decorators/EncryptedBody.ts +39 -15
- package/src/decorators/EncryptedController.ts +12 -3
- package/src/decorators/EncryptedModule.ts +89 -18
- package/src/decorators/EncryptedRoute.ts +27 -16
- 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 +18 -9
- package/src/decorators/TypedException.ts +10 -0
- package/src/decorators/TypedFormData.ts +207 -45
- package/src/decorators/TypedHeaders.ts +5 -0
- package/src/decorators/TypedParam.ts +12 -3
- package/src/decorators/TypedQuery.ts +35 -7
- 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/EncryptedConstant.ts +14 -1
- 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_encryption_password.ts +19 -0
- package/src/decorators/internal/get_path_and_querify.ts +31 -10
- package/src/decorators/internal/get_path_and_stringify.ts +3 -9
- package/src/decorators/internal/get_text_body.ts +8 -4
- package/src/decorators/internal/group_entries.ts +17 -0
- 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/decorators/internal/validate_request_form_data.ts +3 -1
- package/src/decorators/internal/validate_request_headers.ts +2 -2
- package/src/decorators/internal/validate_request_query.ts +3 -2
- 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 +126 -1
- 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 +50 -6
- package/src/utils/SourceFinder.ts +62 -10
- package/src/utils/VersioningStrategy.ts +55 -11
- package/lib/transform.d.ts +0 -10
- package/lib/transform.js +0 -25
- package/lib/transform.js.map +0 -1
- package/src/transform.ts +0 -26
|
@@ -6,25 +6,132 @@ export type IResponseBodyStringifier<T> =
|
|
|
6
6
|
| IResponseBodyStringifier.IAssert<T>
|
|
7
7
|
| IResponseBodyStringifier.IValidate<T>
|
|
8
8
|
| IResponseBodyStringifier.IValidateLog<T>;
|
|
9
|
+
/**
|
|
10
|
+
* The serializer that the transform passes to `TypedRoute` and `EncryptedRoute`
|
|
11
|
+
* for the JSON text of the response body.
|
|
12
|
+
*
|
|
13
|
+
* The literal `type` field selects which typia function generated it:
|
|
14
|
+
* `stringify` (no validation), `is`, `assert`, `validate`, or `validate.log`.
|
|
15
|
+
* `get_path_and_stringify` turns a failing validation into a 500 response,
|
|
16
|
+
* except `validate.log`, which logs the failure and answers with
|
|
17
|
+
* `JSON.stringify` of the data.
|
|
18
|
+
*
|
|
19
|
+
* @evidence contracts/common.md#principled-implementation The union is discriminated by the literal `type`, so the runtime selects the serializer with one comparison; the five variants are the typia stringify families, of which four validate the data and one does not.
|
|
20
|
+
* @evidence contracts/common.md#clear-and-simple-design Five variants, one per typia function family, with no shared base because each function has a different shape.
|
|
21
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior; the runtime rejects an unknown `type` with an error instead of accepting it.
|
|
22
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the decorators that receive the serializer and the response each variant produces on a failed validation.
|
|
23
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
24
|
+
*/
|
|
9
25
|
export namespace IResponseBodyStringifier {
|
|
26
|
+
/**
|
|
27
|
+
* Serializer generated from `typia.json.stringify`, without validation.
|
|
28
|
+
*
|
|
29
|
+
* @evidence contracts/common.md#principled-implementation The variant tags a function that serializes the data as it is, so a value of the wrong type is serialized as far as its shape allows without this variant performing validation.
|
|
30
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record, the tag and the function.
|
|
31
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
32
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the typia function the variant comes from.
|
|
33
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
34
|
+
*/
|
|
10
35
|
export interface IStringify<T> {
|
|
11
36
|
type: "stringify";
|
|
37
|
+
/**
|
|
38
|
+
* The generated function of the variant, taking the response data.
|
|
39
|
+
*
|
|
40
|
+
* @evidence contracts/common.md#principled-implementation The transform generates the function for the return type of the route method, and the runtime uses the result as the response body as it is.
|
|
41
|
+
* @evidence contracts/common.md#clear-and-simple-design One function member.
|
|
42
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function is generated from the type, and the runtime never edits its result.
|
|
43
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the function is generated for the return type; its result is in the signature.
|
|
44
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
45
|
+
*/
|
|
12
46
|
stringify: (input: T) => string;
|
|
13
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Serializer generated from `typia.json.isStringify`.
|
|
50
|
+
*
|
|
51
|
+
* @evidence contracts/common.md#principled-implementation The variant tags a function that returns the serialized text, or `null` when the data is not of the type; `null` becomes a 500 `InternalServerErrorException` with a fixed message.
|
|
52
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record, the tag and the function.
|
|
53
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
54
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the typia function the variant comes from.
|
|
55
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
56
|
+
*/
|
|
14
57
|
export interface IIs<T> {
|
|
15
58
|
type: "is";
|
|
59
|
+
/**
|
|
60
|
+
* The generated function of the variant, taking the response data.
|
|
61
|
+
*
|
|
62
|
+
* @evidence contracts/common.md#principled-implementation The transform generates the function for the return type of the route method, and it returns the serialized text or `null`.
|
|
63
|
+
* @evidence contracts/common.md#clear-and-simple-design One function member.
|
|
64
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function is generated from the type, and the runtime never edits its result.
|
|
65
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the function is generated for the return type; its result is in the signature.
|
|
66
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
67
|
+
*/
|
|
16
68
|
is: (input: T) => string | null;
|
|
17
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Serializer generated from `typia.json.assertStringify`.
|
|
72
|
+
*
|
|
73
|
+
* @evidence contracts/common.md#principled-implementation The variant tags a function that returns the serialized text or throws the `TypeGuardError` of typia, which becomes a 500 `InternalServerErrorException` with the path, reason, expected type, and value.
|
|
74
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record, the tag and the function.
|
|
75
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
76
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the typia function the variant comes from.
|
|
77
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
78
|
+
*/
|
|
18
79
|
export interface IAssert<T> {
|
|
19
80
|
type: "assert";
|
|
81
|
+
/**
|
|
82
|
+
* The generated function of the variant, taking the response data.
|
|
83
|
+
*
|
|
84
|
+
* @evidence contracts/common.md#principled-implementation The transform generates the function for the return type of the route method, and it returns the serialized text or throws.
|
|
85
|
+
* @evidence contracts/common.md#clear-and-simple-design One function member.
|
|
86
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function is generated from the type, and the runtime never edits its result.
|
|
87
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the function is generated for the return type; its result is in the signature.
|
|
88
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
89
|
+
*/
|
|
20
90
|
assert: (input: T) => string;
|
|
21
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Serializer generated from `typia.json.validateStringify`.
|
|
94
|
+
*
|
|
95
|
+
* @evidence contracts/common.md#principled-implementation The variant tags a function that returns the `IValidation` of the text; a failure becomes a 500 `InternalServerErrorException` carrying every error.
|
|
96
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record, the tag and the function.
|
|
97
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
98
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the typia function the variant comes from.
|
|
99
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
100
|
+
*/
|
|
22
101
|
export interface IValidate<T> {
|
|
23
102
|
type: "validate";
|
|
103
|
+
/**
|
|
104
|
+
* The generated function of the variant, taking the response data.
|
|
105
|
+
*
|
|
106
|
+
* @evidence contracts/common.md#principled-implementation The transform generates the function for the return type of the route method, and it returns the validation result.
|
|
107
|
+
* @evidence contracts/common.md#clear-and-simple-design One function member.
|
|
108
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function is generated from the type, and the runtime never edits its result.
|
|
109
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the function is generated for the return type; its result is in the signature.
|
|
110
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
111
|
+
*/
|
|
24
112
|
validate: (input: T) => IValidation<string>;
|
|
25
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Serializer generated from `typia.json.validateStringify`, for the
|
|
116
|
+
* `validate.log` mode.
|
|
117
|
+
*
|
|
118
|
+
* @evidence contracts/common.md#principled-implementation The variant tags the same function shape as `validate`, but a failure is passed to the logger registered with `TypedRoute.setValidateErrorLogger` and the response is `JSON.stringify` of the data, so a validation failure never changes the status.
|
|
119
|
+
* @evidence contracts/common.md#clear-and-simple-design A two-member record, the tag and the function.
|
|
120
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
121
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the typia function the variant comes from.
|
|
122
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
123
|
+
*/
|
|
26
124
|
export interface IValidateLog<T> {
|
|
27
125
|
type: "validate.log";
|
|
126
|
+
/**
|
|
127
|
+
* The generated function of the variant, taking the response data.
|
|
128
|
+
*
|
|
129
|
+
* @evidence contracts/common.md#principled-implementation The transform generates the function for the return type of the route method, and it returns the validation result.
|
|
130
|
+
* @evidence contracts/common.md#clear-and-simple-design One function member.
|
|
131
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The function is generated from the type, and the runtime never edits its result.
|
|
132
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states that the function is generated for the return type; its result is in the signature.
|
|
133
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The variants describe JSON serialization and validation callbacks without native file or process representations.
|
|
134
|
+
*/
|
|
28
135
|
validate: (input: T) => IValidation<string>;
|
|
29
136
|
}
|
|
30
137
|
}
|
package/src/typings/Creator.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class constructor: anything that can be called with `new` to build an
|
|
3
|
+
* instance of `T`.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/common.md#principled-implementation The construct signature with rest arguments is the standard TypeScript spelling of a class type.
|
|
6
|
+
* @evidence contracts/common.md#clear-and-simple-design One construct signature.
|
|
7
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
8
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states what the type stands for.
|
|
9
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The construct signature represents JavaScript class construction rather than a native resource boundary.
|
|
10
|
+
*/
|
|
1
11
|
export type Creator<T extends object> = {
|
|
2
12
|
new (...args: any[]): T;
|
|
3
13
|
};
|
package/src/utils/ArrayUtil.ts
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array helpers of the core runtime.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/common.md#principled-implementation The namespace holds the one membership helper the adapters use.
|
|
5
|
+
* @evidence contracts/common.md#clear-and-simple-design One function.
|
|
6
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a plain helper with no special cases.
|
|
7
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
8
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Array membership uses JavaScript SameValueZero comparisons with no native filesystem or process access.
|
|
9
|
+
*/
|
|
1
10
|
export namespace ArrayUtil {
|
|
11
|
+
/**
|
|
12
|
+
* Reports whether the array contains every one of the items.
|
|
13
|
+
*
|
|
14
|
+
* Membership is decided by `Array.prototype.includes`, so an item that is
|
|
15
|
+
* `undefined` or `NaN` is found when the array holds it.
|
|
16
|
+
*
|
|
17
|
+
* @evidence contracts/common.md#principled-implementation `Array.prototype.includes` compares by SameValueZero, so the result is the conjunction over the items of membership, an item that is `undefined` or `NaN` is found when the array holds it, and no items yields true; an earlier `find` compared the found element with `undefined` and could not report an `undefined` member.
|
|
18
|
+
* @evidence contracts/common.md#clear-and-simple-design One `every` over `includes`.
|
|
19
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts No item is special-cased.
|
|
20
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the conjunction and the comparison rule.
|
|
21
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Array membership uses JavaScript SameValueZero comparisons with no native filesystem or process access.
|
|
22
|
+
*/
|
|
2
23
|
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
-
return items.every(
|
|
4
|
-
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
-
);
|
|
24
|
+
return items.every((item) => array.includes(item));
|
|
6
25
|
}
|
|
7
26
|
}
|
|
@@ -14,21 +14,25 @@ import { Creator } from "../typings/Creator";
|
|
|
14
14
|
* {@link EncryptedRoute} instead of the basic router decorator functions like
|
|
15
15
|
* {@link nest.Get} or {@link nest.Post} and the API function throws a custom
|
|
16
16
|
* error whose class has been {@link ExceptionManager.insert inserted} in this
|
|
17
|
-
* `
|
|
17
|
+
* `ExceptionManager`, the error would be automatically converted to the regular
|
|
18
18
|
* {@link nest.HttpException} instance by the {@link ExceptionManager.Closure}
|
|
19
19
|
* function.
|
|
20
20
|
*
|
|
21
21
|
* Therefore, with this `ExceptionManager` and {@link TypedRoute} or
|
|
22
22
|
* {@link EncryptedRoute}, you can manage your custom error classes much
|
|
23
|
-
*
|
|
23
|
+
* systematically. You can avoid 500 internal server error or hard coding
|
|
24
24
|
* implementation about the custom error classes.
|
|
25
25
|
*
|
|
26
|
-
* Below error
|
|
26
|
+
* Below error class is configured in this `ExceptionManager` by default.
|
|
27
27
|
*
|
|
28
|
-
* - `typia.TypeGuardError`
|
|
29
28
|
* - `@nestia/fetcher.HttpError`
|
|
30
29
|
*
|
|
31
30
|
* @author Jeongho Nam - https://github.com/samchon
|
|
31
|
+
* @evidence contracts/common.md#principled-implementation Converters are kept as an ordered list of class and closure, and an error is converted by the first class it is an instance of; the insertion keeps every subclass before its superclasses so the most specific converter wins, and `HttpError` from the fetcher is registered by default.
|
|
32
|
+
* @evidence contracts/common.md#clear-and-simple-design One namespace with the two collections and four operations; the listener set and the tuple list are the only state.
|
|
33
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The registration is public and explicit; no error class is special-cased except the default `HttpError` conversion.
|
|
34
|
+
* @evidence contracts/common.md#meaningful-documentation The comment documents the converter and listener concepts with an example.
|
|
35
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
32
36
|
*/
|
|
33
37
|
export namespace ExceptionManager {
|
|
34
38
|
/**
|
|
@@ -39,6 +43,11 @@ export namespace ExceptionManager {
|
|
|
39
43
|
*
|
|
40
44
|
* @param creator Target error class
|
|
41
45
|
* @param closure A closure function converting to the `HttpException` class
|
|
46
|
+
* @evidence contracts/common.md#principled-implementation An existing entry for the same class is removed first, then the new entry is placed before the first registered class that it extends, so specificity order holds however the calls are ordered.
|
|
47
|
+
* @evidence contracts/common.md#clear-and-simple-design One function over one list.
|
|
48
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The order rule is derived from the prototype chain, not from a list of known classes.
|
|
49
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the replacement and ordering rules.
|
|
50
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
42
51
|
*/
|
|
43
52
|
export function insert<T extends Error>(
|
|
44
53
|
creator: Creator<T>,
|
|
@@ -47,8 +56,13 @@ export namespace ExceptionManager {
|
|
|
47
56
|
const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
|
|
48
57
|
if (index !== -1) tuples.splice(index, 1);
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
// an error converts by the first class it is an instance of, so a class
|
|
60
|
+
// must precede every superclass of it: insert before the first one
|
|
61
|
+
const ancestor: number = tuples.findIndex(
|
|
62
|
+
([registered]) => creator.prototype instanceof registered,
|
|
63
|
+
);
|
|
64
|
+
if (ancestor === -1) tuples.push([creator, closure]);
|
|
65
|
+
else tuples.splice(ancestor, 0, [creator, closure]);
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
/**
|
|
@@ -56,6 +70,11 @@ export namespace ExceptionManager {
|
|
|
56
70
|
*
|
|
57
71
|
* @param creator Target error class
|
|
58
72
|
* @returns Whether be erased or not
|
|
73
|
+
* @evidence contracts/common.md#principled-implementation The entry for the class is found by identity and removed, and the result says whether anything was removed.
|
|
74
|
+
* @evidence contracts/common.md#clear-and-simple-design One search and one removal.
|
|
75
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It removes only the named class's entry.
|
|
76
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the parameter and the boolean result.
|
|
77
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
59
78
|
*/
|
|
60
79
|
export function erase<T extends Error>(creator: Creator<T>): boolean {
|
|
61
80
|
const index: number = tuples.findIndex((tuple) => tuple[0] === creator);
|
|
@@ -65,10 +84,29 @@ export namespace ExceptionManager {
|
|
|
65
84
|
return true;
|
|
66
85
|
}
|
|
67
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Registers a listener called with every error thrown by a typed route, after
|
|
89
|
+
* the response conversion.
|
|
90
|
+
*
|
|
91
|
+
* @evidence contracts/common.md#principled-implementation The listener is added to a set, so the same function registered twice is called once.
|
|
92
|
+
* @evidence contracts/common.md#clear-and-simple-design One set insertion.
|
|
93
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The listener only observes; the route notifies it after the current turn and ignores its errors.
|
|
94
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states when listeners are called.
|
|
95
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
96
|
+
*/
|
|
68
97
|
export function on(closure: (error: any) => any): void {
|
|
69
98
|
listeners.add(closure);
|
|
70
99
|
}
|
|
71
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Unregisters a listener added with {@link on}.
|
|
103
|
+
*
|
|
104
|
+
* @evidence contracts/common.md#principled-implementation The listener is removed from the set by identity.
|
|
105
|
+
* @evidence contracts/common.md#clear-and-simple-design One set deletion.
|
|
106
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It removes only the named listener.
|
|
107
|
+
* @evidence contracts/common.md#meaningful-documentation The comment names the counterpart operation.
|
|
108
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
109
|
+
*/
|
|
72
110
|
export function off(closure: (error: any) => any): void {
|
|
73
111
|
listeners.delete(closure);
|
|
74
112
|
}
|
|
@@ -81,6 +119,12 @@ export namespace ExceptionManager {
|
|
|
81
119
|
* from custom error to the regular {@link nest.HttpException} instance. It
|
|
82
120
|
* would be used in the {@link ExceptionManager} with {@link TypedRoute} or
|
|
83
121
|
* {@link EncryptedRoute}.
|
|
122
|
+
*
|
|
123
|
+
* @evidence contracts/common.md#principled-implementation A converter is a function from the caught error to an `HttpException`, whose status and body become the response.
|
|
124
|
+
* @evidence contracts/common.md#clear-and-simple-design One call signature.
|
|
125
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It is a type and adds no runtime behavior.
|
|
126
|
+
* @evidence contracts/common.md#meaningful-documentation The comment documents the parameter and the return value.
|
|
127
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation Converter ordering and listener registration operate on JavaScript class and function identity, not native path or process identity.
|
|
84
128
|
*/
|
|
85
129
|
export interface Closure<T extends Error> {
|
|
86
130
|
/**
|
|
@@ -2,26 +2,53 @@ import fs from "fs";
|
|
|
2
2
|
import { glob } from "glob";
|
|
3
3
|
import path from "path";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Finds source files by path, directory, or glob.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/common.md#principled-implementation The finder resolves each pattern to existing files or directories, walks directories, applies the caller's filter to files only, and subtracts the excluded set, so the result is the included files minus the excluded ones.
|
|
9
|
+
* @evidence contracts/common.md#clear-and-simple-design One public function and private walkers; the caller supplies the filter.
|
|
10
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts It contains no file names; extensions come from the caller's filter.
|
|
11
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states its purpose.
|
|
12
|
+
* @evidence contracts/portability.md#os-neutral-implementation The finder turns each pattern into an absolute native path with `path.resolve` and asks the filesystem itself, through `existsSync`, `stat` and `readdir`, whether a path exists and what it is, so the volume's own case policy and links apply. Only the part of a pattern below its longest existing ancestor is globbed, rewritten from the native separator to `/` because glob reads a Windows backslash as an escape. Remaining assumptions: the case policy of wildcard matching is glob's own platform default and not a probe of the volume, accepted files are keyed by filesystem real path while returned locations retain their discovered spelling, and directory links are followed once per real path in each include or exclude collection, so aliases and cycles do not repeat a traversal.
|
|
13
|
+
*/
|
|
5
14
|
export namespace SourceFinder {
|
|
15
|
+
/**
|
|
16
|
+
* Returns the files matched by the include patterns and not by the exclude
|
|
17
|
+
* patterns.
|
|
18
|
+
*
|
|
19
|
+
* A pattern may name a file, a directory that is walked recursively, or a
|
|
20
|
+
* glob. Only files accepted by the filter are returned.
|
|
21
|
+
*
|
|
22
|
+
* @evidence contracts/common.md#principled-implementation A pattern that exists on disk is used as a path; otherwise its longest existing ancestor becomes the base of a glob search, so a pattern with wildcards is matched below the part of the path that exists, and a base that does not exist matches nothing; accepted file identities use filesystem real paths, so includes and exclusions agree across links and case aliases while output retains a discovered native spelling.
|
|
23
|
+
* @evidence contracts/common.md#clear-and-simple-design One function that runs the same collection twice, once adding and once removing.
|
|
24
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts The result follows the patterns and the filter, with no fixed directory.
|
|
25
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states the pattern forms and the filtering.
|
|
26
|
+
* @evidence contracts/portability.md#os-neutral-implementation An existing path is used literally, so no character glob reads specially is interpreted. Otherwise the nearest existing ancestor, found with `existsSync` and `dirname` until the filesystem root, is the glob's working directory and the matches are resolved against it, so a drive letter or a UNC root never enters the pattern.
|
|
27
|
+
*/
|
|
6
28
|
export const find = async (props: IProps): Promise<string[]> => {
|
|
7
|
-
const dict:
|
|
29
|
+
const dict: Map<string, string> = new Map();
|
|
8
30
|
|
|
9
|
-
await emplace(props.filter)(props.include)((str) =>
|
|
31
|
+
await emplace(props.filter)(props.include)((str) =>
|
|
32
|
+
dict.set(fs.realpathSync.native(str), str),
|
|
33
|
+
);
|
|
10
34
|
if (props.exclude?.length)
|
|
11
|
-
await emplace(props.filter)(props.exclude)((str) =>
|
|
35
|
+
await emplace(props.filter)(props.exclude)((str) =>
|
|
36
|
+
dict.delete(fs.realpathSync.native(str)),
|
|
37
|
+
);
|
|
12
38
|
|
|
13
|
-
return [...dict];
|
|
39
|
+
return [...dict.values()];
|
|
14
40
|
};
|
|
15
41
|
|
|
16
42
|
const emplace =
|
|
17
43
|
(filter: (file: string) => boolean) =>
|
|
18
44
|
(input: string[]) =>
|
|
19
45
|
async (closure: (location: string) => void): Promise<void> => {
|
|
46
|
+
const visited: Set<string> = new Set();
|
|
20
47
|
for (const pattern of input) {
|
|
21
|
-
for (const file of await _Glob(
|
|
48
|
+
for (const file of await _Glob(pattern)) {
|
|
22
49
|
const stats: fs.Stats = await fs.promises.stat(file);
|
|
23
50
|
if (stats.isDirectory() === true)
|
|
24
|
-
await iterate(filter)(closure)(file);
|
|
51
|
+
await iterate(filter)(closure)(file, visited);
|
|
25
52
|
else if (stats.isFile() && filter(file)) closure(file);
|
|
26
53
|
}
|
|
27
54
|
}
|
|
@@ -30,20 +57,45 @@ export namespace SourceFinder {
|
|
|
30
57
|
const iterate =
|
|
31
58
|
(filter: (location: string) => boolean) =>
|
|
32
59
|
(closure: (location: string) => void) =>
|
|
33
|
-
async (location: string): Promise<void> => {
|
|
60
|
+
async (location: string, visited: Set<string>): Promise<void> => {
|
|
61
|
+
const identity: string = await fs.promises.realpath(location);
|
|
62
|
+
if (visited.has(identity)) return;
|
|
63
|
+
visited.add(identity);
|
|
34
64
|
const directory: string[] = await fs.promises.readdir(location);
|
|
35
65
|
for (const file of directory) {
|
|
36
66
|
const next: string = path.resolve(`${location}/${file}`);
|
|
37
67
|
const stats: fs.Stats = await fs.promises.stat(next);
|
|
38
68
|
|
|
39
|
-
if (stats.isDirectory() === true)
|
|
69
|
+
if (stats.isDirectory() === true)
|
|
70
|
+
await iterate(filter)(closure)(next, visited);
|
|
40
71
|
else if (stats.isFile() && filter(next)) closure(next);
|
|
41
72
|
}
|
|
42
73
|
};
|
|
43
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Files and directories a path or glob pattern names.
|
|
77
|
+
*
|
|
78
|
+
* An existing path is taken literally, whatever characters it holds, as a
|
|
79
|
+
* directory such as `app [v2]` would otherwise read as a character class. For
|
|
80
|
+
* a pattern, the longest existing ancestor is the literal base and only the
|
|
81
|
+
* rest is globbed, with `/` separators, since glob reads a Windows backslash
|
|
82
|
+
* as an escape.
|
|
83
|
+
*/
|
|
44
84
|
const _Glob = async (pattern: string): Promise<string[]> => {
|
|
45
|
-
const
|
|
46
|
-
|
|
85
|
+
const absolute: string = path.resolve(pattern);
|
|
86
|
+
if (fs.existsSync(absolute)) return [absolute];
|
|
87
|
+
let base: string = absolute;
|
|
88
|
+
while (fs.existsSync(base) === false) {
|
|
89
|
+
const parent: string = path.dirname(base);
|
|
90
|
+
if (parent === base) return [];
|
|
91
|
+
base = parent;
|
|
92
|
+
}
|
|
93
|
+
const rest: string = path
|
|
94
|
+
.relative(base, absolute)
|
|
95
|
+
.split(path.sep)
|
|
96
|
+
.join("/");
|
|
97
|
+
const matches: string[] = await glob(rest, { cwd: base });
|
|
98
|
+
return matches.map((str) => path.resolve(base, str));
|
|
47
99
|
};
|
|
48
100
|
}
|
|
49
101
|
|
|
@@ -1,27 +1,71 @@
|
|
|
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
|
|
|
43
|
+
/**
|
|
44
|
+
* Version path segments of a route, resolved as NestJS resolves them: the
|
|
45
|
+
* method's versions, else the controller's, else the default version, and no
|
|
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.
|
|
53
|
+
*/
|
|
14
54
|
export const merge =
|
|
15
55
|
(config: IConfig | undefined) =>
|
|
16
|
-
(
|
|
56
|
+
(props: {
|
|
57
|
+
controller: Array<string | typeof VERSION_NEUTRAL> | undefined;
|
|
58
|
+
method: Array<string | typeof VERSION_NEUTRAL> | undefined;
|
|
59
|
+
}): string[] => {
|
|
17
60
|
if (config === undefined) return [""];
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
:
|
|
61
|
+
const chosen: Array<string | typeof VERSION_NEUTRAL> | undefined =
|
|
62
|
+
props.method ?? props.controller ?? cast(config.defaultVersion);
|
|
63
|
+
if (chosen === undefined) return [""];
|
|
64
|
+
const unique: Array<string | typeof VERSION_NEUTRAL> = [
|
|
65
|
+
...new Set(chosen),
|
|
66
|
+
];
|
|
67
|
+
return unique.map((x) =>
|
|
68
|
+
typeof x === "symbol" ? "" : `${config.prefix}${x}`,
|
|
69
|
+
);
|
|
26
70
|
};
|
|
27
71
|
}
|
package/lib/transform.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
|
|
2
|
-
/**
|
|
3
|
-
* `@nestia/core` ttsc plugin descriptor.
|
|
4
|
-
*
|
|
5
|
-
* `@nestia/sdk` is not a standalone plugin: its Go transform is declared here
|
|
6
|
-
* as a `contributor` that ttsc statically links into this host binary, and only
|
|
7
|
-
* when `@nestia/sdk` is actually resolvable from the project. A project
|
|
8
|
-
* depending on `@nestia/core` alone never compiles any SDK transform code.
|
|
9
|
-
*/
|
|
10
|
-
export default function createTtscPlugin(context: ITtscPluginFactoryContext): ITtscPlugin;
|
package/lib/transform.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = createTtscPlugin;
|
|
7
|
-
const node_module_1 = require("node:module");
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
/**
|
|
10
|
-
* `@nestia/core` ttsc plugin descriptor.
|
|
11
|
-
*
|
|
12
|
-
* `@nestia/sdk` is not a standalone plugin: its Go transform is declared here
|
|
13
|
-
* as a `contributor` that ttsc statically links into this host binary, and only
|
|
14
|
-
* when `@nestia/sdk` is actually resolvable from the project. A project
|
|
15
|
-
* depending on `@nestia/core` alone never compiles any SDK transform code.
|
|
16
|
-
*/
|
|
17
|
-
function createTtscPlugin(context) {
|
|
18
|
-
const requireFrom = (0, node_module_1.createRequire)(node_path_1.default.join(context.projectRoot, "package.json"));
|
|
19
|
-
const root = node_path_1.default.dirname(requireFrom.resolve("@nestia/core/package.json"));
|
|
20
|
-
return {
|
|
21
|
-
name: "@nestia/core",
|
|
22
|
-
source: node_path_1.default.resolve(root, "native", "cmd", "ttsc-nestia"),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=transform.js.map
|
package/lib/transform.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA4C;AAC5C,0DAA6B;AAG7B;;;;;;;GAOG;AACH,0BACE,OAAkC;IAElC,MAAM,WAAW,GAAG,IAAA,2BAAa,EAC/B,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAC/C,CAAC;IACF,MAAM,IAAI,GAAW,mBAAI,CAAC,OAAO,CAC/B,WAAW,CAAC,OAAO,CAAC,2BAA2B,CAAC,CACjD,CAAC;IACF,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,mBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
package/src/transform.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import type { ITtscPlugin, ITtscPluginFactoryContext } from "ttsc";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `@nestia/core` ttsc plugin descriptor.
|
|
7
|
-
*
|
|
8
|
-
* `@nestia/sdk` is not a standalone plugin: its Go transform is declared here
|
|
9
|
-
* as a `contributor` that ttsc statically links into this host binary, and only
|
|
10
|
-
* when `@nestia/sdk` is actually resolvable from the project. A project
|
|
11
|
-
* depending on `@nestia/core` alone never compiles any SDK transform code.
|
|
12
|
-
*/
|
|
13
|
-
export default function createTtscPlugin(
|
|
14
|
-
context: ITtscPluginFactoryContext,
|
|
15
|
-
): ITtscPlugin {
|
|
16
|
-
const requireFrom = createRequire(
|
|
17
|
-
path.join(context.projectRoot, "package.json"),
|
|
18
|
-
);
|
|
19
|
-
const root: string = path.dirname(
|
|
20
|
-
requireFrom.resolve("@nestia/core/package.json"),
|
|
21
|
-
);
|
|
22
|
-
return {
|
|
23
|
-
name: "@nestia/core",
|
|
24
|
-
source: path.resolve(root, "native", "cmd", "ttsc-nestia"),
|
|
25
|
-
};
|
|
26
|
-
}
|