@kubb/ast 5.22.0 → 5.23.0

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 (155) hide show
  1. package/dist/base-IpYuh3ZP.d.cts +173 -0
  2. package/dist/base-IpYuh3ZP.d.ts +173 -0
  3. package/dist/constants-Ckeonm-D.js +141 -0
  4. package/dist/constants-Ckeonm-D.js.map +1 -0
  5. package/dist/constants-CquR083U.cjs +152 -0
  6. package/dist/constants-CquR083U.cjs.map +1 -0
  7. package/dist/factory.cjs +23 -0
  8. package/dist/factory.d.cts +4 -0
  9. package/dist/factory.d.ts +4 -0
  10. package/dist/factory.js +4 -0
  11. package/dist/file-BVqSiSvV.d.cts +624 -0
  12. package/dist/file-Cg0T6cgz.cjs +319 -0
  13. package/dist/file-Cg0T6cgz.cjs.map +1 -0
  14. package/dist/file-CnuL8oUj.js +283 -0
  15. package/dist/file-CnuL8oUj.js.map +1 -0
  16. package/dist/file-CvlMAp_d.js +131 -0
  17. package/dist/file-CvlMAp_d.js.map +1 -0
  18. package/dist/file-Dd50jPkH.cjs +142 -0
  19. package/dist/file-Dd50jPkH.cjs.map +1 -0
  20. package/dist/file-xJnBQPGq.d.ts +624 -0
  21. package/dist/file.cjs +3 -0
  22. package/dist/file.d.cts +2 -0
  23. package/dist/file.d.ts +2 -0
  24. package/dist/file.js +1 -0
  25. package/dist/graph-BcwFCvei.js +144 -0
  26. package/dist/graph-BcwFCvei.js.map +1 -0
  27. package/dist/graph-DcIY6tQb.cjs +173 -0
  28. package/dist/graph-DcIY6tQb.cjs.map +1 -0
  29. package/dist/graph.cjs +6 -0
  30. package/dist/graph.d.cts +2 -0
  31. package/dist/graph.d.ts +2 -0
  32. package/dist/graph.js +1 -0
  33. package/dist/guards-B8qDgSaT.d.cts +23 -0
  34. package/dist/guards-COVJE6TU.cjs +41 -0
  35. package/dist/guards-COVJE6TU.cjs.map +1 -0
  36. package/dist/guards-D-h9R_sV.d.ts +23 -0
  37. package/dist/guards-DlJkKsT1.js +30 -0
  38. package/dist/guards-DlJkKsT1.js.map +1 -0
  39. package/dist/http-Bm5lhVK4.cjs +12 -0
  40. package/dist/http-Bm5lhVK4.cjs.map +1 -0
  41. package/dist/http-DwboM6pK.js +7 -0
  42. package/dist/http-DwboM6pK.js.map +1 -0
  43. package/dist/http.cjs +4 -0
  44. package/dist/http.d.cts +3 -0
  45. package/dist/http.d.ts +3 -0
  46. package/dist/http.js +2 -0
  47. package/dist/index-BWd95onW.d.cts +5 -0
  48. package/dist/index-Bb1kqq8H.d.cts +20 -0
  49. package/dist/index-BngGJux5.d.cts +12 -0
  50. package/dist/index-BwnMIoLl.d.ts +24 -0
  51. package/dist/index-C-vhkzwR.d.cts +79 -0
  52. package/dist/index-CAGuKv6t.d.ts +74 -0
  53. package/dist/index-CFH4ZC7q.d.ts +44 -0
  54. package/dist/index-CIqwy4EE.d.cts +74 -0
  55. package/dist/index-Cc2K3OzU.d.cts +11 -0
  56. package/dist/index-Cc2K3OzU.d.ts +11 -0
  57. package/dist/index-Csf8xsCc.d.cts +46 -0
  58. package/dist/index-D3M2spDR.d.ts +12 -0
  59. package/dist/index-DNiIem0x.d.ts +79 -0
  60. package/dist/index-DSVef1pp.d.cts +24 -0
  61. package/dist/index-DU_jYpBt.d.cts +44 -0
  62. package/dist/index-DYDha-3I.d.cts +67 -0
  63. package/dist/index-DaHsMJ_S.d.ts +5 -0
  64. package/dist/index-Dp50LM3a.d.ts +67 -0
  65. package/dist/index-cpjUxIik.d.ts +46 -0
  66. package/dist/index-eGkM4FE9.d.ts +20 -0
  67. package/dist/index.cjs +87 -2131
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.d.cts +25 -2745
  70. package/dist/index.d.ts +25 -2745
  71. package/dist/index.js +40 -2052
  72. package/dist/index.js.map +1 -1
  73. package/dist/json-DH7_lcWm.js +74 -0
  74. package/dist/json-DH7_lcWm.js.map +1 -0
  75. package/dist/json-DURdtz9A.cjs +91 -0
  76. package/dist/json-DURdtz9A.cjs.map +1 -0
  77. package/dist/json.cjs +4 -0
  78. package/dist/json.d.cts +2 -0
  79. package/dist/json.d.ts +2 -0
  80. package/dist/json.js +1 -0
  81. package/dist/macro-D0KfNtff.js +104 -0
  82. package/dist/macro-D0KfNtff.js.map +1 -0
  83. package/dist/macro-DrTBT7fh.cjs +127 -0
  84. package/dist/macro-DrTBT7fh.cjs.map +1 -0
  85. package/dist/macro.cjs +4 -0
  86. package/dist/macro.d.cts +2 -0
  87. package/dist/macro.d.ts +2 -0
  88. package/dist/macro.js +1 -0
  89. package/dist/mediaType-CRjggmoG.js +19 -0
  90. package/dist/mediaType-CRjggmoG.js.map +1 -0
  91. package/dist/mediaType-D8uIO8sG.cjs +35 -0
  92. package/dist/mediaType-D8uIO8sG.cjs.map +1 -0
  93. package/dist/mediaType.cjs +4 -0
  94. package/dist/mediaType.d.cts +2 -0
  95. package/dist/mediaType.d.ts +2 -0
  96. package/dist/mediaType.js +1 -0
  97. package/dist/node-DjcETnc8.cjs +19 -0
  98. package/dist/node-DjcETnc8.cjs.map +1 -0
  99. package/dist/node-Djh-mZB2.js +14 -0
  100. package/dist/node-Djh-mZB2.js.map +1 -0
  101. package/dist/node.cjs +9 -0
  102. package/dist/node.d.cts +4 -0
  103. package/dist/node.d.ts +4 -0
  104. package/dist/node.js +5 -0
  105. package/dist/nodeText-DRb_rVd1.cjs +58 -0
  106. package/dist/nodeText-DRb_rVd1.cjs.map +1 -0
  107. package/dist/nodeText-DVVDZQjF.js +47 -0
  108. package/dist/nodeText-DVVDZQjF.js.map +1 -0
  109. package/dist/nodes-BB60Bq2H.cjs +320 -0
  110. package/dist/nodes-BB60Bq2H.cjs.map +1 -0
  111. package/dist/nodes-CWMa9xhW.js +231 -0
  112. package/dist/nodes-CWMa9xhW.js.map +1 -0
  113. package/dist/operation-BgRyVS7z.d.ts +1272 -0
  114. package/dist/operation-X7chCdL2.d.cts +1272 -0
  115. package/dist/optionality-D-zqzVMH.cjs +22 -0
  116. package/dist/optionality-D-zqzVMH.cjs.map +1 -0
  117. package/dist/optionality-DISn8ytP.js +17 -0
  118. package/dist/optionality-DISn8ytP.js.map +1 -0
  119. package/dist/promise-BOdlgT0N.cjs +50 -0
  120. package/dist/promise-BOdlgT0N.cjs.map +1 -0
  121. package/dist/promise-RpnEev9D.js +45 -0
  122. package/dist/promise-RpnEev9D.js.map +1 -0
  123. package/dist/ref-Bu7PoHar.js +22 -0
  124. package/dist/ref-Bu7PoHar.js.map +1 -0
  125. package/dist/ref-P0ZLT1Bg.cjs +39 -0
  126. package/dist/ref-P0ZLT1Bg.cjs.map +1 -0
  127. package/dist/ref.cjs +7 -0
  128. package/dist/ref.d.cts +2 -0
  129. package/dist/ref.d.ts +2 -0
  130. package/dist/ref.js +3 -0
  131. package/dist/refs-CYHpRlQo.cjs +131 -0
  132. package/dist/refs-CYHpRlQo.cjs.map +1 -0
  133. package/dist/refs-YCV3CznS.js +102 -0
  134. package/dist/refs-YCV3CznS.js.map +1 -0
  135. package/dist/rolldown-runtime-BV8xUvPy.cjs +52 -0
  136. package/dist/rolldown-runtime-BYyVTPww.js +16 -0
  137. package/dist/schema-2ZAQk7qE.js +44 -0
  138. package/dist/schema-2ZAQk7qE.js.map +1 -0
  139. package/dist/schema-BIErWqgc.cjs +214 -0
  140. package/dist/schema-BIErWqgc.cjs.map +1 -0
  141. package/dist/schema-DloctnMm.js +179 -0
  142. package/dist/schema-DloctnMm.js.map +1 -0
  143. package/dist/schema-hxMlgCrV.cjs +49 -0
  144. package/dist/schema-hxMlgCrV.cjs.map +1 -0
  145. package/dist/schema.cjs +16 -0
  146. package/dist/schema.d.cts +5 -0
  147. package/dist/schema.d.ts +5 -0
  148. package/dist/schema.js +6 -0
  149. package/dist/visitor-BZozlXBF.d.ts +179 -0
  150. package/dist/visitor-Bw_opzjF.d.cts +179 -0
  151. package/dist/visitor-DTrzvA3R.cjs +382 -0
  152. package/dist/visitor-DTrzvA3R.cjs.map +1 -0
  153. package/dist/visitor-NoQSUQTu.js +347 -0
  154. package/dist/visitor-NoQSUQTu.js.map +1 -0
  155. package/package.json +101 -1
@@ -0,0 +1,79 @@
1
+ import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-X7chCdL2.cjs";
2
+ import { a as schemaTypes } from "./base-IpYuh3ZP.cjs";
3
+ import { n as narrowSchema } from "./guards-B8qDgSaT.cjs";
4
+ import { a as findSchema } from "./visitor-Bw_opzjF.cjs";
5
+ /**
6
+ * Generic JSON Schema optionality: a non-required field is optional, and a
7
+ * non-required nullable field is nullish.
8
+ */
9
+ declare function applyOptionality(schema: SchemaNode, required: boolean): SchemaNode;
10
+ /** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */
11
+ declare function getEmbeddedJson({ content }: Pick<StringSchemaNode, 'content'>): SchemaNode | undefined;
12
+ /** `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`. */
13
+ type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped';
14
+ /** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */
15
+ type SchemaFollow = 'ref' | 'array';
16
+ type IsOptions = {
17
+ /** Links to look through. Following repeats and stops on a ref cycle. */
18
+ follow?: ReadonlyArray<SchemaFollow>;
19
+ };
20
+ /** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */
21
+ declare function is(node: SchemaNode, kind: SchemaKind, { follow }?: IsOptions): boolean;
22
+ /**
23
+ * Finds every matching property exposed by an object, resolved reference, or intersection.
24
+ *
25
+ * References are followed through their parsed `schema`. Circular references terminate without
26
+ * revisiting a node. Unions are not traversed because a property on one branch does not describe
27
+ * every branch.
28
+ *
29
+ * @example Faker discriminator narrowing
30
+ * ```ts
31
+ * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>
32
+ * getSchemaLiteralValues(schema),
33
+ * )
34
+ * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`
35
+ * ```
36
+ *
37
+ * @example Zod discriminated unions
38
+ * ```ts
39
+ * const canDiscriminate = union.members?.every(
40
+ * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,
41
+ * )
42
+ * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`
43
+ * ```
44
+ *
45
+ * @example TypeScript property lookup
46
+ * ```ts
47
+ * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })
48
+ * const statusSchemas = properties.map((property) => print(property.schema))
49
+ * ```
50
+ */
51
+ declare function resolveSchemaProperties({ node, propertyName }: {
52
+ node: SchemaNode;
53
+ propertyName: string;
54
+ }): ReadonlyArray<PropertyNode>;
55
+ /**
56
+ * Reads the unique literal values represented by an enum, resolved reference, or union.
57
+ *
58
+ * Named enum values take precedence over simple enum values, matching how renderers consume
59
+ * `EnumSchemaNode`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const values = getSchemaLiteralValues(enumNode)
64
+ * // ['cat', 'dog']
65
+ * ```
66
+ */
67
+ declare function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue>;
68
+ type LiteralValue = string | number | boolean | null;
69
+ /**
70
+ * Infers an implicit discriminator: a property every member exposes with a distinct single
71
+ * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
72
+ */
73
+ declare function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined;
74
+ declare namespace index_d_exports {
75
+ export { IsOptions, SchemaFollow, SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
76
+ }
77
+ /** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */
78
+ declare function isString(node: SchemaNode): boolean;
79
+ export { resolveSchemaProperties as a, SchemaKind as c, applyOptionality as d, inferDiscriminatorPropertyName as i, is as l, isString as n, IsOptions as o, getSchemaLiteralValues as r, SchemaFollow as s, index_d_exports as t, getEmbeddedJson as u };
@@ -0,0 +1,74 @@
1
+ import { t as Node } from "./index-BwnMIoLl.js";
2
+ import { r as VisitorDepth, t as Visitor } from "./visitor-BZozlXBF.js";
3
+ /**
4
+ * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
5
+ * and `undefined` keeps declaration order.
6
+ */
7
+ type Enforce = 'pre' | 'post';
8
+ /**
9
+ * Compares two `enforce` hints for `Array.prototype.sort`: `pre` first, unmarked next, `post`
10
+ * last. Equal hints compare as `0`, so a stable sort keeps authored order within a bucket.
11
+ *
12
+ * @example
13
+ * `plugins.sort((a, b) => compareMacroOrder(a.enforce, b.enforce))`
14
+ */
15
+ declare function compareMacroOrder(a?: Enforce, b?: Enforce): number;
16
+ /**
17
+ * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
18
+ * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
19
+ * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
20
+ * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
21
+ */
22
+ type Macro = Visitor & {
23
+ /**
24
+ * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
25
+ */
26
+ name: string;
27
+ /**
28
+ * Ordering hint. `pre` macros run before unmarked macros, `post` macros run after.
29
+ * Ordering within a bucket follows list order.
30
+ */
31
+ enforce?: Enforce;
32
+ /**
33
+ * Predicate checked against the current node before any callback runs. Returning `false`
34
+ * skips the macro for that node.
35
+ */
36
+ match?: (node: Node) => boolean;
37
+ };
38
+ /**
39
+ * Types a macro for inference and a single construction site, mirroring `defineExtension`.
40
+ * Adds no runtime behavior.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const macroUntagged = defineMacro({
45
+ * name: 'untagged',
46
+ * operation(node) {
47
+ * return node.tags?.length ? undefined : { ...node, tags: ['untagged'] }
48
+ * },
49
+ * })
50
+ * ```
51
+ */
52
+ declare function defineMacro(macro: Macro): Macro;
53
+ /**
54
+ * Runs a list of macros over a node tree and returns the rewritten tree. Keeps `transform`'s
55
+ * structural sharing, so an empty or no-op macro list returns the same reference. Pass
56
+ * `depth: 'shallow'` to skip the children of every schema node; non-schema nodes, such as an operation's parameters and responses, are still rewritten.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const next = applyMacros(root, [macroIntegerToString])
61
+ * ```
62
+ *
63
+ * @example Rewrite a schema without walking its children
64
+ * ```ts
65
+ * const named = applyMacros(node, [macroEnumName({ parentName, propName, enumSuffix })], { depth: 'shallow' })
66
+ * ```
67
+ */
68
+ declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
69
+ depth?: VisitorDepth;
70
+ }): TNode;
71
+ declare namespace index_d_exports {
72
+ export { applyMacros as apply, compareMacroOrder as compareOrder };
73
+ }
74
+ export { compareMacroOrder as a, applyMacros as i, Enforce as n, defineMacro as o, Macro as r, index_d_exports as t };
@@ -0,0 +1,44 @@
1
+ import { H as SchemaNode, z as RefSchemaNode } from "./operation-BgRyVS7z.js";
2
+ /**
3
+ * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const target = resolveRef(refSchema)
8
+ * ```
9
+ */
10
+ declare function resolveRef(node: SchemaNode): SchemaNode;
11
+ /**
12
+ * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
13
+ *
14
+ * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
15
+ * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
16
+ * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
17
+ * is returned as is.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
22
+ * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
23
+ * ```
24
+ */
25
+ declare function mergeRefWithSchema(node: RefSchemaNode): SchemaNode;
26
+ /**
27
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
28
+ *
29
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
30
+ * referenced schema variable with those modifiers already applied.
31
+ */
32
+ declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
33
+ declare namespace index_d_exports {
34
+ export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
35
+ }
36
+ /** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */
37
+ declare function mergeSchema(node: SchemaNode): SchemaNode;
38
+ /**
39
+ * The name a ref points at. A `$ref` string gives its last segment: `'#/components/schemas/Pet'` gives `'Pet'`.
40
+ * A ref node gives its `targetName` first, so pass the node, not `node.ref`, to respect a renamed target. Other nodes give `null`.
41
+ */
42
+ declare function getName(ref: string): string;
43
+ declare function getName(node: SchemaNode | null | undefined): string | null;
44
+ export { mergeRefWithSchema as a, isBareRef as i, index_d_exports as n, resolveRef as o, mergeSchema as r, getName as t };
@@ -0,0 +1,74 @@
1
+ import { t as Node } from "./index-DSVef1pp.cjs";
2
+ import { r as VisitorDepth, t as Visitor } from "./visitor-Bw_opzjF.cjs";
3
+ /**
4
+ * Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
5
+ * and `undefined` keeps declaration order.
6
+ */
7
+ type Enforce = 'pre' | 'post';
8
+ /**
9
+ * Compares two `enforce` hints for `Array.prototype.sort`: `pre` first, unmarked next, `post`
10
+ * last. Equal hints compare as `0`, so a stable sort keeps authored order within a bucket.
11
+ *
12
+ * @example
13
+ * `plugins.sort((a, b) => compareMacroOrder(a.enforce, b.enforce))`
14
+ */
15
+ declare function compareMacroOrder(a?: Enforce, b?: Enforce): number;
16
+ /**
17
+ * A named, composable transform over the Kubb AST. It carries the same per-kind callbacks as a
18
+ * {@link Visitor} (`schema`, `operation`, …), plus a `name`, an optional `enforce` order, and an
19
+ * optional `match` predicate. Macros run on the shared AST, so the same macro works across every
20
+ * adapter and output target. Exports follow the `macro<Name>` convention, mirroring plugins (`pluginTs`).
21
+ */
22
+ type Macro = Visitor & {
23
+ /**
24
+ * Macro identifier used to tell macros apart, for example `'dedupe-union'`.
25
+ */
26
+ name: string;
27
+ /**
28
+ * Ordering hint. `pre` macros run before unmarked macros, `post` macros run after.
29
+ * Ordering within a bucket follows list order.
30
+ */
31
+ enforce?: Enforce;
32
+ /**
33
+ * Predicate checked against the current node before any callback runs. Returning `false`
34
+ * skips the macro for that node.
35
+ */
36
+ match?: (node: Node) => boolean;
37
+ };
38
+ /**
39
+ * Types a macro for inference and a single construction site, mirroring `defineExtension`.
40
+ * Adds no runtime behavior.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const macroUntagged = defineMacro({
45
+ * name: 'untagged',
46
+ * operation(node) {
47
+ * return node.tags?.length ? undefined : { ...node, tags: ['untagged'] }
48
+ * },
49
+ * })
50
+ * ```
51
+ */
52
+ declare function defineMacro(macro: Macro): Macro;
53
+ /**
54
+ * Runs a list of macros over a node tree and returns the rewritten tree. Keeps `transform`'s
55
+ * structural sharing, so an empty or no-op macro list returns the same reference. Pass
56
+ * `depth: 'shallow'` to skip the children of every schema node; non-schema nodes, such as an operation's parameters and responses, are still rewritten.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const next = applyMacros(root, [macroIntegerToString])
61
+ * ```
62
+ *
63
+ * @example Rewrite a schema without walking its children
64
+ * ```ts
65
+ * const named = applyMacros(node, [macroEnumName({ parentName, propName, enumSuffix })], { depth: 'shallow' })
66
+ * ```
67
+ */
68
+ declare function applyMacros<TNode extends Node>(root: TNode, macros: ReadonlyArray<Macro>, options?: {
69
+ depth?: VisitorDepth;
70
+ }): TNode;
71
+ declare namespace index_d_exports {
72
+ export { applyMacros as apply, compareMacroOrder as compareOrder };
73
+ }
74
+ export { compareMacroOrder as a, applyMacros as i, Enforce as n, defineMacro as o, Macro as r, index_d_exports as t };
@@ -0,0 +1,11 @@
1
+ declare namespace index_d_exports {
2
+ export { getBase, isJson };
3
+ }
4
+ type MediaTypeInput = string | {
5
+ contentType: string;
6
+ };
7
+ /** The media type without its parameters, in lower case: `Text/Plain; charset=utf-8` gives `text/plain`. */
8
+ declare function getBase(mediaType: MediaTypeInput): string;
9
+ /** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
10
+ declare function isJson(mediaType: MediaTypeInput): boolean;
11
+ export { index_d_exports as n, isJson as r, getBase as t };
@@ -0,0 +1,11 @@
1
+ declare namespace index_d_exports {
2
+ export { getBase, isJson };
3
+ }
4
+ type MediaTypeInput = string | {
5
+ contentType: string;
6
+ };
7
+ /** The media type without its parameters, in lower case: `Text/Plain; charset=utf-8` gives `text/plain`. */
8
+ declare function getBase(mediaType: MediaTypeInput): string;
9
+ /** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
10
+ declare function isJson(mediaType: MediaTypeInput): boolean;
11
+ export { index_d_exports as n, isJson as r, getBase as t };
@@ -0,0 +1,46 @@
1
+ import { n as FileNode } from "./file-BVqSiSvV.cjs";
2
+ type InlineFilesResult = {
3
+ /**
4
+ * Files that imported an inline name, rewritten to hold its definition.
5
+ */
6
+ files: Array<FileNode>;
7
+ /**
8
+ * Paths of the virtual files, which are not written.
9
+ */
10
+ virtualPaths: Array<string>;
11
+ /**
12
+ * One message per name that could not be inlined.
13
+ */
14
+ problems: Array<{
15
+ path: string;
16
+ message: string;
17
+ }>;
18
+ };
19
+ /**
20
+ * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.
21
+ */
22
+ type InlineLanguage = {
23
+ /**
24
+ * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.
25
+ */
26
+ replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string;
27
+ /**
28
+ * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.
29
+ */
30
+ wrap(expression: string): string;
31
+ };
32
+ type InlineFilesOptions = {
33
+ /**
34
+ * The inline support for a file's language, or `undefined` when it has none.
35
+ */
36
+ language: (file: FileNode) => InlineLanguage | undefined;
37
+ };
38
+ /**
39
+ * Replaces every name a file imports from a virtual file (one whose sources are all inline, so it is never written) with that name's
40
+ * `inline.expression`, until no inline names are left. The definitions' own imports move to the importing file.
41
+ */
42
+ declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
43
+ declare namespace index_d_exports {
44
+ export { inlineFiles as inline };
45
+ }
46
+ export { InlineLanguage as n, inlineFiles as r, index_d_exports as t };
@@ -0,0 +1,12 @@
1
+ import { i as nodeKinds } from "./base-IpYuh3ZP.js";
2
+ import { f as CodeNode } from "./file-xJnBQPGq.js";
3
+ import { i as collect, o as transform } from "./visitor-BZozlXBF.js";
4
+ /**
5
+ * Extracts all string content from a `CodeNode` tree recursively.
6
+ * Collects the text fields and nested node content, to build the source string for import filtering.
7
+ */
8
+ declare function getNodeText(nodes: Array<CodeNode> | undefined): string;
9
+ declare namespace index_d_exports {
10
+ export { collect, getNodeText as getText, nodeKinds as kinds, transform };
11
+ }
12
+ export { getNodeText as n, index_d_exports as t };
@@ -0,0 +1,79 @@
1
+ import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-BgRyVS7z.js";
2
+ import { a as schemaTypes } from "./base-IpYuh3ZP.js";
3
+ import { n as narrowSchema } from "./guards-D-h9R_sV.js";
4
+ import { a as findSchema } from "./visitor-BZozlXBF.js";
5
+ /**
6
+ * Generic JSON Schema optionality: a non-required field is optional, and a
7
+ * non-required nullable field is nullish.
8
+ */
9
+ declare function applyOptionality(schema: SchemaNode, required: boolean): SchemaNode;
10
+ /** The schema of the JSON document a string holds (`contentMediaType` with `contentSchema`), else `undefined`. */
11
+ declare function getEmbeddedJson({ content }: Pick<StringSchemaNode, 'content'>): SchemaNode | undefined;
12
+ /** `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`. */
13
+ type SchemaKind = 'binary' | 'string' | 'text' | 'scalar' | 'const' | 'enumLike' | 'untyped';
14
+ /** `ref` jumps to a resolved ref's target, `array` matches when some item matches. */
15
+ type SchemaFollow = 'ref' | 'array';
16
+ type IsOptions = {
17
+ /** Links to look through. Following repeats and stops on a ref cycle. */
18
+ follow?: ReadonlyArray<SchemaFollow>;
19
+ };
20
+ /** Whether a schema is of `kind`, looking at the node itself unless `follow` names links to look through. */
21
+ declare function is(node: SchemaNode, kind: SchemaKind, { follow }?: IsOptions): boolean;
22
+ /**
23
+ * Finds every matching property exposed by an object, resolved reference, or intersection.
24
+ *
25
+ * References are followed through their parsed `schema`. Circular references terminate without
26
+ * revisiting a node. Unions are not traversed because a property on one branch does not describe
27
+ * every branch.
28
+ *
29
+ * @example Faker discriminator narrowing
30
+ * ```ts
31
+ * const values = resolveSchemaProperties({ node: member, propertyName: union.discriminatorPropertyName }).flatMap(({ schema }) =>
32
+ * getSchemaLiteralValues(schema),
33
+ * )
34
+ * const typeName = `Extract<Pet, { type: ${values.map(JSON.stringify).join(' | ')} }>`
35
+ * ```
36
+ *
37
+ * @example Zod discriminated unions
38
+ * ```ts
39
+ * const canDiscriminate = union.members?.every(
40
+ * (member) => resolveSchemaProperties({ node: member, propertyName: 'type' }).length > 0,
41
+ * )
42
+ * const expression = canDiscriminate ? `z.discriminatedUnion('type', members)` : `z.union(members)`
43
+ * ```
44
+ *
45
+ * @example TypeScript property lookup
46
+ * ```ts
47
+ * const properties = resolveSchemaProperties({ node: schema, propertyName: 'status' })
48
+ * const statusSchemas = properties.map((property) => print(property.schema))
49
+ * ```
50
+ */
51
+ declare function resolveSchemaProperties({ node, propertyName }: {
52
+ node: SchemaNode;
53
+ propertyName: string;
54
+ }): ReadonlyArray<PropertyNode>;
55
+ /**
56
+ * Reads the unique literal values represented by an enum, resolved reference, or union.
57
+ *
58
+ * Named enum values take precedence over simple enum values, matching how renderers consume
59
+ * `EnumSchemaNode`.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const values = getSchemaLiteralValues(enumNode)
64
+ * // ['cat', 'dog']
65
+ * ```
66
+ */
67
+ declare function getSchemaLiteralValues(node: SchemaNode): ReadonlyArray<LiteralValue>;
68
+ type LiteralValue = string | number | boolean | null;
69
+ /**
70
+ * Infers an implicit discriminator: a property every member exposes with a distinct single
71
+ * literal value, the same shape a declared OpenAPI `discriminator` already narrows on.
72
+ */
73
+ declare function inferDiscriminatorPropertyName(members: ReadonlyArray<SchemaNode>): string | undefined;
74
+ declare namespace index_d_exports {
75
+ export { IsOptions, SchemaFollow, SchemaKind, applyOptionality, findSchema as find, resolveSchemaProperties as findProperties, getEmbeddedJson, getSchemaLiteralValues as getLiterals, inferDiscriminatorPropertyName as inferDiscriminator, is, isString, narrowSchema as narrow, schemaTypes as types };
76
+ }
77
+ /** @deprecated Use `ast.schema.is(node, 'string')`. Removed in Kubb v6. */
78
+ declare function isString(node: SchemaNode): boolean;
79
+ export { resolveSchemaProperties as a, SchemaKind as c, applyOptionality as d, inferDiscriminatorPropertyName as i, is as l, isString as n, IsOptions as o, getSchemaLiteralValues as r, SchemaFollow as s, index_d_exports as t, getEmbeddedJson as u };
@@ -0,0 +1,24 @@
1
+ import { C as createJsx, S as createFunction, T as createType, _ as TextNode, a as UserFileNode, b as createBreak, c as createImport, d as BreakNode, g as JsxNode, i as SourceNode, l as createSource, m as FunctionNode, n as FileNode, o as createExport, p as ConstNode, r as ImportNode, s as createFile, t as ExportNode, u as ArrowFunctionNode, v as TypeNode, w as createText, x as createConst, y as createArrowFunction } from "./file-BVqSiSvV.cjs";
2
+ import { H as SchemaNode, T as InputNode, X as PropertyNode, Y as createSchema, Z as createProperty, a as createOperation, d as createRequestBody, g as ContentNode, h as createParameter, i as OperationNode, k as createInput, l as createResponse, p as ParameterNode, s as ResponseNode, u as RequestBodyNode, y as createContent } from "./operation-X7chCdL2.cjs";
3
+ declare namespace index_d_exports {
4
+ export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
5
+ }
6
+ /**
7
+ * Union of all AST node types.
8
+ *
9
+ * This lets TypeScript narrow types in `switch (node.kind)` blocks.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * function getKind(node: Node): string {
14
+ * switch (node.kind) {
15
+ * case nodeKinds.input:
16
+ * return 'input'
17
+ * default:
18
+ * return 'other'
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ type Node = InputNode | OperationNode | SchemaNode | PropertyNode | ParameterNode | ResponseNode | RequestBodyNode | ContentNode | FileNode | ImportNode | ExportNode | SourceNode | ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
24
+ export { index_d_exports as n, Node as t };
@@ -0,0 +1,44 @@
1
+ import { H as SchemaNode, z as RefSchemaNode } from "./operation-X7chCdL2.cjs";
2
+ /**
3
+ * Follows a resolved ref chain to its target schema. Returns an unresolved or cyclic ref as is.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const target = resolveRef(refSchema)
8
+ * ```
9
+ */
10
+ declare function resolveRef(node: SchemaNode): SchemaNode;
11
+ /**
12
+ * Merges a ref node with its resolved schema, giving the fields set at the usage site precedence.
13
+ *
14
+ * Every field on the ref except `kind`, `type`, `name`, `ref`, and `schema` overrides the same field
15
+ * of the resolved `schema` (for example `description`, `nullable`, `readOnly`, `deprecated`). Fields
16
+ * left `undefined` on the ref do not shadow the resolved schema. A ref without a resolved `schema`
17
+ * is returned as is.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const ref = createSchema({ type: 'ref', ref: '#/components/schemas/Pet', description: 'A pet', schema: petSchema })
22
+ * mergeRefWithSchema(ref) // petSchema's fields with description 'A pet'
23
+ * ```
24
+ */
25
+ declare function mergeRefWithSchema(node: RefSchemaNode): SchemaNode;
26
+ /**
27
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
28
+ *
29
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
30
+ * referenced schema variable with those modifiers already applied.
31
+ */
32
+ declare function isBareRef(node: SchemaNode | null | undefined, keysToOmit?: Array<string> | null): boolean;
33
+ declare namespace index_d_exports {
34
+ export { getName, resolveRef as getSchema, isBareRef as isAlias, mergeSchema };
35
+ }
36
+ /** A resolved ref merged with its target schema, so usage-site fields such as `description` win. Other nodes come back unchanged. */
37
+ declare function mergeSchema(node: SchemaNode): SchemaNode;
38
+ /**
39
+ * The name a ref points at. A `$ref` string gives its last segment: `'#/components/schemas/Pet'` gives `'Pet'`.
40
+ * A ref node gives its `targetName` first, so pass the node, not `node.ref`, to respect a renamed target. Other nodes give `null`.
41
+ */
42
+ declare function getName(ref: string): string;
43
+ declare function getName(node: SchemaNode | null | undefined): string | null;
44
+ export { mergeRefWithSchema as a, isBareRef as i, index_d_exports as n, resolveRef as o, mergeSchema as r, getName as t };
@@ -0,0 +1,67 @@
1
+ import { H as SchemaNode, i as OperationNode } from "./operation-X7chCdL2.cjs";
2
+ /**
3
+ * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
4
+ * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
5
+ * node identity, so repeated calls on one schema scan it once.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * collectSchemaRefs(petSchema)
10
+ * // Set { 'Category', 'Tag' }
11
+ * ```
12
+ */
13
+ declare function collectSchemaRefs(node: SchemaNode): ReadonlySet<string>;
14
+ /**
15
+ * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in
16
+ * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result
17
+ * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.
18
+ *
19
+ * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the
20
+ * same file (a union member created by name) is left out. That leaves exactly the set
21
+ * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with
22
+ * `checks: true`, for a plugin that prints those checks.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * collectImportedRefNames(petSchema)
27
+ * // ['Category', 'Tag']
28
+ * ```
29
+ */
30
+ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
31
+ checks?: boolean;
32
+ }): ReadonlyArray<string>;
33
+ /**
34
+ * Collects the names of all top-level schemas transitively used by a set of operations.
35
+ *
36
+ * An operation uses a schema when its parameters, request body, or responses reference it, directly
37
+ * or through other named schemas. Once a name is added to the result it is not revisited, so
38
+ * reference cycles terminate.
39
+ *
40
+ * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.
41
+ *
42
+ * @example Only generate schemas referenced by included operations
43
+ * ```ts
44
+ * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)
45
+ * const allowed = collectUsedSchemaNames(includedOps, schemas)
46
+ *
47
+ * for (const schema of schemas) {
48
+ * if (schema.name && !allowed.has(schema.name)) continue
49
+ * // generate schema
50
+ * }
51
+ * ```
52
+ */
53
+ declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
54
+ /**
55
+ * Finds every schema that takes part in a circular dependency chain, including direct self-loops.
56
+ *
57
+ * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so
58
+ * the generated code does not recurse forever. Refs are followed by name only, so the walk stays
59
+ * linear in the size of the schema graph.
60
+ *
61
+ * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.
62
+ */
63
+ declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
64
+ declare namespace index_d_exports {
65
+ export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
66
+ }
67
+ export { findCircularSchemas as a, collectUsedSchemaNames as i, collectImportedRefNames as n, collectSchemaRefs as r, index_d_exports as t };
@@ -0,0 +1,5 @@
1
+ import { t as isHttpOperationNode } from "./guards-D-h9R_sV.js";
2
+ declare namespace index_d_exports {
3
+ export { isHttpOperationNode as isOperation };
4
+ }
5
+ export { index_d_exports as t };
@@ -0,0 +1,67 @@
1
+ import { H as SchemaNode, i as OperationNode } from "./operation-BgRyVS7z.js";
2
+ /**
3
+ * Collects the names of every schema a node's subtree references, resolved with `ast.ref.getName`.
4
+ * Each ref contributes its name only, so the schema it points to is never traversed. Memoized by
5
+ * node identity, so repeated calls on one schema scan it once.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * collectSchemaRefs(petSchema)
10
+ * // Set { 'Category', 'Tag' }
11
+ * ```
12
+ */
13
+ declare function collectSchemaRefs(node: SchemaNode): ReadonlySet<string>;
14
+ /**
15
+ * Collects the de-duplicated target names of every pointer-carrying ref in a node's subtree, in
16
+ * first-occurrence order. Memoized by node identity, so `resolver.imports` reads the same result
17
+ * across the ts, zod, and faker plugins instead of re-scanning the same schema per plugin.
18
+ *
19
+ * Only refs that carry a `$ref` pointer count, so a synthesized ref pointing at a sibling in the
20
+ * same file (a union member created by name) is left out. That leaves exactly the set
21
+ * `resolver.imports` emits. Refs inside `conditionals`, `contains` and `content` count only with
22
+ * `checks: true`, for a plugin that prints those checks.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * collectImportedRefNames(petSchema)
27
+ * // ['Category', 'Tag']
28
+ * ```
29
+ */
30
+ declare function collectImportedRefNames(node: SchemaNode, { checks }?: {
31
+ checks?: boolean;
32
+ }): ReadonlyArray<string>;
33
+ /**
34
+ * Collects the names of all top-level schemas transitively used by a set of operations.
35
+ *
36
+ * An operation uses a schema when its parameters, request body, or responses reference it, directly
37
+ * or through other named schemas. Once a name is added to the result it is not revisited, so
38
+ * reference cycles terminate.
39
+ *
40
+ * Pair it with `include` filters so schemas reachable only from excluded operations stay ungenerated.
41
+ *
42
+ * @example Only generate schemas referenced by included operations
43
+ * ```ts
44
+ * const includedOps = operations.filter((op) => resolver.default.options(op, { options, include }) !== null)
45
+ * const allowed = collectUsedSchemaNames(includedOps, schemas)
46
+ *
47
+ * for (const schema of schemas) {
48
+ * if (schema.name && !allowed.has(schema.name)) continue
49
+ * // generate schema
50
+ * }
51
+ * ```
52
+ */
53
+ declare function collectUsedSchemaNames(operations: ReadonlyArray<OperationNode>, schemas: ReadonlyArray<SchemaNode>): Set<string>;
54
+ /**
55
+ * Finds every schema that takes part in a circular dependency chain, including direct self-loops.
56
+ *
57
+ * Wrap the returned schema positions in a deferred construct (a lazy getter or `z.lazy(() => …)`) so
58
+ * the generated code does not recurse forever. Refs are followed by name only, so the walk stays
59
+ * linear in the size of the schema graph.
60
+ *
61
+ * @note Call this once on the full graph, then check a schema's `ast.graph.getRefNames` against the result.
62
+ */
63
+ declare function findCircularSchemas(schemas: ReadonlyArray<SchemaNode>): Set<string>;
64
+ declare namespace index_d_exports {
65
+ export { findCircularSchemas as getCircularNames, collectImportedRefNames as getImportedNames, collectSchemaRefs as getRefNames, collectUsedSchemaNames as getUsedNames };
66
+ }
67
+ export { findCircularSchemas as a, collectUsedSchemaNames as i, collectImportedRefNames as n, collectSchemaRefs as r, index_d_exports as t };