@kubb/ast 5.23.1 → 5.23.3

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 (163) hide show
  1. package/dist/{constants-Ckeonm-D.js → constants-BTTus9ee.js} +1 -1
  2. package/dist/{constants-Ckeonm-D.js.map → constants-BTTus9ee.js.map} +1 -1
  3. package/dist/{constants-CquR083U.cjs → constants-DztHlVmY.cjs} +1 -1
  4. package/dist/{constants-CquR083U.cjs.map → constants-DztHlVmY.cjs.map} +1 -1
  5. package/dist/factory.cjs +3 -3
  6. package/dist/factory.d.cts +3 -3
  7. package/dist/factory.d.ts +3 -3
  8. package/dist/factory.js +3 -3
  9. package/dist/{file-Dd50jPkH.cjs → file-BAICym_L.cjs} +19 -10
  10. package/dist/file-BAICym_L.cjs.map +1 -0
  11. package/dist/{file-CnuL8oUj.js → file-DUFttt26.js} +21 -11
  12. package/dist/file-DUFttt26.js.map +1 -0
  13. package/dist/{file-CvlMAp_d.js → file-Dj9lsbJu.js} +19 -10
  14. package/dist/file-Dj9lsbJu.js.map +1 -0
  15. package/dist/{file-BVqSiSvV.d.cts → file-DkFGn_Os.d.ts} +29 -7
  16. package/dist/{file-Cg0T6cgz.cjs → file-Dz1HPMld.cjs} +21 -11
  17. package/dist/file-Dz1HPMld.cjs.map +1 -0
  18. package/dist/{file-xJnBQPGq.d.ts → file-KunZhFIV.d.cts} +29 -7
  19. package/dist/file.cjs +1 -1
  20. package/dist/file.d.cts +1 -1
  21. package/dist/file.d.ts +1 -1
  22. package/dist/file.js +1 -1
  23. package/dist/{graph-BcwFCvei.js → graph-BUEOBomo.js} +5 -5
  24. package/dist/{graph-BcwFCvei.js.map → graph-BUEOBomo.js.map} +1 -1
  25. package/dist/{graph-DcIY6tQb.cjs → graph-CFJ4wzFR.cjs} +5 -5
  26. package/dist/{graph-DcIY6tQb.cjs.map → graph-CFJ4wzFR.cjs.map} +1 -1
  27. package/dist/graph.cjs +1 -1
  28. package/dist/graph.d.cts +1 -1
  29. package/dist/graph.d.ts +1 -1
  30. package/dist/graph.js +1 -1
  31. package/dist/{guards-COVJE6TU.cjs → guards-4drgx10i.cjs} +1 -1
  32. package/dist/{guards-COVJE6TU.cjs.map → guards-4drgx10i.cjs.map} +1 -1
  33. package/dist/{guards-D-h9R_sV.d.ts → guards-C6w6KQSY.d.ts} +1 -1
  34. package/dist/{guards-B8qDgSaT.d.cts → guards-COBkDtgu.d.cts} +1 -1
  35. package/dist/{guards-DlJkKsT1.js → guards-DKw4uwc5.js} +1 -1
  36. package/dist/{guards-DlJkKsT1.js.map → guards-DKw4uwc5.js.map} +1 -1
  37. package/dist/{http-DwboM6pK.js → http-CAWf6TAJ.js} +2 -2
  38. package/dist/http-CAWf6TAJ.js.map +1 -0
  39. package/dist/{http-Bm5lhVK4.cjs → http-Dv8py6wh.cjs} +2 -2
  40. package/dist/http-Dv8py6wh.cjs.map +1 -0
  41. package/dist/http.cjs +2 -2
  42. package/dist/http.d.cts +2 -2
  43. package/dist/http.d.ts +2 -2
  44. package/dist/http.js +2 -2
  45. package/dist/{index-DNiIem0x.d.ts → index-9l1xMEl_.d.ts} +4 -4
  46. package/dist/{index-Dp50LM3a.d.ts → index-B5w-X5V6.d.ts} +1 -1
  47. package/dist/{index-BwnMIoLl.d.ts → index-Be5d4Zcl.d.ts} +2 -2
  48. package/dist/index-CI6Tu2c7.d.ts +5 -0
  49. package/dist/{index-CAGuKv6t.d.ts → index-CPXo4cA8.d.cts} +8 -3
  50. package/dist/{index-eGkM4FE9.d.ts → index-CX7yfAGI.d.ts} +1 -1
  51. package/dist/{index-CFH4ZC7q.d.ts → index-CnY3KmAg.d.ts} +1 -1
  52. package/dist/{index-CIqwy4EE.d.cts → index-CwFC71XK.d.ts} +8 -3
  53. package/dist/{index-DYDha-3I.d.cts → index-D-BjRrJo.d.cts} +1 -1
  54. package/dist/{index-DU_jYpBt.d.cts → index-DZe5evGM.d.cts} +1 -1
  55. package/dist/{index-D3M2spDR.d.ts → index-DjThtAn4.d.ts} +3 -3
  56. package/dist/{index-cpjUxIik.d.ts → index-DkThxxxq.d.cts} +3 -3
  57. package/dist/{index-BngGJux5.d.cts → index-Dr81DOsC.d.cts} +3 -3
  58. package/dist/index-DuDvNFQ8.d.cts +5 -0
  59. package/dist/{index-C-vhkzwR.d.cts → index-dgiKWRpD.d.cts} +4 -4
  60. package/dist/{index-Bb1kqq8H.d.cts → index-gDZYBeJw.d.cts} +1 -1
  61. package/dist/{index-Csf8xsCc.d.cts → index-jWtEIa7j.d.ts} +3 -3
  62. package/dist/{index-DSVef1pp.d.cts → index-ss1YqjpW.d.cts} +2 -2
  63. package/dist/index.cjs +30 -24
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +27 -27
  66. package/dist/index.d.ts +27 -27
  67. package/dist/index.js +30 -24
  68. package/dist/index.js.map +1 -1
  69. package/dist/{json-DURdtz9A.cjs → json-CCWMgzJZ.cjs} +2 -2
  70. package/dist/{json-DURdtz9A.cjs.map → json-CCWMgzJZ.cjs.map} +1 -1
  71. package/dist/{json-DH7_lcWm.js → json-DyDtIZTj.js} +2 -2
  72. package/dist/{json-DH7_lcWm.js.map → json-DyDtIZTj.js.map} +1 -1
  73. package/dist/json.cjs +1 -1
  74. package/dist/json.d.cts +1 -1
  75. package/dist/json.d.ts +1 -1
  76. package/dist/json.js +1 -1
  77. package/dist/{macro-D0KfNtff.js → macro-9WouvtZe.js} +3 -3
  78. package/dist/macro-9WouvtZe.js.map +1 -0
  79. package/dist/{macro-DrTBT7fh.cjs → macro-BEwfGNu1.cjs} +3 -3
  80. package/dist/macro-BEwfGNu1.cjs.map +1 -0
  81. package/dist/macro.cjs +1 -1
  82. package/dist/macro.d.cts +1 -1
  83. package/dist/macro.d.ts +1 -1
  84. package/dist/macro.js +1 -1
  85. package/dist/{mediaType-D8uIO8sG.cjs → mediaType-BbIfudh0.cjs} +1 -1
  86. package/dist/{mediaType-D8uIO8sG.cjs.map → mediaType-BbIfudh0.cjs.map} +1 -1
  87. package/dist/{mediaType-CRjggmoG.js → mediaType-DXQCNYdM.js} +1 -1
  88. package/dist/{mediaType-CRjggmoG.js.map → mediaType-DXQCNYdM.js.map} +1 -1
  89. package/dist/mediaType.cjs +1 -1
  90. package/dist/mediaType.d.cts +1 -1
  91. package/dist/mediaType.d.ts +1 -1
  92. package/dist/mediaType.js +1 -1
  93. package/dist/{node-Djh-mZB2.js → node-DtuO3zr8.js} +4 -4
  94. package/dist/{node-Djh-mZB2.js.map → node-DtuO3zr8.js.map} +1 -1
  95. package/dist/{node-DjcETnc8.cjs → node-vTrAIz3e.cjs} +4 -4
  96. package/dist/{node-DjcETnc8.cjs.map → node-vTrAIz3e.cjs.map} +1 -1
  97. package/dist/node.cjs +4 -4
  98. package/dist/node.d.cts +3 -3
  99. package/dist/node.d.ts +3 -3
  100. package/dist/node.js +4 -4
  101. package/dist/{nodeText-DVVDZQjF.js → nodeText-BSYvDZOH.js} +2 -2
  102. package/dist/{nodeText-DVVDZQjF.js.map → nodeText-BSYvDZOH.js.map} +1 -1
  103. package/dist/{nodeText-DRb_rVd1.cjs → nodeText-CZ7wgxu9.cjs} +2 -2
  104. package/dist/{nodeText-DRb_rVd1.cjs.map → nodeText-CZ7wgxu9.cjs.map} +1 -1
  105. package/dist/{nodes-BB60Bq2H.cjs → nodes-BT2Ocq0x.cjs} +5 -5
  106. package/dist/{nodes-BB60Bq2H.cjs.map → nodes-BT2Ocq0x.cjs.map} +1 -1
  107. package/dist/{nodes-CWMa9xhW.js → nodes-CwYIFVt5.js} +5 -5
  108. package/dist/{nodes-CWMa9xhW.js.map → nodes-CwYIFVt5.js.map} +1 -1
  109. package/dist/{operation-X7chCdL2.d.cts → operation-BUhPuZMY.d.cts} +1 -1
  110. package/dist/{operation-BgRyVS7z.d.ts → operation-jxEr2No4.d.ts} +1 -1
  111. package/dist/{optionality-D-zqzVMH.cjs → optionality-C-qULYxo.cjs} +1 -1
  112. package/dist/{optionality-D-zqzVMH.cjs.map → optionality-C-qULYxo.cjs.map} +1 -1
  113. package/dist/{optionality-DISn8ytP.js → optionality-FkRredTC.js} +1 -1
  114. package/dist/{optionality-DISn8ytP.js.map → optionality-FkRredTC.js.map} +1 -1
  115. package/dist/{promise-RpnEev9D.js → promise-B3YkZ4C8.js} +1 -1
  116. package/dist/{promise-RpnEev9D.js.map → promise-B3YkZ4C8.js.map} +1 -1
  117. package/dist/{promise-BOdlgT0N.cjs → promise-DScaykew.cjs} +1 -1
  118. package/dist/{promise-BOdlgT0N.cjs.map → promise-DScaykew.cjs.map} +1 -1
  119. package/dist/{ref-P0ZLT1Bg.cjs → ref-Bh5Xo8T7.cjs} +4 -4
  120. package/dist/{ref-P0ZLT1Bg.cjs.map → ref-Bh5Xo8T7.cjs.map} +1 -1
  121. package/dist/{ref-Bu7PoHar.js → ref-DPqeS8K1.js} +4 -4
  122. package/dist/{ref-Bu7PoHar.js.map → ref-DPqeS8K1.js.map} +1 -1
  123. package/dist/ref.cjs +2 -2
  124. package/dist/ref.d.cts +1 -1
  125. package/dist/ref.d.ts +1 -1
  126. package/dist/ref.js +2 -2
  127. package/dist/{refs-YCV3CznS.js → refs-Bgf8_9Ui.js} +2 -2
  128. package/dist/{refs-YCV3CznS.js.map → refs-Bgf8_9Ui.js.map} +1 -1
  129. package/dist/{refs-CYHpRlQo.cjs → refs-rmr2LFV1.cjs} +2 -2
  130. package/dist/{refs-CYHpRlQo.cjs.map → refs-rmr2LFV1.cjs.map} +1 -1
  131. package/dist/{schema-DloctnMm.js → schema-4UcdIPQ2.js} +7 -7
  132. package/dist/{schema-DloctnMm.js.map → schema-4UcdIPQ2.js.map} +1 -1
  133. package/dist/{schema-BIErWqgc.cjs → schema-DuCY4lCG.cjs} +7 -7
  134. package/dist/{schema-BIErWqgc.cjs.map → schema-DuCY4lCG.cjs.map} +1 -1
  135. package/dist/{schema-hxMlgCrV.cjs → schema-gSjYgaCl.cjs} +2 -2
  136. package/dist/{schema-hxMlgCrV.cjs.map → schema-gSjYgaCl.cjs.map} +1 -1
  137. package/dist/{schema-2ZAQk7qE.js → schema-tH14gE6i.js} +2 -2
  138. package/dist/{schema-2ZAQk7qE.js.map → schema-tH14gE6i.js.map} +1 -1
  139. package/dist/schema.cjs +5 -5
  140. package/dist/schema.d.cts +4 -4
  141. package/dist/schema.d.ts +4 -4
  142. package/dist/schema.js +5 -5
  143. package/dist/{visitor-DTrzvA3R.cjs → visitor-Bh1CBAOz.cjs} +4 -5
  144. package/dist/{visitor-DTrzvA3R.cjs.map → visitor-Bh1CBAOz.cjs.map} +1 -1
  145. package/dist/{visitor-BZozlXBF.d.ts → visitor-CFbuH7BY.d.ts} +6 -3
  146. package/dist/{visitor-Bw_opzjF.d.cts → visitor-DxhkIQyP.d.cts} +6 -3
  147. package/dist/{visitor-NoQSUQTu.js → visitor-XA0W3OVv.js} +4 -5
  148. package/dist/{visitor-NoQSUQTu.js.map → visitor-XA0W3OVv.js.map} +1 -1
  149. package/package.json +1 -1
  150. package/dist/file-Cg0T6cgz.cjs.map +0 -1
  151. package/dist/file-CnuL8oUj.js.map +0 -1
  152. package/dist/file-CvlMAp_d.js.map +0 -1
  153. package/dist/file-Dd50jPkH.cjs.map +0 -1
  154. package/dist/http-Bm5lhVK4.cjs.map +0 -1
  155. package/dist/http-DwboM6pK.js.map +0 -1
  156. package/dist/index-BWd95onW.d.cts +0 -5
  157. package/dist/index-DaHsMJ_S.d.ts +0 -5
  158. package/dist/macro-D0KfNtff.js.map +0 -1
  159. package/dist/macro-DrTBT7fh.cjs.map +0 -1
  160. /package/dist/{base-IpYuh3ZP.d.cts → base-LhsPvVY1.d.ts} +0 -0
  161. /package/dist/{base-IpYuh3ZP.d.ts → base-UFBZi-FO.d.cts} +0 -0
  162. /package/dist/{index-Cc2K3OzU.d.cts → index-C-nsgwuD.d.ts} +0 -0
  163. /package/dist/{index-Cc2K3OzU.d.ts → index-DR9ahJ-x.d.cts} +0 -0
package/dist/ref.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DU_jYpBt.cjs";
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-DZe5evGM.cjs";
2
2
  export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
package/dist/ref.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-CFH4ZC7q.js";
1
+ import { i as isBareRef, o as resolveRef, r as mergeSchema, t as getName } from "./index-CnY3KmAg.js";
2
2
  export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
package/dist/ref.js CHANGED
@@ -1,3 +1,3 @@
1
- import { i as resolveRef, t as isBareRef } from "./refs-YCV3CznS.js";
2
- import { n as mergeSchema, t as getName } from "./ref-Bu7PoHar.js";
1
+ import { i as resolveRef, t as isBareRef } from "./refs-Bgf8_9Ui.js";
2
+ import { n as mergeSchema, t as getName } from "./ref-DPqeS8K1.js";
3
3
  export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-BYyVTPww.js";
2
- import { t as memo } from "./promise-RpnEev9D.js";
2
+ import { t as memo } from "./promise-B3YkZ4C8.js";
3
3
  // src/utils/refs.ts
4
4
  /**
5
5
  * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
@@ -99,4 +99,4 @@ function isBareRef(node, keysToOmit) {
99
99
  }
100
100
  export { resolveRefName as a, resolveRef as i, mergeRefWithSchema as n, refName as r, isBareRef as t };
101
101
 
102
- //# sourceMappingURL=refs-YCV3CznS.js.map
102
+ //# sourceMappingURL=refs-Bgf8_9Ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"refs-YCV3CznS.js","names":[],"sources":["../src/utils/refs.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAO,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,CAAC;AACH;AAGA,MAAM,WAAW,KAAK,OAAuB,EAAE,KAAK,IAAQ,CAAC;;;;;;;;;;;;;;AAe7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"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAO,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,C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U,CAAC,YAAY;AACxJ"}
@@ -1,5 +1,5 @@
1
1
  require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_promise = require("./promise-BOdlgT0N.cjs");
2
+ const require_promise = require("./promise-DScaykew.cjs");
3
3
  // src/utils/refs.ts
4
4
  /**
5
5
  * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.
@@ -128,4 +128,4 @@ Object.defineProperty(exports, "resolveRefName", {
128
128
  }
129
129
  });
130
130
 
131
- //# sourceMappingURL=refs-CYHpRlQo.cjs.map
131
+ //# sourceMappingURL=refs-rmr2LFV1.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"refs-CYHpRlQo.cjs","names":["memo"],"sources":["../src/utils/refs.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAOA,gBAAAA,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,CAAC;AACH;AAGA,MAAM,WAAWA,gBAAAA,KAAK,OAAuB,EAAE,KAAK,IAAQ,CAAC;;;;;;;;;;;;;;AAe7D,SAAgB,eAAe,MAAoD;CACjF,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzC,IAAI,KAAK,YAAY,OAAO,KAAK;CACjC,IAAI,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;CAErC,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAC3C;;;;;;;;;AAUA,SAAgB,WAAW,MAA8B;CACvD,IAAI,KAAK,SAAS,SAAS,CAAC,KAAK,QAAQ,OAAO;CAEhD,MAAM,uBAAO,IAAI,QAAoB;CACrC,IAAI,UAAsB;CAC1B,OAAO,QAAQ,SAAS,SAAS,QAAQ,QAAQ;EAC/C,IAAI,KAAK,IAAI,OAAO,GAAG,OAAO;EAC9B,KAAK,IAAI,OAAO;EAChB,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAM,+BAAoC,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAO;AAAQ,CAAC;;;;;;;;;;;;;;;AAgB3F,SAAgB,mBAAmB,MAAiC;CAClE,IAAI,CAAC,KAAK,QAAQ,OAAO;CAEzB,MAAM,SAAkC,EAAE,GAAG,KAAK,OAAO;CACzD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,MAAM,QAAS,KAAiC;EAChD,IAAI,UAAU,KAAA,KAAa,CAAC,aAAa,IAAI,GAAG,GAAG,OAAO,OAAO;CACnE;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,UAAU,MAAqC,YAA4C;CACzG,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CAEzC,MAAM,OAAO,mBAAmB,IAAI;CAEpC,OAAO,CAAC,KAAK,YAAY,CAAC,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,eAAe,CAAC,KAAK,UAAU,UAAU,CAAC,YAAY;AACxJ"}
1
+ {"version":3,"file":"refs-rmr2LFV1.cjs","names":["memo"],"sources":["../src/utils/refs.ts"],"sourcesContent":["import { memo } from '@internals/utils'\nimport type { RefSchemaNode, SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Returns the last segment of a `$ref` pointer, for example `'Pet'` for `#/components/schemas/Pet`.\n * The segment is decoded like the pointer resolver does: percent-escapes first, then `~1` and `~0`\n * (RFC 6901), so `a~1b~0c` names the component `a/b~c`.\n */\nexport function refName(ref: string): string {\n return memo(refNames, ref, () => {\n const segment = ref.split('/').at(-1) ?? ref\n let decoded = segment\n\n try {\n decoded = decodeURIComponent(segment)\n } catch {\n // A stray `%` is not a valid escape, so the segment is already the literal name.\n }\n\n return decoded.replaceAll('~1', '/').replaceAll('~0', '~')\n })\n}\n\n// Every plugin resolves the same refs on every visit; the limit only bounds a long-running host.\nconst refNames = memo.create<string, string>({ max: 100_000 })\n\n/**\n * Resolves the emitted name of the schema a ref node points at. Prefers `targetName` (set when\n * the referenced schema was renamed, e.g. to break a collision), then the last segment of `ref`,\n * then `name`, then the nested `schema.name`.\n *\n * Returns `null` for non-ref nodes or when no name resolves.\n *\n * @example\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Pet' }) // 'Pet'`\n *\n * @example Collision-renamed target\n * `resolveRefName({ kind: 'Schema', type: 'ref', ref: '#/components/schemas/Order', targetName: 'OrderSchema' }) // 'OrderSchema'`\n */\nexport function resolveRefName(node: SchemaNode | null | undefined): string | null {\n if (!node || node.type !== 'ref') return null\n if (node.targetName) return node.targetName\n if (node.ref) return refName(node.ref)\n\n return node.name ?? node.schema?.name ?? null\n}\n\n/**\n * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.\n *\n * @example\n * ```ts\n * const target = resolveRef(refSchema)\n * ```\n */\nexport function resolveRef(node: SchemaNode): SchemaNode {\n if (node.type !== 'ref' || !node.schema) return node\n\n const seen = new WeakSet<SchemaNode>()\n let current: SchemaNode = node\n while (current.type === 'ref' && current.schema) {\n if (seen.has(current)) return current\n seen.add(current)\n current = current.schema\n }\n return current\n}\n\n/** Fields of a ref node that describe the ref itself, so they never override the resolved schema. */\nconst REF_OWN_KEYS: ReadonlySet<string> = new Set(['kind', 'type', 'name', 'ref', 'schema'])\n\n/**\n * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.\n *\n * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field\n * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields\n * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`\n * is returned as is.\n *\n * @example\n * ```ts\n * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })\n * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'\n * ```\n */\nexport function mergeRefWithSchema(node: RefSchemaNode): SchemaNode {\n if (!node.schema) return node\n\n const merged: Record<string, unknown> = { ...node.schema }\n for (const key of Object.keys(node)) {\n const value = (node as Record<string, unknown>)[key]\n if (value !== undefined && !REF_OWN_KEYS.has(key)) merged[key] = value\n }\n\n return merged as SchemaNode\n}\n\n/**\n * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.\n *\n * Modifiers inherited from the resolved schema are included in the check because a ref emits the\n * referenced schema variable with those modifiers already applied.\n */\nexport function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean {\n if (!node || node.type !== 'ref') return false\n\n const meta = mergeRefWithSchema(node)\n\n return !meta.nullable && !meta.optional && !meta.nullish && meta.default === undefined && !meta.description && !meta.examples?.length && !keysToOmit?.length\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,QAAQ,KAAqB;CAC3C,OAAOA,gBAAAA,KAAK,UAAU,WAAW;EAC/B,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK;EACzC,IAAI,UAAU;EAEd,IAAI;GACF,UAAU,mBAAmB,OAAO;EACtC,QAAQ,CAER;EAEA,OAAO,QAAQ,WAAW,MAAM,GAAG,CAAC,CAAC,WAAW,MAAM,GAAG;CAC3D,CAAC;AACH;AAGA,MAAM,WAAWA,gBAAAA,KAAK,OAAuB,EAAE,KAAK,IAAQ,CAAC;;;;;;;;;;;;;;AAe7D,SAAgB,eAAe,MAAoD;CACjF,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzC,IAAI,KAAK,YAAY,OAAO,KAAK;CACjC,IAAI,KAAK,KAAK,OAAO,QAAQ,KAAK,GAAG;CAErC,OAAO,KAAK,QAAQ,KAAK,QAAQ,QAAQ;AAC3C;;;;;;;;;AAUA,SAAgB,WAAW,MAA8B;CACvD,IAAI,KAAK,SAAS,SAAS,CAAC,KAAK,QAAQ,OAAO;CAEhD,MAAM,uBAAO,IAAI,QAAoB;CACrC,IAAI,UAAsB;CAC1B,OAAO,QAAQ,SAAS,SAAS,QAAQ,QAAQ;EAC/C,IAAI,KAAK,IAAI,OAAO,GAAG,OAAO;EAC9B,KAAK,IAAI,OAAO;EAChB,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAM,+BAAoC,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAQ;CAAO;AAAQ,CAAC;;;;;;;;;;;;;;;AAgB3F,SAAgB,mBAAmB,MAAiC;CAClE,IAAI,CAAC,KAAK,QAAQ,OAAO;CAEzB,MAAM,SAAkC,EAAE,GAAG,KAAK,OAAO;CACzD,KAAK,MAAM,OAAO,OAAO,KAAK,IAAI,GAAG;EACnC,MAAM,QAAS,KAAiC;EAChD,IAAI,UAAU,KAAA,KAAa,CAAC,aAAa,IAAI,GAAG,GAAG,OAAO,OAAO;CACnE;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,UAAU,MAAqC,YAA4C;CACzG,IAAI,CAAC,QAAQ,KAAK,SAAS,OAAO,OAAO;CAEzC,MAAM,OAAO,mBAAmB,IAAI;CAEpC,OAAO,CAAC,KAAK,YAAY,CAAC,KAAK,YAAY,CAAC,KAAK,WAAW,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,eAAe,CAAC,KAAK,UAAU,UAAU,CAAC,YAAY;AACxJ"}
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
- import { t as applyOptionality } from "./optionality-DISn8ytP.js";
3
- import { n as schemaTypes } from "./constants-Ckeonm-D.js";
4
- import { n as narrowSchema } from "./guards-DlJkKsT1.js";
5
- import { n as findSchema, o as getEmbeddedJson } from "./visitor-NoQSUQTu.js";
6
- import { n as mergeSchema } from "./ref-Bu7PoHar.js";
7
- import { t as memo } from "./promise-RpnEev9D.js";
2
+ import { t as applyOptionality } from "./optionality-FkRredTC.js";
3
+ import { n as schemaTypes } from "./constants-BTTus9ee.js";
4
+ import { n as narrowSchema } from "./guards-DKw4uwc5.js";
5
+ import { n as findSchema, o as getEmbeddedJson } from "./visitor-XA0W3OVv.js";
6
+ import { n as mergeSchema } from "./ref-DPqeS8K1.js";
7
+ import { t as memo } from "./promise-B3YkZ4C8.js";
8
8
  // src/schema/is.ts
9
9
  const plainStringTypes = /* @__PURE__ */ new Set([
10
10
  "string",
@@ -176,4 +176,4 @@ function isString(node) {
176
176
  }
177
177
  export { resolveSchemaProperties as a, inferDiscriminatorPropertyName as i, schema_exports as n, is as o, getSchemaLiteralValues as r, isString as t };
178
178
 
179
- //# sourceMappingURL=schema-DloctnMm.js.map
179
+ //# sourceMappingURL=schema-4UcdIPQ2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-DloctnMm.js","names":[],"sources":["../src/schema/is.ts","../src/utils/schemaProperties.ts","../src/schema/index.ts"],"sourcesContent":["import { narrowSchema } from '../guards.ts'\nimport type { SchemaNode, SchemaType } from '../nodes/schema.ts'\nimport { mergeSchema } from '../ref/index.ts'\n\n/** `string` prints as a plain `string`, `text` is a non-blob string primitive, `const` a one-value enum, `enumLike` an enum or union of them, `untyped` is `void`, `any` or `unknown`. */\nexport type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped'\n\n/** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */\nexport type SchemaFollow = 'ref' | 'array'\n\nexport type IsOptions = {\n /** Links to look through. Following repeats and stops on a ref cycle. */\n follow?: ReadonlyArray<SchemaFollow>\n}\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])\nconst scalarTypes = new Set<SchemaType>([\n 'string',\n 'email',\n 'url',\n 'uuid',\n 'number',\n 'integer',\n 'bigint',\n 'boolean',\n 'date',\n 'time',\n 'datetime',\n 'blob',\n 'enum',\n])\nconst untypedTypes = new Set<SchemaType>(['void', 'any', 'unknown'])\n\nconst kinds: Record<SchemaKind, (node: SchemaNode, test: (child: SchemaNode) => boolean) => boolean> = {\n binary: (node) => node.type === 'blob',\n string: (node) => {\n if (plainStringTypes.has(node.type)) return true\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n return temporal ? temporal.representation !== 'date' : false\n },\n text: (node) => node.type !== 'blob' && node.primitive === 'string',\n scalar: (node) => scalarTypes.has(node.type),\n const: (node) => node.type === 'enum' && (node.namedEnumValues ?? node.enumValues ?? []).length === 1,\n enumLike: (node, test) => node.type === 'enum' || (node.type === 'union' && !!node.members?.length && node.members.every(test)),\n untyped: (node) => untypedTypes.has(node.type),\n}\n\n/** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */\nexport function is(node: SchemaNode, kind: SchemaKind, { follow = [] }: IsOptions = {}): boolean {\n // `path` holds the ref targets above `current`, so a cycle stops without hiding a target a sibling branch reaches.\n const test = (current: SchemaNode, path: ReadonlySet<SchemaNode>): boolean => {\n if (follow.includes('ref') && current.type === 'ref' && current.schema) {\n return !path.has(current.schema) && test(mergeSchema(current), new Set(path).add(current.schema))\n }\n const child = (next: SchemaNode) => test(next, path)\n return kinds[kind](current, child) || (follow.includes('array') && current.type === 'array' && (current.items ?? []).some(child))\n }\n\n return test(node, new Set())\n}\n","import { memo } from '@internals/utils'\nimport type { PropertyNode } from '../nodes/property.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Finds every matching property exposed by an object, resolved reference, or intersection.\n *\n * References are followed through their parsed `schema`. Circular references terminate without\n * revisiting a node. Unions are not traversed because a property on one branch does not describe\n * every branch.\n *\n * @example Faker discriminator narrowing\n * ```ts\n * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>\n * getSchemaLiteralValues(schema),\n * )\n * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`\n * ```\n *\n * @example Zod discriminated unions\n * ```ts\n * const canDiscriminate = union.members?.every(\n * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,\n * )\n * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`\n * ```\n *\n * @example TypeScript property lookup\n * ```ts\n * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })\n * const statusSchemas = properties.map((property) => print(property.schema))\n * ```\n */\nexport function resolveSchemaProperties({ node, propertyName }: { node: SchemaNode; propertyName: string }): ReadonlyArray<PropertyNode> {\n const properties: Array<PropertyNode> = []\n walkSchema(node, 'intersection', (current) => {\n if (current.type !== 'object') return\n const property = current.properties.find((candidate) => candidate.name === propertyName)\n if (property) properties.push(property)\n })\n return properties\n}\n\nfunction walkSchema(node: SchemaNode, through: 'union' | 'intersection', visit: (schema: SchemaNode) => void): void {\n const visited = new WeakSet<SchemaNode>()\n\n function walk(current: SchemaNode | null | undefined): void {\n if (!current || visited.has(current)) return\n visited.add(current)\n visit(current)\n\n if (current.type === 'ref') return walk(current.schema)\n if (current.type === through) for (const member of current.members ?? []) walk(member)\n }\n\n walk(node)\n}\n\n/**\n * Reads the unique literal values represented by an enum, resolved reference, or union.\n *\n * Named enum values take precedence over simple enum values, matching how renderers consume\n * `EnumSchemaNode`.\n *\n * @example\n * ```ts\n * const values = getSchemaLiteralValues(enumNode)\n * // ['cat', 'dog']\n * ```\n */\nexport function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue> {\n return memo(literalValues, node, () => {\n const values = new Set<LiteralValue>()\n walkSchema(node, 'union', (current) => {\n if (current.type !== 'enum') return\n for (const { value } of current.namedEnumValues ?? current.enumValues?.map((value) => ({ value })) ?? []) values.add(value)\n })\n return Object.freeze([...values])\n })\n}\n\ntype LiteralValue = string | number | boolean | null\n\n// Printers read an enum's values each time they print it.\nconst literalValues = memo.create<SchemaNode, ReadonlyArray<LiteralValue>>({ weak: true })\n\n// Names of every property an object, resolved reference, or intersection exposes.\nfunction collectPropertyNames(node: SchemaNode): Set<string> {\n const names = new Set<string>()\n walkSchema(node, 'intersection', (current) => {\n if (current.type === 'object') for (const property of current.properties) names.add(property.name)\n })\n return names\n}\n\n/**\n * Infers an implicit discriminator: a property every member exposes with a distinct single\n * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.\n */\nexport function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined {\n if (members.length < 2) return undefined\n\n let candidates: Set<string> | undefined\n for (const member of members) {\n const names = collectPropertyNames(member)\n candidates = candidates ? new Set([...candidates].filter((name) => names.has(name))) : names\n }\n\n for (const name of candidates ?? []) {\n const values = members.map((member) => {\n const literals = new Set(resolveSchemaProperties({ node: member, propertyName: name }).flatMap((property) => getSchemaLiteralValues(property.schema)))\n return literals.size === 1 ? [...literals][0] : undefined\n })\n\n if (values.every((value) => value !== undefined) && new Set(values).size === members.length) {\n return name\n }\n }\n\n return undefined\n}\n","export { applyOptionality } from '../optionality.ts'\nexport { schemaTypes as types } from '../constants.ts'\nexport { narrowSchema as narrow } from '../guards.ts'\nexport { findSchema as find } from '../visitor.ts'\nexport { getEmbeddedJson } from './embeddedJson.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { is } from './is.ts'\n\nexport { is } from './is.ts'\nexport type { IsOptions, SchemaFollow, SchemaKind } from './is.ts'\nexport {\n getSchemaLiteralValues as getLiterals,\n inferDiscriminatorPropertyName as inferDiscriminator,\n resolveSchemaProperties as findProperties,\n} from '../utils/schemaProperties.ts'\n\n/** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */\nexport function isString(node: SchemaNode): boolean {\n return is(node, 'string')\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,mCAAmB,IAAI,IAAgB;CAAC;CAAU;CAAQ;CAAS;CAAO;AAAU,CAAC;AAC3F,MAAM,8BAAc,IAAI,IAAgB;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,+BAAe,IAAI,IAAgB;CAAC;CAAQ;CAAO;AAAS,CAAC;AAEnE,MAAM,QAAiG;CACrG,SAAS,SAAS,KAAK,SAAS;CAChC,SAAS,SAAS;EAChB,IAAI,iBAAiB,IAAI,KAAK,IAAI,GAAG,OAAO;EAC5C,MAAM,WAAW,aAAa,MAAM,MAAM,KAAK,aAAa,MAAM,MAAM;EACxE,OAAO,WAAW,SAAS,mBAAmB,SAAS;CACzD;CACA,OAAO,SAAS,KAAK,SAAS,UAAU,KAA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MAAM,SAAS,QAAQ,KAAK,WAAW;GACrC,MAAM,WAAW,IAAI,IAAI,wBAAwB;IAAE,MAAM;IAAQ,cAAc;GAAK,CAAC,CAAC,CAAC,SAAS,aAAa,uBAAuB,SAAS,MAAM,CAAC,CAAC;GACrJ,OAAO,SAAS,SAAS,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,KAAA;EAClD,CAAC;EAED,IAAI,OAAO,OAAO,UAAU,UAAU,KAAA,CAAS,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,QAAQ,QACnF,OAAO;CAEX;AAGF;;;;;;;;;;;;;;;ACvGA,SAAgB,SAAS,MAA2B;CAClD,OAAO,GAAG,MAAM,QAAQ;AAC1B"}
1
+ {"version":3,"file":"schema-4UcdIPQ2.js","names":[],"sources":["../src/schema/is.ts","../src/utils/schemaProperties.ts","../src/schema/index.ts"],"sourcesContent":["import { narrowSchema } from '../guards.ts'\nimport type { SchemaNode, SchemaType } from '../nodes/schema.ts'\nimport { mergeSchema } from '../ref/index.ts'\n\n/** `string` prints as a plain `string`, `text` is a non-blob string primitive, `const` a one-value enum, `enumLike` an enum or union of them, `untyped` is `void`, `any` or `unknown`. */\nexport type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped'\n\n/** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */\nexport type SchemaFollow = 'ref' | 'array'\n\nexport type IsOptions = {\n /** Links to look through. Following repeats and stops on a ref cycle. */\n follow?: ReadonlyArray<SchemaFollow>\n}\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])\nconst scalarTypes = new Set<SchemaType>([\n 'string',\n 'email',\n 'url',\n 'uuid',\n 'number',\n 'integer',\n 'bigint',\n 'boolean',\n 'date',\n 'time',\n 'datetime',\n 'blob',\n 'enum',\n])\nconst untypedTypes = new Set<SchemaType>(['void', 'any', 'unknown'])\n\nconst kinds: Record<SchemaKind, (node: SchemaNode, test: (child: SchemaNode) => boolean) => boolean> = {\n binary: (node) => node.type === 'blob',\n string: (node) => {\n if (plainStringTypes.has(node.type)) return true\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n return temporal ? temporal.representation !== 'date' : false\n },\n text: (node) => node.type !== 'blob' && node.primitive === 'string',\n scalar: (node) => scalarTypes.has(node.type),\n const: (node) => node.type === 'enum' && (node.namedEnumValues ?? node.enumValues ?? []).length === 1,\n enumLike: (node, test) => node.type === 'enum' || (node.type === 'union' && !!node.members?.length && node.members.every(test)),\n untyped: (node) => untypedTypes.has(node.type),\n}\n\n/** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */\nexport function is(node: SchemaNode, kind: SchemaKind, { follow = [] }: IsOptions = {}): boolean {\n // `path` holds the ref targets above `current`, so a cycle stops without hiding a target a sibling branch reaches.\n const test = (current: SchemaNode, path: ReadonlySet<SchemaNode>): boolean => {\n if (follow.includes('ref') && current.type === 'ref' && current.schema) {\n return !path.has(current.schema) && test(mergeSchema(current), new Set(path).add(current.schema))\n }\n const child = (next: SchemaNode) => test(next, path)\n return kinds[kind](current, child) || (follow.includes('array') && current.type === 'array' && (current.items ?? []).some(child))\n }\n\n return test(node, new Set())\n}\n","import { memo } from '@internals/utils'\nimport type { PropertyNode } from '../nodes/property.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Finds every matching property exposed by an object, resolved reference, or intersection.\n *\n * References are followed through their parsed `schema`. Circular references terminate without\n * revisiting a node. Unions are not traversed because a property on one branch does not describe\n * every branch.\n *\n * @example Faker discriminator narrowing\n * ```ts\n * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>\n * getSchemaLiteralValues(schema),\n * )\n * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`\n * ```\n *\n * @example Zod discriminated unions\n * ```ts\n * const canDiscriminate = union.members?.every(\n * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,\n * )\n * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`\n * ```\n *\n * @example TypeScript property lookup\n * ```ts\n * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })\n * const statusSchemas = properties.map((property) => print(property.schema))\n * ```\n */\nexport function resolveSchemaProperties({ node, propertyName }: { node: SchemaNode; propertyName: string }): ReadonlyArray<PropertyNode> {\n const properties: Array<PropertyNode> = []\n walkSchema(node, 'intersection', (current) => {\n if (current.type !== 'object') return\n const property = current.properties.find((candidate) => candidate.name === propertyName)\n if (property) properties.push(property)\n })\n return properties\n}\n\nfunction walkSchema(node: SchemaNode, through: 'union' | 'intersection', visit: (schema: SchemaNode) => void): void {\n const visited = new WeakSet<SchemaNode>()\n\n function walk(current: SchemaNode | null | undefined): void {\n if (!current || visited.has(current)) return\n visited.add(current)\n visit(current)\n\n if (current.type === 'ref') return walk(current.schema)\n if (current.type === through) for (const member of current.members ?? []) walk(member)\n }\n\n walk(node)\n}\n\n/**\n * Reads the unique literal values represented by an enum, resolved reference, or union.\n *\n * Named enum values take precedence over simple enum values, matching how renderers consume\n * `EnumSchemaNode`.\n *\n * @example\n * ```ts\n * const values = getSchemaLiteralValues(enumNode)\n * // ['cat', 'dog']\n * ```\n */\nexport function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue> {\n return memo(literalValues, node, () => {\n const values = new Set<LiteralValue>()\n walkSchema(node, 'union', (current) => {\n if (current.type !== 'enum') return\n for (const { value } of current.namedEnumValues ?? current.enumValues?.map((value) => ({ value })) ?? []) values.add(value)\n })\n return Object.freeze([...values])\n })\n}\n\ntype LiteralValue = string | number | boolean | null\n\n// Printers read an enum's values each time they print it.\nconst literalValues = memo.create<SchemaNode, ReadonlyArray<LiteralValue>>({ weak: true })\n\n// Names of every property an object, resolved reference, or intersection exposes.\nfunction collectPropertyNames(node: SchemaNode): Set<string> {\n const names = new Set<string>()\n walkSchema(node, 'intersection', (current) => {\n if (current.type === 'object') for (const property of current.properties) names.add(property.name)\n })\n return names\n}\n\n/**\n * Infers an implicit discriminator: a property every member exposes with a distinct single\n * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.\n */\nexport function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined {\n if (members.length < 2) return undefined\n\n let candidates: Set<string> | undefined\n for (const member of members) {\n const names = collectPropertyNames(member)\n candidates = candidates ? new Set([...candidates].filter((name) => names.has(name))) : names\n }\n\n for (const name of candidates ?? []) {\n const values = members.map((member) => {\n const literals = new Set(resolveSchemaProperties({ node: member, propertyName: name }).flatMap((property) => getSchemaLiteralValues(property.schema)))\n return literals.size === 1 ? [...literals][0] : undefined\n })\n\n if (values.every((value) => value !== undefined) && new Set(values).size === members.length) {\n return name\n }\n }\n\n return undefined\n}\n","export { applyOptionality } from '../optionality.ts'\nexport { schemaTypes as types } from '../constants.ts'\nexport { narrowSchema as narrow } from '../guards.ts'\nexport { findSchema as find } from '../visitor.ts'\nexport { getEmbeddedJson } from './embeddedJson.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { is } from './is.ts'\n\nexport { is } from './is.ts'\nexport type { IsOptions, SchemaFollow, SchemaKind } from './is.ts'\nexport {\n getSchemaLiteralValues as getLiterals,\n inferDiscriminatorPropertyName as inferDiscriminator,\n resolveSchemaProperties as findProperties,\n} from '../utils/schemaProperties.ts'\n\n/** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */\nexport function isString(node: SchemaNode): boolean {\n return is(node, 'string')\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,mCAAmB,IAAI,IAAgB;CAAC;CAAU;CAAQ;CAAS;CAAO;AAAU,CAAC;AAC3F,MAAM,8BAAc,IAAI,IAAgB;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,+BAAe,IAAI,IAAgB;CAAC;CAAQ;CAAO;AAAS,CAAC;AAEnE,MAAM,QAA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AA;CAE/B,IAAI;CACJ,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ,qBAAqB,MAAM;EACzC,aAAa,aAAa,IAAI,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,QAAQ,SAAS,MAAM,IAAI,IAAI,CAAC,CAAC,IAAI;CACzF;CAEA,KAAK,MAAM,QAAQ,cAAc,CAAC,GAAG;EACnC,MAAM,SAAS,QAAQ,KAAK,WAAW;GACrC,MAAM,WAAW,IAAI,IAAI,wBAAwB;IAAE,MAAM;IAAQ,cAAc;GAAK,CAAC,CAAC,CAAC,SAAS,aAAa,uBAAuB,SAAS,MAAM,CAAC,CAAC;GACrJ,OAAO,SAAS,SAAS,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,KAAA;EAClD,CAAC;EAED,IAAI,OAAO,OAAO,UAAU,UAAU,KAAA,CAAS,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,QAAQ,QACnF,OAAO;CAEX;AAGF;;;;;;;;;;;;;;;ACvGA,SAAgB,SAAS,MAA2B;CAClD,OAAO,GAAG,MAAM,QAAQ;AAC1B"}
@@ -1,10 +1,10 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_optionality = require("./optionality-D-zqzVMH.cjs");
3
- const require_constants = require("./constants-CquR083U.cjs");
4
- const require_guards = require("./guards-COVJE6TU.cjs");
5
- const require_visitor = require("./visitor-DTrzvA3R.cjs");
6
- const require_ref = require("./ref-P0ZLT1Bg.cjs");
7
- const require_promise = require("./promise-BOdlgT0N.cjs");
2
+ const require_optionality = require("./optionality-C-qULYxo.cjs");
3
+ const require_constants = require("./constants-DztHlVmY.cjs");
4
+ const require_guards = require("./guards-4drgx10i.cjs");
5
+ const require_visitor = require("./visitor-Bh1CBAOz.cjs");
6
+ const require_ref = require("./ref-Bh5Xo8T7.cjs");
7
+ const require_promise = require("./promise-DScaykew.cjs");
8
8
  // src/schema/is.ts
9
9
  const plainStringTypes = /* @__PURE__ */ new Set([
10
10
  "string",
@@ -211,4 +211,4 @@ Object.defineProperty(exports, "schema_exports", {
211
211
  }
212
212
  });
213
213
 
214
- //# sourceMappingURL=schema-BIErWqgc.cjs.map
214
+ //# sourceMappingURL=schema-DuCY4lCG.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-BIErWqgc.cjs","names":["narrowSchema","mergeSchema","memo"],"sources":["../src/schema/is.ts","../src/utils/schemaProperties.ts","../src/schema/index.ts"],"sourcesContent":["import { narrowSchema } from '../guards.ts'\nimport type { SchemaNode, SchemaType } from '../nodes/schema.ts'\nimport { mergeSchema } from '../ref/index.ts'\n\n/** `string` prints as a plain `string`, `text` is a non-blob string primitive, `const` a one-value enum, `enumLike` an enum or union of them, `untyped` is `void`, `any` or `unknown`. */\nexport type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped'\n\n/** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */\nexport type SchemaFollow = 'ref' | 'array'\n\nexport type IsOptions = {\n /** Links to look through. Following repeats and stops on a ref cycle. */\n follow?: ReadonlyArray<SchemaFollow>\n}\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])\nconst scalarTypes = new Set<SchemaType>([\n 'string',\n 'email',\n 'url',\n 'uuid',\n 'number',\n 'integer',\n 'bigint',\n 'boolean',\n 'date',\n 'time',\n 'datetime',\n 'blob',\n 'enum',\n])\nconst untypedTypes = new Set<SchemaType>(['void', 'any', 'unknown'])\n\nconst kinds: Record<SchemaKind, (node: SchemaNode, test: (child: SchemaNode) => boolean) => boolean> = {\n binary: (node) => node.type === 'blob',\n string: (node) => {\n if (plainStringTypes.has(node.type)) return true\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n return temporal ? temporal.representation !== 'date' : false\n },\n text: (node) => node.type !== 'blob' && node.primitive === 'string',\n scalar: (node) => scalarTypes.has(node.type),\n const: (node) => node.type === 'enum' && (node.namedEnumValues ?? node.enumValues ?? []).length === 1,\n enumLike: (node, test) => node.type === 'enum' || (node.type === 'union' && !!node.members?.length && node.members.every(test)),\n untyped: (node) => untypedTypes.has(node.type),\n}\n\n/** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */\nexport function is(node: SchemaNode, kind: SchemaKind, { follow = [] }: IsOptions = {}): boolean {\n // `path` holds the ref targets above `current`, so a cycle stops without hiding a target a sibling branch reaches.\n const test = (current: SchemaNode, path: ReadonlySet<SchemaNode>): boolean => {\n if (follow.includes('ref') && current.type === 'ref' && current.schema) {\n return !path.has(current.schema) && test(mergeSchema(current), new Set(path).add(current.schema))\n }\n const child = (next: SchemaNode) => test(next, path)\n return kinds[kind](current, child) || (follow.includes('array') && current.type === 'array' && (current.items ?? []).some(child))\n }\n\n return test(node, new Set())\n}\n","import { memo } from '@internals/utils'\nimport type { PropertyNode } from '../nodes/property.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Finds every matching property exposed by an object, resolved reference, or intersection.\n *\n * References are followed through their parsed `schema`. Circular references terminate without\n * revisiting a node. Unions are not traversed because a property on one branch does not describe\n * every branch.\n *\n * @example Faker discriminator narrowing\n * ```ts\n * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>\n * getSchemaLiteralValues(schema),\n * )\n * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`\n * ```\n *\n * @example Zod discriminated unions\n * ```ts\n * const canDiscriminate = union.members?.every(\n * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,\n * )\n * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`\n * ```\n *\n * @example TypeScript property lookup\n * ```ts\n * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })\n * const statusSchemas = properties.map((property) => print(property.schema))\n * ```\n */\nexport function resolveSchemaProperties({ node, propertyName }: { node: SchemaNode; propertyName: string }): ReadonlyArray<PropertyNode> {\n const properties: Array<PropertyNode> = []\n walkSchema(node, 'intersection', (current) => {\n if (current.type !== 'object') return\n const property = current.properties.find((candidate) => candidate.name === propertyName)\n if (property) properties.push(property)\n })\n return properties\n}\n\nfunction walkSchema(node: SchemaNode, through: 'union' | 'intersection', visit: (schema: SchemaNode) => void): void {\n const visited = new WeakSet<SchemaNode>()\n\n function walk(current: SchemaNode | null | undefined): void {\n if (!current || visited.has(current)) return\n visited.add(current)\n visit(current)\n\n if (current.type === 'ref') return walk(current.schema)\n if (current.type === through) for (const member of current.members ?? []) walk(member)\n }\n\n walk(node)\n}\n\n/**\n * Reads the unique literal values represented by an enum, resolved reference, or union.\n *\n * Named enum values take precedence over simple enum values, matching how renderers consume\n * `EnumSchemaNode`.\n *\n * @example\n * ```ts\n * const values = getSchemaLiteralValues(enumNode)\n * // ['cat', 'dog']\n * ```\n */\nexport function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue> {\n return memo(literalValues, node, () => {\n const values = new Set<LiteralValue>()\n walkSchema(node, 'union', (current) => {\n if (current.type !== 'enum') return\n for (const { value } of current.namedEnumValues ?? current.enumValues?.map((value) => ({ value })) ?? []) values.add(value)\n })\n return Object.freeze([...values])\n })\n}\n\ntype LiteralValue = string | number | boolean | null\n\n// Printers read an enum's values each time they print it.\nconst literalValues = memo.create<SchemaNode, ReadonlyArray<LiteralValue>>({ weak: true })\n\n// Names of every property an object, resolved reference, or intersection exposes.\nfunction collectPropertyNames(node: SchemaNode): Set<string> {\n const names = new Set<string>()\n walkSchema(node, 'intersection', (current) => {\n if (current.type === 'object') for (const property of current.properties) names.add(property.name)\n })\n return names\n}\n\n/**\n * Infers an implicit discriminator: a property every member exposes with a distinct single\n * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.\n */\nexport function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined {\n if (members.length < 2) return undefined\n\n let candidates: Set<string> | undefined\n for (const member of members) {\n const names = collectPropertyNames(member)\n candidates = candidates ? new Set([...candidates].filter((name) => names.has(name))) : names\n }\n\n for (const name of candidates ?? []) {\n const values = members.map((member) => {\n const literals = new Set(resolveSchemaProperties({ node: member, propertyName: name }).flatMap((property) => getSchemaLiteralValues(property.schema)))\n return literals.size === 1 ? [...literals][0] : undefined\n })\n\n if (values.every((value) => value !== undefined) && new Set(values).size === members.length) {\n return name\n }\n }\n\n return undefined\n}\n","export { applyOptionality } from '../optionality.ts'\nexport { schemaTypes as types } from '../constants.ts'\nexport { narrowSchema as narrow } from '../guards.ts'\nexport { findSchema as find } from '../visitor.ts'\nexport { getEmbeddedJson } from './embeddedJson.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { is } from './is.ts'\n\nexport { is } from './is.ts'\nexport type { IsOptions, SchemaFollow, SchemaKind } from './is.ts'\nexport {\n getSchemaLiteralValues as getLiterals,\n inferDiscriminatorPropertyName as inferDiscriminator,\n resolveSchemaProperties as findProperties,\n} from '../utils/schemaProperties.ts'\n\n/** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */\nexport function isString(node: SchemaNode): boolean {\n return is(node, 'string')\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,mCAAmB,IAAI,IAAgB;CAAC;CAAU;CAAQ;CAAS;CAAO;AAAU,CAAC;AAC3F,MAAM,8BAAc,IAAI,IAAgB;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MAAM,+BAAe,IAAI,IAAgB;CAAC;CAAQ;CAAO;AAAS,CAAC;AAEnE,MAAM,QAAiG;CACrG,SAAS,SAAS,KAAK,SAAS;CAChC,SAAS,SAAS;EAChB,IAAI,iBAAiB,IAAI,KAAK,IAAI,GAAG,OAAO;EAC5C,MAAM,WAAWA,eAAAA,aAAa,MAAM,MAAM,KAAKA,eAAAA,aAAa,MAAM,MAAM;EACxE,OAAO,WAAW,SAAS,mBAAmB,SAAS;CACzD;CACA,OAAO,SAAS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;CAEA,KAAK,MAAM,QAAQ,cAAc,CAAC,GAAG;EACnC,MAAM,SAAS,QAAQ,KAAK,WAAW;GACrC,MAAM,WAAW,IAAI,IAAI,wBAAwB;IAAE,MAAM;IAAQ,cAAc;GAAK,CAAC,CAAC,CAAC,SAAS,aAAa,uBAAuB,SAAS,MAAM,CAAC,CAAC;GACrJ,OAAO,SAAS,SAAS,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,KAAA;EAClD,CAAC;EAED,IAAI,OAAO,OAAO,UAAU,UAAU,KAAA,CAAS,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,QAAQ,QACnF,OAAO;CAEX;AAGF;;;;;;;;;;;;;;;ACvGA,SAAgB,SAAS,MAA2B;CAClD,OAAO,GAAG,MAAM,QAAQ;AAC1B"}
1
+ {"version":3,"file":"schema-DuCY4lCG.cjs","names":["narrowSchema","mergeSchema","memo"],"sources":["../src/schema/is.ts","../src/utils/schemaProperties.ts","../src/schema/index.ts"],"sourcesContent":["import { narrowSchema } from '../guards.ts'\nimport type { SchemaNode, SchemaType } from '../nodes/schema.ts'\nimport { mergeSchema } from '../ref/index.ts'\n\n/** `string` prints as a plain `string`, `text` is a non-blob string primitive, `const` a one-value enum, `enumLike` an enum or union of them, `untyped` is `void`, `any` or `unknown`. */\nexport type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped'\n\n/** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */\nexport type SchemaFollow = 'ref' | 'array'\n\nexport type IsOptions = {\n /** Links to look through. Following repeats and stops on a ref cycle. */\n follow?: ReadonlyArray<SchemaFollow>\n}\n\nconst plainStringTypes = new Set<SchemaType>(['string', 'uuid', 'email', 'url', 'datetime'])\nconst scalarTypes = new Set<SchemaType>([\n 'string',\n 'email',\n 'url',\n 'uuid',\n 'number',\n 'integer',\n 'bigint',\n 'boolean',\n 'date',\n 'time',\n 'datetime',\n 'blob',\n 'enum',\n])\nconst untypedTypes = new Set<SchemaType>(['void', 'any', 'unknown'])\n\nconst kinds: Record<SchemaKind, (node: SchemaNode, test: (child: SchemaNode) => boolean) => boolean> = {\n binary: (node) => node.type === 'blob',\n string: (node) => {\n if (plainStringTypes.has(node.type)) return true\n const temporal = narrowSchema(node, 'date') ?? narrowSchema(node, 'time')\n return temporal ? temporal.representation !== 'date' : false\n },\n text: (node) => node.type !== 'blob' && node.primitive === 'string',\n scalar: (node) => scalarTypes.has(node.type),\n const: (node) => node.type === 'enum' && (node.namedEnumValues ?? node.enumValues ?? []).length === 1,\n enumLike: (node, test) => node.type === 'enum' || (node.type === 'union' && !!node.members?.length && node.members.every(test)),\n untyped: (node) => untypedTypes.has(node.type),\n}\n\n/** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */\nexport function is(node: SchemaNode, kind: SchemaKind, { follow = [] }: IsOptions = {}): boolean {\n // `path` holds the ref targets above `current`, so a cycle stops without hiding a target a sibling branch reaches.\n const test = (current: SchemaNode, path: ReadonlySet<SchemaNode>): boolean => {\n if (follow.includes('ref') && current.type === 'ref' && current.schema) {\n return !path.has(current.schema) && test(mergeSchema(current), new Set(path).add(current.schema))\n }\n const child = (next: SchemaNode) => test(next, path)\n return kinds[kind](current, child) || (follow.includes('array') && current.type === 'array' && (current.items ?? []).some(child))\n }\n\n return test(node, new Set())\n}\n","import { memo } from '@internals/utils'\nimport type { PropertyNode } from '../nodes/property.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\n\n/**\n * Finds every matching property exposed by an object, resolved reference, or intersection.\n *\n * References are followed through their parsed `schema`. Circular references terminate without\n * revisiting a node. Unions are not traversed because a property on one branch does not describe\n * every branch.\n *\n * @example Faker discriminator narrowing\n * ```ts\n * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>\n * getSchemaLiteralValues(schema),\n * )\n * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`\n * ```\n *\n * @example Zod discriminated unions\n * ```ts\n * const canDiscriminate = union.members?.every(\n * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,\n * )\n * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`\n * ```\n *\n * @example TypeScript property lookup\n * ```ts\n * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })\n * const statusSchemas = properties.map((property) => print(property.schema))\n * ```\n */\nexport function resolveSchemaProperties({ node, propertyName }: { node: SchemaNode; propertyName: string }): ReadonlyArray<PropertyNode> {\n const properties: Array<PropertyNode> = []\n walkSchema(node, 'intersection', (current) => {\n if (current.type !== 'object') return\n const property = current.properties.find((candidate) => candidate.name === propertyName)\n if (property) properties.push(property)\n })\n return properties\n}\n\nfunction walkSchema(node: SchemaNode, through: 'union' | 'intersection', visit: (schema: SchemaNode) => void): void {\n const visited = new WeakSet<SchemaNode>()\n\n function walk(current: SchemaNode | null | undefined): void {\n if (!current || visited.has(current)) return\n visited.add(current)\n visit(current)\n\n if (current.type === 'ref') return walk(current.schema)\n if (current.type === through) for (const member of current.members ?? []) walk(member)\n }\n\n walk(node)\n}\n\n/**\n * Reads the unique literal values represented by an enum, resolved reference, or union.\n *\n * Named enum values take precedence over simple enum values, matching how renderers consume\n * `EnumSchemaNode`.\n *\n * @example\n * ```ts\n * const values = getSchemaLiteralValues(enumNode)\n * // ['cat', 'dog']\n * ```\n */\nexport function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue> {\n return memo(literalValues, node, () => {\n const values = new Set<LiteralValue>()\n walkSchema(node, 'union', (current) => {\n if (current.type !== 'enum') return\n for (const { value } of current.namedEnumValues ?? current.enumValues?.map((value) => ({ value })) ?? []) values.add(value)\n })\n return Object.freeze([...values])\n })\n}\n\ntype LiteralValue = string | number | boolean | null\n\n// Printers read an enum's values each time they print it.\nconst literalValues = memo.create<SchemaNode, ReadonlyArray<LiteralValue>>({ weak: true })\n\n// Names of every property an object, resolved reference, or intersection exposes.\nfunction collectPropertyNames(node: SchemaNode): Set<string> {\n const names = new Set<string>()\n walkSchema(node, 'intersection', (current) => {\n if (current.type === 'object') for (const property of current.properties) names.add(property.name)\n })\n return names\n}\n\n/**\n * Infers an implicit discriminator: a property every member exposes with a distinct single\n * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.\n */\nexport function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined {\n if (members.length < 2) return undefined\n\n let candidates: Set<string> | undefined\n for (const member of members) {\n const names = collectPropertyNames(member)\n candidates = candidates ? new Set([...candidates].filter((name) => names.has(name))) : names\n }\n\n for (const name of candidates ?? []) {\n const values = members.map((member) => {\n const literals = new Set(resolveSchemaProperties({ node: member, propertyName: name }).flatMap((property) => getSchemaLiteralValues(property.schema)))\n return literals.size === 1 ? [...literals][0] : undefined\n })\n\n if (values.every((value) => value !== undefined) && new Set(values).size === members.length) {\n return name\n }\n }\n\n return undefined\n}\n","export { applyOptionality } from '../optionality.ts'\nexport { schemaTypes as types } from '../constants.ts'\nexport { narrowSchema as narrow } from '../guards.ts'\nexport { findSchema as find } from '../visitor.ts'\nexport { getEmbeddedJson } from './embeddedJson.ts'\nimport type { SchemaNode } from '../nodes/schema.ts'\nimport { is } from './is.ts'\n\nexport { is } from './is.ts'\nexport type { IsOptions, SchemaFollow, SchemaKind } from './is.ts'\nexport {\n getSchemaLiteralValues as getLiterals,\n inferDiscriminatorPropertyName as inferDiscriminator,\n resolveSchemaProperties as findProperties,\n} from '../utils/schemaProperties.ts'\n\n/** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */\nexport function isString(node: SchemaNode): boolean {\n return is(node, 'string')\n}\n"],"mappings":";;;;;;;;AAeA,MAAM,mCAAmB,IAAI,IAAgB;CAAC;CAAU;CAAQ;CAAS;CAAO;AAAU,CAAC;AAC3F,MAAM,8BAAc,IAAI,IAAgB;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AACD,MA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AI,SAAS,IAAI;CACnG,CAAC;CACD,OAAO;AACT;;;;;AAMA,SAAgB,+BAA+B,SAAwD;CACrG,IAAI,QAAQ,SAAS,GAAG,OAAO,KAAA;CAE/B,IAAI;CACJ,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ,qBAAqB,MAAM;EACzC,aAAa,aAAa,IAAI,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,QAAQ,SAAS,MAAM,IAAI,IAAI,CAAC,CAAC,IAAI;CACzF;CAEA,KAAK,MAAM,QAAQ,cAAc,CAAC,GAAG;EACnC,MAAM,SAAS,QAAQ,KAAK,WAAW;GACrC,MAAM,WAAW,IAAI,IAAI,wBAAwB;IAAE,MAAM;IAAQ,cAAc;GAAK,CAAC,CAAC,CAAC,SAAS,aAAa,uBAAuB,SAAS,MAAM,CAAC,CAAC;GACrJ,OAAO,SAAS,SAAS,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,KAAA;EAClD,CAAC;EAED,IAAI,OAAO,OAAO,UAAU,UAAU,KAAA,CAAS,KAAK,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,QAAQ,QACnF,OAAO;CAEX;AAGF;;;;;;;;;;;;;;;ACvGA,SAAgB,SAAS,MAA2B;CAClD,OAAO,GAAG,MAAM,QAAQ;AAC1B"}
@@ -1,5 +1,5 @@
1
1
  require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_constants = require("./constants-CquR083U.cjs");
2
+ const require_constants = require("./constants-DztHlVmY.cjs");
3
3
  // src/nodes/schema.ts
4
4
  /**
5
5
  * Maps schema `type` to its underlying `primitive`.
@@ -46,4 +46,4 @@ Object.defineProperty(exports, "createSchema", {
46
46
  }
47
47
  });
48
48
 
49
- //# sourceMappingURL=schema-hxMlgCrV.cjs.map
49
+ //# sourceMappingURL=schema-gSjYgaCl.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-hxMlgCrV.cjs","names":["nodeKinds"],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;AACtF"}
1
+ {"version":3,"file":"schema-gSjYgaCl.cjs","names":["nodeKinds"],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAMA,kBAAAA,UAAU;CAAO;AACtF"}
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-BYyVTPww.js";
2
- import { t as nodeKinds } from "./constants-Ckeonm-D.js";
2
+ import { t as nodeKinds } from "./constants-BTTus9ee.js";
3
3
  // src/nodes/schema.ts
4
4
  /**
5
5
  * Maps schema `type` to its underlying `primitive`.
@@ -41,4 +41,4 @@ function createSchema(props) {
41
41
  }
42
42
  export { createSchema as t };
43
43
 
44
- //# sourceMappingURL=schema-2ZAQk7qE.js.map
44
+ //# sourceMappingURL=schema-tH14gE6i.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-2ZAQk7qE.js","names":[],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAM,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAM,UAAU;CAAO;AACtF"}
1
+ {"version":3,"file":"schema-tH14gE6i.js","names":[],"sources":["../src/nodes/schema.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { BaseNode, DistributiveOmit } from './base.ts'\nimport type { ExternalDocs } from './input.ts'\nimport type { PropertyNode } from './property.ts'\n\n/**\n * Subset of {@link SchemaType} covering the primitives plus `object`, `array`, and `date`; `schemaTypes` documents each.\n */\nexport type PrimitiveSchemaType =\n | 'string'\n | 'number'\n | 'integer'\n | 'bigint'\n | 'boolean'\n | 'null'\n | 'any'\n | 'unknown'\n | 'void'\n | 'never'\n | 'object'\n | 'array'\n | 'date'\n\n/**\n * All schema type strings, one per key of {@link SchemaNodeByType}.\n */\nexport type SchemaType = keyof SchemaNodeByType\n\n/**\n * Scalar schema types without extra object/array/ref structure or constraints.\n */\nexport type ScalarSchemaType = 'boolean' | 'null' | 'any' | 'unknown' | 'void' | 'never' | 'blob' | 'ipv4' | 'ipv6'\n\n/**\n * Fields shared by all schema nodes.\n */\ntype SchemaNodeBase = BaseNode & {\n /**\n * Node kind.\n */\n kind: 'Schema'\n /**\n * Schema name for named definitions (for example, `\"Pet\"`).\n * Inline schemas omit this field.\n * `null` means Kubb has processed this and determined there is no applicable name.\n * `undefined` means the name has not been set yet.\n */\n name?: string | null\n /**\n * Short schema title.\n */\n title?: string\n /**\n * Schema description text.\n */\n description?: string\n /**\n * Whether `null` is allowed.\n */\n nullable?: boolean\n /**\n * Whether the field is optional.\n */\n optional?: boolean\n /**\n * Both optional and nullable (`optional` + `nullable`).\n */\n nullish?: boolean\n /**\n * Whether the schema is deprecated.\n */\n deprecated?: boolean\n /**\n * Whether the schema is read-only.\n */\n readOnly?: boolean\n /**\n * Whether the schema is write-only.\n */\n writeOnly?: boolean\n /**\n * Default value.\n */\n default?: unknown\n /**\n * Example values from an `examples` array.\n */\n examples?: Array<unknown>\n /**\n * Base primitive type.\n * For example, this is `'string'` for a `uuid` schema.\n */\n primitive?: PrimitiveSchemaType\n /**\n * Schema `format` value.\n */\n format?: string\n externalDocs?: ExternalDocs\n /**\n * `if`/`then`/`else`, `dependentRequired` and `dependentSchemas`. A required `unknown` property in `if` means \"key is present\".\n * Visitors do not walk it.\n */\n conditionals?: Array<{ if: SchemaNode; then?: SchemaNode; else?: SchemaNode }>\n}\n\n/**\n * Object schema with ordered properties.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * properties: [],\n * }\n * ```\n */\nexport type ObjectSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'object'\n /**\n * Primitive type, always `'object'` for object schemas.\n */\n primitive: 'object'\n /**\n * Ordered object properties.\n */\n properties: Array<PropertyNode>\n /**\n * Additional object properties behavior:\n * - `true`: allow any value\n * - `false`: reject unknown properties\n * - `SchemaNode`: allow values that match that schema\n * - `undefined`: no additional properties constraint (open object)\n */\n additionalProperties?: SchemaNode | boolean\n /**\n * Pattern-based property schemas.\n */\n patternProperties?: Record<string, SchemaNode>\n /**\n * Schema that each property name must match.\n *\n * @example\n * ```ts\n * const objectSchema: ObjectSchemaNode = {\n * kind: 'Schema',\n * type: 'object',\n * primitive: 'object',\n * properties: [],\n * propertyNames: { kind: 'Schema', type: 'string', primitive: 'string', pattern: '^[a-z]+$' },\n * }\n * ```\n */\n propertyNames?: SchemaNode\n /**\n * Minimum number of properties allowed.\n */\n min?: number\n /**\n * Maximum number of properties allowed.\n */\n max?: number\n /**\n * @deprecated Use `min`. Removed in Kubb v6.\n */\n minProperties?: number\n /**\n * @deprecated Use `max`. Removed in Kubb v6.\n */\n maxProperties?: number\n}\n\n/**\n * Array-like schema (`array` or `tuple`).\n *\n * @example\n * ```ts\n * const arraySchema: ArraySchemaNode = {\n * kind: 'Schema',\n * type: 'array',\n * items: [],\n * }\n * ```\n */\nexport type ArraySchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator (`array` or `tuple`).\n */\n type: 'array' | 'tuple'\n /**\n * Item schemas.\n */\n items?: Array<SchemaNode>\n /**\n * Tuple rest-item schema for elements beyond positional `items`.\n */\n rest?: SchemaNode\n /**\n * Minimum item count (or tuple length).\n */\n min?: number\n /**\n * Maximum item count (or tuple length).\n */\n max?: number\n /**\n * Whether all items must be unique.\n */\n unique?: boolean\n /**\n * At least `min` (default 1) and at most `max` items match `schema`. Visitors do not walk `schema`.\n */\n contains?: { schema: SchemaNode; min?: number; max?: number }\n}\n\n/**\n * Shared shape for union and intersection schemas.\n */\ntype CompositeSchemaNodeBase = SchemaNodeBase & {\n /**\n * Member schemas.\n */\n members?: Array<SchemaNode>\n}\n\n/**\n * Union schema, often from `oneOf` or `anyOf`.\n *\n * @example\n * ```ts\n * const unionSchema: UnionSchemaNode = {\n * kind: 'Schema',\n * type: 'union',\n * members: [],\n * }\n * ```\n */\nexport type UnionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'union'\n /**\n * Discriminator property name for a polymorphic union.\n */\n discriminatorPropertyName?: string\n /**\n * How many union members must be valid.\n * - `'one'`: exactly one member, from `oneOf`\n * - `'any'`: any number of members, from `anyOf`\n */\n strategy?: 'one' | 'any'\n}\n\n/**\n * Intersection schema, often from `allOf`.\n *\n * @example\n * ```ts\n * const intersectionSchema: IntersectionSchemaNode = {\n * kind: 'Schema',\n * type: 'intersection',\n * members: [],\n * }\n * ```\n */\nexport type IntersectionSchemaNode = CompositeSchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'intersection'\n}\n\n/** Negation from `not`: the value must not match its single member. Printers that cannot express it return `null`. */\nexport type NotSchemaNode = CompositeSchemaNodeBase & {\n /** Schema type discriminator. */\n type: 'not'\n}\n\n/**\n * One named enum item.\n */\ntype EnumValueNode = {\n /**\n * Enum item name.\n */\n name: string\n /**\n * Enum item value.\n */\n value: string | number | boolean\n /**\n * Primitive type of the enum value.\n */\n primitive: Extract<PrimitiveSchemaType, 'string' | 'number' | 'boolean'>\n /**\n * Label for the enum item, taken from the `x-enumDescriptions` or\n * `x-enum-descriptions` vendor extension. A printer can render it as\n * a comment on the matching enum member.\n */\n description?: string\n}\n\n/**\n * Enum schema node.\n *\n * @example\n * ```ts\n * const enumSchema: EnumSchemaNode = {\n * kind: 'Schema',\n * type: 'enum',\n * enumValues: ['a', 'b'],\n * }\n * ```\n */\nexport type EnumSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'enum'\n /**\n * Enum values in simple form.\n */\n enumValues?: Array<string | number | boolean | null>\n /**\n * Enum values in named form.\n * If present, this is used instead of `enumValues`.\n */\n namedEnumValues?: Array<EnumValueNode>\n}\n\n/**\n * Reference schema that points to another schema definition.\n *\n * @example\n * ```ts\n * const refSchema: RefSchemaNode = {\n * kind: 'Schema',\n * type: 'ref',\n * ref: '#/components/schemas/Pet',\n * }\n * ```\n */\nexport type RefSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'ref'\n /**\n * Referenced schema name.\n * `null` means Kubb has processed this and determined there is no applicable name.\n */\n name?: string | null\n /**\n * Original `$ref` path, for example, `#/components/schemas/Order`.\n * Used to resolve names later.\n */\n ref?: string\n /**\n * Emitted name of the referenced schema when it differs from the pointer's last segment,\n * for example after a collision rename (`Order` becomes `OrderSchema`) or a macro rename.\n * Resolve display and import names through `ast.ref.getName`, which prefers this field and\n * falls back to the pointer segment, then `name`.\n */\n targetName?: string\n /**\n * Pattern copied from a sibling `pattern` field.\n */\n pattern?: string\n /**\n * The fully-parsed schema this ref resolves to, so its structure (`primitive`, `properties`)\n * can be read without following the reference. Populated during parsing when the\n * definition resolves, `null` when it can't or the ref is circular, and `undefined` when\n * resolution has not been attempted.\n */\n schema?: SchemaNode | null\n}\n\n/**\n * Datetime schema.\n *\n * @example\n * ```ts\n * const datetimeSchema: DatetimeSchemaNode = { kind: 'Schema', type: 'datetime' }\n * ```\n */\nexport type DatetimeSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'datetime'\n /**\n * Whether the datetime includes a timezone offset (`dateType: 'stringOffset'`).\n */\n offset?: boolean\n /**\n * Whether the datetime is local (no timezone, `dateType: 'stringLocal'`).\n */\n local?: boolean\n}\n\n/**\n * Shared base for `date` and `time` schemas.\n */\ntype TemporalSchemaNodeBase<T extends 'date' | 'time'> = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: T\n /**\n * Output representation in generated code.\n */\n representation: 'date' | 'string'\n}\n\n/**\n * Date schema node.\n *\n * @example\n * ```ts\n * const dateSchema: DateSchemaNode = { kind: 'Schema', type: 'date', representation: 'string' }\n * ```\n */\nexport type DateSchemaNode = TemporalSchemaNodeBase<'date'>\n\n/**\n * Time schema node.\n *\n * @example\n * ```ts\n * const timeSchema: TimeSchemaNode = { kind: 'Schema', type: 'time', representation: 'string' }\n * ```\n */\nexport type TimeSchemaNode = TemporalSchemaNodeBase<'time'>\n\n/**\n * String schema node.\n *\n * @example\n * ```ts\n * const stringSchema: StringSchemaNode = { kind: 'Schema', type: 'string' }\n * ```\n */\nexport type StringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'string'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n /**\n * Regex pattern.\n */\n pattern?: string\n /**\n * The value the string encodes, such as a JSON document or `base64` bytes. Visitors do not walk `schema`.\n */\n content?: {\n mediaType?: string\n encoding?: string\n schema?: SchemaNode\n }\n}\n\n/**\n * Numeric schema (`number`, `integer`, or `bigint`).\n *\n * @example\n * ```ts\n * const numberSchema: NumberSchemaNode = { kind: 'Schema', type: 'number' }\n * ```\n */\nexport type NumberSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'number' | 'integer' | 'bigint'\n /**\n * Minimum value.\n */\n min?: number\n /**\n * Maximum value.\n */\n max?: number\n /**\n * Bounds the value may not equal: it must be greater than `min` and less than `max`.\n */\n exclusive?: { min?: number; max?: number }\n /**\n * @deprecated Use `exclusive.min`. Removed in Kubb v6.\n */\n exclusiveMinimum?: number\n /**\n * @deprecated Use `exclusive.max`. Removed in Kubb v6.\n */\n exclusiveMaximum?: number\n /**\n * The value must be a multiple of this number.\n */\n multipleOf?: number\n}\n\n/**\n * Scalar schema with no extra constraints.\n *\n * @example\n * ```ts\n * const anySchema: ScalarSchemaNode = { kind: 'Schema', type: 'any' }\n * ```\n */\nexport type ScalarSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: ScalarSchemaType\n}\n\n/**\n * URL schema node.\n * Can include a path template for template literal types.\n *\n * @example\n * ```ts\n * const urlSchema: UrlSchemaNode = { kind: 'Schema', type: 'url', path: '/pets/{petId}' }\n * ```\n */\nexport type UrlSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'url'\n /**\n * Path template, for example, `'/pets/{petId}'`.\n */\n path?: string\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Format-string schema for string-based formats that support length constraints.\n *\n * @example\n * ```ts\n * const uuidSchema: FormatStringSchemaNode = { kind: 'Schema', type: 'uuid', min: 36, max: 36 }\n * ```\n */\ntype FormatStringSchemaNode = SchemaNodeBase & {\n /**\n * Schema type discriminator.\n */\n type: 'uuid' | 'email'\n /**\n * Minimum string length.\n */\n min?: number\n /**\n * Maximum string length.\n */\n max?: number\n}\n\n/**\n * Mapping from schema type literals to concrete schema node types.\n * Used by `narrowSchema`.\n */\nexport type SchemaNodeByType = {\n object: ObjectSchemaNode\n array: ArraySchemaNode\n tuple: ArraySchemaNode\n union: UnionSchemaNode\n intersection: IntersectionSchemaNode\n not: NotSchemaNode\n enum: EnumSchemaNode\n ref: RefSchemaNode\n datetime: DatetimeSchemaNode\n date: DateSchemaNode\n time: TimeSchemaNode\n string: StringSchemaNode\n number: NumberSchemaNode\n integer: NumberSchemaNode\n bigint: NumberSchemaNode\n boolean: ScalarSchemaNode\n null: ScalarSchemaNode\n any: ScalarSchemaNode\n unknown: ScalarSchemaNode\n void: ScalarSchemaNode\n never: ScalarSchemaNode\n uuid: FormatStringSchemaNode\n email: FormatStringSchemaNode\n url: UrlSchemaNode\n ipv4: ScalarSchemaNode\n ipv6: ScalarSchemaNode\n blob: ScalarSchemaNode\n}\n\n/**\n * Union of all schema node types.\n */\nexport type SchemaNode =\n | ObjectSchemaNode\n | ArraySchemaNode\n | UnionSchemaNode\n | IntersectionSchemaNode\n | NotSchemaNode\n | EnumSchemaNode\n | RefSchemaNode\n | DatetimeSchemaNode\n | DateSchemaNode\n | TimeSchemaNode\n | StringSchemaNode\n | NumberSchemaNode\n | UrlSchemaNode\n | FormatStringSchemaNode\n | ScalarSchemaNode\n\ntype CreateSchemaObjectInput = Omit<ObjectSchemaNode, 'kind' | 'properties' | 'primitive'> & { properties?: Array<PropertyNode>; primitive?: 'object' }\ntype CreateSchemaInput = CreateSchemaObjectInput | DistributiveOmit<Exclude<SchemaNode, ObjectSchemaNode>, 'kind'>\ntype CreateSchemaOutput<T extends CreateSchemaInput> = SchemaNodeByType[T['type']] & { kind: 'Schema' }\n\n/**\n * Maps schema `type` to its underlying `primitive`.\n * Primitive types map to themselves and special string formats map to `'string'`.\n * Any type not listed here (such as `ref`, `enum`, `union`, `intersection`, `not`, `tuple`, `ipv4`, `ipv6`, `blob`) has no `primitive`.\n */\nconst TYPE_TO_PRIMITIVE: Partial<Record<SchemaNode['type'], PrimitiveSchemaType>> = {\n string: 'string',\n number: 'number',\n integer: 'integer',\n bigint: 'bigint',\n boolean: 'boolean',\n null: 'null',\n any: 'any',\n unknown: 'unknown',\n void: 'void',\n never: 'never',\n object: 'object',\n array: 'array',\n date: 'date',\n uuid: 'string',\n email: 'string',\n url: 'string',\n datetime: 'string',\n time: 'string',\n}\n\n/**\n * Creates a `SchemaNode`, narrowed to the variant of `props.type`. Object schemas default\n * `properties` to an empty array, and `primitive` is inferred from `type` when not explicitly provided.\n *\n * @example\n * ```ts\n * const scalar = createSchema({ type: 'string' })\n * // { kind: 'Schema', type: 'string', primitive: 'string' }\n * ```\n *\n * @example\n * ```ts\n * const object = createSchema({ type: 'object' })\n * // { kind: 'Schema', type: 'object', primitive: 'object', properties: [] }\n * ```\n */\nexport function createSchema<T extends CreateSchemaInput>(props: T): CreateSchemaOutput<T>\nexport function createSchema(props: CreateSchemaInput): SchemaNode\nexport function createSchema(props: CreateSchemaInput): SchemaNode {\n if (props.type === 'object') {\n return { properties: [], primitive: 'object', ...props, kind: nodeKinds.schema }\n }\n\n return { primitive: TYPE_TO_PRIMITIVE[props.type], ...props, kind: nodeKinds.schema }\n}\n"],"mappings":";;;;;;;;AAioBA,MAAM,oBAA8E;CAClF,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,MAAM;CACN,KAAK;CACL,SAAS;CACT,MAAM;CACN,OAAO;CACP,QAAQ;CACR,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACP,KAAK;CACL,UAAU;CACV,MAAM;AACR;AAoBA,SAAgB,aAAa,OAAsC;CACjE,IAAI,MAAM,SAAS,UACjB,OAAO;EAAE,YAAY,CAAC;EAAG,WAAW;EAAU,GAAG;EAAO,MAAM,UAAU;CAAO;CAGjF,OAAO;EAAE,WAAW,kBAAkB,MAAM;EAAO,GAAG;EAAO,MAAM,UAAU;CAAO;AACtF"}
package/dist/schema.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_constants = require("./constants-CquR083U.cjs");
3
- const require_visitor = require("./visitor-DTrzvA3R.cjs");
4
- const require_guards = require("./guards-COVJE6TU.cjs");
5
- const require_optionality = require("./optionality-D-zqzVMH.cjs");
6
- const require_schema = require("./schema-BIErWqgc.cjs");
2
+ const require_constants = require("./constants-DztHlVmY.cjs");
3
+ const require_visitor = require("./visitor-Bh1CBAOz.cjs");
4
+ const require_guards = require("./guards-4drgx10i.cjs");
5
+ const require_optionality = require("./optionality-C-qULYxo.cjs");
6
+ const require_schema = require("./schema-DuCY4lCG.cjs");
7
7
  exports.applyOptionality = require_optionality.applyOptionality;
8
8
  exports.find = require_visitor.findSchema;
9
9
  exports.findProperties = require_schema.resolveSchemaProperties;
package/dist/schema.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as schemaTypes } from "./base-IpYuh3ZP.cjs";
2
- import { n as narrowSchema } from "./guards-B8qDgSaT.cjs";
3
- import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-C-vhkzwR.cjs";
4
- import { a as findSchema } from "./visitor-Bw_opzjF.cjs";
1
+ import { a as schemaTypes } from "./base-UFBZi-FO.cjs";
2
+ import { n as narrowSchema } from "./guards-COBkDtgu.cjs";
3
+ import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-dgiKWRpD.cjs";
4
+ import { o as findSchema } from "./visitor-DxhkIQyP.cjs";
5
5
  export { type IsOptions, type SchemaFollow, type SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as schemaTypes } from "./base-IpYuh3ZP.js";
2
- import { n as narrowSchema } from "./guards-D-h9R_sV.js";
3
- import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-DNiIem0x.js";
4
- import { a as findSchema } from "./visitor-BZozlXBF.js";
1
+ import { a as schemaTypes } from "./base-LhsPvVY1.js";
2
+ import { n as narrowSchema } from "./guards-C6w6KQSY.js";
3
+ import { a as resolveSchemaProperties, c as SchemaKind, d as applyOptionality, i as inferDiscriminatorPropertyName, l as is, n as isString, o as IsOptions, r as getSchemaLiteralValues, s as SchemaFollow, u as getEmbeddedJson } from "./index-9l1xMEl_.js";
4
+ import { o as findSchema } from "./visitor-CFbuH7BY.js";
5
5
  export { type IsOptions, type SchemaFollow, type SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
package/dist/schema.js CHANGED
@@ -1,6 +1,6 @@
1
- import { n as schemaTypes } from "./constants-Ckeonm-D.js";
2
- import { n as findSchema, o as getEmbeddedJson } from "./visitor-NoQSUQTu.js";
3
- import { n as narrowSchema } from "./guards-DlJkKsT1.js";
4
- import { t as applyOptionality } from "./optionality-DISn8ytP.js";
5
- import { a as resolveSchemaProperties, i as inferDiscriminatorPropertyName, o as is, r as getSchemaLiteralValues, t as isString } from "./schema-DloctnMm.js";
1
+ import { n as schemaTypes } from "./constants-BTTus9ee.js";
2
+ import { n as findSchema, o as getEmbeddedJson } from "./visitor-XA0W3OVv.js";
3
+ import { n as narrowSchema } from "./guards-DKw4uwc5.js";
4
+ import { t as applyOptionality } from "./optionality-FkRredTC.js";
5
+ import { a as resolveSchemaProperties, i as inferDiscriminatorPropertyName, o as is, r as getSchemaLiteralValues, t as isString } from "./schema-4UcdIPQ2.js";
6
6
  export { applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
@@ -1,6 +1,6 @@
1
1
  require("./rolldown-runtime-BV8xUvPy.cjs");
2
- const require_constants = require("./constants-CquR083U.cjs");
3
- const require_mediaType = require("./mediaType-D8uIO8sG.cjs");
2
+ const require_constants = require("./constants-DztHlVmY.cjs");
3
+ const require_mediaType = require("./mediaType-BbIfudh0.cjs");
4
4
  // src/schema/embeddedJson.ts
5
5
  /** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */
6
6
  function getEmbeddedJson({ content }) {
@@ -223,8 +223,7 @@ function findSchema(node, { predicate, follow, followRefs = false, cache }) {
223
223
  function applyVisitor(node, visitor, parent) {
224
224
  const key = VISITOR_KEY_BY_KIND[node.kind];
225
225
  if (!key) return void 0;
226
- const fn = visitor[key];
227
- return fn?.(node, { parent });
226
+ return (0, visitor[key])?.(node, { parent });
228
227
  }
229
228
  /**
230
229
  * Synchronous depth-first transform. Each visitor callback can return a
@@ -379,4 +378,4 @@ Object.defineProperty(exports, "visitorKeys", {
379
378
  }
380
379
  });
381
380
 
382
- //# sourceMappingURL=visitor-DTrzvA3R.cjs.map
381
+ //# sourceMappingURL=visitor-Bh1CBAOz.cjs.map