@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,408 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { n as createReactGenerator$1, r as createGenerator$1, t as jsonGenerator } from "./generators-D7C3CXsN.js";
3
+ import { i as pascalCase, r as camelCase } from "./getFooter-Pw3tLCiV.js";
4
+ import { a as buildOperations, c as pLimit, i as buildOperation, n as withRequiredRequestBodySchema, o as buildSchema, r as SchemaGenerator } from "./requestBody-pRavthCw.js";
5
+ import { n as schemaKeywords, t as isKeyword } from "./SchemaMapper-CqMkO2T1.js";
6
+ import path from "node:path";
7
+ import { parseFromConfig, resolveServerUrl } from "@kubb/oas";
8
+ import { definePlugin, getMode } from "@kubb/core";
9
+ //#region src/createParser.ts
10
+ /**
11
+ * Creates a parser function that converts schema trees to output using the provided mapper and handlers
12
+ *
13
+ * This function provides a framework for building parsers by:
14
+ * 1. Checking for custom handlers for each keyword
15
+ * 2. Falling back to the mapper for simple keywords
16
+ * 3. Providing utilities for common operations (finding siblings, etc.)
17
+ *
18
+ * The generated parser is recursive and can handle nested schemas.
19
+ *
20
+ * **Type Safety**: Each handler receives a `tree` parameter where `tree.current` is automatically
21
+ * typed as the specific schema keyword type (e.g., `SchemaKeywordMapper['ref']` for the `ref` handler).
22
+ * This means you can access `tree.current.args` with full type safety without needing `isKeyword` checks,
23
+ * though such checks can still be used as runtime guards if desired.
24
+ *
25
+ * @template TOutput - The output type (e.g., string for Zod/Faker, ts.TypeNode for TypeScript)
26
+ * @template TOptions - The parser options type
27
+ * @param config - Configuration object containing mapper and handlers
28
+ * @returns A parse function that converts SchemaTree to TOutput
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // Create a simple string-based parser
33
+ * const parse = createParser({
34
+ * mapper: zodKeywordMapper,
35
+ * handlers: {
36
+ * // tree.current is typed as SchemaKeywordMapper['union']
37
+ * union(tree, options) {
38
+ * const items = tree.current.args // args is correctly typed as Schema[]
39
+ * .map(it => this.parse({ ...tree, current: it }, options))
40
+ * .filter(Boolean)
41
+ * return `z.union([${items.join(', ')}])`
42
+ * },
43
+ * // tree.current is typed as SchemaKeywordMapper['string']
44
+ * string(tree, options) {
45
+ * const minSchema = findSchemaKeyword(tree.siblings, 'min')
46
+ * const maxSchema = findSchemaKeyword(tree.siblings, 'max')
47
+ * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)
48
+ * },
49
+ * // tree.current is typed as SchemaKeywordMapper['ref']
50
+ * ref(tree, options) {
51
+ * // No need for isKeyword check - tree.current.args is already properly typed
52
+ * return `Ref: ${tree.current.args.name}`
53
+ * }
54
+ * }
55
+ * })
56
+ * ```
57
+ */
58
+ function createParser(config) {
59
+ const { mapper, handlers } = config;
60
+ function parse(tree, options) {
61
+ const { current } = tree;
62
+ const handler = handlers[current.keyword];
63
+ if (handler) {
64
+ const context = { parse };
65
+ return handler.call(context, tree, options);
66
+ }
67
+ const value = mapper[current.keyword];
68
+ if (!value) return;
69
+ if (current.keyword in mapper) return value();
70
+ }
71
+ return parse;
72
+ }
73
+ /**
74
+ * Helper to find a schema keyword in siblings
75
+ * Useful in handlers when you need to find related schemas (e.g., min/max for string)
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const minSchema = findSchemaKeyword(tree.siblings, 'min')
80
+ * const maxSchema = findSchemaKeyword(tree.siblings, 'max')
81
+ * return zodKeywordMapper.string(false, minSchema?.args, maxSchema?.args)
82
+ * ```
83
+ */
84
+ function findSchemaKeyword(siblings, keyword) {
85
+ return SchemaGenerator.find(siblings, schemaKeywords[keyword]);
86
+ }
87
+ //#endregion
88
+ //#region src/OperationGenerator.ts
89
+ var OperationGenerator = class {
90
+ #options;
91
+ #context;
92
+ constructor(options, context) {
93
+ this.#options = options;
94
+ this.#context = context;
95
+ }
96
+ get options() {
97
+ return this.#options;
98
+ }
99
+ set options(options) {
100
+ this.#options = {
101
+ ...this.#options,
102
+ ...options
103
+ };
104
+ }
105
+ get context() {
106
+ return this.#context;
107
+ }
108
+ #matchesPattern(operation, method, type, pattern) {
109
+ switch (type) {
110
+ case "tag": return operation.getTags().some((tag) => tag.name.match(pattern));
111
+ case "operationId": return !!operation.getOperationId({ friendlyCase: true }).match(pattern);
112
+ case "path": return !!operation.path.match(pattern);
113
+ case "method": return !!method.match(pattern);
114
+ case "contentType": return !!operation.getContentType().match(pattern);
115
+ default: return false;
116
+ }
117
+ }
118
+ getOptions(operation, method) {
119
+ const { override = [] } = this.context;
120
+ return override.find(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern))?.options || {};
121
+ }
122
+ #isExcluded(operation, method) {
123
+ const { exclude = [] } = this.context;
124
+ return exclude.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern));
125
+ }
126
+ #isIncluded(operation, method) {
127
+ const { include = [] } = this.context;
128
+ return include.some(({ pattern, type }) => this.#matchesPattern(operation, method, type, pattern));
129
+ }
130
+ getSchemas(operation, { resolveName = (name) => name } = {}) {
131
+ const operationId = operation.getOperationId({ friendlyCase: true });
132
+ const operationName = pascalCase(operationId);
133
+ const resolveKeys = (schema) => schema?.properties ? Object.keys(schema.properties) : void 0;
134
+ const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
135
+ const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
136
+ const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
137
+ const requestSchema = this.context.oas.getRequestSchema(operation);
138
+ const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
139
+ const name = statusCode === "default" ? "error" : statusCode;
140
+ const schema = this.context.oas.getResponseSchema(operation, statusCode);
141
+ const keys = resolveKeys(schema);
142
+ return {
143
+ name: this.context.UNSTABLE_NAMING ? resolveName(pascalCase(`${operationId} status ${name}`)) : resolveName(pascalCase(`${operationId} ${name}`)),
144
+ description: operation.getResponseByStatusCode(statusCode)?.description,
145
+ schema,
146
+ operation,
147
+ operationName,
148
+ statusCode: name === "error" ? void 0 : Number(statusCode),
149
+ keys,
150
+ keysToOmit: keys?.filter((key) => (schema?.properties?.[key])?.writeOnly)
151
+ };
152
+ });
153
+ const successful = statusCodes.filter((item) => item.statusCode?.toString().startsWith("2"));
154
+ const errors = statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5"));
155
+ const request = withRequiredRequestBodySchema(requestSchema ? {
156
+ name: this.context.UNSTABLE_NAMING ? resolveName(pascalCase(`${operationId} RequestData`)) : resolveName(pascalCase(`${operationId} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
157
+ description: operation.schema.requestBody?.description,
158
+ operation,
159
+ operationName,
160
+ schema: requestSchema,
161
+ keys: resolveKeys(requestSchema),
162
+ keysToOmit: resolveKeys(requestSchema)?.filter((key) => (requestSchema.properties?.[key])?.readOnly)
163
+ } : void 0);
164
+ return {
165
+ pathParams: pathParamsSchema ? {
166
+ name: resolveName(pascalCase(`${operationId} PathParams`)),
167
+ operation,
168
+ operationName,
169
+ schema: pathParamsSchema,
170
+ keys: resolveKeys(pathParamsSchema)
171
+ } : void 0,
172
+ queryParams: queryParamsSchema ? {
173
+ name: resolveName(pascalCase(`${operationId} QueryParams`)),
174
+ operation,
175
+ operationName,
176
+ schema: queryParamsSchema,
177
+ keys: resolveKeys(queryParamsSchema) || []
178
+ } : void 0,
179
+ headerParams: headerParamsSchema ? {
180
+ name: resolveName(pascalCase(`${operationId} HeaderParams`)),
181
+ operation,
182
+ operationName,
183
+ schema: headerParamsSchema,
184
+ keys: resolveKeys(headerParamsSchema)
185
+ } : void 0,
186
+ request,
187
+ response: {
188
+ name: this.context.UNSTABLE_NAMING ? resolveName(pascalCase(`${operationId} ResponseData`)) : resolveName(pascalCase(`${operationId} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
189
+ operation,
190
+ operationName,
191
+ schema: { oneOf: successful.map((item) => ({
192
+ ...item.schema,
193
+ $ref: item.name
194
+ })) || void 0 }
195
+ },
196
+ responses: successful,
197
+ errors,
198
+ statusCodes
199
+ };
200
+ }
201
+ async getOperations() {
202
+ const { oas } = this.context;
203
+ const paths = oas.getPaths();
204
+ return Object.entries(paths).flatMap(([path, methods]) => Object.entries(methods).map((values) => {
205
+ const [method, operation] = values;
206
+ if (this.#isExcluded(operation, method)) return null;
207
+ if (this.context.include && !this.#isIncluded(operation, method)) return null;
208
+ return operation ? {
209
+ path,
210
+ method,
211
+ operation
212
+ } : null;
213
+ }).filter((x) => x !== null));
214
+ }
215
+ async build(...generators) {
216
+ const operations = await this.getOperations();
217
+ const generatorLimit = pLimit(3);
218
+ const operationLimit = pLimit(30);
219
+ this.context.events?.emit("debug", {
220
+ date: /* @__PURE__ */ new Date(),
221
+ logs: [`Building ${operations.length} operations`, ` • Generators: ${generators.length}`]
222
+ });
223
+ const writeTasks = generators.map((generator) => generatorLimit(async () => {
224
+ if (generator.version === "2") return [];
225
+ const v1Generator = generator;
226
+ const operationTasks = operations.map(({ operation, method }) => operationLimit(async () => {
227
+ const options = this.getOptions(operation, method);
228
+ if (v1Generator.type === "react") {
229
+ await buildOperation(operation, {
230
+ config: this.context.pluginManager.config,
231
+ fabric: this.context.fabric,
232
+ Component: v1Generator.Operation,
233
+ generator: this,
234
+ plugin: {
235
+ ...this.context.plugin,
236
+ options: {
237
+ ...this.options,
238
+ ...options
239
+ }
240
+ }
241
+ });
242
+ return [];
243
+ }
244
+ return await v1Generator.operation?.({
245
+ generator: this,
246
+ config: this.context.pluginManager.config,
247
+ operation,
248
+ plugin: {
249
+ ...this.context.plugin,
250
+ options: {
251
+ ...this.options,
252
+ ...options
253
+ }
254
+ }
255
+ }) ?? [];
256
+ }));
257
+ const opResultsFlat = (await Promise.all(operationTasks)).flat();
258
+ if (v1Generator.type === "react") {
259
+ await buildOperations(operations.map((op) => op.operation), {
260
+ fabric: this.context.fabric,
261
+ config: this.context.pluginManager.config,
262
+ Component: v1Generator.Operations,
263
+ generator: this,
264
+ plugin: this.context.plugin
265
+ });
266
+ return [];
267
+ }
268
+ const operationsResult = await v1Generator.operations?.({
269
+ generator: this,
270
+ config: this.context.pluginManager.config,
271
+ operations: operations.map((op) => op.operation),
272
+ plugin: this.context.plugin
273
+ });
274
+ return [...opResultsFlat, ...operationsResult ?? []];
275
+ }));
276
+ return (await Promise.all(writeTasks)).flat();
277
+ }
278
+ };
279
+ //#endregion
280
+ //#region src/plugin.ts
281
+ const pluginOasName = "plugin-oas";
282
+ const pluginOas = definePlugin((options) => {
283
+ const { output = { path: "schemas" }, group, validate = true, generators = [jsonGenerator], serverIndex, serverVariables, contentType, oasClass, discriminator = "strict", collisionDetection = false } = options;
284
+ const getOas = async ({ validate, config, events }) => {
285
+ const oas = await parseFromConfig(config, oasClass);
286
+ oas.setOptions({
287
+ contentType,
288
+ discriminator,
289
+ collisionDetection
290
+ });
291
+ try {
292
+ if (validate) await oas.validate();
293
+ } catch (er) {
294
+ const caughtError = er;
295
+ const errorTimestamp = /* @__PURE__ */ new Date();
296
+ const error = new Error("OAS Validation failed", { cause: caughtError });
297
+ events.emit("info", caughtError.message);
298
+ events.emit("debug", {
299
+ date: errorTimestamp,
300
+ logs: [`✗ ${error.message}`, caughtError.message]
301
+ });
302
+ }
303
+ return oas;
304
+ };
305
+ return {
306
+ name: pluginOasName,
307
+ options: {
308
+ output,
309
+ validate,
310
+ discriminator,
311
+ ...options
312
+ },
313
+ inject() {
314
+ const config = this.config;
315
+ const events = this.events;
316
+ let oas;
317
+ return {
318
+ async getOas({ validate = false } = {}) {
319
+ if (!oas) oas = await getOas({
320
+ config,
321
+ events,
322
+ validate
323
+ });
324
+ return oas;
325
+ },
326
+ async getBaseURL() {
327
+ const oas = await getOas({
328
+ config,
329
+ events,
330
+ validate: false
331
+ });
332
+ if (serverIndex === void 0) return;
333
+ const server = oas.api.servers?.at(serverIndex);
334
+ if (!server?.url) return;
335
+ return resolveServerUrl(server, serverVariables);
336
+ }
337
+ };
338
+ },
339
+ resolvePath(baseName, pathMode, options) {
340
+ const root = path.resolve(this.config.root, this.config.output.path);
341
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
342
+ /**
343
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
344
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
345
+ */
346
+ return path.resolve(root, output.path);
347
+ if (group && (options?.group?.path || options?.group?.tag)) {
348
+ const groupName = group?.name ? group.name : (ctx) => {
349
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
350
+ return `${camelCase(ctx.group)}Controller`;
351
+ };
352
+ return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
353
+ }
354
+ return path.resolve(root, output.path, baseName);
355
+ },
356
+ async install() {
357
+ const oas = await this.getOas({ validate });
358
+ if (!output) return;
359
+ await oas.dereference();
360
+ const schemaFiles = await new SchemaGenerator({
361
+ unknownType: "unknown",
362
+ emptySchemaType: "unknown",
363
+ dateType: "date",
364
+ transformers: {},
365
+ ...this.plugin.options
366
+ }, {
367
+ fabric: this.fabric,
368
+ oas,
369
+ pluginManager: this.pluginManager,
370
+ events: this.events,
371
+ plugin: this.plugin,
372
+ contentType,
373
+ include: void 0,
374
+ override: void 0,
375
+ mode: "split",
376
+ output: output.path
377
+ }).build(...generators);
378
+ await this.upsertFile(...schemaFiles);
379
+ const operationFiles = await new OperationGenerator(this.plugin.options, {
380
+ fabric: this.fabric,
381
+ oas,
382
+ pluginManager: this.pluginManager,
383
+ events: this.events,
384
+ plugin: this.plugin,
385
+ contentType,
386
+ exclude: void 0,
387
+ include: void 0,
388
+ override: void 0,
389
+ mode: "split"
390
+ }).build(...generators);
391
+ await this.upsertFile(...operationFiles);
392
+ }
393
+ };
394
+ });
395
+ //#endregion
396
+ //#region src/index.ts
397
+ /**
398
+ * @deprecated use `import { createGenerator } from '@kubb/plugin-oas/generators'`
399
+ */
400
+ const createGenerator = createGenerator$1;
401
+ /**
402
+ * @deprecated use `import { createReactGenerator } from '@kubb/plugin-oas/generators'`
403
+ */
404
+ const createReactGenerator = createReactGenerator$1;
405
+ //#endregion
406
+ export { OperationGenerator, SchemaGenerator, buildOperation, buildOperations, buildSchema, createGenerator, createParser, createReactGenerator, findSchemaKeyword, isKeyword, pluginOas, pluginOasName, schemaKeywords };
407
+
408
+ //# sourceMappingURL=index.js.map