@nestia/core 12.0.0-dev.20260601.1 → 12.0.0-dev.20260612.1
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/LICENSE +21 -21
- package/MIGRATION.md +169 -169
- package/README.md +93 -93
- package/lib/adaptors/McpAdaptor.d.ts +75 -0
- package/lib/adaptors/McpAdaptor.js +257 -0
- package/lib/adaptors/McpAdaptor.js.map +1 -0
- package/lib/adaptors/WebSocketAdaptor.js +4 -4
- package/lib/adaptors/WebSocketAdaptor.js.map +1 -1
- package/lib/decorators/McpRoute.d.ts +69 -0
- package/lib/decorators/McpRoute.js +58 -0
- package/lib/decorators/McpRoute.js.map +1 -0
- package/lib/decorators/TypedParam.js +4 -4
- package/lib/decorators/TypedParam.js.map +1 -1
- package/lib/decorators/TypedRoute.js +1 -1
- package/lib/decorators/TypedRoute.js.map +1 -1
- package/lib/decorators/internal/IMcpRouteReflect.d.ts +2 -0
- package/lib/decorators/internal/IMcpRouteReflect.js +3 -0
- package/lib/decorators/internal/IMcpRouteReflect.js.map +1 -0
- package/lib/decorators/internal/get_path_and_querify.js +4 -4
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/get_path_and_stringify.js +4 -4
- package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
- package/lib/decorators/internal/load_controller.js +34 -65
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.js +4 -4
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +4 -4
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -1
- package/lib/decorators/internal/validate_request_headers.js +4 -4
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.js +4 -4
- package/lib/decorators/internal/validate_request_query.js.map +1 -1
- package/lib/module.d.ts +2 -0
- package/lib/module.js +2 -0
- package/lib/module.js.map +1 -1
- package/native/cmd/ttsc-nestia/main.go +11 -11
- package/native/go.mod +32 -32
- package/native/go.sum +54 -54
- package/native/plugin/plan.go +102 -102
- package/native/transform/ast.go +32 -32
- package/native/transform/build.go +380 -444
- package/native/transform/cleanup.go +408 -408
- package/native/transform/contributor.go +97 -68
- package/native/transform/core_querify.go +231 -227
- package/native/transform/core_transform.go +1996 -1713
- package/native/transform/core_websocket.go +115 -115
- package/native/transform/exports.go +13 -13
- package/native/transform/mcp_transform.go +414 -0
- package/native/transform/node_transform.go +357 -0
- package/native/transform/path_rewrite.go +285 -285
- package/native/transform/printer.go +244 -244
- package/native/transform/rewrite.go +668 -662
- package/native/transform/run.go +73 -73
- package/native/transform/transform.go +336 -403
- package/native/transform/typia_fast.go +352 -326
- package/native/transform/typia_replacement.go +24 -24
- package/native/transform.cjs +43 -43
- package/package.json +15 -8
- package/src/adaptors/McpAdaptor.ts +276 -0
- package/src/adaptors/WebSocketAdaptor.ts +429 -429
- package/src/decorators/DynamicModule.ts +44 -44
- package/src/decorators/EncryptedBody.ts +97 -97
- package/src/decorators/EncryptedController.ts +40 -40
- package/src/decorators/EncryptedModule.ts +98 -98
- package/src/decorators/EncryptedRoute.ts +213 -213
- package/src/decorators/HumanRoute.ts +21 -21
- package/src/decorators/McpRoute.ts +154 -0
- package/src/decorators/NoTransformConfigurationError.ts +40 -40
- package/src/decorators/PlainBody.ts +76 -76
- package/src/decorators/SwaggerCustomizer.ts +97 -97
- package/src/decorators/SwaggerExample.ts +180 -180
- package/src/decorators/TypedBody.ts +57 -57
- package/src/decorators/TypedException.ts +147 -147
- package/src/decorators/TypedFormData.ts +187 -187
- package/src/decorators/TypedHeaders.ts +66 -66
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +234 -234
- package/src/decorators/TypedRoute.ts +198 -196
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/doNotThrowTransformError.ts +5 -5
- package/src/decorators/internal/EncryptedConstant.ts +2 -2
- package/src/decorators/internal/IMcpRouteReflect.ts +40 -0
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/get_path_and_querify.ts +94 -94
- package/src/decorators/internal/get_path_and_stringify.ts +110 -110
- package/src/decorators/internal/get_text_body.ts +16 -16
- package/src/decorators/internal/headers_to_object.ts +11 -11
- package/src/decorators/internal/is_request_body_undefined.ts +12 -12
- package/src/decorators/internal/load_controller.ts +91 -76
- package/src/decorators/internal/route_error.ts +43 -43
- package/src/decorators/internal/validate_request_body.ts +64 -64
- package/src/decorators/internal/validate_request_form_data.ts +67 -67
- package/src/decorators/internal/validate_request_headers.ts +76 -76
- package/src/decorators/internal/validate_request_query.ts +83 -83
- package/src/index.ts +5 -5
- package/src/module.ts +25 -23
- package/src/options/IRequestBodyValidator.ts +20 -20
- package/src/options/IRequestFormDataProps.ts +27 -27
- package/src/options/IRequestHeadersValidator.ts +22 -22
- package/src/options/IRequestQueryValidator.ts +20 -20
- package/src/options/IResponseBodyQuerifier.ts +25 -25
- package/src/options/IResponseBodyStringifier.ts +30 -30
- package/src/transform.ts +101 -101
- package/src/typings/Creator.ts +3 -3
- package/src/typings/get-function-location.d.ts +7 -7
- package/src/utils/ArrayUtil.ts +7 -7
- package/src/utils/ExceptionManager.ts +115 -115
- package/src/utils/Singleton.ts +16 -16
- package/src/utils/SourceFinder.ts +54 -54
- package/src/utils/VersioningStrategy.ts +27 -27
- package/native/transform/cleanup_test.go +0 -76
- package/native/transform/commonjs_import_alias_test.go +0 -49
- package/native/transform/core_dispatch_test.go +0 -127
- package/native/transform/path_rewrite_test.go +0 -243
- package/native/transform/rewrite_test.go +0 -118
- package/native/transform/rewrite_unique_base_test.go +0 -48
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as core from "./module";
|
|
2
|
-
|
|
3
|
-
export * from "./module";
|
|
4
|
-
|
|
5
|
-
export default core;
|
|
1
|
+
import * as core from "./module";
|
|
2
|
+
|
|
3
|
+
export * from "./module";
|
|
4
|
+
|
|
5
|
+
export default core;
|
package/src/module.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
export * from "./decorators/DynamicModule";
|
|
2
|
-
export * from "./utils/ExceptionManager";
|
|
3
|
-
|
|
4
|
-
export * from "./decorators/HumanRoute";
|
|
5
|
-
export * from "./decorators/TypedRoute";
|
|
6
|
-
export * from "./decorators/TypedBody";
|
|
7
|
-
export * from "./decorators/TypedQuery";
|
|
8
|
-
export * from "./decorators/TypedException";
|
|
9
|
-
export * from "./decorators/TypedHeaders";
|
|
10
|
-
export * from "./decorators/TypedFormData";
|
|
11
|
-
export * from "./decorators/TypedParam";
|
|
12
|
-
|
|
13
|
-
export * from "./decorators/EncryptedController";
|
|
14
|
-
export * from "./decorators/EncryptedRoute";
|
|
15
|
-
export * from "./decorators/EncryptedBody";
|
|
16
|
-
export * from "./decorators/EncryptedModule";
|
|
17
|
-
export * from "./decorators/PlainBody";
|
|
18
|
-
export * from "./decorators/SwaggerCustomizer";
|
|
19
|
-
export * from "./decorators/SwaggerExample";
|
|
20
|
-
|
|
21
|
-
export * from "./adaptors/WebSocketAdaptor";
|
|
22
|
-
export * from "./decorators/WebSocketRoute";
|
|
23
|
-
export * from "./
|
|
1
|
+
export * from "./decorators/DynamicModule";
|
|
2
|
+
export * from "./utils/ExceptionManager";
|
|
3
|
+
|
|
4
|
+
export * from "./decorators/HumanRoute";
|
|
5
|
+
export * from "./decorators/TypedRoute";
|
|
6
|
+
export * from "./decorators/TypedBody";
|
|
7
|
+
export * from "./decorators/TypedQuery";
|
|
8
|
+
export * from "./decorators/TypedException";
|
|
9
|
+
export * from "./decorators/TypedHeaders";
|
|
10
|
+
export * from "./decorators/TypedFormData";
|
|
11
|
+
export * from "./decorators/TypedParam";
|
|
12
|
+
|
|
13
|
+
export * from "./decorators/EncryptedController";
|
|
14
|
+
export * from "./decorators/EncryptedRoute";
|
|
15
|
+
export * from "./decorators/EncryptedBody";
|
|
16
|
+
export * from "./decorators/EncryptedModule";
|
|
17
|
+
export * from "./decorators/PlainBody";
|
|
18
|
+
export * from "./decorators/SwaggerCustomizer";
|
|
19
|
+
export * from "./decorators/SwaggerExample";
|
|
20
|
+
|
|
21
|
+
export * from "./adaptors/WebSocketAdaptor";
|
|
22
|
+
export * from "./decorators/WebSocketRoute";
|
|
23
|
+
export * from "./adaptors/McpAdaptor";
|
|
24
|
+
export * from "./decorators/McpRoute";
|
|
25
|
+
export * from "./decorators/doNotThrowTransformError";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export type IRequestBodyValidator<T> =
|
|
4
|
-
| IRequestBodyValidator.IAssert<T>
|
|
5
|
-
| IRequestBodyValidator.IIs<T>
|
|
6
|
-
| IRequestBodyValidator.IValidate<T>;
|
|
7
|
-
export namespace IRequestBodyValidator {
|
|
8
|
-
export interface IAssert<T> {
|
|
9
|
-
type: "assert";
|
|
10
|
-
assert: (input: T) => T;
|
|
11
|
-
}
|
|
12
|
-
export interface IIs<T> {
|
|
13
|
-
type: "is";
|
|
14
|
-
is: (input: T) => boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface IValidate<T> {
|
|
17
|
-
type: "validate";
|
|
18
|
-
validate: (input: T) => IValidation<T>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export type IRequestBodyValidator<T> =
|
|
4
|
+
| IRequestBodyValidator.IAssert<T>
|
|
5
|
+
| IRequestBodyValidator.IIs<T>
|
|
6
|
+
| IRequestBodyValidator.IValidate<T>;
|
|
7
|
+
export namespace IRequestBodyValidator {
|
|
8
|
+
export interface IAssert<T> {
|
|
9
|
+
type: "assert";
|
|
10
|
+
assert: (input: T) => T;
|
|
11
|
+
}
|
|
12
|
+
export interface IIs<T> {
|
|
13
|
+
type: "is";
|
|
14
|
+
is: (input: T) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IValidate<T> {
|
|
17
|
+
type: "validate";
|
|
18
|
+
validate: (input: T) => IValidation<T>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export interface IRequestFormDataProps<T> {
|
|
4
|
-
files: Array<IRequestFormDataProps.IFile>;
|
|
5
|
-
validator:
|
|
6
|
-
| IRequestFormDataProps.IAssert<T>
|
|
7
|
-
| IRequestFormDataProps.IIs<T>
|
|
8
|
-
| IRequestFormDataProps.IValidate<T>;
|
|
9
|
-
}
|
|
10
|
-
export namespace IRequestFormDataProps {
|
|
11
|
-
export interface IAssert<T> {
|
|
12
|
-
type: "assert";
|
|
13
|
-
assert: (input: FormData) => T;
|
|
14
|
-
}
|
|
15
|
-
export interface IIs<T> {
|
|
16
|
-
type: "is";
|
|
17
|
-
is: (input: FormData) => T | null;
|
|
18
|
-
}
|
|
19
|
-
export interface IValidate<T> {
|
|
20
|
-
type: "validate";
|
|
21
|
-
validate: (input: FormData) => IValidation<T>;
|
|
22
|
-
}
|
|
23
|
-
export interface IFile {
|
|
24
|
-
name: string;
|
|
25
|
-
limit: number | null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export interface IRequestFormDataProps<T> {
|
|
4
|
+
files: Array<IRequestFormDataProps.IFile>;
|
|
5
|
+
validator:
|
|
6
|
+
| IRequestFormDataProps.IAssert<T>
|
|
7
|
+
| IRequestFormDataProps.IIs<T>
|
|
8
|
+
| IRequestFormDataProps.IValidate<T>;
|
|
9
|
+
}
|
|
10
|
+
export namespace IRequestFormDataProps {
|
|
11
|
+
export interface IAssert<T> {
|
|
12
|
+
type: "assert";
|
|
13
|
+
assert: (input: FormData) => T;
|
|
14
|
+
}
|
|
15
|
+
export interface IIs<T> {
|
|
16
|
+
type: "is";
|
|
17
|
+
is: (input: FormData) => T | null;
|
|
18
|
+
}
|
|
19
|
+
export interface IValidate<T> {
|
|
20
|
+
type: "validate";
|
|
21
|
+
validate: (input: FormData) => IValidation<T>;
|
|
22
|
+
}
|
|
23
|
+
export interface IFile {
|
|
24
|
+
name: string;
|
|
25
|
+
limit: number | null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export type IRequestHeadersValidator<T> =
|
|
4
|
-
| IRequestHeadersValidator.IAssert<T>
|
|
5
|
-
| IRequestHeadersValidator.IIs<T>
|
|
6
|
-
| IRequestHeadersValidator.IValidate<T>;
|
|
7
|
-
export namespace IRequestHeadersValidator {
|
|
8
|
-
export interface IAssert<T> {
|
|
9
|
-
type: "assert";
|
|
10
|
-
assert: (input: Record<string, string | string[] | undefined>) => T;
|
|
11
|
-
}
|
|
12
|
-
export interface IIs<T> {
|
|
13
|
-
type: "is";
|
|
14
|
-
is: (input: Record<string, string | string[] | undefined>) => T | null;
|
|
15
|
-
}
|
|
16
|
-
export interface IValidate<T> {
|
|
17
|
-
type: "validate";
|
|
18
|
-
validate: (
|
|
19
|
-
input: Record<string, string | string[] | undefined>,
|
|
20
|
-
) => IValidation<T>;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export type IRequestHeadersValidator<T> =
|
|
4
|
+
| IRequestHeadersValidator.IAssert<T>
|
|
5
|
+
| IRequestHeadersValidator.IIs<T>
|
|
6
|
+
| IRequestHeadersValidator.IValidate<T>;
|
|
7
|
+
export namespace IRequestHeadersValidator {
|
|
8
|
+
export interface IAssert<T> {
|
|
9
|
+
type: "assert";
|
|
10
|
+
assert: (input: Record<string, string | string[] | undefined>) => T;
|
|
11
|
+
}
|
|
12
|
+
export interface IIs<T> {
|
|
13
|
+
type: "is";
|
|
14
|
+
is: (input: Record<string, string | string[] | undefined>) => T | null;
|
|
15
|
+
}
|
|
16
|
+
export interface IValidate<T> {
|
|
17
|
+
type: "validate";
|
|
18
|
+
validate: (
|
|
19
|
+
input: Record<string, string | string[] | undefined>,
|
|
20
|
+
) => IValidation<T>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export type IRequestQueryValidator<T> =
|
|
4
|
-
| IRequestQueryValidator.IAssert<T>
|
|
5
|
-
| IRequestQueryValidator.IIs<T>
|
|
6
|
-
| IRequestQueryValidator.IValidate<T>;
|
|
7
|
-
export namespace IRequestQueryValidator {
|
|
8
|
-
export interface IAssert<T> {
|
|
9
|
-
type: "assert";
|
|
10
|
-
assert: (input: URLSearchParams) => T;
|
|
11
|
-
}
|
|
12
|
-
export interface IIs<T> {
|
|
13
|
-
type: "is";
|
|
14
|
-
is: (input: URLSearchParams) => T | null;
|
|
15
|
-
}
|
|
16
|
-
export interface IValidate<T> {
|
|
17
|
-
type: "validate";
|
|
18
|
-
validate: (input: URLSearchParams) => IValidation<T>;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export type IRequestQueryValidator<T> =
|
|
4
|
+
| IRequestQueryValidator.IAssert<T>
|
|
5
|
+
| IRequestQueryValidator.IIs<T>
|
|
6
|
+
| IRequestQueryValidator.IValidate<T>;
|
|
7
|
+
export namespace IRequestQueryValidator {
|
|
8
|
+
export interface IAssert<T> {
|
|
9
|
+
type: "assert";
|
|
10
|
+
assert: (input: URLSearchParams) => T;
|
|
11
|
+
}
|
|
12
|
+
export interface IIs<T> {
|
|
13
|
+
type: "is";
|
|
14
|
+
is: (input: URLSearchParams) => T | null;
|
|
15
|
+
}
|
|
16
|
+
export interface IValidate<T> {
|
|
17
|
+
type: "validate";
|
|
18
|
+
validate: (input: URLSearchParams) => IValidation<T>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export type IResponseBodyQuerifier<T> =
|
|
4
|
-
| IResponseBodyquerifier.IStringify<T>
|
|
5
|
-
| IResponseBodyquerifier.IIs<T>
|
|
6
|
-
| IResponseBodyquerifier.IAssert<T>
|
|
7
|
-
| IResponseBodyquerifier.IValidate<T>;
|
|
8
|
-
export namespace IResponseBodyquerifier {
|
|
9
|
-
export interface IStringify<T> {
|
|
10
|
-
type: "stringify";
|
|
11
|
-
stringify: (input: T) => URLSearchParams;
|
|
12
|
-
}
|
|
13
|
-
export interface IIs<T> {
|
|
14
|
-
type: "is";
|
|
15
|
-
is: (input: T) => URLSearchParams | null;
|
|
16
|
-
}
|
|
17
|
-
export interface IAssert<T> {
|
|
18
|
-
type: "assert";
|
|
19
|
-
assert: (input: T) => URLSearchParams;
|
|
20
|
-
}
|
|
21
|
-
export interface IValidate<T> {
|
|
22
|
-
type: "validate";
|
|
23
|
-
validate: (input: T) => IValidation<URLSearchParams>;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export type IResponseBodyQuerifier<T> =
|
|
4
|
+
| IResponseBodyquerifier.IStringify<T>
|
|
5
|
+
| IResponseBodyquerifier.IIs<T>
|
|
6
|
+
| IResponseBodyquerifier.IAssert<T>
|
|
7
|
+
| IResponseBodyquerifier.IValidate<T>;
|
|
8
|
+
export namespace IResponseBodyquerifier {
|
|
9
|
+
export interface IStringify<T> {
|
|
10
|
+
type: "stringify";
|
|
11
|
+
stringify: (input: T) => URLSearchParams;
|
|
12
|
+
}
|
|
13
|
+
export interface IIs<T> {
|
|
14
|
+
type: "is";
|
|
15
|
+
is: (input: T) => URLSearchParams | null;
|
|
16
|
+
}
|
|
17
|
+
export interface IAssert<T> {
|
|
18
|
+
type: "assert";
|
|
19
|
+
assert: (input: T) => URLSearchParams;
|
|
20
|
+
}
|
|
21
|
+
export interface IValidate<T> {
|
|
22
|
+
type: "validate";
|
|
23
|
+
validate: (input: T) => IValidation<URLSearchParams>;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { IValidation } from "typia";
|
|
2
|
-
|
|
3
|
-
export type IResponseBodyStringifier<T> =
|
|
4
|
-
| IResponseBodyStringifier.IStringify<T>
|
|
5
|
-
| IResponseBodyStringifier.IIs<T>
|
|
6
|
-
| IResponseBodyStringifier.IAssert<T>
|
|
7
|
-
| IResponseBodyStringifier.IValidate<T>
|
|
8
|
-
| IResponseBodyStringifier.IValidateLog<T>;
|
|
9
|
-
export namespace IResponseBodyStringifier {
|
|
10
|
-
export interface IStringify<T> {
|
|
11
|
-
type: "stringify";
|
|
12
|
-
stringify: (input: T) => string;
|
|
13
|
-
}
|
|
14
|
-
export interface IIs<T> {
|
|
15
|
-
type: "is";
|
|
16
|
-
is: (input: T) => string | null;
|
|
17
|
-
}
|
|
18
|
-
export interface IAssert<T> {
|
|
19
|
-
type: "assert";
|
|
20
|
-
assert: (input: T) => string;
|
|
21
|
-
}
|
|
22
|
-
export interface IValidate<T> {
|
|
23
|
-
type: "validate";
|
|
24
|
-
validate: (input: T) => IValidation<string>;
|
|
25
|
-
}
|
|
26
|
-
export interface IValidateLog<T> {
|
|
27
|
-
type: "validate.log";
|
|
28
|
-
validate: (input: T) => IValidation<string>;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import { IValidation } from "typia";
|
|
2
|
+
|
|
3
|
+
export type IResponseBodyStringifier<T> =
|
|
4
|
+
| IResponseBodyStringifier.IStringify<T>
|
|
5
|
+
| IResponseBodyStringifier.IIs<T>
|
|
6
|
+
| IResponseBodyStringifier.IAssert<T>
|
|
7
|
+
| IResponseBodyStringifier.IValidate<T>
|
|
8
|
+
| IResponseBodyStringifier.IValidateLog<T>;
|
|
9
|
+
export namespace IResponseBodyStringifier {
|
|
10
|
+
export interface IStringify<T> {
|
|
11
|
+
type: "stringify";
|
|
12
|
+
stringify: (input: T) => string;
|
|
13
|
+
}
|
|
14
|
+
export interface IIs<T> {
|
|
15
|
+
type: "is";
|
|
16
|
+
is: (input: T) => string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface IAssert<T> {
|
|
19
|
+
type: "assert";
|
|
20
|
+
assert: (input: T) => string;
|
|
21
|
+
}
|
|
22
|
+
export interface IValidate<T> {
|
|
23
|
+
type: "validate";
|
|
24
|
+
validate: (input: T) => IValidation<string>;
|
|
25
|
+
}
|
|
26
|
+
export interface IValidateLog<T> {
|
|
27
|
+
type: "validate.log";
|
|
28
|
+
validate: (input: T) => IValidation<string>;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/transform.ts
CHANGED
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
/** @internal */
|
|
6
|
-
interface ITtscPluginFactoryContext {
|
|
7
|
-
projectRoot: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
interface ITtscPlugin {
|
|
12
|
-
name: string;
|
|
13
|
-
source: string;
|
|
14
|
-
composes: string[];
|
|
15
|
-
contributors?: { name: string; source: string }[];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const filename: string = currentFilename();
|
|
19
|
-
const dirname: string = path.dirname(filename);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* `@nestia/core` ttsc plugin descriptor.
|
|
23
|
-
*
|
|
24
|
-
* `@nestia/sdk` is not a standalone plugin: its Go transform is declared here
|
|
25
|
-
* as a `contributor` that ttsc statically links into this host binary, and
|
|
26
|
-
* only when `@nestia/sdk` is actually resolvable from the project. A project
|
|
27
|
-
* depending on `@nestia/core` alone never compiles any SDK transform code.
|
|
28
|
-
*/
|
|
29
|
-
export function createTtscPlugin(
|
|
30
|
-
context: ITtscPluginFactoryContext,
|
|
31
|
-
): ITtscPlugin {
|
|
32
|
-
const plugin: ITtscPlugin = {
|
|
33
|
-
name: "@nestia/core",
|
|
34
|
-
source: path.resolve(root(context), "native", "cmd", "ttsc-nestia"),
|
|
35
|
-
composes: ["typia/lib/transform"],
|
|
36
|
-
};
|
|
37
|
-
const sdk: string | null = resolveSdkContributorSource(context);
|
|
38
|
-
if (sdk !== null) plugin.contributors = [{ name: "sdk", source: sdk }];
|
|
39
|
-
return plugin;
|
|
40
|
-
}
|
|
41
|
-
export default createTtscPlugin;
|
|
42
|
-
|
|
43
|
-
function root(context: ITtscPluginFactoryContext): string {
|
|
44
|
-
return (
|
|
45
|
-
resolvePackageRoot("@nestia/core/package.json", context.projectRoot) ??
|
|
46
|
-
path.resolve(dirname, "..")
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function resolveSdkContributorSource(
|
|
51
|
-
context: ITtscPluginFactoryContext,
|
|
52
|
-
): string | null {
|
|
53
|
-
const manifest: string | null = resolvePackageRoot(
|
|
54
|
-
"@nestia/sdk/package.json",
|
|
55
|
-
context.projectRoot,
|
|
56
|
-
);
|
|
57
|
-
if (manifest === null) return null;
|
|
58
|
-
const source: string = path.resolve(manifest, "native", "sdk");
|
|
59
|
-
return fs.existsSync(source) ? source : null;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function resolvePackageRoot(
|
|
63
|
-
packageJson: string,
|
|
64
|
-
projectRoot: string,
|
|
65
|
-
): string | null {
|
|
66
|
-
try {
|
|
67
|
-
return path.dirname(
|
|
68
|
-
require.resolve(packageJson, { paths: [dirname, projectRoot] }),
|
|
69
|
-
);
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function currentFilename(): string {
|
|
76
|
-
if (
|
|
77
|
-
typeof __filename === "string" &&
|
|
78
|
-
__filename !== "[stdin]" &&
|
|
79
|
-
__filename.length !== 0
|
|
80
|
-
)
|
|
81
|
-
return normalizeFilename(__filename);
|
|
82
|
-
|
|
83
|
-
const line: string | undefined = new Error().stack
|
|
84
|
-
?.split("\n")
|
|
85
|
-
.find(
|
|
86
|
-
(entry) =>
|
|
87
|
-
entry.includes("/src/transform.ts") ||
|
|
88
|
-
entry.includes("/lib/transform.js") ||
|
|
89
|
-
entry.includes("/lib/transform.mjs"),
|
|
90
|
-
);
|
|
91
|
-
const matched: RegExpMatchArray | null | undefined = line?.match(
|
|
92
|
-
/\(([^()]+):\d+:\d+\)|at ([^\s()]+):\d+:\d+/,
|
|
93
|
-
);
|
|
94
|
-
const fallback: string = typeof __filename === "string" ? __filename : "";
|
|
95
|
-
return normalizeFilename(matched?.[1] ?? matched?.[2] ?? fallback);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function normalizeFilename(value: string): string {
|
|
99
|
-
if (value.startsWith("file:")) return fileURLToPath(value);
|
|
100
|
-
return value;
|
|
101
|
-
}
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
/** @internal */
|
|
6
|
+
interface ITtscPluginFactoryContext {
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** @internal */
|
|
11
|
+
interface ITtscPlugin {
|
|
12
|
+
name: string;
|
|
13
|
+
source: string;
|
|
14
|
+
composes: string[];
|
|
15
|
+
contributors?: { name: string; source: string }[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const filename: string = currentFilename();
|
|
19
|
+
const dirname: string = path.dirname(filename);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `@nestia/core` ttsc plugin descriptor.
|
|
23
|
+
*
|
|
24
|
+
* `@nestia/sdk` is not a standalone plugin: its Go transform is declared here
|
|
25
|
+
* as a `contributor` that ttsc statically links into this host binary, and
|
|
26
|
+
* only when `@nestia/sdk` is actually resolvable from the project. A project
|
|
27
|
+
* depending on `@nestia/core` alone never compiles any SDK transform code.
|
|
28
|
+
*/
|
|
29
|
+
export function createTtscPlugin(
|
|
30
|
+
context: ITtscPluginFactoryContext,
|
|
31
|
+
): ITtscPlugin {
|
|
32
|
+
const plugin: ITtscPlugin = {
|
|
33
|
+
name: "@nestia/core",
|
|
34
|
+
source: path.resolve(root(context), "native", "cmd", "ttsc-nestia"),
|
|
35
|
+
composes: ["typia/lib/transform"],
|
|
36
|
+
};
|
|
37
|
+
const sdk: string | null = resolveSdkContributorSource(context);
|
|
38
|
+
if (sdk !== null) plugin.contributors = [{ name: "sdk", source: sdk }];
|
|
39
|
+
return plugin;
|
|
40
|
+
}
|
|
41
|
+
export default createTtscPlugin;
|
|
42
|
+
|
|
43
|
+
function root(context: ITtscPluginFactoryContext): string {
|
|
44
|
+
return (
|
|
45
|
+
resolvePackageRoot("@nestia/core/package.json", context.projectRoot) ??
|
|
46
|
+
path.resolve(dirname, "..")
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function resolveSdkContributorSource(
|
|
51
|
+
context: ITtscPluginFactoryContext,
|
|
52
|
+
): string | null {
|
|
53
|
+
const manifest: string | null = resolvePackageRoot(
|
|
54
|
+
"@nestia/sdk/package.json",
|
|
55
|
+
context.projectRoot,
|
|
56
|
+
);
|
|
57
|
+
if (manifest === null) return null;
|
|
58
|
+
const source: string = path.resolve(manifest, "native", "sdk");
|
|
59
|
+
return fs.existsSync(source) ? source : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function resolvePackageRoot(
|
|
63
|
+
packageJson: string,
|
|
64
|
+
projectRoot: string,
|
|
65
|
+
): string | null {
|
|
66
|
+
try {
|
|
67
|
+
return path.dirname(
|
|
68
|
+
require.resolve(packageJson, { paths: [dirname, projectRoot] }),
|
|
69
|
+
);
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function currentFilename(): string {
|
|
76
|
+
if (
|
|
77
|
+
typeof __filename === "string" &&
|
|
78
|
+
__filename !== "[stdin]" &&
|
|
79
|
+
__filename.length !== 0
|
|
80
|
+
)
|
|
81
|
+
return normalizeFilename(__filename);
|
|
82
|
+
|
|
83
|
+
const line: string | undefined = new Error().stack
|
|
84
|
+
?.split("\n")
|
|
85
|
+
.find(
|
|
86
|
+
(entry) =>
|
|
87
|
+
entry.includes("/src/transform.ts") ||
|
|
88
|
+
entry.includes("/lib/transform.js") ||
|
|
89
|
+
entry.includes("/lib/transform.mjs"),
|
|
90
|
+
);
|
|
91
|
+
const matched: RegExpMatchArray | null | undefined = line?.match(
|
|
92
|
+
/\(([^()]+):\d+:\d+\)|at ([^\s()]+):\d+:\d+/,
|
|
93
|
+
);
|
|
94
|
+
const fallback: string = typeof __filename === "string" ? __filename : "";
|
|
95
|
+
return normalizeFilename(matched?.[1] ?? matched?.[2] ?? fallback);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function normalizeFilename(value: string): string {
|
|
99
|
+
if (value.startsWith("file:")) return fileURLToPath(value);
|
|
100
|
+
return value;
|
|
101
|
+
}
|
package/src/typings/Creator.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type Creator<T extends object> = {
|
|
2
|
-
new (...args: any[]): T;
|
|
3
|
-
};
|
|
1
|
+
export type Creator<T extends object> = {
|
|
2
|
+
new (...args: any[]): T;
|
|
3
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare module "get-function-location" {
|
|
2
|
-
export default function (func: any): Promise<{
|
|
3
|
-
source: string;
|
|
4
|
-
line: number;
|
|
5
|
-
column: number;
|
|
6
|
-
}>;
|
|
7
|
-
}
|
|
1
|
+
declare module "get-function-location" {
|
|
2
|
+
export default function (func: any): Promise<{
|
|
3
|
+
source: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
package/src/utils/ArrayUtil.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export namespace ArrayUtil {
|
|
2
|
-
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
-
return items.every(
|
|
4
|
-
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
-
);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
export namespace ArrayUtil {
|
|
2
|
+
export function has<T>(array: T[], ...items: T[]): boolean {
|
|
3
|
+
return items.every(
|
|
4
|
+
(elem) => array.find((org) => org === elem) !== undefined,
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
}
|