typia 5.0.4 → 5.0.5-dev.20230921

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 (291) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/IRandomGenerator.ts +35 -35
  4. package/src/IValidation.ts +21 -21
  5. package/src/Primitive.ts +135 -135
  6. package/src/Resolved.ts +116 -116
  7. package/src/TypeGuardError.ts +36 -36
  8. package/src/executable/TypiaGenerateWizard.ts +85 -85
  9. package/src/executable/TypiaSetupWizard.ts +153 -153
  10. package/src/executable/setup/ArgumentParser.ts +45 -45
  11. package/src/executable/setup/CommandExecutor.ts +8 -8
  12. package/src/executable/setup/FileRetriever.ts +22 -22
  13. package/src/executable/setup/PackageManager.ts +71 -71
  14. package/src/executable/setup/PluginConfigurator.ts +70 -70
  15. package/src/executable/typia.ts +52 -52
  16. package/src/factories/CommentFactory.ts +84 -84
  17. package/src/factories/ExpressionFactory.ts +159 -159
  18. package/src/factories/IdentifierFactory.ts +74 -74
  19. package/src/factories/JsonMetadataFactory.ts +43 -43
  20. package/src/factories/LiteralFactory.ts +47 -47
  21. package/src/factories/MetadataCollection.ts +269 -269
  22. package/src/factories/MetadataCommentTagFactory.ts +629 -629
  23. package/src/factories/MetadataFactory.ts +214 -214
  24. package/src/factories/MetadataTypeTagFactory.ts +313 -313
  25. package/src/factories/NumericRangeFactory.ts +33 -33
  26. package/src/factories/ProtobufFactory.ts +272 -272
  27. package/src/factories/StatementFactory.ts +72 -72
  28. package/src/factories/TemplateFactory.ts +58 -58
  29. package/src/factories/TypeFactory.ts +119 -119
  30. package/src/factories/ValueFactory.ts +12 -12
  31. package/src/factories/internal/metadata/MetadataHelper.ts +12 -12
  32. package/src/factories/internal/metadata/emend_metadata_atomics.ts +40 -40
  33. package/src/factories/internal/metadata/emplace_metadata_alias.ts +41 -41
  34. package/src/factories/internal/metadata/emplace_metadata_array_type.ts +41 -41
  35. package/src/factories/internal/metadata/emplace_metadata_object.ts +150 -150
  36. package/src/factories/internal/metadata/emplace_metadata_tuple.ts +60 -60
  37. package/src/factories/internal/metadata/explore_metadata.ts +32 -32
  38. package/src/factories/internal/metadata/iterate_metadata.ts +101 -101
  39. package/src/factories/internal/metadata/iterate_metadata_alias.ts +35 -35
  40. package/src/factories/internal/metadata/iterate_metadata_array.ts +37 -37
  41. package/src/factories/internal/metadata/iterate_metadata_atomic.ts +62 -62
  42. package/src/factories/internal/metadata/iterate_metadata_coalesce.ts +33 -33
  43. package/src/factories/internal/metadata/iterate_metadata_collection.ts +141 -141
  44. package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +26 -26
  45. package/src/factories/internal/metadata/iterate_metadata_constant.ts +58 -58
  46. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +197 -197
  47. package/src/factories/internal/metadata/iterate_metadata_map.ts +57 -57
  48. package/src/factories/internal/metadata/iterate_metadata_native.ts +210 -210
  49. package/src/factories/internal/metadata/iterate_metadata_object.ts +44 -44
  50. package/src/factories/internal/metadata/iterate_metadata_resolve.ts +52 -52
  51. package/src/factories/internal/metadata/iterate_metadata_set.ts +42 -42
  52. package/src/factories/internal/metadata/iterate_metadata_sort.ts +69 -69
  53. package/src/factories/internal/metadata/iterate_metadata_template.ts +47 -47
  54. package/src/factories/internal/metadata/iterate_metadata_tuple.ts +37 -37
  55. package/src/factories/internal/metadata/iterate_metadata_union.ts +27 -27
  56. package/src/functional/$ProtobufReader.ts +201 -201
  57. package/src/functional/$ProtobufSizer.ts +147 -147
  58. package/src/functional/$ProtobufWriter.ts +151 -151
  59. package/src/functional/$any.ts +4 -4
  60. package/src/functional/$clone.ts +4 -4
  61. package/src/functional/$dictionary.ts +25 -25
  62. package/src/functional/$every.ts +11 -11
  63. package/src/functional/$guard.ts +35 -35
  64. package/src/functional/$is_between.ts +2 -2
  65. package/src/functional/$join.ts +46 -46
  66. package/src/functional/$number.ts +13 -13
  67. package/src/functional/$report.ts +15 -15
  68. package/src/functional/$rest.ts +3 -3
  69. package/src/functional/$string.ts +50 -50
  70. package/src/functional/$strlen.ts +7 -7
  71. package/src/functional/$tail.ts +5 -5
  72. package/src/functional/$varint.ts +130 -130
  73. package/src/functional/$zigzag.ts +39 -39
  74. package/src/functional/IProtobufWriter.ts +18 -18
  75. package/src/functional/Namespace.ts +133 -133
  76. package/src/index.ts +4 -4
  77. package/src/json.ts +648 -648
  78. package/src/misc.ts +651 -651
  79. package/src/module.ts +656 -656
  80. package/src/programmers/AssertProgrammer.ts +317 -317
  81. package/src/programmers/CheckerProgrammer.ts +1137 -1137
  82. package/src/programmers/FeatureProgrammer.ts +478 -478
  83. package/src/programmers/IsProgrammer.ts +252 -252
  84. package/src/programmers/RandomProgrammer.ts +878 -878
  85. package/src/programmers/TypiaProgrammer.ts +163 -163
  86. package/src/programmers/ValidateProgrammer.ts +346 -346
  87. package/src/programmers/helpers/AtomicPredicator.ts +31 -31
  88. package/src/programmers/helpers/CloneJoiner.ts +144 -144
  89. package/src/programmers/helpers/FunctionImporeter.ts +91 -91
  90. package/src/programmers/helpers/ICheckEntry.ts +13 -13
  91. package/src/programmers/helpers/IExpressionEntry.ts +12 -12
  92. package/src/programmers/helpers/OptionPredicator.ts +15 -15
  93. package/src/programmers/helpers/ProtobufUtil.ts +125 -125
  94. package/src/programmers/helpers/ProtobufWire.ts +34 -34
  95. package/src/programmers/helpers/PruneJoiner.ts +143 -143
  96. package/src/programmers/helpers/RandomJoiner.ts +151 -151
  97. package/src/programmers/helpers/RandomRanger.ts +173 -173
  98. package/src/programmers/helpers/StringifyJoinder.ts +113 -113
  99. package/src/programmers/helpers/StringifyPredicator.ts +12 -12
  100. package/src/programmers/helpers/UnionExplorer.ts +305 -305
  101. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  102. package/src/programmers/helpers/disable_function_importer_declare.ts +32 -32
  103. package/src/programmers/internal/JSON_SCHEMA_PREFIX.ts +1 -1
  104. package/src/programmers/internal/application_alias.ts +65 -65
  105. package/src/programmers/internal/application_array.ts +53 -53
  106. package/src/programmers/internal/application_boolean.ts +15 -15
  107. package/src/programmers/internal/application_constant.ts +26 -26
  108. package/src/programmers/internal/application_default.ts +17 -17
  109. package/src/programmers/internal/application_default_string.ts +37 -37
  110. package/src/programmers/internal/application_escaped.ts +55 -55
  111. package/src/programmers/internal/application_native.ts +39 -39
  112. package/src/programmers/internal/application_number.ts +88 -88
  113. package/src/programmers/internal/application_object.ts +162 -162
  114. package/src/programmers/internal/application_schema.ts +175 -175
  115. package/src/programmers/internal/application_string.ts +51 -51
  116. package/src/programmers/internal/application_templates.ts +25 -25
  117. package/src/programmers/internal/application_tuple.ts +58 -58
  118. package/src/programmers/internal/check_array_length.ts +41 -41
  119. package/src/programmers/internal/check_bigint.ts +45 -45
  120. package/src/programmers/internal/check_dynamic_properties.ts +194 -194
  121. package/src/programmers/internal/check_everything.ts +28 -28
  122. package/src/programmers/internal/check_native.ts +21 -21
  123. package/src/programmers/internal/check_number.ts +105 -105
  124. package/src/programmers/internal/check_object.ts +55 -55
  125. package/src/programmers/internal/check_string.ts +45 -45
  126. package/src/programmers/internal/check_template.ts +61 -61
  127. package/src/programmers/internal/check_union_array_like.ts +323 -323
  128. package/src/programmers/internal/decode_union_object.ts +84 -84
  129. package/src/programmers/internal/feature_object_entries.ts +58 -58
  130. package/src/programmers/internal/metadata_to_pattern.ts +34 -34
  131. package/src/programmers/internal/prune_object_properties.ts +60 -60
  132. package/src/programmers/internal/random_custom.ts +37 -37
  133. package/src/programmers/internal/stringify_dynamic_properties.ts +171 -171
  134. package/src/programmers/internal/stringify_native.ts +7 -7
  135. package/src/programmers/internal/stringify_regular_properties.ts +83 -83
  136. package/src/programmers/internal/template_to_pattern.ts +15 -15
  137. package/src/programmers/internal/wrap_metadata_rest_tuple.ts +20 -20
  138. package/src/programmers/json/JsonApplicationProgrammer.ts +50 -50
  139. package/src/programmers/json/JsonAssertParseProgrammer.ts +71 -71
  140. package/src/programmers/json/JsonAssertStringifyProgrammer.ts +66 -66
  141. package/src/programmers/json/JsonIsParseProgrammer.ts +77 -77
  142. package/src/programmers/json/JsonIsStringifyProgrammer.ts +76 -76
  143. package/src/programmers/json/JsonStringifyProgrammer.ts +964 -964
  144. package/src/programmers/json/JsonValidateParseProgrammer.ts +68 -68
  145. package/src/programmers/json/JsonValidateStringifyProgrammer.ts +84 -84
  146. package/src/programmers/misc/MiscAssertCloneProgrammer.ts +71 -71
  147. package/src/programmers/misc/MiscAssertPruneProgrammer.ts +68 -68
  148. package/src/programmers/misc/MiscCloneProgrammer.ts +774 -774
  149. package/src/programmers/misc/MiscIsCloneProgrammer.ts +78 -78
  150. package/src/programmers/misc/MiscIsPruneProgrammer.ts +73 -73
  151. package/src/programmers/misc/MiscLiteralsProgrammer.ts +69 -69
  152. package/src/programmers/misc/MiscPruneProgrammer.ts +550 -550
  153. package/src/programmers/misc/MiscValidateCloneProgrammer.ts +85 -85
  154. package/src/programmers/misc/MiscValidatePruneProgrammer.ts +78 -78
  155. package/src/programmers/protobuf/ProtobufAssertDecodeProgrammer.ts +75 -75
  156. package/src/programmers/protobuf/ProtobufAssertEncodeProgrammer.ts +66 -66
  157. package/src/programmers/protobuf/ProtobufDecodeProgrammer.ts +655 -655
  158. package/src/programmers/protobuf/ProtobufEncodeProgrammer.ts +883 -883
  159. package/src/programmers/protobuf/ProtobufIsDecodeProgrammer.ts +85 -85
  160. package/src/programmers/protobuf/ProtobufIsEncodeProgrammer.ts +76 -76
  161. package/src/programmers/protobuf/ProtobufMessageProgrammer.ts +165 -165
  162. package/src/programmers/protobuf/ProtobufValidateDecodeProgrammer.ts +75 -75
  163. package/src/programmers/protobuf/ProtobufValidateEncodeProgrammer.ts +86 -86
  164. package/src/protobuf.ts +881 -881
  165. package/src/schemas/json/IJsonApplication.ts +8 -8
  166. package/src/schemas/json/IJsonComponents.ts +33 -33
  167. package/src/schemas/json/IJsonSchema.ts +110 -110
  168. package/src/schemas/metadata/IJsDocTagInfo.ts +10 -10
  169. package/src/schemas/metadata/IMetadata.ts +34 -34
  170. package/src/schemas/metadata/IMetadataAlias.ts +12 -12
  171. package/src/schemas/metadata/IMetadataApplication.ts +7 -7
  172. package/src/schemas/metadata/IMetadataArray.ts +7 -7
  173. package/src/schemas/metadata/IMetadataArrayType.ts +10 -10
  174. package/src/schemas/metadata/IMetadataAtomic.ts +6 -6
  175. package/src/schemas/metadata/IMetadataCollection.ts +11 -11
  176. package/src/schemas/metadata/IMetadataConstant.ts +16 -16
  177. package/src/schemas/metadata/IMetadataDictionary.ts +14 -14
  178. package/src/schemas/metadata/IMetadataEntry.ts +6 -6
  179. package/src/schemas/metadata/IMetadataEscaped.ts +6 -6
  180. package/src/schemas/metadata/IMetadataObject.ts +18 -18
  181. package/src/schemas/metadata/IMetadataProperty.ts +9 -9
  182. package/src/schemas/metadata/IMetadataTuple.ts +7 -7
  183. package/src/schemas/metadata/IMetadataTupleType.ts +10 -10
  184. package/src/schemas/metadata/IMetadataTypeTag.ts +8 -8
  185. package/src/schemas/metadata/Metadata.ts +685 -685
  186. package/src/schemas/metadata/MetadataAlias.ts +61 -61
  187. package/src/schemas/metadata/MetadataArray.ts +49 -49
  188. package/src/schemas/metadata/MetadataArrayType.ts +57 -57
  189. package/src/schemas/metadata/MetadataAtomic.ts +42 -42
  190. package/src/schemas/metadata/MetadataConstant.ts +3 -3
  191. package/src/schemas/metadata/MetadataEscaped.ts +51 -51
  192. package/src/schemas/metadata/MetadataObject.ts +139 -139
  193. package/src/schemas/metadata/MetadataProperty.ts +59 -59
  194. package/src/schemas/metadata/MetadataTuple.ts +32 -32
  195. package/src/schemas/metadata/MetadataTupleType.ts +67 -67
  196. package/src/tags/ExclusiveMaximum.ts +13 -13
  197. package/src/tags/ExclusiveMinimum.ts +13 -13
  198. package/src/tags/Format.ts +30 -30
  199. package/src/tags/MaxItems.ts +9 -9
  200. package/src/tags/MaxLength.ts +9 -9
  201. package/src/tags/Maximum.ts +13 -13
  202. package/src/tags/MinItems.ts +9 -9
  203. package/src/tags/MinLength.ts +9 -9
  204. package/src/tags/Minimum.ts +13 -13
  205. package/src/tags/MultipleOf.ts +15 -15
  206. package/src/tags/Pattern.ts +8 -8
  207. package/src/tags/TagBase.ts +68 -68
  208. package/src/tags/Type.ts +27 -27
  209. package/src/tags/index.ts +13 -13
  210. package/src/transform.ts +35 -35
  211. package/src/transformers/CallExpressionTransformer.ts +243 -243
  212. package/src/transformers/FileTransformer.ts +57 -57
  213. package/src/transformers/IProject.ts +15 -15
  214. package/src/transformers/ITransformOptions.ts +62 -62
  215. package/src/transformers/ImportTransformer.ts +66 -66
  216. package/src/transformers/NodeTransformer.ts +13 -13
  217. package/src/transformers/TransformerError.ts +55 -55
  218. package/src/transformers/features/AssertTransformer.ts +11 -11
  219. package/src/transformers/features/CreateAssertTransformer.ts +13 -13
  220. package/src/transformers/features/CreateIsTransformer.ts +11 -11
  221. package/src/transformers/features/CreateRandomTransformer.ts +43 -43
  222. package/src/transformers/features/CreateValidateTransformer.ts +13 -13
  223. package/src/transformers/features/IsTransformer.ts +11 -11
  224. package/src/transformers/features/RandomTransformer.ts +46 -46
  225. package/src/transformers/features/ValidateTransformer.ts +11 -11
  226. package/src/transformers/features/json/JsonApplicationTransformer.ts +118 -118
  227. package/src/transformers/features/json/JsonAssertParseTransformer.ts +10 -10
  228. package/src/transformers/features/json/JsonAssertStringifyTransformer.ts +10 -10
  229. package/src/transformers/features/json/JsonCreateAssertParseTransformer.ts +10 -10
  230. package/src/transformers/features/json/JsonCreateAssertStringifyTransformer.ts +12 -12
  231. package/src/transformers/features/json/JsonCreateIsParseTransformer.ts +9 -9
  232. package/src/transformers/features/json/JsonCreateIsStringifyTransformer.ts +10 -10
  233. package/src/transformers/features/json/JsonCreateStringifyTransformer.ts +9 -9
  234. package/src/transformers/features/json/JsonCreateValidateParseTransformer.ts +10 -10
  235. package/src/transformers/features/json/JsonCreateValidateStringifyProgrammer.ts +12 -12
  236. package/src/transformers/features/json/JsonIsParseTransformer.ts +9 -9
  237. package/src/transformers/features/json/JsonIsStringifyTransformer.ts +10 -10
  238. package/src/transformers/features/json/JsonStringifyTransformer.ts +9 -9
  239. package/src/transformers/features/json/JsonValidateParseTransformer.ts +10 -10
  240. package/src/transformers/features/json/JsonValidateStringifyTransformer.ts +10 -10
  241. package/src/transformers/features/misc/MetadataTransformer.ts +61 -61
  242. package/src/transformers/features/misc/MiscAssertCloneTransformer.ts +10 -10
  243. package/src/transformers/features/misc/MiscAssertPruneTransformer.ts +10 -10
  244. package/src/transformers/features/misc/MiscCloneTransformer.ts +9 -9
  245. package/src/transformers/features/misc/MiscCreateAssertCloneTransformer.ts +10 -10
  246. package/src/transformers/features/misc/MiscCreateAssertPruneTransformer.ts +10 -10
  247. package/src/transformers/features/misc/MiscCreateCloneTransformer.ts +9 -9
  248. package/src/transformers/features/misc/MiscCreateIsCloneTransformer.ts +9 -9
  249. package/src/transformers/features/misc/MiscCreateIsPruneTransformer.ts +9 -9
  250. package/src/transformers/features/misc/MiscCreatePruneTransformer.ts +9 -9
  251. package/src/transformers/features/misc/MiscCreateValidateCloneTransformer.ts +10 -10
  252. package/src/transformers/features/misc/MiscCreateValidatePruneTransformer.ts +10 -10
  253. package/src/transformers/features/misc/MiscIsCloneTransformer.ts +9 -9
  254. package/src/transformers/features/misc/MiscIsPruneTransformer.ts +9 -9
  255. package/src/transformers/features/misc/MiscLiteralsTransformer.ts +32 -32
  256. package/src/transformers/features/misc/MiscPruneTransformer.ts +9 -9
  257. package/src/transformers/features/misc/MiscValidateCloneTransformer.ts +10 -10
  258. package/src/transformers/features/misc/MiscValidatePruneTransformer.ts +10 -10
  259. package/src/transformers/features/protobuf/CreateProtobufAssertDecodeTransformer.ts +12 -12
  260. package/src/transformers/features/protobuf/CreateProtobufAssertEncodeTransformer.ts +12 -12
  261. package/src/transformers/features/protobuf/CreateProtobufDecodeTransformer.ts +9 -9
  262. package/src/transformers/features/protobuf/CreateProtobufEncodeTransformer.ts +9 -9
  263. package/src/transformers/features/protobuf/CreateProtobufIsDecodeTransformer.ts +12 -12
  264. package/src/transformers/features/protobuf/CreateProtobufIsEncodeTransformer.ts +12 -12
  265. package/src/transformers/features/protobuf/CreateProtobufValidateDecodeTransformer.ts +12 -12
  266. package/src/transformers/features/protobuf/CreateProtobufValidateEncodeTransformer.ts +12 -12
  267. package/src/transformers/features/protobuf/ProtobufAssertDecodeTransformer.ts +10 -10
  268. package/src/transformers/features/protobuf/ProtobufAssertEncodeTransformer.ts +10 -10
  269. package/src/transformers/features/protobuf/ProtobufDecodeTransformer.ts +10 -10
  270. package/src/transformers/features/protobuf/ProtobufEncodeTransformer.ts +10 -10
  271. package/src/transformers/features/protobuf/ProtobufIsDecodeTransformer.ts +10 -10
  272. package/src/transformers/features/protobuf/ProtobufIsEncodeTransformer.ts +10 -10
  273. package/src/transformers/features/protobuf/ProtobufMessageTransformer.ts +33 -33
  274. package/src/transformers/features/protobuf/ProtobufValidateDecodeTransformer.ts +12 -12
  275. package/src/transformers/features/protobuf/ProtobufValidateEncodeTransformer.ts +12 -12
  276. package/src/transformers/internal/GenericTransformer.ts +104 -104
  277. package/src/typings/Atomic.ts +18 -18
  278. package/src/typings/ClassProperties.ts +5 -5
  279. package/src/typings/Customizable.ts +5 -5
  280. package/src/typings/OmitNever.ts +3 -3
  281. package/src/typings/ProtobufAtomic.ts +19 -19
  282. package/src/typings/SpecialFields.ts +3 -3
  283. package/src/typings/ValidationPipe.ts +9 -9
  284. package/src/typings/Writable.ts +11 -11
  285. package/src/utils/ArrayUtil.ts +45 -45
  286. package/src/utils/Escaper.ts +46 -46
  287. package/src/utils/MapUtil.ts +12 -12
  288. package/src/utils/NameEncoder.ts +32 -32
  289. package/src/utils/PatternUtil.ts +33 -33
  290. package/src/utils/RandomGenerator.ts +83 -83
  291. package/src/utils/Singleton.ts +17 -17
package/src/json.ts CHANGED
@@ -1,648 +1,648 @@
1
- import { Namespace } from "./functional/Namespace";
2
-
3
- import { IJsonApplication } from "./schemas/json/IJsonApplication";
4
-
5
- import { IValidation } from "./IValidation";
6
- import { Primitive } from "./Primitive";
7
-
8
- /* ===========================================================
9
- JSON
10
- - SCHEMA
11
- - PARSE
12
- - STRINGIFY
13
- - FACTORY FUNCTIONS
14
- ==============================================================
15
- SCHEMA
16
- ----------------------------------------------------------- */
17
- /**
18
- * > You must configure the generic argument `T`.
19
- *
20
- * JSON Schema Application.
21
- *
22
- * Creates a JSON schema application which contains both main JSON schemas and
23
- * components. Note that, all of the object types are stored in the
24
- * {@link IJsonApplication.components} property for the `$ref` referencing.
25
- *
26
- * Also, `typia.json.application()` has additional generic arguments, *Purpose*.
27
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
28
- * you should configure the *Purpose* appropriately.
29
- *
30
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
31
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
32
- * the tuple definition.
33
- *
34
- * @template Types Tuple of target types
35
- * @template Purpose Purpose of the JSON schema`
36
- * @return JSON schema application
37
- *
38
- * @author Jeongho Nam - https://github.com/samchon
39
- */
40
- export function application(): never;
41
-
42
- /**
43
- * JSON Schema Application.
44
- *
45
- * Creates a JSON schema application which contains both main JSON schemas and
46
- * components. Note that, all of the object types are stored in the
47
- * {@link IJsonApplication.components} property for the `$ref` referencing.
48
- *
49
- * Also, `typia.json.application()` has additional generic arguments, *Purpose*.
50
- * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
51
- * you should configure the *Purpose* appropriately.
52
- *
53
- * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
54
- * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
55
- * the tuple definition.
56
- *
57
- * @template Types Tuple of target types
58
- * @template Purpose Purpose of the JSON schema
59
- * @return JSON schema application
60
- *
61
- * @author Jeongho Nam - https://github.com/samchon
62
- */
63
- export function application<
64
- Types extends unknown[],
65
- Purpose extends "ajv" | "swagger" = "swagger",
66
- >(): IJsonApplication;
67
-
68
- /**
69
- * @internal
70
- */
71
- export function application(): never {
72
- halt("application");
73
- }
74
-
75
- /* -----------------------------------------------------------
76
- PARSE
77
- ----------------------------------------------------------- */
78
- /**
79
- * > You must configure the generic argument `T`.
80
- *
81
- * Safe `JSON.parse()` function with type assertion.
82
- *
83
- * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
84
- * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
85
- * to a `T` typed instance with type assertion.
86
- *
87
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
88
- * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
89
- * the parsed value would be returned.
90
- *
91
- * @template T Expected type of parsed value
92
- * @param input JSON string
93
- * @returns Parsed value
94
- *
95
- * @author Jeongho Nam - https://github.com/samchon
96
- */
97
- export function assertParse(input: string): never;
98
-
99
- /**
100
- * Safe `JSON.parse()` function with type assertion.
101
- *
102
- * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
103
- * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
104
- * to a `T` typed instance with type assertion.
105
- *
106
- * In such reason, when parsed JSON string value is not matched with the type `T`,
107
- * it throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed
108
- * value, the parsed value would be returned.
109
- *
110
- * @template T Expected type of parsed value
111
- * @param input JSON string
112
- * @returns Parsed value
113
- *
114
- * @author Jeongho Nam - https://github.com/samchon
115
- */
116
- export function assertParse<T>(input: string): Primitive<T>;
117
-
118
- /**
119
- * @internal
120
- */
121
- export function assertParse<T>(): Primitive<T> {
122
- halt("assertParse");
123
- }
124
- Object.assign(assertParse, Namespace.assert("assertParse"));
125
-
126
- /**
127
- * > You must configure the generic argument `T`.
128
- *
129
- * Safe `JSON.parse()` function with type checking.
130
- *
131
- * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
132
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
133
- * instance with type checking.
134
- *
135
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
136
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
137
- * value would be returned.
138
- *
139
- * @template T Expected type of parsed value
140
- * @param input JSON string
141
- * @returns Parsed value when exact type, otherwise `null`
142
- *
143
- * @author Jeongho Nam - https://github.com/samchon
144
- */
145
- export function isParse(input: string): never;
146
-
147
- /**
148
- * Safe `JSON.parse()` function with type checking.
149
- *
150
- * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
151
- * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
152
- * instance with type checking.
153
- *
154
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
155
- * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
156
- * value would be returned.
157
- *
158
- * @template T Expected type of parsed value
159
- * @param input JSON string
160
- * @returns Parsed value when exact type, otherwise `null`
161
- *
162
- * @author Jeongho Nam - https://github.com/samchon
163
- */
164
- export function isParse<T>(input: string): Primitive<T> | null;
165
-
166
- /**
167
- * @internal
168
- */
169
- export function isParse<T>(): Primitive<T> | null {
170
- halt("isParse");
171
- }
172
- Object.assign(isParse, Namespace.is());
173
-
174
- /**
175
- * > You must configure the generic argument `T`.
176
- *
177
- * Safe `JSON.parse()` function with detailed type validation.
178
- *
179
- * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
180
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
181
- * to a `T` typed instance with detailed type validation.
182
- *
183
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
184
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
185
- * there's no problem on the parsed value, the parsed value would be stored in `data`
186
- * property of the output {@link IValidation.ISuccess} instance.
187
- *
188
- * @template T Expected type of parsed value
189
- * @param input JSON string
190
- * @returns Validation result with JSON parsed value
191
- *
192
- * @author Jeongho Nam - https://github.com/samchon
193
- */
194
- export function validateParse(input: string): never;
195
-
196
- /**
197
- * Safe `JSON.parse()` function with detailed type validation.
198
- *
199
- * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
200
- * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
201
- * to a `T` typed instance with detailed type validation.
202
- *
203
- * In such reason, when parsed JSON string value is not matched with the type `T`, it
204
- * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
205
- * there's no problem on the parsed value, the parsed value would be stored in `data`
206
- * property of the output {@link IValidation.ISuccess} instance.
207
- *
208
- * @template T Expected type of parsed value
209
- * @param input JSON string
210
- * @returns Validation result with JSON parsed value
211
- *
212
- * @author Jeongho Nam - https://github.com/samchon
213
- */
214
- export function validateParse<T>(input: string): IValidation<Primitive<T>>;
215
-
216
- /**
217
- * @internal
218
- */
219
- export function validateParse<T>(): IValidation<Primitive<T>> {
220
- halt("validateParse");
221
- }
222
- Object.assign(validateParse, Namespace.validate());
223
-
224
- /* -----------------------------------------------------------
225
- STRINGIFY
226
- ----------------------------------------------------------- */
227
- /**
228
- * 8x faster `JSON.stringify()` function.
229
- *
230
- * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x
231
- * faster than the native `JSON.stringify()` function. The 5x faster principle is
232
- * because it writes an optimized JSON conversion plan, only for the type `T`.
233
- *
234
- * For reference, this `typia.json.stringify()` does not validate the input value type.
235
- * It just believes that the input value is following the type `T`. Therefore, if you
236
- * can't ensure the input value type, it would be better to call one of below
237
- * functions instead.
238
- *
239
- * - {@link assertStringify}
240
- * - {@link isStringify}
241
- * - {@link validateStringify}
242
- *
243
- * @template T Type of the input value
244
- * @param input A value to be converted
245
- * @return JSON string value
246
- *
247
- * @author Jeongho Nam - https://github.com/samchon
248
- */
249
- export function stringify<T>(input: T): string;
250
-
251
- /**
252
- * @internal
253
- */
254
- export function stringify(): never {
255
- halt("stringify");
256
- }
257
- Object.assign(stringify, Namespace.json.stringify("stringify"));
258
-
259
- /**
260
- * 5x faster `JSON.stringify()` function with type assertion.
261
- *
262
- * `typia.json.assertStringify()` is a combination function of {@link assert} and
263
- * {@link stringify}. Therefore, it converts an input value to
264
- * JSON (JavaScript Object Notation) string, with type assertion.
265
- *
266
- * In such reason, when `input` value is not matched with the type `T`, it throws an
267
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
268
- * string would be returned.
269
- *
270
- * For reference, with type assertion, it is even 5x times faster than the native
271
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
272
- * with confidence.
273
- *
274
- * @template T Type of the input value
275
- * @param input A value to be asserted and converted
276
- * @return JSON string value
277
- *
278
- * @author Jeongho Nam - https://github.com/samchon
279
- */
280
- export function assertStringify<T>(input: T): string;
281
-
282
- /**
283
- * 5x faster `JSON.stringify()` function with type assertion.
284
- *
285
- * `typia.json.assertStringify()` is a combination function of {@link assert} and
286
- * {@link stringify}. Therefore, it converts an input value to
287
- * JSON (JavaScript Object Notation) string, with type assertion.
288
- *
289
- * In such reason, when `input` value is not matched with the type `T`, it throws an
290
- * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
291
- * string would be returned.
292
- *
293
- * For reference, with type assertion, it is even 5x times faster than the native
294
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
295
- * with confidence.
296
- *
297
- * @template T Type of the input value
298
- * @param input A value to be asserted and converted
299
- * @return JSON string value
300
- *
301
- * @author Jeongho Nam - https://github.com/samchon
302
- */
303
- export function assertStringify<T>(input: T): unknown;
304
-
305
- /**
306
- * @internal
307
- */
308
- export function assertStringify(): string {
309
- halt("assertStringify");
310
- }
311
- Object.assign(assertStringify, Namespace.assert("assertStringify"));
312
- Object.assign(assertStringify, Namespace.json.stringify("assertStringify"));
313
-
314
- /**
315
- * 7x faster `JSON.stringify()` function with type checking.
316
- *
317
- * `typia.json.stringify()` is a combination function of {@link is} and
318
- * {@link stringify}. Therefore, it converts an input value to JSON
319
- * (JavaScript Object Notation) string, with type checking.
320
- *
321
- * In such reason, when `input` value is not matched with the type `T`, it returns
322
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string
323
- * would be returned.
324
- *
325
- * For reference, with type checking, it is even 7x times faster than the native
326
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
327
- * with confidence.
328
- *
329
- * @template T Type of the input value
330
- * @param input A value to be checked and converted
331
- * @return JSON string value when exact type, otherwise null
332
- *
333
- * @author Jeongho Nam - https://github.com/samchon
334
- */
335
- export function isStringify<T>(input: T): string | null;
336
-
337
- /**
338
- * 7x faster `JSON.stringify()` function with type checking.
339
- *
340
- * `typia.json.isStringify()` is a combination function of {@link is} and
341
- * {@link stringify}. Therefore, it converts an input value to JSON
342
- * (JavaScript Object Notation) string, with type checking.
343
- *
344
- * In such reason, when `input` value is not matched with the type `T`, it returns
345
- * `null` value. Otherwise, there's no problem on the `input` value, JSON string
346
- * would be returned.
347
- *
348
- * For reference, with type checking, it is even 7x times faster than the native
349
- * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
350
- * with confidence.
351
- *
352
- * @template T Type of the input value
353
- * @param input A value to be checked and converted
354
- * @return JSON string value when exact type, otherwise null
355
- *
356
- * @author Jeongho Nam - https://github.com/samchon
357
- */
358
- export function isStringify<T>(input: unknown): string | null;
359
-
360
- /**
361
- * @internal
362
- */
363
- export function isStringify(): string | null {
364
- halt("isStringify");
365
- }
366
-
367
- Object.assign(isStringify, Namespace.is());
368
- Object.assign(isStringify, Namespace.json.stringify("isStringify"));
369
-
370
- /**
371
- * 5x faster `JSON.stringify()` function with detailed type validation.
372
- *
373
- * `typia.json.validateStringify()` is a combination function of {@link validate} and
374
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
375
- * Notation) string, with detailed type validation.
376
- *
377
- * In such reason, when `input` value is not matched with the type `T`, it returns
378
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
379
- * there's no problem on the `input` value, JSON string would be stored in `data`
380
- * property of the output {@link IValidation.ISuccess} instance.
381
- *
382
- * For reference, with detailed type validation, it is even 5x times faster than the
383
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
384
- * conversion with confidence.
385
- *
386
- * @template T Type of the input value
387
- * @param input A value to be checked and converted
388
- * @returns Validation result with JSON string value
389
- *
390
- * @author Jeongho Nam - https://github.com/samchon
391
- */
392
- export function validateStringify<T>(input: T): IValidation<string>;
393
-
394
- /**
395
- * 5x faster `JSON.stringify()` function with detailed type validation.
396
- *
397
- * `typia.json.validateStringify()` is a combination function of {@link validate} and
398
- * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
399
- * Notation) string, with detailed type validation.
400
- *
401
- * In such reason, when `input` value is not matched with the type `T`, it returns
402
- * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
403
- * there's no problem on the `input` value, JSON string would be stored in `data`
404
- * property of the output {@link IValidation.ISuccess} instance.
405
- *
406
- * For reference, with detailed type validation, it is even 5x times faster than the
407
- * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
408
- * conversion with confidence.
409
- *
410
- * @template T Type of the input value
411
- * @param input A value to be checked and converted
412
- * @returns Validation result with JSON string value
413
- *
414
- * @author Jeongho Nam - https://github.com/samchon
415
- */
416
- export function validateStringify<T>(input: unknown): IValidation<string>;
417
-
418
- /**
419
- * @internal
420
- */
421
- export function validateStringify(): IValidation<string> {
422
- halt("validateStringify");
423
- }
424
- Object.assign(validateStringify, Namespace.validate());
425
- Object.assign(validateStringify, Namespace.json.stringify("validateStringify"));
426
-
427
- /* -----------------------------------------------------------
428
- FACTORY FUNCTIONS
429
- ----------------------------------------------------------- */
430
- /**
431
- * Creates a reusable {@link isParse} function.
432
- *
433
- * @danger You must configure the generic argument `T`
434
- * @returns Nothing until you configure the generic argument `T`
435
- * @throws compile error
436
- *
437
- * @author Jeongho Nam - https://github.com/samchon
438
- */
439
- export function createIsParse(): never;
440
-
441
- /**
442
- * Creates a reusable {@link isParse} function.
443
- *
444
- * @template T Expected type of parsed value
445
- * @returns A reusable `isParse` function
446
- *
447
- * @author Jeongho Nam - https://github.com/samchon
448
- */
449
- export function createIsParse<T>(): (input: string) => Primitive<T> | null;
450
-
451
- /**
452
- * @internal
453
- */
454
- export function createIsParse<T>(): (input: string) => Primitive<T> | null {
455
- halt("createIsParse");
456
- }
457
- Object.assign(createIsParse, isParse);
458
-
459
- /**
460
- * Creates a reusable {@link assertParse} function.
461
- *
462
- * @danger You must configure the generic argument `T`
463
- * @returns Nothing until you configure the generic argument `T`
464
- * @throws compile error
465
- *
466
- * @author Jeongho Nam - https://github.com/samchon
467
- */
468
- export function createAssertParse(): never;
469
-
470
- /**
471
- * Creates a reusable {@link assertParse} function.
472
- *
473
- * @template T Expected type of parsed value
474
- * @returns A reusable `assertParse` function
475
- *
476
- * @author Jeongho Nam - https://github.com/samchon
477
- */
478
- export function createAssertParse<T>(): (input: string) => Primitive<T>;
479
-
480
- /**
481
- * @internal
482
- */
483
- export function createAssertParse<T>(): (input: string) => Primitive<T> {
484
- halt("createAssertParse");
485
- }
486
- Object.assign(createAssertParse, assertParse);
487
-
488
- /**
489
- * Creates a reusable {@link validateParse} function.
490
- *
491
- * @danger You must configure the generic argument `T`
492
- * @returns Nothing until you configure the generic argument `T`
493
- * @throws compile error
494
- *
495
- * @author Jeongho Nam - https://github.com/samchon
496
- */
497
- export function createValidateParse(): never;
498
-
499
- /**
500
- * Creates a reusable {@link validateParse} function.
501
- *
502
- * @template T Expected type of parsed value
503
- * @returns A reusable `validateParse` function
504
- *
505
- * @author Jeongho Nam - https://github.com/samchon
506
- */
507
- export function createValidateParse<T>(): (
508
- input: string,
509
- ) => IValidation<Primitive<T>>;
510
-
511
- /**
512
- * @internal
513
- */
514
- export function createValidateParse<T>(): (
515
- input: string,
516
- ) => IValidation<Primitive<T>> {
517
- halt("createValidateParse");
518
- }
519
- Object.assign(createValidateParse, validateParse);
520
-
521
- /**
522
- * Creates a reusable {@link stringify} function.
523
- *
524
- * @danger You must configure the generic argument `T`
525
- * @returns Nothing until you configure the generic argument `T`
526
- * @throws compile error
527
- *
528
- * @author Jeongho Nam - https://github.com/samchon
529
- */
530
- export function createStringify(): never;
531
-
532
- /**
533
- * Creates a reusable {@link stringify} function.
534
- *
535
- * @template T Type of the input value
536
- * @returns A reusable `stringify` function
537
- *
538
- * @author Jeongho Nam - https://github.com/samchon
539
- */
540
- export function createStringify<T>(): (input: T) => string;
541
-
542
- /**
543
- * @internal
544
- */
545
- export function createStringify<T>(): (input: T) => string {
546
- halt("createStringify");
547
- }
548
- Object.assign(createStringify, stringify);
549
-
550
- /**
551
- * Creates a reusable {@link assertStringify} function.
552
- *
553
- * @danger You must configure the generic argument `T`
554
- * @returns Nothing until you configure the generic argument `T`
555
- * @throws compile error
556
- *
557
- * @author Jeongho Nam - https://github.com/samchon
558
- */
559
- export function createAssertStringify(): never;
560
-
561
- /**
562
- * Creates a reusable {@link assertStringify} function.
563
- *
564
- * @template T Type of the input value
565
- * @returns A reusable `assertStringify` function
566
- *
567
- * @author Jeongho Nam - https://github.com/samchon
568
- */
569
- export function createAssertStringify<T>(): (input: unknown) => string;
570
-
571
- /**
572
- * @internal
573
- */
574
- export function createAssertStringify(): (input: unknown) => string {
575
- halt("createAssertStringify");
576
- }
577
- Object.assign(createAssertStringify, assertStringify);
578
-
579
- /**
580
- * Creates a reusable {@link isStringify} function.
581
- *
582
- * @danger You must configure the generic argument `T`
583
- * @returns Nothing until you configure the generic argument `T`
584
- * @throws compile error
585
- *
586
- * @author Jeongho Nam - https://github.com/samchon
587
- */
588
- export function createIsStringify(): never;
589
-
590
- /**
591
- * Creates a reusable {@link isStringify} function.
592
- *
593
- * @template T Type of the input value
594
- * @returns A reusable `isStringify` function
595
- *
596
- * @author Jeongho Nam - https://github.com/samchon
597
- */
598
- export function createIsStringify<T>(): (input: unknown) => string | null;
599
-
600
- /**
601
- * @internal
602
- */
603
- export function createIsStringify(): (input: unknown) => string | null {
604
- halt("createIsStringify");
605
- }
606
- Object.assign(createIsStringify, isStringify);
607
-
608
- /**
609
- * Creates a reusable {@link validateStringify} function.
610
- *
611
- * @danger You must configure the generic argument `T`
612
- * @returns Nothing until you configure the generic argument `T`
613
- * @throws compile error
614
- *
615
- * @author Jeongho Nam - https://github.com/samchon
616
- */
617
- export function createValidateStringify(): never;
618
-
619
- /**
620
- * Creates a reusable {@link validateStringify} function.
621
- *
622
- * @template T Type of the input value
623
- * @returns A reusable `validateStringify` function
624
-
625
- * @author Jeongho Nam - https://github.com/samchon
626
- */
627
- export function createValidateStringify<T>(): (
628
- input: unknown,
629
- ) => IValidation<string>;
630
-
631
- /**
632
- * @internal
633
- */
634
- export function createValidateStringify(): (
635
- input: unknown,
636
- ) => IValidation<string> {
637
- halt("createValidateStringify");
638
- }
639
- Object.assign(createValidateStringify, validateStringify);
640
-
641
- /**
642
- * @internal
643
- */
644
- function halt(name: string): never {
645
- throw new Error(
646
- `Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.json.io/docs/setup please.`,
647
- );
648
- }
1
+ import { Namespace } from "./functional/Namespace";
2
+
3
+ import { IJsonApplication } from "./schemas/json/IJsonApplication";
4
+
5
+ import { IValidation } from "./IValidation";
6
+ import { Primitive } from "./Primitive";
7
+
8
+ /* ===========================================================
9
+ JSON
10
+ - SCHEMA
11
+ - PARSE
12
+ - STRINGIFY
13
+ - FACTORY FUNCTIONS
14
+ ==============================================================
15
+ SCHEMA
16
+ ----------------------------------------------------------- */
17
+ /**
18
+ * > You must configure the generic argument `T`.
19
+ *
20
+ * JSON Schema Application.
21
+ *
22
+ * Creates a JSON schema application which contains both main JSON schemas and
23
+ * components. Note that, all of the object types are stored in the
24
+ * {@link IJsonApplication.components} property for the `$ref` referencing.
25
+ *
26
+ * Also, `typia.json.application()` has additional generic arguments, *Purpose*.
27
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
28
+ * you should configure the *Purpose* appropriately.
29
+ *
30
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
31
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
32
+ * the tuple definition.
33
+ *
34
+ * @template Types Tuple of target types
35
+ * @template Purpose Purpose of the JSON schema`
36
+ * @return JSON schema application
37
+ *
38
+ * @author Jeongho Nam - https://github.com/samchon
39
+ */
40
+ export function application(): never;
41
+
42
+ /**
43
+ * JSON Schema Application.
44
+ *
45
+ * Creates a JSON schema application which contains both main JSON schemas and
46
+ * components. Note that, all of the object types are stored in the
47
+ * {@link IJsonApplication.components} property for the `$ref` referencing.
48
+ *
49
+ * Also, `typia.json.application()` has additional generic arguments, *Purpose*.
50
+ * As JSON schema definitions used by `swagger` and `ajv` are different a little bit,
51
+ * you should configure the *Purpose* appropriately.
52
+ *
53
+ * For an example, `ajv` has an extra property "$recursiveRef" that are not exists
54
+ * in the standard JSON schema definition spec. Otherwise, `swagger` can't identify
55
+ * the tuple definition.
56
+ *
57
+ * @template Types Tuple of target types
58
+ * @template Purpose Purpose of the JSON schema
59
+ * @return JSON schema application
60
+ *
61
+ * @author Jeongho Nam - https://github.com/samchon
62
+ */
63
+ export function application<
64
+ Types extends unknown[],
65
+ Purpose extends "ajv" | "swagger" = "swagger",
66
+ >(): IJsonApplication;
67
+
68
+ /**
69
+ * @internal
70
+ */
71
+ export function application(): never {
72
+ halt("application");
73
+ }
74
+
75
+ /* -----------------------------------------------------------
76
+ PARSE
77
+ ----------------------------------------------------------- */
78
+ /**
79
+ * > You must configure the generic argument `T`.
80
+ *
81
+ * Safe `JSON.parse()` function with type assertion.
82
+ *
83
+ * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
84
+ * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
85
+ * to a `T` typed instance with type assertion.
86
+ *
87
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
88
+ * throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed value,
89
+ * the parsed value would be returned.
90
+ *
91
+ * @template T Expected type of parsed value
92
+ * @param input JSON string
93
+ * @returns Parsed value
94
+ *
95
+ * @author Jeongho Nam - https://github.com/samchon
96
+ */
97
+ export function assertParse(input: string): never;
98
+
99
+ /**
100
+ * Safe `JSON.parse()` function with type assertion.
101
+ *
102
+ * `typia.json.assertParse()` is a combination function of `JSON.parse()` and
103
+ * {@link assert}. Therefore, it convers a JSON (JavaScript Object Notation) string
104
+ * to a `T` typed instance with type assertion.
105
+ *
106
+ * In such reason, when parsed JSON string value is not matched with the type `T`,
107
+ * it throws {@link TypeGuardError}. Otherwise, there's no problem on the parsed
108
+ * value, the parsed value would be returned.
109
+ *
110
+ * @template T Expected type of parsed value
111
+ * @param input JSON string
112
+ * @returns Parsed value
113
+ *
114
+ * @author Jeongho Nam - https://github.com/samchon
115
+ */
116
+ export function assertParse<T>(input: string): Primitive<T>;
117
+
118
+ /**
119
+ * @internal
120
+ */
121
+ export function assertParse<T>(): Primitive<T> {
122
+ halt("assertParse");
123
+ }
124
+ Object.assign(assertParse, Namespace.assert("assertParse"));
125
+
126
+ /**
127
+ * > You must configure the generic argument `T`.
128
+ *
129
+ * Safe `JSON.parse()` function with type checking.
130
+ *
131
+ * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
132
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
133
+ * instance with type checking.
134
+ *
135
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
136
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
137
+ * value would be returned.
138
+ *
139
+ * @template T Expected type of parsed value
140
+ * @param input JSON string
141
+ * @returns Parsed value when exact type, otherwise `null`
142
+ *
143
+ * @author Jeongho Nam - https://github.com/samchon
144
+ */
145
+ export function isParse(input: string): never;
146
+
147
+ /**
148
+ * Safe `JSON.parse()` function with type checking.
149
+ *
150
+ * `typia.json.isParse()` is a combination function of `JSON.parse()` and {@link is}.
151
+ * Therefore, it convers a JSON (JavaScript Object Notation) string to a `T` typed
152
+ * instance with type checking.
153
+ *
154
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
155
+ * returns `null` value. Otherwise, there's no problem on the parsed value, the parsed
156
+ * value would be returned.
157
+ *
158
+ * @template T Expected type of parsed value
159
+ * @param input JSON string
160
+ * @returns Parsed value when exact type, otherwise `null`
161
+ *
162
+ * @author Jeongho Nam - https://github.com/samchon
163
+ */
164
+ export function isParse<T>(input: string): Primitive<T> | null;
165
+
166
+ /**
167
+ * @internal
168
+ */
169
+ export function isParse<T>(): Primitive<T> | null {
170
+ halt("isParse");
171
+ }
172
+ Object.assign(isParse, Namespace.is());
173
+
174
+ /**
175
+ * > You must configure the generic argument `T`.
176
+ *
177
+ * Safe `JSON.parse()` function with detailed type validation.
178
+ *
179
+ * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
180
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
181
+ * to a `T` typed instance with detailed type validation.
182
+ *
183
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
184
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
185
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
186
+ * property of the output {@link IValidation.ISuccess} instance.
187
+ *
188
+ * @template T Expected type of parsed value
189
+ * @param input JSON string
190
+ * @returns Validation result with JSON parsed value
191
+ *
192
+ * @author Jeongho Nam - https://github.com/samchon
193
+ */
194
+ export function validateParse(input: string): never;
195
+
196
+ /**
197
+ * Safe `JSON.parse()` function with detailed type validation.
198
+ *
199
+ * `typia.json.validateParse()` is a combination function of `JSON.parse()` and
200
+ * {@link validate}. Therefore, it convers a JSON (JavaScript Object Notation) string
201
+ * to a `T` typed instance with detailed type validation.
202
+ *
203
+ * In such reason, when parsed JSON string value is not matched with the type `T`, it
204
+ * returns {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
205
+ * there's no problem on the parsed value, the parsed value would be stored in `data`
206
+ * property of the output {@link IValidation.ISuccess} instance.
207
+ *
208
+ * @template T Expected type of parsed value
209
+ * @param input JSON string
210
+ * @returns Validation result with JSON parsed value
211
+ *
212
+ * @author Jeongho Nam - https://github.com/samchon
213
+ */
214
+ export function validateParse<T>(input: string): IValidation<Primitive<T>>;
215
+
216
+ /**
217
+ * @internal
218
+ */
219
+ export function validateParse<T>(): IValidation<Primitive<T>> {
220
+ halt("validateParse");
221
+ }
222
+ Object.assign(validateParse, Namespace.validate());
223
+
224
+ /* -----------------------------------------------------------
225
+ STRINGIFY
226
+ ----------------------------------------------------------- */
227
+ /**
228
+ * 8x faster `JSON.stringify()` function.
229
+ *
230
+ * Converts an input value to a JSON (JavaScript Object Notation) string, about 8x
231
+ * faster than the native `JSON.stringify()` function. The 5x faster principle is
232
+ * because it writes an optimized JSON conversion plan, only for the type `T`.
233
+ *
234
+ * For reference, this `typia.json.stringify()` does not validate the input value type.
235
+ * It just believes that the input value is following the type `T`. Therefore, if you
236
+ * can't ensure the input value type, it would be better to call one of below
237
+ * functions instead.
238
+ *
239
+ * - {@link assertStringify}
240
+ * - {@link isStringify}
241
+ * - {@link validateStringify}
242
+ *
243
+ * @template T Type of the input value
244
+ * @param input A value to be converted
245
+ * @return JSON string value
246
+ *
247
+ * @author Jeongho Nam - https://github.com/samchon
248
+ */
249
+ export function stringify<T>(input: T): string;
250
+
251
+ /**
252
+ * @internal
253
+ */
254
+ export function stringify(): never {
255
+ halt("stringify");
256
+ }
257
+ Object.assign(stringify, Namespace.json.stringify("stringify"));
258
+
259
+ /**
260
+ * 5x faster `JSON.stringify()` function with type assertion.
261
+ *
262
+ * `typia.json.assertStringify()` is a combination function of {@link assert} and
263
+ * {@link stringify}. Therefore, it converts an input value to
264
+ * JSON (JavaScript Object Notation) string, with type assertion.
265
+ *
266
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
267
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
268
+ * string would be returned.
269
+ *
270
+ * For reference, with type assertion, it is even 5x times faster than the native
271
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
272
+ * with confidence.
273
+ *
274
+ * @template T Type of the input value
275
+ * @param input A value to be asserted and converted
276
+ * @return JSON string value
277
+ *
278
+ * @author Jeongho Nam - https://github.com/samchon
279
+ */
280
+ export function assertStringify<T>(input: T): string;
281
+
282
+ /**
283
+ * 5x faster `JSON.stringify()` function with type assertion.
284
+ *
285
+ * `typia.json.assertStringify()` is a combination function of {@link assert} and
286
+ * {@link stringify}. Therefore, it converts an input value to
287
+ * JSON (JavaScript Object Notation) string, with type assertion.
288
+ *
289
+ * In such reason, when `input` value is not matched with the type `T`, it throws an
290
+ * {@link TypeGuardError}. Otherwise, there's no problem on the `input` value, JSON
291
+ * string would be returned.
292
+ *
293
+ * For reference, with type assertion, it is even 5x times faster than the native
294
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
295
+ * with confidence.
296
+ *
297
+ * @template T Type of the input value
298
+ * @param input A value to be asserted and converted
299
+ * @return JSON string value
300
+ *
301
+ * @author Jeongho Nam - https://github.com/samchon
302
+ */
303
+ export function assertStringify<T>(input: T): unknown;
304
+
305
+ /**
306
+ * @internal
307
+ */
308
+ export function assertStringify(): string {
309
+ halt("assertStringify");
310
+ }
311
+ Object.assign(assertStringify, Namespace.assert("assertStringify"));
312
+ Object.assign(assertStringify, Namespace.json.stringify("assertStringify"));
313
+
314
+ /**
315
+ * 7x faster `JSON.stringify()` function with type checking.
316
+ *
317
+ * `typia.json.stringify()` is a combination function of {@link is} and
318
+ * {@link stringify}. Therefore, it converts an input value to JSON
319
+ * (JavaScript Object Notation) string, with type checking.
320
+ *
321
+ * In such reason, when `input` value is not matched with the type `T`, it returns
322
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string
323
+ * would be returned.
324
+ *
325
+ * For reference, with type checking, it is even 7x times faster than the native
326
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
327
+ * with confidence.
328
+ *
329
+ * @template T Type of the input value
330
+ * @param input A value to be checked and converted
331
+ * @return JSON string value when exact type, otherwise null
332
+ *
333
+ * @author Jeongho Nam - https://github.com/samchon
334
+ */
335
+ export function isStringify<T>(input: T): string | null;
336
+
337
+ /**
338
+ * 7x faster `JSON.stringify()` function with type checking.
339
+ *
340
+ * `typia.json.isStringify()` is a combination function of {@link is} and
341
+ * {@link stringify}. Therefore, it converts an input value to JSON
342
+ * (JavaScript Object Notation) string, with type checking.
343
+ *
344
+ * In such reason, when `input` value is not matched with the type `T`, it returns
345
+ * `null` value. Otherwise, there's no problem on the `input` value, JSON string
346
+ * would be returned.
347
+ *
348
+ * For reference, with type checking, it is even 7x times faster than the native
349
+ * `JSON.stringify()` function. So, just enjoy the safe and fast JSON conversion
350
+ * with confidence.
351
+ *
352
+ * @template T Type of the input value
353
+ * @param input A value to be checked and converted
354
+ * @return JSON string value when exact type, otherwise null
355
+ *
356
+ * @author Jeongho Nam - https://github.com/samchon
357
+ */
358
+ export function isStringify<T>(input: unknown): string | null;
359
+
360
+ /**
361
+ * @internal
362
+ */
363
+ export function isStringify(): string | null {
364
+ halt("isStringify");
365
+ }
366
+
367
+ Object.assign(isStringify, Namespace.is());
368
+ Object.assign(isStringify, Namespace.json.stringify("isStringify"));
369
+
370
+ /**
371
+ * 5x faster `JSON.stringify()` function with detailed type validation.
372
+ *
373
+ * `typia.json.validateStringify()` is a combination function of {@link validate} and
374
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
375
+ * Notation) string, with detailed type validation.
376
+ *
377
+ * In such reason, when `input` value is not matched with the type `T`, it returns
378
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
379
+ * there's no problem on the `input` value, JSON string would be stored in `data`
380
+ * property of the output {@link IValidation.ISuccess} instance.
381
+ *
382
+ * For reference, with detailed type validation, it is even 5x times faster than the
383
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
384
+ * conversion with confidence.
385
+ *
386
+ * @template T Type of the input value
387
+ * @param input A value to be checked and converted
388
+ * @returns Validation result with JSON string value
389
+ *
390
+ * @author Jeongho Nam - https://github.com/samchon
391
+ */
392
+ export function validateStringify<T>(input: T): IValidation<string>;
393
+
394
+ /**
395
+ * 5x faster `JSON.stringify()` function with detailed type validation.
396
+ *
397
+ * `typia.json.validateStringify()` is a combination function of {@link validate} and
398
+ * {@link stringify}. Therefore, it converts an input value to JSON (JavaScript Object
399
+ * Notation) string, with detailed type validation.
400
+ *
401
+ * In such reason, when `input` value is not matched with the type `T`, it returns
402
+ * {@link IValidation.IFailure} value with detailed error reasons. Otherwise,
403
+ * there's no problem on the `input` value, JSON string would be stored in `data`
404
+ * property of the output {@link IValidation.ISuccess} instance.
405
+ *
406
+ * For reference, with detailed type validation, it is even 5x times faster than the
407
+ * native `JSON.stringify()` function. So, just enjoy the safe and fast JSON
408
+ * conversion with confidence.
409
+ *
410
+ * @template T Type of the input value
411
+ * @param input A value to be checked and converted
412
+ * @returns Validation result with JSON string value
413
+ *
414
+ * @author Jeongho Nam - https://github.com/samchon
415
+ */
416
+ export function validateStringify<T>(input: unknown): IValidation<string>;
417
+
418
+ /**
419
+ * @internal
420
+ */
421
+ export function validateStringify(): IValidation<string> {
422
+ halt("validateStringify");
423
+ }
424
+ Object.assign(validateStringify, Namespace.validate());
425
+ Object.assign(validateStringify, Namespace.json.stringify("validateStringify"));
426
+
427
+ /* -----------------------------------------------------------
428
+ FACTORY FUNCTIONS
429
+ ----------------------------------------------------------- */
430
+ /**
431
+ * Creates a reusable {@link isParse} function.
432
+ *
433
+ * @danger You must configure the generic argument `T`
434
+ * @returns Nothing until you configure the generic argument `T`
435
+ * @throws compile error
436
+ *
437
+ * @author Jeongho Nam - https://github.com/samchon
438
+ */
439
+ export function createIsParse(): never;
440
+
441
+ /**
442
+ * Creates a reusable {@link isParse} function.
443
+ *
444
+ * @template T Expected type of parsed value
445
+ * @returns A reusable `isParse` function
446
+ *
447
+ * @author Jeongho Nam - https://github.com/samchon
448
+ */
449
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null;
450
+
451
+ /**
452
+ * @internal
453
+ */
454
+ export function createIsParse<T>(): (input: string) => Primitive<T> | null {
455
+ halt("createIsParse");
456
+ }
457
+ Object.assign(createIsParse, isParse);
458
+
459
+ /**
460
+ * Creates a reusable {@link assertParse} function.
461
+ *
462
+ * @danger You must configure the generic argument `T`
463
+ * @returns Nothing until you configure the generic argument `T`
464
+ * @throws compile error
465
+ *
466
+ * @author Jeongho Nam - https://github.com/samchon
467
+ */
468
+ export function createAssertParse(): never;
469
+
470
+ /**
471
+ * Creates a reusable {@link assertParse} function.
472
+ *
473
+ * @template T Expected type of parsed value
474
+ * @returns A reusable `assertParse` function
475
+ *
476
+ * @author Jeongho Nam - https://github.com/samchon
477
+ */
478
+ export function createAssertParse<T>(): (input: string) => Primitive<T>;
479
+
480
+ /**
481
+ * @internal
482
+ */
483
+ export function createAssertParse<T>(): (input: string) => Primitive<T> {
484
+ halt("createAssertParse");
485
+ }
486
+ Object.assign(createAssertParse, assertParse);
487
+
488
+ /**
489
+ * Creates a reusable {@link validateParse} function.
490
+ *
491
+ * @danger You must configure the generic argument `T`
492
+ * @returns Nothing until you configure the generic argument `T`
493
+ * @throws compile error
494
+ *
495
+ * @author Jeongho Nam - https://github.com/samchon
496
+ */
497
+ export function createValidateParse(): never;
498
+
499
+ /**
500
+ * Creates a reusable {@link validateParse} function.
501
+ *
502
+ * @template T Expected type of parsed value
503
+ * @returns A reusable `validateParse` function
504
+ *
505
+ * @author Jeongho Nam - https://github.com/samchon
506
+ */
507
+ export function createValidateParse<T>(): (
508
+ input: string,
509
+ ) => IValidation<Primitive<T>>;
510
+
511
+ /**
512
+ * @internal
513
+ */
514
+ export function createValidateParse<T>(): (
515
+ input: string,
516
+ ) => IValidation<Primitive<T>> {
517
+ halt("createValidateParse");
518
+ }
519
+ Object.assign(createValidateParse, validateParse);
520
+
521
+ /**
522
+ * Creates a reusable {@link stringify} function.
523
+ *
524
+ * @danger You must configure the generic argument `T`
525
+ * @returns Nothing until you configure the generic argument `T`
526
+ * @throws compile error
527
+ *
528
+ * @author Jeongho Nam - https://github.com/samchon
529
+ */
530
+ export function createStringify(): never;
531
+
532
+ /**
533
+ * Creates a reusable {@link stringify} function.
534
+ *
535
+ * @template T Type of the input value
536
+ * @returns A reusable `stringify` function
537
+ *
538
+ * @author Jeongho Nam - https://github.com/samchon
539
+ */
540
+ export function createStringify<T>(): (input: T) => string;
541
+
542
+ /**
543
+ * @internal
544
+ */
545
+ export function createStringify<T>(): (input: T) => string {
546
+ halt("createStringify");
547
+ }
548
+ Object.assign(createStringify, stringify);
549
+
550
+ /**
551
+ * Creates a reusable {@link assertStringify} function.
552
+ *
553
+ * @danger You must configure the generic argument `T`
554
+ * @returns Nothing until you configure the generic argument `T`
555
+ * @throws compile error
556
+ *
557
+ * @author Jeongho Nam - https://github.com/samchon
558
+ */
559
+ export function createAssertStringify(): never;
560
+
561
+ /**
562
+ * Creates a reusable {@link assertStringify} function.
563
+ *
564
+ * @template T Type of the input value
565
+ * @returns A reusable `assertStringify` function
566
+ *
567
+ * @author Jeongho Nam - https://github.com/samchon
568
+ */
569
+ export function createAssertStringify<T>(): (input: unknown) => string;
570
+
571
+ /**
572
+ * @internal
573
+ */
574
+ export function createAssertStringify(): (input: unknown) => string {
575
+ halt("createAssertStringify");
576
+ }
577
+ Object.assign(createAssertStringify, assertStringify);
578
+
579
+ /**
580
+ * Creates a reusable {@link isStringify} function.
581
+ *
582
+ * @danger You must configure the generic argument `T`
583
+ * @returns Nothing until you configure the generic argument `T`
584
+ * @throws compile error
585
+ *
586
+ * @author Jeongho Nam - https://github.com/samchon
587
+ */
588
+ export function createIsStringify(): never;
589
+
590
+ /**
591
+ * Creates a reusable {@link isStringify} function.
592
+ *
593
+ * @template T Type of the input value
594
+ * @returns A reusable `isStringify` function
595
+ *
596
+ * @author Jeongho Nam - https://github.com/samchon
597
+ */
598
+ export function createIsStringify<T>(): (input: unknown) => string | null;
599
+
600
+ /**
601
+ * @internal
602
+ */
603
+ export function createIsStringify(): (input: unknown) => string | null {
604
+ halt("createIsStringify");
605
+ }
606
+ Object.assign(createIsStringify, isStringify);
607
+
608
+ /**
609
+ * Creates a reusable {@link validateStringify} function.
610
+ *
611
+ * @danger You must configure the generic argument `T`
612
+ * @returns Nothing until you configure the generic argument `T`
613
+ * @throws compile error
614
+ *
615
+ * @author Jeongho Nam - https://github.com/samchon
616
+ */
617
+ export function createValidateStringify(): never;
618
+
619
+ /**
620
+ * Creates a reusable {@link validateStringify} function.
621
+ *
622
+ * @template T Type of the input value
623
+ * @returns A reusable `validateStringify` function
624
+
625
+ * @author Jeongho Nam - https://github.com/samchon
626
+ */
627
+ export function createValidateStringify<T>(): (
628
+ input: unknown,
629
+ ) => IValidation<string>;
630
+
631
+ /**
632
+ * @internal
633
+ */
634
+ export function createValidateStringify(): (
635
+ input: unknown,
636
+ ) => IValidation<string> {
637
+ halt("createValidateStringify");
638
+ }
639
+ Object.assign(createValidateStringify, validateStringify);
640
+
641
+ /**
642
+ * @internal
643
+ */
644
+ function halt(name: string): never {
645
+ throw new Error(
646
+ `Error on typia.json.${name}(): no transform has been configured. Read and follow https://typia.json.io/docs/setup please.`,
647
+ );
648
+ }