@kubb/plugin-react-query 5.0.0-alpha.8 → 5.0.0-beta.10
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/LICENSE +17 -10
- package/README.md +34 -85
- package/dist/components-Dow6tde8.js +1459 -0
- package/dist/components-Dow6tde8.js.map +1 -0
- package/dist/components-HwdCDefj.cjs +1603 -0
- package/dist/components-HwdCDefj.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +49 -179
- package/dist/components.js +1 -1
- package/dist/generators-CcOmnTPa.cjs +1454 -0
- package/dist/generators-CcOmnTPa.cjs.map +1 -0
- package/dist/generators-yfZr_qfT.js +1412 -0
- package/dist/generators-yfZr_qfT.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +9 -476
- package/dist/generators.js +1 -1
- package/dist/index.cjs +197 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +193 -126
- package/dist/index.js.map +1 -1
- package/dist/types-DG_OxOym.d.ts +363 -0
- package/extension.yaml +911 -0
- package/package.json +59 -64
- package/src/components/InfiniteQuery.tsx +79 -138
- package/src/components/InfiniteQueryOptions.tsx +55 -166
- package/src/components/Mutation.tsx +74 -111
- package/src/components/MutationOptions.tsx +61 -80
- package/src/components/Query.tsx +66 -142
- package/src/components/QueryOptions.tsx +56 -138
- package/src/components/SuspenseInfiniteQuery.tsx +79 -138
- package/src/components/SuspenseInfiniteQueryOptions.tsx +55 -166
- package/src/components/SuspenseQuery.tsx +66 -152
- package/src/generators/customHookOptionsFileGenerator.tsx +37 -51
- package/src/generators/hookOptionsGenerator.tsx +111 -174
- package/src/generators/infiniteQueryGenerator.tsx +158 -178
- package/src/generators/mutationGenerator.tsx +112 -139
- package/src/generators/queryGenerator.tsx +128 -142
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +157 -156
- package/src/generators/suspenseQueryGenerator.tsx +126 -152
- package/src/index.ts +1 -1
- package/src/plugin.ts +134 -187
- package/src/resolvers/resolverReactQuery.ts +107 -0
- package/src/types.ts +172 -49
- package/src/utils.ts +10 -0
- package/dist/components-BHQT9ZLc.cjs +0 -1634
- package/dist/components-BHQT9ZLc.cjs.map +0 -1
- package/dist/components-CpyHYGOw.js +0 -1520
- package/dist/components-CpyHYGOw.js.map +0 -1
- package/dist/generators-DP07m3rH.cjs +0 -1469
- package/dist/generators-DP07m3rH.cjs.map +0 -1
- package/dist/generators-DkQwKTc2.js +0 -1427
- package/dist/generators-DkQwKTc2.js.map +0 -1
- package/dist/types-D5S7Ny9r.d.ts +0 -270
|
@@ -1,1520 +0,0 @@
|
|
|
1
|
-
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { isAllOptional, isOptional } from "@kubb/oas";
|
|
3
|
-
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
4
|
-
import { File, Function as Function$1, FunctionParams, Type } from "@kubb/react-fabric";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
6
|
-
import { Client } from "@kubb/plugin-client/components";
|
|
7
|
-
//#region ../../internals/utils/src/casing.ts
|
|
8
|
-
/**
|
|
9
|
-
* Shared implementation for camelCase and PascalCase conversion.
|
|
10
|
-
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
11
|
-
* and capitalizes each word according to `pascal`.
|
|
12
|
-
*
|
|
13
|
-
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
14
|
-
*/
|
|
15
|
-
function toCamelOrPascal(text, pascal) {
|
|
16
|
-
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
17
|
-
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
18
|
-
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
19
|
-
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
20
|
-
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
24
|
-
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
25
|
-
* Segments are joined with `/` to form a file path.
|
|
26
|
-
*/
|
|
27
|
-
function applyToFileParts(text, transformPart) {
|
|
28
|
-
const parts = text.split(".");
|
|
29
|
-
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Converts `text` to camelCase.
|
|
33
|
-
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* camelCase('hello-world') // 'helloWorld'
|
|
37
|
-
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
38
|
-
*/
|
|
39
|
-
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
40
|
-
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
41
|
-
prefix,
|
|
42
|
-
suffix
|
|
43
|
-
} : {}));
|
|
44
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Converts `text` to PascalCase.
|
|
48
|
-
* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* pascalCase('hello-world') // 'HelloWorld'
|
|
52
|
-
* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
|
|
53
|
-
*/
|
|
54
|
-
function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
55
|
-
if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
|
|
56
|
-
prefix,
|
|
57
|
-
suffix
|
|
58
|
-
}) : camelCase(part));
|
|
59
|
-
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region ../../internals/utils/src/object.ts
|
|
63
|
-
/**
|
|
64
|
-
* Converts a dot-notation path or string array into an optional-chaining accessor expression.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* getNestedAccessor('pagination.next.id', 'lastPage')
|
|
68
|
-
* // → "lastPage?.['pagination']?.['next']?.['id']"
|
|
69
|
-
*/
|
|
70
|
-
function getNestedAccessor(param, accessor) {
|
|
71
|
-
const parts = Array.isArray(param) ? param : param.split(".");
|
|
72
|
-
if (parts.length === 0 || parts.length === 1 && parts[0] === "") return void 0;
|
|
73
|
-
return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
|
|
74
|
-
}
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region ../../internals/utils/src/reserved.ts
|
|
77
|
-
/**
|
|
78
|
-
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
79
|
-
*/
|
|
80
|
-
function isValidVarName(name) {
|
|
81
|
-
try {
|
|
82
|
-
new Function(`var ${name}`);
|
|
83
|
-
} catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region ../../internals/utils/src/urlPath.ts
|
|
90
|
-
/**
|
|
91
|
-
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* const p = new URLPath('/pet/{petId}')
|
|
95
|
-
* p.URL // '/pet/:petId'
|
|
96
|
-
* p.template // '`/pet/${petId}`'
|
|
97
|
-
*/
|
|
98
|
-
var URLPath = class {
|
|
99
|
-
/** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */
|
|
100
|
-
path;
|
|
101
|
-
#options;
|
|
102
|
-
constructor(path, options = {}) {
|
|
103
|
-
this.path = path;
|
|
104
|
-
this.#options = options;
|
|
105
|
-
}
|
|
106
|
-
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
107
|
-
get URL() {
|
|
108
|
-
return this.toURLPath();
|
|
109
|
-
}
|
|
110
|
-
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */
|
|
111
|
-
get isURL() {
|
|
112
|
-
try {
|
|
113
|
-
return !!new URL(this.path).href;
|
|
114
|
-
} catch {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
123
|
-
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
124
|
-
*/
|
|
125
|
-
get template() {
|
|
126
|
-
return this.toTemplateString();
|
|
127
|
-
}
|
|
128
|
-
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */
|
|
129
|
-
get object() {
|
|
130
|
-
return this.toObject();
|
|
131
|
-
}
|
|
132
|
-
/** Returns a map of path parameter names, or `undefined` when the path has no parameters. */
|
|
133
|
-
get params() {
|
|
134
|
-
return this.getParams();
|
|
135
|
-
}
|
|
136
|
-
#transformParam(raw) {
|
|
137
|
-
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
138
|
-
return this.#options.casing === "camelcase" ? camelCase(param) : param;
|
|
139
|
-
}
|
|
140
|
-
/** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */
|
|
141
|
-
#eachParam(fn) {
|
|
142
|
-
for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
|
|
143
|
-
const raw = match[1];
|
|
144
|
-
fn(raw, this.#transformParam(raw));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
toObject({ type = "path", replacer, stringify } = {}) {
|
|
148
|
-
const object = {
|
|
149
|
-
url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
|
|
150
|
-
params: this.getParams()
|
|
151
|
-
};
|
|
152
|
-
if (stringify) {
|
|
153
|
-
if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
154
|
-
if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
155
|
-
return `{ url: '${object.url}' }`;
|
|
156
|
-
}
|
|
157
|
-
return object;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
161
|
-
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
165
|
-
*/
|
|
166
|
-
toTemplateString({ prefix = "", replacer } = {}) {
|
|
167
|
-
return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
168
|
-
if (i % 2 === 0) return part;
|
|
169
|
-
const param = this.#transformParam(part);
|
|
170
|
-
return `\${${replacer ? replacer(param) : param}}`;
|
|
171
|
-
}).join("")}\``;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
175
|
-
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
176
|
-
* Returns `undefined` when no path parameters are found.
|
|
177
|
-
*/
|
|
178
|
-
getParams(replacer) {
|
|
179
|
-
const params = {};
|
|
180
|
-
this.#eachParam((_raw, param) => {
|
|
181
|
-
const key = replacer ? replacer(param) : param;
|
|
182
|
-
params[key] = key;
|
|
183
|
-
});
|
|
184
|
-
return Object.keys(params).length > 0 ? params : void 0;
|
|
185
|
-
}
|
|
186
|
-
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
187
|
-
toURLPath() {
|
|
188
|
-
return this.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
//#endregion
|
|
192
|
-
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
193
|
-
function getParams$10({}) {
|
|
194
|
-
return FunctionParams.factory({});
|
|
195
|
-
}
|
|
196
|
-
__name(getParams$10, "getParams");
|
|
197
|
-
const getTransformer$1 = /* @__PURE__ */ __name(({ operation, casing }) => {
|
|
198
|
-
return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`];
|
|
199
|
-
}, "getTransformer");
|
|
200
|
-
function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer$1 }) {
|
|
201
|
-
const params = getParams$10({
|
|
202
|
-
pathParamsType,
|
|
203
|
-
typeSchemas
|
|
204
|
-
});
|
|
205
|
-
const keys = transformer({
|
|
206
|
-
operation,
|
|
207
|
-
schemas: typeSchemas,
|
|
208
|
-
casing: paramsCasing
|
|
209
|
-
});
|
|
210
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
211
|
-
name,
|
|
212
|
-
isExportable: true,
|
|
213
|
-
isIndexable: true,
|
|
214
|
-
children: /* @__PURE__ */ jsx(Function$1.Arrow, {
|
|
215
|
-
name,
|
|
216
|
-
export: true,
|
|
217
|
-
params: params.toConstructor(),
|
|
218
|
-
singleLine: true,
|
|
219
|
-
children: `[${keys.join(", ")}] as const`
|
|
220
|
-
})
|
|
221
|
-
}), /* @__PURE__ */ jsx(File.Source, {
|
|
222
|
-
name: typeName,
|
|
223
|
-
isExportable: true,
|
|
224
|
-
isIndexable: true,
|
|
225
|
-
isTypeOnly: true,
|
|
226
|
-
children: /* @__PURE__ */ jsx(Type, {
|
|
227
|
-
name: typeName,
|
|
228
|
-
export: true,
|
|
229
|
-
children: `ReturnType<typeof ${name}>`
|
|
230
|
-
})
|
|
231
|
-
})] });
|
|
232
|
-
}
|
|
233
|
-
MutationKey.getParams = getParams$10;
|
|
234
|
-
MutationKey.getTransformer = getTransformer$1;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region ../../internals/tanstack-query/src/components/QueryKey.tsx
|
|
237
|
-
function getParams$9({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
238
|
-
return FunctionParams.factory({
|
|
239
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
240
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
241
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
242
|
-
typed: true,
|
|
243
|
-
casing: paramsCasing
|
|
244
|
-
})
|
|
245
|
-
} : void 0,
|
|
246
|
-
data: typeSchemas.request?.name ? {
|
|
247
|
-
type: typeSchemas.request?.name,
|
|
248
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
249
|
-
} : void 0,
|
|
250
|
-
params: typeSchemas.queryParams?.name ? {
|
|
251
|
-
type: typeSchemas.queryParams?.name,
|
|
252
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
253
|
-
} : void 0
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
__name(getParams$9, "getParams");
|
|
257
|
-
const getTransformer = ({ operation, schemas, casing }) => {
|
|
258
|
-
return [
|
|
259
|
-
new URLPath(operation.path, { casing }).toObject({
|
|
260
|
-
type: "path",
|
|
261
|
-
stringify: true
|
|
262
|
-
}),
|
|
263
|
-
schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
|
|
264
|
-
schemas.request?.name ? "...(data ? [data] : [])" : void 0
|
|
265
|
-
].filter(Boolean);
|
|
266
|
-
};
|
|
267
|
-
function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
|
|
268
|
-
const params = getParams$9({
|
|
269
|
-
pathParamsType,
|
|
270
|
-
typeSchemas,
|
|
271
|
-
paramsCasing
|
|
272
|
-
});
|
|
273
|
-
const keys = transformer({
|
|
274
|
-
operation,
|
|
275
|
-
schemas: typeSchemas,
|
|
276
|
-
casing: paramsCasing
|
|
277
|
-
});
|
|
278
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
279
|
-
name,
|
|
280
|
-
isExportable: true,
|
|
281
|
-
isIndexable: true,
|
|
282
|
-
children: /* @__PURE__ */ jsx(Function$1.Arrow, {
|
|
283
|
-
name,
|
|
284
|
-
export: true,
|
|
285
|
-
params: params.toConstructor(),
|
|
286
|
-
singleLine: true,
|
|
287
|
-
children: `[${keys.join(", ")}] as const`
|
|
288
|
-
})
|
|
289
|
-
}), /* @__PURE__ */ jsx(File.Source, {
|
|
290
|
-
name: typeName,
|
|
291
|
-
isExportable: true,
|
|
292
|
-
isIndexable: true,
|
|
293
|
-
isTypeOnly: true,
|
|
294
|
-
children: /* @__PURE__ */ jsx(Type, {
|
|
295
|
-
name: typeName,
|
|
296
|
-
export: true,
|
|
297
|
-
children: `ReturnType<typeof ${name}>`
|
|
298
|
-
})
|
|
299
|
-
})] });
|
|
300
|
-
}
|
|
301
|
-
QueryKey.getParams = getParams$9;
|
|
302
|
-
QueryKey.getTransformer = getTransformer;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/components/QueryOptions.tsx
|
|
305
|
-
function getParams$8({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
306
|
-
if (paramsType === "object") {
|
|
307
|
-
const children = {
|
|
308
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
309
|
-
typed: true,
|
|
310
|
-
casing: paramsCasing
|
|
311
|
-
}),
|
|
312
|
-
data: typeSchemas.request?.name ? {
|
|
313
|
-
type: typeSchemas.request?.name,
|
|
314
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
315
|
-
} : void 0,
|
|
316
|
-
params: typeSchemas.queryParams?.name ? {
|
|
317
|
-
type: typeSchemas.queryParams?.name,
|
|
318
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
319
|
-
} : void 0,
|
|
320
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
321
|
-
type: typeSchemas.headerParams?.name,
|
|
322
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
323
|
-
} : void 0
|
|
324
|
-
};
|
|
325
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
326
|
-
return FunctionParams.factory({
|
|
327
|
-
data: {
|
|
328
|
-
mode: "object",
|
|
329
|
-
children,
|
|
330
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
331
|
-
},
|
|
332
|
-
config: {
|
|
333
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
334
|
-
default: "{}"
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
return FunctionParams.factory({
|
|
339
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
340
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
341
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
342
|
-
typed: true,
|
|
343
|
-
casing: paramsCasing
|
|
344
|
-
}),
|
|
345
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
346
|
-
} : void 0,
|
|
347
|
-
data: typeSchemas.request?.name ? {
|
|
348
|
-
type: typeSchemas.request?.name,
|
|
349
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
350
|
-
} : void 0,
|
|
351
|
-
params: typeSchemas.queryParams?.name ? {
|
|
352
|
-
type: typeSchemas.queryParams?.name,
|
|
353
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
354
|
-
} : void 0,
|
|
355
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
356
|
-
type: typeSchemas.headerParams?.name,
|
|
357
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
358
|
-
} : void 0,
|
|
359
|
-
config: {
|
|
360
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
361
|
-
default: "{}"
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
__name(getParams$8, "getParams");
|
|
366
|
-
function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
|
|
367
|
-
const params = getParams$8({
|
|
368
|
-
paramsType,
|
|
369
|
-
paramsCasing,
|
|
370
|
-
pathParamsType,
|
|
371
|
-
typeSchemas
|
|
372
|
-
});
|
|
373
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
374
|
-
const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error";
|
|
375
|
-
const clientParams = Client.getParams({
|
|
376
|
-
typeSchemas,
|
|
377
|
-
paramsCasing,
|
|
378
|
-
paramsType,
|
|
379
|
-
pathParamsType,
|
|
380
|
-
isConfigurable: true
|
|
381
|
-
});
|
|
382
|
-
const queryKeyParams = QueryKey.getParams({
|
|
383
|
-
pathParamsType,
|
|
384
|
-
typeSchemas,
|
|
385
|
-
paramsCasing
|
|
386
|
-
});
|
|
387
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
388
|
-
return item && !item.optional && !item.default ? key : void 0;
|
|
389
|
-
}).filter(Boolean).join("&& ");
|
|
390
|
-
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
391
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
392
|
-
name,
|
|
393
|
-
isExportable: true,
|
|
394
|
-
isIndexable: true,
|
|
395
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
396
|
-
name,
|
|
397
|
-
export: true,
|
|
398
|
-
params: params.toConstructor(),
|
|
399
|
-
children: `
|
|
400
|
-
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
401
|
-
return queryOptions<${TData}, ResponseErrorConfig<${TError}>, ${TData}, typeof queryKey>({
|
|
402
|
-
${enabledText}
|
|
403
|
-
queryKey,
|
|
404
|
-
queryFn: async ({ signal }) => {
|
|
405
|
-
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
406
|
-
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
407
|
-
return name;
|
|
408
|
-
} })})
|
|
409
|
-
},
|
|
410
|
-
})
|
|
411
|
-
`
|
|
412
|
-
})
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
QueryOptions.getParams = getParams$8;
|
|
416
|
-
//#endregion
|
|
417
|
-
//#region src/components/InfiniteQuery.tsx
|
|
418
|
-
function getParams$7({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
|
|
419
|
-
if (paramsType === "object") {
|
|
420
|
-
const children = {
|
|
421
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
422
|
-
typed: true,
|
|
423
|
-
casing: paramsCasing
|
|
424
|
-
}),
|
|
425
|
-
data: typeSchemas.request?.name ? {
|
|
426
|
-
type: typeSchemas.request?.name,
|
|
427
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
428
|
-
} : void 0,
|
|
429
|
-
params: typeSchemas.queryParams?.name ? {
|
|
430
|
-
type: typeSchemas.queryParams?.name,
|
|
431
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
432
|
-
} : void 0,
|
|
433
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
434
|
-
type: typeSchemas.headerParams?.name,
|
|
435
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
436
|
-
} : void 0
|
|
437
|
-
};
|
|
438
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
439
|
-
return FunctionParams.factory({
|
|
440
|
-
data: {
|
|
441
|
-
mode: "object",
|
|
442
|
-
children,
|
|
443
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
444
|
-
},
|
|
445
|
-
options: {
|
|
446
|
-
type: `
|
|
447
|
-
{
|
|
448
|
-
query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
449
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
450
|
-
}
|
|
451
|
-
`,
|
|
452
|
-
default: "{}"
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
return FunctionParams.factory({
|
|
457
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
458
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
459
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
460
|
-
typed: true,
|
|
461
|
-
casing: paramsCasing
|
|
462
|
-
}),
|
|
463
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
464
|
-
} : void 0,
|
|
465
|
-
data: typeSchemas.request?.name ? {
|
|
466
|
-
type: typeSchemas.request?.name,
|
|
467
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
468
|
-
} : void 0,
|
|
469
|
-
params: typeSchemas.queryParams?.name ? {
|
|
470
|
-
type: typeSchemas.queryParams?.name,
|
|
471
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
472
|
-
} : void 0,
|
|
473
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
474
|
-
type: typeSchemas.headerParams?.name,
|
|
475
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
476
|
-
} : void 0,
|
|
477
|
-
options: {
|
|
478
|
-
type: `
|
|
479
|
-
{
|
|
480
|
-
query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
481
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
482
|
-
}
|
|
483
|
-
`,
|
|
484
|
-
default: "{}"
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
__name(getParams$7, "getParams");
|
|
489
|
-
function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, initialPageParam, queryParam, customOptions }) {
|
|
490
|
-
const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
491
|
-
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
492
|
-
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
493
|
-
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
494
|
-
const parts = initialPageParam.split(" as ");
|
|
495
|
-
return parts[parts.length - 1] ?? "unknown";
|
|
496
|
-
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
497
|
-
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
498
|
-
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
499
|
-
const returnType = "UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
|
|
500
|
-
const generics = [
|
|
501
|
-
`TQueryFnData = ${responseType}`,
|
|
502
|
-
`TError = ${errorType}`,
|
|
503
|
-
"TData = InfiniteData<TQueryFnData>",
|
|
504
|
-
`TQueryKey extends QueryKey = ${queryKeyTypeName}`,
|
|
505
|
-
`TPageParam = ${pageParamType}`
|
|
506
|
-
];
|
|
507
|
-
const queryKeyParams = QueryKey.getParams({
|
|
508
|
-
pathParamsType,
|
|
509
|
-
typeSchemas,
|
|
510
|
-
paramsCasing
|
|
511
|
-
});
|
|
512
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
513
|
-
paramsType,
|
|
514
|
-
pathParamsType,
|
|
515
|
-
typeSchemas,
|
|
516
|
-
paramsCasing
|
|
517
|
-
});
|
|
518
|
-
const params = getParams$7({
|
|
519
|
-
paramsCasing,
|
|
520
|
-
paramsType,
|
|
521
|
-
pathParamsType,
|
|
522
|
-
typeSchemas,
|
|
523
|
-
pageParamGeneric: "TPageParam"
|
|
524
|
-
});
|
|
525
|
-
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
526
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
527
|
-
name,
|
|
528
|
-
isExportable: true,
|
|
529
|
-
isIndexable: true,
|
|
530
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
531
|
-
name,
|
|
532
|
-
export: true,
|
|
533
|
-
generics: generics.join(", "),
|
|
534
|
-
params: params.toConstructor(),
|
|
535
|
-
JSDoc: { comments: getComments(operation) },
|
|
536
|
-
children: `
|
|
537
|
-
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
538
|
-
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
539
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
540
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""}
|
|
541
|
-
|
|
542
|
-
const query = useInfiniteQuery({
|
|
543
|
-
...${queryOptions},${customOptions ? "\n...customOptions," : ""}
|
|
544
|
-
...resolvedOptions,
|
|
545
|
-
queryKey,
|
|
546
|
-
} as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
|
|
547
|
-
|
|
548
|
-
query.queryKey = queryKey as TQueryKey
|
|
549
|
-
|
|
550
|
-
return query
|
|
551
|
-
`
|
|
552
|
-
})
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
InfiniteQuery.getParams = getParams$7;
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/components/InfiniteQueryOptions.tsx
|
|
558
|
-
function getParams$6({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
559
|
-
if (paramsType === "object") {
|
|
560
|
-
const children = {
|
|
561
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
562
|
-
typed: true,
|
|
563
|
-
casing: paramsCasing
|
|
564
|
-
}),
|
|
565
|
-
data: typeSchemas.request?.name ? {
|
|
566
|
-
type: typeSchemas.request?.name,
|
|
567
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
568
|
-
} : void 0,
|
|
569
|
-
params: typeSchemas.queryParams?.name ? {
|
|
570
|
-
type: typeSchemas.queryParams?.name,
|
|
571
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
572
|
-
} : void 0,
|
|
573
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
574
|
-
type: typeSchemas.headerParams?.name,
|
|
575
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
576
|
-
} : void 0
|
|
577
|
-
};
|
|
578
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
579
|
-
return FunctionParams.factory({
|
|
580
|
-
data: {
|
|
581
|
-
mode: "object",
|
|
582
|
-
children,
|
|
583
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
584
|
-
},
|
|
585
|
-
config: {
|
|
586
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
587
|
-
default: "{}"
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
return FunctionParams.factory({
|
|
592
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
593
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
594
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
595
|
-
typed: true,
|
|
596
|
-
casing: paramsCasing
|
|
597
|
-
}),
|
|
598
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
599
|
-
} : void 0,
|
|
600
|
-
data: typeSchemas.request?.name ? {
|
|
601
|
-
type: typeSchemas.request?.name,
|
|
602
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
603
|
-
} : void 0,
|
|
604
|
-
params: typeSchemas.queryParams?.name ? {
|
|
605
|
-
type: typeSchemas.queryParams?.name,
|
|
606
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
607
|
-
} : void 0,
|
|
608
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
609
|
-
type: typeSchemas.headerParams?.name,
|
|
610
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
611
|
-
} : void 0,
|
|
612
|
-
config: {
|
|
613
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
614
|
-
default: "{}"
|
|
615
|
-
}
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
__name(getParams$6, "getParams");
|
|
619
|
-
function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
|
|
620
|
-
const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
621
|
-
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
622
|
-
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
623
|
-
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
624
|
-
const parts = initialPageParam.split(" as ");
|
|
625
|
-
return parts[parts.length - 1] ?? "unknown";
|
|
626
|
-
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
627
|
-
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
628
|
-
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
629
|
-
const params = getParams$6({
|
|
630
|
-
paramsType,
|
|
631
|
-
paramsCasing,
|
|
632
|
-
pathParamsType,
|
|
633
|
-
typeSchemas
|
|
634
|
-
});
|
|
635
|
-
const clientParams = Client.getParams({
|
|
636
|
-
paramsCasing,
|
|
637
|
-
typeSchemas,
|
|
638
|
-
paramsType,
|
|
639
|
-
pathParamsType,
|
|
640
|
-
isConfigurable: true
|
|
641
|
-
});
|
|
642
|
-
const queryKeyParams = QueryKey.getParams({
|
|
643
|
-
pathParamsType,
|
|
644
|
-
typeSchemas,
|
|
645
|
-
paramsCasing
|
|
646
|
-
});
|
|
647
|
-
const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
|
|
648
|
-
let getNextPageParamExpr;
|
|
649
|
-
let getPreviousPageParamExpr;
|
|
650
|
-
if (hasNewParams) {
|
|
651
|
-
if (nextParam) {
|
|
652
|
-
const accessor = getNestedAccessor(nextParam, "lastPage");
|
|
653
|
-
if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
|
|
654
|
-
}
|
|
655
|
-
if (previousParam) {
|
|
656
|
-
const accessor = getNestedAccessor(previousParam, "firstPage");
|
|
657
|
-
if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
|
|
658
|
-
}
|
|
659
|
-
} else if (cursorParam) {
|
|
660
|
-
getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
|
|
661
|
-
getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
|
|
662
|
-
} else {
|
|
663
|
-
if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
|
|
664
|
-
else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
|
|
665
|
-
getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
|
|
666
|
-
}
|
|
667
|
-
const queryOptions = [
|
|
668
|
-
`initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
|
|
669
|
-
getNextPageParamExpr,
|
|
670
|
-
getPreviousPageParamExpr
|
|
671
|
-
].filter(Boolean);
|
|
672
|
-
const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
|
|
673
|
-
params = {
|
|
674
|
-
...(params ?? {}),
|
|
675
|
-
['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
|
|
676
|
-
} as ${typeSchemas.queryParams?.name}` : "";
|
|
677
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
678
|
-
return item && !item.optional && !item.default ? key : void 0;
|
|
679
|
-
}).filter(Boolean).join("&& ");
|
|
680
|
-
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
681
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
|
|
682
|
-
name,
|
|
683
|
-
isExportable: true,
|
|
684
|
-
isIndexable: true,
|
|
685
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
686
|
-
name,
|
|
687
|
-
export: true,
|
|
688
|
-
params: params.toConstructor(),
|
|
689
|
-
children: `
|
|
690
|
-
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
691
|
-
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
692
|
-
${enabledText}
|
|
693
|
-
queryKey,
|
|
694
|
-
queryFn: async ({ signal, pageParam }) => {
|
|
695
|
-
${infiniteOverrideParams}
|
|
696
|
-
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
697
|
-
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
698
|
-
return name;
|
|
699
|
-
} })})
|
|
700
|
-
},
|
|
701
|
-
${queryOptions.join(",\n")}
|
|
702
|
-
})
|
|
703
|
-
`
|
|
704
|
-
})
|
|
705
|
-
});
|
|
706
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
707
|
-
name,
|
|
708
|
-
isExportable: true,
|
|
709
|
-
isIndexable: true,
|
|
710
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
711
|
-
name,
|
|
712
|
-
export: true,
|
|
713
|
-
params: params.toConstructor(),
|
|
714
|
-
children: `
|
|
715
|
-
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
716
|
-
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
717
|
-
${enabledText}
|
|
718
|
-
queryKey,
|
|
719
|
-
queryFn: async ({ signal }) => {
|
|
720
|
-
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
721
|
-
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
722
|
-
return name;
|
|
723
|
-
} })})
|
|
724
|
-
},
|
|
725
|
-
${queryOptions.join(",\n")}
|
|
726
|
-
})
|
|
727
|
-
`
|
|
728
|
-
})
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
InfiniteQueryOptions.getParams = getParams$6;
|
|
732
|
-
//#endregion
|
|
733
|
-
//#region src/components/MutationOptions.tsx
|
|
734
|
-
function getParams$5({ typeSchemas }) {
|
|
735
|
-
return FunctionParams.factory({ config: {
|
|
736
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
737
|
-
default: "{}"
|
|
738
|
-
} });
|
|
739
|
-
}
|
|
740
|
-
__name(getParams$5, "getParams");
|
|
741
|
-
function MutationOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, mutationKeyName }) {
|
|
742
|
-
const params = getParams$5({ typeSchemas });
|
|
743
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
744
|
-
const TError = typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error";
|
|
745
|
-
const clientParams = Client.getParams({
|
|
746
|
-
typeSchemas,
|
|
747
|
-
paramsCasing,
|
|
748
|
-
paramsType,
|
|
749
|
-
pathParamsType,
|
|
750
|
-
isConfigurable: true
|
|
751
|
-
});
|
|
752
|
-
const mutationKeyParams = MutationKey.getParams({
|
|
753
|
-
pathParamsType,
|
|
754
|
-
typeSchemas
|
|
755
|
-
});
|
|
756
|
-
const mutationParams = FunctionParams.factory({
|
|
757
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
758
|
-
typed: true,
|
|
759
|
-
casing: paramsCasing
|
|
760
|
-
}),
|
|
761
|
-
data: typeSchemas.request?.name ? {
|
|
762
|
-
type: typeSchemas.request?.name,
|
|
763
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
764
|
-
} : void 0,
|
|
765
|
-
params: typeSchemas.queryParams?.name ? {
|
|
766
|
-
type: typeSchemas.queryParams?.name,
|
|
767
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
768
|
-
} : void 0,
|
|
769
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
770
|
-
type: typeSchemas.headerParams?.name,
|
|
771
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
772
|
-
} : void 0
|
|
773
|
-
});
|
|
774
|
-
const dataParams = FunctionParams.factory({ data: {
|
|
775
|
-
mode: "object",
|
|
776
|
-
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
777
|
-
if (value) acc[key] = {
|
|
778
|
-
...value,
|
|
779
|
-
type: void 0
|
|
780
|
-
};
|
|
781
|
-
return acc;
|
|
782
|
-
}, {})
|
|
783
|
-
} });
|
|
784
|
-
const TRequest = mutationParams.toConstructor();
|
|
785
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
786
|
-
name,
|
|
787
|
-
isExportable: true,
|
|
788
|
-
isIndexable: true,
|
|
789
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
790
|
-
name,
|
|
791
|
-
export: true,
|
|
792
|
-
params: params.toConstructor(),
|
|
793
|
-
generics: ["TContext = unknown"],
|
|
794
|
-
children: `
|
|
795
|
-
const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
796
|
-
return mutationOptions<${TData}, ResponseErrorConfig<${TError}>, ${TRequest ? `{${TRequest}}` : "void"}, TContext>({
|
|
797
|
-
mutationKey,
|
|
798
|
-
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
799
|
-
return ${clientName}(${clientParams.toCall()})
|
|
800
|
-
},
|
|
801
|
-
})
|
|
802
|
-
`
|
|
803
|
-
})
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
MutationOptions.getParams = getParams$5;
|
|
807
|
-
//#endregion
|
|
808
|
-
//#region src/components/Mutation.tsx
|
|
809
|
-
function getParams$4({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
810
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
811
|
-
const pathParams = getPathParams(typeSchemas.pathParams, {
|
|
812
|
-
typed: true,
|
|
813
|
-
casing: paramsCasing
|
|
814
|
-
});
|
|
815
|
-
const TRequest = FunctionParams.factory({
|
|
816
|
-
...pathParams,
|
|
817
|
-
data: typeSchemas.request?.name ? {
|
|
818
|
-
type: typeSchemas.request?.name,
|
|
819
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
820
|
-
} : void 0,
|
|
821
|
-
params: typeSchemas.queryParams?.name ? {
|
|
822
|
-
type: typeSchemas.queryParams?.name,
|
|
823
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
824
|
-
} : void 0,
|
|
825
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
826
|
-
type: typeSchemas.headerParams?.name,
|
|
827
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
828
|
-
} : void 0
|
|
829
|
-
}).toConstructor();
|
|
830
|
-
const generics = [
|
|
831
|
-
TData,
|
|
832
|
-
`ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
|
|
833
|
-
TRequest ? `{${TRequest}}` : "void",
|
|
834
|
-
"TContext"
|
|
835
|
-
].join(", ");
|
|
836
|
-
return FunctionParams.factory({ options: {
|
|
837
|
-
type: `
|
|
838
|
-
{
|
|
839
|
-
mutation?: UseMutationOptions<${generics}> & { client?: QueryClient },
|
|
840
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
|
|
841
|
-
}
|
|
842
|
-
`,
|
|
843
|
-
default: "{}"
|
|
844
|
-
} });
|
|
845
|
-
}
|
|
846
|
-
__name(getParams$4, "getParams");
|
|
847
|
-
function Mutation({ name, mutationOptionsName, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName, customOptions }) {
|
|
848
|
-
const mutationKeyParams = MutationKey.getParams({
|
|
849
|
-
pathParamsType,
|
|
850
|
-
typeSchemas
|
|
851
|
-
});
|
|
852
|
-
const params = getParams$4({
|
|
853
|
-
paramsCasing,
|
|
854
|
-
pathParamsType,
|
|
855
|
-
dataReturnType,
|
|
856
|
-
typeSchemas
|
|
857
|
-
});
|
|
858
|
-
const mutationParams = FunctionParams.factory({
|
|
859
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
860
|
-
typed: true,
|
|
861
|
-
casing: paramsCasing
|
|
862
|
-
}),
|
|
863
|
-
data: typeSchemas.request?.name ? {
|
|
864
|
-
type: typeSchemas.request?.name,
|
|
865
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
866
|
-
} : void 0,
|
|
867
|
-
params: typeSchemas.queryParams?.name ? {
|
|
868
|
-
type: typeSchemas.queryParams?.name,
|
|
869
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
870
|
-
} : void 0,
|
|
871
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
872
|
-
type: typeSchemas.headerParams?.name,
|
|
873
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
874
|
-
} : void 0
|
|
875
|
-
});
|
|
876
|
-
const mutationOptionsParams = MutationOptions.getParams({ typeSchemas });
|
|
877
|
-
const TRequest = mutationParams.toConstructor();
|
|
878
|
-
const generics = [
|
|
879
|
-
dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
|
|
880
|
-
`ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
|
|
881
|
-
TRequest ? `{${TRequest}}` : "void",
|
|
882
|
-
"TContext"
|
|
883
|
-
].join(", ");
|
|
884
|
-
const returnType = `UseMutationResult<${generics}>`;
|
|
885
|
-
const mutationOptions = `${mutationOptionsName}(${mutationOptionsParams.toCall()})`;
|
|
886
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
887
|
-
name,
|
|
888
|
-
isExportable: true,
|
|
889
|
-
isIndexable: true,
|
|
890
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
891
|
-
name,
|
|
892
|
-
export: true,
|
|
893
|
-
params: params.toConstructor(),
|
|
894
|
-
JSDoc: { comments: getComments(operation) },
|
|
895
|
-
generics: ["TContext"],
|
|
896
|
-
children: `
|
|
897
|
-
const { mutation = {}, client: config = {} } = options ?? {}
|
|
898
|
-
const { client: queryClient, ...mutationOptions } = mutation;
|
|
899
|
-
const mutationKey = mutationOptions.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
900
|
-
|
|
901
|
-
const baseOptions = ${mutationOptions} as UseMutationOptions<${generics}>
|
|
902
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' }) as UseMutationOptions<${generics}>` : ""}
|
|
903
|
-
|
|
904
|
-
return useMutation<${generics}>({
|
|
905
|
-
...baseOptions,${customOptions ? "\n...customOptions," : ""}
|
|
906
|
-
mutationKey,
|
|
907
|
-
...mutationOptions,
|
|
908
|
-
}, queryClient) as ${returnType}
|
|
909
|
-
`
|
|
910
|
-
})
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region src/components/Query.tsx
|
|
915
|
-
function getParams$3({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
916
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
917
|
-
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
918
|
-
if (paramsType === "object") {
|
|
919
|
-
const children = {
|
|
920
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
921
|
-
typed: true,
|
|
922
|
-
casing: paramsCasing
|
|
923
|
-
}),
|
|
924
|
-
data: typeSchemas.request?.name ? {
|
|
925
|
-
type: typeSchemas.request?.name,
|
|
926
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
927
|
-
} : void 0,
|
|
928
|
-
params: typeSchemas.queryParams?.name ? {
|
|
929
|
-
type: typeSchemas.queryParams?.name,
|
|
930
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
931
|
-
} : void 0,
|
|
932
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
933
|
-
type: typeSchemas.headerParams?.name,
|
|
934
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
935
|
-
} : void 0
|
|
936
|
-
};
|
|
937
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
938
|
-
return FunctionParams.factory({
|
|
939
|
-
data: {
|
|
940
|
-
mode: "object",
|
|
941
|
-
children,
|
|
942
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
943
|
-
},
|
|
944
|
-
options: {
|
|
945
|
-
type: `
|
|
946
|
-
{
|
|
947
|
-
query?: Partial<QueryObserverOptions<${[
|
|
948
|
-
TData,
|
|
949
|
-
TError,
|
|
950
|
-
"TData",
|
|
951
|
-
"TQueryData",
|
|
952
|
-
"TQueryKey"
|
|
953
|
-
].join(", ")}>> & { client?: QueryClient },
|
|
954
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
955
|
-
}
|
|
956
|
-
`,
|
|
957
|
-
default: "{}"
|
|
958
|
-
}
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
return FunctionParams.factory({
|
|
962
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
963
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
964
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
965
|
-
typed: true,
|
|
966
|
-
casing: paramsCasing
|
|
967
|
-
}),
|
|
968
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
969
|
-
} : void 0,
|
|
970
|
-
data: typeSchemas.request?.name ? {
|
|
971
|
-
type: typeSchemas.request?.name,
|
|
972
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
973
|
-
} : void 0,
|
|
974
|
-
params: typeSchemas.queryParams?.name ? {
|
|
975
|
-
type: typeSchemas.queryParams?.name,
|
|
976
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
977
|
-
} : void 0,
|
|
978
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
979
|
-
type: typeSchemas.headerParams?.name,
|
|
980
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
981
|
-
} : void 0,
|
|
982
|
-
options: {
|
|
983
|
-
type: `
|
|
984
|
-
{
|
|
985
|
-
query?: Partial<QueryObserverOptions<${[
|
|
986
|
-
TData,
|
|
987
|
-
TError,
|
|
988
|
-
"TData",
|
|
989
|
-
"TQueryData",
|
|
990
|
-
"TQueryKey"
|
|
991
|
-
].join(", ")}>> & { client?: QueryClient },
|
|
992
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
993
|
-
}
|
|
994
|
-
`,
|
|
995
|
-
default: "{}"
|
|
996
|
-
}
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
__name(getParams$3, "getParams");
|
|
1000
|
-
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, customOptions }) {
|
|
1001
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1002
|
-
const returnType = `UseQueryResult<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
|
|
1003
|
-
const generics = [
|
|
1004
|
-
`TData = ${TData}`,
|
|
1005
|
-
`TQueryData = ${TData}`,
|
|
1006
|
-
`TQueryKey extends QueryKey = ${queryKeyTypeName}`
|
|
1007
|
-
];
|
|
1008
|
-
const queryKeyParams = QueryKey.getParams({
|
|
1009
|
-
pathParamsType,
|
|
1010
|
-
typeSchemas,
|
|
1011
|
-
paramsCasing
|
|
1012
|
-
});
|
|
1013
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
1014
|
-
paramsType,
|
|
1015
|
-
pathParamsType,
|
|
1016
|
-
typeSchemas,
|
|
1017
|
-
paramsCasing
|
|
1018
|
-
});
|
|
1019
|
-
const params = getParams$3({
|
|
1020
|
-
paramsCasing,
|
|
1021
|
-
paramsType,
|
|
1022
|
-
pathParamsType,
|
|
1023
|
-
dataReturnType,
|
|
1024
|
-
typeSchemas
|
|
1025
|
-
});
|
|
1026
|
-
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
1027
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
1028
|
-
name,
|
|
1029
|
-
isExportable: true,
|
|
1030
|
-
isIndexable: true,
|
|
1031
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1032
|
-
name,
|
|
1033
|
-
export: true,
|
|
1034
|
-
generics: generics.join(", "),
|
|
1035
|
-
params: params.toConstructor(),
|
|
1036
|
-
JSDoc: { comments: getComments(operation) },
|
|
1037
|
-
children: `
|
|
1038
|
-
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
1039
|
-
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
1040
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1041
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""}
|
|
1042
|
-
|
|
1043
|
-
const query = useQuery({
|
|
1044
|
-
...${queryOptions},${customOptions ? "\n...customOptions," : ""}
|
|
1045
|
-
...resolvedOptions,
|
|
1046
|
-
queryKey,
|
|
1047
|
-
} as unknown as QueryObserverOptions, queryClient) as ${returnType}
|
|
1048
|
-
|
|
1049
|
-
query.queryKey = queryKey as TQueryKey
|
|
1050
|
-
|
|
1051
|
-
return query
|
|
1052
|
-
`
|
|
1053
|
-
})
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
Query.getParams = getParams$3;
|
|
1057
|
-
//#endregion
|
|
1058
|
-
//#region src/components/SuspenseInfiniteQuery.tsx
|
|
1059
|
-
function getParams$2({ paramsType, paramsCasing, pathParamsType, typeSchemas, pageParamGeneric }) {
|
|
1060
|
-
if (paramsType === "object") {
|
|
1061
|
-
const children = {
|
|
1062
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
1063
|
-
typed: true,
|
|
1064
|
-
casing: paramsCasing
|
|
1065
|
-
}),
|
|
1066
|
-
data: typeSchemas.request?.name ? {
|
|
1067
|
-
type: typeSchemas.request?.name,
|
|
1068
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1069
|
-
} : void 0,
|
|
1070
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1071
|
-
type: typeSchemas.queryParams?.name,
|
|
1072
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1073
|
-
} : void 0,
|
|
1074
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1075
|
-
type: typeSchemas.headerParams?.name,
|
|
1076
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1077
|
-
} : void 0
|
|
1078
|
-
};
|
|
1079
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
1080
|
-
return FunctionParams.factory({
|
|
1081
|
-
data: {
|
|
1082
|
-
mode: "object",
|
|
1083
|
-
children,
|
|
1084
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
1085
|
-
},
|
|
1086
|
-
options: {
|
|
1087
|
-
type: `
|
|
1088
|
-
{
|
|
1089
|
-
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
1090
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
1091
|
-
}
|
|
1092
|
-
`,
|
|
1093
|
-
default: "{}"
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
return FunctionParams.factory({
|
|
1098
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
1099
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
1100
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
1101
|
-
typed: true,
|
|
1102
|
-
casing: paramsCasing
|
|
1103
|
-
}),
|
|
1104
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
1105
|
-
} : void 0,
|
|
1106
|
-
data: typeSchemas.request?.name ? {
|
|
1107
|
-
type: typeSchemas.request?.name,
|
|
1108
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1109
|
-
} : void 0,
|
|
1110
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1111
|
-
type: typeSchemas.queryParams?.name,
|
|
1112
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1113
|
-
} : void 0,
|
|
1114
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1115
|
-
type: typeSchemas.headerParams?.name,
|
|
1116
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1117
|
-
} : void 0,
|
|
1118
|
-
options: {
|
|
1119
|
-
type: `
|
|
1120
|
-
{
|
|
1121
|
-
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, ${pageParamGeneric}>> & { client?: QueryClient },
|
|
1122
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
1123
|
-
}
|
|
1124
|
-
`,
|
|
1125
|
-
default: "{}"
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
__name(getParams$2, "getParams");
|
|
1130
|
-
function SuspenseInfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, customOptions, initialPageParam, queryParam }) {
|
|
1131
|
-
const responseType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1132
|
-
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
1133
|
-
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
1134
|
-
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
1135
|
-
const parts = initialPageParam.split(" as ");
|
|
1136
|
-
return parts[parts.length - 1] ?? "unknown";
|
|
1137
|
-
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
1138
|
-
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
1139
|
-
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
1140
|
-
const returnType = "UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }";
|
|
1141
|
-
const generics = [
|
|
1142
|
-
`TQueryFnData = ${responseType}`,
|
|
1143
|
-
`TError = ${errorType}`,
|
|
1144
|
-
"TData = InfiniteData<TQueryFnData>",
|
|
1145
|
-
`TQueryKey extends QueryKey = ${queryKeyTypeName}`,
|
|
1146
|
-
`TPageParam = ${pageParamType}`
|
|
1147
|
-
];
|
|
1148
|
-
const queryKeyParams = QueryKey.getParams({
|
|
1149
|
-
pathParamsType,
|
|
1150
|
-
typeSchemas,
|
|
1151
|
-
paramsCasing
|
|
1152
|
-
});
|
|
1153
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
1154
|
-
paramsType,
|
|
1155
|
-
pathParamsType,
|
|
1156
|
-
typeSchemas,
|
|
1157
|
-
paramsCasing
|
|
1158
|
-
});
|
|
1159
|
-
const params = getParams$2({
|
|
1160
|
-
paramsCasing,
|
|
1161
|
-
paramsType,
|
|
1162
|
-
pathParamsType,
|
|
1163
|
-
typeSchemas,
|
|
1164
|
-
pageParamGeneric: "TPageParam"
|
|
1165
|
-
});
|
|
1166
|
-
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
1167
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
1168
|
-
name,
|
|
1169
|
-
isExportable: true,
|
|
1170
|
-
isIndexable: true,
|
|
1171
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1172
|
-
name,
|
|
1173
|
-
export: true,
|
|
1174
|
-
generics: generics.join(", "),
|
|
1175
|
-
params: params.toConstructor(),
|
|
1176
|
-
JSDoc: { comments: getComments(operation) },
|
|
1177
|
-
children: `
|
|
1178
|
-
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
1179
|
-
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
1180
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1181
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""}
|
|
1182
|
-
|
|
1183
|
-
const query = useSuspenseInfiniteQuery({
|
|
1184
|
-
...${queryOptions},${customOptions ? "\n...customOptions," : ""}
|
|
1185
|
-
...resolvedOptions,
|
|
1186
|
-
queryKey,
|
|
1187
|
-
} as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, queryClient) as ${returnType}
|
|
1188
|
-
|
|
1189
|
-
query.queryKey = queryKey as TQueryKey
|
|
1190
|
-
|
|
1191
|
-
return query
|
|
1192
|
-
`
|
|
1193
|
-
})
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
SuspenseInfiniteQuery.getParams = getParams$2;
|
|
1197
|
-
//#endregion
|
|
1198
|
-
//#region src/components/SuspenseInfiniteQueryOptions.tsx
|
|
1199
|
-
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
1200
|
-
if (paramsType === "object") {
|
|
1201
|
-
const children = {
|
|
1202
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
1203
|
-
typed: true,
|
|
1204
|
-
casing: paramsCasing
|
|
1205
|
-
}),
|
|
1206
|
-
data: typeSchemas.request?.name ? {
|
|
1207
|
-
type: typeSchemas.request?.name,
|
|
1208
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1209
|
-
} : void 0,
|
|
1210
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1211
|
-
type: typeSchemas.queryParams?.name,
|
|
1212
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1213
|
-
} : void 0,
|
|
1214
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1215
|
-
type: typeSchemas.headerParams?.name,
|
|
1216
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1217
|
-
} : void 0
|
|
1218
|
-
};
|
|
1219
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
1220
|
-
return FunctionParams.factory({
|
|
1221
|
-
data: {
|
|
1222
|
-
mode: "object",
|
|
1223
|
-
children,
|
|
1224
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
1225
|
-
},
|
|
1226
|
-
config: {
|
|
1227
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
1228
|
-
default: "{}"
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
return FunctionParams.factory({
|
|
1233
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
1234
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
1235
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
1236
|
-
typed: true,
|
|
1237
|
-
casing: paramsCasing
|
|
1238
|
-
}),
|
|
1239
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
1240
|
-
} : void 0,
|
|
1241
|
-
data: typeSchemas.request?.name ? {
|
|
1242
|
-
type: typeSchemas.request?.name,
|
|
1243
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1244
|
-
} : void 0,
|
|
1245
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1246
|
-
type: typeSchemas.queryParams?.name,
|
|
1247
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1248
|
-
} : void 0,
|
|
1249
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1250
|
-
type: typeSchemas.headerParams?.name,
|
|
1251
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1252
|
-
} : void 0,
|
|
1253
|
-
config: {
|
|
1254
|
-
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
1255
|
-
default: "{}"
|
|
1256
|
-
}
|
|
1257
|
-
});
|
|
1258
|
-
}
|
|
1259
|
-
__name(getParams$1, "getParams");
|
|
1260
|
-
function SuspenseInfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
|
|
1261
|
-
const queryFnDataType = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1262
|
-
const errorType = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
1263
|
-
const isInitialPageParamDefined = initialPageParam !== void 0 && initialPageParam !== null;
|
|
1264
|
-
const fallbackPageParamType = typeof initialPageParam === "number" ? "number" : typeof initialPageParam === "string" ? initialPageParam.includes(" as ") ? (() => {
|
|
1265
|
-
const parts = initialPageParam.split(" as ");
|
|
1266
|
-
return parts[parts.length - 1] ?? "unknown";
|
|
1267
|
-
})() : "string" : typeof initialPageParam === "boolean" ? "boolean" : "unknown";
|
|
1268
|
-
const queryParamType = queryParam && typeSchemas.queryParams?.name ? `${typeSchemas.queryParams?.name}['${queryParam}']` : void 0;
|
|
1269
|
-
const pageParamType = queryParamType ? isInitialPageParamDefined ? `NonNullable<${queryParamType}>` : queryParamType : fallbackPageParamType;
|
|
1270
|
-
const params = getParams$1({
|
|
1271
|
-
paramsType,
|
|
1272
|
-
paramsCasing,
|
|
1273
|
-
pathParamsType,
|
|
1274
|
-
typeSchemas
|
|
1275
|
-
});
|
|
1276
|
-
const clientParams = Client.getParams({
|
|
1277
|
-
paramsCasing,
|
|
1278
|
-
typeSchemas,
|
|
1279
|
-
paramsType,
|
|
1280
|
-
pathParamsType,
|
|
1281
|
-
isConfigurable: true
|
|
1282
|
-
});
|
|
1283
|
-
const queryKeyParams = QueryKey.getParams({
|
|
1284
|
-
pathParamsType,
|
|
1285
|
-
typeSchemas,
|
|
1286
|
-
paramsCasing
|
|
1287
|
-
});
|
|
1288
|
-
const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
|
|
1289
|
-
let getNextPageParamExpr;
|
|
1290
|
-
let getPreviousPageParamExpr;
|
|
1291
|
-
if (hasNewParams) {
|
|
1292
|
-
if (nextParam) {
|
|
1293
|
-
const accessor = getNestedAccessor(nextParam, "lastPage");
|
|
1294
|
-
if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
|
|
1295
|
-
}
|
|
1296
|
-
if (previousParam) {
|
|
1297
|
-
const accessor = getNestedAccessor(previousParam, "firstPage");
|
|
1298
|
-
if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
|
|
1299
|
-
}
|
|
1300
|
-
} else if (cursorParam) {
|
|
1301
|
-
getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
|
|
1302
|
-
getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
|
|
1303
|
-
} else {
|
|
1304
|
-
if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
|
|
1305
|
-
else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
|
|
1306
|
-
getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
|
|
1307
|
-
}
|
|
1308
|
-
const queryOptions = [
|
|
1309
|
-
`initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
|
|
1310
|
-
getNextPageParamExpr,
|
|
1311
|
-
getPreviousPageParamExpr
|
|
1312
|
-
].filter(Boolean);
|
|
1313
|
-
const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
|
|
1314
|
-
params = {
|
|
1315
|
-
...(params ?? {}),
|
|
1316
|
-
['${queryParam}']: pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}'],
|
|
1317
|
-
} as ${typeSchemas.queryParams?.name}` : "";
|
|
1318
|
-
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
1319
|
-
return item && !item.optional && !item.default ? key : void 0;
|
|
1320
|
-
}).filter(Boolean).join("&& ");
|
|
1321
|
-
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
1322
|
-
if (infiniteOverrideParams) return /* @__PURE__ */ jsx(File.Source, {
|
|
1323
|
-
name,
|
|
1324
|
-
isExportable: true,
|
|
1325
|
-
isIndexable: true,
|
|
1326
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1327
|
-
name,
|
|
1328
|
-
export: true,
|
|
1329
|
-
params: params.toConstructor(),
|
|
1330
|
-
children: `
|
|
1331
|
-
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1332
|
-
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
1333
|
-
${enabledText}
|
|
1334
|
-
queryKey,
|
|
1335
|
-
queryFn: async ({ signal, pageParam }) => {
|
|
1336
|
-
${infiniteOverrideParams}
|
|
1337
|
-
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
1338
|
-
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
1339
|
-
return name;
|
|
1340
|
-
} })})
|
|
1341
|
-
},
|
|
1342
|
-
${queryOptions.join(",\n")}
|
|
1343
|
-
})
|
|
1344
|
-
`
|
|
1345
|
-
})
|
|
1346
|
-
});
|
|
1347
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
1348
|
-
name,
|
|
1349
|
-
isExportable: true,
|
|
1350
|
-
isIndexable: true,
|
|
1351
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1352
|
-
name,
|
|
1353
|
-
export: true,
|
|
1354
|
-
params: params.toConstructor(),
|
|
1355
|
-
children: `
|
|
1356
|
-
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1357
|
-
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, typeof queryKey, ${pageParamType}>({
|
|
1358
|
-
${enabledText}
|
|
1359
|
-
queryKey,
|
|
1360
|
-
queryFn: async ({ signal }) => {
|
|
1361
|
-
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
1362
|
-
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
1363
|
-
return name;
|
|
1364
|
-
} })})
|
|
1365
|
-
},
|
|
1366
|
-
${queryOptions.join(",\n")}
|
|
1367
|
-
})
|
|
1368
|
-
`
|
|
1369
|
-
})
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
SuspenseInfiniteQueryOptions.getParams = getParams$1;
|
|
1373
|
-
//#endregion
|
|
1374
|
-
//#region src/components/SuspenseQuery.tsx
|
|
1375
|
-
function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
1376
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1377
|
-
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
1378
|
-
if (paramsType === "object") {
|
|
1379
|
-
const children = {
|
|
1380
|
-
...getPathParams(typeSchemas.pathParams, {
|
|
1381
|
-
typed: true,
|
|
1382
|
-
casing: paramsCasing
|
|
1383
|
-
}),
|
|
1384
|
-
data: typeSchemas.request?.name ? {
|
|
1385
|
-
type: typeSchemas.request?.name,
|
|
1386
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1387
|
-
} : void 0,
|
|
1388
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1389
|
-
type: typeSchemas.queryParams?.name,
|
|
1390
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1391
|
-
} : void 0,
|
|
1392
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1393
|
-
type: typeSchemas.headerParams?.name,
|
|
1394
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1395
|
-
} : void 0
|
|
1396
|
-
};
|
|
1397
|
-
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
1398
|
-
return FunctionParams.factory({
|
|
1399
|
-
data: {
|
|
1400
|
-
mode: "object",
|
|
1401
|
-
children,
|
|
1402
|
-
default: allChildrenAreOptional ? "{}" : void 0
|
|
1403
|
-
},
|
|
1404
|
-
options: {
|
|
1405
|
-
type: `
|
|
1406
|
-
{
|
|
1407
|
-
query?: Partial<UseSuspenseQueryOptions<${[
|
|
1408
|
-
TData,
|
|
1409
|
-
TError,
|
|
1410
|
-
"TData",
|
|
1411
|
-
"TQueryKey"
|
|
1412
|
-
].join(", ")}>> & { client?: QueryClient },
|
|
1413
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
1414
|
-
}
|
|
1415
|
-
`,
|
|
1416
|
-
default: "{}"
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
}
|
|
1420
|
-
return FunctionParams.factory({
|
|
1421
|
-
pathParams: typeSchemas.pathParams?.name ? {
|
|
1422
|
-
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
1423
|
-
children: getPathParams(typeSchemas.pathParams, {
|
|
1424
|
-
typed: true,
|
|
1425
|
-
casing: paramsCasing
|
|
1426
|
-
}),
|
|
1427
|
-
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
1428
|
-
} : void 0,
|
|
1429
|
-
data: typeSchemas.request?.name ? {
|
|
1430
|
-
type: typeSchemas.request?.name,
|
|
1431
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
1432
|
-
} : void 0,
|
|
1433
|
-
params: typeSchemas.queryParams?.name ? {
|
|
1434
|
-
type: typeSchemas.queryParams?.name,
|
|
1435
|
-
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
1436
|
-
} : void 0,
|
|
1437
|
-
headers: typeSchemas.headerParams?.name ? {
|
|
1438
|
-
type: typeSchemas.headerParams?.name,
|
|
1439
|
-
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
1440
|
-
} : void 0,
|
|
1441
|
-
options: {
|
|
1442
|
-
type: `
|
|
1443
|
-
{
|
|
1444
|
-
query?: Partial<UseSuspenseQueryOptions<${[
|
|
1445
|
-
TData,
|
|
1446
|
-
TError,
|
|
1447
|
-
"TData",
|
|
1448
|
-
"TQueryKey"
|
|
1449
|
-
].join(", ")}>> & { client?: QueryClient },
|
|
1450
|
-
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
1451
|
-
}
|
|
1452
|
-
`,
|
|
1453
|
-
default: "{}"
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
/**
|
|
1458
|
-
* Generates a strongly-typed React Query Suspense hook function for an OpenAPI operation.
|
|
1459
|
-
*
|
|
1460
|
-
* The generated function wraps `useSuspenseQuery`, providing type-safe parameters and return types based on the supplied OpenAPI schemas and configuration.
|
|
1461
|
-
*
|
|
1462
|
-
* @returns A React component source node containing the generated query function.
|
|
1463
|
-
*/
|
|
1464
|
-
function SuspenseQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation, customOptions }) {
|
|
1465
|
-
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
1466
|
-
const returnType = `UseSuspenseQueryResult<${["TData", `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`].join(", ")}> & { queryKey: TQueryKey }`;
|
|
1467
|
-
const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`];
|
|
1468
|
-
const queryKeyParams = QueryKey.getParams({
|
|
1469
|
-
pathParamsType,
|
|
1470
|
-
typeSchemas,
|
|
1471
|
-
paramsCasing
|
|
1472
|
-
});
|
|
1473
|
-
const queryOptionsParams = QueryOptions.getParams({
|
|
1474
|
-
paramsCasing,
|
|
1475
|
-
paramsType,
|
|
1476
|
-
pathParamsType,
|
|
1477
|
-
typeSchemas
|
|
1478
|
-
});
|
|
1479
|
-
const params = getParams({
|
|
1480
|
-
paramsCasing,
|
|
1481
|
-
paramsType,
|
|
1482
|
-
pathParamsType,
|
|
1483
|
-
dataReturnType,
|
|
1484
|
-
typeSchemas
|
|
1485
|
-
});
|
|
1486
|
-
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
1487
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
1488
|
-
name,
|
|
1489
|
-
isExportable: true,
|
|
1490
|
-
isIndexable: true,
|
|
1491
|
-
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1492
|
-
name,
|
|
1493
|
-
export: true,
|
|
1494
|
-
generics: generics.join(", "),
|
|
1495
|
-
params: params.toConstructor(),
|
|
1496
|
-
JSDoc: { comments: getComments(operation) },
|
|
1497
|
-
children: `
|
|
1498
|
-
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
1499
|
-
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
1500
|
-
const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1501
|
-
${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${operation.getOperationId()}' })` : ""}
|
|
1502
|
-
|
|
1503
|
-
const query = useSuspenseQuery({
|
|
1504
|
-
...${queryOptions},${customOptions ? "\n...customOptions," : ""}
|
|
1505
|
-
...resolvedOptions,
|
|
1506
|
-
queryKey,
|
|
1507
|
-
} as unknown as UseSuspenseQueryOptions, queryClient) as ${returnType}
|
|
1508
|
-
|
|
1509
|
-
query.queryKey = queryKey as TQueryKey
|
|
1510
|
-
|
|
1511
|
-
return query
|
|
1512
|
-
`
|
|
1513
|
-
})
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
SuspenseQuery.getParams = getParams;
|
|
1517
|
-
//#endregion
|
|
1518
|
-
export { Mutation as a, InfiniteQuery as c, MutationKey as d, camelCase as f, Query as i, QueryOptions as l, SuspenseInfiniteQueryOptions as n, MutationOptions as o, pascalCase as p, SuspenseInfiniteQuery as r, InfiniteQueryOptions as s, SuspenseQuery as t, QueryKey as u };
|
|
1519
|
-
|
|
1520
|
-
//# sourceMappingURL=components-CpyHYGOw.js.map
|