typia 3.8.3 → 3.8.4-dev.20230502

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 (157) hide show
  1. package/lib/functional/$dictionary.js +3 -2
  2. package/lib/functional/$dictionary.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/Primitive.ts +123 -123
  5. package/src/executable/TypiaGenerateWizard.ts +85 -85
  6. package/src/executable/TypiaSetupWizard.ts +133 -133
  7. package/src/executable/setup/CommandExecutor.ts +8 -8
  8. package/src/executable/setup/PackageManager.ts +71 -71
  9. package/src/executable/setup/PluginConfigurator.ts +70 -70
  10. package/src/executable/typia.ts +52 -52
  11. package/src/factories/CommentFactory.ts +14 -14
  12. package/src/factories/ExpressionFactory.ts +70 -70
  13. package/src/factories/IdentifierFactory.ts +63 -63
  14. package/src/factories/LiteralFactory.ts +39 -39
  15. package/src/factories/MetadataCollection.ts +121 -121
  16. package/src/factories/MetadataFactory.ts +62 -62
  17. package/src/factories/MetadataTagFactory.ts +297 -297
  18. package/src/factories/StatementFactory.ts +24 -24
  19. package/src/factories/TemplateFactory.ts +58 -58
  20. package/src/factories/TypeFactory.ts +124 -124
  21. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  22. package/src/factories/internal/metadata/emplace_metadata_object.ts +143 -143
  23. package/src/factories/internal/metadata/iterate_metadata.ts +67 -67
  24. package/src/factories/internal/metadata/iterate_metadata_map.ts +41 -41
  25. package/src/factories/internal/metadata/iterate_metadata_native.ts +219 -219
  26. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +27 -27
  27. package/src/factories/internal/metadata/iterate_metadata_set.ts +33 -33
  28. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +48 -48
  29. package/src/factories/internal/metadata/iterate_metadata_union.ts +57 -57
  30. package/src/functional/$any.ts +2 -2
  31. package/src/functional/$dictionary.ts +25 -20
  32. package/src/functional/$is_between.ts +2 -2
  33. package/src/functional/$is_custom.ts +14 -14
  34. package/src/functional/$is_date.ts +3 -3
  35. package/src/functional/$is_datetime.ts +2 -2
  36. package/src/functional/$is_email.ts +4 -4
  37. package/src/functional/$is_ipv4.ts +4 -4
  38. package/src/functional/$is_ipv6.ts +4 -4
  39. package/src/functional/$is_url.ts +4 -4
  40. package/src/functional/$is_uuid.ts +4 -4
  41. package/src/functional/$join.ts +46 -46
  42. package/src/functional/$number.ts +12 -12
  43. package/src/functional/$rest.ts +3 -3
  44. package/src/functional/$string.ts +37 -37
  45. package/src/functional/$tail.ts +5 -5
  46. package/src/metadata/IMetadata.ts +26 -26
  47. package/src/metadata/Metadata.ts +539 -539
  48. package/src/metadata/MetadataConstant.ts +3 -3
  49. package/src/metadata/MetadataObject.ts +127 -127
  50. package/src/module.ts +2043 -2043
  51. package/src/programmers/ApplicationProgrammer.ts +62 -62
  52. package/src/programmers/AssertCloneProgrammer.ts +79 -79
  53. package/src/programmers/AssertParseProgrammer.ts +74 -74
  54. package/src/programmers/AssertProgrammer.ts +285 -285
  55. package/src/programmers/AssertPruneProgrammer.ts +76 -76
  56. package/src/programmers/AssertStringifyProgrammer.ts +74 -74
  57. package/src/programmers/CheckerProgrammer.ts +901 -901
  58. package/src/programmers/CloneProgrammer.ts +389 -389
  59. package/src/programmers/FeatureProgrammer.ts +500 -500
  60. package/src/programmers/IsCloneProgrammer.ts +86 -86
  61. package/src/programmers/IsParseProgrammer.ts +80 -80
  62. package/src/programmers/IsProgrammer.ts +212 -212
  63. package/src/programmers/IsPruneProgrammer.ts +81 -81
  64. package/src/programmers/IsStringifyProgrammer.ts +84 -84
  65. package/src/programmers/LiteralsProgrammer.ts +65 -65
  66. package/src/programmers/PruneProgrammer.ts +347 -347
  67. package/src/programmers/RandomProgrammer.ts +423 -423
  68. package/src/programmers/StringifyProgrammer.ts +798 -798
  69. package/src/programmers/TypiaProgrammer.ts +129 -129
  70. package/src/programmers/ValidateCloneProgrammer.ts +93 -93
  71. package/src/programmers/ValidateParseProgrammer.ts +78 -78
  72. package/src/programmers/ValidateProgrammer.ts +316 -316
  73. package/src/programmers/ValidatePruneProgrammer.ts +86 -86
  74. package/src/programmers/ValidateStringifyProgrammer.ts +92 -92
  75. package/src/programmers/helpers/CloneJoiner.ts +131 -131
  76. package/src/programmers/helpers/FunctionImporeter.ts +54 -54
  77. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  78. package/src/programmers/helpers/PruneJoiner.ts +144 -144
  79. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  80. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  81. package/src/programmers/helpers/UnionExplorer.ts +275 -275
  82. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  83. package/src/programmers/internal/application_array.ts +36 -36
  84. package/src/programmers/internal/application_boolean.ts +17 -17
  85. package/src/programmers/internal/application_constant.ts +30 -30
  86. package/src/programmers/internal/application_default_string.ts +33 -33
  87. package/src/programmers/internal/application_native.ts +32 -32
  88. package/src/programmers/internal/application_number.ts +73 -73
  89. package/src/programmers/internal/application_object.ts +155 -155
  90. package/src/programmers/internal/application_schema.ts +213 -213
  91. package/src/programmers/internal/application_string.ts +45 -45
  92. package/src/programmers/internal/application_templates.ts +26 -26
  93. package/src/programmers/internal/application_tuple.ts +31 -31
  94. package/src/programmers/internal/check_array.ts +30 -30
  95. package/src/programmers/internal/check_custom.ts +31 -31
  96. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  97. package/src/programmers/internal/check_everything.ts +28 -28
  98. package/src/programmers/internal/check_native.ts +21 -21
  99. package/src/programmers/internal/check_string_tags.ts +67 -67
  100. package/src/programmers/internal/check_union_array_like.ts +271 -271
  101. package/src/programmers/internal/check_union_tuple.ts +33 -33
  102. package/src/programmers/internal/random_custom.ts +29 -29
  103. package/src/programmers/internal/stringify_dynamic_properties.ts +167 -167
  104. package/src/programmers/internal/stringify_native.ts +7 -7
  105. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  106. package/src/schemas/IJsonSchema.ts +130 -130
  107. package/src/transform.ts +17 -17
  108. package/src/transformers/CallExpressionTransformer.ts +177 -177
  109. package/src/transformers/FileTransformer.ts +47 -47
  110. package/src/transformers/NodeTransformer.ts +13 -13
  111. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +114 -114
  112. package/src/transformers/features/miscellaneous/AssertCloneTransformer.ts +9 -9
  113. package/src/transformers/features/miscellaneous/AssertPruneTransformer.ts +9 -9
  114. package/src/transformers/features/miscellaneous/CloneTransformer.ts +9 -9
  115. package/src/transformers/features/miscellaneous/CreateAssertCloneTransformer.ts +9 -9
  116. package/src/transformers/features/miscellaneous/CreateAssertPruneTransformer.ts +9 -9
  117. package/src/transformers/features/miscellaneous/CreateCloneTransformer.ts +9 -9
  118. package/src/transformers/features/miscellaneous/CreateIsCloneTransformer.ts +9 -9
  119. package/src/transformers/features/miscellaneous/CreateIsPruneTransformer.ts +9 -9
  120. package/src/transformers/features/miscellaneous/CreatePruneTransformer.ts +9 -9
  121. package/src/transformers/features/miscellaneous/CreateRandomTransformer.ts +39 -39
  122. package/src/transformers/features/miscellaneous/CreateValidateCloneTransformer.ts +9 -9
  123. package/src/transformers/features/miscellaneous/CreateValidatePruneTransformer.ts +9 -9
  124. package/src/transformers/features/miscellaneous/IsCloneTransformer.ts +9 -9
  125. package/src/transformers/features/miscellaneous/IsPruneTransformer.ts +9 -9
  126. package/src/transformers/features/miscellaneous/LiteralsTransformer.ts +28 -28
  127. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +52 -52
  128. package/src/transformers/features/miscellaneous/PruneTransformer.ts +9 -9
  129. package/src/transformers/features/miscellaneous/RandomTransformer.ts +42 -42
  130. package/src/transformers/features/miscellaneous/ValidateCloneTransformer.ts +9 -9
  131. package/src/transformers/features/miscellaneous/ValidatePruneTransformer.ts +9 -9
  132. package/src/transformers/features/parsers/AssertParseTransformer.ts +9 -9
  133. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +9 -9
  134. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +9 -9
  135. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +9 -9
  136. package/src/transformers/features/parsers/IsParseTransformer.ts +9 -9
  137. package/src/transformers/features/parsers/ValidateParseTransformer.ts +9 -9
  138. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +10 -10
  139. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +12 -12
  140. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +9 -9
  141. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +9 -9
  142. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +12 -12
  143. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +9 -9
  144. package/src/transformers/features/stringifiers/StringifyTransformer.ts +9 -9
  145. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +10 -10
  146. package/src/transformers/features/validators/AssertTransformer.ts +11 -11
  147. package/src/transformers/features/validators/CreateAssertTransformer.ts +13 -13
  148. package/src/transformers/features/validators/CreateIsTransformer.ts +11 -11
  149. package/src/transformers/features/validators/CreateValidateTransformer.ts +13 -13
  150. package/src/transformers/features/validators/IsTransformer.ts +11 -11
  151. package/src/transformers/features/validators/ValidateTransformer.ts +11 -11
  152. package/src/transformers/internal/GenericTransformer.ts +97 -97
  153. package/src/utils/ArrayUtil.ts +44 -44
  154. package/src/utils/Escaper.ts +45 -45
  155. package/src/utils/MapUtil.ts +12 -12
  156. package/src/utils/PatternUtil.ts +30 -30
  157. 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
+ });