@kubb/plugin-vue-query 3.0.0-beta.11 → 3.0.0-beta.12
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/dist/{chunk-DM6KQOMW.cjs → chunk-A7SD37VK.cjs} +94 -89
- package/dist/chunk-A7SD37VK.cjs.map +1 -0
- package/dist/{chunk-DWWRCRGY.js → chunk-DHJLKFYS.js} +22 -10
- package/dist/chunk-DHJLKFYS.js.map +1 -0
- package/dist/{chunk-5MY3SE2R.cjs → chunk-J4RZRRHQ.cjs} +22 -10
- package/dist/chunk-J4RZRRHQ.cjs.map +1 -0
- package/dist/{chunk-JOSO5JH4.js → chunk-O4EGNKUX.js} +86 -81
- package/dist/chunk-O4EGNKUX.js.map +1 -0
- package/dist/components.cjs +8 -8
- package/dist/components.d.cts +7 -5
- package/dist/components.d.ts +7 -5
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-CJEMZz_Q.d.cts → types-C8LfCZUP.d.cts} +37 -19
- package/dist/{types-CJEMZz_Q.d.ts → types-C8LfCZUP.d.ts} +37 -19
- package/package.json +11 -11
- package/src/components/MutationKey.tsx +11 -5
- package/src/components/QueryKey.tsx +17 -7
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/clientPostImportPath.ts +2 -2
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +1 -1
- package/src/generators/__snapshots__/postAsQuery.ts +1 -1
- package/src/generators/__snapshots__/updatePetById.ts +2 -2
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +2 -2
- package/src/generators/infiniteQueryGenerator.tsx +37 -32
- package/src/generators/mutationGenerator.tsx +21 -15
- package/src/generators/queryGenerator.tsx +21 -17
- package/src/plugin.ts +5 -2
- package/src/types.ts +23 -10
- package/dist/chunk-5MY3SE2R.cjs.map +0 -1
- package/dist/chunk-DM6KQOMW.cjs.map +0 -1
- package/dist/chunk-DWWRCRGY.js.map +0 -1
- package/dist/chunk-JOSO5JH4.js.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","MutationKey","QueryKey","queryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAeO,IAAM,kBAAqB,GAAA;AAErB,IAAA,cAAA,GAAiBA,iBAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IAC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AA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { 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 = 'inline',\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\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 queryKey,\n query: {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : 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 (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\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 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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 const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\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"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-O4EGNKUX.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-DHJLKFYS.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
5
|
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
@@ -22,6 +22,8 @@ var pluginVueQuery = createPlugin((options) => {
|
|
|
22
22
|
pathParamsType = "inline",
|
|
23
23
|
mutation = {},
|
|
24
24
|
query = {},
|
|
25
|
+
mutationKey = MutationKey.getTransformer,
|
|
26
|
+
queryKey = QueryKey.getTransformer,
|
|
25
27
|
generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean)
|
|
26
28
|
} = options;
|
|
27
29
|
return {
|
|
@@ -40,14 +42,14 @@ var pluginVueQuery = createPlugin((options) => {
|
|
|
40
42
|
cursorParam: void 0,
|
|
41
43
|
...infinite
|
|
42
44
|
} : false,
|
|
45
|
+
queryKey,
|
|
43
46
|
query: {
|
|
44
|
-
key: (key) => key,
|
|
45
47
|
methods: ["get"],
|
|
46
48
|
importPath: "@tanstack/vue-query",
|
|
47
49
|
...query
|
|
48
50
|
},
|
|
51
|
+
mutationKey,
|
|
49
52
|
mutation: {
|
|
50
|
-
key: (key) => key,
|
|
51
53
|
methods: ["post", "put", "patch", "delete"],
|
|
52
54
|
importPath: "@tanstack/vue-query",
|
|
53
55
|
...mutation
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAeO,IAAM,kBAAqB,GAAA;AAErB,IAAA,cAAA,GAAiB,YAA6B,CAAA,CAAC,OAAY,KAAA;AACtE,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,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,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,WAAW,EAAC;AAAA,IACZ,QAAQ,EAAC;AAAA,IACT,cAAc,WAAY,CAAA,cAAA;AAAA,IAC1B,WAAW,QAAS,CAAA,cAAA;AAAA,IACpB,aAAa,CAAC,cAAA,EAAgB,wBAAwB,iBAAiB,CAAA,CAAE,OAAO,OAAO;AAAA,GACrF,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,kBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,cAAg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CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\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 { 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 = 'inline',\n mutation = {},\n query = {},\n mutationKey = MutationKey.getTransformer,\n queryKey = QueryKey.getTransformer,\n generators = [queryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n } = options\n\n return {\n name: pluginVueQueryName,\n options: {\n output,\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 queryKey,\n query: {\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutationKey,\n mutation: {\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/vue-query',\n ...mutation,\n },\n paramsType,\n pathParamsType: paramsType === 'object' ? 'object' : 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 (options?.tag && group?.type === 'tag') {\n const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`\n\n return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)\n }\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 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 if (baseURL) {\n this.plugin.options.client.baseURL = baseURL\n }\n const operationGenerator = new OperationGenerator(this.plugin.options, {\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 const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
2
|
+
import { HttpMethod, Operation } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
6
6
|
/**
|
|
@@ -90,12 +90,21 @@ type ResolvedOptions$2 = {
|
|
|
90
90
|
};
|
|
91
91
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
92
|
|
|
93
|
+
type TransformerProps$1 = {
|
|
94
|
+
operation: Operation;
|
|
95
|
+
schemas: OperationSchemas;
|
|
96
|
+
};
|
|
97
|
+
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
93
98
|
type Suspense = object;
|
|
99
|
+
/**
|
|
100
|
+
* Customize the queryKey
|
|
101
|
+
*/
|
|
102
|
+
type QueryKey$1 = Transformer$1;
|
|
103
|
+
/**
|
|
104
|
+
* Customize the mutationKey
|
|
105
|
+
*/
|
|
106
|
+
type MutationKey$1 = Transformer$1;
|
|
94
107
|
type Query$1 = {
|
|
95
|
-
/**
|
|
96
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
-
*/
|
|
98
|
-
key: (key: unknown[]) => unknown[];
|
|
99
108
|
/**
|
|
100
109
|
* Define which HttpMethods can be used for queries
|
|
101
110
|
* @default ['get']
|
|
@@ -111,10 +120,6 @@ type Query$1 = {
|
|
|
111
120
|
importPath?: string;
|
|
112
121
|
};
|
|
113
122
|
type Mutation$1 = {
|
|
114
|
-
/**
|
|
115
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
-
*/
|
|
117
|
-
key: (key: unknown[]) => unknown[];
|
|
118
123
|
/**
|
|
119
124
|
* Define which HttpMethods can be used for mutations
|
|
120
125
|
* @default ['post', 'put', 'delete']
|
|
@@ -190,10 +195,12 @@ type Options$1 = {
|
|
|
190
195
|
* When set, a suspenseQuery hooks will be added.
|
|
191
196
|
*/
|
|
192
197
|
suspense?: Partial<Suspense> | false;
|
|
198
|
+
queryKey?: QueryKey$1;
|
|
193
199
|
/**
|
|
194
200
|
* Override some useQuery behaviours.
|
|
195
201
|
*/
|
|
196
202
|
query?: Partial<Query$1> | false;
|
|
203
|
+
mutationKey?: MutationKey$1;
|
|
197
204
|
/**
|
|
198
205
|
* Override some useMutation behaviours.
|
|
199
206
|
*/
|
|
@@ -227,16 +234,27 @@ type ResolvedOptions$1 = {
|
|
|
227
234
|
*/
|
|
228
235
|
infinite: NonNullable<Infinite$1> | false;
|
|
229
236
|
suspense: Suspense | false;
|
|
237
|
+
queryKey: QueryKey$1 | undefined;
|
|
230
238
|
query: NonNullable<Required<Query$1>> | false;
|
|
239
|
+
mutationKey: MutationKey$1 | undefined;
|
|
231
240
|
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
232
241
|
};
|
|
233
242
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
234
243
|
|
|
244
|
+
type TransformerProps = {
|
|
245
|
+
operation: Operation;
|
|
246
|
+
schemas: OperationSchemas;
|
|
247
|
+
};
|
|
248
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
|
+
/**
|
|
250
|
+
* Customize the queryKey
|
|
251
|
+
*/
|
|
252
|
+
type QueryKey = Transformer;
|
|
253
|
+
/**
|
|
254
|
+
* Customize the mutationKey
|
|
255
|
+
*/
|
|
256
|
+
type MutationKey = Transformer;
|
|
235
257
|
type Query = {
|
|
236
|
-
/**
|
|
237
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
238
|
-
*/
|
|
239
|
-
key: (key: unknown[]) => unknown[];
|
|
240
258
|
/**
|
|
241
259
|
* Define which HttpMethods can be used for queries
|
|
242
260
|
* @default ['get']
|
|
@@ -252,10 +270,6 @@ type Query = {
|
|
|
252
270
|
importPath?: string;
|
|
253
271
|
};
|
|
254
272
|
type Mutation = {
|
|
255
|
-
/**
|
|
256
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
257
|
-
*/
|
|
258
|
-
key: (key: unknown[]) => unknown[];
|
|
259
273
|
/**
|
|
260
274
|
* Define which HttpMethods can be used for mutations
|
|
261
275
|
* @default ['post', 'put', 'delete']
|
|
@@ -327,10 +341,12 @@ type Options = {
|
|
|
327
341
|
* When set, an infiniteQuery hooks will be added.
|
|
328
342
|
*/
|
|
329
343
|
infinite?: Partial<Infinite> | false;
|
|
344
|
+
queryKey?: QueryKey;
|
|
330
345
|
/**
|
|
331
346
|
* Override some useQuery behaviours.
|
|
332
347
|
*/
|
|
333
348
|
query?: Partial<Query> | false;
|
|
349
|
+
mutationKey?: MutationKey;
|
|
334
350
|
/**
|
|
335
351
|
* Override some useMutation behaviours.
|
|
336
352
|
*/
|
|
@@ -363,9 +379,11 @@ type ResolvedOptions = {
|
|
|
363
379
|
* Only used of infinite
|
|
364
380
|
*/
|
|
365
381
|
infinite: NonNullable<Infinite> | false;
|
|
382
|
+
queryKey: QueryKey | undefined;
|
|
366
383
|
query: NonNullable<Required<Query>> | false;
|
|
384
|
+
mutationKey: MutationKey | undefined;
|
|
367
385
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
368
386
|
};
|
|
369
387
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
370
388
|
|
|
371
|
-
export type { Infinite as I, Options as O, PluginVueQuery as P };
|
|
389
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod } from '@kubb/oas';
|
|
3
|
-
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
2
|
+
import { HttpMethod, Operation } from '@kubb/oas';
|
|
3
|
+
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
6
6
|
/**
|
|
@@ -90,12 +90,21 @@ type ResolvedOptions$2 = {
|
|
|
90
90
|
};
|
|
91
91
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
92
|
|
|
93
|
+
type TransformerProps$1 = {
|
|
94
|
+
operation: Operation;
|
|
95
|
+
schemas: OperationSchemas;
|
|
96
|
+
};
|
|
97
|
+
type Transformer$1 = (props: TransformerProps$1) => unknown[];
|
|
93
98
|
type Suspense = object;
|
|
99
|
+
/**
|
|
100
|
+
* Customize the queryKey
|
|
101
|
+
*/
|
|
102
|
+
type QueryKey$1 = Transformer$1;
|
|
103
|
+
/**
|
|
104
|
+
* Customize the mutationKey
|
|
105
|
+
*/
|
|
106
|
+
type MutationKey$1 = Transformer$1;
|
|
94
107
|
type Query$1 = {
|
|
95
|
-
/**
|
|
96
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
-
*/
|
|
98
|
-
key: (key: unknown[]) => unknown[];
|
|
99
108
|
/**
|
|
100
109
|
* Define which HttpMethods can be used for queries
|
|
101
110
|
* @default ['get']
|
|
@@ -111,10 +120,6 @@ type Query$1 = {
|
|
|
111
120
|
importPath?: string;
|
|
112
121
|
};
|
|
113
122
|
type Mutation$1 = {
|
|
114
|
-
/**
|
|
115
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
-
*/
|
|
117
|
-
key: (key: unknown[]) => unknown[];
|
|
118
123
|
/**
|
|
119
124
|
* Define which HttpMethods can be used for mutations
|
|
120
125
|
* @default ['post', 'put', 'delete']
|
|
@@ -190,10 +195,12 @@ type Options$1 = {
|
|
|
190
195
|
* When set, a suspenseQuery hooks will be added.
|
|
191
196
|
*/
|
|
192
197
|
suspense?: Partial<Suspense> | false;
|
|
198
|
+
queryKey?: QueryKey$1;
|
|
193
199
|
/**
|
|
194
200
|
* Override some useQuery behaviours.
|
|
195
201
|
*/
|
|
196
202
|
query?: Partial<Query$1> | false;
|
|
203
|
+
mutationKey?: MutationKey$1;
|
|
197
204
|
/**
|
|
198
205
|
* Override some useMutation behaviours.
|
|
199
206
|
*/
|
|
@@ -227,16 +234,27 @@ type ResolvedOptions$1 = {
|
|
|
227
234
|
*/
|
|
228
235
|
infinite: NonNullable<Infinite$1> | false;
|
|
229
236
|
suspense: Suspense | false;
|
|
237
|
+
queryKey: QueryKey$1 | undefined;
|
|
230
238
|
query: NonNullable<Required<Query$1>> | false;
|
|
239
|
+
mutationKey: MutationKey$1 | undefined;
|
|
231
240
|
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
232
241
|
};
|
|
233
242
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
234
243
|
|
|
244
|
+
type TransformerProps = {
|
|
245
|
+
operation: Operation;
|
|
246
|
+
schemas: OperationSchemas;
|
|
247
|
+
};
|
|
248
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
249
|
+
/**
|
|
250
|
+
* Customize the queryKey
|
|
251
|
+
*/
|
|
252
|
+
type QueryKey = Transformer;
|
|
253
|
+
/**
|
|
254
|
+
* Customize the mutationKey
|
|
255
|
+
*/
|
|
256
|
+
type MutationKey = Transformer;
|
|
235
257
|
type Query = {
|
|
236
|
-
/**
|
|
237
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
238
|
-
*/
|
|
239
|
-
key: (key: unknown[]) => unknown[];
|
|
240
258
|
/**
|
|
241
259
|
* Define which HttpMethods can be used for queries
|
|
242
260
|
* @default ['get']
|
|
@@ -252,10 +270,6 @@ type Query = {
|
|
|
252
270
|
importPath?: string;
|
|
253
271
|
};
|
|
254
272
|
type Mutation = {
|
|
255
|
-
/**
|
|
256
|
-
* Customize the queryKey, here you can specify a suffix.
|
|
257
|
-
*/
|
|
258
|
-
key: (key: unknown[]) => unknown[];
|
|
259
273
|
/**
|
|
260
274
|
* Define which HttpMethods can be used for mutations
|
|
261
275
|
* @default ['post', 'put', 'delete']
|
|
@@ -327,10 +341,12 @@ type Options = {
|
|
|
327
341
|
* When set, an infiniteQuery hooks will be added.
|
|
328
342
|
*/
|
|
329
343
|
infinite?: Partial<Infinite> | false;
|
|
344
|
+
queryKey?: QueryKey;
|
|
330
345
|
/**
|
|
331
346
|
* Override some useQuery behaviours.
|
|
332
347
|
*/
|
|
333
348
|
query?: Partial<Query> | false;
|
|
349
|
+
mutationKey?: MutationKey;
|
|
334
350
|
/**
|
|
335
351
|
* Override some useMutation behaviours.
|
|
336
352
|
*/
|
|
@@ -363,9 +379,11 @@ type ResolvedOptions = {
|
|
|
363
379
|
* Only used of infinite
|
|
364
380
|
*/
|
|
365
381
|
infinite: NonNullable<Infinite> | false;
|
|
382
|
+
queryKey: QueryKey | undefined;
|
|
366
383
|
query: NonNullable<Required<Query>> | false;
|
|
384
|
+
mutationKey: MutationKey | undefined;
|
|
367
385
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
368
386
|
};
|
|
369
387
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
370
388
|
|
|
371
|
-
export type { Infinite as I, Options as O, PluginVueQuery as P };
|
|
389
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.12",
|
|
4
4
|
"description": "Generator vue-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@kubb/core": "3.0.0-beta.
|
|
66
|
-
"@kubb/fs": "3.0.0-beta.
|
|
67
|
-
"@kubb/oas": "3.0.0-beta.
|
|
68
|
-
"@kubb/plugin-oas": "3.0.0-beta.
|
|
69
|
-
"@kubb/plugin-ts": "3.0.0-beta.
|
|
70
|
-
"@kubb/plugin-zod": "3.0.0-beta.
|
|
71
|
-
"@kubb/react": "3.0.0-beta.
|
|
65
|
+
"@kubb/core": "3.0.0-beta.12",
|
|
66
|
+
"@kubb/fs": "3.0.0-beta.12",
|
|
67
|
+
"@kubb/oas": "3.0.0-beta.12",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-beta.12",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-beta.12",
|
|
70
|
+
"@kubb/plugin-zod": "3.0.0-beta.12",
|
|
71
|
+
"@kubb/react": "3.0.0-beta.12"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.12",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsup": "^8.3.5",
|
|
77
77
|
"typescript": "^5.6.3",
|
|
78
|
-
"@kubb/config-ts": "3.0.0-beta.
|
|
79
|
-
"@kubb/config-tsup": "3.0.0-beta.
|
|
78
|
+
"@kubb/config-ts": "3.0.0-beta.12",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-beta.12"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-beta.
|
|
82
|
+
"@kubb/react": "3.0.0-beta.12"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
|
@@ -4,7 +4,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
|
|
|
4
4
|
import type { Operation } from '@kubb/oas'
|
|
5
5
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
6
6
|
import type { ReactNode } from 'react'
|
|
7
|
-
import type { PluginVueQuery } from '../types'
|
|
7
|
+
import type { PluginVueQuery, Transformer } from '../types'
|
|
8
8
|
|
|
9
9
|
type Props = {
|
|
10
10
|
name: string
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
typeSchemas: OperationSchemas
|
|
13
13
|
operation: Operation
|
|
14
14
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
15
|
-
|
|
15
|
+
transformer: Transformer | undefined
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
type GetParamsProps = {
|
|
@@ -24,16 +24,21 @@ function getParams({}: GetParamsProps) {
|
|
|
24
24
|
return FunctionParams.factory({})
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const getTransformer: Transformer = ({ operation }) => {
|
|
28
28
|
const path = new URLPath(operation.path)
|
|
29
|
+
|
|
30
|
+
return [JSON.stringify({ url: path.path })].filter(Boolean)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
29
34
|
const params = getParams({ pathParamsType, typeSchemas })
|
|
30
|
-
const keys =
|
|
35
|
+
const keys = transformer({ operation, schemas: typeSchemas })
|
|
31
36
|
|
|
32
37
|
return (
|
|
33
38
|
<>
|
|
34
39
|
<File.Source name={name} isExportable isIndexable>
|
|
35
40
|
<Function.Arrow name={name} export params={params.toConstructor()} singleLine>
|
|
36
|
-
{`[${
|
|
41
|
+
{`[${keys.join(', ')}] as const`}
|
|
37
42
|
</Function.Arrow>
|
|
38
43
|
</File.Source>
|
|
39
44
|
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
@@ -46,3 +51,4 @@ export function MutationKey({ name, typeSchemas, pathParamsType, operation, type
|
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
MutationKey.getParams = getParams
|
|
54
|
+
MutationKey.getTransformer = getTransformer
|
|
@@ -5,7 +5,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
|
|
|
5
5
|
import { type Operation, isOptional } from '@kubb/oas'
|
|
6
6
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
7
7
|
import type { ReactNode } from 'react'
|
|
8
|
-
import type { PluginVueQuery } from '../types'
|
|
8
|
+
import type { PluginVueQuery, Transformer } from '../types'
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
11
|
name: string
|
|
@@ -13,7 +13,7 @@ type Props = {
|
|
|
13
13
|
typeSchemas: OperationSchemas
|
|
14
14
|
operation: Operation
|
|
15
15
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
16
|
-
|
|
16
|
+
transformer: Transformer | undefined
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
type GetParamsProps = {
|
|
@@ -50,23 +50,32 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
|
|
|
50
50
|
})
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
const getTransformer: Transformer = ({ operation, schemas }) => {
|
|
54
54
|
const path = new URLPath(operation.path)
|
|
55
|
-
const params = getParams({ pathParamsType, typeSchemas })
|
|
56
55
|
const keys = [
|
|
57
56
|
path.toObject({
|
|
58
57
|
type: 'path',
|
|
59
58
|
stringify: true,
|
|
60
59
|
}),
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
|
|
61
|
+
schemas.request?.name ? '...(data ? [data] : [])' : undefined,
|
|
63
62
|
].filter(Boolean)
|
|
64
63
|
|
|
64
|
+
return keys
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
|
|
68
|
+
const params = getParams({ pathParamsType, typeSchemas })
|
|
69
|
+
const keys = transformer({
|
|
70
|
+
operation,
|
|
71
|
+
schemas: typeSchemas,
|
|
72
|
+
})
|
|
73
|
+
|
|
65
74
|
return (
|
|
66
75
|
<>
|
|
67
76
|
<File.Source name={name} isExportable isIndexable>
|
|
68
77
|
<Function.Arrow name={name} export params={params.toConstructor()} singleLine>
|
|
69
|
-
{`[${
|
|
78
|
+
{`[${keys.join(', ')}] as const`}
|
|
70
79
|
</Function.Arrow>
|
|
71
80
|
</File.Source>
|
|
72
81
|
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
@@ -79,3 +88,4 @@ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeNam
|
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
QueryKey.getParams = getParams
|
|
91
|
+
QueryKey.getTransformer = getTransformer
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -2,7 +2,7 @@ import client from "axios";
|
|
|
2
2
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
|
-
import type { MutationObserverOptions } from "@tanstack/
|
|
2
|
+
import type { MutationObserverOptions } from "@tanstack/vue-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import { useMutation } from "@tanstack/
|
|
5
|
+
import { useMutation } from "@tanstack/vue-query";
|
|
6
6
|
|
|
7
7
|
export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -2,10 +2,10 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
|
-
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [test, { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
8
|
+
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => ["test", { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
9
9
|
|
|
10
10
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
|
|
11
11
|
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { queryOptions, useQuery } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
7
7
|
|
|
8
8
|
export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
|
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
3
|
import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
|
|
6
6
|
|
|
7
7
|
export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
|
|
8
8
|
|