@kubb/plugin-vue-query 3.0.0-alpha.20
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 +21 -0
- package/README.md +123 -0
- package/dist/chunk-3HD4DCDR.js +505 -0
- package/dist/chunk-3HD4DCDR.js.map +1 -0
- package/dist/chunk-4YY5DUPV.cjs +514 -0
- package/dist/chunk-4YY5DUPV.cjs.map +1 -0
- package/dist/chunk-BKYBSBUA.js +567 -0
- package/dist/chunk-BKYBSBUA.js.map +1 -0
- package/dist/chunk-FRKJLBA5.cjs +576 -0
- package/dist/chunk-FRKJLBA5.cjs.map +1 -0
- package/dist/components.cjs +32 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +121 -0
- package/dist/components.d.ts +121 -0
- package/dist/components.js +3 -0
- package/dist/components.js.map +1 -0
- package/dist/generators.cjs +21 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +12 -0
- package/dist/generators.d.ts +12 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +138 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/types-CmetQDTc.d.cts +173 -0
- package/dist/types-CmetQDTc.d.ts +173 -0
- package/package.json +102 -0
- package/src/components/InfiniteQuery.tsx +137 -0
- package/src/components/InfiniteQueryOptions.tsx +129 -0
- package/src/components/Mutation.tsx +141 -0
- package/src/components/Query.tsx +128 -0
- package/src/components/QueryKey.tsx +81 -0
- package/src/components/QueryOptions.tsx +88 -0
- package/src/components/index.ts +6 -0
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +52 -0
- package/src/generators/__snapshots__/clientGetImportPath.ts +52 -0
- package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
- package/src/generators/__snapshots__/findByTags.ts +52 -0
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +52 -0
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +52 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +52 -0
- package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
- package/src/generators/__snapshots__/postAsQuery.ts +50 -0
- package/src/generators/__snapshots__/updatePetById.ts +38 -0
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +40 -0
- package/src/generators/index.ts +3 -0
- package/src/generators/infiniteQueryGenerator.tsx +131 -0
- package/src/generators/mutationGenerator.tsx +96 -0
- package/src/generators/queryGenerator.tsx +124 -0
- package/src/index.ts +2 -0
- package/src/plugin.ts +152 -0
- package/src/types.ts +179 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as _kubb_core from '@kubb/core';
|
|
2
|
+
import { O as Options, P as PluginVueQuery } from './types-CmetQDTc.js';
|
|
3
|
+
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-oas';
|
|
5
|
+
|
|
6
|
+
declare const pluginVueQueryName = "plugin-vue-query";
|
|
7
|
+
declare const pluginVueQuery: (options?: Options | undefined) => _kubb_core.UserPluginWithLifeCycle<PluginVueQuery>;
|
|
8
|
+
|
|
9
|
+
export { PluginVueQuery, pluginVueQuery, pluginVueQueryName };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-3HD4DCDR.js';
|
|
2
|
+
import './chunk-BKYBSBUA.js';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
|
+
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
6
|
+
import { renderTemplate } from '@kubb/core/utils';
|
|
7
|
+
import { pluginOasName, OperationGenerator } from '@kubb/plugin-oas';
|
|
8
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
9
|
+
import { pluginZodName } from '@kubb/plugin-zod';
|
|
10
|
+
|
|
11
|
+
var pluginVueQueryName = "plugin-vue-query";
|
|
12
|
+
var pluginVueQuery = createPlugin((options) => {
|
|
13
|
+
const {
|
|
14
|
+
output = { path: "hooks" },
|
|
15
|
+
group,
|
|
16
|
+
exclude = [],
|
|
17
|
+
include,
|
|
18
|
+
override = [],
|
|
19
|
+
parser = "client",
|
|
20
|
+
infinite,
|
|
21
|
+
transformers = {},
|
|
22
|
+
pathParamsType = "inline",
|
|
23
|
+
mutation = {},
|
|
24
|
+
query = {}
|
|
25
|
+
} = options;
|
|
26
|
+
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
27
|
+
return {
|
|
28
|
+
name: pluginVueQueryName,
|
|
29
|
+
options: {
|
|
30
|
+
output: {
|
|
31
|
+
exportType: "barrelNamed",
|
|
32
|
+
...output
|
|
33
|
+
},
|
|
34
|
+
baseURL: void 0,
|
|
35
|
+
client: {
|
|
36
|
+
importPath: "@kubb/plugin-client/client",
|
|
37
|
+
dataReturnType: "data",
|
|
38
|
+
pathParamsType: "inline",
|
|
39
|
+
...options.client
|
|
40
|
+
},
|
|
41
|
+
infinite: infinite ? {
|
|
42
|
+
queryParam: "id",
|
|
43
|
+
initialPageParam: 0,
|
|
44
|
+
cursorParam: void 0,
|
|
45
|
+
...infinite
|
|
46
|
+
} : false,
|
|
47
|
+
query: {
|
|
48
|
+
key: (key) => key,
|
|
49
|
+
methods: ["get"],
|
|
50
|
+
importPath: "@tanstack/vue-query",
|
|
51
|
+
...query
|
|
52
|
+
},
|
|
53
|
+
mutation: {
|
|
54
|
+
methods: ["post", "put", "patch", "delete"],
|
|
55
|
+
importPath: "@tanstack/vue-query",
|
|
56
|
+
...mutation
|
|
57
|
+
},
|
|
58
|
+
pathParamsType,
|
|
59
|
+
parser
|
|
60
|
+
},
|
|
61
|
+
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
62
|
+
resolvePath(baseName, pathMode, options2) {
|
|
63
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
64
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
65
|
+
if (mode === "single") {
|
|
66
|
+
return path.resolve(root, output.path);
|
|
67
|
+
}
|
|
68
|
+
if (options2?.tag && group?.type === "tag") {
|
|
69
|
+
const tag = camelCase(options2.tag);
|
|
70
|
+
return path.resolve(root, renderTemplate(template, { tag }), baseName);
|
|
71
|
+
}
|
|
72
|
+
return path.resolve(root, output.path, baseName);
|
|
73
|
+
},
|
|
74
|
+
resolveName(name, type) {
|
|
75
|
+
let resolvedName = camelCase(name);
|
|
76
|
+
if (type === "file" || type === "function") {
|
|
77
|
+
resolvedName = camelCase(name, {
|
|
78
|
+
isFile: type === "file"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (type === "type") {
|
|
82
|
+
resolvedName = pascalCase(name);
|
|
83
|
+
}
|
|
84
|
+
if (type) {
|
|
85
|
+
return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
86
|
+
}
|
|
87
|
+
return resolvedName;
|
|
88
|
+
},
|
|
89
|
+
async buildStart() {
|
|
90
|
+
const [swaggerPlugin] = PluginManager.getDependedPlugins(this.plugins, [pluginOasName]);
|
|
91
|
+
const oas = await swaggerPlugin.context.getOas();
|
|
92
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
93
|
+
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
94
|
+
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
95
|
+
const operationGenerator = new OperationGenerator(
|
|
96
|
+
{
|
|
97
|
+
...this.plugin.options,
|
|
98
|
+
baseURL
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
oas,
|
|
102
|
+
pluginManager: this.pluginManager,
|
|
103
|
+
plugin: this.plugin,
|
|
104
|
+
contentType: swaggerPlugin.context.contentType,
|
|
105
|
+
exclude,
|
|
106
|
+
include,
|
|
107
|
+
override,
|
|
108
|
+
mode
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator);
|
|
112
|
+
await this.addFile(...files);
|
|
113
|
+
if (this.config.output.exportType) {
|
|
114
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
115
|
+
root,
|
|
116
|
+
output,
|
|
117
|
+
files: this.fileManager.files,
|
|
118
|
+
meta: {
|
|
119
|
+
pluginKey: this.plugin.key
|
|
120
|
+
},
|
|
121
|
+
logger: this.logger
|
|
122
|
+
});
|
|
123
|
+
await this.addFile(...barrelFiles);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export { pluginVueQuery, pluginVueQueryName };
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA,mBAAA;AAErB,IAAA,cAAA,GAAiB,YAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAA,GAAS,EAAE,IAAA,EAAM,OAAQ,EAAA;AAAA,IACzB,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,QAAA;AAAA,IACA,eAAe,EAAC;AAAA,IAChB,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,GACP,GAAA,OAAA,CAAA;AACJ,EAAA,MAAM,WAAW,KAAO,EAAA,MAAA,GAAS,MAAM,MAAS,GAAA,CAAA,EAAG,OAAO,IAAI,CAAA,kBAAA,CAAA,CAAA;AAE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A,UACA,MAAA;AAAA,UACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,UACxB,IAAM,EAAA;AAAA,YACJ,SAAA,EAAW,KAAK,MAAO,CAAA,GAAA;AAAA,WACzB;AAAA,UACA,QAAQ,IAAK,CAAA,MAAA;AAAA,SACd,CAAA,CAAA;AAED,QAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { renderTemplate } from '@kubb/core/utils'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\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' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n infinite,\n transformers = {},\n pathParamsType = 'inline',\n mutation = {},\n query = {},\n } = options\n const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`\n\n return {\n name: pluginVueQueryName,\n options: {\n output: {\n exportType: 'barrelNamed',\n ...output,\n },\n baseURL: undefined,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n pathParamsType: 'inline',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n pathParamsType,\n parser,\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 ?? FileManager.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 (options?.tag && group?.type === 'tag') {\n const tag = camelCase(options.tag)\n\n return path.resolve(root, renderTemplate(template, { tag }), baseName)\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 buildStart() {\n const [swaggerPlugin]: [Plugin<PluginOas>] = PluginManager.getDependedPlugins<PluginOas>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n const baseURL = await swaggerPlugin.context.getBaseURL()\n\n const operationGenerator = new OperationGenerator(\n {\n ...this.plugin.options,\n baseURL,\n },\n {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n },\n )\n\n const files = await operationGenerator.build(queryGenerator, infiniteQueryGenerator, mutationGenerator)\n await this.addFile(...files)\n\n if (this.config.output.exportType) {\n const barrelFiles = await this.fileManager.getBarrelFiles({\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n }\n },\n }\n})\n"]}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { HttpMethod } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
4
|
+
|
|
5
|
+
type Query = {
|
|
6
|
+
/**
|
|
7
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
8
|
+
*/
|
|
9
|
+
key: (key: unknown[]) => unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* Define which HttpMethods can be used for queries
|
|
12
|
+
* @default ['get']
|
|
13
|
+
*/
|
|
14
|
+
methods: Array<HttpMethod>;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
17
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
18
|
+
* It allows both relative and absolute path.
|
|
19
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
20
|
+
* @default '@tanstack/react-query'
|
|
21
|
+
*/
|
|
22
|
+
importPath?: string;
|
|
23
|
+
};
|
|
24
|
+
type Mutation = {
|
|
25
|
+
/**
|
|
26
|
+
* Define which HttpMethods can be used for mutations
|
|
27
|
+
* @default ['post', 'put', 'delete']
|
|
28
|
+
*/
|
|
29
|
+
methods: Array<HttpMethod>;
|
|
30
|
+
/**
|
|
31
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
32
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
33
|
+
* It allows both relative and absolute path.
|
|
34
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
35
|
+
* @default '@tanstack/react-query'
|
|
36
|
+
*/
|
|
37
|
+
importPath?: string;
|
|
38
|
+
};
|
|
39
|
+
type Infinite = {
|
|
40
|
+
/**
|
|
41
|
+
* Specify the params key used for `pageParam`.
|
|
42
|
+
* Used inside `useInfiniteQuery`, `createInfiniteQueries`, `createInfiniteQuery`
|
|
43
|
+
* @default `'id'`
|
|
44
|
+
*/
|
|
45
|
+
queryParam: string;
|
|
46
|
+
/**
|
|
47
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
48
|
+
*/
|
|
49
|
+
cursorParam?: string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The initial value, the value of the first page.
|
|
52
|
+
* @default `0`
|
|
53
|
+
*/
|
|
54
|
+
initialPageParam: unknown;
|
|
55
|
+
};
|
|
56
|
+
type Options = {
|
|
57
|
+
/**
|
|
58
|
+
* @default 'hooks'
|
|
59
|
+
*/
|
|
60
|
+
output?: Output;
|
|
61
|
+
/**
|
|
62
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
63
|
+
*/
|
|
64
|
+
group?: {
|
|
65
|
+
/**
|
|
66
|
+
* Tag will group based on the operation tag inside the Swagger file
|
|
67
|
+
*/
|
|
68
|
+
type: 'tag';
|
|
69
|
+
/**
|
|
70
|
+
* Relative path to save the grouped @tanstack/query hooks.
|
|
71
|
+
*
|
|
72
|
+
* `{{tag}}` will be replaced by the current tagName.
|
|
73
|
+
* @example `${output}/{{tag}}Controller` => `hooks/PetController`
|
|
74
|
+
* @default `${output}/{{tag}}Controller`
|
|
75
|
+
*/
|
|
76
|
+
output?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Name to be used for the `export * as {{exportAs}} from './`
|
|
79
|
+
* @default `"{{tag}}Hooks"`
|
|
80
|
+
*/
|
|
81
|
+
exportAs?: string;
|
|
82
|
+
};
|
|
83
|
+
client?: {
|
|
84
|
+
/**
|
|
85
|
+
* Path to the client that will be used to do the API calls.
|
|
86
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
87
|
+
* It allows both relative and absolute path.
|
|
88
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
89
|
+
* @default '@kubb/plugin-client/client'
|
|
90
|
+
*/
|
|
91
|
+
importPath?: string;
|
|
92
|
+
/**
|
|
93
|
+
* ReturnType that needs to be used when calling client().
|
|
94
|
+
*
|
|
95
|
+
* `Data` will return ResponseConfig[data].
|
|
96
|
+
*
|
|
97
|
+
* `Full` will return ResponseConfig.
|
|
98
|
+
* @default `'data'`
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
dataReturnType?: 'data' | 'full';
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* ReturnType that needs to be used when calling client().
|
|
105
|
+
*
|
|
106
|
+
* `Data` will return ResponseConfig[data].
|
|
107
|
+
*
|
|
108
|
+
* `Full` will return ResponseConfig.
|
|
109
|
+
* @default `'data'`
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
114
|
+
*/
|
|
115
|
+
exclude?: Array<Exclude>;
|
|
116
|
+
/**
|
|
117
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
118
|
+
*/
|
|
119
|
+
include?: Array<Include>;
|
|
120
|
+
/**
|
|
121
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
122
|
+
*/
|
|
123
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
124
|
+
/**
|
|
125
|
+
* How to pass your pathParams.
|
|
126
|
+
*
|
|
127
|
+
* `object` will return the pathParams as an object.
|
|
128
|
+
*
|
|
129
|
+
* `inline` will return the pathParams as comma separated params.
|
|
130
|
+
* @default `'inline'`
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
pathParamsType?: 'object' | 'inline';
|
|
134
|
+
/**
|
|
135
|
+
* When set, an infiniteQuery hooks will be added.
|
|
136
|
+
*/
|
|
137
|
+
infinite?: Partial<Infinite> | false;
|
|
138
|
+
/**
|
|
139
|
+
* Override some useQuery behaviours.
|
|
140
|
+
*/
|
|
141
|
+
query?: Partial<Query> | false;
|
|
142
|
+
/**
|
|
143
|
+
* Override some useMutation behaviours.
|
|
144
|
+
*/
|
|
145
|
+
mutation?: Mutation | false;
|
|
146
|
+
/**
|
|
147
|
+
* Which parser can be used before returning the data to `@tanstack/query`.
|
|
148
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
149
|
+
*/
|
|
150
|
+
parser?: 'client' | 'zod';
|
|
151
|
+
transformers?: {
|
|
152
|
+
/**
|
|
153
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
154
|
+
*/
|
|
155
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
type ResolvedOptions = {
|
|
159
|
+
output: Output;
|
|
160
|
+
baseURL: string | undefined;
|
|
161
|
+
client: Required<NonNullable<PluginVueQuery['options']['client']>>;
|
|
162
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
163
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
164
|
+
/**
|
|
165
|
+
* Only used of infinite
|
|
166
|
+
*/
|
|
167
|
+
infinite: NonNullable<Infinite> | false;
|
|
168
|
+
query: NonNullable<Required<Query>> | false;
|
|
169
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
170
|
+
};
|
|
171
|
+
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
172
|
+
|
|
173
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { PluginFactoryOptions, Output, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { HttpMethod } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
|
|
4
|
+
|
|
5
|
+
type Query = {
|
|
6
|
+
/**
|
|
7
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
8
|
+
*/
|
|
9
|
+
key: (key: unknown[]) => unknown[];
|
|
10
|
+
/**
|
|
11
|
+
* Define which HttpMethods can be used for queries
|
|
12
|
+
* @default ['get']
|
|
13
|
+
*/
|
|
14
|
+
methods: Array<HttpMethod>;
|
|
15
|
+
/**
|
|
16
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
17
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
18
|
+
* It allows both relative and absolute path.
|
|
19
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
20
|
+
* @default '@tanstack/react-query'
|
|
21
|
+
*/
|
|
22
|
+
importPath?: string;
|
|
23
|
+
};
|
|
24
|
+
type Mutation = {
|
|
25
|
+
/**
|
|
26
|
+
* Define which HttpMethods can be used for mutations
|
|
27
|
+
* @default ['post', 'put', 'delete']
|
|
28
|
+
*/
|
|
29
|
+
methods: Array<HttpMethod>;
|
|
30
|
+
/**
|
|
31
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
32
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
33
|
+
* It allows both relative and absolute path.
|
|
34
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
35
|
+
* @default '@tanstack/react-query'
|
|
36
|
+
*/
|
|
37
|
+
importPath?: string;
|
|
38
|
+
};
|
|
39
|
+
type Infinite = {
|
|
40
|
+
/**
|
|
41
|
+
* Specify the params key used for `pageParam`.
|
|
42
|
+
* Used inside `useInfiniteQuery`, `createInfiniteQueries`, `createInfiniteQuery`
|
|
43
|
+
* @default `'id'`
|
|
44
|
+
*/
|
|
45
|
+
queryParam: string;
|
|
46
|
+
/**
|
|
47
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
48
|
+
*/
|
|
49
|
+
cursorParam?: string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* The initial value, the value of the first page.
|
|
52
|
+
* @default `0`
|
|
53
|
+
*/
|
|
54
|
+
initialPageParam: unknown;
|
|
55
|
+
};
|
|
56
|
+
type Options = {
|
|
57
|
+
/**
|
|
58
|
+
* @default 'hooks'
|
|
59
|
+
*/
|
|
60
|
+
output?: Output;
|
|
61
|
+
/**
|
|
62
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
63
|
+
*/
|
|
64
|
+
group?: {
|
|
65
|
+
/**
|
|
66
|
+
* Tag will group based on the operation tag inside the Swagger file
|
|
67
|
+
*/
|
|
68
|
+
type: 'tag';
|
|
69
|
+
/**
|
|
70
|
+
* Relative path to save the grouped @tanstack/query hooks.
|
|
71
|
+
*
|
|
72
|
+
* `{{tag}}` will be replaced by the current tagName.
|
|
73
|
+
* @example `${output}/{{tag}}Controller` => `hooks/PetController`
|
|
74
|
+
* @default `${output}/{{tag}}Controller`
|
|
75
|
+
*/
|
|
76
|
+
output?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Name to be used for the `export * as {{exportAs}} from './`
|
|
79
|
+
* @default `"{{tag}}Hooks"`
|
|
80
|
+
*/
|
|
81
|
+
exportAs?: string;
|
|
82
|
+
};
|
|
83
|
+
client?: {
|
|
84
|
+
/**
|
|
85
|
+
* Path to the client that will be used to do the API calls.
|
|
86
|
+
* It will be used as `import client from '${client.importPath}'`.
|
|
87
|
+
* It allows both relative and absolute path.
|
|
88
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
89
|
+
* @default '@kubb/plugin-client/client'
|
|
90
|
+
*/
|
|
91
|
+
importPath?: string;
|
|
92
|
+
/**
|
|
93
|
+
* ReturnType that needs to be used when calling client().
|
|
94
|
+
*
|
|
95
|
+
* `Data` will return ResponseConfig[data].
|
|
96
|
+
*
|
|
97
|
+
* `Full` will return ResponseConfig.
|
|
98
|
+
* @default `'data'`
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
dataReturnType?: 'data' | 'full';
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* ReturnType that needs to be used when calling client().
|
|
105
|
+
*
|
|
106
|
+
* `Data` will return ResponseConfig[data].
|
|
107
|
+
*
|
|
108
|
+
* `Full` will return ResponseConfig.
|
|
109
|
+
* @default `'data'`
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
114
|
+
*/
|
|
115
|
+
exclude?: Array<Exclude>;
|
|
116
|
+
/**
|
|
117
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
118
|
+
*/
|
|
119
|
+
include?: Array<Include>;
|
|
120
|
+
/**
|
|
121
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
122
|
+
*/
|
|
123
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
124
|
+
/**
|
|
125
|
+
* How to pass your pathParams.
|
|
126
|
+
*
|
|
127
|
+
* `object` will return the pathParams as an object.
|
|
128
|
+
*
|
|
129
|
+
* `inline` will return the pathParams as comma separated params.
|
|
130
|
+
* @default `'inline'`
|
|
131
|
+
* @private
|
|
132
|
+
*/
|
|
133
|
+
pathParamsType?: 'object' | 'inline';
|
|
134
|
+
/**
|
|
135
|
+
* When set, an infiniteQuery hooks will be added.
|
|
136
|
+
*/
|
|
137
|
+
infinite?: Partial<Infinite> | false;
|
|
138
|
+
/**
|
|
139
|
+
* Override some useQuery behaviours.
|
|
140
|
+
*/
|
|
141
|
+
query?: Partial<Query> | false;
|
|
142
|
+
/**
|
|
143
|
+
* Override some useMutation behaviours.
|
|
144
|
+
*/
|
|
145
|
+
mutation?: Mutation | false;
|
|
146
|
+
/**
|
|
147
|
+
* Which parser can be used before returning the data to `@tanstack/query`.
|
|
148
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
149
|
+
*/
|
|
150
|
+
parser?: 'client' | 'zod';
|
|
151
|
+
transformers?: {
|
|
152
|
+
/**
|
|
153
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
154
|
+
*/
|
|
155
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
type ResolvedOptions = {
|
|
159
|
+
output: Output;
|
|
160
|
+
baseURL: string | undefined;
|
|
161
|
+
client: Required<NonNullable<PluginVueQuery['options']['client']>>;
|
|
162
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
163
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
164
|
+
/**
|
|
165
|
+
* Only used of infinite
|
|
166
|
+
*/
|
|
167
|
+
infinite: NonNullable<Infinite> | false;
|
|
168
|
+
query: NonNullable<Required<Query>> | false;
|
|
169
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
170
|
+
};
|
|
171
|
+
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
172
|
+
|
|
173
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P };
|
package/package.json
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/plugin-vue-query",
|
|
3
|
+
"version": "3.0.0-alpha.20",
|
|
4
|
+
"description": "Generator vue-query hooks",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"faker",
|
|
7
|
+
"faker.js",
|
|
8
|
+
"msw",
|
|
9
|
+
"mock",
|
|
10
|
+
"mocking",
|
|
11
|
+
"plugins",
|
|
12
|
+
"kubb",
|
|
13
|
+
"codegen",
|
|
14
|
+
"swagger",
|
|
15
|
+
"openapi"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git://github.com/kubb-labs/kubb.git",
|
|
20
|
+
"directory": "packages/plugin-vue-query"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Stijn Van Hulle <stijn@stijnvanhulle.be",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
|
+
"default": "./dist/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"./generators": {
|
|
33
|
+
"import": "./dist/generators.js",
|
|
34
|
+
"require": "./dist/generators.cjs",
|
|
35
|
+
"default": "./dist/generators.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./components": {
|
|
38
|
+
"import": "./dist/components.js",
|
|
39
|
+
"require": "./dist/components.cjs",
|
|
40
|
+
"default": "./dist/components.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json",
|
|
43
|
+
"./*": "./*"
|
|
44
|
+
},
|
|
45
|
+
"main": "dist/index.cjs",
|
|
46
|
+
"module": "dist/index.js",
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"typesVersions": {
|
|
49
|
+
"*": {
|
|
50
|
+
"components": [
|
|
51
|
+
"./dist/components.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"generators": [
|
|
54
|
+
"./dist/generators.d.ts"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"src",
|
|
60
|
+
"dist",
|
|
61
|
+
"!/**/**.test.**",
|
|
62
|
+
"!/**/__tests__/**"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@kubb/core": "3.0.0-alpha.20",
|
|
66
|
+
"@kubb/oas": "3.0.0-alpha.20",
|
|
67
|
+
"@kubb/fs": "3.0.0-alpha.20",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-alpha.20",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-alpha.20",
|
|
70
|
+
"@kubb/react": "3.0.0-alpha.20",
|
|
71
|
+
"@kubb/plugin-zod": "3.0.0-alpha.20"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/react": "^18.3.6",
|
|
75
|
+
"react": "^18.3.1",
|
|
76
|
+
"tsup": "^8.2.4",
|
|
77
|
+
"typescript": "^5.6.2",
|
|
78
|
+
"@kubb/config-ts": "3.0.0-alpha.20",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-alpha.20"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"@kubb/react": "3.0.0-alpha.20"
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=20"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public",
|
|
89
|
+
"registry": "https://registry.npmjs.org/"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "tsup",
|
|
93
|
+
"clean": "npx rimraf ./dist",
|
|
94
|
+
"lint": "bun biome lint .",
|
|
95
|
+
"lint:fix": "bun biome lint --apply-unsafe .",
|
|
96
|
+
"release": "pnpm publish --no-git-check",
|
|
97
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
98
|
+
"start": "tsup --watch",
|
|
99
|
+
"test": "vitest --passWithNoTests",
|
|
100
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
101
|
+
}
|
|
102
|
+
}
|