@kubb/plugin-swr 5.0.0-beta.42 → 5.0.0-beta.64

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 (40) hide show
  1. package/dist/{components-CD7ZoS3B.cjs → components-DxWGjLWg.cjs} +231 -313
  2. package/dist/components-DxWGjLWg.cjs.map +1 -0
  3. package/dist/{components-BuLagnaM.js → components-mWBRE6E4.js} +232 -314
  4. package/dist/components-mWBRE6E4.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.ts +1 -1
  7. package/dist/components.js +1 -1
  8. package/dist/{generators-D_Cz5DDw.cjs → generators-CJ4ziuNk.cjs} +66 -90
  9. package/dist/generators-CJ4ziuNk.cjs.map +1 -0
  10. package/dist/{generators-CSinCSzM.js → generators-D2blgLOY.js} +67 -91
  11. package/dist/generators-D2blgLOY.js.map +1 -0
  12. package/dist/generators.cjs +1 -1
  13. package/dist/generators.d.ts +6 -1
  14. package/dist/generators.js +1 -1
  15. package/dist/index.cjs +68 -18
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +69 -19
  19. package/dist/index.js.map +1 -1
  20. package/dist/{types-BoANASs2.d.ts → types-DcBaH0gA.d.ts} +13 -16
  21. package/package.json +10 -18
  22. package/dist/components-BuLagnaM.js.map +0 -1
  23. package/dist/components-CD7ZoS3B.cjs.map +0 -1
  24. package/dist/generators-CSinCSzM.js.map +0 -1
  25. package/dist/generators-D_Cz5DDw.cjs.map +0 -1
  26. package/extension.yaml +0 -199
  27. package/src/components/Mutation.tsx +0 -155
  28. package/src/components/MutationKey.tsx +0 -25
  29. package/src/components/Query.tsx +0 -128
  30. package/src/components/QueryKey.tsx +0 -1
  31. package/src/components/QueryOptions.tsx +0 -74
  32. package/src/components/index.ts +0 -5
  33. package/src/generators/index.ts +0 -2
  34. package/src/generators/mutationGenerator.tsx +0 -162
  35. package/src/generators/queryGenerator.tsx +0 -174
  36. package/src/index.ts +0 -2
  37. package/src/plugin.ts +0 -154
  38. package/src/resolvers/resolverSwr.ts +0 -56
  39. package/src/types.ts +0 -197
  40. package/src/utils.ts +0 -10
@@ -1,5 +1,6 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
2
  import { ast } from "@kubb/core";
3
+ import { buildGroupParam, caseParams, createOperationParams, resolveGroupType, resolveParamType } from "@kubb/ast/utils";
3
4
  import { functionPrinter } from "@kubb/plugin-ts";
4
5
  import { File, Function, Type } from "@kubb/renderer-jsx";
5
6
  import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
@@ -14,35 +15,19 @@ import { Fragment, jsx, jsxs } from "@kubb/renderer-jsx/jsx-runtime";
14
15
  function toCamelOrPascal(text, pascal) {
15
16
  return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
16
17
  if (word.length > 1 && word === word.toUpperCase()) return word;
17
- if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
18
- return word.charAt(0).toUpperCase() + word.slice(1);
18
+ return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
19
19
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
20
20
  }
21
21
  /**
22
- * Splits `text` on `.` and applies `transformPart` to each segment.
23
- * The last segment receives `isLast = true`, all earlier segments receive `false`.
24
- * Segments are joined with `/` to form a file path.
25
- *
26
- * Only splits on dots followed by a letter so that version numbers
27
- * embedded in operationIds (e.g. `v2025.0`) are kept intact.
28
- */
29
- function applyToFileParts(text, transformPart) {
30
- const parts = text.split(/\.(?=[a-zA-Z])/);
31
- return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
32
- }
33
- /**
34
22
  * Converts `text` to camelCase.
35
- * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
36
23
  *
37
- * @example
38
- * camelCase('hello-world') // 'helloWorld'
39
- * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
24
+ * @example Word boundaries
25
+ * `camelCase('hello-world') // 'helloWorld'`
26
+ *
27
+ * @example With a prefix
28
+ * `camelCase('tag', { prefix: 'create' }) // 'createTag'`
40
29
  */
41
- function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
42
- if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
43
- prefix,
44
- suffix
45
- } : {}));
30
+ function camelCase(text, { prefix = "", suffix = "" } = {}) {
46
31
  return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
47
32
  }
48
33
  //#endregion
@@ -149,99 +134,80 @@ function isValidVarName(name) {
149
134
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
150
135
  }
151
136
  //#endregion
152
- //#region ../../internals/utils/src/urlPath.ts
137
+ //#region ../../internals/utils/src/url.ts
138
+ function transformParam(raw, casing) {
139
+ const param = isValidVarName(raw) ? raw : camelCase(raw);
140
+ return casing === "camelcase" ? camelCase(param) : param;
141
+ }
142
+ function toParamsObject(path, { replacer, casing } = {}) {
143
+ const params = {};
144
+ for (const match of path.matchAll(/\{([^}]+)\}/g)) {
145
+ const param = transformParam(match[1], casing);
146
+ const key = replacer ? replacer(param) : param;
147
+ params[key] = key;
148
+ }
149
+ return Object.keys(params).length > 0 ? params : null;
150
+ }
153
151
  /**
154
- * Parses and transforms an OpenAPI/Swagger path string into various URL formats.
155
- *
156
- * @example
157
- * const p = new URLPath('/pet/{petId}')
158
- * p.URL // '/pet/:petId'
159
- * p.template // '`/pet/${petId}`'
152
+ * Helpers for OpenAPI/Swagger paths, plus a thin wrapper over the native `URL`.
160
153
  */
161
- var URLPath = class {
154
+ var Url = class Url {
162
155
  /**
163
- * The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`.
164
- */
165
- path;
166
- #options;
167
- constructor(path, options = {}) {
168
- this.path = path;
169
- this.#options = options;
170
- }
171
- /** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`.
156
+ * Reports whether `url` is a parseable absolute URL. Delegates to the native `URL.canParse`.
172
157
  *
173
158
  * @example
174
- * ```ts
175
- * new URLPath('/pet/{petId}').URL // '/pet/:petId'
176
- * ```
159
+ * Url.canParse('https://petstore.swagger.io/v2') // true
160
+ * Url.canParse('/pet/{petId}') // false
177
161
  */
178
- get URL() {
179
- return this.toURLPath();
162
+ static canParse(url, base) {
163
+ return URL.canParse(url, base);
180
164
  }
181
- /** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`).
165
+ /**
166
+ * Converts an OpenAPI/Swagger path to Express-style colon syntax.
182
167
  *
183
168
  * @example
184
- * ```ts
185
- * new URLPath('https://petstore.swagger.io/v2/pet').isURL // true
186
- * new URLPath('/pet/{petId}').isURL // false
187
- * ```
169
+ * Url.toPath('/pet/{petId}') // '/pet/:petId'
188
170
  */
189
- get isURL() {
190
- try {
191
- return !!new URL(this.path).href;
192
- } catch {
193
- return false;
194
- }
171
+ static toPath(path) {
172
+ return path.replace(/\{([^}]+)\}/g, ":$1");
195
173
  }
196
174
  /**
197
- * Converts the OpenAPI path to a TypeScript template literal string.
175
+ * Converts an OpenAPI/Swagger path to a TypeScript template literal string.
176
+ * `prefix` is prepended inside the literal, `replacer` transforms each parameter name,
177
+ * and `casing` controls parameter identifier casing.
198
178
  *
199
179
  * @example
200
- * new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
201
- * new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
202
- */
203
- get template() {
204
- return this.toTemplateString();
205
- }
206
- /** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set.
180
+ * Url.toTemplateString('/pet/{petId}') // '`/pet/${petId}`'
207
181
  *
208
182
  * @example
209
- * ```ts
210
- * new URLPath('/pet/{petId}').object
211
- * // { url: '/pet/:petId', params: { petId: 'petId' } }
212
- * ```
183
+ * Url.toTemplateString('/pet/{petId}', { prefix: 'https://api' }) // '`https://api/pet/${petId}`'
213
184
  */
214
- get object() {
215
- return this.toObject();
185
+ static toTemplateString(path, { prefix, replacer, casing } = {}) {
186
+ const result = path.split(/\{([^}]+)\}/).map((part, i) => {
187
+ if (i % 2 === 0) return part;
188
+ const param = transformParam(part, casing);
189
+ return `\${${replacer ? replacer(param) : param}}`;
190
+ }).join("");
191
+ return `\`${prefix ?? ""}${result}\``;
216
192
  }
217
- /** Returns a map of path parameter names, or `null` when the path has no parameters.
193
+ /**
194
+ * Returns the path and its extracted params as a structured `URLObject`, or as a stringified
195
+ * expression when `stringify` is set.
218
196
  *
219
197
  * @example
220
- * ```ts
221
- * new URLPath('/pet/{petId}').params // { petId: 'petId' }
222
- * new URLPath('/pet').params // null
223
- * ```
224
- */
225
- get params() {
226
- return this.toParamsObject();
227
- }
228
- #transformParam(raw) {
229
- const param = isValidVarName(raw) ? raw : camelCase(raw);
230
- return this.#options.casing === "camelcase" ? camelCase(param) : param;
231
- }
232
- /**
233
- * Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name.
198
+ * Url.toObject('/pet/{petId}')
199
+ * // { url: '/pet/:petId', params: { petId: 'petId' } }
234
200
  */
235
- #eachParam(fn) {
236
- for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
237
- const raw = match[1];
238
- fn(raw, this.#transformParam(raw));
239
- }
240
- }
241
- toObject({ type = "path", replacer, stringify } = {}) {
201
+ static toObject(path, { type = "path", replacer, stringify, casing } = {}) {
242
202
  const object = {
243
- url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
244
- params: this.toParamsObject()
203
+ url: type === "path" ? Url.toPath(path) : Url.toTemplateString(path, {
204
+ replacer,
205
+ casing
206
+ }),
207
+ params: toParamsObject(path, {
208
+ replacer,
209
+ casing
210
+ })
245
211
  };
246
212
  if (stringify) {
247
213
  if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
@@ -250,85 +216,13 @@ var URLPath = class {
250
216
  }
251
217
  return object;
252
218
  }
253
- /**
254
- * Converts the OpenAPI path to a TypeScript template literal string.
255
- * An optional `replacer` can transform each extracted parameter name before interpolation.
256
- *
257
- * @example
258
- * new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
259
- */
260
- toTemplateString({ prefix, replacer } = {}) {
261
- const result = this.path.split(/\{([^}]+)\}/).map((part, i) => {
262
- if (i % 2 === 0) return part;
263
- const param = this.#transformParam(part);
264
- return `\${${replacer ? replacer(param) : param}}`;
265
- }).join("");
266
- return `\`${prefix ?? ""}${result}\``;
267
- }
268
- /**
269
- * Extracts all `{param}` segments from the path and returns them as a key-value map.
270
- * An optional `replacer` transforms each parameter name in both key and value positions.
271
- * Returns `undefined` when no path parameters are found.
272
- *
273
- * @example
274
- * ```ts
275
- * new URLPath('/pet/{petId}/tag/{tagId}').toParamsObject()
276
- * // { petId: 'petId', tagId: 'tagId' }
277
- * ```
278
- */
279
- toParamsObject(replacer) {
280
- const params = {};
281
- this.#eachParam((_raw, param) => {
282
- const key = replacer ? replacer(param) : param;
283
- params[key] = key;
284
- });
285
- return Object.keys(params).length > 0 ? params : null;
286
- }
287
- /** Converts the OpenAPI path to Express-style colon syntax.
288
- *
289
- * @example
290
- * ```ts
291
- * new URLPath('/pet/{petId}').toURLPath() // '/pet/:petId'
292
- * ```
293
- */
294
- toURLPath() {
295
- return this.path.replace(/\{([^}]+)\}/g, ":$1");
296
- }
297
219
  };
298
220
  //#endregion
299
- //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
300
- const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
301
- const mutationKeyTransformer = ({ node, casing }) => {
302
- if (!node.path) return [];
303
- return [`{ url: '${new URLPath(node.path, { casing }).toURLPath()}' }`];
304
- };
305
- function MutationKey$1({ name, paramsCasing, node, transformer }) {
306
- const paramsNode = ast.createFunctionParameters({ params: [] });
307
- const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
308
- const keys = (transformer ?? mutationKeyTransformer)({
309
- node,
310
- casing: paramsCasing
311
- });
312
- return /* @__PURE__ */ jsx(File.Source, {
313
- name,
314
- isExportable: true,
315
- isIndexable: true,
316
- children: /* @__PURE__ */ jsx(Function.Arrow, {
317
- name,
318
- export: true,
319
- params: paramsSignature,
320
- singleLine: true,
321
- children: `[${keys.join(", ")}] as const`
322
- })
323
- });
324
- }
325
- __name(MutationKey$1, "MutationKey");
326
- //#endregion
327
221
  //#region ../../internals/shared/src/operation.ts
328
222
  function getOperationLink(node, link) {
329
223
  if (!link) return null;
330
224
  if (typeof link === "function") return link(node) ?? null;
331
- if (link === "urlPath") return node.path ? `{@link ${new URLPath(node.path).URL}}` : null;
225
+ if (link === "urlPath") return node.path ? `{@link ${Url.toPath(node.path)}}` : null;
332
226
  return node.path ? `{@link ${node.path.replaceAll("{", ":").replaceAll("}", "")}}` : null;
333
227
  }
334
228
  function getContentTypeInfo(node) {
@@ -365,7 +259,7 @@ function buildOperationComments(node, options = {}) {
365
259
  return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
366
260
  }
367
261
  function getOperationParameters(node, options = {}) {
368
- const params = ast.caseParams(node.parameters, options.paramsCasing);
262
+ const params = caseParams(node.parameters, options.paramsCasing);
369
263
  return {
370
264
  path: params.filter((param) => param.in === "path"),
371
265
  query: params.filter((param) => param.in === "query"),
@@ -387,6 +281,19 @@ function resolveErrorNames(node, resolver) {
387
281
  function resolveStatusCodeNames(node, resolver) {
388
282
  return node.responses.map((response) => resolver.resolveResponseStatusName(node, response.statusCode));
389
283
  }
284
+ /**
285
+ * Builds the discriminated union type string for `dataReturnType: 'full'` return shapes.
286
+ * Each member is `{ status: N; data: StatusNType; statusText: string }`.
287
+ */
288
+ function buildStatusUnionType(node, resolver) {
289
+ const members = node.responses.map((r) => {
290
+ const typeName = resolver.resolveResponseStatusName(node, r.statusCode);
291
+ const statusCode = Number.parseInt(r.statusCode, 10);
292
+ return `{ status: ${Number.isNaN(statusCode) ? "number" : String(statusCode)}; data: ${typeName}; statusText: string }`;
293
+ });
294
+ if (members.length === 1) return members[0];
295
+ return `(${members.join(" | ")})`;
296
+ }
390
297
  const typeNamesByResolver = /* @__PURE__ */ new WeakMap();
391
298
  function resolveOperationTypeNames(node, resolver, options = {}) {
392
299
  const cacheKey = `${node.operationId}\0${options.paramsCasing ?? ""}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${(options.exclude ?? []).join(",")}`;
@@ -420,118 +327,156 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
420
327
  return result;
421
328
  }
422
329
  //#endregion
330
+ //#region ../../internals/tanstack-query/src/components/MutationKey.tsx
331
+ const declarationPrinter$4 = functionPrinter({ mode: "declaration" });
332
+ const mutationKeyTransformer = ({ node }) => {
333
+ if (!node.path) return [];
334
+ return [`{ url: '${Url.toPath(node.path)}' }`];
335
+ };
336
+ function MutationKey$1({ name, paramsCasing, node, transformer }) {
337
+ const paramsNode = ast.factory.createFunctionParameters({ params: [] });
338
+ const paramsSignature = declarationPrinter$4.print(paramsNode) ?? "";
339
+ const keys = (transformer ?? mutationKeyTransformer)({
340
+ node,
341
+ casing: paramsCasing
342
+ });
343
+ return /* @__PURE__ */ jsx(File.Source, {
344
+ name,
345
+ isExportable: true,
346
+ isIndexable: true,
347
+ children: /* @__PURE__ */ jsx(Function.Arrow, {
348
+ name,
349
+ export: true,
350
+ params: paramsSignature,
351
+ singleLine: true,
352
+ children: `[${keys.join(", ")}] as const`
353
+ })
354
+ });
355
+ }
356
+ __name(MutationKey$1, "MutationKey");
357
+ //#endregion
423
358
  //#region ../../internals/tanstack-query/src/utils.ts
424
359
  /**
425
- * Collects the Zod schema import names for an operation (response + request body).
426
- *
427
- * Returns an empty array when no resolver is provided or the operation has no request body schema.
360
+ * Returns the `TypeLiteral` members of a destructured group parameter, or `null`
361
+ * for a plain named parameter.
428
362
  */
429
- function resolveZodSchemaNames(node, zodResolver) {
430
- if (!zodResolver) return [];
431
- return [zodResolver.resolveResponseName?.(node), node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null].filter((n) => Boolean(n));
363
+ function groupMembers(param) {
364
+ if (typeof param.name === "string") return null;
365
+ return param.type && typeof param.type !== "string" && param.type.kind === "TypeLiteral" ? param.type.members : [];
432
366
  }
433
367
  /**
434
- * Resolve the type for a single path parameter.
435
- *
436
- * - When the resolver's group name differs from the individual param name
437
- * (e.g. kubbV4) → `GroupName['paramName']` (member access).
438
- * - When they match (v5 default) → `TypeName` (direct reference).
368
+ * Builds the shared `(…params, config = {})` parameter list for a TanStack
369
+ * query-options function. The trailing `config` parameter is typed as a partial
370
+ * `RequestConfig` with an optional `client`. Framework plugins wrap the result
371
+ * when needed, for example vue-query applies `MaybeRefOrGetter`.
439
372
  */
440
- function resolvePathParamType(node, param, resolver) {
441
- const individualName = resolver.resolveParamName(node, param);
442
- const groupName = resolver.resolvePathParamsName(node, param);
443
- if (groupName !== individualName) return ast.createParamsType({
444
- variant: "member",
445
- base: groupName,
446
- key: param.name
447
- });
448
- return ast.createParamsType({
449
- variant: "reference",
450
- name: individualName
373
+ function buildQueryOptionsParams(node, options) {
374
+ const { paramsType, paramsCasing, pathParamsType, resolver } = options;
375
+ const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
376
+ return createOperationParams(node, {
377
+ paramsType,
378
+ pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
379
+ paramsCasing,
380
+ resolver,
381
+ extraParams: [ast.factory.createFunctionParameter({
382
+ name: "config",
383
+ type: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
384
+ default: "{}"
385
+ })]
451
386
  });
452
387
  }
453
388
  /**
454
- * Derive a query-params group type from the resolver.
455
- * Returns `null` when no query params exist or when the group name
456
- * equals the individual param name (no real group).
389
+ * Returns `'zod'` when response-direction parsing is enabled.
390
+ * The string shorthand `'zod'` also enables response parsing.
457
391
  */
458
- function resolveQueryGroupType(node, params, resolver) {
459
- if (!params.length) return null;
460
- const firstParam = params[0];
461
- const groupName = resolver.resolveQueryParamsName(node, firstParam);
462
- if (groupName === resolver.resolveParamName(node, firstParam)) return null;
463
- return {
464
- type: ast.createParamsType({
465
- variant: "reference",
466
- name: groupName
467
- }),
468
- optional: params.every((p) => !p.required)
469
- };
392
+ function resolveResponseParser(parser) {
393
+ if (!parser) return null;
394
+ if (parser === "zod") return "zod";
395
+ return parser.response ?? null;
470
396
  }
471
397
  /**
472
- * Build a single `FunctionParameterNode` for a query or header group.
398
+ * Returns `'zod'` when request body parsing is enabled.
399
+ * The string shorthand `'zod'` also enables request body parsing (existing behavior).
473
400
  */
474
- function buildGroupParam(name, node, params, groupType, resolver) {
475
- if (groupType) return [ast.createFunctionParameter({
476
- name,
477
- type: groupType.type,
478
- optional: groupType.optional
479
- })];
480
- if (params.length) {
481
- const structProps = params.map((p) => ({
482
- name: p.name,
483
- type: ast.createParamsType({
484
- variant: "reference",
485
- name: resolver.resolveParamName(node, p)
486
- }),
487
- optional: !p.required
488
- }));
489
- return [ast.createFunctionParameter({
490
- name,
491
- type: ast.createParamsType({
492
- variant: "struct",
493
- properties: structProps
494
- }),
495
- optional: params.every((p) => !p.required)
496
- })];
497
- }
498
- return [];
401
+ function resolveRequestParser(parser) {
402
+ if (!parser) return null;
403
+ if (parser === "zod") return "zod";
404
+ return parser.request ?? null;
405
+ }
406
+ /**
407
+ * Returns `'zod'` when query-params parsing is enabled.
408
+ * Only the object form `{ request: 'zod' }` enables this. `parser: 'zod'` does not.
409
+ */
410
+ function resolveQueryParamsParser(parser) {
411
+ if (!parser || parser === "zod") return null;
412
+ return parser.request ?? null;
413
+ }
414
+ /**
415
+ * Collects the Zod schema import names for an operation based on the active parser directions.
416
+ *
417
+ * - `parser: 'zod'`: response and request body names (backward-compatible behavior).
418
+ * - `parser: { request: 'zod' }`: request body and query params names.
419
+ * - `parser: { response: 'zod' }`: response name only.
420
+ * - `parser: { request: 'zod', response: 'zod' }`: all three.
421
+ *
422
+ * Returns an empty array when no resolver is provided or `parser` is falsy.
423
+ */
424
+ function resolveZodSchemaNames(node, zodResolver, parser) {
425
+ if (!zodResolver || !parser) return [];
426
+ const { query: queryParams } = getOperationParameters(node);
427
+ return [
428
+ resolveResponseParser(parser) === "zod" ? zodResolver.resolveResponseName?.(node) : null,
429
+ resolveRequestParser(parser) === "zod" && node.requestBody?.content?.[0]?.schema ? zodResolver.resolveDataName?.(node) : null,
430
+ resolveQueryParamsParser(parser) === "zod" && queryParams.length > 0 ? zodResolver.resolveQueryParamsName?.(node, queryParams[0]) : null
431
+ ].filter((n) => Boolean(n));
499
432
  }
500
433
  /**
501
434
  * Build QueryKey params: pathParams + data + queryParams (NO headers, NO config).
502
435
  */
503
436
  function buildQueryKeyParams(node, options) {
504
437
  const { pathParamsType, paramsCasing, resolver } = options;
505
- const casedParams = ast.caseParams(node.parameters, paramsCasing);
438
+ const casedParams = caseParams(node.parameters, paramsCasing);
506
439
  const pathParams = casedParams.filter((p) => p.in === "path");
507
440
  const queryParams = casedParams.filter((p) => p.in === "query");
508
- const queryGroupType = resolveQueryGroupType(node, queryParams, resolver);
509
- const bodyType = node.requestBody?.content?.[0]?.schema ? ast.createParamsType({
510
- variant: "reference",
511
- name: resolver.resolveDataName(node)
512
- }) : null;
441
+ const queryGroupType = resolveGroupType({
442
+ node,
443
+ params: queryParams,
444
+ group: "query",
445
+ resolver
446
+ });
447
+ const bodyType = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null;
513
448
  const bodyRequired = node.requestBody?.required ?? false;
514
449
  const params = [];
515
450
  if (pathParams.length) {
516
- const pathChildren = pathParams.map((p) => ast.createFunctionParameter({
451
+ const pathChildren = pathParams.map((p) => ({
517
452
  name: p.name,
518
- type: resolvePathParamType(node, p, resolver),
453
+ type: resolveParamType({
454
+ node,
455
+ param: p,
456
+ resolver
457
+ }),
519
458
  optional: !p.required
520
459
  }));
521
- params.push({
522
- kind: "ParameterGroup",
460
+ if (pathParamsType === "object") params.push(ast.factory.createFunctionParameter({
523
461
  properties: pathChildren,
524
- inline: pathParamsType === "inline",
525
462
  default: pathChildren.every((c) => c.optional) ? "{}" : void 0
526
- });
463
+ }));
464
+ else params.push(...pathChildren.map((child) => ast.factory.createFunctionParameter(child)));
527
465
  }
528
- if (bodyType) params.push(ast.createFunctionParameter({
466
+ if (bodyType) params.push(ast.factory.createFunctionParameter({
529
467
  name: "data",
530
468
  type: bodyType,
531
469
  optional: !bodyRequired
532
470
  }));
533
- params.push(...buildGroupParam("params", node, queryParams, queryGroupType, resolver));
534
- return ast.createFunctionParameters({ params });
471
+ params.push(...buildGroupParam({
472
+ name: "params",
473
+ node,
474
+ params: queryParams,
475
+ groupType: queryGroupType,
476
+ resolver,
477
+ wrapType: (type) => type
478
+ }));
479
+ return ast.factory.createFunctionParameters({ params });
535
480
  }
536
481
  /**
537
482
  * Collect the names of the required params (no default) that drive the `enabled`
@@ -540,12 +485,11 @@ function buildQueryKeyParams(node, options) {
540
485
  */
541
486
  function getEnabledParamNames(paramsNode) {
542
487
  const required = [];
543
- for (const param of paramsNode.params) if ("kind" in param && param.kind === "ParameterGroup") {
544
- const group = param;
545
- for (const child of group.properties) if (!child.optional && child.default === void 0) required.push(child.name);
546
- } else {
547
- const fp = param;
548
- if (!fp.optional && fp.default === void 0) required.push(fp.name);
488
+ for (const param of paramsNode.params) {
489
+ const members = groupMembers(param);
490
+ if (members) {
491
+ for (const member of members) if (!member.optional) required.push(member.name);
492
+ } else if (typeof param.name === "string" && !param.optional && param.default === void 0) required.push(param.name);
549
493
  }
550
494
  return required;
551
495
  }
@@ -561,27 +505,25 @@ function markParamsOptional(paramsNode, names) {
561
505
  if (names.length === 0) return paramsNode;
562
506
  const nameSet = new Set(names);
563
507
  const params = paramsNode.params.map((param) => {
564
- if ("kind" in param && param.kind === "ParameterGroup") {
565
- const group = param;
508
+ const members = groupMembers(param);
509
+ if (members) {
510
+ const next = members.map((member) => nameSet.has(member.name) ? {
511
+ ...member,
512
+ optional: true
513
+ } : member);
566
514
  return {
567
- ...group,
568
- properties: group.properties.map((child) => nameSet.has(child.name) ? ast.createFunctionParameter({
569
- name: child.name,
570
- type: child.type,
571
- rest: child.rest,
572
- optional: true
573
- }) : child)
515
+ ...param,
516
+ type: ast.factory.createTypeLiteral({ members: next })
574
517
  };
575
518
  }
576
- const fp = param;
577
- return nameSet.has(fp.name) ? ast.createFunctionParameter({
578
- name: fp.name,
579
- type: fp.type,
580
- rest: fp.rest,
519
+ return typeof param.name === "string" && nameSet.has(param.name) ? ast.factory.createFunctionParameter({
520
+ name: param.name,
521
+ type: param.type,
522
+ rest: param.rest,
581
523
  optional: true
582
- }) : fp;
524
+ }) : param;
583
525
  });
584
- return ast.createFunctionParameters({ params });
526
+ return ast.factory.createFunctionParameters({ params });
585
527
  }
586
528
  /**
587
529
  * Add a non-null assertion (`!`) to the named params inside a printed client-call
@@ -608,13 +550,13 @@ function injectNonNullAssertions(callStr, names) {
608
550
  const declarationPrinter$3 = functionPrinter({ mode: "declaration" });
609
551
  const queryKeyTransformer = ({ node, casing }) => {
610
552
  if (!node.path) return [];
611
- const path = new URLPath(node.path, { casing });
612
553
  const hasQueryParams = getOperationParameters(node).query.length > 0;
613
554
  const hasRequestBody = !!node.requestBody?.content?.[0]?.schema;
614
555
  return [
615
- path.toObject({
556
+ Url.toObject(node.path, {
616
557
  type: "path",
617
- stringify: true
558
+ stringify: true,
559
+ casing
618
560
  }),
619
561
  hasQueryParams ? "...(params ? [params] : [])" : null,
620
562
  hasRequestBody ? "...(data ? [data] : [])" : null
@@ -656,9 +598,9 @@ function QueryKey({ name, node, tsResolver, paramsCasing, pathParamsType, typeNa
656
598
  //#region src/components/Mutation.tsx
657
599
  const declarationPrinter$2 = functionPrinter({ mode: "declaration" });
658
600
  const callPrinter$2 = functionPrinter({ mode: "call" });
659
- const keysPrinter = functionPrinter({ mode: "keys" });
601
+ const keysPrinter = functionPrinter({ mode: "call" });
660
602
  function createMutationArgParams(node, options) {
661
- return ast.createOperationParams(node, {
603
+ return createOperationParams(node, {
662
604
  paramsType: "inline",
663
605
  pathParamsType: "inline",
664
606
  paramsCasing: options.paramsCasing,
@@ -669,25 +611,22 @@ function buildMutationParamsNode(node, options) {
669
611
  const { dataReturnType, mutationKeyTypeName, mutationArgTypeName, resolver } = options;
670
612
  const responseName = resolver.resolveResponseName(node);
671
613
  const errorNames = resolveErrorNames(node, resolver);
672
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
614
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
673
615
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
674
- return ast.createFunctionParameters({ params: [ast.createFunctionParameter({
616
+ return ast.factory.createFunctionParameters({ params: [ast.factory.createFunctionParameter({
675
617
  name: "options",
676
- type: ast.createParamsType({
677
- variant: "reference",
678
- name: `{
618
+ type: `{
679
619
  mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
680
620
  client?: ${buildRequestConfigType(node, resolver)},
681
621
  shouldFetch?: boolean,
682
- }`
683
- }),
622
+ }`,
684
623
  default: "{}"
685
624
  })] });
686
625
  }
687
626
  function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, mutationArgTypeName, paramsCasing, paramsType, pathParamsType, dataReturnType, node, tsResolver }) {
688
627
  const responseName = tsResolver.resolveResponseName(node);
689
628
  const errorNames = resolveErrorNames(node, tsResolver);
690
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
629
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver);
691
630
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
692
631
  const mutationArgParamsNode = createMutationArgParams(node, {
693
632
  paramsCasing,
@@ -710,17 +649,14 @@ function Mutation({ name, clientName, mutationKeyName, mutationKeyTypeName, muta
710
649
  resolver: tsResolver
711
650
  });
712
651
  const paramsSignature = declarationPrinter$2.print(paramsNode) ?? "";
713
- const clientCallParamsNode = ast.createOperationParams(node, {
652
+ const clientCallParamsNode = createOperationParams(node, {
714
653
  paramsType,
715
654
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
716
655
  paramsCasing,
717
656
  resolver: tsResolver,
718
- extraParams: [ast.createFunctionParameter({
657
+ extraParams: [ast.factory.createFunctionParameter({
719
658
  name: "config",
720
- type: ast.createParamsType({
721
- variant: "reference",
722
- name: buildRequestConfigType(node, tsResolver)
723
- }),
659
+ type: buildRequestConfigType(node, tsResolver),
724
660
  default: "{}"
725
661
  })]
726
662
  });
@@ -785,22 +721,7 @@ function MutationKey({ name, typeName, node, paramsCasing, pathParamsType, trans
785
721
  const declarationPrinter$1 = functionPrinter({ mode: "declaration" });
786
722
  const callPrinter$1 = functionPrinter({ mode: "call" });
787
723
  function getQueryOptionsParams(node, options) {
788
- const { paramsType, paramsCasing, pathParamsType, resolver } = options;
789
- const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
790
- return ast.createOperationParams(node, {
791
- paramsType,
792
- pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
793
- paramsCasing,
794
- resolver,
795
- extraParams: [ast.createFunctionParameter({
796
- name: "config",
797
- type: ast.createParamsType({
798
- variant: "reference",
799
- name: requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"
800
- }),
801
- default: "{}"
802
- })]
803
- });
724
+ return buildQueryOptionsParams(node, options);
804
725
  }
805
726
  function QueryOptions({ name, clientName, node, tsResolver, paramsCasing, paramsType, pathParamsType }) {
806
727
  const enabledNames = getEnabledParamNames(buildQueryKeyParams(node, {
@@ -843,22 +764,19 @@ function buildQueryParamsNode(node, options) {
843
764
  const responseName = resolver.resolveResponseName(node);
844
765
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : void 0;
845
766
  const errorNames = resolveErrorNames(node, resolver);
846
- const TData = dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`;
767
+ const TData = dataReturnType === "data" ? responseName : buildStatusUnionType(node, resolver);
847
768
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`;
848
- const optionsParam = ast.createFunctionParameter({
769
+ const optionsParam = ast.factory.createFunctionParameter({
849
770
  name: "options",
850
- type: ast.createParamsType({
851
- variant: "reference",
852
- name: `{
771
+ type: `{
853
772
  query?: SWRConfiguration<${[TData, TError].join(", ")}>,
854
773
  client?: ${requestName ? `Partial<RequestConfig<${requestName}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
855
774
  shouldFetch?: boolean,
856
775
  immutable?: boolean
857
- }`
858
- }),
776
+ }`,
859
777
  default: "{}"
860
778
  });
861
- return ast.createOperationParams(node, {
779
+ return createOperationParams(node, {
862
780
  paramsType,
863
781
  pathParamsType: paramsType === "object" ? "object" : pathParamsType === "object" ? "object" : "inline",
864
782
  paramsCasing,
@@ -870,7 +788,7 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
870
788
  const responseName = tsResolver.resolveResponseName(node);
871
789
  const errorNames = resolveErrorNames(node, tsResolver);
872
790
  const generics = [
873
- dataReturnType === "data" ? responseName : `ResponseConfig<${responseName}>`,
791
+ dataReturnType === "data" ? responseName : buildStatusUnionType(node, tsResolver),
874
792
  `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(" | ") : "Error"}>`,
875
793
  `${queryKeyTypeName} | null`
876
794
  ];
@@ -928,6 +846,6 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsT
928
846
  });
929
847
  }
930
848
  //#endregion
931
- export { QueryKey as a, resolveOperationTypeNames as c, Mutation as i, mutationKeyTransformer as l, QueryOptions as n, queryKeyTransformer as o, MutationKey as r, resolveZodSchemaNames as s, Query as t, camelCase as u };
849
+ export { QueryKey as a, mutationKeyTransformer as c, Mutation as i, resolveOperationTypeNames as l, QueryOptions as n, queryKeyTransformer as o, MutationKey as r, resolveZodSchemaNames as s, Query as t, camelCase as u };
932
850
 
933
- //# sourceMappingURL=components-BuLagnaM.js.map
851
+ //# sourceMappingURL=components-mWBRE6E4.js.map