@kubb/plugin-vue-query 5.0.0-alpha.9 → 5.0.0-beta.10

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 (47) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +26 -7
  3. package/dist/components-B6jAb2as.js +1150 -0
  4. package/dist/components-B6jAb2as.js.map +1 -0
  5. package/dist/components-X0P-3W2G.cjs +1264 -0
  6. package/dist/components-X0P-3W2G.cjs.map +1 -0
  7. package/dist/components.cjs +1 -1
  8. package/dist/components.d.ts +66 -121
  9. package/dist/components.js +1 -1
  10. package/dist/generators-B33PbKzu.js +681 -0
  11. package/dist/generators-B33PbKzu.js.map +1 -0
  12. package/dist/generators-BE3KD0IR.cjs +698 -0
  13. package/dist/generators-BE3KD0IR.cjs.map +1 -0
  14. package/dist/generators.cjs +1 -1
  15. package/dist/generators.d.ts +5 -501
  16. package/dist/generators.js +1 -1
  17. package/dist/index.cjs +150 -121
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +146 -121
  21. package/dist/index.js.map +1 -1
  22. package/dist/types-Bkm7bWT3.d.ts +243 -0
  23. package/extension.yaml +732 -0
  24. package/package.json +60 -65
  25. package/src/components/InfiniteQuery.tsx +71 -159
  26. package/src/components/InfiniteQueryOptions.tsx +115 -163
  27. package/src/components/Mutation.tsx +97 -134
  28. package/src/components/Query.tsx +68 -157
  29. package/src/components/QueryKey.tsx +23 -66
  30. package/src/components/QueryOptions.tsx +92 -143
  31. package/src/generators/infiniteQueryGenerator.tsx +152 -171
  32. package/src/generators/mutationGenerator.tsx +102 -125
  33. package/src/generators/queryGenerator.tsx +125 -137
  34. package/src/index.ts +1 -1
  35. package/src/plugin.ts +126 -177
  36. package/src/resolvers/resolverVueQuery.ts +65 -0
  37. package/src/types.ts +121 -52
  38. package/src/utils.ts +49 -0
  39. package/dist/components-Yjoe78Y7.cjs +0 -1119
  40. package/dist/components-Yjoe78Y7.cjs.map +0 -1
  41. package/dist/components-_AMBl0g-.js +0 -1029
  42. package/dist/components-_AMBl0g-.js.map +0 -1
  43. package/dist/generators-CR34GjVu.js +0 -661
  44. package/dist/generators-CR34GjVu.js.map +0 -1
  45. package/dist/generators-DH8VkK1q.cjs +0 -678
  46. package/dist/generators-DH8VkK1q.cjs.map +0 -1
  47. package/dist/types-CgDFUvfZ.d.ts +0 -211
package/dist/index.cjs CHANGED
@@ -1,158 +1,187 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_components = require("./components-Yjoe78Y7.cjs");
3
- const require_generators = require("./generators-DH8VkK1q.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_components = require("./components-X0P-3W2G.cjs");
6
+ const require_generators = require("./generators-BE3KD0IR.cjs");
4
7
  let node_path = require("node:path");
5
- node_path = require_components.__toESM(node_path);
8
+ node_path = require_components.__toESM(node_path, 1);
6
9
  let _kubb_core = require("@kubb/core");
7
10
  let _kubb_plugin_client = require("@kubb/plugin-client");
8
11
  let _kubb_plugin_client_templates_clients_axios_source = require("@kubb/plugin-client/templates/clients/axios.source");
9
12
  let _kubb_plugin_client_templates_clients_fetch_source = require("@kubb/plugin-client/templates/clients/fetch.source");
10
13
  let _kubb_plugin_client_templates_config_source = require("@kubb/plugin-client/templates/config.source");
11
- let _kubb_plugin_oas = require("@kubb/plugin-oas");
12
14
  let _kubb_plugin_ts = require("@kubb/plugin-ts");
13
15
  let _kubb_plugin_zod = require("@kubb/plugin-zod");
16
+ //#region src/resolvers/resolverVueQuery.ts
17
+ function capitalize(name) {
18
+ return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
19
+ }
20
+ /**
21
+ * Naming convention resolver for Vue Query plugin.
22
+ *
23
+ * Provides default naming helpers using camelCase for functions and file paths.
24
+ */
25
+ const resolverVueQuery = (0, _kubb_core.defineResolver)(() => ({
26
+ name: "default",
27
+ pluginName: "plugin-vue-query",
28
+ default(name, type) {
29
+ return require_components.camelCase(name, { isFile: type === "file" });
30
+ },
31
+ resolveName(name) {
32
+ return this.default(name, "function");
33
+ },
34
+ resolvePathName(name, type) {
35
+ return this.default(name, type);
36
+ },
37
+ resolveQueryName(node) {
38
+ return `use${capitalize(this.resolveName(node.operationId))}`;
39
+ },
40
+ resolveInfiniteQueryName(node) {
41
+ return `use${capitalize(this.resolveName(node.operationId))}Infinite`;
42
+ },
43
+ resolveMutationName(node) {
44
+ return `use${capitalize(this.resolveName(node.operationId))}`;
45
+ },
46
+ resolveQueryOptionsName(node) {
47
+ return `${this.resolveName(node.operationId)}QueryOptions`;
48
+ },
49
+ resolveInfiniteQueryOptionsName(node) {
50
+ return `${this.resolveName(node.operationId)}InfiniteQueryOptions`;
51
+ },
52
+ resolveQueryKeyName(node) {
53
+ return `${this.resolveName(node.operationId)}QueryKey`;
54
+ },
55
+ resolveInfiniteQueryKeyName(node) {
56
+ return `${this.resolveName(node.operationId)}InfiniteQueryKey`;
57
+ },
58
+ resolveMutationKeyName(node) {
59
+ return `${this.resolveName(node.operationId)}MutationKey`;
60
+ },
61
+ resolveQueryKeyTypeName(node) {
62
+ return `${capitalize(this.resolveName(node.operationId))}QueryKey`;
63
+ },
64
+ resolveInfiniteQueryKeyTypeName(node) {
65
+ return `${capitalize(this.resolveName(node.operationId))}InfiniteQueryKey`;
66
+ },
67
+ resolveMutationTypeName(node) {
68
+ return capitalize(this.resolveName(node.operationId));
69
+ },
70
+ resolveClientName(node) {
71
+ return this.resolveName(node.operationId);
72
+ },
73
+ resolveInfiniteClientName(node) {
74
+ return `${this.resolveName(node.operationId)}Infinite`;
75
+ }
76
+ }));
77
+ //#endregion
14
78
  //#region src/plugin.ts
15
79
  const pluginVueQueryName = "plugin-vue-query";
16
- const pluginVueQuery = (0, _kubb_core.createPlugin)((options) => {
80
+ const pluginVueQuery = (0, _kubb_core.definePlugin)((options) => {
17
81
  const { output = {
18
82
  path: "hooks",
19
83
  barrelType: "named"
20
- }, group, exclude = [], include, override = [], parser = "client", infinite, transformers = {}, paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", mutation = {}, query = {}, paramsCasing, mutationKey = require_components.MutationKey.getTransformer, queryKey = require_components.QueryKey.getTransformer, generators = [
84
+ }, group, exclude = [], include, override = [], parser = "client", infinite = 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;
85
+ const clientName = client?.client ?? "axios";
86
+ const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
87
+ const selectedGenerators = options.generators ?? [
21
88
  require_generators.queryGenerator,
22
89
  require_generators.infiniteQueryGenerator,
23
90
  require_generators.mutationGenerator
24
- ].filter(Boolean), contentType, client } = options;
25
- const clientName = client?.client ?? "axios";
26
- const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
91
+ ].filter((generator) => Boolean(generator));
92
+ const groupConfig = group ? {
93
+ ...group,
94
+ name: group.name ? group.name : (ctx) => {
95
+ if (group.type === "path") return `${ctx.group.split("/")[1]}`;
96
+ return `${require_components.camelCase(ctx.group)}Controller`;
97
+ }
98
+ } : void 0;
27
99
  return {
28
100
  name: pluginVueQueryName,
29
- options: {
30
- output,
31
- client: {
32
- bundle: client?.bundle,
33
- baseURL: client?.baseURL,
34
- client: clientName,
35
- clientType: client?.clientType ?? "function",
36
- dataReturnType: client?.dataReturnType ?? "data",
101
+ options,
102
+ dependencies: [_kubb_plugin_ts.pluginTsName, parser === "zod" ? _kubb_plugin_zod.pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
103
+ hooks: { "kubb:plugin:setup"(ctx) {
104
+ const resolver = userResolver ? {
105
+ ...resolverVueQuery,
106
+ ...userResolver
107
+ } : resolverVueQuery;
108
+ ctx.setOptions({
109
+ output,
110
+ client: {
111
+ bundle: client?.bundle,
112
+ baseURL: client?.baseURL,
113
+ client: clientName,
114
+ clientType: client?.clientType ?? "function",
115
+ importPath: clientImportPath,
116
+ dataReturnType: client?.dataReturnType ?? "data",
117
+ paramsCasing
118
+ },
119
+ queryKey,
120
+ query: query === false ? false : {
121
+ importPath: "@tanstack/vue-query",
122
+ methods: ["get"],
123
+ ...query
124
+ },
125
+ mutationKey,
126
+ mutation: mutation === false ? false : {
127
+ importPath: "@tanstack/vue-query",
128
+ methods: [
129
+ "post",
130
+ "put",
131
+ "patch",
132
+ "delete"
133
+ ],
134
+ ...mutation
135
+ },
136
+ infinite: infinite ? {
137
+ queryParam: "id",
138
+ initialPageParam: 0,
139
+ cursorParam: void 0,
140
+ nextParam: void 0,
141
+ previousParam: void 0,
142
+ ...infinite
143
+ } : false,
144
+ parser,
145
+ paramsType,
37
146
  pathParamsType,
38
- importPath: clientImportPath,
39
- paramsCasing
40
- },
41
- infinite: infinite ? {
42
- queryParam: "id",
43
- initialPageParam: 0,
44
- cursorParam: void 0,
45
- nextParam: void 0,
46
- previousParam: void 0,
47
- ...infinite
48
- } : false,
49
- queryKey,
50
- query: query === false ? false : {
51
- methods: ["get"],
52
- importPath: "@tanstack/vue-query",
53
- ...query
54
- },
55
- mutationKey,
56
- mutation: mutation === false ? false : {
57
- methods: [
58
- "post",
59
- "put",
60
- "patch",
61
- "delete"
62
- ],
63
- importPath: "@tanstack/vue-query",
64
- ...mutation
65
- },
66
- paramsType,
67
- pathParamsType,
68
- parser,
69
- paramsCasing,
70
- group
71
- },
72
- pre: [
73
- _kubb_plugin_oas.pluginOasName,
74
- _kubb_plugin_ts.pluginTsName,
75
- parser === "zod" ? _kubb_plugin_zod.pluginZodName : void 0
76
- ].filter(Boolean),
77
- resolvePath(baseName, pathMode, options) {
78
- const root = node_path.default.resolve(this.config.root, this.config.output.path);
79
- if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
80
- /**
81
- * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
82
- * Other plugins then need to call addOrAppend instead of just add from the fileManager class
83
- */
84
- return node_path.default.resolve(root, output.path);
85
- if (group && (options?.group?.path || options?.group?.tag)) {
86
- const groupName = group?.name ? group.name : (ctx) => {
87
- if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
88
- return `${require_components.camelCase(ctx.group)}Controller`;
89
- };
90
- return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
91
- }
92
- return node_path.default.resolve(root, output.path, baseName);
93
- },
94
- resolveName(name, type) {
95
- let resolvedName = require_components.camelCase(name);
96
- if (type === "file" || type === "function") resolvedName = require_components.camelCase(name, { isFile: type === "file" });
97
- if (type === "type") resolvedName = require_components.pascalCase(name);
98
- if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
99
- return resolvedName;
100
- },
101
- async install() {
102
- const root = node_path.default.resolve(this.config.root, this.config.output.path);
103
- const mode = (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path));
104
- const oas = await this.getOas();
105
- const baseURL = await this.getBaseURL();
106
- if (baseURL) this.plugin.options.client.baseURL = baseURL;
107
- const hasClientPlugin = !!this.driver.getPluginByName(_kubb_plugin_client.pluginClientName);
108
- if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
147
+ paramsCasing,
148
+ group: groupConfig,
149
+ exclude,
150
+ include,
151
+ override,
152
+ resolver
153
+ });
154
+ ctx.setResolver(resolver);
155
+ if (userTransformer) ctx.setTransformer(userTransformer);
156
+ for (const gen of selectedGenerators) ctx.addGenerator(gen);
157
+ for (const gen of userGenerators) ctx.addGenerator(gen);
158
+ const root = node_path.default.resolve(ctx.config.root, ctx.config.output.path);
159
+ const hasClientPlugin = !!ctx.config.plugins?.some((p) => p.name === _kubb_plugin_client.pluginClientName);
160
+ if (client?.bundle && !hasClientPlugin && !clientImportPath) ctx.injectFile({
109
161
  baseName: "fetch.ts",
110
162
  path: node_path.default.resolve(root, ".kubb/fetch.ts"),
111
- sources: [{
163
+ sources: [_kubb_core.ast.createSource({
112
164
  name: "fetch",
113
- value: this.plugin.options.client.client === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source,
165
+ nodes: [_kubb_core.ast.createText(clientName === "fetch" ? _kubb_plugin_client_templates_clients_fetch_source.source : _kubb_plugin_client_templates_clients_axios_source.source)],
114
166
  isExportable: true,
115
167
  isIndexable: true
116
- }],
117
- imports: [],
118
- exports: []
168
+ })]
119
169
  });
120
- if (!hasClientPlugin) await this.addFile({
170
+ if (!hasClientPlugin) ctx.injectFile({
121
171
  baseName: "config.ts",
122
172
  path: node_path.default.resolve(root, ".kubb/config.ts"),
123
- sources: [{
173
+ sources: [_kubb_core.ast.createSource({
124
174
  name: "config",
125
- value: _kubb_plugin_client_templates_config_source.source,
175
+ nodes: [_kubb_core.ast.createText(_kubb_plugin_client_templates_config_source.source)],
126
176
  isExportable: false,
127
177
  isIndexable: false
128
- }],
129
- imports: [],
130
- exports: []
178
+ })]
131
179
  });
132
- const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
133
- fabric: this.fabric,
134
- oas,
135
- driver: this.driver,
136
- events: this.events,
137
- plugin: this.plugin,
138
- contentType,
139
- exclude,
140
- include,
141
- override,
142
- mode
143
- }).build(...generators);
144
- await this.upsertFile(...files);
145
- const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
146
- type: output.barrelType ?? "named",
147
- root,
148
- output,
149
- meta: { pluginName: this.plugin.name }
150
- });
151
- await this.upsertFile(...barrelFiles);
152
- }
180
+ } }
153
181
  };
154
182
  });
155
183
  //#endregion
184
+ exports.default = pluginVueQuery;
156
185
  exports.pluginVueQuery = pluginVueQuery;
157
186
  exports.pluginVueQueryName = pluginVueQueryName;
158
187
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["MutationKey","QueryKey","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","path","camelCase","pascalCase","pluginClientName","fetchClientSource","axiosClientSource","configSource","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { camelCase, pascalCase } from '@internals/utils'\nimport { createPlugin, type Group, getBarrelFiles, getMode } 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 { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { MutationKey, QueryKey } from './components'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './generators'\nimport type { PluginVueQuery } from './types.ts'\n\nexport const pluginVueQueryName = 'plugin-vue-query' satisfies PluginVueQuery['name']\n\nexport const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n mutation = {},\n query = {},\n paramsCasing,\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n contentType,\n client,\n } = options\n\n const clientName = client?.client ?? 'axios'\n const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\n client: {\n bundle: client?.bundle,\n baseURL: client?.baseURL,\n client: clientName,\n clientType: client?.clientType ?? 'function',\n dataReturnType: client?.dataReturnType ?? 'data',\n pathParamsType,\n importPath: clientImportPath,\n paramsCasing,\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 queryKey,\n query:\n query === false\n ? false\n : {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation:\n mutation === false\n ? false\n : {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType,\n parser,\n paramsCasing,\n group,\n },\n pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name)\n\n if (type === 'file' || type === 'function') {\n resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n }\n if (type === 'type') {\n resolvedName = pascalCase(name)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n const baseURL = await this.getBaseURL()\n\n if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n\n const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName)\n\n if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) {\n // pre add bundled\n await this.upsertFile({\n baseName: 'fetch.ts',\n path: path.resolve(root, '.kubb/fetch.ts'),\n sources: [\n {\n name: 'fetch',\n value: this.plugin.options.client.client === 'fetch' ? fetchClientSource : axiosClientSource,\n isExportable: true,\n isIndexable: true,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n if (!hasClientPlugin) {\n await this.addFile({\n baseName: 'config.ts',\n path: path.resolve(root, '.kubb/config.ts'),\n sources: [\n {\n name: 'config',\n value: configSource,\n isExportable: false,\n isIndexable: false,\n },\n ],\n imports: [],\n exports: [],\n })\n }\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n driver: this.driver,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginName: this.plugin.name,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,qBAAqB;AAElC,MAAa,kBAAA,GAAA,WAAA,eAA+C,YAAY;CACtE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAS,YAAY;EAAS,EAC/C,OACA,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,SAAS,UACT,UACA,eAAe,EAAE,EACjB,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,UAChF,WAAW,EAAE,EACb,QAAQ,EAAE,EACV,cACA,cAAcA,mBAAAA,YAAY,gBAC1B,WAAWC,mBAAAA,SAAS,gBACpB,aAAa;EAACC,mBAAAA;EAAgBC,mBAAAA;EAAw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IACX,SAAS,EAAE;IACZ,CAAC;AAGJ,OAAI,CAAC,gBACH,OAAM,KAAK,QAAQ;IACjB,UAAU;IACV,MAAML,UAAAA,QAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACP;KACE,MAAM;KACN,OAAOM,4CAAAA;KACP,cAAc;KACd,aAAa;KACd,CACF;IACD,SAAS,EAAE;IACX,SAAS,EAAE;IACZ,CAAC;GAgBJ,MAAM,QAAQ,MAba,IAAIC,iBAAAA,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,OAAA,GAAA,WAAA,gBAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
1
+ {"version":3,"file":"index.cjs","names":["camelCase","mutationKeyTransformer","queryKeyTransformer","queryGenerator","infiniteQueryGenerator","mutationGenerator","camelCase","pluginTsName","pluginZodName","path","pluginClientName","ast","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\nfunction capitalize(name: string): string {\n return `${name.charAt(0).toUpperCase()}${name.slice(1)}`\n}\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>(() => ({\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 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 { 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 } 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\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 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 = 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((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: 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":";;;;;;;;;;;;;;;;AAIA,SAAS,WAAW,MAAsB;CACxC,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE;;;;;;;AAQxD,MAAa,oBAAA,GAAA,WAAA,uBAAyD;CACpE,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;EAClB,OAAOA,mBAAAA,UAAU,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;CAErD,YAAY,MAAM;EAChB,OAAO,KAAK,QAAQ,MAAM,WAAW;;CAEvC,gBAAgB,MAAM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ACP,UAAU,WACN;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;GACF,IAAI,YAAY,SAAS;GACzB,IAAI,iBACF,IAAI,eAAe,gBAAgB;GAGrC,KAAK,MAAM,OAAO,oBAChB,IAAI,aAAa,IAAI;GAEvB,KAAK,MAAM,OAAO,gBAChB,IAAI,aAAa,IAAI;GAGvB,MAAM,OAAOC,UAAAA,QAAK,QAAQ,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO,KAAK;GAClE,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,SAAS,MAAM,MAAO,EAAwB,SAASC,oBAAAA,iBAAiB;GAE7G,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,OAAkB,CAAC;KACvF,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC;GAGJ,IAAI,CAAC,iBACH,IAAI,WAAW;IACb,UAAU;IACV,MAAMJ,UAAAA,QAAK,QAAQ,MAAM,kBAAkB;IAC3C,SAAS,CACPE,WAAAA,IAAI,aAAa;KACf,MAAM;KACN,OAAO,CAACA,WAAAA,IAAI,WAAWG,4CAAAA,OAAa,CAAC;KACrC,cAAc;KACd,aAAa;KACd,CAAC,CACH;IACF,CAAC;KAGP;EACF;EACD"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { n as Options, r as PluginVueQuery } from "./types-CgDFUvfZ.js";
3
- import * as _kubb_core0 from "@kubb/core";
2
+ import { n as Options, r as PluginVueQuery } from "./types-Bkm7bWT3.js";
3
+ import * as _$_kubb_core0 from "@kubb/core";
4
4
 
5
5
  //#region src/plugin.d.ts
6
6
  declare const pluginVueQueryName = "plugin-vue-query";
7
- declare const pluginVueQuery: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginVueQuery>;
7
+ declare const pluginVueQuery: (options?: Options | undefined) => _$_kubb_core0.Plugin<PluginVueQuery>;
8
8
  //#endregion
9
- export { type PluginVueQuery, pluginVueQuery, pluginVueQueryName };
9
+ export { type PluginVueQuery, pluginVueQuery as default, pluginVueQuery, pluginVueQueryName };
10
10
  //# sourceMappingURL=index.d.ts.map