ibm-cloud-sdk-core 4.3.2 → 4.3.4

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 (460) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/es/lib/sdk-test-helpers.js +1 -2
  3. package/iamtest.env +3 -0
  4. package/lib/sdk-test-helpers.js +11 -9
  5. package/package.json +3 -2
  6. package/sdk-test-utilities/node_modules/.package-lock.json +508 -0
  7. package/sdk-test-utilities/node_modules/@babel/code-frame/LICENSE +22 -0
  8. package/sdk-test-utilities/node_modules/@babel/code-frame/README.md +19 -0
  9. package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js +156 -0
  10. package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js.map +1 -0
  11. package/sdk-test-utilities/node_modules/@babel/code-frame/package.json +30 -0
  12. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/LICENSE +22 -0
  13. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/README.md +19 -0
  14. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js +70 -0
  15. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +1 -0
  16. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js +57 -0
  17. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js.map +1 -0
  18. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js +35 -0
  19. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +1 -0
  20. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/package.json +31 -0
  21. package/sdk-test-utilities/node_modules/@babel/highlight/LICENSE +22 -0
  22. package/sdk-test-utilities/node_modules/@babel/highlight/README.md +19 -0
  23. package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js +119 -0
  24. package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js.map +1 -0
  25. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/index.js +165 -0
  26. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/license +9 -0
  27. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/package.json +56 -0
  28. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/readme.md +147 -0
  29. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js +228 -0
  30. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js.flow +93 -0
  31. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/license +9 -0
  32. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/package.json +71 -0
  33. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/readme.md +314 -0
  34. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/templates.js +128 -0
  35. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/types/index.d.ts +97 -0
  36. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/CHANGELOG.md +54 -0
  37. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/LICENSE +21 -0
  38. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/README.md +68 -0
  39. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/conversions.js +868 -0
  40. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/index.js +78 -0
  41. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/package.json +46 -0
  42. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/route.js +97 -0
  43. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/.eslintrc.json +43 -0
  44. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/LICENSE +8 -0
  45. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/README.md +11 -0
  46. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/index.js +152 -0
  47. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/package.json +25 -0
  48. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/test.js +7 -0
  49. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/index.js +11 -0
  50. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/license +21 -0
  51. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/package.json +41 -0
  52. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/readme.md +27 -0
  53. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/index.js +8 -0
  54. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/license +9 -0
  55. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/package.json +44 -0
  56. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/readme.md +70 -0
  57. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/browser.js +5 -0
  58. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/index.js +131 -0
  59. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/license +9 -0
  60. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/package.json +53 -0
  61. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/readme.md +66 -0
  62. package/sdk-test-utilities/node_modules/@babel/highlight/package.json +30 -0
  63. package/sdk-test-utilities/node_modules/@jest/expect-utils/LICENSE +21 -0
  64. package/sdk-test-utilities/node_modules/@jest/expect-utils/README.md +5 -0
  65. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/immutableUtils.js +66 -0
  66. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.d.ts +94 -0
  67. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.js +34 -0
  68. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/jasmineUtils.js +218 -0
  69. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/types.js +1 -0
  70. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/utils.js +462 -0
  71. package/sdk-test-utilities/node_modules/@jest/expect-utils/package.json +35 -0
  72. package/sdk-test-utilities/node_modules/@jest/schemas/LICENSE +21 -0
  73. package/sdk-test-utilities/node_modules/@jest/schemas/README.md +3 -0
  74. package/sdk-test-utilities/node_modules/@jest/schemas/build/index.d.ts +63 -0
  75. package/sdk-test-utilities/node_modules/@jest/schemas/build/index.js +60 -0
  76. package/sdk-test-utilities/node_modules/@jest/schemas/package.json +29 -0
  77. package/sdk-test-utilities/node_modules/@jest/types/LICENSE +21 -0
  78. package/sdk-test-utilities/node_modules/@jest/types/README.md +30 -0
  79. package/sdk-test-utilities/node_modules/@jest/types/build/Circus.js +1 -0
  80. package/sdk-test-utilities/node_modules/@jest/types/build/Config.js +1 -0
  81. package/sdk-test-utilities/node_modules/@jest/types/build/Global.js +1 -0
  82. package/sdk-test-utilities/node_modules/@jest/types/build/TestResult.js +1 -0
  83. package/sdk-test-utilities/node_modules/@jest/types/build/index.d.ts +1204 -0
  84. package/sdk-test-utilities/node_modules/@jest/types/build/index.js +1 -0
  85. package/sdk-test-utilities/node_modules/@jest/types/package.json +38 -0
  86. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.d.ts +35 -0
  87. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.js +577 -0
  88. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.d.ts +2 -0
  89. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.js +47 -0
  90. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.d.ts +88 -0
  91. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.js +609 -0
  92. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.d.ts +1 -0
  93. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.js +44 -0
  94. package/sdk-test-utilities/node_modules/@sinclair/typebox/license +23 -0
  95. package/sdk-test-utilities/node_modules/@sinclair/typebox/package.json +47 -0
  96. package/sdk-test-utilities/node_modules/@sinclair/typebox/readme.md +1424 -0
  97. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.d.ts +1 -0
  98. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.js +44 -0
  99. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.d.ts +26 -0
  100. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.js +90 -0
  101. package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.d.ts +723 -0
  102. package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.js +2220 -0
  103. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.d.ts +30 -0
  104. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.js +372 -0
  105. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.d.ts +12 -0
  106. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.js +484 -0
  107. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.d.ts +3 -0
  108. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.js +71 -0
  109. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.d.ts +13 -0
  110. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.js +372 -0
  111. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.d.ts +26 -0
  112. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.js +480 -0
  113. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.d.ts +43 -0
  114. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.js +204 -0
  115. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.d.ts +3 -0
  116. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.js +80 -0
  117. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.d.ts +8 -0
  118. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.js +208 -0
  119. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.d.ts +6 -0
  120. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.js +56 -0
  121. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.d.ts +11 -0
  122. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.js +53 -0
  123. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.d.ts +13 -0
  124. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.js +121 -0
  125. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.d.ts +24 -0
  126. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.js +142 -0
  127. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.d.ts +39 -0
  128. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.js +99 -0
  129. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/LICENSE +21 -0
  130. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/README.md +15 -0
  131. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/index.d.ts +111 -0
  132. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/package.json +25 -0
  133. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/LICENSE +21 -0
  134. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/README.md +15 -0
  135. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/index.d.ts +184 -0
  136. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/package.json +32 -0
  137. package/sdk-test-utilities/node_modules/@types/istanbul-reports/LICENSE +21 -0
  138. package/sdk-test-utilities/node_modules/@types/istanbul-reports/README.md +86 -0
  139. package/sdk-test-utilities/node_modules/@types/istanbul-reports/index.d.ts +67 -0
  140. package/sdk-test-utilities/node_modules/@types/istanbul-reports/package.json +32 -0
  141. package/sdk-test-utilities/node_modules/@types/node/LICENSE +21 -0
  142. package/sdk-test-utilities/node_modules/@types/node/README.md +15 -0
  143. package/sdk-test-utilities/node_modules/@types/node/assert/strict.d.ts +8 -0
  144. package/sdk-test-utilities/node_modules/@types/node/assert.d.ts +1040 -0
  145. package/sdk-test-utilities/node_modules/@types/node/async_hooks.d.ts +541 -0
  146. package/sdk-test-utilities/node_modules/@types/node/buffer.d.ts +2363 -0
  147. package/sdk-test-utilities/node_modules/@types/node/child_process.d.ts +1544 -0
  148. package/sdk-test-utilities/node_modules/@types/node/cluster.d.ts +578 -0
  149. package/sdk-test-utilities/node_modules/@types/node/console.d.ts +452 -0
  150. package/sdk-test-utilities/node_modules/@types/node/constants.d.ts +19 -0
  151. package/sdk-test-utilities/node_modules/@types/node/crypto.d.ts +4523 -0
  152. package/sdk-test-utilities/node_modules/@types/node/dgram.d.ts +596 -0
  153. package/sdk-test-utilities/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  154. package/sdk-test-utilities/node_modules/@types/node/dns/promises.d.ts +474 -0
  155. package/sdk-test-utilities/node_modules/@types/node/dns.d.ts +864 -0
  156. package/sdk-test-utilities/node_modules/@types/node/dom-events.d.ts +124 -0
  157. package/sdk-test-utilities/node_modules/@types/node/domain.d.ts +170 -0
  158. package/sdk-test-utilities/node_modules/@types/node/events.d.ts +909 -0
  159. package/sdk-test-utilities/node_modules/@types/node/fs/promises.d.ts +1245 -0
  160. package/sdk-test-utilities/node_modules/@types/node/fs.d.ts +4317 -0
  161. package/sdk-test-utilities/node_modules/@types/node/globals.d.ts +411 -0
  162. package/sdk-test-utilities/node_modules/@types/node/globals.global.d.ts +1 -0
  163. package/sdk-test-utilities/node_modules/@types/node/http.d.ts +1908 -0
  164. package/sdk-test-utilities/node_modules/@types/node/http2.d.ts +2418 -0
  165. package/sdk-test-utilities/node_modules/@types/node/https.d.ts +550 -0
  166. package/sdk-test-utilities/node_modules/@types/node/index.d.ts +89 -0
  167. package/sdk-test-utilities/node_modules/@types/node/inspector.d.ts +2746 -0
  168. package/sdk-test-utilities/node_modules/@types/node/module.d.ts +315 -0
  169. package/sdk-test-utilities/node_modules/@types/node/net.d.ts +999 -0
  170. package/sdk-test-utilities/node_modules/@types/node/os.d.ts +495 -0
  171. package/sdk-test-utilities/node_modules/@types/node/package.json +217 -0
  172. package/sdk-test-utilities/node_modules/@types/node/path.d.ts +191 -0
  173. package/sdk-test-utilities/node_modules/@types/node/perf_hooks.d.ts +905 -0
  174. package/sdk-test-utilities/node_modules/@types/node/process.d.ts +1754 -0
  175. package/sdk-test-utilities/node_modules/@types/node/punycode.d.ts +117 -0
  176. package/sdk-test-utilities/node_modules/@types/node/querystring.d.ts +153 -0
  177. package/sdk-test-utilities/node_modules/@types/node/readline/promises.d.ts +150 -0
  178. package/sdk-test-utilities/node_modules/@types/node/readline.d.ts +540 -0
  179. package/sdk-test-utilities/node_modules/@types/node/repl.d.ts +430 -0
  180. package/sdk-test-utilities/node_modules/@types/node/sea.d.ts +153 -0
  181. package/sdk-test-utilities/node_modules/@types/node/stream/consumers.d.ts +12 -0
  182. package/sdk-test-utilities/node_modules/@types/node/stream/promises.d.ts +83 -0
  183. package/sdk-test-utilities/node_modules/@types/node/stream/web.d.ts +367 -0
  184. package/sdk-test-utilities/node_modules/@types/node/stream.d.ts +1707 -0
  185. package/sdk-test-utilities/node_modules/@types/node/string_decoder.d.ts +67 -0
  186. package/sdk-test-utilities/node_modules/@types/node/test.d.ts +1718 -0
  187. package/sdk-test-utilities/node_modules/@types/node/timers/promises.d.ts +97 -0
  188. package/sdk-test-utilities/node_modules/@types/node/timers.d.ts +240 -0
  189. package/sdk-test-utilities/node_modules/@types/node/tls.d.ts +1217 -0
  190. package/sdk-test-utilities/node_modules/@types/node/trace_events.d.ts +197 -0
  191. package/sdk-test-utilities/node_modules/@types/node/tty.d.ts +208 -0
  192. package/sdk-test-utilities/node_modules/@types/node/url.d.ts +952 -0
  193. package/sdk-test-utilities/node_modules/@types/node/util.d.ts +2292 -0
  194. package/sdk-test-utilities/node_modules/@types/node/v8.d.ts +808 -0
  195. package/sdk-test-utilities/node_modules/@types/node/vm.d.ts +924 -0
  196. package/sdk-test-utilities/node_modules/@types/node/wasi.d.ts +181 -0
  197. package/sdk-test-utilities/node_modules/@types/node/worker_threads.d.ts +691 -0
  198. package/sdk-test-utilities/node_modules/@types/node/zlib.d.ts +530 -0
  199. package/sdk-test-utilities/node_modules/@types/stack-utils/LICENSE +21 -0
  200. package/sdk-test-utilities/node_modules/@types/stack-utils/README.md +78 -0
  201. package/sdk-test-utilities/node_modules/@types/stack-utils/index.d.ts +59 -0
  202. package/sdk-test-utilities/node_modules/@types/stack-utils/package.json +25 -0
  203. package/sdk-test-utilities/node_modules/@types/yargs/LICENSE +21 -0
  204. package/sdk-test-utilities/node_modules/@types/yargs/README.md +15 -0
  205. package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.mts +1 -0
  206. package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.ts +5 -0
  207. package/sdk-test-utilities/node_modules/@types/yargs/index.d.mts +46 -0
  208. package/sdk-test-utilities/node_modules/@types/yargs/index.d.ts +1031 -0
  209. package/sdk-test-utilities/node_modules/@types/yargs/package.json +87 -0
  210. package/sdk-test-utilities/node_modules/@types/yargs/yargs.d.ts +9 -0
  211. package/sdk-test-utilities/node_modules/@types/yargs-parser/LICENSE +21 -0
  212. package/sdk-test-utilities/node_modules/@types/yargs-parser/README.md +15 -0
  213. package/sdk-test-utilities/node_modules/@types/yargs-parser/index.d.ts +112 -0
  214. package/sdk-test-utilities/node_modules/@types/yargs-parser/package.json +25 -0
  215. package/sdk-test-utilities/node_modules/ansi-styles/index.d.ts +345 -0
  216. package/sdk-test-utilities/node_modules/ansi-styles/index.js +163 -0
  217. package/sdk-test-utilities/node_modules/ansi-styles/license +9 -0
  218. package/sdk-test-utilities/node_modules/ansi-styles/package.json +56 -0
  219. package/sdk-test-utilities/node_modules/ansi-styles/readme.md +152 -0
  220. package/sdk-test-utilities/node_modules/braces/LICENSE +21 -0
  221. package/sdk-test-utilities/node_modules/braces/README.md +586 -0
  222. package/sdk-test-utilities/node_modules/braces/index.js +170 -0
  223. package/sdk-test-utilities/node_modules/braces/lib/compile.js +60 -0
  224. package/sdk-test-utilities/node_modules/braces/lib/constants.js +57 -0
  225. package/sdk-test-utilities/node_modules/braces/lib/expand.js +113 -0
  226. package/sdk-test-utilities/node_modules/braces/lib/parse.js +331 -0
  227. package/sdk-test-utilities/node_modules/braces/lib/stringify.js +32 -0
  228. package/sdk-test-utilities/node_modules/braces/lib/utils.js +122 -0
  229. package/sdk-test-utilities/node_modules/braces/package.json +77 -0
  230. package/sdk-test-utilities/node_modules/chalk/index.d.ts +415 -0
  231. package/sdk-test-utilities/node_modules/chalk/license +9 -0
  232. package/sdk-test-utilities/node_modules/chalk/package.json +68 -0
  233. package/sdk-test-utilities/node_modules/chalk/readme.md +341 -0
  234. package/sdk-test-utilities/node_modules/chalk/source/index.js +229 -0
  235. package/sdk-test-utilities/node_modules/chalk/source/templates.js +134 -0
  236. package/sdk-test-utilities/node_modules/chalk/source/util.js +39 -0
  237. package/sdk-test-utilities/node_modules/ci-info/CHANGELOG.md +178 -0
  238. package/sdk-test-utilities/node_modules/ci-info/LICENSE +21 -0
  239. package/sdk-test-utilities/node_modules/ci-info/README.md +135 -0
  240. package/sdk-test-utilities/node_modules/ci-info/index.d.ts +75 -0
  241. package/sdk-test-utilities/node_modules/ci-info/index.js +90 -0
  242. package/sdk-test-utilities/node_modules/ci-info/package.json +45 -0
  243. package/sdk-test-utilities/node_modules/ci-info/vendors.json +321 -0
  244. package/sdk-test-utilities/node_modules/color-convert/CHANGELOG.md +54 -0
  245. package/sdk-test-utilities/node_modules/color-convert/LICENSE +21 -0
  246. package/sdk-test-utilities/node_modules/color-convert/README.md +68 -0
  247. package/sdk-test-utilities/node_modules/color-convert/conversions.js +839 -0
  248. package/sdk-test-utilities/node_modules/color-convert/index.js +81 -0
  249. package/sdk-test-utilities/node_modules/color-convert/package.json +48 -0
  250. package/sdk-test-utilities/node_modules/color-convert/route.js +97 -0
  251. package/sdk-test-utilities/node_modules/color-name/LICENSE +8 -0
  252. package/sdk-test-utilities/node_modules/color-name/README.md +11 -0
  253. package/sdk-test-utilities/node_modules/color-name/index.js +152 -0
  254. package/sdk-test-utilities/node_modules/color-name/package.json +28 -0
  255. package/sdk-test-utilities/node_modules/diff-sequences/LICENSE +21 -0
  256. package/sdk-test-utilities/node_modules/diff-sequences/README.md +404 -0
  257. package/sdk-test-utilities/node_modules/diff-sequences/build/index.d.ts +38 -0
  258. package/sdk-test-utilities/node_modules/diff-sequences/build/index.js +798 -0
  259. package/sdk-test-utilities/node_modules/diff-sequences/package.json +39 -0
  260. package/sdk-test-utilities/node_modules/escape-string-regexp/index.d.ts +18 -0
  261. package/sdk-test-utilities/node_modules/escape-string-regexp/index.js +11 -0
  262. package/sdk-test-utilities/node_modules/escape-string-regexp/license +9 -0
  263. package/sdk-test-utilities/node_modules/escape-string-regexp/package.json +43 -0
  264. package/sdk-test-utilities/node_modules/escape-string-regexp/readme.md +29 -0
  265. package/sdk-test-utilities/node_modules/expect/LICENSE +21 -0
  266. package/sdk-test-utilities/node_modules/expect/README.md +3 -0
  267. package/sdk-test-utilities/node_modules/expect/build/asymmetricMatchers.js +375 -0
  268. package/sdk-test-utilities/node_modules/expect/build/extractExpectedAssertionsErrors.js +86 -0
  269. package/sdk-test-utilities/node_modules/expect/build/index.d.ts +370 -0
  270. package/sdk-test-utilities/node_modules/expect/build/index.js +410 -0
  271. package/sdk-test-utilities/node_modules/expect/build/jestMatchersObject.js +123 -0
  272. package/sdk-test-utilities/node_modules/expect/build/matchers.js +1292 -0
  273. package/sdk-test-utilities/node_modules/expect/build/print.js +122 -0
  274. package/sdk-test-utilities/node_modules/expect/build/spyMatchers.js +1254 -0
  275. package/sdk-test-utilities/node_modules/expect/build/toThrowMatchers.js +481 -0
  276. package/sdk-test-utilities/node_modules/expect/build/types.js +3 -0
  277. package/sdk-test-utilities/node_modules/expect/package.json +43 -0
  278. package/sdk-test-utilities/node_modules/fill-range/LICENSE +21 -0
  279. package/sdk-test-utilities/node_modules/fill-range/README.md +237 -0
  280. package/sdk-test-utilities/node_modules/fill-range/index.js +248 -0
  281. package/sdk-test-utilities/node_modules/fill-range/package.json +74 -0
  282. package/sdk-test-utilities/node_modules/graceful-fs/LICENSE +15 -0
  283. package/sdk-test-utilities/node_modules/graceful-fs/README.md +143 -0
  284. package/sdk-test-utilities/node_modules/graceful-fs/clone.js +23 -0
  285. package/sdk-test-utilities/node_modules/graceful-fs/graceful-fs.js +448 -0
  286. package/sdk-test-utilities/node_modules/graceful-fs/legacy-streams.js +118 -0
  287. package/sdk-test-utilities/node_modules/graceful-fs/package.json +53 -0
  288. package/sdk-test-utilities/node_modules/graceful-fs/polyfills.js +355 -0
  289. package/sdk-test-utilities/node_modules/has-flag/index.d.ts +39 -0
  290. package/sdk-test-utilities/node_modules/has-flag/index.js +8 -0
  291. package/sdk-test-utilities/node_modules/has-flag/license +9 -0
  292. package/sdk-test-utilities/node_modules/has-flag/package.json +46 -0
  293. package/sdk-test-utilities/node_modules/has-flag/readme.md +89 -0
  294. package/sdk-test-utilities/node_modules/is-number/LICENSE +21 -0
  295. package/sdk-test-utilities/node_modules/is-number/README.md +187 -0
  296. package/sdk-test-utilities/node_modules/is-number/index.js +18 -0
  297. package/sdk-test-utilities/node_modules/is-number/package.json +82 -0
  298. package/sdk-test-utilities/node_modules/jest-diff/LICENSE +21 -0
  299. package/sdk-test-utilities/node_modules/jest-diff/README.md +671 -0
  300. package/sdk-test-utilities/node_modules/jest-diff/build/cleanupSemantic.js +599 -0
  301. package/sdk-test-utilities/node_modules/jest-diff/build/constants.js +19 -0
  302. package/sdk-test-utilities/node_modules/jest-diff/build/diffLines.js +193 -0
  303. package/sdk-test-utilities/node_modules/jest-diff/build/diffStrings.js +66 -0
  304. package/sdk-test-utilities/node_modules/jest-diff/build/getAlignedDiffs.js +223 -0
  305. package/sdk-test-utilities/node_modules/jest-diff/build/index.d.ts +93 -0
  306. package/sdk-test-utilities/node_modules/jest-diff/build/index.js +232 -0
  307. package/sdk-test-utilities/node_modules/jest-diff/build/joinAlignedDiffs.js +271 -0
  308. package/sdk-test-utilities/node_modules/jest-diff/build/normalizeDiffOptions.js +59 -0
  309. package/sdk-test-utilities/node_modules/jest-diff/build/printDiffs.js +79 -0
  310. package/sdk-test-utilities/node_modules/jest-diff/build/types.js +1 -0
  311. package/sdk-test-utilities/node_modules/jest-diff/package.json +36 -0
  312. package/sdk-test-utilities/node_modules/jest-get-type/LICENSE +21 -0
  313. package/sdk-test-utilities/node_modules/jest-get-type/build/index.d.ts +27 -0
  314. package/sdk-test-utilities/node_modules/jest-get-type/build/index.js +53 -0
  315. package/sdk-test-utilities/node_modules/jest-get-type/package.json +27 -0
  316. package/sdk-test-utilities/node_modules/jest-matcher-utils/LICENSE +21 -0
  317. package/sdk-test-utilities/node_modules/jest-matcher-utils/README.md +24 -0
  318. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/Replaceable.js +64 -0
  319. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/deepCyclicCopyReplaceable.js +111 -0
  320. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.d.ts +138 -0
  321. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.js +542 -0
  322. package/sdk-test-utilities/node_modules/jest-matcher-utils/package.json +37 -0
  323. package/sdk-test-utilities/node_modules/jest-message-util/LICENSE +21 -0
  324. package/sdk-test-utilities/node_modules/jest-message-util/build/index.d.ts +68 -0
  325. package/sdk-test-utilities/node_modules/jest-message-util/build/index.js +518 -0
  326. package/sdk-test-utilities/node_modules/jest-message-util/build/types.js +1 -0
  327. package/sdk-test-utilities/node_modules/jest-message-util/package.json +43 -0
  328. package/sdk-test-utilities/node_modules/jest-util/LICENSE +21 -0
  329. package/sdk-test-utilities/node_modules/jest-util/Readme.md +87 -0
  330. package/sdk-test-utilities/node_modules/jest-util/build/ErrorWithStack.js +28 -0
  331. package/sdk-test-utilities/node_modules/jest-util/build/clearLine.js +18 -0
  332. package/sdk-test-utilities/node_modules/jest-util/build/convertDescriptorToString.js +30 -0
  333. package/sdk-test-utilities/node_modules/jest-util/build/createDirectory.js +71 -0
  334. package/sdk-test-utilities/node_modules/jest-util/build/createProcessObject.js +109 -0
  335. package/sdk-test-utilities/node_modules/jest-util/build/deepCyclicCopy.js +76 -0
  336. package/sdk-test-utilities/node_modules/jest-util/build/formatTime.js +24 -0
  337. package/sdk-test-utilities/node_modules/jest-util/build/globsToMatcher.js +98 -0
  338. package/sdk-test-utilities/node_modules/jest-util/build/index.d.ts +136 -0
  339. package/sdk-test-utilities/node_modules/jest-util/build/index.js +199 -0
  340. package/sdk-test-utilities/node_modules/jest-util/build/installCommonGlobals.js +115 -0
  341. package/sdk-test-utilities/node_modules/jest-util/build/interopRequireDefault.js +22 -0
  342. package/sdk-test-utilities/node_modules/jest-util/build/invariant.js +18 -0
  343. package/sdk-test-utilities/node_modules/jest-util/build/isInteractive.js +22 -0
  344. package/sdk-test-utilities/node_modules/jest-util/build/isNonNullable.js +16 -0
  345. package/sdk-test-utilities/node_modules/jest-util/build/isPromise.js +20 -0
  346. package/sdk-test-utilities/node_modules/jest-util/build/pluralize.js +16 -0
  347. package/sdk-test-utilities/node_modules/jest-util/build/preRunMessage.js +38 -0
  348. package/sdk-test-utilities/node_modules/jest-util/build/replacePathSepForGlob.js +16 -0
  349. package/sdk-test-utilities/node_modules/jest-util/build/requireOrImportModule.js +77 -0
  350. package/sdk-test-utilities/node_modules/jest-util/build/setGlobal.js +17 -0
  351. package/sdk-test-utilities/node_modules/jest-util/build/specialChars.js +25 -0
  352. package/sdk-test-utilities/node_modules/jest-util/build/testPathPatternToRegExp.js +19 -0
  353. package/sdk-test-utilities/node_modules/jest-util/build/tryRealpath.js +30 -0
  354. package/sdk-test-utilities/node_modules/jest-util/package.json +38 -0
  355. package/sdk-test-utilities/node_modules/js-tokens/CHANGELOG.md +151 -0
  356. package/sdk-test-utilities/node_modules/js-tokens/LICENSE +21 -0
  357. package/sdk-test-utilities/node_modules/js-tokens/README.md +240 -0
  358. package/sdk-test-utilities/node_modules/js-tokens/index.js +23 -0
  359. package/sdk-test-utilities/node_modules/js-tokens/package.json +30 -0
  360. package/sdk-test-utilities/node_modules/micromatch/LICENSE +21 -0
  361. package/sdk-test-utilities/node_modules/micromatch/README.md +1017 -0
  362. package/sdk-test-utilities/node_modules/micromatch/index.js +467 -0
  363. package/sdk-test-utilities/node_modules/micromatch/package.json +101 -0
  364. package/sdk-test-utilities/node_modules/picocolors/LICENSE +15 -0
  365. package/sdk-test-utilities/node_modules/picocolors/README.md +21 -0
  366. package/sdk-test-utilities/node_modules/picocolors/package.json +25 -0
  367. package/sdk-test-utilities/node_modules/picocolors/picocolors.browser.js +4 -0
  368. package/sdk-test-utilities/node_modules/picocolors/picocolors.d.ts +5 -0
  369. package/sdk-test-utilities/node_modules/picocolors/picocolors.js +65 -0
  370. package/sdk-test-utilities/node_modules/picomatch/CHANGELOG.md +136 -0
  371. package/sdk-test-utilities/node_modules/picomatch/LICENSE +21 -0
  372. package/sdk-test-utilities/node_modules/picomatch/README.md +708 -0
  373. package/sdk-test-utilities/node_modules/picomatch/index.js +3 -0
  374. package/sdk-test-utilities/node_modules/picomatch/lib/constants.js +179 -0
  375. package/sdk-test-utilities/node_modules/picomatch/lib/parse.js +1091 -0
  376. package/sdk-test-utilities/node_modules/picomatch/lib/picomatch.js +342 -0
  377. package/sdk-test-utilities/node_modules/picomatch/lib/scan.js +391 -0
  378. package/sdk-test-utilities/node_modules/picomatch/lib/utils.js +64 -0
  379. package/sdk-test-utilities/node_modules/picomatch/package.json +81 -0
  380. package/sdk-test-utilities/node_modules/pretty-format/LICENSE +21 -0
  381. package/sdk-test-utilities/node_modules/pretty-format/README.md +463 -0
  382. package/sdk-test-utilities/node_modules/pretty-format/build/collections.js +180 -0
  383. package/sdk-test-utilities/node_modules/pretty-format/build/index.d.ts +163 -0
  384. package/sdk-test-utilities/node_modules/pretty-format/build/index.js +478 -0
  385. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js +89 -0
  386. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMCollection.js +67 -0
  387. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMElement.js +101 -0
  388. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/Immutable.js +217 -0
  389. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactElement.js +143 -0
  390. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactTestComponent.js +66 -0
  391. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/escapeHTML.js +16 -0
  392. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/markup.js +113 -0
  393. package/sdk-test-utilities/node_modules/pretty-format/build/types.js +1 -0
  394. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.d.ts +167 -0
  395. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.js +164 -0
  396. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/license +9 -0
  397. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/package.json +52 -0
  398. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/readme.md +144 -0
  399. package/sdk-test-utilities/node_modules/pretty-format/package.json +43 -0
  400. package/sdk-test-utilities/node_modules/react-is/LICENSE +21 -0
  401. package/sdk-test-utilities/node_modules/react-is/README.md +104 -0
  402. package/sdk-test-utilities/node_modules/react-is/cjs/react-is.development.js +221 -0
  403. package/sdk-test-utilities/node_modules/react-is/cjs/react-is.production.min.js +14 -0
  404. package/sdk-test-utilities/node_modules/react-is/index.js +7 -0
  405. package/sdk-test-utilities/node_modules/react-is/package.json +26 -0
  406. package/sdk-test-utilities/node_modules/react-is/umd/react-is.development.js +220 -0
  407. package/sdk-test-utilities/node_modules/react-is/umd/react-is.production.min.js +15 -0
  408. package/sdk-test-utilities/node_modules/slash/index.d.ts +25 -0
  409. package/sdk-test-utilities/node_modules/slash/index.js +11 -0
  410. package/sdk-test-utilities/node_modules/slash/license +9 -0
  411. package/sdk-test-utilities/node_modules/slash/package.json +35 -0
  412. package/sdk-test-utilities/node_modules/slash/readme.md +44 -0
  413. package/sdk-test-utilities/node_modules/stack-utils/LICENSE.md +21 -0
  414. package/sdk-test-utilities/node_modules/stack-utils/index.js +344 -0
  415. package/sdk-test-utilities/node_modules/stack-utils/package.json +39 -0
  416. package/sdk-test-utilities/node_modules/stack-utils/readme.md +143 -0
  417. package/sdk-test-utilities/node_modules/supports-color/browser.js +5 -0
  418. package/sdk-test-utilities/node_modules/supports-color/index.js +135 -0
  419. package/sdk-test-utilities/node_modules/supports-color/license +9 -0
  420. package/sdk-test-utilities/node_modules/supports-color/package.json +53 -0
  421. package/sdk-test-utilities/node_modules/supports-color/readme.md +76 -0
  422. package/sdk-test-utilities/node_modules/to-regex-range/LICENSE +21 -0
  423. package/sdk-test-utilities/node_modules/to-regex-range/README.md +305 -0
  424. package/sdk-test-utilities/node_modules/to-regex-range/index.js +288 -0
  425. package/sdk-test-utilities/node_modules/to-regex-range/package.json +88 -0
  426. package/sdk-test-utilities/node_modules/undici-types/README.md +6 -0
  427. package/sdk-test-utilities/node_modules/undici-types/agent.d.ts +31 -0
  428. package/sdk-test-utilities/node_modules/undici-types/api.d.ts +43 -0
  429. package/sdk-test-utilities/node_modules/undici-types/balanced-pool.d.ts +18 -0
  430. package/sdk-test-utilities/node_modules/undici-types/cache.d.ts +36 -0
  431. package/sdk-test-utilities/node_modules/undici-types/client.d.ts +97 -0
  432. package/sdk-test-utilities/node_modules/undici-types/connector.d.ts +34 -0
  433. package/sdk-test-utilities/node_modules/undici-types/content-type.d.ts +21 -0
  434. package/sdk-test-utilities/node_modules/undici-types/cookies.d.ts +28 -0
  435. package/sdk-test-utilities/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  436. package/sdk-test-utilities/node_modules/undici-types/dispatcher.d.ts +241 -0
  437. package/sdk-test-utilities/node_modules/undici-types/errors.d.ts +128 -0
  438. package/sdk-test-utilities/node_modules/undici-types/fetch.d.ts +209 -0
  439. package/sdk-test-utilities/node_modules/undici-types/file.d.ts +39 -0
  440. package/sdk-test-utilities/node_modules/undici-types/filereader.d.ts +54 -0
  441. package/sdk-test-utilities/node_modules/undici-types/formdata.d.ts +108 -0
  442. package/sdk-test-utilities/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  443. package/sdk-test-utilities/node_modules/undici-types/global-origin.d.ts +7 -0
  444. package/sdk-test-utilities/node_modules/undici-types/handlers.d.ts +9 -0
  445. package/sdk-test-utilities/node_modules/undici-types/header.d.ts +4 -0
  446. package/sdk-test-utilities/node_modules/undici-types/index.d.ts +63 -0
  447. package/sdk-test-utilities/node_modules/undici-types/interceptors.d.ts +5 -0
  448. package/sdk-test-utilities/node_modules/undici-types/mock-agent.d.ts +50 -0
  449. package/sdk-test-utilities/node_modules/undici-types/mock-client.d.ts +25 -0
  450. package/sdk-test-utilities/node_modules/undici-types/mock-errors.d.ts +12 -0
  451. package/sdk-test-utilities/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  452. package/sdk-test-utilities/node_modules/undici-types/mock-pool.d.ts +25 -0
  453. package/sdk-test-utilities/node_modules/undici-types/package.json +55 -0
  454. package/sdk-test-utilities/node_modules/undici-types/patch.d.ts +71 -0
  455. package/sdk-test-utilities/node_modules/undici-types/pool-stats.d.ts +19 -0
  456. package/sdk-test-utilities/node_modules/undici-types/pool.d.ts +28 -0
  457. package/sdk-test-utilities/node_modules/undici-types/proxy-agent.d.ts +30 -0
  458. package/sdk-test-utilities/node_modules/undici-types/readable.d.ts +61 -0
  459. package/sdk-test-utilities/node_modules/undici-types/webidl.d.ts +220 -0
  460. package/sdk-test-utilities/node_modules/undici-types/websocket.d.ts +131 -0
@@ -0,0 +1,1424 @@
1
+ <div align='center'>
2
+
3
+ <h1>TypeBox</h1>
4
+
5
+ <p>JSON Schema Type Builder with Static Type Resolution for TypeScript</p>
6
+
7
+ <img src="https://github.com/sinclairzx81/typebox/blob/master/typebox.png?raw=true" />
8
+
9
+ <br />
10
+ <br />
11
+
12
+ [![npm version](https://badge.fury.io/js/%40sinclair%2Ftypebox.svg)](https://badge.fury.io/js/%40sinclair%2Ftypebox)
13
+ [![Downloads](https://img.shields.io/npm/dm/%40sinclair%2Ftypebox.svg)](https://www.npmjs.com/package/%40sinclair%2Ftypebox)
14
+ [![GitHub CI](https://github.com/sinclairzx81/typebox/workflows/GitHub%20CI/badge.svg)](https://github.com/sinclairzx81/typebox/actions)
15
+
16
+ </div>
17
+
18
+ <a name="Install"></a>
19
+
20
+ ## Install
21
+
22
+ #### Npm
23
+ ```bash
24
+ $ npm install @sinclair/typebox --save
25
+ ```
26
+
27
+ #### Deno
28
+ ```typescript
29
+ import { Static, Type } from 'npm:@sinclair/typebox'
30
+ ```
31
+
32
+ #### Esm
33
+
34
+ ```typescript
35
+ import { Static, Type } from 'https://esm.sh/@sinclair/typebox'
36
+ ```
37
+
38
+ ## Example
39
+
40
+ ```typescript
41
+ import { Static, Type } from '@sinclair/typebox'
42
+
43
+ const T = Type.Object({ // const T = {
44
+ x: Type.Number(), // type: 'object',
45
+ y: Type.Number(), // required: ['x', 'y', 'z'],
46
+ z: Type.Number() // properties: {
47
+ }) // x: { type: 'number' },
48
+ // y: { type: 'number' },
49
+ // z: { type: 'number' }
50
+ // }
51
+ // }
52
+
53
+ type T = Static<typeof T> // type T = {
54
+ // x: number,
55
+ // y: number,
56
+ // z: number
57
+ // }
58
+ ```
59
+
60
+
61
+ <a name="Overview"></a>
62
+
63
+ ## Overview
64
+
65
+ TypeBox is a runtime type builder that creates in-memory JSON Schema objects that can be statically inferred as TypeScript types. The schemas produced by this library are designed to match the static type assertion rules of the TypeScript compiler. TypeBox enables one to create a unified type that can be statically checked by TypeScript and runtime asserted using standard JSON Schema validation.
66
+
67
+ This library is designed to enable JSON schema to compose with the same flexibility as TypeScript's type system. It can be used as a simple tool to build up complex schemas or integrated into REST or RPC services to help validate data received over the wire.
68
+
69
+ License MIT
70
+
71
+ ## Contents
72
+ - [Install](#install)
73
+ - [Overview](#overview)
74
+ - [Usage](#usage)
75
+ - [Types](#types)
76
+ - [Standard](#types-standard)
77
+ - [Extended](#types-extended)
78
+ - [Modifiers](#types-modifiers)
79
+ - [Options](#types-options)
80
+ - [Generics](#types-generics)
81
+ - [References](#types-references)
82
+ - [Recursive](#types-recursive)
83
+ - [Conditional](#types-conditional)
84
+ - [Template Literal](#types-template-literal)
85
+ - [Guards](#types-guards)
86
+ - [Unsafe](#types-unsafe)
87
+ - [Strict](#types-strict)
88
+ - [Values](#values)
89
+ - [Create](#values-create)
90
+ - [Clone](#values-clone)
91
+ - [Check](#values-check)
92
+ - [Convert](#values-convert)
93
+ - [Cast](#values-cast)
94
+ - [Equal](#values-equal)
95
+ - [Hash](#values-hash)
96
+ - [Diff](#values-diff)
97
+ - [Patch](#values-patch)
98
+ - [Errors](#values-errors)
99
+ - [Mutate](#values-mutate)
100
+ - [Pointer](#values-pointer)
101
+ - [TypeCheck](#typecheck)
102
+ - [Ajv](#typecheck-ajv)
103
+ - [TypeCompiler](#typecheck-typecompiler)
104
+ - [TypeSystem](#typesystem)
105
+ - [Types](#typesystem-types)
106
+ - [Formats](#typesystem-formats)
107
+ - [Policies](#typesystem-policies)
108
+ - [Benchmark](#benchmark)
109
+ - [Compile](#benchmark-compile)
110
+ - [Validate](#benchmark-validate)
111
+ - [Compression](#benchmark-compression)
112
+ - [Contribute](#contribute)
113
+
114
+ <a name="usage"></a>
115
+
116
+ ## Usage
117
+
118
+ The following shows general usage.
119
+
120
+ ```typescript
121
+ import { Static, Type } from '@sinclair/typebox'
122
+
123
+ //--------------------------------------------------------------------------------------------
124
+ //
125
+ // Let's say you have the following type ...
126
+ //
127
+ //--------------------------------------------------------------------------------------------
128
+
129
+ type T = {
130
+ id: string,
131
+ name: string,
132
+ timestamp: number
133
+ }
134
+
135
+ //--------------------------------------------------------------------------------------------
136
+ //
137
+ // ... you can express this type in the following way.
138
+ //
139
+ //--------------------------------------------------------------------------------------------
140
+
141
+ const T = Type.Object({ // const T = {
142
+ id: Type.String(), // type: 'object',
143
+ name: Type.String(), // properties: {
144
+ timestamp: Type.Integer() // id: {
145
+ }) // type: 'string'
146
+ // },
147
+ // name: {
148
+ // type: 'string'
149
+ // },
150
+ // timestamp: {
151
+ // type: 'integer'
152
+ // }
153
+ // },
154
+ // required: [
155
+ // 'id',
156
+ // 'name',
157
+ // 'timestamp'
158
+ // ]
159
+ // }
160
+
161
+ //--------------------------------------------------------------------------------------------
162
+ //
163
+ // ... then infer back to the original static type this way.
164
+ //
165
+ //--------------------------------------------------------------------------------------------
166
+
167
+ type T = Static<typeof T> // type T = {
168
+ // id: string,
169
+ // name: string,
170
+ // timestamp: number
171
+ // }
172
+
173
+ //--------------------------------------------------------------------------------------------
174
+ //
175
+ // ... then use the type both as JSON schema and as a TypeScript type.
176
+ //
177
+ //--------------------------------------------------------------------------------------------
178
+
179
+ import { Value } from '@sinclair/typebox/value'
180
+
181
+ function receive(value: T) { // ... as a Static Type
182
+
183
+ if(Value.Check(T, value)) { // ... as a JSON Schema
184
+
185
+ // ok...
186
+ }
187
+ }
188
+ ```
189
+
190
+ <a name='types'></a>
191
+
192
+ ## Types
193
+
194
+ TypeBox types are JSON schema fragments that can be composed into more complex types. Each fragment is structured such that a JSON schema compliant validator can runtime assert a value the same way TypeScript will statically assert a type. TypeBox provides a set of Standard types which are used create JSON schema compliant schematics as well as an Extended type set used to create schematics for constructs native to JavaScript.
195
+
196
+ <a name='types-standard'></a>
197
+
198
+ ### Standard Types
199
+
200
+ The following table lists the Standard TypeBox types. These types are fully compatible with the JSON Schema Draft 6 specification.
201
+
202
+ ```typescript
203
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
204
+ │ TypeBox │ TypeScript │ JSON Schema │
205
+ │ │ │ │
206
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
207
+ │ const T = Type.Any() │ type T = any │ const T = { } │
208
+ │ │ │ │
209
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
210
+ │ const T = Type.Unknown() │ type T = unknown │ const T = { } │
211
+ │ │ │ │
212
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
213
+ │ const T = Type.String() │ type T = string │ const T = { │
214
+ │ │ │ type: 'string' │
215
+ │ │ │ } │
216
+ │ │ │ │
217
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
218
+ │ const T = Type.Number() │ type T = number │ const T = { │
219
+ │ │ │ type: 'number' │
220
+ │ │ │ } │
221
+ │ │ │ │
222
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
223
+ │ const T = Type.Integer() │ type T = number │ const T = { │
224
+ │ │ │ type: 'integer' │
225
+ │ │ │ } │
226
+ │ │ │ │
227
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
228
+ │ const T = Type.Boolean() │ type T = boolean │ const T = { │
229
+ │ │ │ type: 'boolean' │
230
+ │ │ │ } │
231
+ │ │ │ │
232
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
233
+ │ const T = Type.Null() │ type T = null │ const T = { │
234
+ │ │ │ type: 'null' │
235
+ │ │ │ } │
236
+ │ │ │ │
237
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
238
+ │ const T = Type.Literal(42) │ type T = 42 │ const T = { │
239
+ │ │ │ const: 42, │
240
+ │ │ │ type: 'number' │
241
+ │ │ │ } │
242
+ │ │ │ │
243
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
244
+ │ const T = Type.Array( │ type T = number[] │ const T = { │
245
+ │ Type.Number() │ │ type: 'array', │
246
+ │ ) │ │ items: { │
247
+ │ │ │ type: 'number' │
248
+ │ │ │ } │
249
+ │ │ │ } │
250
+ │ │ │ │
251
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
252
+ │ const T = Type.Object({ │ type T = { │ const T = { │
253
+ │ x: Type.Number(), │ x: number, │ type: 'object', │
254
+ │ y: Type.Number() │ y: number │ required: ['x', 'y'], │
255
+ │ }) │ } │ properties: { │
256
+ │ │ │ x: { │
257
+ │ │ │ type: 'number' │
258
+ │ │ │ }, { │
259
+ │ │ │ type: 'number' │
260
+ │ │ │ } │
261
+ │ │ │ } │
262
+ │ │ │ } │
263
+ │ │ │ │
264
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
265
+ │ const T = Type.Tuple([ │ type T = [number, number] │ const T = { │
266
+ │ Type.Number(), │ │ type: 'array', │
267
+ │ Type.Number() │ │ items: [{ │
268
+ │ ]) │ │ type: 'number' │
269
+ │ │ │ }, { │
270
+ │ │ │ type: 'number' │
271
+ │ │ │ }], │
272
+ │ │ │ additionalItems: false, │
273
+ │ │ │ minItems: 2, │
274
+ │ │ │ maxItems: 2 │
275
+ │ │ │ } │
276
+ │ │ │ │
277
+ │ │ │ │
278
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
279
+ │ enum Foo { │ enum Foo { │ const T = { │
280
+ │ A, │ A, │ anyOf: [{ │
281
+ │ B │ B │ type: 'number', │
282
+ │ } │ } │ const: 0 │
283
+ │ │ │ }, { │
284
+ │ const T = Type.Enum(Foo) │ type T = Foo │ type: 'number', │
285
+ │ │ │ const: 1 │
286
+ │ │ │ }] │
287
+ │ │ │ } │
288
+ │ │ │ │
289
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
290
+ │ const T = Type.KeyOf( │ type T = keyof { │ const T = { │
291
+ │ Type.Object({ │ x: number, │ anyOf: [{ │
292
+ │ x: Type.Number(), │ y: number │ type: 'string', │
293
+ │ y: Type.Number() │ } │ const: 'x' │
294
+ │ }) │ │ }, { │
295
+ │ ) │ │ type: 'string', │
296
+ │ │ │ const: 'y' │
297
+ │ │ │ }] │
298
+ │ │ │ } │
299
+ │ │ │ │
300
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
301
+ │ const T = Type.Union([ │ type T = string | number │ const T = { │
302
+ │ Type.String(), │ │ anyOf: [{ │
303
+ │ Type.Number() │ │ type: 'string' │
304
+ │ ]) │ │ }, { │
305
+ │ │ │ type: 'number' │
306
+ │ │ │ }] │
307
+ │ │ │ } │
308
+ │ │ │ │
309
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
310
+ │ const T = Type.Intersect([ │ type T = { │ const T = { │
311
+ │ Type.Object({ │ x: number │ allOf: [{ │
312
+ │ x: Type.Number() │ } & { │ type: 'object', │
313
+ │ }), │ y: number │ required: ['x'], │
314
+ │ Type.Object({ │ } │ properties: { │
315
+ │ y: Type.Number() │ │ x: { │
316
+ │ ]) │ │ type: 'number' │
317
+ │ ]) │ │ } │
318
+ │ │ │ } │
319
+ │ │ │ }, { │
320
+ │ │ │ type: 'object', |
321
+ │ │ │ required: ['y'], │
322
+ │ │ │ properties: { │
323
+ │ │ │ y: { │
324
+ │ │ │ type: 'number' │
325
+ │ │ │ } │
326
+ │ │ │ } │
327
+ │ │ │ }] │
328
+ │ │ │ } │
329
+ │ │ │ │
330
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
331
+ │ const T = Type.Composite([ │ type I = { │ const T = { │
332
+ │ Type.Object({ │ x: number │ type: 'object', │
333
+ │ x: Type.Number() │ } & { │ required: ['x', 'y'], │
334
+ │ }), │ y: number │ properties: { │
335
+ │ Type.Object({ │ } │ x: { │
336
+ │ y: Type.Number() │ │ type: 'number' │
337
+ │ }) │ type T = { │ }, │
338
+ │ ]) │ [K in keyof I]: I[K] │ y: { │
339
+ │ │ } │ type: 'number' │
340
+ │ │ │ } │
341
+ │ │ │ } │
342
+ │ │ │ } │
343
+ │ │ │ │
344
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
345
+ │ const T = Type.Never() │ type T = never │ const T = { │
346
+ │ │ │ not: {} │
347
+ │ │ │ } │
348
+ │ │ │ │
349
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
350
+ │ const T = Type.Not( | type T = string │ const T = { │
351
+ | Type.Union([ │ │ allOf: [{ │
352
+ │ Type.Literal('x'), │ │ not: { │
353
+ │ Type.Literal('y'), │ │ anyOf: [ │
354
+ │ Type.Literal('z') │ │ { const: 'x' }, │
355
+ │ ]), │ │ { const: 'y' }, │
356
+ │ Type.String() │ │ { const: 'z' } │
357
+ │ ) │ │ ] │
358
+ │ │ │ } │
359
+ │ │ │ }, { │
360
+ │ │ │ type: 'string' │
361
+ │ │ │ }] │
362
+ │ │ │ } │
363
+ │ │ │ │
364
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
365
+ │ const T = Type.Extends( │ type T = │ const T = { │
366
+ │ Type.String(), │ string extends number │ const: false, │
367
+ │ Type.Number(), │ true : false │ type: 'boolean' │
368
+ │ Type.Literal(true), │ │ } │
369
+ │ Type.Literal(false) │ │ │
370
+ │ ) │ │ │
371
+ │ │ │ │
372
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
373
+ │ const T = Type.Extract( │ type T = Extract< │ const T = { │
374
+ │ Type.Union([ │ string | number, │ type: 'string' │
375
+ │ Type.String(), │ string │ } │
376
+ │ Type.Number(), │ > │ │
377
+ │ ]), │ │ │
378
+ │ Type.String() │ │ │
379
+ │ ) │ │ │
380
+ │ │ │ │
381
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
382
+ │ const T = Type.Exclude( │ type T = Exclude< │ const T = { │
383
+ │ Type.Union([ │ string | number, │ type: 'number' │
384
+ │ Type.String(), │ string │ } │
385
+ │ Type.Number(), │ > │ │
386
+ │ ]), │ │ │
387
+ │ Type.String() │ │ │
388
+ │ ) │ │ │
389
+ │ │ │ │
390
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
391
+ │ const U = Type.Union([ │ type U = 'open' | 'close' │ const T = { │
392
+ │ Type.Literal('open'), │ │ type: 'string', │
393
+ │ Type.Literal('close') │ type T = `on${U}` │ pattern: '^on(open|close)$' │
394
+ │ ]) │ │ } │
395
+ │ │ │ │
396
+ │ const T = Type │ │ │
397
+ │ .TemplateLiteral([ │ │ │
398
+ │ Type.Literal('on'), │ │ │
399
+ │ U │ │ │
400
+ │ ]) │ │ │
401
+ │ │ │ │
402
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
403
+ │ const T = Type.Record( │ type T = Record< │ const T = { │
404
+ │ Type.String(), │ string, │ type: 'object', │
405
+ │ Type.Number() │ number │ patternProperties: { │
406
+ │ ) │ > │ '^.*$': { │
407
+ │ │ │ type: 'number' │
408
+ │ │ │ } │
409
+ │ │ │ } │
410
+ │ │ │ } │
411
+ │ │ │ │
412
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
413
+ │ const T = Type.Partial( │ type T = Partial<{ │ const T = { │
414
+ │ Type.Object({ │ x: number, │ type: 'object', │
415
+ │ x: Type.Number(), │ y: number │ properties: { │
416
+ │ y: Type.Number() | }> │ x: { │
417
+ │ }) │ │ type: 'number' │
418
+ │ ) │ │ }, │
419
+ │ │ │ y: { │
420
+ │ │ │ type: 'number' │
421
+ │ │ │ } │
422
+ │ │ │ } │
423
+ │ │ │ } │
424
+ │ │ │ │
425
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
426
+ │ const T = Type.Required( │ type T = Required<{ │ const T = { │
427
+ │ Type.Object({ │ x?: number, │ type: 'object', │
428
+ │ x: Type.Optional( │ y?: number │ required: ['x', 'y'], │
429
+ │ Type.Number() | }> │ properties: { │
430
+ │ ), │ │ x: { │
431
+ │ y: Type.Optional( │ │ type: 'number' │
432
+ │ Type.Number() │ │ }, │
433
+ │ ) │ │ y: { │
434
+ │ }) │ │ type: 'number' │
435
+ │ ) │ │ } │
436
+ │ │ │ } │
437
+ │ │ │ } │
438
+ │ │ │ │
439
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
440
+ │ const T = Type.Pick( │ type T = Pick<{ │ const T = { │
441
+ │ Type.Object({ │ x: number, │ type: 'object', │
442
+ │ x: Type.Number(), │ y: number │ required: ['x'], │
443
+ │ y: Type.Number() │ }, 'x'> │ properties: { │
444
+ │ }), ['x'] | │ x: { │
445
+ │ ) │ │ type: 'number' │
446
+ │ │ │ } │
447
+ │ │ │ } │
448
+ │ │ │ } │
449
+ │ │ │ │
450
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
451
+ │ const T = Type.Omit( │ type T = Omit<{ │ const T = { │
452
+ │ Type.Object({ │ x: number, │ type: 'object', │
453
+ │ x: Type.Number(), │ y: number │ required: ['y'], │
454
+ │ y: Type.Number() │ }, 'x'> │ properties: { │
455
+ │ }), ['x'] | │ y: { │
456
+ │ ) │ │ type: 'number' │
457
+ │ │ │ } │
458
+ │ │ │ } │
459
+ │ │ │ } │
460
+ │ │ │ │
461
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
462
+ │ const T = Type.Object({ │ type T = { │ const R = { │
463
+ │ x: Type.Number(), │ x: number, │ $ref: 'T' │
464
+ │ y: Type.Number() │ y: number │ } │
465
+ │ }, { $id: 'T' }) | } │ │
466
+ │ │ │ │
467
+ │ const R = Type.Ref(T) │ type R = T │ │
468
+ │ │ │ │
469
+ │ │ │ │
470
+ │ │ │ │
471
+ │ │ │ │
472
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
473
+ ```
474
+
475
+ <a name='types-extended'></a>
476
+
477
+ ### Extended Types
478
+
479
+ TypeBox provides several extended types that can be used to produce schematics for common JavaScript constructs. These types can not be used with standard JSON schema validators; but are useful to help frame schematics for RPC interfaces that may receive JSON validated data. Extended types are prefixed with the `[Extended]` doc comment for convenience. The following table lists the supported types.
480
+
481
+ ```typescript
482
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
483
+ │ TypeBox │ TypeScript │ Extended Schema │
484
+ │ │ │ │
485
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
486
+ │ const T = Type.Constructor([ │ type T = new ( │ const T = { │
487
+ │ Type.String(), │ arg0: string, │ type: 'object', │
488
+ │ Type.Number() │ arg1: number │ instanceOf: 'Constructor', │
489
+ │ ], Type.Boolean()) │ ) => boolean │ parameters: [{ │
490
+ │ │ │ type: 'string' │
491
+ │ │ │ }, { │
492
+ │ │ │ type: 'number' │
493
+ │ │ │ }], │
494
+ │ │ │ return: { │
495
+ │ │ │ type: 'boolean' │
496
+ │ │ │ } │
497
+ │ │ │ } │
498
+ │ │ │ │
499
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
500
+ │ const T = Type.Function([ │ type T = ( │ const T = { │
501
+ | Type.String(), │ arg0: string, │ type : 'object', │
502
+ │ Type.Number() │ arg1: number │ instanceOf: 'Function', │
503
+ │ ], Type.Boolean()) │ ) => boolean │ parameters: [{ │
504
+ │ │ │ type: 'string' │
505
+ │ │ │ }, { │
506
+ │ │ │ type: 'number' │
507
+ │ │ │ }], │
508
+ │ │ │ return: { │
509
+ │ │ │ type: 'boolean' │
510
+ │ │ │ } │
511
+ │ │ │ } │
512
+ │ │ │ │
513
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
514
+ │ const T = Type.Promise( │ type T = Promise<string> │ const T = { │
515
+ │ Type.String() │ │ type: 'object', │
516
+ │ ) │ │ instanceOf: 'Promise', │
517
+ │ │ │ item: { │
518
+ │ │ │ type: 'string' │
519
+ │ │ │ } │
520
+ │ │ │ } │
521
+ │ │ │ │
522
+ │ │ │ │
523
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
524
+ │ const T = Type.Uint8Array() │ type T = Uint8Array │ const T = { │
525
+ │ │ │ type: 'object', │
526
+ │ │ │ instanceOf: 'Uint8Array' │
527
+ │ │ │ } │
528
+ │ │ │ │
529
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
530
+ │ const T = Type.Date() │ type T = Date │ const T = { │
531
+ │ │ │ type: 'object', │
532
+ │ │ │ instanceOf: 'Date' │
533
+ │ │ │ } │
534
+ │ │ │ │
535
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
536
+ │ const T = Type.Undefined() │ type T = undefined │ const T = { │
537
+ │ │ │ type: 'null', │
538
+ │ │ │ typeOf: 'Undefined' │
539
+ │ │ │ } │
540
+ │ │ │ │
541
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
542
+ │ const T = Type.RegEx(/foo/) │ type T = string │ const T = { │
543
+ │ │ │ type: 'string', │
544
+ │ │ │ pattern: 'foo' │
545
+ │ │ │ } │
546
+ │ │ │ │
547
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
548
+ │ const T = Type.Symbol() │ type T = symbol │ const T = { │
549
+ │ │ │ type: 'null', │
550
+ │ │ │ typeOf: 'Symbol' │
551
+ │ │ │ } │
552
+ │ │ │ │
553
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
554
+ │ const T = Type.BigInt() │ type T = bigint │ const T = { │
555
+ │ │ │ type: 'null', │
556
+ │ │ │ typeOf: 'BigInt' │
557
+ │ │ │ } │
558
+ │ │ │ │
559
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
560
+ │ const T = Type.Void() │ type T = void │ const T = { │
561
+ │ │ │ type: 'null' │
562
+ │ │ │ typeOf: 'Void' │
563
+ │ │ │ } │
564
+ │ │ │ │
565
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
566
+ ```
567
+
568
+ <a name='types-modifiers'></a>
569
+
570
+ ### Modifiers
571
+
572
+ TypeBox provides modifiers that allow schema properties to be statically inferred as `readonly` or `optional`. The following table shows the supported modifiers and how they map between TypeScript and JSON Schema.
573
+
574
+ ```typescript
575
+ ┌────────────────────────────────┬─────────────────────────────┬────────────────────────────────┐
576
+ │ TypeBox │ TypeScript │ JSON Schema │
577
+ │ │ │ │
578
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
579
+ │ const T = Type.Object({ │ type T = { │ const T = { │
580
+ │ name: Type.Optional( │ name?: string │ type: 'object', │
581
+ │ Type.String() │ } │ properties: { │
582
+ │ ) │ │ name: { │
583
+ │ }) │ │ type: 'string' │
584
+ │ │ │ } │
585
+ │ │ │ } │
586
+ │ │ │ } │
587
+ │ │ │ │
588
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
589
+ │ const T = Type.Object({ │ type T = { │ const T = { │
590
+ │ name: Type.Readonly( │ readonly name: string │ type: 'object', │
591
+ │ Type.String() │ } │ properties: { │
592
+ │ ) │ │ name: { │
593
+ │ }) │ │ type: 'string' │
594
+ │ │ │ } │
595
+ │ │ │ }, │
596
+ │ │ │ required: ['name'] │
597
+ │ │ │ } │
598
+ │ │ │ │
599
+ ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
600
+ │ const T = Type.Object({ │ type T = { │ const T = { │
601
+ │ name: Type.ReadonlyOptional( │ readonly name?: string │ type: 'object', │
602
+ │ Type.String() │ } │ properties: { │
603
+ │ ) │ │ name: { │
604
+ │ }) │ │ type: 'string' │
605
+ │ │ │ } │
606
+ │ │ │ } │
607
+ │ │ │ } │
608
+ │ │ │ │
609
+ └────────────────────────────────┴─────────────────────────────┴────────────────────────────────┘
610
+ ```
611
+
612
+ <a name='types-options'></a>
613
+
614
+ ### Options
615
+
616
+ You can pass JSON Schema options on the last argument of any type. Option hints specific to each type are provided for convenience.
617
+
618
+ ```typescript
619
+ // String must be an email
620
+ const T = Type.String({ // const T = {
621
+ format: 'email' // type: 'string',
622
+ }) // format: 'email'
623
+ // }
624
+
625
+ // Mumber must be a multiple of 2
626
+ const T = Type.Number({ // const T = {
627
+ multipleOf: 2 // type: 'number',
628
+ }) // multipleOf: 2
629
+ // }
630
+
631
+ // Array must have at least 5 integer values
632
+ const T = Type.Array(Type.Integer(), { // const T = {
633
+ minItems: 5 // type: 'array',
634
+ }) // minItems: 5,
635
+ // items: {
636
+ // type: 'integer'
637
+ // }
638
+ // }
639
+
640
+ ```
641
+
642
+ <a name='types-generics'></a>
643
+
644
+ ### Generic Types
645
+
646
+ Generic types can be created with generic functions constrained to type `TSchema`. The following creates a generic `Vector<T>` type.
647
+
648
+ ```typescript
649
+ import { Type, Static, TSchema } from '@sinclair/typebox'
650
+
651
+ const Vector = <T extends TSchema>(t: T) => Type.Object({ x: t, y: t, z: t })
652
+
653
+ const NumberVector = Vector(Type.Number()) // const NumberVector = {
654
+ // type: 'object',
655
+ // required: ['x', 'y', 'z'],
656
+ // properties: {
657
+ // x: { type: 'number' },
658
+ // y: { type: 'number' },
659
+ // z: { type: 'number' }
660
+ // }
661
+ // }
662
+
663
+ type NumberVector = Static<typeof NumberVector> // type NumberVector = {
664
+ // x: number,
665
+ // y: number,
666
+ // z: number
667
+ // }
668
+
669
+ const BooleanVector = Vector(Type.Boolean()) // const BooleanVector = {
670
+ // type: 'object',
671
+ // required: ['x', 'y', 'z'],
672
+ // properties: {
673
+ // x: { type: 'boolean' },
674
+ // y: { type: 'boolean' },
675
+ // z: { type: 'boolean' }
676
+ // }
677
+ // }
678
+
679
+ type BooleanVector = Static<typeof BooleanVector> // type BooleanVector = {
680
+ // x: boolean,
681
+ // y: boolean,
682
+ // z: boolean
683
+ // }
684
+ ```
685
+
686
+ The following creates a generic `Nullable<T>` type.
687
+
688
+ ```typescript
689
+ const Nullable = <T extends TSchema>(schema: T) => Type.Union([schema, Type.Null()])
690
+
691
+ const T = Nullable(Type.String()) // const T = {
692
+ // anyOf: [
693
+ // { type: 'string' },
694
+ // { type: 'null' }
695
+ // ]
696
+ // }
697
+
698
+ type T = Static<typeof T> // type T = string | null
699
+ ```
700
+
701
+ <a name='types-references'></a>
702
+
703
+ ### Reference Types
704
+
705
+ Reference types are supported with `Type.Ref`. The target type must specify a valid `$id`.
706
+
707
+ ```typescript
708
+ const T = Type.String({ $id: 'T' }) // const T = {
709
+ // $id: 'T',
710
+ // type: 'string'
711
+ // }
712
+
713
+ const R = Type.Ref(T) // const R = {
714
+ // $ref: 'T'
715
+ // }
716
+ ```
717
+
718
+ <a name='types-recursive'></a>
719
+
720
+ ### Recursive Types
721
+
722
+ Recursive types are supported with `Type.Recursive`
723
+
724
+ ```typescript
725
+ const Node = Type.Recursive(Node => Type.Object({ // const Node = {
726
+ id: Type.String(), // $id: 'Node',
727
+ nodes: Type.Array(Node) // type: 'object',
728
+ }), { $id: 'Node' }) // properties: {
729
+ // id: {
730
+ // type: 'string'
731
+ // },
732
+ // nodes: {
733
+ // type: 'array',
734
+ // items: {
735
+ // $ref: 'Node'
736
+ // }
737
+ // }
738
+ // },
739
+ // required: [
740
+ // 'id',
741
+ // 'nodes'
742
+ // ]
743
+ // }
744
+
745
+ type Node = Static<typeof Node> // type Node = {
746
+ // id: string
747
+ // nodes: Node[]
748
+ // }
749
+
750
+ function test(node: Node) {
751
+ const id = node.nodes[0].nodes[0].id // id is string
752
+ }
753
+ ```
754
+
755
+ <a name='types-conditional'></a>
756
+
757
+ ### Conditional Types
758
+
759
+ Conditional types are supported with `Type.Extends`, `Type.Exclude` and `Type.Extract`
760
+
761
+ ```typescript
762
+ // TypeScript
763
+
764
+ type T0 = string extends number ? true : false // type T0 = false
765
+
766
+ type T1 = Extract<string | number, number> // type T1 = number
767
+
768
+ type T2 = Exclude<string | number, number> // type T2 = string
769
+
770
+ // TypeBox
771
+
772
+ const T0 = Type.Extends(Type.String(), Type.Number(), Type.Literal(true), Type.Literal(false))
773
+
774
+ const T1 = Type.Extract(Type.Union([Type.String(), Type.Number()]), Type.Number())
775
+
776
+ const T2 = Type.Exclude(Type.Union([Type.String(), Type.Number()]), Type.Number())
777
+
778
+
779
+ type T0 = Static<typeof T0> // type T0 = false
780
+
781
+ type T1 = Static<typeof T1> // type T1 = number
782
+
783
+ type T2 = Static<typeof T2> // type T2 = string
784
+ ```
785
+
786
+ <a name='types-template-literal'></a>
787
+
788
+ ### Template Literal Types
789
+
790
+ Template Literal types are supported with `Type.TemplateLiteral`
791
+
792
+ ```typescript
793
+ // TypeScript
794
+
795
+ type T = `option${'A'|'B'}` // type T = 'optionA' | 'optionB'
796
+
797
+ type R = Record<T, string> // type R = {
798
+ // optionA: string
799
+ // optionB: string
800
+ // }
801
+
802
+ // TypeBox
803
+
804
+ const T = Type.TemplateLiteral([ // const T = {
805
+ Type.Literal('option'), // pattern: '^option(A|B)$',
806
+ Type.Union([ // type: 'string'
807
+ Type.Literal('A'), // }
808
+ Type.Literal('B')
809
+ ])
810
+ ])
811
+
812
+ const R = Type.Record(T, Type.String()) // const R = {
813
+ // type: 'object',
814
+ // required: ['optionA', 'optionB'],
815
+ // properties: {
816
+ // optionA: {
817
+ // type: 'string'
818
+ // },
819
+ // optionB: {
820
+ // type: 'string'
821
+ // }
822
+ // }
823
+ // }
824
+
825
+ type T = Static<typeof T> // type T = 'optionA' | 'optionB'
826
+
827
+ type R = Static<typeof R> // type R = {
828
+ // optionA: string
829
+ // optionB: string
830
+ // }
831
+ ```
832
+
833
+ <a name='types-unsafe'></a>
834
+
835
+ ### Unsafe
836
+
837
+ Use `Type.Unsafe` to create custom schematics with user defined inference rules.
838
+
839
+ ```typescript
840
+ const T = Type.Unsafe<string>({ type: 'number' }) // const T = {
841
+ // type: 'number'
842
+ // }
843
+
844
+ type T = Static<typeof T> // type T = string
845
+ ```
846
+
847
+ The `Type.Unsafe` type can be useful to express specific OpenAPI schema representations.
848
+
849
+ ```typescript
850
+ import { Type, Static, TSchema } from '@sinclair/typebox'
851
+
852
+ // Nullable<T>
853
+
854
+ function Nullable<T extends TSchema>(schema: T) {
855
+ return Type.Unsafe<Static<T> | null>({ ...schema, nullable: true })
856
+ }
857
+
858
+ const T = Nullable(Type.String()) // const T = {
859
+ // type: 'string',
860
+ // nullable: true
861
+ // }
862
+
863
+ type T = Static<typeof T> // type T = string | null
864
+
865
+ // StringEnum<string[]>
866
+
867
+ function StringEnum<T extends string[]>(values: [...T]) {
868
+ return Type.Unsafe<T[number]>({ type: 'string', enum: values })
869
+ }
870
+
871
+ const T = StringEnum(['A', 'B', 'C']) // const T = {
872
+ // enum: ['A', 'B', 'C']
873
+ // }
874
+
875
+ type T = Static<typeof T> // type T = 'A' | 'B' | 'C'
876
+ ```
877
+
878
+ <a name='types-guards'></a>
879
+
880
+ ### Guards
881
+
882
+ TypeBox provides a `TypeGuard` module that can be used for reflection and asserting values as types.
883
+
884
+ ```typescript
885
+ import { Type, TypeGuard } from '@sinclair/typebox'
886
+
887
+ const T = Type.String()
888
+
889
+ if(TypeGuard.TString(T)) {
890
+
891
+ // T is TString
892
+ }
893
+ ```
894
+
895
+ <a name='types-strict'></a>
896
+
897
+ ### Strict
898
+
899
+ TypeBox schemas contain the `Kind` and `Modifier` symbol properties. These properties are used for type composition and reflection. These properties are not strictly valid JSON schema; so in some cases it may be desirable to omit them. TypeBox provides a `Type.Strict` function that will omit these properties if necessary.
900
+
901
+ ```typescript
902
+ const T = Type.Object({ // const T = {
903
+ name: Type.Optional(Type.String()) // [Kind]: 'Object',
904
+ }) // type: 'object',
905
+ // properties: {
906
+ // name: {
907
+ // [Kind]: 'String',
908
+ // type: 'string',
909
+ // [Modifier]: 'Optional'
910
+ // }
911
+ // }
912
+ // }
913
+
914
+ const U = Type.Strict(T) // const U = {
915
+ // type: 'object',
916
+ // properties: {
917
+ // name: {
918
+ // type: 'string'
919
+ // }
920
+ // }
921
+ // }
922
+ ```
923
+
924
+ <a name='values'></a>
925
+
926
+ ## Values
927
+
928
+ TypeBox provides an optional utility module that can be used to perform common operations on JavaScript values. This module includes functionality to create, check and cast values from types as well as check equality, clone, diff and patch JavaScript values. This module is provided via optional import.
929
+
930
+ ```typescript
931
+ import { Value } from '@sinclair/typebox/value'
932
+ ```
933
+
934
+ <a name='values-create'></a>
935
+
936
+ ### Create
937
+
938
+ Use the Create function to create a value from a type. TypeBox will use default values if specified.
939
+
940
+ ```typescript
941
+ const T = Type.Object({ x: Type.Number(), y: Type.Number({ default: 42 }) })
942
+
943
+ const A = Value.Create(T) // const A = { x: 0, y: 42 }
944
+ ```
945
+
946
+ <a name='values-clone'></a>
947
+
948
+ ### Clone
949
+
950
+ Use the Clone function to deeply clone a value
951
+
952
+ ```typescript
953
+ const A = Value.Clone({ x: 1, y: 2, z: 3 }) // const A = { x: 1, y: 2, z: 3 }
954
+ ```
955
+
956
+ <a name='values-check'></a>
957
+
958
+ ### Check
959
+
960
+ Use the Check function to type check a value
961
+
962
+ ```typescript
963
+ const T = Type.Object({ x: Type.Number() })
964
+
965
+ const R = Value.Check(T, { x: 1 }) // const R = true
966
+ ```
967
+
968
+ <a name='values-convert'></a>
969
+
970
+ ### Convert
971
+
972
+ Use the Convert function to convert a value into its target type if a reasonable conversion is possible.
973
+
974
+ ```typescript
975
+ const T = Type.Object({ x: Type.Number() })
976
+
977
+ const R1 = Value.Convert(T, { x: '3.14' }) // const R1 = { x: 3.14 }
978
+
979
+ const R2 = Value.Convert(T, { x: 'not a number' }) // const R2 = { x: 'not a number' }
980
+ ```
981
+
982
+ <a name='values-cast'></a>
983
+
984
+ ### Cast
985
+
986
+ Use the Cast function to cast a value into a type. The cast function will retain as much information as possible from the original value.
987
+
988
+ ```typescript
989
+ const T = Type.Object({ x: Type.Number(), y: Type.Number() }, { additionalProperties: false })
990
+
991
+ const X = Value.Cast(T, null) // const X = { x: 0, y: 0 }
992
+
993
+ const Y = Value.Cast(T, { x: 1 }) // const Y = { x: 1, y: 0 }
994
+
995
+ const Z = Value.Cast(T, { x: 1, y: 2, z: 3 }) // const Z = { x: 1, y: 2 }
996
+ ```
997
+
998
+ <a name='values-equal'></a>
999
+
1000
+ ### Equal
1001
+
1002
+ Use the Equal function to deeply check for value equality.
1003
+
1004
+ ```typescript
1005
+ const R = Value.Equal( // const R = true
1006
+ { x: 1, y: 2, z: 3 },
1007
+ { x: 1, y: 2, z: 3 }
1008
+ )
1009
+ ```
1010
+
1011
+ <a name='values-hash'></a>
1012
+
1013
+ ### Hash
1014
+
1015
+ Use the Hash function to create a [FNV1A-64](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) non cryptographic hash of a value.
1016
+
1017
+ ```typescript
1018
+ const A = Value.Hash({ x: 1, y: 2, z: 3 }) // const A = 2910466848807138541n
1019
+
1020
+ const B = Value.Hash({ x: 1, y: 4, z: 3 }) // const B = 1418369778807423581n
1021
+ ```
1022
+
1023
+ <a name='values-diff'></a>
1024
+
1025
+ ### Diff
1026
+
1027
+ Use the Diff function to produce a sequence of edits to transform one value into another.
1028
+
1029
+ ```typescript
1030
+ const E = Value.Diff( // const E = [
1031
+ { x: 1, y: 2, z: 3 }, // { type: 'update', path: '/y', value: 4 },
1032
+ { y: 4, z: 5, w: 6 } // { type: 'update', path: '/z', value: 5 },
1033
+ ) // { type: 'insert', path: '/w', value: 6 },
1034
+ // { type: 'delete', path: '/x' }
1035
+ // ]
1036
+ ```
1037
+
1038
+ <a name='values-patch'></a>
1039
+
1040
+ ### Patch
1041
+
1042
+ Use the Patch function to apply edits
1043
+
1044
+ ```typescript
1045
+ const A = { x: 1, y: 2 }
1046
+
1047
+ const B = { x: 3 }
1048
+
1049
+ const E = Value.Diff(A, B) // const E = [
1050
+ // { type: 'update', path: '/x', value: 3 },
1051
+ // { type: 'delete', path: '/y' }
1052
+ // ]
1053
+
1054
+ const C = Value.Patch<typeof B>(A, E) // const C = { x: 3 }
1055
+ ```
1056
+
1057
+ <a name='values-errors'></a>
1058
+
1059
+ ### Errors
1060
+
1061
+ Use the Errors function enumerate validation errors.
1062
+
1063
+ ```typescript
1064
+ const T = Type.Object({ x: Type.Number(), y: Type.Number() })
1065
+
1066
+ const R = [...Value.Errors(T, { x: '42' })] // const R = [{
1067
+ // schema: { type: 'number' },
1068
+ // path: '/x',
1069
+ // value: '42',
1070
+ // message: 'Expected number'
1071
+ // }, {
1072
+ // schema: { type: 'number' },
1073
+ // path: '/y',
1074
+ // value: undefined,
1075
+ // message: 'Expected number'
1076
+ // }]
1077
+ ```
1078
+
1079
+ <a name='values-mutate'></a>
1080
+
1081
+ ### Mutate
1082
+
1083
+ Use the Mutate function to perform a deep mutable value assignment while retaining internal references.
1084
+
1085
+ ```typescript
1086
+ const Y = { z: 1 } // const Y = { z: 1 }
1087
+
1088
+ const X = { y: Y } // const X = { y: { z: 1 } }
1089
+
1090
+ const A = { x: X } // const A = { x: { y: { z: 1 } } }
1091
+
1092
+
1093
+ Value.Mutate(A, { x: { y: { z: 2 } } }) // const A' = { x: { y: { z: 2 } } }
1094
+
1095
+ const R0 = A.x.y.z === 2 // const R0 = 2
1096
+
1097
+ const R1 = A.x.y === Y // const R1 = true
1098
+
1099
+ const R2 = A.x === X // const R2 = true
1100
+ ```
1101
+
1102
+ <a name='values-pointer'></a>
1103
+
1104
+ ### Pointer
1105
+
1106
+ Use ValuePointer to perform mutable updates on existing values using [RFC6901](https://www.rfc-editor.org/rfc/rfc6901) JSON Pointers.
1107
+
1108
+ ```typescript
1109
+ import { ValuePointer } from '@sinclair/typebox/value'
1110
+
1111
+ const A = { x: 0, y: 0, z: 0 }
1112
+
1113
+ ValuePointer.Set(A, '/x', 1) // const A' = { x: 1, y: 0, z: 0 }
1114
+
1115
+ ValuePointer.Set(A, '/y', 1) // const A' = { x: 1, y: 1, z: 0 }
1116
+
1117
+ ValuePointer.Set(A, '/z', 1) // const A' = { x: 1, y: 1, z: 1 }
1118
+ ```
1119
+
1120
+ <a name='typecheck'></a>
1121
+
1122
+ ## TypeCheck
1123
+
1124
+ TypeBox types target JSON Schema draft 6 so are compatible with any validator that supports this specification. TypeBox also provides a built in type checking compiler designed specifically for high performance compilation and value assertion.
1125
+
1126
+ The following sections detail using Ajv and TypeBox's compiler infrastructure.
1127
+
1128
+ <a name='typecheck-ajv'></a>
1129
+
1130
+ ## Ajv
1131
+
1132
+ The following shows the recommended setup for Ajv.
1133
+
1134
+ ```bash
1135
+ $ npm install ajv ajv-formats --save
1136
+ ```
1137
+
1138
+ ```typescript
1139
+ import { Type } from '@sinclair/typebox'
1140
+ import addFormats from 'ajv-formats'
1141
+ import Ajv from 'ajv'
1142
+
1143
+ const ajv = addFormats(new Ajv({}), [
1144
+ 'date-time',
1145
+ 'time',
1146
+ 'date',
1147
+ 'email',
1148
+ 'hostname',
1149
+ 'ipv4',
1150
+ 'ipv6',
1151
+ 'uri',
1152
+ 'uri-reference',
1153
+ 'uuid',
1154
+ 'uri-template',
1155
+ 'json-pointer',
1156
+ 'relative-json-pointer',
1157
+ 'regex'
1158
+ ])
1159
+
1160
+ const C = ajv.compile(Type.Object({
1161
+ x: Type.Number(),
1162
+ y: Type.Number(),
1163
+ z: Type.Number()
1164
+ }))
1165
+
1166
+ const R = C({ x: 1, y: 2, z: 3 }) // const R = true
1167
+ ```
1168
+
1169
+ <a name='typecheck-typecompiler'></a>
1170
+
1171
+ ### TypeCompiler
1172
+
1173
+ The TypeBox TypeCompiler is a high performance JIT compiler that transforms TypeBox types into optimized JavaScript validation routines. The compiler is tuned for fast compilation as well as fast value assertion. It is designed to serve as a validation backend that can be integrated into larger applications; but can also be used as a general purpose validator.
1174
+
1175
+ The TypeCompiler is provided as an optional import.
1176
+
1177
+ ```typescript
1178
+ import { TypeCompiler } from '@sinclair/typebox/compiler'
1179
+ ```
1180
+
1181
+ Use the `Compile(...)` function to compile a type.
1182
+
1183
+ ```typescript
1184
+ const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
1185
+ x: Type.Number(), // x: TNumber;
1186
+ y: Type.Number(), // y: TNumber;
1187
+ z: Type.Number() // z: TNumber;
1188
+ })) // }>>
1189
+
1190
+ const R = C.Check({ x: 1, y: 2, z: 3 }) // const R = true
1191
+ ```
1192
+
1193
+ Use the `Errors(...)` function to produce diagnostic errors for a value. The `Errors(...)` function will return an iterator that if enumerated; will perform an exhaustive check across the entire value and yield any error found. For performance, this function should only be called after failed `Check(...)`. Applications may also choose to yield only the first value to avoid exhaustive error generation.
1194
+
1195
+ ```typescript
1196
+ const C = TypeCompiler.Compile(Type.Object({ // const C: TypeCheck<TObject<{
1197
+ x: Type.Number(), // x: TNumber;
1198
+ y: Type.Number(), // y: TNumber;
1199
+ z: Type.Number() // z: TNumber;
1200
+ })) // }>>
1201
+
1202
+ const value = { }
1203
+
1204
+ const errors = [...C.Errors(value)] // const errors = [{
1205
+ // schema: { type: 'number' },
1206
+ // path: '/x',
1207
+ // value: undefined,
1208
+ // message: 'Expected number'
1209
+ // }, {
1210
+ // schema: { type: 'number' },
1211
+ // path: '/y',
1212
+ // value: undefined,
1213
+ // message: 'Expected number'
1214
+ // }, {
1215
+ // schema: { type: 'number' },
1216
+ // path: '/z',
1217
+ // value: undefined,
1218
+ // message: 'Expected number'
1219
+ // }]
1220
+ ```
1221
+
1222
+ Compiled routines can be inspected with the `.Code()` function.
1223
+
1224
+ ```typescript
1225
+ const C = TypeCompiler.Compile(Type.String()) // const C: TypeCheck<TString>
1226
+
1227
+ console.log(C.Code()) // return function check(value) {
1228
+ // return (
1229
+ // (typeof value === 'string')
1230
+ // )
1231
+ // }
1232
+ ```
1233
+
1234
+ <a name='typesystem'></a>
1235
+
1236
+ ## TypeSystem
1237
+
1238
+ The TypeBox TypeSystem module provides functionality to define types above and beyond the Standard and Extended type sets as well as control various assertion polices. Configurations made to the TypeSystem module are observed by both `TypeCompiler` and `Value` modules.
1239
+
1240
+ The TypeSystem module is provided as an optional import.
1241
+
1242
+ ```typescript
1243
+ import { TypeSystem } from '@sinclair/typebox/system'
1244
+ ```
1245
+
1246
+ <a name='typesystem-types'></a>
1247
+
1248
+ ### Types
1249
+
1250
+ Use the `Type(...)` function to create a custom type. This function will return a type factory function that can be used to construct the type. The following creates a Point type.
1251
+
1252
+ ```typescript
1253
+ type PointOptions = { } // The Type Options
1254
+
1255
+ type PointType = { x: number, y: number } // The Static<T> Type
1256
+
1257
+ const Point = TypeSystem.Type<PointType, PointOptions>('Point', (options, value) => {
1258
+ return (
1259
+ typeof value === 'object' && value !== null &&
1260
+ typeof value.x === 'number' &&
1261
+ typeof value.y === 'number'
1262
+ )
1263
+ })
1264
+
1265
+ const T = Point()
1266
+
1267
+ type T = Static<typeof T> // type T = { x: number, y: number }
1268
+
1269
+ const R = Value.Check(T, { x: 1, y: 2 }) // const R = true
1270
+ ```
1271
+
1272
+ <a name='typesystem-formats'></a>
1273
+
1274
+ ### Formats
1275
+
1276
+ Use the `Format(...)` function to create a custom string format. The following creates a format that checks for lowercase strings.
1277
+
1278
+ ```typescript
1279
+ TypeSystem.Format('lowercase', value => value === value.toLowerCase()) // format should be lowercase
1280
+
1281
+ const T = Type.String({ format: 'lowercase' })
1282
+
1283
+ const A = Value.Check(T, 'Hello') // const A = false
1284
+
1285
+ const B = Value.Check(T, 'hello') // const B = true
1286
+ ```
1287
+
1288
+ <a name='typesystem-policies'></a>
1289
+
1290
+ ### Policies
1291
+
1292
+ TypeBox validates using JSON Schema assertion policies by default. It is possible to override these policies and have TypeBox assert using TypeScript policies. The following overrides are available.
1293
+
1294
+ ```typescript
1295
+ // Allow arrays to validate as object types (default is false)
1296
+ //
1297
+ // const A: {} = [] - allowed in TS
1298
+
1299
+ TypeSystem.AllowArrayObjects = true
1300
+
1301
+ // Allow numeric values to be NaN or + or - Infinity (default is false)
1302
+ //
1303
+ // const A: number = NaN - allowed in TS
1304
+
1305
+ TypeSystem.AllowNaN = true
1306
+ ```
1307
+
1308
+ <a name='benchmark'></a>
1309
+
1310
+ ## Benchmark
1311
+
1312
+ This project maintains a set of benchmarks that measure Ajv, Value and TypeCompiler compilation and validation performance. These benchmarks can be run locally by cloning this repository and running `npm run benchmark`. The results below show for Ajv version 8.12.0.
1313
+
1314
+ For additional comparative benchmarks, please refer to [typescript-runtime-type-benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/).
1315
+
1316
+ <a name='benchmark-compile'></a>
1317
+
1318
+ ### Compile
1319
+
1320
+ This benchmark measures compilation performance for varying types. You can review this benchmark [here](https://github.com/sinclairzx81/typebox/blob/master/benchmark/measurement/module/compile.ts).
1321
+
1322
+ ```typescript
1323
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1324
+ │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1325
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1326
+ │ Literal_String │ 1000 │ ' 257 ms' │ ' 8 ms' │ ' 32.13 x' │
1327
+ │ Literal_Number │ 1000 │ ' 203 ms' │ ' 4 ms' │ ' 50.75 x' │
1328
+ │ Literal_Boolean │ 1000 │ ' 183 ms' │ ' 4 ms' │ ' 45.75 x' │
1329
+ │ Primitive_Number │ 1000 │ ' 174 ms' │ ' 8 ms' │ ' 21.75 x' │
1330
+ │ Primitive_String │ 1000 │ ' 158 ms' │ ' 9 ms' │ ' 17.56 x' │
1331
+ │ Primitive_String_Pattern │ 1000 │ ' 213 ms' │ ' 13 ms' │ ' 16.38 x' │
1332
+ │ Primitive_Boolean │ 1000 │ ' 136 ms' │ ' 6 ms' │ ' 22.67 x' │
1333
+ │ Primitive_Null │ 1000 │ ' 144 ms' │ ' 6 ms' │ ' 24.00 x' │
1334
+ │ Object_Unconstrained │ 1000 │ ' 1176 ms' │ ' 38 ms' │ ' 30.95 x' │
1335
+ │ Object_Constrained │ 1000 │ ' 1181 ms' │ ' 31 ms' │ ' 38.10 x' │
1336
+ │ Object_Vector3 │ 1000 │ ' 387 ms' │ ' 8 ms' │ ' 48.38 x' │
1337
+ │ Object_Box3D │ 1000 │ ' 1693 ms' │ ' 25 ms' │ ' 67.72 x' │
1338
+ │ Tuple_Primitive │ 1000 │ ' 470 ms' │ ' 15 ms' │ ' 31.33 x' │
1339
+ │ Tuple_Object │ 1000 │ ' 1206 ms' │ ' 17 ms' │ ' 70.94 x' │
1340
+ │ Composite_Intersect │ 1000 │ ' 567 ms' │ ' 20 ms' │ ' 28.35 x' │
1341
+ │ Composite_Union │ 1000 │ ' 515 ms' │ ' 21 ms' │ ' 24.52 x' │
1342
+ │ Math_Vector4 │ 1000 │ ' 787 ms' │ ' 10 ms' │ ' 78.70 x' │
1343
+ │ Math_Matrix4 │ 1000 │ ' 386 ms' │ ' 8 ms' │ ' 48.25 x' │
1344
+ │ Array_Primitive_Number │ 1000 │ ' 349 ms' │ ' 7 ms' │ ' 49.86 x' │
1345
+ │ Array_Primitive_String │ 1000 │ ' 336 ms' │ ' 4 ms' │ ' 84.00 x' │
1346
+ │ Array_Primitive_Boolean │ 1000 │ ' 284 ms' │ ' 3 ms' │ ' 94.67 x' │
1347
+ │ Array_Object_Unconstrained │ 1000 │ ' 1704 ms' │ ' 19 ms' │ ' 89.68 x' │
1348
+ │ Array_Object_Constrained │ 1000 │ ' 1456 ms' │ ' 18 ms' │ ' 80.89 x' │
1349
+ │ Array_Tuple_Primitive │ 1000 │ ' 792 ms' │ ' 15 ms' │ ' 52.80 x' │
1350
+ │ Array_Tuple_Object │ 1000 │ ' 1552 ms' │ ' 17 ms' │ ' 91.29 x' │
1351
+ │ Array_Composite_Intersect │ 1000 │ ' 744 ms' │ ' 18 ms' │ ' 41.33 x' │
1352
+ │ Array_Composite_Union │ 1000 │ ' 783 ms' │ ' 15 ms' │ ' 52.20 x' │
1353
+ │ Array_Math_Vector4 │ 1000 │ ' 1093 ms' │ ' 14 ms' │ ' 78.07 x' │
1354
+ │ Array_Math_Matrix4 │ 1000 │ ' 684 ms' │ ' 6 ms' │ ' 114.00 x' │
1355
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1356
+ ```
1357
+
1358
+ <a name='benchmark-validate'></a>
1359
+
1360
+ ### Validate
1361
+
1362
+ This benchmark measures validation performance for varying types. You can review this benchmark [here](https://github.com/sinclairzx81/typebox/blob/master/benchmark/measurement/module/check.ts).
1363
+
1364
+ ```typescript
1365
+ ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1366
+ │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1367
+ ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1368
+ │ Literal_String │ 1000000 │ ' 27 ms' │ ' 6 ms' │ ' 5 ms' │ ' 1.20 x' │
1369
+ │ Literal_Number │ 1000000 │ ' 23 ms' │ ' 21 ms' │ ' 11 ms' │ ' 1.91 x' │
1370
+ │ Literal_Boolean │ 1000000 │ ' 21 ms' │ ' 20 ms' │ ' 10 ms' │ ' 2.00 x' │
1371
+ │ Primitive_Number │ 1000000 │ ' 26 ms' │ ' 19 ms' │ ' 11 ms' │ ' 1.73 x' │
1372
+ │ Primitive_String │ 1000000 │ ' 25 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1373
+ │ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 49 ms' │ ' 43 ms' │ ' 1.14 x' │
1374
+ │ Primitive_Boolean │ 1000000 │ ' 23 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1375
+ │ Primitive_Null │ 1000000 │ ' 24 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1376
+ │ Object_Unconstrained │ 1000000 │ ' 804 ms' │ ' 35 ms' │ ' 28 ms' │ ' 1.25 x' │
1377
+ │ Object_Constrained │ 1000000 │ ' 1041 ms' │ ' 55 ms' │ ' 41 ms' │ ' 1.34 x' │
1378
+ │ Object_Vector3 │ 1000000 │ ' 380 ms' │ ' 26 ms' │ ' 20 ms' │ ' 1.30 x' │
1379
+ │ Object_Box3D │ 1000000 │ ' 1785 ms' │ ' 65 ms' │ ' 52 ms' │ ' 1.25 x' │
1380
+ │ Object_Recursive │ 1000000 │ ' 4984 ms' │ ' 396 ms' │ ' 114 ms' │ ' 3.47 x' │
1381
+ │ Tuple_Primitive │ 1000000 │ ' 168 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1382
+ │ Tuple_Object │ 1000000 │ ' 673 ms' │ ' 30 ms' │ ' 26 ms' │ ' 1.15 x' │
1383
+ │ Composite_Intersect │ 1000000 │ ' 751 ms' │ ' 28 ms' │ ' 20 ms' │ ' 1.40 x' │
1384
+ │ Composite_Union │ 1000000 │ ' 489 ms' │ ' 24 ms' │ ' 16 ms' │ ' 1.50 x' │
1385
+ │ Math_Vector4 │ 1000000 │ ' 259 ms' │ ' 23 ms' │ ' 13 ms' │ ' 1.77 x' │
1386
+ │ Math_Matrix4 │ 1000000 │ ' 1002 ms' │ ' 40 ms' │ ' 30 ms' │ ' 1.33 x' │
1387
+ │ Array_Primitive_Number │ 1000000 │ ' 252 ms' │ ' 22 ms' │ ' 15 ms' │ ' 1.47 x' │
1388
+ │ Array_Primitive_String │ 1000000 │ ' 227 ms' │ ' 22 ms' │ ' 18 ms' │ ' 1.22 x' │
1389
+ │ Array_Primitive_Boolean │ 1000000 │ ' 150 ms' │ ' 23 ms' │ ' 22 ms' │ ' 1.05 x' │
1390
+ │ Array_Object_Unconstrained │ 1000000 │ ' 4754 ms' │ ' 71 ms' │ ' 64 ms' │ ' 1.11 x' │
1391
+ │ Array_Object_Constrained │ 1000000 │ ' 4787 ms' │ ' 142 ms' │ ' 123 ms' │ ' 1.15 x' │
1392
+ │ Array_Object_Recursive │ 1000000 │ ' 19088 ms' │ ' 1735 ms' │ ' 314 ms' │ ' 5.53 x' │
1393
+ │ Array_Tuple_Primitive │ 1000000 │ ' 650 ms' │ ' 41 ms' │ ' 31 ms' │ ' 1.32 x' │
1394
+ │ Array_Tuple_Object │ 1000000 │ ' 2770 ms' │ ' 67 ms' │ ' 55 ms' │ ' 1.22 x' │
1395
+ │ Array_Composite_Intersect │ 1000000 │ ' 2693 ms' │ ' 50 ms' │ ' 39 ms' │ ' 1.28 x' │
1396
+ │ Array_Composite_Union │ 1000000 │ ' 1982 ms' │ ' 72 ms' │ ' 33 ms' │ ' 2.18 x' │
1397
+ │ Array_Math_Vector4 │ 1000000 │ ' 1068 ms' │ ' 40 ms' │ ' 26 ms' │ ' 1.54 x' │
1398
+ │ Array_Math_Matrix4 │ 1000000 │ ' 4609 ms' │ ' 115 ms' │ ' 88 ms' │ ' 1.31 x' │
1399
+ └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1400
+ ```
1401
+
1402
+ <a name='benchmark-compression'></a>
1403
+
1404
+ ### Compression
1405
+
1406
+ The following table lists esbuild compiled and minified sizes for each TypeBox module.
1407
+
1408
+ ```typescript
1409
+ ┌──────────────────────┬────────────┬────────────┬─────────────┐
1410
+ │ (index) │ Compiled │ Minified │ Compression │
1411
+ ├──────────────────────┼────────────┼────────────┼─────────────┤
1412
+ │ typebox/compiler │ '124.3 kb' │ ' 55.7 kb' │ '2.23 x' │
1413
+ │ typebox/errors │ '107.8 kb' │ ' 47.9 kb' │ '2.25 x' │
1414
+ │ typebox/system │ ' 73.3 kb' │ ' 30.2 kb' │ '2.43 x' │
1415
+ │ typebox/value │ '170.7 kb' │ ' 74.2 kb' │ '2.30 x' │
1416
+ │ typebox │ ' 72.0 kb' │ ' 29.7 kb' │ '2.43 x' │
1417
+ └──────────────────────┴────────────┴────────────┴─────────────┘
1418
+ ```
1419
+
1420
+ <a name='contribute'></a>
1421
+
1422
+ ## Contribute
1423
+
1424
+ TypeBox is open to community contribution. Please ensure you submit an open issue before submitting your pull request. The TypeBox project preferences open community discussion prior to accepting new features.