@nestia/core 11.0.0-dev.20260313-4 → 11.0.0-dev.20260316
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/options/INestiaTransformOptions.d.ts +1 -1
- package/lib/programmers/PlainBodyProgrammer.js +1 -1
- package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedBodyProgrammer.js +6 -3
- package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryBodyProgrammer.js +9 -4
- package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryProgrammer.js +9 -4
- package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
- package/lib/programmers/TypedQueryRouteProgrammer.js +14 -8
- package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
- package/lib/programmers/TypedRouteProgrammer.js +11 -6
- package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
- package/package.json +8 -8
- package/src/decorators/DynamicModule.ts +44 -44
- package/src/decorators/PlainBody.ts +76 -76
- package/src/decorators/SwaggerExample.ts +100 -100
- package/src/decorators/TypedBody.ts +57 -57
- package/src/decorators/TypedException.ts +147 -147
- package/src/decorators/TypedHeaders.ts +66 -66
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +234 -234
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/internal/EncryptedConstant.ts +2 -2
- package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
- package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
- 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/is_request_body_undefined.ts +12 -12
- package/src/decorators/internal/load_controller.ts +45 -45
- 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 +64 -64
- package/src/index.ts +5 -5
- package/src/options/INestiaTransformOptions.ts +1 -1
- 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/programmers/PlainBodyProgrammer.ts +1 -1
- package/src/programmers/TypedBodyProgrammer.ts +7 -3
- package/src/programmers/TypedQueryBodyProgrammer.ts +11 -9
- package/src/programmers/TypedQueryProgrammer.ts +11 -9
- package/src/programmers/TypedQueryRouteProgrammer.ts +19 -16
- package/src/programmers/TypedRouteProgrammer.ts +14 -7
- package/src/transformers/NodeTransformer.ts +23 -23
- package/src/transformers/ParameterTransformer.ts +57 -57
- 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
|
@@ -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
|
+
}
|
|
@@ -28,12 +28,16 @@ export namespace TypedBodyProgrammer {
|
|
|
28
28
|
transformer: props.context.transformer,
|
|
29
29
|
type: props.type,
|
|
30
30
|
validate: props.context.options.llm
|
|
31
|
-
? (
|
|
31
|
+
? (next) =>
|
|
32
32
|
LlmSchemaProgrammer.validate({
|
|
33
33
|
config: {
|
|
34
|
-
strict:
|
|
34
|
+
strict:
|
|
35
|
+
typeof props.context.options.llm === "boolean"
|
|
36
|
+
? false
|
|
37
|
+
: (props.context.options.llm?.strict ?? false),
|
|
35
38
|
},
|
|
36
|
-
metadata,
|
|
39
|
+
metadata: next.metadata,
|
|
40
|
+
explore: next.explore,
|
|
37
41
|
})
|
|
38
42
|
: undefined,
|
|
39
43
|
});
|
|
@@ -25,7 +25,8 @@ export namespace TypedQueryBodyProgrammer {
|
|
|
25
25
|
}): ts.ObjectLiteralExpression => {
|
|
26
26
|
// VALIDATE TYPE
|
|
27
27
|
if (props.context.options.llm) {
|
|
28
|
-
const llm: INestiaTransformOptions.ILlm =
|
|
28
|
+
const llm: INestiaTransformOptions.ILlm | true =
|
|
29
|
+
props.context.options.llm;
|
|
29
30
|
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
30
31
|
MetadataFactory.analyze({
|
|
31
32
|
checker: props.context.checker,
|
|
@@ -34,18 +35,19 @@ export namespace TypedQueryBodyProgrammer {
|
|
|
34
35
|
escape: false,
|
|
35
36
|
constant: true,
|
|
36
37
|
absorb: true,
|
|
37
|
-
validate: (
|
|
38
|
-
const errors: string[] = HttpQueryProgrammer.validate(
|
|
39
|
-
|
|
40
|
-
explore,
|
|
41
|
-
true,
|
|
42
|
-
);
|
|
38
|
+
validate: (next) => {
|
|
39
|
+
const errors: string[] = HttpQueryProgrammer.validate({
|
|
40
|
+
metadata: next.metadata,
|
|
41
|
+
explore: next.explore,
|
|
42
|
+
allowOptional: true,
|
|
43
|
+
});
|
|
43
44
|
errors.push(
|
|
44
45
|
...LlmSchemaProgrammer.validate({
|
|
45
46
|
config: {
|
|
46
|
-
strict: llm.strict ?? false,
|
|
47
|
+
strict: llm === true ? false : (llm.strict ?? false),
|
|
47
48
|
},
|
|
48
|
-
metadata:
|
|
49
|
+
metadata: next.metadata,
|
|
50
|
+
explore: next.explore,
|
|
49
51
|
}),
|
|
50
52
|
);
|
|
51
53
|
return errors;
|
|
@@ -25,7 +25,8 @@ export namespace TypedQueryProgrammer {
|
|
|
25
25
|
}): ts.Expression => {
|
|
26
26
|
// VALIDATE TYPE
|
|
27
27
|
if (props.context.options.llm) {
|
|
28
|
-
const llm: INestiaTransformOptions.ILlm =
|
|
28
|
+
const llm: INestiaTransformOptions.ILlm | true =
|
|
29
|
+
props.context.options.llm;
|
|
29
30
|
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
30
31
|
MetadataFactory.analyze({
|
|
31
32
|
checker: props.context.checker,
|
|
@@ -34,18 +35,19 @@ export namespace TypedQueryProgrammer {
|
|
|
34
35
|
escape: false,
|
|
35
36
|
constant: true,
|
|
36
37
|
absorb: true,
|
|
37
|
-
validate: (
|
|
38
|
-
const errors: string[] = HttpQueryProgrammer.validate(
|
|
39
|
-
|
|
40
|
-
explore,
|
|
41
|
-
true,
|
|
42
|
-
);
|
|
38
|
+
validate: (next) => {
|
|
39
|
+
const errors: string[] = HttpQueryProgrammer.validate({
|
|
40
|
+
metadata: next.metadata,
|
|
41
|
+
explore: next.explore,
|
|
42
|
+
allowOptional: true,
|
|
43
|
+
});
|
|
43
44
|
errors.push(
|
|
44
45
|
...LlmSchemaProgrammer.validate({
|
|
45
46
|
config: {
|
|
46
|
-
strict: llm.strict ?? false,
|
|
47
|
+
strict: llm === true ? false : (llm.strict ?? false),
|
|
47
48
|
},
|
|
48
|
-
metadata:
|
|
49
|
+
metadata: next.metadata,
|
|
50
|
+
explore: next.explore,
|
|
49
51
|
}),
|
|
50
52
|
);
|
|
51
53
|
return errors;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpQueryProgrammer,
|
|
3
3
|
ITypiaContext,
|
|
4
|
-
|
|
4
|
+
LlmParametersProgrammer,
|
|
5
5
|
MetadataCollection,
|
|
6
6
|
MetadataFactory,
|
|
7
7
|
MetadataSchema,
|
|
@@ -25,7 +25,8 @@ export namespace TypedQueryRouteProgrammer {
|
|
|
25
25
|
}): ts.Expression => {
|
|
26
26
|
// VALIDATE TYPE
|
|
27
27
|
if (props.context.options.llm) {
|
|
28
|
-
const llm: INestiaTransformOptions.ILlm =
|
|
28
|
+
const llm: INestiaTransformOptions.ILlm | true =
|
|
29
|
+
props.context.options.llm;
|
|
29
30
|
const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
|
|
30
31
|
MetadataFactory.analyze({
|
|
31
32
|
checker: props.context.checker,
|
|
@@ -34,20 +35,22 @@ export namespace TypedQueryRouteProgrammer {
|
|
|
34
35
|
escape: false,
|
|
35
36
|
constant: true,
|
|
36
37
|
absorb: true,
|
|
37
|
-
validate: (
|
|
38
|
-
const errors: string[] = HttpQueryProgrammer.validate(
|
|
39
|
-
|
|
40
|
-
explore,
|
|
41
|
-
true,
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
validate: (next) => {
|
|
39
|
+
const errors: string[] = HttpQueryProgrammer.validate({
|
|
40
|
+
metadata: next.metadata,
|
|
41
|
+
explore: next.explore,
|
|
42
|
+
allowOptional: true,
|
|
43
|
+
});
|
|
44
|
+
if (next.metadata.size() !== 0)
|
|
45
|
+
errors.push(
|
|
46
|
+
...LlmParametersProgrammer.validate({
|
|
47
|
+
config: {
|
|
48
|
+
strict: llm === true ? false : (llm.strict ?? false),
|
|
49
|
+
},
|
|
50
|
+
metadata: next.metadata,
|
|
51
|
+
explore: next.explore,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
51
54
|
return errors;
|
|
52
55
|
},
|
|
53
56
|
},
|
|
@@ -5,10 +5,11 @@ import {
|
|
|
5
5
|
JsonMetadataFactory,
|
|
6
6
|
JsonStringifyProgrammer,
|
|
7
7
|
JsonValidateStringifyProgrammer,
|
|
8
|
-
|
|
8
|
+
LlmParametersProgrammer,
|
|
9
9
|
} from "@typia/core";
|
|
10
10
|
import ts from "typescript";
|
|
11
11
|
|
|
12
|
+
import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
|
|
12
13
|
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
13
14
|
|
|
14
15
|
export namespace TypedRouteProgrammer {
|
|
@@ -18,20 +19,26 @@ export namespace TypedRouteProgrammer {
|
|
|
18
19
|
type: ts.Type;
|
|
19
20
|
}): ts.Expression => {
|
|
20
21
|
// VALIDATE TYPE
|
|
21
|
-
if (props.context.options.llm)
|
|
22
|
+
if (props.context.options.llm) {
|
|
23
|
+
const llm: INestiaTransformOptions.ILlm | true =
|
|
24
|
+
props.context.options.llm;
|
|
22
25
|
JsonMetadataFactory.analyze({
|
|
23
26
|
method: "@nestia.core.TypedRoute",
|
|
24
27
|
checker: props.context.checker,
|
|
25
28
|
transformer: props.context.transformer,
|
|
26
29
|
type: props.type,
|
|
27
|
-
validate: (
|
|
28
|
-
|
|
30
|
+
validate: (next) => {
|
|
31
|
+
if (next.metadata.size() === 0) return [];
|
|
32
|
+
return LlmParametersProgrammer.validate({
|
|
29
33
|
config: {
|
|
30
|
-
strict:
|
|
34
|
+
strict: llm === true ? false : (llm.strict ?? false),
|
|
31
35
|
},
|
|
32
|
-
metadata,
|
|
33
|
-
|
|
36
|
+
metadata: next.metadata,
|
|
37
|
+
explore: next.explore,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
34
40
|
});
|
|
41
|
+
}
|
|
35
42
|
|
|
36
43
|
// GENERATE STRINGIFY PLAN
|
|
37
44
|
const parameter = (next: {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
4
|
-
import { MethodTransformer } from "./MethodTransformer";
|
|
5
|
-
import { ParameterTransformer } from "./ParameterTransformer";
|
|
6
|
-
|
|
7
|
-
export namespace NodeTransformer {
|
|
8
|
-
export const transform = (props: {
|
|
9
|
-
context: INestiaTransformContext;
|
|
10
|
-
node: ts.Node;
|
|
11
|
-
}): ts.Node =>
|
|
12
|
-
ts.isMethodDeclaration(props.node)
|
|
13
|
-
? MethodTransformer.transform({
|
|
14
|
-
context: props.context,
|
|
15
|
-
method: props.node,
|
|
16
|
-
})
|
|
17
|
-
: ts.isParameter(props.node)
|
|
18
|
-
? ParameterTransformer.transform({
|
|
19
|
-
context: props.context,
|
|
20
|
-
param: props.node,
|
|
21
|
-
})
|
|
22
|
-
: props.node;
|
|
23
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
4
|
+
import { MethodTransformer } from "./MethodTransformer";
|
|
5
|
+
import { ParameterTransformer } from "./ParameterTransformer";
|
|
6
|
+
|
|
7
|
+
export namespace NodeTransformer {
|
|
8
|
+
export const transform = (props: {
|
|
9
|
+
context: INestiaTransformContext;
|
|
10
|
+
node: ts.Node;
|
|
11
|
+
}): ts.Node =>
|
|
12
|
+
ts.isMethodDeclaration(props.node)
|
|
13
|
+
? MethodTransformer.transform({
|
|
14
|
+
context: props.context,
|
|
15
|
+
method: props.node,
|
|
16
|
+
})
|
|
17
|
+
: ts.isParameter(props.node)
|
|
18
|
+
? ParameterTransformer.transform({
|
|
19
|
+
context: props.context,
|
|
20
|
+
param: props.node,
|
|
21
|
+
})
|
|
22
|
+
: props.node;
|
|
23
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
|
|
3
|
-
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
4
|
-
import { ParameterDecoratorTransformer } from "./ParameterDecoratorTransformer";
|
|
5
|
-
|
|
6
|
-
export namespace ParameterTransformer {
|
|
7
|
-
export const transform = (props: {
|
|
8
|
-
context: INestiaTransformContext;
|
|
9
|
-
param: ts.ParameterDeclaration;
|
|
10
|
-
}): ts.ParameterDeclaration => {
|
|
11
|
-
// CHECK DECORATOR
|
|
12
|
-
const decorators: readonly ts.Decorator[] | undefined = ts.getDecorators
|
|
13
|
-
? ts.getDecorators(props.param)
|
|
14
|
-
: (props.param as any).decorators;
|
|
15
|
-
if (!decorators?.length) return props.param;
|
|
16
|
-
|
|
17
|
-
// GET TYPE INFO
|
|
18
|
-
const type: ts.Type = props.context.checker.getTypeAtLocation(props.param);
|
|
19
|
-
|
|
20
|
-
// WHEN LATEST TS VERSION
|
|
21
|
-
if (ts.getDecorators !== undefined)
|
|
22
|
-
return ts.factory.updateParameterDeclaration(
|
|
23
|
-
props.param,
|
|
24
|
-
(props.param.modifiers || []).map((mod) =>
|
|
25
|
-
ts.isDecorator(mod)
|
|
26
|
-
? ParameterDecoratorTransformer.transform({
|
|
27
|
-
context: props.context,
|
|
28
|
-
decorator: mod,
|
|
29
|
-
type,
|
|
30
|
-
})
|
|
31
|
-
: mod,
|
|
32
|
-
),
|
|
33
|
-
props.param.dotDotDotToken,
|
|
34
|
-
props.param.name,
|
|
35
|
-
props.param.questionToken,
|
|
36
|
-
props.param.type,
|
|
37
|
-
props.param.initializer,
|
|
38
|
-
);
|
|
39
|
-
// eslint-disable-next-line
|
|
40
|
-
return (ts.factory.updateParameterDeclaration as any)(
|
|
41
|
-
props.param,
|
|
42
|
-
decorators.map((deco) =>
|
|
43
|
-
ParameterDecoratorTransformer.transform({
|
|
44
|
-
context: props.context,
|
|
45
|
-
decorator: deco,
|
|
46
|
-
type,
|
|
47
|
-
}),
|
|
48
|
-
),
|
|
49
|
-
(props.param as any).modifiers,
|
|
50
|
-
props.param.dotDotDotToken,
|
|
51
|
-
props.param.name,
|
|
52
|
-
props.param.questionToken,
|
|
53
|
-
props.param.type,
|
|
54
|
-
props.param.initializer,
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
|
|
3
|
+
import { INestiaTransformContext } from "../options/INestiaTransformProject";
|
|
4
|
+
import { ParameterDecoratorTransformer } from "./ParameterDecoratorTransformer";
|
|
5
|
+
|
|
6
|
+
export namespace ParameterTransformer {
|
|
7
|
+
export const transform = (props: {
|
|
8
|
+
context: INestiaTransformContext;
|
|
9
|
+
param: ts.ParameterDeclaration;
|
|
10
|
+
}): ts.ParameterDeclaration => {
|
|
11
|
+
// CHECK DECORATOR
|
|
12
|
+
const decorators: readonly ts.Decorator[] | undefined = ts.getDecorators
|
|
13
|
+
? ts.getDecorators(props.param)
|
|
14
|
+
: (props.param as any).decorators;
|
|
15
|
+
if (!decorators?.length) return props.param;
|
|
16
|
+
|
|
17
|
+
// GET TYPE INFO
|
|
18
|
+
const type: ts.Type = props.context.checker.getTypeAtLocation(props.param);
|
|
19
|
+
|
|
20
|
+
// WHEN LATEST TS VERSION
|
|
21
|
+
if (ts.getDecorators !== undefined)
|
|
22
|
+
return ts.factory.updateParameterDeclaration(
|
|
23
|
+
props.param,
|
|
24
|
+
(props.param.modifiers || []).map((mod) =>
|
|
25
|
+
ts.isDecorator(mod)
|
|
26
|
+
? ParameterDecoratorTransformer.transform({
|
|
27
|
+
context: props.context,
|
|
28
|
+
decorator: mod,
|
|
29
|
+
type,
|
|
30
|
+
})
|
|
31
|
+
: mod,
|
|
32
|
+
),
|
|
33
|
+
props.param.dotDotDotToken,
|
|
34
|
+
props.param.name,
|
|
35
|
+
props.param.questionToken,
|
|
36
|
+
props.param.type,
|
|
37
|
+
props.param.initializer,
|
|
38
|
+
);
|
|
39
|
+
// eslint-disable-next-line
|
|
40
|
+
return (ts.factory.updateParameterDeclaration as any)(
|
|
41
|
+
props.param,
|
|
42
|
+
decorators.map((deco) =>
|
|
43
|
+
ParameterDecoratorTransformer.transform({
|
|
44
|
+
context: props.context,
|
|
45
|
+
decorator: deco,
|
|
46
|
+
type,
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
(props.param as any).modifiers,
|
|
50
|
+
props.param.dotDotDotToken,
|
|
51
|
+
props.param.name,
|
|
52
|
+
props.param.questionToken,
|
|
53
|
+
props.param.type,
|
|
54
|
+
props.param.initializer,
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
}
|
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
|
+
}
|