@kubb/agent 5.0.0-beta.75 → 5.0.0-beta.9

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 (146) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +353 -418
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +1 -1
  5. package/.output/server/index.mjs +1 -1
  6. package/.output/server/node_modules/ajv/dist/2019.d.ts +1 -1
  7. package/.output/server/node_modules/ajv/dist/2019.js.map +1 -1
  8. package/.output/server/node_modules/ajv/dist/2020.d.ts +1 -1
  9. package/.output/server/node_modules/ajv/dist/2020.js.map +1 -1
  10. package/.output/server/node_modules/ajv/dist/ajv.d.ts +1 -1
  11. package/.output/server/node_modules/ajv/dist/ajv.js.map +1 -1
  12. package/.output/server/node_modules/ajv/dist/compile/index.d.ts +2 -1
  13. package/.output/server/node_modules/ajv/dist/compile/index.js +10 -3
  14. package/.output/server/node_modules/ajv/dist/compile/index.js.map +1 -1
  15. package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
  16. package/.output/server/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
  17. package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
  18. package/.output/server/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
  19. package/.output/server/node_modules/ajv/dist/compile/names.d.ts +1 -0
  20. package/.output/server/node_modules/ajv/dist/compile/names.js +1 -0
  21. package/.output/server/node_modules/ajv/dist/compile/names.js.map +1 -1
  22. package/.output/server/node_modules/ajv/dist/compile/validate/index.d.ts +1 -1
  23. package/.output/server/node_modules/ajv/dist/compile/validate/index.js +18 -4
  24. package/.output/server/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
  25. package/.output/server/node_modules/ajv/dist/core.d.ts +4 -0
  26. package/.output/server/node_modules/ajv/dist/core.js +15 -1
  27. package/.output/server/node_modules/ajv/dist/core.js.map +1 -1
  28. package/.output/server/node_modules/ajv/dist/draft4.d.ts +19 -0
  29. package/.output/server/node_modules/ajv/dist/draft4.js +57 -0
  30. package/.output/server/node_modules/ajv/dist/draft4.js.map +1 -0
  31. package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-04.json +138 -0
  32. package/.output/server/node_modules/ajv/dist/types/index.d.ts +3 -0
  33. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +2 -1
  34. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -1
  35. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -1
  36. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -1
  37. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +2 -1
  38. package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -1
  39. package/.output/server/node_modules/ajv/dist/vocabularies/code.d.ts +1 -1
  40. package/.output/server/node_modules/ajv/dist/vocabularies/code.js +10 -3
  41. package/.output/server/node_modules/ajv/dist/vocabularies/code.js.map +1 -1
  42. package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +12 -2
  43. package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
  44. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +56 -21
  45. package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
  46. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.d.ts +3 -0
  47. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js +29 -0
  48. package/.output/server/node_modules/ajv/dist/vocabularies/draft4.js.map +1 -0
  49. package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +10 -2
  50. package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -1
  51. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.d.ts +3 -0
  52. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js +26 -0
  53. package/.output/server/node_modules/ajv/dist/vocabularies/oasContext.js.map +1 -0
  54. package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +22 -3
  55. package/.output/server/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -1
  56. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.d.ts +12 -0
  57. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js +43 -0
  58. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumber.js.map +1 -0
  59. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.d.ts +3 -0
  60. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js +19 -0
  61. package/.output/server/node_modules/ajv/dist/vocabularies/validation/draft04/limitNumberExclusive.js.map +1 -0
  62. package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +4 -0
  63. package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -1
  64. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.d.ts +3 -0
  65. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js +20 -0
  66. package/.output/server/node_modules/ajv/dist/vocabularies/validation/readOnly.js.map +1 -0
  67. package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +8 -1
  68. package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -1
  69. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.d.ts +3 -0
  70. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js +20 -0
  71. package/.output/server/node_modules/ajv/dist/vocabularies/validation/writeOnly.js.map +1 -0
  72. package/.output/server/node_modules/ajv/lib/2019.ts +1 -0
  73. package/.output/server/node_modules/ajv/lib/2020.ts +1 -0
  74. package/.output/server/node_modules/ajv/lib/ajv.ts +1 -0
  75. package/.output/server/node_modules/ajv/lib/compile/index.ts +16 -3
  76. package/.output/server/node_modules/ajv/lib/compile/jtd/parse.ts +3 -1
  77. package/.output/server/node_modules/ajv/lib/compile/jtd/serialize.ts +3 -1
  78. package/.output/server/node_modules/ajv/lib/compile/names.ts +1 -0
  79. package/.output/server/node_modules/ajv/lib/compile/validate/index.ts +21 -4
  80. package/.output/server/node_modules/ajv/lib/core.ts +20 -1
  81. package/.output/server/node_modules/ajv/lib/draft4.ts +79 -0
  82. package/.output/server/node_modules/ajv/lib/refs/json-schema-draft-04.json +138 -0
  83. package/.output/server/node_modules/ajv/lib/types/index.ts +4 -0
  84. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +2 -1
  85. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +1 -1
  86. package/.output/server/node_modules/ajv/lib/vocabularies/applicator/properties.ts +4 -1
  87. package/.output/server/node_modules/ajv/lib/vocabularies/code.ts +10 -3
  88. package/.output/server/node_modules/ajv/lib/vocabularies/core/ref.ts +21 -5
  89. package/.output/server/node_modules/ajv/lib/vocabularies/discriminator/index.ts +69 -19
  90. package/.output/server/node_modules/ajv/lib/vocabularies/draft4.ts +32 -0
  91. package/.output/server/node_modules/ajv/lib/vocabularies/metadata.ts +10 -2
  92. package/.output/server/node_modules/ajv/lib/vocabularies/oasContext.ts +27 -0
  93. package/.output/server/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +29 -7
  94. package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumber.ts +75 -0
  95. package/.output/server/node_modules/ajv/lib/vocabularies/validation/draft04/limitNumberExclusive.ts +26 -0
  96. package/.output/server/node_modules/ajv/lib/vocabularies/validation/index.ts +4 -0
  97. package/.output/server/node_modules/ajv/lib/vocabularies/validation/readOnly.ts +23 -0
  98. package/.output/server/node_modules/ajv/lib/vocabularies/validation/required.ts +7 -1
  99. package/.output/server/node_modules/ajv/lib/vocabularies/validation/writeOnly.ts +22 -0
  100. package/.output/server/node_modules/ajv/package.json +9 -6
  101. package/.output/server/node_modules/jiti/LICENSE +21 -0
  102. package/.output/server/node_modules/jiti/README.md +258 -0
  103. package/.output/server/node_modules/jiti/dist/babel.cjs +257 -0
  104. package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
  105. package/.output/server/node_modules/jiti/lib/jiti-cli.mjs +34 -0
  106. package/.output/server/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
  107. package/.output/server/node_modules/jiti/lib/jiti-native.mjs +121 -0
  108. package/.output/server/node_modules/jiti/lib/jiti-register.d.mts +1 -0
  109. package/.output/server/node_modules/jiti/lib/jiti-register.mjs +4 -0
  110. package/.output/server/node_modules/jiti/lib/jiti-static.mjs +23 -0
  111. package/.output/server/node_modules/jiti/lib/jiti.cjs +30 -0
  112. package/.output/server/node_modules/jiti/lib/jiti.d.cts +8 -0
  113. package/.output/server/node_modules/jiti/lib/jiti.d.mts +8 -0
  114. package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
  115. package/.output/server/node_modules/jiti/lib/types.d.ts +420 -0
  116. package/.output/server/node_modules/jiti/package.json +146 -0
  117. package/.output/server/package.json +2 -5
  118. package/README.md +62 -27
  119. package/package.json +13 -12
  120. package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  121. package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  122. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +0 -256
  123. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +0 -75
  124. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/index.js +0 -3
  125. package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +0 -70
  126. package/.output/server/node_modules/@rolldown/pluginutils/dist/index.js +0 -1
  127. package/.output/server/node_modules/@rolldown/pluginutils/dist/utils.js +0 -17
  128. package/.output/server/node_modules/@rolldown/pluginutils/package.json +0 -37
  129. package/.output/server/node_modules/rolldown/dist/index.mjs +0 -50
  130. package/.output/server/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  131. package/.output/server/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +0 -582
  132. package/.output/server/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +0 -2211
  133. package/.output/server/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +0 -6
  134. package/.output/server/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +0 -85
  135. package/.output/server/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +0 -180
  136. package/.output/server/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +0 -21
  137. package/.output/server/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +0 -66
  138. package/.output/server/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +0 -74
  139. package/.output/server/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +0 -847
  140. package/.output/server/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +0 -40
  141. package/.output/server/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +0 -3325
  142. package/.output/server/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +0 -374
  143. package/.output/server/node_modules/rolldown/package.json +0 -153
  144. package/.output/server/node_modules/unrun/dist/index.mjs +0 -2
  145. package/.output/server/node_modules/unrun/dist/src-GU5PtktT.mjs +0 -887
  146. package/.output/server/node_modules/unrun/package.json +0 -125
@@ -18,7 +18,7 @@ import { deflateSync } from 'fflate';
18
18
  import { x } from 'tinyexec';
19
19
  import { access, rm, readFile as readFile$1, readdir as readdir$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
20
20
  import { styleText } from 'node:util';
21
- import { unrun } from 'unrun';
21
+ import { createJiti } from 'jiti';
22
22
  import { mergeDeep } from 'remeda';
23
23
  import WebSocket from 'ws';
24
24
 
@@ -90,26 +90,26 @@ function destr(value, options = {}) {
90
90
  }
91
91
  }
92
92
 
93
- const HASH_RE$1 = /#/g;
94
- const AMPERSAND_RE$1 = /&/g;
95
- const SLASH_RE$1 = /\//g;
96
- const EQUAL_RE$1 = /=/g;
97
- const PLUS_RE$1 = /\+/g;
98
- const ENC_CARET_RE$1 = /%5e/gi;
99
- const ENC_BACKTICK_RE$1 = /%60/gi;
100
- const ENC_PIPE_RE$1 = /%7c/gi;
101
- const ENC_SPACE_RE$1 = /%20/gi;
93
+ const HASH_RE = /#/g;
94
+ const AMPERSAND_RE = /&/g;
95
+ const SLASH_RE = /\//g;
96
+ const EQUAL_RE = /=/g;
97
+ const PLUS_RE = /\+/g;
98
+ const ENC_CARET_RE = /%5e/gi;
99
+ const ENC_BACKTICK_RE = /%60/gi;
100
+ const ENC_PIPE_RE = /%7c/gi;
101
+ const ENC_SPACE_RE = /%20/gi;
102
102
  const ENC_SLASH_RE = /%2f/gi;
103
- function encode$1(text) {
104
- return encodeURI("" + text).replace(ENC_PIPE_RE$1, "|");
103
+ function encode(text) {
104
+ return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
105
105
  }
106
- function encodeQueryValue$1(input) {
107
- return encode$1(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE$1, "%2B").replace(ENC_SPACE_RE$1, "+").replace(HASH_RE$1, "%23").replace(AMPERSAND_RE$1, "%26").replace(ENC_BACKTICK_RE$1, "`").replace(ENC_CARET_RE$1, "^").replace(SLASH_RE$1, "%2F");
106
+ function encodeQueryValue(input) {
107
+ return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
108
108
  }
109
- function encodeQueryKey$1(text) {
110
- return encodeQueryValue$1(text).replace(EQUAL_RE$1, "%3D");
109
+ function encodeQueryKey(text) {
110
+ return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
111
111
  }
112
- function decode$1(text = "") {
112
+ function decode(text = "") {
113
113
  try {
114
114
  return decodeURIComponent("" + text);
115
115
  } catch {
@@ -117,16 +117,16 @@ function decode$1(text = "") {
117
117
  }
118
118
  }
119
119
  function decodePath(text) {
120
- return decode$1(text.replace(ENC_SLASH_RE, "%252F"));
120
+ return decode(text.replace(ENC_SLASH_RE, "%252F"));
121
121
  }
122
- function decodeQueryKey$1(text) {
123
- return decode$1(text.replace(PLUS_RE$1, " "));
122
+ function decodeQueryKey(text) {
123
+ return decode(text.replace(PLUS_RE, " "));
124
124
  }
125
- function decodeQueryValue$1(text) {
126
- return decode$1(text.replace(PLUS_RE$1, " "));
125
+ function decodeQueryValue(text) {
126
+ return decode(text.replace(PLUS_RE, " "));
127
127
  }
128
128
 
129
- function parseQuery$1(parametersString = "") {
129
+ function parseQuery(parametersString = "") {
130
130
  const object = /* @__PURE__ */ Object.create(null);
131
131
  if (parametersString[0] === "?") {
132
132
  parametersString = parametersString.slice(1);
@@ -136,11 +136,11 @@ function parseQuery$1(parametersString = "") {
136
136
  if (s.length < 2) {
137
137
  continue;
138
138
  }
139
- const key = decodeQueryKey$1(s[1]);
139
+ const key = decodeQueryKey(s[1]);
140
140
  if (key === "__proto__" || key === "constructor") {
141
141
  continue;
142
142
  }
143
- const value = decodeQueryValue$1(s[2] || "");
143
+ const value = decodeQueryValue(s[2] || "");
144
144
  if (object[key] === void 0) {
145
145
  object[key] = value;
146
146
  } else if (Array.isArray(object[key])) {
@@ -151,48 +151,48 @@ function parseQuery$1(parametersString = "") {
151
151
  }
152
152
  return object;
153
153
  }
154
- function encodeQueryItem$1(key, value) {
154
+ function encodeQueryItem(key, value) {
155
155
  if (typeof value === "number" || typeof value === "boolean") {
156
156
  value = String(value);
157
157
  }
158
158
  if (!value) {
159
- return encodeQueryKey$1(key);
159
+ return encodeQueryKey(key);
160
160
  }
161
161
  if (Array.isArray(value)) {
162
162
  return value.map(
163
- (_value) => `${encodeQueryKey$1(key)}=${encodeQueryValue$1(_value)}`
163
+ (_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
164
164
  ).join("&");
165
165
  }
166
- return `${encodeQueryKey$1(key)}=${encodeQueryValue$1(value)}`;
166
+ return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
167
167
  }
168
- function stringifyQuery$1(query) {
169
- return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem$1(k, query[k])).filter(Boolean).join("&");
168
+ function stringifyQuery(query) {
169
+ return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
170
170
  }
171
171
 
172
- const PROTOCOL_STRICT_REGEX$1 = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
173
- const PROTOCOL_REGEX$1 = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
174
- const PROTOCOL_RELATIVE_REGEX$1 = /^([/\\]\s*){2,}[^/\\]/;
175
- const JOIN_LEADING_SLASH_RE$1 = /^\.?\//;
176
- function hasProtocol$1(inputString, opts = {}) {
172
+ const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
173
+ const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
174
+ const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
175
+ const JOIN_LEADING_SLASH_RE = /^\.?\//;
176
+ function hasProtocol(inputString, opts = {}) {
177
177
  if (typeof opts === "boolean") {
178
178
  opts = { acceptRelative: opts };
179
179
  }
180
180
  if (opts.strict) {
181
- return PROTOCOL_STRICT_REGEX$1.test(inputString);
181
+ return PROTOCOL_STRICT_REGEX.test(inputString);
182
182
  }
183
- return PROTOCOL_REGEX$1.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX$1.test(inputString) : false);
183
+ return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
184
184
  }
185
- function hasTrailingSlash$1(input = "", respectQueryAndFragment) {
185
+ function hasTrailingSlash(input = "", respectQueryAndFragment) {
186
186
  {
187
187
  return input.endsWith("/");
188
188
  }
189
189
  }
190
- function withoutTrailingSlash$1(input = "", respectQueryAndFragment) {
190
+ function withoutTrailingSlash(input = "", respectQueryAndFragment) {
191
191
  {
192
- return (hasTrailingSlash$1(input) ? input.slice(0, -1) : input) || "/";
192
+ return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
193
193
  }
194
194
  }
195
- function withTrailingSlash$1(input = "", respectQueryAndFragment) {
195
+ function withTrailingSlash(input = "", respectQueryAndFragment) {
196
196
  {
197
197
  return input.endsWith("/") ? input : input + "/";
198
198
  }
@@ -204,36 +204,54 @@ function withLeadingSlash(input = "") {
204
204
  return hasLeadingSlash(input) ? input : "/" + input;
205
205
  }
206
206
  function withBase(input, base) {
207
- if (isEmptyURL$1(base) || hasProtocol$1(input)) {
207
+ if (isEmptyURL(base) || hasProtocol(input)) {
208
208
  return input;
209
209
  }
210
- const _base = withoutTrailingSlash$1(base);
210
+ const _base = withoutTrailingSlash(base);
211
211
  if (input.startsWith(_base)) {
212
212
  const nextChar = input[_base.length];
213
213
  if (!nextChar || nextChar === "/" || nextChar === "?") {
214
214
  return input;
215
215
  }
216
216
  }
217
- return joinURL$1(_base, input);
217
+ return joinURL(_base, input);
218
+ }
219
+ function withoutBase(input, base) {
220
+ if (isEmptyURL(base)) {
221
+ return input;
222
+ }
223
+ const _base = withoutTrailingSlash(base);
224
+ if (!input.startsWith(_base)) {
225
+ return input;
226
+ }
227
+ const nextChar = input[_base.length];
228
+ if (nextChar && nextChar !== "/" && nextChar !== "?") {
229
+ return input;
230
+ }
231
+ const trimmed = input.slice(_base.length).replace(/^\/+/, "");
232
+ return "/" + trimmed;
233
+ }
234
+ function withQuery(input, query) {
235
+ const parsed = parseURL(input);
236
+ const mergedQuery = { ...parseQuery(parsed.search), ...query };
237
+ parsed.search = stringifyQuery(mergedQuery);
238
+ return stringifyParsedURL(parsed);
218
239
  }
219
- function withQuery$1(input, query) {
220
- const parsed = parseURL$1(input);
221
- const mergedQuery = { ...parseQuery$1(parsed.search), ...query };
222
- parsed.search = stringifyQuery$1(mergedQuery);
223
- return stringifyParsedURL$1(parsed);
240
+ function getQuery(input) {
241
+ return parseQuery(parseURL(input).search);
224
242
  }
225
- function isEmptyURL$1(url) {
243
+ function isEmptyURL(url) {
226
244
  return !url || url === "/";
227
245
  }
228
- function isNonEmptyURL$1(url) {
246
+ function isNonEmptyURL(url) {
229
247
  return url && url !== "/";
230
248
  }
231
- function joinURL$1(base, ...input) {
249
+ function joinURL(base, ...input) {
232
250
  let url = base || "";
233
- for (const segment of input.filter((url2) => isNonEmptyURL$1(url2))) {
251
+ for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
234
252
  if (url) {
235
- const _segment = segment.replace(JOIN_LEADING_SLASH_RE$1, "");
236
- url = withTrailingSlash$1(url) + _segment;
253
+ const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
254
+ url = withTrailingSlash(url) + _segment;
237
255
  } else {
238
256
  url = segment;
239
257
  }
@@ -241,8 +259,8 @@ function joinURL$1(base, ...input) {
241
259
  return url;
242
260
  }
243
261
 
244
- const protocolRelative$1 = Symbol.for("ufo:protocolRelative");
245
- function parseURL$1(input = "", defaultProto) {
262
+ const protocolRelative = Symbol.for("ufo:protocolRelative");
263
+ function parseURL(input = "", defaultProto) {
246
264
  const _specialProtoMatch = input.match(
247
265
  /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
248
266
  );
@@ -258,15 +276,15 @@ function parseURL$1(input = "", defaultProto) {
258
276
  hash: ""
259
277
  };
260
278
  }
261
- if (!hasProtocol$1(input, { acceptRelative: true })) {
262
- return parsePath$1(input);
279
+ if (!hasProtocol(input, { acceptRelative: true })) {
280
+ return parsePath(input);
263
281
  }
264
282
  const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
265
283
  let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
266
284
  if (protocol === "file:") {
267
285
  path = path.replace(/\/(?=[A-Za-z]:)/, "");
268
286
  }
269
- const { pathname, search, hash } = parsePath$1(path);
287
+ const { pathname, search, hash } = parsePath(path);
270
288
  return {
271
289
  protocol: protocol.toLowerCase(),
272
290
  auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
@@ -274,10 +292,10 @@ function parseURL$1(input = "", defaultProto) {
274
292
  pathname,
275
293
  search,
276
294
  hash,
277
- [protocolRelative$1]: !protocol
295
+ [protocolRelative]: !protocol
278
296
  };
279
297
  }
280
- function parsePath$1(input = "") {
298
+ function parsePath(input = "") {
281
299
  const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
282
300
  return {
283
301
  pathname,
@@ -285,13 +303,13 @@ function parsePath$1(input = "") {
285
303
  hash
286
304
  };
287
305
  }
288
- function stringifyParsedURL$1(parsed) {
306
+ function stringifyParsedURL(parsed) {
289
307
  const pathname = parsed.pathname || "";
290
308
  const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
291
309
  const hash = parsed.hash || "";
292
310
  const auth = parsed.auth ? parsed.auth + "@" : "";
293
311
  const host = parsed.host || "";
294
- const proto = parsed.protocol || parsed[protocolRelative$1] ? (parsed.protocol || "") + "//" : "";
312
+ const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
295
313
  return proto + auth + host + pathname + search + hash;
296
314
  }
297
315
 
@@ -1591,7 +1609,7 @@ function createResolver(stack) {
1591
1609
  res = {
1592
1610
  ...res,
1593
1611
  ..._res,
1594
- route: joinURL$1(res.route || "/", _res.route || "/")
1612
+ route: joinURL(res.route || "/", _res.route || "/")
1595
1613
  };
1596
1614
  }
1597
1615
  return res;
@@ -1609,7 +1627,7 @@ function normalizeLayer(input) {
1609
1627
  handler = toEventHandler(handler, void 0, input.route);
1610
1628
  }
1611
1629
  return {
1612
- route: withoutTrailingSlash$1(input.route),
1630
+ route: withoutTrailingSlash(input.route),
1613
1631
  match: input.match,
1614
1632
  handler
1615
1633
  };
@@ -1676,7 +1694,7 @@ function websocketOptions(evResolver, appOptions) {
1676
1694
  ...appOptions.websocket,
1677
1695
  async resolve(info) {
1678
1696
  const url = info.request?.url || info.url || "/";
1679
- const { pathname } = typeof url === "string" ? parseURL$1(url) : url;
1697
+ const { pathname } = typeof url === "string" ? parseURL(url) : url;
1680
1698
  const resolved = await evResolver(pathname);
1681
1699
  return resolved?.handler?.__websocket__ || {};
1682
1700
  }
@@ -2268,7 +2286,7 @@ function createFetch(globalOptions = {}) {
2268
2286
  context.request = withBase(context.request, context.options.baseURL);
2269
2287
  }
2270
2288
  if (context.options.query) {
2271
- context.request = withQuery$1(context.request, context.options.query);
2289
+ context.request = withQuery(context.request, context.options.query);
2272
2290
  delete context.options.query;
2273
2291
  }
2274
2292
  if ("query" in context.options) {
@@ -2413,206 +2431,6 @@ const Headers$1 = globalThis.Headers || s$1;
2413
2431
  const AbortController = globalThis.AbortController || i;
2414
2432
  createFetch({ fetch, Headers: Headers$1, AbortController });
2415
2433
 
2416
- const HASH_RE = /#/g;
2417
- const AMPERSAND_RE = /&/g;
2418
- const SLASH_RE = /\//g;
2419
- const EQUAL_RE = /=/g;
2420
- const PLUS_RE = /\+/g;
2421
- const ENC_CARET_RE = /%5e/gi;
2422
- const ENC_BACKTICK_RE = /%60/gi;
2423
- const ENC_PIPE_RE = /%7c/gi;
2424
- const ENC_SPACE_RE = /%20/gi;
2425
- function encode(text) {
2426
- return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
2427
- }
2428
- function encodeQueryValue(input) {
2429
- return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
2430
- }
2431
- function encodeQueryKey(text) {
2432
- return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
2433
- }
2434
- function decode(text = "") {
2435
- try {
2436
- return decodeURIComponent("" + text);
2437
- } catch {
2438
- return "" + text;
2439
- }
2440
- }
2441
- function decodeQueryKey(text) {
2442
- return decode(text.replace(PLUS_RE, " "));
2443
- }
2444
- function decodeQueryValue(text) {
2445
- return decode(text.replace(PLUS_RE, " "));
2446
- }
2447
-
2448
- function parseQuery(parametersString = "") {
2449
- const object = /* @__PURE__ */ Object.create(null);
2450
- if (parametersString[0] === "?") {
2451
- parametersString = parametersString.slice(1);
2452
- }
2453
- for (const parameter of parametersString.split("&")) {
2454
- const s = parameter.match(/([^=]+)=?(.*)/) || [];
2455
- if (s.length < 2) {
2456
- continue;
2457
- }
2458
- const key = decodeQueryKey(s[1]);
2459
- if (key === "__proto__" || key === "constructor") {
2460
- continue;
2461
- }
2462
- const value = decodeQueryValue(s[2] || "");
2463
- if (object[key] === void 0) {
2464
- object[key] = value;
2465
- } else if (Array.isArray(object[key])) {
2466
- object[key].push(value);
2467
- } else {
2468
- object[key] = [object[key], value];
2469
- }
2470
- }
2471
- return object;
2472
- }
2473
- function encodeQueryItem(key, value) {
2474
- if (typeof value === "number" || typeof value === "boolean") {
2475
- value = String(value);
2476
- }
2477
- if (!value) {
2478
- return encodeQueryKey(key);
2479
- }
2480
- if (Array.isArray(value)) {
2481
- return value.map(
2482
- (_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`
2483
- ).join("&");
2484
- }
2485
- return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
2486
- }
2487
- function stringifyQuery(query) {
2488
- return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
2489
- }
2490
-
2491
- const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
2492
- const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
2493
- const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
2494
- const JOIN_LEADING_SLASH_RE = /^\.?\//;
2495
- function hasProtocol(inputString, opts = {}) {
2496
- if (typeof opts === "boolean") {
2497
- opts = { acceptRelative: opts };
2498
- }
2499
- if (opts.strict) {
2500
- return PROTOCOL_STRICT_REGEX.test(inputString);
2501
- }
2502
- return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
2503
- }
2504
- function hasTrailingSlash(input = "", respectQueryAndFragment) {
2505
- {
2506
- return input.endsWith("/");
2507
- }
2508
- }
2509
- function withoutTrailingSlash(input = "", respectQueryAndFragment) {
2510
- {
2511
- return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
2512
- }
2513
- }
2514
- function withTrailingSlash(input = "", respectQueryAndFragment) {
2515
- {
2516
- return input.endsWith("/") ? input : input + "/";
2517
- }
2518
- }
2519
- function withoutBase(input, base) {
2520
- if (isEmptyURL(base)) {
2521
- return input;
2522
- }
2523
- const _base = withoutTrailingSlash(base);
2524
- if (!input.startsWith(_base)) {
2525
- return input;
2526
- }
2527
- const nextChar = input[_base.length];
2528
- if (nextChar && nextChar !== "/" && nextChar !== "?") {
2529
- return input;
2530
- }
2531
- const trimmed = input.slice(_base.length).replace(/^\/+/, "");
2532
- return "/" + trimmed;
2533
- }
2534
- function withQuery(input, query) {
2535
- const parsed = parseURL(input);
2536
- const mergedQuery = { ...parseQuery(parsed.search), ...query };
2537
- parsed.search = stringifyQuery(mergedQuery);
2538
- return stringifyParsedURL(parsed);
2539
- }
2540
- function getQuery(input) {
2541
- return parseQuery(parseURL(input).search);
2542
- }
2543
- function isEmptyURL(url) {
2544
- return !url || url === "/";
2545
- }
2546
- function isNonEmptyURL(url) {
2547
- return url && url !== "/";
2548
- }
2549
- function joinURL(base, ...input) {
2550
- let url = base || "";
2551
- for (const segment of input.filter((url2) => isNonEmptyURL(url2))) {
2552
- if (url) {
2553
- const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
2554
- url = withTrailingSlash(url) + _segment;
2555
- } else {
2556
- url = segment;
2557
- }
2558
- }
2559
- return url;
2560
- }
2561
-
2562
- const protocolRelative = Symbol.for("ufo:protocolRelative");
2563
- function parseURL(input = "", defaultProto) {
2564
- const _specialProtoMatch = input.match(
2565
- /^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
2566
- );
2567
- if (_specialProtoMatch) {
2568
- const [, _proto, _pathname = ""] = _specialProtoMatch;
2569
- return {
2570
- protocol: _proto.toLowerCase(),
2571
- pathname: _pathname,
2572
- href: _proto + _pathname,
2573
- auth: "",
2574
- host: "",
2575
- search: "",
2576
- hash: ""
2577
- };
2578
- }
2579
- if (!hasProtocol(input, { acceptRelative: true })) {
2580
- return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
2581
- }
2582
- const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
2583
- let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
2584
- if (protocol === "file:") {
2585
- path = path.replace(/\/(?=[A-Za-z]:)/, "");
2586
- }
2587
- const { pathname, search, hash } = parsePath(path);
2588
- return {
2589
- protocol: protocol.toLowerCase(),
2590
- auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
2591
- host,
2592
- pathname,
2593
- search,
2594
- hash,
2595
- [protocolRelative]: !protocol
2596
- };
2597
- }
2598
- function parsePath(input = "") {
2599
- const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
2600
- return {
2601
- pathname,
2602
- search,
2603
- hash
2604
- };
2605
- }
2606
- function stringifyParsedURL(parsed) {
2607
- const pathname = parsed.pathname || "";
2608
- const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
2609
- const hash = parsed.hash || "";
2610
- const auth = parsed.auth ? parsed.auth + "@" : "";
2611
- const host = parsed.host || "";
2612
- const proto = parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "";
2613
- return proto + auth + host + pathname + search + hash;
2614
- }
2615
-
2616
2434
  function wrapToPromise(value) {
2617
2435
  if (!value || typeof value.then !== "function") {
2618
2436
  return Promise.resolve(value);
@@ -4608,11 +4426,14 @@ function sendToBetterStack(level, tag, message, ctx) {
4608
4426
  const fullMessage = message !== void 0 ? `[${tag}] ${message}` : tag;
4609
4427
  const context = toBetterStackContext(ctx);
4610
4428
  if (level === "error") {
4611
- client.error(fullMessage, context).then(() => client.flush());
4429
+ client.error(fullMessage, context).then(() => client.flush()).catch(() => {
4430
+ });
4612
4431
  } else if (level === "warn") {
4613
- client.warn(fullMessage, context).then(() => client.flush());
4432
+ client.warn(fullMessage, context).then(() => client.flush()).catch(() => {
4433
+ });
4614
4434
  } else {
4615
- client.info(fullMessage, context).then(() => client.flush());
4435
+ client.info(fullMessage, context).then(() => client.flush()).catch(() => {
4436
+ });
4616
4437
  }
4617
4438
  } catch (_e) {
4618
4439
  }
@@ -4906,6 +4727,10 @@ function isKind(kind) {
4906
4727
  }
4907
4728
  const isOperationNode = isKind("Operation");
4908
4729
  const isSchemaNode = isKind("Schema");
4730
+ function extractRefName(ref) {
4731
+ var _a;
4732
+ return (_a = ref.split("/").at(-1)) != null ? _a : ref;
4733
+ }
4909
4734
  function createLimit(concurrency) {
4910
4735
  let active = 0;
4911
4736
  const queue = [];
@@ -5130,6 +4955,42 @@ function transform(node, options) {
5130
4955
  return node;
5131
4956
  }
5132
4957
  }
4958
+ function collect(node, options) {
4959
+ var _a, _b, _c, _d, _e, _f, _g;
4960
+ const { depth, parent, ...visitor } = options;
4961
+ const recurse = (depth != null ? depth : visitorDepths.deep) === visitorDepths.deep;
4962
+ const results = [];
4963
+ let v;
4964
+ switch (node.kind) {
4965
+ case "Input":
4966
+ v = (_a = visitor.input) == null ? void 0 : _a.call(visitor, node, { parent });
4967
+ break;
4968
+ case "Output":
4969
+ v = (_b = visitor.output) == null ? void 0 : _b.call(visitor, node, { parent });
4970
+ break;
4971
+ case "Operation":
4972
+ v = (_c = visitor.operation) == null ? void 0 : _c.call(visitor, node, { parent });
4973
+ break;
4974
+ case "Schema":
4975
+ v = (_d = visitor.schema) == null ? void 0 : _d.call(visitor, node, { parent });
4976
+ break;
4977
+ case "Property":
4978
+ v = (_e = visitor.property) == null ? void 0 : _e.call(visitor, node, { parent });
4979
+ break;
4980
+ case "Parameter":
4981
+ v = (_f = visitor.parameter) == null ? void 0 : _f.call(visitor, node, { parent });
4982
+ break;
4983
+ case "Response":
4984
+ v = (_g = visitor.response) == null ? void 0 : _g.call(visitor, node, { parent });
4985
+ break;
4986
+ }
4987
+ if (v !== void 0) results.push(v);
4988
+ for (const child of getChildren(node, recurse)) for (const item of collect(child, {
4989
+ ...options,
4990
+ parent: node
4991
+ })) results.push(item);
4992
+ return results;
4993
+ }
5133
4994
  function sourceKey(source) {
5134
4995
  var _a, _b, _c;
5135
4996
  return `${(_a = source.name) != null ? _a : extractStringsFromNodes(source.nodes)}:${(_b = source.isExportable) != null ? _b : false}:${(_c = source.isTypeOnly) != null ? _c : false}`;
@@ -5159,11 +5020,11 @@ function combineSources(sources) {
5159
5020
  }
5160
5021
  return [...seen.values()];
5161
5022
  }
5162
- function combineExports(exports$1) {
5023
+ function combineExports(exports) {
5163
5024
  const result = [];
5164
5025
  const namedByPath = /* @__PURE__ */ new Map();
5165
5026
  const seen = /* @__PURE__ */ new Set();
5166
- const keyed = exports$1.map((node) => ({
5027
+ const keyed = exports.map((node) => ({
5167
5028
  node,
5168
5029
  key: sortKey(node)
5169
5030
  }));
@@ -5196,9 +5057,17 @@ function combineExports(exports$1) {
5196
5057
  }
5197
5058
  return result;
5198
5059
  }
5199
- function combineImports(imports, exports$1, source) {
5200
- const exportedNames = new Set(exports$1.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
5060
+ function combineImports(imports, exports, source) {
5061
+ const exportedNames = new Set(exports.flatMap((e) => Array.isArray(e.name) ? e.name : e.name ? [e.name] : []));
5201
5062
  const isUsed = (importName) => !source || source.includes(importName) || exportedNames.has(importName);
5063
+ const importNameMemo = /* @__PURE__ */ new Map();
5064
+ const canonicalizeName = (n) => {
5065
+ var _a;
5066
+ if (typeof n === "string") return n;
5067
+ const key = `${n.propertyName}:${(_a = n.name) != null ? _a : ""}`;
5068
+ if (!importNameMemo.has(key)) importNameMemo.set(key, n);
5069
+ return importNameMemo.get(key);
5070
+ };
5202
5071
  const result = [];
5203
5072
  const namedByPath = /* @__PURE__ */ new Map();
5204
5073
  const seen = /* @__PURE__ */ new Set();
@@ -5212,7 +5081,10 @@ function combineImports(imports, exports$1, source) {
5212
5081
  const { path: path2, isTypeOnly } = curr;
5213
5082
  let { name } = curr;
5214
5083
  if (Array.isArray(name)) {
5215
- name = [...new Set(name)].filter((item) => typeof item === "string" ? isUsed(item) : isUsed(item.propertyName));
5084
+ name = [...new Set(name.map(canonicalizeName))].filter((item) => {
5085
+ var _a;
5086
+ return typeof item === "string" ? isUsed(item) : isUsed((_a = item.name) != null ? _a : item.propertyName);
5087
+ });
5216
5088
  if (!name.length) continue;
5217
5089
  const key = pathTypeKey(path2, isTypeOnly);
5218
5090
  const existing = namedByPath.get(key);
@@ -5256,6 +5128,40 @@ function extractStringsFromNodes(nodes) {
5256
5128
  return parts.join("\n");
5257
5129
  }).filter(Boolean).join("\n");
5258
5130
  }
5131
+ function resolveRefName(node) {
5132
+ var _a, _b, _c, _d, _e, _f, _g;
5133
+ if (!node || node.type !== "ref") return void 0;
5134
+ if (node.ref) return (_d = (_c = (_a = extractRefName(node.ref)) != null ? _a : node.name) != null ? _c : (_b = node.schema) == null ? void 0 : _b.name) != null ? _d : void 0;
5135
+ return (_g = (_f = node.name) != null ? _f : (_e = node.schema) == null ? void 0 : _e.name) != null ? _g : void 0;
5136
+ }
5137
+ function collectReferencedSchemaNames(node, out = /* @__PURE__ */ new Set()) {
5138
+ if (!node) return out;
5139
+ collect(node, { schema(child) {
5140
+ if (child.type === "ref") {
5141
+ const name = resolveRefName(child);
5142
+ if (name) out.add(name);
5143
+ }
5144
+ } });
5145
+ return out;
5146
+ }
5147
+ function collectUsedSchemaNames(operations, schemas) {
5148
+ const schemaMap = /* @__PURE__ */ new Map();
5149
+ for (const schema of schemas) if (schema.name) schemaMap.set(schema.name, schema);
5150
+ const result = /* @__PURE__ */ new Set();
5151
+ function visitSchema(schema) {
5152
+ const directRefs = collectReferencedSchemaNames(schema);
5153
+ for (const name of directRefs) if (!result.has(name)) {
5154
+ result.add(name);
5155
+ const namedSchema = schemaMap.get(name);
5156
+ if (namedSchema) visitSchema(namedSchema);
5157
+ }
5158
+ }
5159
+ for (const op of operations) for (const schema of collect(op, {
5160
+ depth: "shallow",
5161
+ schema: (node) => node
5162
+ })) visitSchema(schema);
5163
+ return result;
5164
+ }
5259
5165
  function syncOptionality(schema, required) {
5260
5166
  var _a;
5261
5167
  const nullable = (_a = schema.nullable) != null ? _a : false;
@@ -5346,9 +5252,13 @@ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
5346
5252
  }) : camelCase(part));
5347
5253
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
5348
5254
  }
5349
- const DEFAULT_STUDIO_URL = "https://studio.kubb.dev";
5255
+ const DEFAULT_STUDIO_URL = "https://kubb.studio";
5350
5256
  const DEFAULT_BANNER = "simple";
5351
5257
  const DEFAULT_EXTENSION = { ".ts": ".ts" };
5258
+ function getMode(fileOrFolder) {
5259
+ if (!fileOrFolder) return "split";
5260
+ return extname(fileOrFolder) ? "single" : "split";
5261
+ }
5352
5262
  const stringPatternCache = /* @__PURE__ */ new Map();
5353
5263
  function testPattern(value, pattern) {
5354
5264
  if (typeof pattern === "string") {
@@ -5419,7 +5329,7 @@ function defaultResolveOptions(node, { options, exclude = [], include, override
5419
5329
  }
5420
5330
  function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root, output, group }) {
5421
5331
  var _a2;
5422
- if ((pathMode != null ? pathMode : PluginDriver.getMode(path$1.resolve(root, output.path))) === "single") return path$1.resolve(root, output.path);
5332
+ if ((pathMode != null ? pathMode : getMode(path$1.resolve(root, output.path))) === "single") return path$1.resolve(root, output.path);
5423
5333
  let result;
5424
5334
  if (group && (groupPath || tag)) {
5425
5335
  const groupValue = group.type === "path" ? groupPath : tag;
@@ -5435,10 +5345,10 @@ function defaultResolvePath({ baseName, pathMode, tag, path: groupPath }, { root
5435
5345
  if (result !== outputDir && !result.startsWith(outputDirWithSep)) throw new Error(`[Kubb] Resolved path "${result}" is outside the output directory "${outputDir}". This may indicate a path traversal attempt in the OpenAPI specification or a misconfigured group.name function.`);
5436
5346
  return result;
5437
5347
  }
5438
- function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context, ctx) {
5439
- const pathMode = PluginDriver.getMode(path$1.resolve(context.root, context.output.path));
5440
- const baseName = `${pathMode === "single" ? "" : ctx.default(name, "file")}${extname2}`;
5441
- const filePath = ctx.resolvePath({
5348
+ function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, context) {
5349
+ const pathMode = getMode(path$1.resolve(context.root, context.output.path));
5350
+ const baseName = `${pathMode === "single" ? "" : this.default(name, "file")}${extname2}`;
5351
+ const filePath = this.resolvePath({
5442
5352
  baseName,
5443
5353
  pathMode,
5444
5354
  tag,
@@ -5447,7 +5357,7 @@ function defaultResolveFile({ name, extname: extname2, tag, path: groupPath }, c
5447
5357
  return createFile({
5448
5358
  path: filePath,
5449
5359
  baseName: path$1.basename(filePath),
5450
- meta: { pluginName: ctx.pluginName },
5360
+ meta: { pluginName: this.pluginName },
5451
5361
  sources: [],
5452
5362
  imports: [],
5453
5363
  exports: []
@@ -5459,8 +5369,8 @@ function buildDefaultBanner({ title, description, version, config }) {
5459
5369
  if (Array.isArray(config.input)) {
5460
5370
  const first = config.input[0];
5461
5371
  if (first && "path" in first) source = path$1.basename(first.path);
5462
- } else if ("path" in config.input) source = path$1.basename(config.input.path);
5463
- else if ("data" in config.input) source = "text content";
5372
+ } else if (config.input && "path" in config.input) source = path$1.basename(config.input.path);
5373
+ else if (config.input && "data" in config.input) source = "text content";
5464
5374
  let banner = "/**\n* Generated by Kubb (https://kubb.dev/).\n* Do not edit manually.\n";
5465
5375
  if (config.output.defaultBanner === "simple") {
5466
5376
  banner += "*/\n";
@@ -5499,16 +5409,16 @@ function defaultResolveFooter(node, { output }) {
5499
5409
  if (typeof (output == null ? void 0 : output.footer) === "string") return output.footer;
5500
5410
  }
5501
5411
  function defineResolver(build) {
5502
- const resolver = {};
5503
- Object.assign(resolver, {
5412
+ let resolver;
5413
+ resolver = {
5504
5414
  default: defaultResolver,
5505
5415
  resolveOptions: defaultResolveOptions,
5506
5416
  resolvePath: defaultResolvePath,
5507
- resolveFile: (params, context) => defaultResolveFile(params, context, resolver),
5417
+ resolveFile: (params, context) => defaultResolveFile.call(resolver, params, context),
5508
5418
  resolveBanner: defaultResolveBanner,
5509
5419
  resolveFooter: defaultResolveFooter,
5510
- ...build(resolver)
5511
- });
5420
+ ...build()
5421
+ };
5512
5422
  return resolver;
5513
5423
  }
5514
5424
  function encodeAst(input) {
@@ -5614,18 +5524,6 @@ var FileManager = (_a$1 = class {
5614
5524
  __privateSet$1(this, _filesCache, null);
5615
5525
  return resolvedFiles;
5616
5526
  }, _a$1);
5617
- async function applyHookResult(result, driver, rendererFactory) {
5618
- if (!result) return;
5619
- if (Array.isArray(result)) {
5620
- driver.fileManager.upsert(...result);
5621
- return;
5622
- }
5623
- if (!rendererFactory) return;
5624
- const renderer = rendererFactory();
5625
- await renderer.render(result);
5626
- driver.fileManager.upsert(...renderer.files);
5627
- renderer.unmount();
5628
- }
5629
5527
  function enforceOrder(enforce) {
5630
5528
  return enforce === "pre" ? -1 : enforce === "post" ? 1 : 0;
5631
5529
  }
@@ -5680,8 +5578,7 @@ var PluginDriver = (_b$1 = class {
5680
5578
  * ```
5681
5579
  */
5682
5580
  static getMode(fileOrFolder) {
5683
- if (!fileOrFolder) return "split";
5684
- return extname(fileOrFolder) ? "single" : "split";
5581
+ return getMode(fileOrFolder);
5685
5582
  }
5686
5583
  get hooks() {
5687
5584
  return this.options.hooks;
@@ -5703,6 +5600,7 @@ var PluginDriver = (_b$1 = class {
5703
5600
  */
5704
5601
  registerPluginHooks(hookPlugin, normalizedPlugin) {
5705
5602
  const { hooks } = hookPlugin;
5603
+ if (!hooks) return;
5706
5604
  if (hooks["kubb:plugin:setup"]) {
5707
5605
  const setupHandler = (globalCtx) => {
5708
5606
  var _a2;
@@ -5897,7 +5795,7 @@ var PluginDriver = (_b$1 = class {
5897
5795
  if (typeof driver.config.devtools !== "object") throw new Error("Devtools must be an object");
5898
5796
  if (!driver.inputNode || !driver.adapter) throw new Error("adapter is not defined, make sure you have set the parser in kubb.config.ts");
5899
5797
  __privateSet$1(driver, _studioIsOpen, true);
5900
- const studioUrl = (_b2 = (_a2 = driver.config.devtools) == null ? void 0 : _a2.studioUrl) != null ? _b2 : "https://studio.kubb.dev";
5798
+ const studioUrl = (_b2 = (_a2 = driver.config.devtools) == null ? void 0 : _a2.studioUrl) != null ? _b2 : "https://kubb.studio";
5901
5799
  return openInStudio(driver.inputNode, studioUrl, options);
5902
5800
  }
5903
5801
  };
@@ -5937,13 +5835,25 @@ normalizePlugin_fn = function(hookPlugin) {
5937
5835
  }, createDefaultResolver_fn = function(pluginName) {
5938
5836
  const existingResolver = __privateGet$1(this, _defaultResolvers).get(pluginName);
5939
5837
  if (existingResolver) return existingResolver;
5940
- const resolver = defineResolver((_ctx) => ({
5838
+ const resolver = defineResolver(() => ({
5941
5839
  name: "default",
5942
5840
  pluginName
5943
5841
  }));
5944
5842
  __privateGet$1(this, _defaultResolvers).set(pluginName, resolver);
5945
5843
  return resolver;
5946
5844
  }, _b$1);
5845
+ async function applyHookResult(result, driver, rendererFactory) {
5846
+ if (!result) return;
5847
+ if (Array.isArray(result)) {
5848
+ driver.fileManager.upsert(...result);
5849
+ return;
5850
+ }
5851
+ if (!rendererFactory) return;
5852
+ const renderer = rendererFactory();
5853
+ await renderer.render(result);
5854
+ driver.fileManager.upsert(...renderer.files);
5855
+ renderer.unmount();
5856
+ }
5947
5857
 
5948
5858
  var __defProp = Object.defineProperty;
5949
5859
  var __typeError = (msg) => {
@@ -6342,6 +6252,7 @@ eachParam_fn = function(fn) {
6342
6252
  fn(raw, __privateMethod(this, _URLPath_instances, transformParam_fn).call(this, raw));
6343
6253
  }
6344
6254
  }, _b);
6255
+ var version$1 = "5.0.0-beta.9";
6345
6256
  var Node$1 = (_c = class {
6346
6257
  constructor(value) {
6347
6258
  __publicField(this, "value");
@@ -6508,26 +6419,21 @@ var FileProcessor = (_e = class {
6508
6419
  function createStorage(build2) {
6509
6420
  return (options) => build2(options != null ? options : {});
6510
6421
  }
6511
- function isMissingPathError(error) {
6512
- return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
6513
- }
6514
6422
  const fsStorage = createStorage(() => ({
6515
6423
  name: "fs",
6516
6424
  async hasItem(key) {
6517
6425
  try {
6518
6426
  await access(resolve(key));
6519
6427
  return true;
6520
- } catch (error) {
6521
- if (isMissingPathError(error)) return false;
6522
- throw new Error(`Failed to access storage item "${key}"`, { cause: error });
6428
+ } catch (_error) {
6429
+ return false;
6523
6430
  }
6524
6431
  },
6525
6432
  async getItem(key) {
6526
6433
  try {
6527
6434
  return await readFile$1(resolve(key), "utf8");
6528
- } catch (error) {
6529
- if (isMissingPathError(error)) return null;
6530
- throw new Error(`Failed to read storage item "${key}"`, { cause: error });
6435
+ } catch (_error) {
6436
+ return null;
6531
6437
  }
6532
6438
  },
6533
6439
  async setItem(key, value) {
@@ -6543,9 +6449,8 @@ const fsStorage = createStorage(() => ({
6543
6449
  let entries;
6544
6450
  try {
6545
6451
  entries = await readdir$1(dir, { withFileTypes: true });
6546
- } catch (error) {
6547
- if (isMissingPathError(error)) return;
6548
- throw new Error(`Failed to list storage keys under "${resolvedBase}"`, { cause: error });
6452
+ } catch (_error) {
6453
+ return;
6549
6454
  }
6550
6455
  for (const entry of entries) {
6551
6456
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
@@ -6561,37 +6466,43 @@ const fsStorage = createStorage(() => ({
6561
6466
  await clean(resolve(base));
6562
6467
  }
6563
6468
  }));
6564
- var version$1 = "5.0.0-beta.75";
6565
- function getDiagnosticInfo() {
6566
- return {
6567
- nodeVersion: version$2,
6568
- KubbVersion: version$1,
6569
- platform: process.platform,
6570
- arch: process.arch,
6571
- cwd: process.cwd()
6572
- };
6573
- }
6574
- function isInputPath(config) {
6575
- return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
6576
- }
6577
6469
  async function setup(userConfig, options = {}) {
6578
6470
  var _a2, _b2, _c2, _d2, _e2, _f, _g, _h, _i;
6579
6471
  const hooks = (_a2 = options.hooks) != null ? _a2 : new AsyncEventEmitter();
6472
+ const config = {
6473
+ ...userConfig,
6474
+ root: userConfig.root || process.cwd(),
6475
+ parsers: (_b2 = userConfig.parsers) != null ? _b2 : [],
6476
+ adapter: userConfig.adapter,
6477
+ output: {
6478
+ format: false,
6479
+ lint: false,
6480
+ extension: DEFAULT_EXTENSION,
6481
+ defaultBanner: DEFAULT_BANNER,
6482
+ ...userConfig.output
6483
+ },
6484
+ storage: (_c2 = userConfig.storage) != null ? _c2 : fsStorage(),
6485
+ devtools: userConfig.devtools ? {
6486
+ studioUrl: DEFAULT_STUDIO_URL,
6487
+ ...typeof userConfig.devtools === "boolean" ? {} : userConfig.devtools
6488
+ } : void 0,
6489
+ plugins: (_d2 = userConfig.plugins) != null ? _d2 : []
6490
+ };
6491
+ const driver = new PluginDriver(config, { hooks });
6580
6492
  const sources = /* @__PURE__ */ new Map();
6581
6493
  const diagnosticInfo = getDiagnosticInfo();
6582
- if (Array.isArray(userConfig.input)) await hooks.emit("kubb:warn", { message: "This feature is still under development \u2014 use with caution" });
6583
6494
  await hooks.emit("kubb:debug", {
6584
6495
  date: /* @__PURE__ */ new Date(),
6585
6496
  logs: [
6586
6497
  "Configuration:",
6587
6498
  ` \u2022 Name: ${userConfig.name || "unnamed"}`,
6588
6499
  ` \u2022 Root: ${userConfig.root || process.cwd()}`,
6589
- ` \u2022 Output: ${((_b2 = userConfig.output) == null ? void 0 : _b2.path) || "not specified"}`,
6590
- ` \u2022 Plugins: ${((_c2 = userConfig.plugins) == null ? void 0 : _c2.length) || 0}`,
6500
+ ` \u2022 Output: ${((_e2 = userConfig.output) == null ? void 0 : _e2.path) || "not specified"}`,
6501
+ ` \u2022 Plugins: ${((_f = userConfig.plugins) == null ? void 0 : _f.length) || 0}`,
6591
6502
  "Output Settings:",
6592
- ` \u2022 Storage: ${userConfig.storage ? `custom(${userConfig.storage.name})` : ((_d2 = userConfig.output) == null ? void 0 : _d2.write) === false ? "disabled" : "filesystem (default)"}`,
6593
- ` \u2022 Formatter: ${((_e2 = userConfig.output) == null ? void 0 : _e2.format) || "none"}`,
6594
- ` \u2022 Linter: ${((_f = userConfig.output) == null ? void 0 : _f.lint) || "none"}`,
6503
+ ` \u2022 Storage: ${config.storage.name}`,
6504
+ ` \u2022 Formatter: ${((_g = userConfig.output) == null ? void 0 : _g.format) || "none"}`,
6505
+ ` \u2022 Linter: ${((_h = userConfig.output) == null ? void 0 : _h.lint) || "none"}`,
6595
6506
  "Environment:",
6596
6507
  Object.entries(diagnosticInfo).map(([key, value]) => ` \u2022 ${key}: ${value}`).join("\n")
6597
6508
  ]
@@ -6610,73 +6521,50 @@ async function setup(userConfig, options = {}) {
6610
6521
  throw new Error(`Cannot read file/URL defined in \`input.path\` or set with \`kubb generate PATH\` in the CLI of your Kubb config ${userConfig.input.path}`, { cause: error });
6611
6522
  }
6612
6523
  }
6613
- if (!userConfig.adapter) throw new Error("Adapter should be defined");
6614
- const config = {
6615
- ...userConfig,
6616
- root: userConfig.root || process.cwd(),
6617
- parsers: (_g = userConfig.parsers) != null ? _g : [],
6618
- adapter: userConfig.adapter,
6619
- output: {
6620
- format: false,
6621
- lint: false,
6622
- write: true,
6623
- extension: DEFAULT_EXTENSION,
6624
- defaultBanner: DEFAULT_BANNER,
6625
- ...userConfig.output
6626
- },
6627
- devtools: userConfig.devtools ? {
6628
- studioUrl: DEFAULT_STUDIO_URL,
6629
- ...typeof userConfig.devtools === "boolean" ? {} : userConfig.devtools
6630
- } : void 0,
6631
- plugins: userConfig.plugins
6632
- };
6633
- const storage = config.output.write === false ? null : (_h = config.storage) != null ? _h : fsStorage();
6634
6524
  if (config.output.clean) {
6635
6525
  await hooks.emit("kubb:debug", {
6636
6526
  date: /* @__PURE__ */ new Date(),
6637
6527
  logs: ["Cleaning output directories", ` \u2022 Output: ${config.output.path}`]
6638
6528
  });
6639
- await (storage == null ? void 0 : storage.clear(resolve(config.root, config.output.path)));
6529
+ await config.storage.clear(resolve(config.root, config.output.path));
6640
6530
  }
6641
- const driver = new PluginDriver(config, { hooks });
6642
6531
  function registerMiddlewareHook(event, middlewareHooks) {
6643
6532
  const handler = middlewareHooks[event];
6644
6533
  if (handler) hooks.on(event, handler);
6645
6534
  }
6646
6535
  for (const middleware of (_i = config.middleware) != null ? _i : []) for (const event of Object.keys(middleware.hooks)) registerMiddlewareHook(event, middleware.hooks);
6647
- const adapter = config.adapter;
6648
- if (!adapter) throw new Error("No adapter configured. Please provide an adapter in your kubb.config.ts.");
6649
- const source = inputToAdapterSource(config);
6650
- await hooks.emit("kubb:debug", {
6651
- date: /* @__PURE__ */ new Date(),
6652
- logs: [`Running adapter: ${adapter.name}`]
6653
- });
6654
- driver.adapter = adapter;
6655
- driver.inputNode = await adapter.parse(source);
6656
- await hooks.emit("kubb:debug", {
6657
- date: /* @__PURE__ */ new Date(),
6658
- logs: [
6659
- `\u2713 Adapter '${adapter.name}' resolved InputNode`,
6660
- ` \u2022 Schemas: ${driver.inputNode.schemas.length}`,
6661
- ` \u2022 Operations: ${driver.inputNode.operations.length}`
6662
- ]
6663
- });
6536
+ if (config.adapter) {
6537
+ const source = inputToAdapterSource(config);
6538
+ await hooks.emit("kubb:debug", {
6539
+ date: /* @__PURE__ */ new Date(),
6540
+ logs: [`Running adapter: ${config.adapter.name}`]
6541
+ });
6542
+ driver.adapter = config.adapter;
6543
+ driver.inputNode = await config.adapter.parse(source);
6544
+ await hooks.emit("kubb:debug", {
6545
+ date: /* @__PURE__ */ new Date(),
6546
+ logs: [
6547
+ `\u2713 Adapter '${config.adapter.name}' resolved InputNode`,
6548
+ ` \u2022 Schemas: ${driver.inputNode.schemas.length}`,
6549
+ ` \u2022 Operations: ${driver.inputNode.operations.length}`
6550
+ ]
6551
+ });
6552
+ }
6664
6553
  return {
6665
6554
  config,
6666
6555
  hooks,
6667
6556
  driver,
6668
- sources,
6669
- storage
6557
+ sources
6670
6558
  };
6671
6559
  }
6672
6560
  async function runPluginAstHooks(plugin, context) {
6673
- var _a2;
6561
+ var _a2, _b2, _c2;
6674
6562
  const { adapter, inputNode, resolver, driver } = context;
6675
6563
  const { exclude, include, override } = plugin.options;
6676
- if (!adapter || !inputNode) throw new Error(`[${plugin.name}] No adapter found. Add an OAS adapter (e.g. pluginOas()) before this plugin in your Kubb config.`);
6564
+ if (!adapter || !inputNode) throw new Error(`[${plugin.name}] No adapter found. Add an OAS adapter (e.g. adapterOas()) before this plugin in your Kubb config.`);
6677
6565
  function resolveRenderer(gen) {
6678
- var _a3, _b2;
6679
- return gen.renderer === null ? void 0 : (_b2 = (_a3 = gen.renderer) != null ? _a3 : plugin.renderer) != null ? _b2 : context.config.renderer;
6566
+ var _a3, _b3;
6567
+ return gen.renderer === null ? void 0 : (_b3 = (_a3 = gen.renderer) != null ? _a3 : plugin.renderer) != null ? _b3 : context.config.renderer;
6680
6568
  }
6681
6569
  const generators = (_a2 = plugin.generators) != null ? _a2 : [];
6682
6570
  const collectedOperations = [];
@@ -6684,10 +6572,27 @@ async function runPluginAstHooks(plugin, context) {
6684
6572
  ...context,
6685
6573
  resolver: driver.getResolver(plugin.name)
6686
6574
  };
6575
+ const operationFilterTypes = /* @__PURE__ */ new Set([
6576
+ "tag",
6577
+ "operationId",
6578
+ "path",
6579
+ "method",
6580
+ "contentType"
6581
+ ]);
6582
+ const hasOperationBasedIncludes = (_b2 = include == null ? void 0 : include.some(({ type }) => operationFilterTypes.has(type))) != null ? _b2 : false;
6583
+ const hasSchemaNameIncludes = (_c2 = include == null ? void 0 : include.some(({ type }) => type === "schemaName")) != null ? _c2 : false;
6584
+ let allowedSchemaNames;
6585
+ if (hasOperationBasedIncludes && !hasSchemaNameIncludes) allowedSchemaNames = collectUsedSchemaNames(inputNode.operations.filter((op) => resolver.resolveOptions(op, {
6586
+ options: plugin.options,
6587
+ exclude,
6588
+ include,
6589
+ override
6590
+ }) !== null), inputNode.schemas);
6687
6591
  await walk(inputNode, {
6688
6592
  depth: "shallow",
6689
6593
  async schema(node) {
6690
6594
  const transformedNode = plugin.transformer ? transform(node, plugin.transformer) : node;
6595
+ if (allowedSchemaNames !== void 0 && transformedNode.name && !allowedSchemaNames.has(transformedNode.name)) return;
6691
6596
  const options = resolver.resolveOptions(transformedNode, {
6692
6597
  options: plugin.options,
6693
6598
  exclude,
@@ -6741,7 +6646,7 @@ async function runPluginAstHooks(plugin, context) {
6741
6646
  }
6742
6647
  async function safeBuild(setupResult) {
6743
6648
  var _a2;
6744
- const { driver, hooks, sources, storage } = setupResult;
6649
+ const { driver, hooks, sources } = setupResult;
6745
6650
  const failedPlugins = /* @__PURE__ */ new Set();
6746
6651
  const pluginTimings = /* @__PURE__ */ new Map();
6747
6652
  const config = driver.config;
@@ -6832,6 +6737,7 @@ async function safeBuild(setupResult) {
6832
6737
  });
6833
6738
  await fileProcessor.run(files, {
6834
6739
  parsers: parsersMap,
6740
+ mode: "parallel",
6835
6741
  extension: config.output.extension,
6836
6742
  onStart: async (processingFiles) => {
6837
6743
  await hooks.emit("kubb:files:processing:start", { files: processingFiles });
@@ -6846,7 +6752,7 @@ async function safeBuild(setupResult) {
6846
6752
  config
6847
6753
  });
6848
6754
  if (source) {
6849
- await (storage == null ? void 0 : storage.setItem(file.path, source));
6755
+ await config.storage.setItem(file.path, source);
6850
6756
  sources.set(file.path, source);
6851
6757
  }
6852
6758
  },
@@ -6899,22 +6805,32 @@ async function build(setupResult) {
6899
6805
  sources
6900
6806
  };
6901
6807
  }
6902
- function inputToAdapterSource(config) {
6903
- if (Array.isArray(config.input)) return {
6904
- type: "paths",
6905
- paths: config.input.map((i) => new URLPath(i.path).isURL ? i.path : resolve(config.root, i.path))
6808
+ function getDiagnosticInfo() {
6809
+ return {
6810
+ nodeVersion: version$2,
6811
+ KubbVersion: version$1,
6812
+ platform: process.platform,
6813
+ arch: process.arch,
6814
+ cwd: process.cwd()
6906
6815
  };
6907
- if ("data" in config.input) return {
6816
+ }
6817
+ function isInputPath(config) {
6818
+ return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
6819
+ }
6820
+ function inputToAdapterSource(config) {
6821
+ const input = config.input;
6822
+ if (!input) throw new Error("[kubb] input is required when using an adapter. Provide input.path or input.data in your config.");
6823
+ if ("data" in input) return {
6908
6824
  type: "data",
6909
- data: config.input.data
6825
+ data: input.data
6910
6826
  };
6911
- if (new URLPath(config.input.path).isURL) return {
6827
+ if (new URLPath(input.path).isURL) return {
6912
6828
  type: "path",
6913
- path: config.input.path
6829
+ path: input.path
6914
6830
  };
6915
6831
  return {
6916
6832
  type: "path",
6917
- path: resolve(config.root, config.input.path)
6833
+ path: resolve(config.root, input.path)
6918
6834
  };
6919
6835
  }
6920
6836
  function createKubb(userConfig, options = {}) {
@@ -6980,7 +6896,7 @@ const memoryStorage = createStorage(() => {
6980
6896
  };
6981
6897
  });
6982
6898
 
6983
- var version = "5.0.0-beta.75";
6899
+ var version = "5.0.0-beta.9";
6984
6900
 
6985
6901
  function isCommandMessage(msg) {
6986
6902
  return msg.type === "command";
@@ -7127,20 +7043,15 @@ async function generate({ config, hooks }) {
7127
7043
  }
7128
7044
  }
7129
7045
 
7130
- const unrunInputOptions = {
7131
- transform: {
7132
- jsx: {
7133
- runtime: "automatic",
7134
- importSource: "@kubb/renderer-jsx"
7135
- }
7136
- }
7137
- };
7046
+ const jiti = createJiti(globalThis._importMeta_.url, {
7047
+ jsx: {
7048
+ runtime: "automatic",
7049
+ importSource: "@kubb/renderer-jsx"
7050
+ },
7051
+ moduleCache: false
7052
+ });
7138
7053
  const tsLoader = async (configFile) => {
7139
- const { module } = await unrun({
7140
- path: configFile,
7141
- inputOptions: unrunInputOptions
7142
- });
7143
- return module;
7054
+ return jiti.import(configFile, { default: true });
7144
7055
  };
7145
7056
  async function getCosmiConfig(configPath) {
7146
7057
  var _a;
@@ -7201,6 +7112,21 @@ async function resolvePlugins(plugins) {
7201
7112
  })
7202
7113
  );
7203
7114
  }
7115
+ async function resolveMiddlewares(middlewares) {
7116
+ return Promise.all(
7117
+ middlewares.map(async ({ name, options }) => {
7118
+ const factory = await loadPluginFactory(name);
7119
+ return factory(options != null ? options : {});
7120
+ })
7121
+ );
7122
+ }
7123
+ async function checkPeerDependencies() {
7124
+ try {
7125
+ await import('@kubb/renderer-jsx');
7126
+ } catch {
7127
+ logger.warn("Missing peer dependency @kubb/renderer-jsx. Install it alongside kubb plugins.");
7128
+ }
7129
+ }
7204
7130
 
7205
7131
  async function mergePlugins(diskPlugins, studioPlugins) {
7206
7132
  if (!diskPlugins && !studioPlugins) return void 0;
@@ -7302,7 +7228,7 @@ function setupHookListener(hooks, root) {
7302
7228
  }
7303
7229
 
7304
7230
  const agentDefaults = {
7305
- studioUrl: "https://studio.kubb.dev",
7231
+ studioUrl: "https://kubb.studio",
7306
7232
  configPath: "kubb.config.ts",
7307
7233
  retryIntervalMs: 3e4,
7308
7234
  heartbeatIntervalMs: 3e4,
@@ -7347,14 +7273,14 @@ function setupEventsStream(ws, hooks, getSource) {
7347
7273
  hooks.on("kubb:plugin:start", (ctx) => {
7348
7274
  sendDataMessage({
7349
7275
  type: "kubb:plugin:start",
7350
- data: [ctx.plugin],
7276
+ data: [{ plugin: ctx.plugin }],
7351
7277
  timestamp: Date.now()
7352
7278
  });
7353
7279
  });
7354
7280
  hooks.on("kubb:plugin:end", (ctx) => {
7355
7281
  sendDataMessage({
7356
7282
  type: "kubb:plugin:end",
7357
- data: [ctx.plugin, { duration: ctx.duration, success: ctx.success }],
7283
+ data: [{ plugin: ctx.plugin, duration: ctx.duration, success: ctx.success }],
7358
7284
  timestamp: Date.now()
7359
7285
  });
7360
7286
  });
@@ -7389,21 +7315,21 @@ function setupEventsStream(ws, hooks, getSource) {
7389
7315
  hooks.on("kubb:info", ({ message, info }) => {
7390
7316
  sendDataMessage({
7391
7317
  type: "kubb:info",
7392
- data: [message, info],
7318
+ data: [{ message, info }],
7393
7319
  timestamp: Date.now()
7394
7320
  });
7395
7321
  });
7396
7322
  hooks.on("kubb:success", ({ message, info }) => {
7397
7323
  sendDataMessage({
7398
7324
  type: "kubb:success",
7399
- data: [message, info],
7325
+ data: [{ message, info }],
7400
7326
  timestamp: Date.now()
7401
7327
  });
7402
7328
  });
7403
7329
  hooks.on("kubb:warn", ({ message, info }) => {
7404
7330
  sendDataMessage({
7405
7331
  type: "kubb:warn",
7406
- data: [message, info],
7332
+ data: [{ message, info }],
7407
7333
  timestamp: Date.now()
7408
7334
  });
7409
7335
  });
@@ -7426,7 +7352,7 @@ function setupEventsStream(ws, hooks, getSource) {
7426
7352
  });
7427
7353
  sendDataMessage({
7428
7354
  type: "kubb:generation:end",
7429
- data: [config, files, sourcesRecord],
7355
+ data: [{ config, files, sources: sourcesRecord }],
7430
7356
  timestamp: Date.now()
7431
7357
  });
7432
7358
  });
@@ -7549,6 +7475,7 @@ async function connectToStudio(options) {
7549
7475
  const storedConfig = data.payload ? null : await getLatestStudioConfigFromStorage({ sessionId }).catch(() => null);
7550
7476
  const patch = (_b = (_a2 = data.payload) != null ? _a2 : storedConfig) != null ? _b : void 0;
7551
7477
  const plugins = await mergePlugins(config.plugins, patch == null ? void 0 : patch.plugins);
7478
+ const middleware = (patch == null ? void 0 : patch.middleware) ? await resolveMiddlewares(patch.middleware) : config.middleware;
7552
7479
  const inputOverride = isSandbox ? { data: (_c = patch == null ? void 0 : patch.input) != null ? _c : "" } : void 0;
7553
7480
  if (allowWrite && isSandbox) {
7554
7481
  logger.warn(`[${maskedSessionId}] Agent is running in a sandbox environment, write will be disabled`);
@@ -7564,6 +7491,9 @@ async function connectToStudio(options) {
7564
7491
  logger.warn(`[${maskedSessionId}] Failed to save studio config: ${err == null ? void 0 : err.message}`);
7565
7492
  });
7566
7493
  }
7494
+ const generationHooks = new AsyncEventEmitter();
7495
+ setupHookListener(generationHooks, root);
7496
+ setupEventsStream(ws, generationHooks, () => currentSource);
7567
7497
  await generate({
7568
7498
  config: {
7569
7499
  ...config,
@@ -7573,9 +7503,13 @@ async function connectToStudio(options) {
7573
7503
  output: {
7574
7504
  ...config.output
7575
7505
  },
7576
- plugins
7506
+ plugins,
7507
+ middleware,
7508
+ // Studio may send an opaque adapter options blob; forward it unchanged to createKubb.
7509
+ // The adapter factory is responsible for validating and merging its own options.
7510
+ ...(patch == null ? void 0 : patch.adapter) != null && { adapter: patch.adapter }
7577
7511
  },
7578
- hooks
7512
+ hooks: generationHooks
7579
7513
  });
7580
7514
  logger.success(`[${maskedSessionId}] Completed "${data.type}" from Studio`);
7581
7515
  currentSource = void 0;
@@ -7677,6 +7611,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
7677
7611
  }
7678
7612
  const maskedToken = maskString(token);
7679
7613
  try {
7614
+ await checkPeerDependencies();
7680
7615
  await registerAgent({ token, studioUrl, poolSize });
7681
7616
  const baseOptions = {
7682
7617
  token,