@nestia/core 2.4.2 → 2.4.3-dev.20231207

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.
Files changed (112) hide show
  1. package/lib/decorators/DynamicModule.js.map +1 -1
  2. package/lib/decorators/EncryptedBody.js.map +1 -1
  3. package/lib/decorators/EncryptedController.js.map +1 -1
  4. package/lib/decorators/EncryptedModule.js.map +1 -1
  5. package/lib/decorators/EncryptedRoute.js +0 -2
  6. package/lib/decorators/EncryptedRoute.js.map +1 -1
  7. package/lib/decorators/PlainBody.js.map +1 -1
  8. package/lib/decorators/TypedBody.js.map +1 -1
  9. package/lib/decorators/TypedException.js.map +1 -1
  10. package/lib/decorators/TypedHeaders.js.map +1 -1
  11. package/lib/decorators/TypedParam.js.map +1 -1
  12. package/lib/decorators/TypedQuery.js +1 -5
  13. package/lib/decorators/TypedQuery.js.map +1 -1
  14. package/lib/decorators/TypedRoute.js.map +1 -1
  15. package/lib/decorators/internal/NoTransformConfigureError.js.map +1 -1
  16. package/lib/decorators/internal/get_path_and_querify.js.map +1 -1
  17. package/lib/decorators/internal/get_path_and_stringify.js.map +1 -1
  18. package/lib/decorators/internal/get_text_body.js.map +1 -1
  19. package/lib/decorators/internal/headers_to_object.js.map +1 -1
  20. package/lib/decorators/internal/load_controller.js.map +1 -1
  21. package/lib/decorators/internal/route_error.js.map +1 -1
  22. package/lib/decorators/internal/validate_request_body.js.map +1 -1
  23. package/lib/decorators/internal/validate_request_headers.js.map +1 -1
  24. package/lib/decorators/internal/validate_request_query.js.map +1 -1
  25. package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
  26. package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
  27. package/lib/programmers/TypedExceptionProgrammer.js.map +1 -1
  28. package/lib/programmers/TypedHeadersProgrammer.js.map +1 -1
  29. package/lib/programmers/TypedParamProgrammer.js.map +1 -1
  30. package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
  31. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  32. package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
  33. package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
  34. package/lib/programmers/http/HttpAssertQuerifyProgrammer.js.map +1 -1
  35. package/lib/programmers/http/HttpIsQuerifyProgrammer.js.map +1 -1
  36. package/lib/programmers/http/HttpQuerifyProgrammer.js.map +1 -1
  37. package/lib/programmers/http/HttpValidateQuerifyProgrammer.js.map +1 -1
  38. package/lib/programmers/internal/CoreMetadataUtil.js.map +1 -1
  39. package/lib/transform.js.map +1 -1
  40. package/lib/transformers/FileTransformer.js.map +1 -1
  41. package/lib/transformers/MethodTransformer.js +1 -2
  42. package/lib/transformers/MethodTransformer.js.map +1 -1
  43. package/lib/transformers/NodeTransformer.js.map +1 -1
  44. package/lib/transformers/ParameterDecoratorTransformer.js +1 -3
  45. package/lib/transformers/ParameterDecoratorTransformer.js.map +1 -1
  46. package/lib/transformers/ParameterTransformer.js.map +1 -1
  47. package/lib/transformers/TypedExceptionTransformer.js.map +1 -1
  48. package/lib/transformers/TypedRouteTransformer.js +1 -2
  49. package/lib/transformers/TypedRouteTransformer.js.map +1 -1
  50. package/lib/utils/ExceptionManager.js.map +1 -1
  51. package/lib/utils/Singleton.js.map +1 -1
  52. package/lib/utils/SourceFinder.js +1 -3
  53. package/lib/utils/SourceFinder.js.map +1 -1
  54. package/package.json +3 -6
  55. package/src/decorators/DynamicModule.ts +39 -39
  56. package/src/decorators/EncryptedBody.ts +49 -57
  57. package/src/decorators/EncryptedController.ts +38 -38
  58. package/src/decorators/EncryptedModule.ts +79 -79
  59. package/src/decorators/EncryptedRoute.ts +126 -135
  60. package/src/decorators/PlainBody.ts +72 -75
  61. package/src/decorators/TypedBody.ts +59 -60
  62. package/src/decorators/TypedException.ts +89 -89
  63. package/src/decorators/TypedHeaders.ts +69 -70
  64. package/src/decorators/TypedParam.ts +65 -66
  65. package/src/decorators/TypedQuery.ts +246 -253
  66. package/src/decorators/TypedRoute.ts +144 -147
  67. package/src/decorators/internal/EncryptedConstant.ts +4 -4
  68. package/src/decorators/internal/NoTransformConfigureError.ts +8 -8
  69. package/src/decorators/internal/get_path_and_querify.ts +103 -104
  70. package/src/decorators/internal/get_path_and_stringify.ts +91 -94
  71. package/src/decorators/internal/get_text_body.ts +20 -20
  72. package/src/decorators/internal/headers_to_object.ts +13 -13
  73. package/src/decorators/internal/load_controller.ts +51 -51
  74. package/src/decorators/internal/route_error.ts +45 -45
  75. package/src/decorators/internal/validate_request_body.ts +57 -61
  76. package/src/decorators/internal/validate_request_headers.ts +68 -73
  77. package/src/decorators/internal/validate_request_query.ts +56 -59
  78. package/src/index.ts +5 -5
  79. package/src/module.ts +14 -14
  80. package/src/options/INestiaTransformOptions.ts +17 -17
  81. package/src/options/INestiaTransformProject.ts +7 -7
  82. package/src/options/IRequestBodyValidator.ts +20 -20
  83. package/src/options/IRequestHeadersValidator.ts +22 -22
  84. package/src/options/IRequestQueryValidator.ts +20 -20
  85. package/src/options/IResponseBodyQuerifier.ts +25 -25
  86. package/src/options/IResponseBodyStringifier.ts +25 -25
  87. package/src/programmers/PlainBodyProgrammer.ts +52 -56
  88. package/src/programmers/TypedBodyProgrammer.ts +108 -112
  89. package/src/programmers/TypedExceptionProgrammer.ts +72 -76
  90. package/src/programmers/TypedHeadersProgrammer.ts +56 -59
  91. package/src/programmers/TypedParamProgrammer.ts +24 -25
  92. package/src/programmers/TypedQueryBodyProgrammer.ts +56 -57
  93. package/src/programmers/TypedQueryProgrammer.ts +56 -57
  94. package/src/programmers/TypedQueryRouteProgrammer.ts +51 -55
  95. package/src/programmers/TypedRouteProgrammer.ts +51 -55
  96. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +58 -59
  97. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +62 -63
  98. package/src/programmers/http/HttpQuerifyProgrammer.ts +96 -105
  99. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +63 -64
  100. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  101. package/src/transform.ts +35 -36
  102. package/src/transformers/FileTransformer.ts +66 -67
  103. package/src/transformers/MethodTransformer.ts +94 -97
  104. package/src/transformers/NodeTransformer.ts +16 -16
  105. package/src/transformers/ParameterDecoratorTransformer.ts +121 -126
  106. package/src/transformers/ParameterTransformer.ts +48 -53
  107. package/src/transformers/TypedExceptionTransformer.ts +49 -51
  108. package/src/transformers/TypedRouteTransformer.ts +95 -96
  109. package/src/typings/Creator.ts +3 -3
  110. package/src/utils/ExceptionManager.ts +112 -112
  111. package/src/utils/Singleton.ts +20 -20
  112. package/src/utils/SourceFinder.ts +57 -60
@@ -1,25 +1,24 @@
1
- import ts from "typescript";
2
-
3
- import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
4
-
5
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
6
-
7
- export namespace TypedParamProgrammer {
8
- export const generate =
9
- (project: INestiaTransformProject) =>
10
- (modulo: ts.LeftHandSideExpression) =>
11
- (parameters: readonly ts.Expression[]) =>
12
- (type: ts.Type): readonly ts.Expression[] => {
13
- // ALREADY BEING TRANSFORMED
14
- if (parameters.length !== 1) return parameters;
15
- return [
16
- parameters[0],
17
- HttpParameterProgrammer.write({
18
- ...project,
19
- options: {
20
- numeric: true,
21
- },
22
- })(modulo)(type),
23
- ];
24
- };
25
- }
1
+ import ts from "typescript";
2
+ import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
3
+
4
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
5
+
6
+ export namespace TypedParamProgrammer {
7
+ export const generate =
8
+ (project: INestiaTransformProject) =>
9
+ (modulo: ts.LeftHandSideExpression) =>
10
+ (parameters: readonly ts.Expression[]) =>
11
+ (type: ts.Type): readonly ts.Expression[] => {
12
+ // ALREADY BEING TRANSFORMED
13
+ if (parameters.length !== 1) return parameters;
14
+ return [
15
+ parameters[0],
16
+ HttpParameterProgrammer.write({
17
+ ...project,
18
+ options: {
19
+ numeric: true,
20
+ },
21
+ })(modulo)(type),
22
+ ];
23
+ };
24
+ }
@@ -1,57 +1,56 @@
1
- import ts from "typescript";
2
-
3
- import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
4
- import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
5
- import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
6
- import { IProject } from "typia/lib/transformers/IProject";
7
-
8
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
9
- import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
10
-
11
- export namespace TypedQueryBodyProgrammer {
12
- export const generate =
13
- (project: INestiaTransformProject) =>
14
- (modulo: ts.LeftHandSideExpression) =>
15
- (type: ts.Type): ts.ObjectLiteralExpression => {
16
- // GENERATE VALIDATION PLAN
17
- const parameter =
18
- (key: IRequestQueryValidator<any>["type"]) =>
19
- (
20
- programmer: (
21
- project: IProject,
22
- ) => (
23
- modulo: ts.LeftHandSideExpression,
24
- ) => (type: ts.Type) => ts.ArrowFunction,
25
- ) =>
26
- ts.factory.createObjectLiteralExpression([
27
- ts.factory.createPropertyAssignment(
28
- ts.factory.createIdentifier("type"),
29
- ts.factory.createStringLiteral(key),
30
- ),
31
- ts.factory.createPropertyAssignment(
32
- ts.factory.createIdentifier(key),
33
- programmer({
34
- ...project,
35
- options: {
36
- numeric: false,
37
- finite: false,
38
- functional: false,
39
- },
40
- })(modulo)(type),
41
- ),
42
- ]);
43
-
44
- // RETURNS
45
- const category = project.options.validate;
46
- if (category === "is" || category === "equals")
47
- return parameter("is")(HttpIsQueryProgrammer.write);
48
- else if (
49
- category === "validate" ||
50
- category === "validateEquals" ||
51
- category === "validateClone" ||
52
- category === "validatePrune"
53
- )
54
- return parameter("validate")(HttpValidateQueryProgrammer.write);
55
- return parameter("assert")(HttpAssertQueryProgrammer.write);
56
- };
57
- }
1
+ import ts from "typescript";
2
+ import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
3
+ import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
4
+ import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
5
+ import { IProject } from "typia/lib/transformers/IProject";
6
+
7
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
8
+ import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
+
10
+ export namespace TypedQueryBodyProgrammer {
11
+ export const generate =
12
+ (project: INestiaTransformProject) =>
13
+ (modulo: ts.LeftHandSideExpression) =>
14
+ (type: ts.Type): ts.ObjectLiteralExpression => {
15
+ // GENERATE VALIDATION PLAN
16
+ const parameter =
17
+ (key: IRequestQueryValidator<any>["type"]) =>
18
+ (
19
+ programmer: (
20
+ project: IProject,
21
+ ) => (
22
+ modulo: ts.LeftHandSideExpression,
23
+ ) => (type: ts.Type) => ts.ArrowFunction,
24
+ ) =>
25
+ ts.factory.createObjectLiteralExpression([
26
+ ts.factory.createPropertyAssignment(
27
+ ts.factory.createIdentifier("type"),
28
+ ts.factory.createStringLiteral(key),
29
+ ),
30
+ ts.factory.createPropertyAssignment(
31
+ ts.factory.createIdentifier(key),
32
+ programmer({
33
+ ...project,
34
+ options: {
35
+ numeric: false,
36
+ finite: false,
37
+ functional: false,
38
+ },
39
+ })(modulo)(type),
40
+ ),
41
+ ]);
42
+
43
+ // RETURNS
44
+ const category = project.options.validate;
45
+ if (category === "is" || category === "equals")
46
+ return parameter("is")(HttpIsQueryProgrammer.write);
47
+ else if (
48
+ category === "validate" ||
49
+ category === "validateEquals" ||
50
+ category === "validateClone" ||
51
+ category === "validatePrune"
52
+ )
53
+ return parameter("validate")(HttpValidateQueryProgrammer.write);
54
+ return parameter("assert")(HttpAssertQueryProgrammer.write);
55
+ };
56
+ }
@@ -1,57 +1,56 @@
1
- import ts from "typescript";
2
-
3
- import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
4
- import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
5
- import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
6
- import { IProject } from "typia/lib/transformers/IProject";
7
-
8
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
9
- import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
10
-
11
- export namespace TypedQueryProgrammer {
12
- export const generate =
13
- (project: INestiaTransformProject) =>
14
- (modulo: ts.LeftHandSideExpression) =>
15
- (type: ts.Type): ts.Expression => {
16
- // GENERATE VALIDATION PLAN
17
- const parameter =
18
- (key: IRequestQueryValidator<any>["type"]) =>
19
- (
20
- programmer: (
21
- project: IProject,
22
- ) => (
23
- modulo: ts.LeftHandSideExpression,
24
- ) => (type: ts.Type) => ts.ArrowFunction,
25
- ) =>
26
- ts.factory.createObjectLiteralExpression([
27
- ts.factory.createPropertyAssignment(
28
- ts.factory.createIdentifier("type"),
29
- ts.factory.createStringLiteral(key),
30
- ),
31
- ts.factory.createPropertyAssignment(
32
- ts.factory.createIdentifier(key),
33
- programmer({
34
- ...project,
35
- options: {
36
- numeric: false,
37
- finite: false,
38
- functional: false,
39
- },
40
- })(modulo)(type),
41
- ),
42
- ]);
43
-
44
- // RETURNS
45
- const category = project.options.validate;
46
- if (category === "is" || category === "equals")
47
- return parameter("is")(HttpIsQueryProgrammer.write);
48
- else if (
49
- category === "validate" ||
50
- category === "validateEquals" ||
51
- category === "validateClone" ||
52
- category === "validatePrune"
53
- )
54
- return parameter("validate")(HttpValidateQueryProgrammer.write);
55
- return parameter("assert")(HttpAssertQueryProgrammer.write);
56
- };
57
- }
1
+ import ts from "typescript";
2
+ import { HttpAssertQueryProgrammer } from "typia/lib/programmers/http/HttpAssertQueryProgrammer";
3
+ import { HttpIsQueryProgrammer } from "typia/lib/programmers/http/HttpIsQueryProgrammer";
4
+ import { HttpValidateQueryProgrammer } from "typia/lib/programmers/http/HttpValidateQueryProgrammer";
5
+ import { IProject } from "typia/lib/transformers/IProject";
6
+
7
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
8
+ import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
+
10
+ export namespace TypedQueryProgrammer {
11
+ export const generate =
12
+ (project: INestiaTransformProject) =>
13
+ (modulo: ts.LeftHandSideExpression) =>
14
+ (type: ts.Type): ts.Expression => {
15
+ // GENERATE VALIDATION PLAN
16
+ const parameter =
17
+ (key: IRequestQueryValidator<any>["type"]) =>
18
+ (
19
+ programmer: (
20
+ project: IProject,
21
+ ) => (
22
+ modulo: ts.LeftHandSideExpression,
23
+ ) => (type: ts.Type) => ts.ArrowFunction,
24
+ ) =>
25
+ ts.factory.createObjectLiteralExpression([
26
+ ts.factory.createPropertyAssignment(
27
+ ts.factory.createIdentifier("type"),
28
+ ts.factory.createStringLiteral(key),
29
+ ),
30
+ ts.factory.createPropertyAssignment(
31
+ ts.factory.createIdentifier(key),
32
+ programmer({
33
+ ...project,
34
+ options: {
35
+ numeric: false,
36
+ finite: false,
37
+ functional: false,
38
+ },
39
+ })(modulo)(type),
40
+ ),
41
+ ]);
42
+
43
+ // RETURNS
44
+ const category = project.options.validate;
45
+ if (category === "is" || category === "equals")
46
+ return parameter("is")(HttpIsQueryProgrammer.write);
47
+ else if (
48
+ category === "validate" ||
49
+ category === "validateEquals" ||
50
+ category === "validateClone" ||
51
+ category === "validatePrune"
52
+ )
53
+ return parameter("validate")(HttpValidateQueryProgrammer.write);
54
+ return parameter("assert")(HttpAssertQueryProgrammer.write);
55
+ };
56
+ }
@@ -1,55 +1,51 @@
1
- import ts from "typescript";
2
-
3
- import { IProject } from "typia/lib/transformers/IProject";
4
-
5
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
6
- import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
7
- import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
8
- import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
9
- import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
10
-
11
- export namespace TypedQueryRouteProgrammer {
12
- export const generate =
13
- (project: INestiaTransformProject) =>
14
- (modulo: ts.LeftHandSideExpression) =>
15
- (type: ts.Type): ts.Expression => {
16
- // GENERATE STRINGIFY PLAN
17
- const parameter = (
18
- key: string,
19
- programmer: (
20
- project: IProject,
21
- ) => (
22
- modulo: ts.LeftHandSideExpression,
23
- ) => (type: ts.Type) => ts.ArrowFunction,
24
- ) =>
25
- ts.factory.createObjectLiteralExpression([
26
- ts.factory.createPropertyAssignment(
27
- ts.factory.createIdentifier("type"),
28
- ts.factory.createStringLiteral(key),
29
- ),
30
- ts.factory.createPropertyAssignment(
31
- ts.factory.createIdentifier(key),
32
- programmer({
33
- ...project,
34
- options: {}, // use default option
35
- })(modulo)(type),
36
- ),
37
- ]);
38
-
39
- // RETURNS
40
- if (project.options.stringify === "is")
41
- return parameter("is", HttpIsQuerifyProgrammer.write);
42
- else if (project.options.stringify === "validate")
43
- return parameter(
44
- "validate",
45
- HttpValidateQuerifyProgrammer.write,
46
- );
47
- else if (project.options.stringify === "stringify")
48
- return parameter("stringify", HttpQuerifyProgrammer.write);
49
- else if (project.options.stringify === null)
50
- return ts.factory.createNull();
51
-
52
- // ASSERT IS DEFAULT
53
- return parameter("assert", HttpAssertQuerifyProgrammer.write);
54
- };
55
- }
1
+ import ts from "typescript";
2
+ import { IProject } from "typia/lib/transformers/IProject";
3
+
4
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
5
+ import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
6
+ import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
7
+ import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
8
+ import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
9
+
10
+ export namespace TypedQueryRouteProgrammer {
11
+ export const generate =
12
+ (project: INestiaTransformProject) =>
13
+ (modulo: ts.LeftHandSideExpression) =>
14
+ (type: ts.Type): ts.Expression => {
15
+ // GENERATE STRINGIFY PLAN
16
+ const parameter = (
17
+ key: string,
18
+ programmer: (
19
+ project: IProject,
20
+ ) => (
21
+ modulo: ts.LeftHandSideExpression,
22
+ ) => (type: ts.Type) => ts.ArrowFunction,
23
+ ) =>
24
+ ts.factory.createObjectLiteralExpression([
25
+ ts.factory.createPropertyAssignment(
26
+ ts.factory.createIdentifier("type"),
27
+ ts.factory.createStringLiteral(key),
28
+ ),
29
+ ts.factory.createPropertyAssignment(
30
+ ts.factory.createIdentifier(key),
31
+ programmer({
32
+ ...project,
33
+ options: {}, // use default option
34
+ })(modulo)(type),
35
+ ),
36
+ ]);
37
+
38
+ // RETURNS
39
+ if (project.options.stringify === "is")
40
+ return parameter("is", HttpIsQuerifyProgrammer.write);
41
+ else if (project.options.stringify === "validate")
42
+ return parameter("validate", HttpValidateQuerifyProgrammer.write);
43
+ else if (project.options.stringify === "stringify")
44
+ return parameter("stringify", HttpQuerifyProgrammer.write);
45
+ else if (project.options.stringify === null)
46
+ return ts.factory.createNull();
47
+
48
+ // ASSERT IS DEFAULT
49
+ return parameter("assert", HttpAssertQuerifyProgrammer.write);
50
+ };
51
+ }
@@ -1,55 +1,51 @@
1
- import ts from "typescript";
2
-
3
- import { JsonAssertStringifyProgrammer } from "typia/lib/programmers/json/JsonAssertStringifyProgrammer";
4
- import { JsonIsStringifyProgrammer } from "typia/lib/programmers/json/JsonIsStringifyProgrammer";
5
- import { JsonStringifyProgrammer } from "typia/lib/programmers/json/JsonStringifyProgrammer";
6
- import { JsonValidateStringifyProgrammer } from "typia/lib/programmers/json/JsonValidateStringifyProgrammer";
7
- import { IProject } from "typia/lib/transformers/IProject";
8
-
9
- import { INestiaTransformProject } from "../options/INestiaTransformProject";
10
-
11
- export namespace TypedRouteProgrammer {
12
- export const generate =
13
- (project: INestiaTransformProject) =>
14
- (modulo: ts.LeftHandSideExpression) =>
15
- (type: ts.Type): ts.Expression => {
16
- // GENERATE STRINGIFY PLAN
17
- const parameter = (
18
- key: string,
19
- programmer: (
20
- project: IProject,
21
- ) => (
22
- modulo: ts.LeftHandSideExpression,
23
- ) => (type: ts.Type) => ts.ArrowFunction,
24
- ) =>
25
- ts.factory.createObjectLiteralExpression([
26
- ts.factory.createPropertyAssignment(
27
- ts.factory.createIdentifier("type"),
28
- ts.factory.createStringLiteral(key),
29
- ),
30
- ts.factory.createPropertyAssignment(
31
- ts.factory.createIdentifier(key),
32
- programmer({
33
- ...project,
34
- options: {}, // use default option
35
- })(modulo)(type),
36
- ),
37
- ]);
38
-
39
- // RETURNS
40
- if (project.options.stringify === "is")
41
- return parameter("is", JsonIsStringifyProgrammer.write);
42
- else if (project.options.stringify === "validate")
43
- return parameter(
44
- "validate",
45
- JsonValidateStringifyProgrammer.write,
46
- );
47
- else if (project.options.stringify === "stringify")
48
- return parameter("stringify", JsonStringifyProgrammer.write);
49
- else if (project.options.stringify === null)
50
- return ts.factory.createNull();
51
-
52
- // ASSERT IS DEFAULT
53
- return parameter("assert", JsonAssertStringifyProgrammer.write);
54
- };
55
- }
1
+ import ts from "typescript";
2
+ import { JsonAssertStringifyProgrammer } from "typia/lib/programmers/json/JsonAssertStringifyProgrammer";
3
+ import { JsonIsStringifyProgrammer } from "typia/lib/programmers/json/JsonIsStringifyProgrammer";
4
+ import { JsonStringifyProgrammer } from "typia/lib/programmers/json/JsonStringifyProgrammer";
5
+ import { JsonValidateStringifyProgrammer } from "typia/lib/programmers/json/JsonValidateStringifyProgrammer";
6
+ import { IProject } from "typia/lib/transformers/IProject";
7
+
8
+ import { INestiaTransformProject } from "../options/INestiaTransformProject";
9
+
10
+ export namespace TypedRouteProgrammer {
11
+ export const generate =
12
+ (project: INestiaTransformProject) =>
13
+ (modulo: ts.LeftHandSideExpression) =>
14
+ (type: ts.Type): ts.Expression => {
15
+ // GENERATE STRINGIFY PLAN
16
+ const parameter = (
17
+ key: string,
18
+ programmer: (
19
+ project: IProject,
20
+ ) => (
21
+ modulo: ts.LeftHandSideExpression,
22
+ ) => (type: ts.Type) => ts.ArrowFunction,
23
+ ) =>
24
+ ts.factory.createObjectLiteralExpression([
25
+ ts.factory.createPropertyAssignment(
26
+ ts.factory.createIdentifier("type"),
27
+ ts.factory.createStringLiteral(key),
28
+ ),
29
+ ts.factory.createPropertyAssignment(
30
+ ts.factory.createIdentifier(key),
31
+ programmer({
32
+ ...project,
33
+ options: {}, // use default option
34
+ })(modulo)(type),
35
+ ),
36
+ ]);
37
+
38
+ // RETURNS
39
+ if (project.options.stringify === "is")
40
+ return parameter("is", JsonIsStringifyProgrammer.write);
41
+ else if (project.options.stringify === "validate")
42
+ return parameter("validate", JsonValidateStringifyProgrammer.write);
43
+ else if (project.options.stringify === "stringify")
44
+ return parameter("stringify", JsonStringifyProgrammer.write);
45
+ else if (project.options.stringify === null)
46
+ return ts.factory.createNull();
47
+
48
+ // ASSERT IS DEFAULT
49
+ return parameter("assert", JsonAssertStringifyProgrammer.write);
50
+ };
51
+ }
@@ -1,59 +1,58 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
- import { AssertProgrammer } from "typia/lib/programmers/AssertProgrammer";
6
- import { IProject } from "typia/lib/transformers/IProject";
7
-
8
- import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
9
-
10
- export namespace HttpAssertQuerifyProgrammer {
11
- export const write =
12
- (project: IProject) =>
13
- (modulo: ts.LeftHandSideExpression) =>
14
- (type: ts.Type, name?: string): 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
- "assert",
24
- AssertProgrammer.write({
25
- ...project,
26
- options: {
27
- ...project.options,
28
- functional: false,
29
- numeric: false,
30
- },
31
- })(modulo)(false)(type, name),
32
- ),
33
- StatementFactory.constant(
34
- "stringify",
35
- HttpQuerifyProgrammer.write({
36
- ...project,
37
- options: {
38
- ...project.options,
39
- functional: false,
40
- numeric: false,
41
- },
42
- })(modulo)(type),
43
- ),
44
- ts.factory.createReturnStatement(
45
- ts.factory.createCallExpression(
46
- ts.factory.createIdentifier("stringify"),
47
- undefined,
48
- [
49
- ts.factory.createCallExpression(
50
- ts.factory.createIdentifier("assert"),
51
- undefined,
52
- [ts.factory.createIdentifier("input")],
53
- ),
54
- ],
55
- ),
56
- ),
57
- ]),
58
- );
59
- }
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
+ }