@kubb/plugin-vue-query 3.10.9 → 3.10.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-HFS3E2XN.js → chunk-7XHWHNQJ.js} +9 -291
- package/dist/chunk-7XHWHNQJ.js.map +1 -0
- package/dist/{chunk-X4ORE2OB.cjs → chunk-BZCUE3CY.cjs} +27 -313
- package/dist/chunk-BZCUE3CY.cjs.map +1 -0
- package/dist/{chunk-5ZPM3EXG.js → chunk-N3CF7PJF.js} +29 -214
- package/dist/chunk-N3CF7PJF.js.map +1 -0
- package/dist/{chunk-OBHV4PZA.cjs → chunk-WCY7AM2R.cjs} +46 -234
- package/dist/chunk-WCY7AM2R.cjs.map +1 -0
- package/dist/components.cjs +8 -8
- package/dist/components.d.cts +4 -3
- package/dist/components.d.ts +4 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.d.cts +2 -1
- package/dist/generators.d.ts +2 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/types-CDzVWC17.d.cts +164 -0
- package/dist/types-CDzVWC17.d.ts +164 -0
- package/package.json +12 -11
- package/src/components/Mutation.tsx +2 -1
- package/src/components/Query.tsx +4 -6
- package/src/generators/__snapshots__/clientPostImportPath.ts +2 -1
- package/src/generators/__snapshots__/updatePetById.ts +2 -1
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +2 -1
- package/src/types.ts +1 -2
- package/dist/chunk-5ZPM3EXG.js.map +0 -1
- package/dist/chunk-HFS3E2XN.js.map +0 -1
- package/dist/chunk-OBHV4PZA.cjs.map +0 -1
- package/dist/chunk-X4ORE2OB.cjs.map +0 -1
- package/dist/types-_wjAWo-H.d.cts +0 -441
- package/dist/types-_wjAWo-H.d.ts +0 -441
package/dist/components.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkWCY7AM2R_cjs = require('./chunk-WCY7AM2R.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "InfiniteQuery", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkWCY7AM2R_cjs.InfiniteQuery; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "InfiniteQueryOptions", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkWCY7AM2R_cjs.InfiniteQueryOptions; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "Mutation", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkWCY7AM2R_cjs.Mutation; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "MutationKey", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkWCY7AM2R_cjs.MutationKey; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "Query", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkWCY7AM2R_cjs.Query; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "QueryKey", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkWCY7AM2R_cjs.QueryKey; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "QueryOptions", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkWCY7AM2R_cjs.QueryOptions; }
|
|
34
34
|
});
|
|
35
35
|
//# sourceMappingURL=components.cjs.map
|
|
36
36
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Operation } from '@kubb/oas';
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { P as PluginVueQuery,
|
|
4
|
+
import { P as PluginVueQuery, T as Transformer, I as Infinite } from './types-CDzVWC17.cjs';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
|
+
import '@kubb/plugin-client';
|
|
7
8
|
|
|
8
9
|
type Props$6 = {
|
|
9
10
|
/**
|
|
@@ -32,13 +33,13 @@ type Props$5 = {
|
|
|
32
33
|
queryKeyTypeName: string;
|
|
33
34
|
typeSchemas: OperationSchemas;
|
|
34
35
|
operation: Operation;
|
|
35
|
-
paramsCasing:
|
|
36
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing'];
|
|
36
37
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType'];
|
|
37
38
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
|
|
38
39
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
|
|
39
40
|
};
|
|
40
41
|
type GetParamsProps$5 = {
|
|
41
|
-
paramsCasing:
|
|
42
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing'];
|
|
42
43
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType'];
|
|
43
44
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
|
|
44
45
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
|
package/dist/components.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Operation } from '@kubb/oas';
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { P as PluginVueQuery,
|
|
4
|
+
import { P as PluginVueQuery, T as Transformer, I as Infinite } from './types-CDzVWC17.js';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
|
+
import '@kubb/plugin-client';
|
|
7
8
|
|
|
8
9
|
type Props$6 = {
|
|
9
10
|
/**
|
|
@@ -32,13 +33,13 @@ type Props$5 = {
|
|
|
32
33
|
queryKeyTypeName: string;
|
|
33
34
|
typeSchemas: OperationSchemas;
|
|
34
35
|
operation: Operation;
|
|
35
|
-
paramsCasing:
|
|
36
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing'];
|
|
36
37
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType'];
|
|
37
38
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
|
|
38
39
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
|
|
39
40
|
};
|
|
40
41
|
type GetParamsProps$5 = {
|
|
41
|
-
paramsCasing:
|
|
42
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing'];
|
|
42
43
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType'];
|
|
43
44
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType'];
|
|
44
45
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType'];
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions } from './chunk-
|
|
1
|
+
export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions } from './chunk-N3CF7PJF.js';
|
|
2
2
|
//# sourceMappingURL=components.js.map
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
package/dist/generators.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkBZCUE3CY_cjs = require('./chunk-BZCUE3CY.cjs');
|
|
4
|
+
require('./chunk-WCY7AM2R.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "infiniteQueryGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkBZCUE3CY_cjs.infiniteQueryGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "mutationGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkBZCUE3CY_cjs.mutationGenerator; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "queryGenerator", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkBZCUE3CY_cjs.queryGenerator; }
|
|
19
19
|
});
|
|
20
20
|
//# sourceMappingURL=generators.cjs.map
|
|
21
21
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginVueQuery } from './types-
|
|
2
|
+
import { P as PluginVueQuery } from './types-CDzVWC17.cjs';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
import '@kubb/oas';
|
|
5
|
+
import '@kubb/plugin-client';
|
|
5
6
|
|
|
6
7
|
declare const queryGenerator: _kubb_plugin_oas.Generator<PluginVueQuery>;
|
|
7
8
|
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginVueQuery } from './types-
|
|
2
|
+
import { P as PluginVueQuery } from './types-CDzVWC17.js';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
import '@kubb/oas';
|
|
5
|
+
import '@kubb/plugin-client';
|
|
5
6
|
|
|
6
7
|
declare const queryGenerator: _kubb_plugin_oas.Generator<PluginVueQuery>;
|
|
7
8
|
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { infiniteQueryGenerator, mutationGenerator, queryGenerator } from './chunk-7XHWHNQJ.js';
|
|
2
|
+
import './chunk-N3CF7PJF.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkBZCUE3CY_cjs = require('./chunk-BZCUE3CY.cjs');
|
|
4
|
+
var chunkWCY7AM2R_cjs = require('./chunk-WCY7AM2R.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -29,9 +29,9 @@ var pluginVueQuery = core.createPlugin((options) => {
|
|
|
29
29
|
mutation = {},
|
|
30
30
|
query = {},
|
|
31
31
|
paramsCasing,
|
|
32
|
-
mutationKey =
|
|
33
|
-
queryKey =
|
|
34
|
-
generators = [
|
|
32
|
+
mutationKey = chunkWCY7AM2R_cjs.MutationKey.getTransformer,
|
|
33
|
+
queryKey = chunkWCY7AM2R_cjs.QueryKey.getTransformer,
|
|
34
|
+
generators = [chunkBZCUE3CY_cjs.queryGenerator, chunkBZCUE3CY_cjs.infiniteQueryGenerator, chunkBZCUE3CY_cjs.mutationGenerator].filter(Boolean),
|
|
35
35
|
contentType
|
|
36
36
|
} = options;
|
|
37
37
|
return {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginVueQuery } from './types-
|
|
2
|
+
import { O as Options, P as PluginVueQuery } from './types-CDzVWC17.cjs';
|
|
3
3
|
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-client';
|
|
4
5
|
import '@kubb/plugin-oas';
|
|
5
6
|
|
|
6
7
|
declare const pluginVueQueryName = "plugin-vue-query";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginVueQuery } from './types-
|
|
2
|
+
import { O as Options, P as PluginVueQuery } from './types-CDzVWC17.js';
|
|
3
3
|
import '@kubb/oas';
|
|
4
|
+
import '@kubb/plugin-client';
|
|
4
5
|
import '@kubb/plugin-oas';
|
|
5
6
|
|
|
6
7
|
declare const pluginVueQueryName = "plugin-vue-query";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-
|
|
2
|
-
import { MutationKey, QueryKey } from './chunk-
|
|
1
|
+
import { queryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-7XHWHNQJ.js';
|
|
2
|
+
import { MutationKey, QueryKey } from './chunk-N3CF7PJF.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, PluginManager, FileManager } from '@kubb/core';
|
|
5
5
|
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Output, Group, PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
|
|
3
|
+
import { PluginClient } from '@kubb/plugin-client';
|
|
4
|
+
import { Exclude, Include, Override, ResolvePathOptions, OperationSchemas, Generator } from '@kubb/plugin-oas';
|
|
5
|
+
|
|
6
|
+
type TransformerProps = {
|
|
7
|
+
operation: Operation;
|
|
8
|
+
schemas: OperationSchemas;
|
|
9
|
+
casing: 'camelcase' | undefined;
|
|
10
|
+
};
|
|
11
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
12
|
+
/**
|
|
13
|
+
* Customize the queryKey
|
|
14
|
+
*/
|
|
15
|
+
type QueryKey = Transformer;
|
|
16
|
+
/**
|
|
17
|
+
* Customize the mutationKey
|
|
18
|
+
*/
|
|
19
|
+
type MutationKey = Transformer;
|
|
20
|
+
type Query = {
|
|
21
|
+
/**
|
|
22
|
+
* Define which HttpMethods can be used for queries
|
|
23
|
+
* @default ['get']
|
|
24
|
+
*/
|
|
25
|
+
methods: Array<HttpMethod>;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
28
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
29
|
+
* It allows both relative and absolute path.
|
|
30
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
31
|
+
* @default '@tanstack/react-query'
|
|
32
|
+
*/
|
|
33
|
+
importPath?: string;
|
|
34
|
+
};
|
|
35
|
+
type Mutation = {
|
|
36
|
+
/**
|
|
37
|
+
* Define which HttpMethods can be used for mutations
|
|
38
|
+
* @default ['post', 'put', 'delete']
|
|
39
|
+
*/
|
|
40
|
+
methods: Array<HttpMethod>;
|
|
41
|
+
/**
|
|
42
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
43
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
44
|
+
* It allows both relative and absolute path.
|
|
45
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
46
|
+
* @default '@tanstack/react-query'
|
|
47
|
+
*/
|
|
48
|
+
importPath?: string;
|
|
49
|
+
};
|
|
50
|
+
type Infinite = {
|
|
51
|
+
/**
|
|
52
|
+
* Specify the params key used for `pageParam`.
|
|
53
|
+
* @default `'id'`
|
|
54
|
+
*/
|
|
55
|
+
queryParam: string;
|
|
56
|
+
/**
|
|
57
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
58
|
+
*/
|
|
59
|
+
cursorParam?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The initial value, the value of the first page.
|
|
62
|
+
* @default `0`
|
|
63
|
+
*/
|
|
64
|
+
initialPageParam: unknown;
|
|
65
|
+
};
|
|
66
|
+
type Options = {
|
|
67
|
+
/**
|
|
68
|
+
* Specify the export location for the files and define the behavior of the output
|
|
69
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
70
|
+
*/
|
|
71
|
+
output?: Output<Oas>;
|
|
72
|
+
/**
|
|
73
|
+
* Define which contentType should be used.
|
|
74
|
+
* By default, the first JSON valid mediaType will be used
|
|
75
|
+
*/
|
|
76
|
+
contentType?: contentType;
|
|
77
|
+
/**
|
|
78
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
79
|
+
*/
|
|
80
|
+
group?: Group;
|
|
81
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
82
|
+
/**
|
|
83
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
84
|
+
*/
|
|
85
|
+
exclude?: Array<Exclude>;
|
|
86
|
+
/**
|
|
87
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
88
|
+
*/
|
|
89
|
+
include?: Array<Include>;
|
|
90
|
+
/**
|
|
91
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
92
|
+
*/
|
|
93
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
94
|
+
/**
|
|
95
|
+
* How to style your params, by default no casing is applied
|
|
96
|
+
* - 'camelcase' will use camelcase for the params names
|
|
97
|
+
*/
|
|
98
|
+
paramsCasing?: 'camelcase';
|
|
99
|
+
/**
|
|
100
|
+
* How to pass your params
|
|
101
|
+
* - 'object' will return the params and pathParams as an object.
|
|
102
|
+
* - 'inline' will return the params as comma separated params.
|
|
103
|
+
* @default 'inline'
|
|
104
|
+
*/
|
|
105
|
+
paramsType?: 'object' | 'inline';
|
|
106
|
+
/**
|
|
107
|
+
* How to pass your pathParams.
|
|
108
|
+
* - 'object' will return the pathParams as an object.
|
|
109
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
110
|
+
* @default 'inline'
|
|
111
|
+
*/
|
|
112
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
113
|
+
/**
|
|
114
|
+
* When set, an infiniteQuery hooks will be added.
|
|
115
|
+
*/
|
|
116
|
+
infinite?: Partial<Infinite> | false;
|
|
117
|
+
queryKey?: QueryKey;
|
|
118
|
+
/**
|
|
119
|
+
* Override some useQuery behaviours.
|
|
120
|
+
*/
|
|
121
|
+
query?: Partial<Query> | false;
|
|
122
|
+
mutationKey?: MutationKey;
|
|
123
|
+
/**
|
|
124
|
+
* Override some useMutation behaviours.
|
|
125
|
+
*/
|
|
126
|
+
mutation?: Mutation | false;
|
|
127
|
+
/**
|
|
128
|
+
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
129
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
130
|
+
*/
|
|
131
|
+
parser?: PluginClient['options']['parser'];
|
|
132
|
+
transformers?: {
|
|
133
|
+
/**
|
|
134
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
135
|
+
*/
|
|
136
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Define some generators next to the vue-query generators
|
|
140
|
+
*/
|
|
141
|
+
generators?: Array<Generator<PluginVueQuery>>;
|
|
142
|
+
};
|
|
143
|
+
type ResolvedOptions = {
|
|
144
|
+
output: Output<Oas>;
|
|
145
|
+
group: Options['group'];
|
|
146
|
+
client: Required<Omit<NonNullable<PluginVueQuery['options']['client']>, 'baseURL'>> & {
|
|
147
|
+
baseURL?: string;
|
|
148
|
+
};
|
|
149
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
150
|
+
paramsCasing: Options['paramsCasing'];
|
|
151
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
152
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
153
|
+
/**
|
|
154
|
+
* Only used of infinite
|
|
155
|
+
*/
|
|
156
|
+
infinite: NonNullable<Infinite> | false;
|
|
157
|
+
queryKey: QueryKey | undefined;
|
|
158
|
+
query: NonNullable<Required<Query>> | false;
|
|
159
|
+
mutationKey: MutationKey | undefined;
|
|
160
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
161
|
+
};
|
|
162
|
+
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
163
|
+
|
|
164
|
+
export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Output, Group, PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
|
|
2
|
+
import { Oas, contentType, Operation, HttpMethod } from '@kubb/oas';
|
|
3
|
+
import { PluginClient } from '@kubb/plugin-client';
|
|
4
|
+
import { Exclude, Include, Override, ResolvePathOptions, OperationSchemas, Generator } from '@kubb/plugin-oas';
|
|
5
|
+
|
|
6
|
+
type TransformerProps = {
|
|
7
|
+
operation: Operation;
|
|
8
|
+
schemas: OperationSchemas;
|
|
9
|
+
casing: 'camelcase' | undefined;
|
|
10
|
+
};
|
|
11
|
+
type Transformer = (props: TransformerProps) => unknown[];
|
|
12
|
+
/**
|
|
13
|
+
* Customize the queryKey
|
|
14
|
+
*/
|
|
15
|
+
type QueryKey = Transformer;
|
|
16
|
+
/**
|
|
17
|
+
* Customize the mutationKey
|
|
18
|
+
*/
|
|
19
|
+
type MutationKey = Transformer;
|
|
20
|
+
type Query = {
|
|
21
|
+
/**
|
|
22
|
+
* Define which HttpMethods can be used for queries
|
|
23
|
+
* @default ['get']
|
|
24
|
+
*/
|
|
25
|
+
methods: Array<HttpMethod>;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
28
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
29
|
+
* It allows both relative and absolute path.
|
|
30
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
31
|
+
* @default '@tanstack/react-query'
|
|
32
|
+
*/
|
|
33
|
+
importPath?: string;
|
|
34
|
+
};
|
|
35
|
+
type Mutation = {
|
|
36
|
+
/**
|
|
37
|
+
* Define which HttpMethods can be used for mutations
|
|
38
|
+
* @default ['post', 'put', 'delete']
|
|
39
|
+
*/
|
|
40
|
+
methods: Array<HttpMethod>;
|
|
41
|
+
/**
|
|
42
|
+
* Path to the useQuery that will be used to do the useQuery functionality.
|
|
43
|
+
* It will be used as `import { useQuery } from '${importPath}'`.
|
|
44
|
+
* It allows both relative and absolute path.
|
|
45
|
+
* the path will be applied as is, so relative path should be based on the file being generated.
|
|
46
|
+
* @default '@tanstack/react-query'
|
|
47
|
+
*/
|
|
48
|
+
importPath?: string;
|
|
49
|
+
};
|
|
50
|
+
type Infinite = {
|
|
51
|
+
/**
|
|
52
|
+
* Specify the params key used for `pageParam`.
|
|
53
|
+
* @default `'id'`
|
|
54
|
+
*/
|
|
55
|
+
queryParam: string;
|
|
56
|
+
/**
|
|
57
|
+
* Which field of the data will be used, set it to undefined when no cursor is known.
|
|
58
|
+
*/
|
|
59
|
+
cursorParam?: string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The initial value, the value of the first page.
|
|
62
|
+
* @default `0`
|
|
63
|
+
*/
|
|
64
|
+
initialPageParam: unknown;
|
|
65
|
+
};
|
|
66
|
+
type Options = {
|
|
67
|
+
/**
|
|
68
|
+
* Specify the export location for the files and define the behavior of the output
|
|
69
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
70
|
+
*/
|
|
71
|
+
output?: Output<Oas>;
|
|
72
|
+
/**
|
|
73
|
+
* Define which contentType should be used.
|
|
74
|
+
* By default, the first JSON valid mediaType will be used
|
|
75
|
+
*/
|
|
76
|
+
contentType?: contentType;
|
|
77
|
+
/**
|
|
78
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
79
|
+
*/
|
|
80
|
+
group?: Group;
|
|
81
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
82
|
+
/**
|
|
83
|
+
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
84
|
+
*/
|
|
85
|
+
exclude?: Array<Exclude>;
|
|
86
|
+
/**
|
|
87
|
+
* Array containing include parameters to include tags/operations/methods/paths.
|
|
88
|
+
*/
|
|
89
|
+
include?: Array<Include>;
|
|
90
|
+
/**
|
|
91
|
+
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
92
|
+
*/
|
|
93
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
94
|
+
/**
|
|
95
|
+
* How to style your params, by default no casing is applied
|
|
96
|
+
* - 'camelcase' will use camelcase for the params names
|
|
97
|
+
*/
|
|
98
|
+
paramsCasing?: 'camelcase';
|
|
99
|
+
/**
|
|
100
|
+
* How to pass your params
|
|
101
|
+
* - 'object' will return the params and pathParams as an object.
|
|
102
|
+
* - 'inline' will return the params as comma separated params.
|
|
103
|
+
* @default 'inline'
|
|
104
|
+
*/
|
|
105
|
+
paramsType?: 'object' | 'inline';
|
|
106
|
+
/**
|
|
107
|
+
* How to pass your pathParams.
|
|
108
|
+
* - 'object' will return the pathParams as an object.
|
|
109
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
110
|
+
* @default 'inline'
|
|
111
|
+
*/
|
|
112
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
113
|
+
/**
|
|
114
|
+
* When set, an infiniteQuery hooks will be added.
|
|
115
|
+
*/
|
|
116
|
+
infinite?: Partial<Infinite> | false;
|
|
117
|
+
queryKey?: QueryKey;
|
|
118
|
+
/**
|
|
119
|
+
* Override some useQuery behaviours.
|
|
120
|
+
*/
|
|
121
|
+
query?: Partial<Query> | false;
|
|
122
|
+
mutationKey?: MutationKey;
|
|
123
|
+
/**
|
|
124
|
+
* Override some useMutation behaviours.
|
|
125
|
+
*/
|
|
126
|
+
mutation?: Mutation | false;
|
|
127
|
+
/**
|
|
128
|
+
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
129
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
130
|
+
*/
|
|
131
|
+
parser?: PluginClient['options']['parser'];
|
|
132
|
+
transformers?: {
|
|
133
|
+
/**
|
|
134
|
+
* Customize the names based on the type that is provided by the plugin.
|
|
135
|
+
*/
|
|
136
|
+
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Define some generators next to the vue-query generators
|
|
140
|
+
*/
|
|
141
|
+
generators?: Array<Generator<PluginVueQuery>>;
|
|
142
|
+
};
|
|
143
|
+
type ResolvedOptions = {
|
|
144
|
+
output: Output<Oas>;
|
|
145
|
+
group: Options['group'];
|
|
146
|
+
client: Required<Omit<NonNullable<PluginVueQuery['options']['client']>, 'baseURL'>> & {
|
|
147
|
+
baseURL?: string;
|
|
148
|
+
};
|
|
149
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
150
|
+
paramsCasing: Options['paramsCasing'];
|
|
151
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
152
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
153
|
+
/**
|
|
154
|
+
* Only used of infinite
|
|
155
|
+
*/
|
|
156
|
+
infinite: NonNullable<Infinite> | false;
|
|
157
|
+
queryKey: QueryKey | undefined;
|
|
158
|
+
query: NonNullable<Required<Query>> | false;
|
|
159
|
+
mutationKey: MutationKey | undefined;
|
|
160
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
161
|
+
};
|
|
162
|
+
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
163
|
+
|
|
164
|
+
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.10.
|
|
3
|
+
"version": "3.10.11",
|
|
4
4
|
"description": "Generator vue-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -62,21 +62,22 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"remeda": "^2.21.
|
|
66
|
-
"@kubb/core": "3.10.
|
|
67
|
-
"@kubb/oas": "3.10.
|
|
68
|
-
"@kubb/plugin-
|
|
69
|
-
"@kubb/plugin-
|
|
70
|
-
"@kubb/plugin-
|
|
71
|
-
"@kubb/
|
|
65
|
+
"remeda": "^2.21.4",
|
|
66
|
+
"@kubb/core": "3.10.11",
|
|
67
|
+
"@kubb/oas": "3.10.11",
|
|
68
|
+
"@kubb/plugin-client": "3.10.11",
|
|
69
|
+
"@kubb/plugin-oas": "3.10.11",
|
|
70
|
+
"@kubb/plugin-ts": "3.10.11",
|
|
71
|
+
"@kubb/plugin-zod": "3.10.11",
|
|
72
|
+
"@kubb/react": "3.10.11"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@types/react": "^18.3.21",
|
|
75
76
|
"react": "^18.3.1",
|
|
76
77
|
"tsup": "^8.4.0",
|
|
77
78
|
"typescript": "^5.8.3",
|
|
78
|
-
"@kubb/config-ts": "3.10.
|
|
79
|
-
"@kubb/config-tsup": "3.10.
|
|
79
|
+
"@kubb/config-ts": "3.10.11",
|
|
80
|
+
"@kubb/config-tsup": "3.10.11"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|
|
82
83
|
"@kubb/react": "^3.0.0"
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"build": "tsup",
|
|
93
94
|
"clean": "npx rimraf ./dist",
|
|
94
95
|
"lint": "bun biome lint .",
|
|
95
|
-
"lint:fix": "bun biome lint --
|
|
96
|
+
"lint:fix": "bun biome lint--fix --unsafe .",
|
|
96
97
|
"release": "pnpm publish --no-git-check",
|
|
97
98
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
98
99
|
"start": "tsup --watch",
|
|
@@ -169,7 +169,8 @@ export function Mutation({
|
|
|
169
169
|
generics={['TContext']}
|
|
170
170
|
>
|
|
171
171
|
{`
|
|
172
|
-
const { mutation
|
|
172
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
173
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
173
174
|
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
174
175
|
|
|
175
176
|
return useMutation<${generics}>({
|
package/src/components/Query.tsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { type Operation, isOptional } from '@kubb/oas'
|
|
1
|
+
import { isOptional, type Operation } from '@kubb/oas'
|
|
4
2
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
5
3
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
6
|
-
import
|
|
4
|
+
import { File, Function, FunctionParams } from '@kubb/react'
|
|
7
5
|
import type { ReactNode } from 'react'
|
|
8
6
|
import type { PluginVueQuery } from '../types.ts'
|
|
9
7
|
import { QueryKey } from './QueryKey.tsx'
|
|
@@ -19,14 +17,14 @@ type Props = {
|
|
|
19
17
|
queryKeyTypeName: string
|
|
20
18
|
typeSchemas: OperationSchemas
|
|
21
19
|
operation: Operation
|
|
22
|
-
paramsCasing:
|
|
20
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
23
21
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
24
22
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
25
23
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
type GetParamsProps = {
|
|
29
|
-
paramsCasing:
|
|
27
|
+
paramsCasing: PluginVueQuery['resolvedOptions']['paramsCasing']
|
|
30
28
|
paramsType: PluginVueQuery['resolvedOptions']['paramsType']
|
|
31
29
|
pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
|
|
32
30
|
dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
|
|
@@ -53,7 +53,8 @@ export function useUpdatePetWithForm<TContext>(
|
|
|
53
53
|
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: typeof client }
|
|
54
54
|
} = {},
|
|
55
55
|
) {
|
|
56
|
-
const { mutation
|
|
56
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
57
|
+
const { client: queryClient, ...mutationOptions } = mutation
|
|
57
58
|
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
58
59
|
|
|
59
60
|
return useMutation<
|
|
@@ -53,7 +53,8 @@ export function useUpdatePetWithForm<TContext>(
|
|
|
53
53
|
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: typeof client }
|
|
54
54
|
} = {},
|
|
55
55
|
) {
|
|
56
|
-
const { mutation
|
|
56
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
57
|
+
const { client: queryClient, ...mutationOptions } = mutation
|
|
57
58
|
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
58
59
|
|
|
59
60
|
return useMutation<
|