@nestia/core 3.0.0-dev.20231209 → 3.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/README.md +12 -9
- package/lib/decorators/DynamicModule.js +3 -3
- package/lib/decorators/DynamicModule.js.map +1 -1
- package/lib/decorators/EncryptedBody.js +14 -13
- package/lib/decorators/EncryptedBody.js.map +1 -1
- package/lib/decorators/EncryptedModule.d.ts +1 -1
- package/lib/decorators/EncryptedModule.js +45 -21
- package/lib/decorators/EncryptedModule.js.map +1 -1
- package/lib/decorators/EncryptedRoute.d.ts +5 -5
- package/lib/decorators/EncryptedRoute.js +12 -29
- package/lib/decorators/EncryptedRoute.js.map +1 -1
- package/lib/decorators/PlainBody.js +3 -0
- package/lib/decorators/PlainBody.js.map +1 -1
- package/lib/decorators/SwaggerCustomizer.d.ts +79 -0
- package/lib/decorators/SwaggerCustomizer.js +32 -0
- package/lib/decorators/SwaggerCustomizer.js.map +1 -0
- package/lib/decorators/TypedBody.js +3 -0
- package/lib/decorators/TypedBody.js.map +1 -1
- package/lib/decorators/TypedException.d.ts +0 -1
- package/lib/decorators/TypedException.js +0 -1
- package/lib/decorators/TypedException.js.map +1 -1
- package/lib/decorators/TypedFormData.d.ts +60 -0
- package/lib/decorators/TypedFormData.js +403 -0
- package/lib/decorators/TypedFormData.js.map +1 -0
- package/lib/decorators/TypedQuery.d.ts +11 -6
- package/lib/decorators/TypedQuery.js +6 -1
- package/lib/decorators/TypedQuery.js.map +1 -1
- package/lib/decorators/TypedRoute.d.ts +5 -5
- package/lib/decorators/internal/get_path_and_querify.js +3 -0
- package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
- package/lib/decorators/internal/load_controller.js.map +1 -1
- package/lib/decorators/internal/validate_request_body.d.ts +1 -3
- package/lib/decorators/internal/validate_request_body.js +15 -0
- package/lib/decorators/internal/validate_request_body.js.map +1 -1
- package/lib/decorators/internal/validate_request_form_data.js +79 -0
- package/lib/decorators/internal/validate_request_form_data.js.map +1 -0
- package/lib/decorators/internal/validate_request_headers.d.ts +1 -3
- package/lib/decorators/internal/validate_request_headers.js +15 -0
- package/lib/decorators/internal/validate_request_headers.js.map +1 -1
- package/lib/decorators/internal/validate_request_query.d.ts +1 -3
- package/lib/decorators/internal/validate_request_query.js +15 -0
- 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/lib/options/IRequestFormDataProps.d.ts +23 -0
- package/lib/options/IRequestFormDataProps.js +3 -0
- package/lib/options/IRequestFormDataProps.js.map +1 -0
- package/lib/programmers/PlainBodyProgrammer.js +1 -1
- package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
- package/lib/programmers/TypedExceptionProgrammer.js +5 -5
- package/lib/programmers/TypedExceptionProgrammer.js.map +1 -1
- package/lib/programmers/TypedFormDataBodyProgrammer.d.ts +6 -0
- package/lib/programmers/TypedFormDataBodyProgrammer.js +84 -0
- package/lib/programmers/TypedFormDataBodyProgrammer.js.map +1 -0
- package/lib/programmers/http/HttpQuerifyProgrammer.js +2 -2
- package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
- package/lib/transformers/NodeTransformer.js.map +1 -1
- package/lib/transformers/ParameterDecoratorTransformer.js +7 -1
- package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
- package/lib/transformers/TypedExceptionTransformer.js +1 -1
- package/lib/transformers/TypedExceptionTransformer.js.map +1 -1
- package/lib/transformers/TypedRouteTransformer.js +1 -1
- package/lib/transformers/TypedRouteTransformer.js.map +1 -1
- package/package.json +15 -16
- package/src/decorators/DynamicModule.ts +39 -39
- package/src/decorators/EncryptedBody.ts +105 -107
- package/src/decorators/EncryptedController.ts +38 -38
- package/src/decorators/EncryptedModule.ts +96 -79
- package/src/decorators/EncryptedRoute.ts +182 -206
- package/src/decorators/PlainBody.ts +75 -72
- package/src/decorators/SwaggerCustomizer.ts +115 -0
- package/src/decorators/TypedBody.ts +62 -59
- package/src/decorators/TypedException.ts +90 -89
- package/src/decorators/TypedFormData.ts +219 -0
- package/src/decorators/TypedHeaders.ts +69 -69
- package/src/decorators/TypedParam.ts +65 -65
- package/src/decorators/TypedQuery.ts +251 -246
- package/src/decorators/TypedRoute.ts +144 -144
- package/src/decorators/internal/EncryptedConstant.ts +4 -4
- package/src/decorators/internal/NoTransformConfigureError.ts +8 -8
- package/src/decorators/internal/get_path_and_querify.ts +106 -103
- package/src/decorators/internal/get_path_and_stringify.ts +91 -91
- package/src/decorators/internal/get_text_body.ts +20 -20
- package/src/decorators/internal/headers_to_object.ts +13 -13
- package/src/decorators/internal/load_controller.ts +51 -51
- package/src/decorators/internal/route_error.ts +45 -45
- package/src/decorators/internal/validate_request_body.ts +72 -57
- package/src/decorators/internal/validate_request_form_data.ts +75 -0
- package/src/decorators/internal/validate_request_headers.ts +83 -68
- package/src/decorators/internal/validate_request_query.ts +71 -56
- package/src/index.ts +5 -5
- package/src/module.ts +16 -14
- package/src/options/INestiaTransformOptions.ts +17 -17
- package/src/options/INestiaTransformProject.ts +7 -7
- package/src/options/IRequestBodyValidator.ts +20 -20
- package/src/options/IRequestFormDataProps.ts +27 -0
- 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 +25 -25
- package/src/programmers/PlainBodyProgrammer.ts +52 -52
- package/src/programmers/TypedBodyProgrammer.ts +108 -108
- package/src/programmers/TypedExceptionProgrammer.ts +71 -72
- package/src/programmers/TypedFormDataBodyProgrammer.ts +108 -0
- package/src/programmers/TypedHeadersProgrammer.ts +56 -56
- package/src/programmers/TypedParamProgrammer.ts +24 -24
- package/src/programmers/TypedQueryBodyProgrammer.ts +56 -56
- package/src/programmers/TypedQueryProgrammer.ts +56 -56
- package/src/programmers/TypedQueryRouteProgrammer.ts +51 -51
- package/src/programmers/TypedRouteProgrammer.ts +51 -51
- package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +58 -58
- package/src/programmers/http/HttpIsQuerifyProgrammer.ts +62 -62
- package/src/programmers/http/HttpQuerifyProgrammer.ts +96 -96
- package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +63 -63
- package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
- package/src/transform.ts +35 -35
- package/src/transformers/FileTransformer.ts +66 -66
- package/src/transformers/MethodTransformer.ts +94 -94
- package/src/transformers/NodeTransformer.ts +16 -16
- package/src/transformers/ParameterDecoratorTransformer.ts +120 -121
- package/src/transformers/ParameterTransformer.ts +48 -48
- package/src/transformers/TypedExceptionTransformer.ts +48 -49
- package/src/transformers/TypedRouteTransformer.ts +88 -95
- package/src/typings/Creator.ts +3 -3
- package/src/utils/ExceptionManager.ts +112 -112
- package/src/utils/Singleton.ts +20 -20
- package/src/utils/SourceFinder.ts +57 -57
- package/lib/decorators/internal/get_binary_body.js +0 -66
- package/lib/decorators/internal/get_binary_body.js.map +0 -1
- package/src/decorators/internal/get_binary_body.ts +0 -18
- /package/lib/decorators/internal/{get_binary_body.d.ts → validate_request_form_data.d.ts} +0 -0
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
-
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
-
import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
|
|
5
|
-
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpAssertQuerifyProgrammer {
|
|
10
|
-
export const write =
|
|
11
|
-
(project: IProject) =>
|
|
12
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
-
(type: ts.Type, name?: string): ts.ArrowFunction =>
|
|
14
|
-
ts.factory.createArrowFunction(
|
|
15
|
-
undefined,
|
|
16
|
-
undefined,
|
|
17
|
-
[IdentifierFactory.parameter("input")],
|
|
18
|
-
undefined,
|
|
19
|
-
undefined,
|
|
20
|
-
ts.factory.createBlock([
|
|
21
|
-
StatementFactory.constant(
|
|
22
|
-
"assert",
|
|
23
|
-
AssertProgrammer.write({
|
|
24
|
-
...project,
|
|
25
|
-
options: {
|
|
26
|
-
...project.options,
|
|
27
|
-
functional: false,
|
|
28
|
-
numeric: false,
|
|
29
|
-
},
|
|
30
|
-
})(modulo)(false)(type, name),
|
|
31
|
-
),
|
|
32
|
-
StatementFactory.constant(
|
|
33
|
-
"stringify",
|
|
34
|
-
HttpQuerifyProgrammer.write({
|
|
35
|
-
...project,
|
|
36
|
-
options: {
|
|
37
|
-
...project.options,
|
|
38
|
-
functional: false,
|
|
39
|
-
numeric: false,
|
|
40
|
-
},
|
|
41
|
-
})(modulo)(type),
|
|
42
|
-
),
|
|
43
|
-
ts.factory.createReturnStatement(
|
|
44
|
-
ts.factory.createCallExpression(
|
|
45
|
-
ts.factory.createIdentifier("stringify"),
|
|
46
|
-
undefined,
|
|
47
|
-
[
|
|
48
|
-
ts.factory.createCallExpression(
|
|
49
|
-
ts.factory.createIdentifier("assert"),
|
|
50
|
-
undefined,
|
|
51
|
-
[ts.factory.createIdentifier("input")],
|
|
52
|
-
),
|
|
53
|
-
],
|
|
54
|
-
),
|
|
55
|
-
),
|
|
56
|
-
]),
|
|
57
|
-
);
|
|
58
|
-
}
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
|
|
3
|
+
import { StatementFactory } from "typia/lib/factories/StatementFactory";
|
|
4
|
+
import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
|
|
5
|
+
import { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpAssertQuerifyProgrammer {
|
|
10
|
+
export const write =
|
|
11
|
+
(project: IProject) =>
|
|
12
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
+
(type: ts.Type, name?: string): ts.ArrowFunction =>
|
|
14
|
+
ts.factory.createArrowFunction(
|
|
15
|
+
undefined,
|
|
16
|
+
undefined,
|
|
17
|
+
[IdentifierFactory.parameter("input")],
|
|
18
|
+
undefined,
|
|
19
|
+
undefined,
|
|
20
|
+
ts.factory.createBlock([
|
|
21
|
+
StatementFactory.constant(
|
|
22
|
+
"assert",
|
|
23
|
+
AssertProgrammer.write({
|
|
24
|
+
...project,
|
|
25
|
+
options: {
|
|
26
|
+
...project.options,
|
|
27
|
+
functional: false,
|
|
28
|
+
numeric: false,
|
|
29
|
+
},
|
|
30
|
+
})(modulo)(false)(type, name),
|
|
31
|
+
),
|
|
32
|
+
StatementFactory.constant(
|
|
33
|
+
"stringify",
|
|
34
|
+
HttpQuerifyProgrammer.write({
|
|
35
|
+
...project,
|
|
36
|
+
options: {
|
|
37
|
+
...project.options,
|
|
38
|
+
functional: false,
|
|
39
|
+
numeric: false,
|
|
40
|
+
},
|
|
41
|
+
})(modulo)(type),
|
|
42
|
+
),
|
|
43
|
+
ts.factory.createReturnStatement(
|
|
44
|
+
ts.factory.createCallExpression(
|
|
45
|
+
ts.factory.createIdentifier("stringify"),
|
|
46
|
+
undefined,
|
|
47
|
+
[
|
|
48
|
+
ts.factory.createCallExpression(
|
|
49
|
+
ts.factory.createIdentifier("assert"),
|
|
50
|
+
undefined,
|
|
51
|
+
[ts.factory.createIdentifier("input")],
|
|
52
|
+
),
|
|
53
|
+
],
|
|
54
|
+
),
|
|
55
|
+
),
|
|
56
|
+
]),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -1,62 +1,62 @@
|
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpIsQuerifyProgrammer {
|
|
10
|
-
export const write =
|
|
11
|
-
(project: IProject) =>
|
|
12
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
-
(type: ts.Type): ts.ArrowFunction =>
|
|
14
|
-
ts.factory.createArrowFunction(
|
|
15
|
-
undefined,
|
|
16
|
-
undefined,
|
|
17
|
-
[IdentifierFactory.parameter("input")],
|
|
18
|
-
undefined,
|
|
19
|
-
undefined,
|
|
20
|
-
ts.factory.createBlock([
|
|
21
|
-
StatementFactory.constant(
|
|
22
|
-
"is",
|
|
23
|
-
IsProgrammer.write({
|
|
24
|
-
...project,
|
|
25
|
-
options: {
|
|
26
|
-
...project.options,
|
|
27
|
-
functional: false,
|
|
28
|
-
numeric: false,
|
|
29
|
-
},
|
|
30
|
-
})(modulo)(false)(type),
|
|
31
|
-
),
|
|
32
|
-
StatementFactory.constant(
|
|
33
|
-
"stringify",
|
|
34
|
-
HttpQuerifyProgrammer.write({
|
|
35
|
-
...project,
|
|
36
|
-
options: {
|
|
37
|
-
...project.options,
|
|
38
|
-
functional: false,
|
|
39
|
-
numeric: false,
|
|
40
|
-
},
|
|
41
|
-
})(modulo)(type),
|
|
42
|
-
),
|
|
43
|
-
ts.factory.createReturnStatement(
|
|
44
|
-
ts.factory.createConditionalExpression(
|
|
45
|
-
ts.factory.createCallExpression(
|
|
46
|
-
ts.factory.createIdentifier("is"),
|
|
47
|
-
undefined,
|
|
48
|
-
[ts.factory.createIdentifier("input")],
|
|
49
|
-
),
|
|
50
|
-
undefined,
|
|
51
|
-
ts.factory.createCallExpression(
|
|
52
|
-
ts.factory.createIdentifier("stringify"),
|
|
53
|
-
undefined,
|
|
54
|
-
[ts.factory.createIdentifier("input")],
|
|
55
|
-
),
|
|
56
|
-
undefined,
|
|
57
|
-
ts.factory.createNull(),
|
|
58
|
-
),
|
|
59
|
-
),
|
|
60
|
-
]),
|
|
61
|
-
);
|
|
62
|
-
}
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpIsQuerifyProgrammer {
|
|
10
|
+
export const write =
|
|
11
|
+
(project: IProject) =>
|
|
12
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
+
(type: ts.Type): ts.ArrowFunction =>
|
|
14
|
+
ts.factory.createArrowFunction(
|
|
15
|
+
undefined,
|
|
16
|
+
undefined,
|
|
17
|
+
[IdentifierFactory.parameter("input")],
|
|
18
|
+
undefined,
|
|
19
|
+
undefined,
|
|
20
|
+
ts.factory.createBlock([
|
|
21
|
+
StatementFactory.constant(
|
|
22
|
+
"is",
|
|
23
|
+
IsProgrammer.write({
|
|
24
|
+
...project,
|
|
25
|
+
options: {
|
|
26
|
+
...project.options,
|
|
27
|
+
functional: false,
|
|
28
|
+
numeric: false,
|
|
29
|
+
},
|
|
30
|
+
})(modulo)(false)(type),
|
|
31
|
+
),
|
|
32
|
+
StatementFactory.constant(
|
|
33
|
+
"stringify",
|
|
34
|
+
HttpQuerifyProgrammer.write({
|
|
35
|
+
...project,
|
|
36
|
+
options: {
|
|
37
|
+
...project.options,
|
|
38
|
+
functional: false,
|
|
39
|
+
numeric: false,
|
|
40
|
+
},
|
|
41
|
+
})(modulo)(type),
|
|
42
|
+
),
|
|
43
|
+
ts.factory.createReturnStatement(
|
|
44
|
+
ts.factory.createConditionalExpression(
|
|
45
|
+
ts.factory.createCallExpression(
|
|
46
|
+
ts.factory.createIdentifier("is"),
|
|
47
|
+
undefined,
|
|
48
|
+
[ts.factory.createIdentifier("input")],
|
|
49
|
+
),
|
|
50
|
+
undefined,
|
|
51
|
+
ts.factory.createCallExpression(
|
|
52
|
+
ts.factory.createIdentifier("stringify"),
|
|
53
|
+
undefined,
|
|
54
|
+
[ts.factory.createIdentifier("input")],
|
|
55
|
+
),
|
|
56
|
+
undefined,
|
|
57
|
+
ts.factory.createNull(),
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
]),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -1,96 +1,96 @@
|
|
|
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 { FunctionImporter } from "typia/lib/programmers/helpers/FunctionImporeter";
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
11
|
-
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
12
|
-
|
|
13
|
-
export namespace HttpQuerifyProgrammer {
|
|
14
|
-
export const write =
|
|
15
|
-
(project: IProject) =>
|
|
16
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
17
|
-
(type: ts.Type): ts.ArrowFunction => {
|
|
18
|
-
// GET OBJECT TYPE
|
|
19
|
-
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
|
|
20
|
-
const collection: MetadataCollection = new MetadataCollection();
|
|
21
|
-
const result = MetadataFactory.analyze(project.checker)({
|
|
22
|
-
escape: false,
|
|
23
|
-
constant: true,
|
|
24
|
-
absorb: true,
|
|
25
|
-
validate: HttpQueryProgrammer.validate,
|
|
26
|
-
})(collection)(type);
|
|
27
|
-
if (result.success === false)
|
|
28
|
-
throw TransformerError.from(
|
|
29
|
-
|
|
30
|
-
)(result.errors);
|
|
31
|
-
|
|
32
|
-
const object: MetadataObject = result.data.objects[0]!;
|
|
33
|
-
return ts.factory.createArrowFunction(
|
|
34
|
-
undefined,
|
|
35
|
-
undefined,
|
|
36
|
-
[IdentifierFactory.parameter("input")],
|
|
37
|
-
undefined,
|
|
38
|
-
undefined,
|
|
39
|
-
ts.factory.createBlock(
|
|
40
|
-
[
|
|
41
|
-
...importer.declare(modulo),
|
|
42
|
-
StatementFactory.constant(
|
|
43
|
-
"output",
|
|
44
|
-
ts.factory.createNewExpression(
|
|
45
|
-
ts.factory.createIdentifier("URLSearchParams"),
|
|
46
|
-
undefined,
|
|
47
|
-
[],
|
|
48
|
-
),
|
|
49
|
-
),
|
|
50
|
-
...object.properties.map((p) =>
|
|
51
|
-
ts.factory.createExpressionStatement(
|
|
52
|
-
decode(p.key.constants[0]!.values[0] as string)(p.value),
|
|
53
|
-
),
|
|
54
|
-
),
|
|
55
|
-
ts.factory.createReturnStatement(
|
|
56
|
-
ts.factory.createIdentifier("output"),
|
|
57
|
-
),
|
|
58
|
-
],
|
|
59
|
-
true,
|
|
60
|
-
),
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const decode =
|
|
65
|
-
(key: string) =>
|
|
66
|
-
(value: Metadata): ts.CallExpression =>
|
|
67
|
-
!!value.arrays.length
|
|
68
|
-
? ts.factory.createCallExpression(
|
|
69
|
-
IdentifierFactory.access(
|
|
70
|
-
IdentifierFactory.access(ts.factory.createIdentifier("input"))(
|
|
71
|
-
key,
|
|
72
|
-
),
|
|
73
|
-
)("forEach"),
|
|
74
|
-
undefined,
|
|
75
|
-
[
|
|
76
|
-
ts.factory.createArrowFunction(
|
|
77
|
-
undefined,
|
|
78
|
-
undefined,
|
|
79
|
-
[IdentifierFactory.parameter("elem")],
|
|
80
|
-
undefined,
|
|
81
|
-
undefined,
|
|
82
|
-
append(key)(ts.factory.createIdentifier("elem")),
|
|
83
|
-
),
|
|
84
|
-
],
|
|
85
|
-
)
|
|
86
|
-
: append(key)(
|
|
87
|
-
IdentifierFactory.access(ts.factory.createIdentifier("input"))(key),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const append = (key: string) => (elem: ts.Expression) =>
|
|
91
|
-
ts.factory.createCallExpression(
|
|
92
|
-
IdentifierFactory.access(ts.factory.createIdentifier("output"))("append"),
|
|
93
|
-
undefined,
|
|
94
|
-
[ts.factory.createStringLiteral(key), elem],
|
|
95
|
-
);
|
|
96
|
-
}
|
|
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 { FunctionImporter } from "typia/lib/programmers/helpers/FunctionImporeter";
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
11
|
+
import { TransformerError } from "typia/lib/transformers/TransformerError";
|
|
12
|
+
|
|
13
|
+
export namespace HttpQuerifyProgrammer {
|
|
14
|
+
export const write =
|
|
15
|
+
(project: IProject) =>
|
|
16
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
17
|
+
(type: ts.Type): ts.ArrowFunction => {
|
|
18
|
+
// GET OBJECT TYPE
|
|
19
|
+
const importer: FunctionImporter = new FunctionImporter(modulo.getText());
|
|
20
|
+
const collection: MetadataCollection = new MetadataCollection();
|
|
21
|
+
const result = MetadataFactory.analyze(project.checker)({
|
|
22
|
+
escape: false,
|
|
23
|
+
constant: true,
|
|
24
|
+
absorb: true,
|
|
25
|
+
validate: HttpQueryProgrammer.validate,
|
|
26
|
+
})(collection)(type);
|
|
27
|
+
if (result.success === false)
|
|
28
|
+
throw TransformerError.from(
|
|
29
|
+
`nestia.core.TypedQuery.${importer.method}`,
|
|
30
|
+
)(result.errors);
|
|
31
|
+
|
|
32
|
+
const object: MetadataObject = result.data.objects[0]!;
|
|
33
|
+
return ts.factory.createArrowFunction(
|
|
34
|
+
undefined,
|
|
35
|
+
undefined,
|
|
36
|
+
[IdentifierFactory.parameter("input")],
|
|
37
|
+
undefined,
|
|
38
|
+
undefined,
|
|
39
|
+
ts.factory.createBlock(
|
|
40
|
+
[
|
|
41
|
+
...importer.declare(modulo),
|
|
42
|
+
StatementFactory.constant(
|
|
43
|
+
"output",
|
|
44
|
+
ts.factory.createNewExpression(
|
|
45
|
+
ts.factory.createIdentifier("URLSearchParams"),
|
|
46
|
+
undefined,
|
|
47
|
+
[],
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
...object.properties.map((p) =>
|
|
51
|
+
ts.factory.createExpressionStatement(
|
|
52
|
+
decode(p.key.constants[0]!.values[0].value as string)(p.value),
|
|
53
|
+
),
|
|
54
|
+
),
|
|
55
|
+
ts.factory.createReturnStatement(
|
|
56
|
+
ts.factory.createIdentifier("output"),
|
|
57
|
+
),
|
|
58
|
+
],
|
|
59
|
+
true,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const decode =
|
|
65
|
+
(key: string) =>
|
|
66
|
+
(value: Metadata): ts.CallExpression =>
|
|
67
|
+
!!value.arrays.length
|
|
68
|
+
? ts.factory.createCallExpression(
|
|
69
|
+
IdentifierFactory.access(
|
|
70
|
+
IdentifierFactory.access(ts.factory.createIdentifier("input"))(
|
|
71
|
+
key,
|
|
72
|
+
),
|
|
73
|
+
)("forEach"),
|
|
74
|
+
undefined,
|
|
75
|
+
[
|
|
76
|
+
ts.factory.createArrowFunction(
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
[IdentifierFactory.parameter("elem")],
|
|
80
|
+
undefined,
|
|
81
|
+
undefined,
|
|
82
|
+
append(key)(ts.factory.createIdentifier("elem")),
|
|
83
|
+
),
|
|
84
|
+
],
|
|
85
|
+
)
|
|
86
|
+
: append(key)(
|
|
87
|
+
IdentifierFactory.access(ts.factory.createIdentifier("input"))(key),
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const append = (key: string) => (elem: ts.Expression) =>
|
|
91
|
+
ts.factory.createCallExpression(
|
|
92
|
+
IdentifierFactory.access(ts.factory.createIdentifier("output"))("append"),
|
|
93
|
+
undefined,
|
|
94
|
+
[ts.factory.createStringLiteral(key), elem],
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -1,63 +1,63 @@
|
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
-
|
|
7
|
-
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
-
|
|
9
|
-
export namespace HttpValidateQuerifyProgrammer {
|
|
10
|
-
export const write =
|
|
11
|
-
(project: IProject) =>
|
|
12
|
-
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
-
(type: ts.Type, name?: string): ts.ArrowFunction =>
|
|
14
|
-
ts.factory.createArrowFunction(
|
|
15
|
-
undefined,
|
|
16
|
-
undefined,
|
|
17
|
-
[IdentifierFactory.parameter("input")],
|
|
18
|
-
undefined,
|
|
19
|
-
undefined,
|
|
20
|
-
ts.factory.createBlock([
|
|
21
|
-
StatementFactory.constant(
|
|
22
|
-
"validate",
|
|
23
|
-
ValidateProgrammer.write({
|
|
24
|
-
...project,
|
|
25
|
-
options: {
|
|
26
|
-
...project.options,
|
|
27
|
-
functional: false,
|
|
28
|
-
numeric: true,
|
|
29
|
-
},
|
|
30
|
-
})(modulo)(false)(type, name),
|
|
31
|
-
),
|
|
32
|
-
StatementFactory.constant(
|
|
33
|
-
"query",
|
|
34
|
-
HttpQuerifyProgrammer.write({
|
|
35
|
-
...project,
|
|
36
|
-
options: {
|
|
37
|
-
...project.options,
|
|
38
|
-
functional: false,
|
|
39
|
-
numeric: false,
|
|
40
|
-
},
|
|
41
|
-
})(modulo)(type),
|
|
42
|
-
),
|
|
43
|
-
StatementFactory.constant(
|
|
44
|
-
"output",
|
|
45
|
-
ts.factory.createCallExpression(
|
|
46
|
-
ts.factory.createIdentifier("query"),
|
|
47
|
-
undefined,
|
|
48
|
-
[ts.factory.createIdentifier("input")],
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
ts.factory.createReturnStatement(
|
|
52
|
-
ts.factory.createAsExpression(
|
|
53
|
-
ts.factory.createCallExpression(
|
|
54
|
-
ts.factory.createIdentifier("validate"),
|
|
55
|
-
undefined,
|
|
56
|
-
[ts.factory.createIdentifier("output")],
|
|
57
|
-
),
|
|
58
|
-
ts.factory.createTypeReferenceNode("any"),
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
]),
|
|
62
|
-
);
|
|
63
|
-
}
|
|
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 { IProject } from "typia/lib/transformers/IProject";
|
|
6
|
+
|
|
7
|
+
import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
|
|
8
|
+
|
|
9
|
+
export namespace HttpValidateQuerifyProgrammer {
|
|
10
|
+
export const write =
|
|
11
|
+
(project: IProject) =>
|
|
12
|
+
(modulo: ts.LeftHandSideExpression) =>
|
|
13
|
+
(type: ts.Type, name?: string): ts.ArrowFunction =>
|
|
14
|
+
ts.factory.createArrowFunction(
|
|
15
|
+
undefined,
|
|
16
|
+
undefined,
|
|
17
|
+
[IdentifierFactory.parameter("input")],
|
|
18
|
+
undefined,
|
|
19
|
+
undefined,
|
|
20
|
+
ts.factory.createBlock([
|
|
21
|
+
StatementFactory.constant(
|
|
22
|
+
"validate",
|
|
23
|
+
ValidateProgrammer.write({
|
|
24
|
+
...project,
|
|
25
|
+
options: {
|
|
26
|
+
...project.options,
|
|
27
|
+
functional: false,
|
|
28
|
+
numeric: true,
|
|
29
|
+
},
|
|
30
|
+
})(modulo)(false)(type, name),
|
|
31
|
+
),
|
|
32
|
+
StatementFactory.constant(
|
|
33
|
+
"query",
|
|
34
|
+
HttpQuerifyProgrammer.write({
|
|
35
|
+
...project,
|
|
36
|
+
options: {
|
|
37
|
+
...project.options,
|
|
38
|
+
functional: false,
|
|
39
|
+
numeric: false,
|
|
40
|
+
},
|
|
41
|
+
})(modulo)(type),
|
|
42
|
+
),
|
|
43
|
+
StatementFactory.constant(
|
|
44
|
+
"output",
|
|
45
|
+
ts.factory.createCallExpression(
|
|
46
|
+
ts.factory.createIdentifier("query"),
|
|
47
|
+
undefined,
|
|
48
|
+
[ts.factory.createIdentifier("input")],
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
ts.factory.createReturnStatement(
|
|
52
|
+
ts.factory.createAsExpression(
|
|
53
|
+
ts.factory.createCallExpression(
|
|
54
|
+
ts.factory.createIdentifier("validate"),
|
|
55
|
+
undefined,
|
|
56
|
+
[ts.factory.createIdentifier("output")],
|
|
57
|
+
),
|
|
58
|
+
ts.factory.createTypeReferenceNode("any"),
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
]),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -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
|
+
}
|