typia 3.5.0-dev.20221222 → 3.5.0-dev.20230124

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 (184) hide show
  1. package/README.md +5 -2
  2. package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
  3. package/lib/executable/internal/TypiaSetupWizard.js +23 -22
  4. package/lib/executable/internal/TypiaSetupWizard.js.map +1 -1
  5. package/lib/executable/typia.js +11 -10
  6. package/lib/executable/typia.js.map +1 -1
  7. package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +1 -0
  8. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +20 -0
  9. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +1 -1
  10. package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +2 -1
  11. package/lib/factories/internal/protocols/iterate_protocol_map.js +7 -4
  12. package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -1
  13. package/lib/factories/internal/protocols/iterate_protocol_metadata.js +3 -3
  14. package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -1
  15. package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +2 -1
  16. package/lib/factories/internal/protocols/iterate_protocol_repeated.js +5 -4
  17. package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -1
  18. package/lib/messages/IProtocolMap.d.ts +5 -0
  19. package/lib/messages/IProtocolMap.js +3 -0
  20. package/lib/messages/IProtocolMap.js.map +1 -0
  21. package/lib/messages/IProtocolProperty.d.ts +2 -1
  22. package/lib/metadata/Metadata.d.ts +1 -0
  23. package/lib/metadata/Metadata.js +145 -51
  24. package/lib/metadata/Metadata.js.map +1 -1
  25. package/lib/programmers/AssertProgrammer.js +1 -1
  26. package/lib/programmers/AssertProgrammer.js.map +1 -1
  27. package/lib/programmers/CheckerProgrammer.d.ts +1 -0
  28. package/lib/programmers/CheckerProgrammer.js +147 -138
  29. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  30. package/lib/programmers/MessageProgrammer.js +7 -2
  31. package/lib/programmers/MessageProgrammer.js.map +1 -1
  32. package/lib/programmers/ValidateProgrammer.js +1 -1
  33. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  34. package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
  35. package/lib/programmers/helpers/UnionExplorer.js +29 -41
  36. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  37. package/lib/programmers/internal/application_array.js +29 -27
  38. package/lib/programmers/internal/application_array.js.map +1 -1
  39. package/lib/programmers/internal/application_object.js +96 -31
  40. package/lib/programmers/internal/application_object.js.map +1 -1
  41. package/lib/programmers/internal/application_schema.js +28 -136
  42. package/lib/programmers/internal/application_schema.js.map +1 -1
  43. package/lib/programmers/internal/application_tuple.js +3 -2
  44. package/lib/programmers/internal/application_tuple.js.map +1 -1
  45. package/lib/programmers/internal/check_array.js +4 -32
  46. package/lib/programmers/internal/check_array.js.map +1 -1
  47. package/lib/programmers/internal/check_array_length.d.ts +1 -0
  48. package/lib/programmers/internal/check_array_length.js +47 -0
  49. package/lib/programmers/internal/check_array_length.js.map +1 -0
  50. package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
  51. package/lib/programmers/internal/check_union_array_like.js +83 -0
  52. package/lib/programmers/internal/check_union_array_like.js.map +1 -0
  53. package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
  54. package/lib/programmers/internal/check_union_tuple.js +11 -0
  55. package/lib/programmers/internal/check_union_tuple.js.map +1 -0
  56. package/lib/schemas/IJsonComponents.d.ts +4 -2
  57. package/lib/schemas/IJsonSchema.d.ts +2 -0
  58. package/package.json +4 -4
  59. package/src/IValidation.ts +21 -21
  60. package/src/Primitive.ts +82 -82
  61. package/src/TypeGuardError.ts +36 -36
  62. package/src/executable/internal/CommandParser.ts +15 -15
  63. package/src/executable/internal/TypiaSetupWizard.ts +30 -21
  64. package/src/executable/typia.ts +48 -46
  65. package/src/factories/CommentFactory.ts +10 -10
  66. package/src/factories/ExpressionFactory.ts +66 -66
  67. package/src/factories/IdentifierFactory.ts +72 -72
  68. package/src/factories/LiteralFactory.ts +44 -44
  69. package/src/factories/StatementFactory.ts +60 -60
  70. package/src/factories/TemplateFactory.ts +56 -56
  71. package/src/factories/TypeFactory.ts +101 -101
  72. package/src/factories/ValueFactory.ts +12 -12
  73. package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +20 -0
  74. package/src/factories/internal/protocols/iterate_protocol_map.ts +9 -3
  75. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +17 -4
  76. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +14 -5
  77. package/src/functional/$every.ts +11 -11
  78. package/src/functional/$guard.ts +35 -35
  79. package/src/functional/$is_email.ts +5 -5
  80. package/src/functional/$is_ipv4.ts +5 -5
  81. package/src/functional/$is_ipv6.ts +5 -5
  82. package/src/functional/$is_url.ts +5 -5
  83. package/src/functional/$is_uuid.ts +5 -5
  84. package/src/functional/$join.ts +50 -50
  85. package/src/functional/$report.ts +15 -15
  86. package/src/functional/$rest.ts +3 -3
  87. package/src/functional/$string.ts +37 -37
  88. package/src/functional/$tail.ts +6 -6
  89. package/src/index.ts +4 -4
  90. package/src/messages/IProtocolMap.ts +5 -0
  91. package/src/messages/IProtocolProperty.ts +3 -1
  92. package/src/metadata/IJsDocTagInfo.ts +10 -10
  93. package/src/metadata/IMetadata.ts +25 -25
  94. package/src/metadata/IMetadataApplication.ts +7 -7
  95. package/src/metadata/IMetadataConstant.ts +16 -16
  96. package/src/metadata/IMetadataEntry.ts +6 -6
  97. package/src/metadata/IMetadataObject.ts +29 -29
  98. package/src/metadata/IMetadataProperty.ts +11 -11
  99. package/src/metadata/Metadata.ts +64 -7
  100. package/src/metadata/MetadataConstant.ts +3 -3
  101. package/src/metadata/MetadataObject.ts +131 -131
  102. package/src/metadata/MetadataProperty.ts +64 -64
  103. package/src/programmers/ApplicationProgrammer.ts +55 -55
  104. package/src/programmers/AssertProgrammer.ts +1 -1
  105. package/src/programmers/CheckerProgrammer.ts +252 -200
  106. package/src/programmers/FeatureProgrammer.ts +327 -327
  107. package/src/programmers/MessageProgrammer.ts +9 -2
  108. package/src/programmers/ValidateProgrammer.ts +1 -1
  109. package/src/programmers/helpers/AtomicPredicator.ts +15 -15
  110. package/src/programmers/helpers/FunctionImporeter.ts +31 -31
  111. package/src/programmers/helpers/IExpressionEntry.ts +10 -10
  112. package/src/programmers/helpers/StringifyJoinder.ts +111 -111
  113. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  114. package/src/programmers/helpers/UnionExplorer.ts +274 -437
  115. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  116. package/src/programmers/internal/application_array.ts +47 -45
  117. package/src/programmers/internal/application_boolean.ts +17 -17
  118. package/src/programmers/internal/application_constant.ts +29 -29
  119. package/src/programmers/internal/application_default_string.ts +32 -32
  120. package/src/programmers/internal/application_native.ts +29 -29
  121. package/src/programmers/internal/application_number.ts +76 -76
  122. package/src/programmers/internal/application_object.ts +153 -103
  123. package/src/programmers/internal/application_schema.ts +15 -68
  124. package/src/programmers/internal/application_string.ts +49 -49
  125. package/src/programmers/internal/application_templates.ts +27 -27
  126. package/src/programmers/internal/application_tuple.ts +29 -25
  127. package/src/programmers/internal/check_array.ts +22 -44
  128. package/src/programmers/internal/check_array_length.ts +45 -0
  129. package/src/programmers/internal/check_dynamic_properties.ts +146 -146
  130. package/src/programmers/internal/check_everything.ts +25 -25
  131. package/src/programmers/internal/check_length.ts +46 -46
  132. package/src/programmers/internal/check_native.ts +9 -9
  133. package/src/programmers/internal/check_object.ts +42 -42
  134. package/src/programmers/internal/check_string.ts +24 -24
  135. package/src/programmers/internal/check_string_tags.ts +63 -63
  136. package/src/programmers/internal/check_template.ts +50 -50
  137. package/src/programmers/internal/check_union_array_like.ts +242 -0
  138. package/src/programmers/internal/check_union_tuple.ts +33 -0
  139. package/src/programmers/internal/decode_union_object.ts +73 -73
  140. package/src/programmers/internal/feature_object_entries.ts +49 -49
  141. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  142. package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
  143. package/src/programmers/internal/stringify_native.ts +8 -8
  144. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  145. package/src/programmers/internal/template_to_pattern.ts +15 -15
  146. package/src/schemas/IJsonApplication.ts +9 -9
  147. package/src/schemas/IJsonComponents.ts +26 -24
  148. package/src/schemas/IJsonSchema.ts +2 -0
  149. package/src/transform.ts +20 -20
  150. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  151. package/src/transformers/FileTransformer.ts +49 -49
  152. package/src/transformers/IProject.ts +11 -11
  153. package/src/transformers/NodeTransformer.ts +19 -19
  154. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +1 -0
  155. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  156. package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
  157. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
  158. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
  159. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
  160. package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
  161. package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
  162. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
  163. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
  164. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
  165. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
  166. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
  167. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
  168. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
  169. package/src/transformers/features/validators/AssertTransformer.ts +43 -43
  170. package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
  171. package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
  172. package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
  173. package/src/transformers/features/validators/IsTransformer.ts +43 -43
  174. package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
  175. package/src/typings/Atomic.ts +17 -17
  176. package/src/typings/ClassProperties.ts +5 -5
  177. package/src/typings/OmitNever.ts +3 -3
  178. package/src/typings/SpecialFields.ts +3 -3
  179. package/src/typings/Writable.ts +11 -11
  180. package/src/utils/ArrayUtil.ts +49 -49
  181. package/src/utils/Escaper.ts +50 -50
  182. package/src/utils/MapUtil.ts +14 -14
  183. package/src/utils/PatternUtil.ts +30 -30
  184. package/src/utils/Singleton.ts +17 -17
@@ -1,81 +1,81 @@
1
- import ts from "typescript";
2
-
3
- import { TemplateFactory } from "../../factories/TemplateFactory";
4
- import { ValueFactory } from "../../factories/ValueFactory";
5
-
6
- import { Metadata } from "../../metadata/Metadata";
7
-
8
- import { IExpressionEntry } from "../helpers/IExpressionEntry";
9
-
10
- /**
11
- * @internal
12
- */
13
- export function stringify_regular_properties(
14
- regular: IExpressionEntry[],
15
- dynamic: IExpressionEntry[],
16
- ): ts.Expression[] {
17
- const output: ts.Expression[] = [];
18
-
19
- regular.sort((x, y) => sequence(x.meta) - sequence(y.meta));
20
- regular.forEach((entry, index) => {
21
- // BASE ELEMENTS
22
- const key: string = entry.key.getSoleLiteral()!;
23
- const base: ts.Expression[] = [
24
- ts.factory.createStringLiteral(`${JSON.stringify(key)}:`),
25
- entry.expression,
26
- ];
27
- if (index !== regular.length - 1 || dynamic.length !== 0)
28
- base.push(ts.factory.createStringLiteral(`,`));
29
-
30
- const empty: boolean =
31
- (entry.meta.required === false &&
32
- entry.meta.nullable === false &&
33
- entry.meta.size() === 0) ||
34
- (entry.meta.functional &&
35
- entry.meta.nullable === false &&
36
- entry.meta.size() === 1);
37
-
38
- if (empty === true) return;
39
- else if (
40
- entry.meta.required === false ||
41
- entry.meta.functional === true ||
42
- entry.meta.any === true
43
- )
44
- output.push(
45
- ts.factory.createConditionalExpression(
46
- (() => {
47
- const conditions: ts.BinaryExpression[] = [];
48
- if (entry.meta.required === false || entry.meta.any)
49
- conditions.push(
50
- ts.factory.createStrictEquality(
51
- ts.factory.createIdentifier("undefined"),
52
- entry.input,
53
- ),
54
- );
55
- if (entry.meta.functional || entry.meta.any)
56
- conditions.push(
57
- ts.factory.createStrictEquality(
58
- ts.factory.createStringLiteral("function"),
59
- ValueFactory.TYPEOF(entry.input),
60
- ),
61
- );
62
- return conditions.length === 1
63
- ? conditions[0]!
64
- : conditions.reduce((x, y) =>
65
- ts.factory.createLogicalOr(x, y),
66
- );
67
- })(),
68
- undefined,
69
- ts.factory.createStringLiteral(""),
70
- undefined,
71
- TemplateFactory.generate(base),
72
- ),
73
- );
74
- else output.push(...base);
75
- });
76
- return output;
77
- }
78
-
79
- function sequence(meta: Metadata): number {
80
- return meta.any || !meta.required || meta.functional ? 0 : 1;
81
- }
1
+ import ts from "typescript";
2
+
3
+ import { TemplateFactory } from "../../factories/TemplateFactory";
4
+ import { ValueFactory } from "../../factories/ValueFactory";
5
+
6
+ import { Metadata } from "../../metadata/Metadata";
7
+
8
+ import { IExpressionEntry } from "../helpers/IExpressionEntry";
9
+
10
+ /**
11
+ * @internal
12
+ */
13
+ export function stringify_regular_properties(
14
+ regular: IExpressionEntry[],
15
+ dynamic: IExpressionEntry[],
16
+ ): ts.Expression[] {
17
+ const output: ts.Expression[] = [];
18
+
19
+ regular.sort((x, y) => sequence(x.meta) - sequence(y.meta));
20
+ regular.forEach((entry, index) => {
21
+ // BASE ELEMENTS
22
+ const key: string = entry.key.getSoleLiteral()!;
23
+ const base: ts.Expression[] = [
24
+ ts.factory.createStringLiteral(`${JSON.stringify(key)}:`),
25
+ entry.expression,
26
+ ];
27
+ if (index !== regular.length - 1 || dynamic.length !== 0)
28
+ base.push(ts.factory.createStringLiteral(`,`));
29
+
30
+ const empty: boolean =
31
+ (entry.meta.required === false &&
32
+ entry.meta.nullable === false &&
33
+ entry.meta.size() === 0) ||
34
+ (entry.meta.functional &&
35
+ entry.meta.nullable === false &&
36
+ entry.meta.size() === 1);
37
+
38
+ if (empty === true) return;
39
+ else if (
40
+ entry.meta.required === false ||
41
+ entry.meta.functional === true ||
42
+ entry.meta.any === true
43
+ )
44
+ output.push(
45
+ ts.factory.createConditionalExpression(
46
+ (() => {
47
+ const conditions: ts.BinaryExpression[] = [];
48
+ if (entry.meta.required === false || entry.meta.any)
49
+ conditions.push(
50
+ ts.factory.createStrictEquality(
51
+ ts.factory.createIdentifier("undefined"),
52
+ entry.input,
53
+ ),
54
+ );
55
+ if (entry.meta.functional || entry.meta.any)
56
+ conditions.push(
57
+ ts.factory.createStrictEquality(
58
+ ts.factory.createStringLiteral("function"),
59
+ ValueFactory.TYPEOF(entry.input),
60
+ ),
61
+ );
62
+ return conditions.length === 1
63
+ ? conditions[0]!
64
+ : conditions.reduce((x, y) =>
65
+ ts.factory.createLogicalOr(x, y),
66
+ );
67
+ })(),
68
+ undefined,
69
+ ts.factory.createStringLiteral(""),
70
+ undefined,
71
+ TemplateFactory.generate(base),
72
+ ),
73
+ );
74
+ else output.push(...base);
75
+ });
76
+ return output;
77
+ }
78
+
79
+ function sequence(meta: Metadata): number {
80
+ return meta.any || !meta.required || meta.functional ? 0 : 1;
81
+ }
@@ -1,15 +1,15 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
-
3
- import { PatternUtil } from "../../utils/PatternUtil";
4
-
5
- import { metadata_to_pattern } from "./metadata_to_pattern";
6
-
7
- /**
8
- * @internal
9
- */
10
- export const template_to_pattern = (top: boolean) => (template: Metadata[]) => {
11
- const pattern: string = template
12
- .map((meta) => metadata_to_pattern(false)(meta))
13
- .join("");
14
- return top ? PatternUtil.fix(pattern) : pattern;
15
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+
3
+ import { PatternUtil } from "../../utils/PatternUtil";
4
+
5
+ import { metadata_to_pattern } from "./metadata_to_pattern";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const template_to_pattern = (top: boolean) => (template: Metadata[]) => {
11
+ const pattern: string = template
12
+ .map((meta) => metadata_to_pattern(false)(meta))
13
+ .join("");
14
+ return top ? PatternUtil.fix(pattern) : pattern;
15
+ };
@@ -1,9 +1,9 @@
1
- import { IJsonComponents } from "./IJsonComponents";
2
- import { IJsonSchema } from "./IJsonSchema";
3
-
4
- export interface IJsonApplication {
5
- schemas: IJsonSchema[];
6
- components: IJsonComponents;
7
- purpose: "swagger" | "ajv";
8
- prefix: string;
9
- }
1
+ import { IJsonComponents } from "./IJsonComponents";
2
+ import { IJsonSchema } from "./IJsonSchema";
3
+
4
+ export interface IJsonApplication {
5
+ schemas: IJsonSchema[];
6
+ components: IJsonComponents;
7
+ purpose: "swagger" | "ajv";
8
+ prefix: string;
9
+ }
@@ -1,24 +1,26 @@
1
- import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
-
3
- import { IJsonSchema } from "./IJsonSchema";
4
-
5
- export interface IJsonComponents {
6
- schemas: Record<string, IJsonComponents.IObject>;
7
- }
8
- export namespace IJsonComponents {
9
- export interface IObject {
10
- $id?: string;
11
- type: "object";
12
- nullable: boolean;
13
-
14
- properties: Record<string, IJsonSchema>;
15
- patternProperties?: Record<string, IJsonSchema>;
16
- additionalProperties?: IJsonSchema;
17
-
18
- required?: string[];
19
- description?: string;
20
- "x-typia_jsDocTags"?: IJsDocTagInfo[];
21
-
22
- $recursiveAnchor?: boolean;
23
- }
24
- }
1
+ import { IJsDocTagInfo } from "../metadata/IJsDocTagInfo";
2
+
3
+ import { IJsonSchema } from "./IJsonSchema";
4
+
5
+ export interface IJsonComponents {
6
+ schemas: Record<string, IJsonComponents.IObject>;
7
+ }
8
+ export namespace IJsonComponents {
9
+ export interface IObject {
10
+ $id?: string;
11
+ $recursiveAnchor?: boolean;
12
+
13
+ type: "object";
14
+ nullable: boolean;
15
+
16
+ properties: Record<string, IJsonSchema>;
17
+ patternProperties?: Record<string, IJsonSchema>;
18
+ additionalProperties?: IJsonSchema;
19
+
20
+ required?: string[];
21
+ description?: string;
22
+ "x-typia-jsDocTags"?: IJsDocTagInfo[];
23
+ "x-typia-patternProperties"?: Record<string, IJsonSchema>;
24
+ "x-typia-additionalProperties"?: IJsonSchema;
25
+ }
26
+ }
@@ -53,6 +53,7 @@ export namespace IJsonSchema {
53
53
  items: IJsonSchema;
54
54
  minItems?: number;
55
55
  maxItems?: number;
56
+ "x-typia-tuple"?: ITuple;
56
57
  }
57
58
  export interface ITuple extends ISignificant<"array"> {
58
59
  items: IJsonSchema[];
@@ -86,5 +87,6 @@ export namespace IJsonSchema {
86
87
  "x-typia-metaTags"?: IMetadataTag[];
87
88
  "x-typia-jsDocTags"?: IJsDocTagInfo[];
88
89
  "x-typia-required"?: boolean;
90
+ "x-typia-rest"?: boolean;
89
91
  }
90
92
  }
package/src/transform.ts CHANGED
@@ -1,20 +1,20 @@
1
- import ts from "typescript";
2
-
3
- import { FileTransformer } from "./transformers/FileTransformer";
4
- import { IProject } from "./transformers/IProject";
5
- import { ITransformOptions } from "./transformers/ITransformOptions";
6
-
7
- export default function transform(
8
- program: ts.Program,
9
- options?: ITransformOptions,
10
- ): ts.TransformerFactory<ts.SourceFile> {
11
- const project: IProject = {
12
- program,
13
- compilerOptions: program.getCompilerOptions(),
14
- checker: program.getTypeChecker(),
15
- printer: ts.createPrinter(),
16
- options: options || {},
17
- };
18
- return (context) => (file) =>
19
- FileTransformer.transform(project, context, file);
20
- }
1
+ import ts from "typescript";
2
+
3
+ import { FileTransformer } from "./transformers/FileTransformer";
4
+ import { IProject } from "./transformers/IProject";
5
+ import { ITransformOptions } from "./transformers/ITransformOptions";
6
+
7
+ export default function transform(
8
+ program: ts.Program,
9
+ options?: ITransformOptions,
10
+ ): ts.TransformerFactory<ts.SourceFile> {
11
+ const project: IProject = {
12
+ program,
13
+ compilerOptions: program.getCompilerOptions(),
14
+ checker: program.getTypeChecker(),
15
+ printer: ts.createPrinter(),
16
+ options: options || {},
17
+ };
18
+ return (context) => (file) =>
19
+ FileTransformer.transform(project, context, file);
20
+ }
@@ -1,66 +1,66 @@
1
- // import path from "path";
2
- // import ts from "typescript";
3
- // import { AssertProgrammer } from "../programmers/AssertProgrammer";
4
- // import { IsProgrammer } from "../programmers/IsProgrammer";
5
- // import { StringifyProgrammer } from "../programmers/StringifyProgrammer";
6
- // import { IProject } from "../structures/IProject";
7
-
8
- // export namespace ExpressionWithArgumentTransformer {
9
- // export function transform(
10
- // project: IProject,
11
- // expression: ts.ExpressionWithTypeArguments,
12
- // ): ts.Expression {
13
- // //----
14
- // // VALIDATIONS
15
- // //----
16
- // // SYMBOL DECLARATION
17
- // const symbol: ts.Symbol | undefined =
18
- // project.checker.getSymbolAtLocation(expression.expression);
19
- // const declaration: ts.Declaration | undefined = symbol?.declarations
20
- // ? symbol.declarations[0]
21
- // : undefined;
22
- // if (!declaration) return expression;
23
-
24
- // // FILE PATH
25
- // const file: string = path.resolve(declaration.getSourceFile().fileName);
26
- // if (file !== LIB_PATH && file !== SRC_PATH) return expression;
27
-
28
- // // ARGUMENTS
29
- // if (expression.typeArguments?.length !== 1) return expression;
30
-
31
- // //----
32
- // // TRANSFORMATION
33
- // //----
34
- // // GET MODULO AND TYPE
35
- // const modulo: ts.LeftHandSideExpression = expression.expression;
36
- // const type: ts.Type = project.checker.getTypeFromTypeNode(
37
- // expression.typeArguments[0]!,
38
- // );
39
-
40
- // // FUNCTION NAME
41
- // const { name } = project.checker.getTypeAtLocation(declaration).symbol;
42
-
43
- // // FIND TRANSFORMER
44
- // const functor: (() => Task) | undefined = FUNCTORS[name];
45
- // if (functor === undefined) return expression;
46
-
47
- // // RETURNS WITH TRANSFORMATION
48
- // return functor()(project, modulo, type);
49
- // }
50
- // }
51
-
52
- // type Task = (
53
- // project: IProject,
54
- // modulo: ts.LeftHandSideExpression,
55
- // type: ts.Type,
56
- // ) => ts.ArrowFunction;
57
-
58
- // const LIB_PATH = path.resolve(path.join(__dirname, "..", "module.d.ts"));
59
- // const SRC_PATH = path.resolve(path.join(__dirname, "..", "module.ts"));
60
-
61
- // const FUNCTORS: Record<string, () => Task> = {
62
- // assert: () => AssertProgrammer.generate,
63
- // is: () => (project, _modulo, type) => IsProgrammer.generate(project, type),
64
- // stringify: () => (project, modulo, type) =>
65
- // StringifyProgrammer.generate(modulo)(project, type),
66
- // };
1
+ // import path from "path";
2
+ // import ts from "typescript";
3
+ // import { AssertProgrammer } from "../programmers/AssertProgrammer";
4
+ // import { IsProgrammer } from "../programmers/IsProgrammer";
5
+ // import { StringifyProgrammer } from "../programmers/StringifyProgrammer";
6
+ // import { IProject } from "../structures/IProject";
7
+
8
+ // export namespace ExpressionWithArgumentTransformer {
9
+ // export function transform(
10
+ // project: IProject,
11
+ // expression: ts.ExpressionWithTypeArguments,
12
+ // ): ts.Expression {
13
+ // //----
14
+ // // VALIDATIONS
15
+ // //----
16
+ // // SYMBOL DECLARATION
17
+ // const symbol: ts.Symbol | undefined =
18
+ // project.checker.getSymbolAtLocation(expression.expression);
19
+ // const declaration: ts.Declaration | undefined = symbol?.declarations
20
+ // ? symbol.declarations[0]
21
+ // : undefined;
22
+ // if (!declaration) return expression;
23
+
24
+ // // FILE PATH
25
+ // const file: string = path.resolve(declaration.getSourceFile().fileName);
26
+ // if (file !== LIB_PATH && file !== SRC_PATH) return expression;
27
+
28
+ // // ARGUMENTS
29
+ // if (expression.typeArguments?.length !== 1) return expression;
30
+
31
+ // //----
32
+ // // TRANSFORMATION
33
+ // //----
34
+ // // GET MODULO AND TYPE
35
+ // const modulo: ts.LeftHandSideExpression = expression.expression;
36
+ // const type: ts.Type = project.checker.getTypeFromTypeNode(
37
+ // expression.typeArguments[0]!,
38
+ // );
39
+
40
+ // // FUNCTION NAME
41
+ // const { name } = project.checker.getTypeAtLocation(declaration).symbol;
42
+
43
+ // // FIND TRANSFORMER
44
+ // const functor: (() => Task) | undefined = FUNCTORS[name];
45
+ // if (functor === undefined) return expression;
46
+
47
+ // // RETURNS WITH TRANSFORMATION
48
+ // return functor()(project, modulo, type);
49
+ // }
50
+ // }
51
+
52
+ // type Task = (
53
+ // project: IProject,
54
+ // modulo: ts.LeftHandSideExpression,
55
+ // type: ts.Type,
56
+ // ) => ts.ArrowFunction;
57
+
58
+ // const LIB_PATH = path.resolve(path.join(__dirname, "..", "module.d.ts"));
59
+ // const SRC_PATH = path.resolve(path.join(__dirname, "..", "module.ts"));
60
+
61
+ // const FUNCTORS: Record<string, () => Task> = {
62
+ // assert: () => AssertProgrammer.generate,
63
+ // is: () => (project, _modulo, type) => IsProgrammer.generate(project, type),
64
+ // stringify: () => (project, modulo, type) =>
65
+ // StringifyProgrammer.generate(modulo)(project, type),
66
+ // };
@@ -1,49 +1,49 @@
1
- import ts from "typescript";
2
-
3
- import { IProject } from "./IProject";
4
- import { NodeTransformer } from "./NodeTransformer";
5
-
6
- export namespace FileTransformer {
7
- export function transform(
8
- project: IProject,
9
- context: ts.TransformationContext,
10
- file: ts.SourceFile,
11
- ): ts.SourceFile {
12
- // DO NOT TRANSFORM D.TS FILE
13
- if (file.isDeclarationFile) return file;
14
-
15
- // ITERATE NODES
16
- return ts.visitEachChild(
17
- file,
18
- (node) => iterate_node(project, context, node),
19
- context,
20
- );
21
- }
22
-
23
- function iterate_node(
24
- project: IProject,
25
- context: ts.TransformationContext,
26
- node: ts.Node,
27
- ): ts.Node {
28
- return ts.visitEachChild(
29
- try_transform_node(project, node),
30
- (child) => iterate_node(project, context, child),
31
- context,
32
- );
33
- }
34
-
35
- function try_transform_node(project: IProject, node: ts.Node): ts.Node {
36
- try {
37
- return NodeTransformer.transform(project, node);
38
- } catch (exp) {
39
- if (!(exp instanceof Error)) throw exp;
40
-
41
- const file: ts.SourceFile = node.getSourceFile();
42
- const { line, character } = file.getLineAndCharacterOfPosition(
43
- node.pos,
44
- );
45
- exp.message += ` - ${file.fileName}:${line + 1}:${character + 1}`;
46
- throw exp;
47
- }
48
- }
49
- }
1
+ import ts from "typescript";
2
+
3
+ import { IProject } from "./IProject";
4
+ import { NodeTransformer } from "./NodeTransformer";
5
+
6
+ export namespace FileTransformer {
7
+ export function transform(
8
+ project: IProject,
9
+ context: ts.TransformationContext,
10
+ file: ts.SourceFile,
11
+ ): ts.SourceFile {
12
+ // DO NOT TRANSFORM D.TS FILE
13
+ if (file.isDeclarationFile) return file;
14
+
15
+ // ITERATE NODES
16
+ return ts.visitEachChild(
17
+ file,
18
+ (node) => iterate_node(project, context, node),
19
+ context,
20
+ );
21
+ }
22
+
23
+ function iterate_node(
24
+ project: IProject,
25
+ context: ts.TransformationContext,
26
+ node: ts.Node,
27
+ ): ts.Node {
28
+ return ts.visitEachChild(
29
+ try_transform_node(project, node),
30
+ (child) => iterate_node(project, context, child),
31
+ context,
32
+ );
33
+ }
34
+
35
+ function try_transform_node(project: IProject, node: ts.Node): ts.Node {
36
+ try {
37
+ return NodeTransformer.transform(project, node);
38
+ } catch (exp) {
39
+ if (!(exp instanceof Error)) throw exp;
40
+
41
+ const file: ts.SourceFile = node.getSourceFile();
42
+ const { line, character } = file.getLineAndCharacterOfPosition(
43
+ node.pos,
44
+ );
45
+ exp.message += ` - ${file.fileName}:${line + 1}:${character + 1}`;
46
+ throw exp;
47
+ }
48
+ }
49
+ }
@@ -1,11 +1,11 @@
1
- import ts from "typescript";
2
-
3
- import { ITransformOptions } from "./ITransformOptions";
4
-
5
- export interface IProject {
6
- program: ts.Program;
7
- compilerOptions: ts.CompilerOptions;
8
- checker: ts.TypeChecker;
9
- printer: ts.Printer;
10
- options: ITransformOptions;
11
- }
1
+ import ts from "typescript";
2
+
3
+ import { ITransformOptions } from "./ITransformOptions";
4
+
5
+ export interface IProject {
6
+ program: ts.Program;
7
+ compilerOptions: ts.CompilerOptions;
8
+ checker: ts.TypeChecker;
9
+ printer: ts.Printer;
10
+ options: ITransformOptions;
11
+ }
@@ -1,19 +1,19 @@
1
- import ts from "typescript";
2
-
3
- import { CallExpressionTransformer } from "./CallExpressionTransformer";
4
- import { IProject } from "./IProject";
5
-
6
- // import { ExpressionWithArgumentTransformer } from "./ExpressionWithArgumentTransformer";
7
-
8
- export namespace NodeTransformer {
9
- export function transform(project: IProject, expression: ts.Node): ts.Node {
10
- if (ts.isCallExpression(expression))
11
- return CallExpressionTransformer.transform(project, expression);
12
- // else if (ts.isExpressionWithTypeArguments(expression))
13
- // return ExpressionWithArgumentTransformer.transform(
14
- // project,
15
- // expression,
16
- // );
17
- return expression;
18
- }
19
- }
1
+ import ts from "typescript";
2
+
3
+ import { CallExpressionTransformer } from "./CallExpressionTransformer";
4
+ import { IProject } from "./IProject";
5
+
6
+ // import { ExpressionWithArgumentTransformer } from "./ExpressionWithArgumentTransformer";
7
+
8
+ export namespace NodeTransformer {
9
+ export function transform(project: IProject, expression: ts.Node): ts.Node {
10
+ if (ts.isCallExpression(expression))
11
+ return CallExpressionTransformer.transform(project, expression);
12
+ // else if (ts.isExpressionWithTypeArguments(expression))
13
+ // return ExpressionWithArgumentTransformer.transform(
14
+ // project,
15
+ // expression,
16
+ // );
17
+ return expression;
18
+ }
19
+ }
@@ -114,4 +114,5 @@ const enum ErrorMessages {
114
114
  NO_GENERIC_ARGUMENT = "Error on typia.application(): no generic argument.",
115
115
  GENERIC_ARGUMENT = "Error on typia.application(): non-specified generic argument(s).",
116
116
  NO_BIGIT = "Error on typia.application(): does not allow bigint type.",
117
+ NO_ZERO_LENGTH_TUPLE = "Error on typia.application(): swagger does not support zero length tuple type.",
117
118
  }