@nestia/core 7.0.0-dev.20250607 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +92 -92
- package/package.json +3 -3
- package/src/adaptors/WebSocketAdaptor.ts +429 -429
- package/src/decorators/DynamicModule.ts +43 -43
- package/src/decorators/EncryptedBody.ts +101 -101
- package/src/decorators/EncryptedController.ts +38 -38
- package/src/decorators/EncryptedModule.ts +100 -100
- package/src/decorators/EncryptedRoute.ts +219 -219
- package/src/decorators/HumanRoute.ts +22 -22
- package/src/decorators/NoTransformConfigurationError.ts +32 -32
- package/src/decorators/PlainBody.ts +79 -79
- package/src/decorators/SwaggerCustomizer.ts +115 -115
- package/src/decorators/SwaggerExample.ts +100 -100
- package/src/decorators/TypedBody.ts +59 -59
- package/src/decorators/TypedException.ts +166 -166
- package/src/decorators/TypedFormData.ts +195 -195
- package/src/decorators/TypedHeaders.ts +64 -64
- package/src/decorators/TypedParam.ts +77 -77
- package/src/decorators/TypedQuery.ts +245 -245
- package/src/decorators/TypedRoute.ts +214 -214
- package/src/decorators/WebSocketRoute.ts +242 -242
- package/src/decorators/internal/EncryptedConstant.ts +4 -4
- 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 +108 -108
- package/src/decorators/internal/get_path_and_stringify.ts +122 -122
- package/src/decorators/internal/get_text_body.ts +20 -20
- package/src/decorators/internal/headers_to_object.ts +13 -13
- package/src/decorators/internal/is_request_body_undefined.ts +14 -14
- package/src/decorators/internal/load_controller.ts +49 -49
- package/src/decorators/internal/route_error.ts +45 -45
- package/src/decorators/internal/validate_request_body.ts +74 -74
- package/src/decorators/internal/validate_request_form_data.ts +77 -77
- package/src/decorators/internal/validate_request_headers.ts +86 -86
- package/src/decorators/internal/validate_request_query.ts +74 -74
- package/src/index.ts +5 -5
- package/src/module.ts +22 -22
- package/src/options/INestiaTransformOptions.ts +38 -38
- package/src/options/INestiaTransformProject.ts +8 -8
- 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 +70 -70
- package/src/programmers/TypedBodyProgrammer.ts +142 -142
- package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
- package/src/programmers/TypedHeadersProgrammer.ts +63 -63
- package/src/programmers/TypedParamProgrammer.ts +33 -33
- package/src/programmers/TypedQueryBodyProgrammer.ts +112 -112
- package/src/programmers/TypedQueryProgrammer.ts +114 -114
- package/src/programmers/TypedQueryRouteProgrammer.ts +105 -105
- package/src/programmers/TypedRouteProgrammer.ts +94 -94
- package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +72 -72
- package/src/programmers/http/HttpIsQuerifyProgrammer.ts +75 -75
- package/src/programmers/http/HttpQuerifyProgrammer.ts +108 -108
- package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +76 -76
- package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
- package/src/transform.ts +35 -35
- package/src/transformers/FileTransformer.ts +110 -110
- package/src/transformers/MethodTransformer.ts +103 -103
- package/src/transformers/NodeTransformer.ts +23 -23
- package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
- package/src/transformers/ParameterTransformer.ts +57 -57
- package/src/transformers/TypedRouteTransformer.ts +85 -85
- package/src/transformers/WebSocketRouteTransformer.ts +120 -120
- 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 +112 -112
- package/src/utils/Singleton.ts +20 -20
- package/src/utils/SourceFinder.ts +57 -57
- package/src/utils/VersioningStrategy.ts +27 -27
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
-
import { IsProgrammer } from "typia/lib/programmers/IsProgrammer";
|
|
5
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpIsQuerifyProgrammer {
|
|
10
|
-
export const write = (props: {
|
|
11
|
-
context: ITypiaContext;
|
|
12
|
-
modulo: ts.LeftHandSideExpression;
|
|
13
|
-
type: ts.Type;
|
|
14
|
-
}): ts.ArrowFunction =>
|
|
15
|
-
ts.factory.createArrowFunction(
|
|
16
|
-
undefined,
|
|
17
|
-
undefined,
|
|
18
|
-
[IdentifierFactory.parameter("input")],
|
|
19
|
-
undefined,
|
|
20
|
-
undefined,
|
|
21
|
-
ts.factory.createBlock([
|
|
22
|
-
StatementFactory.constant({
|
|
23
|
-
name: "is",
|
|
24
|
-
value: IsProgrammer.write({
|
|
25
|
-
config: {
|
|
26
|
-
equals: false,
|
|
27
|
-
},
|
|
28
|
-
context: {
|
|
29
|
-
...props.context,
|
|
30
|
-
options: {
|
|
31
|
-
...props.context.options,
|
|
32
|
-
functional: false,
|
|
33
|
-
numeric: false,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
modulo: props.modulo,
|
|
37
|
-
type: props.type,
|
|
38
|
-
name: undefined,
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
StatementFactory.constant({
|
|
42
|
-
name: "stringify",
|
|
43
|
-
value: HttpQuerifyProgrammer.write({
|
|
44
|
-
context: {
|
|
45
|
-
...props.context,
|
|
46
|
-
options: {
|
|
47
|
-
...props.context.options,
|
|
48
|
-
functional: false,
|
|
49
|
-
numeric: false,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
modulo: props.modulo,
|
|
53
|
-
type: props.type,
|
|
54
|
-
}),
|
|
55
|
-
}),
|
|
56
|
-
ts.factory.createReturnStatement(
|
|
57
|
-
ts.factory.createConditionalExpression(
|
|
58
|
-
ts.factory.createCallExpression(
|
|
59
|
-
ts.factory.createIdentifier("is"),
|
|
60
|
-
undefined,
|
|
61
|
-
[ts.factory.createIdentifier("input")],
|
|
62
|
-
),
|
|
63
|
-
undefined,
|
|
64
|
-
ts.factory.createCallExpression(
|
|
65
|
-
ts.factory.createIdentifier("stringify"),
|
|
66
|
-
undefined,
|
|
67
|
-
[ts.factory.createIdentifier("input")],
|
|
68
|
-
),
|
|
69
|
-
undefined,
|
|
70
|
-
ts.factory.createNull(),
|
|
71
|
-
),
|
|
72
|
-
),
|
|
73
|
-
]),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
+
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
+
import { IsProgrammer } from "typia/lib/programmers/IsProgrammer";
|
|
5
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpIsQuerifyProgrammer {
|
|
10
|
+
export const write = (props: {
|
|
11
|
+
context: ITypiaContext;
|
|
12
|
+
modulo: ts.LeftHandSideExpression;
|
|
13
|
+
type: ts.Type;
|
|
14
|
+
}): ts.ArrowFunction =>
|
|
15
|
+
ts.factory.createArrowFunction(
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
[IdentifierFactory.parameter("input")],
|
|
19
|
+
undefined,
|
|
20
|
+
undefined,
|
|
21
|
+
ts.factory.createBlock([
|
|
22
|
+
StatementFactory.constant({
|
|
23
|
+
name: "is",
|
|
24
|
+
value: IsProgrammer.write({
|
|
25
|
+
config: {
|
|
26
|
+
equals: false,
|
|
27
|
+
},
|
|
28
|
+
context: {
|
|
29
|
+
...props.context,
|
|
30
|
+
options: {
|
|
31
|
+
...props.context.options,
|
|
32
|
+
functional: false,
|
|
33
|
+
numeric: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
modulo: props.modulo,
|
|
37
|
+
type: props.type,
|
|
38
|
+
name: undefined,
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
StatementFactory.constant({
|
|
42
|
+
name: "stringify",
|
|
43
|
+
value: HttpQuerifyProgrammer.write({
|
|
44
|
+
context: {
|
|
45
|
+
...props.context,
|
|
46
|
+
options: {
|
|
47
|
+
...props.context.options,
|
|
48
|
+
functional: false,
|
|
49
|
+
numeric: false,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
modulo: props.modulo,
|
|
53
|
+
type: props.type,
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
ts.factory.createReturnStatement(
|
|
57
|
+
ts.factory.createConditionalExpression(
|
|
58
|
+
ts.factory.createCallExpression(
|
|
59
|
+
ts.factory.createIdentifier("is"),
|
|
60
|
+
undefined,
|
|
61
|
+
[ts.factory.createIdentifier("input")],
|
|
62
|
+
),
|
|
63
|
+
undefined,
|
|
64
|
+
ts.factory.createCallExpression(
|
|
65
|
+
ts.factory.createIdentifier("stringify"),
|
|
66
|
+
undefined,
|
|
67
|
+
[ts.factory.createIdentifier("input")],
|
|
68
|
+
),
|
|
69
|
+
undefined,
|
|
70
|
+
ts.factory.createNull(),
|
|
71
|
+
),
|
|
72
|
+
),
|
|
73
|
+
]),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
-
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
-
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
6
|
-
import { FunctionProgrammer } from "typia/lib/programmers/helpers/FunctionProgrammer";
|
|
7
|
-
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
|
|
8
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
9
|
-
import { MetadataObject } from "typia/lib/schemas/metadata/MetadataObject";
|
|
10
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
11
|
-
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
12
|
-
|
|
13
|
-
export namespace HttpQuerifyProgrammer {
|
|
14
|
-
export const write = (props: {
|
|
15
|
-
context: ITypiaContext;
|
|
16
|
-
modulo: ts.LeftHandSideExpression;
|
|
17
|
-
type: ts.Type;
|
|
18
|
-
}): ts.ArrowFunction => {
|
|
19
|
-
// GET OBJECT TYPE
|
|
20
|
-
const functor: FunctionProgrammer = new FunctionProgrammer(
|
|
21
|
-
props.modulo.getText(),
|
|
22
|
-
);
|
|
23
|
-
const collection: MetadataCollection = new MetadataCollection();
|
|
24
|
-
const result = MetadataFactory.analyze({
|
|
25
|
-
checker: props.context.checker,
|
|
26
|
-
transformer: props.context.transformer,
|
|
27
|
-
options: {
|
|
28
|
-
escape: false,
|
|
29
|
-
constant: true,
|
|
30
|
-
absorb: true,
|
|
31
|
-
validate: HttpQueryProgrammer.validate,
|
|
32
|
-
},
|
|
33
|
-
type: props.type,
|
|
34
|
-
collection,
|
|
35
|
-
});
|
|
36
|
-
if (result.success === false)
|
|
37
|
-
throw TransformerError.from({
|
|
38
|
-
code: functor.method,
|
|
39
|
-
errors: result.errors,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const object: MetadataObject = result.data.objects[0]!;
|
|
43
|
-
return ts.factory.createArrowFunction(
|
|
44
|
-
undefined,
|
|
45
|
-
undefined,
|
|
46
|
-
[IdentifierFactory.parameter("input")],
|
|
47
|
-
undefined,
|
|
48
|
-
undefined,
|
|
49
|
-
ts.factory.createBlock(
|
|
50
|
-
[
|
|
51
|
-
...functor.declare(),
|
|
52
|
-
StatementFactory.constant({
|
|
53
|
-
name: "output",
|
|
54
|
-
value: ts.factory.createNewExpression(
|
|
55
|
-
ts.factory.createIdentifier("URLSearchParams"),
|
|
56
|
-
undefined,
|
|
57
|
-
[],
|
|
58
|
-
),
|
|
59
|
-
}),
|
|
60
|
-
...object.type.properties.map((p) =>
|
|
61
|
-
ts.factory.createExpressionStatement(
|
|
62
|
-
decode(p.key.constants[0]!.values[0].value as string)(p.value),
|
|
63
|
-
),
|
|
64
|
-
),
|
|
65
|
-
ts.factory.createReturnStatement(
|
|
66
|
-
ts.factory.createIdentifier("output"),
|
|
67
|
-
),
|
|
68
|
-
],
|
|
69
|
-
true,
|
|
70
|
-
),
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const decode =
|
|
75
|
-
(key: string) =>
|
|
76
|
-
(value: Metadata): ts.CallExpression =>
|
|
77
|
-
!!value.arrays.length
|
|
78
|
-
? ts.factory.createCallExpression(
|
|
79
|
-
IdentifierFactory.access(
|
|
80
|
-
IdentifierFactory.access(
|
|
81
|
-
ts.factory.createIdentifier("input"),
|
|
82
|
-
key,
|
|
83
|
-
),
|
|
84
|
-
"forEach",
|
|
85
|
-
),
|
|
86
|
-
undefined,
|
|
87
|
-
[
|
|
88
|
-
ts.factory.createArrowFunction(
|
|
89
|
-
undefined,
|
|
90
|
-
undefined,
|
|
91
|
-
[IdentifierFactory.parameter("elem")],
|
|
92
|
-
undefined,
|
|
93
|
-
undefined,
|
|
94
|
-
append(key)(ts.factory.createIdentifier("elem")),
|
|
95
|
-
),
|
|
96
|
-
],
|
|
97
|
-
)
|
|
98
|
-
: append(key)(
|
|
99
|
-
IdentifierFactory.access(ts.factory.createIdentifier("input"), key),
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const append = (key: string) => (elem: ts.Expression) =>
|
|
103
|
-
ts.factory.createCallExpression(
|
|
104
|
-
IdentifierFactory.access(ts.factory.createIdentifier("output"), "append"),
|
|
105
|
-
undefined,
|
|
106
|
-
[ts.factory.createStringLiteral(key), elem],
|
|
107
|
-
);
|
|
108
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
+
import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
|
|
4
|
+
import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
|
|
5
|
+
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
6
|
+
import { FunctionProgrammer } from "typia/lib/programmers/helpers/FunctionProgrammer";
|
|
7
|
+
import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
|
|
8
|
+
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
9
|
+
import { MetadataObject } from "typia/lib/schemas/metadata/MetadataObject";
|
|
10
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
11
|
+
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
12
|
+
|
|
13
|
+
export namespace HttpQuerifyProgrammer {
|
|
14
|
+
export const write = (props: {
|
|
15
|
+
context: ITypiaContext;
|
|
16
|
+
modulo: ts.LeftHandSideExpression;
|
|
17
|
+
type: ts.Type;
|
|
18
|
+
}): ts.ArrowFunction => {
|
|
19
|
+
// GET OBJECT TYPE
|
|
20
|
+
const functor: FunctionProgrammer = new FunctionProgrammer(
|
|
21
|
+
props.modulo.getText(),
|
|
22
|
+
);
|
|
23
|
+
const collection: MetadataCollection = new MetadataCollection();
|
|
24
|
+
const result = MetadataFactory.analyze({
|
|
25
|
+
checker: props.context.checker,
|
|
26
|
+
transformer: props.context.transformer,
|
|
27
|
+
options: {
|
|
28
|
+
escape: false,
|
|
29
|
+
constant: true,
|
|
30
|
+
absorb: true,
|
|
31
|
+
validate: HttpQueryProgrammer.validate,
|
|
32
|
+
},
|
|
33
|
+
type: props.type,
|
|
34
|
+
collection,
|
|
35
|
+
});
|
|
36
|
+
if (result.success === false)
|
|
37
|
+
throw TransformerError.from({
|
|
38
|
+
code: functor.method,
|
|
39
|
+
errors: result.errors,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const object: MetadataObject = result.data.objects[0]!;
|
|
43
|
+
return ts.factory.createArrowFunction(
|
|
44
|
+
undefined,
|
|
45
|
+
undefined,
|
|
46
|
+
[IdentifierFactory.parameter("input")],
|
|
47
|
+
undefined,
|
|
48
|
+
undefined,
|
|
49
|
+
ts.factory.createBlock(
|
|
50
|
+
[
|
|
51
|
+
...functor.declare(),
|
|
52
|
+
StatementFactory.constant({
|
|
53
|
+
name: "output",
|
|
54
|
+
value: ts.factory.createNewExpression(
|
|
55
|
+
ts.factory.createIdentifier("URLSearchParams"),
|
|
56
|
+
undefined,
|
|
57
|
+
[],
|
|
58
|
+
),
|
|
59
|
+
}),
|
|
60
|
+
...object.type.properties.map((p) =>
|
|
61
|
+
ts.factory.createExpressionStatement(
|
|
62
|
+
decode(p.key.constants[0]!.values[0].value as string)(p.value),
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
ts.factory.createReturnStatement(
|
|
66
|
+
ts.factory.createIdentifier("output"),
|
|
67
|
+
),
|
|
68
|
+
],
|
|
69
|
+
true,
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const decode =
|
|
75
|
+
(key: string) =>
|
|
76
|
+
(value: Metadata): ts.CallExpression =>
|
|
77
|
+
!!value.arrays.length
|
|
78
|
+
? ts.factory.createCallExpression(
|
|
79
|
+
IdentifierFactory.access(
|
|
80
|
+
IdentifierFactory.access(
|
|
81
|
+
ts.factory.createIdentifier("input"),
|
|
82
|
+
key,
|
|
83
|
+
),
|
|
84
|
+
"forEach",
|
|
85
|
+
),
|
|
86
|
+
undefined,
|
|
87
|
+
[
|
|
88
|
+
ts.factory.createArrowFunction(
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
[IdentifierFactory.parameter("elem")],
|
|
92
|
+
undefined,
|
|
93
|
+
undefined,
|
|
94
|
+
append(key)(ts.factory.createIdentifier("elem")),
|
|
95
|
+
),
|
|
96
|
+
],
|
|
97
|
+
)
|
|
98
|
+
: append(key)(
|
|
99
|
+
IdentifierFactory.access(ts.factory.createIdentifier("input"), key),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const append = (key: string) => (elem: ts.Expression) =>
|
|
103
|
+
ts.factory.createCallExpression(
|
|
104
|
+
IdentifierFactory.access(ts.factory.createIdentifier("output"), "append"),
|
|
105
|
+
undefined,
|
|
106
|
+
[ts.factory.createStringLiteral(key), elem],
|
|
107
|
+
);
|
|
108
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
-
import { ValidateProgrammer } from "typia/lib/programmers/ValidateProgrammer";
|
|
5
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpValidateQuerifyProgrammer {
|
|
10
|
-
export const write = (props: {
|
|
11
|
-
context: ITypiaContext;
|
|
12
|
-
modulo: ts.LeftHandSideExpression;
|
|
13
|
-
type: ts.Type;
|
|
14
|
-
}): ts.ArrowFunction =>
|
|
15
|
-
ts.factory.createArrowFunction(
|
|
16
|
-
undefined,
|
|
17
|
-
undefined,
|
|
18
|
-
[IdentifierFactory.parameter("input")],
|
|
19
|
-
undefined,
|
|
20
|
-
undefined,
|
|
21
|
-
ts.factory.createBlock([
|
|
22
|
-
StatementFactory.constant({
|
|
23
|
-
name: "validate",
|
|
24
|
-
value: ValidateProgrammer.write({
|
|
25
|
-
config: {
|
|
26
|
-
equals: false,
|
|
27
|
-
},
|
|
28
|
-
context: {
|
|
29
|
-
...props.context,
|
|
30
|
-
options: {
|
|
31
|
-
...props.context.options,
|
|
32
|
-
functional: false,
|
|
33
|
-
numeric: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
modulo: props.modulo,
|
|
37
|
-
type: props.type,
|
|
38
|
-
name: undefined,
|
|
39
|
-
}),
|
|
40
|
-
}),
|
|
41
|
-
StatementFactory.constant({
|
|
42
|
-
name: "query",
|
|
43
|
-
value: HttpQuerifyProgrammer.write({
|
|
44
|
-
context: {
|
|
45
|
-
...props.context,
|
|
46
|
-
options: {
|
|
47
|
-
...props.context.options,
|
|
48
|
-
functional: false,
|
|
49
|
-
numeric: false,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
modulo: props.modulo,
|
|
53
|
-
type: props.type,
|
|
54
|
-
}),
|
|
55
|
-
}),
|
|
56
|
-
StatementFactory.constant({
|
|
57
|
-
name: "output",
|
|
58
|
-
value: ts.factory.createCallExpression(
|
|
59
|
-
ts.factory.createIdentifier("query"),
|
|
60
|
-
undefined,
|
|
61
|
-
[ts.factory.createIdentifier("input")],
|
|
62
|
-
),
|
|
63
|
-
}),
|
|
64
|
-
ts.factory.createReturnStatement(
|
|
65
|
-
ts.factory.createAsExpression(
|
|
66
|
-
ts.factory.createCallExpression(
|
|
67
|
-
ts.factory.createIdentifier("validate"),
|
|
68
|
-
undefined,
|
|
69
|
-
[ts.factory.createIdentifier("output")],
|
|
70
|
-
),
|
|
71
|
-
ts.factory.createTypeReferenceNode("any"),
|
|
72
|
-
),
|
|
73
|
-
),
|
|
74
|
-
]),
|
|
75
|
-
);
|
|
76
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
+
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
+
import { ValidateProgrammer } from "typia/lib/programmers/ValidateProgrammer";
|
|
5
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpValidateQuerifyProgrammer {
|
|
10
|
+
export const write = (props: {
|
|
11
|
+
context: ITypiaContext;
|
|
12
|
+
modulo: ts.LeftHandSideExpression;
|
|
13
|
+
type: ts.Type;
|
|
14
|
+
}): ts.ArrowFunction =>
|
|
15
|
+
ts.factory.createArrowFunction(
|
|
16
|
+
undefined,
|
|
17
|
+
undefined,
|
|
18
|
+
[IdentifierFactory.parameter("input")],
|
|
19
|
+
undefined,
|
|
20
|
+
undefined,
|
|
21
|
+
ts.factory.createBlock([
|
|
22
|
+
StatementFactory.constant({
|
|
23
|
+
name: "validate",
|
|
24
|
+
value: ValidateProgrammer.write({
|
|
25
|
+
config: {
|
|
26
|
+
equals: false,
|
|
27
|
+
},
|
|
28
|
+
context: {
|
|
29
|
+
...props.context,
|
|
30
|
+
options: {
|
|
31
|
+
...props.context.options,
|
|
32
|
+
functional: false,
|
|
33
|
+
numeric: true,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
modulo: props.modulo,
|
|
37
|
+
type: props.type,
|
|
38
|
+
name: undefined,
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
StatementFactory.constant({
|
|
42
|
+
name: "query",
|
|
43
|
+
value: HttpQuerifyProgrammer.write({
|
|
44
|
+
context: {
|
|
45
|
+
...props.context,
|
|
46
|
+
options: {
|
|
47
|
+
...props.context.options,
|
|
48
|
+
functional: false,
|
|
49
|
+
numeric: false,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
modulo: props.modulo,
|
|
53
|
+
type: props.type,
|
|
54
|
+
}),
|
|
55
|
+
}),
|
|
56
|
+
StatementFactory.constant({
|
|
57
|
+
name: "output",
|
|
58
|
+
value: ts.factory.createCallExpression(
|
|
59
|
+
ts.factory.createIdentifier("query"),
|
|
60
|
+
undefined,
|
|
61
|
+
[ts.factory.createIdentifier("input")],
|
|
62
|
+
),
|
|
63
|
+
}),
|
|
64
|
+
ts.factory.createReturnStatement(
|
|
65
|
+
ts.factory.createAsExpression(
|
|
66
|
+
ts.factory.createCallExpression(
|
|
67
|
+
ts.factory.createIdentifier("validate"),
|
|
68
|
+
undefined,
|
|
69
|
+
[ts.factory.createIdentifier("output")],
|
|
70
|
+
),
|
|
71
|
+
ts.factory.createTypeReferenceNode("any"),
|
|
72
|
+
),
|
|
73
|
+
),
|
|
74
|
+
]),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
2
|
-
|
|
3
|
-
export namespace CoreMetadataUtil {
|
|
4
|
-
export const atomics = (
|
|
5
|
-
meta: Metadata,
|
|
6
|
-
): Set<"boolean" | "bigint" | "number" | "string"> =>
|
|
7
|
-
new Set([
|
|
8
|
-
...meta.atomics.map((a) => a.type),
|
|
9
|
-
...meta.constants.map((c) => c.type),
|
|
10
|
-
...(meta.templates.length ? (["string"] as const) : []),
|
|
11
|
-
]);
|
|
12
|
-
|
|
13
|
-
export const isUnion = (meta: Metadata): boolean =>
|
|
14
|
-
atomics(meta).size +
|
|
15
|
-
meta.arrays.length +
|
|
16
|
-
meta.tuples.length +
|
|
17
|
-
meta.natives.length +
|
|
18
|
-
meta.maps.length +
|
|
19
|
-
meta.objects.length >
|
|
20
|
-
1;
|
|
21
|
-
}
|
|
1
|
+
import { Metadata } from "typia/lib/schemas/metadata/Metadata";
|
|
2
|
+
|
|
3
|
+
export namespace CoreMetadataUtil {
|
|
4
|
+
export const atomics = (
|
|
5
|
+
meta: Metadata,
|
|
6
|
+
): Set<"boolean" | "bigint" | "number" | "string"> =>
|
|
7
|
+
new Set([
|
|
8
|
+
...meta.atomics.map((a) => a.type),
|
|
9
|
+
...meta.constants.map((c) => c.type),
|
|
10
|
+
...(meta.templates.length ? (["string"] as const) : []),
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export const isUnion = (meta: Metadata): boolean =>
|
|
14
|
+
atomics(meta).size +
|
|
15
|
+
meta.arrays.length +
|
|
16
|
+
meta.tuples.length +
|
|
17
|
+
meta.natives.length +
|
|
18
|
+
meta.maps.length +
|
|
19
|
+
meta.objects.length >
|
|
20
|
+
1;
|
|
21
|
+
}
|
package/src/transform.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
3
|
-
|
|
4
|
-
import { INestiaTransformOptions } from "./options/INestiaTransformOptions";
|
|
5
|
-
import { FileTransformer } from "./transformers/FileTransformer";
|
|
6
|
-
|
|
7
|
-
export const transform = (
|
|
8
|
-
program: ts.Program,
|
|
9
|
-
options: INestiaTransformOptions | undefined,
|
|
10
|
-
extras: ITypiaContext["extras"],
|
|
11
|
-
): ts.TransformerFactory<ts.SourceFile> => {
|
|
12
|
-
const compilerOptions: ts.CompilerOptions = program.getCompilerOptions();
|
|
13
|
-
const strict: boolean =
|
|
14
|
-
compilerOptions.strictNullChecks !== undefined
|
|
15
|
-
? !!compilerOptions.strictNullChecks
|
|
16
|
-
: !!compilerOptions.strict;
|
|
17
|
-
if (strict === false)
|
|
18
|
-
extras.addDiagnostic({
|
|
19
|
-
category: ts.DiagnosticCategory.Error,
|
|
20
|
-
code: "(@nestia/core)" as any,
|
|
21
|
-
file: undefined,
|
|
22
|
-
start: undefined,
|
|
23
|
-
length: undefined,
|
|
24
|
-
messageText: "strict mode is required.",
|
|
25
|
-
});
|
|
26
|
-
return FileTransformer.transform({
|
|
27
|
-
program,
|
|
28
|
-
compilerOptions,
|
|
29
|
-
checker: program.getTypeChecker(),
|
|
30
|
-
printer: ts.createPrinter(),
|
|
31
|
-
options: options ?? {},
|
|
32
|
-
extras,
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
export default transform;
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
|
|
3
|
+
|
|
4
|
+
import { INestiaTransformOptions } from "./options/INestiaTransformOptions";
|
|
5
|
+
import { FileTransformer } from "./transformers/FileTransformer";
|
|
6
|
+
|
|
7
|
+
export const transform = (
|
|
8
|
+
program: ts.Program,
|
|
9
|
+
options: INestiaTransformOptions | undefined,
|
|
10
|
+
extras: ITypiaContext["extras"],
|
|
11
|
+
): ts.TransformerFactory<ts.SourceFile> => {
|
|
12
|
+
const compilerOptions: ts.CompilerOptions = program.getCompilerOptions();
|
|
13
|
+
const strict: boolean =
|
|
14
|
+
compilerOptions.strictNullChecks !== undefined
|
|
15
|
+
? !!compilerOptions.strictNullChecks
|
|
16
|
+
: !!compilerOptions.strict;
|
|
17
|
+
if (strict === false)
|
|
18
|
+
extras.addDiagnostic({
|
|
19
|
+
category: ts.DiagnosticCategory.Error,
|
|
20
|
+
code: "(@nestia/core)" as any,
|
|
21
|
+
file: undefined,
|
|
22
|
+
start: undefined,
|
|
23
|
+
length: undefined,
|
|
24
|
+
messageText: "strict mode is required.",
|
|
25
|
+
});
|
|
26
|
+
return FileTransformer.transform({
|
|
27
|
+
program,
|
|
28
|
+
compilerOptions,
|
|
29
|
+
checker: program.getTypeChecker(),
|
|
30
|
+
printer: ts.createPrinter(),
|
|
31
|
+
options: options ?? {},
|
|
32
|
+
extras,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
export default transform;
|