@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,63 +1,62 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
- import { IsProgrammer } from "typia/lib/programmers/IsProgrammer";
6
- import { IProject } from "typia/lib/transformers/IProject";
7
-
8
- import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
9
-
10
- export namespace HttpIsQuerifyProgrammer {
11
- export const write =
12
- (project: IProject) =>
13
- (modulo: ts.LeftHandSideExpression) =>
14
- (type: ts.Type): 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
- "is",
24
- IsProgrammer.write({
25
- ...project,
26
- options: {
27
- ...project.options,
28
- functional: false,
29
- numeric: false,
30
- },
31
- })(modulo)(false)(type),
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.createConditionalExpression(
46
- ts.factory.createCallExpression(
47
- ts.factory.createIdentifier("is"),
48
- undefined,
49
- [ts.factory.createIdentifier("input")],
50
- ),
51
- undefined,
52
- ts.factory.createCallExpression(
53
- ts.factory.createIdentifier("stringify"),
54
- undefined,
55
- [ts.factory.createIdentifier("input")],
56
- ),
57
- undefined,
58
- ts.factory.createNull(),
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 { 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,105 +1,96 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { MetadataCollection } from "typia/lib/factories/MetadataCollection";
5
- import { MetadataFactory } from "typia/lib/factories/MetadataFactory";
6
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
7
- import { FunctionImporter } from "typia/lib/programmers/helpers/FunctionImporeter";
8
- import { HttpQueryProgrammer } from "typia/lib/programmers/http/HttpQueryProgrammer";
9
- import { Metadata } from "typia/lib/schemas/metadata/Metadata";
10
- import { MetadataObject } from "typia/lib/schemas/metadata/MetadataObject";
11
- import { IProject } from "typia/lib/transformers/IProject";
12
- import { TransformerError } from "typia/lib/transformers/TransformerError";
13
-
14
- export namespace HttpQuerifyProgrammer {
15
- export const write =
16
- (project: IProject) =>
17
- (modulo: ts.LeftHandSideExpression) =>
18
- (type: ts.Type): ts.ArrowFunction => {
19
- // GET OBJECT TYPE
20
- const importer: FunctionImporter = new FunctionImporter(
21
- modulo.getText(),
22
- );
23
- const collection: MetadataCollection = new MetadataCollection();
24
- const result = MetadataFactory.analyze(project.checker)({
25
- escape: false,
26
- constant: true,
27
- absorb: true,
28
- validate: HttpQueryProgrammer.validate,
29
- })(collection)(type);
30
- if (result.success === false)
31
- throw TransformerError.from(
32
- `@nestia.core.TypedQuery.${importer.method}`,
33
- )(result.errors);
34
-
35
- const object: MetadataObject = result.data.objects[0]!;
36
- return ts.factory.createArrowFunction(
37
- undefined,
38
- undefined,
39
- [IdentifierFactory.parameter("input")],
40
- undefined,
41
- undefined,
42
- ts.factory.createBlock(
43
- [
44
- ...importer.declare(modulo),
45
- StatementFactory.constant(
46
- "output",
47
- ts.factory.createNewExpression(
48
- ts.factory.createIdentifier("URLSearchParams"),
49
- undefined,
50
- [],
51
- ),
52
- ),
53
- ...object.properties.map((p) =>
54
- ts.factory.createExpressionStatement(
55
- decode(p.key.constants[0]!.values[0] as string)(
56
- p.value,
57
- ),
58
- ),
59
- ),
60
- ts.factory.createReturnStatement(
61
- ts.factory.createIdentifier("output"),
62
- ),
63
- ],
64
- true,
65
- ),
66
- );
67
- };
68
-
69
- const decode =
70
- (key: string) =>
71
- (value: Metadata): ts.CallExpression =>
72
- !!value.arrays.length
73
- ? ts.factory.createCallExpression(
74
- IdentifierFactory.access(
75
- IdentifierFactory.access(
76
- ts.factory.createIdentifier("input"),
77
- )(key),
78
- )("forEach"),
79
- undefined,
80
- [
81
- ts.factory.createArrowFunction(
82
- undefined,
83
- undefined,
84
- [IdentifierFactory.parameter("elem")],
85
- undefined,
86
- undefined,
87
- append(key)(ts.factory.createIdentifier("elem")),
88
- ),
89
- ],
90
- )
91
- : append(key)(
92
- IdentifierFactory.access(
93
- ts.factory.createIdentifier("input"),
94
- )(key),
95
- );
96
-
97
- const append = (key: string) => (elem: ts.Expression) =>
98
- ts.factory.createCallExpression(
99
- IdentifierFactory.access(ts.factory.createIdentifier("output"))(
100
- "append",
101
- ),
102
- undefined,
103
- [ts.factory.createStringLiteral(key), elem],
104
- );
105
- }
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] 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,64 +1,63 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
- import { ValidateProgrammer } from "typia/lib/programmers/ValidateProgrammer";
6
- import { IProject } from "typia/lib/transformers/IProject";
7
-
8
- import { HttpQuerifyProgrammer } from "./HttpQuerifyProgrammer";
9
-
10
- export namespace HttpValidateQuerifyProgrammer {
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
- "validate",
24
- ValidateProgrammer.write({
25
- ...project,
26
- options: {
27
- ...project.options,
28
- functional: false,
29
- numeric: true,
30
- },
31
- })(modulo)(false)(type, name),
32
- ),
33
- StatementFactory.constant(
34
- "query",
35
- HttpQuerifyProgrammer.write({
36
- ...project,
37
- options: {
38
- ...project.options,
39
- functional: false,
40
- numeric: false,
41
- },
42
- })(modulo)(type),
43
- ),
44
- StatementFactory.constant(
45
- "output",
46
- ts.factory.createCallExpression(
47
- ts.factory.createIdentifier("query"),
48
- undefined,
49
- [ts.factory.createIdentifier("input")],
50
- ),
51
- ),
52
- ts.factory.createReturnStatement(
53
- ts.factory.createAsExpression(
54
- ts.factory.createCallExpression(
55
- ts.factory.createIdentifier("validate"),
56
- undefined,
57
- [ts.factory.createIdentifier("output")],
58
- ),
59
- ts.factory.createTypeReferenceNode("any"),
60
- ),
61
- ),
62
- ]),
63
- );
64
- }
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
+ }
package/src/transform.ts CHANGED
@@ -1,36 +1,35 @@
1
- import ts from "typescript";
2
-
3
- import { IProject } from "typia/lib/transformers/IProject";
4
-
5
- import { INestiaTransformOptions } from "./options/INestiaTransformOptions";
6
- import { FileTransformer } from "./transformers/FileTransformer";
7
-
8
- export const transform = (
9
- program: ts.Program,
10
- options: INestiaTransformOptions | undefined,
11
- extras: IProject["extras"],
12
- ): ts.TransformerFactory<ts.SourceFile> => {
13
- const compilerOptions: ts.CompilerOptions = program.getCompilerOptions();
14
- const strict: boolean =
15
- compilerOptions.strictNullChecks !== undefined
16
- ? !!compilerOptions.strictNullChecks
17
- : !!compilerOptions.strict;
18
- if (strict === false)
19
- extras.addDiagnostic({
20
- category: ts.DiagnosticCategory.Error,
21
- code: "(@nestia/core)" as any,
22
- file: undefined,
23
- start: undefined,
24
- length: undefined,
25
- messageText: "strict mode is required.",
26
- });
27
- return FileTransformer.transform({
28
- program,
29
- compilerOptions,
30
- checker: program.getTypeChecker(),
31
- printer: ts.createPrinter(),
32
- options: options ?? {},
33
- extras,
34
- });
35
- };
36
- export default transform;
1
+ import ts from "typescript";
2
+ import { IProject } from "typia/lib/transformers/IProject";
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: IProject["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;