@kubb/plugin-react-query 3.0.0-beta.9 → 3.0.1
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-U35NELYJ.js → chunk-ARL3PQR3.js} +259 -41
- package/dist/chunk-ARL3PQR3.js.map +1 -0
- package/dist/{chunk-D5PFCZWQ.cjs → chunk-FYBD7BZP.cjs} +259 -41
- package/dist/chunk-FYBD7BZP.cjs.map +1 -0
- package/dist/{chunk-JKG4EZID.cjs → chunk-WMQRQT7P.cjs} +158 -116
- package/dist/chunk-WMQRQT7P.cjs.map +1 -0
- package/dist/{chunk-3OOSVEDM.js → chunk-WYNK6OE2.js} +147 -105
- package/dist/chunk-WYNK6OE2.js.map +1 -0
- package/dist/components.cjs +9 -9
- package/dist/components.d.cts +29 -16
- package/dist/components.d.ts +29 -16
- 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 +25 -25
- 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 +24 -24
- package/dist/index.js.map +1 -1
- package/dist/{types-LhwfnVo7.d.cts → types-IuxCCG1K.d.cts} +46 -16
- package/dist/{types-LhwfnVo7.d.ts → types-IuxCCG1K.d.ts} +46 -16
- package/package.json +13 -12
- package/src/components/InfiniteQuery.tsx +53 -6
- package/src/components/InfiniteQueryOptions.tsx +47 -6
- package/src/components/Mutation.tsx +3 -1
- package/src/components/MutationKey.tsx +11 -5
- package/src/components/Query.tsx +62 -6
- package/src/components/QueryKey.tsx +17 -7
- package/src/components/QueryOptions.tsx +47 -7
- package/src/components/SuspenseQuery.tsx +52 -5
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTags.ts +3 -3
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +3 -3
- package/src/generators/__snapshots__/postAsQuery.ts +1 -1
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +1 -3
- package/src/generators/infiniteQueryGenerator.tsx +48 -30
- package/src/generators/mutationGenerator.tsx +30 -18
- package/src/generators/queryGenerator.tsx +29 -17
- package/src/generators/suspenseQueryGenerator.tsx +34 -19
- package/src/plugin.ts +31 -25
- package/src/types.ts +35 -15
- package/dist/chunk-3OOSVEDM.js.map +0 -1
- package/dist/chunk-D5PFCZWQ.cjs.map +0 -1
- package/dist/chunk-JKG4EZID.cjs.map +0 -1
- package/dist/chunk-U35NELYJ.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkFYBD7BZP_cjs = require('./chunk-FYBD7BZP.cjs');
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var core = require('@kubb/core');
|
|
6
6
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -10,6 +10,7 @@ var hooks = require('@kubb/plugin-oas/hooks');
|
|
|
10
10
|
var pluginTs = require('@kubb/plugin-ts');
|
|
11
11
|
var react = require('@kubb/react');
|
|
12
12
|
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
13
|
+
var remeda = require('remeda');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
|
|
@@ -57,12 +58,13 @@ var clientGenerator = pluginOas.createReactGenerator({
|
|
|
57
58
|
}
|
|
58
59
|
),
|
|
59
60
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
-
|
|
61
|
+
chunkFYBD7BZP_cjs.Client,
|
|
61
62
|
{
|
|
62
63
|
name: client.name,
|
|
63
64
|
baseURL: options.baseURL,
|
|
64
65
|
dataReturnType: options.dataReturnType,
|
|
65
66
|
pathParamsType: options.pathParamsType,
|
|
67
|
+
paramsType: options.paramsType,
|
|
66
68
|
typeSchemas: type.schemas,
|
|
67
69
|
operation,
|
|
68
70
|
parser: options.parser,
|
|
@@ -83,7 +85,7 @@ var operationsGenerator = pluginOas.createReactGenerator({
|
|
|
83
85
|
} = react.useApp();
|
|
84
86
|
const name = "operations";
|
|
85
87
|
const file = pluginManager.getFile({ name, extname: ".ts", pluginKey: [pluginClientName] });
|
|
86
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, banner: output?.banner, footer: output?.footer, children: /* @__PURE__ */ jsxRuntime.jsx(chunkFYBD7BZP_cjs.Operations, { name, operations }) });
|
|
87
89
|
}
|
|
88
90
|
});
|
|
89
91
|
var groupedClientGenerator = pluginOas.createReactGenerator({
|
|
@@ -141,10 +143,12 @@ core.createPlugin((options) => {
|
|
|
141
143
|
exclude = [],
|
|
142
144
|
include,
|
|
143
145
|
override = [],
|
|
144
|
-
transformers:
|
|
146
|
+
transformers: transformers$1 = {},
|
|
145
147
|
dataReturnType = "data",
|
|
146
148
|
pathParamsType = "inline",
|
|
149
|
+
paramsType = "inline",
|
|
147
150
|
operations = false,
|
|
151
|
+
baseURL,
|
|
148
152
|
generators = [clientGenerator, group ? groupedClientGenerator : void 0, operations ? operationsGenerator : void 0].filter(Boolean),
|
|
149
153
|
importPath = "@kubb/plugin-client/client",
|
|
150
154
|
parser = "client"
|
|
@@ -157,8 +161,9 @@ core.createPlugin((options) => {
|
|
|
157
161
|
parser,
|
|
158
162
|
dataReturnType,
|
|
159
163
|
importPath,
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
paramsType,
|
|
165
|
+
pathParamsType: paramsType === "object" ? "object" : pathParamsType,
|
|
166
|
+
baseURL
|
|
162
167
|
},
|
|
163
168
|
pre: [pluginOas.pluginOasName, parser === "zod" ? pluginZod.pluginZodName : void 0].filter(Boolean),
|
|
164
169
|
resolvePath(baseName, pathMode, options2) {
|
|
@@ -176,7 +181,7 @@ core.createPlugin((options) => {
|
|
|
176
181
|
resolveName(name, type) {
|
|
177
182
|
const resolvedName = transformers.camelCase(name, { isFile: type === "file" });
|
|
178
183
|
if (type) {
|
|
179
|
-
return
|
|
184
|
+
return transformers$1?.name?.(resolvedName, type) || resolvedName;
|
|
180
185
|
}
|
|
181
186
|
return resolvedName;
|
|
182
187
|
},
|
|
@@ -185,12 +190,12 @@ core.createPlugin((options) => {
|
|
|
185
190
|
const oas = await swaggerPlugin.context.getOas();
|
|
186
191
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
187
192
|
const mode = core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
188
|
-
const
|
|
193
|
+
const baseURL2 = await swaggerPlugin.context.getBaseURL();
|
|
189
194
|
const operationGenerator = new pluginOas.OperationGenerator(
|
|
190
|
-
{
|
|
195
|
+
baseURL2 ? {
|
|
191
196
|
...this.plugin.options,
|
|
192
|
-
baseURL
|
|
193
|
-
},
|
|
197
|
+
baseURL: baseURL2
|
|
198
|
+
} : this.plugin.options,
|
|
194
199
|
{
|
|
195
200
|
oas,
|
|
196
201
|
pluginManager: this.pluginManager,
|
|
@@ -228,7 +233,10 @@ var queryGenerator = pluginOas.createReactGenerator({
|
|
|
228
233
|
} = react.useApp();
|
|
229
234
|
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
230
235
|
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
231
|
-
|
|
236
|
+
const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
237
|
+
(method) => operation.method === method
|
|
238
|
+
);
|
|
239
|
+
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
232
240
|
const query = {
|
|
233
241
|
name: getName(operation, { type: "function", prefix: "use" }),
|
|
234
242
|
typeName: getName(operation, { type: "type" }),
|
|
@@ -253,13 +261,11 @@ var queryGenerator = pluginOas.createReactGenerator({
|
|
|
253
261
|
file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
|
|
254
262
|
schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
|
|
255
263
|
};
|
|
256
|
-
if (!isQuery ||
|
|
264
|
+
if (!isQuery || isMutation) {
|
|
257
265
|
return null;
|
|
258
266
|
}
|
|
259
267
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
260
268
|
options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
|
|
261
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useQuery", "queryOptions"], path: options.query.importPath }),
|
|
262
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired", "QueryObserverOptions", "UseQueryResult"], path: options.query.importPath, isTypeOnly: true }),
|
|
263
269
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
264
270
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
265
271
|
options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
@@ -280,54 +286,62 @@ var queryGenerator = pluginOas.createReactGenerator({
|
|
|
280
286
|
}
|
|
281
287
|
),
|
|
282
288
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
283
|
-
|
|
289
|
+
chunkFYBD7BZP_cjs.QueryKey,
|
|
284
290
|
{
|
|
285
291
|
name: queryKey.name,
|
|
286
292
|
typeName: queryKey.typeName,
|
|
287
293
|
operation,
|
|
288
294
|
pathParamsType: options.pathParamsType,
|
|
289
295
|
typeSchemas: type.schemas,
|
|
290
|
-
|
|
296
|
+
transformer: options.queryKey
|
|
291
297
|
}
|
|
292
298
|
),
|
|
293
299
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
294
|
-
|
|
300
|
+
chunkFYBD7BZP_cjs.Client,
|
|
295
301
|
{
|
|
296
302
|
name: client.name,
|
|
297
303
|
isExportable: false,
|
|
298
304
|
isIndexable: false,
|
|
299
|
-
baseURL: options.baseURL,
|
|
305
|
+
baseURL: options.client.baseURL,
|
|
300
306
|
operation,
|
|
301
307
|
typeSchemas: type.schemas,
|
|
302
308
|
zodSchemas: zod.schemas,
|
|
303
309
|
dataReturnType: options.client.dataReturnType,
|
|
310
|
+
paramsType: options.paramsType,
|
|
304
311
|
pathParamsType: options.pathParamsType,
|
|
305
312
|
parser: options.parser
|
|
306
313
|
}
|
|
307
314
|
),
|
|
315
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
|
|
308
316
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
309
|
-
|
|
317
|
+
chunkFYBD7BZP_cjs.QueryOptions,
|
|
310
318
|
{
|
|
311
319
|
name: queryOptions.name,
|
|
312
320
|
clientName: client.name,
|
|
313
321
|
queryKeyName: queryKey.name,
|
|
314
322
|
typeSchemas: type.schemas,
|
|
323
|
+
paramsType: options.paramsType,
|
|
315
324
|
pathParamsType: options.pathParamsType
|
|
316
325
|
}
|
|
317
326
|
),
|
|
318
|
-
/* @__PURE__ */ jsxRuntime.
|
|
319
|
-
|
|
320
|
-
{
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
327
|
+
options.query && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useQuery"], path: importPath }),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "QueryObserverOptions", "UseQueryResult"], path: importPath, isTypeOnly: true }),
|
|
330
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
331
|
+
chunkFYBD7BZP_cjs.Query,
|
|
332
|
+
{
|
|
333
|
+
name: query.name,
|
|
334
|
+
queryOptionsName: queryOptions.name,
|
|
335
|
+
typeSchemas: type.schemas,
|
|
336
|
+
paramsType: options.paramsType,
|
|
337
|
+
pathParamsType: options.pathParamsType,
|
|
338
|
+
operation,
|
|
339
|
+
dataReturnType: options.client.dataReturnType,
|
|
340
|
+
queryKeyName: queryKey.name,
|
|
341
|
+
queryKeyTypeName: queryKey.typeName
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] })
|
|
331
345
|
] });
|
|
332
346
|
}
|
|
333
347
|
});
|
|
@@ -340,8 +354,9 @@ var mutationGenerator = pluginOas.createReactGenerator({
|
|
|
340
354
|
}
|
|
341
355
|
} = react.useApp();
|
|
342
356
|
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
343
|
-
const isQuery =
|
|
344
|
-
const isMutation = !isQuery && options.mutation
|
|
357
|
+
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
|
|
358
|
+
const isMutation = !isQuery && remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
359
|
+
const importPath = options.mutation ? options.mutation.importPath : "@tanstack/react-query";
|
|
345
360
|
const mutation = {
|
|
346
361
|
name: getName(operation, { type: "function", prefix: "use" }),
|
|
347
362
|
typeName: getName(operation, { type: "type" }),
|
|
@@ -363,13 +378,11 @@ var mutationGenerator = pluginOas.createReactGenerator({
|
|
|
363
378
|
name: getName(operation, { type: "const", suffix: "MutationKey" }),
|
|
364
379
|
typeName: getName(operation, { type: "type", suffix: "MutationKey" })
|
|
365
380
|
};
|
|
366
|
-
if (!isMutation
|
|
381
|
+
if (!isMutation) {
|
|
367
382
|
return null;
|
|
368
383
|
}
|
|
369
384
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: mutation.file.baseName, path: mutation.file.path, meta: mutation.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
370
385
|
options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: mutation.file.path, path: zod.file.path }),
|
|
371
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useMutation"], path: options.mutation.importPath }),
|
|
372
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["UseMutationOptions"], path: options.mutation.importPath, isTypeOnly: true }),
|
|
373
386
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
374
387
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig", "ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
375
388
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -389,44 +402,50 @@ var mutationGenerator = pluginOas.createReactGenerator({
|
|
|
389
402
|
}
|
|
390
403
|
),
|
|
391
404
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
392
|
-
|
|
405
|
+
chunkFYBD7BZP_cjs.MutationKey,
|
|
393
406
|
{
|
|
394
407
|
name: mutationKey.name,
|
|
395
408
|
typeName: mutationKey.typeName,
|
|
396
409
|
operation,
|
|
397
410
|
pathParamsType: options.pathParamsType,
|
|
398
411
|
typeSchemas: type.schemas,
|
|
399
|
-
|
|
412
|
+
transformer: options.mutationKey
|
|
400
413
|
}
|
|
401
414
|
),
|
|
402
415
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
403
|
-
|
|
416
|
+
chunkFYBD7BZP_cjs.Client,
|
|
404
417
|
{
|
|
405
418
|
name: client.name,
|
|
406
419
|
isExportable: false,
|
|
407
420
|
isIndexable: false,
|
|
408
|
-
baseURL: options.baseURL,
|
|
421
|
+
baseURL: options.client.baseURL,
|
|
409
422
|
operation,
|
|
410
423
|
typeSchemas: type.schemas,
|
|
411
424
|
zodSchemas: zod.schemas,
|
|
412
425
|
dataReturnType: options.client.dataReturnType,
|
|
426
|
+
paramsType: options.paramsType,
|
|
413
427
|
pathParamsType: options.pathParamsType,
|
|
414
428
|
parser: options.parser
|
|
415
429
|
}
|
|
416
430
|
),
|
|
417
|
-
/* @__PURE__ */ jsxRuntime.
|
|
418
|
-
|
|
419
|
-
{
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
431
|
+
options.mutation && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
432
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useMutation"], path: importPath }),
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["UseMutationOptions"], path: importPath, isTypeOnly: true }),
|
|
434
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
435
|
+
chunkFYBD7BZP_cjs.Mutation,
|
|
436
|
+
{
|
|
437
|
+
name: mutation.name,
|
|
438
|
+
clientName: client.name,
|
|
439
|
+
typeName: mutation.typeName,
|
|
440
|
+
typeSchemas: type.schemas,
|
|
441
|
+
operation,
|
|
442
|
+
dataReturnType: options.client.dataReturnType,
|
|
443
|
+
paramsType: options.paramsType,
|
|
444
|
+
pathParamsType: options.pathParamsType,
|
|
445
|
+
mutationKeyName: mutationKey.name
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
] })
|
|
430
449
|
] });
|
|
431
450
|
}
|
|
432
451
|
});
|
|
@@ -439,8 +458,12 @@ var infiniteQueryGenerator = pluginOas.createReactGenerator({
|
|
|
439
458
|
}
|
|
440
459
|
} = react.useApp();
|
|
441
460
|
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
442
|
-
const isQuery = typeof options.query === "boolean" ?
|
|
443
|
-
const
|
|
461
|
+
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
462
|
+
const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
463
|
+
(method) => operation.method === method
|
|
464
|
+
);
|
|
465
|
+
const isInfinite = !!options.infinite;
|
|
466
|
+
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
444
467
|
const query = {
|
|
445
468
|
name: getName(operation, { type: "function", prefix: "use", suffix: "infinite" }),
|
|
446
469
|
typeName: getName(operation, { type: "type" }),
|
|
@@ -465,13 +488,11 @@ var infiniteQueryGenerator = pluginOas.createReactGenerator({
|
|
|
465
488
|
file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
|
|
466
489
|
schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
|
|
467
490
|
};
|
|
468
|
-
if (!isQuery ||
|
|
491
|
+
if (!isQuery || isMutation || !isInfinite) {
|
|
469
492
|
return null;
|
|
470
493
|
}
|
|
471
494
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
472
495
|
options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
|
|
473
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useInfiniteQuery", "infiniteQueryOptions"], path: options.query.importPath }),
|
|
474
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: options.query.importPath, isTypeOnly: true }),
|
|
475
496
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
476
497
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
477
498
|
options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
@@ -492,58 +513,69 @@ var infiniteQueryGenerator = pluginOas.createReactGenerator({
|
|
|
492
513
|
}
|
|
493
514
|
),
|
|
494
515
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
495
|
-
|
|
516
|
+
chunkFYBD7BZP_cjs.QueryKey,
|
|
496
517
|
{
|
|
497
518
|
name: queryKey.name,
|
|
498
519
|
typeName: queryKey.typeName,
|
|
499
520
|
operation,
|
|
500
521
|
pathParamsType: options.pathParamsType,
|
|
501
522
|
typeSchemas: type.schemas,
|
|
502
|
-
|
|
523
|
+
transformer: options.queryKey
|
|
503
524
|
}
|
|
504
525
|
),
|
|
505
526
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
506
|
-
|
|
527
|
+
chunkFYBD7BZP_cjs.Client,
|
|
507
528
|
{
|
|
508
529
|
name: client.name,
|
|
509
530
|
isExportable: false,
|
|
510
531
|
isIndexable: false,
|
|
511
|
-
baseURL: options.baseURL,
|
|
532
|
+
baseURL: options.client.baseURL,
|
|
512
533
|
operation,
|
|
513
534
|
typeSchemas: type.schemas,
|
|
514
535
|
zodSchemas: zod.schemas,
|
|
515
536
|
dataReturnType: options.client.dataReturnType,
|
|
537
|
+
paramsType: options.paramsType,
|
|
516
538
|
pathParamsType: options.pathParamsType,
|
|
517
539
|
parser: options.parser
|
|
518
540
|
}
|
|
519
541
|
),
|
|
520
|
-
/* @__PURE__ */ jsxRuntime.
|
|
521
|
-
|
|
522
|
-
{
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
542
|
+
options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
543
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["InfiniteData"], isTypeOnly: true, path: importPath }),
|
|
544
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["infiniteQueryOptions"], path: importPath }),
|
|
545
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
546
|
+
chunkFYBD7BZP_cjs.InfiniteQueryOptions,
|
|
547
|
+
{
|
|
548
|
+
name: queryOptions.name,
|
|
549
|
+
clientName: client.name,
|
|
550
|
+
queryKeyName: queryKey.name,
|
|
551
|
+
typeSchemas: type.schemas,
|
|
552
|
+
paramsType: options.paramsType,
|
|
553
|
+
pathParamsType: options.pathParamsType,
|
|
554
|
+
dataReturnType: options.client.dataReturnType,
|
|
555
|
+
cursorParam: options.infinite.cursorParam,
|
|
556
|
+
initialPageParam: options.infinite.initialPageParam,
|
|
557
|
+
queryParam: options.infinite.queryParam
|
|
558
|
+
}
|
|
559
|
+
)
|
|
560
|
+
] }),
|
|
561
|
+
options.infinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
562
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useInfiniteQuery"], path: importPath }),
|
|
563
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "InfiniteQueryObserverOptions", "UseInfiniteQueryResult"], path: importPath, isTypeOnly: true }),
|
|
564
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
565
|
+
chunkFYBD7BZP_cjs.InfiniteQuery,
|
|
566
|
+
{
|
|
567
|
+
name: query.name,
|
|
568
|
+
queryOptionsName: queryOptions.name,
|
|
569
|
+
typeSchemas: type.schemas,
|
|
570
|
+
paramsType: options.paramsType,
|
|
571
|
+
pathParamsType: options.pathParamsType,
|
|
572
|
+
operation,
|
|
573
|
+
dataReturnType: options.client.dataReturnType,
|
|
574
|
+
queryKeyName: queryKey.name,
|
|
575
|
+
queryKeyTypeName: queryKey.typeName
|
|
576
|
+
}
|
|
577
|
+
)
|
|
578
|
+
] })
|
|
547
579
|
] });
|
|
548
580
|
}
|
|
549
581
|
});
|
|
@@ -556,8 +588,12 @@ var suspenseQueryGenerator = pluginOas.createReactGenerator({
|
|
|
556
588
|
}
|
|
557
589
|
} = react.useApp();
|
|
558
590
|
const { getSchemas, getName, getFile } = hooks.useOperationManager();
|
|
559
|
-
const isQuery = typeof options.query === "boolean" ?
|
|
560
|
-
const
|
|
591
|
+
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
592
|
+
const isMutation = remeda.difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
|
|
593
|
+
(method) => operation.method === method
|
|
594
|
+
);
|
|
595
|
+
const isSuspense = !!options.suspense;
|
|
596
|
+
const importPath = options.query ? options.query.importPath : "@tanstack/react-query";
|
|
561
597
|
const query = {
|
|
562
598
|
name: getName(operation, { type: "function", prefix: "use", suffix: "suspense" }),
|
|
563
599
|
typeName: getName(operation, { type: "type" }),
|
|
@@ -582,13 +618,11 @@ var suspenseQueryGenerator = pluginOas.createReactGenerator({
|
|
|
582
618
|
file: getFile(operation, { pluginKey: [pluginZod.pluginZodName] }),
|
|
583
619
|
schemas: getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" })
|
|
584
620
|
};
|
|
585
|
-
if (!isQuery ||
|
|
621
|
+
if (!isQuery || isMutation || !isSuspense) {
|
|
586
622
|
return null;
|
|
587
623
|
}
|
|
588
624
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: query.file.baseName, path: query.file.path, meta: query.file.meta, banner: output?.banner, footer: output?.footer, children: [
|
|
589
625
|
options.parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zod.schemas.response.name], root: query.file.path, path: zod.file.path }),
|
|
590
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useSuspenseQuery", "queryOptions"], path: options.query.importPath }),
|
|
591
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: options.query.importPath, isTypeOnly: true }),
|
|
592
626
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: options.client.importPath }),
|
|
593
627
|
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["RequestConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
594
628
|
options.client.dataReturnType === "full" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: options.client.importPath, isTypeOnly: true }),
|
|
@@ -609,54 +643,62 @@ var suspenseQueryGenerator = pluginOas.createReactGenerator({
|
|
|
609
643
|
}
|
|
610
644
|
),
|
|
611
645
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
612
|
-
|
|
646
|
+
chunkFYBD7BZP_cjs.QueryKey,
|
|
613
647
|
{
|
|
614
648
|
name: queryKey.name,
|
|
615
649
|
typeName: queryKey.typeName,
|
|
616
650
|
operation,
|
|
617
651
|
pathParamsType: options.pathParamsType,
|
|
618
652
|
typeSchemas: type.schemas,
|
|
619
|
-
|
|
653
|
+
transformer: options.queryKey
|
|
620
654
|
}
|
|
621
655
|
),
|
|
622
656
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
623
|
-
|
|
657
|
+
chunkFYBD7BZP_cjs.Client,
|
|
624
658
|
{
|
|
625
659
|
name: client.name,
|
|
626
660
|
isExportable: false,
|
|
627
661
|
isIndexable: false,
|
|
628
|
-
baseURL: options.baseURL,
|
|
662
|
+
baseURL: options.client.baseURL,
|
|
629
663
|
operation,
|
|
630
664
|
typeSchemas: type.schemas,
|
|
631
665
|
zodSchemas: zod.schemas,
|
|
632
666
|
dataReturnType: options.client.dataReturnType,
|
|
667
|
+
paramsType: options.paramsType,
|
|
633
668
|
pathParamsType: options.pathParamsType,
|
|
634
669
|
parser: options.parser
|
|
635
670
|
}
|
|
636
671
|
),
|
|
672
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["queryOptions"], path: importPath }),
|
|
637
673
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
638
|
-
|
|
674
|
+
chunkFYBD7BZP_cjs.QueryOptions,
|
|
639
675
|
{
|
|
640
676
|
name: queryOptions.name,
|
|
641
677
|
clientName: client.name,
|
|
642
678
|
queryKeyName: queryKey.name,
|
|
643
679
|
typeSchemas: type.schemas,
|
|
680
|
+
paramsType: options.paramsType,
|
|
644
681
|
pathParamsType: options.pathParamsType
|
|
645
682
|
}
|
|
646
683
|
),
|
|
647
|
-
/* @__PURE__ */ jsxRuntime.
|
|
648
|
-
|
|
649
|
-
{
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
684
|
+
options.suspense && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
685
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useSuspenseQuery"], path: importPath }),
|
|
686
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "UseSuspenseQueryOptions", "UseSuspenseQueryResult"], path: importPath, isTypeOnly: true }),
|
|
687
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
688
|
+
chunkFYBD7BZP_cjs.SuspenseQuery,
|
|
689
|
+
{
|
|
690
|
+
name: query.name,
|
|
691
|
+
queryOptionsName: queryOptions.name,
|
|
692
|
+
typeSchemas: type.schemas,
|
|
693
|
+
paramsType: options.paramsType,
|
|
694
|
+
pathParamsType: options.pathParamsType,
|
|
695
|
+
operation,
|
|
696
|
+
dataReturnType: options.client.dataReturnType,
|
|
697
|
+
queryKeyName: queryKey.name,
|
|
698
|
+
queryKeyTypeName: queryKey.typeName
|
|
699
|
+
}
|
|
700
|
+
)
|
|
701
|
+
] })
|
|
660
702
|
] });
|
|
661
703
|
}
|
|
662
704
|
});
|
|
@@ -665,5 +707,5 @@ exports.infiniteQueryGenerator = infiniteQueryGenerator;
|
|
|
665
707
|
exports.mutationGenerator = mutationGenerator;
|
|
666
708
|
exports.queryGenerator = queryGenerator;
|
|
667
709
|
exports.suspenseQueryGenerator = suspenseQueryGenerator;
|
|
668
|
-
//# sourceMappingURL=chunk-
|
|
669
|
-
//# sourceMappingURL=chunk-
|
|
710
|
+
//# sourceMappingURL=chunk-WMQRQT7P.cjs.map
|
|
711
|
+
//# sourceMappingURL=chunk-WMQRQT7P.cjs.map
|