@kubb/plugin-react-query 3.0.0-beta.1 → 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-C2H3KPHM.cjs → chunk-BML6BZ4F.cjs} +256 -36
- package/dist/chunk-BML6BZ4F.cjs.map +1 -0
- package/dist/{chunk-Y3DM2P6L.js → chunk-JFIGHRBM.js} +256 -36
- package/dist/chunk-JFIGHRBM.js.map +1 -0
- package/dist/{chunk-IRW2Y3EC.js → chunk-PQJ45MEL.js} +31 -16
- package/dist/chunk-PQJ45MEL.js.map +1 -0
- package/dist/{chunk-37VO6QXJ.cjs → chunk-SIKQARDB.cjs} +48 -33
- package/dist/chunk-SIKQARDB.cjs.map +1 -0
- package/dist/components.cjs +9 -9
- package/dist/components.d.cts +23 -12
- package/dist/components.d.ts +23 -12
- package/dist/components.js +1 -1
- package/dist/generators.cjs +6 -6
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +19 -21
- 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 +18 -20
- package/dist/index.js.map +1 -1
- package/dist/{types-5pnOmDmM.d.cts → types-DL6Qblcz.d.cts} +41 -37
- package/dist/{types-5pnOmDmM.d.ts → types-DL6Qblcz.d.ts} +41 -37
- package/package.json +14 -14
- package/src/components/InfiniteQuery.tsx +52 -5
- package/src/components/InfiniteQueryOptions.tsx +62 -7
- package/src/components/Mutation.tsx +9 -3
- package/src/components/Query.tsx +62 -6
- package/src/components/QueryOptions.tsx +47 -7
- package/src/components/SuspenseQuery.tsx +52 -5
- package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +1 -3
- package/src/generators/infiniteQueryGenerator.tsx +4 -2
- package/src/generators/mutationGenerator.tsx +3 -2
- package/src/generators/queryGenerator.tsx +4 -2
- package/src/generators/suspenseQueryGenerator.tsx +4 -1
- package/src/plugin.ts +17 -18
- package/src/types.ts +19 -24
- package/dist/chunk-37VO6QXJ.cjs.map +0 -1
- package/dist/chunk-C2H3KPHM.cjs.map +0 -1
- package/dist/chunk-IRW2Y3EC.js.map +0 -1
- package/dist/chunk-Y3DM2P6L.js.map +0 -1
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 PluginReactQuery, I as Infinite } from './types-
|
|
4
|
+
import { P as PluginReactQuery, I as Infinite } from './types-DL6Qblcz.js';
|
|
5
5
|
import { FunctionParams } from '@kubb/react';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
|
|
@@ -16,9 +16,10 @@ type Props$7 = {
|
|
|
16
16
|
typeSchemas: OperationSchemas;
|
|
17
17
|
operation: Operation;
|
|
18
18
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
19
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
19
20
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
20
21
|
};
|
|
21
|
-
declare function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$7): ReactNode;
|
|
22
|
+
declare function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props$7): ReactNode;
|
|
22
23
|
|
|
23
24
|
type Props$6 = {
|
|
24
25
|
/**
|
|
@@ -30,17 +31,19 @@ type Props$6 = {
|
|
|
30
31
|
queryKeyTypeName: string;
|
|
31
32
|
typeSchemas: OperationSchemas;
|
|
32
33
|
operation: Operation;
|
|
34
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
33
35
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
34
36
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
35
37
|
};
|
|
36
38
|
type GetParamsProps$6 = {
|
|
39
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
37
40
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
38
41
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
39
42
|
typeSchemas: OperationSchemas;
|
|
40
43
|
};
|
|
41
|
-
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props$6): ReactNode;
|
|
44
|
+
declare function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$6): ReactNode;
|
|
42
45
|
declare namespace Query {
|
|
43
|
-
var getParams: ({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$6) => FunctionParams;
|
|
46
|
+
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$6) => FunctionParams;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
type Props$5 = {
|
|
@@ -82,15 +85,17 @@ type Props$3 = {
|
|
|
82
85
|
clientName: string;
|
|
83
86
|
queryKeyName: string;
|
|
84
87
|
typeSchemas: OperationSchemas;
|
|
88
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
85
89
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
86
90
|
};
|
|
87
91
|
type GetParamsProps$3 = {
|
|
92
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
88
93
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
89
94
|
typeSchemas: OperationSchemas;
|
|
90
95
|
};
|
|
91
|
-
declare function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }: Props$3): ReactNode;
|
|
96
|
+
declare function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props$3): ReactNode;
|
|
92
97
|
declare namespace QueryOptions {
|
|
93
|
-
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
98
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps$3) => FunctionParams;
|
|
94
99
|
}
|
|
95
100
|
|
|
96
101
|
type Props$2 = {
|
|
@@ -98,6 +103,7 @@ type Props$2 = {
|
|
|
98
103
|
clientName: string;
|
|
99
104
|
queryKeyName: string;
|
|
100
105
|
typeSchemas: OperationSchemas;
|
|
106
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
101
107
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
102
108
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
103
109
|
initialPageParam: Infinite['initialPageParam'];
|
|
@@ -105,12 +111,13 @@ type Props$2 = {
|
|
|
105
111
|
queryParam: Infinite['queryParam'];
|
|
106
112
|
};
|
|
107
113
|
type GetParamsProps$2 = {
|
|
114
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
108
115
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
109
116
|
typeSchemas: OperationSchemas;
|
|
110
117
|
};
|
|
111
|
-
declare function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, dataReturnType, pathParamsType, queryParam, queryKeyName, }: Props$2): ReactNode;
|
|
118
|
+
declare function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, typeSchemas, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName, }: Props$2): ReactNode;
|
|
112
119
|
declare namespace InfiniteQueryOptions {
|
|
113
|
-
var getParams: ({ pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
120
|
+
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps$2) => FunctionParams;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
type Props$1 = {
|
|
@@ -123,17 +130,19 @@ type Props$1 = {
|
|
|
123
130
|
queryKeyTypeName: string;
|
|
124
131
|
typeSchemas: OperationSchemas;
|
|
125
132
|
operation: Operation;
|
|
133
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
126
134
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
127
135
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
128
136
|
};
|
|
129
137
|
type GetParamsProps$1 = {
|
|
138
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
130
139
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
131
140
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
132
141
|
typeSchemas: OperationSchemas;
|
|
133
142
|
};
|
|
134
|
-
declare function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$1): ReactNode;
|
|
143
|
+
declare function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props$1): ReactNode;
|
|
135
144
|
declare namespace InfiniteQuery {
|
|
136
|
-
var getParams: ({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
145
|
+
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
type Props = {
|
|
@@ -146,17 +155,19 @@ type Props = {
|
|
|
146
155
|
queryKeyTypeName: string;
|
|
147
156
|
typeSchemas: OperationSchemas;
|
|
148
157
|
operation: Operation;
|
|
158
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
149
159
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
150
160
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
151
161
|
};
|
|
152
162
|
type GetParamsProps = {
|
|
163
|
+
paramsType: PluginReactQuery['resolvedOptions']['paramsType'];
|
|
153
164
|
pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType'];
|
|
154
165
|
dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType'];
|
|
155
166
|
typeSchemas: OperationSchemas;
|
|
156
167
|
};
|
|
157
|
-
declare function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation, }: Props): ReactNode;
|
|
168
|
+
declare function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, }: Props): ReactNode;
|
|
158
169
|
declare namespace SuspenseQuery {
|
|
159
|
-
var getParams: ({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
170
|
+
var getParams: ({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions, SuspenseQuery };
|
package/dist/components.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions, SuspenseQuery } from './chunk-
|
|
1
|
+
export { InfiniteQuery, InfiniteQueryOptions, Mutation, MutationKey, Query, QueryKey, QueryOptions, SuspenseQuery } from './chunk-JFIGHRBM.js';
|
|
2
2
|
//# sourceMappingURL=components.js.map
|
|
3
3
|
//# sourceMappingURL=components.js.map
|
package/dist/generators.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkSIKQARDB_cjs = require('./chunk-SIKQARDB.cjs');
|
|
4
|
+
require('./chunk-BML6BZ4F.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 chunkSIKQARDB_cjs.infiniteQueryGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "mutationGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkSIKQARDB_cjs.mutationGenerator; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "queryGenerator", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkSIKQARDB_cjs.queryGenerator; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "suspenseQueryGenerator", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkSIKQARDB_cjs.suspenseQueryGenerator; }
|
|
23
23
|
});
|
|
24
24
|
//# sourceMappingURL=generators.cjs.map
|
|
25
25
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './chunk-PQJ45MEL.js';
|
|
2
|
+
import './chunk-JFIGHRBM.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
|
-
require('./chunk-
|
|
3
|
+
var chunkSIKQARDB_cjs = require('./chunk-SIKQARDB.cjs');
|
|
4
|
+
require('./chunk-BML6BZ4F.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -25,8 +25,9 @@ var pluginReactQuery = core.createPlugin((options) => {
|
|
|
25
25
|
suspense = {},
|
|
26
26
|
infinite = false,
|
|
27
27
|
transformers: transformers$1 = {},
|
|
28
|
+
paramsType = "inline",
|
|
28
29
|
pathParamsType = "inline",
|
|
29
|
-
generators = [
|
|
30
|
+
generators = [chunkSIKQARDB_cjs.queryGenerator, chunkSIKQARDB_cjs.suspenseQueryGenerator, chunkSIKQARDB_cjs.infiniteQueryGenerator, chunkSIKQARDB_cjs.mutationGenerator].filter(Boolean),
|
|
30
31
|
mutation = {},
|
|
31
32
|
query = {}
|
|
32
33
|
} = options;
|
|
@@ -34,7 +35,6 @@ var pluginReactQuery = core.createPlugin((options) => {
|
|
|
34
35
|
name: pluginReactQueryName,
|
|
35
36
|
options: {
|
|
36
37
|
output,
|
|
37
|
-
baseURL: void 0,
|
|
38
38
|
client: {
|
|
39
39
|
importPath: "@kubb/plugin-client/client",
|
|
40
40
|
dataReturnType: "data",
|
|
@@ -59,7 +59,8 @@ var pluginReactQuery = core.createPlugin((options) => {
|
|
|
59
59
|
importPath: "@tanstack/react-query",
|
|
60
60
|
...mutation
|
|
61
61
|
},
|
|
62
|
-
|
|
62
|
+
paramsType,
|
|
63
|
+
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
63
64
|
parser
|
|
64
65
|
},
|
|
65
66
|
pre: [pluginOas.pluginOasName, pluginTs.pluginTsName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
|
|
@@ -96,22 +97,19 @@ var pluginReactQuery = core.createPlugin((options) => {
|
|
|
96
97
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
97
98
|
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
98
99
|
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
mode
|
|
113
|
-
}
|
|
114
|
-
);
|
|
100
|
+
if (baseURL) {
|
|
101
|
+
this.plugin.options.client.baseURL = baseURL;
|
|
102
|
+
}
|
|
103
|
+
const operationGenerator = new pluginOas.OperationGenerator(this.plugin.options, {
|
|
104
|
+
oas,
|
|
105
|
+
pluginManager: this.pluginManager,
|
|
106
|
+
plugin: this.plugin,
|
|
107
|
+
contentType: swaggerPlugin.context.contentType,
|
|
108
|
+
exclude,
|
|
109
|
+
include,
|
|
110
|
+
override,
|
|
111
|
+
mode
|
|
112
|
+
});
|
|
115
113
|
const files = await operationGenerator.build(...generators);
|
|
116
114
|
await this.addFile(...files);
|
|
117
115
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAcO,IAAM,oBAAuB,GAAA
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","queryGenerator","suspenseQueryGenerator","infiniteQueryGenerator","mutationGenerator","pluginOasName","pluginTsName","pluginZodName","options","path","FileManager","camelCase","pascalCase","PluginManager","OperationGenerator"],"mappings":";;;;;;;;;;;;;;;AAcO,IAAM,oBAAuB,GAAA;AAEvB,IAAA,gBAAA,GAAm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,kBAAqB,GAAA,IAAIK,4BAAmB,CAAA,IAAA,CAAK,OAAO,OAAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA,EAAa,cAAc,OAAQ,CAAA,WAAA;AAAA,QACnC,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,KAAQ,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AAC1D,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,KAAK,CAAA;AAE3B,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas } from '@kubb/plugin-oas'\nimport { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n } = options\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-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\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType: swaggerPlugin.context.contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.addFile(...files)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator } from './chunk-PQJ45MEL.js';
|
|
2
|
+
import './chunk-JFIGHRBM.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
5
|
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
@@ -19,6 +19,7 @@ var pluginReactQuery = createPlugin((options) => {
|
|
|
19
19
|
suspense = {},
|
|
20
20
|
infinite = false,
|
|
21
21
|
transformers = {},
|
|
22
|
+
paramsType = "inline",
|
|
22
23
|
pathParamsType = "inline",
|
|
23
24
|
generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),
|
|
24
25
|
mutation = {},
|
|
@@ -28,7 +29,6 @@ var pluginReactQuery = createPlugin((options) => {
|
|
|
28
29
|
name: pluginReactQueryName,
|
|
29
30
|
options: {
|
|
30
31
|
output,
|
|
31
|
-
baseURL: void 0,
|
|
32
32
|
client: {
|
|
33
33
|
importPath: "@kubb/plugin-client/client",
|
|
34
34
|
dataReturnType: "data",
|
|
@@ -53,7 +53,8 @@ var pluginReactQuery = createPlugin((options) => {
|
|
|
53
53
|
importPath: "@tanstack/react-query",
|
|
54
54
|
...mutation
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
paramsType,
|
|
57
|
+
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
57
58
|
parser
|
|
58
59
|
},
|
|
59
60
|
pre: [pluginOasName, pluginTsName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
@@ -90,22 +91,19 @@ var pluginReactQuery = createPlugin((options) => {
|
|
|
90
91
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
91
92
|
const mode = FileManager.getMode(path.resolve(root, output.path));
|
|
92
93
|
const baseURL = await swaggerPlugin.context.getBaseURL();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
mode
|
|
107
|
-
}
|
|
108
|
-
);
|
|
94
|
+
if (baseURL) {
|
|
95
|
+
this.plugin.options.client.baseURL = baseURL;
|
|
96
|
+
}
|
|
97
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
98
|
+
oas,
|
|
99
|
+
pluginManager: this.pluginManager,
|
|
100
|
+
plugin: this.plugin,
|
|
101
|
+
contentType: swaggerPlugin.context.contentType,
|
|
102
|
+
exclude,
|
|
103
|
+
include,
|
|
104
|
+
override,
|
|
105
|
+
mode
|
|
106
|
+
});
|
|
109
107
|
const files = await operationGenerator.build(...generators);
|
|
110
108
|
await this.addFile(...files);
|
|
111
109
|
const barrelFiles = await this.fileManager.getBarrelFiles({
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAcO,IAAM,oBAAuB,GAAA
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;;AAcO,IAAM,oBAAuB,GAAA;AAEvB,IAAA,gBAAA,GAAmB,YAA+B,CAAA,CAAC,OAAY,KAAA;AAC1E,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,OAAA,EAAS,YAAY,OAAQ,EAAA;AAAA,IAC9C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,MAAS,GAAA,QAAA;AAAA,IACT,WAAW,EAAC;AAAA,IACZ,QAAW,GAAA,KAAA;AAAA,IACX,eAAe,EAAC;AAAA,IAChB,UAAa,GAAA,QAAA;AAAA,IACb,cAAiB,GAAA,QAAA;AAAA,IACjB,UAAA,GAAa,CAAC,cAAgB,EAAA,sBAAA,EAAwB,wBAAwB,iBAAiB,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IAC/G,WAAW,EAAC;AAAA,IACZ,QAAQ;AAAC,GACP,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,oBAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,UAAY,EAAA,4BAAA;AAAA,QACZ,cAAgB,EAAA,MAAA;AAAA,QAChB,GAAG,OAAQ,CAAA;AAAA,OACb;AAAA,MACA,UAAU,QACN,GAAA;AAAA,QACE,UAAY,EAAA,IAA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'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, suspenseQueryGenerator } from './generators'\nimport type { PluginReactQuery } from './types.ts'\n\nexport const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']\n\nexport const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {\n const {\n output = { path: 'hooks', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n parser = 'client',\n suspense = {},\n infinite = false,\n transformers = {},\n paramsType = 'inline',\n pathParamsType = 'inline',\n generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),\n mutation = {},\n query = {},\n } = options\n\n return {\n name: pluginReactQueryName,\n options: {\n output,\n client: {\n importPath: '@kubb/plugin-client/client',\n dataReturnType: 'data',\n ...options.client,\n },\n infinite: infinite\n ? {\n queryParam: 'id',\n initialPageParam: 0,\n cursorParam: undefined,\n ...infinite,\n }\n : false,\n suspense,\n query: {\n key: (key: unknown[]) => key,\n methods: ['get'],\n importPath: '@tanstack/react-query',\n ...query,\n },\n mutation: {\n key: (key: unknown[]) => key,\n methods: ['post', 'put', 'patch', 'delete'],\n importPath: '@tanstack/react-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\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"]}
|
|
@@ -26,7 +26,7 @@ type Options$1 = {
|
|
|
26
26
|
override?: Array<Override<ResolvedOptions$1>>;
|
|
27
27
|
/**
|
|
28
28
|
* Create `operations.ts` file with all operations grouped by methods.
|
|
29
|
-
* @default
|
|
29
|
+
* @default false
|
|
30
30
|
*/
|
|
31
31
|
operations?: boolean;
|
|
32
32
|
/**
|
|
@@ -36,29 +36,34 @@ 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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* `Full` will return ResponseConfig.
|
|
45
|
-
* @default `'data'`
|
|
46
|
-
* @private
|
|
45
|
+
* - 'data' will return ResponseConfig[data].
|
|
46
|
+
* - 'full' will return ResponseConfig.
|
|
47
|
+
* @default 'data'
|
|
47
48
|
*/
|
|
48
49
|
dataReturnType?: 'data' | 'full';
|
|
50
|
+
/**
|
|
51
|
+
* How to pass your params
|
|
52
|
+
* - 'object' will return the params and pathParams as an object.
|
|
53
|
+
* - 'inline' will return the params as comma separated params.
|
|
54
|
+
* @default 'inline'
|
|
55
|
+
*/
|
|
56
|
+
paramsType?: 'object' | 'inline';
|
|
49
57
|
/**
|
|
50
58
|
* How to pass your pathParams.
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* `inline` will return the pathParams as comma separated params.
|
|
55
|
-
* @default `'inline'`
|
|
56
|
-
* @private
|
|
59
|
+
* - 'object' will return the pathParams as an object.
|
|
60
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
61
|
+
* @default 'inline'
|
|
57
62
|
*/
|
|
58
63
|
pathParamsType?: 'object' | 'inline';
|
|
59
64
|
/**
|
|
60
65
|
* Which parser can be used before returning the data
|
|
61
|
-
*
|
|
66
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
62
67
|
* @default 'client'
|
|
63
68
|
*/
|
|
64
69
|
parser?: 'client' | 'zod';
|
|
@@ -81,6 +86,7 @@ type ResolvedOptions$1 = {
|
|
|
81
86
|
importPath: NonNullable<Options$1['importPath']>;
|
|
82
87
|
dataReturnType: NonNullable<Options$1['dataReturnType']>;
|
|
83
88
|
pathParamsType: NonNullable<Options$1['pathParamsType']>;
|
|
89
|
+
paramsType: NonNullable<Options$1['paramsType']>;
|
|
84
90
|
};
|
|
85
91
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
|
|
86
92
|
|
|
@@ -126,7 +132,7 @@ type Mutation = {
|
|
|
126
132
|
type Infinite = {
|
|
127
133
|
/**
|
|
128
134
|
* Specify the params key used for `pageParam`.
|
|
129
|
-
* @default
|
|
135
|
+
* @default 'id'
|
|
130
136
|
*/
|
|
131
137
|
queryParam: string;
|
|
132
138
|
/**
|
|
@@ -135,29 +141,21 @@ type Infinite = {
|
|
|
135
141
|
cursorParam?: string | undefined;
|
|
136
142
|
/**
|
|
137
143
|
* The initial value, the value of the first page.
|
|
138
|
-
* @default
|
|
144
|
+
* @default 0
|
|
139
145
|
*/
|
|
140
146
|
initialPageParam: unknown;
|
|
141
147
|
};
|
|
142
148
|
type Options = {
|
|
143
149
|
/**
|
|
144
|
-
*
|
|
150
|
+
* Specify the export location for the files and define the behavior of the output
|
|
151
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
145
152
|
*/
|
|
146
153
|
output?: Output;
|
|
147
154
|
/**
|
|
148
155
|
* Group the @tanstack/query hooks based on the provided name.
|
|
149
156
|
*/
|
|
150
157
|
group?: Group;
|
|
151
|
-
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath'>;
|
|
152
|
-
/**
|
|
153
|
-
* ReturnType that needs to be used when calling client().
|
|
154
|
-
*
|
|
155
|
-
* `Data` will return ResponseConfig[data].
|
|
156
|
-
*
|
|
157
|
-
* `Full` will return ResponseConfig.
|
|
158
|
-
* @default `'data'`
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
158
|
+
client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
|
|
161
159
|
/**
|
|
162
160
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
163
161
|
*/
|
|
@@ -170,14 +168,18 @@ type Options = {
|
|
|
170
168
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
171
169
|
*/
|
|
172
170
|
override?: Array<Override<ResolvedOptions>>;
|
|
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';
|
|
173
178
|
/**
|
|
174
179
|
* How to pass your pathParams.
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* `inline` will return the pathParams as comma separated params.
|
|
179
|
-
* @default `'inline'`
|
|
180
|
-
* @private
|
|
180
|
+
* - 'object' will return the pathParams as an object.
|
|
181
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
182
|
+
* @default 'inline'
|
|
181
183
|
*/
|
|
182
184
|
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
183
185
|
/**
|
|
@@ -195,9 +197,9 @@ type Options = {
|
|
|
195
197
|
/**
|
|
196
198
|
* Override some useMutation behaviours.
|
|
197
199
|
*/
|
|
198
|
-
mutation?: Mutation | false;
|
|
200
|
+
mutation?: Partial<Mutation> | false;
|
|
199
201
|
/**
|
|
200
|
-
* Which parser
|
|
202
|
+
* Which parser should be used before returning the data to `@tanstack/query`.
|
|
201
203
|
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
202
204
|
*/
|
|
203
205
|
parser?: PluginClient['options']['parser'];
|
|
@@ -214,10 +216,12 @@ type Options = {
|
|
|
214
216
|
};
|
|
215
217
|
type ResolvedOptions = {
|
|
216
218
|
output: Output;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
+
client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
|
|
220
|
+
baseURL?: string;
|
|
221
|
+
};
|
|
219
222
|
parser: Required<NonNullable<Options['parser']>>;
|
|
220
223
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
224
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
221
225
|
/**
|
|
222
226
|
* Only used of infinite
|
|
223
227
|
*/
|