@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.
- package/LICENSE +17 -10
- package/README.md +26 -7
- package/dist/components-B6jAb2as.js +1150 -0
- package/dist/components-B6jAb2as.js.map +1 -0
- package/dist/components-X0P-3W2G.cjs +1264 -0
- package/dist/components-X0P-3W2G.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +66 -121
- package/dist/components.js +1 -1
- package/dist/generators-B33PbKzu.js +681 -0
- package/dist/generators-B33PbKzu.js.map +1 -0
- package/dist/generators-BE3KD0IR.cjs +698 -0
- package/dist/generators-BE3KD0IR.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +5 -501
- package/dist/generators.js +1 -1
- package/dist/index.cjs +150 -121
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +146 -121
- package/dist/index.js.map +1 -1
- package/dist/types-Bkm7bWT3.d.ts +243 -0
- package/extension.yaml +732 -0
- package/package.json +60 -65
- package/src/components/InfiniteQuery.tsx +71 -159
- package/src/components/InfiniteQueryOptions.tsx +115 -163
- package/src/components/Mutation.tsx +97 -134
- package/src/components/Query.tsx +68 -157
- package/src/components/QueryKey.tsx +23 -66
- package/src/components/QueryOptions.tsx +92 -143
- package/src/generators/infiniteQueryGenerator.tsx +152 -171
- package/src/generators/mutationGenerator.tsx +102 -125
- package/src/generators/queryGenerator.tsx +125 -137
- package/src/index.ts +1 -1
- package/src/plugin.ts +126 -177
- package/src/resolvers/resolverVueQuery.ts +65 -0
- package/src/types.ts +121 -52
- package/src/utils.ts +49 -0
- package/dist/components-Yjoe78Y7.cjs +0 -1119
- package/dist/components-Yjoe78Y7.cjs.map +0 -1
- package/dist/components-_AMBl0g-.js +0 -1029
- package/dist/components-_AMBl0g-.js.map +0 -1
- package/dist/generators-CR34GjVu.js +0 -661
- package/dist/generators-CR34GjVu.js.map +0 -1
- package/dist/generators-DH8VkK1q.cjs +0 -678
- package/dist/generators-DH8VkK1q.cjs.map +0 -1
- package/dist/types-CgDFUvfZ.d.ts +0 -211
package/dist/index.js
CHANGED
|
@@ -1,157 +1,182 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as mutationGenerator, r as infiniteQueryGenerator, t as queryGenerator } from "./generators-
|
|
2
|
+
import { f as mutationKeyTransformer, p as camelCase, s as queryKeyTransformer } from "./components-B6jAb2as.js";
|
|
3
|
+
import { n as mutationGenerator, r as infiniteQueryGenerator, t as queryGenerator } from "./generators-B33PbKzu.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { ast, definePlugin, defineResolver } from "@kubb/core";
|
|
6
6
|
import { 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
|
-
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
11
10
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
12
11
|
import { pluginZodName } from "@kubb/plugin-zod";
|
|
12
|
+
//#region src/resolvers/resolverVueQuery.ts
|
|
13
|
+
function capitalize(name) {
|
|
14
|
+
return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Naming convention resolver for Vue Query plugin.
|
|
18
|
+
*
|
|
19
|
+
* Provides default naming helpers using camelCase for functions and file paths.
|
|
20
|
+
*/
|
|
21
|
+
const resolverVueQuery = defineResolver(() => ({
|
|
22
|
+
name: "default",
|
|
23
|
+
pluginName: "plugin-vue-query",
|
|
24
|
+
default(name, type) {
|
|
25
|
+
return camelCase(name, { isFile: type === "file" });
|
|
26
|
+
},
|
|
27
|
+
resolveName(name) {
|
|
28
|
+
return this.default(name, "function");
|
|
29
|
+
},
|
|
30
|
+
resolvePathName(name, type) {
|
|
31
|
+
return this.default(name, type);
|
|
32
|
+
},
|
|
33
|
+
resolveQueryName(node) {
|
|
34
|
+
return `use${capitalize(this.resolveName(node.operationId))}`;
|
|
35
|
+
},
|
|
36
|
+
resolveInfiniteQueryName(node) {
|
|
37
|
+
return `use${capitalize(this.resolveName(node.operationId))}Infinite`;
|
|
38
|
+
},
|
|
39
|
+
resolveMutationName(node) {
|
|
40
|
+
return `use${capitalize(this.resolveName(node.operationId))}`;
|
|
41
|
+
},
|
|
42
|
+
resolveQueryOptionsName(node) {
|
|
43
|
+
return `${this.resolveName(node.operationId)}QueryOptions`;
|
|
44
|
+
},
|
|
45
|
+
resolveInfiniteQueryOptionsName(node) {
|
|
46
|
+
return `${this.resolveName(node.operationId)}InfiniteQueryOptions`;
|
|
47
|
+
},
|
|
48
|
+
resolveQueryKeyName(node) {
|
|
49
|
+
return `${this.resolveName(node.operationId)}QueryKey`;
|
|
50
|
+
},
|
|
51
|
+
resolveInfiniteQueryKeyName(node) {
|
|
52
|
+
return `${this.resolveName(node.operationId)}InfiniteQueryKey`;
|
|
53
|
+
},
|
|
54
|
+
resolveMutationKeyName(node) {
|
|
55
|
+
return `${this.resolveName(node.operationId)}MutationKey`;
|
|
56
|
+
},
|
|
57
|
+
resolveQueryKeyTypeName(node) {
|
|
58
|
+
return `${capitalize(this.resolveName(node.operationId))}QueryKey`;
|
|
59
|
+
},
|
|
60
|
+
resolveInfiniteQueryKeyTypeName(node) {
|
|
61
|
+
return `${capitalize(this.resolveName(node.operationId))}InfiniteQueryKey`;
|
|
62
|
+
},
|
|
63
|
+
resolveMutationTypeName(node) {
|
|
64
|
+
return capitalize(this.resolveName(node.operationId));
|
|
65
|
+
},
|
|
66
|
+
resolveClientName(node) {
|
|
67
|
+
return this.resolveName(node.operationId);
|
|
68
|
+
},
|
|
69
|
+
resolveInfiniteClientName(node) {
|
|
70
|
+
return `${this.resolveName(node.operationId)}Infinite`;
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
//#endregion
|
|
13
74
|
//#region src/plugin.ts
|
|
14
75
|
const pluginVueQueryName = "plugin-vue-query";
|
|
15
|
-
const pluginVueQuery =
|
|
76
|
+
const pluginVueQuery = definePlugin((options) => {
|
|
16
77
|
const { output = {
|
|
17
78
|
path: "hooks",
|
|
18
79
|
barrelType: "named"
|
|
19
|
-
}, group, exclude = [], include, override = [], parser = "client", infinite
|
|
80
|
+
}, group, exclude = [], include, override = [], parser = "client", 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;
|
|
81
|
+
const clientName = client?.client ?? "axios";
|
|
82
|
+
const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : void 0);
|
|
83
|
+
const selectedGenerators = options.generators ?? [
|
|
20
84
|
queryGenerator,
|
|
21
85
|
infiniteQueryGenerator,
|
|
22
86
|
mutationGenerator
|
|
23
|
-
].filter(
|
|
24
|
-
const
|
|
25
|
-
|
|
87
|
+
].filter((generator) => Boolean(generator));
|
|
88
|
+
const groupConfig = group ? {
|
|
89
|
+
...group,
|
|
90
|
+
name: group.name ? group.name : (ctx) => {
|
|
91
|
+
if (group.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
92
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
93
|
+
}
|
|
94
|
+
} : void 0;
|
|
26
95
|
return {
|
|
27
96
|
name: pluginVueQueryName,
|
|
28
|
-
options
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
97
|
+
options,
|
|
98
|
+
dependencies: [pluginTsName, parser === "zod" ? pluginZodName : void 0].filter((dependency) => Boolean(dependency)),
|
|
99
|
+
hooks: { "kubb:plugin:setup"(ctx) {
|
|
100
|
+
const resolver = userResolver ? {
|
|
101
|
+
...resolverVueQuery,
|
|
102
|
+
...userResolver
|
|
103
|
+
} : resolverVueQuery;
|
|
104
|
+
ctx.setOptions({
|
|
105
|
+
output,
|
|
106
|
+
client: {
|
|
107
|
+
bundle: client?.bundle,
|
|
108
|
+
baseURL: client?.baseURL,
|
|
109
|
+
client: clientName,
|
|
110
|
+
clientType: client?.clientType ?? "function",
|
|
111
|
+
importPath: clientImportPath,
|
|
112
|
+
dataReturnType: client?.dataReturnType ?? "data",
|
|
113
|
+
paramsCasing
|
|
114
|
+
},
|
|
115
|
+
queryKey,
|
|
116
|
+
query: query === false ? false : {
|
|
117
|
+
importPath: "@tanstack/vue-query",
|
|
118
|
+
methods: ["get"],
|
|
119
|
+
...query
|
|
120
|
+
},
|
|
121
|
+
mutationKey,
|
|
122
|
+
mutation: mutation === false ? false : {
|
|
123
|
+
importPath: "@tanstack/vue-query",
|
|
124
|
+
methods: [
|
|
125
|
+
"post",
|
|
126
|
+
"put",
|
|
127
|
+
"patch",
|
|
128
|
+
"delete"
|
|
129
|
+
],
|
|
130
|
+
...mutation
|
|
131
|
+
},
|
|
132
|
+
infinite: infinite ? {
|
|
133
|
+
queryParam: "id",
|
|
134
|
+
initialPageParam: 0,
|
|
135
|
+
cursorParam: void 0,
|
|
136
|
+
nextParam: void 0,
|
|
137
|
+
previousParam: void 0,
|
|
138
|
+
...infinite
|
|
139
|
+
} : false,
|
|
140
|
+
parser,
|
|
141
|
+
paramsType,
|
|
36
142
|
pathParamsType,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
importPath: "@tanstack/vue-query",
|
|
52
|
-
...query
|
|
53
|
-
},
|
|
54
|
-
mutationKey,
|
|
55
|
-
mutation: mutation === false ? false : {
|
|
56
|
-
methods: [
|
|
57
|
-
"post",
|
|
58
|
-
"put",
|
|
59
|
-
"patch",
|
|
60
|
-
"delete"
|
|
61
|
-
],
|
|
62
|
-
importPath: "@tanstack/vue-query",
|
|
63
|
-
...mutation
|
|
64
|
-
},
|
|
65
|
-
paramsType,
|
|
66
|
-
pathParamsType,
|
|
67
|
-
parser,
|
|
68
|
-
paramsCasing,
|
|
69
|
-
group
|
|
70
|
-
},
|
|
71
|
-
pre: [
|
|
72
|
-
pluginOasName,
|
|
73
|
-
pluginTsName,
|
|
74
|
-
parser === "zod" ? pluginZodName : void 0
|
|
75
|
-
].filter(Boolean),
|
|
76
|
-
resolvePath(baseName, pathMode, options) {
|
|
77
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
78
|
-
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
79
|
-
/**
|
|
80
|
-
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
81
|
-
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
82
|
-
*/
|
|
83
|
-
return path.resolve(root, output.path);
|
|
84
|
-
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
85
|
-
const groupName = group?.name ? group.name : (ctx) => {
|
|
86
|
-
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
87
|
-
return `${camelCase(ctx.group)}Controller`;
|
|
88
|
-
};
|
|
89
|
-
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
90
|
-
}
|
|
91
|
-
return path.resolve(root, output.path, baseName);
|
|
92
|
-
},
|
|
93
|
-
resolveName(name, type) {
|
|
94
|
-
let resolvedName = camelCase(name);
|
|
95
|
-
if (type === "file" || type === "function") resolvedName = camelCase(name, { isFile: type === "file" });
|
|
96
|
-
if (type === "type") resolvedName = pascalCase(name);
|
|
97
|
-
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
98
|
-
return resolvedName;
|
|
99
|
-
},
|
|
100
|
-
async install() {
|
|
101
|
-
const root = path.resolve(this.config.root, this.config.output.path);
|
|
102
|
-
const mode = getMode(path.resolve(root, output.path));
|
|
103
|
-
const oas = await this.getOas();
|
|
104
|
-
const baseURL = await this.getBaseURL();
|
|
105
|
-
if (baseURL) this.plugin.options.client.baseURL = baseURL;
|
|
106
|
-
const hasClientPlugin = !!this.driver.getPluginByName(pluginClientName);
|
|
107
|
-
if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
|
|
143
|
+
paramsCasing,
|
|
144
|
+
group: groupConfig,
|
|
145
|
+
exclude,
|
|
146
|
+
include,
|
|
147
|
+
override,
|
|
148
|
+
resolver
|
|
149
|
+
});
|
|
150
|
+
ctx.setResolver(resolver);
|
|
151
|
+
if (userTransformer) ctx.setTransformer(userTransformer);
|
|
152
|
+
for (const gen of selectedGenerators) ctx.addGenerator(gen);
|
|
153
|
+
for (const gen of userGenerators) ctx.addGenerator(gen);
|
|
154
|
+
const root = path.resolve(ctx.config.root, ctx.config.output.path);
|
|
155
|
+
const hasClientPlugin = !!ctx.config.plugins?.some((p) => p.name === pluginClientName);
|
|
156
|
+
if (client?.bundle && !hasClientPlugin && !clientImportPath) ctx.injectFile({
|
|
108
157
|
baseName: "fetch.ts",
|
|
109
158
|
path: path.resolve(root, ".kubb/fetch.ts"),
|
|
110
|
-
sources: [{
|
|
159
|
+
sources: [ast.createSource({
|
|
111
160
|
name: "fetch",
|
|
112
|
-
|
|
161
|
+
nodes: [ast.createText(clientName === "fetch" ? source$1 : source)],
|
|
113
162
|
isExportable: true,
|
|
114
163
|
isIndexable: true
|
|
115
|
-
}]
|
|
116
|
-
imports: [],
|
|
117
|
-
exports: []
|
|
164
|
+
})]
|
|
118
165
|
});
|
|
119
|
-
if (!hasClientPlugin)
|
|
166
|
+
if (!hasClientPlugin) ctx.injectFile({
|
|
120
167
|
baseName: "config.ts",
|
|
121
168
|
path: path.resolve(root, ".kubb/config.ts"),
|
|
122
|
-
sources: [{
|
|
169
|
+
sources: [ast.createSource({
|
|
123
170
|
name: "config",
|
|
124
|
-
|
|
171
|
+
nodes: [ast.createText(source$2)],
|
|
125
172
|
isExportable: false,
|
|
126
173
|
isIndexable: false
|
|
127
|
-
}]
|
|
128
|
-
imports: [],
|
|
129
|
-
exports: []
|
|
130
|
-
});
|
|
131
|
-
const files = await new OperationGenerator(this.plugin.options, {
|
|
132
|
-
fabric: this.fabric,
|
|
133
|
-
oas,
|
|
134
|
-
driver: this.driver,
|
|
135
|
-
events: this.events,
|
|
136
|
-
plugin: this.plugin,
|
|
137
|
-
contentType,
|
|
138
|
-
exclude,
|
|
139
|
-
include,
|
|
140
|
-
override,
|
|
141
|
-
mode
|
|
142
|
-
}).build(...generators);
|
|
143
|
-
await this.upsertFile(...files);
|
|
144
|
-
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
145
|
-
type: output.barrelType ?? "named",
|
|
146
|
-
root,
|
|
147
|
-
output,
|
|
148
|
-
meta: { pluginName: this.plugin.name }
|
|
174
|
+
})]
|
|
149
175
|
});
|
|
150
|
-
|
|
151
|
-
}
|
|
176
|
+
} }
|
|
152
177
|
};
|
|
153
178
|
});
|
|
154
179
|
//#endregion
|
|
155
|
-
export { pluginVueQuery, pluginVueQueryName };
|
|
180
|
+
export { pluginVueQuery as default, pluginVueQuery, pluginVueQueryName };
|
|
156
181
|
|
|
157
182
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fetchClientSource","axiosClientSource","configSource"],"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,iBAAiB,cAA8B,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,cAAc,YAAY,gBAC1B,WAAW,SAAS,gBACpB,aAAa;EAAC;EAAgB;EAAwB;EAAkB,CAAC,OAAO,QAAQ,EACxF,aACA,WACE;CAEJ,MAAM,aAAa,QAAQ,UAAU;CACrC,MAAM,mBAAmB,QAAQ,eAAe,CAAC,QAAQ,SAAS,+BAA+B,eAAe,KAAA;AAEhH,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA,QAAQ;IACN,QAAQ,QAAQ;IAChB,SAAS,QAAQ;IACjB,QAAQ;IACR,YAAY,QAAQ,cAAc;IAClC,gBAAgB,QAAQ,kBAAkB;IAC1C;IACA,YAAY;IACZ;IACD;GACD,UAAU,WACN;IACE,YAAY;IACZ,k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;IACA,MAAM,EACJ,YAAY,KAAK,OAAO,MACzB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
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\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,mBAAmB,sBAAsC;CACpE,MAAM;CACN,YAAY;CACZ,QAAQ,MAAM,MAAM;EAClB,OAAO,UAAU,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC;;CAErD,YAAY,MAAM;EAChB,OAAO,KAAK,QAAQ,MAAM,WAAW;;CAEvC,gBAAgB,MAAM,MAAM;EAC1B,OAAO,KAAK,QAAQ,MAAM,KAAK;;CAEjC,iBAAiB,MAAM;EACrB,OAAO,MAAM,WAAW,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE7D,yBAAyB,MAAM;EAC7B,OAAO,MAAM,WAAW,KAAK,YAAY,KAAK,YAAY,CAAC,CAAC;;CAE9D,oBAAoB,MAAM;EACxB,OAAO,MAAM,WAAW,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE7D,wBAAwB,MAAM;EAC5B,OAAO,GAAG,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE/C,gCAAgC,MAAM;EACpC,OAAO,GAAG,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE/C,oBAAoB,MAAM;EACxB,OAAO,GAAG,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE/C,4BAA4B,MAAM;EAChC,OAAO,GAAG,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE/C,uBAAuB,MAAM;EAC3B,OAAO,GAAG,KAAK,YAAY,KAAK,YAAY,CAAC;;CAE/C,wBAAwB,MAAM;EAC5B,OAAO,GAAG,WAAW,KAAK,YAAY,KAAK,YAAY,CAAC,CAA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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"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
+
import { Exclude, Generator, Group, Include, Output, 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
|
+
}) => 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
|
+
* Customize the queryKey.
|
|
77
|
+
*/
|
|
78
|
+
type QueryKey = Transformer;
|
|
79
|
+
/**
|
|
80
|
+
* Customize the mutationKey.
|
|
81
|
+
*/
|
|
82
|
+
type MutationKey = Transformer;
|
|
83
|
+
type Query = {
|
|
84
|
+
/**
|
|
85
|
+
* HTTP methods to use for queries.
|
|
86
|
+
*
|
|
87
|
+
* @default ['get']
|
|
88
|
+
*/
|
|
89
|
+
methods?: Array<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Path to the useQuery hook for useQuery functionality.
|
|
92
|
+
* Used as `import { useQuery } from '${importPath}'`.
|
|
93
|
+
* Accepts relative and absolute paths.
|
|
94
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
95
|
+
* @default '@tanstack/vue-query'
|
|
96
|
+
*/
|
|
97
|
+
importPath?: string;
|
|
98
|
+
};
|
|
99
|
+
type Mutation = {
|
|
100
|
+
/**
|
|
101
|
+
* HTTP methods to use for mutations.
|
|
102
|
+
*
|
|
103
|
+
* @default ['post', 'put', 'delete']
|
|
104
|
+
*/
|
|
105
|
+
methods?: Array<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Path to the useMutation hook for useMutation functionality.
|
|
108
|
+
* Used as `import { useMutation } from '${importPath}'`.
|
|
109
|
+
* Accepts relative and absolute paths.
|
|
110
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
111
|
+
* @default '@tanstack/vue-query'
|
|
112
|
+
*/
|
|
113
|
+
importPath?: string;
|
|
114
|
+
};
|
|
115
|
+
type Infinite = {
|
|
116
|
+
/**
|
|
117
|
+
* Specify the params key used for `pageParam`.
|
|
118
|
+
* @default 'id'
|
|
119
|
+
*/
|
|
120
|
+
queryParam: string;
|
|
121
|
+
/**
|
|
122
|
+
* Which field of the data is used, set it to undefined when no cursor is known.
|
|
123
|
+
* @deprecated Use `nextParam` and `previousParam` instead for more flexible pagination handling.
|
|
124
|
+
*/
|
|
125
|
+
cursorParam?: string | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Which field of the data is used to get the cursor for the next page.
|
|
128
|
+
* Supports dot notation (e.g. 'pagination.next.id') or array path (e.g. ['pagination', 'next', 'id']) to access nested fields.
|
|
129
|
+
*/
|
|
130
|
+
nextParam?: string | string[] | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Which field of the data is used to get the cursor for the previous page.
|
|
133
|
+
* Supports dot notation (e.g. 'pagination.prev.id') or array path (e.g. ['pagination', 'prev', 'id']) to access nested fields.
|
|
134
|
+
*/
|
|
135
|
+
previousParam?: string | string[] | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* The initial value, the value of the first page.
|
|
138
|
+
* @default 0
|
|
139
|
+
*/
|
|
140
|
+
initialPageParam: unknown;
|
|
141
|
+
};
|
|
142
|
+
type Options = {
|
|
143
|
+
/**
|
|
144
|
+
* Specify the export location for the files and define the behavior of the output
|
|
145
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
146
|
+
*/
|
|
147
|
+
output?: Output;
|
|
148
|
+
/**
|
|
149
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
150
|
+
*/
|
|
151
|
+
group?: Group;
|
|
152
|
+
client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
153
|
+
/**
|
|
154
|
+
* Tags, operations, or paths to exclude from generation.
|
|
155
|
+
*/
|
|
156
|
+
exclude?: Array<Exclude>;
|
|
157
|
+
/**
|
|
158
|
+
* Tags, operations, or paths to include in generation.
|
|
159
|
+
*/
|
|
160
|
+
include?: Array<Include>;
|
|
161
|
+
/**
|
|
162
|
+
* Override options for specific tags, operations, or paths.
|
|
163
|
+
*/
|
|
164
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
165
|
+
/**
|
|
166
|
+
* Apply casing to parameter names.
|
|
167
|
+
*/
|
|
168
|
+
paramsCasing?: 'camelcase';
|
|
169
|
+
/**
|
|
170
|
+
* How parameters are passed: grouped in an object or spread inline.
|
|
171
|
+
*
|
|
172
|
+
* @default 'inline'
|
|
173
|
+
*/
|
|
174
|
+
paramsType?: 'object' | 'inline';
|
|
175
|
+
/**
|
|
176
|
+
* How path parameters are passed: grouped in an object or spread inline.
|
|
177
|
+
*
|
|
178
|
+
* @default 'inline'
|
|
179
|
+
*/
|
|
180
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
181
|
+
/**
|
|
182
|
+
* Add infinite query hooks.
|
|
183
|
+
*/
|
|
184
|
+
infinite?: Partial<Infinite> | false;
|
|
185
|
+
queryKey?: QueryKey;
|
|
186
|
+
/**
|
|
187
|
+
* Configure useQuery behavior.
|
|
188
|
+
*/
|
|
189
|
+
query?: Partial<Query> | false;
|
|
190
|
+
mutationKey?: MutationKey;
|
|
191
|
+
/**
|
|
192
|
+
* Configure useMutation behavior.
|
|
193
|
+
*/
|
|
194
|
+
mutation?: Partial<Mutation> | false;
|
|
195
|
+
/**
|
|
196
|
+
* Parser to use for validating response data.
|
|
197
|
+
*/
|
|
198
|
+
parser?: PluginClient['options']['parser'];
|
|
199
|
+
/**
|
|
200
|
+
* Override naming conventions for function names and types.
|
|
201
|
+
*/
|
|
202
|
+
resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>;
|
|
203
|
+
/**
|
|
204
|
+
* AST visitor to transform generated nodes.
|
|
205
|
+
*/
|
|
206
|
+
transformer?: ast.Visitor;
|
|
207
|
+
/**
|
|
208
|
+
* Additional generators alongside the default generators.
|
|
209
|
+
*/
|
|
210
|
+
generators?: Array<Generator<PluginVueQuery>>;
|
|
211
|
+
};
|
|
212
|
+
type ResolvedOptions = {
|
|
213
|
+
output: Output;
|
|
214
|
+
group: Group | undefined;
|
|
215
|
+
exclude: NonNullable<Options['exclude']>;
|
|
216
|
+
include: Options['include'];
|
|
217
|
+
override: NonNullable<Options['override']>;
|
|
218
|
+
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
219
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
220
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
221
|
+
paramsCasing: Options['paramsCasing'];
|
|
222
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
223
|
+
/**
|
|
224
|
+
* Only used for infinite
|
|
225
|
+
*/
|
|
226
|
+
infinite: NonNullable<Infinite> | false;
|
|
227
|
+
queryKey: QueryKey | undefined;
|
|
228
|
+
query: NonNullable<Required<Query>> | false;
|
|
229
|
+
mutationKey: MutationKey | undefined;
|
|
230
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
231
|
+
resolver: ResolverVueQuery;
|
|
232
|
+
};
|
|
233
|
+
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
|
|
234
|
+
declare global {
|
|
235
|
+
namespace Kubb {
|
|
236
|
+
interface PluginRegistry {
|
|
237
|
+
'plugin-vue-query': PluginVueQuery;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
//#endregion
|
|
242
|
+
export { Transformer as i, Options as n, PluginVueQuery as r, Infinite as t };
|
|
243
|
+
//# sourceMappingURL=types-Bkm7bWT3.d.ts.map
|