typia 3.8.4-dev.20230502 → 3.8.5-dev.20230510

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 (170) hide show
  1. package/lib/factories/MetadataTagFactory.js +5 -5
  2. package/lib/factories/MetadataTagFactory.js.map +1 -1
  3. package/lib/factories/internal/metadata/emplace_metadata_object.js +17 -15
  4. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  5. package/lib/programmers/AssertProgrammer.js +1 -1
  6. package/lib/programmers/AssertProgrammer.js.map +1 -1
  7. package/lib/programmers/IsProgrammer.d.ts +1 -1
  8. package/lib/programmers/IsProgrammer.js +5 -2
  9. package/lib/programmers/IsProgrammer.js.map +1 -1
  10. package/lib/programmers/ValidateProgrammer.js +1 -1
  11. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  12. package/lib/programmers/helpers/disable_function_importer_declare.d.ts +2 -0
  13. package/lib/programmers/helpers/disable_function_importer_declare.js +15 -0
  14. package/lib/programmers/helpers/disable_function_importer_declare.js.map +1 -0
  15. package/package.json +1 -1
  16. package/src/Primitive.ts +123 -123
  17. package/src/executable/TypiaGenerateWizard.ts +85 -85
  18. package/src/executable/TypiaSetupWizard.ts +133 -133
  19. package/src/executable/setup/CommandExecutor.ts +8 -8
  20. package/src/executable/setup/PackageManager.ts +71 -71
  21. package/src/executable/setup/PluginConfigurator.ts +70 -70
  22. package/src/executable/typia.ts +52 -52
  23. package/src/factories/CommentFactory.ts +14 -14
  24. package/src/factories/ExpressionFactory.ts +70 -70
  25. package/src/factories/IdentifierFactory.ts +63 -63
  26. package/src/factories/LiteralFactory.ts +39 -39
  27. package/src/factories/MetadataCollection.ts +121 -121
  28. package/src/factories/MetadataFactory.ts +62 -62
  29. package/src/factories/MetadataTagFactory.ts +295 -297
  30. package/src/factories/StatementFactory.ts +24 -24
  31. package/src/factories/TemplateFactory.ts +58 -58
  32. package/src/factories/TypeFactory.ts +124 -124
  33. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  34. package/src/factories/internal/metadata/emplace_metadata_object.ts +143 -143
  35. package/src/factories/internal/metadata/iterate_metadata.ts +67 -67
  36. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  37. package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
  38. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  39. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  40. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +48 -48
  41. package/src/factories/internal/metadata/iterate_metadata_union.ts +57 -57
  42. package/src/functional/$any.ts +2 -2
  43. package/src/functional/$dictionary.ts +25 -25
  44. package/src/functional/$is_between.ts +2 -2
  45. package/src/functional/$is_custom.ts +14 -14
  46. package/src/functional/$is_date.ts +3 -3
  47. package/src/functional/$is_datetime.ts +2 -2
  48. package/src/functional/$is_email.ts +4 -4
  49. package/src/functional/$is_ipv4.ts +4 -4
  50. package/src/functional/$is_ipv6.ts +4 -4
  51. package/src/functional/$is_url.ts +4 -4
  52. package/src/functional/$is_uuid.ts +4 -4
  53. package/src/functional/$join.ts +46 -46
  54. package/src/functional/$number.ts +12 -12
  55. package/src/functional/$rest.ts +3 -3
  56. package/src/functional/$string.ts +37 -37
  57. package/src/functional/$tail.ts +5 -5
  58. package/src/metadata/IMetadata.ts +26 -26
  59. package/src/metadata/Metadata.ts +539 -539
  60. package/src/metadata/MetadataConstant.ts +3 -3
  61. package/src/metadata/MetadataObject.ts +127 -127
  62. package/src/module.ts +2043 -2043
  63. package/src/programmers/ApplicationProgrammer.ts +62 -62
  64. package/src/programmers/AssertCloneProgrammer.ts +79 -79
  65. package/src/programmers/AssertParseProgrammer.ts +74 -74
  66. package/src/programmers/AssertProgrammer.ts +285 -285
  67. package/src/programmers/AssertPruneProgrammer.ts +76 -76
  68. package/src/programmers/AssertStringifyProgrammer.ts +74 -74
  69. package/src/programmers/CheckerProgrammer.ts +901 -901
  70. package/src/programmers/CloneProgrammer.ts +389 -389
  71. package/src/programmers/FeatureProgrammer.ts +500 -500
  72. package/src/programmers/IsCloneProgrammer.ts +86 -86
  73. package/src/programmers/IsParseProgrammer.ts +80 -80
  74. package/src/programmers/IsProgrammer.ts +216 -212
  75. package/src/programmers/IsPruneProgrammer.ts +81 -81
  76. package/src/programmers/IsStringifyProgrammer.ts +84 -84
  77. package/src/programmers/LiteralsProgrammer.ts +65 -65
  78. package/src/programmers/PruneProgrammer.ts +347 -347
  79. package/src/programmers/RandomProgrammer.ts +423 -423
  80. package/src/programmers/StringifyProgrammer.ts +798 -798
  81. package/src/programmers/TypiaProgrammer.ts +129 -129
  82. package/src/programmers/ValidateCloneProgrammer.ts +93 -93
  83. package/src/programmers/ValidateParseProgrammer.ts +78 -78
  84. package/src/programmers/ValidateProgrammer.ts +316 -316
  85. package/src/programmers/ValidatePruneProgrammer.ts +86 -86
  86. package/src/programmers/ValidateStringifyProgrammer.ts +92 -92
  87. package/src/programmers/helpers/CloneJoiner.ts +131 -131
  88. package/src/programmers/helpers/FunctionImporeter.ts +54 -54
  89. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  90. package/src/programmers/helpers/PruneJoiner.ts +144 -144
  91. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  92. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  93. package/src/programmers/helpers/UnionExplorer.ts +275 -275
  94. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  95. package/src/programmers/helpers/disable_function_importer_declare.ts +21 -0
  96. package/src/programmers/internal/application_array.ts +36 -36
  97. package/src/programmers/internal/application_boolean.ts +17 -17
  98. package/src/programmers/internal/application_constant.ts +30 -30
  99. package/src/programmers/internal/application_default_string.ts +33 -33
  100. package/src/programmers/internal/application_native.ts +32 -32
  101. package/src/programmers/internal/application_number.ts +73 -73
  102. package/src/programmers/internal/application_object.ts +155 -155
  103. package/src/programmers/internal/application_schema.ts +213 -213
  104. package/src/programmers/internal/application_string.ts +45 -45
  105. package/src/programmers/internal/application_templates.ts +26 -26
  106. package/src/programmers/internal/application_tuple.ts +31 -31
  107. package/src/programmers/internal/check_array.ts +30 -30
  108. package/src/programmers/internal/check_custom.ts +31 -31
  109. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  110. package/src/programmers/internal/check_everything.ts +28 -28
  111. package/src/programmers/internal/check_native.ts +21 -21
  112. package/src/programmers/internal/check_string_tags.ts +67 -67
  113. package/src/programmers/internal/check_union_array_like.ts +271 -271
  114. package/src/programmers/internal/check_union_tuple.ts +33 -33
  115. package/src/programmers/internal/random_custom.ts +29 -29
  116. package/src/programmers/internal/stringify_dynamic_properties.ts +167 -167
  117. package/src/programmers/internal/stringify_native.ts +7 -7
  118. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  119. package/src/schemas/IJsonSchema.ts +130 -130
  120. package/src/transform.ts +17 -17
  121. package/src/transformers/CallExpressionTransformer.ts +177 -177
  122. package/src/transformers/FileTransformer.ts +47 -47
  123. package/src/transformers/NodeTransformer.ts +13 -13
  124. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +114 -114
  125. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  126. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  127. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  128. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  129. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  130. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  131. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  132. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  133. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  134. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +39 -39
  135. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  136. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  137. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  138. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  139. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +28 -28
  140. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +52 -52
  141. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  142. package/src/transformers/features/miscellaneous/RandomTransformer.ts +42 -42
  143. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  144. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  145. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  146. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  147. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  148. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  149. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  150. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  151. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  152. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
  153. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  154. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  155. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
  156. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  157. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  158. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  159. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  160. package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
  161. package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
  162. package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
  163. package/src/transformers/features/validators/IsTransformer.ts +11 -11
  164. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  165. package/src/transformers/internal/GenericTransformer.ts +97 -97
  166. package/src/utils/ArrayUtil.ts +44 -44
  167. package/src/utils/Escaper.ts +45 -45
  168. package/src/utils/MapUtil.ts +12 -12
  169. package/src/utils/PatternUtil.ts +30 -30
  170. package/src/utils/RandomGenerator.ts +81 -81
@@ -1,213 +1,213 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonComponents } from "../../schemas/IJsonComponents";
3
- import { IJsonSchema } from "../../schemas/IJsonSchema";
4
-
5
- import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
- import { AtomicPredicator } from "../helpers/AtomicPredicator";
7
- import { application_array } from "./application_array";
8
- import { application_boolean } from "./application_boolean";
9
- import { application_constant } from "./application_constant";
10
- import { application_native } from "./application_native";
11
- import { application_number } from "./application_number";
12
- import { application_object } from "./application_object";
13
- import { application_string } from "./application_string";
14
- import { application_templates } from "./application_templates";
15
- import { application_tuple } from "./application_tuple";
16
-
17
- /**
18
- * @internal
19
- */
20
- export const application_schema =
21
- (options: ApplicationProgrammer.IOptions) =>
22
- <BlockNever extends boolean>(blockNever: BlockNever) =>
23
- (components: IJsonComponents) =>
24
- (meta: Metadata) =>
25
- (
26
- attribute: IJsonSchema.IAttribute,
27
- ): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
28
- // VULNERABLE CASE
29
- if (meta.any === true)
30
- return {
31
- ...attribute,
32
- type: undefined,
33
- };
34
- else if (meta.nullable && meta.empty())
35
- return { type: "null", ...attribute };
36
-
37
- //----
38
- // GATHER UNION SCHEMAS
39
- //----
40
- const union: IJsonSchema[] = [];
41
-
42
- // toJSON() METHOD
43
- if (meta.resolved !== null) {
44
- const resolved = application_schema(options)(blockNever)(
45
- components,
46
- )(meta.resolved)(attribute);
47
- if (resolved !== null) union.push(resolved);
48
- }
49
-
50
- // ATOMIC TYPES
51
- if (meta.templates.length && AtomicPredicator.template(meta))
52
- union.push(application_templates(meta)(attribute));
53
- for (const constant of meta.constants)
54
- if (constant.type === "bigint") throw new Error(NO_BIGINT);
55
- else if (
56
- (constant.type === "string" && meta.templates.length) ||
57
- AtomicPredicator.constant(meta)(constant.type) === false
58
- )
59
- continue;
60
- else
61
- union.push(
62
- application_constant(constant)({
63
- nullable: meta.nullable,
64
- attribute,
65
- }),
66
- );
67
- for (const type of meta.atomics)
68
- if (type === "bigint") throw new Error(NO_BIGINT);
69
- else if (AtomicPredicator.atomic(meta)(type) === false) continue;
70
- else
71
- union.push(
72
- type === "string"
73
- ? application_string(meta, attribute)
74
- : type === "boolean"
75
- ? application_boolean({
76
- nullable: meta.nullable,
77
- attribute,
78
- })
79
- : application_number({
80
- nullable: meta.nullable,
81
- attribute,
82
- }),
83
- );
84
-
85
- // ARRAY
86
- for (const schema of meta.arrays.values())
87
- union.push(
88
- application_array(options)(components)()(schema)({
89
- nullable: meta.nullable,
90
- attribute,
91
- }),
92
- );
93
-
94
- // TUPLE
95
- for (const items of meta.tuples) {
96
- const tuple: IJsonSchema.ITuple = application_tuple(options)(
97
- components,
98
- )(items)({
99
- nullable: meta.nullable,
100
- attribute,
101
- });
102
- if (options.purpose === "swagger" && items.length === 0)
103
- throw new Error(
104
- "Error on typia.application(): swagger does not support zero length tuple type.",
105
- );
106
- else if (
107
- options.purpose === "ajv" &&
108
- !items[items.length - 1]?.rest
109
- )
110
- union.push(tuple);
111
- else {
112
- // SWAGGER DOES NOT SUPPORT TUPLE TYPE YET
113
- const merged: Metadata = items.reduce((x, y) =>
114
- Metadata.merge(x, y),
115
- );
116
- union.push(
117
- application_array(options)(components)(tuple)(merged)({
118
- nullable: merged?.nullable ?? false,
119
- attribute,
120
- }),
121
- );
122
- }
123
- }
124
-
125
- // NATIVES
126
- for (const native of meta.natives)
127
- if (AtomicPredicator.native(native))
128
- union.push(
129
- native === "String"
130
- ? application_string(meta, attribute)
131
- : native === "Boolean"
132
- ? application_boolean({
133
- nullable: meta.nullable,
134
- attribute,
135
- })
136
- : application_number({
137
- nullable: meta.nullable,
138
- attribute,
139
- }),
140
- );
141
- else
142
- union.push(
143
- application_native(options)(components)(native)({
144
- nullable: meta.nullable,
145
- attribute,
146
- }),
147
- );
148
- if (meta.sets.length)
149
- union.push(
150
- application_native(options)(components)(`Set`)({
151
- nullable: meta.nullable,
152
- attribute,
153
- }),
154
- );
155
- if (meta.maps.length)
156
- union.push(
157
- application_native(options)(components)(`Map`)({
158
- nullable: meta.nullable,
159
- attribute,
160
- }),
161
- );
162
-
163
- // OBJECT
164
- for (const obj of meta.objects) {
165
- const key: string = obj.name + (meta.nullable ? ".Nullable" : "");
166
- application_object(options)(components)(obj)({
167
- key,
168
- nullable: meta.nullable,
169
- });
170
- union.push(
171
- (options.purpose === "ajv" && obj.recursive
172
- ? recursive
173
- : reference)(`${options.prefix}/${key}`, attribute),
174
- );
175
- }
176
-
177
- //----
178
- // RETURNS
179
- //----
180
- if (union.length === 0)
181
- return blockNever === true
182
- ? null!
183
- : {
184
- ...attribute,
185
- type: undefined,
186
- };
187
- else if (union.length === 1) return union[0]!;
188
- return { oneOf: union, ...attribute };
189
- };
190
-
191
- /**
192
- * @internal
193
- */
194
- const reference = (
195
- $ref: string,
196
- attribute: IJsonSchema.IAttribute,
197
- ): IJsonSchema.IReference => ({
198
- $ref,
199
- ...attribute,
200
- });
201
-
202
- /**
203
- * @internal
204
- */
205
- const recursive = (
206
- $recursiveRef: string,
207
- attribute: IJsonSchema.IAttribute,
208
- ): IJsonSchema.IRecursiveReference => ({
209
- $recursiveRef,
210
- ...attribute,
211
- });
212
-
213
- const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonComponents } from "../../schemas/IJsonComponents";
3
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
4
+
5
+ import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
+ import { AtomicPredicator } from "../helpers/AtomicPredicator";
7
+ import { application_array } from "./application_array";
8
+ import { application_boolean } from "./application_boolean";
9
+ import { application_constant } from "./application_constant";
10
+ import { application_native } from "./application_native";
11
+ import { application_number } from "./application_number";
12
+ import { application_object } from "./application_object";
13
+ import { application_string } from "./application_string";
14
+ import { application_templates } from "./application_templates";
15
+ import { application_tuple } from "./application_tuple";
16
+
17
+ /**
18
+ * @internal
19
+ */
20
+ export const application_schema =
21
+ (options: ApplicationProgrammer.IOptions) =>
22
+ <BlockNever extends boolean>(blockNever: BlockNever) =>
23
+ (components: IJsonComponents) =>
24
+ (meta: Metadata) =>
25
+ (
26
+ attribute: IJsonSchema.IAttribute,
27
+ ): BlockNever extends true ? IJsonSchema | null : IJsonSchema => {
28
+ // VULNERABLE CASE
29
+ if (meta.any === true)
30
+ return {
31
+ ...attribute,
32
+ type: undefined,
33
+ };
34
+ else if (meta.nullable && meta.empty())
35
+ return { type: "null", ...attribute };
36
+
37
+ //----
38
+ // GATHER UNION SCHEMAS
39
+ //----
40
+ const union: IJsonSchema[] = [];
41
+
42
+ // toJSON() METHOD
43
+ if (meta.resolved !== null) {
44
+ const resolved = application_schema(options)(blockNever)(
45
+ components,
46
+ )(meta.resolved)(attribute);
47
+ if (resolved !== null) union.push(resolved);
48
+ }
49
+
50
+ // ATOMIC TYPES
51
+ if (meta.templates.length && AtomicPredicator.template(meta))
52
+ union.push(application_templates(meta)(attribute));
53
+ for (const constant of meta.constants)
54
+ if (constant.type === "bigint") throw new Error(NO_BIGINT);
55
+ else if (
56
+ (constant.type === "string" && meta.templates.length) ||
57
+ AtomicPredicator.constant(meta)(constant.type) === false
58
+ )
59
+ continue;
60
+ else
61
+ union.push(
62
+ application_constant(constant)({
63
+ nullable: meta.nullable,
64
+ attribute,
65
+ }),
66
+ );
67
+ for (const type of meta.atomics)
68
+ if (type === "bigint") throw new Error(NO_BIGINT);
69
+ else if (AtomicPredicator.atomic(meta)(type) === false) continue;
70
+ else
71
+ union.push(
72
+ type === "string"
73
+ ? application_string(meta, attribute)
74
+ : type === "boolean"
75
+ ? application_boolean({
76
+ nullable: meta.nullable,
77
+ attribute,
78
+ })
79
+ : application_number({
80
+ nullable: meta.nullable,
81
+ attribute,
82
+ }),
83
+ );
84
+
85
+ // ARRAY
86
+ for (const schema of meta.arrays.values())
87
+ union.push(
88
+ application_array(options)(components)()(schema)({
89
+ nullable: meta.nullable,
90
+ attribute,
91
+ }),
92
+ );
93
+
94
+ // TUPLE
95
+ for (const items of meta.tuples) {
96
+ const tuple: IJsonSchema.ITuple = application_tuple(options)(
97
+ components,
98
+ )(items)({
99
+ nullable: meta.nullable,
100
+ attribute,
101
+ });
102
+ if (options.purpose === "swagger" && items.length === 0)
103
+ throw new Error(
104
+ "Error on typia.application(): swagger does not support zero length tuple type.",
105
+ );
106
+ else if (
107
+ options.purpose === "ajv" &&
108
+ !items[items.length - 1]?.rest
109
+ )
110
+ union.push(tuple);
111
+ else {
112
+ // SWAGGER DOES NOT SUPPORT TUPLE TYPE YET
113
+ const merged: Metadata = items.reduce((x, y) =>
114
+ Metadata.merge(x, y),
115
+ );
116
+ union.push(
117
+ application_array(options)(components)(tuple)(merged)({
118
+ nullable: merged?.nullable ?? false,
119
+ attribute,
120
+ }),
121
+ );
122
+ }
123
+ }
124
+
125
+ // NATIVES
126
+ for (const native of meta.natives)
127
+ if (AtomicPredicator.native(native))
128
+ union.push(
129
+ native === "String"
130
+ ? application_string(meta, attribute)
131
+ : native === "Boolean"
132
+ ? application_boolean({
133
+ nullable: meta.nullable,
134
+ attribute,
135
+ })
136
+ : application_number({
137
+ nullable: meta.nullable,
138
+ attribute,
139
+ }),
140
+ );
141
+ else
142
+ union.push(
143
+ application_native(options)(components)(native)({
144
+ nullable: meta.nullable,
145
+ attribute,
146
+ }),
147
+ );
148
+ if (meta.sets.length)
149
+ union.push(
150
+ application_native(options)(components)(`Set`)({
151
+ nullable: meta.nullable,
152
+ attribute,
153
+ }),
154
+ );
155
+ if (meta.maps.length)
156
+ union.push(
157
+ application_native(options)(components)(`Map`)({
158
+ nullable: meta.nullable,
159
+ attribute,
160
+ }),
161
+ );
162
+
163
+ // OBJECT
164
+ for (const obj of meta.objects) {
165
+ const key: string = obj.name + (meta.nullable ? ".Nullable" : "");
166
+ application_object(options)(components)(obj)({
167
+ key,
168
+ nullable: meta.nullable,
169
+ });
170
+ union.push(
171
+ (options.purpose === "ajv" && obj.recursive
172
+ ? recursive
173
+ : reference)(`${options.prefix}/${key}`, attribute),
174
+ );
175
+ }
176
+
177
+ //----
178
+ // RETURNS
179
+ //----
180
+ if (union.length === 0)
181
+ return blockNever === true
182
+ ? null!
183
+ : {
184
+ ...attribute,
185
+ type: undefined,
186
+ };
187
+ else if (union.length === 1) return union[0]!;
188
+ return { oneOf: union, ...attribute };
189
+ };
190
+
191
+ /**
192
+ * @internal
193
+ */
194
+ const reference = (
195
+ $ref: string,
196
+ attribute: IJsonSchema.IAttribute,
197
+ ): IJsonSchema.IReference => ({
198
+ $ref,
199
+ ...attribute,
200
+ });
201
+
202
+ /**
203
+ * @internal
204
+ */
205
+ const recursive = (
206
+ $recursiveRef: string,
207
+ attribute: IJsonSchema.IAttribute,
208
+ ): IJsonSchema.IRecursiveReference => ({
209
+ $recursiveRef,
210
+ ...attribute,
211
+ });
212
+
213
+ const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
@@ -1,45 +1,45 @@
1
- import { IMetadataTag } from "../../metadata/IMetadataTag";
2
- import { Metadata } from "../../metadata/Metadata";
3
- import { IJsonSchema } from "../../schemas/IJsonSchema";
4
-
5
- import { application_default_string } from "./application_default_string";
6
-
7
- /**
8
- * @internal
9
- */
10
- export const application_string = (
11
- meta: Metadata,
12
- attribute: IJsonSchema.IAttribute,
13
- ): IJsonSchema.IString => {
14
- const output: IJsonSchema.IString = {
15
- type: "string",
16
- nullable: meta.nullable,
17
- ...attribute,
18
- };
19
-
20
- // FORMAT TAG OF METADATA
21
- const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
22
- (tag) => tag.name === "format",
23
- );
24
- if (formatJsdocTag?.text?.length)
25
- output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
26
-
27
- // REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
28
- for (const tag of attribute["x-typia-metaTags"] ?? []) {
29
- // RANGE
30
- if (tag.kind === "minLength") output.minLength = tag.value;
31
- else if (tag.kind === "maxLength") output.maxLength = tag.value;
32
- // FORMAT AND PATTERN
33
- else if (tag.kind === "format") output.format = emendFormat(tag.value);
34
- else if (tag.kind === "pattern") output.pattern = tag.value;
35
- }
36
-
37
- // DEFAULT CONFIGURATION
38
- output.default = application_default_string(meta)(attribute)(output);
39
-
40
- // RETURNS
41
- return output;
42
- };
43
-
44
- const emendFormat = (tag: IMetadataTag.IFormat["value"]) =>
45
- tag === "datetime" ? "date-time" : tag;
1
+ import { IMetadataTag } from "../../metadata/IMetadataTag";
2
+ import { Metadata } from "../../metadata/Metadata";
3
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
4
+
5
+ import { application_default_string } from "./application_default_string";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const application_string = (
11
+ meta: Metadata,
12
+ attribute: IJsonSchema.IAttribute,
13
+ ): IJsonSchema.IString => {
14
+ const output: IJsonSchema.IString = {
15
+ type: "string",
16
+ nullable: meta.nullable,
17
+ ...attribute,
18
+ };
19
+
20
+ // FORMAT TAG OF METADATA
21
+ const formatJsdocTag = attribute["x-typia-jsDocTags"]?.find(
22
+ (tag) => tag.name === "format",
23
+ );
24
+ if (formatJsdocTag?.text?.length)
25
+ output.format = formatJsdocTag?.text.map((t) => t.text).join(" ");
26
+
27
+ // REGULAR TAGS COMPATIBLE WITH JSON-SCHEMA
28
+ for (const tag of attribute["x-typia-metaTags"] ?? []) {
29
+ // RANGE
30
+ if (tag.kind === "minLength") output.minLength = tag.value;
31
+ else if (tag.kind === "maxLength") output.maxLength = tag.value;
32
+ // FORMAT AND PATTERN
33
+ else if (tag.kind === "format") output.format = emendFormat(tag.value);
34
+ else if (tag.kind === "pattern") output.pattern = tag.value;
35
+ }
36
+
37
+ // DEFAULT CONFIGURATION
38
+ output.default = application_default_string(meta)(attribute)(output);
39
+
40
+ // RETURNS
41
+ return output;
42
+ };
43
+
44
+ const emendFormat = (tag: IMetadataTag.IFormat["value"]) =>
45
+ tag === "datetime" ? "date-time" : tag;
@@ -1,26 +1,26 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonSchema } from "../../schemas/IJsonSchema";
3
-
4
- import { application_default_string } from "./application_default_string";
5
- import { metadata_to_pattern } from "./metadata_to_pattern";
6
-
7
- /**
8
- * @internal
9
- */
10
- export const application_templates =
11
- (meta: Metadata) =>
12
- (attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
13
- // CONSTRUCT PATTERN
14
- const output: IJsonSchema.IString = {
15
- type: "string",
16
- nullable: meta.nullable,
17
- ...attribute,
18
- };
19
- output.pattern = metadata_to_pattern(true)(meta);
20
-
21
- // DEFAULT VALUE
22
- output.default = application_default_string(meta)(attribute)(output);
23
-
24
- // RETURNS
25
- return output;
26
- };
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
3
+
4
+ import { application_default_string } from "./application_default_string";
5
+ import { metadata_to_pattern } from "./metadata_to_pattern";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const application_templates =
11
+ (meta: Metadata) =>
12
+ (attribute: IJsonSchema.IAttribute): IJsonSchema.IString => {
13
+ // CONSTRUCT PATTERN
14
+ const output: IJsonSchema.IString = {
15
+ type: "string",
16
+ nullable: meta.nullable,
17
+ ...attribute,
18
+ };
19
+ output.pattern = metadata_to_pattern(true)(meta);
20
+
21
+ // DEFAULT VALUE
22
+ output.default = application_default_string(meta)(attribute)(output);
23
+
24
+ // RETURNS
25
+ return output;
26
+ };
@@ -1,31 +1,31 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonComponents } from "../../schemas/IJsonComponents";
3
- import { IJsonSchema } from "../../schemas/IJsonSchema";
4
-
5
- import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
- import { application_schema } from "./application_schema";
7
-
8
- /**
9
- * @internal
10
- */
11
- export const application_tuple =
12
- (options: ApplicationProgrammer.IOptions) =>
13
- (components: IJsonComponents) =>
14
- (items: Array<Metadata>) =>
15
- (props: {
16
- nullable: boolean;
17
- attribute: IJsonSchema.IAttribute;
18
- }): IJsonSchema.ITuple => ({
19
- type: "array",
20
- items: items.map((meta, i) =>
21
- application_schema(options)(false)(components)(meta.rest ?? meta)({
22
- ...props.attribute,
23
- "x-typia-rest":
24
- i === items.length - 1 ? meta.rest !== null : undefined,
25
- "x-typia-required": meta.required,
26
- "x-typia-optional": meta.optional,
27
- }),
28
- ),
29
- nullable: props.nullable,
30
- ...props.attribute,
31
- });
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonComponents } from "../../schemas/IJsonComponents";
3
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
4
+
5
+ import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
+ import { application_schema } from "./application_schema";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const application_tuple =
12
+ (options: ApplicationProgrammer.IOptions) =>
13
+ (components: IJsonComponents) =>
14
+ (items: Array<Metadata>) =>
15
+ (props: {
16
+ nullable: boolean;
17
+ attribute: IJsonSchema.IAttribute;
18
+ }): IJsonSchema.ITuple => ({
19
+ type: "array",
20
+ items: items.map((meta, i) =>
21
+ application_schema(options)(false)(components)(meta.rest ?? meta)({
22
+ ...props.attribute,
23
+ "x-typia-rest":
24
+ i === items.length - 1 ? meta.rest !== null : undefined,
25
+ "x-typia-required": meta.required,
26
+ "x-typia-optional": meta.optional,
27
+ }),
28
+ ),
29
+ nullable: props.nullable,
30
+ ...props.attribute,
31
+ });