@nestia/core 4.3.0 → 4.4.0-dev.20241216

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 (74) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +87 -87
  3. package/package.json +5 -5
  4. package/src/adaptors/WebSocketAdaptor.ts +426 -426
  5. package/src/decorators/DynamicModule.ts +43 -43
  6. package/src/decorators/EncryptedBody.ts +101 -101
  7. package/src/decorators/EncryptedController.ts +38 -38
  8. package/src/decorators/EncryptedModule.ts +100 -100
  9. package/src/decorators/EncryptedRoute.ts +219 -219
  10. package/src/decorators/NoTransformConfigurationError.ts +32 -32
  11. package/src/decorators/PlainBody.ts +79 -79
  12. package/src/decorators/SwaggerCustomizer.ts +115 -115
  13. package/src/decorators/SwaggerExample.ts +100 -100
  14. package/src/decorators/TypedBody.ts +59 -59
  15. package/src/decorators/TypedException.ts +128 -128
  16. package/src/decorators/TypedFormData.ts +195 -195
  17. package/src/decorators/TypedHeaders.ts +64 -64
  18. package/src/decorators/TypedParam.ts +66 -66
  19. package/src/decorators/TypedQuery.ts +245 -245
  20. package/src/decorators/TypedRoute.ts +214 -214
  21. package/src/decorators/WebSocketRoute.ts +242 -242
  22. package/src/decorators/internal/EncryptedConstant.ts +4 -4
  23. package/src/decorators/internal/IWebSocketRouteReflect.ts +23 -23
  24. package/src/decorators/internal/NoTransformConfigureError.ts +2 -2
  25. package/src/decorators/internal/get_path_and_querify.ts +108 -108
  26. package/src/decorators/internal/get_path_and_stringify.ts +122 -122
  27. package/src/decorators/internal/get_text_body.ts +20 -20
  28. package/src/decorators/internal/headers_to_object.ts +13 -13
  29. package/src/decorators/internal/is_request_body_undefined.ts +14 -14
  30. package/src/decorators/internal/load_controller.ts +49 -49
  31. package/src/decorators/internal/route_error.ts +45 -45
  32. package/src/decorators/internal/validate_request_body.ts +74 -74
  33. package/src/decorators/internal/validate_request_form_data.ts +77 -77
  34. package/src/decorators/internal/validate_request_headers.ts +86 -86
  35. package/src/decorators/internal/validate_request_query.ts +74 -74
  36. package/src/index.ts +5 -5
  37. package/src/module.ts +21 -21
  38. package/src/options/INestiaTransformOptions.ts +24 -24
  39. package/src/options/INestiaTransformProject.ts +8 -8
  40. package/src/options/IRequestBodyValidator.ts +20 -20
  41. package/src/options/IRequestFormDataProps.ts +27 -27
  42. package/src/options/IRequestHeadersValidator.ts +22 -22
  43. package/src/options/IRequestQueryValidator.ts +20 -20
  44. package/src/options/IResponseBodyQuerifier.ts +25 -25
  45. package/src/options/IResponseBodyStringifier.ts +30 -30
  46. package/src/programmers/PlainBodyProgrammer.ts +70 -70
  47. package/src/programmers/TypedBodyProgrammer.ts +132 -132
  48. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  49. package/src/programmers/TypedHeadersProgrammer.ts +63 -63
  50. package/src/programmers/TypedParamProgrammer.ts +30 -30
  51. package/src/programmers/TypedQueryBodyProgrammer.ts +63 -63
  52. package/src/programmers/TypedQueryProgrammer.ts +65 -65
  53. package/src/programmers/TypedQueryRouteProgrammer.ts +56 -56
  54. package/src/programmers/TypedRouteProgrammer.ts +76 -76
  55. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +72 -72
  56. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +75 -75
  57. package/src/programmers/http/HttpQuerifyProgrammer.ts +108 -108
  58. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +76 -76
  59. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  60. package/src/transform.ts +35 -35
  61. package/src/transformers/FileTransformer.ts +110 -110
  62. package/src/transformers/MethodTransformer.ts +103 -103
  63. package/src/transformers/NodeTransformer.ts +23 -23
  64. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  65. package/src/transformers/ParameterTransformer.ts +57 -57
  66. package/src/transformers/TypedRouteTransformer.ts +85 -85
  67. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
  68. package/src/typings/Creator.ts +3 -3
  69. package/src/typings/get-function-location.d.ts +7 -7
  70. package/src/utils/ArrayUtil.ts +7 -7
  71. package/src/utils/ExceptionManager.ts +112 -112
  72. package/src/utils/Singleton.ts +20 -20
  73. package/src/utils/SourceFinder.ts +57 -57
  74. package/src/utils/VersioningStrategy.ts +27 -27
@@ -1,63 +1,63 @@
1
- import ts from "typescript";
2
- import { HttpAssertHeadersProgrammer } from "typia/lib/programmers/http/HttpAssertHeadersProgrammer";
3
- import { HttpIsHeadersProgrammer } from "typia/lib/programmers/http/HttpIsHeadersProgrammer";
4
- import { HttpValidateHeadersProgrammer } from "typia/lib/programmers/http/HttpValidateHeadersProgrammer";
5
- import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
-
7
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
- import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
9
-
10
- export namespace TypedHeadersProgrammer {
11
- export const generate = (props: {
12
- context: INestiaTransformContext;
13
- modulo: ts.LeftHandSideExpression;
14
- type: ts.Type;
15
- }): ts.Expression => {
16
- // GENERATE VALIDATION PLAN
17
- const parameter =
18
- (key: IRequestHeadersValidator<any>["type"]) =>
19
- (
20
- programmer: (next: {
21
- context: ITypiaContext;
22
- modulo: ts.LeftHandSideExpression;
23
- type: ts.Type;
24
- name: string | undefined;
25
- }) => ts.Expression,
26
- ) =>
27
- ts.factory.createObjectLiteralExpression([
28
- ts.factory.createPropertyAssignment(
29
- ts.factory.createIdentifier("type"),
30
- ts.factory.createStringLiteral(key),
31
- ),
32
- ts.factory.createPropertyAssignment(
33
- ts.factory.createIdentifier(key),
34
- programmer({
35
- context: {
36
- ...props.context,
37
- options: {
38
- numeric: false,
39
- finite: false,
40
- functional: false,
41
- },
42
- },
43
- modulo: props.modulo,
44
- type: props.type,
45
- name: undefined,
46
- }),
47
- ),
48
- ]);
49
-
50
- // RETURNS
51
- const category = props.context.options.validate;
52
- if (category === "is" || category === "equals")
53
- return parameter("is")(HttpIsHeadersProgrammer.write);
54
- else if (
55
- category === "validate" ||
56
- category === "validateEquals" ||
57
- category === "validateClone" ||
58
- category === "validatePrune"
59
- )
60
- return parameter("validate")(HttpValidateHeadersProgrammer.write);
61
- return parameter("assert")(HttpAssertHeadersProgrammer.write);
62
- };
63
- }
1
+ import ts from "typescript";
2
+ import { HttpAssertHeadersProgrammer } from "typia/lib/programmers/http/HttpAssertHeadersProgrammer";
3
+ import { HttpIsHeadersProgrammer } from "typia/lib/programmers/http/HttpIsHeadersProgrammer";
4
+ import { HttpValidateHeadersProgrammer } from "typia/lib/programmers/http/HttpValidateHeadersProgrammer";
5
+ import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
+
7
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
+ import { IRequestHeadersValidator } from "../options/IRequestHeadersValidator";
9
+
10
+ export namespace TypedHeadersProgrammer {
11
+ export const generate = (props: {
12
+ context: INestiaTransformContext;
13
+ modulo: ts.LeftHandSideExpression;
14
+ type: ts.Type;
15
+ }): ts.Expression => {
16
+ // GENERATE VALIDATION PLAN
17
+ const parameter =
18
+ (key: IRequestHeadersValidator<any>["type"]) =>
19
+ (
20
+ programmer: (next: {
21
+ context: ITypiaContext;
22
+ modulo: ts.LeftHandSideExpression;
23
+ type: ts.Type;
24
+ name: string | undefined;
25
+ }) => ts.Expression,
26
+ ) =>
27
+ ts.factory.createObjectLiteralExpression([
28
+ ts.factory.createPropertyAssignment(
29
+ ts.factory.createIdentifier("type"),
30
+ ts.factory.createStringLiteral(key),
31
+ ),
32
+ ts.factory.createPropertyAssignment(
33
+ ts.factory.createIdentifier(key),
34
+ programmer({
35
+ context: {
36
+ ...props.context,
37
+ options: {
38
+ numeric: false,
39
+ finite: false,
40
+ functional: false,
41
+ },
42
+ },
43
+ modulo: props.modulo,
44
+ type: props.type,
45
+ name: undefined,
46
+ }),
47
+ ),
48
+ ]);
49
+
50
+ // RETURNS
51
+ const category = props.context.options.validate;
52
+ if (category === "is" || category === "equals")
53
+ return parameter("is")(HttpIsHeadersProgrammer.write);
54
+ else if (
55
+ category === "validate" ||
56
+ category === "validateEquals" ||
57
+ category === "validateClone" ||
58
+ category === "validatePrune"
59
+ )
60
+ return parameter("validate")(HttpValidateHeadersProgrammer.write);
61
+ return parameter("assert")(HttpAssertHeadersProgrammer.write);
62
+ };
63
+ }
@@ -1,30 +1,30 @@
1
- import ts from "typescript";
2
- import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
3
-
4
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
5
-
6
- export namespace TypedParamProgrammer {
7
- export const generate = (props: {
8
- context: INestiaTransformContext;
9
- modulo: ts.LeftHandSideExpression;
10
- arguments: readonly ts.Expression[];
11
- type: ts.Type;
12
- }): readonly ts.Expression[] => {
13
- // ALREADY BEING TRANSFORMED
14
- if (props.arguments.length !== 1) return props.arguments;
15
- return [
16
- props.arguments[0],
17
- HttpParameterProgrammer.write({
18
- context: {
19
- ...props.context,
20
- options: {
21
- numeric: true,
22
- },
23
- },
24
- modulo: props.modulo,
25
- type: props.type,
26
- name: undefined,
27
- }),
28
- ];
29
- };
30
- }
1
+ import ts from "typescript";
2
+ import { HttpParameterProgrammer } from "typia/lib/programmers/http/HttpParameterProgrammer";
3
+
4
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
5
+
6
+ export namespace TypedParamProgrammer {
7
+ export const generate = (props: {
8
+ context: INestiaTransformContext;
9
+ modulo: ts.LeftHandSideExpression;
10
+ arguments: readonly ts.Expression[];
11
+ type: ts.Type;
12
+ }): readonly ts.Expression[] => {
13
+ // ALREADY BEING TRANSFORMED
14
+ if (props.arguments.length !== 1) return props.arguments;
15
+ return [
16
+ props.arguments[0],
17
+ HttpParameterProgrammer.write({
18
+ context: {
19
+ ...props.context,
20
+ options: {
21
+ numeric: true,
22
+ },
23
+ },
24
+ modulo: props.modulo,
25
+ type: props.type,
26
+ name: undefined,
27
+ }),
28
+ ];
29
+ };
30
+ }
@@ -1,63 +1,63 @@
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
-
7
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
- import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
-
10
- export namespace TypedQueryBodyProgrammer {
11
- export const generate = (props: {
12
- context: INestiaTransformContext;
13
- modulo: ts.LeftHandSideExpression;
14
- type: ts.Type;
15
- }): ts.ObjectLiteralExpression => {
16
- // GENERATE VALIDATION PLAN
17
- const parameter =
18
- (key: IRequestQueryValidator<any>["type"]) =>
19
- (
20
- programmer: (next: {
21
- context: ITypiaContext;
22
- modulo: ts.LeftHandSideExpression;
23
- type: ts.Type;
24
- name: string | undefined;
25
- }) => ts.Expression,
26
- ) =>
27
- ts.factory.createObjectLiteralExpression([
28
- ts.factory.createPropertyAssignment(
29
- ts.factory.createIdentifier("type"),
30
- ts.factory.createStringLiteral(key),
31
- ),
32
- ts.factory.createPropertyAssignment(
33
- ts.factory.createIdentifier(key),
34
- programmer({
35
- context: {
36
- ...props.context,
37
- options: {
38
- numeric: false,
39
- finite: false,
40
- functional: false,
41
- },
42
- },
43
- modulo: props.modulo,
44
- type: props.type,
45
- name: undefined,
46
- }),
47
- ),
48
- ]);
49
-
50
- // RETURNS
51
- const category = props.context.options.validate;
52
- if (category === "is" || category === "equals")
53
- return parameter("is")(HttpIsQueryProgrammer.write);
54
- else if (
55
- category === "validate" ||
56
- category === "validateEquals" ||
57
- category === "validateClone" ||
58
- category === "validatePrune"
59
- )
60
- return parameter("validate")(HttpValidateQueryProgrammer.write);
61
- return parameter("assert")(HttpAssertQueryProgrammer.write);
62
- };
63
- }
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
+
7
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
+ import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
+
10
+ export namespace TypedQueryBodyProgrammer {
11
+ export const generate = (props: {
12
+ context: INestiaTransformContext;
13
+ modulo: ts.LeftHandSideExpression;
14
+ type: ts.Type;
15
+ }): ts.ObjectLiteralExpression => {
16
+ // GENERATE VALIDATION PLAN
17
+ const parameter =
18
+ (key: IRequestQueryValidator<any>["type"]) =>
19
+ (
20
+ programmer: (next: {
21
+ context: ITypiaContext;
22
+ modulo: ts.LeftHandSideExpression;
23
+ type: ts.Type;
24
+ name: string | undefined;
25
+ }) => ts.Expression,
26
+ ) =>
27
+ ts.factory.createObjectLiteralExpression([
28
+ ts.factory.createPropertyAssignment(
29
+ ts.factory.createIdentifier("type"),
30
+ ts.factory.createStringLiteral(key),
31
+ ),
32
+ ts.factory.createPropertyAssignment(
33
+ ts.factory.createIdentifier(key),
34
+ programmer({
35
+ context: {
36
+ ...props.context,
37
+ options: {
38
+ numeric: false,
39
+ finite: false,
40
+ functional: false,
41
+ },
42
+ },
43
+ modulo: props.modulo,
44
+ type: props.type,
45
+ name: undefined,
46
+ }),
47
+ ),
48
+ ]);
49
+
50
+ // RETURNS
51
+ const category = props.context.options.validate;
52
+ if (category === "is" || category === "equals")
53
+ return parameter("is")(HttpIsQueryProgrammer.write);
54
+ else if (
55
+ category === "validate" ||
56
+ category === "validateEquals" ||
57
+ category === "validateClone" ||
58
+ category === "validatePrune"
59
+ )
60
+ return parameter("validate")(HttpValidateQueryProgrammer.write);
61
+ return parameter("assert")(HttpAssertQueryProgrammer.write);
62
+ };
63
+ }
@@ -1,65 +1,65 @@
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
-
7
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
- import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
-
10
- export namespace TypedQueryProgrammer {
11
- export const generate = (props: {
12
- context: INestiaTransformContext;
13
- modulo: ts.LeftHandSideExpression;
14
- type: ts.Type;
15
- }): ts.Expression => {
16
- // GENERATE VALIDATION PLAN
17
- const parameter =
18
- (key: IRequestQueryValidator<any>["type"]) =>
19
- (
20
- programmer: (next: {
21
- context: ITypiaContext;
22
- modulo: ts.LeftHandSideExpression;
23
- type: ts.Type;
24
- name: string | undefined;
25
- allowOptional: boolean;
26
- }) => ts.Expression,
27
- ) =>
28
- ts.factory.createObjectLiteralExpression([
29
- ts.factory.createPropertyAssignment(
30
- ts.factory.createIdentifier("type"),
31
- ts.factory.createStringLiteral(key),
32
- ),
33
- ts.factory.createPropertyAssignment(
34
- ts.factory.createIdentifier(key),
35
- programmer({
36
- context: {
37
- ...props.context,
38
- options: {
39
- numeric: false,
40
- finite: false,
41
- functional: false,
42
- },
43
- },
44
- modulo: props.modulo,
45
- type: props.type,
46
- name: undefined,
47
- allowOptional: true,
48
- }),
49
- ),
50
- ]);
51
-
52
- // RETURNS
53
- const category = props.context.options.validate;
54
- if (category === "is" || category === "equals")
55
- return parameter("is")(HttpIsQueryProgrammer.write);
56
- else if (
57
- category === "validate" ||
58
- category === "validateEquals" ||
59
- category === "validateClone" ||
60
- category === "validatePrune"
61
- )
62
- return parameter("validate")(HttpValidateQueryProgrammer.write);
63
- return parameter("assert")(HttpAssertQueryProgrammer.write);
64
- };
65
- }
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 { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
6
+
7
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
8
+ import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
9
+
10
+ export namespace TypedQueryProgrammer {
11
+ export const generate = (props: {
12
+ context: INestiaTransformContext;
13
+ modulo: ts.LeftHandSideExpression;
14
+ type: ts.Type;
15
+ }): ts.Expression => {
16
+ // GENERATE VALIDATION PLAN
17
+ const parameter =
18
+ (key: IRequestQueryValidator<any>["type"]) =>
19
+ (
20
+ programmer: (next: {
21
+ context: ITypiaContext;
22
+ modulo: ts.LeftHandSideExpression;
23
+ type: ts.Type;
24
+ name: string | undefined;
25
+ allowOptional: boolean;
26
+ }) => ts.Expression,
27
+ ) =>
28
+ ts.factory.createObjectLiteralExpression([
29
+ ts.factory.createPropertyAssignment(
30
+ ts.factory.createIdentifier("type"),
31
+ ts.factory.createStringLiteral(key),
32
+ ),
33
+ ts.factory.createPropertyAssignment(
34
+ ts.factory.createIdentifier(key),
35
+ programmer({
36
+ context: {
37
+ ...props.context,
38
+ options: {
39
+ numeric: false,
40
+ finite: false,
41
+ functional: false,
42
+ },
43
+ },
44
+ modulo: props.modulo,
45
+ type: props.type,
46
+ name: undefined,
47
+ allowOptional: true,
48
+ }),
49
+ ),
50
+ ]);
51
+
52
+ // RETURNS
53
+ const category = props.context.options.validate;
54
+ if (category === "is" || category === "equals")
55
+ return parameter("is")(HttpIsQueryProgrammer.write);
56
+ else if (
57
+ category === "validate" ||
58
+ category === "validateEquals" ||
59
+ category === "validateClone" ||
60
+ category === "validatePrune"
61
+ )
62
+ return parameter("validate")(HttpValidateQueryProgrammer.write);
63
+ return parameter("assert")(HttpAssertQueryProgrammer.write);
64
+ };
65
+ }
@@ -1,56 +1,56 @@
1
- import ts from "typescript";
2
- import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
3
-
4
- import { INestiaTransformContext } 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 = (props: {
12
- context: INestiaTransformContext;
13
- modulo: ts.LeftHandSideExpression;
14
- type: ts.Type;
15
- }): ts.Expression => {
16
- // GENERATE STRINGIFY PLAN
17
- const parameter = (
18
- key: string,
19
- programmer: (next: {
20
- context: ITypiaContext;
21
- modulo: ts.LeftHandSideExpression;
22
- type: ts.Type;
23
- }) => 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
- context: {
34
- ...props.context,
35
- options: {}, // use default option
36
- },
37
- modulo: props.modulo,
38
- type: props.type,
39
- }),
40
- ),
41
- ]);
42
-
43
- // RETURNS
44
- if (props.context.options.stringify === "is")
45
- return parameter("is", HttpIsQuerifyProgrammer.write);
46
- else if (props.context.options.stringify === "validate")
47
- return parameter("validate", HttpValidateQuerifyProgrammer.write);
48
- else if (props.context.options.stringify === "stringify")
49
- return parameter("stringify", HttpQuerifyProgrammer.write);
50
- else if (props.context.options.stringify === null)
51
- return ts.factory.createNull();
52
-
53
- // ASSERT IS DEFAULT
54
- return parameter("assert", HttpAssertQuerifyProgrammer.write);
55
- };
56
- }
1
+ import ts from "typescript";
2
+ import { ITypiaContext } from "typia/lib/transformers/ITypiaContext";
3
+
4
+ import { INestiaTransformContext } 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 = (props: {
12
+ context: INestiaTransformContext;
13
+ modulo: ts.LeftHandSideExpression;
14
+ type: ts.Type;
15
+ }): ts.Expression => {
16
+ // GENERATE STRINGIFY PLAN
17
+ const parameter = (
18
+ key: string,
19
+ programmer: (next: {
20
+ context: ITypiaContext;
21
+ modulo: ts.LeftHandSideExpression;
22
+ type: ts.Type;
23
+ }) => 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
+ context: {
34
+ ...props.context,
35
+ options: {}, // use default option
36
+ },
37
+ modulo: props.modulo,
38
+ type: props.type,
39
+ }),
40
+ ),
41
+ ]);
42
+
43
+ // RETURNS
44
+ if (props.context.options.stringify === "is")
45
+ return parameter("is", HttpIsQuerifyProgrammer.write);
46
+ else if (props.context.options.stringify === "validate")
47
+ return parameter("validate", HttpValidateQuerifyProgrammer.write);
48
+ else if (props.context.options.stringify === "stringify")
49
+ return parameter("stringify", HttpQuerifyProgrammer.write);
50
+ else if (props.context.options.stringify === null)
51
+ return ts.factory.createNull();
52
+
53
+ // ASSERT IS DEFAULT
54
+ return parameter("assert", HttpAssertQuerifyProgrammer.write);
55
+ };
56
+ }