typia 3.5.0-dev.20221219 → 3.5.0-dev.20230107

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 (136) hide show
  1. package/README.md +62 -17
  2. package/lib/executable/internal/TypiaSetupWizard.d.ts +6 -2
  3. package/lib/executable/internal/TypiaSetupWizard.js +25 -23
  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/MetadataCollection.d.ts +1 -9
  8. package/lib/factories/MetadataCollection.js +2 -77
  9. package/lib/factories/MetadataCollection.js.map +1 -1
  10. package/lib/factories/MetadataTagFactory.js +4 -1
  11. package/lib/factories/MetadataTagFactory.js.map +1 -1
  12. package/lib/factories/ProtocolFactory.d.ts +0 -1
  13. package/lib/factories/ProtocolFactory.js +0 -6
  14. package/lib/factories/ProtocolFactory.js.map +1 -1
  15. package/lib/factories/internal/metadata/iterate_metadata_object.js +4 -2
  16. package/lib/factories/internal/metadata/iterate_metadata_object.js.map +1 -1
  17. package/lib/factories/internal/protocols/iterate_protocol_main.js +2 -3
  18. package/lib/factories/internal/protocols/iterate_protocol_main.js.map +1 -1
  19. package/lib/factories/internal/protocols/iterate_protocol_map.js +3 -4
  20. package/lib/factories/internal/protocols/iterate_protocol_map.js.map +1 -1
  21. package/lib/factories/internal/protocols/iterate_protocol_metadata.js +2 -0
  22. package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +1 -1
  23. package/lib/factories/internal/protocols/iterate_protocol_repeated.js +3 -4
  24. package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +1 -1
  25. package/lib/factories/internal/protocols/iterate_protocol_tuple.js +3 -4
  26. package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +1 -1
  27. package/lib/functional/$number.js +2 -9
  28. package/lib/functional/$number.js.map +1 -1
  29. package/lib/metadata/Metadata.js +32 -29
  30. package/lib/metadata/Metadata.js.map +1 -1
  31. package/lib/programmers/AssertParseProgrammer.js +12 -1
  32. package/lib/programmers/AssertParseProgrammer.js.map +1 -1
  33. package/lib/programmers/AssertProgrammer.js +3 -2
  34. package/lib/programmers/AssertProgrammer.js.map +1 -1
  35. package/lib/programmers/AssertStringifyProgrammer.js +13 -2
  36. package/lib/programmers/AssertStringifyProgrammer.js.map +1 -1
  37. package/lib/programmers/CheckerProgrammer.d.ts +1 -0
  38. package/lib/programmers/CheckerProgrammer.js +153 -138
  39. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  40. package/lib/programmers/IsParseProgrammer.js +12 -1
  41. package/lib/programmers/IsParseProgrammer.js.map +1 -1
  42. package/lib/programmers/IsProgrammer.js +5 -2
  43. package/lib/programmers/IsProgrammer.js.map +1 -1
  44. package/lib/programmers/IsStringifyProgrammer.js +13 -2
  45. package/lib/programmers/IsStringifyProgrammer.js.map +1 -1
  46. package/lib/programmers/MessageProgrammer.js +11 -6
  47. package/lib/programmers/MessageProgrammer.js.map +1 -1
  48. package/lib/programmers/StringifyProgrammer.js +6 -1
  49. package/lib/programmers/StringifyProgrammer.js.map +1 -1
  50. package/lib/programmers/ValidateParseProgrammer.js +12 -1
  51. package/lib/programmers/ValidateParseProgrammer.js.map +1 -1
  52. package/lib/programmers/ValidateProgrammer.js +3 -2
  53. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  54. package/lib/programmers/ValidateStringifyProgrammer.js +13 -2
  55. package/lib/programmers/ValidateStringifyProgrammer.js.map +1 -1
  56. package/lib/programmers/helpers/OptionPredicator.d.ts +2 -1
  57. package/lib/programmers/helpers/OptionPredicator.js +8 -6
  58. package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
  59. package/lib/programmers/helpers/UnionExplorer.d.ts +23 -29
  60. package/lib/programmers/helpers/UnionExplorer.js +29 -41
  61. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  62. package/lib/programmers/internal/application_object.js +9 -9
  63. package/lib/programmers/internal/application_object.js.map +1 -1
  64. package/lib/programmers/internal/application_schema.js +14 -6
  65. package/lib/programmers/internal/application_schema.js.map +1 -1
  66. package/lib/programmers/internal/check_array.js +4 -32
  67. package/lib/programmers/internal/check_array.js.map +1 -1
  68. package/lib/programmers/internal/check_array_length.d.ts +1 -0
  69. package/lib/programmers/internal/check_array_length.js +47 -0
  70. package/lib/programmers/internal/check_array_length.js.map +1 -0
  71. package/lib/programmers/internal/check_bigint.d.ts +3 -0
  72. package/lib/programmers/internal/check_bigint.js +97 -0
  73. package/lib/programmers/internal/check_bigint.js.map +1 -0
  74. package/lib/programmers/internal/check_number.js +21 -23
  75. package/lib/programmers/internal/check_number.js.map +1 -1
  76. package/lib/programmers/internal/check_union_array_like.d.ts +21 -0
  77. package/lib/programmers/internal/check_union_array_like.js +83 -0
  78. package/lib/programmers/internal/check_union_array_like.js.map +1 -0
  79. package/lib/programmers/internal/check_union_tuple.d.ts +1 -0
  80. package/lib/programmers/internal/check_union_tuple.js +11 -0
  81. package/lib/programmers/internal/check_union_tuple.js.map +1 -0
  82. package/lib/schemas/IJsonSchema.d.ts +3 -5
  83. package/lib/transformers/ITransformOptions.d.ts +43 -2
  84. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +5 -3
  85. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
  86. package/lib/transformers/features/stringifiers/StringifyTransformer.js +12 -1
  87. package/lib/transformers/features/stringifiers/StringifyTransformer.js.map +1 -1
  88. package/lib/utils/NameEncoder.d.ts +4 -0
  89. package/lib/utils/NameEncoder.js +89 -0
  90. package/lib/utils/NameEncoder.js.map +1 -0
  91. package/package.json +6 -5
  92. package/src/executable/internal/TypiaSetupWizard.ts +37 -24
  93. package/src/executable/typia.ts +7 -5
  94. package/src/factories/MetadataCollection.ts +2 -43
  95. package/src/factories/MetadataTagFactory.ts +5 -1
  96. package/src/factories/ProtocolFactory.ts +0 -5
  97. package/src/factories/internal/metadata/iterate_metadata_object.ts +6 -3
  98. package/src/factories/internal/protocols/iterate_protocol_main.ts +2 -3
  99. package/src/factories/internal/protocols/iterate_protocol_map.ts +3 -5
  100. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +1 -0
  101. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +3 -6
  102. package/src/factories/internal/protocols/iterate_protocol_tuple.ts +3 -6
  103. package/src/functional/$number.ts +2 -9
  104. package/src/metadata/Metadata.ts +10 -7
  105. package/src/programmers/AssertParseProgrammer.ts +11 -1
  106. package/src/programmers/AssertProgrammer.ts +4 -3
  107. package/src/programmers/AssertStringifyProgrammer.ts +22 -2
  108. package/src/programmers/CheckerProgrammer.ts +258 -200
  109. package/src/programmers/IsParseProgrammer.ts +11 -1
  110. package/src/programmers/IsProgrammer.ts +5 -2
  111. package/src/programmers/IsStringifyProgrammer.ts +22 -2
  112. package/src/programmers/MessageProgrammer.ts +12 -6
  113. package/src/programmers/StringifyProgrammer.ts +7 -1
  114. package/src/programmers/ValidateParseProgrammer.ts +11 -1
  115. package/src/programmers/ValidateProgrammer.ts +3 -2
  116. package/src/programmers/ValidateStringifyProgrammer.ts +22 -2
  117. package/src/programmers/helpers/OptionPredicator.ts +7 -10
  118. package/src/programmers/helpers/UnionExplorer.ts +75 -238
  119. package/src/programmers/internal/application_default.ts +1 -1
  120. package/src/programmers/internal/application_object.ts +5 -5
  121. package/src/programmers/internal/application_schema.ts +20 -5
  122. package/src/programmers/internal/check_array.ts +3 -25
  123. package/src/programmers/internal/check_array_length.ts +45 -0
  124. package/src/programmers/internal/check_bigint.ts +85 -0
  125. package/src/programmers/internal/check_number.ts +45 -51
  126. package/src/programmers/internal/check_union_array_like.ts +242 -0
  127. package/src/programmers/internal/check_union_tuple.ts +33 -0
  128. package/src/schemas/IJsonSchema.ts +4 -6
  129. package/src/transformers/ITransformOptions.ts +45 -2
  130. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +7 -3
  131. package/src/transformers/features/stringifiers/StringifyTransformer.ts +11 -1
  132. package/src/utils/NameEncoder.ts +32 -0
  133. package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.d.ts +0 -5
  134. package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.js +0 -29
  135. package/lib/transformers/features/miscellaneous/CreateInstanceTransformer.js.map +0 -1
  136. package/src/transformers/features/miscellaneous/CreateInstanceTransformer.ts +0 -41
@@ -498,7 +498,7 @@ export namespace StringifyProgrammer {
498
498
  );
499
499
  else if (
500
500
  type === "number" &&
501
- OptionPredicator.numeric(project.options, "stringify")
501
+ OptionPredicator.numeric(project.options)
502
502
  )
503
503
  input = ts.factory.createCallExpression(
504
504
  importer.use("number"),
@@ -700,6 +700,10 @@ export namespace StringifyProgrammer {
700
700
  {
701
701
  resolve: true,
702
702
  constant: true,
703
+ validate: (meta) => {
704
+ if (meta.atomics.find((str) => str === "bigint"))
705
+ throw new Error(NO_BIGINT);
706
+ },
703
707
  },
704
708
  );
705
709
  return [collection, meta];
@@ -754,3 +758,5 @@ interface IUnion {
754
758
  is: () => ts.Expression;
755
759
  value: () => ts.Expression;
756
760
  }
761
+
762
+ const NO_BIGINT = "Error on typia.stringify(): does not allow bigint type.";
@@ -20,7 +20,17 @@ export namespace ValidateParseProgrammer {
20
20
  ts.factory.createBlock([
21
21
  StatementFactory.constant(
22
22
  "validate",
23
- ValidateProgrammer.generate(project, modulo)(type),
23
+ ValidateProgrammer.generate(
24
+ {
25
+ ...project,
26
+ options: {
27
+ ...project.options,
28
+ functional: false,
29
+ numeric: false,
30
+ },
31
+ },
32
+ modulo,
33
+ )(type),
24
34
  ),
25
35
  ts.factory.createExpressionStatement(
26
36
  ts.factory.createBinaryExpression(
@@ -8,6 +8,7 @@ import { IProject } from "../transformers/IProject";
8
8
  import { CheckerProgrammer } from "./CheckerProgrammer";
9
9
  import { IsProgrammer } from "./IsProgrammer";
10
10
  import { FunctionImporter } from "./helpers/FunctionImporeter";
11
+ import { OptionPredicator } from "./helpers/OptionPredicator";
11
12
  import { check_everything } from "./internal/check_everything";
12
13
  import { check_object } from "./internal/check_object";
13
14
 
@@ -27,7 +28,7 @@ export namespace ValidateProgrammer {
27
28
  unioners: "$vu",
28
29
  path: true,
29
30
  trace: true,
30
- numeric: !!project.options.numeric,
31
+ numeric: OptionPredicator.numeric(project.options),
31
32
  equals,
32
33
  combiner: combine(equals)(importer),
33
34
  joiner: joiner(equals)(importer),
@@ -87,7 +88,7 @@ const combine =
87
88
  (equals: boolean) =>
88
89
  (importer: FunctionImporter): CheckerProgrammer.IConfig.Combiner =>
89
90
  (explore: CheckerProgrammer.IExplore) => {
90
- if (explore.tracable === false && explore.from !== "top")
91
+ if (explore.tracable === false)
91
92
  return IsProgrammer.CONFIG({
92
93
  object: validate_object(equals)(importer),
93
94
  numeric: true,
@@ -21,11 +21,31 @@ export namespace ValidateStringifyProgrammer {
21
21
  ts.factory.createBlock([
22
22
  StatementFactory.constant(
23
23
  "validate",
24
- ValidateProgrammer.generate(project, modulo)(type),
24
+ ValidateProgrammer.generate(
25
+ {
26
+ ...project,
27
+ options: {
28
+ ...project.options,
29
+ functional: false,
30
+ numeric: true,
31
+ },
32
+ },
33
+ modulo,
34
+ )(type),
25
35
  ),
26
36
  StatementFactory.constant(
27
37
  "stringify",
28
- StringifyProgrammer.generate(project, modulo)(type),
38
+ StringifyProgrammer.generate(
39
+ {
40
+ ...project,
41
+ options: {
42
+ ...project.options,
43
+ functional: false,
44
+ numeric: false,
45
+ },
46
+ },
47
+ modulo,
48
+ )(type),
29
49
  ),
30
50
  StatementFactory.constant(
31
51
  "output",
@@ -1,18 +1,15 @@
1
1
  import { ITransformOptions } from "../../transformers/ITransformOptions";
2
2
 
3
3
  export namespace OptionPredicator {
4
+ export function numeric(options: ITransformOptions): boolean {
5
+ return finite(options) || options.numeric === true;
6
+ }
7
+
4
8
  export function functional(options: ITransformOptions): boolean {
5
- return options.functional !== false;
9
+ return options.functional === true;
6
10
  }
7
11
 
8
- export function numeric(
9
- options: ITransformOptions,
10
- from: "checker" | "stringify",
11
- ): boolean {
12
- return (
13
- options.numeric === undefined ||
14
- options.numeric === true ||
15
- options.numeric === from
16
- );
12
+ export function finite(options: ITransformOptions): boolean {
13
+ return options.finite === true;
17
14
  }
18
15
  }
@@ -2,14 +2,13 @@ import ts from "typescript";
2
2
 
3
3
  import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
4
  import { IdentifierFactory } from "../../factories/IdentifierFactory";
5
- import { StatementFactory } from "../../factories/StatementFactory";
6
5
 
7
6
  import { IMetadataTag } from "../../metadata/IMetadataTag";
8
7
  import { Metadata } from "../../metadata/Metadata";
9
8
  import { MetadataObject } from "../../metadata/MetadataObject";
10
9
 
11
- import { CheckerProgrammer } from "../CheckerProgrammer";
12
10
  import { FeatureProgrammer } from "../FeatureProgrammer";
11
+ import { check_union_array_like } from "../internal/check_union_array_like";
13
12
  import { UnionPredicator } from "./UnionPredicator";
14
13
 
15
14
  export namespace UnionExplorer {
@@ -23,16 +22,17 @@ export namespace UnionExplorer {
23
22
  }
24
23
  export type ObjectCombiner = Decoder<MetadataObject[]>;
25
24
 
26
- export function object(
27
- config: FeatureProgrammer.IConfig,
28
- level: number = 0,
29
- ) {
30
- return function (
25
+ /* -----------------------------------------------------------
26
+ OBJECT
27
+ ----------------------------------------------------------- */
28
+ export const object =
29
+ (config: FeatureProgrammer.IConfig, level: number = 0) =>
30
+ (
31
31
  input: ts.Expression,
32
32
  targets: MetadataObject[],
33
33
  explore: FeatureProgrammer.IExplore,
34
34
  tags: IMetadataTag[],
35
- ): ts.Expression {
35
+ ): ts.Expression => {
36
36
  // BREAKER
37
37
  if (targets.length === 1)
38
38
  return config.objector.decoder(
@@ -135,10 +135,25 @@ export namespace UnionExplorer {
135
135
  undefined,
136
136
  );
137
137
  };
138
+
139
+ /* -----------------------------------------------------------
140
+ ARRAY LIKE
141
+ ----------------------------------------------------------- */
142
+ export const tuple = (props: check_union_array_like.IProps<Metadata[]>) =>
143
+ check_union_array_like<Metadata[]>({
144
+ size: null,
145
+ front: (input) => input,
146
+ array: (input) => input,
147
+ name: (elems) => `[${elems.map((e) => e.getName()).join(", ")}]`,
148
+ })(props);
149
+ export namespace tuple {
150
+ export type IProps = check_union_array_like.IProps<
151
+ Metadata | Metadata[]
152
+ >;
138
153
  }
139
154
 
140
155
  export const array = (props: array.IProps) =>
141
- iterate<Metadata>({
156
+ check_union_array_like<Metadata>({
142
157
  size: (input) => IdentifierFactory.join(input, "length"),
143
158
  front: (input) =>
144
159
  ts.factory.createElementAccessExpression(input, 0),
@@ -146,11 +161,28 @@ export namespace UnionExplorer {
146
161
  name: (t) => `Array<${t.getName()}>`,
147
162
  })(props);
148
163
  export namespace array {
149
- export type IProps = iterate.IProps<Metadata>;
164
+ export type IProps = check_union_array_like.IProps<Metadata>;
165
+ }
166
+
167
+ export const array_or_tuple = (props: array_or_tuple.IProps) =>
168
+ check_union_array_like<Metadata | Metadata[]>({
169
+ size: (input) => IdentifierFactory.join(input, "length"),
170
+ front: (input) =>
171
+ ts.factory.createElementAccessExpression(input, 0),
172
+ array: (input) => input,
173
+ name: (t) =>
174
+ Array.isArray(t)
175
+ ? `[${t.map((e) => e.getName()).join(", ")}]`
176
+ : `Array<${t.getName()}>`,
177
+ })(props);
178
+ export namespace array_or_tuple {
179
+ export type IProps = check_union_array_like.IProps<
180
+ Metadata | Metadata[]
181
+ >;
150
182
  }
151
183
 
152
184
  export const set = (props: set.IProps) =>
153
- iterate<Metadata>({
185
+ check_union_array_like<Metadata>({
154
186
  size: (input) => IdentifierFactory.join(input, "size"),
155
187
  front: (input) =>
156
188
  IdentifierFactory.join(
@@ -176,11 +208,11 @@ export namespace UnionExplorer {
176
208
  name: (t) => `Set<${t.getName()}>`,
177
209
  })(props);
178
210
  export namespace set {
179
- export type IProps = iterate.IProps<Metadata>;
211
+ export type IProps = check_union_array_like.IProps<Metadata>;
180
212
  }
181
213
 
182
214
  export const map = (props: map.IProps) =>
183
- iterate<[Metadata, Metadata]>({
215
+ check_union_array_like<[Metadata, Metadata]>({
184
216
  size: (input) => IdentifierFactory.join(input, "size"),
185
217
  front: (input) =>
186
218
  IdentifierFactory.join(
@@ -207,231 +239,36 @@ export namespace UnionExplorer {
207
239
  })(props);
208
240
 
209
241
  export namespace map {
210
- export type IProps = iterate.IProps<[Metadata, Metadata]>;
242
+ export type IProps = check_union_array_like.IProps<
243
+ [Metadata, Metadata]
244
+ >;
211
245
  }
212
246
 
213
- const iterate =
214
- <T>(accessor: iterate.IAccessor<T>) =>
215
- (props: iterate.IProps<T>) =>
216
- (
217
- input: ts.Expression,
218
- targets: T[],
219
- explore: FeatureProgrammer.IExplore,
220
- tags: IMetadataTag[],
221
- ): ts.Expression => {
222
- if (targets.length === 1)
223
- return props.decoder(
224
- accessor.array(input),
225
- targets[0]!,
226
- explore,
227
- tags,
228
- );
229
-
230
- //----
231
- // LIST UP VARIABLES
232
- //----
233
- // TUPLES
234
- const tupleListVariable: ts.VariableStatement =
235
- StatementFactory.constant(
236
- "tupleList",
237
- ts.factory.createArrayLiteralExpression(
238
- targets.map((meta) =>
239
- ts.factory.createArrayLiteralExpression([
240
- ts.factory.createArrowFunction(
241
- undefined,
242
- undefined,
243
- [IdentifierFactory.parameter("branch")],
244
- undefined,
245
- undefined,
246
- props.checker(
247
- ts.factory.createIdentifier("branch"),
248
- meta,
249
- {
250
- ...explore,
251
- tracable: false,
252
- postfix: `"[0]"`,
253
- },
254
- tags,
255
- ),
256
- ),
257
- ts.factory.createArrowFunction(
258
- undefined,
259
- undefined,
260
- [IdentifierFactory.parameter("branch")],
261
- undefined,
262
- undefined,
263
- props.decoder(
264
- ts.factory.createIdentifier("branch"),
265
- meta,
266
- {
267
- ...explore,
268
- tracable: true,
269
- },
270
- tags,
271
- ),
272
- ),
273
- ]),
274
- ),
275
- ),
276
- );
277
-
278
- // FILTERED TUPLES
279
- const filteredVariable = StatementFactory.constant(
280
- "filtered",
281
- ts.factory.createCallExpression(
282
- ts.factory.createIdentifier("tupleList.filter"),
283
- undefined,
284
- [
285
- ts.factory.createArrowFunction(
286
- undefined,
287
- undefined,
288
- [IdentifierFactory.parameter("tuple")],
289
- undefined,
290
- undefined,
291
- ts.factory.createStrictEquality(
292
- props.success,
293
- ts.factory.createCallExpression(
294
- ts.factory.createIdentifier("tuple[0]"),
295
- undefined,
296
- [ts.factory.createIdentifier("front")],
297
- ),
298
- ),
299
- ),
300
- ],
301
- ),
302
- );
303
-
304
- //----
305
- // STATEMENTS
306
- //----
307
- // ONLY ONE TYPE
308
- const uniqueStatement = ts.factory.createIfStatement(
309
- ts.factory.createStrictEquality(
310
- ts.factory.createNumericLiteral(1),
311
- ts.factory.createIdentifier("filtered.length"),
312
- ),
313
- ts.factory.createReturnStatement(
314
- ts.factory.createCallExpression(
315
- ts.factory.createIdentifier(`filtered[0][1]`),
316
- undefined,
317
- [accessor.array(input)],
318
- ),
319
- ),
320
- );
321
-
322
- // UNION TYPE
323
- const forOfStatement = ts.factory.createForOfStatement(
324
- undefined,
325
- ts.factory.createVariableDeclarationList(
326
- [ts.factory.createVariableDeclaration("tuple")],
327
- ts.NodeFlags.Const,
328
- ),
329
- // StatementFactory.variable(ts.NodeFlags.Const, "tuple"),
330
- ts.factory.createIdentifier("filtered"),
331
- ts.factory.createIfStatement(
332
- ts.factory.createCallExpression(
333
- IdentifierFactory.join(
334
- ts.factory.createIdentifier("array"),
335
- "every",
336
- ),
337
- undefined,
338
- [
339
- ts.factory.createArrowFunction(
340
- undefined,
341
- undefined,
342
- [IdentifierFactory.parameter("value")],
343
- undefined,
344
- undefined,
345
- ts.factory.createStrictEquality(
346
- props.success,
347
- ts.factory.createCallExpression(
348
- ts.factory.createIdentifier("tuple[0]"),
349
- undefined,
350
- [ts.factory.createIdentifier("value")],
351
- ),
352
- ),
353
- ),
354
- ],
355
- ),
356
- ts.factory.createReturnStatement(
357
- ts.factory.createCallExpression(
358
- ts.factory.createIdentifier(`tuple[1]`),
359
- undefined,
360
- [ts.factory.createIdentifier("array")],
361
- ),
362
- ),
363
- ),
364
- );
365
- const unionStatement = ts.factory.createIfStatement(
366
- ts.factory.createLessThan(
367
- ts.factory.createNumericLiteral(1),
368
- ts.factory.createIdentifier("filtered.length"),
369
- ),
370
- forOfStatement,
371
- );
372
-
373
- const block = [
374
- // ARRAY.LENGTH := 0
375
- ts.factory.createIfStatement(
376
- ts.factory.createStrictEquality(
377
- ts.factory.createNumericLiteral(0),
378
- accessor.size(input),
379
- ),
380
- ts.factory.createReturnStatement(props.empty),
381
- ),
382
-
383
- // UNION PREDICATORS
384
- tupleListVariable,
385
- StatementFactory.constant("front", accessor.front(input)),
386
- filteredVariable,
387
- uniqueStatement,
388
-
389
- // CONDITIONAL STATEMENTS
390
- StatementFactory.constant("array", accessor.array(input)),
391
- unionStatement,
392
- props.failure(
393
- input,
394
- `(${targets.map((t) => accessor.name(t)).join(" | ")})`,
395
- explore,
396
- ),
397
- ];
398
-
399
- return ts.factory.createCallExpression(
400
- ts.factory.createArrowFunction(
401
- undefined,
402
- undefined,
403
- [],
404
- undefined,
405
- undefined,
406
- ts.factory.createBlock(block, true),
407
- ),
408
- undefined,
409
- undefined,
410
- );
411
- };
412
- namespace iterate {
413
- export interface IProps<T> {
414
- checker(
415
- input: ts.Expression,
416
- target: T,
417
- explore: FeatureProgrammer.IExplore,
418
- tags: IMetadataTag[],
419
- ): ts.Expression;
420
- decoder: Decoder<T>;
421
- empty: ts.Expression;
422
- success: ts.Expression;
423
- failure(
424
- input: ts.Expression,
425
- expected: string,
426
- explore: CheckerProgrammer.IExplore,
427
- ): ts.Statement;
428
- }
429
-
430
- export interface IAccessor<T> {
431
- name(metadata: T): string;
432
- size(input: ts.Expression): ts.Expression;
433
- front(input: ts.Expression): ts.Expression;
434
- array(input: ts.Expression): ts.Expression;
435
- }
436
- }
247
+ // const transform = <T>(
248
+ // props: check_union_array_like.IProps<T>,
249
+ // ): check_union_array_like.IProps<T> => ({
250
+ // ...props,
251
+ // checker: (top, targets, explore, tags, array) =>
252
+ // props.checker(
253
+ // top,
254
+ // targets,
255
+ // {
256
+ // ...explore,
257
+ // tracable: false,
258
+ // postfix: `"[0]"`,
259
+ // },
260
+ // tags,
261
+ // array,
262
+ // ),
263
+ // decoder: (input, targets, explore, tags) =>
264
+ // props.decoder(
265
+ // input,
266
+ // targets,
267
+ // {
268
+ // ...explore,
269
+ // tracable: true,
270
+ // },
271
+ // tags,
272
+ // ),
273
+ // });
437
274
  }
@@ -1,4 +1,4 @@
1
- import { IJsonSchema } from "../../module";
1
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
2
2
 
3
3
  /**
4
4
  * @internal
@@ -17,10 +17,10 @@ import { metadata_to_pattern } from "./metadata_to_pattern";
17
17
  export const application_object =
18
18
  (options: ApplicationProgrammer.IOptions) =>
19
19
  (components: IJsonComponents) =>
20
- (key: string, obj: MetadataObject, nullable: boolean): void => {
20
+ (id: string, obj: MetadataObject, nullable: boolean): void => {
21
21
  // TEMPORARY ASSIGNMENT
22
- if (components.schemas[key] !== undefined) return;
23
- components.schemas[key] = {} as any;
22
+ if (components.schemas[id] !== undefined) return;
23
+ components.schemas[id] = {} as any;
24
24
 
25
25
  // ITERATE PROPERTIES
26
26
  const properties: Record<string, any> = {};
@@ -80,7 +80,7 @@ export const application_object =
80
80
  const schema: IJsonComponents.IObject = {
81
81
  $id:
82
82
  options.purpose === "ajv"
83
- ? options.prefix + "/" + key
83
+ ? options.prefix + "/" + id
84
84
  : undefined,
85
85
  $recursiveAnchor:
86
86
  (options.purpose === "ajv" && obj.recursive) || undefined,
@@ -99,5 +99,5 @@ export const application_object =
99
99
  description: obj.description,
100
100
  "x-typia_jsDocTags": obj.jsDocTags,
101
101
  };
102
- components.schemas[key] = schema;
102
+ components.schemas[id] = schema;
103
103
  };
@@ -4,6 +4,7 @@ import { IJsonComponents } from "../../schemas/IJsonComponents";
4
4
  import { IJsonSchema } from "../../schemas/IJsonSchema";
5
5
 
6
6
  import { ArrayUtil } from "../../utils/ArrayUtil";
7
+ import { NameEncoder } from "../../utils/NameEncoder";
7
8
 
8
9
  import { ApplicationProgrammer } from "../ApplicationProgrammer";
9
10
  import { AtomicPredicator } from "../helpers/AtomicPredicator";
@@ -50,13 +51,18 @@ export const application_schema =
50
51
  if (meta.templates.length && AtomicPredicator.template(meta))
51
52
  union.push(application_templates(meta, attribute));
52
53
  for (const constant of meta.constants) {
53
- if (constant.type === "string" && meta.templates.length) continue;
54
- else if (!AtomicPredicator.constant(meta)(constant.type)) continue;
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;
55
60
  union.push(
56
61
  application_constant(constant, meta.nullable, attribute),
57
62
  );
58
63
  }
59
64
  for (const type of meta.atomics) {
65
+ if (type === "bigint") throw new Error(NO_BIGINT);
60
66
  union.push(
61
67
  type === "string"
62
68
  ? application_string(meta, attribute)
@@ -90,6 +96,11 @@ export const application_schema =
90
96
  ),
91
97
  );
92
98
  else {
99
+ if (items.length === 0)
100
+ throw new Error(
101
+ "Error on typia.application(): swagger does not support zero length tuple type.",
102
+ );
103
+
93
104
  // SWAGGER DOES NOT SUPPORT TUPLE TYPE YET
94
105
  const merged: Metadata = items.reduce((x, y) =>
95
106
  merge_metadata(x, y),
@@ -128,12 +139,14 @@ export const application_schema =
128
139
 
129
140
  // OBJECT
130
141
  for (const obj of meta.objects) {
131
- const key: string = obj.name + (meta.nullable ? ".Nullable" : "");
132
- application_object(options)(components)(key, obj, meta.nullable);
142
+ const id: string =
143
+ NameEncoder.encode(obj.name) +
144
+ (meta.nullable ? ".Nullable" : "");
145
+ application_object(options)(components)(id, obj, meta.nullable);
133
146
  union.push(
134
147
  (options.purpose === "ajv" && obj.recursive
135
148
  ? recursive
136
- : reference)(`${options.prefix}/${key}`, attribute),
149
+ : reference)(`${options.prefix}/${id}`, attribute),
137
150
  );
138
151
  }
139
152
 
@@ -219,3 +232,5 @@ function merge_metadata(x: Metadata, y: Metadata): Metadata {
219
232
 
220
233
  return output;
221
234
  }
235
+
236
+ const NO_BIGINT = "Error on typia.application(): does not allow bigint type.";
@@ -1,11 +1,10 @@
1
1
  import ts from "typescript";
2
2
 
3
3
  import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
5
4
 
6
5
  import { IMetadataTag } from "../../metadata/IMetadataTag";
7
6
 
8
- import { check_length } from "./check_length";
7
+ import { check_array_length } from "./check_array_length";
9
8
 
10
9
  /**
11
10
  * @internal
@@ -16,29 +15,8 @@ export function check_array(
16
15
  ): ts.Expression {
17
16
  const conditions: ts.Expression[] = [ExpressionFactory.isArray(input)];
18
17
 
19
- // CHECK TAGS
20
- for (const tag of tagList)
21
- if (tag.kind === "minItems")
22
- conditions.push(
23
- ts.factory.createLessThanEquals(
24
- ts.factory.createNumericLiteral(tag.value),
25
- IdentifierFactory.join(input, "length"),
26
- ),
27
- );
28
- else if (tag.kind === "maxItems")
29
- conditions.push(
30
- ts.factory.createGreaterThanEquals(
31
- ts.factory.createNumericLiteral(tag.value),
32
- IdentifierFactory.join(input, "length"),
33
- ),
34
- );
35
- else if (tag.kind === "items")
36
- check_length(
37
- conditions,
38
- IdentifierFactory.join(input, "length"),
39
- tag,
40
- );
18
+ const length: ts.Expression | null = check_array_length(input, tagList);
19
+ if (length !== null) conditions.push(length);
41
20
 
42
- // COMBINATION
43
21
  return conditions.reduce((x, y) => ts.factory.createLogicalAnd(x, y));
44
22
  }