@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,79 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { n as camelCase } from "./components-BK_6GU4v.js";
3
+ import { t as cypressGenerator } from "./generators-D5YFtyyC.js";
4
+ import path from "node:path";
5
+ import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
6
+ import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
7
+ import { pluginTsName } from "@kubb/plugin-ts";
8
+ //#region src/plugin.ts
9
+ const pluginCypressName = "plugin-cypress";
10
+ const pluginCypress = definePlugin((options) => {
11
+ const { output = {
12
+ path: "cypress",
13
+ barrelType: "named"
14
+ }, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [cypressGenerator].filter(Boolean), contentType, baseURL, paramsCasing, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline" } = options;
15
+ return {
16
+ name: pluginCypressName,
17
+ options: {
18
+ output,
19
+ dataReturnType,
20
+ group,
21
+ baseURL,
22
+ paramsCasing,
23
+ paramsType,
24
+ pathParamsType
25
+ },
26
+ pre: [pluginOasName, pluginTsName].filter(Boolean),
27
+ resolvePath(baseName, pathMode, options) {
28
+ const root = path.resolve(this.config.root, this.config.output.path);
29
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
30
+ /**
31
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
32
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
33
+ */
34
+ return path.resolve(root, output.path);
35
+ if (group && (options?.group?.path || options?.group?.tag)) {
36
+ const groupName = group?.name ? group.name : (ctx) => {
37
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
38
+ return `${camelCase(ctx.group)}Requests`;
39
+ };
40
+ return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
41
+ }
42
+ return path.resolve(root, output.path, baseName);
43
+ },
44
+ resolveName(name, type) {
45
+ const resolvedName = camelCase(name, { isFile: type === "file" });
46
+ if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
47
+ return resolvedName;
48
+ },
49
+ async install() {
50
+ const root = path.resolve(this.config.root, this.config.output.path);
51
+ const mode = getMode(path.resolve(root, output.path));
52
+ const oas = await this.getOas();
53
+ const files = await new OperationGenerator(this.plugin.options, {
54
+ fabric: this.fabric,
55
+ oas,
56
+ pluginManager: this.pluginManager,
57
+ events: this.events,
58
+ plugin: this.plugin,
59
+ contentType,
60
+ exclude,
61
+ include,
62
+ override,
63
+ mode
64
+ }).build(...generators);
65
+ await this.upsertFile(...files);
66
+ const barrelFiles = await getBarrelFiles(this.fabric.files, {
67
+ type: output.barrelType ?? "named",
68
+ root,
69
+ output,
70
+ meta: { pluginKey: this.plugin.key }
71
+ });
72
+ await this.upsertFile(...barrelFiles);
73
+ }
74
+ };
75
+ });
76
+ //#endregion
77
+ export { pluginCypress, pluginCypressName };
78
+
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,108 @@
1
+ {
2
+ "name": "@kubb/plugin-cypress",
3
+ "version": "4.37.2",
4
+ "description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
5
+ "keywords": [
6
+ "cypress",
7
+ "e2e-testing",
8
+ "end-to-end",
9
+ "testing",
10
+ "test-generation",
11
+ "api-testing",
12
+ "test-automation",
13
+ "integration-testing",
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-cypress"
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-oas": "4.37.2",
83
+ "@kubb/plugin-ts": "4.37.2"
84
+ },
85
+ "engines": {
86
+ "node": ">=20"
87
+ },
88
+ "publishConfig": {
89
+ "access": "public",
90
+ "registry": "https://registry.npmjs.org/"
91
+ },
92
+ "main": "./dist/index.cjs",
93
+ "module": "./dist/index.js",
94
+ "devDependencies": {
95
+ "@internals/utils": "0.0.0"
96
+ },
97
+ "scripts": {
98
+ "build": "tsdown && size-limit",
99
+ "clean": "npx rimraf ./dist",
100
+ "lint": "bun biome lint .",
101
+ "lint:fix": "bun biome lint --fix --unsafe .",
102
+ "release": "pnpm publish --no-git-check",
103
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
104
+ "start": "tsdown --watch",
105
+ "test": "vitest --passWithNoTests",
106
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
107
+ }
108
+ }
@@ -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 };
@@ -0,0 +1,419 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { createParser, findSchemaKeyword, isKeyword, schemaKeywords } from "@kubb/plugin-oas";
3
+ import { File, Function, FunctionParams } from "@kubb/react-fabric";
4
+ import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
5
+ //#region ../../internals/utils/src/string.ts
6
+ /**
7
+ * Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
8
+ * Returns the string unchanged when no balanced quote pair is found.
9
+ *
10
+ * @example
11
+ * trimQuotes('"hello"') // 'hello'
12
+ * trimQuotes('hello') // 'hello'
13
+ */
14
+ function trimQuotes(text) {
15
+ if (text.length >= 2) {
16
+ const first = text[0];
17
+ const last = text[text.length - 1];
18
+ if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
19
+ }
20
+ return text;
21
+ }
22
+ /**
23
+ * Escapes characters that are not allowed inside JS string literals.
24
+ * Handles quotes, backslashes, and Unicode line terminators (U+2028 / U+2029).
25
+ *
26
+ * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
27
+ */
28
+ function jsStringEscape(input) {
29
+ return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
30
+ switch (character) {
31
+ case "\"":
32
+ case "'":
33
+ case "\\": return `\\${character}`;
34
+ case "\n": return "\\n";
35
+ case "\r": return "\\r";
36
+ case "\u2028": return "\\u2028";
37
+ case "\u2029": return "\\u2029";
38
+ default: return "";
39
+ }
40
+ });
41
+ }
42
+ //#endregion
43
+ //#region ../../internals/utils/src/object.ts
44
+ /**
45
+ * Serializes a primitive value to a JSON string literal, stripping any surrounding quote characters first.
46
+ *
47
+ * @example
48
+ * stringify('hello') // '"hello"'
49
+ * stringify('"hello"') // '"hello"'
50
+ */
51
+ function stringify(value) {
52
+ if (value === void 0 || value === null) return "\"\"";
53
+ return JSON.stringify(trimQuotes(value.toString()));
54
+ }
55
+ //#endregion
56
+ //#region ../../internals/utils/src/regexp.ts
57
+ /**
58
+ * Converts a pattern string into a `new RegExp(...)` constructor call or a regex literal string.
59
+ * Inline flags expressed as `^(?im)` prefixes are extracted and applied to the resulting expression.
60
+ * Pass `null` as the second argument to emit a `/pattern/flags` literal instead.
61
+ *
62
+ * @example
63
+ * toRegExpString('^(?im)foo') // → 'new RegExp("foo", "im")'
64
+ * toRegExpString('^(?im)foo', null) // → '/foo/im'
65
+ */
66
+ function toRegExpString(text, func = "RegExp") {
67
+ const raw = trimQuotes(text);
68
+ const match = raw.match(/^\^(\(\?([igmsuy]+)\))/i);
69
+ const replacementTarget = match?.[1] ?? "";
70
+ const matchedFlags = match?.[2];
71
+ const cleaned = raw.replace(/^\\?\//, "").replace(/\\?\/$/, "").replace(replacementTarget, "");
72
+ const { source, flags } = new RegExp(cleaned, matchedFlags);
73
+ if (func === null) return `/${source}/${flags}`;
74
+ return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
75
+ }
76
+ //#endregion
77
+ //#region src/parser.ts
78
+ const fakerKeywordMapper = {
79
+ any: () => "undefined",
80
+ unknown: () => "undefined",
81
+ void: () => "undefined",
82
+ number: (min, max) => {
83
+ if (max !== void 0 && min !== void 0) return `faker.number.float({ min: ${min}, max: ${max} })`;
84
+ if (max !== void 0) return `faker.number.float({ max: ${max} })`;
85
+ if (min !== void 0) return `faker.number.float({ min: ${min} })`;
86
+ return "faker.number.float()";
87
+ },
88
+ integer: (min, max) => {
89
+ if (max !== void 0 && min !== void 0) return `faker.number.int({ min: ${min}, max: ${max} })`;
90
+ if (max !== void 0) return `faker.number.int({ max: ${max} })`;
91
+ if (min !== void 0) return `faker.number.int({ min: ${min} })`;
92
+ return "faker.number.int()";
93
+ },
94
+ bigint: () => "faker.number.bigInt()",
95
+ string: (min, max) => {
96
+ if (max !== void 0 && min !== void 0) return `faker.string.alpha({ length: { min: ${min}, max: ${max} } })`;
97
+ if (max !== void 0) return `faker.string.alpha({ length: ${max} })`;
98
+ if (min !== void 0) return `faker.string.alpha({ length: ${min} })`;
99
+ return "faker.string.alpha()";
100
+ },
101
+ boolean: () => "faker.datatype.boolean()",
102
+ undefined: () => "undefined",
103
+ null: () => "null",
104
+ array: (items = [], min, max) => {
105
+ if (items.length > 1) return `faker.helpers.arrayElements([${items.join(", ")}])`;
106
+ const item = items.at(0);
107
+ if (min !== void 0 && max !== void 0) return `faker.helpers.multiple(() => (${item}), { count: { min: ${min}, max: ${max} }})`;
108
+ if (min !== void 0) return `faker.helpers.multiple(() => (${item}), { count: ${min} })`;
109
+ if (max !== void 0) return `faker.helpers.multiple(() => (${item}), { count: { min: 0, max: ${max} }})`;
110
+ return `faker.helpers.multiple(() => (${item}))`;
111
+ },
112
+ tuple: (items = []) => `[${items.join(", ")}]`,
113
+ enum: (items = [], type = "any") => `faker.helpers.arrayElement<${type}>([${items.join(", ")}])`,
114
+ union: (items = []) => `faker.helpers.arrayElement<any>([${items.join(", ")}])`,
115
+ datetime: () => "faker.date.anytime().toISOString()",
116
+ date: (type = "string", parser = "faker") => {
117
+ if (type === "string") {
118
+ if (parser !== "faker") return `${parser}(faker.date.anytime()).format("YYYY-MM-DD")`;
119
+ return "faker.date.anytime().toISOString().substring(0, 10)";
120
+ }
121
+ if (parser !== "faker") throw new Error(`type '${type}' and parser '${parser}' can not work together`);
122
+ return "faker.date.anytime()";
123
+ },
124
+ time: (type = "string", parser = "faker") => {
125
+ if (type === "string") {
126
+ if (parser !== "faker") return `${parser}(faker.date.anytime()).format("HH:mm:ss")`;
127
+ return "faker.date.anytime().toISOString().substring(11, 19)";
128
+ }
129
+ if (parser !== "faker") throw new Error(`type '${type}' and parser '${parser}' can not work together`);
130
+ return "faker.date.anytime()";
131
+ },
132
+ uuid: () => "faker.string.uuid()",
133
+ url: () => "faker.internet.url()",
134
+ and: (items = []) => {
135
+ if (items.length === 0) return "{}";
136
+ if (items.length === 1) return items[0] ?? "{}";
137
+ return `{...${items.join(", ...")}}`;
138
+ },
139
+ object: () => "object",
140
+ ref: () => "ref",
141
+ matches: (value = "", regexGenerator = "faker") => {
142
+ if (regexGenerator === "randexp") return `${toRegExpString(value, "RandExp")}.gen()`;
143
+ return `faker.helpers.fromRegExp("${value}")`;
144
+ },
145
+ email: () => "faker.internet.email()",
146
+ firstName: () => "faker.person.firstName()",
147
+ lastName: () => "faker.person.lastName()",
148
+ password: () => "faker.internet.password()",
149
+ phone: () => "faker.phone.number()",
150
+ blob: () => "faker.image.url() as unknown as Blob",
151
+ default: void 0,
152
+ describe: void 0,
153
+ const: (value) => value ?? "",
154
+ max: void 0,
155
+ min: void 0,
156
+ nullable: void 0,
157
+ nullish: void 0,
158
+ optional: void 0,
159
+ readOnly: void 0,
160
+ writeOnly: void 0,
161
+ deprecated: void 0,
162
+ example: void 0,
163
+ schema: void 0,
164
+ catchall: void 0,
165
+ name: void 0,
166
+ interface: void 0,
167
+ exclusiveMaximum: void 0,
168
+ exclusiveMinimum: void 0
169
+ };
170
+ /**
171
+ * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398
172
+ */
173
+ function schemaKeywordSorter(_a, b) {
174
+ if (b.keyword === "null") return -1;
175
+ return 0;
176
+ }
177
+ function joinItems(items) {
178
+ switch (items.length) {
179
+ case 0: return "undefined";
180
+ case 1: return items[0];
181
+ default: return fakerKeywordMapper.union(items);
182
+ }
183
+ }
184
+ const parse = createParser({
185
+ mapper: fakerKeywordMapper,
186
+ handlers: {
187
+ union(tree, options) {
188
+ const { current, schema, name, siblings } = tree;
189
+ if (Array.isArray(current.args) && !current.args.length) return "";
190
+ return fakerKeywordMapper.union(current.args.map((it) => this.parse({
191
+ schema,
192
+ parent: current,
193
+ name,
194
+ current: it,
195
+ siblings
196
+ }, {
197
+ ...options,
198
+ canOverride: false
199
+ })).filter((x) => Boolean(x)));
200
+ },
201
+ and(tree, options) {
202
+ const { current, schema, siblings } = tree;
203
+ return fakerKeywordMapper.and(current.args.map((it) => this.parse({
204
+ schema,
205
+ parent: current,
206
+ current: it,
207
+ siblings
208
+ }, {
209
+ ...options,
210
+ canOverride: false
211
+ })).filter((x) => Boolean(x)));
212
+ },
213
+ array(tree, options) {
214
+ const { current, schema } = tree;
215
+ return fakerKeywordMapper.array(current.args.items.map((it) => this.parse({
216
+ schema,
217
+ parent: current,
218
+ current: it,
219
+ siblings: current.args.items
220
+ }, {
221
+ ...options,
222
+ typeName: `NonNullable<${options.typeName}>[number]`,
223
+ canOverride: false
224
+ })).filter((x) => Boolean(x)), current.args.min, current.args.max);
225
+ },
226
+ enum(tree, options) {
227
+ const { current, parent, name } = tree;
228
+ if (parent ? isKeyword(parent, schemaKeywords.tuple) : false) return fakerKeywordMapper.enum(current.args.items.map((schema) => {
229
+ if (schema.format === "number") return schema.value;
230
+ if (schema.format === "boolean") return schema.value;
231
+ return stringify(schema.value);
232
+ }));
233
+ return fakerKeywordMapper.enum(current.args.items.map((schema) => {
234
+ if (schema.format === "number") return schema.value;
235
+ if (schema.format === "boolean") return schema.value;
236
+ return stringify(schema.value);
237
+ }), name ? options.typeName : void 0);
238
+ },
239
+ ref(tree, options) {
240
+ const { current, parent } = tree;
241
+ if (!current.args?.name) throw new Error(`Name not defined for keyword ${current.keyword}`);
242
+ if (options.rootTypeName && current.args.name === options.rootTypeName) return "undefined as any";
243
+ const isNestedInObjectOrAnd = parent && (isKeyword(parent, schemaKeywords.object) || isKeyword(parent, schemaKeywords.and));
244
+ if (options.canOverride && !isNestedInObjectOrAnd) return `${current.args.name}(data)`;
245
+ return `${current.args.name}()`;
246
+ },
247
+ object(tree, options) {
248
+ const { current, schema } = tree;
249
+ return `{${Object.entries(current.args?.properties || {}).filter((item) => {
250
+ const schema = item[1];
251
+ return schema && typeof schema.map === "function";
252
+ }).map(([name, schemas]) => {
253
+ const mappedName = schemas.find((schema) => schema.keyword === schemaKeywords.name)?.args || name;
254
+ if (options.mapper && Object.hasOwn(options.mapper, mappedName)) return `"${name}": ${options.mapper?.[mappedName]}`;
255
+ return `"${name}": ${joinItems(schemas.sort(schemaKeywordSorter).map((it) => this.parse({
256
+ schema,
257
+ name,
258
+ parent: current,
259
+ current: it,
260
+ siblings: schemas
261
+ }, {
262
+ ...options,
263
+ typeName: `NonNullable<${options.typeName}>[${JSON.stringify(name)}]`,
264
+ canOverride: false
265
+ })).filter((x) => Boolean(x)))}`;
266
+ }).join(",")}}`;
267
+ },
268
+ tuple(tree, options) {
269
+ const { current, schema, siblings } = tree;
270
+ if (Array.isArray(current.args.items)) return fakerKeywordMapper.tuple(current.args.items.map((it) => this.parse({
271
+ schema,
272
+ parent: current,
273
+ current: it,
274
+ siblings
275
+ }, {
276
+ ...options,
277
+ canOverride: false
278
+ })).filter((x) => Boolean(x)));
279
+ return this.parse({
280
+ schema,
281
+ parent: current,
282
+ current: current.args.items,
283
+ siblings
284
+ }, {
285
+ ...options,
286
+ canOverride: false
287
+ });
288
+ },
289
+ const(tree, _options) {
290
+ const { current } = tree;
291
+ if (current.args.format === "number" && current.args.name !== void 0) return fakerKeywordMapper.const(current.args.name?.toString());
292
+ return fakerKeywordMapper.const(stringify(current.args.value));
293
+ },
294
+ matches(tree, options) {
295
+ const { current } = tree;
296
+ if (current.args) return fakerKeywordMapper.matches(current.args, options.regexGenerator);
297
+ },
298
+ null() {
299
+ return fakerKeywordMapper.null();
300
+ },
301
+ undefined() {
302
+ return fakerKeywordMapper.undefined();
303
+ },
304
+ any() {
305
+ return fakerKeywordMapper.any();
306
+ },
307
+ string(tree, _options) {
308
+ const { siblings } = tree;
309
+ if (siblings) {
310
+ const minSchema = findSchemaKeyword(siblings, "min");
311
+ const maxSchema = findSchemaKeyword(siblings, "max");
312
+ return fakerKeywordMapper.string(minSchema?.args, maxSchema?.args);
313
+ }
314
+ return fakerKeywordMapper.string();
315
+ },
316
+ number(tree, _options) {
317
+ const { siblings } = tree;
318
+ if (siblings) {
319
+ const minSchema = findSchemaKeyword(siblings, "min");
320
+ const maxSchema = findSchemaKeyword(siblings, "max");
321
+ return fakerKeywordMapper.number(minSchema?.args, maxSchema?.args);
322
+ }
323
+ return fakerKeywordMapper.number();
324
+ },
325
+ integer(tree, _options) {
326
+ const { siblings } = tree;
327
+ if (siblings) {
328
+ const minSchema = findSchemaKeyword(siblings, "min");
329
+ const maxSchema = findSchemaKeyword(siblings, "max");
330
+ return fakerKeywordMapper.integer(minSchema?.args, maxSchema?.args);
331
+ }
332
+ return fakerKeywordMapper.integer();
333
+ },
334
+ bigint(_tree, _options) {
335
+ return fakerKeywordMapper.bigint();
336
+ },
337
+ datetime() {
338
+ return fakerKeywordMapper.datetime();
339
+ },
340
+ date(tree, options) {
341
+ const { current } = tree;
342
+ return fakerKeywordMapper.date(current.args.type, options.dateParser);
343
+ },
344
+ time(tree, options) {
345
+ const { current } = tree;
346
+ return fakerKeywordMapper.time(current.args.type, options.dateParser);
347
+ }
348
+ }
349
+ });
350
+ //#endregion
351
+ //#region src/components/Faker.tsx
352
+ function Faker({ tree, description, name, typeName, seed, regexGenerator, canOverride, mapper, dateParser }) {
353
+ const fakerText = joinItems(tree.map((schema, _index, siblings) => parse({
354
+ name,
355
+ schema,
356
+ parent: void 0,
357
+ current: schema,
358
+ siblings
359
+ }, {
360
+ typeName,
361
+ rootTypeName: name,
362
+ regexGenerator,
363
+ mapper,
364
+ canOverride,
365
+ dateParser
366
+ })).filter((x) => Boolean(x)));
367
+ const isArray = fakerText.startsWith("faker.helpers.arrayElements") || fakerText.startsWith("faker.helpers.multiple");
368
+ const isRefToArray = tree.some((s) => isKeyword(s, schemaKeywords.schema) && s.args.type === "array");
369
+ const isObject = fakerText.startsWith("{");
370
+ const isTuple = fakerText.startsWith("faker.helpers.arrayElement");
371
+ const isSimpleString = name === "string";
372
+ const isSimpleInt = name === "integer";
373
+ const isSimpleFloat = name === "float";
374
+ let fakerTextWithOverride = fakerText;
375
+ if (canOverride && isObject) fakerTextWithOverride = `{
376
+ ...${fakerText},
377
+ ...data || {}
378
+ }`;
379
+ if (canOverride && isTuple) fakerTextWithOverride = `data || ${fakerText}`;
380
+ if (canOverride && isArray) fakerTextWithOverride = `[
381
+ ...${fakerText},
382
+ ...data || []
383
+ ]`;
384
+ if (canOverride && isSimpleString) fakerTextWithOverride = "data ?? faker.string.alpha()";
385
+ if (canOverride && isSimpleInt) fakerTextWithOverride = "data ?? faker.number.int()";
386
+ if (canOverride && isSimpleFloat) fakerTextWithOverride = "data ?? faker.number.float()";
387
+ let type = `Partial<${typeName}>`;
388
+ if (isArray) type = typeName;
389
+ if (isRefToArray) type = typeName;
390
+ if (isSimpleString) type = name;
391
+ if (isSimpleInt || isSimpleFloat) type = "number";
392
+ const params = FunctionParams.factory({ data: {
393
+ type,
394
+ optional: true
395
+ } });
396
+ let returnType = canOverride ? typeName : void 0;
397
+ if (isSimpleString || isSimpleInt || isSimpleFloat) returnType = type;
398
+ return /* @__PURE__ */ jsx(File.Source, {
399
+ name,
400
+ isExportable: true,
401
+ isIndexable: true,
402
+ children: /* @__PURE__ */ jsxs(Function, {
403
+ export: true,
404
+ name,
405
+ JSDoc: { comments: [description ? `@description ${jsStringEscape(description)}` : void 0].filter(Boolean) },
406
+ params: canOverride ? params.toConstructor() : void 0,
407
+ returnType,
408
+ children: [
409
+ seed ? `faker.seed(${JSON.stringify(seed)})` : void 0,
410
+ /* @__PURE__ */ jsx("br", {}),
411
+ `return ${fakerTextWithOverride}`
412
+ ]
413
+ })
414
+ });
415
+ }
416
+ //#endregion
417
+ export { Faker as t };
418
+
419
+ //# sourceMappingURL=components-BkBIov4R.js.map