@ykdz/template 0.0.38 → 0.0.40

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 (220) hide show
  1. package/dist/application.d.ts +1 -52
  2. package/dist/application.js +0 -81
  3. package/dist/cli.js +14 -28
  4. package/dist/input-schemas.d.ts +30 -0
  5. package/dist/input-schemas.js +75 -0
  6. package/dist/main.d.ts +3 -14
  7. package/dist/main.js +496 -378
  8. package/dist/result-schemas.d.ts +222 -0
  9. package/dist/result-schemas.js +74 -0
  10. package/dist/standard-schema.d.ts +3 -0
  11. package/dist/standard-schema.js +29 -0
  12. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  13. package/node_modules/@standard-schema/spec/README.md +198 -0
  14. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  15. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  16. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  17. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  18. package/node_modules/@standard-schema/spec/package.json +52 -0
  19. package/node_modules/@types/node/LICENSE +21 -0
  20. package/node_modules/@types/node/README.md +15 -0
  21. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  22. package/node_modules/@types/node/assert.d.ts +1115 -0
  23. package/node_modules/@types/node/async_hooks.d.ts +619 -0
  24. package/node_modules/@types/node/buffer.buffer.d.ts +477 -0
  25. package/node_modules/@types/node/buffer.d.ts +1941 -0
  26. package/node_modules/@types/node/child_process.d.ts +1480 -0
  27. package/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  29. package/node_modules/@types/node/console.d.ts +453 -0
  30. package/node_modules/@types/node/constants.d.ts +21 -0
  31. package/node_modules/@types/node/crypto.d.ts +5484 -0
  32. package/node_modules/@types/node/dgram.d.ts +715 -0
  33. package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
  34. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  35. package/node_modules/@types/node/dns.d.ts +923 -0
  36. package/node_modules/@types/node/domain.d.ts +166 -0
  37. package/node_modules/@types/node/events.d.ts +967 -0
  38. package/node_modules/@types/node/fs/promises.d.ts +1354 -0
  39. package/node_modules/@types/node/fs.d.ts +4777 -0
  40. package/node_modules/@types/node/globals.d.ts +170 -0
  41. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  42. package/node_modules/@types/node/http.d.ts +2246 -0
  43. package/node_modules/@types/node/http2.d.ts +2882 -0
  44. package/node_modules/@types/node/https.d.ts +585 -0
  45. package/node_modules/@types/node/index.d.ts +101 -0
  46. package/node_modules/@types/node/inspector.d.ts +323 -0
  47. package/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  48. package/node_modules/@types/node/module.d.ts +844 -0
  49. package/node_modules/@types/node/net.d.ts +1197 -0
  50. package/node_modules/@types/node/os.d.ts +507 -0
  51. package/node_modules/@types/node/package.json +140 -0
  52. package/node_modules/@types/node/path.d.ts +200 -0
  53. package/node_modules/@types/node/perf_hooks.d.ts +1054 -0
  54. package/node_modules/@types/node/process.d.ts +2101 -0
  55. package/node_modules/@types/node/punycode.d.ts +117 -0
  56. package/node_modules/@types/node/querystring.d.ts +152 -0
  57. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  58. package/node_modules/@types/node/readline.d.ts +600 -0
  59. package/node_modules/@types/node/repl.d.ts +438 -0
  60. package/node_modules/@types/node/sea.d.ts +162 -0
  61. package/node_modules/@types/node/sqlite.d.ts +1182 -0
  62. package/node_modules/@types/node/stream/consumers.d.ts +45 -0
  63. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  64. package/node_modules/@types/node/stream/web.d.ts +596 -0
  65. package/node_modules/@types/node/stream.d.ts +1707 -0
  66. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  67. package/node_modules/@types/node/test.d.ts +2656 -0
  68. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  69. package/node_modules/@types/node/timers.d.ts +285 -0
  70. package/node_modules/@types/node/tls.d.ts +1314 -0
  71. package/node_modules/@types/node/trace_events.d.ts +197 -0
  72. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +473 -0
  73. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  74. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  75. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  76. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  77. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  78. package/node_modules/@types/node/tty.d.ts +209 -0
  79. package/node_modules/@types/node/url.d.ts +1103 -0
  80. package/node_modules/@types/node/util.d.ts +2376 -0
  81. package/node_modules/@types/node/v8.d.ts +1010 -0
  82. package/node_modules/@types/node/vm.d.ts +1160 -0
  83. package/node_modules/@types/node/wasi.d.ts +202 -0
  84. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  85. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  86. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  87. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  88. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  89. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  90. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  91. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  92. package/node_modules/@types/node/worker_threads.d.ts +894 -0
  93. package/node_modules/@types/node/zlib.d.ts +768 -0
  94. package/node_modules/@valibot/to-json-schema/LICENSE.md +9 -0
  95. package/node_modules/@valibot/to-json-schema/README.md +475 -0
  96. package/node_modules/@valibot/to-json-schema/dist/index.cjs +800 -0
  97. package/node_modules/@valibot/to-json-schema/dist/index.d.cts +991 -0
  98. package/node_modules/@valibot/to-json-schema/dist/index.d.mts +991 -0
  99. package/node_modules/@valibot/to-json-schema/dist/index.min.cjs +1 -0
  100. package/node_modules/@valibot/to-json-schema/dist/index.min.mjs +1 -0
  101. package/node_modules/@valibot/to-json-schema/dist/index.mjs +795 -0
  102. package/node_modules/@valibot/to-json-schema/package.json +75 -0
  103. package/node_modules/@ykdz/cli-contract/LICENSE +21 -0
  104. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.d.ts +17 -0
  105. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.js +55 -0
  106. package/node_modules/@ykdz/cli-contract/dist/cli-contract.d.ts +1164 -0
  107. package/node_modules/@ykdz/cli-contract/dist/cli-contract.js +1408 -0
  108. package/node_modules/@ykdz/cli-contract/dist/cli-execution.d.ts +54 -0
  109. package/node_modules/@ykdz/cli-contract/dist/cli-execution.js +708 -0
  110. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.d.ts +174 -0
  111. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.js +524 -0
  112. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.d.ts +10 -0
  113. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.js +14 -0
  114. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.d.ts +260 -0
  115. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.js +130 -0
  116. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.d.ts +63 -0
  117. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.js +17 -0
  118. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.d.ts +6 -0
  119. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.js +532 -0
  120. package/node_modules/@ykdz/cli-contract/dist/contract-schema.d.ts +14 -0
  121. package/node_modules/@ykdz/cli-contract/dist/contract-schema.js +1 -0
  122. package/node_modules/@ykdz/cli-contract/dist/description.d.ts +2 -0
  123. package/node_modules/@ykdz/cli-contract/dist/description.js +13 -0
  124. package/node_modules/@ykdz/cli-contract/dist/index.d.ts +8 -0
  125. package/node_modules/@ykdz/cli-contract/dist/index.js +7 -0
  126. package/node_modules/@ykdz/cli-contract/dist/json-value.d.ts +4 -0
  127. package/node_modules/@ykdz/cli-contract/dist/json-value.js +64 -0
  128. package/node_modules/@ykdz/cli-contract/dist/node.d.ts +21 -0
  129. package/node_modules/@ykdz/cli-contract/dist/node.js +109 -0
  130. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.d.ts +162 -0
  131. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.js +113 -0
  132. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.d.ts +53 -0
  133. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.js +189 -0
  134. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.d.ts +16 -0
  135. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.js +45 -0
  136. package/node_modules/@ykdz/cli-contract/package.json +69 -0
  137. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +20 -0
  138. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +5 -0
  139. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.d.ts +19 -0
  140. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.js +1 -1
  141. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.d.ts +2 -1
  142. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.js +2 -1
  143. package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +9 -5
  144. package/node_modules/@ykdz/template-builtin-presets/package.json +2 -1
  145. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +3 -3
  146. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/artifact.ts +128 -59
  147. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/handoff.ts +80 -8
  148. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/readiness.ts +7 -3
  149. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli.ts +9 -19
  150. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/main.ts +144 -60
  151. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/standard-schema.ts +37 -0
  152. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/lookup.journey.ts +71 -0
  153. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +118 -59
  154. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +2 -1
  155. package/node_modules/@ykdz/template-core/dist/project-blueprint.d.ts +15 -0
  156. package/node_modules/@ykdz/template-core/dist/project-blueprint.js +1 -1
  157. package/node_modules/undici-types/LICENSE +21 -0
  158. package/node_modules/undici-types/README.md +6 -0
  159. package/node_modules/undici-types/agent.d.ts +32 -0
  160. package/node_modules/undici-types/api.d.ts +43 -0
  161. package/node_modules/undici-types/balanced-pool.d.ts +30 -0
  162. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  163. package/node_modules/undici-types/cache.d.ts +36 -0
  164. package/node_modules/undici-types/client-stats.d.ts +15 -0
  165. package/node_modules/undici-types/client.d.ts +123 -0
  166. package/node_modules/undici-types/connector.d.ts +36 -0
  167. package/node_modules/undici-types/content-type.d.ts +21 -0
  168. package/node_modules/undici-types/cookies.d.ts +30 -0
  169. package/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  170. package/node_modules/undici-types/dispatcher.d.ts +279 -0
  171. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  172. package/node_modules/undici-types/errors.d.ts +177 -0
  173. package/node_modules/undici-types/eventsource.d.ts +66 -0
  174. package/node_modules/undici-types/fetch.d.ts +211 -0
  175. package/node_modules/undici-types/formdata.d.ts +108 -0
  176. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  177. package/node_modules/undici-types/global-origin.d.ts +7 -0
  178. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  179. package/node_modules/undici-types/handlers.d.ts +15 -0
  180. package/node_modules/undici-types/header.d.ts +160 -0
  181. package/node_modules/undici-types/index.d.ts +91 -0
  182. package/node_modules/undici-types/interceptors.d.ts +80 -0
  183. package/node_modules/undici-types/mock-agent.d.ts +68 -0
  184. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  185. package/node_modules/undici-types/mock-client.d.ts +27 -0
  186. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  187. package/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  188. package/node_modules/undici-types/mock-pool.d.ts +27 -0
  189. package/node_modules/undici-types/package.json +55 -0
  190. package/node_modules/undici-types/patch.d.ts +29 -0
  191. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  192. package/node_modules/undici-types/pool.d.ts +41 -0
  193. package/node_modules/undici-types/proxy-agent.d.ts +29 -0
  194. package/node_modules/undici-types/readable.d.ts +68 -0
  195. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  196. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  197. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  198. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  199. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  200. package/node_modules/undici-types/util.d.ts +18 -0
  201. package/node_modules/undici-types/utility.d.ts +7 -0
  202. package/node_modules/undici-types/webidl.d.ts +347 -0
  203. package/node_modules/undici-types/websocket.d.ts +188 -0
  204. package/package.json +5 -3
  205. package/dist/command-result.d.ts +0 -9
  206. package/dist/command-result.js +0 -231
  207. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/greet.journey.ts +0 -46
  208. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/greet.test.ts +0 -15
  209. package/node_modules/commander/LICENSE +0 -22
  210. package/node_modules/commander/Readme.md +0 -1172
  211. package/node_modules/commander/index.js +0 -21
  212. package/node_modules/commander/lib/argument.js +0 -147
  213. package/node_modules/commander/lib/command.js +0 -2790
  214. package/node_modules/commander/lib/error.js +0 -36
  215. package/node_modules/commander/lib/help.js +0 -731
  216. package/node_modules/commander/lib/option.js +0 -377
  217. package/node_modules/commander/lib/suggestSimilar.js +0 -99
  218. package/node_modules/commander/package-support.json +0 -19
  219. package/node_modules/commander/package.json +0 -64
  220. package/node_modules/commander/typings/index.d.ts +0 -1113
@@ -0,0 +1 @@
1
+ function e(e,t){return e?(e.push(t),e):[t]}const t=/[.*+?^${}()|[\]\\]/g;function n(e){return e.replace(t,`\\$&`)}function r(e,t){switch(t?.errorMode){case`ignore`:break;case`warn`:console.warn(e);break;default:throw Error(e)}}function i(e){return typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)||typeof e==`string`}function a(e){return e.every(i)}var o=class extends Map{constructor(){super(),this.count=0,this.usedIds=new Set}set(e,t){return this.usedIds.add(t),super.set(e,t)}createId(e){for(;this.usedIds.has(`${this.count}`)||`${this.count}`in e;)this.count++;return`${this.count++}`}};function s(e,t){return typeof e!=`number`||!Number.isFinite(e)||t>e?t:e}function c(e,t){return typeof e!=`number`||!Number.isFinite(e)||t<e?t:e}function l(e,t){return e===void 0?t:{anyOf:[e,t]}}function u(e,t){let n=e.enum??t;if(e.enum){let e=new Set(t);n=n.filter(t=>e.has(t))}n.length?e.enum=[...new Set(n)]:(delete e.enum,e.not=l(e.not,{}))}function d(t,o,d){if(d?.ignoreActions?.includes(o.type))return t;let f;switch(o.type){case`base64`:t.contentEncoding=`base64`;break;case`bic`:case`cuid2`:case`decimal`:case`digits`:case`domain`:case`emoji`:case`hash`:case`hexadecimal`:case`hex_color`:case`isrc`:case`iso_time_second`:case`iso_week`:case`ksuid`:case`mac`:case`mac48`:case`mac64`:case`nanoid`:case`octal`:case`slug`:case`ulid`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`description`:t.description=o.description;break;case`email`:case`rfc_email`:t.format=`email`;break;case`ends_with`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=`${n(o.requirement)}$`;break;case`empty`:t.type===`array`?t.maxItems=0:(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.maxLength=0);break;case`entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "entries" action must be a non-negative integer.`);break}t.minProperties=s(t.minProperties,o.requirement),t.maxProperties=c(t.maxProperties,o.requirement);break;case`examples`:Array.isArray(t.examples)?t.examples=[...t.examples,...o.examples]:t.examples=o.examples;break;case`gt_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "gt_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "gt_value" action is not JSON compatible.`);break}if(d?.target===`openapi-3.0`){f=e(f,`The "gt_value" action is not supported for OpenAPI 3.0.`);break}t.exclusiveMinimum=s(t.exclusiveMinimum,o.requirement);break;case`includes`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=n(o.requirement);break;case`integer`:t.type=`integer`;break;case`ipv4`:t.format=`ipv4`;break;case`ipv6`:t.format=`ipv6`;break;case`iso_date`:t.format=`date`;break;case`iso_date_time`:case`iso_timestamp`:t.format=`date-time`;break;case`iso_time`:t.format=`time`;break;case`jws_compact`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "length" action must be a non-negative integer.`);break}t.type===`array`?(t.minItems=s(t.minItems,o.requirement),t.maxItems=c(t.maxItems,o.requirement)):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,o.requirement),t.maxLength=c(t.maxLength,o.requirement));break;case`lt_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "lt_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "lt_value" action is not JSON compatible.`);break}if(d?.target===`openapi-3.0`){f=e(f,`The "lt_value" action is not supported for OpenAPI 3.0.`);break}t.exclusiveMaximum=c(t.exclusiveMaximum,o.requirement);break;case`max_entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "max_entries" action must be a non-negative integer.`);break}t.maxProperties=c(t.maxProperties,o.requirement);break;case`max_length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "max_length" action must be a non-negative integer.`);break}t.type===`array`?t.maxItems=c(t.maxItems,o.requirement):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.maxLength=c(t.maxLength,o.requirement));break;case`max_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "max_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "max_value" action is not JSON compatible.`);break}t.maximum=c(t.maximum,o.requirement);break;case`metadata`:typeof o.metadata.title==`string`&&(t.title=o.metadata.title),typeof o.metadata.description==`string`&&(t.description=o.metadata.description),Array.isArray(o.metadata.examples)&&(Array.isArray(t.examples)?t.examples=[...t.examples,...o.metadata.examples]:t.examples=o.metadata.examples);for(let e of Object.keys(o.metadata))e!==`title`&&e!==`description`&&e!==`examples`&&e!==`__proto__`&&(t[e]=o.metadata[e]);break;case`min_entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "min_entries" action must be a non-negative integer.`);break}t.minProperties=s(t.minProperties,o.requirement);break;case`min_length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "min_length" action must be a non-negative integer.`);break}t.type===`array`?t.minItems=s(t.minItems,o.requirement):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,o.requirement));break;case`min_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "min_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "min_value" action is not JSON compatible.`);break}t.minimum=s(t.minimum,o.requirement);break;case`multiple_of`:t.multipleOf=o.requirement;break;case`non_empty`:t.type===`array`?t.minItems=s(t.minItems,1):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,1));break;case`not_value`:if(!i(o.requirement)){f=e(f,`The requirement of the "not_value" action is not JSON compatible.`);break}t.not=l(t.not,d?.target===`openapi-3.0`?{enum:[o.requirement]}:{const:o.requirement});break;case`not_values`:if(!a(o.requirement)){f=e(f,`A requirement of the "not_values" action is not JSON compatible.`);break}o.requirement.length&&(t.not=l(t.not,{enum:[...new Set(o.requirement)]}));break;case`regex`:o.requirement.flags&&(f=e(f,`RegExp flags are not supported by JSON Schema.`)),t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`safe_integer`:t.type=`integer`,t.minimum=s(t.minimum,-(2**53-1)),t.maximum=c(t.maximum,2**53-1);break;case`starts_with`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=`^${n(o.requirement)}`;break;case`title`:t.title=o.title;break;case`url`:t.format=`uri`;break;case`uuid`:t.format=`uuid`;break;case`value`:if(!i(o.requirement)){f=e(f,`The requirement of the "value" action is not JSON compatible.`);break}d?.target===`openapi-3.0`?u(t,[o.requirement]):`const`in t&&t.const!==o.requirement?f=e(f,`The "${o.type}" action is not supported in combination with a different "const" restriction.`):t.const=o.requirement;break;case`values`:if(!a(o.requirement)){f=e(f,`A requirement of the "values" action is not JSON compatible.`);break}u(t,o.requirement);break;default:f=e(f,`The "${o.type}" action cannot be converted to JSON Schema.`)}if(d?.overrideAction){let e=d.overrideAction({valibotAction:o,jsonSchema:t,errors:f});if(e)return{...e}}if(f)for(let e of f)r(e,d);return t}function f(e){return e.flatMap(e=>`pipe`in e?f(e.pipe):e)}function p(e){return`#/$defs/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function m(t,n,a,o,s=!1){if(!s){let e=o.referenceMap.get(n);if(e){if(t.$ref=p(e),a?.overrideRef){let r=a.overrideRef({...o,referenceId:e,valibotSchema:n,jsonSchema:t});r&&(t.$ref=r)}return t}}if(`pipe`in n){let e=f(n.pipe),i=0,s=e.length-1;if(a?.typeMode===`input`){let t=e.slice(1).findIndex(e=>e.kind===`schema`||e.kind===`transformation`&&(e.type===`find_item`||e.type===`parse_json`||e.type===`raw_transform`||e.type===`reduce_items`||e.type===`stringify_json`||e.type===`to_bigint`||e.type===`to_boolean`||e.type===`to_date`||e.type===`to_number`||e.type===`to_string`||e.type===`transform`));t!==-1&&(s=t)}else if(a?.typeMode===`output`){let t=e.findLastIndex(e=>e.kind===`schema`);t!==-1&&(i=t)}for(let n=i;n<=s;n++){let s=e[n];s.kind===`schema`?(n>i&&r(`Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.`,a),t=m(t,s,a,o,!0)):t=d(t,s,a)}return t}let c;switch(n.type){case`boolean`:t.type=`boolean`;break;case`null`:a?.target===`openapi-3.0`?t.enum=[null]:t.type=`null`;break;case`number`:t.type=`number`;break;case`string`:t.type=`string`;break;case`array`:t.type=`array`,t.items=m({},n.item,a,o);break;case`tuple`:case`tuple_with_rest`:case`loose_tuple`:case`strict_tuple`:if(t.type=`array`,a?.target===`openapi-3.0`){t.items={anyOf:[]},t.minItems=n.items.length;for(let e of n.items)t.items.anyOf.push(m({},e,a,o));n.type===`tuple_with_rest`?t.items.anyOf.push(m({},n.rest,a,o)):(n.type===`strict_tuple`||n.type===`tuple`)&&(t.maxItems=n.items.length)}else if(a?.target===`draft-2020-12`){t.prefixItems=[],t.minItems=n.items.length;for(let e of n.items)t.prefixItems.push(m({},e,a,o));n.type===`tuple_with_rest`?t.items=m({},n.rest,a,o):n.type===`strict_tuple`&&(t.items=!1)}else{t.items=[],t.minItems=n.items.length;for(let e of n.items)t.items.push(m({},e,a,o));n.type===`tuple_with_rest`?t.additionalItems=m({},n.rest,a,o):n.type===`strict_tuple`&&(t.additionalItems=!1)}break;case`object`:case`object_with_rest`:case`loose_object`:case`strict_object`:for(let e in t.type=`object`,t.properties={},t.required=[],n.entries){let r=n.entries[e];t.properties[e]=m({},r,a,o),r.type!==`exact_optional`&&r.type!==`nullish`&&r.type!==`optional`&&t.required.push(e)}n.type===`object_with_rest`?t.additionalProperties=m({},n.rest,a,o):n.type===`strict_object`&&(t.additionalProperties=!1);break;case`record`:a?.target===`openapi-3.0`&&`pipe`in n.key&&(c=e(c,`The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.`)),n.key.type!==`string`&&(c=e(c,`The "record" schema with the "${n.key.type}" schema for the key cannot be converted to JSON Schema.`)),t.type=`object`,a?.target!==`openapi-3.0`&&(t.propertyNames=m({},n.key,a,o)),t.additionalProperties=m({},n.value,a,o);break;case`any`:case`unknown`:break;case`never`:t.not={};break;case`nullable`:case`nullish`:if(a?.target===`openapi-3.0`){let e=m({},n.wrapped,a,o);Object.assign(t,e),t.nullable=!0}else t.anyOf=[m({},n.wrapped,a,o),{type:`null`}];n.default!==void 0&&(t.default=typeof n.default==`function`?n.default():n.default);break;case`exact_optional`:case`optional`:case`undefinedable`:t=m(t,n.wrapped,a,o),n.default!==void 0&&(t.default=typeof n.default==`function`?n.default():n.default);break;case`literal`:if(!i(n.literal)){c=e(c,`The value of the "literal" schema is not JSON compatible.`);break}a?.target===`openapi-3.0`?t.enum=[n.literal]:t.const=n.literal;break;case`enum`:case`picklist`:{let r=n.options;if(!r.every(e=>typeof e==`string`||typeof e==`number`&&Number.isFinite(e))){c=e(c,`An option of the "${n.type}" schema is not JSON compatible.`);break}t.enum=r,r.every(e=>typeof e==`string`)?t.type=`string`:r.every(e=>typeof e==`number`)?t.type=`number`:a?.target!==`openapi-3.0`&&(t.type=[`string`,`number`]);break}case`union`:t.anyOf=n.options.map(e=>m({},e,a,o));break;case`variant`:t.oneOf=n.options.map(e=>m({},e,a,o));break;case`intersect`:t.allOf=n.options.map(e=>m({},e,a,o));break;case`lazy`:{let e=o.getterMap.get(n.getter);e||(e=n.getter(void 0),o.getterMap.set(n.getter,e));let r=o.referenceMap.get(e);if(r||(r=o.referenceMap.createId(o.definitions),o.referenceMap.set(e,r),o.definitions[r]=m({},e,a,o,!0)),t.$ref=p(r),a?.overrideRef){let n=a.overrideRef({...o,referenceId:r,valibotSchema:e,jsonSchema:t});n&&(t.$ref=n)}break}default:c=e(c,`The "${n.type}" schema cannot be converted to JSON Schema.`)}if(a?.overrideSchema){let e=a.overrideSchema({...o,referenceId:o.referenceMap.get(n),valibotSchema:n,jsonSchema:t,errors:c});if(e)return{...e}}if(c)for(let e of c)r(e,a);return t}let h;function g(e){h={...h??{},...e}}function _(){return h}function v(e,t){let n={definitions:{},referenceMap:new o,getterMap:new Map},r=t?.definitions??_();if(r){for(let e in r)n.referenceMap.set(r[e],e);for(let e in r)n.definitions[e]=m({},r[e],t,n,!0)}let i=m({},e,t,n),a=t?.target??`draft-07`;return a===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:a===`draft-07`&&(i.$schema=`http://json-schema.org/draft-07/schema#`),n.referenceMap.size&&(i.$defs=n.definitions),i}function y(e,t){let n={definitions:{},referenceMap:new o,getterMap:new Map};for(let t in e)n.referenceMap.set(e[t],t);for(let r in e)n.definitions[r]=m({},e[r],t,n,!0);return n.definitions}const b=[`draft-07`,`draft-2020-12`,`openapi-3.0`];function x(e){return{"~standard":{...e[`~standard`],jsonSchema:{input(t){if(b.includes(t.target))return v(e,{typeMode:`input`,target:t.target,...t.libraryOptions});throw Error(`Unsupported target: ${t.target}`)},output(t){if(b.includes(t.target))return v(e,{typeMode:`output`,target:t.target,...t.libraryOptions});throw Error(`Unsupported target: ${t.target}`)}}}}}exports.addGlobalDefs=g,exports.getGlobalDefs=_,exports.toJsonSchema=v,exports.toJsonSchemaDefs=y,exports.toStandardJsonSchema=x;
@@ -0,0 +1 @@
1
+ function e(e,t){return e?(e.push(t),e):[t]}const t=/[.*+?^${}()|[\]\\]/g;function n(e){return e.replace(t,`\\$&`)}function r(e,t){switch(t?.errorMode){case`ignore`:break;case`warn`:console.warn(e);break;default:throw Error(e)}}function i(e){return typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e)||typeof e==`string`}function a(e){return e.every(i)}var o=class extends Map{constructor(){super(),this.count=0,this.usedIds=new Set}set(e,t){return this.usedIds.add(t),super.set(e,t)}createId(e){for(;this.usedIds.has(`${this.count}`)||`${this.count}`in e;)this.count++;return`${this.count++}`}};function s(e,t){return typeof e!=`number`||!Number.isFinite(e)||t>e?t:e}function c(e,t){return typeof e!=`number`||!Number.isFinite(e)||t<e?t:e}function l(e,t){return e===void 0?t:{anyOf:[e,t]}}function u(e,t){let n=e.enum??t;if(e.enum){let e=new Set(t);n=n.filter(t=>e.has(t))}n.length?e.enum=[...new Set(n)]:(delete e.enum,e.not=l(e.not,{}))}function d(t,o,d){if(d?.ignoreActions?.includes(o.type))return t;let f;switch(o.type){case`base64`:t.contentEncoding=`base64`;break;case`bic`:case`cuid2`:case`decimal`:case`digits`:case`domain`:case`emoji`:case`hash`:case`hexadecimal`:case`hex_color`:case`isrc`:case`iso_time_second`:case`iso_week`:case`ksuid`:case`mac`:case`mac48`:case`mac64`:case`nanoid`:case`octal`:case`slug`:case`ulid`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`description`:t.description=o.description;break;case`email`:case`rfc_email`:t.format=`email`;break;case`ends_with`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=`${n(o.requirement)}$`;break;case`empty`:t.type===`array`?t.maxItems=0:(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.maxLength=0);break;case`entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "entries" action must be a non-negative integer.`);break}t.minProperties=s(t.minProperties,o.requirement),t.maxProperties=c(t.maxProperties,o.requirement);break;case`examples`:Array.isArray(t.examples)?t.examples=[...t.examples,...o.examples]:t.examples=o.examples;break;case`gt_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "gt_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "gt_value" action is not JSON compatible.`);break}if(d?.target===`openapi-3.0`){f=e(f,`The "gt_value" action is not supported for OpenAPI 3.0.`);break}t.exclusiveMinimum=s(t.exclusiveMinimum,o.requirement);break;case`includes`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=n(o.requirement);break;case`integer`:t.type=`integer`;break;case`ipv4`:t.format=`ipv4`;break;case`ipv6`:t.format=`ipv6`;break;case`iso_date`:t.format=`date`;break;case`iso_date_time`:case`iso_timestamp`:t.format=`date-time`;break;case`iso_time`:t.format=`time`;break;case`jws_compact`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "length" action must be a non-negative integer.`);break}t.type===`array`?(t.minItems=s(t.minItems,o.requirement),t.maxItems=c(t.maxItems,o.requirement)):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,o.requirement),t.maxLength=c(t.maxLength,o.requirement));break;case`lt_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "lt_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "lt_value" action is not JSON compatible.`);break}if(d?.target===`openapi-3.0`){f=e(f,`The "lt_value" action is not supported for OpenAPI 3.0.`);break}t.exclusiveMaximum=c(t.exclusiveMaximum,o.requirement);break;case`max_entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "max_entries" action must be a non-negative integer.`);break}t.maxProperties=c(t.maxProperties,o.requirement);break;case`max_length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "max_length" action must be a non-negative integer.`);break}t.type===`array`?t.maxItems=c(t.maxItems,o.requirement):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.maxLength=c(t.maxLength,o.requirement));break;case`max_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "max_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "max_value" action is not JSON compatible.`);break}t.maximum=c(t.maximum,o.requirement);break;case`metadata`:typeof o.metadata.title==`string`&&(t.title=o.metadata.title),typeof o.metadata.description==`string`&&(t.description=o.metadata.description),Array.isArray(o.metadata.examples)&&(Array.isArray(t.examples)?t.examples=[...t.examples,...o.metadata.examples]:t.examples=o.metadata.examples);for(let e of Object.keys(o.metadata))e!==`title`&&e!==`description`&&e!==`examples`&&e!==`__proto__`&&(t[e]=o.metadata[e]);break;case`min_entries`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "min_entries" action must be a non-negative integer.`);break}t.minProperties=s(t.minProperties,o.requirement);break;case`min_length`:if(!Number.isInteger(o.requirement)||o.requirement<0){f=e(f,`The requirement of the "min_length" action must be a non-negative integer.`);break}t.type===`array`?t.minItems=s(t.minItems,o.requirement):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,o.requirement));break;case`min_value`:if(t.type!==`number`&&t.type!==`integer`){f=e(f,`The "min_value" action is not supported on type "${t.type}".`);break}if(!Number.isFinite(o.requirement)){f=e(f,`The requirement of the "min_value" action is not JSON compatible.`);break}t.minimum=s(t.minimum,o.requirement);break;case`multiple_of`:t.multipleOf=o.requirement;break;case`non_empty`:t.type===`array`?t.minItems=s(t.minItems,1):(t.type!==`string`&&(f=e(f,`The "${o.type}" action is not supported on type "${t.type}".`)),t.minLength=s(t.minLength,1));break;case`not_value`:if(!i(o.requirement)){f=e(f,`The requirement of the "not_value" action is not JSON compatible.`);break}t.not=l(t.not,d?.target===`openapi-3.0`?{enum:[o.requirement]}:{const:o.requirement});break;case`not_values`:if(!a(o.requirement)){f=e(f,`A requirement of the "not_values" action is not JSON compatible.`);break}o.requirement.length&&(t.not=l(t.not,{enum:[...new Set(o.requirement)]}));break;case`regex`:o.requirement.flags&&(f=e(f,`RegExp flags are not supported by JSON Schema.`)),t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=o.requirement.source;break;case`safe_integer`:t.type=`integer`,t.minimum=s(t.minimum,-(2**53-1)),t.maximum=c(t.maximum,2**53-1);break;case`starts_with`:t.pattern?f=e(f,`The "${o.type}" action is not supported in combination with another regex action.`):t.pattern=`^${n(o.requirement)}`;break;case`title`:t.title=o.title;break;case`url`:t.format=`uri`;break;case`uuid`:t.format=`uuid`;break;case`value`:if(!i(o.requirement)){f=e(f,`The requirement of the "value" action is not JSON compatible.`);break}d?.target===`openapi-3.0`?u(t,[o.requirement]):`const`in t&&t.const!==o.requirement?f=e(f,`The "${o.type}" action is not supported in combination with a different "const" restriction.`):t.const=o.requirement;break;case`values`:if(!a(o.requirement)){f=e(f,`A requirement of the "values" action is not JSON compatible.`);break}u(t,o.requirement);break;default:f=e(f,`The "${o.type}" action cannot be converted to JSON Schema.`)}if(d?.overrideAction){let e=d.overrideAction({valibotAction:o,jsonSchema:t,errors:f});if(e)return{...e}}if(f)for(let e of f)r(e,d);return t}function f(e){return e.flatMap(e=>`pipe`in e?f(e.pipe):e)}function p(e){return`#/$defs/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`}function m(t,n,a,o,s=!1){if(!s){let e=o.referenceMap.get(n);if(e){if(t.$ref=p(e),a?.overrideRef){let r=a.overrideRef({...o,referenceId:e,valibotSchema:n,jsonSchema:t});r&&(t.$ref=r)}return t}}if(`pipe`in n){let e=f(n.pipe),i=0,s=e.length-1;if(a?.typeMode===`input`){let t=e.slice(1).findIndex(e=>e.kind===`schema`||e.kind===`transformation`&&(e.type===`find_item`||e.type===`parse_json`||e.type===`raw_transform`||e.type===`reduce_items`||e.type===`stringify_json`||e.type===`to_bigint`||e.type===`to_boolean`||e.type===`to_date`||e.type===`to_number`||e.type===`to_string`||e.type===`transform`));t!==-1&&(s=t)}else if(a?.typeMode===`output`){let t=e.findLastIndex(e=>e.kind===`schema`);t!==-1&&(i=t)}for(let n=i;n<=s;n++){let s=e[n];s.kind===`schema`?(n>i&&r(`Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.`,a),t=m(t,s,a,o,!0)):t=d(t,s,a)}return t}let c;switch(n.type){case`boolean`:t.type=`boolean`;break;case`null`:a?.target===`openapi-3.0`?t.enum=[null]:t.type=`null`;break;case`number`:t.type=`number`;break;case`string`:t.type=`string`;break;case`array`:t.type=`array`,t.items=m({},n.item,a,o);break;case`tuple`:case`tuple_with_rest`:case`loose_tuple`:case`strict_tuple`:if(t.type=`array`,a?.target===`openapi-3.0`){t.items={anyOf:[]},t.minItems=n.items.length;for(let e of n.items)t.items.anyOf.push(m({},e,a,o));n.type===`tuple_with_rest`?t.items.anyOf.push(m({},n.rest,a,o)):(n.type===`strict_tuple`||n.type===`tuple`)&&(t.maxItems=n.items.length)}else if(a?.target===`draft-2020-12`){t.prefixItems=[],t.minItems=n.items.length;for(let e of n.items)t.prefixItems.push(m({},e,a,o));n.type===`tuple_with_rest`?t.items=m({},n.rest,a,o):n.type===`strict_tuple`&&(t.items=!1)}else{t.items=[],t.minItems=n.items.length;for(let e of n.items)t.items.push(m({},e,a,o));n.type===`tuple_with_rest`?t.additionalItems=m({},n.rest,a,o):n.type===`strict_tuple`&&(t.additionalItems=!1)}break;case`object`:case`object_with_rest`:case`loose_object`:case`strict_object`:for(let e in t.type=`object`,t.properties={},t.required=[],n.entries){let r=n.entries[e];t.properties[e]=m({},r,a,o),r.type!==`exact_optional`&&r.type!==`nullish`&&r.type!==`optional`&&t.required.push(e)}n.type===`object_with_rest`?t.additionalProperties=m({},n.rest,a,o):n.type===`strict_object`&&(t.additionalProperties=!1);break;case`record`:a?.target===`openapi-3.0`&&`pipe`in n.key&&(c=e(c,`The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.`)),n.key.type!==`string`&&(c=e(c,`The "record" schema with the "${n.key.type}" schema for the key cannot be converted to JSON Schema.`)),t.type=`object`,a?.target!==`openapi-3.0`&&(t.propertyNames=m({},n.key,a,o)),t.additionalProperties=m({},n.value,a,o);break;case`any`:case`unknown`:break;case`never`:t.not={};break;case`nullable`:case`nullish`:if(a?.target===`openapi-3.0`){let e=m({},n.wrapped,a,o);Object.assign(t,e),t.nullable=!0}else t.anyOf=[m({},n.wrapped,a,o),{type:`null`}];n.default!==void 0&&(t.default=typeof n.default==`function`?n.default():n.default);break;case`exact_optional`:case`optional`:case`undefinedable`:t=m(t,n.wrapped,a,o),n.default!==void 0&&(t.default=typeof n.default==`function`?n.default():n.default);break;case`literal`:if(!i(n.literal)){c=e(c,`The value of the "literal" schema is not JSON compatible.`);break}a?.target===`openapi-3.0`?t.enum=[n.literal]:t.const=n.literal;break;case`enum`:case`picklist`:{let r=n.options;if(!r.every(e=>typeof e==`string`||typeof e==`number`&&Number.isFinite(e))){c=e(c,`An option of the "${n.type}" schema is not JSON compatible.`);break}t.enum=r,r.every(e=>typeof e==`string`)?t.type=`string`:r.every(e=>typeof e==`number`)?t.type=`number`:a?.target!==`openapi-3.0`&&(t.type=[`string`,`number`]);break}case`union`:t.anyOf=n.options.map(e=>m({},e,a,o));break;case`variant`:t.oneOf=n.options.map(e=>m({},e,a,o));break;case`intersect`:t.allOf=n.options.map(e=>m({},e,a,o));break;case`lazy`:{let e=o.getterMap.get(n.getter);e||(e=n.getter(void 0),o.getterMap.set(n.getter,e));let r=o.referenceMap.get(e);if(r||(r=o.referenceMap.createId(o.definitions),o.referenceMap.set(e,r),o.definitions[r]=m({},e,a,o,!0)),t.$ref=p(r),a?.overrideRef){let n=a.overrideRef({...o,referenceId:r,valibotSchema:e,jsonSchema:t});n&&(t.$ref=n)}break}default:c=e(c,`The "${n.type}" schema cannot be converted to JSON Schema.`)}if(a?.overrideSchema){let e=a.overrideSchema({...o,referenceId:o.referenceMap.get(n),valibotSchema:n,jsonSchema:t,errors:c});if(e)return{...e}}if(c)for(let e of c)r(e,a);return t}let h;function g(e){h={...h??{},...e}}function _(){return h}function v(e,t){let n={definitions:{},referenceMap:new o,getterMap:new Map},r=t?.definitions??_();if(r){for(let e in r)n.referenceMap.set(r[e],e);for(let e in r)n.definitions[e]=m({},r[e],t,n,!0)}let i=m({},e,t,n),a=t?.target??`draft-07`;return a===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:a===`draft-07`&&(i.$schema=`http://json-schema.org/draft-07/schema#`),n.referenceMap.size&&(i.$defs=n.definitions),i}function y(e,t){let n={definitions:{},referenceMap:new o,getterMap:new Map};for(let t in e)n.referenceMap.set(e[t],t);for(let r in e)n.definitions[r]=m({},e[r],t,n,!0);return n.definitions}const b=[`draft-07`,`draft-2020-12`,`openapi-3.0`];function x(e){return{"~standard":{...e[`~standard`],jsonSchema:{input(t){if(b.includes(t.target))return v(e,{typeMode:`input`,target:t.target,...t.libraryOptions});throw Error(`Unsupported target: ${t.target}`)},output(t){if(b.includes(t.target))return v(e,{typeMode:`output`,target:t.target,...t.libraryOptions});throw Error(`Unsupported target: ${t.target}`)}}}}}export{g as addGlobalDefs,_ as getGlobalDefs,v as toJsonSchema,y as toJsonSchemaDefs,x as toStandardJsonSchema};