@kubb/plugin-vue-query 3.4.4 → 3.5.0
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-HUKJLE4A.cjs +424 -0
- package/dist/chunk-HUKJLE4A.cjs.map +1 -0
- package/dist/chunk-VTRFZL5E.js +420 -0
- package/dist/chunk-VTRFZL5E.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 +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{types-B6HlLDzG.d.cts → types-DKq2nW8w.d.cts} +7 -7
- package/dist/{types-B6HlLDzG.d.ts → types-DKq2nW8w.d.ts} +7 -7
- package/package.json +11 -11
- package/src/generators/infiniteQueryGenerator.tsx +10 -3
- package/src/generators/mutationGenerator.tsx +10 -2
- package/src/generators/queryGenerator.tsx +10 -2
- package/src/types.ts +3 -3
- package/dist/chunk-KQSFBSYB.js +0 -386
- package/dist/chunk-KQSFBSYB.js.map +0 -1
- package/dist/chunk-P5FF4CZ7.cjs +0 -390
- package/dist/chunk-P5FF4CZ7.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod, Operation } from '@kubb/oas';
|
|
2
|
+
import { Oas, HttpMethod, Operation } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
@@ -7,7 +7,7 @@ type Options$2 = {
|
|
|
7
7
|
* Specify the export location for the files and define the behavior of the output
|
|
8
8
|
* @default { path: 'clients', barrelType: 'named' }
|
|
9
9
|
*/
|
|
10
|
-
output?: Output
|
|
10
|
+
output?: Output<Oas>;
|
|
11
11
|
/**
|
|
12
12
|
* Group the clients based on the provided name.
|
|
13
13
|
*/
|
|
@@ -91,7 +91,7 @@ type Options$2 = {
|
|
|
91
91
|
generators?: Array<Generator<PluginClient>>;
|
|
92
92
|
};
|
|
93
93
|
type ResolvedOptions$2 = {
|
|
94
|
-
output: Output
|
|
94
|
+
output: Output<Oas>;
|
|
95
95
|
group?: Options$2['group'];
|
|
96
96
|
baseURL: string | undefined;
|
|
97
97
|
parser: NonNullable<Options$2['parser']>;
|
|
@@ -169,7 +169,7 @@ type Options$1 = {
|
|
|
169
169
|
* Specify the export location for the files and define the behavior of the output
|
|
170
170
|
* @default { path: 'hooks', barrelType: 'named' }
|
|
171
171
|
*/
|
|
172
|
-
output?: Output
|
|
172
|
+
output?: Output<Oas>;
|
|
173
173
|
/**
|
|
174
174
|
* Group the @tanstack/query hooks based on the provided name.
|
|
175
175
|
*/
|
|
@@ -241,7 +241,7 @@ type Options$1 = {
|
|
|
241
241
|
generators?: Array<Generator<PluginReactQuery>>;
|
|
242
242
|
};
|
|
243
243
|
type ResolvedOptions$1 = {
|
|
244
|
-
output: Output
|
|
244
|
+
output: Output<Oas>;
|
|
245
245
|
group: Options$1['group'];
|
|
246
246
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
247
247
|
baseURL?: string;
|
|
@@ -327,7 +327,7 @@ type Options = {
|
|
|
327
327
|
* Specify the export location for the files and define the behavior of the output
|
|
328
328
|
* @default { path: 'hooks', barrelType: 'named' }
|
|
329
329
|
*/
|
|
330
|
-
output?: Output
|
|
330
|
+
output?: Output<Oas>;
|
|
331
331
|
/**
|
|
332
332
|
* Group the @tanstack/query hooks based on the provided name.
|
|
333
333
|
*/
|
|
@@ -395,7 +395,7 @@ type Options = {
|
|
|
395
395
|
generators?: Array<Generator<PluginVueQuery>>;
|
|
396
396
|
};
|
|
397
397
|
type ResolvedOptions = {
|
|
398
|
-
output: Output
|
|
398
|
+
output: Output<Oas>;
|
|
399
399
|
group: Options['group'];
|
|
400
400
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
401
401
|
baseURL?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { HttpMethod, Operation } from '@kubb/oas';
|
|
2
|
+
import { Oas, HttpMethod, Operation } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options$2 = {
|
|
@@ -7,7 +7,7 @@ type Options$2 = {
|
|
|
7
7
|
* Specify the export location for the files and define the behavior of the output
|
|
8
8
|
* @default { path: 'clients', barrelType: 'named' }
|
|
9
9
|
*/
|
|
10
|
-
output?: Output
|
|
10
|
+
output?: Output<Oas>;
|
|
11
11
|
/**
|
|
12
12
|
* Group the clients based on the provided name.
|
|
13
13
|
*/
|
|
@@ -91,7 +91,7 @@ type Options$2 = {
|
|
|
91
91
|
generators?: Array<Generator<PluginClient>>;
|
|
92
92
|
};
|
|
93
93
|
type ResolvedOptions$2 = {
|
|
94
|
-
output: Output
|
|
94
|
+
output: Output<Oas>;
|
|
95
95
|
group?: Options$2['group'];
|
|
96
96
|
baseURL: string | undefined;
|
|
97
97
|
parser: NonNullable<Options$2['parser']>;
|
|
@@ -169,7 +169,7 @@ type Options$1 = {
|
|
|
169
169
|
* Specify the export location for the files and define the behavior of the output
|
|
170
170
|
* @default { path: 'hooks', barrelType: 'named' }
|
|
171
171
|
*/
|
|
172
|
-
output?: Output
|
|
172
|
+
output?: Output<Oas>;
|
|
173
173
|
/**
|
|
174
174
|
* Group the @tanstack/query hooks based on the provided name.
|
|
175
175
|
*/
|
|
@@ -241,7 +241,7 @@ type Options$1 = {
|
|
|
241
241
|
generators?: Array<Generator<PluginReactQuery>>;
|
|
242
242
|
};
|
|
243
243
|
type ResolvedOptions$1 = {
|
|
244
|
-
output: Output
|
|
244
|
+
output: Output<Oas>;
|
|
245
245
|
group: Options$1['group'];
|
|
246
246
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
247
247
|
baseURL?: string;
|
|
@@ -327,7 +327,7 @@ type Options = {
|
|
|
327
327
|
* Specify the export location for the files and define the behavior of the output
|
|
328
328
|
* @default { path: 'hooks', barrelType: 'named' }
|
|
329
329
|
*/
|
|
330
|
-
output?: Output
|
|
330
|
+
output?: Output<Oas>;
|
|
331
331
|
/**
|
|
332
332
|
* Group the @tanstack/query hooks based on the provided name.
|
|
333
333
|
*/
|
|
@@ -395,7 +395,7 @@ type Options = {
|
|
|
395
395
|
generators?: Array<Generator<PluginVueQuery>>;
|
|
396
396
|
};
|
|
397
397
|
type ResolvedOptions = {
|
|
398
|
-
output: Output
|
|
398
|
+
output: Output<Oas>;
|
|
399
399
|
group: Options['group'];
|
|
400
400
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
401
401
|
baseURL?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Generator vue-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -63,21 +63,21 @@
|
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"remeda": "^2.19.0",
|
|
66
|
-
"@kubb/core": "3.
|
|
67
|
-
"@kubb/fs": "3.
|
|
68
|
-
"@kubb/oas": "3.
|
|
69
|
-
"@kubb/plugin-oas": "3.
|
|
70
|
-
"@kubb/plugin-ts": "3.
|
|
71
|
-
"@kubb/plugin-zod": "3.
|
|
72
|
-
"@kubb/react": "3.
|
|
66
|
+
"@kubb/core": "3.5.0",
|
|
67
|
+
"@kubb/fs": "3.5.0",
|
|
68
|
+
"@kubb/oas": "3.5.0",
|
|
69
|
+
"@kubb/plugin-oas": "3.5.0",
|
|
70
|
+
"@kubb/plugin-ts": "3.5.0",
|
|
71
|
+
"@kubb/plugin-zod": "3.5.0",
|
|
72
|
+
"@kubb/react": "3.5.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/react": "^18.3.18",
|
|
76
76
|
"react": "^18.3.1",
|
|
77
77
|
"tsup": "^8.3.5",
|
|
78
|
-
"typescript": "^5.7.
|
|
79
|
-
"@kubb/config-ts": "3.
|
|
80
|
-
"@kubb/config-tsup": "3.
|
|
78
|
+
"typescript": "^5.7.3",
|
|
79
|
+
"@kubb/config-ts": "3.5.0",
|
|
80
|
+
"@kubb/config-tsup": "3.5.0"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@kubb/react": "^3.0.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { pluginClientName } from '@kubb/plugin-client'
|
|
2
1
|
import { Client } from '@kubb/plugin-client/components'
|
|
3
2
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
4
|
-
import { useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
|
+
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
|
+
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
5
5
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
6
6
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
7
7
|
import { File, useApp } from '@kubb/react'
|
|
@@ -17,6 +17,7 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
17
17
|
options: { output },
|
|
18
18
|
},
|
|
19
19
|
} = useApp<PluginVueQuery>()
|
|
20
|
+
const oas = useOas()
|
|
20
21
|
const { getSchemas, getName, getFile } = useOperationManager()
|
|
21
22
|
|
|
22
23
|
const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
|
|
@@ -61,7 +62,13 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
return (
|
|
64
|
-
<File
|
|
65
|
+
<File
|
|
66
|
+
baseName={query.file.baseName}
|
|
67
|
+
path={query.file.path}
|
|
68
|
+
meta={query.file.meta}
|
|
69
|
+
banner={getBanner({ oas, output })}
|
|
70
|
+
footer={getFooter({ oas, output })}
|
|
71
|
+
>
|
|
65
72
|
{options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
|
|
66
73
|
<File.Import name={['unref']} path="vue" />
|
|
67
74
|
<File.Import name={['MaybeRef']} path="vue" isTypeOnly />
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { pluginClientName } from '@kubb/plugin-client'
|
|
2
2
|
import { Client } from '@kubb/plugin-client/components'
|
|
3
3
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
4
|
-
import { useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
|
+
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
5
|
+
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
5
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
6
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
7
8
|
import { File, useApp } from '@kubb/react'
|
|
@@ -17,6 +18,7 @@ export const mutationGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
17
18
|
options: { output },
|
|
18
19
|
},
|
|
19
20
|
} = useApp<PluginVueQuery>()
|
|
21
|
+
const oas = useOas()
|
|
20
22
|
const { getSchemas, getName, getFile } = useOperationManager()
|
|
21
23
|
|
|
22
24
|
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)
|
|
@@ -57,7 +59,13 @@ export const mutationGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
return (
|
|
60
|
-
<File
|
|
62
|
+
<File
|
|
63
|
+
baseName={mutation.file.baseName}
|
|
64
|
+
path={mutation.file.path}
|
|
65
|
+
meta={mutation.file.meta}
|
|
66
|
+
banner={getBanner({ oas, output })}
|
|
67
|
+
footer={getFooter({ oas, output })}
|
|
68
|
+
>
|
|
61
69
|
{options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}
|
|
62
70
|
<File.Import name={['MaybeRef']} path="vue" isTypeOnly />
|
|
63
71
|
<File.Import name={'client'} path={options.client.importPath} />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client } from '@kubb/plugin-client/components'
|
|
2
2
|
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
3
|
-
import { useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
3
|
+
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
|
+
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
4
5
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
5
6
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
6
7
|
import { File, useApp } from '@kubb/react'
|
|
@@ -16,6 +17,7 @@ export const queryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
16
17
|
options: { output },
|
|
17
18
|
},
|
|
18
19
|
} = useApp<PluginVueQuery>()
|
|
20
|
+
const oas = useOas()
|
|
19
21
|
const { getSchemas, getName, getFile } = useOperationManager()
|
|
20
22
|
|
|
21
23
|
const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
|
|
@@ -59,7 +61,13 @@ export const queryGenerator = createReactGenerator<PluginVueQuery>({
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
return (
|
|
62
|
-
<File
|
|
64
|
+
<File
|
|
65
|
+
baseName={query.file.baseName}
|
|
66
|
+
path={query.file.path}
|
|
67
|
+
meta={query.file.meta}
|
|
68
|
+
banner={getBanner({ oas, output })}
|
|
69
|
+
footer={getFooter({ oas, output })}
|
|
70
|
+
>
|
|
63
71
|
{options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
|
|
64
72
|
<File.Import name={['unref']} path="vue" />
|
|
65
73
|
<File.Import name={['MaybeRef']} path="vue" isTypeOnly />
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
|
|
2
2
|
|
|
3
|
-
import type { HttpMethod, Operation } from '@kubb/oas'
|
|
3
|
+
import type { HttpMethod, Oas, Operation } from '@kubb/oas'
|
|
4
4
|
import type { PluginClient } from '@kubb/plugin-client'
|
|
5
5
|
import type { Exclude, Generator, Include, OperationSchemas, Override, ResolvePathOptions } from '@kubb/plugin-oas'
|
|
6
6
|
import type { PluginReactQuery } from '@kubb/plugin-react-query'
|
|
@@ -77,7 +77,7 @@ export type Options = {
|
|
|
77
77
|
* Specify the export location for the files and define the behavior of the output
|
|
78
78
|
* @default { path: 'hooks', barrelType: 'named' }
|
|
79
79
|
*/
|
|
80
|
-
output?: Output
|
|
80
|
+
output?: Output<Oas>
|
|
81
81
|
/**
|
|
82
82
|
* Group the @tanstack/query hooks based on the provided name.
|
|
83
83
|
*/
|
|
@@ -147,7 +147,7 @@ export type Options = {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
type ResolvedOptions = {
|
|
150
|
-
output: Output
|
|
150
|
+
output: Output<Oas>
|
|
151
151
|
group: Options['group']
|
|
152
152
|
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & { baseURL?: string }
|
|
153
153
|
parser: Required<NonNullable<Options['parser']>>
|
package/dist/chunk-KQSFBSYB.js
DELETED
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { QueryKey, Client, QueryOptions, Query, MutationKey, Mutation, InfiniteQueryOptions, InfiniteQuery } from './chunk-N6FQE7MO.js';
|
|
2
|
-
import { createReactGenerator } from '@kubb/plugin-oas';
|
|
3
|
-
import { useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
4
|
-
import { pluginTsName } from '@kubb/plugin-ts';
|
|
5
|
-
import { pluginZodName } from '@kubb/plugin-zod';
|
|
6
|
-
import { useApp, File } from '@kubb/react';
|
|
7
|
-
import { difference } from 'remeda';
|
|
8
|
-
import { jsxs, jsx, Fragment } from '@kubb/react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
var queryGenerator = createReactGenerator({
|
|
11
|
-
name: "vue-query",
|
|
12
|
-
Operation({ options, operation }) {
|
|
13
|
-
const {
|
|
14
|
-
plugin: {
|
|
15
|
-
options: { output }
|
|
16
|
-
}
|
|
17
|
-
} = useApp();
|
|
18
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
19
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
20
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
21
|
-
(method) => operation.method === method
|
|
22
|
-
);
|
|
23
|
-
const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
|
|
24
|
-
const query = {
|
|
25
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
26
|
-
typeName: getName(operation, { type: "type" }),
|
|
27
|
-
file: getFile(operation, { prefix: "use" })
|
|
28
|
-
};
|
|
29
|
-
const client = {
|
|
30
|
-
name: getName(operation, { type: "function" })
|
|
31
|
-
};
|
|
32
|
-
const queryOptions = {
|
|
33
|
-
name: getName(operation, { type: "function", suffix: "QueryOptions" })
|
|
34
|
-
};
|
|
35
|
-
const queryKey = {
|
|
36
|
-
name: getName(operation, { type: "const", suffix: "QueryKey" }),
|
|
37
|
-
typeName: getName(operation, { type: "type", suffix: "QueryKey" })
|
|
38
|
-
};
|
|
39
|
-
const type = {
|
|
40
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
41
|
-
//todo remove type?
|
|
42
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
43
|
-
};
|
|
44
|
-
const zod = {
|
|
45
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
46
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
47
|
-
};
|
|
48
|
-
if (!isQuery || isMutation) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
52
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
|
|
53
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["unref"], path: "vue" }),
|
|
54
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
|
|
55
|
-
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
56
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
57
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
58
|
-
/* @__PURE__ */ jsx(
|
|
59
|
-
File.Import,
|
|
60
|
-
{
|
|
61
|
-
name: [
|
|
62
|
-
type.schemas.request?.name,
|
|
63
|
-
type.schemas.response.name,
|
|
64
|
-
type.schemas.pathParams?.name,
|
|
65
|
-
type.schemas.queryParams?.name,
|
|
66
|
-
type.schemas.headerParams?.name,
|
|
67
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
68
|
-
].filter(Boolean),
|
|
69
|
-
root: query.file.path,
|
|
70
|
-
path: type.file.path,
|
|
71
|
-
isTypeOnly: true
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
/* @__PURE__ */ jsx(
|
|
75
|
-
QueryKey,
|
|
76
|
-
{
|
|
77
|
-
name: queryKey.name,
|
|
78
|
-
typeName: queryKey.typeName,
|
|
79
|
-
operation,
|
|
80
|
-
paramsCasing: options.paramsCasing,
|
|
81
|
-
pathParamsType: options.pathParamsType,
|
|
82
|
-
typeSchemas: type.schemas,
|
|
83
|
-
transformer: options.queryKey
|
|
84
|
-
}
|
|
85
|
-
),
|
|
86
|
-
/* @__PURE__ */ jsx(
|
|
87
|
-
Client,
|
|
88
|
-
{
|
|
89
|
-
name: client.name,
|
|
90
|
-
isExportable: false,
|
|
91
|
-
isIndexable: false,
|
|
92
|
-
baseURL: options.client.baseURL,
|
|
93
|
-
operation,
|
|
94
|
-
typeSchemas: type.schemas,
|
|
95
|
-
zodSchemas: zod.schemas,
|
|
96
|
-
dataReturnType: options.client.dataReturnType,
|
|
97
|
-
paramsCasing: options.paramsCasing,
|
|
98
|
-
paramsType: options.paramsType,
|
|
99
|
-
pathParamsType: options.pathParamsType,
|
|
100
|
-
parser: options.parser
|
|
101
|
-
}
|
|
102
|
-
),
|
|
103
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["queryOptions"], path: importPath }),
|
|
104
|
-
/* @__PURE__ */ jsx(
|
|
105
|
-
QueryOptions,
|
|
106
|
-
{
|
|
107
|
-
name: queryOptions.name,
|
|
108
|
-
clientName: client.name,
|
|
109
|
-
queryKeyName: queryKey.name,
|
|
110
|
-
paramsCasing: options.paramsCasing,
|
|
111
|
-
typeSchemas: type.schemas,
|
|
112
|
-
paramsType: options.paramsType,
|
|
113
|
-
pathParamsType: options.pathParamsType,
|
|
114
|
-
dataReturnType: options.client.dataReturnType
|
|
115
|
-
}
|
|
116
|
-
),
|
|
117
|
-
options.query && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
118
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useQuery"], path: importPath }),
|
|
119
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "QueryObserverOptions", "UseQueryReturnType"], path: importPath, isTypeOnly: true }),
|
|
120
|
-
/* @__PURE__ */ jsx(
|
|
121
|
-
Query,
|
|
122
|
-
{
|
|
123
|
-
name: query.name,
|
|
124
|
-
queryOptionsName: queryOptions.name,
|
|
125
|
-
typeSchemas: type.schemas,
|
|
126
|
-
paramsCasing: options.paramsCasing,
|
|
127
|
-
paramsType: options.paramsType,
|
|
128
|
-
pathParamsType: options.pathParamsType,
|
|
129
|
-
operation,
|
|
130
|
-
dataReturnType: options.client.dataReturnType,
|
|
131
|
-
queryKeyName: queryKey.name,
|
|
132
|
-
queryKeyTypeName: queryKey.typeName
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
] })
|
|
136
|
-
] });
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
var mutationGenerator = createReactGenerator({
|
|
140
|
-
name: "vue-query",
|
|
141
|
-
Operation({ options, operation }) {
|
|
142
|
-
const {
|
|
143
|
-
plugin: {
|
|
144
|
-
options: { output }
|
|
145
|
-
}
|
|
146
|
-
} = useApp();
|
|
147
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
148
|
-
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
|
|
149
|
-
const isMutation = !isQuery && difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
150
|
-
const importPath = options.mutation ? options.mutation.importPath : "@tanstack/vue-query";
|
|
151
|
-
const mutation = {
|
|
152
|
-
name: getName(operation, { type: "function", prefix: "use" }),
|
|
153
|
-
typeName: getName(operation, { type: "type" }),
|
|
154
|
-
file: getFile(operation, { prefix: "use" })
|
|
155
|
-
};
|
|
156
|
-
const type = {
|
|
157
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
158
|
-
//todo remove type?
|
|
159
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
160
|
-
};
|
|
161
|
-
const zod = {
|
|
162
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
163
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
164
|
-
};
|
|
165
|
-
const client = {
|
|
166
|
-
name: getName(operation, { type: "function" })
|
|
167
|
-
};
|
|
168
|
-
const mutationKey = {
|
|
169
|
-
name: getName(operation, { type: "const", suffix: "MutationKey" }),
|
|
170
|
-
typeName: getName(operation, { type: "type", suffix: "MutationKey" })
|
|
171
|
-
};
|
|
172
|
-
if (!isMutation) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
return /* @__PURE__ */ jsxs(File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
176
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
|
|
177
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
|
|
178
|
-
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
179
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
180
|
-
/* @__PURE__ */ jsx(
|
|
181
|
-
File.Import,
|
|
182
|
-
{
|
|
183
|
-
name: [
|
|
184
|
-
type.schemas.request?.name,
|
|
185
|
-
type.schemas.response.name,
|
|
186
|
-
type.schemas.pathParams?.name,
|
|
187
|
-
type.schemas.queryParams?.name,
|
|
188
|
-
type.schemas.headerParams?.name,
|
|
189
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
190
|
-
].filter(Boolean),
|
|
191
|
-
root: mutation.file.path,
|
|
192
|
-
path: type.file.path,
|
|
193
|
-
isTypeOnly: true
|
|
194
|
-
}
|
|
195
|
-
),
|
|
196
|
-
/* @__PURE__ */ jsx(
|
|
197
|
-
MutationKey,
|
|
198
|
-
{
|
|
199
|
-
name: mutationKey.name,
|
|
200
|
-
typeName: mutationKey.typeName,
|
|
201
|
-
operation,
|
|
202
|
-
pathParamsType: options.pathParamsType,
|
|
203
|
-
paramsCasing: options.paramsCasing,
|
|
204
|
-
typeSchemas: type.schemas,
|
|
205
|
-
transformer: options.mutationKey
|
|
206
|
-
}
|
|
207
|
-
),
|
|
208
|
-
/* @__PURE__ */ jsx(
|
|
209
|
-
Client,
|
|
210
|
-
{
|
|
211
|
-
name: client.name,
|
|
212
|
-
isExportable: false,
|
|
213
|
-
isIndexable: false,
|
|
214
|
-
baseURL: options.client.baseURL,
|
|
215
|
-
operation,
|
|
216
|
-
typeSchemas: type.schemas,
|
|
217
|
-
zodSchemas: zod.schemas,
|
|
218
|
-
dataReturnType: options.client.dataReturnType,
|
|
219
|
-
paramsCasing: options.paramsCasing,
|
|
220
|
-
paramsType: options.paramsType,
|
|
221
|
-
pathParamsType: options.pathParamsType,
|
|
222
|
-
parser: options.parser
|
|
223
|
-
}
|
|
224
|
-
),
|
|
225
|
-
options.mutation && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
226
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: importPath }),
|
|
227
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["MutationObserverOptions"], path: importPath, isTypeOnly: true }),
|
|
228
|
-
/* @__PURE__ */ jsx(
|
|
229
|
-
Mutation,
|
|
230
|
-
{
|
|
231
|
-
name: mutation.name,
|
|
232
|
-
clientName: client.name,
|
|
233
|
-
typeName: mutation.typeName,
|
|
234
|
-
typeSchemas: type.schemas,
|
|
235
|
-
operation,
|
|
236
|
-
paramsCasing: options.paramsCasing,
|
|
237
|
-
dataReturnType: options.client.dataReturnType,
|
|
238
|
-
paramsType: options.paramsType,
|
|
239
|
-
pathParamsType: options.pathParamsType,
|
|
240
|
-
mutationKeyName: mutationKey.name
|
|
241
|
-
}
|
|
242
|
-
)
|
|
243
|
-
] })
|
|
244
|
-
] });
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
var infiniteQueryGenerator = createReactGenerator({
|
|
248
|
-
name: "vue-infinite-query",
|
|
249
|
-
Operation({ options, operation }) {
|
|
250
|
-
const {
|
|
251
|
-
plugin: {
|
|
252
|
-
options: { output }
|
|
253
|
-
}
|
|
254
|
-
} = useApp();
|
|
255
|
-
const { getSchemas, getName, getFile } = useOperationManager();
|
|
256
|
-
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
257
|
-
const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
258
|
-
(method) => operation.method === method
|
|
259
|
-
);
|
|
260
|
-
const isInfinite = isQuery && !!options.infinite;
|
|
261
|
-
const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
|
|
262
|
-
const query = {
|
|
263
|
-
name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
|
|
264
|
-
typeName: getName(operation, { type: "type" }),
|
|
265
|
-
file: getFile(operation, { prefix: "use", suffix: "infinite" })
|
|
266
|
-
};
|
|
267
|
-
const client = {
|
|
268
|
-
name: getName(operation, { type: "function" })
|
|
269
|
-
};
|
|
270
|
-
const queryOptions = {
|
|
271
|
-
name: getName(operation, { type: "function", suffix: "InfiniteQueryOptions" })
|
|
272
|
-
};
|
|
273
|
-
const queryKey = {
|
|
274
|
-
name: getName(operation, { type: "const", suffix: "InfiniteQueryKey" }),
|
|
275
|
-
typeName: getName(operation, { type: "type", suffix: "InfiniteQueryKey" })
|
|
276
|
-
};
|
|
277
|
-
const type = {
|
|
278
|
-
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
279
|
-
//todo remove type?
|
|
280
|
-
schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: "type" })
|
|
281
|
-
};
|
|
282
|
-
const zod = {
|
|
283
|
-
file: getFile(operation, { pluginKey: [pluginZodName] }),
|
|
284
|
-
schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: "function" })
|
|
285
|
-
};
|
|
286
|
-
if (!isQuery || isMutation || !isInfinite) {
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
return /* @__PURE__ */ jsxs(File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
290
|
-
options.parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
|
|
291
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["unref"], path: "vue" }),
|
|
292
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
|
|
293
|
-
/* @__PURE__ */ jsx(File.Import, { name: "client", path: options.client.importPath }),
|
|
294
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["RequestConfig", "ResponseErrorConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
295
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
296
|
-
/* @__PURE__ */ jsx(
|
|
297
|
-
File.Import,
|
|
298
|
-
{
|
|
299
|
-
name: [
|
|
300
|
-
type.schemas.request?.name,
|
|
301
|
-
type.schemas.response.name,
|
|
302
|
-
type.schemas.pathParams?.name,
|
|
303
|
-
type.schemas.queryParams?.name,
|
|
304
|
-
type.schemas.headerParams?.name,
|
|
305
|
-
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
306
|
-
].filter(Boolean),
|
|
307
|
-
root: query.file.path,
|
|
308
|
-
path: type.file.path,
|
|
309
|
-
isTypeOnly: true
|
|
310
|
-
}
|
|
311
|
-
),
|
|
312
|
-
/* @__PURE__ */ jsx(
|
|
313
|
-
QueryKey,
|
|
314
|
-
{
|
|
315
|
-
name: queryKey.name,
|
|
316
|
-
typeName: queryKey.typeName,
|
|
317
|
-
operation,
|
|
318
|
-
paramsCasing: options.paramsCasing,
|
|
319
|
-
pathParamsType: options.pathParamsType,
|
|
320
|
-
typeSchemas: type.schemas,
|
|
321
|
-
transformer: options.queryKey
|
|
322
|
-
}
|
|
323
|
-
),
|
|
324
|
-
/* @__PURE__ */ jsx(
|
|
325
|
-
Client,
|
|
326
|
-
{
|
|
327
|
-
name: client.name,
|
|
328
|
-
isExportable: false,
|
|
329
|
-
isIndexable: false,
|
|
330
|
-
baseURL: options.client.baseURL,
|
|
331
|
-
operation,
|
|
332
|
-
typeSchemas: type.schemas,
|
|
333
|
-
zodSchemas: zod.schemas,
|
|
334
|
-
dataReturnType: options.client.dataReturnType,
|
|
335
|
-
paramsCasing: options.paramsCasing,
|
|
336
|
-
paramsType: options.paramsType,
|
|
337
|
-
pathParamsType: options.pathParamsType,
|
|
338
|
-
parser: options.parser
|
|
339
|
-
}
|
|
340
|
-
),
|
|
341
|
-
options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
342
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["InfiniteData"], isTypeOnly: true, path: importPath }),
|
|
343
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["infiniteQueryOptions"], path: importPath }),
|
|
344
|
-
/* @__PURE__ */ jsx(
|
|
345
|
-
InfiniteQueryOptions,
|
|
346
|
-
{
|
|
347
|
-
name: queryOptions.name,
|
|
348
|
-
clientName: client.name,
|
|
349
|
-
queryKeyName: queryKey.name,
|
|
350
|
-
typeSchemas: type.schemas,
|
|
351
|
-
paramsType: options.paramsType,
|
|
352
|
-
paramsCasing: options.paramsCasing,
|
|
353
|
-
pathParamsType: options.pathParamsType,
|
|
354
|
-
dataReturnType: options.client.dataReturnType,
|
|
355
|
-
cursorParam: options.infinite.cursorParam,
|
|
356
|
-
initialPageParam: options.infinite.initialPageParam,
|
|
357
|
-
queryParam: options.infinite.queryParam
|
|
358
|
-
}
|
|
359
|
-
)
|
|
360
|
-
] }),
|
|
361
|
-
options.infinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
362
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["useInfiniteQuery"], path: importPath }),
|
|
363
|
-
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "InfiniteQueryObserverOptions", "UseInfiniteQueryReturnType"], path: importPath, isTypeOnly: true }),
|
|
364
|
-
/* @__PURE__ */ jsx(
|
|
365
|
-
InfiniteQuery,
|
|
366
|
-
{
|
|
367
|
-
name: query.name,
|
|
368
|
-
queryOptionsName: queryOptions.name,
|
|
369
|
-
typeSchemas: type.schemas,
|
|
370
|
-
paramsCasing: options.paramsCasing,
|
|
371
|
-
paramsType: options.paramsType,
|
|
372
|
-
pathParamsType: options.pathParamsType,
|
|
373
|
-
operation,
|
|
374
|
-
dataReturnType: options.client.dataReturnType,
|
|
375
|
-
queryKeyName: queryKey.name,
|
|
376
|
-
queryKeyTypeName: queryKey.typeName
|
|
377
|
-
}
|
|
378
|
-
)
|
|
379
|
-
] })
|
|
380
|
-
] });
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
export { infiniteQueryGenerator, mutationGenerator, queryGenerator };
|
|
385
|
-
//# sourceMappingURL=chunk-KQSFBSYB.js.map
|
|
386
|
-
//# sourceMappingURL=chunk-KQSFBSYB.js.map
|