ibm-cloud-sdk-core 4.3.3 → 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 (457) hide show
  1. package/iamtest.env +3 -0
  2. package/package.json +2 -2
  3. package/sdk-test-utilities/node_modules/.package-lock.json +508 -0
  4. package/sdk-test-utilities/node_modules/@babel/code-frame/LICENSE +22 -0
  5. package/sdk-test-utilities/node_modules/@babel/code-frame/README.md +19 -0
  6. package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js +156 -0
  7. package/sdk-test-utilities/node_modules/@babel/code-frame/lib/index.js.map +1 -0
  8. package/sdk-test-utilities/node_modules/@babel/code-frame/package.json +30 -0
  9. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/LICENSE +22 -0
  10. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/README.md +19 -0
  11. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js +70 -0
  12. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/identifier.js.map +1 -0
  13. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js +57 -0
  14. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/index.js.map +1 -0
  15. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js +35 -0
  16. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/lib/keyword.js.map +1 -0
  17. package/sdk-test-utilities/node_modules/@babel/helper-validator-identifier/package.json +31 -0
  18. package/sdk-test-utilities/node_modules/@babel/highlight/LICENSE +22 -0
  19. package/sdk-test-utilities/node_modules/@babel/highlight/README.md +19 -0
  20. package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js +119 -0
  21. package/sdk-test-utilities/node_modules/@babel/highlight/lib/index.js.map +1 -0
  22. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/index.js +165 -0
  23. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/license +9 -0
  24. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/package.json +56 -0
  25. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/ansi-styles/readme.md +147 -0
  26. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js +228 -0
  27. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/index.js.flow +93 -0
  28. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/license +9 -0
  29. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/package.json +71 -0
  30. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/readme.md +314 -0
  31. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/templates.js +128 -0
  32. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/chalk/types/index.d.ts +97 -0
  33. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/CHANGELOG.md +54 -0
  34. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/LICENSE +21 -0
  35. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/README.md +68 -0
  36. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/conversions.js +868 -0
  37. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/index.js +78 -0
  38. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/package.json +46 -0
  39. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-convert/route.js +97 -0
  40. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/.eslintrc.json +43 -0
  41. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/LICENSE +8 -0
  42. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/README.md +11 -0
  43. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/index.js +152 -0
  44. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/package.json +25 -0
  45. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/color-name/test.js +7 -0
  46. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/index.js +11 -0
  47. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/license +21 -0
  48. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/package.json +41 -0
  49. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/escape-string-regexp/readme.md +27 -0
  50. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/index.js +8 -0
  51. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/license +9 -0
  52. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/package.json +44 -0
  53. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/has-flag/readme.md +70 -0
  54. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/browser.js +5 -0
  55. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/index.js +131 -0
  56. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/license +9 -0
  57. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/package.json +53 -0
  58. package/sdk-test-utilities/node_modules/@babel/highlight/node_modules/supports-color/readme.md +66 -0
  59. package/sdk-test-utilities/node_modules/@babel/highlight/package.json +30 -0
  60. package/sdk-test-utilities/node_modules/@jest/expect-utils/LICENSE +21 -0
  61. package/sdk-test-utilities/node_modules/@jest/expect-utils/README.md +5 -0
  62. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/immutableUtils.js +66 -0
  63. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.d.ts +94 -0
  64. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/index.js +34 -0
  65. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/jasmineUtils.js +218 -0
  66. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/types.js +1 -0
  67. package/sdk-test-utilities/node_modules/@jest/expect-utils/build/utils.js +462 -0
  68. package/sdk-test-utilities/node_modules/@jest/expect-utils/package.json +35 -0
  69. package/sdk-test-utilities/node_modules/@jest/schemas/LICENSE +21 -0
  70. package/sdk-test-utilities/node_modules/@jest/schemas/README.md +3 -0
  71. package/sdk-test-utilities/node_modules/@jest/schemas/build/index.d.ts +63 -0
  72. package/sdk-test-utilities/node_modules/@jest/schemas/build/index.js +60 -0
  73. package/sdk-test-utilities/node_modules/@jest/schemas/package.json +29 -0
  74. package/sdk-test-utilities/node_modules/@jest/types/LICENSE +21 -0
  75. package/sdk-test-utilities/node_modules/@jest/types/README.md +30 -0
  76. package/sdk-test-utilities/node_modules/@jest/types/build/Circus.js +1 -0
  77. package/sdk-test-utilities/node_modules/@jest/types/build/Config.js +1 -0
  78. package/sdk-test-utilities/node_modules/@jest/types/build/Global.js +1 -0
  79. package/sdk-test-utilities/node_modules/@jest/types/build/TestResult.js +1 -0
  80. package/sdk-test-utilities/node_modules/@jest/types/build/index.d.ts +1204 -0
  81. package/sdk-test-utilities/node_modules/@jest/types/build/index.js +1 -0
  82. package/sdk-test-utilities/node_modules/@jest/types/package.json +38 -0
  83. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.d.ts +35 -0
  84. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/compiler.js +577 -0
  85. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.d.ts +2 -0
  86. package/sdk-test-utilities/node_modules/@sinclair/typebox/compiler/index.js +47 -0
  87. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.d.ts +88 -0
  88. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/errors.js +609 -0
  89. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.d.ts +1 -0
  90. package/sdk-test-utilities/node_modules/@sinclair/typebox/errors/index.js +44 -0
  91. package/sdk-test-utilities/node_modules/@sinclair/typebox/license +23 -0
  92. package/sdk-test-utilities/node_modules/@sinclair/typebox/package.json +47 -0
  93. package/sdk-test-utilities/node_modules/@sinclair/typebox/readme.md +1424 -0
  94. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.d.ts +1 -0
  95. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/index.js +44 -0
  96. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.d.ts +26 -0
  97. package/sdk-test-utilities/node_modules/@sinclair/typebox/system/system.js +90 -0
  98. package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.d.ts +723 -0
  99. package/sdk-test-utilities/node_modules/@sinclair/typebox/typebox.js +2220 -0
  100. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.d.ts +30 -0
  101. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/cast.js +372 -0
  102. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.d.ts +12 -0
  103. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/check.js +484 -0
  104. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.d.ts +3 -0
  105. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/clone.js +71 -0
  106. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.d.ts +13 -0
  107. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/convert.js +372 -0
  108. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.d.ts +26 -0
  109. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/create.js +480 -0
  110. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.d.ts +43 -0
  111. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/delta.js +204 -0
  112. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.d.ts +3 -0
  113. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/equal.js +80 -0
  114. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.d.ts +8 -0
  115. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/hash.js +208 -0
  116. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.d.ts +6 -0
  117. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/index.js +56 -0
  118. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.d.ts +11 -0
  119. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/is.js +53 -0
  120. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.d.ts +13 -0
  121. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/mutate.js +121 -0
  122. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.d.ts +24 -0
  123. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/pointer.js +142 -0
  124. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.d.ts +39 -0
  125. package/sdk-test-utilities/node_modules/@sinclair/typebox/value/value.js +99 -0
  126. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/LICENSE +21 -0
  127. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/README.md +15 -0
  128. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/index.d.ts +111 -0
  129. package/sdk-test-utilities/node_modules/@types/istanbul-lib-coverage/package.json +25 -0
  130. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/LICENSE +21 -0
  131. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/README.md +15 -0
  132. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/index.d.ts +184 -0
  133. package/sdk-test-utilities/node_modules/@types/istanbul-lib-report/package.json +32 -0
  134. package/sdk-test-utilities/node_modules/@types/istanbul-reports/LICENSE +21 -0
  135. package/sdk-test-utilities/node_modules/@types/istanbul-reports/README.md +86 -0
  136. package/sdk-test-utilities/node_modules/@types/istanbul-reports/index.d.ts +67 -0
  137. package/sdk-test-utilities/node_modules/@types/istanbul-reports/package.json +32 -0
  138. package/sdk-test-utilities/node_modules/@types/node/LICENSE +21 -0
  139. package/sdk-test-utilities/node_modules/@types/node/README.md +15 -0
  140. package/sdk-test-utilities/node_modules/@types/node/assert/strict.d.ts +8 -0
  141. package/sdk-test-utilities/node_modules/@types/node/assert.d.ts +1040 -0
  142. package/sdk-test-utilities/node_modules/@types/node/async_hooks.d.ts +541 -0
  143. package/sdk-test-utilities/node_modules/@types/node/buffer.d.ts +2363 -0
  144. package/sdk-test-utilities/node_modules/@types/node/child_process.d.ts +1544 -0
  145. package/sdk-test-utilities/node_modules/@types/node/cluster.d.ts +578 -0
  146. package/sdk-test-utilities/node_modules/@types/node/console.d.ts +452 -0
  147. package/sdk-test-utilities/node_modules/@types/node/constants.d.ts +19 -0
  148. package/sdk-test-utilities/node_modules/@types/node/crypto.d.ts +4523 -0
  149. package/sdk-test-utilities/node_modules/@types/node/dgram.d.ts +596 -0
  150. package/sdk-test-utilities/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
  151. package/sdk-test-utilities/node_modules/@types/node/dns/promises.d.ts +474 -0
  152. package/sdk-test-utilities/node_modules/@types/node/dns.d.ts +864 -0
  153. package/sdk-test-utilities/node_modules/@types/node/dom-events.d.ts +124 -0
  154. package/sdk-test-utilities/node_modules/@types/node/domain.d.ts +170 -0
  155. package/sdk-test-utilities/node_modules/@types/node/events.d.ts +909 -0
  156. package/sdk-test-utilities/node_modules/@types/node/fs/promises.d.ts +1245 -0
  157. package/sdk-test-utilities/node_modules/@types/node/fs.d.ts +4317 -0
  158. package/sdk-test-utilities/node_modules/@types/node/globals.d.ts +411 -0
  159. package/sdk-test-utilities/node_modules/@types/node/globals.global.d.ts +1 -0
  160. package/sdk-test-utilities/node_modules/@types/node/http.d.ts +1908 -0
  161. package/sdk-test-utilities/node_modules/@types/node/http2.d.ts +2418 -0
  162. package/sdk-test-utilities/node_modules/@types/node/https.d.ts +550 -0
  163. package/sdk-test-utilities/node_modules/@types/node/index.d.ts +89 -0
  164. package/sdk-test-utilities/node_modules/@types/node/inspector.d.ts +2746 -0
  165. package/sdk-test-utilities/node_modules/@types/node/module.d.ts +315 -0
  166. package/sdk-test-utilities/node_modules/@types/node/net.d.ts +999 -0
  167. package/sdk-test-utilities/node_modules/@types/node/os.d.ts +495 -0
  168. package/sdk-test-utilities/node_modules/@types/node/package.json +217 -0
  169. package/sdk-test-utilities/node_modules/@types/node/path.d.ts +191 -0
  170. package/sdk-test-utilities/node_modules/@types/node/perf_hooks.d.ts +905 -0
  171. package/sdk-test-utilities/node_modules/@types/node/process.d.ts +1754 -0
  172. package/sdk-test-utilities/node_modules/@types/node/punycode.d.ts +117 -0
  173. package/sdk-test-utilities/node_modules/@types/node/querystring.d.ts +153 -0
  174. package/sdk-test-utilities/node_modules/@types/node/readline/promises.d.ts +150 -0
  175. package/sdk-test-utilities/node_modules/@types/node/readline.d.ts +540 -0
  176. package/sdk-test-utilities/node_modules/@types/node/repl.d.ts +430 -0
  177. package/sdk-test-utilities/node_modules/@types/node/sea.d.ts +153 -0
  178. package/sdk-test-utilities/node_modules/@types/node/stream/consumers.d.ts +12 -0
  179. package/sdk-test-utilities/node_modules/@types/node/stream/promises.d.ts +83 -0
  180. package/sdk-test-utilities/node_modules/@types/node/stream/web.d.ts +367 -0
  181. package/sdk-test-utilities/node_modules/@types/node/stream.d.ts +1707 -0
  182. package/sdk-test-utilities/node_modules/@types/node/string_decoder.d.ts +67 -0
  183. package/sdk-test-utilities/node_modules/@types/node/test.d.ts +1718 -0
  184. package/sdk-test-utilities/node_modules/@types/node/timers/promises.d.ts +97 -0
  185. package/sdk-test-utilities/node_modules/@types/node/timers.d.ts +240 -0
  186. package/sdk-test-utilities/node_modules/@types/node/tls.d.ts +1217 -0
  187. package/sdk-test-utilities/node_modules/@types/node/trace_events.d.ts +197 -0
  188. package/sdk-test-utilities/node_modules/@types/node/tty.d.ts +208 -0
  189. package/sdk-test-utilities/node_modules/@types/node/url.d.ts +952 -0
  190. package/sdk-test-utilities/node_modules/@types/node/util.d.ts +2292 -0
  191. package/sdk-test-utilities/node_modules/@types/node/v8.d.ts +808 -0
  192. package/sdk-test-utilities/node_modules/@types/node/vm.d.ts +924 -0
  193. package/sdk-test-utilities/node_modules/@types/node/wasi.d.ts +181 -0
  194. package/sdk-test-utilities/node_modules/@types/node/worker_threads.d.ts +691 -0
  195. package/sdk-test-utilities/node_modules/@types/node/zlib.d.ts +530 -0
  196. package/sdk-test-utilities/node_modules/@types/stack-utils/LICENSE +21 -0
  197. package/sdk-test-utilities/node_modules/@types/stack-utils/README.md +78 -0
  198. package/sdk-test-utilities/node_modules/@types/stack-utils/index.d.ts +59 -0
  199. package/sdk-test-utilities/node_modules/@types/stack-utils/package.json +25 -0
  200. package/sdk-test-utilities/node_modules/@types/yargs/LICENSE +21 -0
  201. package/sdk-test-utilities/node_modules/@types/yargs/README.md +15 -0
  202. package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.mts +1 -0
  203. package/sdk-test-utilities/node_modules/@types/yargs/helpers.d.ts +5 -0
  204. package/sdk-test-utilities/node_modules/@types/yargs/index.d.mts +46 -0
  205. package/sdk-test-utilities/node_modules/@types/yargs/index.d.ts +1031 -0
  206. package/sdk-test-utilities/node_modules/@types/yargs/package.json +87 -0
  207. package/sdk-test-utilities/node_modules/@types/yargs/yargs.d.ts +9 -0
  208. package/sdk-test-utilities/node_modules/@types/yargs-parser/LICENSE +21 -0
  209. package/sdk-test-utilities/node_modules/@types/yargs-parser/README.md +15 -0
  210. package/sdk-test-utilities/node_modules/@types/yargs-parser/index.d.ts +112 -0
  211. package/sdk-test-utilities/node_modules/@types/yargs-parser/package.json +25 -0
  212. package/sdk-test-utilities/node_modules/ansi-styles/index.d.ts +345 -0
  213. package/sdk-test-utilities/node_modules/ansi-styles/index.js +163 -0
  214. package/sdk-test-utilities/node_modules/ansi-styles/license +9 -0
  215. package/sdk-test-utilities/node_modules/ansi-styles/package.json +56 -0
  216. package/sdk-test-utilities/node_modules/ansi-styles/readme.md +152 -0
  217. package/sdk-test-utilities/node_modules/braces/LICENSE +21 -0
  218. package/sdk-test-utilities/node_modules/braces/README.md +586 -0
  219. package/sdk-test-utilities/node_modules/braces/index.js +170 -0
  220. package/sdk-test-utilities/node_modules/braces/lib/compile.js +60 -0
  221. package/sdk-test-utilities/node_modules/braces/lib/constants.js +57 -0
  222. package/sdk-test-utilities/node_modules/braces/lib/expand.js +113 -0
  223. package/sdk-test-utilities/node_modules/braces/lib/parse.js +331 -0
  224. package/sdk-test-utilities/node_modules/braces/lib/stringify.js +32 -0
  225. package/sdk-test-utilities/node_modules/braces/lib/utils.js +122 -0
  226. package/sdk-test-utilities/node_modules/braces/package.json +77 -0
  227. package/sdk-test-utilities/node_modules/chalk/index.d.ts +415 -0
  228. package/sdk-test-utilities/node_modules/chalk/license +9 -0
  229. package/sdk-test-utilities/node_modules/chalk/package.json +68 -0
  230. package/sdk-test-utilities/node_modules/chalk/readme.md +341 -0
  231. package/sdk-test-utilities/node_modules/chalk/source/index.js +229 -0
  232. package/sdk-test-utilities/node_modules/chalk/source/templates.js +134 -0
  233. package/sdk-test-utilities/node_modules/chalk/source/util.js +39 -0
  234. package/sdk-test-utilities/node_modules/ci-info/CHANGELOG.md +178 -0
  235. package/sdk-test-utilities/node_modules/ci-info/LICENSE +21 -0
  236. package/sdk-test-utilities/node_modules/ci-info/README.md +135 -0
  237. package/sdk-test-utilities/node_modules/ci-info/index.d.ts +75 -0
  238. package/sdk-test-utilities/node_modules/ci-info/index.js +90 -0
  239. package/sdk-test-utilities/node_modules/ci-info/package.json +45 -0
  240. package/sdk-test-utilities/node_modules/ci-info/vendors.json +321 -0
  241. package/sdk-test-utilities/node_modules/color-convert/CHANGELOG.md +54 -0
  242. package/sdk-test-utilities/node_modules/color-convert/LICENSE +21 -0
  243. package/sdk-test-utilities/node_modules/color-convert/README.md +68 -0
  244. package/sdk-test-utilities/node_modules/color-convert/conversions.js +839 -0
  245. package/sdk-test-utilities/node_modules/color-convert/index.js +81 -0
  246. package/sdk-test-utilities/node_modules/color-convert/package.json +48 -0
  247. package/sdk-test-utilities/node_modules/color-convert/route.js +97 -0
  248. package/sdk-test-utilities/node_modules/color-name/LICENSE +8 -0
  249. package/sdk-test-utilities/node_modules/color-name/README.md +11 -0
  250. package/sdk-test-utilities/node_modules/color-name/index.js +152 -0
  251. package/sdk-test-utilities/node_modules/color-name/package.json +28 -0
  252. package/sdk-test-utilities/node_modules/diff-sequences/LICENSE +21 -0
  253. package/sdk-test-utilities/node_modules/diff-sequences/README.md +404 -0
  254. package/sdk-test-utilities/node_modules/diff-sequences/build/index.d.ts +38 -0
  255. package/sdk-test-utilities/node_modules/diff-sequences/build/index.js +798 -0
  256. package/sdk-test-utilities/node_modules/diff-sequences/package.json +39 -0
  257. package/sdk-test-utilities/node_modules/escape-string-regexp/index.d.ts +18 -0
  258. package/sdk-test-utilities/node_modules/escape-string-regexp/index.js +11 -0
  259. package/sdk-test-utilities/node_modules/escape-string-regexp/license +9 -0
  260. package/sdk-test-utilities/node_modules/escape-string-regexp/package.json +43 -0
  261. package/sdk-test-utilities/node_modules/escape-string-regexp/readme.md +29 -0
  262. package/sdk-test-utilities/node_modules/expect/LICENSE +21 -0
  263. package/sdk-test-utilities/node_modules/expect/README.md +3 -0
  264. package/sdk-test-utilities/node_modules/expect/build/asymmetricMatchers.js +375 -0
  265. package/sdk-test-utilities/node_modules/expect/build/extractExpectedAssertionsErrors.js +86 -0
  266. package/sdk-test-utilities/node_modules/expect/build/index.d.ts +370 -0
  267. package/sdk-test-utilities/node_modules/expect/build/index.js +410 -0
  268. package/sdk-test-utilities/node_modules/expect/build/jestMatchersObject.js +123 -0
  269. package/sdk-test-utilities/node_modules/expect/build/matchers.js +1292 -0
  270. package/sdk-test-utilities/node_modules/expect/build/print.js +122 -0
  271. package/sdk-test-utilities/node_modules/expect/build/spyMatchers.js +1254 -0
  272. package/sdk-test-utilities/node_modules/expect/build/toThrowMatchers.js +481 -0
  273. package/sdk-test-utilities/node_modules/expect/build/types.js +3 -0
  274. package/sdk-test-utilities/node_modules/expect/package.json +43 -0
  275. package/sdk-test-utilities/node_modules/fill-range/LICENSE +21 -0
  276. package/sdk-test-utilities/node_modules/fill-range/README.md +237 -0
  277. package/sdk-test-utilities/node_modules/fill-range/index.js +248 -0
  278. package/sdk-test-utilities/node_modules/fill-range/package.json +74 -0
  279. package/sdk-test-utilities/node_modules/graceful-fs/LICENSE +15 -0
  280. package/sdk-test-utilities/node_modules/graceful-fs/README.md +143 -0
  281. package/sdk-test-utilities/node_modules/graceful-fs/clone.js +23 -0
  282. package/sdk-test-utilities/node_modules/graceful-fs/graceful-fs.js +448 -0
  283. package/sdk-test-utilities/node_modules/graceful-fs/legacy-streams.js +118 -0
  284. package/sdk-test-utilities/node_modules/graceful-fs/package.json +53 -0
  285. package/sdk-test-utilities/node_modules/graceful-fs/polyfills.js +355 -0
  286. package/sdk-test-utilities/node_modules/has-flag/index.d.ts +39 -0
  287. package/sdk-test-utilities/node_modules/has-flag/index.js +8 -0
  288. package/sdk-test-utilities/node_modules/has-flag/license +9 -0
  289. package/sdk-test-utilities/node_modules/has-flag/package.json +46 -0
  290. package/sdk-test-utilities/node_modules/has-flag/readme.md +89 -0
  291. package/sdk-test-utilities/node_modules/is-number/LICENSE +21 -0
  292. package/sdk-test-utilities/node_modules/is-number/README.md +187 -0
  293. package/sdk-test-utilities/node_modules/is-number/index.js +18 -0
  294. package/sdk-test-utilities/node_modules/is-number/package.json +82 -0
  295. package/sdk-test-utilities/node_modules/jest-diff/LICENSE +21 -0
  296. package/sdk-test-utilities/node_modules/jest-diff/README.md +671 -0
  297. package/sdk-test-utilities/node_modules/jest-diff/build/cleanupSemantic.js +599 -0
  298. package/sdk-test-utilities/node_modules/jest-diff/build/constants.js +19 -0
  299. package/sdk-test-utilities/node_modules/jest-diff/build/diffLines.js +193 -0
  300. package/sdk-test-utilities/node_modules/jest-diff/build/diffStrings.js +66 -0
  301. package/sdk-test-utilities/node_modules/jest-diff/build/getAlignedDiffs.js +223 -0
  302. package/sdk-test-utilities/node_modules/jest-diff/build/index.d.ts +93 -0
  303. package/sdk-test-utilities/node_modules/jest-diff/build/index.js +232 -0
  304. package/sdk-test-utilities/node_modules/jest-diff/build/joinAlignedDiffs.js +271 -0
  305. package/sdk-test-utilities/node_modules/jest-diff/build/normalizeDiffOptions.js +59 -0
  306. package/sdk-test-utilities/node_modules/jest-diff/build/printDiffs.js +79 -0
  307. package/sdk-test-utilities/node_modules/jest-diff/build/types.js +1 -0
  308. package/sdk-test-utilities/node_modules/jest-diff/package.json +36 -0
  309. package/sdk-test-utilities/node_modules/jest-get-type/LICENSE +21 -0
  310. package/sdk-test-utilities/node_modules/jest-get-type/build/index.d.ts +27 -0
  311. package/sdk-test-utilities/node_modules/jest-get-type/build/index.js +53 -0
  312. package/sdk-test-utilities/node_modules/jest-get-type/package.json +27 -0
  313. package/sdk-test-utilities/node_modules/jest-matcher-utils/LICENSE +21 -0
  314. package/sdk-test-utilities/node_modules/jest-matcher-utils/README.md +24 -0
  315. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/Replaceable.js +64 -0
  316. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/deepCyclicCopyReplaceable.js +111 -0
  317. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.d.ts +138 -0
  318. package/sdk-test-utilities/node_modules/jest-matcher-utils/build/index.js +542 -0
  319. package/sdk-test-utilities/node_modules/jest-matcher-utils/package.json +37 -0
  320. package/sdk-test-utilities/node_modules/jest-message-util/LICENSE +21 -0
  321. package/sdk-test-utilities/node_modules/jest-message-util/build/index.d.ts +68 -0
  322. package/sdk-test-utilities/node_modules/jest-message-util/build/index.js +518 -0
  323. package/sdk-test-utilities/node_modules/jest-message-util/build/types.js +1 -0
  324. package/sdk-test-utilities/node_modules/jest-message-util/package.json +43 -0
  325. package/sdk-test-utilities/node_modules/jest-util/LICENSE +21 -0
  326. package/sdk-test-utilities/node_modules/jest-util/Readme.md +87 -0
  327. package/sdk-test-utilities/node_modules/jest-util/build/ErrorWithStack.js +28 -0
  328. package/sdk-test-utilities/node_modules/jest-util/build/clearLine.js +18 -0
  329. package/sdk-test-utilities/node_modules/jest-util/build/convertDescriptorToString.js +30 -0
  330. package/sdk-test-utilities/node_modules/jest-util/build/createDirectory.js +71 -0
  331. package/sdk-test-utilities/node_modules/jest-util/build/createProcessObject.js +109 -0
  332. package/sdk-test-utilities/node_modules/jest-util/build/deepCyclicCopy.js +76 -0
  333. package/sdk-test-utilities/node_modules/jest-util/build/formatTime.js +24 -0
  334. package/sdk-test-utilities/node_modules/jest-util/build/globsToMatcher.js +98 -0
  335. package/sdk-test-utilities/node_modules/jest-util/build/index.d.ts +136 -0
  336. package/sdk-test-utilities/node_modules/jest-util/build/index.js +199 -0
  337. package/sdk-test-utilities/node_modules/jest-util/build/installCommonGlobals.js +115 -0
  338. package/sdk-test-utilities/node_modules/jest-util/build/interopRequireDefault.js +22 -0
  339. package/sdk-test-utilities/node_modules/jest-util/build/invariant.js +18 -0
  340. package/sdk-test-utilities/node_modules/jest-util/build/isInteractive.js +22 -0
  341. package/sdk-test-utilities/node_modules/jest-util/build/isNonNullable.js +16 -0
  342. package/sdk-test-utilities/node_modules/jest-util/build/isPromise.js +20 -0
  343. package/sdk-test-utilities/node_modules/jest-util/build/pluralize.js +16 -0
  344. package/sdk-test-utilities/node_modules/jest-util/build/preRunMessage.js +38 -0
  345. package/sdk-test-utilities/node_modules/jest-util/build/replacePathSepForGlob.js +16 -0
  346. package/sdk-test-utilities/node_modules/jest-util/build/requireOrImportModule.js +77 -0
  347. package/sdk-test-utilities/node_modules/jest-util/build/setGlobal.js +17 -0
  348. package/sdk-test-utilities/node_modules/jest-util/build/specialChars.js +25 -0
  349. package/sdk-test-utilities/node_modules/jest-util/build/testPathPatternToRegExp.js +19 -0
  350. package/sdk-test-utilities/node_modules/jest-util/build/tryRealpath.js +30 -0
  351. package/sdk-test-utilities/node_modules/jest-util/package.json +38 -0
  352. package/sdk-test-utilities/node_modules/js-tokens/CHANGELOG.md +151 -0
  353. package/sdk-test-utilities/node_modules/js-tokens/LICENSE +21 -0
  354. package/sdk-test-utilities/node_modules/js-tokens/README.md +240 -0
  355. package/sdk-test-utilities/node_modules/js-tokens/index.js +23 -0
  356. package/sdk-test-utilities/node_modules/js-tokens/package.json +30 -0
  357. package/sdk-test-utilities/node_modules/micromatch/LICENSE +21 -0
  358. package/sdk-test-utilities/node_modules/micromatch/README.md +1017 -0
  359. package/sdk-test-utilities/node_modules/micromatch/index.js +467 -0
  360. package/sdk-test-utilities/node_modules/micromatch/package.json +101 -0
  361. package/sdk-test-utilities/node_modules/picocolors/LICENSE +15 -0
  362. package/sdk-test-utilities/node_modules/picocolors/README.md +21 -0
  363. package/sdk-test-utilities/node_modules/picocolors/package.json +25 -0
  364. package/sdk-test-utilities/node_modules/picocolors/picocolors.browser.js +4 -0
  365. package/sdk-test-utilities/node_modules/picocolors/picocolors.d.ts +5 -0
  366. package/sdk-test-utilities/node_modules/picocolors/picocolors.js +65 -0
  367. package/sdk-test-utilities/node_modules/picomatch/CHANGELOG.md +136 -0
  368. package/sdk-test-utilities/node_modules/picomatch/LICENSE +21 -0
  369. package/sdk-test-utilities/node_modules/picomatch/README.md +708 -0
  370. package/sdk-test-utilities/node_modules/picomatch/index.js +3 -0
  371. package/sdk-test-utilities/node_modules/picomatch/lib/constants.js +179 -0
  372. package/sdk-test-utilities/node_modules/picomatch/lib/parse.js +1091 -0
  373. package/sdk-test-utilities/node_modules/picomatch/lib/picomatch.js +342 -0
  374. package/sdk-test-utilities/node_modules/picomatch/lib/scan.js +391 -0
  375. package/sdk-test-utilities/node_modules/picomatch/lib/utils.js +64 -0
  376. package/sdk-test-utilities/node_modules/picomatch/package.json +81 -0
  377. package/sdk-test-utilities/node_modules/pretty-format/LICENSE +21 -0
  378. package/sdk-test-utilities/node_modules/pretty-format/README.md +463 -0
  379. package/sdk-test-utilities/node_modules/pretty-format/build/collections.js +180 -0
  380. package/sdk-test-utilities/node_modules/pretty-format/build/index.d.ts +163 -0
  381. package/sdk-test-utilities/node_modules/pretty-format/build/index.js +478 -0
  382. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js +89 -0
  383. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMCollection.js +67 -0
  384. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/DOMElement.js +101 -0
  385. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/Immutable.js +217 -0
  386. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactElement.js +143 -0
  387. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/ReactTestComponent.js +66 -0
  388. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/escapeHTML.js +16 -0
  389. package/sdk-test-utilities/node_modules/pretty-format/build/plugins/lib/markup.js +113 -0
  390. package/sdk-test-utilities/node_modules/pretty-format/build/types.js +1 -0
  391. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.d.ts +167 -0
  392. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/index.js +164 -0
  393. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/license +9 -0
  394. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/package.json +52 -0
  395. package/sdk-test-utilities/node_modules/pretty-format/node_modules/ansi-styles/readme.md +144 -0
  396. package/sdk-test-utilities/node_modules/pretty-format/package.json +43 -0
  397. package/sdk-test-utilities/node_modules/react-is/LICENSE +21 -0
  398. package/sdk-test-utilities/node_modules/react-is/README.md +104 -0
  399. package/sdk-test-utilities/node_modules/react-is/cjs/react-is.development.js +221 -0
  400. package/sdk-test-utilities/node_modules/react-is/cjs/react-is.production.min.js +14 -0
  401. package/sdk-test-utilities/node_modules/react-is/index.js +7 -0
  402. package/sdk-test-utilities/node_modules/react-is/package.json +26 -0
  403. package/sdk-test-utilities/node_modules/react-is/umd/react-is.development.js +220 -0
  404. package/sdk-test-utilities/node_modules/react-is/umd/react-is.production.min.js +15 -0
  405. package/sdk-test-utilities/node_modules/slash/index.d.ts +25 -0
  406. package/sdk-test-utilities/node_modules/slash/index.js +11 -0
  407. package/sdk-test-utilities/node_modules/slash/license +9 -0
  408. package/sdk-test-utilities/node_modules/slash/package.json +35 -0
  409. package/sdk-test-utilities/node_modules/slash/readme.md +44 -0
  410. package/sdk-test-utilities/node_modules/stack-utils/LICENSE.md +21 -0
  411. package/sdk-test-utilities/node_modules/stack-utils/index.js +344 -0
  412. package/sdk-test-utilities/node_modules/stack-utils/package.json +39 -0
  413. package/sdk-test-utilities/node_modules/stack-utils/readme.md +143 -0
  414. package/sdk-test-utilities/node_modules/supports-color/browser.js +5 -0
  415. package/sdk-test-utilities/node_modules/supports-color/index.js +135 -0
  416. package/sdk-test-utilities/node_modules/supports-color/license +9 -0
  417. package/sdk-test-utilities/node_modules/supports-color/package.json +53 -0
  418. package/sdk-test-utilities/node_modules/supports-color/readme.md +76 -0
  419. package/sdk-test-utilities/node_modules/to-regex-range/LICENSE +21 -0
  420. package/sdk-test-utilities/node_modules/to-regex-range/README.md +305 -0
  421. package/sdk-test-utilities/node_modules/to-regex-range/index.js +288 -0
  422. package/sdk-test-utilities/node_modules/to-regex-range/package.json +88 -0
  423. package/sdk-test-utilities/node_modules/undici-types/README.md +6 -0
  424. package/sdk-test-utilities/node_modules/undici-types/agent.d.ts +31 -0
  425. package/sdk-test-utilities/node_modules/undici-types/api.d.ts +43 -0
  426. package/sdk-test-utilities/node_modules/undici-types/balanced-pool.d.ts +18 -0
  427. package/sdk-test-utilities/node_modules/undici-types/cache.d.ts +36 -0
  428. package/sdk-test-utilities/node_modules/undici-types/client.d.ts +97 -0
  429. package/sdk-test-utilities/node_modules/undici-types/connector.d.ts +34 -0
  430. package/sdk-test-utilities/node_modules/undici-types/content-type.d.ts +21 -0
  431. package/sdk-test-utilities/node_modules/undici-types/cookies.d.ts +28 -0
  432. package/sdk-test-utilities/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  433. package/sdk-test-utilities/node_modules/undici-types/dispatcher.d.ts +241 -0
  434. package/sdk-test-utilities/node_modules/undici-types/errors.d.ts +128 -0
  435. package/sdk-test-utilities/node_modules/undici-types/fetch.d.ts +209 -0
  436. package/sdk-test-utilities/node_modules/undici-types/file.d.ts +39 -0
  437. package/sdk-test-utilities/node_modules/undici-types/filereader.d.ts +54 -0
  438. package/sdk-test-utilities/node_modules/undici-types/formdata.d.ts +108 -0
  439. package/sdk-test-utilities/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  440. package/sdk-test-utilities/node_modules/undici-types/global-origin.d.ts +7 -0
  441. package/sdk-test-utilities/node_modules/undici-types/handlers.d.ts +9 -0
  442. package/sdk-test-utilities/node_modules/undici-types/header.d.ts +4 -0
  443. package/sdk-test-utilities/node_modules/undici-types/index.d.ts +63 -0
  444. package/sdk-test-utilities/node_modules/undici-types/interceptors.d.ts +5 -0
  445. package/sdk-test-utilities/node_modules/undici-types/mock-agent.d.ts +50 -0
  446. package/sdk-test-utilities/node_modules/undici-types/mock-client.d.ts +25 -0
  447. package/sdk-test-utilities/node_modules/undici-types/mock-errors.d.ts +12 -0
  448. package/sdk-test-utilities/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  449. package/sdk-test-utilities/node_modules/undici-types/mock-pool.d.ts +25 -0
  450. package/sdk-test-utilities/node_modules/undici-types/package.json +55 -0
  451. package/sdk-test-utilities/node_modules/undici-types/patch.d.ts +71 -0
  452. package/sdk-test-utilities/node_modules/undici-types/pool-stats.d.ts +19 -0
  453. package/sdk-test-utilities/node_modules/undici-types/pool.d.ts +28 -0
  454. package/sdk-test-utilities/node_modules/undici-types/proxy-agent.d.ts +30 -0
  455. package/sdk-test-utilities/node_modules/undici-types/readable.d.ts +61 -0
  456. package/sdk-test-utilities/node_modules/undici-types/webidl.d.ts +220 -0
  457. package/sdk-test-utilities/node_modules/undici-types/websocket.d.ts +131 -0
@@ -0,0 +1,2220 @@
1
+ "use strict";
2
+ /*--------------------------------------------------------------------------
3
+
4
+ @sinclair/typebox
5
+
6
+ The MIT License (MIT)
7
+
8
+ Copyright (c) 2017-2023 Haydn Paterson (sinclair) <haydn.developer@gmail.com>
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ ---------------------------------------------------------------------------*/
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.Type = exports.StandardType = exports.ExtendedTypeBuilder = exports.StandardTypeBuilder = exports.TypeBuilder = exports.TemplateLiteralGenerator = exports.TemplateLiteralFinite = exports.TemplateLiteralParser = exports.TemplateLiteralParserError = exports.TemplateLiteralResolver = exports.TemplateLiteralPattern = exports.KeyResolver = exports.ObjectMap = exports.TypeClone = exports.TypeExtends = exports.TypeExtendsResult = exports.ExtendsUndefined = exports.TypeGuard = exports.TypeGuardUnknownTypeError = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternNumberExact = exports.PatternBooleanExact = exports.PatternString = exports.PatternNumber = exports.PatternBoolean = exports.Kind = exports.Hint = exports.Modifier = void 0;
31
+ // --------------------------------------------------------------------------
32
+ // Symbols
33
+ // --------------------------------------------------------------------------
34
+ exports.Modifier = Symbol.for('TypeBox.Modifier');
35
+ exports.Hint = Symbol.for('TypeBox.Hint');
36
+ exports.Kind = Symbol.for('TypeBox.Kind');
37
+ // --------------------------------------------------------------------------
38
+ // Patterns
39
+ // --------------------------------------------------------------------------
40
+ exports.PatternBoolean = '(true|false)';
41
+ exports.PatternNumber = '(0|[1-9][0-9]*)';
42
+ exports.PatternString = '(.*)';
43
+ exports.PatternBooleanExact = `^${exports.PatternBoolean}$`;
44
+ exports.PatternNumberExact = `^${exports.PatternNumber}$`;
45
+ exports.PatternStringExact = `^${exports.PatternString}$`;
46
+ /** A registry for user defined types */
47
+ var TypeRegistry;
48
+ (function (TypeRegistry) {
49
+ const map = new Map();
50
+ /** Returns the entries in this registry */
51
+ function Entries() {
52
+ return new Map(map);
53
+ }
54
+ TypeRegistry.Entries = Entries;
55
+ /** Clears all user defined types */
56
+ function Clear() {
57
+ return map.clear();
58
+ }
59
+ TypeRegistry.Clear = Clear;
60
+ /** Returns true if this registry contains this kind */
61
+ function Has(kind) {
62
+ return map.has(kind);
63
+ }
64
+ TypeRegistry.Has = Has;
65
+ /** Sets a validation function for a user defined type */
66
+ function Set(kind, func) {
67
+ map.set(kind, func);
68
+ }
69
+ TypeRegistry.Set = Set;
70
+ /** Gets a custom validation function for a user defined type */
71
+ function Get(kind) {
72
+ return map.get(kind);
73
+ }
74
+ TypeRegistry.Get = Get;
75
+ })(TypeRegistry = exports.TypeRegistry || (exports.TypeRegistry = {}));
76
+ /** A registry for user defined string formats */
77
+ var FormatRegistry;
78
+ (function (FormatRegistry) {
79
+ const map = new Map();
80
+ /** Returns the entries in this registry */
81
+ function Entries() {
82
+ return new Map(map);
83
+ }
84
+ FormatRegistry.Entries = Entries;
85
+ /** Clears all user defined string formats */
86
+ function Clear() {
87
+ return map.clear();
88
+ }
89
+ FormatRegistry.Clear = Clear;
90
+ /** Returns true if the user defined string format exists */
91
+ function Has(format) {
92
+ return map.has(format);
93
+ }
94
+ FormatRegistry.Has = Has;
95
+ /** Sets a validation function for a user defined string format */
96
+ function Set(format, func) {
97
+ map.set(format, func);
98
+ }
99
+ FormatRegistry.Set = Set;
100
+ /** Gets a validation function for a user defined string format */
101
+ function Get(format) {
102
+ return map.get(format);
103
+ }
104
+ FormatRegistry.Get = Get;
105
+ })(FormatRegistry = exports.FormatRegistry || (exports.FormatRegistry = {}));
106
+ // --------------------------------------------------------------------------
107
+ // TypeGuard
108
+ // --------------------------------------------------------------------------
109
+ class TypeGuardUnknownTypeError extends Error {
110
+ constructor(schema) {
111
+ super('TypeGuard: Unknown type');
112
+ this.schema = schema;
113
+ }
114
+ }
115
+ exports.TypeGuardUnknownTypeError = TypeGuardUnknownTypeError;
116
+ /** Provides functions to test if JavaScript values are TypeBox types */
117
+ var TypeGuard;
118
+ (function (TypeGuard) {
119
+ function IsObject(value) {
120
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
121
+ }
122
+ function IsArray(value) {
123
+ return typeof value === 'object' && value !== null && Array.isArray(value);
124
+ }
125
+ function IsPattern(value) {
126
+ try {
127
+ new RegExp(value);
128
+ return true;
129
+ }
130
+ catch {
131
+ return false;
132
+ }
133
+ }
134
+ function IsControlCharacterFree(value) {
135
+ if (typeof value !== 'string')
136
+ return false;
137
+ for (let i = 0; i < value.length; i++) {
138
+ const code = value.charCodeAt(i);
139
+ if ((code >= 7 && code <= 13) || code === 27 || code === 127) {
140
+ return false;
141
+ }
142
+ }
143
+ return true;
144
+ }
145
+ function IsBigInt(value) {
146
+ return typeof value === 'bigint';
147
+ }
148
+ function IsString(value) {
149
+ return typeof value === 'string';
150
+ }
151
+ function IsNumber(value) {
152
+ return typeof value === 'number' && globalThis.Number.isFinite(value);
153
+ }
154
+ function IsBoolean(value) {
155
+ return typeof value === 'boolean';
156
+ }
157
+ function IsOptionalBigInt(value) {
158
+ return value === undefined || (value !== undefined && IsBigInt(value));
159
+ }
160
+ function IsOptionalNumber(value) {
161
+ return value === undefined || (value !== undefined && IsNumber(value));
162
+ }
163
+ function IsOptionalBoolean(value) {
164
+ return value === undefined || (value !== undefined && IsBoolean(value));
165
+ }
166
+ function IsOptionalString(value) {
167
+ return value === undefined || (value !== undefined && IsString(value));
168
+ }
169
+ function IsOptionalPattern(value) {
170
+ return value === undefined || (value !== undefined && IsString(value) && IsControlCharacterFree(value) && IsPattern(value));
171
+ }
172
+ function IsOptionalFormat(value) {
173
+ return value === undefined || (value !== undefined && IsString(value) && IsControlCharacterFree(value));
174
+ }
175
+ function IsOptionalSchema(value) {
176
+ return value === undefined || TSchema(value);
177
+ }
178
+ /** Returns true if the given schema is TAny */
179
+ function TAny(schema) {
180
+ return TKind(schema) && schema[exports.Kind] === 'Any' && IsOptionalString(schema.$id);
181
+ }
182
+ TypeGuard.TAny = TAny;
183
+ /** Returns true if the given schema is TArray */
184
+ function TArray(schema) {
185
+ return (TKind(schema) &&
186
+ schema[exports.Kind] === 'Array' &&
187
+ schema.type === 'array' &&
188
+ IsOptionalString(schema.$id) &&
189
+ TSchema(schema.items) &&
190
+ IsOptionalNumber(schema.minItems) &&
191
+ IsOptionalNumber(schema.maxItems) &&
192
+ IsOptionalBoolean(schema.uniqueItems));
193
+ }
194
+ TypeGuard.TArray = TArray;
195
+ /** Returns true if the given schema is TBigInt */
196
+ function TBigInt(schema) {
197
+ // prettier-ignore
198
+ return (TKind(schema) &&
199
+ schema[exports.Kind] === 'BigInt' &&
200
+ schema.type === 'null' &&
201
+ schema.typeOf === 'BigInt' &&
202
+ IsOptionalString(schema.$id) &&
203
+ IsOptionalBigInt(schema.multipleOf) &&
204
+ IsOptionalBigInt(schema.minimum) &&
205
+ IsOptionalBigInt(schema.maximum) &&
206
+ IsOptionalBigInt(schema.exclusiveMinimum) &&
207
+ IsOptionalBigInt(schema.exclusiveMaximum));
208
+ }
209
+ TypeGuard.TBigInt = TBigInt;
210
+ /** Returns true if the given schema is TBoolean */
211
+ function TBoolean(schema) {
212
+ // prettier-ignore
213
+ return (TKind(schema) &&
214
+ schema[exports.Kind] === 'Boolean' &&
215
+ schema.type === 'boolean' &&
216
+ IsOptionalString(schema.$id));
217
+ }
218
+ TypeGuard.TBoolean = TBoolean;
219
+ /** Returns true if the given schema is TConstructor */
220
+ function TConstructor(schema) {
221
+ // prettier-ignore
222
+ if (!(TKind(schema) &&
223
+ schema[exports.Kind] === 'Constructor' &&
224
+ schema.type === 'object' &&
225
+ schema.instanceOf === 'Constructor' &&
226
+ IsOptionalString(schema.$id) &&
227
+ IsArray(schema.parameters) &&
228
+ TSchema(schema.returns))) {
229
+ return false;
230
+ }
231
+ for (const parameter of schema.parameters) {
232
+ if (!TSchema(parameter))
233
+ return false;
234
+ }
235
+ return true;
236
+ }
237
+ TypeGuard.TConstructor = TConstructor;
238
+ /** Returns true if the given schema is TDate */
239
+ function TDate(schema) {
240
+ return (TKind(schema) &&
241
+ schema[exports.Kind] === 'Date' &&
242
+ schema.type === 'object' &&
243
+ schema.instanceOf === 'Date' &&
244
+ IsOptionalString(schema.$id) &&
245
+ IsOptionalNumber(schema.minimumTimestamp) &&
246
+ IsOptionalNumber(schema.maximumTimestamp) &&
247
+ IsOptionalNumber(schema.exclusiveMinimumTimestamp) &&
248
+ IsOptionalNumber(schema.exclusiveMaximumTimestamp));
249
+ }
250
+ TypeGuard.TDate = TDate;
251
+ /** Returns true if the given schema is TFunction */
252
+ function TFunction(schema) {
253
+ // prettier-ignore
254
+ if (!(TKind(schema) &&
255
+ schema[exports.Kind] === 'Function' &&
256
+ schema.type === 'object' &&
257
+ schema.instanceOf === 'Function' &&
258
+ IsOptionalString(schema.$id) &&
259
+ IsArray(schema.parameters) &&
260
+ TSchema(schema.returns))) {
261
+ return false;
262
+ }
263
+ for (const parameter of schema.parameters) {
264
+ if (!TSchema(parameter))
265
+ return false;
266
+ }
267
+ return true;
268
+ }
269
+ TypeGuard.TFunction = TFunction;
270
+ /** Returns true if the given schema is TInteger */
271
+ function TInteger(schema) {
272
+ return (TKind(schema) &&
273
+ schema[exports.Kind] === 'Integer' &&
274
+ schema.type === 'integer' &&
275
+ IsOptionalString(schema.$id) &&
276
+ IsOptionalNumber(schema.multipleOf) &&
277
+ IsOptionalNumber(schema.minimum) &&
278
+ IsOptionalNumber(schema.maximum) &&
279
+ IsOptionalNumber(schema.exclusiveMinimum) &&
280
+ IsOptionalNumber(schema.exclusiveMaximum));
281
+ }
282
+ TypeGuard.TInteger = TInteger;
283
+ /** Returns true if the given schema is TIntersect */
284
+ function TIntersect(schema) {
285
+ // prettier-ignore
286
+ if (!(TKind(schema) &&
287
+ schema[exports.Kind] === 'Intersect' &&
288
+ IsArray(schema.allOf) &&
289
+ IsOptionalString(schema.type) &&
290
+ (IsOptionalBoolean(schema.unevaluatedProperties) || IsOptionalSchema(schema.unevaluatedProperties)) &&
291
+ IsOptionalString(schema.$id))) {
292
+ return false;
293
+ }
294
+ if ('type' in schema && schema.type !== 'object') {
295
+ return false;
296
+ }
297
+ for (const inner of schema.allOf) {
298
+ if (!TSchema(inner))
299
+ return false;
300
+ }
301
+ return true;
302
+ }
303
+ TypeGuard.TIntersect = TIntersect;
304
+ /** Returns true if the given schema is TKind */
305
+ function TKind(schema) {
306
+ return IsObject(schema) && exports.Kind in schema && typeof schema[exports.Kind] === 'string'; // TS 4.1.5: any required for symbol indexer
307
+ }
308
+ TypeGuard.TKind = TKind;
309
+ /** Returns true if the given schema is TLiteral */
310
+ function TLiteral(schema) {
311
+ // prettier-ignore
312
+ return (TKind(schema) &&
313
+ schema[exports.Kind] === 'Literal' &&
314
+ IsOptionalString(schema.$id) &&
315
+ (IsString(schema.const) ||
316
+ IsNumber(schema.const) ||
317
+ IsBoolean(schema.const) ||
318
+ IsBigInt(schema.const)));
319
+ }
320
+ TypeGuard.TLiteral = TLiteral;
321
+ /** Returns true if the given schema is TNever */
322
+ function TNever(schema) {
323
+ return TKind(schema) && schema[exports.Kind] === 'Never' && IsObject(schema.not) && globalThis.Object.getOwnPropertyNames(schema.not).length === 0;
324
+ }
325
+ TypeGuard.TNever = TNever;
326
+ /** Returns true if the given schema is TNot */
327
+ function TNot(schema) {
328
+ // prettier-ignore
329
+ return (TKind(schema) &&
330
+ schema[exports.Kind] === 'Not' &&
331
+ IsArray(schema.allOf) &&
332
+ schema.allOf.length === 2 &&
333
+ IsObject(schema.allOf[0]) &&
334
+ TSchema(schema.allOf[0].not) &&
335
+ TSchema(schema.allOf[1]));
336
+ }
337
+ TypeGuard.TNot = TNot;
338
+ /** Returns true if the given schema is TNull */
339
+ function TNull(schema) {
340
+ // prettier-ignore
341
+ return (TKind(schema) &&
342
+ schema[exports.Kind] === 'Null' &&
343
+ schema.type === 'null' &&
344
+ IsOptionalString(schema.$id));
345
+ }
346
+ TypeGuard.TNull = TNull;
347
+ /** Returns true if the given schema is TNumber */
348
+ function TNumber(schema) {
349
+ return (TKind(schema) &&
350
+ schema[exports.Kind] === 'Number' &&
351
+ schema.type === 'number' &&
352
+ IsOptionalString(schema.$id) &&
353
+ IsOptionalNumber(schema.multipleOf) &&
354
+ IsOptionalNumber(schema.minimum) &&
355
+ IsOptionalNumber(schema.maximum) &&
356
+ IsOptionalNumber(schema.exclusiveMinimum) &&
357
+ IsOptionalNumber(schema.exclusiveMaximum));
358
+ }
359
+ TypeGuard.TNumber = TNumber;
360
+ /** Returns true if the given schema is TObject */
361
+ function TObject(schema) {
362
+ if (!(TKind(schema) &&
363
+ schema[exports.Kind] === 'Object' &&
364
+ schema.type === 'object' &&
365
+ IsOptionalString(schema.$id) &&
366
+ IsObject(schema.properties) &&
367
+ (IsOptionalBoolean(schema.additionalProperties) || IsOptionalSchema(schema.additionalProperties)) &&
368
+ IsOptionalNumber(schema.minProperties) &&
369
+ IsOptionalNumber(schema.maxProperties))) {
370
+ return false;
371
+ }
372
+ for (const [key, value] of Object.entries(schema.properties)) {
373
+ if (!IsControlCharacterFree(key))
374
+ return false;
375
+ if (!TSchema(value))
376
+ return false;
377
+ }
378
+ return true;
379
+ }
380
+ TypeGuard.TObject = TObject;
381
+ /** Returns true if the given schema is TPromise */
382
+ function TPromise(schema) {
383
+ // prettier-ignore
384
+ return (TKind(schema) &&
385
+ schema[exports.Kind] === 'Promise' &&
386
+ schema.type === 'object' &&
387
+ schema.instanceOf === 'Promise' &&
388
+ IsOptionalString(schema.$id) &&
389
+ TSchema(schema.item));
390
+ }
391
+ TypeGuard.TPromise = TPromise;
392
+ /** Returns true if the given schema is TRecord */
393
+ function TRecord(schema) {
394
+ // prettier-ignore
395
+ if (!(TKind(schema) &&
396
+ schema[exports.Kind] === 'Record' &&
397
+ schema.type === 'object' &&
398
+ IsOptionalString(schema.$id) &&
399
+ schema.additionalProperties === false &&
400
+ IsObject(schema.patternProperties))) {
401
+ return false;
402
+ }
403
+ const keys = Object.keys(schema.patternProperties);
404
+ if (keys.length !== 1) {
405
+ return false;
406
+ }
407
+ if (!IsPattern(keys[0])) {
408
+ return false;
409
+ }
410
+ if (!TSchema(schema.patternProperties[keys[0]])) {
411
+ return false;
412
+ }
413
+ return true;
414
+ }
415
+ TypeGuard.TRecord = TRecord;
416
+ /** Returns true if the given schema is TRef */
417
+ function TRef(schema) {
418
+ // prettier-ignore
419
+ return (TKind(schema) &&
420
+ schema[exports.Kind] === 'Ref' &&
421
+ IsOptionalString(schema.$id) &&
422
+ IsString(schema.$ref));
423
+ }
424
+ TypeGuard.TRef = TRef;
425
+ /** Returns true if the given schema is TString */
426
+ function TString(schema) {
427
+ return (TKind(schema) &&
428
+ schema[exports.Kind] === 'String' &&
429
+ schema.type === 'string' &&
430
+ IsOptionalString(schema.$id) &&
431
+ IsOptionalNumber(schema.minLength) &&
432
+ IsOptionalNumber(schema.maxLength) &&
433
+ IsOptionalPattern(schema.pattern) &&
434
+ IsOptionalFormat(schema.format));
435
+ }
436
+ TypeGuard.TString = TString;
437
+ /** Returns true if the given schema is TSymbol */
438
+ function TSymbol(schema) {
439
+ // prettier-ignore
440
+ return (TKind(schema) &&
441
+ schema[exports.Kind] === 'Symbol' &&
442
+ schema.type === 'null' &&
443
+ schema.typeOf === 'Symbol' &&
444
+ IsOptionalString(schema.$id));
445
+ }
446
+ TypeGuard.TSymbol = TSymbol;
447
+ /** Returns true if the given schema is TTemplateLiteral */
448
+ function TTemplateLiteral(schema) {
449
+ // prettier-ignore
450
+ return (TKind(schema) &&
451
+ schema[exports.Kind] === 'TemplateLiteral' &&
452
+ schema.type === 'string' &&
453
+ IsString(schema.pattern) &&
454
+ schema.pattern[0] === '^' &&
455
+ schema.pattern[schema.pattern.length - 1] === '$');
456
+ }
457
+ TypeGuard.TTemplateLiteral = TTemplateLiteral;
458
+ /** Returns true if the given schema is TThis */
459
+ function TThis(schema) {
460
+ // prettier-ignore
461
+ return (TKind(schema) &&
462
+ schema[exports.Kind] === 'This' &&
463
+ IsOptionalString(schema.$id) &&
464
+ IsString(schema.$ref));
465
+ }
466
+ TypeGuard.TThis = TThis;
467
+ /** Returns true if the given schema is TTuple */
468
+ function TTuple(schema) {
469
+ // prettier-ignore
470
+ if (!(TKind(schema) &&
471
+ schema[exports.Kind] === 'Tuple' &&
472
+ schema.type === 'array' &&
473
+ IsOptionalString(schema.$id) &&
474
+ IsNumber(schema.minItems) &&
475
+ IsNumber(schema.maxItems) &&
476
+ schema.minItems === schema.maxItems)) {
477
+ return false;
478
+ }
479
+ if (schema.items === undefined && schema.additionalItems === undefined && schema.minItems === 0) {
480
+ return true;
481
+ }
482
+ if (!IsArray(schema.items)) {
483
+ return false;
484
+ }
485
+ for (const inner of schema.items) {
486
+ if (!TSchema(inner))
487
+ return false;
488
+ }
489
+ return true;
490
+ }
491
+ TypeGuard.TTuple = TTuple;
492
+ /** Returns true if the given schema is TUndefined */
493
+ function TUndefined(schema) {
494
+ // prettier-ignore
495
+ return (TKind(schema) &&
496
+ schema[exports.Kind] === 'Undefined' &&
497
+ schema.type === 'null' &&
498
+ schema.typeOf === 'Undefined' &&
499
+ IsOptionalString(schema.$id));
500
+ }
501
+ TypeGuard.TUndefined = TUndefined;
502
+ /** Returns true if the given schema is TUnion */
503
+ function TUnion(schema) {
504
+ // prettier-ignore
505
+ if (!(TKind(schema) &&
506
+ schema[exports.Kind] === 'Union' &&
507
+ IsArray(schema.anyOf) &&
508
+ IsOptionalString(schema.$id))) {
509
+ return false;
510
+ }
511
+ for (const inner of schema.anyOf) {
512
+ if (!TSchema(inner))
513
+ return false;
514
+ }
515
+ return true;
516
+ }
517
+ TypeGuard.TUnion = TUnion;
518
+ /** Returns true if the given schema is TUnion<Literal<string>[]> */
519
+ function TUnionLiteral(schema) {
520
+ return TUnion(schema) && schema.anyOf.every((schema) => TLiteral(schema) && typeof schema.const === 'string');
521
+ }
522
+ TypeGuard.TUnionLiteral = TUnionLiteral;
523
+ /** Returns true if the given schema is TUint8Array */
524
+ function TUint8Array(schema) {
525
+ return TKind(schema) && schema[exports.Kind] === 'Uint8Array' && schema.type === 'object' && IsOptionalString(schema.$id) && schema.instanceOf === 'Uint8Array' && IsOptionalNumber(schema.minByteLength) && IsOptionalNumber(schema.maxByteLength);
526
+ }
527
+ TypeGuard.TUint8Array = TUint8Array;
528
+ /** Returns true if the given schema is TUnknown */
529
+ function TUnknown(schema) {
530
+ // prettier-ignore
531
+ return (TKind(schema) &&
532
+ schema[exports.Kind] === 'Unknown' &&
533
+ IsOptionalString(schema.$id));
534
+ }
535
+ TypeGuard.TUnknown = TUnknown;
536
+ /** Returns true if the given schema is a raw TUnsafe */
537
+ function TUnsafe(schema) {
538
+ // prettier-ignore
539
+ return (TKind(schema) &&
540
+ schema[exports.Kind] === 'Unsafe');
541
+ }
542
+ TypeGuard.TUnsafe = TUnsafe;
543
+ /** Returns true if the given schema is TVoid */
544
+ function TVoid(schema) {
545
+ // prettier-ignore
546
+ return (TKind(schema) &&
547
+ schema[exports.Kind] === 'Void' &&
548
+ schema.type === 'null' &&
549
+ schema.typeOf === 'Void' &&
550
+ IsOptionalString(schema.$id));
551
+ }
552
+ TypeGuard.TVoid = TVoid;
553
+ /** Returns true if this schema has the ReadonlyOptional modifier */
554
+ function TReadonlyOptional(schema) {
555
+ return IsObject(schema) && schema[exports.Modifier] === 'ReadonlyOptional';
556
+ }
557
+ TypeGuard.TReadonlyOptional = TReadonlyOptional;
558
+ /** Returns true if this schema has the Readonly modifier */
559
+ function TReadonly(schema) {
560
+ return IsObject(schema) && schema[exports.Modifier] === 'Readonly';
561
+ }
562
+ TypeGuard.TReadonly = TReadonly;
563
+ /** Returns true if this schema has the Optional modifier */
564
+ function TOptional(schema) {
565
+ return IsObject(schema) && schema[exports.Modifier] === 'Optional';
566
+ }
567
+ TypeGuard.TOptional = TOptional;
568
+ /** Returns true if the given schema is TSchema */
569
+ function TSchema(schema) {
570
+ return (typeof schema === 'object' &&
571
+ (TAny(schema) ||
572
+ TArray(schema) ||
573
+ TBoolean(schema) ||
574
+ TBigInt(schema) ||
575
+ TConstructor(schema) ||
576
+ TDate(schema) ||
577
+ TFunction(schema) ||
578
+ TInteger(schema) ||
579
+ TIntersect(schema) ||
580
+ TLiteral(schema) ||
581
+ TNever(schema) ||
582
+ TNot(schema) ||
583
+ TNull(schema) ||
584
+ TNumber(schema) ||
585
+ TObject(schema) ||
586
+ TPromise(schema) ||
587
+ TRecord(schema) ||
588
+ TRef(schema) ||
589
+ TString(schema) ||
590
+ TSymbol(schema) ||
591
+ TTemplateLiteral(schema) ||
592
+ TThis(schema) ||
593
+ TTuple(schema) ||
594
+ TUndefined(schema) ||
595
+ TUnion(schema) ||
596
+ TUint8Array(schema) ||
597
+ TUnknown(schema) ||
598
+ TUnsafe(schema) ||
599
+ TVoid(schema) ||
600
+ (TKind(schema) && TypeRegistry.Has(schema[exports.Kind]))));
601
+ }
602
+ TypeGuard.TSchema = TSchema;
603
+ })(TypeGuard = exports.TypeGuard || (exports.TypeGuard = {}));
604
+ // --------------------------------------------------------------------------
605
+ // ExtendsUndefined
606
+ // --------------------------------------------------------------------------
607
+ /** Fast undefined check used for properties of type undefined */
608
+ var ExtendsUndefined;
609
+ (function (ExtendsUndefined) {
610
+ function Check(schema) {
611
+ if (schema[exports.Kind] === 'Undefined')
612
+ return true;
613
+ if (schema[exports.Kind] === 'Union') {
614
+ const union = schema;
615
+ return union.anyOf.some((schema) => Check(schema));
616
+ }
617
+ return false;
618
+ }
619
+ ExtendsUndefined.Check = Check;
620
+ })(ExtendsUndefined = exports.ExtendsUndefined || (exports.ExtendsUndefined = {}));
621
+ // --------------------------------------------------------------------------
622
+ // TypeExtends
623
+ // --------------------------------------------------------------------------
624
+ var TypeExtendsResult;
625
+ (function (TypeExtendsResult) {
626
+ TypeExtendsResult[TypeExtendsResult["Union"] = 0] = "Union";
627
+ TypeExtendsResult[TypeExtendsResult["True"] = 1] = "True";
628
+ TypeExtendsResult[TypeExtendsResult["False"] = 2] = "False";
629
+ })(TypeExtendsResult = exports.TypeExtendsResult || (exports.TypeExtendsResult = {}));
630
+ var TypeExtends;
631
+ (function (TypeExtends) {
632
+ // --------------------------------------------------------------------------
633
+ // IntoBooleanResult
634
+ // --------------------------------------------------------------------------
635
+ function IntoBooleanResult(result) {
636
+ return result === TypeExtendsResult.False ? TypeExtendsResult.False : TypeExtendsResult.True;
637
+ }
638
+ // --------------------------------------------------------------------------
639
+ // Any
640
+ // --------------------------------------------------------------------------
641
+ function AnyRight(left, right) {
642
+ return TypeExtendsResult.True;
643
+ }
644
+ function Any(left, right) {
645
+ if (TypeGuard.TIntersect(right))
646
+ return IntersectRight(left, right);
647
+ if (TypeGuard.TUnion(right) && right.anyOf.some((schema) => TypeGuard.TAny(schema) || TypeGuard.TUnknown(schema)))
648
+ return TypeExtendsResult.True;
649
+ if (TypeGuard.TUnion(right))
650
+ return TypeExtendsResult.Union;
651
+ if (TypeGuard.TUnknown(right))
652
+ return TypeExtendsResult.True;
653
+ if (TypeGuard.TAny(right))
654
+ return TypeExtendsResult.True;
655
+ return TypeExtendsResult.Union;
656
+ }
657
+ // --------------------------------------------------------------------------
658
+ // Array
659
+ // --------------------------------------------------------------------------
660
+ function ArrayRight(left, right) {
661
+ if (TypeGuard.TUnknown(left))
662
+ return TypeExtendsResult.False;
663
+ if (TypeGuard.TAny(left))
664
+ return TypeExtendsResult.Union;
665
+ if (TypeGuard.TNever(left))
666
+ return TypeExtendsResult.True;
667
+ return TypeExtendsResult.False;
668
+ }
669
+ function Array(left, right) {
670
+ if (TypeGuard.TIntersect(right))
671
+ return IntersectRight(left, right);
672
+ if (TypeGuard.TUnion(right))
673
+ return UnionRight(left, right);
674
+ if (TypeGuard.TUnknown(right))
675
+ return UnknownRight(left, right);
676
+ if (TypeGuard.TAny(right))
677
+ return AnyRight(left, right);
678
+ if (TypeGuard.TObject(right) && IsObjectArrayLike(right))
679
+ return TypeExtendsResult.True;
680
+ if (!TypeGuard.TArray(right))
681
+ return TypeExtendsResult.False;
682
+ return IntoBooleanResult(Visit(left.items, right.items));
683
+ }
684
+ // --------------------------------------------------------------------------
685
+ // BigInt
686
+ // --------------------------------------------------------------------------
687
+ function BigInt(left, right) {
688
+ if (TypeGuard.TIntersect(right))
689
+ return IntersectRight(left, right);
690
+ if (TypeGuard.TUnion(right))
691
+ return UnionRight(left, right);
692
+ if (TypeGuard.TNever(right))
693
+ return NeverRight(left, right);
694
+ if (TypeGuard.TUnknown(right))
695
+ return UnknownRight(left, right);
696
+ if (TypeGuard.TAny(right))
697
+ return AnyRight(left, right);
698
+ if (TypeGuard.TObject(right))
699
+ return ObjectRight(left, right);
700
+ if (TypeGuard.TRecord(right))
701
+ return RecordRight(left, right);
702
+ return TypeGuard.TBigInt(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
703
+ }
704
+ // --------------------------------------------------------------------------
705
+ // Boolean
706
+ // --------------------------------------------------------------------------
707
+ function BooleanRight(left, right) {
708
+ if (TypeGuard.TLiteral(left) && typeof left.const === 'boolean')
709
+ return TypeExtendsResult.True;
710
+ return TypeGuard.TBoolean(left) ? TypeExtendsResult.True : TypeExtendsResult.False;
711
+ }
712
+ function Boolean(left, right) {
713
+ if (TypeGuard.TIntersect(right))
714
+ return IntersectRight(left, right);
715
+ if (TypeGuard.TUnion(right))
716
+ return UnionRight(left, right);
717
+ if (TypeGuard.TNever(right))
718
+ return NeverRight(left, right);
719
+ if (TypeGuard.TUnknown(right))
720
+ return UnknownRight(left, right);
721
+ if (TypeGuard.TAny(right))
722
+ return AnyRight(left, right);
723
+ if (TypeGuard.TObject(right))
724
+ return ObjectRight(left, right);
725
+ if (TypeGuard.TRecord(right))
726
+ return RecordRight(left, right);
727
+ return TypeGuard.TBoolean(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
728
+ }
729
+ // --------------------------------------------------------------------------
730
+ // Constructor
731
+ // --------------------------------------------------------------------------
732
+ function Constructor(left, right) {
733
+ if (TypeGuard.TIntersect(right))
734
+ return IntersectRight(left, right);
735
+ if (TypeGuard.TUnion(right))
736
+ return UnionRight(left, right);
737
+ if (TypeGuard.TUnknown(right))
738
+ return UnknownRight(left, right);
739
+ if (TypeGuard.TAny(right))
740
+ return AnyRight(left, right);
741
+ if (TypeGuard.TObject(right))
742
+ return ObjectRight(left, right);
743
+ if (!TypeGuard.TConstructor(right))
744
+ return TypeExtendsResult.False;
745
+ if (left.parameters.length > right.parameters.length)
746
+ return TypeExtendsResult.False;
747
+ if (!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === TypeExtendsResult.True)) {
748
+ return TypeExtendsResult.False;
749
+ }
750
+ return IntoBooleanResult(Visit(left.returns, right.returns));
751
+ }
752
+ // --------------------------------------------------------------------------
753
+ // Date
754
+ // --------------------------------------------------------------------------
755
+ function Date(left, right) {
756
+ if (TypeGuard.TIntersect(right))
757
+ return IntersectRight(left, right);
758
+ if (TypeGuard.TUnion(right))
759
+ return UnionRight(left, right);
760
+ if (TypeGuard.TUnknown(right))
761
+ return UnknownRight(left, right);
762
+ if (TypeGuard.TAny(right))
763
+ return AnyRight(left, right);
764
+ if (TypeGuard.TObject(right))
765
+ return ObjectRight(left, right);
766
+ if (TypeGuard.TRecord(right))
767
+ return RecordRight(left, right);
768
+ return TypeGuard.TDate(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
769
+ }
770
+ // --------------------------------------------------------------------------
771
+ // Function
772
+ // --------------------------------------------------------------------------
773
+ function Function(left, right) {
774
+ if (TypeGuard.TIntersect(right))
775
+ return IntersectRight(left, right);
776
+ if (TypeGuard.TUnion(right))
777
+ return UnionRight(left, right);
778
+ if (TypeGuard.TUnknown(right))
779
+ return UnknownRight(left, right);
780
+ if (TypeGuard.TAny(right))
781
+ return AnyRight(left, right);
782
+ if (TypeGuard.TObject(right))
783
+ return ObjectRight(left, right);
784
+ if (!TypeGuard.TFunction(right))
785
+ return TypeExtendsResult.False;
786
+ if (left.parameters.length > right.parameters.length)
787
+ return TypeExtendsResult.False;
788
+ if (!left.parameters.every((schema, index) => IntoBooleanResult(Visit(right.parameters[index], schema)) === TypeExtendsResult.True)) {
789
+ return TypeExtendsResult.False;
790
+ }
791
+ return IntoBooleanResult(Visit(left.returns, right.returns));
792
+ }
793
+ // --------------------------------------------------------------------------
794
+ // Integer
795
+ // --------------------------------------------------------------------------
796
+ function IntegerRight(left, right) {
797
+ if (TypeGuard.TLiteral(left) && typeof left.const === 'number')
798
+ return TypeExtendsResult.True;
799
+ return TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? TypeExtendsResult.True : TypeExtendsResult.False;
800
+ }
801
+ function Integer(left, right) {
802
+ if (TypeGuard.TIntersect(right))
803
+ return IntersectRight(left, right);
804
+ if (TypeGuard.TUnion(right))
805
+ return UnionRight(left, right);
806
+ if (TypeGuard.TNever(right))
807
+ return NeverRight(left, right);
808
+ if (TypeGuard.TUnknown(right))
809
+ return UnknownRight(left, right);
810
+ if (TypeGuard.TAny(right))
811
+ return AnyRight(left, right);
812
+ if (TypeGuard.TObject(right))
813
+ return ObjectRight(left, right);
814
+ if (TypeGuard.TRecord(right))
815
+ return RecordRight(left, right);
816
+ return TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
817
+ }
818
+ // --------------------------------------------------------------------------
819
+ // Intersect
820
+ // --------------------------------------------------------------------------
821
+ function IntersectRight(left, right) {
822
+ return right.allOf.every((schema) => Visit(left, schema) === TypeExtendsResult.True) ? TypeExtendsResult.True : TypeExtendsResult.False;
823
+ }
824
+ function Intersect(left, right) {
825
+ return left.allOf.some((schema) => Visit(schema, right) === TypeExtendsResult.True) ? TypeExtendsResult.True : TypeExtendsResult.False;
826
+ }
827
+ // --------------------------------------------------------------------------
828
+ // Literal
829
+ // --------------------------------------------------------------------------
830
+ function IsLiteralString(schema) {
831
+ return typeof schema.const === 'string';
832
+ }
833
+ function IsLiteralNumber(schema) {
834
+ return typeof schema.const === 'number';
835
+ }
836
+ function IsLiteralBoolean(schema) {
837
+ return typeof schema.const === 'boolean';
838
+ }
839
+ function Literal(left, right) {
840
+ if (TypeGuard.TIntersect(right))
841
+ return IntersectRight(left, right);
842
+ if (TypeGuard.TUnion(right))
843
+ return UnionRight(left, right);
844
+ if (TypeGuard.TNever(right))
845
+ return NeverRight(left, right);
846
+ if (TypeGuard.TUnknown(right))
847
+ return UnknownRight(left, right);
848
+ if (TypeGuard.TAny(right))
849
+ return AnyRight(left, right);
850
+ if (TypeGuard.TObject(right))
851
+ return ObjectRight(left, right);
852
+ if (TypeGuard.TRecord(right))
853
+ return RecordRight(left, right);
854
+ if (TypeGuard.TString(right))
855
+ return StringRight(left, right);
856
+ if (TypeGuard.TNumber(right))
857
+ return NumberRight(left, right);
858
+ if (TypeGuard.TInteger(right))
859
+ return IntegerRight(left, right);
860
+ if (TypeGuard.TBoolean(right))
861
+ return BooleanRight(left, right);
862
+ return TypeGuard.TLiteral(right) && right.const === left.const ? TypeExtendsResult.True : TypeExtendsResult.False;
863
+ }
864
+ // --------------------------------------------------------------------------
865
+ // Never
866
+ // --------------------------------------------------------------------------
867
+ function NeverRight(left, right) {
868
+ return TypeExtendsResult.False;
869
+ }
870
+ function Never(left, right) {
871
+ return TypeExtendsResult.True;
872
+ }
873
+ // --------------------------------------------------------------------------
874
+ // Null
875
+ // --------------------------------------------------------------------------
876
+ function Null(left, right) {
877
+ if (TypeGuard.TIntersect(right))
878
+ return IntersectRight(left, right);
879
+ if (TypeGuard.TUnion(right))
880
+ return UnionRight(left, right);
881
+ if (TypeGuard.TNever(right))
882
+ return NeverRight(left, right);
883
+ if (TypeGuard.TUnknown(right))
884
+ return UnknownRight(left, right);
885
+ if (TypeGuard.TAny(right))
886
+ return AnyRight(left, right);
887
+ if (TypeGuard.TObject(right))
888
+ return ObjectRight(left, right);
889
+ if (TypeGuard.TRecord(right))
890
+ return RecordRight(left, right);
891
+ return TypeGuard.TNull(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
892
+ }
893
+ // --------------------------------------------------------------------------
894
+ // Number
895
+ // --------------------------------------------------------------------------
896
+ function NumberRight(left, right) {
897
+ if (TypeGuard.TLiteral(left) && IsLiteralNumber(left))
898
+ return TypeExtendsResult.True;
899
+ return TypeGuard.TNumber(left) || TypeGuard.TInteger(left) ? TypeExtendsResult.True : TypeExtendsResult.False;
900
+ }
901
+ function Number(left, right) {
902
+ if (TypeGuard.TIntersect(right))
903
+ return IntersectRight(left, right);
904
+ if (TypeGuard.TUnion(right))
905
+ return UnionRight(left, right);
906
+ if (TypeGuard.TNever(right))
907
+ return NeverRight(left, right);
908
+ if (TypeGuard.TUnknown(right))
909
+ return UnknownRight(left, right);
910
+ if (TypeGuard.TAny(right))
911
+ return AnyRight(left, right);
912
+ if (TypeGuard.TObject(right))
913
+ return ObjectRight(left, right);
914
+ if (TypeGuard.TRecord(right))
915
+ return RecordRight(left, right);
916
+ return TypeGuard.TInteger(right) || TypeGuard.TNumber(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
917
+ }
918
+ // --------------------------------------------------------------------------
919
+ // Object
920
+ // --------------------------------------------------------------------------
921
+ function IsObjectPropertyCount(schema, count) {
922
+ return globalThis.Object.keys(schema.properties).length === count;
923
+ }
924
+ function IsObjectStringLike(schema) {
925
+ return IsObjectArrayLike(schema);
926
+ }
927
+ function IsObjectSymbolLike(schema) {
928
+ // prettier-ignore
929
+ return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'description' in schema.properties && TypeGuard.TUnion(schema.properties.description) && schema.properties.description.anyOf.length === 2 && ((TypeGuard.TString(schema.properties.description.anyOf[0]) &&
930
+ TypeGuard.TUndefined(schema.properties.description.anyOf[1])) || (TypeGuard.TString(schema.properties.description.anyOf[1]) &&
931
+ TypeGuard.TUndefined(schema.properties.description.anyOf[0]))));
932
+ }
933
+ function IsObjectNumberLike(schema) {
934
+ return IsObjectPropertyCount(schema, 0);
935
+ }
936
+ function IsObjectBooleanLike(schema) {
937
+ return IsObjectPropertyCount(schema, 0);
938
+ }
939
+ function IsObjectBigIntLike(schema) {
940
+ return IsObjectPropertyCount(schema, 0);
941
+ }
942
+ function IsObjectDateLike(schema) {
943
+ return IsObjectPropertyCount(schema, 0);
944
+ }
945
+ function IsObjectUint8ArrayLike(schema) {
946
+ return IsObjectArrayLike(schema);
947
+ }
948
+ function IsObjectFunctionLike(schema) {
949
+ const length = exports.Type.Number();
950
+ return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'length' in schema.properties && IntoBooleanResult(Visit(schema.properties['length'], length)) === TypeExtendsResult.True);
951
+ }
952
+ function IsObjectConstructorLike(schema) {
953
+ return IsObjectPropertyCount(schema, 0);
954
+ }
955
+ function IsObjectArrayLike(schema) {
956
+ const length = exports.Type.Number();
957
+ return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'length' in schema.properties && IntoBooleanResult(Visit(schema.properties['length'], length)) === TypeExtendsResult.True);
958
+ }
959
+ function IsObjectPromiseLike(schema) {
960
+ const then = exports.Type.Function([exports.Type.Any()], exports.Type.Any());
961
+ return IsObjectPropertyCount(schema, 0) || (IsObjectPropertyCount(schema, 1) && 'then' in schema.properties && IntoBooleanResult(Visit(schema.properties['then'], then)) === TypeExtendsResult.True);
962
+ }
963
+ // --------------------------------------------------------------------------
964
+ // Property
965
+ // --------------------------------------------------------------------------
966
+ function Property(left, right) {
967
+ if (Visit(left, right) === TypeExtendsResult.False)
968
+ return TypeExtendsResult.False;
969
+ if (TypeGuard.TOptional(left) && !TypeGuard.TOptional(right))
970
+ return TypeExtendsResult.False;
971
+ return TypeExtendsResult.True;
972
+ }
973
+ function ObjectRight(left, right) {
974
+ if (TypeGuard.TUnknown(left))
975
+ return TypeExtendsResult.False;
976
+ if (TypeGuard.TAny(left))
977
+ return TypeExtendsResult.Union;
978
+ if (TypeGuard.TNever(left))
979
+ return TypeExtendsResult.True;
980
+ if (TypeGuard.TLiteral(left) && IsLiteralString(left) && IsObjectStringLike(right))
981
+ return TypeExtendsResult.True;
982
+ if (TypeGuard.TLiteral(left) && IsLiteralNumber(left) && IsObjectNumberLike(right))
983
+ return TypeExtendsResult.True;
984
+ if (TypeGuard.TLiteral(left) && IsLiteralBoolean(left) && IsObjectBooleanLike(right))
985
+ return TypeExtendsResult.True;
986
+ if (TypeGuard.TSymbol(left) && IsObjectSymbolLike(right))
987
+ return TypeExtendsResult.True;
988
+ if (TypeGuard.TBigInt(left) && IsObjectBigIntLike(right))
989
+ return TypeExtendsResult.True;
990
+ if (TypeGuard.TString(left) && IsObjectStringLike(right))
991
+ return TypeExtendsResult.True;
992
+ if (TypeGuard.TSymbol(left) && IsObjectSymbolLike(right))
993
+ return TypeExtendsResult.True;
994
+ if (TypeGuard.TNumber(left) && IsObjectNumberLike(right))
995
+ return TypeExtendsResult.True;
996
+ if (TypeGuard.TInteger(left) && IsObjectNumberLike(right))
997
+ return TypeExtendsResult.True;
998
+ if (TypeGuard.TBoolean(left) && IsObjectBooleanLike(right))
999
+ return TypeExtendsResult.True;
1000
+ if (TypeGuard.TUint8Array(left) && IsObjectUint8ArrayLike(right))
1001
+ return TypeExtendsResult.True;
1002
+ if (TypeGuard.TDate(left) && IsObjectDateLike(right))
1003
+ return TypeExtendsResult.True;
1004
+ if (TypeGuard.TConstructor(left) && IsObjectConstructorLike(right))
1005
+ return TypeExtendsResult.True;
1006
+ if (TypeGuard.TFunction(left) && IsObjectFunctionLike(right))
1007
+ return TypeExtendsResult.True;
1008
+ if (TypeGuard.TRecord(left) && TypeGuard.TString(RecordKey(left))) {
1009
+ // When expressing a Record with literal key values, the Record is converted into a Object with
1010
+ // the Hint assigned as `Record`. This is used to invert the extends logic.
1011
+ return right[exports.Hint] === 'Record' ? TypeExtendsResult.True : TypeExtendsResult.False;
1012
+ }
1013
+ if (TypeGuard.TRecord(left) && TypeGuard.TNumber(RecordKey(left))) {
1014
+ return IsObjectPropertyCount(right, 0) ? TypeExtendsResult.True : TypeExtendsResult.False;
1015
+ }
1016
+ return TypeExtendsResult.False;
1017
+ }
1018
+ function Object(left, right) {
1019
+ if (TypeGuard.TIntersect(right))
1020
+ return IntersectRight(left, right);
1021
+ if (TypeGuard.TUnion(right))
1022
+ return UnionRight(left, right);
1023
+ if (TypeGuard.TUnknown(right))
1024
+ return UnknownRight(left, right);
1025
+ if (TypeGuard.TAny(right))
1026
+ return AnyRight(left, right);
1027
+ if (TypeGuard.TRecord(right))
1028
+ return RecordRight(left, right);
1029
+ if (!TypeGuard.TObject(right))
1030
+ return TypeExtendsResult.False;
1031
+ for (const key of globalThis.Object.keys(right.properties)) {
1032
+ if (!(key in left.properties))
1033
+ return TypeExtendsResult.False;
1034
+ if (Property(left.properties[key], right.properties[key]) === TypeExtendsResult.False) {
1035
+ return TypeExtendsResult.False;
1036
+ }
1037
+ }
1038
+ return TypeExtendsResult.True;
1039
+ }
1040
+ // --------------------------------------------------------------------------
1041
+ // Promise
1042
+ // --------------------------------------------------------------------------
1043
+ function Promise(left, right) {
1044
+ if (TypeGuard.TIntersect(right))
1045
+ return IntersectRight(left, right);
1046
+ if (TypeGuard.TUnion(right))
1047
+ return UnionRight(left, right);
1048
+ if (TypeGuard.TUnknown(right))
1049
+ return UnknownRight(left, right);
1050
+ if (TypeGuard.TAny(right))
1051
+ return AnyRight(left, right);
1052
+ if (TypeGuard.TObject(right) && IsObjectPromiseLike(right))
1053
+ return TypeExtendsResult.True;
1054
+ if (!TypeGuard.TPromise(right))
1055
+ return TypeExtendsResult.False;
1056
+ return IntoBooleanResult(Visit(left.item, right.item));
1057
+ }
1058
+ // --------------------------------------------------------------------------
1059
+ // Record
1060
+ // --------------------------------------------------------------------------
1061
+ function RecordKey(schema) {
1062
+ if (exports.PatternNumberExact in schema.patternProperties)
1063
+ return exports.Type.Number();
1064
+ if (exports.PatternStringExact in schema.patternProperties)
1065
+ return exports.Type.String();
1066
+ throw Error('TypeExtends: Cannot get record key');
1067
+ }
1068
+ function RecordValue(schema) {
1069
+ if (exports.PatternNumberExact in schema.patternProperties)
1070
+ return schema.patternProperties[exports.PatternNumberExact];
1071
+ if (exports.PatternStringExact in schema.patternProperties)
1072
+ return schema.patternProperties[exports.PatternStringExact];
1073
+ throw Error('TypeExtends: Cannot get record value');
1074
+ }
1075
+ function RecordRight(left, right) {
1076
+ const Key = RecordKey(right);
1077
+ const Value = RecordValue(right);
1078
+ if (TypeGuard.TLiteral(left) && IsLiteralString(left) && TypeGuard.TNumber(Key) && IntoBooleanResult(Visit(left, Value)) === TypeExtendsResult.True)
1079
+ return TypeExtendsResult.True;
1080
+ if (TypeGuard.TUint8Array(left) && TypeGuard.TNumber(Key))
1081
+ return Visit(left, Value);
1082
+ if (TypeGuard.TString(left) && TypeGuard.TNumber(Key))
1083
+ return Visit(left, Value);
1084
+ if (TypeGuard.TArray(left) && TypeGuard.TNumber(Key))
1085
+ return Visit(left, Value);
1086
+ if (TypeGuard.TObject(left)) {
1087
+ for (const key of globalThis.Object.keys(left.properties)) {
1088
+ if (Property(Value, left.properties[key]) === TypeExtendsResult.False) {
1089
+ return TypeExtendsResult.False;
1090
+ }
1091
+ }
1092
+ return TypeExtendsResult.True;
1093
+ }
1094
+ return TypeExtendsResult.False;
1095
+ }
1096
+ function Record(left, right) {
1097
+ const Value = RecordValue(left);
1098
+ if (TypeGuard.TIntersect(right))
1099
+ return IntersectRight(left, right);
1100
+ if (TypeGuard.TUnion(right))
1101
+ return UnionRight(left, right);
1102
+ if (TypeGuard.TUnknown(right))
1103
+ return UnknownRight(left, right);
1104
+ if (TypeGuard.TAny(right))
1105
+ return AnyRight(left, right);
1106
+ if (TypeGuard.TObject(right))
1107
+ return ObjectRight(left, right);
1108
+ if (!TypeGuard.TRecord(right))
1109
+ return TypeExtendsResult.False;
1110
+ return Visit(Value, RecordValue(right));
1111
+ }
1112
+ // --------------------------------------------------------------------------
1113
+ // String
1114
+ // --------------------------------------------------------------------------
1115
+ function StringRight(left, right) {
1116
+ if (TypeGuard.TLiteral(left) && typeof left.const === 'string')
1117
+ return TypeExtendsResult.True;
1118
+ return TypeGuard.TString(left) ? TypeExtendsResult.True : TypeExtendsResult.False;
1119
+ }
1120
+ function String(left, right) {
1121
+ if (TypeGuard.TIntersect(right))
1122
+ return IntersectRight(left, right);
1123
+ if (TypeGuard.TUnion(right))
1124
+ return UnionRight(left, right);
1125
+ if (TypeGuard.TNever(right))
1126
+ return NeverRight(left, right);
1127
+ if (TypeGuard.TUnknown(right))
1128
+ return UnknownRight(left, right);
1129
+ if (TypeGuard.TAny(right))
1130
+ return AnyRight(left, right);
1131
+ if (TypeGuard.TObject(right))
1132
+ return ObjectRight(left, right);
1133
+ if (TypeGuard.TRecord(right))
1134
+ return RecordRight(left, right);
1135
+ return TypeGuard.TString(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1136
+ }
1137
+ // --------------------------------------------------------------------------
1138
+ // Symbol
1139
+ // --------------------------------------------------------------------------
1140
+ function Symbol(left, right) {
1141
+ if (TypeGuard.TIntersect(right))
1142
+ return IntersectRight(left, right);
1143
+ if (TypeGuard.TUnion(right))
1144
+ return UnionRight(left, right);
1145
+ if (TypeGuard.TNever(right))
1146
+ return NeverRight(left, right);
1147
+ if (TypeGuard.TUnknown(right))
1148
+ return UnknownRight(left, right);
1149
+ if (TypeGuard.TAny(right))
1150
+ return AnyRight(left, right);
1151
+ if (TypeGuard.TObject(right))
1152
+ return ObjectRight(left, right);
1153
+ if (TypeGuard.TRecord(right))
1154
+ return RecordRight(left, right);
1155
+ return TypeGuard.TSymbol(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1156
+ }
1157
+ // --------------------------------------------------------------------------
1158
+ // Tuple
1159
+ // --------------------------------------------------------------------------
1160
+ function TupleRight(left, right) {
1161
+ if (TypeGuard.TUnknown(left))
1162
+ return TypeExtendsResult.False;
1163
+ if (TypeGuard.TAny(left))
1164
+ return TypeExtendsResult.Union;
1165
+ if (TypeGuard.TNever(left))
1166
+ return TypeExtendsResult.True;
1167
+ return TypeExtendsResult.False;
1168
+ }
1169
+ function IsArrayOfTuple(left, right) {
1170
+ return TypeGuard.TArray(right) && left.items !== undefined && left.items.every((schema) => Visit(schema, right.items) === TypeExtendsResult.True);
1171
+ }
1172
+ function Tuple(left, right) {
1173
+ if (TypeGuard.TIntersect(right))
1174
+ return IntersectRight(left, right);
1175
+ if (TypeGuard.TUnion(right))
1176
+ return UnionRight(left, right);
1177
+ if (TypeGuard.TUnknown(right))
1178
+ return UnknownRight(left, right);
1179
+ if (TypeGuard.TAny(right))
1180
+ return AnyRight(left, right);
1181
+ if (TypeGuard.TObject(right) && IsObjectArrayLike(right))
1182
+ return TypeExtendsResult.True;
1183
+ if (TypeGuard.TArray(right) && IsArrayOfTuple(left, right))
1184
+ return TypeExtendsResult.True;
1185
+ if (!TypeGuard.TTuple(right))
1186
+ return TypeExtendsResult.False;
1187
+ if ((left.items === undefined && right.items !== undefined) || (left.items !== undefined && right.items === undefined))
1188
+ return TypeExtendsResult.False;
1189
+ if (left.items === undefined && right.items === undefined)
1190
+ return TypeExtendsResult.True;
1191
+ return left.items.every((schema, index) => Visit(schema, right.items[index]) === TypeExtendsResult.True) ? TypeExtendsResult.True : TypeExtendsResult.False;
1192
+ }
1193
+ // --------------------------------------------------------------------------
1194
+ // Uint8Array
1195
+ // --------------------------------------------------------------------------
1196
+ function Uint8Array(left, right) {
1197
+ if (TypeGuard.TIntersect(right))
1198
+ return IntersectRight(left, right);
1199
+ if (TypeGuard.TUnion(right))
1200
+ return UnionRight(left, right);
1201
+ if (TypeGuard.TUnknown(right))
1202
+ return UnknownRight(left, right);
1203
+ if (TypeGuard.TAny(right))
1204
+ return AnyRight(left, right);
1205
+ if (TypeGuard.TObject(right))
1206
+ return ObjectRight(left, right);
1207
+ if (TypeGuard.TRecord(right))
1208
+ return RecordRight(left, right);
1209
+ return TypeGuard.TUint8Array(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1210
+ }
1211
+ // --------------------------------------------------------------------------
1212
+ // Undefined
1213
+ // --------------------------------------------------------------------------
1214
+ function Undefined(left, right) {
1215
+ if (TypeGuard.TIntersect(right))
1216
+ return IntersectRight(left, right);
1217
+ if (TypeGuard.TUnion(right))
1218
+ return UnionRight(left, right);
1219
+ if (TypeGuard.TNever(right))
1220
+ return NeverRight(left, right);
1221
+ if (TypeGuard.TUnknown(right))
1222
+ return UnknownRight(left, right);
1223
+ if (TypeGuard.TAny(right))
1224
+ return AnyRight(left, right);
1225
+ if (TypeGuard.TObject(right))
1226
+ return ObjectRight(left, right);
1227
+ if (TypeGuard.TRecord(right))
1228
+ return RecordRight(left, right);
1229
+ if (TypeGuard.TVoid(right))
1230
+ return VoidRight(left, right);
1231
+ return TypeGuard.TUndefined(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1232
+ }
1233
+ // --------------------------------------------------------------------------
1234
+ // Union
1235
+ // --------------------------------------------------------------------------
1236
+ function UnionRight(left, right) {
1237
+ return right.anyOf.some((schema) => Visit(left, schema) === TypeExtendsResult.True) ? TypeExtendsResult.True : TypeExtendsResult.False;
1238
+ }
1239
+ function Union(left, right) {
1240
+ return left.anyOf.every((schema) => Visit(schema, right) === TypeExtendsResult.True) ? TypeExtendsResult.True : TypeExtendsResult.False;
1241
+ }
1242
+ // --------------------------------------------------------------------------
1243
+ // Unknown
1244
+ // --------------------------------------------------------------------------
1245
+ function UnknownRight(left, right) {
1246
+ return TypeExtendsResult.True;
1247
+ }
1248
+ function Unknown(left, right) {
1249
+ if (TypeGuard.TIntersect(right))
1250
+ return IntersectRight(left, right);
1251
+ if (TypeGuard.TUnion(right))
1252
+ return UnionRight(left, right);
1253
+ if (TypeGuard.TAny(right))
1254
+ return AnyRight(left, right);
1255
+ if (TypeGuard.TString(right))
1256
+ return StringRight(left, right);
1257
+ if (TypeGuard.TNumber(right))
1258
+ return NumberRight(left, right);
1259
+ if (TypeGuard.TInteger(right))
1260
+ return IntegerRight(left, right);
1261
+ if (TypeGuard.TBoolean(right))
1262
+ return BooleanRight(left, right);
1263
+ if (TypeGuard.TArray(right))
1264
+ return ArrayRight(left, right);
1265
+ if (TypeGuard.TTuple(right))
1266
+ return TupleRight(left, right);
1267
+ if (TypeGuard.TObject(right))
1268
+ return ObjectRight(left, right);
1269
+ return TypeGuard.TUnknown(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1270
+ }
1271
+ // --------------------------------------------------------------------------
1272
+ // Void
1273
+ // --------------------------------------------------------------------------
1274
+ function VoidRight(left, right) {
1275
+ if (TypeGuard.TUndefined(left))
1276
+ return TypeExtendsResult.True;
1277
+ return TypeGuard.TUndefined(left) ? TypeExtendsResult.True : TypeExtendsResult.False;
1278
+ }
1279
+ function Void(left, right) {
1280
+ if (TypeGuard.TIntersect(right))
1281
+ return IntersectRight(left, right);
1282
+ if (TypeGuard.TUnion(right))
1283
+ return UnionRight(left, right);
1284
+ if (TypeGuard.TUnknown(right))
1285
+ return UnknownRight(left, right);
1286
+ if (TypeGuard.TAny(right))
1287
+ return AnyRight(left, right);
1288
+ if (TypeGuard.TObject(right))
1289
+ return ObjectRight(left, right);
1290
+ return TypeGuard.TVoid(right) ? TypeExtendsResult.True : TypeExtendsResult.False;
1291
+ }
1292
+ function Visit(left, right) {
1293
+ // template union remap
1294
+ if (TypeGuard.TTemplateLiteral(left))
1295
+ return Visit(TemplateLiteralResolver.Resolve(left), right);
1296
+ if (TypeGuard.TTemplateLiteral(right))
1297
+ return Visit(left, TemplateLiteralResolver.Resolve(right));
1298
+ // standard extends
1299
+ if (TypeGuard.TAny(left))
1300
+ return Any(left, right);
1301
+ if (TypeGuard.TArray(left))
1302
+ return Array(left, right);
1303
+ if (TypeGuard.TBigInt(left))
1304
+ return BigInt(left, right);
1305
+ if (TypeGuard.TBoolean(left))
1306
+ return Boolean(left, right);
1307
+ if (TypeGuard.TConstructor(left))
1308
+ return Constructor(left, right);
1309
+ if (TypeGuard.TDate(left))
1310
+ return Date(left, right);
1311
+ if (TypeGuard.TFunction(left))
1312
+ return Function(left, right);
1313
+ if (TypeGuard.TInteger(left))
1314
+ return Integer(left, right);
1315
+ if (TypeGuard.TIntersect(left))
1316
+ return Intersect(left, right);
1317
+ if (TypeGuard.TLiteral(left))
1318
+ return Literal(left, right);
1319
+ if (TypeGuard.TNever(left))
1320
+ return Never(left, right);
1321
+ if (TypeGuard.TNull(left))
1322
+ return Null(left, right);
1323
+ if (TypeGuard.TNumber(left))
1324
+ return Number(left, right);
1325
+ if (TypeGuard.TObject(left))
1326
+ return Object(left, right);
1327
+ if (TypeGuard.TRecord(left))
1328
+ return Record(left, right);
1329
+ if (TypeGuard.TString(left))
1330
+ return String(left, right);
1331
+ if (TypeGuard.TSymbol(left))
1332
+ return Symbol(left, right);
1333
+ if (TypeGuard.TTuple(left))
1334
+ return Tuple(left, right);
1335
+ if (TypeGuard.TPromise(left))
1336
+ return Promise(left, right);
1337
+ if (TypeGuard.TUint8Array(left))
1338
+ return Uint8Array(left, right);
1339
+ if (TypeGuard.TUndefined(left))
1340
+ return Undefined(left, right);
1341
+ if (TypeGuard.TUnion(left))
1342
+ return Union(left, right);
1343
+ if (TypeGuard.TUnknown(left))
1344
+ return Unknown(left, right);
1345
+ if (TypeGuard.TVoid(left))
1346
+ return Void(left, right);
1347
+ throw Error(`TypeExtends: Unknown left type operand '${left[exports.Kind]}'`);
1348
+ }
1349
+ function Extends(left, right) {
1350
+ return Visit(left, right);
1351
+ }
1352
+ TypeExtends.Extends = Extends;
1353
+ })(TypeExtends = exports.TypeExtends || (exports.TypeExtends = {}));
1354
+ // --------------------------------------------------------------------------
1355
+ // TypeClone
1356
+ // --------------------------------------------------------------------------
1357
+ /** Specialized Clone for Types */
1358
+ var TypeClone;
1359
+ (function (TypeClone) {
1360
+ function IsObject(value) {
1361
+ return typeof value === 'object' && value !== null;
1362
+ }
1363
+ function IsArray(value) {
1364
+ return globalThis.Array.isArray(value);
1365
+ }
1366
+ function Array(value) {
1367
+ return value.map((value) => Visit(value));
1368
+ }
1369
+ function Object(value) {
1370
+ const clonedProperties = globalThis.Object.getOwnPropertyNames(value).reduce((acc, key) => {
1371
+ return { ...acc, [key]: Visit(value[key]) };
1372
+ }, {});
1373
+ const clonedSymbols = globalThis.Object.getOwnPropertySymbols(value).reduce((acc, key) => {
1374
+ return { ...acc, [key]: Visit(value[key]) };
1375
+ }, {});
1376
+ return { ...clonedProperties, ...clonedSymbols };
1377
+ }
1378
+ function Visit(value) {
1379
+ if (IsArray(value))
1380
+ return Array(value);
1381
+ if (IsObject(value))
1382
+ return Object(value);
1383
+ return value;
1384
+ }
1385
+ /** Clones a type. */
1386
+ function Clone(schema, options) {
1387
+ return { ...Visit(schema), ...options };
1388
+ }
1389
+ TypeClone.Clone = Clone;
1390
+ })(TypeClone = exports.TypeClone || (exports.TypeClone = {}));
1391
+ // --------------------------------------------------------------------------
1392
+ // ObjectMap
1393
+ // --------------------------------------------------------------------------
1394
+ var ObjectMap;
1395
+ (function (ObjectMap) {
1396
+ function Intersect(schema, callback) {
1397
+ // prettier-ignore
1398
+ return exports.Type.Intersect(schema.allOf.map((inner) => Visit(inner, callback)), { ...schema });
1399
+ }
1400
+ function Union(schema, callback) {
1401
+ // prettier-ignore
1402
+ return exports.Type.Union(schema.anyOf.map((inner) => Visit(inner, callback)), { ...schema });
1403
+ }
1404
+ function Object(schema, callback) {
1405
+ return callback(schema);
1406
+ }
1407
+ function Visit(schema, callback) {
1408
+ // There are cases where users need to map objects with unregistered kinds. Using a TypeGuard here would
1409
+ // prevent sub schema mapping as unregistered kinds will not pass TSchema checks. This is notable in the
1410
+ // case of TObject where unregistered property kinds cause the TObject check to fail. As mapping is only
1411
+ // used for composition, we use explicit checks instead.
1412
+ if (schema[exports.Kind] === 'Intersect')
1413
+ return Intersect(schema, callback);
1414
+ if (schema[exports.Kind] === 'Union')
1415
+ return Union(schema, callback);
1416
+ if (schema[exports.Kind] === 'Object')
1417
+ return Object(schema, callback);
1418
+ return schema;
1419
+ }
1420
+ function Map(schema, callback, options) {
1421
+ return { ...Visit(TypeClone.Clone(schema, {}), callback), ...options };
1422
+ }
1423
+ ObjectMap.Map = Map;
1424
+ })(ObjectMap = exports.ObjectMap || (exports.ObjectMap = {}));
1425
+ // --------------------------------------------------------------------------
1426
+ // KeyResolver
1427
+ // --------------------------------------------------------------------------
1428
+ var KeyResolver;
1429
+ (function (KeyResolver) {
1430
+ function IsKeyable(schema) {
1431
+ return TypeGuard.TIntersect(schema) || TypeGuard.TUnion(schema) || (TypeGuard.TObject(schema) && globalThis.Object.getOwnPropertyNames(schema.properties).length > 0);
1432
+ }
1433
+ function Intersect(schema) {
1434
+ return [...schema.allOf.filter((schema) => IsKeyable(schema)).reduce((set, schema) => Visit(schema).map((key) => set.add(key))[0], new Set())];
1435
+ }
1436
+ function Union(schema) {
1437
+ const sets = schema.anyOf.filter((schema) => IsKeyable(schema)).map((inner) => Visit(inner));
1438
+ return [...sets.reduce((set, outer) => outer.map((key) => (sets.every((inner) => inner.includes(key)) ? set.add(key) : set))[0], new Set())];
1439
+ }
1440
+ function Object(schema) {
1441
+ return globalThis.Object.keys(schema.properties);
1442
+ }
1443
+ function Visit(schema) {
1444
+ if (TypeGuard.TIntersect(schema))
1445
+ return Intersect(schema);
1446
+ if (TypeGuard.TUnion(schema))
1447
+ return Union(schema);
1448
+ if (TypeGuard.TObject(schema))
1449
+ return Object(schema);
1450
+ return [];
1451
+ }
1452
+ function Resolve(schema) {
1453
+ return Visit(schema);
1454
+ }
1455
+ KeyResolver.Resolve = Resolve;
1456
+ })(KeyResolver = exports.KeyResolver || (exports.KeyResolver = {}));
1457
+ // --------------------------------------------------------------------------
1458
+ // TemplateLiteralPattern
1459
+ // --------------------------------------------------------------------------
1460
+ var TemplateLiteralPattern;
1461
+ (function (TemplateLiteralPattern) {
1462
+ function Escape(value) {
1463
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
1464
+ }
1465
+ function Visit(schema, acc) {
1466
+ if (TypeGuard.TTemplateLiteral(schema)) {
1467
+ const pattern = schema.pattern.slice(1, schema.pattern.length - 1);
1468
+ return pattern;
1469
+ }
1470
+ else if (TypeGuard.TUnion(schema)) {
1471
+ const tokens = schema.anyOf.map((schema) => Visit(schema, acc)).join('|');
1472
+ return `(${tokens})`;
1473
+ }
1474
+ else if (TypeGuard.TNumber(schema)) {
1475
+ return `${acc}${exports.PatternNumber}`;
1476
+ }
1477
+ else if (TypeGuard.TInteger(schema)) {
1478
+ return `${acc}${exports.PatternNumber}`;
1479
+ }
1480
+ else if (TypeGuard.TBigInt(schema)) {
1481
+ return `${acc}${exports.PatternNumber}`;
1482
+ }
1483
+ else if (TypeGuard.TString(schema)) {
1484
+ return `${acc}${exports.PatternString}`;
1485
+ }
1486
+ else if (TypeGuard.TLiteral(schema)) {
1487
+ return `${acc}${Escape(schema.const.toString())}`;
1488
+ }
1489
+ else if (TypeGuard.TBoolean(schema)) {
1490
+ return `${acc}${exports.PatternBoolean}`;
1491
+ }
1492
+ else if (TypeGuard.TNever(schema)) {
1493
+ throw Error('TemplateLiteralPattern: TemplateLiteral cannot operate on types of TNever');
1494
+ }
1495
+ else {
1496
+ throw Error(`TemplateLiteralPattern: Unexpected Kind '${schema[exports.Kind]}'`);
1497
+ }
1498
+ }
1499
+ function Create(kinds) {
1500
+ return `^${kinds.map((schema) => Visit(schema, '')).join('')}\$`;
1501
+ }
1502
+ TemplateLiteralPattern.Create = Create;
1503
+ })(TemplateLiteralPattern = exports.TemplateLiteralPattern || (exports.TemplateLiteralPattern = {}));
1504
+ // --------------------------------------------------------------------------------------
1505
+ // TemplateLiteralResolver
1506
+ // --------------------------------------------------------------------------------------
1507
+ var TemplateLiteralResolver;
1508
+ (function (TemplateLiteralResolver) {
1509
+ function Resolve(template) {
1510
+ const expression = TemplateLiteralParser.ParseExact(template.pattern);
1511
+ if (!TemplateLiteralFinite.Check(expression))
1512
+ return exports.Type.String();
1513
+ const literals = [...TemplateLiteralGenerator.Generate(expression)].map((value) => exports.Type.Literal(value));
1514
+ return exports.Type.Union(literals);
1515
+ }
1516
+ TemplateLiteralResolver.Resolve = Resolve;
1517
+ })(TemplateLiteralResolver = exports.TemplateLiteralResolver || (exports.TemplateLiteralResolver = {}));
1518
+ // --------------------------------------------------------------------------------------
1519
+ // TemplateLiteralParser
1520
+ // --------------------------------------------------------------------------------------
1521
+ class TemplateLiteralParserError extends Error {
1522
+ constructor(message) {
1523
+ super(message);
1524
+ }
1525
+ }
1526
+ exports.TemplateLiteralParserError = TemplateLiteralParserError;
1527
+ var TemplateLiteralParser;
1528
+ (function (TemplateLiteralParser) {
1529
+ function IsNonEscaped(pattern, index, char) {
1530
+ return pattern[index] === char && pattern.charCodeAt(index - 1) !== 92;
1531
+ }
1532
+ function IsOpenParen(pattern, index) {
1533
+ return IsNonEscaped(pattern, index, '(');
1534
+ }
1535
+ function IsCloseParen(pattern, index) {
1536
+ return IsNonEscaped(pattern, index, ')');
1537
+ }
1538
+ function IsSeparator(pattern, index) {
1539
+ return IsNonEscaped(pattern, index, '|');
1540
+ }
1541
+ function IsGroup(pattern) {
1542
+ if (!(IsOpenParen(pattern, 0) && IsCloseParen(pattern, pattern.length - 1)))
1543
+ return false;
1544
+ let count = 0;
1545
+ for (let index = 0; index < pattern.length; index++) {
1546
+ if (IsOpenParen(pattern, index))
1547
+ count += 1;
1548
+ if (IsCloseParen(pattern, index))
1549
+ count -= 1;
1550
+ if (count === 0 && index !== pattern.length - 1)
1551
+ return false;
1552
+ }
1553
+ return true;
1554
+ }
1555
+ function InGroup(pattern) {
1556
+ return pattern.slice(1, pattern.length - 1);
1557
+ }
1558
+ function IsPrecedenceOr(pattern) {
1559
+ let count = 0;
1560
+ for (let index = 0; index < pattern.length; index++) {
1561
+ if (IsOpenParen(pattern, index))
1562
+ count += 1;
1563
+ if (IsCloseParen(pattern, index))
1564
+ count -= 1;
1565
+ if (IsSeparator(pattern, index) && count === 0)
1566
+ return true;
1567
+ }
1568
+ return false;
1569
+ }
1570
+ function IsPrecedenceAnd(pattern) {
1571
+ for (let index = 0; index < pattern.length; index++) {
1572
+ if (IsOpenParen(pattern, index))
1573
+ return true;
1574
+ }
1575
+ return false;
1576
+ }
1577
+ function Or(pattern) {
1578
+ let [count, start] = [0, 0];
1579
+ const expressions = [];
1580
+ for (let index = 0; index < pattern.length; index++) {
1581
+ if (IsOpenParen(pattern, index))
1582
+ count += 1;
1583
+ if (IsCloseParen(pattern, index))
1584
+ count -= 1;
1585
+ if (IsSeparator(pattern, index) && count === 0) {
1586
+ const range = pattern.slice(start, index);
1587
+ if (range.length > 0)
1588
+ expressions.push(Parse(range));
1589
+ start = index + 1;
1590
+ }
1591
+ }
1592
+ const range = pattern.slice(start);
1593
+ if (range.length > 0)
1594
+ expressions.push(Parse(range));
1595
+ if (expressions.length === 0)
1596
+ return { type: 'const', const: '' };
1597
+ if (expressions.length === 1)
1598
+ return expressions[0];
1599
+ return { type: 'or', expr: expressions };
1600
+ }
1601
+ function And(pattern) {
1602
+ function Group(value, index) {
1603
+ if (!IsOpenParen(value, index))
1604
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Index must point to open parens`);
1605
+ let count = 0;
1606
+ for (let scan = index; scan < value.length; scan++) {
1607
+ if (IsOpenParen(value, scan))
1608
+ count += 1;
1609
+ if (IsCloseParen(value, scan))
1610
+ count -= 1;
1611
+ if (count === 0)
1612
+ return [index, scan];
1613
+ }
1614
+ throw new TemplateLiteralParserError(`TemplateLiteralParser: Unclosed group parens in expression`);
1615
+ }
1616
+ function Range(pattern, index) {
1617
+ for (let scan = index; scan < pattern.length; scan++) {
1618
+ if (IsOpenParen(pattern, scan))
1619
+ return [index, scan];
1620
+ }
1621
+ return [index, pattern.length];
1622
+ }
1623
+ const expressions = [];
1624
+ for (let index = 0; index < pattern.length; index++) {
1625
+ if (IsOpenParen(pattern, index)) {
1626
+ const [start, end] = Group(pattern, index);
1627
+ const range = pattern.slice(start, end + 1);
1628
+ expressions.push(Parse(range));
1629
+ index = end;
1630
+ }
1631
+ else {
1632
+ const [start, end] = Range(pattern, index);
1633
+ const range = pattern.slice(start, end);
1634
+ if (range.length > 0)
1635
+ expressions.push(Parse(range));
1636
+ index = end - 1;
1637
+ }
1638
+ }
1639
+ if (expressions.length === 0)
1640
+ return { type: 'const', const: '' };
1641
+ if (expressions.length === 1)
1642
+ return expressions[0];
1643
+ return { type: 'and', expr: expressions };
1644
+ }
1645
+ /** Parses a pattern and returns an expression tree */
1646
+ function Parse(pattern) {
1647
+ if (IsGroup(pattern))
1648
+ return Parse(InGroup(pattern));
1649
+ if (IsPrecedenceOr(pattern))
1650
+ return Or(pattern);
1651
+ if (IsPrecedenceAnd(pattern))
1652
+ return And(pattern);
1653
+ return { type: 'const', const: pattern };
1654
+ }
1655
+ TemplateLiteralParser.Parse = Parse;
1656
+ /** Parses a pattern and strips forward and trailing ^ and $ */
1657
+ function ParseExact(pattern) {
1658
+ return Parse(pattern.slice(1, pattern.length - 1));
1659
+ }
1660
+ TemplateLiteralParser.ParseExact = ParseExact;
1661
+ })(TemplateLiteralParser = exports.TemplateLiteralParser || (exports.TemplateLiteralParser = {}));
1662
+ // --------------------------------------------------------------------------------------
1663
+ // TemplateLiteralFinite
1664
+ // --------------------------------------------------------------------------------------
1665
+ var TemplateLiteralFinite;
1666
+ (function (TemplateLiteralFinite) {
1667
+ function IsNumber(expression) {
1668
+ // prettier-ignore
1669
+ return (expression.type === 'or' &&
1670
+ expression.expr.length === 2 &&
1671
+ expression.expr[0].type === 'const' &&
1672
+ expression.expr[0].const === '0' &&
1673
+ expression.expr[1].type === 'const' &&
1674
+ expression.expr[1].const === '[1-9][0-9]*');
1675
+ }
1676
+ function IsBoolean(expression) {
1677
+ // prettier-ignore
1678
+ return (expression.type === 'or' &&
1679
+ expression.expr.length === 2 &&
1680
+ expression.expr[0].type === 'const' &&
1681
+ expression.expr[0].const === 'true' &&
1682
+ expression.expr[1].type === 'const' &&
1683
+ expression.expr[1].const === 'false');
1684
+ }
1685
+ function IsString(expression) {
1686
+ return expression.type === 'const' && expression.const === '.*';
1687
+ }
1688
+ function Check(expression) {
1689
+ if (IsBoolean(expression))
1690
+ return true;
1691
+ if (IsNumber(expression) || IsString(expression))
1692
+ return false;
1693
+ if (expression.type === 'and')
1694
+ return expression.expr.every((expr) => Check(expr));
1695
+ if (expression.type === 'or')
1696
+ return expression.expr.every((expr) => Check(expr));
1697
+ if (expression.type === 'const')
1698
+ return true;
1699
+ throw Error(`TemplateLiteralFinite: Unknown expression type`);
1700
+ }
1701
+ TemplateLiteralFinite.Check = Check;
1702
+ })(TemplateLiteralFinite = exports.TemplateLiteralFinite || (exports.TemplateLiteralFinite = {}));
1703
+ // --------------------------------------------------------------------------------------
1704
+ // TemplateLiteralGenerator
1705
+ // --------------------------------------------------------------------------------------
1706
+ var TemplateLiteralGenerator;
1707
+ (function (TemplateLiteralGenerator) {
1708
+ function* Reduce(buffer) {
1709
+ if (buffer.length === 1)
1710
+ return yield* buffer[0];
1711
+ for (const left of buffer[0]) {
1712
+ for (const right of Reduce(buffer.slice(1))) {
1713
+ yield `${left}${right}`;
1714
+ }
1715
+ }
1716
+ }
1717
+ function* And(expression) {
1718
+ return yield* Reduce(expression.expr.map((expr) => [...Generate(expr)]));
1719
+ }
1720
+ function* Or(expression) {
1721
+ for (const expr of expression.expr)
1722
+ yield* Generate(expr);
1723
+ }
1724
+ function* Const(expression) {
1725
+ return yield expression.const;
1726
+ }
1727
+ function* Generate(expression) {
1728
+ if (expression.type === 'and')
1729
+ return yield* And(expression);
1730
+ if (expression.type === 'or')
1731
+ return yield* Or(expression);
1732
+ if (expression.type === 'const')
1733
+ return yield* Const(expression);
1734
+ throw Error('TemplateLiteralGenerator: Unknown expression');
1735
+ }
1736
+ TemplateLiteralGenerator.Generate = Generate;
1737
+ })(TemplateLiteralGenerator = exports.TemplateLiteralGenerator || (exports.TemplateLiteralGenerator = {}));
1738
+ // --------------------------------------------------------------------------
1739
+ // TypeOrdinal: Used for auto $id generation
1740
+ // --------------------------------------------------------------------------
1741
+ let TypeOrdinal = 0;
1742
+ // --------------------------------------------------------------------------
1743
+ // TypeBuilder
1744
+ // --------------------------------------------------------------------------
1745
+ class TypeBuilder {
1746
+ /** `[Utility]` Creates a schema without `static` and `params` types */
1747
+ Create(schema) {
1748
+ return schema;
1749
+ }
1750
+ /** `[Standard]` Omits compositing symbols from this schema */
1751
+ Strict(schema) {
1752
+ return JSON.parse(JSON.stringify(schema));
1753
+ }
1754
+ }
1755
+ exports.TypeBuilder = TypeBuilder;
1756
+ // --------------------------------------------------------------------------
1757
+ // StandardTypeBuilder
1758
+ // --------------------------------------------------------------------------
1759
+ class StandardTypeBuilder extends TypeBuilder {
1760
+ // ------------------------------------------------------------------------
1761
+ // Modifiers
1762
+ // ------------------------------------------------------------------------
1763
+ /** `[Modifier]` Creates a Optional property */
1764
+ Optional(schema) {
1765
+ return { [exports.Modifier]: 'Optional', ...TypeClone.Clone(schema, {}) };
1766
+ }
1767
+ /** `[Modifier]` Creates a ReadonlyOptional property */
1768
+ ReadonlyOptional(schema) {
1769
+ return { [exports.Modifier]: 'ReadonlyOptional', ...TypeClone.Clone(schema, {}) };
1770
+ }
1771
+ /** `[Modifier]` Creates a Readonly object or property */
1772
+ Readonly(schema) {
1773
+ return { [exports.Modifier]: 'Readonly', ...schema };
1774
+ }
1775
+ // ------------------------------------------------------------------------
1776
+ // Types
1777
+ // ------------------------------------------------------------------------
1778
+ /** `[Standard]` Creates an Any type */
1779
+ Any(options = {}) {
1780
+ return this.Create({ ...options, [exports.Kind]: 'Any' });
1781
+ }
1782
+ /** `[Standard]` Creates an Array type */
1783
+ Array(items, options = {}) {
1784
+ return this.Create({ ...options, [exports.Kind]: 'Array', type: 'array', items: TypeClone.Clone(items, {}) });
1785
+ }
1786
+ /** `[Standard]` Creates a Boolean type */
1787
+ Boolean(options = {}) {
1788
+ return this.Create({ ...options, [exports.Kind]: 'Boolean', type: 'boolean' });
1789
+ }
1790
+ /** `[Standard]` Creates a Composite object type. */
1791
+ Composite(objects, options) {
1792
+ const isOptionalAll = (objects, key) => objects.every((object) => !(key in object.properties) || IsOptional(object.properties[key]));
1793
+ const IsOptional = (schema) => TypeGuard.TOptional(schema) || TypeGuard.TReadonlyOptional(schema);
1794
+ const [required, optional] = [new Set(), new Set()];
1795
+ for (const object of objects) {
1796
+ for (const key of globalThis.Object.getOwnPropertyNames(object.properties)) {
1797
+ if (isOptionalAll(objects, key))
1798
+ optional.add(key);
1799
+ }
1800
+ }
1801
+ for (const object of objects) {
1802
+ for (const key of globalThis.Object.getOwnPropertyNames(object.properties)) {
1803
+ if (!optional.has(key))
1804
+ required.add(key);
1805
+ }
1806
+ }
1807
+ const properties = {};
1808
+ for (const object of objects) {
1809
+ for (const [key, schema] of Object.entries(object.properties)) {
1810
+ const property = TypeClone.Clone(schema, {});
1811
+ if (!optional.has(key))
1812
+ delete property[exports.Modifier];
1813
+ if (key in properties) {
1814
+ const left = TypeExtends.Extends(properties[key], property) !== TypeExtendsResult.False;
1815
+ const right = TypeExtends.Extends(property, properties[key]) !== TypeExtendsResult.False;
1816
+ if (!left && !right)
1817
+ properties[key] = exports.Type.Never();
1818
+ if (!left && right)
1819
+ properties[key] = property;
1820
+ }
1821
+ else {
1822
+ properties[key] = property;
1823
+ }
1824
+ }
1825
+ }
1826
+ if (required.size > 0) {
1827
+ return this.Create({ ...options, [exports.Kind]: 'Object', [exports.Hint]: 'Composite', type: 'object', properties, required: [...required] });
1828
+ }
1829
+ else {
1830
+ return this.Create({ ...options, [exports.Kind]: 'Object', [exports.Hint]: 'Composite', type: 'object', properties });
1831
+ }
1832
+ }
1833
+ /** `[Standard]` Creates a Enum type */
1834
+ Enum(item, options = {}) {
1835
+ // prettier-ignore
1836
+ const values = globalThis.Object.keys(item).filter((key) => isNaN(key)).map((key) => item[key]);
1837
+ const anyOf = values.map((value) => (typeof value === 'string' ? { [exports.Kind]: 'Literal', type: 'string', const: value } : { [exports.Kind]: 'Literal', type: 'number', const: value }));
1838
+ return this.Create({ ...options, [exports.Kind]: 'Union', anyOf });
1839
+ }
1840
+ /** `[Standard]` A conditional type expression that will return the true type if the left type extends the right */
1841
+ Extends(left, right, trueType, falseType, options = {}) {
1842
+ switch (TypeExtends.Extends(left, right)) {
1843
+ case TypeExtendsResult.Union:
1844
+ return this.Union([TypeClone.Clone(trueType, options), TypeClone.Clone(falseType, options)]);
1845
+ case TypeExtendsResult.True:
1846
+ return TypeClone.Clone(trueType, options);
1847
+ case TypeExtendsResult.False:
1848
+ return TypeClone.Clone(falseType, options);
1849
+ }
1850
+ }
1851
+ /** `[Standard]` Excludes from the left type any type that is not assignable to the right */
1852
+ Exclude(left, right, options = {}) {
1853
+ if (TypeGuard.TTemplateLiteral(left))
1854
+ return this.Exclude(TemplateLiteralResolver.Resolve(left), right, options);
1855
+ if (TypeGuard.TTemplateLiteral(right))
1856
+ return this.Exclude(left, TemplateLiteralResolver.Resolve(right), options);
1857
+ if (TypeGuard.TUnion(left)) {
1858
+ const narrowed = left.anyOf.filter((inner) => TypeExtends.Extends(inner, right) === TypeExtendsResult.False);
1859
+ return (narrowed.length === 1 ? TypeClone.Clone(narrowed[0], options) : this.Union(narrowed, options));
1860
+ }
1861
+ else {
1862
+ return (TypeExtends.Extends(left, right) !== TypeExtendsResult.False ? this.Never(options) : TypeClone.Clone(left, options));
1863
+ }
1864
+ }
1865
+ /** `[Standard]` Extracts from the left type any type that is assignable to the right */
1866
+ Extract(left, right, options = {}) {
1867
+ if (TypeGuard.TTemplateLiteral(left))
1868
+ return this.Extract(TemplateLiteralResolver.Resolve(left), right, options);
1869
+ if (TypeGuard.TTemplateLiteral(right))
1870
+ return this.Extract(left, TemplateLiteralResolver.Resolve(right), options);
1871
+ if (TypeGuard.TUnion(left)) {
1872
+ const narrowed = left.anyOf.filter((inner) => TypeExtends.Extends(inner, right) !== TypeExtendsResult.False);
1873
+ return (narrowed.length === 1 ? TypeClone.Clone(narrowed[0], options) : this.Union(narrowed, options));
1874
+ }
1875
+ else {
1876
+ return (TypeExtends.Extends(left, right) !== TypeExtendsResult.False ? TypeClone.Clone(left, options) : this.Never(options));
1877
+ }
1878
+ }
1879
+ /** `[Standard]` Creates an Integer type */
1880
+ Integer(options = {}) {
1881
+ return this.Create({ ...options, [exports.Kind]: 'Integer', type: 'integer' });
1882
+ }
1883
+ Intersect(allOf, options = {}) {
1884
+ if (allOf.length === 0)
1885
+ return exports.Type.Never();
1886
+ if (allOf.length === 1)
1887
+ return TypeClone.Clone(allOf[0], options);
1888
+ const objects = allOf.every((schema) => TypeGuard.TObject(schema));
1889
+ const cloned = allOf.map((schema) => TypeClone.Clone(schema, {}));
1890
+ const clonedUnevaluatedProperties = TypeGuard.TSchema(options.unevaluatedProperties) ? { unevaluatedProperties: TypeClone.Clone(options.unevaluatedProperties, {}) } : {};
1891
+ if (options.unevaluatedProperties === false || TypeGuard.TSchema(options.unevaluatedProperties) || objects) {
1892
+ return this.Create({ ...options, ...clonedUnevaluatedProperties, [exports.Kind]: 'Intersect', type: 'object', allOf: cloned });
1893
+ }
1894
+ else {
1895
+ return this.Create({ ...options, ...clonedUnevaluatedProperties, [exports.Kind]: 'Intersect', allOf: cloned });
1896
+ }
1897
+ }
1898
+ /** `[Standard]` Creates a KeyOf type */
1899
+ KeyOf(schema, options = {}) {
1900
+ if (TypeGuard.TRecord(schema)) {
1901
+ const pattern = Object.getOwnPropertyNames(schema.patternProperties)[0];
1902
+ if (pattern === exports.PatternNumberExact)
1903
+ return this.Number(options);
1904
+ if (pattern === exports.PatternStringExact)
1905
+ return this.String(options);
1906
+ throw Error('StandardTypeBuilder: Unable to resolve key type from Record key pattern');
1907
+ }
1908
+ else {
1909
+ const resolved = KeyResolver.Resolve(schema);
1910
+ if (resolved.length === 0)
1911
+ return this.Never(options);
1912
+ const literals = resolved.map((key) => this.Literal(key));
1913
+ return this.Union(literals, options);
1914
+ }
1915
+ }
1916
+ /** `[Standard]` Creates a Literal type */
1917
+ Literal(value, options = {}) {
1918
+ return this.Create({ ...options, [exports.Kind]: 'Literal', const: value, type: typeof value });
1919
+ }
1920
+ /** `[Standard]` Creates a Never type */
1921
+ Never(options = {}) {
1922
+ return this.Create({ ...options, [exports.Kind]: 'Never', not: {} });
1923
+ }
1924
+ /** `[Standard]` Creates a Not type. The first argument is the disallowed type, the second is the allowed. */
1925
+ Not(not, schema, options) {
1926
+ return this.Create({ ...options, [exports.Kind]: 'Not', allOf: [{ not: TypeClone.Clone(not, {}) }, TypeClone.Clone(schema, {})] });
1927
+ }
1928
+ /** `[Standard]` Creates a Null type */
1929
+ Null(options = {}) {
1930
+ return this.Create({ ...options, [exports.Kind]: 'Null', type: 'null' });
1931
+ }
1932
+ /** `[Standard]` Creates a Number type */
1933
+ Number(options = {}) {
1934
+ return this.Create({ ...options, [exports.Kind]: 'Number', type: 'number' });
1935
+ }
1936
+ /** `[Standard]` Creates an Object type */
1937
+ Object(properties, options = {}) {
1938
+ const propertyKeys = globalThis.Object.getOwnPropertyNames(properties);
1939
+ const optionalKeys = propertyKeys.filter((key) => TypeGuard.TOptional(properties[key]) || TypeGuard.TReadonlyOptional(properties[key]));
1940
+ const requiredKeys = propertyKeys.filter((name) => !optionalKeys.includes(name));
1941
+ const clonedAdditionalProperties = TypeGuard.TSchema(options.additionalProperties) ? { additionalProperties: TypeClone.Clone(options.additionalProperties, {}) } : {};
1942
+ const clonedProperties = propertyKeys.reduce((acc, key) => ({ ...acc, [key]: TypeClone.Clone(properties[key], {}) }), {});
1943
+ if (requiredKeys.length > 0) {
1944
+ return this.Create({ ...options, ...clonedAdditionalProperties, [exports.Kind]: 'Object', type: 'object', properties: clonedProperties, required: requiredKeys });
1945
+ }
1946
+ else {
1947
+ return this.Create({ ...options, ...clonedAdditionalProperties, [exports.Kind]: 'Object', type: 'object', properties: clonedProperties });
1948
+ }
1949
+ }
1950
+ Omit(schema, unresolved, options = {}) {
1951
+ // prettier-ignore
1952
+ const keys = TypeGuard.TUnionLiteral(unresolved) ? unresolved.anyOf.map((schema) => schema.const) :
1953
+ TypeGuard.TLiteral(unresolved) ? [unresolved.const] :
1954
+ TypeGuard.TNever(unresolved) ? [] :
1955
+ unresolved;
1956
+ // prettier-ignore
1957
+ return ObjectMap.Map(TypeClone.Clone(schema, {}), (schema) => {
1958
+ if (schema.required) {
1959
+ schema.required = schema.required.filter((key) => !keys.includes(key));
1960
+ if (schema.required.length === 0)
1961
+ delete schema.required;
1962
+ }
1963
+ for (const key of globalThis.Object.keys(schema.properties)) {
1964
+ if (keys.includes(key))
1965
+ delete schema.properties[key];
1966
+ }
1967
+ return this.Create(schema);
1968
+ }, options);
1969
+ }
1970
+ /** `[Standard]` Creates a mapped type where all properties are Optional */
1971
+ Partial(schema, options = {}) {
1972
+ function Apply(schema) {
1973
+ // prettier-ignore
1974
+ switch (schema[exports.Modifier]) {
1975
+ case 'ReadonlyOptional':
1976
+ schema[exports.Modifier] = 'ReadonlyOptional';
1977
+ break;
1978
+ case 'Readonly':
1979
+ schema[exports.Modifier] = 'ReadonlyOptional';
1980
+ break;
1981
+ case 'Optional':
1982
+ schema[exports.Modifier] = 'Optional';
1983
+ break;
1984
+ default:
1985
+ schema[exports.Modifier] = 'Optional';
1986
+ break;
1987
+ }
1988
+ }
1989
+ // prettier-ignore
1990
+ return ObjectMap.Map(TypeClone.Clone(schema, {}), (schema) => {
1991
+ delete schema.required;
1992
+ globalThis.Object.keys(schema.properties).forEach(key => Apply(schema.properties[key]));
1993
+ return schema;
1994
+ }, options);
1995
+ }
1996
+ Pick(schema, unresolved, options = {}) {
1997
+ // prettier-ignore
1998
+ const keys = TypeGuard.TUnionLiteral(unresolved) ? unresolved.anyOf.map((schema) => schema.const) :
1999
+ TypeGuard.TLiteral(unresolved) ? [unresolved.const] :
2000
+ TypeGuard.TNever(unresolved) ? [] :
2001
+ unresolved;
2002
+ // prettier-ignore
2003
+ return ObjectMap.Map(TypeClone.Clone(schema, {}), (schema) => {
2004
+ if (schema.required) {
2005
+ schema.required = schema.required.filter((key) => keys.includes(key));
2006
+ if (schema.required.length === 0)
2007
+ delete schema.required;
2008
+ }
2009
+ for (const key of globalThis.Object.keys(schema.properties)) {
2010
+ if (!keys.includes(key))
2011
+ delete schema.properties[key];
2012
+ }
2013
+ return this.Create(schema);
2014
+ }, options);
2015
+ }
2016
+ /** `[Standard]` Creates a Record type */
2017
+ Record(key, schema, options = {}) {
2018
+ if (TypeGuard.TTemplateLiteral(key)) {
2019
+ const expression = TemplateLiteralParser.ParseExact(key.pattern);
2020
+ // prettier-ignore
2021
+ return TemplateLiteralFinite.Check(expression)
2022
+ ? (this.Object([...TemplateLiteralGenerator.Generate(expression)].reduce((acc, key) => ({ ...acc, [key]: TypeClone.Clone(schema, {}) }), {}), options))
2023
+ : this.Create({ ...options, [exports.Kind]: 'Record', type: 'object', patternProperties: { [key.pattern]: TypeClone.Clone(schema, {}) }, additionalProperties: false });
2024
+ }
2025
+ else if (TypeGuard.TUnionLiteral(key)) {
2026
+ if (key.anyOf.every((schema) => TypeGuard.TLiteral(schema) && (typeof schema.const === 'string' || typeof schema.const === 'number'))) {
2027
+ const properties = key.anyOf.reduce((acc, literal) => ({ ...acc, [literal.const]: TypeClone.Clone(schema, {}) }), {});
2028
+ return this.Object(properties, { ...options, [exports.Hint]: 'Record' });
2029
+ }
2030
+ else
2031
+ throw Error('TypeBuilder: Record key can only be derived from union literal of number or string');
2032
+ }
2033
+ else if (TypeGuard.TLiteral(key)) {
2034
+ if (typeof key.const === 'string' || typeof key.const === 'number') {
2035
+ return this.Object({ [key.const]: TypeClone.Clone(schema, {}) }, options);
2036
+ }
2037
+ else
2038
+ throw Error('TypeBuilder: Record key can only be derived from literals of number or string');
2039
+ }
2040
+ else if (TypeGuard.TInteger(key) || TypeGuard.TNumber(key)) {
2041
+ const pattern = exports.PatternNumberExact;
2042
+ return this.Create({ ...options, [exports.Kind]: 'Record', type: 'object', patternProperties: { [pattern]: TypeClone.Clone(schema, {}) }, additionalProperties: false });
2043
+ }
2044
+ else if (TypeGuard.TString(key)) {
2045
+ const pattern = key.pattern === undefined ? exports.PatternStringExact : key.pattern;
2046
+ return this.Create({ ...options, [exports.Kind]: 'Record', type: 'object', patternProperties: { [pattern]: TypeClone.Clone(schema, {}) }, additionalProperties: false });
2047
+ }
2048
+ else {
2049
+ throw Error(`StandardTypeBuilder: Invalid Record Key`);
2050
+ }
2051
+ }
2052
+ /** `[Standard]` Creates a Recursive type */
2053
+ Recursive(callback, options = {}) {
2054
+ if (options.$id === undefined)
2055
+ options.$id = `T${TypeOrdinal++}`;
2056
+ const thisType = callback({ [exports.Kind]: 'This', $ref: `${options.$id}` });
2057
+ thisType.$id = options.$id;
2058
+ return this.Create({ ...options, [exports.Hint]: 'Recursive', ...thisType });
2059
+ }
2060
+ /** `[Standard]` Creates a Ref type. The referenced type must contain a $id */
2061
+ Ref(schema, options = {}) {
2062
+ if (schema.$id === undefined)
2063
+ throw Error('StandardTypeBuilder.Ref: Target type must specify an $id');
2064
+ return this.Create({ ...options, [exports.Kind]: 'Ref', $ref: schema.$id });
2065
+ }
2066
+ /** `[Standard]` Creates a mapped type where all properties are Required */
2067
+ Required(schema, options = {}) {
2068
+ function Apply(schema) {
2069
+ // prettier-ignore
2070
+ switch (schema[exports.Modifier]) {
2071
+ case 'ReadonlyOptional':
2072
+ schema[exports.Modifier] = 'Readonly';
2073
+ break;
2074
+ case 'Readonly':
2075
+ schema[exports.Modifier] = 'Readonly';
2076
+ break;
2077
+ case 'Optional':
2078
+ delete schema[exports.Modifier];
2079
+ break;
2080
+ default:
2081
+ delete schema[exports.Modifier];
2082
+ break;
2083
+ }
2084
+ }
2085
+ // prettier-ignore
2086
+ return ObjectMap.Map(TypeClone.Clone(schema, {}), (schema) => {
2087
+ schema.required = globalThis.Object.keys(schema.properties);
2088
+ globalThis.Object.keys(schema.properties).forEach(key => Apply(schema.properties[key]));
2089
+ return schema;
2090
+ }, options);
2091
+ }
2092
+ /** `[Standard]` Creates a String type */
2093
+ String(options = {}) {
2094
+ return this.Create({ ...options, [exports.Kind]: 'String', type: 'string' });
2095
+ }
2096
+ /** `[Standard]` Creates a template literal type */
2097
+ TemplateLiteral(kinds, options = {}) {
2098
+ const pattern = TemplateLiteralPattern.Create(kinds);
2099
+ return this.Create({ ...options, [exports.Kind]: 'TemplateLiteral', type: 'string', pattern });
2100
+ }
2101
+ /** `[Standard]` Creates a Tuple type */
2102
+ Tuple(items, options = {}) {
2103
+ const [additionalItems, minItems, maxItems] = [false, items.length, items.length];
2104
+ const clonedItems = items.map((item) => TypeClone.Clone(item, {}));
2105
+ // prettier-ignore
2106
+ const schema = (items.length > 0 ?
2107
+ { ...options, [exports.Kind]: 'Tuple', type: 'array', items: clonedItems, additionalItems, minItems, maxItems } :
2108
+ { ...options, [exports.Kind]: 'Tuple', type: 'array', minItems, maxItems });
2109
+ return this.Create(schema);
2110
+ }
2111
+ Union(union, options = {}) {
2112
+ if (TypeGuard.TTemplateLiteral(union)) {
2113
+ return TemplateLiteralResolver.Resolve(union);
2114
+ }
2115
+ else {
2116
+ const anyOf = union;
2117
+ if (anyOf.length === 0)
2118
+ return this.Never(options);
2119
+ if (anyOf.length === 1)
2120
+ return this.Create(TypeClone.Clone(anyOf[0], options));
2121
+ const clonedAnyOf = anyOf.map((schema) => TypeClone.Clone(schema, {}));
2122
+ return this.Create({ ...options, [exports.Kind]: 'Union', anyOf: clonedAnyOf });
2123
+ }
2124
+ }
2125
+ /** `[Standard]` Creates an Unknown type */
2126
+ Unknown(options = {}) {
2127
+ return this.Create({ ...options, [exports.Kind]: 'Unknown' });
2128
+ }
2129
+ /** `[Standard]` Creates a Unsafe type that infers for the generic argument */
2130
+ Unsafe(options = {}) {
2131
+ return this.Create({ ...options, [exports.Kind]: options[exports.Kind] || 'Unsafe' });
2132
+ }
2133
+ }
2134
+ exports.StandardTypeBuilder = StandardTypeBuilder;
2135
+ // --------------------------------------------------------------------------
2136
+ // ExtendedTypeBuilder
2137
+ // --------------------------------------------------------------------------
2138
+ class ExtendedTypeBuilder extends StandardTypeBuilder {
2139
+ /** `[Extended]` Creates a BigInt type */
2140
+ BigInt(options = {}) {
2141
+ return this.Create({ ...options, [exports.Kind]: 'BigInt', type: 'null', typeOf: 'BigInt' });
2142
+ }
2143
+ /** `[Extended]` Extracts the ConstructorParameters from the given Constructor type */
2144
+ ConstructorParameters(schema, options = {}) {
2145
+ return this.Tuple([...schema.parameters], { ...options });
2146
+ }
2147
+ Constructor(parameters, returns, options = {}) {
2148
+ const clonedReturns = TypeClone.Clone(returns, {});
2149
+ if (TypeGuard.TTuple(parameters)) {
2150
+ const clonedParameters = parameters.items === undefined ? [] : parameters.items.map((parameter) => TypeClone.Clone(parameter, {}));
2151
+ return this.Create({ ...options, [exports.Kind]: 'Constructor', type: 'object', instanceOf: 'Constructor', parameters: clonedParameters, returns: clonedReturns });
2152
+ }
2153
+ else if (globalThis.Array.isArray(parameters)) {
2154
+ const clonedParameters = parameters.map((parameter) => TypeClone.Clone(parameter, {}));
2155
+ return this.Create({ ...options, [exports.Kind]: 'Constructor', type: 'object', instanceOf: 'Constructor', parameters: clonedParameters, returns: clonedReturns });
2156
+ }
2157
+ else {
2158
+ throw new Error('ExtendedTypeBuilder.Constructor: Invalid parameters');
2159
+ }
2160
+ }
2161
+ /** `[Extended]` Creates a Date type */
2162
+ Date(options = {}) {
2163
+ return this.Create({ ...options, [exports.Kind]: 'Date', type: 'object', instanceOf: 'Date' });
2164
+ }
2165
+ Function(parameters, returns, options = {}) {
2166
+ const clonedReturns = TypeClone.Clone(returns, {});
2167
+ if (TypeGuard.TTuple(parameters)) {
2168
+ const clonedParameters = parameters.items === undefined ? [] : parameters.items.map((parameter) => TypeClone.Clone(parameter, {}));
2169
+ return this.Create({ ...options, [exports.Kind]: 'Function', type: 'object', instanceOf: 'Function', parameters: clonedParameters, returns: clonedReturns });
2170
+ }
2171
+ else if (globalThis.Array.isArray(parameters)) {
2172
+ const clonedParameters = parameters.map((parameter) => TypeClone.Clone(parameter, {}));
2173
+ return this.Create({ ...options, [exports.Kind]: 'Function', type: 'object', instanceOf: 'Function', parameters: clonedParameters, returns: clonedReturns });
2174
+ }
2175
+ else {
2176
+ throw new Error('ExtendedTypeBuilder.Function: Invalid parameters');
2177
+ }
2178
+ }
2179
+ /** `[Extended]` Extracts the InstanceType from the given Constructor */
2180
+ InstanceType(schema, options = {}) {
2181
+ return TypeClone.Clone(schema.returns, options);
2182
+ }
2183
+ /** `[Extended]` Extracts the Parameters from the given Function type */
2184
+ Parameters(schema, options = {}) {
2185
+ return this.Tuple(schema.parameters, { ...options });
2186
+ }
2187
+ /** `[Extended]` Creates a Promise type */
2188
+ Promise(item, options = {}) {
2189
+ return this.Create({ ...options, [exports.Kind]: 'Promise', type: 'object', instanceOf: 'Promise', item: TypeClone.Clone(item, {}) });
2190
+ }
2191
+ /** `[Extended]` Creates a regular expression type */
2192
+ RegEx(regex, options = {}) {
2193
+ return this.Create({ ...options, [exports.Kind]: 'String', type: 'string', pattern: regex.source });
2194
+ }
2195
+ /** `[Extended]` Extracts the ReturnType from the given Function */
2196
+ ReturnType(schema, options = {}) {
2197
+ return TypeClone.Clone(schema.returns, options);
2198
+ }
2199
+ /** `[Extended]` Creates a Symbol type */
2200
+ Symbol(options) {
2201
+ return this.Create({ ...options, [exports.Kind]: 'Symbol', type: 'null', typeOf: 'Symbol' });
2202
+ }
2203
+ /** `[Extended]` Creates a Undefined type */
2204
+ Undefined(options = {}) {
2205
+ return this.Create({ ...options, [exports.Kind]: 'Undefined', type: 'null', typeOf: 'Undefined' });
2206
+ }
2207
+ /** `[Extended]` Creates a Uint8Array type */
2208
+ Uint8Array(options = {}) {
2209
+ return this.Create({ ...options, [exports.Kind]: 'Uint8Array', type: 'object', instanceOf: 'Uint8Array' });
2210
+ }
2211
+ /** `[Extended]` Creates a Void type */
2212
+ Void(options = {}) {
2213
+ return this.Create({ ...options, [exports.Kind]: 'Void', type: 'null', typeOf: 'Void' });
2214
+ }
2215
+ }
2216
+ exports.ExtendedTypeBuilder = ExtendedTypeBuilder;
2217
+ /** JSON Schema TypeBuilder with Static Resolution for TypeScript */
2218
+ exports.StandardType = new StandardTypeBuilder();
2219
+ /** JSON Schema TypeBuilder with Static Resolution for TypeScript */
2220
+ exports.Type = new ExtendedTypeBuilder();