typia 3.3.12

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 (341) hide show
  1. package/CODE_OF_CONDUCT.md +133 -0
  2. package/CONTRIBUTING.md +104 -0
  3. package/LICENSE +21 -0
  4. package/README.md +572 -0
  5. package/lib/IValidation.d.ts +11 -0
  6. package/lib/IValidation.js +3 -0
  7. package/lib/IValidation.js.map +1 -0
  8. package/lib/TypeGuardError.d.ts +16 -0
  9. package/lib/TypeGuardError.js +39 -0
  10. package/lib/TypeGuardError.js.map +1 -0
  11. package/lib/factories/CommentFactory.d.ts +4 -0
  12. package/lib/factories/CommentFactory.js +14 -0
  13. package/lib/factories/CommentFactory.js.map +1 -0
  14. package/lib/factories/ExpressionFactory.d.ts +6 -0
  15. package/lib/factories/ExpressionFactory.js +30 -0
  16. package/lib/factories/ExpressionFactory.js.map +1 -0
  17. package/lib/factories/IdentifierFactory.d.ts +7 -0
  18. package/lib/factories/IdentifierFactory.js +35 -0
  19. package/lib/factories/IdentifierFactory.js.map +1 -0
  20. package/lib/factories/LiteralFactory.d.ts +4 -0
  21. package/lib/factories/LiteralFactory.js +67 -0
  22. package/lib/factories/LiteralFactory.js.map +1 -0
  23. package/lib/factories/MetadataCollection.d.ts +20 -0
  24. package/lib/factories/MetadataCollection.js +141 -0
  25. package/lib/factories/MetadataCollection.js.map +1 -0
  26. package/lib/factories/MetadataFactory.d.ts +10 -0
  27. package/lib/factories/MetadataFactory.js +47 -0
  28. package/lib/factories/MetadataFactory.js.map +1 -0
  29. package/lib/factories/MetadataTagFactory.d.ts +6 -0
  30. package/lib/factories/MetadataTagFactory.js +317 -0
  31. package/lib/factories/MetadataTagFactory.js.map +1 -0
  32. package/lib/factories/StatementFactory.d.ts +7 -0
  33. package/lib/factories/StatementFactory.js +31 -0
  34. package/lib/factories/StatementFactory.js.map +1 -0
  35. package/lib/factories/TemplateFactory.d.ts +4 -0
  36. package/lib/factories/TemplateFactory.js +41 -0
  37. package/lib/factories/TemplateFactory.js.map +1 -0
  38. package/lib/factories/TypeFactory.d.ts +6 -0
  39. package/lib/factories/TypeFactory.js +71 -0
  40. package/lib/factories/TypeFactory.js.map +1 -0
  41. package/lib/factories/ValueFactory.d.ts +8 -0
  42. package/lib/factories/ValueFactory.js +23 -0
  43. package/lib/factories/ValueFactory.js.map +1 -0
  44. package/lib/factories/internal/MetadataHelper.d.ts +4 -0
  45. package/lib/factories/internal/MetadataHelper.js +17 -0
  46. package/lib/factories/internal/MetadataHelper.js.map +1 -0
  47. package/lib/factories/internal/emplace_metadata_object.d.ts +5 -0
  48. package/lib/factories/internal/emplace_metadata_object.js +149 -0
  49. package/lib/factories/internal/emplace_metadata_object.js.map +1 -0
  50. package/lib/factories/internal/explore_metadata.d.ts +5 -0
  51. package/lib/factories/internal/explore_metadata.js +88 -0
  52. package/lib/factories/internal/explore_metadata.js.map +1 -0
  53. package/lib/factories/internal/iterate_metadata.d.ts +5 -0
  54. package/lib/factories/internal/iterate_metadata.js +37 -0
  55. package/lib/factories/internal/iterate_metadata.js.map +1 -0
  56. package/lib/factories/internal/iterate_metadata_array.d.ts +5 -0
  57. package/lib/factories/internal/iterate_metadata_array.js +22 -0
  58. package/lib/factories/internal/iterate_metadata_array.js.map +1 -0
  59. package/lib/factories/internal/iterate_metadata_atomic.d.ts +3 -0
  60. package/lib/factories/internal/iterate_metadata_atomic.js +73 -0
  61. package/lib/factories/internal/iterate_metadata_atomic.js.map +1 -0
  62. package/lib/factories/internal/iterate_metadata_coalesce.d.ts +3 -0
  63. package/lib/factories/internal/iterate_metadata_coalesce.js +35 -0
  64. package/lib/factories/internal/iterate_metadata_coalesce.js.map +1 -0
  65. package/lib/factories/internal/iterate_metadata_constant.d.ts +4 -0
  66. package/lib/factories/internal/iterate_metadata_constant.js +40 -0
  67. package/lib/factories/internal/iterate_metadata_constant.js.map +1 -0
  68. package/lib/factories/internal/iterate_metadata_object.d.ts +5 -0
  69. package/lib/factories/internal/iterate_metadata_object.js +38 -0
  70. package/lib/factories/internal/iterate_metadata_object.js.map +1 -0
  71. package/lib/factories/internal/iterate_metadata_resolve.d.ts +5 -0
  72. package/lib/factories/internal/iterate_metadata_resolve.js +24 -0
  73. package/lib/factories/internal/iterate_metadata_resolve.js.map +1 -0
  74. package/lib/factories/internal/iterate_metadata_template.d.ts +5 -0
  75. package/lib/factories/internal/iterate_metadata_template.js +33 -0
  76. package/lib/factories/internal/iterate_metadata_template.js.map +1 -0
  77. package/lib/factories/internal/iterate_metadata_tuple.d.ts +5 -0
  78. package/lib/factories/internal/iterate_metadata_tuple.js +27 -0
  79. package/lib/factories/internal/iterate_metadata_tuple.js.map +1 -0
  80. package/lib/factories/internal/iterate_metadata_union.d.ts +5 -0
  81. package/lib/factories/internal/iterate_metadata_union.js +82 -0
  82. package/lib/factories/internal/iterate_metadata_union.js.map +1 -0
  83. package/lib/functional/$is_email.d.ts +1 -0
  84. package/lib/functional/$is_email.js +9 -0
  85. package/lib/functional/$is_email.js.map +1 -0
  86. package/lib/functional/$is_ipv4.d.ts +1 -0
  87. package/lib/functional/$is_ipv4.js +9 -0
  88. package/lib/functional/$is_ipv4.js.map +1 -0
  89. package/lib/functional/$is_ipv6.d.ts +1 -0
  90. package/lib/functional/$is_ipv6.js +9 -0
  91. package/lib/functional/$is_ipv6.js.map +1 -0
  92. package/lib/functional/$is_url.d.ts +1 -0
  93. package/lib/functional/$is_url.js +9 -0
  94. package/lib/functional/$is_url.js.map +1 -0
  95. package/lib/functional/$is_uuid.d.ts +1 -0
  96. package/lib/functional/$is_uuid.js +9 -0
  97. package/lib/functional/$is_uuid.js.map +1 -0
  98. package/lib/functional/$join.d.ts +1 -0
  99. package/lib/functional/$join.js +52 -0
  100. package/lib/functional/$join.js.map +1 -0
  101. package/lib/functional/$number.d.ts +1 -0
  102. package/lib/functional/$number.js +23 -0
  103. package/lib/functional/$number.js.map +1 -0
  104. package/lib/functional/$string.d.ts +1 -0
  105. package/lib/functional/$string.js +36 -0
  106. package/lib/functional/$string.js.map +1 -0
  107. package/lib/functional/$tail.d.ts +1 -0
  108. package/lib/functional/$tail.js +8 -0
  109. package/lib/functional/$tail.js.map +1 -0
  110. package/lib/index.d.ts +3 -0
  111. package/lib/index.js +32 -0
  112. package/lib/index.js.map +1 -0
  113. package/lib/metadata/IJsDocTagInfo.d.ts +10 -0
  114. package/lib/metadata/IJsDocTagInfo.js +3 -0
  115. package/lib/metadata/IJsDocTagInfo.js.map +1 -0
  116. package/lib/metadata/IMetadata.d.ts +15 -0
  117. package/lib/metadata/IMetadata.js +3 -0
  118. package/lib/metadata/IMetadata.js.map +1 -0
  119. package/lib/metadata/IMetadataConstant.d.ts +8 -0
  120. package/lib/metadata/IMetadataConstant.js +3 -0
  121. package/lib/metadata/IMetadataConstant.js.map +1 -0
  122. package/lib/metadata/IMetadataObject.d.ts +8 -0
  123. package/lib/metadata/IMetadataObject.js +3 -0
  124. package/lib/metadata/IMetadataObject.js.map +1 -0
  125. package/lib/metadata/IMetadataProperty.d.ts +10 -0
  126. package/lib/metadata/IMetadataProperty.js +3 -0
  127. package/lib/metadata/IMetadataProperty.js.map +1 -0
  128. package/lib/metadata/IMetadataTag.d.ts +74 -0
  129. package/lib/metadata/IMetadataTag.js +3 -0
  130. package/lib/metadata/IMetadataTag.js.map +1 -0
  131. package/lib/metadata/Metadata.d.ts +33 -0
  132. package/lib/metadata/Metadata.js +568 -0
  133. package/lib/metadata/Metadata.js.map +1 -0
  134. package/lib/metadata/MetadataConstant.d.ts +2 -0
  135. package/lib/metadata/MetadataConstant.js +3 -0
  136. package/lib/metadata/MetadataConstant.js.map +1 -0
  137. package/lib/metadata/MetadataObject.d.ts +15 -0
  138. package/lib/metadata/MetadataObject.js +64 -0
  139. package/lib/metadata/MetadataObject.js.map +1 -0
  140. package/lib/metadata/MetadataProperty.d.ts +16 -0
  141. package/lib/metadata/MetadataProperty.js +37 -0
  142. package/lib/metadata/MetadataProperty.js.map +1 -0
  143. package/lib/module.d.ts +382 -0
  144. package/lib/module.js +187 -0
  145. package/lib/module.js.map +1 -0
  146. package/lib/programmers/ApplicationProgrammer.d.ts +11 -0
  147. package/lib/programmers/ApplicationProgrammer.js +48 -0
  148. package/lib/programmers/ApplicationProgrammer.js.map +1 -0
  149. package/lib/programmers/AssertProgrammer.d.ts +5 -0
  150. package/lib/programmers/AssertProgrammer.js +79 -0
  151. package/lib/programmers/AssertProgrammer.js.map +1 -0
  152. package/lib/programmers/CheckerProgrammer.d.ts +41 -0
  153. package/lib/programmers/CheckerProgrammer.js +279 -0
  154. package/lib/programmers/CheckerProgrammer.js.map +1 -0
  155. package/lib/programmers/FeatureProgrammer.d.ts +53 -0
  156. package/lib/programmers/FeatureProgrammer.js +211 -0
  157. package/lib/programmers/FeatureProgrammer.js.map +1 -0
  158. package/lib/programmers/IsProgrammer.d.ts +21 -0
  159. package/lib/programmers/IsProgrammer.js +78 -0
  160. package/lib/programmers/IsProgrammer.js.map +1 -0
  161. package/lib/programmers/StringifyProgrammer.d.ts +5 -0
  162. package/lib/programmers/StringifyProgrammer.js +433 -0
  163. package/lib/programmers/StringifyProgrammer.js.map +1 -0
  164. package/lib/programmers/ValidateProgrammer.d.ts +5 -0
  165. package/lib/programmers/ValidateProgrammer.js +96 -0
  166. package/lib/programmers/ValidateProgrammer.js.map +1 -0
  167. package/lib/programmers/helpers/FunctionImporeter.d.ts +9 -0
  168. package/lib/programmers/helpers/FunctionImporeter.js +58 -0
  169. package/lib/programmers/helpers/FunctionImporeter.js.map +1 -0
  170. package/lib/programmers/helpers/IExpressionEntry.d.ts +8 -0
  171. package/lib/programmers/helpers/IExpressionEntry.js +3 -0
  172. package/lib/programmers/helpers/IExpressionEntry.js.map +1 -0
  173. package/lib/programmers/helpers/OptionPredicator.d.ts +5 -0
  174. package/lib/programmers/helpers/OptionPredicator.js +17 -0
  175. package/lib/programmers/helpers/OptionPredicator.js.map +1 -0
  176. package/lib/programmers/helpers/StringifyJoinder.d.ts +8 -0
  177. package/lib/programmers/helpers/StringifyJoinder.js +95 -0
  178. package/lib/programmers/helpers/StringifyJoinder.js.map +1 -0
  179. package/lib/programmers/helpers/StringifyPredicator.d.ts +5 -0
  180. package/lib/programmers/helpers/StringifyPredicator.js +19 -0
  181. package/lib/programmers/helpers/StringifyPredicator.js.map +1 -0
  182. package/lib/programmers/helpers/UnionExplorer.d.ts +13 -0
  183. package/lib/programmers/helpers/UnionExplorer.js +117 -0
  184. package/lib/programmers/helpers/UnionExplorer.js.map +1 -0
  185. package/lib/programmers/helpers/UnionPredicator.d.ts +11 -0
  186. package/lib/programmers/helpers/UnionPredicator.js +111 -0
  187. package/lib/programmers/helpers/UnionPredicator.js.map +1 -0
  188. package/lib/programmers/internal/application_array.d.ts +1 -0
  189. package/lib/programmers/internal/application_array.js +63 -0
  190. package/lib/programmers/internal/application_array.js.map +1 -0
  191. package/lib/programmers/internal/application_boolean.d.ts +1 -0
  192. package/lib/programmers/internal/application_boolean.js +18 -0
  193. package/lib/programmers/internal/application_boolean.js.map +1 -0
  194. package/lib/programmers/internal/application_constant.d.ts +1 -0
  195. package/lib/programmers/internal/application_constant.js +26 -0
  196. package/lib/programmers/internal/application_constant.js.map +1 -0
  197. package/lib/programmers/internal/application_default.d.ts +1 -0
  198. package/lib/programmers/internal/application_default.js +40 -0
  199. package/lib/programmers/internal/application_default.js.map +1 -0
  200. package/lib/programmers/internal/application_default_string.d.ts +1 -0
  201. package/lib/programmers/internal/application_default_string.js +61 -0
  202. package/lib/programmers/internal/application_default_string.js.map +1 -0
  203. package/lib/programmers/internal/application_number.d.ts +1 -0
  204. package/lib/programmers/internal/application_number.js +86 -0
  205. package/lib/programmers/internal/application_number.js.map +1 -0
  206. package/lib/programmers/internal/application_object.d.ts +1 -0
  207. package/lib/programmers/internal/application_object.js +96 -0
  208. package/lib/programmers/internal/application_object.js.map +1 -0
  209. package/lib/programmers/internal/application_schema.d.ts +1 -0
  210. package/lib/programmers/internal/application_schema.js +246 -0
  211. package/lib/programmers/internal/application_schema.js.map +1 -0
  212. package/lib/programmers/internal/application_string.d.ts +1 -0
  213. package/lib/programmers/internal/application_string.js +66 -0
  214. package/lib/programmers/internal/application_string.js.map +1 -0
  215. package/lib/programmers/internal/application_templates.d.ts +1 -0
  216. package/lib/programmers/internal/application_templates.js +24 -0
  217. package/lib/programmers/internal/application_templates.js.map +1 -0
  218. package/lib/programmers/internal/application_tuple.d.ts +1 -0
  219. package/lib/programmers/internal/application_tuple.js +24 -0
  220. package/lib/programmers/internal/application_tuple.js.map +1 -0
  221. package/lib/programmers/internal/check_array.d.ts +1 -0
  222. package/lib/programmers/internal/check_array.js +52 -0
  223. package/lib/programmers/internal/check_array.js.map +1 -0
  224. package/lib/programmers/internal/check_dynamic_properties.d.ts +1 -0
  225. package/lib/programmers/internal/check_dynamic_properties.js +111 -0
  226. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -0
  227. package/lib/programmers/internal/check_everything.d.ts +1 -0
  228. package/lib/programmers/internal/check_everything.js +17 -0
  229. package/lib/programmers/internal/check_everything.js.map +1 -0
  230. package/lib/programmers/internal/check_length.d.ts +1 -0
  231. package/lib/programmers/internal/check_length.js +28 -0
  232. package/lib/programmers/internal/check_length.js.map +1 -0
  233. package/lib/programmers/internal/check_number.d.ts +1 -0
  234. package/lib/programmers/internal/check_number.js +124 -0
  235. package/lib/programmers/internal/check_number.js.map +1 -0
  236. package/lib/programmers/internal/check_object.d.ts +1 -0
  237. package/lib/programmers/internal/check_object.js +35 -0
  238. package/lib/programmers/internal/check_object.js.map +1 -0
  239. package/lib/programmers/internal/check_string.d.ts +1 -0
  240. package/lib/programmers/internal/check_string.js +45 -0
  241. package/lib/programmers/internal/check_string.js.map +1 -0
  242. package/lib/programmers/internal/check_string_tags.d.ts +1 -0
  243. package/lib/programmers/internal/check_string_tags.js +51 -0
  244. package/lib/programmers/internal/check_string_tags.js.map +1 -0
  245. package/lib/programmers/internal/check_template.d.ts +1 -0
  246. package/lib/programmers/internal/check_template.js +50 -0
  247. package/lib/programmers/internal/check_template.js.map +1 -0
  248. package/lib/programmers/internal/decode_union_object.d.ts +1 -0
  249. package/lib/programmers/internal/decode_union_object.js +56 -0
  250. package/lib/programmers/internal/decode_union_object.js.map +1 -0
  251. package/lib/programmers/internal/metadata_to_pattern.d.ts +2 -0
  252. package/lib/programmers/internal/metadata_to_pattern.js +62 -0
  253. package/lib/programmers/internal/metadata_to_pattern.js.map +1 -0
  254. package/lib/programmers/internal/stringify_dynamic_properties.d.ts +1 -0
  255. package/lib/programmers/internal/stringify_dynamic_properties.js +76 -0
  256. package/lib/programmers/internal/stringify_dynamic_properties.js.map +1 -0
  257. package/lib/programmers/internal/stringify_regular_properties.d.ts +1 -0
  258. package/lib/programmers/internal/stringify_regular_properties.js +78 -0
  259. package/lib/programmers/internal/stringify_regular_properties.js.map +1 -0
  260. package/lib/programmers/internal/template_to_pattern.d.ts +1 -0
  261. package/lib/programmers/internal/template_to_pattern.js +13 -0
  262. package/lib/programmers/internal/template_to_pattern.js.map +1 -0
  263. package/lib/schemas/IJsonApplication.d.ts +8 -0
  264. package/lib/schemas/IJsonApplication.js +3 -0
  265. package/lib/schemas/IJsonApplication.js.map +1 -0
  266. package/lib/schemas/IJsonComponents.d.ts +19 -0
  267. package/lib/schemas/IJsonComponents.js +3 -0
  268. package/lib/schemas/IJsonComponents.js.map +1 -0
  269. package/lib/schemas/IJsonSchema.d.ts +62 -0
  270. package/lib/schemas/IJsonSchema.js +3 -0
  271. package/lib/schemas/IJsonSchema.js.map +1 -0
  272. package/lib/transform.d.ts +3 -0
  273. package/lib/transform.js +21 -0
  274. package/lib/transform.js.map +1 -0
  275. package/lib/transformers/CallExpressionTransformer.d.ts +5 -0
  276. package/lib/transformers/CallExpressionTransformer.js +45 -0
  277. package/lib/transformers/CallExpressionTransformer.js.map +1 -0
  278. package/lib/transformers/ExpressionWithArgumentTransformer.d.ts +0 -0
  279. package/lib/transformers/ExpressionWithArgumentTransformer.js +2 -0
  280. package/lib/transformers/ExpressionWithArgumentTransformer.js.map +1 -0
  281. package/lib/transformers/FileTransformer.d.ts +5 -0
  282. package/lib/transformers/FileTransformer.js +34 -0
  283. package/lib/transformers/FileTransformer.js.map +1 -0
  284. package/lib/transformers/IProject.d.ts +9 -0
  285. package/lib/transformers/IProject.js +3 -0
  286. package/lib/transformers/IProject.js.map +1 -0
  287. package/lib/transformers/ITransformOptions.d.ts +4 -0
  288. package/lib/transformers/ITransformOptions.js +3 -0
  289. package/lib/transformers/ITransformOptions.js.map +1 -0
  290. package/lib/transformers/NodeTransformer.d.ts +5 -0
  291. package/lib/transformers/NodeTransformer.js +18 -0
  292. package/lib/transformers/NodeTransformer.js.map +1 -0
  293. package/lib/transformers/features/ApplicationTransformer.d.ts +5 -0
  294. package/lib/transformers/features/ApplicationTransformer.js +63 -0
  295. package/lib/transformers/features/ApplicationTransformer.js.map +1 -0
  296. package/lib/transformers/features/AssertTransformer.d.ts +5 -0
  297. package/lib/transformers/features/AssertTransformer.js +30 -0
  298. package/lib/transformers/features/AssertTransformer.js.map +1 -0
  299. package/lib/transformers/features/CreateTransformer.d.ts +5 -0
  300. package/lib/transformers/features/CreateTransformer.js +29 -0
  301. package/lib/transformers/features/CreateTransformer.js.map +1 -0
  302. package/lib/transformers/features/IsTransformer.d.ts +5 -0
  303. package/lib/transformers/features/IsTransformer.js +30 -0
  304. package/lib/transformers/features/IsTransformer.js.map +1 -0
  305. package/lib/transformers/features/StringifyTransformer.d.ts +5 -0
  306. package/lib/transformers/features/StringifyTransformer.js +23 -0
  307. package/lib/transformers/features/StringifyTransformer.js.map +1 -0
  308. package/lib/transformers/features/ValidateTransformer.d.ts +5 -0
  309. package/lib/transformers/features/ValidateTransformer.js +30 -0
  310. package/lib/transformers/features/ValidateTransformer.js.map +1 -0
  311. package/lib/typings/Atomic.d.ts +11 -0
  312. package/lib/typings/Atomic.js +3 -0
  313. package/lib/typings/Atomic.js.map +1 -0
  314. package/lib/typings/ClassProperties.d.ts +4 -0
  315. package/lib/typings/ClassProperties.js +3 -0
  316. package/lib/typings/ClassProperties.js.map +1 -0
  317. package/lib/typings/OmitNever.d.ts +2 -0
  318. package/lib/typings/OmitNever.js +3 -0
  319. package/lib/typings/OmitNever.js.map +1 -0
  320. package/lib/typings/SpecialFields.d.ts +3 -0
  321. package/lib/typings/SpecialFields.js +3 -0
  322. package/lib/typings/SpecialFields.js.map +1 -0
  323. package/lib/typings/Writable.d.ts +5 -0
  324. package/lib/typings/Writable.js +8 -0
  325. package/lib/typings/Writable.js.map +1 -0
  326. package/lib/utils/ArrayUtil.d.ts +8 -0
  327. package/lib/utils/ArrayUtil.js +69 -0
  328. package/lib/utils/ArrayUtil.js.map +1 -0
  329. package/lib/utils/Escaper.d.ts +3 -0
  330. package/lib/utils/Escaper.js +52 -0
  331. package/lib/utils/Escaper.js.map +1 -0
  332. package/lib/utils/MapUtil.d.ts +3 -0
  333. package/lib/utils/MapUtil.js +16 -0
  334. package/lib/utils/MapUtil.js.map +1 -0
  335. package/lib/utils/PatternUtil.d.ts +7 -0
  336. package/lib/utils/PatternUtil.js +59 -0
  337. package/lib/utils/PatternUtil.js.map +1 -0
  338. package/lib/utils/Singleton.d.ts +6 -0
  339. package/lib/utils/Singleton.js +47 -0
  340. package/lib/utils/Singleton.js.map +1 -0
  341. package/package.json +78 -0
package/README.md ADDED
@@ -0,0 +1,572 @@
1
+ # TypeScript-JSON
2
+ Super-fast Runtime validators and `JSON.stringify()` functions, with only one line.
3
+
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/typescript-json/blob/master/LICENSE)
5
+ [![npm version](https://img.shields.io/npm/v/typescript-json.svg)](https://www.npmjs.com/package/typescript-json)
6
+ [![Downloads](https://img.shields.io/npm/dm/typescript-json.svg)](https://www.npmjs.com/package/typescript-json)
7
+ [![Build Status](https://github.com/samchon/typescript-json/workflows/build/badge.svg)](https://github.com/samchon/typescript-json/actions?query=workflow%3Abuild)
8
+ [![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/typescript-json/wiki)
9
+
10
+ - Github: https://github.com/samchon/typescript-json
11
+ - NPM: https://www.npmjs.com/package/typescript-json
12
+ - Guide Documents: https://github.com/samchon/typescript-json/wiki
13
+
14
+ ```typescript
15
+ import TSON from "typescript-json";
16
+
17
+ //----
18
+ // RUNTIME VALIDATORS
19
+ //----
20
+ // ALLOW SUPERFLUOUS PROPERTIES
21
+ TSON.assertType<T>(input); // throws exception
22
+ TSON.is<T>(input); // returns boolean value
23
+ TSON.validate<T>(input); // archives all errors
24
+
25
+ // DO NOT ALLOW SUPERFLUOUS PROPERTIES
26
+ TSON.equals<T>(input); // returns boolean value
27
+ TSON.assertEquals<T>(input); // throws exception
28
+ TSON.validateEquals<T>(input); // archives all errors
29
+
30
+ //----
31
+ // APPENDIX FUNCTIONS
32
+ //----
33
+ TSON.stringify<T>(input); // 5x faster JSON.stringify()
34
+ TSON.application<[T, U, V], "swagger">(); // JSON schema application generator
35
+ TSON.create<T>(input); // 2x faster object creator (only one-time construction)
36
+ ```
37
+
38
+ `typescript-json` is a transformer library providing JSON related functions.
39
+
40
+ - Powerful Runtime type checkers:
41
+ - Performed by only one line, `TSON.assertType<T>(input)`
42
+ - Only one library which can validate union type
43
+ - Maximum 2,000x faster than other libraries
44
+ - 5x faster `JSON.stringify()` function:
45
+ - Performed by only one line: `TSON.stringify<T>(input)`
46
+ - Only one library which can stringify union type
47
+ - 10,000x faster optimizer construction time than similar libraries
48
+
49
+ ![Is Function Benchmark](https://user-images.githubusercontent.com/13158709/196679891-d06ef698-603b-49f8-98c8-d140b813a06d.png)
50
+
51
+ > Measured on AMD R9 5900HX, ASUS Rog Strix G15 (numeric option: `false`)
52
+
53
+
54
+
55
+
56
+ ## Setup
57
+ ### NPM Package
58
+ At first, install this `typescript-json` by the `npm install` command.
59
+
60
+ Also, you need additional `devDependencies` to compile the TypeScript code with transformation. Therefore, install those all libraries `typescript`, `ttypescript` and `ts-node`. Inform that, `ttypescript` is not mis-writing. Do not forget to install the `ttypescript`.
61
+
62
+ ```bash
63
+ npm install --save typescript-json
64
+
65
+ # ENSURE THOSE PACKAGES ARE INSTALLED
66
+ npm install --save-dev typescript
67
+ npm install --save-dev ttypescript
68
+ npm install --save-dev ts-node
69
+ ```
70
+
71
+ ### tsconfig.json
72
+ After the installation, you've to configure `tsconfig.json` file like below.
73
+
74
+ Add a property `transform` and its value as `typescript-json/lib/transform` into `compilerOptions.plugins` array. When configuring, I recommend you to use the `strict` option, to enforce developers to distinguish whether each property is nullable or undefindable.
75
+
76
+ Also, you can configure additional properties like `numeric` and `functional`. The first, `numeric` is an option whether to test `Number.isNaN()` and `Number.isFinite()` to numeric value or not. The second, `functional` is an option whether to test function type or not. Default values of those options are all `true`.
77
+
78
+ ```typescript
79
+ {
80
+ "compilerOptions": {
81
+ "strict": true,
82
+ "plugins": [
83
+ {
84
+ "transform": "typescript-json/lib/transform",
85
+ // "functional": true, // test function type
86
+ // "numeric": true, // test `isNaN()` and `isFinite()`
87
+ }
88
+ ]
89
+ }
90
+ }
91
+ ```
92
+
93
+ After the `tsconfig.json` definition, you can compile `typescript-json` utilized code by using `ttypescript`. If you want to run your TypeScript file through `ts-node`, use `-C ttypescript` argument like below:
94
+
95
+ ```bash
96
+ # COMPILE
97
+ npx ttsc
98
+
99
+ # WITH TS-NODE
100
+ npx ts-node -C ttypescript
101
+ ```
102
+
103
+ ### vite
104
+ Just open `vite.config.ts` file and assign `typescript: ttsc` property like below.
105
+
106
+ For reference, don't forget configuring [`tsconfig.json`](#tsconfigjson) file of above.
107
+
108
+ ```typescript
109
+ import { defineConfig } from 'vite'
110
+ import react from '@vitejs/plugin-react'
111
+ import typescript from "@rollup/plugin-typescript";
112
+ import ttsc from "ttypescript";
113
+
114
+ // https://vitejs.dev/config/
115
+ export default defineConfig({
116
+ plugins: [
117
+ react(),
118
+ typescript({
119
+ typescript: ttsc,
120
+ })
121
+ ]
122
+ });
123
+ ```
124
+
125
+ ### webpack
126
+ If you're using `webpack` with `ts-loader`, configure the `webpack.config.js` file like below.
127
+
128
+ ```javascript
129
+ const transform = require("typescript-json/lib/transform").default;
130
+
131
+ module.exports = {
132
+ // I am hiding the rest of the webpack config
133
+ module: {
134
+ rules: [
135
+ {
136
+ test: /\.(ts|tsx)$/,
137
+ exclude: /node_modules/,
138
+ loader: 'ts-loader',
139
+ options: {
140
+ getCustomTransformers: program => ({
141
+ before: [transform(program)]
142
+ // before: [
143
+ // transform(program, {
144
+ // functional: true,
145
+ // numeric: true
146
+ // })
147
+ // ]
148
+ })
149
+ }
150
+ }
151
+ ]
152
+ }
153
+ };
154
+ ```
155
+
156
+
157
+
158
+
159
+ ## Features
160
+ ### Runtime Validators
161
+ ```typescript
162
+ // ALLOW SUPERFLUOUS PROPERTIES
163
+ export function is<T>(input: T): boolean; // true or false
164
+ export function assertType<T>(input: T): T; // throws `TypeGuardError`
165
+ export function validate<T>(input: T): IValidation; // detailed reasons
166
+
167
+ // DO NOT ALLOW SUPERFLUOUS PROPERTIES
168
+ export function equals<T>(input: T): boolean;
169
+ export function assertEquals<T>(input: T): T;
170
+ export function validateEquals<T>(input: T): IValidation;
171
+
172
+ export interface IValidation {
173
+ success: boolean;
174
+ errors: IValidation.IError[];
175
+ }
176
+ export namespace IValidation {
177
+ export interface IError {
178
+ path: string;
179
+ expected: string;
180
+ value: any;
181
+ }
182
+ }
183
+
184
+ export class TypeGuardError extends Error {
185
+ public readonly method: string;
186
+ public readonly path: string | undefined;
187
+ public readonly expected: string;
188
+ public readonly value: any;
189
+ }
190
+ ```
191
+
192
+ > You can enhance type constraint more by using [**Comment Tags**](#comment-tags).
193
+
194
+ `typescript-json` provides three basic validator functions.
195
+
196
+ The first, `assertType()` is a function throwing `TypeGuardError` when an `input` value is different with its type, generic argument `T`. The second function, `is()` returns a `boolean` value meaning whether matched or not. The last `validate()` function archives all type errors into an `IValidation.errors` array.
197
+
198
+ If you want much strict validators that do not allow superfluous properties, you can use below functions instead. `assertEquals()` function throws `TypeGuardError`, `equals()` function returns `boolean` value, and `validateEquals()` function archives all type errors into an `IValidation.errors` array.
199
+
200
+ Basic | Strict
201
+ ------|--------
202
+ `assertType` | `assertEquals`
203
+ `is` | `equals`
204
+ `validate` | `validateEquals`
205
+
206
+ ```typescript
207
+ interface IPerson {
208
+ name: string;
209
+ age: number;
210
+ }
211
+
212
+ const person = {
213
+ name: "Jeongho Nam",
214
+ age: 34,
215
+ account: "samchon", // superfluous property
216
+ };
217
+
218
+ TSON.is<IPerson>(person); // -> true, allow superfluous property
219
+ TSON.equals<IPerson>(person); // -> false, do not allow
220
+ ```
221
+
222
+ Comparing those type checker functions with other similar libraries, `typescript-json` is much easier than others. For example, `ajv` requires complicate JSON schema definition that is different with the TypeScript type. Besides, `typescript-json` requires only one line.
223
+
224
+ Also, only `typescript-json` can validate union typed structure exactly. All the other libraries can check simple object type, however, none of them can validate complicate union type. The fun thing is, `ajv` requires JSON schema definition for validation, but it can't validate the JSON schema type. How contradict it is.
225
+
226
+ Components | `TSON` | `ajv` | `io-ts` | `zod` | `C.V.`
227
+ -------------------------|-------------------|-----------------|-------|---------|------------------
228
+ **Easy to use** | ✅ | ❌ | ❌ | ❌ | ❌
229
+ [Object (simple)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectSimple.ts) | ✔ | ✔ | ✔ | ✔ | ✔
230
+ [Object (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectHierarchical.ts) | ✔ | ❌ | ✔ | ✔ | ✔
231
+ [Object (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔ | ✔
232
+ [Object (union, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
233
+ [Object (union, explicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ObjectUnionExplicit.ts) | ✔ | ✔ | ✔ | ✔ | ❌
234
+ [Object (additional tags)](https://github.com/samchon/typescript-json/#comment-tags) | ✔ | ✔ | ✔ | ✔ | ✔
235
+ [Object (template literal types)](https://github.com/samchon/typescript-json/blob/master/test/structures/TemplateUnion.ts) | ✔ | ✔ | ❌ | ❌ | ❌
236
+ [Object (dynamic properties)](https://github.com/samchon/typescript-json/blob/master/test/structures/DynamicTemplate.ts) | ✔ | ✔ | ❌ | ❌ | ❌
237
+ [Array (hierarchical)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayHierarchical.ts) | ✔ | ✔ | ✔ | ✔ | ✔
238
+ [Array (recursive)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursive.ts) | ✔ | ❌ | ✔ | ✔ | ✔
239
+ [Array (recursive, union)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionExplicit.ts) | ✔ | ❌ | ✔ | ✔ | ❌
240
+ [Array (R+U, implicit)](https://github.com/samchon/typescript-json/blob/master/test/structures/ArrayRecursiveUnionImplicit.ts) | ✅ | ❌ | ❌ | ❌ | ❌
241
+ [**Ultimate Union Type**](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts) | ✅ | ❌ | ❌ | ❌ | ❌
242
+
243
+ > - TSON: `typescript-json`
244
+ > - C.V.: `class-validator`
245
+
246
+ Furthermore, when union type comes, `typescript-json` is extremely faster than others.
247
+
248
+ As you can see from the above table, `ajv` and `typescript-is` are fallen in the most union type cases. Also, they're even showing a huge different from `typescript-json`, in the time benchmark that does not care whether the validation is exact or not.
249
+
250
+ The extreme different is shown in the "ultimate union" type, when validating [JSON schema](https://github.com/samchon/typescript-json/blob/master/src/schemas/IJsonSchema.ts).
251
+
252
+ ![Super-fast runtime validator](https://user-images.githubusercontent.com/13158709/196680107-f4e77835-3380-4dde-9fa3-d9d419c046e2.png)
253
+
254
+ > Measured on Intel i5-1135g7, Surface Pro 8
255
+
256
+ ### Fastest JSON String Converter
257
+ ```typescript
258
+ export function stringify<T>(input: T): string;
259
+ ```
260
+
261
+ Super-fast JSON string conversion function.
262
+
263
+ If you call `TSON.stringify()` function instead of the native `JSON.stringify()`, the JSON conversion time would be 5x times faster. Also, you can perform such super-fast JSON string conversion very easily, by only one line: `TSON.stringify<T>(input)`.
264
+
265
+ On the other side, other similary library like `fast-json-stringify` requires complicate JSON schema definition. Furthermore, `typescript-json` can convert complicate structured data that `fast-json-stringify` cannot convert.
266
+
267
+ Comparing performance, `typescript-json` is about 5x times faster when comparing only JSON string conversion time. If compare optimizer construction time, `typescript-json` is even 10,000x times faster.
268
+
269
+ ![JSON conversion speed on each CPU](https://user-images.githubusercontent.com/13158709/177259522-791578dc-fa96-4d62-9c96-b22cb9575450.png)
270
+
271
+ > AMD CPU shows dramatic improvement
272
+
273
+ ### JSON Schema Generation
274
+ ```typescript
275
+ export function application<
276
+ Types extends unknown[],
277
+ Purpose extends "swagger" | "ajv" = "swagger",
278
+ Prefix extends string = Purpose extends "swagger"
279
+ ? "#/components/schemas"
280
+ : "components#/schemas",
281
+ >(): IJsonApplication;
282
+ ```
283
+
284
+ > You can enhance JSON schema more by using [**Comment Tags**](#comment-tags).
285
+
286
+ `typescript-json` even supports JSON schema application generation.
287
+
288
+ When you need to share your TypeScript types to other language, this `application()` function would be useful. It generates JSON schema definition by analyzing your `Types`. Therefore, with `typescript-json` and its `application()` function, you don't need to write JSON schema definition manually.
289
+
290
+ By the way, the reason why you're using this `application()` is for generating a swagger documents, I recommend you to use my another library [nestia](https://github.com/samchon/nestia). It will automate the swagger documents generation, by analyzing your entire backend server code.
291
+
292
+ ### Comment Tags
293
+ You can enhance [Runtime Validators](#runtime-validators) and [JSON Schema Generator](#json-schema-generation) by writing comment tags.
294
+
295
+ Below table shows list of supported comment tags. You can utilize those tags by writing in comments like below example structure `TagExample`. Look at them and utilize those comment tags to make your TypeScript program to be safer and more convenient.
296
+
297
+ Also, don't worry about taking a mistake on using those comment tags. In that case, compile error would be occured. By the compile level error detection, `typescript-json` is much stronger than any other runtime validator libraries using decorator functions, which can't catch any mistake on the compilation level.
298
+
299
+ Tag Kind | Target Type
300
+ ------------|-----------------
301
+ `@type {"int"\|"uint"}` | number
302
+ `@range (number, number]` | number
303
+ `@minimum {number}` | number
304
+ `@maximum {number}` | number
305
+ `@exclusiveMinimum {number}` | number
306
+ `@exclusiveMaximum {number}` | number
307
+ `@multipleOf {number}` | number
308
+ `@step {number}` | number
309
+ `@length {number} \| [number, number)` | string
310
+ `@minLength {number}` | string
311
+ `@maxLength {number}` | string
312
+ `@format {"email"\|"uuid"\|"url"\|"ipv4"\|"ipv6"}` | string
313
+ `@pattern {string}` | string
314
+ `@items {number} \| [number, number)` | array
315
+ `@minItems {number}` | array
316
+ `@maxItems {number}` | array
317
+
318
+ ```typescript
319
+ export interface TagExample {
320
+ /* -----------------------------------------------------------
321
+ ARRAYS
322
+ ----------------------------------------------------------- */
323
+ /**
324
+ * You can limit array length like below.
325
+ *
326
+ * @minItems 3
327
+ * @maxItems 10
328
+ *
329
+ * Also, you can use `@items` tag instead.
330
+ *
331
+ * @items (5, 10] --> 5 < length <= 10
332
+ * @items [7 --> 7 <= length
333
+ * @items 12) --> length < 12
334
+ *
335
+ * Furthermore, you can use additional tags for each item.
336
+ *
337
+ * @type uint
338
+ * @format uuid
339
+ */
340
+ array: Array<string|number>;
341
+
342
+ /**
343
+ * If two-dimensional array comes, length limit would work for
344
+ * both 1st and 2nd level arraies. Also using additional tags
345
+ * for each item (string) would still work.
346
+ *
347
+ * @items (5, 10)
348
+ * @format url
349
+ */
350
+ matrix: string[][];
351
+
352
+ /* -----------------------------------------------------------
353
+ NUMBERS
354
+ ----------------------------------------------------------- */
355
+ /**
356
+ * Type of number.
357
+ *
358
+ * It must be one of integer or unsigned integer.
359
+ *
360
+ * @type int
361
+ * @type uint
362
+ */
363
+ type: number;
364
+
365
+ /**
366
+ * You can limit range of numeric value like below.
367
+ *
368
+ * @minimum 5
369
+ * @maximum 10
370
+ *
371
+ * Also, you can use `@range` tag instead.
372
+ *
373
+ * @range (5, 10] --> 5 < x <= 10
374
+ * @range [7 --> 7 <= x
375
+ * @range 12) --> x < 12
376
+ */
377
+ range: number;
378
+
379
+ /**
380
+ * Step tag requires minmum or exclusiveMinimum tag.
381
+ *
382
+ * 3, 13, 23, 33, ...
383
+ *
384
+ * @step 10
385
+ * @exclusiveMinimum 3
386
+ * @range [3
387
+ */
388
+ step: number;
389
+
390
+ /**
391
+ * Value must be multiple of the given number.
392
+ *
393
+ * -5, 0, 5, 10, 15, ...
394
+ *
395
+ * @multipleOf 5
396
+ */
397
+ multipleOf: number;
398
+
399
+ /* -----------------------------------------------------------
400
+ STRINGS
401
+ ----------------------------------------------------------- */
402
+ /**
403
+ * You can limit string length like below.
404
+ *
405
+ * @minLength 3
406
+ * @maxLength 10
407
+ *
408
+ * Also, you can use `@length` tag instead.
409
+ *
410
+ * @length 10 --> length = 10
411
+ * @length [3, 7] --> 3 <= length && length <= 7
412
+ * @length (5, 10) --> 5 < length && length < 10
413
+ * @length [4 --> 4 < length
414
+ * @length 7) --> length < 7
415
+ */
416
+ length: string;
417
+
418
+ /**
419
+ * Mobile number composed by only numbers.
420
+ *
421
+ * Note that, `typescript-json` does not support flag of regex,
422
+ * because JSON schema definition does not suppor it either.
423
+ * Therefore, write regex pattern without `/` characters and flag.
424
+ *
425
+ * @pattern ^0[0-9]{7,16}
426
+ * -> RegExp(/[0-9]{7,16}/).test("01012345678")
427
+ */
428
+ mobile: string;
429
+
430
+ /**
431
+ * E-mail address.
432
+ *
433
+ * @format email
434
+ */
435
+ email: string;
436
+
437
+ /**
438
+ * UUID value.
439
+ *
440
+ * @format uuid
441
+ */
442
+ uuid: string;
443
+
444
+ /**
445
+ * URL address.
446
+ *
447
+ * @format url
448
+ */
449
+ url: string;
450
+
451
+ /**
452
+ * IPv4 address.
453
+ *
454
+ * @format ipv4
455
+ */
456
+ ipv4: string;
457
+
458
+ /**
459
+ * IPv6 address.
460
+ *
461
+ * @format ipv6
462
+ */
463
+ ipv6: string;
464
+ }
465
+ ```
466
+
467
+
468
+
469
+
470
+ ## Appendix
471
+ ### Nestia
472
+ https://github.com/samchon/nestia
473
+
474
+ Automatic `SDK` and `Swagger` generator for `NestJS`, evolved than ever.
475
+
476
+ `nestia` is an evolved `SDK` and `Swagger` generator, which analyzes your `NestJS` server code in the compilation level. With `nestia` and compilation level analyzer, you don't need to write any swagger or class-validator decorators.
477
+
478
+ Reading below table and example code, feel how the "compilation level" makes `nestia` stronger.
479
+
480
+ Components | `nestia`::SDK | `nestia`::swagger | `@nestjs/swagger`
481
+ -----------|---|---|---
482
+ Pure DTO interface | ✔ | ✔ | ❌
483
+ Description comments | ✔ | ✔ | ❌
484
+ Simple structure | ✔ | ✔ | ✔
485
+ Generic type | ✔ | ✔ | ❌
486
+ Union type | ✔ | ✔ | ▲
487
+ Intersection type | ✔ | ✔ | ▲
488
+ Conditional type | ✔ | ▲ | ❌
489
+ Auto completion | ✔ | ❌ | ❌
490
+ Type hints | ✔ | ❌ | ❌
491
+ 5x faster `JSON.stringify()` | ✔ | ❌ | ❌
492
+ Ensure type safety | ✅ | ❌ | ❌
493
+
494
+ ```typescript
495
+ // IMPORT SDK LIBRARY GENERATED BY NESTIA
496
+ import api from "@samchon/shopping-api";
497
+ import { IPage } from "@samchon/shopping-api/lib/structures/IPage";
498
+ import { ISale } from "@samchon/shopping-api/lib/structures/ISale";
499
+ import { ISaleArticleComment } from "@samchon/shopping-api/lib/structures/ISaleArticleComment";
500
+ import { ISaleQuestion } from "@samchon/shopping-api/lib/structures/ISaleQuestion";
501
+
502
+ export async function trace_sale_question_and_comment
503
+ (connection: api.IConnection): Promise<void>
504
+ {
505
+ // LIST UP SALE SUMMARIES
506
+ const index: IPage<ISale.ISummary> = await api.functional.shoppings.sales.index
507
+ (
508
+ connection,
509
+ "general",
510
+ { limit: 100, page: 1 }
511
+ );
512
+
513
+ // PICK A SALE
514
+ const sale: ISale = await api.functional.shoppings.sales.at
515
+ (
516
+ connection,
517
+ index.data[0].id
518
+ );
519
+ console.log("sale", sale);
520
+
521
+ // WRITE A QUESTION
522
+ const question: ISaleQuestion = await api.functional.shoppings.sales.questions.store
523
+ (
524
+ connection,
525
+ "general",
526
+ sale.id,
527
+ {
528
+ title: "How to use this product?",
529
+ body: "The description is not fully enough. Can you introduce me more?",
530
+ files: []
531
+ }
532
+ );
533
+ console.log("question", question);
534
+
535
+ // WRITE A COMMENT
536
+ const comment: ISaleArticleComment = await api.functional.shoppings.sales.comments.store
537
+ (
538
+ connection,
539
+ "general",
540
+ sale.id,
541
+ question.id,
542
+ {
543
+ body: "p.s) Can you send me a detailed catalogue?",
544
+ anonymous: false
545
+ }
546
+ );
547
+ console.log("comment", comment);
548
+ }
549
+ ```
550
+
551
+ ### Nestia-Helper
552
+ https://github.com/samchon/nestia-helper
553
+
554
+ Helper library of `NestJS`, using this `typescript-json`.
555
+
556
+ `nestia-helper` is a helper library of `NestJS`, which boosts up the `JSON.stringify()` speed 5x times faster about the API responses, automatically. Also, `nestia-helper` supports automatic valiation of request body, too.
557
+
558
+ ```typescript
559
+ import helper from "nestia-helper";
560
+ import * as nest from "@nestjs/common";
561
+
562
+ @nest.Controller("bbs/articles")
563
+ export class BbsArticlesController
564
+ {
565
+ // automatic TSON.stringify() for response body
566
+ @helper.TypedRoute.Get()
567
+ public store(
568
+ // automatic TSON.assertType() for request body
569
+ @helper.TypedBody() input: IBbsArticle.IStore
570
+ ): Promise<IBbsArticle>;
571
+ }
572
+ ```
@@ -0,0 +1,11 @@
1
+ export interface IValidation {
2
+ success: boolean;
3
+ errors: IValidation.IError[];
4
+ }
5
+ export declare namespace IValidation {
6
+ interface IError {
7
+ path: string;
8
+ expected: string;
9
+ value: any;
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IValidation.js","sourceRoot":"","sources":["../src/IValidation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ export declare class TypeGuardError extends Error {
2
+ readonly method: string;
3
+ readonly path: string | undefined;
4
+ readonly expected: string;
5
+ readonly value: any;
6
+ constructor(props: TypeGuardError.IProps);
7
+ }
8
+ export declare namespace TypeGuardError {
9
+ interface IProps {
10
+ method: string;
11
+ path?: string;
12
+ expected: string;
13
+ value: any;
14
+ message?: string;
15
+ }
16
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.TypeGuardError = void 0;
19
+ var TypeGuardError = (function (_super) {
20
+ __extends(TypeGuardError, _super);
21
+ function TypeGuardError(props) {
22
+ var _newTarget = this.constructor;
23
+ var _this = _super.call(this, props.message ||
24
+ "Error on ".concat(props.method, "(): invalid type").concat(props.path ? " on ".concat(props.path) : "", ", expect to be ").concat(props.expected)) || this;
25
+ var proto = _newTarget.prototype;
26
+ if (Object.setPrototypeOf)
27
+ Object.setPrototypeOf(_this, proto);
28
+ else
29
+ _this.__proto__ = proto;
30
+ _this.method = props.method;
31
+ _this.path = props.path;
32
+ _this.expected = props.expected;
33
+ _this.value = props.value;
34
+ return _this;
35
+ }
36
+ return TypeGuardError;
37
+ }(Error));
38
+ exports.TypeGuardError = TypeGuardError;
39
+ //# sourceMappingURL=TypeGuardError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeGuardError.js","sourceRoot":"","sources":["../src/TypeGuardError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;IAAoC,kCAAK;IAMrC,wBAAmB,KAA4B;;QAA/C,YAEI,kBACI,KAAK,CAAC,OAAO;YACT,mBAAY,KAAK,CAAC,MAAM,6BACpB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAO,KAAK,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAE,4BACvB,KAAK,CAAC,QAAQ,CAAE,CACzC,SAYJ;QATG,IAAM,KAAK,GAAG,WAAW,SAAS,CAAC;QACnC,IAAI,MAAM,CAAC,cAAc;YAAE,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,KAAK,CAAC,CAAC;;YACxD,KAAY,CAAC,SAAS,GAAG,KAAK,CAAC;QAGrC,KAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,KAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,KAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,KAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;;IAC7B,CAAC;IACL,qBAAC;AAAD,CAAC,AA1BD,CAAoC,KAAK,GA0BxC;AA1BY,wCAAc"}
@@ -0,0 +1,4 @@
1
+ import ts from "typescript";
2
+ export declare namespace CommentFactory {
3
+ function generate(comments: ts.SymbolDisplayPart[]): string;
4
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommentFactory = void 0;
4
+ var CommentFactory;
5
+ (function (CommentFactory) {
6
+ function generate(comments) {
7
+ return comments
8
+ .map(function (part) { return "".concat(part.kind === "linkText" ? " " : "").concat(part.text); })
9
+ .map(function (str) { return str.split("\r\n").join("\n"); })
10
+ .join("");
11
+ }
12
+ CommentFactory.generate = generate;
13
+ })(CommentFactory = exports.CommentFactory || (exports.CommentFactory = {}));
14
+ //# sourceMappingURL=CommentFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentFactory.js","sourceRoot":"","sources":["../../src/factories/CommentFactory.ts"],"names":[],"mappings":";;;AAEA,IAAiB,cAAc,CAO9B;AAPD,WAAiB,cAAc;IAC3B,SAAgB,QAAQ,CAAC,QAAgC;QACrD,OAAO,QAAQ;aACV,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,UAAG,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,SAAG,IAAI,CAAC,IAAI,CAAE,EAApD,CAAoD,CAAC;aACnE,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAA5B,CAA4B,CAAC;aAC1C,IAAI,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IALe,uBAAQ,WAKvB,CAAA;AACL,CAAC,EAPgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAO9B"}
@@ -0,0 +1,6 @@
1
+ import ts from "typescript";
2
+ export declare namespace ExpressionFactory {
3
+ function isRequired(input: ts.Expression): ts.Expression;
4
+ function isArray(input: ts.Expression): ts.Expression;
5
+ function isObject(input: ts.Expression, nullChecked: boolean): ts.Expression;
6
+ }