@kubb/plugin-vue-query 3.0.0-beta.10 → 3.0.0-beta.11
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-PGNSMLGU.cjs → chunk-DM6KQOMW.cjs} +11 -10
- package/dist/chunk-DM6KQOMW.cjs.map +1 -0
- package/dist/{chunk-YQOJHRKU.js → chunk-JOSO5JH4.js} +11 -10
- package/dist/chunk-JOSO5JH4.js.map +1 -0
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +15 -19
- 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 +14 -18
- package/dist/index.js.map +1 -1
- package/dist/{types-Dx6yZliF.d.cts → types-CJEMZz_Q.d.cts} +158 -11
- package/dist/{types-Dx6yZliF.d.ts → types-CJEMZz_Q.d.ts} +158 -11
- package/package.json +11 -11
- package/src/generators/infiniteQueryGenerator.tsx +1 -1
- package/src/generators/mutationGenerator.tsx +1 -1
- package/src/generators/queryGenerator.tsx +1 -1
- package/src/plugin.ts +13 -17
- package/src/types.ts +3 -3
- package/dist/chunk-PGNSMLGU.cjs.map +0 -1
- package/dist/chunk-YQOJHRKU.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAcO,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,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;AAAA;AACnC,GACF;AACF,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 { 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 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 query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/vue-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\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"]}
|
|
@@ -2,7 +2,7 @@ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/co
|
|
|
2
2
|
import { HttpMethod } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
|
-
type Options$
|
|
5
|
+
type Options$2 = {
|
|
6
6
|
/**
|
|
7
7
|
* Specify the export location for the files and define the behavior of the output
|
|
8
8
|
* @default { path: 'clients', barrelType: 'named' }
|
|
@@ -23,7 +23,7 @@ type Options$1 = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
25
25
|
*/
|
|
26
|
-
override?: Array<Override<ResolvedOptions$
|
|
26
|
+
override?: Array<Override<ResolvedOptions$2>>;
|
|
27
27
|
/**
|
|
28
28
|
* Create `operations.ts` file with all operations grouped by methods.
|
|
29
29
|
* @default false
|
|
@@ -36,6 +36,10 @@ type Options$1 = {
|
|
|
36
36
|
* @default '@kubb/plugin-client/client'
|
|
37
37
|
*/
|
|
38
38
|
importPath?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Allows you to set a custom base url for all generated calls.
|
|
41
|
+
*/
|
|
42
|
+
baseURL?: string;
|
|
39
43
|
/**
|
|
40
44
|
* ReturnType that will be used when calling the client.
|
|
41
45
|
* - 'data' will return ResponseConfig[data].
|
|
@@ -74,17 +78,159 @@ type Options$1 = {
|
|
|
74
78
|
*/
|
|
75
79
|
generators?: Array<Generator<PluginClient>>;
|
|
76
80
|
};
|
|
77
|
-
type ResolvedOptions$
|
|
81
|
+
type ResolvedOptions$2 = {
|
|
78
82
|
output: Output;
|
|
79
|
-
group?: Options$
|
|
83
|
+
group?: Options$2['group'];
|
|
80
84
|
baseURL: string | undefined;
|
|
81
|
-
parser: NonNullable<Options$
|
|
82
|
-
importPath: NonNullable<Options$
|
|
83
|
-
dataReturnType: NonNullable<Options$
|
|
85
|
+
parser: NonNullable<Options$2['parser']>;
|
|
86
|
+
importPath: NonNullable<Options$2['importPath']>;
|
|
87
|
+
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
|
+
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
|
+
paramsType: NonNullable<Options$2['paramsType']>;
|
|
90
|
+
};
|
|
91
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
|
+
|
|
93
|
+
type Suspense = object;
|
|
94
|
+
type Query$1 = {
|
|
95
|
+
/**
|
|
96
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
+
*/
|
|
98
|
+
key: (key: unknown[]) => unknown[];
|
|
99
|
+
/**
|
|
100
|
+
* Define which HttpMethods can be used for queries
|
|
101
|
+
* @default ['get']
|
|
102
|
+
*/
|
|
103
|
+
methods: Array<HttpMethod>;
|
|
104
|
+
/**
|
|
105
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
106
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
107
|
+
* It allows both relative and absolute path.
|
|
108
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
109
|
+
* @default '@tanstack/react-query'
|
|
110
|
+
*/
|
|
111
|
+
importPath?: string;
|
|
112
|
+
};
|
|
113
|
+
type Mutation$1 = {
|
|
114
|
+
/**
|
|
115
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
+
*/
|
|
117
|
+
key: (key: unknown[]) => unknown[];
|
|
118
|
+
/**
|
|
119
|
+
* Define which HttpMethods can be used for mutations
|
|
120
|
+
* @default ['post', 'put', 'delete']
|
|
121
|
+
*/
|
|
122
|
+
methods: Array<HttpMethod>;
|
|
123
|
+
/**
|
|
124
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
125
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
126
|
+
* It allows both relative and absolute path.
|
|
127
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
128
|
+
* @default '@tanstack/react-query'
|
|
129
|
+
*/
|
|
130
|
+
importPath?: string;
|
|
131
|
+
};
|
|
132
|
+
type Infinite$1 = {
|
|
133
|
+
/**
|
|
134
|
+
* Specify the params key used for `pageParam`.
|
|
135
|
+
* @default 'id'
|
|
136
|
+
*/
|
|
137
|
+
queryParam: string;
|
|
138
|
+
/**
|
|
139
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
140
|
+
*/
|
|
141
|
+
cursorParam?: string | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* The initial value, the value of the first page.
|
|
144
|
+
* @default 0
|
|
145
|
+
*/
|
|
146
|
+
initialPageParam: unknown;
|
|
147
|
+
};
|
|
148
|
+
type Options$1 = {
|
|
149
|
+
/**
|
|
150
|
+
* Specify the export location for the files and define the behavior of the output
|
|
151
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
152
|
+
*/
|
|
153
|
+
output?: Output;
|
|
154
|
+
/**
|
|
155
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
156
|
+
*/
|
|
157
|
+
group?: Group;
|
|
158
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
159
|
+
/**
|
|
160
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
161
|
+
*/
|
|
162
|
+
exclude?: Array<Exclude>;
|
|
163
|
+
/**
|
|
164
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
165
|
+
*/
|
|
166
|
+
include?: Array<Include>;
|
|
167
|
+
/**
|
|
168
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
169
|
+
*/
|
|
170
|
+
override?: Array<Override<ResolvedOptions$1>>;
|
|
171
|
+
/**
|
|
172
|
+
* How to pass your params
|
|
173
|
+
* - 'object' will return the params and pathParams as an object.
|
|
174
|
+
* - 'inline' will return the params as comma separated params.
|
|
175
|
+
* @default 'inline'
|
|
176
|
+
*/
|
|
177
|
+
paramsType?: 'object' | 'inline';
|
|
178
|
+
/**
|
|
179
|
+
* How to pass your pathParams.
|
|
180
|
+
* - 'object' will return the pathParams as an object.
|
|
181
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
182
|
+
* @default 'inline'
|
|
183
|
+
*/
|
|
184
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
185
|
+
/**
|
|
186
|
+
* When set, an infiniteQuery hooks will be added.
|
|
187
|
+
*/
|
|
188
|
+
infinite?: Partial<Infinite$1> | false;
|
|
189
|
+
/**
|
|
190
|
+
* When set, a suspenseQuery hooks will be added.
|
|
191
|
+
*/
|
|
192
|
+
suspense?: Partial<Suspense> | false;
|
|
193
|
+
/**
|
|
194
|
+
* Override some useQuery behaviours.
|
|
195
|
+
*/
|
|
196
|
+
query?: Partial<Query$1> | false;
|
|
197
|
+
/**
|
|
198
|
+
* Override some useMutation behaviours.
|
|
199
|
+
*/
|
|
200
|
+
mutation?: Partial<Mutation$1> | false;
|
|
201
|
+
/**
|
|
202
|
+
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
203
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
204
|
+
*/
|
|
205
|
+
parser?: PluginClient['options']['parser'];
|
|
206
|
+
transformers?: {
|
|
207
|
+
/**
|
|
208
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
209
|
+
*/
|
|
210
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Define some generators next to the react-query generators
|
|
214
|
+
*/
|
|
215
|
+
generators?: Array<Generator<PluginReactQuery>>;
|
|
216
|
+
};
|
|
217
|
+
type ResolvedOptions$1 = {
|
|
218
|
+
output: Output;
|
|
219
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
220
|
+
baseURL?: string;
|
|
221
|
+
};
|
|
222
|
+
parser: Required<NonNullable<Options$1['parser']>>;
|
|
84
223
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
85
224
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
225
|
+
/**
|
|
226
|
+
* Only used of infinite
|
|
227
|
+
*/
|
|
228
|
+
infinite: NonNullable<Infinite$1> | false;
|
|
229
|
+
suspense: Suspense | false;
|
|
230
|
+
query: NonNullable<Required<Query$1>> | false;
|
|
231
|
+
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
86
232
|
};
|
|
87
|
-
type
|
|
233
|
+
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
88
234
|
|
|
89
235
|
type Query = {
|
|
90
236
|
/**
|
|
@@ -150,7 +296,7 @@ type Options = {
|
|
|
150
296
|
* Group the @tanstack/query hooks based on the provided name.
|
|
151
297
|
*/
|
|
152
298
|
group?: Group;
|
|
153
|
-
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath'>;
|
|
299
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
154
300
|
/**
|
|
155
301
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
156
302
|
*/
|
|
@@ -207,8 +353,9 @@ type Options = {
|
|
|
207
353
|
};
|
|
208
354
|
type ResolvedOptions = {
|
|
209
355
|
output: Output;
|
|
210
|
-
|
|
211
|
-
|
|
356
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
357
|
+
baseURL?: string;
|
|
358
|
+
};
|
|
212
359
|
parser: Required<NonNullable<Options['parser']>>;
|
|
213
360
|
paramsType: NonNullable<Options['paramsType']>;
|
|
214
361
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
@@ -2,7 +2,7 @@ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/co
|
|
|
2
2
|
import { HttpMethod } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
|
-
type Options$
|
|
5
|
+
type Options$2 = {
|
|
6
6
|
/**
|
|
7
7
|
* Specify the export location for the files and define the behavior of the output
|
|
8
8
|
* @default { path: 'clients', barrelType: 'named' }
|
|
@@ -23,7 +23,7 @@ type Options$1 = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
25
25
|
*/
|
|
26
|
-
override?: Array<Override<ResolvedOptions$
|
|
26
|
+
override?: Array<Override<ResolvedOptions$2>>;
|
|
27
27
|
/**
|
|
28
28
|
* Create `operations.ts` file with all operations grouped by methods.
|
|
29
29
|
* @default false
|
|
@@ -36,6 +36,10 @@ type Options$1 = {
|
|
|
36
36
|
* @default '@kubb/plugin-client/client'
|
|
37
37
|
*/
|
|
38
38
|
importPath?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Allows you to set a custom base url for all generated calls.
|
|
41
|
+
*/
|
|
42
|
+
baseURL?: string;
|
|
39
43
|
/**
|
|
40
44
|
* ReturnType that will be used when calling the client.
|
|
41
45
|
* - 'data' will return ResponseConfig[data].
|
|
@@ -74,17 +78,159 @@ type Options$1 = {
|
|
|
74
78
|
*/
|
|
75
79
|
generators?: Array<Generator<PluginClient>>;
|
|
76
80
|
};
|
|
77
|
-
type ResolvedOptions$
|
|
81
|
+
type ResolvedOptions$2 = {
|
|
78
82
|
output: Output;
|
|
79
|
-
group?: Options$
|
|
83
|
+
group?: Options$2['group'];
|
|
80
84
|
baseURL: string | undefined;
|
|
81
|
-
parser: NonNullable<Options$
|
|
82
|
-
importPath: NonNullable<Options$
|
|
83
|
-
dataReturnType: NonNullable<Options$
|
|
85
|
+
parser: NonNullable<Options$2['parser']>;
|
|
86
|
+
importPath: NonNullable<Options$2['importPath']>;
|
|
87
|
+
dataReturnType: NonNullable<Options$2['dataReturnType']>;
|
|
88
|
+
pathParamsType: NonNullable<Options$2['pathParamsType']>;
|
|
89
|
+
paramsType: NonNullable<Options$2['paramsType']>;
|
|
90
|
+
};
|
|
91
|
+
type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
|
|
92
|
+
|
|
93
|
+
type Suspense = object;
|
|
94
|
+
type Query$1 = {
|
|
95
|
+
/**
|
|
96
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
97
|
+
*/
|
|
98
|
+
key: (key: unknown[]) => unknown[];
|
|
99
|
+
/**
|
|
100
|
+
* Define which HttpMethods can be used for queries
|
|
101
|
+
* @default ['get']
|
|
102
|
+
*/
|
|
103
|
+
methods: Array<HttpMethod>;
|
|
104
|
+
/**
|
|
105
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
106
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
107
|
+
* It allows both relative and absolute path.
|
|
108
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
109
|
+
* @default '@tanstack/react-query'
|
|
110
|
+
*/
|
|
111
|
+
importPath?: string;
|
|
112
|
+
};
|
|
113
|
+
type Mutation$1 = {
|
|
114
|
+
/**
|
|
115
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
116
|
+
*/
|
|
117
|
+
key: (key: unknown[]) => unknown[];
|
|
118
|
+
/**
|
|
119
|
+
* Define which HttpMethods can be used for mutations
|
|
120
|
+
* @default ['post', 'put', 'delete']
|
|
121
|
+
*/
|
|
122
|
+
methods: Array<HttpMethod>;
|
|
123
|
+
/**
|
|
124
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
125
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
126
|
+
* It allows both relative and absolute path.
|
|
127
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
128
|
+
* @default '@tanstack/react-query'
|
|
129
|
+
*/
|
|
130
|
+
importPath?: string;
|
|
131
|
+
};
|
|
132
|
+
type Infinite$1 = {
|
|
133
|
+
/**
|
|
134
|
+
* Specify the params key used for `pageParam`.
|
|
135
|
+
* @default 'id'
|
|
136
|
+
*/
|
|
137
|
+
queryParam: string;
|
|
138
|
+
/**
|
|
139
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
140
|
+
*/
|
|
141
|
+
cursorParam?: string | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* The initial value, the value of the first page.
|
|
144
|
+
* @default 0
|
|
145
|
+
*/
|
|
146
|
+
initialPageParam: unknown;
|
|
147
|
+
};
|
|
148
|
+
type Options$1 = {
|
|
149
|
+
/**
|
|
150
|
+
* Specify the export location for the files and define the behavior of the output
|
|
151
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
152
|
+
*/
|
|
153
|
+
output?: Output;
|
|
154
|
+
/**
|
|
155
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
156
|
+
*/
|
|
157
|
+
group?: Group;
|
|
158
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
159
|
+
/**
|
|
160
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
161
|
+
*/
|
|
162
|
+
exclude?: Array<Exclude>;
|
|
163
|
+
/**
|
|
164
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
165
|
+
*/
|
|
166
|
+
include?: Array<Include>;
|
|
167
|
+
/**
|
|
168
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
169
|
+
*/
|
|
170
|
+
override?: Array<Override<ResolvedOptions$1>>;
|
|
171
|
+
/**
|
|
172
|
+
* How to pass your params
|
|
173
|
+
* - 'object' will return the params and pathParams as an object.
|
|
174
|
+
* - 'inline' will return the params as comma separated params.
|
|
175
|
+
* @default 'inline'
|
|
176
|
+
*/
|
|
177
|
+
paramsType?: 'object' | 'inline';
|
|
178
|
+
/**
|
|
179
|
+
* How to pass your pathParams.
|
|
180
|
+
* - 'object' will return the pathParams as an object.
|
|
181
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
182
|
+
* @default 'inline'
|
|
183
|
+
*/
|
|
184
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
185
|
+
/**
|
|
186
|
+
* When set, an infiniteQuery hooks will be added.
|
|
187
|
+
*/
|
|
188
|
+
infinite?: Partial<Infinite$1> | false;
|
|
189
|
+
/**
|
|
190
|
+
* When set, a suspenseQuery hooks will be added.
|
|
191
|
+
*/
|
|
192
|
+
suspense?: Partial<Suspense> | false;
|
|
193
|
+
/**
|
|
194
|
+
* Override some useQuery behaviours.
|
|
195
|
+
*/
|
|
196
|
+
query?: Partial<Query$1> | false;
|
|
197
|
+
/**
|
|
198
|
+
* Override some useMutation behaviours.
|
|
199
|
+
*/
|
|
200
|
+
mutation?: Partial<Mutation$1> | false;
|
|
201
|
+
/**
|
|
202
|
+
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
203
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
204
|
+
*/
|
|
205
|
+
parser?: PluginClient['options']['parser'];
|
|
206
|
+
transformers?: {
|
|
207
|
+
/**
|
|
208
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
209
|
+
*/
|
|
210
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Define some generators next to the react-query generators
|
|
214
|
+
*/
|
|
215
|
+
generators?: Array<Generator<PluginReactQuery>>;
|
|
216
|
+
};
|
|
217
|
+
type ResolvedOptions$1 = {
|
|
218
|
+
output: Output;
|
|
219
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
220
|
+
baseURL?: string;
|
|
221
|
+
};
|
|
222
|
+
parser: Required<NonNullable<Options$1['parser']>>;
|
|
84
223
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
85
224
|
paramsType: NonNullable<Options$1['paramsType']>;
|
|
225
|
+
/**
|
|
226
|
+
* Only used of infinite
|
|
227
|
+
*/
|
|
228
|
+
infinite: NonNullable<Infinite$1> | false;
|
|
229
|
+
suspense: Suspense | false;
|
|
230
|
+
query: NonNullable<Required<Query$1>> | false;
|
|
231
|
+
mutation: NonNullable<Required<Mutation$1>> | false;
|
|
86
232
|
};
|
|
87
|
-
type
|
|
233
|
+
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
88
234
|
|
|
89
235
|
type Query = {
|
|
90
236
|
/**
|
|
@@ -150,7 +296,7 @@ type Options = {
|
|
|
150
296
|
* Group the @tanstack/query hooks based on the provided name.
|
|
151
297
|
*/
|
|
152
298
|
group?: Group;
|
|
153
|
-
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath'>;
|
|
299
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
154
300
|
/**
|
|
155
301
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
156
302
|
*/
|
|
@@ -207,8 +353,9 @@ type Options = {
|
|
|
207
353
|
};
|
|
208
354
|
type ResolvedOptions = {
|
|
209
355
|
output: Output;
|
|
210
|
-
|
|
211
|
-
|
|
356
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
357
|
+
baseURL?: string;
|
|
358
|
+
};
|
|
212
359
|
parser: Required<NonNullable<Options['parser']>>;
|
|
213
360
|
paramsType: NonNullable<Options['paramsType']>;
|
|
214
361
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
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.11",
|
|
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.11",
|
|
66
|
+
"@kubb/fs": "3.0.0-beta.11",
|
|
67
|
+
"@kubb/oas": "3.0.0-beta.11",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-beta.11",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-beta.11",
|
|
70
|
+
"@kubb/plugin-zod": "3.0.0-beta.11",
|
|
71
|
+
"@kubb/react": "3.0.0-beta.11"
|
|
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.11",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-beta.11"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-beta.
|
|
82
|
+
"@kubb/react": "3.0.0-beta.11"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
|
@@ -94,7 +94,7 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
94
94
|
name={client.name}
|
|
95
95
|
isExportable={false}
|
|
96
96
|
isIndexable={false}
|
|
97
|
-
baseURL={options.baseURL}
|
|
97
|
+
baseURL={options.client.baseURL}
|
|
98
98
|
operation={operation}
|
|
99
99
|
typeSchemas={type.schemas}
|
|
100
100
|
zodSchemas={zod.schemas}
|
|
@@ -84,7 +84,7 @@ export const mutationGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
84
84
|
name={client.name}
|
|
85
85
|
isExportable={false}
|
|
86
86
|
isIndexable={false}
|
|
87
|
-
baseURL={options.baseURL}
|
|
87
|
+
baseURL={options.client.baseURL}
|
|
88
88
|
operation={operation}
|
|
89
89
|
typeSchemas={type.schemas}
|
|
90
90
|
zodSchemas={zod.schemas}
|
|
@@ -91,7 +91,7 @@ export const queryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
91
91
|
name={client.name}
|
|
92
92
|
isExportable={false}
|
|
93
93
|
isIndexable={false}
|
|
94
|
-
baseURL={options.baseURL}
|
|
94
|
+
baseURL={options.client.baseURL}
|
|
95
95
|
operation={operation}
|
|
96
96
|
typeSchemas={type.schemas}
|
|
97
97
|
zodSchemas={zod.schemas}
|
package/src/plugin.ts
CHANGED
|
@@ -35,7 +35,6 @@ export const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {
|
|
|
35
35
|
name: pluginVueQueryName,
|
|
36
36
|
options: {
|
|
37
37
|
output,
|
|
38
|
-
baseURL: undefined,
|
|
39
38
|
client: {
|
|
40
39
|
importPath: '@kubb/plugin-client/client',
|
|
41
40
|
dataReturnType: 'data',
|
|
@@ -113,22 +112,19 @@ export const pluginVueQuery = createPlugin<PluginVueQuery>((options) => {
|
|
|
113
112
|
const mode = FileManager.getMode(path.resolve(root, output.path))
|
|
114
113
|
const baseURL = await swaggerPlugin.context.getBaseURL()
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
mode,
|
|
130
|
-
},
|
|
131
|
-
)
|
|
115
|
+
if (baseURL) {
|
|
116
|
+
this.plugin.options.client.baseURL = baseURL
|
|
117
|
+
}
|
|
118
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
119
|
+
oas,
|
|
120
|
+
pluginManager: this.pluginManager,
|
|
121
|
+
plugin: this.plugin,
|
|
122
|
+
contentType: swaggerPlugin.context.contentType,
|
|
123
|
+
exclude,
|
|
124
|
+
include,
|
|
125
|
+
override,
|
|
126
|
+
mode,
|
|
127
|
+
})
|
|
132
128
|
|
|
133
129
|
const files = await operationGenerator.build(...generators)
|
|
134
130
|
await this.addFile(...files)
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@ku
|
|
|
3
3
|
import type { HttpMethod } from '@kubb/oas'
|
|
4
4
|
import type { PluginClient } from '@kubb/plugin-client'
|
|
5
5
|
import type { Exclude, Generator, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
|
|
6
|
+
import type { PluginReactQuery } from '@kubb/plugin-react-query'
|
|
6
7
|
|
|
7
8
|
type Query = {
|
|
8
9
|
/**
|
|
@@ -71,7 +72,7 @@ export type Options = {
|
|
|
71
72
|
* Group the @tanstack/query hooks based on the provided name.
|
|
72
73
|
*/
|
|
73
74
|
group?: Group
|
|
74
|
-
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath'>
|
|
75
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
78
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
@@ -130,8 +131,7 @@ export type Options = {
|
|
|
130
131
|
|
|
131
132
|
type ResolvedOptions = {
|
|
132
133
|
output: Output
|
|
133
|
-
|
|
134
|
-
client: Required<NonNullable<PluginVueQuery['options']['client']>>
|
|
134
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & { baseURL?: string }
|
|
135
135
|
parser: Required<NonNullable<Options['parser']>>
|
|
136
136
|
paramsType: NonNullable<Options['paramsType']>
|
|
137
137
|
pathParamsType: NonNullable<Options['pathParamsType']>
|