typia 3.5.0-dev.20230126 → 3.5.0-dev.20230211

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 (227) hide show
  1. package/README.md +64 -71
  2. package/lib/factories/MetadataCollection.d.ts +9 -1
  3. package/lib/factories/MetadataCollection.js +75 -2
  4. package/lib/factories/MetadataCollection.js.map +1 -1
  5. package/lib/factories/internal/metadata/iterate_metadata_native.js +0 -3
  6. package/lib/factories/internal/metadata/iterate_metadata_native.js.map +1 -1
  7. package/lib/functional/$is_between.d.ts +1 -0
  8. package/lib/functional/$is_between.js +8 -0
  9. package/lib/functional/$is_between.js.map +1 -0
  10. package/lib/metadata/IMetadataTag.d.ts +3 -7
  11. package/lib/metadata/Metadata.js +2 -2
  12. package/lib/metadata/Metadata.js.map +1 -1
  13. package/lib/module.d.ts +33 -3
  14. package/lib/module.js +36 -8
  15. package/lib/module.js.map +1 -1
  16. package/lib/programmers/AssertProgrammer.js +3 -2
  17. package/lib/programmers/AssertProgrammer.js.map +1 -1
  18. package/lib/programmers/CheckerProgrammer.d.ts +2 -2
  19. package/lib/programmers/CheckerProgrammer.js +21 -16
  20. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  21. package/lib/programmers/FeatureProgrammer.d.ts +114 -18
  22. package/lib/programmers/FeatureProgrammer.js +4 -4
  23. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  24. package/lib/programmers/IsProgrammer.d.ts +4 -3
  25. package/lib/programmers/IsProgrammer.js +72 -61
  26. package/lib/programmers/IsProgrammer.js.map +1 -1
  27. package/lib/programmers/PruneProgrammer.d.ts +5 -0
  28. package/lib/programmers/PruneProgrammer.js +279 -0
  29. package/lib/programmers/PruneProgrammer.js.map +1 -0
  30. package/lib/programmers/StringifyProgrammer.js +26 -21
  31. package/lib/programmers/StringifyProgrammer.js.map +1 -1
  32. package/lib/programmers/ValidateProgrammer.js +3 -2
  33. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  34. package/lib/programmers/helpers/AtomicPredicator.d.ts +2 -0
  35. package/lib/programmers/helpers/AtomicPredicator.js +9 -1
  36. package/lib/programmers/helpers/AtomicPredicator.js.map +1 -1
  37. package/lib/programmers/helpers/IExpressionEntry.d.ts +2 -2
  38. package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
  39. package/lib/programmers/helpers/OptionPredicator.js +4 -0
  40. package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
  41. package/lib/programmers/helpers/PruneJoiner.d.ts +8 -0
  42. package/lib/programmers/helpers/PruneJoiner.js +60 -0
  43. package/lib/programmers/helpers/PruneJoiner.js.map +1 -0
  44. package/lib/programmers/helpers/StringifyJoinder.d.ts +1 -1
  45. package/lib/programmers/helpers/StringifyJoinder.js +2 -4
  46. package/lib/programmers/helpers/StringifyJoinder.js.map +1 -1
  47. package/lib/programmers/internal/application_object.js +11 -11
  48. package/lib/programmers/internal/application_object.js.map +1 -1
  49. package/lib/programmers/internal/application_schema.js +21 -12
  50. package/lib/programmers/internal/application_schema.js.map +1 -1
  51. package/lib/programmers/internal/check_dynamic_properties.js +34 -11
  52. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  53. package/lib/programmers/internal/check_native.js +9 -1
  54. package/lib/programmers/internal/check_native.js.map +1 -1
  55. package/lib/programmers/internal/check_object.d.ts +1 -0
  56. package/lib/programmers/internal/check_object.js +13 -9
  57. package/lib/programmers/internal/check_object.js.map +1 -1
  58. package/lib/programmers/internal/check_union_array_like.d.ts +1 -1
  59. package/lib/programmers/internal/check_union_array_like.js +3 -1
  60. package/lib/programmers/internal/check_union_array_like.js.map +1 -1
  61. package/lib/programmers/internal/feature_object_entries.d.ts +2 -2
  62. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  63. package/lib/programmers/internal/prune_object_properties.d.ts +1 -0
  64. package/lib/programmers/internal/prune_object_properties.js +28 -0
  65. package/lib/programmers/internal/prune_object_properties.js.map +1 -0
  66. package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -1
  67. package/lib/programmers/internal/stringify_regular_properties.js.map +1 -1
  68. package/lib/transformers/CallExpressionTransformer.js +5 -3
  69. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  70. package/lib/transformers/ITransformOptions.d.ts +14 -0
  71. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
  72. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
  73. package/lib/transformers/features/miscellaneous/CreatePruneTransformer.d.ts +5 -0
  74. package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js +17 -0
  75. package/lib/transformers/features/miscellaneous/CreatePruneTransformer.js.map +1 -0
  76. package/lib/transformers/features/miscellaneous/PruneTransformer.d.ts +5 -0
  77. package/lib/transformers/features/miscellaneous/PruneTransformer.js +34 -0
  78. package/lib/transformers/features/miscellaneous/PruneTransformer.js.map +1 -0
  79. package/package.json +5 -4
  80. package/src/factories/MetadataCollection.ts +41 -2
  81. package/src/factories/internal/metadata/iterate_metadata_native.ts +0 -5
  82. package/src/functional/$is_between.ts +7 -0
  83. package/src/metadata/IMetadataTag.ts +4 -19
  84. package/src/metadata/Metadata.ts +3 -6
  85. package/src/module.ts +91 -17
  86. package/src/programmers/AssertProgrammer.ts +3 -2
  87. package/src/programmers/CheckerProgrammer.ts +21 -13
  88. package/src/programmers/FeatureProgrammer.ts +146 -21
  89. package/src/programmers/IsProgrammer.ts +107 -87
  90. package/src/programmers/PruneProgrammer.ts +320 -0
  91. package/src/programmers/StringifyProgrammer.ts +51 -34
  92. package/src/programmers/ValidateProgrammer.ts +3 -2
  93. package/src/programmers/helpers/AtomicPredicator.ts +17 -1
  94. package/src/programmers/helpers/IExpressionEntry.ts +4 -2
  95. package/src/programmers/helpers/OptionPredicator.ts +4 -0
  96. package/src/programmers/helpers/PruneJoiner.ts +52 -0
  97. package/src/programmers/helpers/StringifyJoinder.ts +7 -4
  98. package/src/programmers/internal/application_object.ts +5 -5
  99. package/src/programmers/internal/application_schema.ts +33 -27
  100. package/src/programmers/internal/check_dynamic_properties.ts +67 -16
  101. package/src/programmers/internal/check_native.ts +14 -2
  102. package/src/programmers/internal/check_object.ts +8 -2
  103. package/src/programmers/internal/check_union_array_like.ts +4 -2
  104. package/src/programmers/internal/feature_object_entries.ts +6 -1
  105. package/src/programmers/internal/prune_object_properties.ts +60 -0
  106. package/src/programmers/internal/stringify_dynamic_properties.ts +2 -2
  107. package/src/programmers/internal/stringify_regular_properties.ts +2 -2
  108. package/src/transformers/CallExpressionTransformer.ts +15 -16
  109. package/src/transformers/ITransformOptions.ts +15 -0
  110. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
  111. package/src/transformers/features/{protocols/MessageTransformer.ts → miscellaneous/CreatePruneTransformer.ts} +6 -7
  112. package/src/transformers/features/miscellaneous/PruneTransformer.ts +46 -0
  113. package/lib/factories/ProtocolFactory.d.ts +0 -8
  114. package/lib/factories/ProtocolFactory.js +0 -112
  115. package/lib/factories/ProtocolFactory.js.map +0 -1
  116. package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +0 -16
  117. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +0 -156
  118. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +0 -1
  119. package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +0 -3
  120. package/lib/factories/internal/protocols/emplace_protocol_object.js +0 -47
  121. package/lib/factories/internal/protocols/emplace_protocol_object.js.map +0 -1
  122. package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +0 -4
  123. package/lib/factories/internal/protocols/emplace_protocol_property.js +0 -20
  124. package/lib/factories/internal/protocols/emplace_protocol_property.js.map +0 -1
  125. package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +0 -3
  126. package/lib/factories/internal/protocols/iterate_protocol_atomic.js +0 -69
  127. package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +0 -1
  128. package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +0 -2
  129. package/lib/factories/internal/protocols/iterate_protocol_constant.js +0 -30
  130. package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +0 -1
  131. package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +0 -3
  132. package/lib/factories/internal/protocols/iterate_protocol_main.js +0 -17
  133. package/lib/factories/internal/protocols/iterate_protocol_main.js.map +0 -1
  134. package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +0 -4
  135. package/lib/factories/internal/protocols/iterate_protocol_map.js +0 -75
  136. package/lib/factories/internal/protocols/iterate_protocol_map.js.map +0 -1
  137. package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +0 -5
  138. package/lib/factories/internal/protocols/iterate_protocol_metadata.js +0 -190
  139. package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +0 -1
  140. package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +0 -2
  141. package/lib/factories/internal/protocols/iterate_protocol_native.js +0 -33
  142. package/lib/factories/internal/protocols/iterate_protocol_native.js.map +0 -1
  143. package/lib/factories/internal/protocols/iterate_protocol_never.d.ts +0 -1
  144. package/lib/factories/internal/protocols/iterate_protocol_never.js +0 -6
  145. package/lib/factories/internal/protocols/iterate_protocol_never.js.map +0 -1
  146. package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +0 -4
  147. package/lib/factories/internal/protocols/iterate_protocol_object.js +0 -157
  148. package/lib/factories/internal/protocols/iterate_protocol_object.js.map +0 -1
  149. package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +0 -5
  150. package/lib/factories/internal/protocols/iterate_protocol_repeated.js +0 -25
  151. package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +0 -1
  152. package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +0 -3
  153. package/lib/factories/internal/protocols/iterate_protocol_tuple.js +0 -46
  154. package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +0 -1
  155. package/lib/functional/$proto_bytes.d.ts +0 -2
  156. package/lib/functional/$proto_bytes.js +0 -37
  157. package/lib/functional/$proto_bytes.js.map +0 -1
  158. package/lib/functional/$proto_field.d.ts +0 -10
  159. package/lib/functional/$proto_field.js +0 -42
  160. package/lib/functional/$proto_field.js.map +0 -1
  161. package/lib/functional/$proto_float.d.ts +0 -4
  162. package/lib/functional/$proto_float.js +0 -28
  163. package/lib/functional/$proto_float.js.map +0 -1
  164. package/lib/functional/$proto_i32.d.ts +0 -2
  165. package/lib/functional/$proto_i32.js +0 -23
  166. package/lib/functional/$proto_i32.js.map +0 -1
  167. package/lib/functional/$proto_i64.d.ts +0 -2
  168. package/lib/functional/$proto_i64.js +0 -31
  169. package/lib/functional/$proto_i64.js.map +0 -1
  170. package/lib/functional/$proto_size.d.ts +0 -6
  171. package/lib/functional/$proto_size.js +0 -76
  172. package/lib/functional/$proto_size.js.map +0 -1
  173. package/lib/functional/$proto_string.d.ts +0 -2
  174. package/lib/functional/$proto_string.js +0 -34
  175. package/lib/functional/$proto_string.js.map +0 -1
  176. package/lib/functional/$varint.d.ts +0 -6
  177. package/lib/functional/$varint.js +0 -99
  178. package/lib/functional/$varint.js.map +0 -1
  179. package/lib/functional/$zigzag.d.ts +0 -4
  180. package/lib/functional/$zigzag.js +0 -34
  181. package/lib/functional/$zigzag.js.map +0 -1
  182. package/lib/messages/IProtocolMap.d.ts +0 -5
  183. package/lib/messages/IProtocolMap.js +0 -3
  184. package/lib/messages/IProtocolMap.js.map +0 -1
  185. package/lib/messages/IProtocolMessage.d.ts +0 -5
  186. package/lib/messages/IProtocolMessage.js +0 -3
  187. package/lib/messages/IProtocolMessage.js.map +0 -1
  188. package/lib/messages/IProtocolProperty.d.ts +0 -12
  189. package/lib/messages/IProtocolProperty.js +0 -3
  190. package/lib/messages/IProtocolProperty.js.map +0 -1
  191. package/lib/programmers/MessageProgrammer.d.ts +0 -5
  192. package/lib/programmers/MessageProgrammer.js +0 -141
  193. package/lib/programmers/MessageProgrammer.js.map +0 -1
  194. package/lib/transformers/features/protocols/MessageTransformer.d.ts +0 -5
  195. package/lib/transformers/features/protocols/MessageTransformer.js +0 -17
  196. package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
  197. package/lib/utils/NameEncoder.d.ts +0 -4
  198. package/lib/utils/NameEncoder.js +0 -89
  199. package/lib/utils/NameEncoder.js.map +0 -1
  200. package/src/factories/ProtocolFactory.ts +0 -79
  201. package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +0 -163
  202. package/src/factories/internal/protocols/emplace_protocol_object.ts +0 -25
  203. package/src/factories/internal/protocols/emplace_protocol_property.ts +0 -12
  204. package/src/factories/internal/protocols/iterate_protocol_atomic.ts +0 -34
  205. package/src/factories/internal/protocols/iterate_protocol_constant.ts +0 -27
  206. package/src/factories/internal/protocols/iterate_protocol_main.ts +0 -19
  207. package/src/factories/internal/protocols/iterate_protocol_map.ts +0 -58
  208. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +0 -96
  209. package/src/factories/internal/protocols/iterate_protocol_native.ts +0 -34
  210. package/src/factories/internal/protocols/iterate_protocol_never.ts +0 -1
  211. package/src/factories/internal/protocols/iterate_protocol_object.ts +0 -110
  212. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +0 -34
  213. package/src/factories/internal/protocols/iterate_protocol_tuple.ts +0 -29
  214. package/src/functional/$proto_bytes.ts +0 -25
  215. package/src/functional/$proto_field.ts +0 -30
  216. package/src/functional/$proto_float.ts +0 -37
  217. package/src/functional/$proto_i32.ts +0 -29
  218. package/src/functional/$proto_i64.ts +0 -37
  219. package/src/functional/$proto_size.ts +0 -82
  220. package/src/functional/$proto_string.ts +0 -24
  221. package/src/functional/$varint.ts +0 -130
  222. package/src/functional/$zigzag.ts +0 -39
  223. package/src/messages/IProtocolMap.ts +0 -5
  224. package/src/messages/IProtocolMessage.ts +0 -6
  225. package/src/messages/IProtocolProperty.ts +0 -13
  226. package/src/programmers/MessageProgrammer.ts +0 -126
  227. package/src/utils/NameEncoder.ts +0 -32
@@ -205,7 +205,6 @@ export class Metadata {
205
205
  public empty(): boolean {
206
206
  return this.bucket() === 0 || this.size() === 0;
207
207
  }
208
-
209
208
  public size(): number {
210
209
  return (
211
210
  (this.resolved ? 1 : 0) +
@@ -224,7 +223,6 @@ export class Metadata {
224
223
  this.maps.length
225
224
  );
226
225
  }
227
-
228
226
  public bucket(): number {
229
227
  return (
230
228
  (this.resolved ? 1 : 0) +
@@ -241,7 +239,6 @@ export class Metadata {
241
239
  (this.maps.length ? 1 : 0)
242
240
  );
243
241
  }
244
-
245
242
  public isConstant(): boolean {
246
243
  return this.bucket() === (this.constants.length ? 1 : 0);
247
244
  }
@@ -511,15 +508,15 @@ function getName(metadata: Metadata): string {
511
508
  elements.push(`Map<${map.key.getName()}, ${map.value.getName()}>`);
512
509
 
513
510
  // ARRAY
514
- if (metadata.rest !== null)
515
- elements.push(`Rest<${metadata.rest.getName()}>`);
511
+ if (metadata.rest !== null) elements.push(`...${metadata.rest.getName()}`);
516
512
  for (const tuple of metadata.tuples)
517
513
  elements.push(`[${tuple.map((elem) => elem.getName()).join(", ")}]`);
518
514
  for (const array of metadata.arrays)
519
515
  elements.push(`Array<${array.getName()}>`);
520
516
 
521
517
  // OBJECT
522
- for (const object of metadata.objects) elements.push(object.name);
518
+ for (const object of metadata.objects)
519
+ elements.push(`Resolve<${object.name}>`);
523
520
  if (metadata.resolved !== null) elements.push(metadata.resolved.getName());
524
521
 
525
522
  // RETURNS
package/src/module.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { $every } from "./functional/$every";
2
2
  import { $guard } from "./functional/$guard";
3
+ import { $is_between } from "./functional/$is_between";
3
4
  import { $is_email } from "./functional/$is_email";
4
5
  import { $is_ipv4 } from "./functional/$is_ipv4";
5
6
  import { $is_ipv6 } from "./functional/$is_ipv6";
@@ -29,9 +30,8 @@ export * from "./IValidation";
29
30
  SINGLE FUNCTIONS
30
31
  - BASIC VALIDATORS
31
32
  - STRICT VALIDATORS
32
- - PROTOCOL BUFFER FUNCTIONS
33
33
  - JSON FUNCTIONS
34
- - MISC
34
+ - MISCELLANEOUS
35
35
  ==============================================================
36
36
  BASIC VALIDATORS
37
37
  ----------------------------------------------------------- */
@@ -97,6 +97,7 @@ export namespace assert {
97
97
  export const is_url = $is_url;
98
98
  export const is_ipv4 = $is_ipv4;
99
99
  export const is_ipv6 = $is_ipv6;
100
+ export const is_between = $is_between;
100
101
 
101
102
  export const join = $join;
102
103
  export const every = $every;
@@ -224,6 +225,7 @@ export namespace is {
224
225
  export const is_url = $is_url;
225
226
  export const is_ipv4 = $is_ipv4;
226
227
  export const is_ipv6 = $is_ipv6;
228
+ export const is_between = $is_between;
227
229
  }
228
230
 
229
231
  /**
@@ -292,6 +294,7 @@ export namespace validate {
292
294
  export const is_url = $is_url;
293
295
  export const is_ipv4 = $is_ipv4;
294
296
  export const is_ipv6 = $is_ipv6;
297
+ export const is_between = $is_between;
295
298
 
296
299
  export const join = $join;
297
300
  export const report = $report;
@@ -396,6 +399,7 @@ export namespace assertEquals {
396
399
  export const is_url = $is_url;
397
400
  export const is_ipv4 = $is_ipv4;
398
401
  export const is_ipv6 = $is_ipv6;
402
+ export const is_between = $is_between;
399
403
 
400
404
  export const join = $join;
401
405
  export const every = $every;
@@ -483,6 +487,7 @@ export namespace equals {
483
487
  export const is_url = $is_url;
484
488
  export const is_ipv4 = $is_ipv4;
485
489
  export const is_ipv6 = $is_ipv6;
490
+ export const is_between = $is_between;
486
491
  export const join = $join;
487
492
  }
488
493
 
@@ -554,6 +559,7 @@ export namespace validateEquals {
554
559
  export const is_url = $is_url;
555
560
  export const is_ipv4 = $is_ipv4;
556
561
  export const is_ipv6 = $is_ipv6;
562
+ export const is_between = $is_between;
557
563
  export const join = $join;
558
564
 
559
565
  export const report = validate.report;
@@ -589,16 +595,6 @@ export namespace validateEquals {
589
595
  };
590
596
  }
591
597
 
592
- /* -----------------------------------------------------------
593
- PROTOCOL BUFFER FUNCTIONS
594
- ----------------------------------------------------------- */
595
- export function message(): never;
596
- export function message<T>(): string;
597
-
598
- export function message(): string {
599
- halt("message");
600
- }
601
-
602
598
  /* -----------------------------------------------------------
603
599
  JSON FUNCTIONS
604
600
  ----------------------------------------------------------- */
@@ -721,6 +717,7 @@ export namespace assertParse {
721
717
  export const is_url = $is_url;
722
718
  export const is_ipv4 = $is_ipv4;
723
719
  export const is_ipv6 = $is_ipv6;
720
+ export const is_between = $is_between;
724
721
 
725
722
  export const join = $join;
726
723
  export const every = $every;
@@ -937,6 +934,7 @@ export namespace assertStringify {
937
934
  export const is_url = $is_url;
938
935
  export const is_ipv4 = $is_ipv4;
939
936
  export const is_ipv6 = $is_ipv6;
937
+ export const is_between = $is_between;
940
938
 
941
939
  export const number = $number;
942
940
  export const string = $string;
@@ -1025,6 +1023,7 @@ export namespace isStringify {
1025
1023
  export const is_url = $is_url;
1026
1024
  export const is_ipv4 = $is_ipv4;
1027
1025
  export const is_ipv6 = $is_ipv6;
1026
+ export const is_between = $is_between;
1028
1027
 
1029
1028
  export const number = $number;
1030
1029
  export const string = $string;
@@ -1091,6 +1090,64 @@ export function validateStringify(): IValidation<string> {
1091
1090
  Object.assign(validateStringify, validate);
1092
1091
  Object.assign(validateStringify, stringify);
1093
1092
 
1093
+ /* -----------------------------------------------------------
1094
+ MISCELLANEOUS
1095
+ ----------------------------------------------------------- */
1096
+ /**
1097
+ * @internal
1098
+ */
1099
+ export function metadata<Types extends unknown[]>(): IMetadataApplication;
1100
+
1101
+ /**
1102
+ * @internal
1103
+ */
1104
+ export function metadata(): never {
1105
+ halt("metadata");
1106
+ }
1107
+
1108
+ /**
1109
+ * Prune, erase superfluous properties.
1110
+ *
1111
+ * Remove every superfluous properties from the `input` object, even including nested
1112
+ * objects. Note that, as every superfluous properties would be deleted, you never can
1113
+ * read those superfluous properties after calling this `prune()` function.
1114
+ *
1115
+ * @template T Type of the input value
1116
+ * @param input target instance to prune
1117
+ *
1118
+ * @author Jeongho Nam - https://github.com/samchon
1119
+ */
1120
+ export function prune<T extends object>(input: T): void;
1121
+
1122
+ /**
1123
+ * @internal
1124
+ */
1125
+ export function prune(): never {
1126
+ halt("prune");
1127
+ }
1128
+
1129
+ /**
1130
+ * @internal
1131
+ */
1132
+ export namespace prune {
1133
+ export const is_uuid = $is_uuid;
1134
+ export const is_email = $is_email;
1135
+ export const is_url = $is_url;
1136
+ export const is_ipv4 = $is_ipv4;
1137
+ export const is_ipv6 = $is_ipv6;
1138
+ export const is_between = $is_between;
1139
+
1140
+ export const rest = $rest;
1141
+ export function throws(
1142
+ props: Pick<TypeGuardError.IProps, "expected" | "value">,
1143
+ ): void {
1144
+ throw new TypeGuardError({
1145
+ ...props,
1146
+ method: "typia.prune",
1147
+ });
1148
+ }
1149
+ }
1150
+
1094
1151
  /* ===========================================================
1095
1152
  FACTORY FUNCTIONS
1096
1153
  - BASIC VALIDATORS
@@ -1505,7 +1562,7 @@ export function createValidateStringify(): never;
1505
1562
  *
1506
1563
  * @template T Type of the input value
1507
1564
  * @returns A reusable `validateStringify` function
1508
- *
1565
+
1509
1566
  * @author Jeongho Nam - https://github.com/samchon
1510
1567
  */
1511
1568
  export function createValidateStringify<T>(): (
@@ -1526,16 +1583,33 @@ Object.assign(createValidateStringify, validateStringify);
1526
1583
  MISCELLANEOUS
1527
1584
  ----------------------------------------------------------- */
1528
1585
  /**
1529
- * @internal
1586
+ * Creates a reusable {@link prune} function.
1587
+ *
1588
+ * @danger You have to specify the generic argument `T`
1589
+ * @return Nothing until specifying the generic argument `T`
1590
+ * @throws compile error
1591
+ *
1592
+ * @author Jeongho Nam - https://github.com/samchon
1530
1593
  */
1531
- export function metadata<Types extends unknown[]>(): IMetadataApplication;
1594
+ export function createPrune(): never;
1595
+
1596
+ /**
1597
+ * Creates a resuable {@link prune} function.
1598
+ *
1599
+ * @template T Type of the input value
1600
+ * @returns A reusable `prune` function
1601
+ *
1602
+ * @author Jeongho Nam - https://github.com/samchon
1603
+ */
1604
+ export function createPrune<T extends object>(): (input: T) => void;
1532
1605
 
1533
1606
  /**
1534
1607
  * @internal
1535
1608
  */
1536
- export function metadata(): never {
1537
- halt("metadata");
1609
+ export function createPrune<T extends object>(): (input: T) => void {
1610
+ halt("createPrune");
1538
1611
  }
1612
+ Object.assign(createPrune, prune);
1539
1613
 
1540
1614
  /**
1541
1615
  * @internal
@@ -284,7 +284,7 @@ export namespace AssertProgrammer {
284
284
  return IsProgrammer.CONFIG({
285
285
  object: assert_object(equals)(importer),
286
286
  numeric: true,
287
- }).combiner(explore);
287
+ })(importer).combiner(explore);
288
288
 
289
289
  const path: string = explore.postfix
290
290
  ? `path + ${explore.postfix}`
@@ -354,6 +354,7 @@ export namespace AssertProgrammer {
354
354
  check_object({
355
355
  equals,
356
356
  assert: true,
357
+ undefined: true,
357
358
  reduce: ts.factory.createLogicalAnd,
358
359
  positive: ts.factory.createTrue(),
359
360
  superfluous: (value) =>
@@ -377,7 +378,7 @@ export namespace AssertProgrammer {
377
378
  ),
378
379
  expr,
379
380
  ),
380
- });
381
+ })(importer);
381
382
 
382
383
  const joiner =
383
384
  (equals: boolean) =>
@@ -13,6 +13,7 @@ import { MetadataObject } from "../metadata/MetadataObject";
13
13
  import { IProject } from "../transformers/IProject";
14
14
 
15
15
  import { FeatureProgrammer } from "./FeatureProgrammer";
16
+ import { AtomicPredicator } from "./helpers/AtomicPredicator";
16
17
  import { FunctionImporter } from "./helpers/FunctionImporeter";
17
18
  import { IExpressionEntry } from "./helpers/IExpressionEntry";
18
19
  import { OptionPredicator } from "./helpers/OptionPredicator";
@@ -36,7 +37,7 @@ export namespace CheckerProgrammer {
36
37
  equals: boolean;
37
38
  numeric: boolean;
38
39
  combiner: IConfig.Combiner;
39
- decoder?: FeatureProgrammer.Decoder<Metadata>;
40
+ decoder?: FeatureProgrammer.Decoder<Metadata, ts.Expression>;
40
41
  joiner: IConfig.IJoiner;
41
42
  success: ts.Expression;
42
43
  }
@@ -53,7 +54,10 @@ export namespace CheckerProgrammer {
53
54
  };
54
55
  }
55
56
  export interface IJoiner {
56
- object(entries: IExpressionEntry[]): ts.Expression;
57
+ object(
58
+ input: ts.Expression,
59
+ entries: IExpressionEntry[],
60
+ ): ts.Expression;
57
61
  array(input: ts.Expression, arrow: ts.ArrowFunction): ts.Expression;
58
62
  tuple?(exprs: ts.Expression[]): ts.Expression;
59
63
 
@@ -246,6 +250,7 @@ export namespace CheckerProgrammer {
246
250
  //----
247
251
  // CHECK OPTIONAL
248
252
  //----
253
+ // @todo -> should be elaborated
249
254
  const checkOptional: boolean = meta.empty() || meta.isUnionBucket();
250
255
 
251
256
  // NULLABLE
@@ -288,12 +293,14 @@ export namespace CheckerProgrammer {
288
293
  //----
289
294
  // CONSTANT VALUES
290
295
  for (const constant of meta.constants)
291
- for (const val of constant.values)
292
- add(true, getConstantValue(val));
296
+ if (AtomicPredicator.constant(meta)(constant.type))
297
+ for (const val of constant.values)
298
+ add(true, getConstantValue(val));
293
299
 
294
300
  // ATOMIC VALUES
295
301
  for (const type of meta.atomics)
296
- if (type === "number")
302
+ if (AtomicPredicator.atomic(meta)(type) === false) continue;
303
+ else if (type === "number")
297
304
  binaries.push({
298
305
  expression: check_number(project, config.numeric)(
299
306
  input,
@@ -320,14 +327,15 @@ export namespace CheckerProgrammer {
320
327
 
321
328
  // TEMPLATE LITERAL VALUES
322
329
  if (meta.templates.length)
323
- binaries.push({
324
- expression: check_template(importer)(
325
- input,
326
- meta.templates,
327
- tags,
328
- ),
329
- combined: false,
330
- });
330
+ if (AtomicPredicator.template(meta))
331
+ binaries.push({
332
+ expression: check_template(importer)(
333
+ input,
334
+ meta.templates,
335
+ tags,
336
+ ),
337
+ combined: false,
338
+ });
331
339
 
332
340
  // NATIVE CLASSES
333
341
  for (const native of meta.natives)
@@ -21,29 +21,135 @@ export namespace FeatureProgrammer {
21
21
  /* -----------------------------------------------------------
22
22
  PARAMETERS
23
23
  ----------------------------------------------------------- */
24
- export interface IConfig {
24
+ export interface IConfig<Output extends ts.ConciseBody = ts.ConciseBody> {
25
+ /**
26
+ * Prefix name of functions for specific object types.
27
+ */
25
28
  functors: string;
29
+
30
+ /**
31
+ * Prefix name of functions for union object types.
32
+ */
26
33
  unioners: string;
34
+
35
+ /**
36
+ * Whether to archive access path or not.
37
+ */
27
38
  path: boolean;
39
+
40
+ /**
41
+ * Whether to trace exception or not.
42
+ */
28
43
  trace: boolean;
29
- initializer: Initializer;
30
- decoder: Decoder<Metadata>;
44
+
45
+ /**
46
+ * Initializer of metadata.
47
+ */
48
+ initializer(
49
+ project: IProject,
50
+ type: ts.Type,
51
+ ): [MetadataCollection, Metadata];
52
+
53
+ /**
54
+ * Decoder, station of every types.
55
+ */
56
+ decoder: Decoder<Metadata, Output>;
57
+
58
+ /**
59
+ * Object configurator.
60
+ */
31
61
  objector: IConfig.IObjector;
62
+
63
+ /**
64
+ * Generator of functions for object types.
65
+ */
32
66
  generator?: Partial<IConfig.IGenerator>;
33
67
  }
34
68
  export namespace IConfig {
35
69
  export interface IObjector {
36
- checker: Decoder<Metadata>;
37
- decoder: Decoder<MetadataObject>;
38
- joiner: ObjectJoiner;
39
- unionizer: Decoder<MetadataObject[]>;
40
- failure: (
70
+ /**
71
+ * Type checker when union object type comes.
72
+ */
73
+ checker: Decoder<Metadata, ts.Expression>;
74
+
75
+ /**
76
+ * Decoder, function call expression generator of specific typed objects.
77
+ */
78
+ decoder: Decoder<MetadataObject, ts.Expression>;
79
+
80
+ /**
81
+ * Joiner of expressions from properties.
82
+ */
83
+ joiner(
84
+ input: ts.Expression,
85
+ entries: IExpressionEntry[],
86
+ parent: MetadataObject,
87
+ ): ts.ConciseBody;
88
+
89
+ /**
90
+ * Union type specificator.
91
+ *
92
+ * Expression of an algorithm specifying object type and calling
93
+ * the `decoder` function of the specified object type.
94
+ */
95
+ unionizer: Decoder<MetadataObject[], ts.Expression>;
96
+
97
+ /**
98
+ * Handler of union type specification failure.
99
+ *
100
+ * @param value Expression of input parameter
101
+ * @param expected Expected type name
102
+ * @param explore Exploration info
103
+ * @returns Statement of failure
104
+ */
105
+ failure(
41
106
  value: ts.Expression,
42
107
  expected: string,
43
108
  explore?: IExplore,
44
- ) => ts.Statement;
45
- is?: (exp: ts.Expression) => ts.Expression;
46
- required?: (exp: ts.Expression) => ts.Expression;
109
+ ): ts.Statement;
110
+
111
+ /**
112
+ * Transformer of type checking expression by discrimination.
113
+ *
114
+ * When an object type has been specified by a discrimination without full
115
+ * iteration, the `unionizer` will decode the object instance after
116
+ * the last type checking.
117
+ *
118
+ * In such circumtance, you can transform the last type checking function.
119
+ *
120
+ * @param exp Current expression about type checking
121
+ * @returns Transformed expression
122
+ * @deprecated
123
+ */
124
+ is?(exp: ts.Expression): ts.Expression;
125
+
126
+ /**
127
+ * Transformer of non-undefined type checking by discrimination.
128
+ *
129
+ * When specifying an union type of objects, `typia` tries to find
130
+ * descrimination way just by checking only one property type.
131
+ * If succeeded to find the discrimination way, `typia` will check the target
132
+ * property type and in the checking, non-undefined type checking would be
133
+ * done.
134
+ *
135
+ * In such process, you can transform the non-undefined type checking.
136
+ *
137
+ * @param exp
138
+ * @returns Transformed expression
139
+ * @deprecated
140
+ */
141
+ required?(exp: ts.Expression): ts.Expression;
142
+
143
+ /**
144
+ * Conditon wrapper when unable to specify any object type.
145
+ *
146
+ * When failed to specify an object type through discrimination, full
147
+ * iteration type checking would be happend. In such circumstance, you
148
+ * can wrap the condition with additional function.
149
+ *
150
+ * @param condition Current condition
151
+ * @returns A function wrapped current condition
152
+ */
47
153
  full?: (
48
154
  condition: ts.Expression,
49
155
  ) => (
@@ -53,10 +159,20 @@ export namespace FeatureProgrammer {
53
159
  ) => ts.Expression;
54
160
  }
55
161
  export interface IGenerator {
162
+ /**
163
+ *
164
+ * @param col
165
+ */
56
166
  functors(col: MetadataCollection): ts.VariableStatement[];
167
+
168
+ /**
169
+ *
170
+ * @param col
171
+ */
57
172
  unioners(col: MetadataCollection): ts.VariableStatement[];
58
173
  }
59
174
  }
175
+
60
176
  export interface IExplore {
61
177
  tracable: boolean;
62
178
  source: "top" | "object";
@@ -65,24 +181,30 @@ export namespace FeatureProgrammer {
65
181
  start?: number;
66
182
  }
67
183
 
68
- export interface Initializer {
69
- (project: IProject, type: ts.Type): [MetadataCollection, Metadata];
70
- }
71
- export interface Decoder<T> {
184
+ export interface Decoder<
185
+ T,
186
+ Output extends ts.ConciseBody = ts.ConciseBody,
187
+ > {
72
188
  (
73
189
  input: ts.Expression,
74
190
  target: T,
75
191
  explore: IExplore,
76
192
  tags: IMetadataTag[],
77
- ): ts.Expression;
78
- }
79
- export interface ObjectJoiner {
80
- (entries: IExpressionEntry[], parent: MetadataObject): ts.ConciseBody;
193
+ ): Output;
81
194
  }
82
195
 
83
196
  /* -----------------------------------------------------------
84
197
  GENERATORS
85
198
  ----------------------------------------------------------- */
199
+ /**
200
+ * Generates a decoder function for a specific type.
201
+ *
202
+ * @param project Project configuration
203
+ * @param config Detailed configuration for programming
204
+ * @param importer Function importer
205
+ * @param addition Generator of additinal statements in the top of function
206
+ * @returns Currying function generating type decoder function
207
+ */
86
208
  export const generate =
87
209
  (
88
210
  project: IProject,
@@ -96,7 +218,7 @@ export namespace FeatureProgrammer {
96
218
  const [collection, meta] = config.initializer(project, type);
97
219
 
98
220
  // ITERATE OVER ALL METADATA
99
- const output: ts.Expression = config.decoder(
221
+ const output: ts.ConciseBody = config.decoder(
100
222
  ValueFactory.INPUT(),
101
223
  meta,
102
224
  {
@@ -130,7 +252,9 @@ export namespace FeatureProgrammer {
130
252
  ...(added || []),
131
253
  ...functors,
132
254
  ...unioners,
133
- ts.factory.createReturnStatement(output),
255
+ ...(ts.isBlock(output)
256
+ ? output.statements
257
+ : [ts.factory.createReturnStatement(output)]),
134
258
  ],
135
259
  true,
136
260
  ),
@@ -170,6 +294,7 @@ export namespace FeatureProgrammer {
170
294
  undefined,
171
295
  undefined,
172
296
  config.objector.joiner(
297
+ ts.factory.createIdentifier("input"),
173
298
  feature_object_entries(config)(obj)(
174
299
  ts.factory.createIdentifier("input"),
175
300
  ),