@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
@@ -1,4 +1,4 @@
1
- import { n as FileNode } from "./file-xJnBQPGq.js";
1
+ import { n as FileNode } from "./file-KunZhFIV.cjs";
2
2
  type InlineFilesResult = {
3
3
  /**
4
4
  * Files that imported an inline name, rewritten to hold its definition.
@@ -36,8 +36,8 @@ type InlineFilesOptions = {
36
36
  language: (file: FileNode) => InlineLanguage | undefined;
37
37
  };
38
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.
39
+ * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's
40
+ * declaration, until no inline names are left. The definitions' own imports move to the importing file.
41
41
  */
42
42
  declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
43
43
  declare namespace index_d_exports {
@@ -1,6 +1,6 @@
1
- import { i as nodeKinds } from "./base-IpYuh3ZP.cjs";
2
- import { f as CodeNode } from "./file-BVqSiSvV.cjs";
3
- import { i as collect, o as transform } from "./visitor-Bw_opzjF.cjs";
1
+ import { i as nodeKinds } from "./base-UFBZi-FO.cjs";
2
+ import { f as CodeNode } from "./file-KunZhFIV.cjs";
3
+ import { a as collect, s as transform } from "./visitor-DxhkIQyP.cjs";
4
4
  /**
5
5
  * Extracts all string content from a `CodeNode` tree recursively.
6
6
  * Collects the text fields and nested node content, to build the source string for import filtering.
@@ -0,0 +1,5 @@
1
+ import { t as isHttpOperationNode } from "./guards-COBkDtgu.cjs";
2
+ declare namespace index_d_exports {
3
+ export { isHttpOperationNode as isOperation };
4
+ }
5
+ export { index_d_exports as t };
@@ -1,7 +1,7 @@
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";
1
+ import { G as StringSchemaNode, H as SchemaNode, X as PropertyNode } from "./operation-BUhPuZMY.cjs";
2
+ import { a as schemaTypes } from "./base-UFBZi-FO.cjs";
3
+ import { n as narrowSchema } from "./guards-COBkDtgu.cjs";
4
+ import { o as findSchema } from "./visitor-DxhkIQyP.cjs";
5
5
  /**
6
6
  * Generic JSON Schema optionality: a non-required field is optional, and a
7
7
  * non-required nullable field is nullish.
@@ -1,4 +1,4 @@
1
- import { T as InputNode } from "./operation-X7chCdL2.cjs";
1
+ import { T as InputNode } from "./operation-BUhPuZMY.cjs";
2
2
  declare namespace index_d_exports {
3
3
  export { parse, stringify };
4
4
  }
@@ -1,4 +1,4 @@
1
- import { n as FileNode } from "./file-BVqSiSvV.cjs";
1
+ import { n as FileNode } from "./file-DkFGn_Os.js";
2
2
  type InlineFilesResult = {
3
3
  /**
4
4
  * Files that imported an inline name, rewritten to hold its definition.
@@ -36,8 +36,8 @@ type InlineFilesOptions = {
36
36
  language: (file: FileNode) => InlineLanguage | undefined;
37
37
  };
38
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.
39
+ * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's
40
+ * declaration, until no inline names are left. The definitions' own imports move to the importing file.
41
41
  */
42
42
  declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
43
43
  declare namespace index_d_exports {
@@ -1,5 +1,5 @@
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";
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-KunZhFIV.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-BUhPuZMY.cjs";
3
3
  declare namespace index_d_exports {
4
4
  export { Node, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
5
5
  }
package/dist/index.cjs CHANGED
@@ -1,21 +1,21 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
3
- const require_constants = require("./constants-CquR083U.cjs");
4
- const require_graph = require("./graph-DcIY6tQb.cjs");
5
- const require_visitor = require("./visitor-DTrzvA3R.cjs");
6
- const require_ref = require("./ref-P0ZLT1Bg.cjs");
7
- const require_schema = require("./schema-BIErWqgc.cjs");
8
- const require_guards = require("./guards-COVJE6TU.cjs");
9
- const require_refs = require("./refs-CYHpRlQo.cjs");
10
- const require_macro = require("./macro-DrTBT7fh.cjs");
11
- const require_optionality = require("./optionality-D-zqzVMH.cjs");
12
- const require_node = require("./node-DjcETnc8.cjs");
13
- const require_file = require("./file-Dd50jPkH.cjs");
14
- const require_nodeText = require("./nodeText-DRb_rVd1.cjs");
15
- const require_nodes = require("./nodes-BB60Bq2H.cjs");
16
- const require_http = require("./http-Bm5lhVK4.cjs");
17
- const require_json = require("./json-DURdtz9A.cjs");
18
- const require_mediaType = require("./mediaType-D8uIO8sG.cjs");
3
+ const require_constants = require("./constants-DztHlVmY.cjs");
4
+ const require_graph = require("./graph-CFJ4wzFR.cjs");
5
+ const require_visitor = require("./visitor-Bh1CBAOz.cjs");
6
+ const require_ref = require("./ref-Bh5Xo8T7.cjs");
7
+ const require_schema = require("./schema-DuCY4lCG.cjs");
8
+ const require_guards = require("./guards-4drgx10i.cjs");
9
+ const require_refs = require("./refs-rmr2LFV1.cjs");
10
+ const require_macro = require("./macro-BEwfGNu1.cjs");
11
+ const require_node = require("./node-vTrAIz3e.cjs");
12
+ const require_optionality = require("./optionality-C-qULYxo.cjs");
13
+ const require_file = require("./file-BAICym_L.cjs");
14
+ const require_nodeText = require("./nodeText-CZ7wgxu9.cjs");
15
+ const require_nodes = require("./nodes-BT2Ocq0x.cjs");
16
+ const require_http = require("./http-Dv8py6wh.cjs");
17
+ const require_json = require("./json-CCWMgzJZ.cjs");
18
+ const require_mediaType = require("./mediaType-BbIfudh0.cjs");
19
19
  // src/createPrinter.ts
20
20
  /**
21
21
  * Creates a schema printer: a function that takes a `SchemaNode` and emits
@@ -76,7 +76,8 @@ function createPrinter$1(build) {
76
76
  const dispatch = (table, node, options, parent) => {
77
77
  const handler = table[node.type];
78
78
  if (!handler) return null;
79
- return handler.call(createContext(options, node, parent), node);
79
+ const context = createContext(options, node, parent);
80
+ return handler.call(context, node, context);
80
81
  };
81
82
  function createContext(options, current, parent) {
82
83
  const context = {
@@ -88,14 +89,19 @@ function createPrinter$1(build) {
88
89
  };
89
90
  return context;
90
91
  }
91
- const root = createContext(resolvedOptions);
92
- return {
93
- name,
94
- options: resolvedOptions,
95
- transform: root.transform,
96
- print: printOverride ? (node, extra) => printOverride.call(extra ? createContext(withOptions(resolvedOptions, extra)) : root, node) : root.transform,
97
- drainImports: () => collectedImports.splice(0)
92
+ const drainImports = () => collectedImports.splice(0);
93
+ const toPrinter = (options) => {
94
+ const root = createContext(options);
95
+ return {
96
+ name,
97
+ options,
98
+ transform: (node) => root.transform(node),
99
+ print: printOverride ? (node) => printOverride.call(root, node, root) : (node) => root.transform(node),
100
+ with: (extra) => toPrinter(withOptions(options, extra)),
101
+ drainImports
102
+ };
98
103
  };
104
+ return toPrinter(resolvedOptions);
99
105
  };
100
106
  }
101
107
  require_rolldown_runtime.__name(createPrinter$1, "createPrinter");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createPrinter","mergeRef","createPrinterImpl","defineMacroImpl"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed as `this` to printer handlers.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type.\n *\n * Use a regular function (not an arrow function) if you need `this`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'string'> = function () {\n * return 'string'\n * }\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode, options?: Partial<T['options']>) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode, options?: Partial<T['options']>) => T['printOutput'] | null\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n return (handler as (this: Context, node: SchemaNode) => T['output'] | null).call(createContext(options, node, parent), node)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const root = createContext(resolvedOptions)\n\n return {\n name,\n options: resolvedOptions,\n transform: root.transform,\n print: (printOverride\n ? (node: SchemaNode, extra?: Partial<T['options']>) => printOverride.call(extra ? createContext(withOptions(resolvedOptions, extra)) : root, node)\n : root.transform) as Printer<T>['print'],\n drainImports: () => collectedImports.splice(0),\n }\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport * as ref from './ref/index.ts'\nexport * as schema from './schema/index.ts'\nexport type * from './types.ts'\nexport * as ast from './index.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkNA,SAAgBA,gBAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,WAAW,OAAO,kBAAkB,MAAO,WAAW,CAAC,CAAkB;EACxH,MAAM,SAAS,YAAY;GAAE,GAAG;GAAO,GAAG;EAAU,IAAI;EAExD,MAAM,mBAAsC,CAAC;EAC7C,MAAM,cAAc,SAA2B;GAC7C,iBAAiB,KAAK,IAAI;EAC5B;EAEA,MAAM,eAAe,SAAuB,UAAiD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAM,IAAI;EAEhI,MAAM,YAAY,OAAkD,MAAkB,SAAuB,WAA4C;GACvJ,MAAM,UAAU,MAAM,KAAK;GAC3B,IAAI,CAAC,SAAS,OAAO;GAErB,OAAQ,QAAoE,KAAK,cAAc,SAAS,MAAM,MAAM,GAAG,IAAI;EAC7H;EAGA,SAAS,cAAc,SAAuB,SAAsB,QAA8B;GAChG,MAAM,UAAmB;IACvB;IACA;IACA,QAAQ;IACR,YAAY,MAAM,UAAU,SAAS,QAAQ,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,OAAO;IAC/F,OAAO,MAAM,UAAU,SAAS,OAAO,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,MAAM;GAC1F;GACA,OAAO;EACT;EAEA,MAAM,OAAO,cAAc,eAAe;EAE1C,OAAO;GACL;GACA,SAAS;GACT,WAAW,KAAK;GAChB,OAAQ,iBACH,MAAkB,UAAkC,cAAc,KAAK,QAAQ,cAAc,YAAY,iBAAiB,KAAK,CAAC,IAAI,MAAM,IAAI,IAC/I,KAAK;GACT,oBAAoB,iBAAiB,OAAO,CAAC;EAC/C;CACF;AACF;;;;ACjPA,MAAa,YAAA,aAAA;;AAGb,MAAa,qBAAqBC,aAAAA;;AAGlC,MAAa,UAAA,YAAA;;AAGb,MAAa,aAAA,aAAA;;AAGb,MAAa,iBAAA,YAAA;;AAGb,MAAa,0BAAA,cAAA;;AAGb,MAAa,oBAAA,cAAA;;AAGb,MAAa,yBAAA,cAAA;;AAGb,MAAa,sBAAA,cAAA;;AAGb,MAAa,yBAAA,eAAA;;AAGb,MAAa,iCAAA,eAAA;;AAGb,MAAa,0BAAA,eAAA;;AAGb,MAAa,sBAAA,eAAA;;AAGb,MAAa,cAAA,gBAAA;;AAGb,MAAa,cAAA,oBAAA;;AAGb,MAAa,0BAAA,iBAAA;;AAGb,MAAa,iBAAA,cAAA;;AAGb,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC,cAAAA;;AAG3B,MAAa,cAAA,cAAA;;AAGb,MAAa,YAAA,kBAAA;;AAGb,MAAa,cAAA,kBAAA;;AAGb,MAAa,aAAA,gBAAA;;AAGb,MAAa,eAAA,eAAA;;AAGb,MAAa,YAAA,gBAAA;;AAGb,MAAa,UAAA,gBAAA;;AAGb,MAAa,cAAA,aAAA"}
1
+ {"version":3,"file":"index.cjs","names":["createPrinter","mergeRef","createPrinterImpl","defineMacroImpl"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed to printer handlers, both as `this` and as the second argument.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type. The handler context is `this` and the second argument,\n * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an\n * arrow function asserts it with `ctx!`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n // Optional and without the options type, so one-argument handler types stay assignable and\n // a union of printer tables keeps its contextual `this`. Use `this.options` for typed options.\n ctx?: PrinterHandlerContext<TOutput, object>,\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */\n with: (extra: Partial<T['options']>) => Printer<T>\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe. The root context is also the second argument.\n */\n print?: (\n this: PrinterHandlerContext<T['output'], T['options']>,\n node: SchemaNode,\n ctx: PrinterHandlerContext<T['output'], T['options']>,\n ) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n const context = createContext(options, node, parent)\n return (handler as (this: Context, node: SchemaNode, ctx: Context) => T['output'] | null).call(context, node, context)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const drainImports = () => collectedImports.splice(0)\n\n const toPrinter = (options: T['options']): Printer<T> => {\n const root = createContext(options)\n return {\n name,\n options,\n transform: (node) => root.transform(node),\n print: (printOverride ? (node: SchemaNode) => printOverride.call(root, node, root) : (node: SchemaNode) => root.transform(node)) as Printer<T>['print'],\n with: (extra) => toPrinter(withOptions(options, extra)),\n drainImports,\n }\n }\n\n return toPrinter(resolvedOptions)\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport * as ref from './ref/index.ts'\nexport * as schema from './schema/index.ts'\nexport type * from './types.ts'\nexport * as ast from './index.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyNA,SAAgBA,gBAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,WAAW,OAAO,kBAAkB,MAAO,WAAW,CAAC,CAAkB;EACxH,MAAM,SAAS,YAAY;GAAE,GAAG;GAAO,GAAG;EAAU,IAAI;EAExD,MAAM,mBAAsC,CAAC;EAC7C,MAAM,cAAc,SAA2B;GAC7C,iBAAiB,KAAK,IAAI;EAC5B;EAEA,MAAM,eAAe,SAAuB,UAAiD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAM,IAAI;EAEhI,MAAM,YAAY,OAAkD,MAAkB,SAAuB,WAA4C;GACvJ,MAAM,UAAU,MAAM,KAAK;GAC3B,IAAI,CAAC,SAAS,OAAO;GAErB,MAAM,UAAU,cAAc,SAAS,MAAM,MAAM;GACnD,OAAQ,QAAkF,KAAK,SAAS,MAAM,OAAO;EACvH;EAGA,SAAS,cAAc,SAAuB,SAAsB,QAA8B;GAChG,MAAM,UAAmB;IACvB;IACA;IACA,QAAQ;IACR,YAAY,MAAM,UAAU,SAAS,QAAQ,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,OAAO;IAC/F,OAAO,MAAM,UAAU,SAAS,OAAO,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,MAAM;GAC1F;GACA,OAAO;EACT;EAEA,MAAM,qBAAqB,iBAAiB,OAAO,CAAC;EAEpD,MAAM,aAAa,YAAsC;GACvD,MAAM,OAAO,cAAc,OAAO;GAClC,OAAO;IACL;IACA;IACA,YAAY,SAAS,KAAK,UAAU,IAAI;IACxC,OAAQ,iBAAiB,SAAqB,cAAc,KAAK,MAAM,MAAM,IAAI,KAAK,SAAqB,KAAK,UAAU,IAAI;IAC9H,OAAO,UAAU,UAAU,YAAY,SAAS,KAAK,CAAC;IACtD;GACF;EACF;EAEA,OAAO,UAAU,eAAe;CAClC;AACF;;;;AC7PA,MAAa,YAAA,aAAA;;AAGb,MAAa,qBAAqBC,aAAAA;;AAGlC,MAAa,UAAA,YAAA;;AAGb,MAAa,aAAA,aAAA;;AAGb,MAAa,iBAAA,YAAA;;AAGb,MAAa,0BAAA,cAAA;;AAGb,MAAa,oBAAA,cAAA;;AAGb,MAAa,yBAAA,cAAA;;AAGb,MAAa,sBAAA,cAAA;;AAGb,MAAa,yBAAA,eAAA;;AAGb,MAAa,iCAAA,eAAA;;AAGb,MAAa,0BAAA,eAAA;;AAGb,MAAa,sBAAA,eAAA;;AAGb,MAAa,cAAA,gBAAA;;AAGb,MAAa,cAAA,oBAAA;;AAGb,MAAa,0BAAA,iBAAA;;AAGb,MAAa,iBAAA,cAAA;;AAGb,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC,cAAAA;;AAG3B,MAAa,cAAA,cAAA;;AAGb,MAAa,YAAA,kBAAA;;AAGb,MAAa,cAAA,kBAAA;;AAGb,MAAa,aAAA,gBAAA;;AAGb,MAAa,eAAA,eAAA;;AAGb,MAAa,YAAA,gBAAA;;AAGb,MAAa,UAAA,gBAAA;;AAGb,MAAa,cAAA,aAAA"}
package/dist/index.d.cts CHANGED
@@ -1,20 +1,20 @@
1
- import { n as InlineLanguage, r as inlineFiles$1, t as index_d_exports$2 } from "./index-Csf8xsCc.cjs";
2
- import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-DYDha-3I.cjs";
3
- import { t as index_d_exports$4 } from "./index-BWd95onW.cjs";
4
- import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-DU_jYpBt.cjs";
5
- import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-C-vhkzwR.cjs";
6
- import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-B8qDgSaT.cjs";
7
- import { _ as TextNode, a as UserFileNode, d as BreakNode, f as CodeNode, g as JsxNode, h as JSDocNode, i as SourceNode, m as FunctionNode, n as FileNode, p as ConstNode, r as ImportNode, t as ExportNode, u as ArrowFunctionNode, v as TypeNode } from "./file-BVqSiSvV.cjs";
8
- import { A as ArraySchemaNode, B as ScalarSchemaNode, C as ExternalDocs, D as InputTag, E as InputServer, F as NotSchemaNode, G as StringSchemaNode, H as SchemaNode, I as NumberSchemaNode, J as UrlSchemaNode, K as TimeSchemaNode, L as ObjectSchemaNode, M as DatetimeSchemaNode, N as EnumSchemaNode, O as OAuthFlow, P as IntersectionSchemaNode, R as PrimitiveSchemaType, S as AuthScheme, T as InputNode, U as SchemaNodeByType, V as ScalarSchemaType, W as SchemaType, X as PropertyNode, _ as EncodingNode, b as AuthCredential, c as StatusCode, f as ParameterLocation, g as ContentNode, i as OperationNode, j as DateSchemaNode, m as ParameterStyle, n as HttpMethod, o as ResponseLink, p as ParameterNode, q as UnionSchemaNode, r as HttpOperationNode, s as ResponseNode, t as GenericOperationNode, u as RequestBodyNode, v as ExampleNode, w as InputMeta, x as AuthRequirement, z as RefSchemaNode } from "./operation-X7chCdL2.cjs";
9
- import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-CIqwy4EE.cjs";
10
- import { n as getNodeText, t as index_d_exports$8 } from "./index-BngGJux5.cjs";
11
- import { n as index_d_exports$1, t as Node } from "./index-DSVef1pp.cjs";
12
- import { t as index_d_exports$5 } from "./index-Bb1kqq8H.cjs";
13
- import { n as index_d_exports$7 } from "./index-Cc2K3OzU.cjs";
14
- import { n as DistributiveOmit, r as NodeKind } from "./base-IpYuh3ZP.cjs";
15
- import { a as findSchema$1, i as collect$1, n as VisitorContext, o as transform$1, t as Visitor } from "./visitor-Bw_opzjF.cjs";
1
+ import { n as InlineLanguage, r as inlineFiles$1, t as index_d_exports$2 } from "./index-DkThxxxq.cjs";
2
+ import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-D-BjRrJo.cjs";
3
+ import { t as index_d_exports$4 } from "./index-DuDvNFQ8.cjs";
4
+ import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-DZe5evGM.cjs";
5
+ import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-COBkDtgu.cjs";
6
+ import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-dgiKWRpD.cjs";
7
+ import { _ as TextNode, a as UserFileNode, d as BreakNode, f as CodeNode, g as JsxNode, h as JSDocNode, i as SourceNode, m as FunctionNode, n as FileNode, p as ConstNode, r as ImportNode, t as ExportNode, u as ArrowFunctionNode, v as TypeNode } from "./file-KunZhFIV.cjs";
8
+ import { A as ArraySchemaNode, B as ScalarSchemaNode, C as ExternalDocs, D as InputTag, E as InputServer, F as NotSchemaNode, G as StringSchemaNode, H as SchemaNode, I as NumberSchemaNode, J as UrlSchemaNode, K as TimeSchemaNode, L as ObjectSchemaNode, M as DatetimeSchemaNode, N as EnumSchemaNode, O as OAuthFlow, P as IntersectionSchemaNode, R as PrimitiveSchemaType, S as AuthScheme, T as InputNode, U as SchemaNodeByType, V as ScalarSchemaType, W as SchemaType, X as PropertyNode, _ as EncodingNode, b as AuthCredential, c as StatusCode, f as ParameterLocation, g as ContentNode, i as OperationNode, j as DateSchemaNode, m as ParameterStyle, n as HttpMethod, o as ResponseLink, p as ParameterNode, q as UnionSchemaNode, r as HttpOperationNode, s as ResponseNode, t as GenericOperationNode, u as RequestBodyNode, v as ExampleNode, w as InputMeta, x as AuthRequirement, z as RefSchemaNode } from "./operation-BUhPuZMY.cjs";
9
+ import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-CPXo4cA8.cjs";
10
+ import { n as getNodeText, t as index_d_exports$8 } from "./index-Dr81DOsC.cjs";
11
+ import { n as index_d_exports$1, t as Node } from "./index-ss1YqjpW.cjs";
12
+ import { t as index_d_exports$5 } from "./index-gDZYBeJw.cjs";
13
+ import { n as index_d_exports$7 } from "./index-DR9ahJ-x.cjs";
14
+ import { n as DistributiveOmit, r as NodeKind } from "./base-UFBZi-FO.cjs";
15
+ import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-DxhkIQyP.cjs";
16
16
  /**
17
- * Runtime context passed as `this` to printer handlers.
17
+ * Runtime context passed to printer handlers, both as `this` and as the second argument.
18
18
  *
19
19
  * `this.transform` dispatches to node-level handlers from `nodes`.
20
20
  *
@@ -51,18 +51,16 @@ type PrinterHandlerContext<TOutput, TOptions extends object> = {
51
51
  parent?: SchemaNode;
52
52
  };
53
53
  /**
54
- * Handler for one schema node type.
55
- *
56
- * Use a regular function (not an arrow function) if you need `this`.
54
+ * Handler for one schema node type. The handler context is `this` and the second argument,
55
+ * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an
56
+ * arrow function asserts it with `ctx!`.
57
57
  *
58
58
  * @example
59
59
  * ```ts
60
- * const handler: PrinterHandler<string, {}, 'string'> = function () {
61
- * return 'string'
62
- * }
60
+ * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`
63
61
  * ```
64
62
  */
65
- type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (this: PrinterHandlerContext<TOutput, TOptions>, node: SchemaNodeByType[T]) => TOutput | null;
63
+ type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (this: PrinterHandlerContext<TOutput, TOptions>, node: SchemaNodeByType[T], ctx?: PrinterHandlerContext<TOutput, object>) => TOutput | null;
66
64
  /**
67
65
  * Partial map of per-node-type handler overrides for a printer.
68
66
  *
@@ -125,13 +123,15 @@ type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {
125
123
  * Always dispatches through the `nodes` map. Never calls the `print` override.
126
124
  * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.
127
125
  */
128
- transform: (node: SchemaNode, options?: Partial<T['options']>) => T['output'] | null;
126
+ transform: (node: SchemaNode) => T['output'] | null;
129
127
  /**
130
128
  * Public printer. If the builder provides a root-level `print`, this calls that
131
129
  * higher-level function (which may produce full declarations).
132
130
  * Otherwise, falls back to the node-level dispatcher.
133
131
  */
134
- print: (node: SchemaNode, options?: Partial<T['options']>) => T['printOutput'] | null;
132
+ print: (node: SchemaNode) => T['printOutput'] | null;
133
+ /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */
134
+ with: (extra: Partial<T['options']>) => Printer<T>;
135
135
  /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */
136
136
  drainImports: () => Array<ImportNode>;
137
137
  };
@@ -165,9 +165,9 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
165
165
  /**
166
166
  * Optional root-level print override. When provided, becomes the public `printer.print`.
167
167
  * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),
168
- * not the override itself, so recursion is safe.
168
+ * not the override itself, so recursion is safe. The root context is also the second argument.
169
169
  */
170
- print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null;
170
+ print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode, ctx: PrinterHandlerContext<T['output'], T['options']>) => T['printOutput'] | null;
171
171
  };
172
172
  /**
173
173
  * Creates a schema printer: a function that takes a `SchemaNode` and emits
package/dist/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- import { n as InlineLanguage, r as inlineFiles$1, t as index_d_exports$2 } from "./index-cpjUxIik.js";
2
- import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-Dp50LM3a.js";
3
- import { t as index_d_exports$4 } from "./index-DaHsMJ_S.js";
4
- import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-CFH4ZC7q.js";
5
- import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-DNiIem0x.js";
6
- import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-D-h9R_sV.js";
7
- import { _ as TextNode, a as UserFileNode, d as BreakNode, f as CodeNode, g as JsxNode, h as JSDocNode, i as SourceNode, m as FunctionNode, n as FileNode, p as ConstNode, r as ImportNode, t as ExportNode, u as ArrowFunctionNode, v as TypeNode } from "./file-xJnBQPGq.js";
8
- import { A as ArraySchemaNode, B as ScalarSchemaNode, C as ExternalDocs, D as InputTag, E as InputServer, F as NotSchemaNode, G as StringSchemaNode, H as SchemaNode, I as NumberSchemaNode, J as UrlSchemaNode, K as TimeSchemaNode, L as ObjectSchemaNode, M as DatetimeSchemaNode, N as EnumSchemaNode, O as OAuthFlow, P as IntersectionSchemaNode, R as PrimitiveSchemaType, S as AuthScheme, T as InputNode, U as SchemaNodeByType, V as ScalarSchemaType, W as SchemaType, X as PropertyNode, _ as EncodingNode, b as AuthCredential, c as StatusCode, f as ParameterLocation, g as ContentNode, i as OperationNode, j as DateSchemaNode, m as ParameterStyle, n as HttpMethod, o as ResponseLink, p as ParameterNode, q as UnionSchemaNode, r as HttpOperationNode, s as ResponseNode, t as GenericOperationNode, u as RequestBodyNode, v as ExampleNode, w as InputMeta, x as AuthRequirement, z as RefSchemaNode } from "./operation-BgRyVS7z.js";
9
- import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-CAGuKv6t.js";
10
- import { n as getNodeText, t as index_d_exports$8 } from "./index-D3M2spDR.js";
11
- import { n as index_d_exports$1, t as Node } from "./index-BwnMIoLl.js";
12
- import { t as index_d_exports$5 } from "./index-eGkM4FE9.js";
13
- import { n as index_d_exports$7 } from "./index-Cc2K3OzU.js";
14
- import { n as DistributiveOmit, r as NodeKind } from "./base-IpYuh3ZP.js";
15
- import { a as findSchema$1, i as collect$1, n as VisitorContext, o as transform$1, t as Visitor } from "./visitor-BZozlXBF.js";
1
+ import { n as InlineLanguage, r as inlineFiles$1, t as index_d_exports$2 } from "./index-jWtEIa7j.js";
2
+ import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-B5w-X5V6.js";
3
+ import { t as index_d_exports$4 } from "./index-CI6Tu2c7.js";
4
+ import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-CnY3KmAg.js";
5
+ import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-C6w6KQSY.js";
6
+ import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-9l1xMEl_.js";
7
+ import { _ as TextNode, a as UserFileNode, d as BreakNode, f as CodeNode, g as JsxNode, h as JSDocNode, i as SourceNode, m as FunctionNode, n as FileNode, p as ConstNode, r as ImportNode, t as ExportNode, u as ArrowFunctionNode, v as TypeNode } from "./file-DkFGn_Os.js";
8
+ import { A as ArraySchemaNode, B as ScalarSchemaNode, C as ExternalDocs, D as InputTag, E as InputServer, F as NotSchemaNode, G as StringSchemaNode, H as SchemaNode, I as NumberSchemaNode, J as UrlSchemaNode, K as TimeSchemaNode, L as ObjectSchemaNode, M as DatetimeSchemaNode, N as EnumSchemaNode, O as OAuthFlow, P as IntersectionSchemaNode, R as PrimitiveSchemaType, S as AuthScheme, T as InputNode, U as SchemaNodeByType, V as ScalarSchemaType, W as SchemaType, X as PropertyNode, _ as EncodingNode, b as AuthCredential, c as StatusCode, f as ParameterLocation, g as ContentNode, i as OperationNode, j as DateSchemaNode, m as ParameterStyle, n as HttpMethod, o as ResponseLink, p as ParameterNode, q as UnionSchemaNode, r as HttpOperationNode, s as ResponseNode, t as GenericOperationNode, u as RequestBodyNode, v as ExampleNode, w as InputMeta, x as AuthRequirement, z as RefSchemaNode } from "./operation-jxEr2No4.js";
9
+ import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-CwFC71XK.js";
10
+ import { n as getNodeText, t as index_d_exports$8 } from "./index-DjThtAn4.js";
11
+ import { n as index_d_exports$1, t as Node } from "./index-Be5d4Zcl.js";
12
+ import { t as index_d_exports$5 } from "./index-CX7yfAGI.js";
13
+ import { n as index_d_exports$7 } from "./index-C-nsgwuD.js";
14
+ import { n as DistributiveOmit, r as NodeKind } from "./base-LhsPvVY1.js";
15
+ import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-CFbuH7BY.js";
16
16
  /**
17
- * Runtime context passed as `this` to printer handlers.
17
+ * Runtime context passed to printer handlers, both as `this` and as the second argument.
18
18
  *
19
19
  * `this.transform` dispatches to node-level handlers from `nodes`.
20
20
  *
@@ -51,18 +51,16 @@ type PrinterHandlerContext<TOutput, TOptions extends object> = {
51
51
  parent?: SchemaNode;
52
52
  };
53
53
  /**
54
- * Handler for one schema node type.
55
- *
56
- * Use a regular function (not an arrow function) if you need `this`.
54
+ * Handler for one schema node type. The handler context is `this` and the second argument,
55
+ * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an
56
+ * arrow function asserts it with `ctx!`.
57
57
  *
58
58
  * @example
59
59
  * ```ts
60
- * const handler: PrinterHandler<string, {}, 'string'> = function () {
61
- * return 'string'
62
- * }
60
+ * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`
63
61
  * ```
64
62
  */
65
- type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (this: PrinterHandlerContext<TOutput, TOptions>, node: SchemaNodeByType[T]) => TOutput | null;
63
+ type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (this: PrinterHandlerContext<TOutput, TOptions>, node: SchemaNodeByType[T], ctx?: PrinterHandlerContext<TOutput, object>) => TOutput | null;
66
64
  /**
67
65
  * Partial map of per-node-type handler overrides for a printer.
68
66
  *
@@ -125,13 +123,15 @@ type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {
125
123
  * Always dispatches through the `nodes` map. Never calls the `print` override.
126
124
  * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.
127
125
  */
128
- transform: (node: SchemaNode, options?: Partial<T['options']>) => T['output'] | null;
126
+ transform: (node: SchemaNode) => T['output'] | null;
129
127
  /**
130
128
  * Public printer. If the builder provides a root-level `print`, this calls that
131
129
  * higher-level function (which may produce full declarations).
132
130
  * Otherwise, falls back to the node-level dispatcher.
133
131
  */
134
- print: (node: SchemaNode, options?: Partial<T['options']>) => T['printOutput'] | null;
132
+ print: (node: SchemaNode) => T['printOutput'] | null;
133
+ /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */
134
+ with: (extra: Partial<T['options']>) => Printer<T>;
135
135
  /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */
136
136
  drainImports: () => Array<ImportNode>;
137
137
  };
@@ -165,9 +165,9 @@ type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) =
165
165
  /**
166
166
  * Optional root-level print override. When provided, becomes the public `printer.print`.
167
167
  * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),
168
- * not the override itself, so recursion is safe.
168
+ * not the override itself, so recursion is safe. The root context is also the second argument.
169
169
  */
170
- print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null;
170
+ print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode, ctx: PrinterHandlerContext<T['output'], T['options']>) => T['printOutput'] | null;
171
171
  };
172
172
  /**
173
173
  * Creates a schema printer: a function that takes a `SchemaNode` and emits
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { n as __name, t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
2
- import { n as schemaTypes$1, t as nodeKinds$1 } from "./constants-Ckeonm-D.js";
3
- import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as graph_exports } from "./graph-BcwFCvei.js";
4
- import { n as findSchema$1, r as transform$1, t as collect$1 } from "./visitor-NoQSUQTu.js";
5
- import { r as ref_exports, t as getName } from "./ref-Bu7PoHar.js";
6
- import { a as resolveSchemaProperties$1, i as inferDiscriminatorPropertyName$1, n as schema_exports, r as getSchemaLiteralValues$1 } from "./schema-DloctnMm.js";
7
- import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-DlJkKsT1.js";
8
- import { i as resolveRef$1, n as mergeRefWithSchema$1, t as isBareRef$1 } from "./refs-YCV3CznS.js";
9
- import { i as defineMacro$1, n as applyMacros$1, r as compareMacroOrder, t as macro_exports } from "./macro-D0KfNtff.js";
10
- import { t as applyOptionality } from "./optionality-DISn8ytP.js";
11
- import { t as node_exports } from "./node-Djh-mZB2.js";
12
- import { n as inlineFiles$1, t as file_exports } from "./file-CvlMAp_d.js";
13
- import { n as getNodeText } from "./nodeText-DVVDZQjF.js";
14
- import { t as nodes_exports } from "./nodes-CWMa9xhW.js";
15
- import { t as http_exports } from "./http-DwboM6pK.js";
16
- import { t as json_exports } from "./json-DH7_lcWm.js";
17
- import { r as mediaType_exports } from "./mediaType-CRjggmoG.js";
2
+ import { n as schemaTypes$1, t as nodeKinds$1 } from "./constants-BTTus9ee.js";
3
+ import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as graph_exports } from "./graph-BUEOBomo.js";
4
+ import { n as findSchema$1, r as transform$1, t as collect$1 } from "./visitor-XA0W3OVv.js";
5
+ import { r as ref_exports, t as getName } from "./ref-DPqeS8K1.js";
6
+ import { a as resolveSchemaProperties$1, i as inferDiscriminatorPropertyName$1, n as schema_exports, r as getSchemaLiteralValues$1 } from "./schema-4UcdIPQ2.js";
7
+ import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-DKw4uwc5.js";
8
+ import { i as resolveRef$1, n as mergeRefWithSchema$1, t as isBareRef$1 } from "./refs-Bgf8_9Ui.js";
9
+ import { i as defineMacro$1, n as applyMacros$1, r as compareMacroOrder, t as macro_exports } from "./macro-9WouvtZe.js";
10
+ import { t as node_exports } from "./node-DtuO3zr8.js";
11
+ import { t as applyOptionality } from "./optionality-FkRredTC.js";
12
+ import { n as inlineFiles$1, t as file_exports } from "./file-Dj9lsbJu.js";
13
+ import { n as getNodeText } from "./nodeText-BSYvDZOH.js";
14
+ import { t as nodes_exports } from "./nodes-CwYIFVt5.js";
15
+ import { t as http_exports } from "./http-CAWf6TAJ.js";
16
+ import { t as json_exports } from "./json-DyDtIZTj.js";
17
+ import { r as mediaType_exports } from "./mediaType-DXQCNYdM.js";
18
18
  // src/createPrinter.ts
19
19
  /**
20
20
  * Creates a schema printer: a function that takes a `SchemaNode` and emits
@@ -75,7 +75,8 @@ function createPrinter$1(build) {
75
75
  const dispatch = (table, node, options, parent) => {
76
76
  const handler = table[node.type];
77
77
  if (!handler) return null;
78
- return handler.call(createContext(options, node, parent), node);
78
+ const context = createContext(options, node, parent);
79
+ return handler.call(context, node, context);
79
80
  };
80
81
  function createContext(options, current, parent) {
81
82
  const context = {
@@ -87,14 +88,19 @@ function createPrinter$1(build) {
87
88
  };
88
89
  return context;
89
90
  }
90
- const root = createContext(resolvedOptions);
91
- return {
92
- name,
93
- options: resolvedOptions,
94
- transform: root.transform,
95
- print: printOverride ? (node, extra) => printOverride.call(extra ? createContext(withOptions(resolvedOptions, extra)) : root, node) : root.transform,
96
- drainImports: () => collectedImports.splice(0)
91
+ const drainImports = () => collectedImports.splice(0);
92
+ const toPrinter = (options) => {
93
+ const root = createContext(options);
94
+ return {
95
+ name,
96
+ options,
97
+ transform: (node) => root.transform(node),
98
+ print: printOverride ? (node) => printOverride.call(root, node, root) : (node) => root.transform(node),
99
+ with: (extra) => toPrinter(withOptions(options, extra)),
100
+ drainImports
101
+ };
97
102
  };
103
+ return toPrinter(resolvedOptions);
98
104
  };
99
105
  }
100
106
  __name(createPrinter$1, "createPrinter");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createPrinter","ref.isAlias","mergeRef","ref.getName","ref.getSchema","graph.getImportedNames","graph.getRefNames","graph.getUsedNames","graph.getCircularNames","schema.getLiterals","schema.inferDiscriminator","schema.findProperties","http.isOperation","node.collect","schema.applyOptionality","node.getText","macro.compareOrder","createPrinterImpl","defineMacroImpl","macro.apply","node.kinds","schema.types","schema.find","schema.narrow","node.transform","file.inline"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed as `this` to printer handlers.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type.\n *\n * Use a regular function (not an arrow function) if you need `this`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'string'> = function () {\n * return 'string'\n * }\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode, options?: Partial<T['options']>) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode, options?: Partial<T['options']>) => T['printOutput'] | null\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe.\n */\n print?: (this: PrinterHandlerContext<T['output'], T['options']>, node: SchemaNode) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n return (handler as (this: Context, node: SchemaNode) => T['output'] | null).call(createContext(options, node, parent), node)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const root = createContext(resolvedOptions)\n\n return {\n name,\n options: resolvedOptions,\n transform: root.transform,\n print: (printOverride\n ? (node: SchemaNode, extra?: Partial<T['options']>) => printOverride.call(extra ? createContext(withOptions(resolvedOptions, extra)) : root, node)\n : root.transform) as Printer<T>['print'],\n drainImports: () => collectedImports.splice(0),\n }\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport * as ref from './ref/index.ts'\nexport * as schema from './schema/index.ts'\nexport type * from './types.ts'\nexport * as ast from './index.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkNA,SAAgBA,gBAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,WAAW,OAAO,kBAAkB,MAAO,WAAW,CAAC,CAAkB;EACxH,MAAM,SAAS,YAAY;GAAE,GAAG;GAAO,GAAG;EAAU,IAAI;EAExD,MAAM,mBAAsC,CAAC;EAC7C,MAAM,cAAc,SAA2B;GAC7C,iBAAiB,KAAK,IAAI;EAC5B;EAEA,MAAM,eAAe,SAAuB,UAAiD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAM,IAAI;EAEhI,MAAM,YAAY,OAAkD,MAAkB,SAAuB,WAA4C;GACvJ,MAAM,UAAU,MAAM,KAAK;GAC3B,IAAI,CAAC,SAAS,OAAO;GAErB,OAAQ,QAAoE,KAAK,cAAc,SAAS,MAAM,MAAM,GAAG,IAAI;EAC7H;EAGA,SAAS,cAAc,SAAuB,SAAsB,QAA8B;GAChG,MAAM,UAAmB;IACvB;IACA;IACA,QAAQ;IACR,YAAY,MAAM,UAAU,SAAS,QAAQ,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,OAAO;IAC/F,OAAO,MAAM,UAAU,SAAS,OAAO,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,MAAM;GAC1F;GACA,OAAO;EACT;EAEA,MAAM,OAAO,cAAc,eAAe;EAE1C,OAAO;GACL;GACA,SAAS;GACT,WAAW,KAAK;GAChB,OAAQ,iBACH,MAAkB,UAAkC,cAAc,KAAK,QAAQ,cAAc,YAAY,iBAAiB,KAAK,CAAC,IAAI,MAAM,IAAI,IAC/I,KAAK;GACT,oBAAoB,iBAAiB,OAAO,CAAC;EAC/C;CACF;AACF;;;;ACjPA,MAAa,YAAYC;;AAGzB,MAAa,qBAAqBC;;AAGlC,MAAa,UAAUC;;AAGvB,MAAa,aAAaC;;AAG1B,MAAa,iBAAiBD;;AAG9B,MAAa,0BAA0BE;;AAGvC,MAAa,oBAAoBC;;AAGjC,MAAa,yBAAyBC;;AAGtC,MAAa,sBAAsBC;;AAGnC,MAAa,yBAAyBC;;AAGtC,MAAa,iCAAiCC;;AAG9C,MAAa,0BAA0BC;;AAGvC,MAAa,sBAAsBC;;AAGnC,MAAa,cAAcC;;AAG3B,MAAa,cAAcC;;AAG3B,MAAa,0BAA0BC;;AAGvC,MAAa,iBAAiBC;;AAG9B,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC;;AAG3B,MAAa,cAAcC;;AAG3B,MAAa,YAAYC;;AAGzB,MAAa,cAAcC;;AAG3B,MAAa,aAAaC;;AAG1B,MAAa,eAAeC;;AAG5B,MAAa,YAAYC;;AAGzB,MAAa,UAAUX;;AAGvB,MAAa,cAAcY"}
1
+ {"version":3,"file":"index.js","names":["createPrinter","ref.isAlias","mergeRef","ref.getName","ref.getSchema","graph.getImportedNames","graph.getRefNames","graph.getUsedNames","graph.getCircularNames","schema.getLiterals","schema.inferDiscriminator","schema.findProperties","http.isOperation","node.collect","schema.applyOptionality","node.getText","macro.compareOrder","createPrinterImpl","defineMacroImpl","macro.apply","node.kinds","schema.types","schema.find","schema.narrow","node.transform","file.inline"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed to printer handlers, both as `this` and as the second argument.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type. The handler context is `this` and the second argument,\n * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an\n * arrow function asserts it with `ctx!`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n // Optional and without the options type, so one-argument handler types stay assignable and\n // a union of printer tables keeps its contextual `this`. Use `this.options` for typed options.\n ctx?: PrinterHandlerContext<TOutput, object>,\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */\n with: (extra: Partial<T['options']>) => Printer<T>\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe. The root context is also the second argument.\n */\n print?: (\n this: PrinterHandlerContext<T['output'], T['options']>,\n node: SchemaNode,\n ctx: PrinterHandlerContext<T['output'], T['options']>,\n ) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n const context = createContext(options, node, parent)\n return (handler as (this: Context, node: SchemaNode, ctx: Context) => T['output'] | null).call(context, node, context)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const drainImports = () => collectedImports.splice(0)\n\n const toPrinter = (options: T['options']): Printer<T> => {\n const root = createContext(options)\n return {\n name,\n options,\n transform: (node) => root.transform(node),\n print: (printOverride ? (node: SchemaNode) => printOverride.call(root, node, root) : (node: SchemaNode) => root.transform(node)) as Printer<T>['print'],\n with: (extra) => toPrinter(withOptions(options, extra)),\n drainImports,\n }\n }\n\n return toPrinter(resolvedOptions)\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport * as ref from './ref/index.ts'\nexport * as schema from './schema/index.ts'\nexport type * from './types.ts'\nexport * as ast from './index.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyNA,SAAgBA,gBAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,WAAW,OAAO,kBAAkB,MAAO,WAAW,CAAC,CAAkB;EACxH,MAAM,SAAS,YAAY;GAAE,GAAG;GAAO,GAAG;EAAU,IAAI;EAExD,MAAM,mBAAsC,CAAC;EAC7C,MAAM,cAAc,SAA2B;GAC7C,iBAAiB,KAAK,IAAI;EAC5B;EAEA,MAAM,eAAe,SAAuB,UAAiD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAM,IAAI;EAEhI,MAAM,YAAY,OAAkD,MAAkB,SAAuB,WAA4C;GACvJ,MAAM,UAAU,MAAM,KAAK;GAC3B,IAAI,CAAC,SAAS,OAAO;GAErB,MAAM,UAAU,cAAc,SAAS,MAAM,MAAM;GACnD,OAAQ,QAAkF,KAAK,SAAS,MAAM,OAAO;EACvH;EAGA,SAAS,cAAc,SAAuB,SAAsB,QAA8B;GAChG,MAAM,UAAmB;IACvB;IACA;IACA,QAAQ;IACR,YAAY,MAAM,UAAU,SAAS,QAAQ,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,OAAO;IAC/F,OAAO,MAAM,UAAU,SAAS,OAAO,MAAM,YAAY,QAAQ,SAAS,KAAK,GAAG,MAAM;GAC1F;GACA,OAAO;EACT;EAEA,MAAM,qBAAqB,iBAAiB,OAAO,CAAC;EAEpD,MAAM,aAAa,YAAsC;GACvD,MAAM,OAAO,cAAc,OAAO;GAClC,OAAO;IACL;IACA;IACA,YAAY,SAAS,KAAK,UAAU,IAAI;IACxC,OAAQ,iBAAiB,SAAqB,cAAc,KAAK,MAAM,MAAM,IAAI,KAAK,SAAqB,KAAK,UAAU,IAAI;IAC9H,OAAO,UAAU,UAAU,YAAY,SAAS,KAAK,CAAC;IACtD;GACF;EACF;EAEA,OAAO,UAAU,eAAe;CAClC;AACF;;;;AC7PA,MAAa,YAAYC;;AAGzB,MAAa,qBAAqBC;;AAGlC,MAAa,UAAUC;;AAGvB,MAAa,aAAaC;;AAG1B,MAAa,iBAAiBD;;AAG9B,MAAa,0BAA0BE;;AAGvC,MAAa,oBAAoBC;;AAGjC,MAAa,yBAAyBC;;AAGtC,MAAa,sBAAsBC;;AAGnC,MAAa,yBAAyBC;;AAGtC,MAAa,iCAAiCC;;AAG9C,MAAa,0BAA0BC;;AAGvC,MAAa,sBAAsBC;;AAGnC,MAAa,cAAcC;;AAG3B,MAAa,cAAcC;;AAG3B,MAAa,0BAA0BC;;AAGvC,MAAa,iBAAiBC;;AAG9B,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC;;AAG3B,MAAa,cAAcC;;AAG3B,MAAa,YAAYC;;AAGzB,MAAa,cAAcC;;AAG3B,MAAa,aAAaC;;AAG1B,MAAa,eAAeC;;AAG5B,MAAa,YAAYC;;AAGzB,MAAa,UAAUX;;AAGvB,MAAa,cAAcY"}