@kubb/plugin-vue-query 5.0.0-beta.4 → 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 (43) hide show
  1. package/README.md +39 -22
  2. package/dist/{components-D1UhYFgY.js → components-B79Gljyl.js} +483 -565
  3. package/dist/components-B79Gljyl.js.map +1 -0
  4. package/dist/{components-qfOFRSoM.cjs → components-D3xIZ9FA.cjs} +513 -565
  5. package/dist/components-D3xIZ9FA.cjs.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +4 -68
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-C4gs_P1i.cjs → generators-BTtcGtUY.cjs} +225 -314
  10. package/dist/generators-BTtcGtUY.cjs.map +1 -0
  11. package/dist/generators-D95ddIFV.js +620 -0
  12. package/dist/generators-D95ddIFV.js.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +21 -6
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +158 -25
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +31 -4
  19. package/dist/index.js +160 -27
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-CwabLiFK.d.ts +266 -0
  22. package/package.json +18 -27
  23. package/src/components/InfiniteQuery.tsx +18 -50
  24. package/src/components/InfiniteQueryOptions.tsx +64 -82
  25. package/src/components/Mutation.tsx +35 -44
  26. package/src/components/Query.tsx +18 -51
  27. package/src/components/QueryKey.tsx +9 -61
  28. package/src/components/QueryOptions.tsx +22 -99
  29. package/src/generators/infiniteQueryGenerator.tsx +55 -67
  30. package/src/generators/mutationGenerator.tsx +53 -65
  31. package/src/generators/queryGenerator.tsx +52 -65
  32. package/src/plugin.ts +48 -32
  33. package/src/resolvers/resolverVueQuery.ts +63 -6
  34. package/src/types.ts +132 -60
  35. package/src/utils.ts +45 -25
  36. package/dist/components-D1UhYFgY.js.map +0 -1
  37. package/dist/components-qfOFRSoM.cjs.map +0 -1
  38. package/dist/generators-C4gs_P1i.cjs.map +0 -1
  39. package/dist/generators-CbnIVBgY.js +0 -709
  40. package/dist/generators-CbnIVBgY.js.map +0 -1
  41. package/dist/types-nVDTfuS1.d.ts +0 -194
  42. package/extension.yaml +0 -793
  43. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/dist/index.js CHANGED
@@ -1,56 +1,190 @@
1
- import "./chunk--u3MIqq1.js";
2
- import { c as MutationKey, l as camelCase, o as QueryKey } from "./components-D1UhYFgY.js";
3
- import { n as mutationGenerator, r as infiniteQueryGenerator, t as queryGenerator } from "./generators-CbnIVBgY.js";
1
+ import "./chunk-C0LytTxp.js";
2
+ import { m as camelCase, s as queryKeyTransformer, u as mutationKeyTransformer } from "./components-B79Gljyl.js";
3
+ import { n as mutationGenerator, r as infiniteQueryGenerator, t as queryGenerator } from "./generators-D95ddIFV.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/resolverVueQuery.ts
69
+ function capitalize(name) {
70
+ return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
71
+ }
13
72
  /**
14
- * Naming convention resolver for Vue Query plugin.
73
+ * Default resolver used by `@kubb/plugin-vue-query`. Decides the names and
74
+ * file paths for every generated TanStack Query composable (`useFooQuery`,
75
+ * `useFooMutation`, `useFooInfiniteQuery`) and its companion helpers.
76
+ *
77
+ * Functions and files use camelCase; composables get the `use` prefix.
15
78
  *
16
- * Provides default naming helpers using camelCase for functions and file paths.
79
+ * @example Resolve composable and helper names
80
+ * ```ts
81
+ * import { resolverVueQuery } from '@kubb/plugin-vue-query'
82
+ *
83
+ * resolverVueQuery.resolveQueryName(operationNode) // 'useGetPetById'
84
+ * resolverVueQuery.resolveQueryKeyName(operationNode) // 'getPetByIdQueryKey'
85
+ * resolverVueQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'
86
+ * ```
17
87
  */
18
- const resolverVueQuery = defineResolver((ctx) => ({
88
+ const resolverVueQuery = defineResolver(() => ({
19
89
  name: "default",
20
90
  pluginName: "plugin-vue-query",
21
91
  default(name, type) {
22
- return camelCase(name, { isFile: type === "file" });
92
+ return type === "file" ? toFilePath(name) : camelCase(name);
23
93
  },
24
94
  resolveName(name) {
25
- return ctx.default(name, "function");
95
+ return this.default(name, "function");
96
+ },
97
+ resolvePathName(name, type) {
98
+ return this.default(name, type);
99
+ },
100
+ resolveQueryName(node) {
101
+ return `use${capitalize(this.resolveName(node.operationId))}`;
102
+ },
103
+ resolveInfiniteQueryName(node) {
104
+ return `use${capitalize(this.resolveName(node.operationId))}Infinite`;
105
+ },
106
+ resolveMutationName(node) {
107
+ return `use${capitalize(this.resolveName(node.operationId))}`;
108
+ },
109
+ resolveQueryOptionsName(node) {
110
+ return `${this.resolveName(node.operationId)}QueryOptions`;
111
+ },
112
+ resolveInfiniteQueryOptionsName(node) {
113
+ return `${this.resolveName(node.operationId)}InfiniteQueryOptions`;
114
+ },
115
+ resolveQueryKeyName(node) {
116
+ return `${this.resolveName(node.operationId)}QueryKey`;
117
+ },
118
+ resolveInfiniteQueryKeyName(node) {
119
+ return `${this.resolveName(node.operationId)}InfiniteQueryKey`;
120
+ },
121
+ resolveMutationKeyName(node) {
122
+ return `${this.resolveName(node.operationId)}MutationKey`;
123
+ },
124
+ resolveQueryKeyTypeName(node) {
125
+ return `${capitalize(this.resolveName(node.operationId))}QueryKey`;
126
+ },
127
+ resolveInfiniteQueryKeyTypeName(node) {
128
+ return `${capitalize(this.resolveName(node.operationId))}InfiniteQueryKey`;
129
+ },
130
+ resolveMutationTypeName(node) {
131
+ return capitalize(this.resolveName(node.operationId));
132
+ },
133
+ resolveClientName(node) {
134
+ return this.resolveName(node.operationId);
135
+ },
136
+ resolveInfiniteClientName(node) {
137
+ return `${this.resolveName(node.operationId)}Infinite`;
26
138
  }
27
139
  }));
28
140
  //#endregion
29
141
  //#region src/plugin.ts
142
+ /**
143
+ * Canonical plugin name for `@kubb/plugin-vue-query`. Used for driver lookups
144
+ * and cross-plugin dependency references.
145
+ */
30
146
  const pluginVueQueryName = "plugin-vue-query";
147
+ /**
148
+ * Generates one TanStack Query composable per OpenAPI operation for Vue's
149
+ * Composition API. Queries become `useFooQuery` (and optionally
150
+ * `useFooInfiniteQuery`); mutations become `useFooMutation`. Each composable
151
+ * is fully typed end to end.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { defineConfig } from 'kubb'
156
+ * import { pluginTs } from '@kubb/plugin-ts'
157
+ * import { pluginVueQuery } from '@kubb/plugin-vue-query'
158
+ *
159
+ * export default defineConfig({
160
+ * input: { path: './petStore.yaml' },
161
+ * output: { path: './src/gen' },
162
+ * plugins: [
163
+ * pluginTs(),
164
+ * pluginVueQuery({
165
+ * output: { path: './hooks' },
166
+ * }),
167
+ * ],
168
+ * })
169
+ * ```
170
+ */
31
171
  const pluginVueQuery = definePlugin((options) => {
32
172
  const { output = {
33
173
  path: "hooks",
34
- barrelType: "named"
35
- }, group, exclude = [], include, override = [], parser = "client", infinite = false, transformers = {}, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", mutation = {}, query = {}, mutationKey = MutationKey.getTransformer, queryKey = QueryKey.getTransformer, paramsCasing, client, resolver: userResolver, transformer: userTransformer, generators: userGenerators = [] } = options;
174
+ barrel: { type: "named" }
175
+ }, group, exclude = [], include, override = [], parser = false, infinite = 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;
36
176
  const clientName = client?.client ?? "axios";
37
177
  const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
38
178
  const selectedGenerators = options.generators ?? [
39
179
  queryGenerator,
40
180
  infiniteQueryGenerator,
41
181
  mutationGenerator
42
- ].filter(Boolean);
43
- const groupConfig = group ? {
44
- ...group,
45
- name: group.name ? group.name : (ctx) => {
46
- if (group.type === "path") return `${ctx.group.split("/")[1]}`;
47
- return `${camelCase(ctx.group)}Controller`;
48
- }
49
- } : void 0;
182
+ ].filter((generator) => Boolean(generator));
183
+ const groupConfig = createGroupConfig(group);
50
184
  return {
51
185
  name: pluginVueQueryName,
52
186
  options,
53
- dependencies: [pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
187
+ dependencies: [pluginTsName, isParserEnabled(parser) ? pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
54
188
  hooks: { "kubb:plugin:setup"(ctx) {
55
189
  const resolver = userResolver ? {
56
190
  ...resolverVueQuery,
@@ -58,7 +192,6 @@ const pluginVueQuery = definePlugin((options) => {
58
192
  } : resolverVueQuery;
59
193
  ctx.setOptions({
60
194
  output,
61
- transformers,
62
195
  client: {
63
196
  bundle: client?.bundle,
64
197
  baseURL: client?.baseURL,
@@ -88,9 +221,9 @@ const pluginVueQuery = definePlugin((options) => {
88
221
  infinite: infinite ? {
89
222
  queryParam: "id",
90
223
  initialPageParam: 0,
91
- cursorParam: void 0,
92
- nextParam: void 0,
93
- previousParam: void 0,
224
+ cursorParam: null,
225
+ nextParam: null,
226
+ previousParam: null,
94
227
  ...infinite
95
228
  } : false,
96
229
  parser,
@@ -110,10 +243,10 @@ const pluginVueQuery = definePlugin((options) => {
110
243
  const root = path.resolve(ctx.config.root, ctx.config.output.path);
111
244
  const hasClientPlugin = !!ctx.config.plugins?.some((p) => p.name === pluginClientName);
112
245
  if (client?.bundle && !hasClientPlugin && !clientImportPath) ctx.injectFile({
113
- baseName: "fetch.ts",
114
- path: path.resolve(root, ".kubb/fetch.ts"),
246
+ baseName: "client.ts",
247
+ path: path.resolve(root, ".kubb/client.ts"),
115
248
  sources: [ast.createSource({
116
- name: "fetch",
249
+ name: "client",
117
250
  nodes: [ast.createText(clientName === "fetch" ? source$1 : source)],
118
251
  isExportable: true,
119
252
  isIndexable: true
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../src/resolvers/resolverVueQuery.ts","../src/plugin.ts"],"sourcesContent":["import { camelCase } from '@internals/utils'\nimport { defineResolver } from '@kubb/core'\nimport type { PluginVueQuery } from '../types.ts'\n\n/**\n * Naming convention resolver for Vue Query plugin.\n *\n * Provides default naming helpers using camelCase for functions and file paths.\n */\nexport const resolverVueQuery = defineResolver<PluginVueQuery>((ctx) => ({\n name: 'default',\n pluginName: 'plugin-vue-query',\n default(name, type) {\n return camelCase(name, { isFile: type === 'file' })\n },\n resolveName(name) {\n return ctx.default(name, 'function')\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 { MutationKey } from './components/MutationKey.tsx'\nimport { QueryKey } from './components/QueryKey.tsx'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport { resolverVueQuery } from './resolvers/resolverVueQuery.ts'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\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 = options.generators ?? [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean)\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: pluginVueQueryName,\n options,\n dependencies: [pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n hooks: {\n 'kubb:plugin:setup'(ctx) {\n const resolver = userResolver ? { ...resolverVueQuery, ...userResolver } : resolverVueQuery\n\n ctx.setOptions({\n output,\n transformers,\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: '@tanstack/vue-query',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: '@tanstack/vue-query',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutation,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n nextParam: undefined,\n previousParam: undefined,\n ...infinite,\n }\n : false,\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: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n ast.createSource({\n name: 'fetch',\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 pluginVueQuery\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,mBAAmB,gBAAgC,SAAS;CACvE,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;AAClB,SAAO,UAAU,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;CAErD,YAAY,MAAM;AAChB,SAAO,IAAI,QAAQ,MAAM,WAAW;;CAEvC,EAAE;;;ACHH,MAAa,qBAAqB;AAElC,MAAa,iBAAiB,cAA8B,YAAY;CACtE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAA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;KACE,YAAY;KACZ,kBAAkB;KAClB,aAAa,KAAA;KACb,WAAW,KAAA;KACX,eAAe,KAAA;KACf,GAAG;KACJ,GACD;IACJ;IACA;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;IACD,CAAC;AACF,OAAI,YAAY,SAAS;AACzB,OAAI,gBACF,KAAI,eAAe,gBAAgB;AAGrC,QAAK,MAAM,OAAO,mBAChB,KAAI,aAAa,IAAI;AAEvB,QAAK,MAAM,OAAO,eAChB,KAAI,aAAa,IAAI;GAGvB,MAAM,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,KAAK;GAClE,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,SAAS,MAAM,MAAO,EAAwB,SAAS,iBAAiB;AAE7G,OAAI,QAAQ,UAAU,CAAC,mBAAmB,CAAC,iBACzC,KAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAW,eAAe,UAAUA,WAAoBC,OAAkB,CAAC;KACvF,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC;AAGJ,OAAI,CAAC,gBACH,KAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAWC,SAAa,CAAC;KACrC,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC;KAGP;EACF;EACD"}
1
+ {"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"sources":["../../../internals/utils/src/fs.ts","../../../internals/shared/src/group.ts","../src/resolvers/resolverVueQuery.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 { PluginVueQuery } from '../types.ts'\n\nfunction capitalize(name: string): string {\n return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\n\n/**\n * Default resolver used by `@kubb/plugin-vue-query`. Decides the names and\n * file paths for every generated TanStack Query composable (`useFooQuery`,\n * `useFooMutation`, `useFooInfiniteQuery`) and its companion helpers.\n *\n * Functions and files use camelCase; composables get the `use` prefix.\n *\n * @example Resolve composable and helper names\n * ```ts\n * import { resolverVueQuery } from '@kubb/plugin-vue-query'\n *\n * resolverVueQuery.resolveQueryName(operationNode) // 'useGetPetById'\n * resolverVueQuery.resolveQueryKeyName(operationNode) // 'getPetByIdQueryKey'\n * resolverVueQuery.resolveQueryOptionsName(operationNode) // 'getPetByIdQueryOptions'\n * ```\n */\nexport const resolverVueQuery = defineResolver<PluginVueQuery>(() => ({\n name: 'default',\n pluginName: 'plugin-vue-query',\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 resolveInfiniteQueryName(node) {\n return `use${capitalize(this.resolveName(node.operationId))}Infinite`\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 resolveInfiniteQueryOptionsName(node) {\n return `${this.resolveName(node.operationId)}InfiniteQueryOptions`\n },\n resolveQueryKeyName(node) {\n return `${this.resolveName(node.operationId)}QueryKey`\n },\n resolveInfiniteQueryKeyName(node) {\n return `${this.resolveName(node.operationId)}InfiniteQueryKey`\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 resolveInfiniteQueryKeyTypeName(node) {\n return `${capitalize(this.resolveName(node.operationId))}InfiniteQueryKey`\n },\n resolveMutationTypeName(node) {\n return capitalize(this.resolveName(node.operationId))\n },\n resolveClientName(node) {\n return this.resolveName(node.operationId)\n },\n resolveInfiniteClientName(node) {\n return `${this.resolveName(node.operationId)}Infinite`\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 } from '@internals/tanstack-query'\nimport { queryKeyTransformer } from '@internals/tanstack-query'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport { resolverVueQuery } from './resolvers/resolverVueQuery.ts'\nimport type { PluginVueQuery } from './types.ts'\n\n/**\n * Canonical plugin name for `@kubb/plugin-vue-query`. Used for driver lookups\n * and cross-plugin dependency references.\n */\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\n/**\n * Generates one TanStack Query composable per OpenAPI operation for Vue's\n * Composition API. Queries become `useFooQuery` (and optionally\n * `useFooInfiniteQuery`); mutations become `useFooMutation`. Each composable\n * is fully typed end to end.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { pluginTs } from '@kubb/plugin-ts'\n * import { pluginVueQuery } from '@kubb/plugin-vue-query'\n *\n * export default defineConfig({\n * input: { path: './petStore.yaml' },\n * output: { path: './src/gen' },\n * plugins: [\n * pluginTs(),\n * pluginVueQuery({\n * output: { path: './hooks' },\n * }),\n * ],\n * })\n * ```\n */\nexport const pluginVueQuery = definePlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrel: { type: 'named' } },\n group,\n exclude = [],\n include,\n override = [],\n parser = false,\n infinite = 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 ??\n [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))\n\n const groupConfig = createGroupConfig(group)\n\n return {\n name: pluginVueQueryName,\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 ? { ...resolverVueQuery, ...userResolver } : resolverVueQuery\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: '@tanstack/vue-query',\n methods: ['get'],\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n importPath: '@tanstack/vue-query',\n methods: ['post', 'put', 'patch', 'delete'],\n ...mutation,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: null,\n nextParam: null,\n previousParam: null,\n ...infinite,\n }\n : false,\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 pluginVueQuery\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,WAAW,MAAc,WAAqC,WAAmB;CAC/F,MAAM,QAAQ,KAAK,MAAM,gBAAgB;CACzC,OAAO,MACJ,KAAK,MAAM,MAAO,MAAM,MAAM,SAAS,IAAI,SAAS,IAAI,IAAI,UAAU,IAAI,CAAE,CAAC,CAC7E,OAAO,OAAO,CAAC,CAC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aAAa;IACf,CAAC,CACH;GACF,CAAC;GAGH,IAAI,CAAC,iBACH,IAAI,WAAW;IACb,UAAU;IACV,MAAM,KAAK,QAAQ,MAAM,iBAAiB;IAC1C,SAAS,CACP,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAAC,IAAI,WAAWC,QAAY,CAAC;KACpC,cAAc;KACd,aAAa;IACf,CAAC,CACH;GACF,CAAC;EAEL,EACF;CACF;AACF,CAAC"}
@@ -0,0 +1,266 @@
1
+ import { t as __name } from "./chunk-C0LytTxp.js";
2
+ import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
+ import { ClientImportPath, PluginClient } from "@kubb/plugin-client";
4
+
5
+ //#region src/types.d.ts
6
+ type Transformer = (props: {
7
+ node: ast.OperationNode;
8
+ casing: 'camelcase' | undefined;
9
+ }) => Array<unknown>;
10
+ /**
11
+ * Resolver for Vue Query that provides naming methods for hook functions.
12
+ */
13
+ type ResolverVueQuery = Resolver & {
14
+ /**
15
+ * Resolves the base function name for an operation.
16
+ */
17
+ resolveName(this: ResolverVueQuery, name: string): string;
18
+ /**
19
+ * Resolves the output file name for a hook module.
20
+ */
21
+ resolvePathName(this: ResolverVueQuery, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
22
+ /**
23
+ * Resolves a query hook function name.
24
+ */
25
+ resolveQueryName(this: ResolverVueQuery, node: ast.OperationNode): string;
26
+ /**
27
+ * Resolves an infinite query hook function name.
28
+ */
29
+ resolveInfiniteQueryName(this: ResolverVueQuery, node: ast.OperationNode): string;
30
+ /**
31
+ * Resolves a mutation hook function name.
32
+ */
33
+ resolveMutationName(this: ResolverVueQuery, node: ast.OperationNode): string;
34
+ /**
35
+ * Resolves the query options helper name.
36
+ */
37
+ resolveQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string;
38
+ /**
39
+ * Resolves the infinite query options helper name.
40
+ */
41
+ resolveInfiniteQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string;
42
+ /**
43
+ * Resolves the query key helper name.
44
+ */
45
+ resolveQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
46
+ /**
47
+ * Resolves the infinite query key helper name.
48
+ */
49
+ resolveInfiniteQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
50
+ /**
51
+ * Resolves the mutation key helper name.
52
+ */
53
+ resolveMutationKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
54
+ /**
55
+ * Resolves the query key type name.
56
+ */
57
+ resolveQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
58
+ /**
59
+ * Resolves the infinite query key type name.
60
+ */
61
+ resolveInfiniteQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
62
+ /**
63
+ * Resolves the mutation type name.
64
+ */
65
+ resolveMutationTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
66
+ /**
67
+ * Resolves the client function name generated inline by query hooks.
68
+ */
69
+ resolveClientName(this: ResolverVueQuery, node: ast.OperationNode): string;
70
+ /**
71
+ * Resolves the client function name generated inline by infinite query hooks.
72
+ */
73
+ resolveInfiniteClientName(this: ResolverVueQuery, node: ast.OperationNode): string;
74
+ };
75
+ /**
76
+ * Builds the `queryKey` used by each generated query composable.
77
+ *
78
+ * @note String values are inlined verbatim into generated code. Wrap literal
79
+ * strings in `JSON.stringify(...)`.
80
+ */
81
+ type QueryKey = Transformer;
82
+ /**
83
+ * Builds the `mutationKey` used by each generated mutation composable.
84
+ *
85
+ * @note String values are inlined verbatim into generated code. Wrap literal
86
+ * strings in `JSON.stringify(...)`.
87
+ */
88
+ type MutationKey = Transformer;
89
+ type Query = {
90
+ /**
91
+ * HTTP methods treated as queries.
92
+ *
93
+ * @default ['get']
94
+ */
95
+ methods?: Array<string>;
96
+ /**
97
+ * Module specifier used in the `import { useQuery } from '...'` statement at
98
+ * the top of every generated composable file.
99
+ *
100
+ * @default '@tanstack/vue-query'
101
+ */
102
+ importPath?: string;
103
+ };
104
+ type Mutation = {
105
+ /**
106
+ * HTTP methods treated as mutations.
107
+ *
108
+ * @default ['post', 'put', 'delete']
109
+ */
110
+ methods?: Array<string>;
111
+ /**
112
+ * Module specifier used in the `import { useMutation } from '...'` statement
113
+ * at the top of every generated composable file.
114
+ *
115
+ * @default '@tanstack/vue-query'
116
+ */
117
+ importPath?: string;
118
+ };
119
+ type Infinite = {
120
+ /**
121
+ * Name of the query parameter that holds the page cursor.
122
+ *
123
+ * @default 'id'
124
+ */
125
+ queryParam?: string;
126
+ /**
127
+ * Path to the cursor field on the response. Leave undefined when the cursor
128
+ * is not known.
129
+ *
130
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
131
+ */
132
+ cursorParam?: string | null;
133
+ /**
134
+ * Path to the next-page cursor on the response. Supports dot notation
135
+ * (`'pagination.next.id'`) or array form.
136
+ */
137
+ nextParam?: string | Array<string> | null;
138
+ /**
139
+ * Path to the previous-page cursor on the response. Supports dot notation
140
+ * or array form.
141
+ */
142
+ previousParam?: string | Array<string> | null;
143
+ /**
144
+ * Initial value for `pageParam` on the first fetch.
145
+ *
146
+ * @default 0
147
+ */
148
+ initialPageParam?: unknown;
149
+ };
150
+ /**
151
+ * Where the generated composables are written and how they are exported, plus the optional
152
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
153
+ *
154
+ * @default { path: 'hooks', barrel: { type: 'named' } }
155
+ */
156
+ type Options = OutputOptions & {
157
+ /**
158
+ * HTTP client used inside every generated composable. Mirrors a subset of
159
+ * `pluginClient` options.
160
+ */
161
+ client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
162
+ /**
163
+ * Skip operations matching at least one entry in the list.
164
+ */
165
+ exclude?: Array<Exclude>;
166
+ /**
167
+ * Restrict generation to operations matching at least one entry in the list.
168
+ */
169
+ include?: Array<Include>;
170
+ /**
171
+ * Apply a different options object to operations matching a pattern.
172
+ */
173
+ override?: Array<Override<ResolvedOptions>>;
174
+ /**
175
+ * Rename parameter properties in the generated composables.
176
+ *
177
+ * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
178
+ */
179
+ paramsCasing?: 'camelcase';
180
+ /**
181
+ * How operation parameters appear in the generated composable signature.
182
+ *
183
+ * @default 'inline'
184
+ */
185
+ paramsType?: 'object' | 'inline';
186
+ /**
187
+ * How URL path parameters are arranged inside the inline argument list.
188
+ *
189
+ * @default 'inline'
190
+ */
191
+ pathParamsType?: PluginClient['options']['pathParamsType'];
192
+ /**
193
+ * Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
194
+ * Pass an object to configure how the cursor is read; pass `false` to skip.
195
+ *
196
+ * @default false
197
+ */
198
+ infinite?: Partial<Infinite> | false;
199
+ /**
200
+ * Custom `queryKey` builder.
201
+ */
202
+ queryKey?: QueryKey;
203
+ /**
204
+ * Configures query composables. Set to `false` to skip composable generation
205
+ * and emit only `queryOptions(...)` helpers.
206
+ */
207
+ query?: Partial<Query> | false;
208
+ /**
209
+ * Custom `mutationKey` builder.
210
+ */
211
+ mutationKey?: MutationKey;
212
+ /**
213
+ * Configures mutation composables. Set to `false` to skip mutation generation.
214
+ */
215
+ mutation?: Partial<Mutation> | false;
216
+ /**
217
+ * Validator applied to response bodies before they reach the caller.
218
+ * - `'client'` — no validation.
219
+ * - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
220
+ */
221
+ parser?: PluginClient['options']['parser'];
222
+ /**
223
+ * Override how composable names and file paths are built.
224
+ */
225
+ resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>;
226
+ /**
227
+ * AST visitor applied to each operation node before printing.
228
+ */
229
+ transformer?: ast.Visitor;
230
+ /**
231
+ * Custom generators that run alongside the built-in Vue Query generators.
232
+ */
233
+ generators?: Array<Generator<PluginVueQuery>>;
234
+ };
235
+ type ResolvedOptions = {
236
+ output: Output;
237
+ group: Group | null;
238
+ exclude: NonNullable<Options['exclude']>;
239
+ include: Options['include'];
240
+ override: NonNullable<Options['override']>;
241
+ client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
242
+ parser: NonNullable<Options['parser']>;
243
+ pathParamsType: NonNullable<Options['pathParamsType']>;
244
+ paramsCasing: Options['paramsCasing'];
245
+ paramsType: NonNullable<Options['paramsType']>;
246
+ /**
247
+ * Only used for infinite
248
+ */
249
+ infinite: NonNullable<Infinite> | false;
250
+ queryKey: QueryKey | null;
251
+ query: NonNullable<Required<Query>> | false;
252
+ mutationKey: MutationKey | null;
253
+ mutation: NonNullable<Required<Mutation>> | false;
254
+ resolver: ResolverVueQuery;
255
+ };
256
+ type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
257
+ declare global {
258
+ namespace Kubb {
259
+ interface PluginRegistry {
260
+ 'plugin-vue-query': PluginVueQuery;
261
+ }
262
+ }
263
+ }
264
+ //#endregion
265
+ export { Transformer as i, Options as n, PluginVueQuery as r, Infinite as t };
266
+ //# sourceMappingURL=types-CwabLiFK.d.ts.map
package/package.json CHANGED
@@ -1,26 +1,23 @@
1
1
  {
2
2
  "name": "@kubb/plugin-vue-query",
3
- "version": "5.0.0-beta.4",
4
- "description": "Vue Query hooks generator plugin for Kubb, creating type-safe API client hooks from OpenAPI specifications for Vue.js applications.",
3
+ "version": "5.0.0-beta.56",
4
+ "description": "Generate type-safe TanStack Query (Vue Query) composables from your OpenAPI specification. Covers useQuery, useMutation, useInfiniteQuery, and queryOptions with Vue 3 Composition API support.",
5
5
  "keywords": [
6
- "api-client",
7
- "code-generator",
6
+ "code-generation",
8
7
  "codegen",
9
8
  "composables",
9
+ "composition-api",
10
10
  "data-fetching",
11
- "hooks",
12
11
  "kubb",
13
- "oas",
14
12
  "openapi",
15
- "plugins",
16
- "sdk-generator",
17
13
  "swagger",
14
+ "tanstack",
18
15
  "tanstack-query",
19
- "type-safe",
20
16
  "typescript",
17
+ "use-mutation",
18
+ "use-query",
21
19
  "vue",
22
20
  "vue-query",
23
- "vue.js",
24
21
  "vue3"
25
22
  ],
26
23
  "license": "MIT",
@@ -33,7 +30,6 @@
33
30
  "files": [
34
31
  "src",
35
32
  "dist",
36
- "extension.yaml",
37
33
  "!/**/**.test.**",
38
34
  "!/**/__tests__/**",
39
35
  "!/**/__snapshots__/**"
@@ -73,37 +69,32 @@
73
69
  "registry": "https://registry.npmjs.org/"
74
70
  },
75
71
  "dependencies": {
76
- "@kubb/core": "5.0.0-beta.4",
77
- "@kubb/renderer-jsx": "5.0.0-beta.4",
78
- "remeda": "^2.34.0",
79
- "@kubb/plugin-client": "5.0.0-beta.4",
80
- "@kubb/plugin-ts": "5.0.0-beta.4",
81
- "@kubb/plugin-zod": "5.0.0-beta.4"
72
+ "@kubb/ast": "5.0.0-beta.55",
73
+ "@kubb/core": "5.0.0-beta.55",
74
+ "@kubb/renderer-jsx": "5.0.0-beta.55",
75
+ "@kubb/plugin-client": "5.0.0-beta.56",
76
+ "@kubb/plugin-ts": "5.0.0-beta.56",
77
+ "@kubb/plugin-zod": "5.0.0-beta.56"
82
78
  },
83
79
  "devDependencies": {
80
+ "@internals/shared": "0.0.0",
84
81
  "@internals/tanstack-query": "0.0.0",
85
82
  "@internals/utils": "0.0.0"
86
83
  },
87
84
  "peerDependencies": {
88
- "@kubb/renderer-jsx": "5.0.0-beta.4"
85
+ "@kubb/renderer-jsx": "5.0.0-beta.55"
89
86
  },
90
- "size-limit": [
91
- {
92
- "path": "./dist/*.js",
93
- "limit": "510 KiB",
94
- "gzip": true
95
- }
96
- ],
97
87
  "engines": {
98
88
  "node": ">=22"
99
89
  },
100
90
  "scripts": {
101
- "build": "tsdown && size-limit",
102
- "clean": "npx rimraf ./dist",
91
+ "build": "tsdown",
92
+ "clean": "node -e \"require('node:fs').rmSync('./dist', {recursive:true,force:true})\"",
103
93
  "lint": "oxlint .",
104
94
  "lint:fix": "oxlint --fix .",
105
95
  "release": "pnpm publish --no-git-check",
106
96
  "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
97
+ "release:stage": "pnpm stage publish --no-git-check",
107
98
  "start": "tsdown --watch",
108
99
  "test": "vitest --passWithNoTests",
109
100
  "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"