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