@kubb/plugin-swr 5.0.0-beta.36 → 5.0.0-beta.56

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 (36) hide show
  1. package/README.md +11 -11
  2. package/dist/{components-CD7ZoS3B.cjs → components-C8FJ3-Cb.cjs} +175 -196
  3. package/dist/components-C8FJ3-Cb.cjs.map +1 -0
  4. package/dist/{components-BuLagnaM.js → components-CR9NLFcO.js} +176 -197
  5. package/dist/components-CR9NLFcO.js.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +1 -1
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-bnwHiUqJ.js → generators-BB6csINY.js} +71 -94
  10. package/dist/generators-BB6csINY.js.map +1 -0
  11. package/dist/{generators-DM18y_Qk.cjs → generators-mw3FvFJD.cjs} +70 -93
  12. package/dist/generators-mw3FvFJD.cjs.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +6 -1
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +62 -12
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +63 -13
  20. package/dist/index.js.map +1 -1
  21. package/dist/{types-BoANASs2.d.ts → types-Dz_j0Bqv.d.ts} +11 -14
  22. package/package.json +9 -18
  23. package/src/components/Mutation.tsx +3 -3
  24. package/src/components/Query.tsx +3 -3
  25. package/src/components/QueryOptions.tsx +3 -21
  26. package/src/generators/mutationGenerator.tsx +13 -9
  27. package/src/generators/queryGenerator.tsx +5 -9
  28. package/src/plugin.ts +6 -18
  29. package/src/resolvers/resolverSwr.ts +2 -2
  30. package/src/types.ts +9 -12
  31. package/src/utils.ts +8 -1
  32. package/dist/components-BuLagnaM.js.map +0 -1
  33. package/dist/components-CD7ZoS3B.cjs.map +0 -1
  34. package/dist/generators-DM18y_Qk.cjs.map +0 -1
  35. package/dist/generators-bnwHiUqJ.js.map +0 -1
  36. package/extension.yaml +0 -199
@@ -1,4 +1,4 @@
1
- const require_components = require("./components-CD7ZoS3B.cjs");
1
+ const require_components = require("./components-C8FJ3-Cb.cjs");
2
2
  let node_path = require("node:path");
3
3
  node_path = require_components.__toESM(node_path);
4
4
  let _kubb_core = require("@kubb/core");
@@ -7,8 +7,12 @@ let _kubb_plugin_ts = require("@kubb/plugin-ts");
7
7
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
8
8
  let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
9
9
  let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
10
- let remeda = require("remeda");
11
10
  //#region src/generators/mutationGenerator.tsx
11
+ /**
12
+ * Built-in generator for `useSWRMutation` hooks. Emits one `useFooMutation` hook
13
+ * per POST/PUT/DELETE operation (configurable via `mutation.methods`) plus
14
+ * the matching `fooMutationKey` helper.
15
+ */
12
16
  const mutationGenerator = (0, _kubb_core.defineGenerator)({
13
17
  name: "swr-mutation",
14
18
  renderer: _kubb_renderer_jsx.jsxRenderer,
@@ -20,7 +24,8 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
20
24
  if (!pluginTs) return null;
21
25
  const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
22
26
  const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
23
- if (!(mutation !== false && !isQuery && (0, remeda.difference)(mutation ? mutation.methods : [], query ? query.methods : []).some((method) => node.method.toLowerCase() === method.toLowerCase()))) return null;
27
+ const queryMethods = new Set(query ? query.methods : []);
28
+ if (!(mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase()))) return null;
24
29
  const importPath = mutation ? mutation.importPath : "swr/mutation";
25
30
  const mutationHookName = resolver.resolveMutationName(node);
26
31
  const mutationKeyName = resolver.resolveMutationKeyName(node);
@@ -53,7 +58,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
53
58
  paramsCasing,
54
59
  order: "body-response-first"
55
60
  });
56
- const pluginZod = parser === "zod" ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
61
+ const pluginZod = (0, _kubb_plugin_client.isParserEnabled)(parser) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
57
62
  const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : void 0;
58
63
  const fileZod = zodResolver ? zodResolver.resolveFile({
59
64
  name: node.operationId,
@@ -65,7 +70,7 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
65
70
  output: pluginZod?.options?.output ?? output,
66
71
  group: pluginZod?.options?.group
67
72
  }) : void 0;
68
- const zodSchemaNames = require_components.resolveZodSchemaNames(node, zodResolver);
73
+ const zodSchemaNames = require_components.resolveZodSchemaNames(node, zodResolver, parser);
69
74
  const clientPlugin = driver.getPlugin(_kubb_plugin_client.pluginClientName);
70
75
  const shouldUseClientPlugin = clientPlugin?.name === _kubb_plugin_client.pluginClientName && clientOptions.clientType !== "class";
71
76
  const clientResolver = shouldUseClientPlugin ? driver.getResolver(_kubb_plugin_client.pluginClientName) : void 0;
@@ -106,48 +111,31 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
106
111
  root: meta.file.path,
107
112
  path: fileZod.path
108
113
  }),
109
- clientOptions.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
110
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
111
- name: "client",
112
- path: clientOptions.importPath
113
- }),
114
- /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
115
- name: [
116
- "Client",
117
- "RequestConfig",
118
- "ResponseErrorConfig"
119
- ],
120
- path: clientOptions.importPath,
121
- isTypeOnly: true
122
- }),
123
- clientOptions.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
124
- name: ["ResponseConfig"],
125
- path: clientOptions.importPath,
126
- isTypeOnly: true
127
- })
128
- ] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
129
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
130
- name: ["client"],
131
- root: meta.file.path,
132
- path: node_path.default.resolve(root, ".kubb/client.ts")
133
- }),
134
- /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
135
- name: [
136
- "Client",
137
- "RequestConfig",
138
- "ResponseErrorConfig"
139
- ],
140
- root: meta.file.path,
141
- path: node_path.default.resolve(root, ".kubb/client.ts"),
142
- isTypeOnly: true
143
- }),
144
- clientOptions.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
145
- name: ["ResponseConfig"],
146
- root: meta.file.path,
147
- path: node_path.default.resolve(root, ".kubb/client.ts"),
148
- isTypeOnly: true
149
- })
150
- ] }),
114
+ clientOptions.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
115
+ name: "client",
116
+ path: clientOptions.importPath
117
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
118
+ name: [
119
+ "Client",
120
+ "RequestConfig",
121
+ "ResponseErrorConfig"
122
+ ],
123
+ path: clientOptions.importPath,
124
+ isTypeOnly: true
125
+ })] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
126
+ name: ["client"],
127
+ root: meta.file.path,
128
+ path: node_path.default.resolve(root, ".kubb/client.ts")
129
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
130
+ name: [
131
+ "Client",
132
+ "RequestConfig",
133
+ "ResponseErrorConfig"
134
+ ],
135
+ root: meta.file.path,
136
+ path: node_path.default.resolve(root, ".kubb/client.ts"),
137
+ isTypeOnly: true
138
+ })] }),
151
139
  shouldUseClientPlugin && clientFile && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
152
140
  name: [resolvedClientName],
153
141
  root: meta.file.path,
@@ -158,6 +146,11 @@ const mutationGenerator = (0, _kubb_core.defineGenerator)({
158
146
  root: meta.file.path,
159
147
  path: node_path.default.resolve(root, ".kubb/config.ts")
160
148
  }),
149
+ !shouldUseClientPlugin && parser === "zod" && zodResolver && node.requestBody?.content?.[0]?.schema && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
150
+ name: ["z"],
151
+ path: "zod",
152
+ isTypeOnly: true
153
+ }),
161
154
  meta.fileTs && importedTypeNames.length > 0 && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
162
155
  name: Array.from(new Set(importedTypeNames)),
163
156
  root: meta.file.path,
@@ -225,7 +218,8 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
225
218
  if (!pluginTs) return null;
226
219
  const tsResolver = driver.getResolver(_kubb_plugin_ts.pluginTsName);
227
220
  const isQuery = query === false || !!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase());
228
- const isMutation = mutation !== false && !isQuery && (0, remeda.difference)(mutation ? mutation.methods : [], query ? query.methods : []).some((method) => node.method.toLowerCase() === method.toLowerCase());
221
+ const queryMethods = new Set(query ? query.methods : []);
222
+ const isMutation = mutation !== false && !isQuery && (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase());
229
223
  if (!isQuery || isMutation) return null;
230
224
  const importPath = query ? query.importPath : "swr";
231
225
  const queryName = resolver.resolveQueryName(node);
@@ -260,7 +254,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
260
254
  exclude: [queryKeyTypeName],
261
255
  order: "body-response-first"
262
256
  });
263
- const pluginZod = parser === "zod" ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
257
+ const pluginZod = (0, _kubb_plugin_client.isParserEnabled)(parser) ? driver.getPlugin(_kubb_plugin_zod.pluginZodName) : void 0;
264
258
  const zodResolver = pluginZod ? driver.getResolver(_kubb_plugin_zod.pluginZodName) : void 0;
265
259
  const fileZod = zodResolver ? zodResolver.resolveFile({
266
260
  name: node.operationId,
@@ -272,7 +266,7 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
272
266
  output: pluginZod?.options?.output ?? output,
273
267
  group: pluginZod?.options?.group
274
268
  }) : void 0;
275
- const zodSchemaNames = require_components.resolveZodSchemaNames(node, zodResolver);
269
+ const zodSchemaNames = require_components.resolveZodSchemaNames(node, zodResolver, parser);
276
270
  const clientPlugin = driver.getPlugin(_kubb_plugin_client.pluginClientName);
277
271
  const shouldUseClientPlugin = clientPlugin?.name === _kubb_plugin_client.pluginClientName && clientOptions.clientType !== "class";
278
272
  const clientResolver = shouldUseClientPlugin ? driver.getResolver(_kubb_plugin_client.pluginClientName) : void 0;
@@ -313,48 +307,31 @@ const queryGenerator = (0, _kubb_core.defineGenerator)({
313
307
  root: meta.file.path,
314
308
  path: fileZod.path
315
309
  }),
316
- clientOptions.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
317
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
318
- name: "client",
319
- path: clientOptions.importPath
320
- }),
321
- /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
322
- name: [
323
- "Client",
324
- "RequestConfig",
325
- "ResponseErrorConfig"
326
- ],
327
- path: clientOptions.importPath,
328
- isTypeOnly: true
329
- }),
330
- clientOptions.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
331
- name: ["ResponseConfig"],
332
- path: clientOptions.importPath,
333
- isTypeOnly: true
334
- })
335
- ] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [
336
- !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
337
- name: ["client"],
338
- root: meta.file.path,
339
- path: node_path.default.resolve(root, ".kubb/client.ts")
340
- }),
341
- /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
342
- name: [
343
- "Client",
344
- "RequestConfig",
345
- "ResponseErrorConfig"
346
- ],
347
- root: meta.file.path,
348
- path: node_path.default.resolve(root, ".kubb/client.ts"),
349
- isTypeOnly: true
350
- }),
351
- clientOptions.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
352
- name: ["ResponseConfig"],
353
- root: meta.file.path,
354
- path: node_path.default.resolve(root, ".kubb/client.ts"),
355
- isTypeOnly: true
356
- })
357
- ] }),
310
+ clientOptions.importPath ? /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
311
+ name: "client",
312
+ path: clientOptions.importPath
313
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
314
+ name: [
315
+ "Client",
316
+ "RequestConfig",
317
+ "ResponseErrorConfig"
318
+ ],
319
+ path: clientOptions.importPath,
320
+ isTypeOnly: true
321
+ })] }) : /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
322
+ name: ["client"],
323
+ root: meta.file.path,
324
+ path: node_path.default.resolve(root, ".kubb/client.ts")
325
+ }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
326
+ name: [
327
+ "Client",
328
+ "RequestConfig",
329
+ "ResponseErrorConfig"
330
+ ],
331
+ root: meta.file.path,
332
+ path: node_path.default.resolve(root, ".kubb/client.ts"),
333
+ isTypeOnly: true
334
+ })] }),
358
335
  shouldUseClientPlugin && clientFile && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
359
336
  name: [resolvedClientName],
360
337
  root: meta.file.path,
@@ -442,4 +419,4 @@ Object.defineProperty(exports, "queryGenerator", {
442
419
  }
443
420
  });
444
421
 
445
- //# sourceMappingURL=generators-DM18y_Qk.cjs.map
422
+ //# sourceMappingURL=generators-mw3FvFJD.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-mw3FvFJD.cjs","names":["jsxRenderer","ast","pluginTsName","resolveOperationTypeNames","pluginZodName","resolveZodSchemaNames","pluginClientName","File","path","MutationKey","Client","Mutation","jsxRenderer","ast","pluginTsName","resolveOperationTypeNames","pluginZodName","resolveZodSchemaNames","pluginClientName","File","path","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { resolveZodSchemaNames } from '@internals/tanstack-query'\nimport { ast, defineGenerator } from '@kubb/core'\nimport { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\n/**\n * Built-in generator for `useSWRMutation` hooks. Emits one `useFooMutation` hook\n * per POST/PUT/DELETE operation (configurable via `mutation.methods`) plus\n * the matching `fooMutationKey` helper.\n */\nexport const mutationGenerator = defineGenerator<PluginSwr>({\n name: 'swr-mutation',\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n const { config, driver, resolver, root } = ctx\n const { output, query, mutation, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options\n\n const pluginTs = driver.getPlugin(pluginTsName)\n if (!pluginTs) return null\n const tsResolver = driver.getResolver(pluginTsName)\n\n const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))\n const queryMethods = new Set(query ? query.methods : [])\n const isMutation =\n mutation !== false &&\n !isQuery &&\n (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())\n\n if (!isMutation) return null\n\n const importPath = mutation ? mutation.importPath : 'swr/mutation'\n\n const mutationHookName = resolver.resolveMutationName(node)\n const mutationKeyName = resolver.resolveMutationKeyName(node)\n const mutationKeyTypeName = resolver.resolveMutationKeyTypeName(node)\n const mutationArgTypeName = resolver.resolveMutationArgTypeName(node)\n const clientName = resolver.resolveClientName(node)\n\n const meta = {\n file: resolver.resolveFile({ name: mutationHookName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n fileTs: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n }\n\n const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })\n\n const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : undefined\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : undefined\n const fileZod = zodResolver\n ? zodResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginZod?.options?.output ?? output, group: pluginZod?.options?.group },\n )\n : undefined\n const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)\n\n const clientPlugin = driver.getPlugin(pluginClientName)\n const hasClientPlugin = clientPlugin?.name === pluginClientName\n const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'\n const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : undefined\n\n const clientFile = shouldUseClientPlugin\n ? clientResolver?.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n {\n root,\n output: clientPlugin?.options?.output ?? output,\n group: clientPlugin?.options?.group,\n },\n )\n : undefined\n\n const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientName) : clientName\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}\n {clientOptions.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={meta.file.path}\n path={path.resolve(root, '.kubb/client.ts')}\n isTypeOnly\n />\n </>\n )}\n {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}\n {!shouldUseClientPlugin && node.requestBody?.content?.some((e) => e.contentType === 'multipart/form-data') && (\n <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />\n )}\n {!shouldUseClientPlugin && parser === 'zod' && zodResolver && node.requestBody?.content?.[0]?.schema && (\n <File.Import name={['z']} path=\"zod\" isTypeOnly />\n )}\n {meta.fileTs && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />\n )}\n\n <MutationKey\n name={mutationKeyName}\n typeName={mutationKeyTypeName}\n node={node}\n pathParamsType={pathParamsType}\n paramsCasing={paramsCasing}\n transformer={ctx.options.mutationKey}\n />\n\n {!shouldUseClientPlugin && (\n <Client\n name={resolvedClientName}\n baseURL={clientOptions.baseURL}\n dataReturnType={clientOptions.dataReturnType || 'data'}\n paramsCasing={clientOptions.paramsCasing || paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n parser={parser}\n node={node}\n tsResolver={tsResolver}\n zodResolver={zodResolver}\n />\n )}\n\n {mutation && (\n <>\n <File.Import name={'useSWRMutation'} path={importPath} />\n <File.Import name={['SWRMutationConfiguration']} path={importPath} isTypeOnly />\n <Mutation\n name={mutationHookName}\n clientName={resolvedClientName}\n mutationKeyName={mutationKeyName}\n mutationKeyTypeName={mutationKeyTypeName}\n mutationArgTypeName={mutationArgTypeName}\n node={node}\n tsResolver={tsResolver}\n dataReturnType={clientOptions.dataReturnType || 'data'}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { resolveOperationTypeNames } from '@internals/shared'\nimport { resolveZodSchemaNames } from '@internals/tanstack-query'\nimport { ast, defineGenerator } from '@kubb/core'\nimport { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, jsxRenderer } from '@kubb/renderer-jsx'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = defineGenerator<PluginSwr>({\n name: 'swr-query',\n renderer: jsxRenderer,\n operation(node, ctx) {\n if (!ast.isHttpOperationNode(node)) return null\n const { config, driver, resolver, root } = ctx\n const { output, query, mutation, paramsCasing, paramsType, pathParamsType, parser, client: clientOptions, group } = ctx.options\n\n const pluginTs = driver.getPlugin(pluginTsName)\n if (!pluginTs) return null\n const tsResolver = driver.getResolver(pluginTsName)\n\n const isQuery = query === false || (!!query && query.methods.some((method) => node.method.toLowerCase() === method.toLowerCase()))\n const queryMethods = new Set(query ? query.methods : [])\n const isMutation =\n mutation !== false &&\n !isQuery &&\n (mutation ? mutation.methods : []).some((method) => !queryMethods.has(method) && node.method.toLowerCase() === method.toLowerCase())\n\n if (!isQuery || isMutation) return null\n\n const importPath = query ? query.importPath : 'swr'\n\n const queryName = resolver.resolveQueryName(node)\n const queryOptionsName = resolver.resolveQueryOptionsName(node)\n const queryKeyName = resolver.resolveQueryKeyName(node)\n const queryKeyTypeName = resolver.resolveQueryKeyTypeName(node)\n const clientName = resolver.resolveClientName(node)\n\n const meta = {\n file: resolver.resolveFile({ name: queryName, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path }, { root, output, group }),\n fileTs: tsResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginTs.options?.output ?? output, group: pluginTs.options?.group },\n ),\n }\n\n const importedTypeNames = resolveOperationTypeNames(node, tsResolver, {\n paramsCasing,\n exclude: [queryKeyTypeName],\n order: 'body-response-first',\n })\n\n const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : undefined\n const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : undefined\n const fileZod = zodResolver\n ? zodResolver.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n { root, output: pluginZod?.options?.output ?? output, group: pluginZod?.options?.group },\n )\n : undefined\n const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)\n\n const clientPlugin = driver.getPlugin(pluginClientName)\n const hasClientPlugin = clientPlugin?.name === pluginClientName\n const shouldUseClientPlugin = hasClientPlugin && clientOptions.clientType !== 'class'\n const clientResolver = shouldUseClientPlugin ? driver.getResolver(pluginClientName) : undefined\n\n const clientFile = shouldUseClientPlugin\n ? clientResolver?.resolveFile(\n { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },\n {\n root,\n output: clientPlugin?.options?.output ?? output,\n group: clientPlugin?.options?.group,\n },\n )\n : undefined\n\n const resolvedClientName = shouldUseClientPlugin ? (clientResolver?.resolveName(node.operationId) ?? clientName) : clientName\n\n return (\n <File\n baseName={meta.file.baseName}\n path={meta.file.path}\n meta={meta.file.meta}\n banner={resolver.resolveBanner(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n footer={resolver.resolveFooter(ctx.meta, { output, config, file: { path: meta.file.path, baseName: meta.file.baseName } })}\n >\n {fileZod && zodSchemaNames.length > 0 && <File.Import name={zodSchemaNames} root={meta.file.path} path={fileZod.path} />}\n {clientOptions.importPath ? (\n <>\n {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}\n <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />\n </>\n ) : (\n <>\n {!shouldUseClientPlugin && <File.Import name={['client']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} />}\n <File.Import\n name={['Client', 'RequestConfig', 'ResponseErrorConfig']}\n root={meta.file.path}\n path={path.resolve(root, '.kubb/client.ts')}\n isTypeOnly\n />\n </>\n )}\n {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}\n {!shouldUseClientPlugin && <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />}\n {meta.fileTs && importedTypeNames.length > 0 && (\n <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />\n )}\n\n <QueryKey\n name={queryKeyName}\n typeName={queryKeyTypeName}\n node={node}\n tsResolver={tsResolver}\n pathParamsType={pathParamsType}\n paramsCasing={paramsCasing}\n transformer={ctx.options.queryKey}\n />\n\n {!shouldUseClientPlugin && (\n <Client\n name={resolvedClientName}\n baseURL={clientOptions.baseURL}\n dataReturnType={clientOptions.dataReturnType || 'data'}\n paramsCasing={clientOptions.paramsCasing || paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n parser={parser}\n node={node}\n tsResolver={tsResolver}\n zodResolver={zodResolver}\n />\n )}\n\n <QueryOptions\n name={queryOptionsName}\n clientName={resolvedClientName}\n node={node}\n tsResolver={tsResolver}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n />\n\n {query && (\n <>\n <File.Import name={'useSWR'} path={importPath} />\n <File.Import name={['SWRConfiguration']} path={importPath} isTypeOnly />\n <Query\n name={queryName}\n queryOptionsName={queryOptionsName}\n queryKeyName={queryKeyName}\n queryKeyTypeName={queryKeyTypeName}\n node={node}\n tsResolver={tsResolver}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n dataReturnType={clientOptions.dataReturnType || 'data'}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,MAAa,qBAAA,GAAA,WAAA,gBAAA,CAA+C;CAC1D,MAAM;CACN,UAAUA,mBAAAA;CACV,UAAU,MAAM,KAAK;EACnB,IAAI,CAACC,WAAAA,IAAI,oBAAoB,IAAI,GAAG,OAAO;EAC3C,MAAM,EAAE,QAAQ,QAAQ,UAAU,SAAS;EAC3C,MAAM,EAAE,QAAQ,OAAO,UAAU,cAAc,YAAY,gBAAgB,QAAQ,QAAQ,eAAe,UAAU,IAAI;EAExH,MAAM,WAAW,OAAO,UAAUC,gBAAAA,YAAY;EAC9C,IAAI,CAAC,UAAU,OAAO;EACtB,MAAM,aAAa,OAAO,YAAYA,gBAAAA,YAAY;EAElD,MAAM,UAAU,UAAU,SAAU,CAAC,CAAC,SAAS,MAAM,QAAQ,MAAM,WAAW,KAAK,OAAO,YAAY,MAAM,OAAO,YAAY,CAAC;EAChI,MAAM,eAAe,IAAI,IAAI,QAAQ,MAAM,UAAU,CAAC,CAAC;EAMvD,IAAI,EAJF,aAAa,SACb,CAAC,YACA,WAAW,SAAS,UAAU,CAAC,EAAA,CAAG,MAAM,WAAW,CAAC,aAAa,IAAI,MAAM,KAAK,KAAK,OAAO,YAAY,MAAM,OAAO,YAAY,CAAC,IAEpH,OAAO;EAExB,MAAM,aAAa,WAAW,SAAS,aAAa;EAEpD,MAAM,mBAAmB,SAAS,oBAAoB,IAAI;EAC1D,MAAM,kBAAkB,SAAS,uBAAuB,IAAI;EAC5D,MAAM,sBAAsB,SAAS,2BAA2B,IAAI;EACpE,MAAM,sBAAsB,SAAS,2BAA2B,IAAI;EACpE,MAAM,aAAa,SAAS,kBAAkB,IAAI;EAElD,MAAM,OAAO;GACX,MAAM,SAAS,YAAY;IAAE,MAAM;IAAkB,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IAC1B,CAAA;IAEA,CAAC,yBACA,iBAAA,GAAA,+BAAA,IAAA,CAACC,oBAAAA,QAAD;KACE,MAAM;KACN,SAAS,cAAc;KACvB,gBAAgB,cAAc,kBAAkB;KAChD,cAAc,cAAc,gBAAgB;KAChC;KACI;KACR;KACF;KACM;KACC;IACd,CAAA;IAGH,iBAAA,GAAA,+BAAA,IAAA,CAACC,mBAAAA,cAAD;KACE,MAAM;KACN,YAAY;KACN;KACM;KACE;KACF;KACI;IACjB,CAAA;IAEA,SACC,iBAAA,GAAA,+BAAA,KAAA,CAAA,+BAAA,UAAA,EAAA,UAAA;KACE,iBAAA,GAAA,+BAAA,IAAA,CAACJ,mBAAAA,KAAK,QAAN;MAAa,MAAM;MAAU,MAAM;KAAa,CAAA;KAChD,iBAAA,GAAA,+BAAA,IAAA,CAACA,mBAAAA,KAAK,QAAN;MAAa,MAAM,CAAC,kBAAkB;MAAG,MAAM;MAAY,YAAA;KAAY,CAAA;KACvE,iBAAA,GAAA,+BAAA,IAAA,CAACK,mBAAAA,OAAD;MACE,MAAM;MACY;MACJ;MACI;MACZ;MACM;MACE;MACF;MACI;MAChB,gBAAgB,cAAc,kBAAkB;KACjD,CAAA;IACD,EAAA,CAAA;GAEA;;CAEV;AACF,CAAC"}
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generators = require("./generators-DM18y_Qk.cjs");
2
+ const require_generators = require("./generators-mw3FvFJD.cjs");
3
3
  exports.mutationGenerator = require_generators.mutationGenerator;
4
4
  exports.queryGenerator = require_generators.queryGenerator;
@@ -1,7 +1,12 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { n as PluginSwr } from "./types-BoANASs2.js";
2
+ import { n as PluginSwr } from "./types-Dz_j0Bqv.js";
3
3
 
4
4
  //#region src/generators/mutationGenerator.d.ts
5
+ /**
6
+ * Built-in generator for `useSWRMutation` hooks. Emits one `useFooMutation` hook
7
+ * per POST/PUT/DELETE operation (configurable via `mutation.methods`) plus
8
+ * the matching `fooMutationKey` helper.
9
+ */
5
10
  declare const mutationGenerator: import("@kubb/core").Generator<PluginSwr, unknown>;
6
11
  //#endregion
7
12
  //#region src/generators/queryGenerator.d.ts
@@ -1,2 +1,2 @@
1
- import { n as mutationGenerator, t as queryGenerator } from "./generators-bnwHiUqJ.js";
1
+ import { n as mutationGenerator, t as queryGenerator } from "./generators-BB6csINY.js";
2
2
  export { mutationGenerator, queryGenerator };
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_components = require("./components-CD7ZoS3B.cjs");
6
- const require_generators = require("./generators-DM18y_Qk.cjs");
5
+ const require_components = require("./components-C8FJ3-Cb.cjs");
6
+ const require_generators = require("./generators-mw3FvFJD.cjs");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_components.__toESM(node_path, 1);
9
9
  let _kubb_core = require("@kubb/core");
@@ -13,6 +13,62 @@ let _kubb_plugin_client_templates_clients_fetch_source = require("@kubb/plugin-c
13
13
  let _kubb_plugin_client_templates_config_source = require("@kubb/plugin-client/templates/config.source");
14
14
  let _kubb_plugin_ts = require("@kubb/plugin-ts");
15
15
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
16
+ //#region ../../internals/utils/src/fs.ts
17
+ /**
18
+ * Builds a nested file path from a dotted name. Splits on dots that precede a letter
19
+ * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases
20
+ * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.
21
+ *
22
+ * Empty segments are dropped before joining. They arise when the name starts with a dot
23
+ * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to
24
+ * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an
25
+ * absolute path, letting generated files escape the configured output directory.
26
+ *
27
+ * @example Nested path from a dotted name
28
+ * `toFilePath('pet.petId') // 'pet/petId'`
29
+ *
30
+ * @example PascalCase the final segment
31
+ * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`
32
+ *
33
+ * @example Suffix applied to the final segment only
34
+ * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
35
+ */
36
+ function toFilePath(name, caseLast = require_components.camelCase) {
37
+ const parts = name.split(/\.(?=[a-zA-Z])/);
38
+ return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : require_components.camelCase(part)).filter(Boolean).join("/");
39
+ }
40
+ //#endregion
41
+ //#region ../../internals/shared/src/group.ts
42
+ /**
43
+ * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
44
+ * shared default naming so every plugin groups output consistently:
45
+ *
46
+ * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).
47
+ * - other groups use the camelCased group (`pet store` → `petStore`).
48
+ *
49
+ * A user-provided `group.name` always wins over the default namer, so callers stay in
50
+ * control of their output folders. Returns `null` when grouping is disabled, matching the
51
+ * per-plugin convention.
52
+ *
53
+ * @param group - The user-supplied group option, or `undefined` to disable grouping.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * createGroupConfig(group) // shared across every plugin
58
+ * ```
59
+ */
60
+ function createGroupConfig(group) {
61
+ if (!group) return null;
62
+ const defaultName = (ctx) => {
63
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
64
+ return require_components.camelCase(ctx.group);
65
+ };
66
+ return {
67
+ ...group,
68
+ name: group.name ? group.name : defaultName
69
+ };
70
+ }
71
+ //#endregion
16
72
  //#region src/resolvers/resolverSwr.ts
17
73
  function capitalize(name) {
18
74
  return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
@@ -29,7 +85,7 @@ const resolverSwr = (0, _kubb_core.defineResolver)(() => ({
29
85
  name: "default",
30
86
  pluginName: "plugin-swr",
31
87
  default(name, type) {
32
- return require_components.camelCase(name, { isFile: type === "file" });
88
+ return type === "file" ? toFilePath(name) : require_components.camelCase(name);
33
89
  },
34
90
  resolveName(name) {
35
91
  return this.default(name, "function");
@@ -71,22 +127,16 @@ const pluginSwrName = "plugin-swr";
71
127
  const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
72
128
  const { output = {
73
129
  path: "hooks",
74
- barrelType: "named"
130
+ barrel: { type: "named" }
75
131
  }, group, exclude = [], include, override = [], parser = false, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", mutation = {}, query = {}, mutationKey = require_components.mutationKeyTransformer, queryKey = require_components.queryKeyTransformer, paramsCasing, client, resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
76
132
  const clientName = client?.client ?? "axios";
77
133
  const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
78
134
  const selectedGenerators = options.generators ?? [require_generators.queryGenerator, require_generators.mutationGenerator].filter((generator) => Boolean(generator));
79
- const groupConfig = group ? {
80
- ...group,
81
- name: group.name ? group.name : (ctx) => {
82
- if (group.type === "path") return `${ctx.group.split("/")[1]}`;
83
- return `${require_components.camelCase(ctx.group)}Controller`;
84
- }
85
- } : void 0;
135
+ const groupConfig = createGroupConfig(group) ?? void 0;
86
136
  return {
87
137
  name: pluginSwrName,
88
138
  options,
89
- dependencies: [_kubb_plugin_ts.pluginTsName, parser === "zod" ? _kubb_plugin_zod.pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
139
+ dependencies: [_kubb_plugin_ts.pluginTsName, (0, _kubb_plugin_client.isParserEnabled)(parser) ? _kubb_plugin_zod.pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
90
140
  hooks: { "kubb:plugin:setup"(ctx) {
91
141
  const resolver = userResolver ? {
92
142
  ...resolverSwr,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["camelCase","mutationKeyTransformer","queryKeyTransformer","queryGenerator","mutationGenerator","camelCase","pluginTsName","pluginZodName","path","pluginClientName","ast","fetchClientSource","axiosClientSource","configSource"],"sources":["../src/resolvers/resolverSwr.ts","../src/plugin.ts"],"sourcesContent":["import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginSwr } from '../types.ts'\n\nfunction capitalize(name: string): string {\n return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\n/**\n * Naming convention resolver for the SWR plugin.\n *\n * Provides default naming helpers using camelCase for functions and file paths.\n *\n * @example\n * `resolverSwr.default('list pets', 'function') // → 'listPets'`\n */\nexport const resolverSwr = defineResolver<PluginSwr>(() => ({\n name: 'default',\n pluginName: 'plugin-swr',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveQueryName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveMutationName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveQueryOptionsName(node) {\n return `${this.resolveName(node.operationId)}QueryOptions`\n },\n resolveQueryKeyName(node) {\n return `${this.resolveName(node.operationId)}QueryKey`\n },\n resolveMutationKeyName(node) {\n return `${this.resolveName(node.operationId)}MutationKey`\n },\n resolveQueryKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}QueryKey`\n },\n resolveMutationKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationKey`\n },\n resolveMutationArgTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationArg`\n },\n resolveClientName(node) {\n return this.resolveName(node.operationId)\n },\n}))\n","import path from 'node:path'\nimport { camelCase } from '@internals/utils'\nimport { ast, definePlugin, type Group } from '@kubb/core'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mutationKeyTransformer, queryKeyTransformer } from '@internals/tanstack-query'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport { resolverSwr } from './resolvers/resolverSwr.ts'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = definePlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = false,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n mutationKey = mutationKeyTransformer,\n queryKey = queryKeyTransformer,\n paramsCasing,\n client,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n const selectedGenerators =\n options.generators ?? [queryGenerator, mutationGenerator].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))\n\n const groupConfig = group\n ? ({\n ...group,\n name: group.name\n ? group.name\n : (ctx: { group: string }) => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n },\n } satisfies Group)\n : undefined\n\n return {\n name: pluginSwrName,\n options,\n dependencies: [pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverSwr, ...userResolver } : resolverSwr\n\n ctx.setOptions({\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group: groupConfig,\n exclude,\n include,\n override,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n\n for (const gen of selectedGenerators) {\n ctx.addGenerator(gen)\n }\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n\n const root = path.resolve(ctx.config.root, ctx.config.output.path)\n const hasClientPlugin = !!ctx.config.plugins?.some((p) => (p as { name?: string }).name === pluginClientName)\n\n if (client?.bundle && !hasClientPlugin && !clientImportPath) {\n ctx.injectFile({\n baseName: 'client.ts',\n path: path.resolve(root, '.kubb/client.ts'),\n sources: [\n ast.createSource({\n name: 'client',\n nodes: [ast.createText(clientName === 'fetch' ? fetchClientSource : axiosClientSource)],\n isExportable: true,\n isIndexable: true,\n }),\n ],\n })\n }\n\n if (!hasClientPlugin) {\n ctx.injectFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n ast.createSource({\n name: 'config',\n nodes: [ast.createText(configSource)],\n isExportable: false,\n isIndexable: false,\n }),\n ],\n })\n }\n },\n },\n }\n})\n\nexport default pluginSwr\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,SAAS,WAAW,MAAsB;CACxC,OAAO,GAAG,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AACvD;;;;;;;;;AAUA,MAAa,eAAA,GAAA,WAAA,uBAA+C;CAC1D,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;EAClB,OAAOA,mBAAAA,UAAU,MAAM,EAAE,QAAQ,SAAS,OAAO,CAAC;CACpD;CACA,YAAY,MAAM;EAChB,OAAO,KAAK,QAAQ,MAAM,UAAU;CACtC;CACA,gBAAgB,MAAM,MAAM;EAC1B,OAAO,KAAK,QAAQ,MAAM,IAAI;CAChC;CACA,i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CAAC,IAAI,OAAO,SAAS,MAAM,MAAO,EAAwB,SAASC,oBAAAA,gBAAgB;GAE5G,IAAI,QAAQ,UAAU,CAAC,mBAAmB,CAAC,kBACzC,IAAI,WAAW;IACb,UAAU;IACV,MAAMD,UAAAA,QAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACPE,WAAAA,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAACA,WAAAA,IAAI,WAAW,eAAe,UAAUC,mDAAAA,SAAoBC,mDAAAA,MAAiB,CAAC;KACtF,cAAc;KACd,aAAa;IACf,CAAC,CACH;GACF,CAAC;GAGH,IAAI,CAAC,iBACH,IAAI,WAAW;IACb,UAAU;IACV,MAAMJ,UAAAA,QAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACPE,WAAAA,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAACA,WAAAA,IAAI,WAAWG,4CAAAA,MAAY,CAAC;KACpC,cAAc;KACd,aAAa;IACf,CAAC,CACH;GACF,CAAC;EAEL,EACF;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["camelCase","camelCase","camelCase","mutationKeyTransformer","queryKeyTransformer","queryGenerator","mutationGenerator","pluginTsName","pluginZodName","path","pluginClientName","ast","fetchClientSource","axiosClientSource","configSource"],"sources":["../../../internals/utils/src/fs.ts","../../../internals/shared/src/group.ts","../src/resolvers/resolverSwr.ts","../src/plugin.ts"],"sourcesContent":["import { posix } from 'node:path'\nimport { camelCase } from './casing.ts'\n\nfunction toSlash(p: string): string {\n if (p.startsWith('\\\\\\\\?\\\\')) return p\n return p.replaceAll('\\\\', '/')\n}\n\n/**\n * Returns the relative path from `rootDir` to `filePath`, always using forward slashes\n * and prefixed with `./` when not already traversing upward.\n *\n * @example\n * ```ts\n * getRelativePath('/src/components', '/src/components/Button.tsx') // './Button.tsx'\n * getRelativePath('/src/components', '/src/utils/helpers.ts') // '../utils/helpers.ts'\n * ```\n */\nexport function getRelativePath(rootDir?: string | null, filePath?: string | null): string {\n if (!rootDir || !filePath) {\n throw new Error(`Root and file should be filled in when retrieving the relativePath, ${rootDir || ''} ${filePath || ''}`)\n }\n\n const relativePath = posix.relative(toSlash(rootDir), toSlash(filePath))\n\n return relativePath.startsWith('../') ? relativePath : `./${relativePath}`\n}\n\n/**\n * Builds a nested file path from a dotted name. Splits on dots that precede a letter\n * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases\n * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.\n *\n * Empty segments are dropped before joining. They arise when the name starts with a dot\n * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to\n * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an\n * absolute path, letting generated files escape the configured output directory.\n *\n * @example Nested path from a dotted name\n * `toFilePath('pet.petId') // 'pet/petId'`\n *\n * @example PascalCase the final segment\n * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`\n *\n * @example Suffix applied to the final segment only\n * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`\n */\nexport function toFilePath(name: string, caseLast: (part: string) => string = camelCase): string {\n const parts = name.split(/\\.(?=[a-zA-Z])/)\n return parts\n .map((part, i) => (i === parts.length - 1 ? caseLast(part) : camelCase(part)))\n .filter(Boolean)\n .join('/')\n}\n","import { camelCase } from '@internals/utils'\nimport type { Group } from '@kubb/core'\n\n/**\n * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the\n * shared default naming so every plugin groups output consistently:\n *\n * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).\n * - other groups use the camelCased group (`pet store` → `petStore`).\n *\n * A user-provided `group.name` always wins over the default namer, so callers stay in\n * control of their output folders. Returns `null` when grouping is disabled, matching the\n * per-plugin convention.\n *\n * @param group - The user-supplied group option, or `undefined` to disable grouping.\n *\n * @example\n * ```ts\n * createGroupConfig(group) // shared across every plugin\n * ```\n */\nexport function createGroupConfig(group: Group | undefined): Group | null {\n if (!group) {\n return null\n }\n\n const defaultName = (ctx: { group: string }): string => {\n if (group.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n\n return camelCase(ctx.group)\n }\n\n return {\n ...group,\n name: group.name ? group.name : defaultName,\n } satisfies Group\n}\n","import { camelCase, toFilePath } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginSwr } from '../types.ts'\n\nfunction capitalize(name: string): string {\n return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\n/**\n * Naming convention resolver for the SWR plugin.\n *\n * Provides default naming helpers using camelCase for functions and file paths.\n *\n * @example\n * `resolverSwr.default('list pets', 'function') // → 'listPets'`\n */\nexport const resolverSwr = defineResolver<PluginSwr>(() => ({\n name: 'default',\n pluginName: 'plugin-swr',\n default(name, type) {\n return type === 'file' ? toFilePath(name) : camelCase(name)\n },\n resolveName(name) {\n return this.default(name, 'function')\n },\n resolvePathName(name, type) {\n return this.default(name, type)\n },\n resolveQueryName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveMutationName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}`\n },\n resolveQueryOptionsName(node) {\n return `${this.resolveName(node.operationId)}QueryOptions`\n },\n resolveQueryKeyName(node) {\n return `${this.resolveName(node.operationId)}QueryKey`\n },\n resolveMutationKeyName(node) {\n return `${this.resolveName(node.operationId)}MutationKey`\n },\n resolveQueryKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}QueryKey`\n },\n resolveMutationKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationKey`\n },\n resolveMutationArgTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}MutationArg`\n },\n resolveClientName(node) {\n return this.resolveName(node.operationId)\n },\n}))\n","import path from 'node:path'\nimport { createGroupConfig } from '@internals/shared'\nimport { ast, definePlugin } from '@kubb/core'\nimport { isParserEnabled, pluginClientName } from '@kubb/plugin-client'\nimport { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'\nimport { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'\nimport { source as configSource } from '@kubb/plugin-client/templates/config.source'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { mutationKeyTransformer, queryKeyTransformer } from '@internals/tanstack-query'\nimport { mutationGenerator, queryGenerator } from './generators'\nimport { resolverSwr } from './resolvers/resolverSwr.ts'\nimport type { PluginSwr } from './types.ts'\n\nexport const pluginSwrName = 'plugin-swr' satisfies PluginSwr['name']\n\nexport const pluginSwr = definePlugin<PluginSwr>((options) => {\n const {\n output = { path: 'hooks', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n parser = false,\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n mutationKey = mutationKeyTransformer,\n queryKey = queryKeyTransformer,\n paramsCasing,\n client,\n resolver: userResolver,\n transformer: userTransformer,\n generators: userGenerators = [],\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n const selectedGenerators =\n options.generators ?? [queryGenerator, mutationGenerator].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))\n\n const groupConfig = createGroupConfig(group) ?? undefined\n\n return {\n name: pluginSwrName,\n options,\n dependencies: [pluginTsName, isParserEnabled(parser) ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverSwr, ...userResolver } : resolverSwr\n\n ctx.setOptions({\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n importPath: clientImportPath,\n dataReturnType: client?.dataReturnType ?? 'data',\n paramsCasing,\n },\n queryKey,\n query:\n query === false\n ? false\n : {\n importPath: 'swr',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: 'swr/mutation',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutation,\n },\n parser,\n paramsType,\n pathParamsType,\n paramsCasing,\n group: groupConfig,\n exclude,\n include,\n override,\n resolver,\n })\n ctx.setResolver(resolver)\n if (userTransformer) {\n ctx.setTransformer(userTransformer)\n }\n\n for (const gen of selectedGenerators) {\n ctx.addGenerator(gen)\n }\n for (const gen of userGenerators) {\n ctx.addGenerator(gen)\n }\n\n const root = path.resolve(ctx.config.root, ctx.config.output.path)\n const hasClientPlugin = !!ctx.config.plugins?.some((p) => (p as { name?: string }).name === pluginClientName)\n\n if (client?.bundle && !hasClientPlugin && !clientImportPath) {\n ctx.injectFile({\n baseName: 'client.ts',\n path: path.resolve(root, '.kubb/client.ts'),\n sources: [\n ast.createSource({\n name: 'client',\n nodes: [ast.createText(clientName === 'fetch' ? fetchClientSource : axiosClientSource)],\n isExportable: true,\n isIndexable: true,\n }),\n ],\n })\n }\n\n if (!hasClientPlugin) {\n ctx.injectFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n ast.createSource({\n name: 'config',\n nodes: [ast.createText(configSource)],\n isExportable: false,\n isIndexable: false,\n }),\n ],\n })\n }\n },\n },\n }\n})\n\nexport default pluginSwr\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,WAAW,MAAc,WAAqCA,mBAAAA,WAAmB;CAC/F,MAAM,QAAQ,KAAK,MAAM,gBAAgB;CACzC,OAAO,MACJ,KAAK,MAAM,MAAO,MAAM,MAAM,SAAS,IAAI,SAAS,IAAI,IAAIA,mBAAAA,UAAU,IAAI,CAAE,CAAC,CAC7E,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;AACb;;;;;;;;;;;;;;;;;;;;;AChCA,SAAgB,kBAAkB,OAAwC;CACxE,IAAI,CAAC,OACH,OAAO;CAGT,MAAM,eAAe,QAAmC;EACtD,I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
2
- import { i as Transformer, n as PluginSwr, t as Options } from "./types-BoANASs2.js";
2
+ import { i as Transformer, n as PluginSwr, t as Options } from "./types-Dz_j0Bqv.js";
3
3
 
4
4
  //#region src/plugin.d.ts
5
5
  declare const pluginSwrName = "plugin-swr";
package/dist/index.js CHANGED
@@ -1,14 +1,70 @@
1
1
  import "./chunk-C0LytTxp.js";
2
- import { l as mutationKeyTransformer, o as queryKeyTransformer, u as camelCase } from "./components-BuLagnaM.js";
3
- import { n as mutationGenerator, t as queryGenerator } from "./generators-bnwHiUqJ.js";
2
+ import { c as mutationKeyTransformer, o as queryKeyTransformer, u as camelCase } from "./components-CR9NLFcO.js";
3
+ import { n as mutationGenerator, t as queryGenerator } from "./generators-BB6csINY.js";
4
4
  import path from "node:path";
5
5
  import { ast, definePlugin, defineResolver } from "@kubb/core";
6
- import { pluginClientName } from "@kubb/plugin-client";
6
+ import { isParserEnabled, pluginClientName } from "@kubb/plugin-client";
7
7
  import { source } from "@kubb/plugin-client/templates/clients/axios.source";
8
8
  import { source as source$1 } from "@kubb/plugin-client/templates/clients/fetch.source";
9
9
  import { source as source$2 } from "@kubb/plugin-client/templates/config.source";
10
10
  import { pluginTsName } from "@kubb/plugin-ts";
11
11
  import { pluginZodName } from "@kubb/plugin-zod";
12
+ //#region ../../internals/utils/src/fs.ts
13
+ /**
14
+ * Builds a nested file path from a dotted name. Splits on dots that precede a letter
15
+ * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases
16
+ * every earlier segment, applies `caseLast` to the final segment, and joins with `/`.
17
+ *
18
+ * Empty segments are dropped before joining. They arise when the name starts with a dot
19
+ * followed by a letter (e.g. `..Schema` splits into `['..', 'Schema']` and `'..'` cases to
20
+ * an empty string). Without this a leading `/` would form, which `path.resolve` reads as an
21
+ * absolute path, letting generated files escape the configured output directory.
22
+ *
23
+ * @example Nested path from a dotted name
24
+ * `toFilePath('pet.petId') // 'pet/petId'`
25
+ *
26
+ * @example PascalCase the final segment
27
+ * `toFilePath('pet.Pet', pascalCase) // 'pet/Pet'`
28
+ *
29
+ * @example Suffix applied to the final segment only
30
+ * `toFilePath('tag.tag', (part) => camelCase(part, { suffix: 'schema' })) // 'tag/tagSchema'`
31
+ */
32
+ function toFilePath(name, caseLast = camelCase) {
33
+ const parts = name.split(/\.(?=[a-zA-Z])/);
34
+ return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
35
+ }
36
+ //#endregion
37
+ //#region ../../internals/shared/src/group.ts
38
+ /**
39
+ * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
40
+ * shared default naming so every plugin groups output consistently:
41
+ *
42
+ * - `path` groups use the second path segment (`/pet/findByStatus` → `pet`).
43
+ * - other groups use the camelCased group (`pet store` → `petStore`).
44
+ *
45
+ * A user-provided `group.name` always wins over the default namer, so callers stay in
46
+ * control of their output folders. Returns `null` when grouping is disabled, matching the
47
+ * per-plugin convention.
48
+ *
49
+ * @param group - The user-supplied group option, or `undefined` to disable grouping.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * createGroupConfig(group) // shared across every plugin
54
+ * ```
55
+ */
56
+ function createGroupConfig(group) {
57
+ if (!group) return null;
58
+ const defaultName = (ctx) => {
59
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
60
+ return camelCase(ctx.group);
61
+ };
62
+ return {
63
+ ...group,
64
+ name: group.name ? group.name : defaultName
65
+ };
66
+ }
67
+ //#endregion
12
68
  //#region src/resolvers/resolverSwr.ts
13
69
  function capitalize(name) {
14
70
  return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
@@ -25,7 +81,7 @@ const resolverSwr = defineResolver(() => ({
25
81
  name: "default",
26
82
  pluginName: "plugin-swr",
27
83
  default(name, type) {
28
- return camelCase(name, { isFile: type === "file" });
84
+ return type === "file" ? toFilePath(name) : camelCase(name);
29
85
  },
30
86
  resolveName(name) {
31
87
  return this.default(name, "function");
@@ -67,22 +123,16 @@ const pluginSwrName = "plugin-swr";
67
123
  const pluginSwr = definePlugin((options) => {
68
124
  const { output = {
69
125
  path: "hooks",
70
- barrelType: "named"
126
+ barrel: { type: "named" }
71
127
  }, group, exclude = [], include, override = [], parser = false, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", mutation = {}, query = {}, mutationKey = mutationKeyTransformer, queryKey = queryKeyTransformer, paramsCasing, client, resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
72
128
  const clientName = client?.client ?? "axios";
73
129
  const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
74
130
  const selectedGenerators = options.generators ?? [queryGenerator, mutationGenerator].filter((generator) => Boolean(generator));
75
- const groupConfig = group ? {
76
- ...group,
77
- name: group.name ? group.name : (ctx) => {
78
- if (group.type === "path") return `${ctx.group.split("/")[1]}`;
79
- return `${camelCase(ctx.group)}Controller`;
80
- }
81
- } : void 0;
131
+ const groupConfig = createGroupConfig(group) ?? void 0;
82
132
  return {
83
133
  name: pluginSwrName,
84
134
  options,
85
- dependencies: [pluginTsName, parser === "zod" ? pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
135
+ dependencies: [pluginTsName, isParserEnabled(parser) ? pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
86
136
  hooks: { "kubb:plugin:setup"(ctx) {
87
137
  const resolver = userResolver ? {
88
138
  ...resolverSwr,