typia 3.7.0-dev.20230310 → 3.7.0-dev.20230401

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 (267) hide show
  1. package/README.md +16 -45
  2. package/lib/IRandomGenerator.d.ts +2 -1
  3. package/lib/executable/TypiaSetupWizard.js +12 -2
  4. package/lib/executable/TypiaSetupWizard.js.map +1 -1
  5. package/lib/factories/MetadataCollection.d.ts +9 -1
  6. package/lib/factories/MetadataCollection.js +75 -2
  7. package/lib/factories/MetadataCollection.js.map +1 -1
  8. package/lib/factories/MetadataTagFactory.js +151 -132
  9. package/lib/factories/MetadataTagFactory.js.map +1 -1
  10. package/lib/factories/TypeFactory.js +1 -1
  11. package/lib/factories/TypeFactory.js.map +1 -1
  12. package/lib/factories/TypiaFileFactory.js +61 -54
  13. package/lib/factories/TypiaFileFactory.js.map +1 -1
  14. package/lib/functional/$dictionary.d.ts +1 -0
  15. package/lib/functional/$dictionary.js +14 -0
  16. package/lib/functional/$dictionary.js.map +1 -0
  17. package/lib/functional/$is_custom.d.ts +2 -0
  18. package/lib/functional/$is_custom.js +12 -0
  19. package/lib/functional/$is_custom.js.map +1 -0
  20. package/lib/functional/$is_date.d.ts +1 -0
  21. package/lib/functional/$is_date.js +9 -0
  22. package/lib/functional/$is_date.js.map +1 -0
  23. package/lib/functional/$is_datetime.d.ts +1 -0
  24. package/lib/functional/$is_datetime.js +8 -0
  25. package/lib/functional/$is_datetime.js.map +1 -0
  26. package/lib/functional/Namespace.js +6 -0
  27. package/lib/functional/Namespace.js.map +1 -1
  28. package/lib/metadata/IMetadataTag.d.ts +30 -38
  29. package/lib/metadata/Metadata.js +2 -2
  30. package/lib/metadata/Metadata.js.map +1 -1
  31. package/lib/module.d.ts +25 -2
  32. package/lib/module.js +12 -5
  33. package/lib/module.js.map +1 -1
  34. package/lib/programmers/AssertProgrammer.js +11 -0
  35. package/lib/programmers/AssertProgrammer.js.map +1 -1
  36. package/lib/programmers/CheckerProgrammer.d.ts +4 -2
  37. package/lib/programmers/CheckerProgrammer.js +26 -27
  38. package/lib/programmers/CheckerProgrammer.js.map +1 -1
  39. package/lib/programmers/CloneProgrammer.js +2 -2
  40. package/lib/programmers/CloneProgrammer.js.map +1 -1
  41. package/lib/programmers/FeatureProgrammer.d.ts +3 -2
  42. package/lib/programmers/FeatureProgrammer.js +5 -5
  43. package/lib/programmers/FeatureProgrammer.js.map +1 -1
  44. package/lib/programmers/IsProgrammer.d.ts +1 -1
  45. package/lib/programmers/IsProgrammer.js +32 -2
  46. package/lib/programmers/IsProgrammer.js.map +1 -1
  47. package/lib/programmers/PruneProgrammer.js +2 -2
  48. package/lib/programmers/PruneProgrammer.js.map +1 -1
  49. package/lib/programmers/RandomProgrammer.js +1 -2
  50. package/lib/programmers/RandomProgrammer.js.map +1 -1
  51. package/lib/programmers/StringifyProgrammer.js +6 -6
  52. package/lib/programmers/StringifyProgrammer.js.map +1 -1
  53. package/lib/programmers/ValidateProgrammer.js +11 -0
  54. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  55. package/lib/programmers/helpers/ICheckEntry.d.ts +11 -0
  56. package/lib/{messages/IProtocolMap.js → programmers/helpers/ICheckEntry.js} +1 -1
  57. package/lib/programmers/helpers/ICheckEntry.js.map +1 -0
  58. package/lib/programmers/helpers/UnionExplorer.d.ts +7 -7
  59. package/lib/programmers/helpers/UnionExplorer.js +6 -6
  60. package/lib/programmers/helpers/UnionExplorer.js.map +1 -1
  61. package/lib/programmers/internal/application_object.js +11 -11
  62. package/lib/programmers/internal/application_object.js.map +1 -1
  63. package/lib/programmers/internal/application_schema.js +3 -5
  64. package/lib/programmers/internal/application_schema.js.map +1 -1
  65. package/lib/programmers/internal/application_string.js +8 -5
  66. package/lib/programmers/internal/application_string.js.map +1 -1
  67. package/lib/programmers/internal/check_array.js +35 -10
  68. package/lib/programmers/internal/check_array.js.map +1 -1
  69. package/lib/programmers/internal/check_array_length.js +23 -36
  70. package/lib/programmers/internal/check_array_length.js.map +1 -1
  71. package/lib/programmers/internal/check_bigint.d.ts +1 -3
  72. package/lib/programmers/internal/check_bigint.js +92 -57
  73. package/lib/programmers/internal/check_bigint.js.map +1 -1
  74. package/lib/programmers/internal/check_custom.d.ts +5 -0
  75. package/lib/programmers/internal/check_custom.js +40 -0
  76. package/lib/programmers/internal/check_custom.js.map +1 -0
  77. package/lib/programmers/internal/check_number.js +126 -73
  78. package/lib/programmers/internal/check_number.js.map +1 -1
  79. package/lib/programmers/internal/check_string.js +10 -9
  80. package/lib/programmers/internal/check_string.js.map +1 -1
  81. package/lib/programmers/internal/check_string_tags.js +63 -24
  82. package/lib/programmers/internal/check_string_tags.js.map +1 -1
  83. package/lib/programmers/internal/check_template.js +23 -11
  84. package/lib/programmers/internal/check_template.js.map +1 -1
  85. package/lib/programmers/internal/check_union_array_like.d.ts +2 -2
  86. package/lib/programmers/internal/check_union_array_like.js +4 -4
  87. package/lib/programmers/internal/check_union_array_like.js.map +1 -1
  88. package/lib/programmers/internal/check_union_tuple.js +2 -2
  89. package/lib/programmers/internal/check_union_tuple.js.map +1 -1
  90. package/lib/programmers/internal/feature_object_entries.js +1 -1
  91. package/lib/programmers/internal/feature_object_entries.js.map +1 -1
  92. package/lib/transformers/CallExpressionTransformer.js +1 -3
  93. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  94. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js +3 -1
  95. package/lib/transformers/features/miscellaneous/ApplicationTransformer.js.map +1 -1
  96. package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js +1 -1
  97. package/lib/transformers/features/miscellaneous/CreateRandomGenerator.js.map +1 -1
  98. package/lib/transformers/features/miscellaneous/RandomTransformer.js +1 -1
  99. package/lib/transformers/features/miscellaneous/RandomTransformer.js.map +1 -1
  100. package/lib/transformers/internal/GenericTransformer.js +2 -2
  101. package/lib/transformers/internal/GenericTransformer.js.map +1 -1
  102. package/lib/typings/Customizable.d.ts +6 -0
  103. package/lib/{messages/IProtocolMessage.js → typings/Customizable.js} +1 -1
  104. package/lib/typings/Customizable.js.map +1 -0
  105. package/lib/utils/RandomGenerator.js +8 -2
  106. package/lib/utils/RandomGenerator.js.map +1 -1
  107. package/package.json +10 -9
  108. package/src/IRandomGenerator.ts +2 -1
  109. package/src/executable/TypiaSetupWizard.ts +16 -6
  110. package/src/factories/MetadataCollection.ts +41 -2
  111. package/src/factories/MetadataTagFactory.ts +186 -149
  112. package/src/factories/TypeFactory.ts +1 -1
  113. package/src/factories/TypiaFileFactory.ts +10 -7
  114. package/src/functional/$dictionary.ts +17 -0
  115. package/src/functional/$is_custom.ts +14 -0
  116. package/src/functional/$is_date.ts +4 -0
  117. package/src/functional/$is_datetime.ts +3 -0
  118. package/src/functional/Namespace.ts +6 -0
  119. package/src/metadata/IMetadataTag.ts +46 -70
  120. package/src/metadata/Metadata.ts +3 -6
  121. package/src/module.ts +39 -10
  122. package/src/programmers/AssertProgrammer.ts +24 -0
  123. package/src/programmers/CheckerProgrammer.ts +66 -37
  124. package/src/programmers/CloneProgrammer.ts +2 -0
  125. package/src/programmers/FeatureProgrammer.ts +12 -5
  126. package/src/programmers/IsProgrammer.ts +7 -1
  127. package/src/programmers/PruneProgrammer.ts +2 -0
  128. package/src/programmers/RandomProgrammer.ts +1 -4
  129. package/src/programmers/StringifyProgrammer.ts +6 -0
  130. package/src/programmers/ValidateProgrammer.ts +24 -0
  131. package/src/programmers/helpers/ICheckEntry.ts +12 -0
  132. package/src/programmers/helpers/UnionExplorer.ts +7 -0
  133. package/src/programmers/internal/application_object.ts +5 -5
  134. package/src/programmers/internal/application_schema.ts +3 -7
  135. package/src/programmers/internal/application_string.ts +6 -2
  136. package/src/programmers/internal/check_array.ts +15 -11
  137. package/src/programmers/internal/check_array_length.ts +31 -35
  138. package/src/programmers/internal/check_bigint.ts +76 -58
  139. package/src/programmers/internal/check_custom.ts +41 -0
  140. package/src/programmers/internal/check_number.ts +106 -77
  141. package/src/programmers/internal/check_string.ts +15 -14
  142. package/src/programmers/internal/check_string_tags.ts +23 -13
  143. package/src/programmers/internal/check_template.ts +16 -7
  144. package/src/programmers/internal/check_union_array_like.ts +5 -0
  145. package/src/programmers/internal/check_union_tuple.ts +2 -0
  146. package/src/programmers/internal/feature_object_entries.ts +1 -0
  147. package/src/transformers/CallExpressionTransformer.ts +9 -16
  148. package/src/transformers/features/miscellaneous/ApplicationTransformer.ts +3 -1
  149. package/src/transformers/features/miscellaneous/CreateRandomGenerator.ts +1 -1
  150. package/src/transformers/features/miscellaneous/RandomTransformer.ts +1 -1
  151. package/src/transformers/internal/GenericTransformer.ts +2 -2
  152. package/src/typings/Customizable.ts +6 -0
  153. package/src/utils/RandomGenerator.ts +8 -2
  154. package/lib/factories/ProtocolFactory.d.ts +0 -8
  155. package/lib/factories/ProtocolFactory.js +0 -112
  156. package/lib/factories/ProtocolFactory.js.map +0 -1
  157. package/lib/factories/internal/protocols/ProtocolMetadataUtil.d.ts +0 -16
  158. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js +0 -156
  159. package/lib/factories/internal/protocols/ProtocolMetadataUtil.js.map +0 -1
  160. package/lib/factories/internal/protocols/emplace_protocol_object.d.ts +0 -3
  161. package/lib/factories/internal/protocols/emplace_protocol_object.js +0 -47
  162. package/lib/factories/internal/protocols/emplace_protocol_object.js.map +0 -1
  163. package/lib/factories/internal/protocols/emplace_protocol_property.d.ts +0 -4
  164. package/lib/factories/internal/protocols/emplace_protocol_property.js +0 -20
  165. package/lib/factories/internal/protocols/emplace_protocol_property.js.map +0 -1
  166. package/lib/factories/internal/protocols/iterate_protocol_atomic.d.ts +0 -3
  167. package/lib/factories/internal/protocols/iterate_protocol_atomic.js +0 -69
  168. package/lib/factories/internal/protocols/iterate_protocol_atomic.js.map +0 -1
  169. package/lib/factories/internal/protocols/iterate_protocol_constant.d.ts +0 -2
  170. package/lib/factories/internal/protocols/iterate_protocol_constant.js +0 -30
  171. package/lib/factories/internal/protocols/iterate_protocol_constant.js.map +0 -1
  172. package/lib/factories/internal/protocols/iterate_protocol_main.d.ts +0 -3
  173. package/lib/factories/internal/protocols/iterate_protocol_main.js +0 -17
  174. package/lib/factories/internal/protocols/iterate_protocol_main.js.map +0 -1
  175. package/lib/factories/internal/protocols/iterate_protocol_map.d.ts +0 -4
  176. package/lib/factories/internal/protocols/iterate_protocol_map.js +0 -75
  177. package/lib/factories/internal/protocols/iterate_protocol_map.js.map +0 -1
  178. package/lib/factories/internal/protocols/iterate_protocol_metadata.d.ts +0 -5
  179. package/lib/factories/internal/protocols/iterate_protocol_metadata.js +0 -190
  180. package/lib/factories/internal/protocols/iterate_protocol_metadata.js.map +0 -1
  181. package/lib/factories/internal/protocols/iterate_protocol_native.d.ts +0 -2
  182. package/lib/factories/internal/protocols/iterate_protocol_native.js +0 -33
  183. package/lib/factories/internal/protocols/iterate_protocol_native.js.map +0 -1
  184. package/lib/factories/internal/protocols/iterate_protocol_never.d.ts +0 -1
  185. package/lib/factories/internal/protocols/iterate_protocol_never.js +0 -6
  186. package/lib/factories/internal/protocols/iterate_protocol_never.js.map +0 -1
  187. package/lib/factories/internal/protocols/iterate_protocol_object.d.ts +0 -4
  188. package/lib/factories/internal/protocols/iterate_protocol_object.js +0 -157
  189. package/lib/factories/internal/protocols/iterate_protocol_object.js.map +0 -1
  190. package/lib/factories/internal/protocols/iterate_protocol_repeated.d.ts +0 -5
  191. package/lib/factories/internal/protocols/iterate_protocol_repeated.js +0 -25
  192. package/lib/factories/internal/protocols/iterate_protocol_repeated.js.map +0 -1
  193. package/lib/factories/internal/protocols/iterate_protocol_tuple.d.ts +0 -3
  194. package/lib/factories/internal/protocols/iterate_protocol_tuple.js +0 -46
  195. package/lib/factories/internal/protocols/iterate_protocol_tuple.js.map +0 -1
  196. package/lib/functional/$proto_bytes.d.ts +0 -2
  197. package/lib/functional/$proto_bytes.js +0 -37
  198. package/lib/functional/$proto_bytes.js.map +0 -1
  199. package/lib/functional/$proto_field.d.ts +0 -10
  200. package/lib/functional/$proto_field.js +0 -42
  201. package/lib/functional/$proto_field.js.map +0 -1
  202. package/lib/functional/$proto_float.d.ts +0 -4
  203. package/lib/functional/$proto_float.js +0 -28
  204. package/lib/functional/$proto_float.js.map +0 -1
  205. package/lib/functional/$proto_i32.d.ts +0 -2
  206. package/lib/functional/$proto_i32.js +0 -23
  207. package/lib/functional/$proto_i32.js.map +0 -1
  208. package/lib/functional/$proto_i64.d.ts +0 -2
  209. package/lib/functional/$proto_i64.js +0 -31
  210. package/lib/functional/$proto_i64.js.map +0 -1
  211. package/lib/functional/$proto_size.d.ts +0 -6
  212. package/lib/functional/$proto_size.js +0 -76
  213. package/lib/functional/$proto_size.js.map +0 -1
  214. package/lib/functional/$proto_string.d.ts +0 -2
  215. package/lib/functional/$proto_string.js +0 -34
  216. package/lib/functional/$proto_string.js.map +0 -1
  217. package/lib/functional/$varint.d.ts +0 -6
  218. package/lib/functional/$varint.js +0 -99
  219. package/lib/functional/$varint.js.map +0 -1
  220. package/lib/functional/$zigzag.d.ts +0 -4
  221. package/lib/functional/$zigzag.js +0 -34
  222. package/lib/functional/$zigzag.js.map +0 -1
  223. package/lib/messages/IProtocolMap.d.ts +0 -5
  224. package/lib/messages/IProtocolMap.js.map +0 -1
  225. package/lib/messages/IProtocolMessage.d.ts +0 -5
  226. package/lib/messages/IProtocolMessage.js.map +0 -1
  227. package/lib/messages/IProtocolProperty.d.ts +0 -12
  228. package/lib/messages/IProtocolProperty.js +0 -3
  229. package/lib/messages/IProtocolProperty.js.map +0 -1
  230. package/lib/programmers/MessageProgrammer.d.ts +0 -5
  231. package/lib/programmers/MessageProgrammer.js +0 -141
  232. package/lib/programmers/MessageProgrammer.js.map +0 -1
  233. package/lib/transformers/features/protocols/MessageTransformer.d.ts +0 -5
  234. package/lib/transformers/features/protocols/MessageTransformer.js +0 -17
  235. package/lib/transformers/features/protocols/MessageTransformer.js.map +0 -1
  236. package/lib/utils/NameEncoder.d.ts +0 -4
  237. package/lib/utils/NameEncoder.js +0 -89
  238. package/lib/utils/NameEncoder.js.map +0 -1
  239. package/src/factories/ProtocolFactory.ts +0 -79
  240. package/src/factories/internal/protocols/ProtocolMetadataUtil.ts +0 -163
  241. package/src/factories/internal/protocols/emplace_protocol_object.ts +0 -25
  242. package/src/factories/internal/protocols/emplace_protocol_property.ts +0 -12
  243. package/src/factories/internal/protocols/iterate_protocol_atomic.ts +0 -34
  244. package/src/factories/internal/protocols/iterate_protocol_constant.ts +0 -27
  245. package/src/factories/internal/protocols/iterate_protocol_main.ts +0 -19
  246. package/src/factories/internal/protocols/iterate_protocol_map.ts +0 -58
  247. package/src/factories/internal/protocols/iterate_protocol_metadata.ts +0 -96
  248. package/src/factories/internal/protocols/iterate_protocol_native.ts +0 -34
  249. package/src/factories/internal/protocols/iterate_protocol_never.ts +0 -1
  250. package/src/factories/internal/protocols/iterate_protocol_object.ts +0 -110
  251. package/src/factories/internal/protocols/iterate_protocol_repeated.ts +0 -34
  252. package/src/factories/internal/protocols/iterate_protocol_tuple.ts +0 -29
  253. package/src/functional/$proto_bytes.ts +0 -25
  254. package/src/functional/$proto_field.ts +0 -30
  255. package/src/functional/$proto_float.ts +0 -37
  256. package/src/functional/$proto_i32.ts +0 -29
  257. package/src/functional/$proto_i64.ts +0 -37
  258. package/src/functional/$proto_size.ts +0 -82
  259. package/src/functional/$proto_string.ts +0 -24
  260. package/src/functional/$varint.ts +0 -130
  261. package/src/functional/$zigzag.ts +0 -39
  262. package/src/messages/IProtocolMap.ts +0 -5
  263. package/src/messages/IProtocolMessage.ts +0 -6
  264. package/src/messages/IProtocolProperty.ts +0 -13
  265. package/src/programmers/MessageProgrammer.ts +0 -126
  266. package/src/transformers/features/protocols/MessageTransformer.ts +0 -32
  267. package/src/utils/NameEncoder.ts +0 -32
package/README.md CHANGED
@@ -11,6 +11,11 @@ export function is<T>(input: unknown | T): input is T; // returns boolean
11
11
  export function assert<T>(input: unknown | T): T; // throws TypeGuardError
12
12
  export function validate<T>(input: unknown | T): IValidation<T>; // detailed
13
13
 
14
+ // STRICT VALIDATORS
15
+ export function equals<T>(input: unknown | T): input is T;
16
+ export function assertEquals<T>(input: unknown | T): T;
17
+ export function validateEquals<T>(input: unknown | T): IValidation<T>;
18
+
14
19
  // JSON
15
20
  export function application<T>(): IJsonApplication; // JSON schema
16
21
  export function assertParse<T>(input: string): T; // type safe parser
@@ -18,13 +23,6 @@ export function assertStringify<T>(input: T): string; // safe and faster
18
23
  // +) isParse, validateParse
19
24
  // +) stringify, isStringify, validateStringify
20
25
 
21
- // PROTOCOL BUFFER
22
- export function message<T>(): string; // Protocol Buffer message
23
- export function assertDecode<T>(buffer: Buffer): T; // safe decoder
24
- export function assertEncode<T>(input: T): Uint8Array; // safe encoder
25
- // +) decode, isDecode, validateDecode
26
- // +) encode, isEncode, validateEncode
27
-
28
26
  // MISC
29
27
  export function random<T>(): Primitive<T>; // generate random data
30
28
  export function clone<T>(input: T): Primitive<T>; // deep clone
@@ -37,8 +35,7 @@ export function prune<T extends object>(input: T): void; // erase extra props
37
35
 
38
36
  - Super-fast Runtime Validators
39
37
  - Safe JSON parse and fast stringify functions
40
- - Protocol Buffer encoder and decoder
41
- - Protobuf/JSON schema generator
38
+ - JSON schema generator
42
39
  - Random data generator
43
40
 
44
41
  All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
@@ -52,7 +49,7 @@ Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance
52
49
 
53
50
 
54
51
 
55
- ## Sponsors
52
+ ## Sponsors and Backers
56
53
  Thanks for your support.
57
54
 
58
55
  Your donation would encourage `typia` development.
@@ -87,7 +84,7 @@ For reference, to use this transform mode, you've install one onf them; [ttypesc
87
84
 
88
85
  If [ttypescript](https://github.com/cevek/ttypescript), you should compile through `ttsc` command, instead of using `tsc`.
89
86
 
90
- Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can use original `tsc` command. However, [ts-patch](https://github.com/nonara/ts-patch) hacks `node_modules/typescript` source code. Also, whenever update `typescrtip` version, you have to run `npm run prepare` command repeatedly.
87
+ Otherwise, you've chosen [ts-patch](https://github.com/nonara/ts-patch), you can use original `tsc` command. However, [ts-patch](https://github.com/nonara/ts-patch) hacks `node_modules/typescript` source code. Also, whenever update `typescript` version, you have to run `npm run prepare` command repeatedly.
91
88
 
92
89
  By the way, when using [@nest/cli](https://nestjs.com), you must just choose [ts-patch](https://github.com/nonara/ts-patch).
93
90
 
@@ -177,12 +174,6 @@ For more details, refer to the [Guide Documents (wiki)](https://github.com/samch
177
174
  > - [`parse()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#parse-functions)
178
175
  > - [`stringify()` functions](https://github.com/samchon/typia/wiki/Enhanced-JSON#stringify-functions)
179
176
  > - [comment tags](https://github.com/samchon/typia/wiki/Enhanced-JSON#comment-tags)
180
- > - **Protocol Buffer**
181
- > - [`message()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#message-function)
182
- > - [`decode()` function](https://github.com/samchon/typia/wiki/Protocol-Buffer#decode-function)
183
- > - [`encode()` functions](https://github.com/samchon/typia/wiki/Protocol-Buffer#encode-functions)
184
- > - [comment tags](https://github.com/samchon/typia/wiki/Protocol-Buffer#comment-tags)
185
- > - [weaknesses](https://github.com/samchon/typia/wiki/Protocol-Buffer#weaknesses)
186
177
  > - **Miscellaneous**
187
178
  > - [`random()` function](https://github.com/samchon/typia/wiki/Miscellaneous#random-function)
188
179
  > - [`clone()` functions](https://github.com/samchon/typia/wiki/Miscellaneous#clone-functions)
@@ -261,39 +252,19 @@ export function createAssertStringify<T>(): (input: T) => string;
261
252
 
262
253
  > Measured on [AMD R7 6800HS](https://github.com/samchon/typia/tree/master/benchmark/results/AMD%20Ryzen%207%206800HS%20with%20Radeon%20Graphics)
263
254
 
264
- ### Protocol Buffer
255
+ ### Miscellaneous
265
256
  ```typescript
266
- // PROTOCOL BUFFER MESSAGE
267
- export function message<T>(): string;
268
-
269
- // ENCODE FUNCTIONS
270
- export function encode<T>(input: T): Uint8Array;
271
- export function isEncode<T>(input: T): Uint8Array | null;
272
- export function assertEncode<T>(input: T): Uint8Array;
273
- export function validateEncode<T>(input: T): IValidation<Uint8Array>;
274
-
275
- // DECODE FUNCTIONS
276
- export function decode<T>(buffer: Uint8Array): T;
277
- export function isDecode<T>(buffer: Uint8Array): T | null;
278
- export function assertDecode<T>(buffer: Uint8Array): T;
279
- export function validateDecode<T>(buffer: Uint8Array): IValidation<T>;
280
-
281
- // FACTORY FUNCTIONS
282
- export function createDecode<T>(): (input: Uint8Array) => T;
283
- export function createEncode<T>(): (input: T) => Uint8Array;
284
- // +) createIsDecode, createAssertDecode, createValidateDecode
285
- // +) createIsEncode, createAssertEncode, createValidateEncode
257
+ export function random<T>(): Primitive<T>; // random data generator
258
+ export function clone<T>(input: T): Primitive<T>; // deep copy
259
+ export function prune<T>(input: T): void; // remove superfluous properties
260
+ // +) isClone, assertClone, validateClone
261
+ // +) isPrune, assertPrune, validatePrune
286
262
  ```
287
263
 
288
- `typia` supports Protocol Buffer.
289
-
290
- - `message()`: generate Protocol Buffer schema
291
- - `encode()`: encode JavaScript object to Protocol Buffer
292
- - `decode()`: decode Protocol Buffer to JavaScript object
264
+ When you need test data, just generate it through `typia.random<T>()`.
293
265
 
294
- Do not need to define any `*.proto` schema file. Just call above functions with generic argument `T`, then `typia` will generate the Protocol Buffer schema automatically, by analyzing your type `T`.
266
+ If a little bit special data being required, use ([Features > Runtime Validators > Comment Tags](https://github.com/samchon/typia/wiki/Runtime-Validators#comment-tags))
295
267
 
296
- If you want to add special type like `float32`, you can do it through **comment tags**. If you want to know more about those comment tags, visit Guide Documents ([Features > Protocol Buffer > Comment Tags](https://github.com/samchon/typia/wiki/Protocol-Buffer#comment-tags)).
297
268
 
298
269
 
299
270
 
@@ -11,5 +11,6 @@ export interface IRandomGenerator {
11
11
  ipv4(): string;
12
12
  ipv6(): string;
13
13
  pattern(regex: RegExp): string;
14
- date(): string;
14
+ date(minimum?: number, maximum?: number): string;
15
+ datetime(minimum?: number, maximum?: number): string;
15
16
  }
@@ -65,7 +65,7 @@ var TypiaSetupWizard;
65
65
  return [4, ArgumentParser_1.ArgumentParser.parse(pack)(true)(inquiry)];
66
66
  case 2:
67
67
  args = _b.sent();
68
- pack.install({ dev: true, modulo: "typescript" });
68
+ pack.install({ dev: true, modulo: "typescript", version: "4.9.5" });
69
69
  (_a = args.project) !== null && _a !== void 0 ? _a : (args.project = (function () {
70
70
  CommandExecutor_1.CommandExecutor.run("npx tsc --init", false);
71
71
  return (args.project = "tsconfig.json");
@@ -130,9 +130,19 @@ var TypiaSetupWizard;
130
130
  return __generator(this, function (_a) {
131
131
  switch (_a.label) {
132
132
  case 0: return [4, fs_1.default.promises.readdir(process.cwd())];
133
- case 1: return [4, (_a.sent()).filter(function (str) {
133
+ case 1: return [4, (_a.sent())
134
+ .filter(function (str) {
134
135
  return str.substring(0, 8) === "tsconfig" &&
135
136
  str.substring(str.length - 5) === ".json";
137
+ })
138
+ .sort(function (x, y) {
139
+ return x === "tsconfig.json"
140
+ ? -1
141
+ : y === "tsconfig.json"
142
+ ? 1
143
+ : x < y
144
+ ? -1
145
+ : 1;
136
146
  })];
137
147
  case 2:
138
148
  fileList = _a.sent();
@@ -1 +1 @@
1
- {"version":3,"file":"TypiaSetupWizard.js","sourceRoot":"","sources":["../../src/executable/TypiaSetupWizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAExB,yDAAwD;AACxD,2DAA0D;AAC1D,yDAAwD;AACxD,iEAAgE;AAEhE,IAAiB,gBAAgB,CA0HhC;AA1HD,WAAiB,gBAAgB;;IAO7B,SAAsB,KAAK;;;;;;;wBACvB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;wBACxD,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;wBACnC,OAAO,CAAC,GAAG,CAAC,0CAA0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F,+EAA2E;IAC3E,0EAAsE;IACtE,kFAA8E;IAC9E,EAAE;IACF,0EAAsE;IACtE,EAAE;CACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -1,13 +1,21 @@
1
1
  import ts from "typescript";
2
2
  import { MetadataObject } from "../metadata/MetadataObject";
3
3
  export declare class MetadataCollection {
4
+ private readonly options?;
4
5
  private readonly dict_;
5
6
  private readonly names_;
6
7
  private readonly unions_;
7
8
  private index_;
8
- constructor();
9
+ constructor(options?: Partial<MetadataCollection.IOptions> | undefined);
9
10
  objects(): MetadataObject[];
10
11
  unions(): MetadataObject[][];
11
12
  emplace(checker: ts.TypeChecker, type: ts.Type): [MetadataObject, boolean];
12
13
  private get_name;
13
14
  }
15
+ export declare namespace MetadataCollection {
16
+ interface IOptions {
17
+ replace?(str: string): string;
18
+ }
19
+ function replace(str: string): string;
20
+ function escape(str: string): string;
21
+ }
@@ -24,6 +24,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
24
  }
25
25
  return to.concat(ar || Array.prototype.slice.call(from));
26
26
  };
27
+ var __values = (this && this.__values) || function(o) {
28
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
29
+ if (m) return m.call(o);
30
+ if (o && typeof o.length === "number") return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
37
+ };
27
38
  Object.defineProperty(exports, "__esModule", { value: true });
28
39
  exports.MetadataCollection = void 0;
29
40
  var MetadataObject_1 = require("../metadata/MetadataObject");
@@ -31,7 +42,8 @@ var MapUtil_1 = require("../utils/MapUtil");
31
42
  var CommentFactory_1 = require("./CommentFactory");
32
43
  var TypeFactory_1 = require("./TypeFactory");
33
44
  var MetadataCollection = (function () {
34
- function MetadataCollection() {
45
+ function MetadataCollection(options) {
46
+ this.options = options;
35
47
  this.dict_ = new Map();
36
48
  this.names_ = new Map();
37
49
  this.unions_ = new Map();
@@ -70,7 +82,12 @@ var MetadataCollection = (function () {
70
82
  return __spreadArray([], __read(this.unions_.keys()), false).indexOf(key);
71
83
  };
72
84
  MetadataCollection.prototype.get_name = function (checker, type) {
73
- var name = TypeFactory_1.TypeFactory.getFullName(checker, type);
85
+ var _this = this;
86
+ var name = (function () {
87
+ var _a;
88
+ var str = TypeFactory_1.TypeFactory.getFullName(checker, type);
89
+ return ((_a = _this.options) === null || _a === void 0 ? void 0 : _a.replace) ? _this.options.replace(str) : str;
90
+ })();
74
91
  var duplicates = MapUtil_1.MapUtil.take(this.names_, name, function () { return new Map(); });
75
92
  var oldbie = duplicates.get(type);
76
93
  if (oldbie !== undefined)
@@ -84,4 +101,60 @@ var MetadataCollection = (function () {
84
101
  return MetadataCollection;
85
102
  }());
86
103
  exports.MetadataCollection = MetadataCollection;
104
+ (function (MetadataCollection) {
105
+ function replace(str) {
106
+ var e_1, _a;
107
+ try {
108
+ for (var REPLACERS_1 = __values(REPLACERS), REPLACERS_1_1 = REPLACERS_1.next(); !REPLACERS_1_1.done; REPLACERS_1_1 = REPLACERS_1.next()) {
109
+ var _b = __read(REPLACERS_1_1.value, 2), before = _b[0], after = _b[1];
110
+ str = str.split(before).join(after);
111
+ }
112
+ }
113
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
114
+ finally {
115
+ try {
116
+ if (REPLACERS_1_1 && !REPLACERS_1_1.done && (_a = REPLACERS_1.return)) _a.call(REPLACERS_1);
117
+ }
118
+ finally { if (e_1) throw e_1.error; }
119
+ }
120
+ return str;
121
+ }
122
+ MetadataCollection.replace = replace;
123
+ function escape(str) {
124
+ var e_2, _a;
125
+ try {
126
+ for (var REPLACERS_2 = __values(REPLACERS), REPLACERS_2_1 = REPLACERS_2.next(); !REPLACERS_2_1.done; REPLACERS_2_1 = REPLACERS_2.next()) {
127
+ var _b = __read(REPLACERS_2_1.value, 2), before = _b[0], after = _b[1];
128
+ if (after !== "")
129
+ str = str.split(after).join(before);
130
+ }
131
+ }
132
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
133
+ finally {
134
+ try {
135
+ if (REPLACERS_2_1 && !REPLACERS_2_1.done && (_a = REPLACERS_2.return)) _a.call(REPLACERS_2);
136
+ }
137
+ finally { if (e_2) throw e_2.error; }
138
+ }
139
+ return str;
140
+ }
141
+ MetadataCollection.escape = escape;
142
+ })(MetadataCollection = exports.MetadataCollection || (exports.MetadataCollection = {}));
143
+ exports.MetadataCollection = MetadataCollection;
144
+ var REPLACERS = [
145
+ ["$", "_dollar_"],
146
+ ["&", "_and_"],
147
+ ["|", "_or_"],
148
+ ["{", "_blt_"],
149
+ ["}", "_bgt_"],
150
+ ["<", "_lt_"],
151
+ [">", "_gt_"],
152
+ ["[", "_alt_"],
153
+ ["]", "_agt_"],
154
+ [",", "_comma_"],
155
+ ["`", "_backquote_"],
156
+ ["'", "_singlequote_"],
157
+ ['"', "_doublequote_"],
158
+ [" ", "_space_"],
159
+ ];
87
160
  //# sourceMappingURL=MetadataCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetadataCollection.js","sourceRoot":"","sources":["../../src/factories/MetadataCollection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,6DAA4D;AAE5D,4CAA2C;AAE3C,mDAAkD;AAClD,6CAA4C;AAE5C;IAMI;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAEM,oCAAO,GAAd;QACI,gCAAW,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,UAAE;IACpC,CAAC;IACM,mCAAM,GAAb;QACI,gCAAW,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,U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
37
  MetadataTagFactory.generate = generate;
38
38
  function parse(identifier, metadata, tag, output) {
39
39
  var _a;
40
- var closure = PARSER[tag.name];
40
+ var closure = MetadataTagFactory._PARSER[tag.name];
41
41
  if (closure === undefined)
42
42
  return null;
43
43
  var text = (_a = (tag.text || [])[0]) === null || _a === void 0 ? void 0 : _a.text;
@@ -45,137 +45,146 @@ var MetadataTagFactory;
45
45
  throw new Error("".concat(LABEL, ": no tag value on ").concat(identifier()));
46
46
  return closure(identifier, metadata, text, output);
47
47
  }
48
+ MetadataTagFactory._PARSER = {
49
+ items: function (identifier, metadata, text, output) {
50
+ validate(identifier, metadata, output, "items", "array", [
51
+ "minItems",
52
+ ]);
53
+ return {
54
+ kind: "items",
55
+ value: parse_number(identifier, text),
56
+ };
57
+ },
58
+ minItems: function (identifier, metadata, text, output) {
59
+ validate(identifier, metadata, output, "minItems", "array", [
60
+ "items",
61
+ ]);
62
+ return {
63
+ kind: "minItems",
64
+ value: parse_number(identifier, text),
65
+ };
66
+ },
67
+ maxItems: function (identifier, metadata, text, output) {
68
+ validate(identifier, metadata, output, "maxItems", "array", [
69
+ "items",
70
+ ]);
71
+ return {
72
+ kind: "maxItems",
73
+ value: parse_number(identifier, text),
74
+ };
75
+ },
76
+ type: function (identifier, metadata, text, output) {
77
+ validate(identifier, metadata, output, "type", "number", []);
78
+ if (text !== "int" && text !== "uint")
79
+ throw new Error("".concat(LABEL, ": invalid type tag on \"").concat(identifier(), "\"."));
80
+ return { kind: "type", value: text };
81
+ },
82
+ minimum: function (identifier, metadata, text, output) {
83
+ validate(identifier, metadata, output, "minimum", "number", [
84
+ "exclusiveMinimum",
85
+ ]);
86
+ return {
87
+ kind: "minimum",
88
+ value: parse_number(identifier, text),
89
+ };
90
+ },
91
+ maximum: function (identifier, metadata, text, output) {
92
+ validate(identifier, metadata, output, "maximum", "number", [
93
+ "exclusiveMaximum",
94
+ ]);
95
+ return {
96
+ kind: "maximum",
97
+ value: parse_number(identifier, text),
98
+ };
99
+ },
100
+ exclusiveMinimum: function (identifier, metadata, text, output) {
101
+ validate(identifier, metadata, output, "exclusiveMinimum", "number", ["minimum"]);
102
+ return {
103
+ kind: "exclusiveMinimum",
104
+ value: parse_number(identifier, text),
105
+ };
106
+ },
107
+ exclusiveMaximum: function (identifier, metadata, text, output) {
108
+ validate(identifier, metadata, output, "exclusiveMaximum", "number", ["maximum"]);
109
+ return {
110
+ kind: "exclusiveMaximum",
111
+ value: parse_number(identifier, text),
112
+ };
113
+ },
114
+ multipleOf: function (identifier, metadata, text, output) {
115
+ validate(identifier, metadata, output, "multipleOf", "number", [
116
+ "step",
117
+ ]);
118
+ return {
119
+ kind: "multipleOf",
120
+ value: parse_number(identifier, text),
121
+ };
122
+ },
123
+ step: function (identifier, metadata, text, output) {
124
+ validate(identifier, metadata, output, "step", "number", [
125
+ "multipleOf",
126
+ ]);
127
+ var minimum = output.some(function (tag) {
128
+ return tag.kind === "minimum" || tag.kind === "exclusiveMinimum";
129
+ });
130
+ if (minimum === undefined)
131
+ throw new Error("".concat(LABEL, ": step requires minimum or exclusiveMinimum tag on \"").concat(identifier(), "\"."));
132
+ return {
133
+ kind: "step",
134
+ value: parse_number(identifier, text),
135
+ };
136
+ },
137
+ format: function (identifier, metadata, str, output) {
138
+ validate(identifier, metadata, output, "format", "string", [
139
+ "pattern",
140
+ ]);
141
+ var value = FORMATS.get(str);
142
+ if (value === undefined)
143
+ return null;
144
+ return {
145
+ kind: "format",
146
+ value: value,
147
+ };
148
+ },
149
+ pattern: function (identifier, metadata, value, output) {
150
+ validate(identifier, metadata, output, "pattern", "string", [
151
+ "format",
152
+ ]);
153
+ return {
154
+ kind: "pattern",
155
+ value: value,
156
+ };
157
+ },
158
+ length: function (identifier, metadata, text, output) {
159
+ validate(identifier, metadata, output, "length", "string", [
160
+ "minLength",
161
+ "maxLength",
162
+ ]);
163
+ return {
164
+ kind: "length",
165
+ value: parse_number(identifier, text),
166
+ };
167
+ },
168
+ minLength: function (identifier, metadata, text, output) {
169
+ validate(identifier, metadata, output, "minLength", "string", [
170
+ "length",
171
+ ]);
172
+ return {
173
+ kind: "minLength",
174
+ value: parse_number(identifier, text),
175
+ };
176
+ },
177
+ maxLength: function (identifier, metadata, text, output) {
178
+ validate(identifier, metadata, output, "maxLength", "string", [
179
+ "length",
180
+ ]);
181
+ return {
182
+ kind: "maxLength",
183
+ value: parse_number(identifier, text),
184
+ };
185
+ },
186
+ };
48
187
  })(MetadataTagFactory = exports.MetadataTagFactory || (exports.MetadataTagFactory = {}));
49
- var PARSER = {
50
- items: function (identifier, metadata, text, output) {
51
- validate(identifier, metadata, output, "items", "array", ["minItems"]);
52
- return {
53
- kind: "items",
54
- value: parse_number(identifier, text),
55
- };
56
- },
57
- minItems: function (identifier, metadata, text, output) {
58
- validate(identifier, metadata, output, "minItems", "array", ["items"]);
59
- return {
60
- kind: "minItems",
61
- value: parse_number(identifier, text),
62
- };
63
- },
64
- maxItems: function (identifier, metadata, text, output) {
65
- validate(identifier, metadata, output, "maxItems", "array", ["items"]);
66
- return {
67
- kind: "maxItems",
68
- value: parse_number(identifier, text),
69
- };
70
- },
71
- type: function (identifier, metadata, text, output) {
72
- validate(identifier, metadata, output, "type", "number", []);
73
- if (text !== "int" && text !== "uint")
74
- throw new Error("".concat(LABEL, ": invalid type tag on \"").concat(identifier(), "\"."));
75
- return { kind: "type", value: text };
76
- },
77
- minimum: function (identifier, metadata, text, output) {
78
- validate(identifier, metadata, output, "minimum", "number", [
79
- "exclusiveMinimum",
80
- ]);
81
- return {
82
- kind: "minimum",
83
- value: parse_number(identifier, text),
84
- };
85
- },
86
- maximum: function (identifier, metadata, text, output) {
87
- validate(identifier, metadata, output, "maximum", "number", [
88
- "exclusiveMaximum",
89
- ]);
90
- return {
91
- kind: "maximum",
92
- value: parse_number(identifier, text),
93
- };
94
- },
95
- exclusiveMinimum: function (identifier, metadata, text, output) {
96
- validate(identifier, metadata, output, "exclusiveMinimum", "number", [
97
- "minimum",
98
- ]);
99
- return {
100
- kind: "exclusiveMinimum",
101
- value: parse_number(identifier, text),
102
- };
103
- },
104
- exclusiveMaximum: function (identifier, metadata, text, output) {
105
- validate(identifier, metadata, output, "exclusiveMaximum", "number", [
106
- "maximum",
107
- ]);
108
- return {
109
- kind: "exclusiveMaximum",
110
- value: parse_number(identifier, text),
111
- };
112
- },
113
- multipleOf: function (identifier, metadata, text, output) {
114
- validate(identifier, metadata, output, "multipleOf", "number", [
115
- "step",
116
- ]);
117
- return {
118
- kind: "multipleOf",
119
- value: parse_number(identifier, text),
120
- };
121
- },
122
- step: function (identifier, metadata, text, output) {
123
- validate(identifier, metadata, output, "step", "number", [
124
- "multipleOf",
125
- ]);
126
- var minimum = output.some(function (tag) { return tag.kind === "minimum" || tag.kind === "exclusiveMinimum"; });
127
- if (minimum === undefined)
128
- throw new Error("".concat(LABEL, ": step requires minimum or exclusiveMinimum tag on \"").concat(identifier(), "\"."));
129
- return {
130
- kind: "step",
131
- value: parse_number(identifier, text),
132
- };
133
- },
134
- format: function (identifier, metadata, value, output) {
135
- validate(identifier, metadata, output, "format", "string", ["pattern"]);
136
- if (FORMATS.has(value) === false)
137
- return null;
138
- return {
139
- kind: "format",
140
- value: value,
141
- };
142
- },
143
- pattern: function (identifier, metadata, value, output) {
144
- validate(identifier, metadata, output, "pattern", "string", ["format"]);
145
- return {
146
- kind: "pattern",
147
- value: value,
148
- };
149
- },
150
- length: function (identifier, metadata, text, output) {
151
- validate(identifier, metadata, output, "length", "string", [
152
- "minLength",
153
- "maxLength",
154
- ]);
155
- return {
156
- kind: "length",
157
- value: parse_number(identifier, text),
158
- };
159
- },
160
- minLength: function (identifier, metadata, text, output) {
161
- validate(identifier, metadata, output, "minLength", "string", [
162
- "length",
163
- ]);
164
- return {
165
- kind: "minLength",
166
- value: parse_number(identifier, text),
167
- };
168
- },
169
- maxLength: function (identifier, metadata, text, output) {
170
- validate(identifier, metadata, output, "maxLength", "string", [
171
- "length",
172
- ]);
173
- return {
174
- kind: "maxLength",
175
- value: parse_number(identifier, text),
176
- };
177
- },
178
- };
179
188
  function parse_number(identifier, str) {
180
189
  var value = Number(str);
181
190
  if (isNaN(value) === true)
@@ -183,7 +192,17 @@ function parse_number(identifier, str) {
183
192
  return value;
184
193
  }
185
194
  var LABEL = "Error on typia.MetadataTagFactory.generate()";
186
- var FORMATS = new Set(["uuid", "email", "url", "mobile", "ipv4", "ipv6"]);
195
+ var FORMATS = new Map([
196
+ ["uuid", "uuid"],
197
+ ["email", "email"],
198
+ ["url", "url"],
199
+ ["ipv4", "ipv4"],
200
+ ["ipv6", "ipv6"],
201
+ ["date", "date"],
202
+ ["datetime", "datetime"],
203
+ ["date-time", "datetime"],
204
+ ["dateTime", "datetime"],
205
+ ]);
187
206
  var WRONG_TYPE = function (tag, type, identifier) { return "".concat(LABEL, ": ").concat(tag, " requires ").concat(type, " type, but no \"").concat(identifier(), "\"."); };
188
207
  function validate(identifier, metadata, output, kind, type, neighbors) {
189
208
  var e_2, _a;