@kubb/agent 5.0.0-alpha.34 → 5.0.0-alpha.36

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 (183) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +16 -14
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +16 -14
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
  9. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
  10. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
  11. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
  12. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
  13. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
  14. package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
  15. package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
  16. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
  17. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
  18. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
  19. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
  20. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
  21. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
  22. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
  23. package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
  24. package/.output/server/node_modules/@clack/core/package.json +60 -0
  25. package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
  26. package/.output/server/node_modules/@clack/prompts/package.json +65 -0
  27. package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
  28. package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
  29. package/.output/server/node_modules/@kubb/ast/package.json +70 -0
  30. package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
  31. package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
  32. package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
  33. package/.output/server/node_modules/@kubb/core/package.json +109 -0
  34. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
  35. package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
  36. package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
  37. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
  38. package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
  39. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
  40. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
  41. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
  42. package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
  43. package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
  44. package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
  45. package/.output/server/node_modules/@kubb/oas/package.json +94 -0
  46. package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
  47. package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
  48. package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
  49. package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
  50. package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
  51. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
  52. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
  53. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
  54. package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
  55. package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
  56. package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
  57. package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
  58. package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
  59. package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
  60. package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
  61. package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
  62. package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
  63. package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
  64. package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
  65. package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
  66. package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
  67. package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
  68. package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
  69. package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
  70. package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
  71. package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
  72. package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
  73. package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
  74. package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
  75. package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
  76. package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
  77. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
  78. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
  79. package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
  80. package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
  81. package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
  82. package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
  83. package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
  84. package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
  85. package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
  86. package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
  87. package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
  88. package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
  89. package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
  90. package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
  91. package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
  92. package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
  93. package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
  94. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
  95. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
  96. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
  97. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
  98. package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
  99. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
  100. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
  101. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
  102. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
  103. package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
  104. package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
  105. package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
  106. package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
  107. package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
  108. package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
  109. package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
  110. package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
  111. package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
  112. package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
  113. package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
  114. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
  115. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
  116. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
  117. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
  118. package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
  119. package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
  120. package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
  121. package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
  122. package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
  123. package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
  124. package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
  125. package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
  126. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
  127. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
  128. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
  129. package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
  130. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
  131. package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
  132. package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
  133. package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
  134. package/.output/server/node_modules/@redocly/config/package.json +1 -1
  135. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
  136. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
  137. package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
  138. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
  139. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
  140. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
  141. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
  142. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
  143. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
  144. package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
  145. package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
  146. package/.output/server/node_modules/buffer-from/index.js +72 -0
  147. package/.output/server/node_modules/buffer-from/package.json +19 -0
  148. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  149. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  150. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  151. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  152. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  153. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  154. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  155. package/.output/server/node_modules/p-limit/index.js +127 -0
  156. package/.output/server/node_modules/p-limit/package.json +58 -0
  157. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  158. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  159. package/.output/server/node_modules/sisteransi/package.json +34 -0
  160. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  161. package/.output/server/node_modules/source-map-support/package.json +31 -0
  162. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  163. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  164. package/.output/server/node_modules/typescript/package.json +120 -0
  165. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  166. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  167. package/.output/server/package.json +35 -4
  168. package/package.json +20 -20
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  181. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  182. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  183. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,101 @@
1
+ import "../chunk-O_arW02_.js";
2
+ import { n as defineParser, r as trimExtName, t as getRelativePath } from "../getRelativePath-NAm_Y-vp.js";
3
+ import path from "node:path";
4
+ import ts from "typescript";
5
+ //#region src/parsers/typescriptParser.ts
6
+ const { factory } = ts;
7
+ /**
8
+ * Validates TypeScript AST nodes before printing to catch invalid nodes early.
9
+ * Throws an error if any node has SyntaxKind.Unknown which would cause the TypeScript printer to crash.
10
+ */
11
+ function validateNodes(...nodes) {
12
+ for (const node of nodes) {
13
+ if (!node) throw new Error("Attempted to print undefined or null TypeScript node");
14
+ if (node.kind === ts.SyntaxKind.Unknown) throw new Error(`Invalid TypeScript AST node detected with SyntaxKind.Unknown. This typically indicates a schema pattern that couldn't be properly converted to TypeScript. Node: ${JSON.stringify(node, null, 2)}`);
15
+ }
16
+ }
17
+ /**
18
+ * Convert AST TypeScript/TSX nodes to a string based on the TypeScript printer.
19
+ */
20
+ function print(...elements) {
21
+ const sourceFile = ts.createSourceFile("print.tsx", "", ts.ScriptTarget.ES2022, true, ts.ScriptKind.TSX);
22
+ const printer = ts.createPrinter({
23
+ omitTrailingSemicolon: true,
24
+ newLine: ts.NewLineKind.LineFeed,
25
+ removeComments: false,
26
+ noEmitHelpers: true
27
+ });
28
+ for (const node of elements) if (node.kind === ts.SyntaxKind.Unknown) console.error("⚠️ Unknown node found:", node);
29
+ return printer.printList(ts.ListFormat.MultiLine, factory.createNodeArray(elements.filter(Boolean)), sourceFile).replace(/\r\n/g, "\n");
30
+ }
31
+ function safePrint(...elements) {
32
+ validateNodes(...elements);
33
+ return print(...elements);
34
+ }
35
+ function createImport({ name, path, root, isTypeOnly = false, isNameSpace = false }) {
36
+ const resolvePath = root ? getRelativePath(root, path) : path;
37
+ if (!Array.isArray(name)) {
38
+ if (isNameSpace) return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamespaceImport(factory.createIdentifier(name))), factory.createStringLiteral(resolvePath), void 0);
39
+ return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, factory.createIdentifier(name), void 0), factory.createStringLiteral(resolvePath), void 0);
40
+ }
41
+ const specifiers = name.map((item) => {
42
+ if (typeof item === "object") {
43
+ const { propertyName, name: alias } = item;
44
+ return factory.createImportSpecifier(false, alias ? factory.createIdentifier(propertyName) : void 0, factory.createIdentifier(alias ?? propertyName));
45
+ }
46
+ return factory.createImportSpecifier(false, void 0, factory.createIdentifier(item));
47
+ });
48
+ return factory.createImportDeclaration(void 0, factory.createImportClause(isTypeOnly, void 0, factory.createNamedImports(specifiers)), factory.createStringLiteral(resolvePath), void 0);
49
+ }
50
+ function createExport({ path, asAlias, isTypeOnly = false, name }) {
51
+ if (name && !Array.isArray(name) && !asAlias) console.warn(`When using name as string, asAlias should be true ${name}`);
52
+ if (!Array.isArray(name)) {
53
+ const parsedName = name?.match(/^\d/) ? `_${name?.slice(1)}` : name;
54
+ return factory.createExportDeclaration(void 0, isTypeOnly, asAlias && parsedName ? factory.createNamespaceExport(factory.createIdentifier(parsedName)) : void 0, factory.createStringLiteral(path), void 0);
55
+ }
56
+ return factory.createExportDeclaration(void 0, isTypeOnly, factory.createNamedExports(name.map((propertyName) => {
57
+ return factory.createExportSpecifier(false, void 0, typeof propertyName === "string" ? factory.createIdentifier(propertyName) : propertyName);
58
+ })), factory.createStringLiteral(path), void 0);
59
+ }
60
+ const typescriptParser = defineParser({
61
+ name: "typescript",
62
+ extNames: [".ts", ".js"],
63
+ install() {},
64
+ async parse(file, options = { extname: ".ts" }) {
65
+ const sourceParts = [];
66
+ for (const item of file.sources) if (item.value) sourceParts.push(item.value);
67
+ const source = sourceParts.join("\n\n");
68
+ const importNodes = [];
69
+ for (const item of file.imports) {
70
+ const importPath = item.root ? getRelativePath(item.root, item.path) : item.path;
71
+ const hasExtname = !!path.extname(importPath);
72
+ importNodes.push(createImport({
73
+ name: item.name,
74
+ path: options.extname && hasExtname ? `${trimExtName(importPath)}${options.extname}` : item.root ? trimExtName(importPath) : importPath,
75
+ isTypeOnly: item.isTypeOnly,
76
+ isNameSpace: item.isNameSpace
77
+ }));
78
+ }
79
+ const exportNodes = [];
80
+ for (const item of file.exports) {
81
+ const exportPath = item.path;
82
+ const hasExtname = !!path.extname(exportPath);
83
+ exportNodes.push(createExport({
84
+ name: item.name,
85
+ path: options.extname && hasExtname ? `${trimExtName(item.path)}${options.extname}` : trimExtName(item.path),
86
+ isTypeOnly: item.isTypeOnly,
87
+ asAlias: item.asAlias
88
+ }));
89
+ }
90
+ return [
91
+ file.banner,
92
+ print(...importNodes, ...exportNodes),
93
+ source,
94
+ file.footer
95
+ ].filter((segment) => segment != null).join("\n");
96
+ }
97
+ });
98
+ //#endregion
99
+ export { createExport, createImport, print, safePrint, typescriptParser, validateNodes };
100
+
101
+ //# sourceMappingURL=typescript.js.map
@@ -0,0 +1,17 @@
1
+ import "./chunk-O_arW02_.js";
2
+ import { n as defineParser } from "./getRelativePath-NAm_Y-vp.js";
3
+ import { t as defaultParser } from "./defaultParser-iCpMSYCp.js";
4
+ import { typescriptParser } from "./parsers/typescript.js";
5
+ //#region src/parsers/tsxParser.ts
6
+ const tsxParser = defineParser({
7
+ name: "tsx",
8
+ extNames: [".tsx", ".jsx"],
9
+ install() {},
10
+ async parse(file, options = { extname: ".tsx" }) {
11
+ return typescriptParser.parse(file, options);
12
+ }
13
+ });
14
+ //#endregion
15
+ export { defaultParser, defineParser, tsxParser, typescriptParser };
16
+
17
+ //# sourceMappingURL=parsers.js.map
@@ -0,0 +1,375 @@
1
+ import "./chunk-O_arW02_.js";
2
+ import { c as createFile, i as TreeNode, n as Root, t as onProcessExit } from "./onProcessExit-Cput7j2c.js";
3
+ import { t as getRelativePath } from "./getRelativePath-NAm_Y-vp.js";
4
+ import path, { dirname, relative, resolve } from "node:path";
5
+ import { rmSync } from "node:fs";
6
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
7
+ import { styleText } from "node:util";
8
+ import * as clack from "@clack/prompts";
9
+ //#region src/plugins/definePlugin.ts
10
+ /**
11
+ * Defines a Fabric plugin with type safety.
12
+ *
13
+ * Use this function to create plugins that hook into Fabric's lifecycle
14
+ * events and extend its functionality.
15
+ *
16
+ * @param plugin - The plugin configuration object
17
+ * @returns A typed plugin ready to use with Fabric
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { definePlugin } from '@kubb/fabric-core'
22
+ *
23
+ * export const myPlugin = definePlugin({
24
+ * name: 'my-plugin',
25
+ * async setup(fabric) {
26
+ * fabric.context.on('write:start', (files) => {
27
+ * console.log(`Writing ${files.length} files`)
28
+ * })
29
+ * }
30
+ * })
31
+ * ```
32
+ */
33
+ function definePlugin(plugin) {
34
+ return {
35
+ type: "plugin",
36
+ ...plugin
37
+ };
38
+ }
39
+ //#endregion
40
+ //#region src/plugins/barrelPlugin.ts
41
+ /** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */
42
+ function getBarrelFiles({ files, root, mode }) {
43
+ if (mode === "propagate" || mode === false) return [];
44
+ const indexableSourcesMap = /* @__PURE__ */ new Map();
45
+ for (const file of files) {
46
+ const indexableSources = [];
47
+ for (const source of file.sources || []) if (source.isIndexable && source.name) indexableSources.push(source);
48
+ if (indexableSources.length > 0) indexableSourcesMap.set(file, indexableSources);
49
+ }
50
+ const cachedFiles = /* @__PURE__ */ new Map();
51
+ const dedupe = /* @__PURE__ */ new Map();
52
+ const treeNode = TreeNode.fromFiles(files, root);
53
+ if (!treeNode) return [];
54
+ treeNode.forEach((node) => {
55
+ if (!node?.children || !node.parent?.data.path) return;
56
+ const parentPath = node.parent.data.path;
57
+ const barrelPath = path.join(parentPath, "index.ts");
58
+ let barrelFile = cachedFiles.get(barrelPath);
59
+ if (!barrelFile) {
60
+ barrelFile = createFile({
61
+ path: barrelPath,
62
+ baseName: "index.ts",
63
+ imports: [],
64
+ exports: [],
65
+ sources: []
66
+ });
67
+ cachedFiles.set(barrelPath, barrelFile);
68
+ dedupe.set(barrelPath, /* @__PURE__ */ new Set());
69
+ }
70
+ const seen = dedupe.get(barrelPath);
71
+ for (const leaf of node.leaves) {
72
+ const file = leaf.data.file;
73
+ if (!file || !file.path) continue;
74
+ const indexableSources = indexableSourcesMap.get(file);
75
+ if (!indexableSources) continue;
76
+ for (const source of indexableSources) {
77
+ const key = `${source.name}|${source.isTypeOnly ? "1" : "0"}`;
78
+ if (seen.has(key)) continue;
79
+ seen.add(key);
80
+ barrelFile.exports.push({
81
+ name: [source.name],
82
+ path: getRelativePath(parentPath, file.path),
83
+ isTypeOnly: source.isTypeOnly
84
+ });
85
+ barrelFile.sources.push({
86
+ name: source.name,
87
+ isTypeOnly: source.isTypeOnly,
88
+ value: "",
89
+ isExportable: mode === "all" || mode === "named",
90
+ isIndexable: mode === "all" || mode === "named"
91
+ });
92
+ }
93
+ }
94
+ });
95
+ const result = [...cachedFiles.values()];
96
+ if (mode === "all") return result.map((file) => ({
97
+ ...file,
98
+ exports: file.exports?.map((e) => ({
99
+ ...e,
100
+ name: void 0
101
+ }))
102
+ }));
103
+ return result;
104
+ }
105
+ const barrelPlugin = definePlugin({
106
+ name: "barrel",
107
+ install(ctx, options) {
108
+ if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
109
+ if (!options.mode) return;
110
+ ctx.on("files:writing:start", async (files) => {
111
+ const root = options.root;
112
+ const barrelFiles = getBarrelFiles({
113
+ files,
114
+ root,
115
+ mode: options.mode
116
+ });
117
+ await ctx.fileManager.add(...barrelFiles);
118
+ });
119
+ },
120
+ inject(ctx, options) {
121
+ if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
122
+ return { async writeEntry({ root, mode }) {
123
+ if (!mode || mode === "propagate") return;
124
+ const rootPath = path.resolve(root, "index.ts");
125
+ const barrelFiles = [];
126
+ for (const file of ctx.files) for (const source of file.sources) if (source.isIndexable) {
127
+ barrelFiles.push(file);
128
+ break;
129
+ }
130
+ const fileTypeCache = /* @__PURE__ */ new Map();
131
+ for (const file of barrelFiles) fileTypeCache.set(file, file.sources.every((source) => source.isTypeOnly));
132
+ const exports = [];
133
+ for (const file of barrelFiles) {
134
+ const containsOnlyTypes = fileTypeCache.get(file) ?? false;
135
+ for (const source of file.sources) {
136
+ if (!file.path || !source.isIndexable) continue;
137
+ exports.push({
138
+ name: mode === "all" ? void 0 : [source.name],
139
+ path: getRelativePath(rootPath, file.path),
140
+ isTypeOnly: mode === "all" ? containsOnlyTypes : source.isTypeOnly
141
+ });
142
+ }
143
+ }
144
+ const entryFile = createFile({
145
+ path: rootPath,
146
+ baseName: "index.ts",
147
+ imports: [],
148
+ exports,
149
+ sources: []
150
+ });
151
+ await ctx.addFile(entryFile);
152
+ await ctx.fileManager.write({
153
+ mode: ctx.config.mode,
154
+ dryRun: options.dryRun,
155
+ parsers: ctx.installedParsers
156
+ });
157
+ } };
158
+ }
159
+ });
160
+ //#endregion
161
+ //#region src/plugins/fsPlugin.ts
162
+ async function write(path, data, options = {}) {
163
+ if (typeof Bun !== "undefined") {
164
+ if (!data || data?.trim() === "") return;
165
+ await Bun.write(resolve(path), data.trim());
166
+ if (options?.sanity) {
167
+ const savedData = await Bun.file(resolve(path)).text();
168
+ if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
169
+ return savedData;
170
+ }
171
+ return data;
172
+ }
173
+ if (!data || data?.trim() === "") return;
174
+ try {
175
+ if ((await readFile(resolve(path), { encoding: "utf-8" }))?.toString() === data?.toString()) return;
176
+ } catch (_err) {}
177
+ await mkdir(dirname(resolve(path)), { recursive: true });
178
+ await writeFile(resolve(path), data.trim(), { encoding: "utf-8" });
179
+ if (options?.sanity) {
180
+ const savedData = await readFile(resolve(path), { encoding: "utf-8" });
181
+ if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
182
+ return savedData;
183
+ }
184
+ return data;
185
+ }
186
+ const fsPlugin = definePlugin({
187
+ name: "fs",
188
+ install(ctx, options = {}) {
189
+ if (options.clean) rmSync(options.clean.path, {
190
+ recursive: true,
191
+ force: true
192
+ });
193
+ ctx.on("file:processing:update", async ({ file, source }) => {
194
+ if (options.onBeforeWrite) await options.onBeforeWrite(file.path, source);
195
+ await write(file.path, source, { sanity: false });
196
+ });
197
+ },
198
+ inject(ctx, { dryRun } = {}) {
199
+ return { async write(options = { extension: { ".ts": ".ts" } }) {
200
+ await ctx.fileManager.write({
201
+ mode: ctx.config.mode,
202
+ extension: options.extension,
203
+ dryRun,
204
+ parsers: ctx.installedParsers
205
+ });
206
+ await ctx.emit("lifecycle:end");
207
+ } };
208
+ }
209
+ });
210
+ //#endregion
211
+ //#region src/plugins/fsxPlugin/Runtime.ts
212
+ var Runtime = class {
213
+ #options;
214
+ exitPromise;
215
+ constructor(options) {
216
+ this.#options = options;
217
+ this.unsubscribeExit = onProcessExit((code) => {
218
+ this.unmount(code);
219
+ });
220
+ }
221
+ get fileManager() {
222
+ return this.#options.fileManager;
223
+ }
224
+ #renderPromise = Promise.resolve();
225
+ resolveExitPromise = () => {};
226
+ rejectExitPromise = () => {};
227
+ unsubscribeExit = () => {};
228
+ onError(error) {
229
+ throw error;
230
+ }
231
+ onExit(error) {
232
+ setTimeout(() => {
233
+ this.unmount(error);
234
+ }, 0);
235
+ }
236
+ async render(node) {
237
+ const treeNode = this.#options.treeNode || new TreeNode({
238
+ type: "Root",
239
+ props: {}
240
+ });
241
+ const props = {
242
+ fileManager: this.fileManager,
243
+ treeNode,
244
+ onExit: this.onExit.bind(this),
245
+ onError: this.onError.bind(this)
246
+ };
247
+ try {
248
+ treeNode.data.props = props;
249
+ const element = Root({
250
+ ...props,
251
+ children: node
252
+ });
253
+ await this.#renderPromise;
254
+ return element()?.toString() || "";
255
+ } catch (e) {
256
+ props.onError(e);
257
+ return "";
258
+ }
259
+ }
260
+ unmount(error) {
261
+ if (this.#options?.debug) console.log("Unmount", error);
262
+ this.unsubscribeExit();
263
+ if (error instanceof Error) {
264
+ this.rejectExitPromise(error);
265
+ return;
266
+ }
267
+ this.resolveExitPromise();
268
+ }
269
+ async waitUntilExit() {
270
+ if (!this.exitPromise) this.exitPromise = new Promise((resolve, reject) => {
271
+ this.resolveExitPromise = resolve;
272
+ this.rejectExitPromise = reject;
273
+ });
274
+ return this.exitPromise;
275
+ }
276
+ };
277
+ //#endregion
278
+ //#region src/plugins/fsxPlugin/fsxPlugin.ts
279
+ const fsxPlugin = definePlugin({
280
+ name: "fsx",
281
+ install() {},
282
+ inject(ctx, options = {}) {
283
+ const runtime = new Runtime({
284
+ fileManager: ctx.fileManager,
285
+ ...options
286
+ });
287
+ return {
288
+ async render(Fabric) {
289
+ await ctx.emit("lifecycle:start");
290
+ return runtime.render(Fabric);
291
+ },
292
+ async waitUntilExit() {
293
+ await runtime.waitUntilExit();
294
+ }
295
+ };
296
+ }
297
+ });
298
+ //#endregion
299
+ //#region src/plugins/loggerPlugin.ts
300
+ function pluralize(word, count) {
301
+ return `${count} ${word}${count === 1 ? "" : "s"}`;
302
+ }
303
+ const DEFAULT_PROGRESS_BAR_SIZE = 30;
304
+ const loggerPlugin = definePlugin({
305
+ name: "logger",
306
+ install(ctx, options = {}) {
307
+ const { progress = true } = options;
308
+ const state = {
309
+ spinner: clack.spinner(),
310
+ isSpinning: false,
311
+ progressBar: void 0
312
+ };
313
+ function formatPath(path) {
314
+ return relative(process.cwd(), path);
315
+ }
316
+ ctx.on("lifecycle:start", async () => {
317
+ clack.intro(`${styleText("blue", "Fabric")} ${styleText("dim", "Starting run")}`);
318
+ });
319
+ ctx.on("lifecycle:render", async () => {
320
+ clack.log.info(`${styleText("blue", "ℹ")} Rendering application graph`);
321
+ });
322
+ ctx.on("files:added", async (files) => {
323
+ if (!files.length) return;
324
+ clack.log.info(`${styleText("blue", "ℹ")} Queued ${pluralize("file", files.length)}`);
325
+ });
326
+ ctx.on("file:resolve:path", async (file) => {
327
+ clack.log.step(`Resolving path for ${styleText("dim", formatPath(file.path))}`);
328
+ });
329
+ ctx.on("file:resolve:name", async (file) => {
330
+ clack.log.step(`Resolving name for ${styleText("dim", formatPath(file.path))}`);
331
+ });
332
+ ctx.on("files:processing:start", async (files) => {
333
+ clack.log.step(`Processing ${styleText("green", pluralize("file", files.length))}`);
334
+ if (progress) {
335
+ state.progressBar = clack.progress({
336
+ style: "block",
337
+ max: files.length,
338
+ size: DEFAULT_PROGRESS_BAR_SIZE
339
+ });
340
+ state.progressBar.start(`Processing ${files.length} files`);
341
+ }
342
+ });
343
+ ctx.on("file:processing:start", async (file, index, total) => {
344
+ if (!state.progressBar) clack.log.step(`Processing ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
345
+ });
346
+ ctx.on("file:processing:update", async ({ processed, total, percentage, file }) => {
347
+ if (state.progressBar) state.progressBar.advance(void 0, `Writing ${formatPath(file.path)}`);
348
+ else {
349
+ const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : "0.0";
350
+ clack.log.step(`Progress ${styleText("green", `${formattedPercentage}%`)} ${styleText("dim", `(${processed}/${total})`)} → ${formatPath(file.path)}`);
351
+ }
352
+ });
353
+ ctx.on("file:processing:end", async (file, index, total) => {
354
+ if (state.progressBar) state.progressBar.message(`${styleText("green", "✓")} Finished ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
355
+ else clack.log.success(`${styleText("green", "✓")} Finished ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
356
+ });
357
+ ctx.on("files:processing:end", async (files) => {
358
+ if (state.progressBar) {
359
+ state.progressBar.stop(`${styleText("green", "✓")} Processed ${pluralize("file", files.length)}`);
360
+ state.progressBar = void 0;
361
+ } else clack.log.success(`${styleText("green", "✓")} Processed ${pluralize("file", files.length)}`);
362
+ });
363
+ ctx.on("lifecycle:end", async () => {
364
+ if (state.progressBar) {
365
+ state.progressBar.stop();
366
+ state.progressBar = void 0;
367
+ }
368
+ clack.outro(`${styleText("blue", "Fabric")} ${styleText("dim", "completed")}`);
369
+ });
370
+ }
371
+ });
372
+ //#endregion
373
+ export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin, loggerPlugin };
374
+
375
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1,111 @@
1
+ {
2
+ "name": "@kubb/fabric-core",
3
+ "version": "0.14.0",
4
+ "description": "Core functionality for Kubb's fabric - A language-agnostic toolkit providing the foundation for plugin-based code generation with TypeScript support",
5
+ "keywords": [
6
+ "codegen",
7
+ "code-generator",
8
+ "typescript",
9
+ "file-system",
10
+ "ast",
11
+ "parser",
12
+ "plugin-system",
13
+ "plugins",
14
+ "fabric",
15
+ "openapi",
16
+ "swagger",
17
+ "kubb"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/kubb-labs/fabric.git",
22
+ "directory": "packages/fabric-core"
23
+ },
24
+ "license": "MIT",
25
+ "author": "stijnvanhulle",
26
+ "sideEffects": false,
27
+ "type": "module",
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.cjs"
32
+ },
33
+ "./parsers": {
34
+ "import": "./dist/parsers.js",
35
+ "require": "./dist/parsers.cjs"
36
+ },
37
+ "./parsers/typescript": {
38
+ "import": "./dist/parsers/typescript.js",
39
+ "require": "./dist/parsers/typescript.cjs"
40
+ },
41
+ "./plugins": {
42
+ "import": "./dist/plugins.js",
43
+ "require": "./dist/plugins.cjs"
44
+ },
45
+ "./types": {
46
+ "import": "./dist/types.js",
47
+ "require": "./dist/types.cjs"
48
+ },
49
+ "./package.json": "./package.json"
50
+ },
51
+ "main": "./dist/index.cjs",
52
+ "module": "./dist/index.js",
53
+ "types": "./dist/index.d.ts",
54
+ "typesVersions": {
55
+ "*": {
56
+ "parsers": [
57
+ "./dist/parsers.d.ts"
58
+ ],
59
+ "parsers/typescript": [
60
+ "./dist/parsers/typescript.d.ts"
61
+ ],
62
+ "plugins": [
63
+ "./dist/plugins.d.ts"
64
+ ],
65
+ "types": [
66
+ "./dist/types.d.ts"
67
+ ]
68
+ }
69
+ },
70
+ "files": [
71
+ "src",
72
+ "dist",
73
+ "*.d.ts",
74
+ "*.d.cts",
75
+ "!/**/**.test.**",
76
+ "!/**/__tests__/**",
77
+ "!/**/__snapshots__/**"
78
+ ],
79
+ "size-limit": [
80
+ {
81
+ "path": "./dist/*.js",
82
+ "limit": "510 KiB",
83
+ "gzip": true
84
+ }
85
+ ],
86
+ "dependencies": {
87
+ "@clack/prompts": "^1.1.0",
88
+ "p-limit": "^7.3.0",
89
+ "remeda": "^2.33.6",
90
+ "typescript": "5.9.3"
91
+ },
92
+ "devDependencies": {},
93
+ "engines": {
94
+ "node": ">=20"
95
+ },
96
+ "publishConfig": {
97
+ "access": "public",
98
+ "registry": "https://registry.npmjs.org/"
99
+ },
100
+ "scripts": {
101
+ "build": "tsdown && size-limit",
102
+ "clean": "node -e \"require('fs').rmSync('./dist', {recursive:true,force:true})\"",
103
+ "lint": "pnpm biome lint .",
104
+ "lint:fix": "pnpm biome lint --fix --unsafe .",
105
+ "release": "pnpm publish --no-git-check",
106
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
107
+ "start": "tsdown --watch ./src",
108
+ "test": "vitest --passWithNoTests",
109
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
110
+ }
111
+ }
@@ -0,0 +1,8 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+ //#endregion
8
+ export { __name as t };