@kubb/plugin-react-query 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
Files changed (81) hide show
  1. package/README.md +13 -4
  2. package/dist/chunk-2D27Y6L5.js +618 -0
  3. package/dist/chunk-2D27Y6L5.js.map +1 -0
  4. package/dist/chunk-C2H3KPHM.cjs +658 -0
  5. package/dist/chunk-C2H3KPHM.cjs.map +1 -0
  6. package/dist/chunk-JW3GZUSC.cjs +627 -0
  7. package/dist/chunk-JW3GZUSC.cjs.map +1 -0
  8. package/dist/chunk-Y3DM2P6L.js +647 -0
  9. package/dist/chunk-Y3DM2P6L.js.map +1 -0
  10. package/dist/components.cjs +39 -14
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +161 -7
  13. package/dist/components.d.ts +161 -7
  14. package/dist/components.js +2 -14
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +25 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +14 -0
  19. package/dist/generators.d.ts +14 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +75 -154
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +1 -5
  25. package/dist/index.d.ts +1 -5
  26. package/dist/index.js +54 -140
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-rJasmoxy.d.cts +187 -0
  29. package/dist/types-rJasmoxy.d.ts +187 -0
  30. package/package.json +22 -17
  31. package/src/components/InfiniteQuery.tsx +129 -0
  32. package/src/components/InfiniteQueryOptions.tsx +130 -0
  33. package/src/components/Mutation.tsx +138 -322
  34. package/src/components/MutationKey.tsx +48 -0
  35. package/src/components/Query.tsx +91 -598
  36. package/src/components/QueryKey.tsx +51 -178
  37. package/src/components/QueryOptions.tsx +72 -466
  38. package/src/components/SuspenseQuery.tsx +129 -0
  39. package/src/components/index.ts +4 -1
  40. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  41. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  42. package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
  43. package/src/generators/__snapshots__/findByTags.ts +51 -0
  44. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  45. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  46. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  47. package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
  48. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
  49. package/src/generators/__snapshots__/getAsMutation.ts +31 -0
  50. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +44 -0
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -0
  53. package/src/generators/index.ts +4 -0
  54. package/src/generators/infiniteQueryGenerator.tsx +124 -0
  55. package/src/generators/mutationGenerator.tsx +108 -0
  56. package/src/generators/queryGenerator.tsx +121 -0
  57. package/src/generators/suspenseQueryGenerator.tsx +120 -0
  58. package/src/plugin.ts +51 -75
  59. package/src/types.ts +49 -88
  60. package/dist/chunk-5IL6M74X.js +0 -1504
  61. package/dist/chunk-5IL6M74X.js.map +0 -1
  62. package/dist/chunk-JFX7DCS7.cjs +0 -1504
  63. package/dist/chunk-JFX7DCS7.cjs.map +0 -1
  64. package/dist/index-C9fwRDH7.d.cts +0 -579
  65. package/dist/index-C9fwRDH7.d.ts +0 -579
  66. package/src/OperationGenerator.tsx +0 -86
  67. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -64
  68. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -57
  69. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -63
  70. package/src/__snapshots__/queryOptions/getPetById.ts +0 -37
  71. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -47
  72. package/src/__snapshots__/upload/UploadFile.ts +0 -67
  73. package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -44
  74. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -21
  75. package/src/components/Operations.tsx +0 -74
  76. package/src/components/QueryImports.tsx +0 -167
  77. package/src/components/SchemaType.tsx +0 -55
  78. package/src/components/__snapshots__/gen/showPetById.ts +0 -57
  79. package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
  80. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -47
  81. package/src/utils.ts +0 -96
@@ -1,1504 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/components/Mutation.tsx
2
- var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
3
- var _utils = require('@kubb/core/utils');
4
- var _hooks = require('@kubb/plugin-oas/hooks');
5
- var _utils3 = require('@kubb/plugin-oas/utils');
6
- var _react = require('@kubb/react');
7
- var _plugints = require('@kubb/plugin-ts');
8
-
9
- // src/components/SchemaType.tsx
10
-
11
-
12
-
13
- var _jsxruntime = require('@kubb/react/jsx-runtime');
14
- function SchemaType() {
15
- const {
16
- plugin: {
17
- options: { dataReturnType }
18
- }
19
- } = _react.useApp.call(void 0, );
20
- const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
21
- const operation = _hooks.useOperation.call(void 0, );
22
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
23
- const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [
24
- schemas.response.name,
25
- _optionalChain([schemas, 'access', _ => _.errors, 'optionalAccess', _2 => _2.map, 'call', _3 => _3((item) => item.name), 'access', _4 => _4.join, 'call', _5 => _5(" | ")]) || "never",
26
- _optionalChain([schemas, 'access', _6 => _6.request, 'optionalAccess', _7 => _7.name]) || "never",
27
- _optionalChain([schemas, 'access', _8 => _8.pathParams, 'optionalAccess', _9 => _9.name]) || "never",
28
- _optionalChain([schemas, 'access', _10 => _10.queryParams, 'optionalAccess', _11 => _11.name]) || "never",
29
- _optionalChain([schemas, 'access', _12 => _12.headerParams, 'optionalAccess', _13 => _13.name]) || "never",
30
- schemas.response.name
31
- ];
32
- const factoryName = getName(operation, { type: "type" });
33
- const clientType = `${factoryName}Client`;
34
- const isFormData = operation.getContentType() === "multipart/form-data";
35
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
36
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${isFormData ? "FormData" : TRequest}>` }),
37
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: factoryName, children: `
38
- {
39
- data: ${TData}
40
- error: ${TError}
41
- request: ${isFormData ? "FormData" : TRequest}
42
- pathParams: ${TPathParams}
43
- queryParams: ${TQueryParams}
44
- headerParams: ${THeaderParams}
45
- response: ${dataReturnType === "data" ? TData : `Awaited<ReturnType<${clientType}>>`}
46
- client: {
47
- parameters: Partial<Parameters<${clientType}>[0]>
48
- return: Awaited<ReturnType<${clientType}>>
49
- }
50
- }
51
- ` })
52
- ] });
53
- }
54
-
55
- // src/components/Mutation.tsx
56
- var _oas = require('@kubb/oas');
57
-
58
- function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnType }) {
59
- const isFormData = client.contentType === "multipart/form-data";
60
- const headers = [
61
- client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
62
- client.withHeaders ? "...headers" : void 0
63
- ].filter(Boolean).join(", ");
64
- const clientOptions = [
65
- `method: "${client.method}"`,
66
- `url: ${client.path.template}`,
67
- client.withQueryParams ? "params" : void 0,
68
- client.withData && !isFormData ? "data" : void 0,
69
- client.withData && isFormData ? "data: formData" : void 0,
70
- headers.length ? `headers: { ${headers}, ...clientOptions.headers }` : void 0,
71
- "...clientOptions"
72
- ].filter(Boolean);
73
- const resolvedClientOptions = `${_transformers2.default.createIndent(4)}${clientOptions.join(`,
74
- ${_transformers2.default.createIndent(4)}`)}`;
75
- const formData = isFormData ? `
76
- const formData = new FormData()
77
- if(data) {
78
- Object.keys(data).forEach((key) => {
79
- const value = data[key];
80
- if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
81
- formData.append(key, value);
82
- }
83
- })
84
- }
85
- ` : void 0;
86
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, params, JSDoc, children: `
87
- const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
88
-
89
- return ${hook.name}({
90
- mutationFn: async(${mutateParams}) => {
91
- ${hook.children || ""}
92
- ${formData || ""}
93
- const res = await client<${client.generics}>({
94
- ${resolvedClientOptions}
95
- })
96
-
97
- return ${dataReturnType === "data" ? "res.data" : "res"}
98
- },
99
- ...mutationOptions
100
- })` });
101
- }
102
- function RootTemplate({ children }) {
103
- const {
104
- plugin: {
105
- options: {
106
- client: { importPath },
107
- mutate
108
- }
109
- }
110
- } = _react.useApp.call(void 0, );
111
- const { getSchemas, getFile } = _hooks.useOperationManager.call(void 0, );
112
- const operation = _hooks.useOperation.call(void 0, );
113
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
114
- const file = getFile(operation);
115
- const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
116
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
117
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
118
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
119
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
120
- _react.File.Import,
121
- {
122
- name: [
123
- _optionalChain([schemas, 'access', _14 => _14.request, 'optionalAccess', _15 => _15.name]),
124
- schemas.response.name,
125
- _optionalChain([schemas, 'access', _16 => _16.pathParams, 'optionalAccess', _17 => _17.name]),
126
- _optionalChain([schemas, 'access', _18 => _18.queryParams, 'optionalAccess', _19 => _19.name]),
127
- _optionalChain([schemas, 'access', _20 => _20.headerParams, 'optionalAccess', _21 => _21.name]),
128
- ..._optionalChain([schemas, 'access', _22 => _22.errors, 'optionalAccess', _23 => _23.map, 'call', _24 => _24((error) => error.name)]) || []
129
- ].filter(Boolean),
130
- root: file.path,
131
- path: fileType.path,
132
- isTypeOnly: true
133
- }
134
- ),
135
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
136
- _react.File.Import,
137
- {
138
- name: ["UseMutationOptions", "UseMutationResult"],
139
- path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query",
140
- isTypeOnly: true
141
- }
142
- ),
143
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["useMutation"], path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query" }),
144
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children })
145
- ] }) });
146
- }
147
- var defaultTemplates = { default: Template, root: RootTemplate };
148
- function Mutation({ Template: Template7 = defaultTemplates.default }) {
149
- const {
150
- plugin: {
151
- options: { dataReturnType, mutate }
152
- }
153
- } = _react.useApp.call(void 0, );
154
- const operation = _hooks.useOperation.call(void 0, );
155
- const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
156
- const name = getName(operation, { type: "function" });
157
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
158
- const contentType = operation.getContentType();
159
- const params = new (0, _utils.FunctionParams)();
160
- const mutateParams = new (0, _utils.FunctionParams)();
161
- const factoryName = getName(operation, { type: "type" });
162
- const requestType = mutate && mutate.variablesType === "mutate" ? _optionalChain([_utils.FunctionParams, 'access', _25 => _25.toObject, 'call', _26 => _26([
163
- ..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
164
- {
165
- name: "params",
166
- type: `${factoryName}['queryParams']`,
167
- enabled: !!_optionalChain([schemas, 'access', _27 => _27.queryParams, 'optionalAccess', _28 => _28.name]),
168
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _29 => _29.queryParams, 'optionalAccess', _30 => _30.schema]))
169
- },
170
- {
171
- name: "headers",
172
- type: `${factoryName}['headerParams']`,
173
- enabled: !!_optionalChain([schemas, 'access', _31 => _31.headerParams, 'optionalAccess', _32 => _32.name]),
174
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _33 => _33.headerParams, 'optionalAccess', _34 => _34.schema]))
175
- },
176
- {
177
- name: "data",
178
- type: `${factoryName}['request']`,
179
- enabled: !!_optionalChain([schemas, 'access', _35 => _35.request, 'optionalAccess', _36 => _36.name]),
180
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _37 => _37.request, 'optionalAccess', _38 => _38.schema]))
181
- }
182
- ]), 'optionalAccess', _39 => _39.type]) : _optionalChain([schemas, 'access', _40 => _40.request, 'optionalAccess', _41 => _41.name]) ? `${factoryName}['request']` : "never";
183
- const client = {
184
- method: operation.method,
185
- path: new (0, _utils.URLPath)(operation.path),
186
- generics: [`${factoryName}["data"]`, `${factoryName}["error"]`, requestType ? `${factoryName}["request"]` : "void"].join(", "),
187
- withQueryParams: !!_optionalChain([schemas, 'access', _42 => _42.queryParams, 'optionalAccess', _43 => _43.name]),
188
- withData: !!_optionalChain([schemas, 'access', _44 => _44.request, 'optionalAccess', _45 => _45.name]),
189
- withPathParams: !!_optionalChain([schemas, 'access', _46 => _46.pathParams, 'optionalAccess', _47 => _47.name]),
190
- withHeaders: !!_optionalChain([schemas, 'access', _48 => _48.headerParams, 'optionalAccess', _49 => _49.name]),
191
- contentType
192
- };
193
- const hook = {
194
- name: "useMutation",
195
- generics: [`${factoryName}['response']`, `${factoryName}["error"]`, requestType ? `${requestType}` : "void"].join(", ")
196
- };
197
- const resultGenerics = [
198
- `${factoryName}["response"]`,
199
- `${factoryName}["error"]`,
200
- mutate && _optionalChain([mutate, 'optionalAccess', _50 => _50.variablesType]) === "mutate" ? requestType : `${factoryName}["request"]`
201
- ];
202
- if (mutate && _optionalChain([mutate, 'optionalAccess', _51 => _51.variablesType]) === "mutate") {
203
- params.add([
204
- {
205
- name: "options",
206
- type: `{
207
- mutation?: UseMutationOptions<${resultGenerics.join(", ")}>,
208
- client?: ${factoryName}['client']['parameters']
209
- }`,
210
- default: "{}"
211
- }
212
- ]);
213
- mutateParams.add([
214
- [
215
- ..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: false }),
216
- {
217
- name: "params",
218
- enabled: client.withQueryParams,
219
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _52 => _52.queryParams, 'optionalAccess', _53 => _53.schema]))
220
- },
221
- {
222
- name: "headers",
223
- enabled: client.withHeaders,
224
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _54 => _54.headerParams, 'optionalAccess', _55 => _55.schema]))
225
- },
226
- {
227
- name: "data",
228
- enabled: !!_optionalChain([schemas, 'access', _56 => _56.request, 'optionalAccess', _57 => _57.name]),
229
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _58 => _58.request, 'optionalAccess', _59 => _59.schema]))
230
- }
231
- ]
232
- ]);
233
- } else {
234
- params.add([
235
- ..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
236
- {
237
- name: "params",
238
- type: `${factoryName}['queryParams']`,
239
- enabled: client.withQueryParams,
240
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _60 => _60.queryParams, 'optionalAccess', _61 => _61.schema]))
241
- },
242
- {
243
- name: "headers",
244
- type: `${factoryName}['headerParams']`,
245
- enabled: client.withHeaders,
246
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _62 => _62.headerParams, 'optionalAccess', _63 => _63.schema]))
247
- },
248
- {
249
- name: "options",
250
- type: `{
251
- mutation?: UseMutationOptions<${resultGenerics.join(", ")}>,
252
- client?: ${factoryName}['client']['parameters']
253
- }`,
254
- default: "{}"
255
- }
256
- ]);
257
- mutateParams.add([
258
- {
259
- name: "data",
260
- enabled: !!_optionalChain([schemas, 'access', _64 => _64.request, 'optionalAccess', _65 => _65.name]),
261
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _66 => _66.request, 'optionalAccess', _67 => _67.schema]))
262
- }
263
- ]);
264
- }
265
- if (!mutate) {
266
- return null;
267
- }
268
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
269
- Template7,
270
- {
271
- name,
272
- JSDoc: { comments: _utils3.getComments.call(void 0, operation) },
273
- client,
274
- hook,
275
- params: params.toString(),
276
- mutateParams: mutateParams.toString(),
277
- dataReturnType
278
- }
279
- ) });
280
- }
281
- Mutation.File = function({ ...props }) {
282
- const templates = { ...defaultTemplates, ...props.templates };
283
- const Template7 = templates.default;
284
- const RootTemplate3 = templates.root;
285
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, RootTemplate3, { children: [
286
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, {}),
287
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mutation, { Template: Template7 })
288
- ] });
289
- };
290
- Mutation.templates = defaultTemplates;
291
-
292
- // src/components/Operations.tsx
293
-
294
-
295
- function Template2({}) {
296
- return null;
297
- }
298
- function RootTemplate2({ children }) {
299
- const {
300
- pluginManager,
301
- plugin: { key: pluginKey }
302
- } = _react.useApp.call(void 0, );
303
- const file = pluginManager.getFile({
304
- name: "operations",
305
- mode: "split",
306
- extName: ".ts",
307
- pluginKey
308
- });
309
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Source, { children }) }) });
310
- }
311
- var defaultTemplates2 = { default: Template2, root: RootTemplate2 };
312
- function Operations({ Template: Template7 = defaultTemplates2.default }) {
313
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template7, {});
314
- }
315
- Operations.File = function(props) {
316
- const templates = { ...defaultTemplates2, ...props.templates };
317
- const Template7 = templates.default;
318
- const RootTemplate3 = templates.root;
319
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RootTemplate3, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Operations, { Template: Template7 }) });
320
- };
321
- Operations.templates = defaultTemplates2;
322
-
323
- // src/components/Query.tsx
324
- var _core = require('@kubb/core');
325
-
326
-
327
-
328
-
329
- var _pluginzod = require('@kubb/plugin-zod');
330
-
331
-
332
-
333
- // src/utils.ts
334
-
335
- var reactQueryDepRegex = /@tanstack\/(react|solid|vue|svelte)-query/;
336
- function getImportNames() {
337
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
338
- return {
339
- mutation: {
340
- react: {
341
- path: "@tanstack/react-query",
342
- hookName: "useMutation",
343
- optionsType: "UseMutationOptions",
344
- resultType: "UseMutationResult"
345
- },
346
- solid: {
347
- path: "@tanstack/solid-query",
348
- hookName: "createMutation",
349
- optionsType: "CreateMutationOptions",
350
- resultType: "CreateMutationResult"
351
- },
352
- svelte: {
353
- path: "@tanstack/svelte-query",
354
- hookName: "createMutation",
355
- optionsType: "CreateMutationOptions",
356
- resultType: "CreateMutationResult"
357
- },
358
- vue: {
359
- path: "@tanstack/vue-query",
360
- hookName: "useMutation",
361
- optionsType: isV5 ? "UseMutationOptions" : "VueMutationObserverOptions",
362
- resultType: "UseMutationReturnType"
363
- }
364
- },
365
- query: {
366
- react: {
367
- path: "@tanstack/react-query",
368
- hookName: "useQuery",
369
- optionsType: isV5 ? "QueryObserverOptions" : "UseBaseQueryOptions",
370
- resultType: "UseQueryResult"
371
- },
372
- solid: {
373
- path: "@tanstack/solid-query",
374
- hookName: "createQuery",
375
- optionsType: "CreateBaseQueryOptions",
376
- resultType: "CreateQueryResult"
377
- },
378
- svelte: {
379
- path: "@tanstack/svelte-query",
380
- hookName: "createQuery",
381
- optionsType: "CreateBaseQueryOptions",
382
- resultType: "CreateQueryResult"
383
- },
384
- vue: {
385
- path: "@tanstack/vue-query",
386
- hookName: "useQuery",
387
- optionsType: isV5 ? "QueryObserverOptions" : "VueQueryObserverOptions",
388
- resultType: isV5 ? "UseQueryReturnType" : "UseQueryReturnType"
389
- }
390
- },
391
- queryInfinite: {
392
- react: {
393
- path: "@tanstack/react-query",
394
- hookName: "useInfiniteQuery",
395
- optionsType: isV5 ? "InfiniteQueryObserverOptions" : "UseInfiniteQueryOptions",
396
- resultType: "UseInfiniteQueryResult"
397
- },
398
- solid: {
399
- path: "@tanstack/solid-query",
400
- hookName: "createInfiniteQuery",
401
- optionsType: "CreateInfiniteQueryOptions",
402
- resultType: "CreateInfiniteQueryResult"
403
- },
404
- svelte: {
405
- path: "@tanstack/svelte-query",
406
- hookName: "createInfiniteQuery",
407
- optionsType: "CreateInfiniteQueryOptions",
408
- resultType: "CreateInfiniteQueryResult"
409
- },
410
- vue: {
411
- path: "@tanstack/vue-query",
412
- hookName: "useInfiniteQuery",
413
- optionsType: isV5 ? "UseInfiniteQueryOptions" : "VueInfiniteQueryObserverOptions",
414
- resultType: isV5 ? "UseInfiniteQueryReturnType" : "VueInfiniteQueryObserverOptions"
415
- }
416
- },
417
- querySuspense: {
418
- react: {
419
- path: "@tanstack/react-query",
420
- hookName: "useSuspenseQuery",
421
- optionsType: "UseSuspenseQueryOptions",
422
- resultType: "UseSuspenseQueryResult"
423
- }
424
- }
425
- };
426
- }
427
-
428
- // src/components/QueryImports.tsx
429
-
430
-
431
-
432
- function Template3({ path, hookPath = path, isInfinite, hookName, queryOptions, optionsType, resultType }) {
433
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
434
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [optionsType, resultType], path, isTypeOnly: true }),
435
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [hookName], path: hookPath }),
436
- queryOptions && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [queryOptions].filter(Boolean), path }),
437
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["QueryKey", "WithRequired", isInfinite ? "InfiniteData" : void 0].filter(Boolean), path, isTypeOnly: true })
438
- ] });
439
- }
440
- var defaultTemplates3 = {
441
- get react() {
442
- return function({ context, hookPath, ...rest }) {
443
- const importNames = getImportNames();
444
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
445
- const { isInfinite, isSuspense } = context;
446
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
447
- Template3,
448
- {
449
- isInfinite,
450
- ...isSuspense ? importNames.querySuspense.react : isInfinite ? importNames.queryInfinite.react : importNames.query.react,
451
- queryOptions: isV5 ? isInfinite ? "infiniteQueryOptions" : "queryOptions" : void 0,
452
- hookPath,
453
- ...rest
454
- }
455
- );
456
- };
457
- },
458
- get solid() {
459
- return function({ context, hookPath, ...rest }) {
460
- const importNames = getImportNames();
461
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
462
- const { isInfinite } = context;
463
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
464
- Template3,
465
- {
466
- isInfinite,
467
- ...isInfinite ? importNames.queryInfinite.solid : importNames.query.solid,
468
- queryOptions: isV5 ? isInfinite ? "infiniteQueryOptions" : "queryOptions" : void 0,
469
- hookPath,
470
- ...rest
471
- }
472
- );
473
- };
474
- },
475
- get svelte() {
476
- return function({ context, hookPath, ...rest }) {
477
- const importNames = getImportNames();
478
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
479
- const { isInfinite } = context;
480
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
481
- Template3,
482
- {
483
- isInfinite,
484
- ...isInfinite ? importNames.queryInfinite.svelte : importNames.query.svelte,
485
- queryOptions: isV5 ? isInfinite ? "infiniteQueryOptions" : "queryOptions" : void 0,
486
- hookPath,
487
- ...rest
488
- }
489
- );
490
- };
491
- },
492
- get vue() {
493
- return function({ context, hookPath, ...rest }) {
494
- const importNames = getImportNames();
495
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
496
- const { isInfinite } = context;
497
- const path = "@tanstack/vue-query";
498
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
499
- isV5 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
500
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
501
- Template3,
502
- {
503
- isInfinite,
504
- ...isInfinite ? importNames.queryInfinite.vue : importNames.query.vue,
505
- queryOptions: isInfinite ? "infiniteQueryOptions" : "queryOptions",
506
- hookPath,
507
- ...rest
508
- }
509
- ),
510
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["QueryObserverOptions"], path, isTypeOnly: true })
511
- ] }),
512
- !isV5 && isInfinite && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
513
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.queryInfinite.vue.resultType], path, isTypeOnly: true }),
514
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.queryInfinite.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
515
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.queryInfinite.vue.hookName], path })
516
- ] }),
517
- !isV5 && !isInfinite && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
518
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.query.vue.resultType], path, isTypeOnly: true }),
519
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.query.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
520
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [importNames.query.vue.hookName], path })
521
- ] }),
522
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["unref"], path: "vue" }),
523
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
524
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["QueryKey", "WithRequired"], path, isTypeOnly: true })
525
- ] });
526
- };
527
- }
528
- };
529
- function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template7 = defaultTemplates3.react }) {
530
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
531
- Template7,
532
- {
533
- hookPath,
534
- context: {
535
- isInfinite,
536
- isSuspense
537
- }
538
- }
539
- );
540
- }
541
- QueryImports.templates = defaultTemplates3;
542
-
543
- // src/components/QueryKey.tsx
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
- function Template4({ name, typeName, params, generics, returnType, JSDoc, keys }) {
552
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
553
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function.Arrow, { name, export: true, generics, params, returnType, singleLine: true, JSDoc, children: `[${keys}] as const` }),
554
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` })
555
- ] });
556
- }
557
- var defaultTemplates4 = {
558
- get react() {
559
- return function(props) {
560
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template4, { ...props });
561
- };
562
- },
563
- get solid() {
564
- return function(props) {
565
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template4, { ...props });
566
- };
567
- },
568
- get svelte() {
569
- return function(props) {
570
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template4, { ...props });
571
- };
572
- },
573
- get vue() {
574
- return function({ context, ...rest }) {
575
- const { factory } = context;
576
- const {
577
- plugin: {
578
- options: { pathParamsType, query }
579
- }
580
- } = _react.useApp.call(void 0, );
581
- const { getSchemas } = _hooks.useOperationManager.call(void 0, );
582
- const operation = _hooks.useOperation.call(void 0, );
583
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
584
- const path = new (0, _utils.URLPath)(operation.path);
585
- const params = new (0, _utils.FunctionParams)();
586
- const withQueryParams = !!_optionalChain([schemas, 'access', _68 => _68.queryParams, 'optionalAccess', _69 => _69.name]);
587
- const withRequest = !!_optionalChain([schemas, 'access', _70 => _70.request, 'optionalAccess', _71 => _71.name]);
588
- params.add([
589
- ...pathParamsType === "object" ? [
590
- _utils3.getASTParams.call(void 0, schemas.pathParams, {
591
- typed: true,
592
- override: (item) => ({
593
- ...item,
594
- type: `MaybeRef<${item.type}>`
595
- })
596
- })
597
- ] : _utils3.getASTParams.call(void 0, schemas.pathParams, {
598
- typed: true,
599
- override: (item) => ({
600
- ...item,
601
- type: `MaybeRef<${item.type}>`
602
- })
603
- }),
604
- {
605
- name: "params",
606
- type: `MaybeRef<${`${factory.name}["queryParams"]`}>`,
607
- enabled: withQueryParams,
608
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _72 => _72.queryParams, 'optionalAccess', _73 => _73.schema]))
609
- },
610
- {
611
- name: "request",
612
- type: `MaybeRef<${`${factory.name}["request"]`}>`,
613
- enabled: withRequest,
614
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _74 => _74.request, 'optionalAccess', _75 => _75.schema]))
615
- }
616
- ]);
617
- const keys = [
618
- path.toObject({
619
- type: "path",
620
- stringify: true,
621
- replacer: (pathParam) => `unref(${pathParam})`
622
- }),
623
- withQueryParams ? "...(params ? [params] : [])" : void 0,
624
- withRequest ? "...(request ? [request] : [])" : void 0
625
- ].filter(Boolean);
626
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template4, { ...rest, params: params.toString(), keys: keys.join(", ") });
627
- };
628
- }
629
- };
630
- function QueryKey({ name, typeName, factory, keysFn, Template: Template7 = defaultTemplates4.react }) {
631
- const {
632
- plugin: {
633
- options: { pathParamsType }
634
- }
635
- } = _react.useApp.call(void 0, );
636
- const { getSchemas } = _hooks.useOperationManager.call(void 0, );
637
- const operation = _hooks.useOperation.call(void 0, );
638
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
639
- const path = new (0, _utils.URLPath)(operation.path);
640
- const params = new (0, _utils.FunctionParams)();
641
- const withQueryParams = !!_optionalChain([schemas, 'access', _76 => _76.queryParams, 'optionalAccess', _77 => _77.name]);
642
- const withRequest = !!_optionalChain([schemas, 'access', _78 => _78.request, 'optionalAccess', _79 => _79.name]);
643
- params.add([
644
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true })] : _utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
645
- {
646
- name: "params",
647
- type: `${factory.name}["queryParams"]`,
648
- enabled: withQueryParams,
649
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _80 => _80.queryParams, 'optionalAccess', _81 => _81.schema]))
650
- },
651
- {
652
- name: "data",
653
- type: `${factory.name}["request"]`,
654
- enabled: withRequest,
655
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _82 => _82.request, 'optionalAccess', _83 => _83.schema]))
656
- }
657
- ]);
658
- const keys = [
659
- path.toObject({
660
- type: "path",
661
- stringify: true
662
- }),
663
- withQueryParams ? "...(params ? [params] : [])" : void 0,
664
- withRequest ? "...(data ? [data] : [])" : void 0
665
- ].filter(Boolean);
666
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template7, { typeName, name, params: params.toString(), keys: keysFn(keys).join(", "), context: { factory } });
667
- }
668
- QueryKey.templates = defaultTemplates4;
669
-
670
- // src/components/QueryOptions.tsx
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
-
679
-
680
-
681
- function Template5({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }) {
682
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
683
- const isFormData = client.contentType === "multipart/form-data";
684
- const headers = [
685
- client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
686
- client.withHeaders ? "...headers" : void 0
687
- ].filter(Boolean).join(", ");
688
- const clientOptions = [
689
- `method: "${client.method}"`,
690
- `url: ${client.path.template}`,
691
- client.withQueryParams && !infinite ? "params" : void 0,
692
- client.withData && !isFormData ? "data" : void 0,
693
- client.withData && isFormData ? "data: formData" : void 0,
694
- headers.length ? `headers: { ${headers}, ...options.headers }` : void 0,
695
- "...options",
696
- client.withQueryParams && !!infinite ? `params: {
697
- ...params,
698
- ['${infinite.queryParam}']: pageParam,
699
- ...(options.params || {}),
700
- }` : void 0
701
- ].filter(Boolean);
702
- const queryOptions = [
703
- isV5 && !!infinite ? `initialPageParam: ${infinite.initialPageParam}` : void 0,
704
- isV5 && !!infinite && !!infinite.cursorParam ? `getNextPageParam: (lastPage) => lastPage['${infinite.cursorParam}']` : void 0,
705
- isV5 && !!infinite && !!infinite.cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${infinite.cursorParam}']` : void 0,
706
- isV5 && !!infinite && !infinite.cursorParam && dataReturnType === "full" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1" : void 0,
707
- isV5 && !!infinite && !infinite.cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : void 0,
708
- isV5 && !!infinite && !infinite.cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : void 0
709
- ].filter(Boolean);
710
- const resolvedClientOptions = `${_transformers2.default.createIndent(4)}${clientOptions.join(`,
711
- ${_transformers2.default.createIndent(4)}`)}`;
712
- const resolvedQueryOptions = `${_transformers2.default.createIndent(4)}${queryOptions.join(`,
713
- ${_transformers2.default.createIndent(4)}`)}`;
714
- let returnRes = parser ? `return ${parser}(res.data)` : "return res.data";
715
- if (dataReturnType === "full") {
716
- returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : "return res";
717
- }
718
- const formData = isFormData ? `
719
- const formData = new FormData()
720
- if(data) {
721
- Object.keys(data).forEach((key) => {
722
- const value = data[key];
723
- if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
724
- formData.append(key, value);
725
- }
726
- })
727
- }
728
- ` : void 0;
729
- if (infinite) {
730
- if (isV5) {
731
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, params, JSDoc, children: `
732
- const queryKey = ${hook.queryKey}
733
-
734
- return infiniteQueryOptions({
735
- queryKey,
736
- queryFn: async ({ pageParam }) => {
737
- ${hook.children || ""}
738
- ${formData || ""}
739
- const res = await client<${client.generics}>({
740
- ${resolvedClientOptions}
741
- })
742
-
743
- ${returnRes}
744
- },
745
- ${resolvedQueryOptions}
746
- })
747
-
748
- ` });
749
- }
750
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
751
- const queryKey = ${hook.queryKey}
752
-
753
- return {
754
- queryKey,
755
- queryFn: async ({ pageParam }) => {
756
- ${hook.children || ""}
757
- ${formData || ""}
758
- const res = await client<${client.generics}>({
759
- ${resolvedClientOptions}
760
- })
761
-
762
- ${returnRes}
763
- },
764
- ${resolvedQueryOptions}
765
- }
766
-
767
- ` });
768
- }
769
- if (isV5) {
770
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, params, JSDoc, children: `
771
- const queryKey = ${hook.queryKey}
772
-
773
- return queryOptions({
774
- queryKey,
775
- queryFn: async () => {
776
- ${hook.children || ""}
777
- ${formData || ""}
778
- const res = await client<${client.generics}>({
779
- ${resolvedClientOptions}
780
- })
781
-
782
- ${returnRes}
783
- },
784
- ${resolvedQueryOptions}
785
- })
786
-
787
- ` });
788
- }
789
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
790
- const queryKey = ${hook.queryKey}
791
-
792
- return {
793
- queryKey,
794
- queryFn: async () => {
795
- ${hook.children || ""}
796
- ${formData || ""}
797
- const res = await client<${client.generics}>({
798
- ${resolvedClientOptions}
799
- })
800
-
801
- ${returnRes}
802
- },
803
- ${resolvedQueryOptions}
804
- }
805
-
806
- ` });
807
- }
808
- var defaultTemplates5 = {
809
- get react() {
810
- return function(props) {
811
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template5, { ...props });
812
- };
813
- },
814
- get solid() {
815
- return function(props) {
816
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template5, { ...props });
817
- };
818
- },
819
- get svelte() {
820
- return function(props) {
821
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template5, { ...props });
822
- };
823
- },
824
- get vue() {
825
- return function({ client, context, ...rest }) {
826
- const { factory, queryKey } = context;
827
- const {
828
- plugin: {
829
- options: { pathParamsType }
830
- }
831
- } = _react.useApp.call(void 0, );
832
- const { getSchemas } = _hooks.useOperationManager.call(void 0, );
833
- const operation = _hooks.useOperation.call(void 0, );
834
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
835
- const params = new (0, _utils.FunctionParams)();
836
- const queryKeyParams = new (0, _utils.FunctionParams)();
837
- params.add([
838
- ...pathParamsType === "object" ? [
839
- _utils3.getASTParams.call(void 0, schemas.pathParams, {
840
- typed: true,
841
- override: (item) => ({
842
- ...item,
843
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0,
844
- type: `MaybeRef<${item.type}>`
845
- })
846
- })
847
- ] : _utils3.getASTParams.call(void 0, schemas.pathParams, {
848
- typed: true,
849
- override: (item) => ({
850
- ...item,
851
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0,
852
- type: `MaybeRef<${item.type}>`
853
- })
854
- }),
855
- {
856
- name: "refParams",
857
- type: `MaybeRef<${_optionalChain([schemas, 'access', _84 => _84.queryParams, 'optionalAccess', _85 => _85.name])}>`,
858
- enabled: client.withQueryParams,
859
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _86 => _86.queryParams, 'optionalAccess', _87 => _87.schema]))
860
- },
861
- {
862
- name: "refHeaders",
863
- type: `MaybeRef<${_optionalChain([schemas, 'access', _88 => _88.headerParams, 'optionalAccess', _89 => _89.name])}>`,
864
- enabled: client.withHeaders,
865
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _90 => _90.headerParams, 'optionalAccess', _91 => _91.schema]))
866
- },
867
- {
868
- name: "refData",
869
- type: `MaybeRef<${_optionalChain([schemas, 'access', _92 => _92.request, 'optionalAccess', _93 => _93.name])}>`,
870
- enabled: client.withData,
871
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _94 => _94.request, 'optionalAccess', _95 => _95.schema]))
872
- },
873
- {
874
- name: "options",
875
- type: `${factory.name}['client']['parameters']`,
876
- default: "{}"
877
- }
878
- ]);
879
- queryKeyParams.add([
880
- ...pathParamsType === "object" ? [
881
- _utils3.getASTParams.call(void 0, schemas.pathParams, {
882
- override: (item) => ({
883
- ...item,
884
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
885
- })
886
- })
887
- ] : _utils3.getASTParams.call(void 0, schemas.pathParams, {
888
- override: (item) => ({
889
- ...item,
890
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
891
- })
892
- }),
893
- {
894
- name: "refParams",
895
- enabled: client.withQueryParams,
896
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _96 => _96.queryParams, 'optionalAccess', _97 => _97.schema]))
897
- },
898
- {
899
- name: "refData",
900
- enabled: client.withData,
901
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _98 => _98.request, 'optionalAccess', _99 => _99.schema]))
902
- }
903
- ]);
904
- const unrefs = params.items.filter((item) => item.enabled).map((item) => {
905
- return item.name ? `const ${_transformers2.default.camelCase(item.name.replace("ref", ""))} = unref(${item.name})` : void 0;
906
- }).join("\n");
907
- const hook = {
908
- queryKey: `${queryKey}(${queryKeyParams.toString()})`,
909
- children: unrefs
910
- };
911
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template5, { ...rest, params: params.toString(), hook, client });
912
- };
913
- }
914
- };
915
- function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType, Template: Template7 = defaultTemplates5.react }) {
916
- const {
917
- pluginManager,
918
- plugin: {
919
- key: pluginKey,
920
- options: { parser, pathParamsType, queryOptions }
921
- }
922
- } = _react.useApp.call(void 0, );
923
- const { getSchemas } = _hooks.useOperationManager.call(void 0, );
924
- const operation = _hooks.useOperation.call(void 0, );
925
- const contentType = operation.getContentType();
926
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
927
- const zodSchemas = getSchemas(operation, { pluginKey: [_pluginzod.pluginZodName], type: "function" });
928
- const queryKey = pluginManager.resolveName({
929
- name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
930
- pluginKey
931
- });
932
- const queryOptionsName = pluginManager.resolveName({
933
- name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
934
- pluginKey
935
- });
936
- const generics = new (0, _utils.FunctionParams)();
937
- const params = new (0, _utils.FunctionParams)();
938
- const queryKeyParams = new (0, _utils.FunctionParams)();
939
- const clientGenerics = [`${factory.name}['data']`, `${factory.name}['error']`];
940
- const resultGenerics = suspense ? [`${factory.name}['response']`, `${factory.name}["error"]`, "TData"] : [`${factory.name}['response']`, `${factory.name}["error"]`, "TData", "TQueryData"];
941
- const client = {
942
- withQueryParams: !!_optionalChain([schemas, 'access', _100 => _100.queryParams, 'optionalAccess', _101 => _101.name]),
943
- withData: !!_optionalChain([schemas, 'access', _102 => _102.request, 'optionalAccess', _103 => _103.name]),
944
- withPathParams: !!_optionalChain([schemas, 'access', _104 => _104.pathParams, 'optionalAccess', _105 => _105.name]),
945
- withHeaders: !!_optionalChain([schemas, 'access', _106 => _106.headerParams, 'optionalAccess', _107 => _107.name]),
946
- method: operation.method,
947
- path: new (0, _utils.URLPath)(operation.path),
948
- generics: clientGenerics.toString(),
949
- contentType
950
- };
951
- generics.add([
952
- { type: "TData", default: `${factory.name}["response"]` },
953
- suspense ? void 0 : { type: "TQueryData", default: `${factory.name}["response"]` }
954
- ]);
955
- params.add([
956
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true })] : _utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
957
- {
958
- name: "params",
959
- type: `${factory.name}['queryParams']`,
960
- enabled: client.withQueryParams,
961
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _108 => _108.queryParams, 'optionalAccess', _109 => _109.schema]))
962
- },
963
- {
964
- name: "headers",
965
- type: `${factory.name}['headerParams']`,
966
- enabled: client.withHeaders,
967
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _110 => _110.headerParams, 'optionalAccess', _111 => _111.schema]))
968
- },
969
- {
970
- name: "data",
971
- type: `${factory.name}['request']`,
972
- enabled: client.withData,
973
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _112 => _112.request, 'optionalAccess', _113 => _113.schema]))
974
- },
975
- {
976
- name: "options",
977
- type: `${factory.name}['client']['parameters']`,
978
- default: "{}"
979
- }
980
- ]);
981
- queryKeyParams.add([
982
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams)] : _utils3.getASTParams.call(void 0, schemas.pathParams),
983
- {
984
- name: "params",
985
- enabled: client.withQueryParams,
986
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _114 => _114.queryParams, 'optionalAccess', _115 => _115.schema]))
987
- },
988
- {
989
- name: "data",
990
- enabled: client.withData,
991
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _116 => _116.request, 'optionalAccess', _117 => _117.schema]))
992
- }
993
- ]);
994
- const hook = {
995
- queryKey: `${queryKey}(${queryKeyParams.toString()})`
996
- };
997
- if (!queryOptions) {
998
- return null;
999
- }
1000
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1001
- Template7,
1002
- {
1003
- name: queryOptionsName,
1004
- params: params.toString(),
1005
- generics: generics.toString(),
1006
- returnType: `WithRequired<${resultType}<${resultGenerics.join(", ")}>, 'queryKey'>`,
1007
- client,
1008
- hook,
1009
- infinite,
1010
- dataReturnType,
1011
- parser: parser === "zod" ? `${zodSchemas.response.name}.parse` : void 0,
1012
- context: {
1013
- factory,
1014
- queryKey
1015
- }
1016
- }
1017
- );
1018
- }
1019
- QueryOptions.templates = defaultTemplates5;
1020
-
1021
- // src/components/Query.tsx
1022
-
1023
-
1024
- function Template6({ name, generics, returnType, params, JSDoc, hook, infinite }) {
1025
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
1026
- const resolvedReturnType = `${returnType} & { queryKey: TQueryKey }`;
1027
- if (isV5) {
1028
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
1029
- const { query: queryOptions, client: clientOptions = {} } = options ?? {}
1030
- const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
1031
-
1032
- const query = ${hook.name}({
1033
- ...${hook.queryOptions} as unknown as ${infinite ? "InfiniteQueryObserverOptions" : "QueryObserverOptions"},
1034
- queryKey,
1035
- ...queryOptions as unknown as ${infinite ? 'Omit<InfiniteQueryObserverOptions, "queryKey">' : 'Omit<QueryObserverOptions, "queryKey">'}
1036
- }) as ${resolvedReturnType}
1037
-
1038
- query.queryKey = queryKey as TQueryKey
1039
-
1040
- return query
1041
-
1042
- ` }) });
1043
- }
1044
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
1045
- const { query: queryOptions, client: clientOptions = {} } = options ?? {}
1046
- const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
1047
-
1048
- const query = ${hook.name}<${hook.generics}>({
1049
- ...${hook.queryOptions},
1050
- queryKey,
1051
- ...queryOptions
1052
- }) as ${resolvedReturnType}
1053
-
1054
- query.queryKey = queryKey as TQueryKey
1055
-
1056
- return query
1057
-
1058
- ` }) });
1059
- }
1060
- var defaultTemplates6 = {
1061
- get react() {
1062
- return function(props) {
1063
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template6, { ...props });
1064
- };
1065
- },
1066
- get solid() {
1067
- return function(props) {
1068
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template6, { ...props });
1069
- };
1070
- },
1071
- get svelte() {
1072
- return function(props) {
1073
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Template6, { ...props });
1074
- };
1075
- },
1076
- get vue() {
1077
- return function({ context, hook, ...rest }) {
1078
- const { factory, queryKey } = context;
1079
- const {
1080
- pluginManager,
1081
- plugin: {
1082
- key: pluginKey,
1083
- options: { pathParamsType }
1084
- }
1085
- } = _react.useApp.call(void 0, );
1086
- const operation = _hooks.useOperation.call(void 0, );
1087
- const { getSchemas } = _hooks.useOperationManager.call(void 0, );
1088
- const importNames = getImportNames();
1089
- const queryOptions = pluginManager.resolveName({
1090
- name: `${factory.name}QueryOptions`,
1091
- pluginKey
1092
- });
1093
- const hookName = rest.infinite ? importNames.queryInfinite.vue.hookName : importNames.query.vue.hookName;
1094
- const resultType = rest.infinite ? importNames.queryInfinite.vue.resultType : importNames.query.vue.resultType;
1095
- const optionsType = rest.infinite ? importNames.queryInfinite.vue.optionsType : importNames.query.vue.optionsType;
1096
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
1097
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
1098
- const params = new (0, _utils.FunctionParams)();
1099
- const queryParams = new (0, _utils.FunctionParams)();
1100
- const queryKeyParams = new (0, _utils.FunctionParams)();
1101
- const client = {
1102
- withQueryParams: !!_optionalChain([schemas, 'access', _118 => _118.queryParams, 'optionalAccess', _119 => _119.name]),
1103
- withData: !!_optionalChain([schemas, 'access', _120 => _120.request, 'optionalAccess', _121 => _121.name]),
1104
- withPathParams: !!_optionalChain([schemas, 'access', _122 => _122.pathParams, 'optionalAccess', _123 => _123.name]),
1105
- withHeaders: !!_optionalChain([schemas, 'access', _124 => _124.headerParams, 'optionalAccess', _125 => _125.name])
1106
- };
1107
- const resultGenerics = ["TData", `${factory.name}['error']`];
1108
- const queryOptionsOverrideGenerics = [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"];
1109
- const queryOptionsGenerics = ["TData", "TQueryData"];
1110
- params.add([
1111
- ...pathParamsType === "object" ? [
1112
- _utils3.getASTParams.call(void 0, schemas.pathParams, {
1113
- typed: true,
1114
- override: (item) => ({
1115
- ...item,
1116
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
1117
- })
1118
- })
1119
- ] : _utils3.getASTParams.call(void 0, schemas.pathParams, {
1120
- typed: true,
1121
- override: (item) => ({
1122
- ...item,
1123
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
1124
- })
1125
- }),
1126
- {
1127
- name: "refParams",
1128
- type: `MaybeRef<${_optionalChain([schemas, 'access', _126 => _126.queryParams, 'optionalAccess', _127 => _127.name])}>`,
1129
- enabled: client.withQueryParams,
1130
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _128 => _128.queryParams, 'optionalAccess', _129 => _129.schema]))
1131
- },
1132
- {
1133
- name: "refHeaders",
1134
- type: `MaybeRef<${_optionalChain([schemas, 'access', _130 => _130.headerParams, 'optionalAccess', _131 => _131.name])}>`,
1135
- enabled: client.withHeaders,
1136
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _132 => _132.headerParams, 'optionalAccess', _133 => _133.schema]))
1137
- },
1138
- {
1139
- name: "refData",
1140
- type: `MaybeRef<${_optionalChain([schemas, 'access', _134 => _134.request, 'optionalAccess', _135 => _135.name])}>`,
1141
- enabled: client.withData,
1142
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _136 => _136.request, 'optionalAccess', _137 => _137.schema]))
1143
- },
1144
- {
1145
- name: "options",
1146
- type: `{
1147
- query?: Partial<${optionsType}<${queryOptionsOverrideGenerics.join(", ")}>>,
1148
- client?: ${factory.name}['client']['parameters']
1149
- }`,
1150
- default: "{}"
1151
- }
1152
- ]);
1153
- queryParams.add([
1154
- ..._utils3.getASTParams.call(void 0, schemas.pathParams, {
1155
- typed: false,
1156
- override: (item) => ({
1157
- ...item,
1158
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
1159
- })
1160
- }),
1161
- {
1162
- name: "refParams",
1163
- enabled: client.withQueryParams,
1164
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _138 => _138.queryParams, 'optionalAccess', _139 => _139.schema]))
1165
- },
1166
- {
1167
- name: "refHeaders",
1168
- enabled: client.withHeaders,
1169
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _140 => _140.headerParams, 'optionalAccess', _141 => _141.schema]))
1170
- },
1171
- {
1172
- name: "clientOptions",
1173
- required: false
1174
- }
1175
- ]);
1176
- queryKeyParams.add([
1177
- ...pathParamsType === "object" ? [
1178
- _utils3.getASTParams.call(void 0, schemas.pathParams, {
1179
- override: (item) => ({
1180
- ...item,
1181
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
1182
- })
1183
- })
1184
- ] : _utils3.getASTParams.call(void 0, schemas.pathParams, {
1185
- override: (item) => ({
1186
- ...item,
1187
- name: item.name ? `ref${_transformers2.default.pascalCase(item.name)}` : void 0
1188
- })
1189
- }),
1190
- {
1191
- name: "refParams",
1192
- enabled: client.withQueryParams,
1193
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _142 => _142.queryParams, 'optionalAccess', _143 => _143.schema]))
1194
- },
1195
- {
1196
- name: "refData",
1197
- enabled: client.withData,
1198
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _144 => _144.request, 'optionalAccess', _145 => _145.schema]))
1199
- }
1200
- ]);
1201
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1202
- Template6,
1203
- {
1204
- ...rest,
1205
- params: params.toString(),
1206
- returnType: `${resultType}<${resultGenerics.join(", ")}>`,
1207
- hook: {
1208
- ...hook,
1209
- name: hookName,
1210
- queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`,
1211
- queryKey: `${queryKey}(${queryKeyParams.toString()})`
1212
- }
1213
- }
1214
- );
1215
- };
1216
- }
1217
- };
1218
- function Query({
1219
- factory,
1220
- optionsType,
1221
- hookName,
1222
- resultType,
1223
- Template: Template7 = defaultTemplates6.react,
1224
- QueryKeyTemplate = QueryKey.templates.react,
1225
- QueryOptionsTemplate = QueryOptions.templates.react,
1226
- ...props
1227
- }) {
1228
- const {
1229
- pluginManager,
1230
- plugin: {
1231
- key: pluginKey,
1232
- options: { dataReturnType, pathParamsType }
1233
- }
1234
- } = _react.useApp.call(void 0, );
1235
- const operation = _hooks.useOperation.call(void 0, );
1236
- const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
1237
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
1238
- const name = getName(operation, { type: "function" });
1239
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
1240
- const queryKey = pluginManager.resolveName({
1241
- name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
1242
- pluginKey
1243
- });
1244
- const queryKeyType = pluginManager.resolveName({
1245
- name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
1246
- type: "type",
1247
- pluginKey
1248
- });
1249
- const queryOptions = pluginManager.resolveName({
1250
- name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
1251
- pluginKey
1252
- });
1253
- const generics = new (0, _utils.FunctionParams)();
1254
- const params = new (0, _utils.FunctionParams)();
1255
- const queryParams = new (0, _utils.FunctionParams)();
1256
- const queryKeyParams = new (0, _utils.FunctionParams)();
1257
- const client = {
1258
- method: operation.method,
1259
- path: new (0, _utils.URLPath)(operation.path),
1260
- withQueryParams: !!_optionalChain([schemas, 'access', _146 => _146.queryParams, 'optionalAccess', _147 => _147.name]),
1261
- withData: !!_optionalChain([schemas, 'access', _148 => _148.request, 'optionalAccess', _149 => _149.name]),
1262
- withPathParams: !!_optionalChain([schemas, 'access', _150 => _150.pathParams, 'optionalAccess', _151 => _151.name]),
1263
- withHeaders: !!_optionalChain([schemas, 'access', _152 => _152.headerParams, 'optionalAccess', _153 => _153.name])
1264
- };
1265
- generics.add([
1266
- {
1267
- type: "TData",
1268
- default: props.infinite ? `InfiniteData<${factory.name}["response"]>` : `${factory.name}["response"]`
1269
- },
1270
- props.suspense ? void 0 : { type: "TQueryData", default: `${factory.name}["response"]` },
1271
- { type: "TQueryKey extends QueryKey", default: queryKeyType }
1272
- ]);
1273
- const resultGenerics = ["TData", `${factory.name}['error']`];
1274
- const queryOptionsOverrideGenerics = props.suspense ? [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"] : [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryData", "TQueryKey"];
1275
- const queryOptionsGenerics = props.suspense ? ["TData"] : ["TData", "TQueryData"];
1276
- params.add([
1277
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true })] : _utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
1278
- {
1279
- name: "params",
1280
- type: `${factory.name}['queryParams']`,
1281
- enabled: client.withQueryParams,
1282
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _154 => _154.queryParams, 'optionalAccess', _155 => _155.schema]))
1283
- },
1284
- {
1285
- name: "headers",
1286
- type: `${factory.name}['headerParams']`,
1287
- enabled: client.withHeaders,
1288
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _156 => _156.headerParams, 'optionalAccess', _157 => _157.schema]))
1289
- },
1290
- {
1291
- name: "data",
1292
- type: `${factory.name}['request']`,
1293
- enabled: client.withData,
1294
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _158 => _158.request, 'optionalAccess', _159 => _159.schema]))
1295
- },
1296
- {
1297
- name: "options",
1298
- type: `{
1299
- query?: Partial<${optionsType}<${queryOptionsOverrideGenerics.join(", ")}>>,
1300
- client?: ${factory.name}['client']['parameters']
1301
- }`,
1302
- default: "{}"
1303
- }
1304
- ]);
1305
- queryParams.add([
1306
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams)] : _utils3.getASTParams.call(void 0, schemas.pathParams),
1307
- {
1308
- name: "params",
1309
- enabled: client.withQueryParams,
1310
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _160 => _160.queryParams, 'optionalAccess', _161 => _161.schema]))
1311
- },
1312
- {
1313
- name: "headers",
1314
- enabled: client.withHeaders,
1315
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _162 => _162.headerParams, 'optionalAccess', _163 => _163.schema]))
1316
- },
1317
- {
1318
- name: "data",
1319
- enabled: client.withData,
1320
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _164 => _164.request, 'optionalAccess', _165 => _165.schema]))
1321
- },
1322
- {
1323
- name: "clientOptions",
1324
- required: false
1325
- }
1326
- ]);
1327
- queryKeyParams.add([
1328
- ...pathParamsType === "object" ? [_utils3.getASTParams.call(void 0, schemas.pathParams)] : _utils3.getASTParams.call(void 0, schemas.pathParams),
1329
- {
1330
- name: "params",
1331
- enabled: client.withQueryParams,
1332
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _166 => _166.queryParams, 'optionalAccess', _167 => _167.schema]))
1333
- },
1334
- {
1335
- name: "data",
1336
- enabled: client.withData,
1337
- required: _oas.isRequired.call(void 0, _optionalChain([schemas, 'access', _168 => _168.request, 'optionalAccess', _169 => _169.schema]))
1338
- }
1339
- ]);
1340
- const hook = {
1341
- name: hookName,
1342
- generics: [isV5 ? "any" : `${factory.name}['data']`, `${factory.name}['error']`, "TData", "any"].join(", "),
1343
- queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`,
1344
- queryKey: `${queryKey}(${queryKeyParams.toString()})`
1345
- };
1346
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1347
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1348
- QueryKey,
1349
- {
1350
- keysFn: props.query ? props.query.queryKey : (keys) => keys,
1351
- Template: QueryKeyTemplate,
1352
- factory,
1353
- name: queryKey,
1354
- typeName: queryKeyType
1355
- }
1356
- ),
1357
- props.queryOptions && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1358
- QueryOptions,
1359
- {
1360
- Template: QueryOptionsTemplate,
1361
- factory,
1362
- resultType: optionsType,
1363
- dataReturnType,
1364
- infinite: props.infinite,
1365
- suspense: props.suspense
1366
- }
1367
- ),
1368
- props.query && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1369
- Template7,
1370
- {
1371
- name: [name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0].filter(Boolean).join(""),
1372
- generics: generics.toString(),
1373
- JSDoc: { comments: _utils3.getComments.call(void 0, operation) },
1374
- params: params.toString(),
1375
- returnType: `${resultType}<${resultGenerics.join(", ")}>`,
1376
- hook,
1377
- infinite: props.infinite,
1378
- context: {
1379
- factory,
1380
- queryKey
1381
- }
1382
- }
1383
- )
1384
- ] });
1385
- }
1386
- Query.File = function({ templates }) {
1387
- const {
1388
- plugin: {
1389
- options: {
1390
- client: { importPath },
1391
- infinite,
1392
- suspense,
1393
- query,
1394
- queryOptions,
1395
- parser
1396
- }
1397
- }
1398
- } = _react.useApp.call(void 0, );
1399
- const { getSchemas, getFile, getName } = _hooks.useOperationManager.call(void 0, );
1400
- const operation = _hooks.useOperation.call(void 0, );
1401
- const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
1402
- const zodSchemas = getSchemas(operation, { pluginKey: [_pluginzod.pluginZodName], type: "function" });
1403
- const file = getFile(operation);
1404
- const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
1405
- const fileZodSchemas = getFile(operation, {
1406
- pluginKey: [_pluginzod.pluginZodName]
1407
- });
1408
- const factoryName = getName(operation, { type: "type" });
1409
- const importNames = getImportNames();
1410
- const isV5 = new (0, _core.PackageManager)().isValidSync(reactQueryDepRegex, ">=5");
1411
- const Template7 = _optionalChain([templates, 'optionalAccess', _170 => _170.query, 'access', _171 => _171["react"]]) || defaultTemplates6["react"];
1412
- const QueryOptionsTemplate = _optionalChain([templates, 'optionalAccess', _172 => _172.queryOptions, 'access', _173 => _173["react"]]) || QueryOptions.templates["react"];
1413
- const QueryKeyTemplate = _optionalChain([templates, 'optionalAccess', _174 => _174.queryKey, 'access', _175 => _175["react"]]) || QueryKey.templates["react"];
1414
- const Import = _optionalChain([templates, 'optionalAccess', _176 => _176.queryImports, 'access', _177 => _177["react"]]) || QueryImports.templates["react"];
1415
- const factory = {
1416
- name: factoryName
1417
- };
1418
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
1419
- parser === "zod" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: [_optionalChain([zodSchemas, 'access', _178 => _178.response, 'optionalAccess', _179 => _179.name])], root: file.path, path: fileZodSchemas.path }),
1420
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
1421
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
1422
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1423
- _react.File.Import,
1424
- {
1425
- name: [
1426
- _optionalChain([schemas, 'access', _180 => _180.request, 'optionalAccess', _181 => _181.name]),
1427
- schemas.response.name,
1428
- _optionalChain([schemas, 'access', _182 => _182.pathParams, 'optionalAccess', _183 => _183.name]),
1429
- _optionalChain([schemas, 'access', _184 => _184.queryParams, 'optionalAccess', _185 => _185.name]),
1430
- _optionalChain([schemas, 'access', _186 => _186.headerParams, 'optionalAccess', _187 => _187.name]),
1431
- ..._optionalChain([schemas, 'access', _188 => _188.errors, 'optionalAccess', _189 => _189.map, 'call', _190 => _190((error) => error.name)]) || []
1432
- ].filter(Boolean),
1433
- root: file.path,
1434
- path: fileType.path,
1435
- isTypeOnly: true
1436
- }
1437
- ),
1438
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: false }),
1439
- !!infinite && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: true, isSuspense: false }),
1440
- !!suspense && isV5 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: true }),
1441
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File.Source, { children: [
1442
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, {}),
1443
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1444
- Query,
1445
- {
1446
- factory,
1447
- Template: Template7,
1448
- QueryKeyTemplate,
1449
- QueryOptionsTemplate,
1450
- infinite: false,
1451
- suspense: false,
1452
- query,
1453
- queryOptions,
1454
- hookName: importNames.query["react"].hookName,
1455
- resultType: importNames.query["react"].resultType,
1456
- optionsType: importNames.query["react"].optionsType
1457
- }
1458
- ),
1459
- !!infinite && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1460
- Query,
1461
- {
1462
- factory,
1463
- Template: Template7,
1464
- QueryKeyTemplate,
1465
- QueryOptionsTemplate,
1466
- infinite,
1467
- suspense: false,
1468
- query,
1469
- queryOptions,
1470
- hookName: importNames.queryInfinite["react"].hookName,
1471
- resultType: importNames.queryInfinite["react"].resultType,
1472
- optionsType: importNames.queryInfinite["react"].optionsType
1473
- }
1474
- ),
1475
- !!suspense && isV5 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1476
- Query,
1477
- {
1478
- factory,
1479
- Template: Template7,
1480
- QueryKeyTemplate,
1481
- QueryOptionsTemplate,
1482
- infinite: false,
1483
- suspense,
1484
- query,
1485
- queryOptions,
1486
- hookName: importNames.querySuspense["react"].hookName,
1487
- resultType: importNames.querySuspense["react"].resultType,
1488
- optionsType: importNames.querySuspense["react"].optionsType
1489
- }
1490
- )
1491
- ] })
1492
- ] }) });
1493
- };
1494
- Query.templates = defaultTemplates6;
1495
-
1496
-
1497
-
1498
-
1499
-
1500
-
1501
-
1502
-
1503
- exports.Mutation = Mutation; exports.Operations = Operations; exports.QueryImports = QueryImports; exports.QueryKey = QueryKey; exports.QueryOptions = QueryOptions; exports.Query = Query;
1504
- //# sourceMappingURL=chunk-JFX7DCS7.cjs.map