@kubb/agent 5.0.0-alpha.35 → 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 (180) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1293 -20554
  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/buffer-from/index.js +72 -0
  134. package/.output/server/node_modules/buffer-from/package.json +19 -0
  135. package/.output/server/node_modules/empathic/access.js +39 -0
  136. package/.output/server/node_modules/empathic/access.mjs +34 -0
  137. package/.output/server/node_modules/empathic/find.js +81 -0
  138. package/.output/server/node_modules/empathic/find.mjs +76 -0
  139. package/.output/server/node_modules/empathic/package.json +49 -0
  140. package/.output/server/node_modules/empathic/package.mjs +52 -0
  141. package/.output/server/node_modules/empathic/resolve.js +31 -0
  142. package/.output/server/node_modules/empathic/resolve.mjs +27 -0
  143. package/.output/server/node_modules/empathic/walk.js +22 -0
  144. package/.output/server/node_modules/empathic/walk.mjs +20 -0
  145. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  146. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  147. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  148. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  149. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  150. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  151. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  152. package/.output/server/node_modules/p-limit/index.js +127 -0
  153. package/.output/server/node_modules/p-limit/package.json +58 -0
  154. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  155. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  156. package/.output/server/node_modules/sisteransi/package.json +34 -0
  157. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  158. package/.output/server/node_modules/source-map-support/package.json +31 -0
  159. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  160. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  161. package/.output/server/node_modules/typescript/package.json +120 -0
  162. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  163. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  164. package/.output/server/package.json +34 -2
  165. package/package.json +20 -20
  166. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  167. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  168. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,277 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { File, Function as Function$1, FunctionParams } from "@kubb/react-fabric";
3
+ import { jsx } from "@kubb/react-fabric/jsx-runtime";
4
+ //#region ../../internals/utils/src/casing.ts
5
+ /**
6
+ * Shared implementation for camelCase and PascalCase conversion.
7
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
8
+ * and capitalizes each word according to `pascal`.
9
+ *
10
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
11
+ */
12
+ function toCamelOrPascal(text, pascal) {
13
+ return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
14
+ if (word.length > 1 && word === word.toUpperCase()) return word;
15
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
16
+ return word.charAt(0).toUpperCase() + word.slice(1);
17
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
18
+ }
19
+ /**
20
+ * Splits `text` on `.` and applies `transformPart` to each segment.
21
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
22
+ * Segments are joined with `/` to form a file path.
23
+ */
24
+ function applyToFileParts(text, transformPart) {
25
+ const parts = text.split(".");
26
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
27
+ }
28
+ /**
29
+ * Converts `text` to camelCase.
30
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
31
+ *
32
+ * @example
33
+ * camelCase('hello-world') // 'helloWorld'
34
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
35
+ */
36
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
37
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
38
+ prefix,
39
+ suffix
40
+ } : {}));
41
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
42
+ }
43
+ //#endregion
44
+ //#region ../../internals/utils/src/reserved.ts
45
+ /**
46
+ * Returns `true` when `name` is a syntactically valid JavaScript variable name.
47
+ */
48
+ function isValidVarName(name) {
49
+ try {
50
+ new Function(`var ${name}`);
51
+ } catch {
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+ //#endregion
57
+ //#region ../../internals/utils/src/urlPath.ts
58
+ /**
59
+ * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
60
+ *
61
+ * @example
62
+ * const p = new URLPath('/pet/{petId}')
63
+ * p.URL // '/pet/:petId'
64
+ * p.template // '`/pet/${petId}`'
65
+ */
66
+ var URLPath = class {
67
+ /** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */
68
+ path;
69
+ #options;
70
+ constructor(path, options = {}) {
71
+ this.path = path;
72
+ this.#options = options;
73
+ }
74
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
75
+ get URL() {
76
+ return this.toURLPath();
77
+ }
78
+ /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */
79
+ get isURL() {
80
+ try {
81
+ return !!new URL(this.path).href;
82
+ } catch {
83
+ return false;
84
+ }
85
+ }
86
+ /**
87
+ * Converts the OpenAPI path to a TypeScript template literal string.
88
+ *
89
+ * @example
90
+ * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
91
+ * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
92
+ */
93
+ get template() {
94
+ return this.toTemplateString();
95
+ }
96
+ /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */
97
+ get object() {
98
+ return this.toObject();
99
+ }
100
+ /** Returns a map of path parameter names, or `undefined` when the path has no parameters. */
101
+ get params() {
102
+ return this.getParams();
103
+ }
104
+ #transformParam(raw) {
105
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
106
+ return this.#options.casing === "camelcase" ? camelCase(param) : param;
107
+ }
108
+ /** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */
109
+ #eachParam(fn) {
110
+ for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
111
+ const raw = match[1];
112
+ fn(raw, this.#transformParam(raw));
113
+ }
114
+ }
115
+ toObject({ type = "path", replacer, stringify } = {}) {
116
+ const object = {
117
+ url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
118
+ params: this.getParams()
119
+ };
120
+ if (stringify) {
121
+ if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
122
+ if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
123
+ return `{ url: '${object.url}' }`;
124
+ }
125
+ return object;
126
+ }
127
+ /**
128
+ * Converts the OpenAPI path to a TypeScript template literal string.
129
+ * An optional `replacer` can transform each extracted parameter name before interpolation.
130
+ *
131
+ * @example
132
+ * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
133
+ */
134
+ toTemplateString({ prefix = "", replacer } = {}) {
135
+ return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
136
+ if (i % 2 === 0) return part;
137
+ const param = this.#transformParam(part);
138
+ return `\${${replacer ? replacer(param) : param}}`;
139
+ }).join("")}\``;
140
+ }
141
+ /**
142
+ * Extracts all `{param}` segments from the path and returns them as a key-value map.
143
+ * An optional `replacer` transforms each parameter name in both key and value positions.
144
+ * Returns `undefined` when no path parameters are found.
145
+ */
146
+ getParams(replacer) {
147
+ const params = {};
148
+ this.#eachParam((_raw, param) => {
149
+ const key = replacer ? replacer(param) : param;
150
+ params[key] = key;
151
+ });
152
+ return Object.keys(params).length > 0 ? params : void 0;
153
+ }
154
+ /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
155
+ toURLPath() {
156
+ return this.path.replace(/\{([^}]+)\}/g, ":$1");
157
+ }
158
+ };
159
+ //#endregion
160
+ //#region src/components/Handlers.tsx
161
+ function Handlers({ name, handlers }) {
162
+ return /* @__PURE__ */ jsx(File.Source, {
163
+ name,
164
+ isIndexable: true,
165
+ isExportable: true,
166
+ children: `export const ${name} = ${JSON.stringify(handlers).replaceAll(`"`, "")} as const`
167
+ });
168
+ }
169
+ //#endregion
170
+ //#region src/components/Mock.tsx
171
+ function Mock({ baseURL = "", name, typeName, operation }) {
172
+ const method = operation.method;
173
+ const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith("2"));
174
+ const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200;
175
+ const responseObject = operation.getResponseByStatusCode(statusCode);
176
+ const contentType = Object.keys(responseObject.content || {})?.[0];
177
+ const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, "$1\\\\:");
178
+ const headers = [contentType ? `'Content-Type': '${contentType}'` : void 0].filter(Boolean);
179
+ const dataType = contentType && responseObject?.content?.[contentType]?.schema !== void 0 ? typeName : "string | number | boolean | null | object";
180
+ const params = FunctionParams.factory({ data: {
181
+ type: `${dataType} | ((
182
+ info: Parameters<Parameters<typeof http.${method}>[1]>[0],
183
+ ) => Response | Promise<Response>)`,
184
+ optional: true
185
+ } });
186
+ return /* @__PURE__ */ jsx(File.Source, {
187
+ name,
188
+ isIndexable: true,
189
+ isExportable: true,
190
+ children: /* @__PURE__ */ jsx(Function$1, {
191
+ name,
192
+ export: true,
193
+ params: params.toConstructor(),
194
+ children: `return http.${method}(\`${baseURL}${url.replace(/([^/]):/g, "$1\\\\:")}\`, function handler(info) {
195
+ if(typeof data === 'function') return data(info)
196
+
197
+ return new Response(JSON.stringify(data), {
198
+ status: ${statusCode},
199
+ ${headers.length ? ` headers: {
200
+ ${headers.join(", \n")}
201
+ },` : ""}
202
+ })
203
+ })`
204
+ })
205
+ });
206
+ }
207
+ //#endregion
208
+ //#region src/components/MockWithFaker.tsx
209
+ function MockWithFaker({ baseURL = "", name, fakerName, typeName, operation }) {
210
+ const method = operation.method;
211
+ const successStatusCodes = operation.getResponseStatusCodes().filter((code) => code.startsWith("2"));
212
+ const statusCode = successStatusCodes.length > 0 ? Number(successStatusCodes[0]) : 200;
213
+ const responseObject = operation.getResponseByStatusCode(statusCode);
214
+ const contentType = Object.keys(responseObject.content || {})?.[0];
215
+ const url = new URLPath(operation.path).toURLPath().replace(/([^/]):/g, "$1\\\\:");
216
+ const headers = [contentType ? `'Content-Type': '${contentType}'` : void 0].filter(Boolean);
217
+ const params = FunctionParams.factory({ data: {
218
+ type: `${typeName} | ((
219
+ info: Parameters<Parameters<typeof http.${method}>[1]>[0],
220
+ ) => Response | Promise<Response>)`,
221
+ optional: true
222
+ } });
223
+ return /* @__PURE__ */ jsx(File.Source, {
224
+ name,
225
+ isIndexable: true,
226
+ isExportable: true,
227
+ children: /* @__PURE__ */ jsx(Function$1, {
228
+ name,
229
+ export: true,
230
+ params: params.toConstructor(),
231
+ children: `return http.${method}('${baseURL}${url.replace(/([^/]):/g, "$1\\\\:")}', function handler(info) {
232
+ if(typeof data === 'function') return data(info)
233
+
234
+ return new Response(JSON.stringify(data || ${fakerName}(data)), {
235
+ status: ${statusCode},
236
+ ${headers.length ? ` headers: {
237
+ ${headers.join(", \n")}
238
+ },` : ""}
239
+ })
240
+ })`
241
+ })
242
+ });
243
+ }
244
+ //#endregion
245
+ //#region src/components/Response.tsx
246
+ function Response({ name, typeName, operation, statusCode }) {
247
+ const responseObject = operation.getResponseByStatusCode(statusCode);
248
+ const contentType = Object.keys(responseObject.content || {})?.[0];
249
+ const headers = [contentType ? `'Content-Type': '${contentType}'` : void 0].filter(Boolean);
250
+ const hasResponseSchema = contentType && responseObject?.content?.[contentType]?.schema !== void 0;
251
+ const params = FunctionParams.factory({ data: {
252
+ type: `${typeName}`,
253
+ optional: !hasResponseSchema
254
+ } });
255
+ const responseName = `${name}Response${statusCode}`;
256
+ return /* @__PURE__ */ jsx(File.Source, {
257
+ name: responseName,
258
+ isIndexable: true,
259
+ isExportable: true,
260
+ children: /* @__PURE__ */ jsx(Function$1, {
261
+ name: responseName,
262
+ export: true,
263
+ params: params.toConstructor(),
264
+ children: `
265
+ return new Response(JSON.stringify(data), {
266
+ status: ${statusCode},
267
+ ${headers.length ? ` headers: {
268
+ ${headers.join(", \n")}
269
+ },` : ""}
270
+ })`
271
+ })
272
+ });
273
+ }
274
+ //#endregion
275
+ export { camelCase as a, Handlers as i, MockWithFaker as n, Mock as r, Response as t };
276
+
277
+ //# sourceMappingURL=components-DgtTZkWX.js.map
@@ -0,0 +1,161 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { i as Handlers, n as MockWithFaker, r as Mock, t as Response } from "./components-DgtTZkWX.js";
3
+ import { pluginFakerName } from "@kubb/plugin-faker";
4
+ import { pluginTsName } from "@kubb/plugin-ts";
5
+ import { usePluginManager } from "@kubb/core/hooks";
6
+ import { createReactGenerator } from "@kubb/plugin-oas/generators";
7
+ import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
8
+ import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
9
+ import { File } from "@kubb/react-fabric";
10
+ import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
11
+ //#region src/generators/handlersGenerator.tsx
12
+ const handlersGenerator = createReactGenerator({
13
+ name: "plugin-msw",
14
+ Operations({ operations, generator, plugin }) {
15
+ const pluginManager = usePluginManager();
16
+ const oas = useOas();
17
+ const { getName, getFile } = useOperationManager(generator);
18
+ const file = pluginManager.getFile({
19
+ name: "handlers",
20
+ extname: ".ts",
21
+ pluginKey: plugin.key
22
+ });
23
+ const imports = operations.map((operation) => {
24
+ const operationFile = getFile(operation, { pluginKey: plugin.key });
25
+ const operationName = getName(operation, {
26
+ pluginKey: plugin.key,
27
+ type: "function"
28
+ });
29
+ return /* @__PURE__ */ jsx(File.Import, {
30
+ name: [operationName],
31
+ root: file.path,
32
+ path: operationFile.path
33
+ }, operationFile.path);
34
+ });
35
+ const handlers = operations.map((operation) => `${getName(operation, {
36
+ type: "function",
37
+ pluginKey: plugin.key
38
+ })}()`);
39
+ return /* @__PURE__ */ jsxs(File, {
40
+ baseName: file.baseName,
41
+ path: file.path,
42
+ meta: file.meta,
43
+ banner: getBanner({
44
+ oas,
45
+ output: plugin.options.output,
46
+ config: pluginManager.config
47
+ }),
48
+ footer: getFooter({
49
+ oas,
50
+ output: plugin.options.output
51
+ }),
52
+ children: [imports, /* @__PURE__ */ jsx(Handlers, {
53
+ name: "handlers",
54
+ handlers
55
+ })]
56
+ });
57
+ }
58
+ });
59
+ //#endregion
60
+ //#region src/generators/mswGenerator.tsx
61
+ const mswGenerator = createReactGenerator({
62
+ name: "msw",
63
+ Operation({ operation, generator, plugin }) {
64
+ const { options: { output, parser, baseURL } } = plugin;
65
+ const pluginManager = usePluginManager();
66
+ const oas = useOas();
67
+ const { getSchemas, getName, getFile } = useOperationManager(generator);
68
+ const mock = {
69
+ name: getName(operation, { type: "function" }),
70
+ file: getFile(operation)
71
+ };
72
+ const faker = {
73
+ file: getFile(operation, { pluginKey: [pluginFakerName] }),
74
+ schemas: getSchemas(operation, {
75
+ pluginKey: [pluginFakerName],
76
+ type: "function"
77
+ })
78
+ };
79
+ const type = {
80
+ file: getFile(operation, { pluginKey: [pluginTsName] }),
81
+ schemas: getSchemas(operation, {
82
+ pluginKey: [pluginTsName],
83
+ type: "type"
84
+ })
85
+ };
86
+ const responseStatusCodes = operation.getResponseStatusCodes();
87
+ const types = [];
88
+ for (const code of responseStatusCodes) {
89
+ if (code === "default") {
90
+ types.push(["default", type.schemas.response.name]);
91
+ continue;
92
+ }
93
+ if (code.startsWith("2")) {
94
+ types.push([Number(code), type.schemas.response.name]);
95
+ continue;
96
+ }
97
+ const codeType = type.schemas.errors?.find((err) => err.statusCode === Number(code));
98
+ if (codeType) types.push([Number(code), codeType.name]);
99
+ }
100
+ return /* @__PURE__ */ jsxs(File, {
101
+ baseName: mock.file.baseName,
102
+ path: mock.file.path,
103
+ meta: mock.file.meta,
104
+ banner: getBanner({
105
+ oas,
106
+ output,
107
+ config: pluginManager.config
108
+ }),
109
+ footer: getFooter({
110
+ oas,
111
+ output
112
+ }),
113
+ children: [
114
+ /* @__PURE__ */ jsx(File.Import, {
115
+ name: ["http"],
116
+ path: "msw"
117
+ }),
118
+ /* @__PURE__ */ jsx(File.Import, {
119
+ name: ["ResponseResolver"],
120
+ isTypeOnly: true,
121
+ path: "msw"
122
+ }),
123
+ /* @__PURE__ */ jsx(File.Import, {
124
+ name: Array.from(new Set([type.schemas.response.name, ...types.map((t) => t[1])])),
125
+ path: type.file.path,
126
+ root: mock.file.path,
127
+ isTypeOnly: true
128
+ }),
129
+ parser === "faker" && faker.file && faker.schemas.response && /* @__PURE__ */ jsx(File.Import, {
130
+ name: [faker.schemas.response.name],
131
+ root: mock.file.path,
132
+ path: faker.file.path
133
+ }),
134
+ types.filter(([code]) => code !== "default").map(([code, typeName]) => /* @__PURE__ */ jsx(Response, {
135
+ typeName,
136
+ operation,
137
+ name: mock.name,
138
+ statusCode: code
139
+ })),
140
+ parser === "faker" && /* @__PURE__ */ jsx(MockWithFaker, {
141
+ name: mock.name,
142
+ typeName: type.schemas.response.name,
143
+ fakerName: faker.schemas.response.name,
144
+ operation,
145
+ baseURL
146
+ }),
147
+ parser === "data" && /* @__PURE__ */ jsx(Mock, {
148
+ name: mock.name,
149
+ typeName: type.schemas.response.name,
150
+ fakerName: faker.schemas.response.name,
151
+ operation,
152
+ baseURL
153
+ })
154
+ ]
155
+ });
156
+ }
157
+ });
158
+ //#endregion
159
+ export { handlersGenerator as n, mswGenerator as t };
160
+
161
+ //# sourceMappingURL=generators-C34kqa1L.js.map
@@ -0,0 +1,84 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { a as camelCase } from "./components-DgtTZkWX.js";
3
+ import { n as handlersGenerator, t as mswGenerator } from "./generators-C34kqa1L.js";
4
+ import path from "node:path";
5
+ import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
6
+ import { pluginFakerName } from "@kubb/plugin-faker";
7
+ import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
8
+ import { pluginTsName } from "@kubb/plugin-ts";
9
+ //#region src/plugin.ts
10
+ const pluginMswName = "plugin-msw";
11
+ const pluginMsw = definePlugin((options) => {
12
+ const { output = {
13
+ path: "handlers",
14
+ barrelType: "named"
15
+ }, group, exclude = [], include, override = [], transformers = {}, handlers = false, parser = "data", generators = [mswGenerator, handlers ? handlersGenerator : void 0].filter(Boolean), contentType, baseURL } = options;
16
+ return {
17
+ name: pluginMswName,
18
+ options: {
19
+ output,
20
+ parser,
21
+ group,
22
+ baseURL
23
+ },
24
+ pre: [
25
+ pluginOasName,
26
+ pluginTsName,
27
+ parser === "faker" ? pluginFakerName : void 0
28
+ ].filter(Boolean),
29
+ resolvePath(baseName, pathMode, options) {
30
+ const root = path.resolve(this.config.root, this.config.output.path);
31
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
32
+ /**
33
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
34
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
35
+ */
36
+ return path.resolve(root, output.path);
37
+ if (group && (options?.group?.path || options?.group?.tag)) {
38
+ const groupName = group?.name ? group.name : (ctx) => {
39
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
40
+ return `${camelCase(ctx.group)}Controller`;
41
+ };
42
+ return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
43
+ }
44
+ return path.resolve(root, output.path, baseName);
45
+ },
46
+ resolveName(name, type) {
47
+ const resolvedName = camelCase(name, {
48
+ suffix: type ? "handler" : void 0,
49
+ isFile: type === "file"
50
+ });
51
+ if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
52
+ return resolvedName;
53
+ },
54
+ async install() {
55
+ const root = path.resolve(this.config.root, this.config.output.path);
56
+ const mode = getMode(path.resolve(root, output.path));
57
+ const oas = await this.getOas();
58
+ const files = await new OperationGenerator(this.plugin.options, {
59
+ fabric: this.fabric,
60
+ oas,
61
+ pluginManager: this.pluginManager,
62
+ events: this.events,
63
+ plugin: this.plugin,
64
+ contentType,
65
+ exclude,
66
+ include,
67
+ override,
68
+ mode
69
+ }).build(...generators);
70
+ await this.upsertFile(...files);
71
+ const barrelFiles = await getBarrelFiles(this.fabric.files, {
72
+ type: output.barrelType ?? "named",
73
+ root,
74
+ output,
75
+ meta: { pluginKey: this.plugin.key }
76
+ });
77
+ await this.upsertFile(...barrelFiles);
78
+ }
79
+ };
80
+ });
81
+ //#endregion
82
+ export { pluginMsw, pluginMswName };
83
+
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,109 @@
1
+ {
2
+ "name": "@kubb/plugin-msw",
3
+ "version": "4.37.2",
4
+ "description": "Mock Service Worker (MSW) handlers generator plugin for Kubb, creating API mocks from OpenAPI specifications for frontend development and testing.",
5
+ "keywords": [
6
+ "msw",
7
+ "mock-service-worker",
8
+ "api-mocking",
9
+ "mocking",
10
+ "mocks",
11
+ "testing",
12
+ "development",
13
+ "interceptor",
14
+ "typescript",
15
+ "openapi",
16
+ "swagger",
17
+ "oas",
18
+ "code-generator",
19
+ "codegen",
20
+ "plugins",
21
+ "kubb"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/kubb-labs/kubb.git",
26
+ "directory": "packages/plugin-msw"
27
+ },
28
+ "license": "MIT",
29
+ "author": "stijnvanhulle",
30
+ "sideEffects": false,
31
+ "type": "module",
32
+ "exports": {
33
+ ".": {
34
+ "import": "./dist/index.js",
35
+ "require": "./dist/index.cjs"
36
+ },
37
+ "./components": {
38
+ "import": "./dist/components.js",
39
+ "require": "./dist/components.cjs"
40
+ },
41
+ "./generators": {
42
+ "import": "./dist/generators.js",
43
+ "require": "./dist/generators.cjs"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "types": "./dist/index.d.ts",
48
+ "typesVersions": {
49
+ "*": {
50
+ "utils": [
51
+ "./dist/utils.d.ts"
52
+ ],
53
+ "hooks": [
54
+ "./dist/hooks.d.ts"
55
+ ],
56
+ "components": [
57
+ "./dist/components.d.ts"
58
+ ],
59
+ "generators": [
60
+ "./dist/generators.d.ts"
61
+ ]
62
+ }
63
+ },
64
+ "files": [
65
+ "src",
66
+ "dist",
67
+ "!/**/**.test.**",
68
+ "!/**/__tests__/**",
69
+ "!/**/__snapshots__/**"
70
+ ],
71
+ "size-limit": [
72
+ {
73
+ "path": "./dist/*.js",
74
+ "limit": "510 KiB",
75
+ "gzip": true
76
+ }
77
+ ],
78
+ "dependencies": {
79
+ "@kubb/react-fabric": "0.14.0",
80
+ "@kubb/core": "4.37.2",
81
+ "@kubb/oas": "4.37.2",
82
+ "@kubb/plugin-faker": "4.37.2",
83
+ "@kubb/plugin-oas": "4.37.2",
84
+ "@kubb/plugin-ts": "4.37.2"
85
+ },
86
+ "devDependencies": {
87
+ "@internals/utils": "0.0.0"
88
+ },
89
+ "engines": {
90
+ "node": ">=20"
91
+ },
92
+ "publishConfig": {
93
+ "access": "public",
94
+ "registry": "https://registry.npmjs.org/"
95
+ },
96
+ "main": "./dist/index.cjs",
97
+ "module": "./dist/index.js",
98
+ "scripts": {
99
+ "build": "tsdown && size-limit",
100
+ "clean": "npx rimraf ./dist",
101
+ "lint": "bun biome lint .",
102
+ "lint:fix": "bun biome lint --fix --unsafe .",
103
+ "release": "pnpm publish --no-git-check",
104
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
105
+ "start": "tsdown --watch",
106
+ "test": "vitest --passWithNoTests",
107
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
108
+ }
109
+ }
@@ -0,0 +1,58 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ //#region src/SchemaMapper.ts
3
+ const schemaKeywords = {
4
+ any: "any",
5
+ unknown: "unknown",
6
+ number: "number",
7
+ integer: "integer",
8
+ bigint: "bigint",
9
+ string: "string",
10
+ boolean: "boolean",
11
+ undefined: "undefined",
12
+ nullable: "nullable",
13
+ null: "null",
14
+ nullish: "nullish",
15
+ array: "array",
16
+ tuple: "tuple",
17
+ enum: "enum",
18
+ union: "union",
19
+ datetime: "datetime",
20
+ date: "date",
21
+ email: "email",
22
+ uuid: "uuid",
23
+ url: "url",
24
+ void: "void",
25
+ default: "default",
26
+ const: "const",
27
+ and: "and",
28
+ describe: "describe",
29
+ min: "min",
30
+ max: "max",
31
+ exclusiveMinimum: "exclusiveMinimum",
32
+ exclusiveMaximum: "exclusiveMaximum",
33
+ optional: "optional",
34
+ readOnly: "readOnly",
35
+ writeOnly: "writeOnly",
36
+ object: "object",
37
+ ref: "ref",
38
+ matches: "matches",
39
+ firstName: "firstName",
40
+ lastName: "lastName",
41
+ password: "password",
42
+ phone: "phone",
43
+ blob: "blob",
44
+ deprecated: "deprecated",
45
+ example: "example",
46
+ schema: "schema",
47
+ catchall: "catchall",
48
+ time: "time",
49
+ name: "name",
50
+ interface: "interface"
51
+ };
52
+ function isKeyword(meta, keyword) {
53
+ return meta.keyword === keyword;
54
+ }
55
+ //#endregion
56
+ export { schemaKeywords as n, isKeyword as t };
57
+
58
+ //# sourceMappingURL=SchemaMapper-CqMkO2T1.js.map
@@ -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 };