@kubb/plugin-vue-query 5.11.0-canary.20261117T231551 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +252 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -39
- package/dist/index.d.ts +51 -39
- package/dist/index.js +253 -195
- package/dist/index.js.map +1 -1
- package/docs/guides/calling-operations.md +1 -1
- package/docs/options.md +8 -4
- package/docs/overview.md +2 -2
- package/kubb-extension.json +5 -1
- package/package.json +11 -9
package/dist/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ let _kubb_kit = require("@kubb/kit");
|
|
|
27
27
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
28
28
|
let node_path = require("node:path");
|
|
29
29
|
node_path = __toESM(node_path, 1);
|
|
30
|
+
let _kubb_ast = require("@kubb/ast");
|
|
30
31
|
let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
|
|
31
32
|
let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
|
|
32
33
|
// kubb-extension.json
|
|
@@ -35,14 +36,14 @@ var compatibility = {
|
|
|
35
36
|
"node": ">=22.22"
|
|
36
37
|
};
|
|
37
38
|
// package.json
|
|
38
|
-
var version = "5.11.
|
|
39
|
+
var version = "5.11.1";
|
|
39
40
|
// ../../internals/client/src/resolveClient.ts
|
|
40
41
|
/**
|
|
41
42
|
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
42
43
|
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
43
44
|
*
|
|
44
45
|
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
45
|
-
* contract client plugin (plugin-fetch, plugin-axios, or plugin-client) and never emits its own
|
|
46
|
+
* contract client plugin (plugin-fetch, plugin-axios, plugin-ky, or plugin-client) and never emits its own
|
|
46
47
|
* inline client:
|
|
47
48
|
*
|
|
48
49
|
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
@@ -50,20 +51,23 @@ var version = "5.11.0-canary.20261117T231551";
|
|
|
50
51
|
* - `error` — no client plugin is registered, several are registered without a selector, the
|
|
51
52
|
* requested one is missing, or `client` is not a known selector.
|
|
52
53
|
*
|
|
53
|
-
* The `client` string selects explicitly (`'fetch'` / `'axios'` / `'client'`); when it is unset a
|
|
54
|
+
* The `client` string selects explicitly (`'fetch'` / `'axios'` / `'ky'` / `'client'`); when it is unset a
|
|
54
55
|
* lone registered contract client plugin is picked up automatically.
|
|
55
56
|
*/
|
|
56
57
|
const pluginFetchName = "plugin-fetch";
|
|
57
58
|
const pluginAxiosName = "plugin-axios";
|
|
59
|
+
const pluginKyName = "plugin-ky";
|
|
58
60
|
const pluginClientName = "plugin-client";
|
|
59
61
|
const selectorToPlugin = {
|
|
60
62
|
fetch: pluginFetchName,
|
|
61
63
|
axios: pluginAxiosName,
|
|
64
|
+
ky: pluginKyName,
|
|
62
65
|
client: pluginClientName
|
|
63
66
|
};
|
|
64
67
|
const contractPlugins = [
|
|
65
68
|
pluginFetchName,
|
|
66
69
|
pluginAxiosName,
|
|
70
|
+
pluginKyName,
|
|
67
71
|
pluginClientName
|
|
68
72
|
];
|
|
69
73
|
/**
|
|
@@ -84,7 +88,7 @@ const contractPlugins = [
|
|
|
84
88
|
function resolveClient(options) {
|
|
85
89
|
const { client, pluginNames } = options;
|
|
86
90
|
const has = (name) => pluginNames.includes(name);
|
|
87
|
-
if (client
|
|
91
|
+
if (client !== void 0 && Object.hasOwn(selectorToPlugin, client)) {
|
|
88
92
|
const pluginName = selectorToPlugin[client];
|
|
89
93
|
if (!has(pluginName)) return {
|
|
90
94
|
kind: "error",
|
|
@@ -100,7 +104,7 @@ function resolveClient(options) {
|
|
|
100
104
|
if (client !== void 0) return {
|
|
101
105
|
kind: "error",
|
|
102
106
|
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
103
|
-
message: `Option \`client\` is ${typeof client === "string" ? `'${client}'` : String(client)}, but it must be one of 'fetch', 'axios', 'client'.`,
|
|
107
|
+
message: `Option \`client\` is ${typeof client === "string" ? `'${client}'` : String(client)}, but it must be one of 'fetch', 'axios', 'ky', 'client'.`,
|
|
104
108
|
help: "Set `client` to one of those values, or drop it to use the registered client plugin."
|
|
105
109
|
};
|
|
106
110
|
const registered = contractPlugins.filter(has);
|
|
@@ -112,13 +116,13 @@ function resolveClient(options) {
|
|
|
112
116
|
kind: "error",
|
|
113
117
|
code: _kubb_kit.Diagnostics.code.invalidPluginOptions,
|
|
114
118
|
message: `Multiple client plugins are registered (${registered.map((name) => `\`@kubb/${name}\``).join(", ")}) and \`client\` is not set.`,
|
|
115
|
-
help: "Set `client: 'fetch' | 'axios' | 'client'` to choose which client the hooks call, or register a single client plugin."
|
|
119
|
+
help: "Set `client: 'fetch' | 'axios' | 'ky' | 'client'` to choose which client the hooks call, or register a single client plugin."
|
|
116
120
|
};
|
|
117
121
|
return {
|
|
118
122
|
kind: "error",
|
|
119
123
|
code: _kubb_kit.Diagnostics.code.missingDependency,
|
|
120
124
|
message: "No client plugin is registered.",
|
|
121
|
-
help: "Add `@kubb/plugin-fetch`, `@kubb/plugin-axios`, or `@kubb/plugin-client` to `plugins` so the generated code has an HTTP client to call."
|
|
125
|
+
help: "Add `@kubb/plugin-fetch`, `@kubb/plugin-axios`, `@kubb/plugin-ky`, or `@kubb/plugin-client` to `plugins` so the generated code has an HTTP client to call."
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
@@ -146,6 +150,143 @@ function resolveContractClient(options) {
|
|
|
146
150
|
}
|
|
147
151
|
return resolved;
|
|
148
152
|
}
|
|
153
|
+
// ../../internals/ast/src/http/requestBody.ts
|
|
154
|
+
/** The schema of the first request body entry, else `undefined` when the operation takes no body. */
|
|
155
|
+
function getSchema(node) {
|
|
156
|
+
return node.requestBody?.content?.[0]?.schema;
|
|
157
|
+
}
|
|
158
|
+
// ../../internals/ast/src/http/status.ts
|
|
159
|
+
const classByRange = /* @__PURE__ */ new Map([
|
|
160
|
+
["1xx", 1],
|
|
161
|
+
["2xx", 2],
|
|
162
|
+
["3xx", 3],
|
|
163
|
+
["4xx", 4],
|
|
164
|
+
["5xx", 5]
|
|
165
|
+
]);
|
|
166
|
+
/** The class digit of a status code or range: `2` for `201` and `2xx`, `null` for `default`. */
|
|
167
|
+
function statusClass(input) {
|
|
168
|
+
const statusCode = typeof input === "object" ? input.statusCode : input;
|
|
169
|
+
const rangeClass = classByRange.get(String(statusCode));
|
|
170
|
+
if (rangeClass) return rangeClass;
|
|
171
|
+
const code = Number(statusCode);
|
|
172
|
+
return Number.isNaN(code) ? null : Math.floor(code / 100);
|
|
173
|
+
}
|
|
174
|
+
function isSuccess(statusCode) {
|
|
175
|
+
return statusClass(statusCode) === 2;
|
|
176
|
+
}
|
|
177
|
+
function isError(statusCode) {
|
|
178
|
+
const code = statusClass(statusCode);
|
|
179
|
+
return code !== null && code >= 4;
|
|
180
|
+
}
|
|
181
|
+
// ../../internals/ast/src/http/responses.ts
|
|
182
|
+
/** The `4xx` and `5xx` responses, ranges included. */
|
|
183
|
+
function filterError(node) {
|
|
184
|
+
return node.responses.filter((response) => isError(response.statusCode));
|
|
185
|
+
}
|
|
186
|
+
function filterSuccess(node) {
|
|
187
|
+
return node.responses.filter((response) => isSuccess(response.statusCode));
|
|
188
|
+
}
|
|
189
|
+
/** The success response a client returns: one with a body first, then an exact code over a `2xx` range. */
|
|
190
|
+
function findPrimary(node) {
|
|
191
|
+
const responses = filterSuccess(node);
|
|
192
|
+
const withBody = responses.filter((response) => response.content?.some((entry) => entry.contentType));
|
|
193
|
+
const candidates = withBody.length ? withBody : responses;
|
|
194
|
+
return candidates.find((response) => !Number.isNaN(Number(response.statusCode))) ?? candidates[0] ?? null;
|
|
195
|
+
}
|
|
196
|
+
// ../../internals/ast/src/http/index.ts
|
|
197
|
+
const isOperation = _kubb_ast.ast.http.isOperation;
|
|
198
|
+
/** Computes once per key; generators visit the same node many times. */
|
|
199
|
+
function cached(store, key, compute) {
|
|
200
|
+
if (!store.has(key)) store.set(key, compute());
|
|
201
|
+
return store.get(key);
|
|
202
|
+
}
|
|
203
|
+
const parametersByNode = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
/** The operation's parameters by location, with a `querystring` parameter in `query`. A repeated name keeps its first parameter. */
|
|
205
|
+
function groupParameters(node) {
|
|
206
|
+
return cached(parametersByNode, node, () => {
|
|
207
|
+
const group = (...locations) => {
|
|
208
|
+
const seen = /* @__PURE__ */ new Set();
|
|
209
|
+
return locations.flatMap((location) => node.parameters.filter((param) => {
|
|
210
|
+
if (param.in !== location || seen.has(param.name)) return false;
|
|
211
|
+
seen.add(param.name);
|
|
212
|
+
return true;
|
|
213
|
+
}));
|
|
214
|
+
};
|
|
215
|
+
return {
|
|
216
|
+
path: group("path"),
|
|
217
|
+
query: group("query", "querystring"),
|
|
218
|
+
header: group("header"),
|
|
219
|
+
cookie: group("cookie")
|
|
220
|
+
};
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
const requestGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
224
|
+
/** Which request groups are present, which hold a required member, and the body's media types. Built once per operation. */
|
|
225
|
+
function getRequestGroups(node) {
|
|
226
|
+
return cached(requestGroupsByNode, node, () => {
|
|
227
|
+
const { path, query, header, cookie } = groupParameters(node);
|
|
228
|
+
const content = node.requestBody?.content ?? [];
|
|
229
|
+
const body = Boolean(content[0]?.schema);
|
|
230
|
+
const required = {
|
|
231
|
+
path: path.some((param) => param.required),
|
|
232
|
+
query: query.some((param) => param.required),
|
|
233
|
+
headers: header.some((param) => param.required),
|
|
234
|
+
body: body && node.requestBody?.required === true
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
path: path.length > 0,
|
|
238
|
+
query: query.length > 0,
|
|
239
|
+
body,
|
|
240
|
+
headers: header.length > 0,
|
|
241
|
+
cookies: cookie.length > 0,
|
|
242
|
+
required,
|
|
243
|
+
isOptional: !required.path && !required.query && !required.headers && !required.body,
|
|
244
|
+
contentTypes: content.map((entry) => entry.contentType),
|
|
245
|
+
hasContentTypeChoice: content.filter((entry) => entry.schema).length > 1
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
// ../../internals/ast/src/mediaType.ts
|
|
250
|
+
const streamMediaTypes = /* @__PURE__ */ new Set([
|
|
251
|
+
"application/jsonl",
|
|
252
|
+
"application/x-ndjson",
|
|
253
|
+
"application/json-seq",
|
|
254
|
+
"text/event-stream"
|
|
255
|
+
]);
|
|
256
|
+
const getBase = _kubb_ast.ast.mediaType.getBase;
|
|
257
|
+
const isJson = _kubb_ast.ast.mediaType.isJson;
|
|
258
|
+
/** Whether the media type is a stream of items: SSE, JSON Lines, or a `+json-seq` sequence. */
|
|
259
|
+
function isStream(mediaType) {
|
|
260
|
+
const baseType = getBase(mediaType);
|
|
261
|
+
return streamMediaTypes.has(baseType) || baseType.startsWith("application/") && baseType.endsWith("+json-seq");
|
|
262
|
+
}
|
|
263
|
+
const formKinds = {
|
|
264
|
+
"multipart/form-data": "form",
|
|
265
|
+
"application/x-www-form-urlencoded": "urlencoded"
|
|
266
|
+
};
|
|
267
|
+
/** How a client reads or sends a content entry, or `null` for another media type. A `blob` schema is `binary`. */
|
|
268
|
+
function getKind(entry) {
|
|
269
|
+
const content = typeof entry === "string" ? { contentType: entry } : entry;
|
|
270
|
+
const baseType = getBase(content);
|
|
271
|
+
if (!baseType) return null;
|
|
272
|
+
if (baseType === "text/event-stream") return "eventStream";
|
|
273
|
+
if (content.stream && isStream(content)) return "lineStream";
|
|
274
|
+
if (isJson(baseType)) return "json";
|
|
275
|
+
if (formKinds[baseType]) return formKinds[baseType];
|
|
276
|
+
if (content.schema?.type === "blob") return "binary";
|
|
277
|
+
if (baseType.startsWith("text/")) return "text";
|
|
278
|
+
if (baseType === "application/octet-stream" || baseType === "application/pdf" || /^(image|audio|video)\//.test(baseType)) return "binary";
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
_kubb_ast.ast.schema.applyOptionality;
|
|
282
|
+
_kubb_ast.ast.schema.types;
|
|
283
|
+
const narrow = _kubb_ast.ast.schema.narrow;
|
|
284
|
+
_kubb_ast.ast.schema.find;
|
|
285
|
+
_kubb_ast.ast.schema.getEmbeddedJson;
|
|
286
|
+
const is = _kubb_ast.ast.schema.is;
|
|
287
|
+
const getLiterals = _kubb_ast.ast.schema.getLiterals;
|
|
288
|
+
_kubb_ast.ast.schema.inferDiscriminator;
|
|
289
|
+
const findProperties = _kubb_ast.ast.schema.findProperties;
|
|
149
290
|
// ../../internals/utils/src/reserved.ts
|
|
150
291
|
/**
|
|
151
292
|
* JavaScript and Java reserved words.
|
|
@@ -382,7 +523,7 @@ function resolveOperationFile(options) {
|
|
|
382
523
|
* The operation's method and path as plain text, such as `` `GET /pet/{petId}` ``. A path is not a valid `{@link}` target.
|
|
383
524
|
*/
|
|
384
525
|
function getOperationRequestLine(node) {
|
|
385
|
-
return
|
|
526
|
+
return isOperation(node) && node.path ? `\`${node.method.toUpperCase()} ${node.path}\`` : null;
|
|
386
527
|
}
|
|
387
528
|
/**
|
|
388
529
|
* Derives the shared `ContentTypeInfo` shape from a list of content types, tracking whether several
|
|
@@ -399,55 +540,52 @@ function buildContentTypeInfo(contentTypes) {
|
|
|
399
540
|
};
|
|
400
541
|
}
|
|
401
542
|
function getContentTypeInfo(node) {
|
|
402
|
-
return buildContentTypeInfo(node
|
|
543
|
+
return buildContentTypeInfo(getRequestGroups(node).contentTypes);
|
|
403
544
|
}
|
|
404
545
|
/**
|
|
405
546
|
* The request-body counterpart for the primary success response: the content types it documents and
|
|
406
547
|
* whether several are present, so the client can let a caller pick which one to accept.
|
|
407
548
|
*/
|
|
408
549
|
function getResponseContentTypeInfo(node) {
|
|
409
|
-
return buildContentTypeInfo(
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
*/
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
return getEventStream(node) !== null;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Whether a success response offers a stream media type next to other content types. The client returns that variant's
|
|
444
|
-
* body as a `ReadableStream`, so the stream runtime is registered and a hook's data type includes the stream.
|
|
445
|
-
*/
|
|
446
|
-
function hasStreamVariant(node) {
|
|
447
|
-
return _kubb_kit.ast.http.responses.filterSuccess(node).some((response) => {
|
|
448
|
-
const variants = (response.content ?? []).filter((entry) => entry.schema);
|
|
449
|
-
return variants.length > 1 && variants.some((entry) => _kubb_kit.ast.mediaType.isStream(entry));
|
|
550
|
+
return buildContentTypeInfo(findPrimary(node)?.content?.map((e) => e.contentType) ?? []);
|
|
551
|
+
}
|
|
552
|
+
const isText = (schema) => !!schema && is(schema, "text", { follow: ["ref"] });
|
|
553
|
+
function getTextEvents(entry, shape) {
|
|
554
|
+
if (shape === "data") return isText(entry.stream?.schema ?? entry.schema);
|
|
555
|
+
if (shape !== "event" || !entry.stream?.schema) return false;
|
|
556
|
+
const item = _kubb_ast.ref.getSchema(entry.stream.schema);
|
|
557
|
+
const events = narrow(item, "union")?.members ?? [item];
|
|
558
|
+
const propertySchemas = (event, propertyName) => findProperties({
|
|
559
|
+
node: event,
|
|
560
|
+
propertyName
|
|
561
|
+
}).map(({ schema }) => schema);
|
|
562
|
+
const textEvents = events.filter((event) => {
|
|
563
|
+
const dataSchemas = propertySchemas(event, "data");
|
|
564
|
+
return dataSchemas.length > 0 && dataSchemas.every(isText);
|
|
565
|
+
});
|
|
566
|
+
if (textEvents.length === events.length) return events.length > 0;
|
|
567
|
+
const eventNames = textEvents.map((event) => propertySchemas(event, "event").flatMap((schema) => getLiterals(_kubb_ast.ref.getSchema(schema))));
|
|
568
|
+
if (!eventNames.length || eventNames.some((values) => !values.length)) return false;
|
|
569
|
+
return [...new Set(eventNames.flat().map(String))];
|
|
570
|
+
}
|
|
571
|
+
/** How an operation streams its success responses, or `null` when none offers a stream. */
|
|
572
|
+
function getStream(node) {
|
|
573
|
+
const entries = findPrimary(node)?.content ?? [];
|
|
574
|
+
const entry = entries.length === 1 ? entries[0] : void 0;
|
|
575
|
+
const kind = entry ? getKind(entry) : null;
|
|
576
|
+
const shape = kind === "eventStream" ? entry?.stream?.shape ?? "data" : kind === "lineStream" ? "line" : null;
|
|
577
|
+
const hasEventStream = entries.some((item) => getKind(item) === "eventStream" && (entries.length === 1 || !!item.schema));
|
|
578
|
+
const hasVariant = filterSuccess(node).some((response) => {
|
|
579
|
+
const variants = (response.content ?? []).filter((item) => item.schema);
|
|
580
|
+
return variants.length > 1 && variants.some(isStream);
|
|
450
581
|
});
|
|
582
|
+
if (!shape && !hasEventStream && !hasVariant) return null;
|
|
583
|
+
return {
|
|
584
|
+
shape,
|
|
585
|
+
textEvents: entry ? getTextEvents(entry, shape) : false,
|
|
586
|
+
hasEventStream,
|
|
587
|
+
hasVariant
|
|
588
|
+
};
|
|
451
589
|
}
|
|
452
590
|
/**
|
|
453
591
|
* Builds the `client?:` option type shared by the generated query hooks (`useQuery`,
|
|
@@ -471,7 +609,7 @@ function buildClientOptionType(options = {}) {
|
|
|
471
609
|
* generated call.
|
|
472
610
|
*/
|
|
473
611
|
function buildRequestConfigType(node) {
|
|
474
|
-
if (
|
|
612
|
+
if (getRequestGroups(node).hasContentTypeChoice) return buildClientOptionType({ omit: ["contentType"] });
|
|
475
613
|
const request = getContentTypeInfo(node);
|
|
476
614
|
const response = getResponseContentTypeInfo(node);
|
|
477
615
|
const members = [request.isMultipleContentTypes ? `request?: ${request.contentTypeUnion}` : null, response.isMultipleContentTypes ? `response?: ${response.contentTypeUnion}` : null].filter(Boolean);
|
|
@@ -486,38 +624,6 @@ const requestGroupOrder = [
|
|
|
486
624
|
"headers",
|
|
487
625
|
"cookies"
|
|
488
626
|
];
|
|
489
|
-
/**
|
|
490
|
-
* Which of the grouped request options an operation carries.
|
|
491
|
-
*/
|
|
492
|
-
function getRequestGroups(node) {
|
|
493
|
-
const { path, query, header, cookie } = _kubb_kit.ast.http.groupParameters(node);
|
|
494
|
-
return {
|
|
495
|
-
path: path.length > 0,
|
|
496
|
-
query: query.length > 0,
|
|
497
|
-
body: Boolean(_kubb_kit.ast.http.requestBody.getSchema(node)),
|
|
498
|
-
headers: header.length > 0,
|
|
499
|
-
cookies: cookie.length > 0
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
/**
|
|
503
|
-
* Resolves which grouped request options an operation carries together with whether each group
|
|
504
|
-
* holds a required member. The grouped parameter stays optional only when nothing inside it is
|
|
505
|
-
* required, matching the generated `RequestConfig` type.
|
|
506
|
-
*/
|
|
507
|
-
function getRequestGroupOptionality(node) {
|
|
508
|
-
const groups = getRequestGroups(node);
|
|
509
|
-
const { path, query, header } = _kubb_kit.ast.http.groupParameters(node);
|
|
510
|
-
const hasRequiredPath = path.some((param) => param.required);
|
|
511
|
-
const hasRequiredQuery = query.some((param) => param.required);
|
|
512
|
-
const hasRequiredHeader = header.some((param) => param.required);
|
|
513
|
-
return {
|
|
514
|
-
groups,
|
|
515
|
-
hasRequiredPath,
|
|
516
|
-
hasRequiredQuery,
|
|
517
|
-
hasRequiredHeader,
|
|
518
|
-
isOptional: !hasRequiredPath && !hasRequiredQuery && !hasRequiredHeader && !(groups.body && node.requestBody?.required === true)
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
627
|
function buildOperationComments(node, options = {}) {
|
|
522
628
|
const { splitLines = false } = options;
|
|
523
629
|
const filteredComments = [
|
|
@@ -530,17 +636,11 @@ function buildOperationComments(node, options = {}) {
|
|
|
530
636
|
if (!splitLines) return filteredComments;
|
|
531
637
|
return filteredComments.flatMap((text) => text.split(/\r?\n/).map((line) => line.trim())).filter((comment) => Boolean(comment));
|
|
532
638
|
}
|
|
533
|
-
/**
|
|
534
|
-
* Whether the operation declares more than one request media type with a schema, so a caller must pick one on `contentType`.
|
|
535
|
-
*/
|
|
536
|
-
function hasRequestContentTypeChoice(node) {
|
|
537
|
-
return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
|
|
538
|
-
}
|
|
539
639
|
function resolveErrorNames(node, resolver) {
|
|
540
|
-
return
|
|
640
|
+
return filterError(node).map((response) => resolver.response.status(node, response.statusCode));
|
|
541
641
|
}
|
|
542
642
|
function resolveSuccessNames(node, resolver) {
|
|
543
|
-
return
|
|
643
|
+
return filterSuccess(node).map((response) => resolver.response.status(node, response.statusCode));
|
|
544
644
|
}
|
|
545
645
|
function resolveStatusCodeNames(node, resolver) {
|
|
546
646
|
return node.responses.map((response) => resolver.response.status(node, response.statusCode));
|
|
@@ -552,7 +652,7 @@ function resolveStatusCodeNames(node, resolver) {
|
|
|
552
652
|
function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
553
653
|
const key = `${node.operationId}\0${options.order ?? ""}\0${options.responseStatusNames ?? ""}\0${options.includeParams === false ? "noparams" : ""}\0${(options.exclude ?? []).join(",")}`;
|
|
554
654
|
return resolver.memo(`operationTypeNames:${key}`, () => {
|
|
555
|
-
const { path, query, header, cookie } =
|
|
655
|
+
const { path, query, header, cookie } = groupParameters(node);
|
|
556
656
|
const responseStatusNames = options.responseStatusNames === "error" ? resolveErrorNames(node, resolver) : options.responseStatusNames === false ? [] : resolveStatusCodeNames(node, resolver);
|
|
557
657
|
const exclude = new Set(options.exclude ?? []);
|
|
558
658
|
const paramNames = options.includeParams === false ? [] : [
|
|
@@ -561,7 +661,7 @@ function resolveOperationTypeNames(node, resolver, options = {}) {
|
|
|
561
661
|
...header.map((param) => resolver.param.headers(node, param)),
|
|
562
662
|
...cookie.map((param) => resolver.param.cookies(node, param))
|
|
563
663
|
];
|
|
564
|
-
const bodyAndResponseNames = [
|
|
664
|
+
const bodyAndResponseNames = [getSchema(node) ? resolver.response.body(node) : null, resolver.response.response(node)];
|
|
565
665
|
return (options.order === "body-response-first" ? [
|
|
566
666
|
...bodyAndResponseNames,
|
|
567
667
|
...paramNames,
|
|
@@ -913,19 +1013,19 @@ function maybeRefOrGetter(type) {
|
|
|
913
1013
|
*/
|
|
914
1014
|
function buildGroupedRequestParam(node, options) {
|
|
915
1015
|
const { resolver, keys = requestGroupOrder, memberTypeWrapper, withContentType = false } = options;
|
|
916
|
-
const
|
|
1016
|
+
const groups = getRequestGroups(node);
|
|
917
1017
|
const names = keys.filter((key) => groups[key]);
|
|
918
1018
|
if (names.length === 0) return null;
|
|
919
1019
|
const requiredByGroup = {
|
|
920
|
-
path:
|
|
921
|
-
query:
|
|
1020
|
+
path: groups.required.path,
|
|
1021
|
+
query: groups.required.query,
|
|
922
1022
|
body: groups.body,
|
|
923
|
-
headers:
|
|
1023
|
+
headers: groups.required.headers,
|
|
924
1024
|
cookies: false
|
|
925
1025
|
};
|
|
926
1026
|
const isOptional = names.every((name) => !requiredByGroup[name]);
|
|
927
1027
|
const optionsName = resolver.response.options(node);
|
|
928
|
-
if (withContentType &&
|
|
1028
|
+
if (withContentType && groups.hasContentTypeChoice) return (0, _kubb_plugin_ts.createFunctionParameter)({
|
|
929
1029
|
name: "variables",
|
|
930
1030
|
type: optionsName,
|
|
931
1031
|
optional: false
|
|
@@ -989,7 +1089,7 @@ function buildQueryOptionsParams(node, options) {
|
|
|
989
1089
|
*/
|
|
990
1090
|
function buildClientCall(node, options) {
|
|
991
1091
|
const { clientName, signal = false, unwrapName, withContentType = false, pageParam } = options;
|
|
992
|
-
const
|
|
1092
|
+
const groups = getRequestGroups(node);
|
|
993
1093
|
const names = requestGroupOrder.filter((key) => groups[key]);
|
|
994
1094
|
const member = (name) => {
|
|
995
1095
|
const value = unwrapName ? unwrapName(name) : name;
|
|
@@ -998,7 +1098,7 @@ function buildClientCall(node, options) {
|
|
|
998
1098
|
};
|
|
999
1099
|
return `${clientName}({ ${[
|
|
1000
1100
|
"...config",
|
|
1001
|
-
...withContentType &&
|
|
1101
|
+
...withContentType && groups.hasContentTypeChoice ? ["...variables"] : names.map(member),
|
|
1002
1102
|
signal ? "signal: config.signal ?? signal" : null,
|
|
1003
1103
|
"throwOnError: true"
|
|
1004
1104
|
].filter((part) => part !== null).join(", ")} })`;
|
|
@@ -1042,7 +1142,7 @@ function buildResponseTypes(node, resolver, options = {}) {
|
|
|
1042
1142
|
return resolver.memo(`responseTypes:${returnType}:${typedHeaders}:${node.method}\0${node.path}`, () => {
|
|
1043
1143
|
const successNames = resolveSuccessNames(node, resolver);
|
|
1044
1144
|
const bodyName = successNames.length > 0 ? successNames.join(" | ") : resolver.response.response(node);
|
|
1045
|
-
const responseName =
|
|
1145
|
+
const responseName = getStream(node)?.hasVariant ? `${bodyName} | ReadableStream<Uint8Array>` : bodyName;
|
|
1046
1146
|
const errorNames = resolveErrorNames(node, resolver);
|
|
1047
1147
|
return {
|
|
1048
1148
|
TData: returnType === "data" ? responseName : buildResultType(node, resolver, typedHeaders),
|
|
@@ -1064,7 +1164,7 @@ function resolveFallbackPageParamType(initialPageParam) {
|
|
|
1064
1164
|
* so callers can reuse it when rewriting the paginated request.
|
|
1065
1165
|
*/
|
|
1066
1166
|
function resolvePageParamType(node, { resolver, initialPageParam, queryParam }) {
|
|
1067
|
-
const firstQueryParam =
|
|
1167
|
+
const firstQueryParam = groupParameters(node).query[0];
|
|
1068
1168
|
const groupName = firstQueryParam ? resolver.param.query(node, firstQueryParam) : null;
|
|
1069
1169
|
const queryParamsTypeName = groupName !== (firstQueryParam ? resolver.param.name(node, firstQueryParam) : null) ? groupName : null;
|
|
1070
1170
|
const queryParamType = queryParam && queryParamsTypeName ? `${queryParamsTypeName}['${queryParam}']` : null;
|
|
@@ -1115,7 +1215,7 @@ function resolveMutationConfig(mutation, options) {
|
|
|
1115
1215
|
* directly, so they do not generate query or mutation hooks.
|
|
1116
1216
|
*/
|
|
1117
1217
|
function classifyOperation(node, { query, mutation }) {
|
|
1118
|
-
if (
|
|
1218
|
+
if (getStream(node)?.shape) return {
|
|
1119
1219
|
isQuery: false,
|
|
1120
1220
|
isMutation: false
|
|
1121
1221
|
};
|
|
@@ -1167,7 +1267,7 @@ function resolveInfiniteConfig(infinite) {
|
|
|
1167
1267
|
*/
|
|
1168
1268
|
function matchesInfinite(node, infinite) {
|
|
1169
1269
|
if (!infinite.queryParam) return false;
|
|
1170
|
-
return
|
|
1270
|
+
return groupParameters(node).query.some((param) => param.name.replace(/\?$/, "") === infinite.queryParam);
|
|
1171
1271
|
}
|
|
1172
1272
|
/**
|
|
1173
1273
|
* Warning for an infinite hook that falls back to the built-in page params on a response that
|
|
@@ -1175,8 +1275,8 @@ function matchesInfinite(node, infinite) {
|
|
|
1175
1275
|
*/
|
|
1176
1276
|
function getDefaultPageParamsWarning(node, infinite) {
|
|
1177
1277
|
if (!(infinite.getNextPageParam == null && infinite.getPreviousPageParam == null && infinite.nextParam == null && infinite.previousParam == null && !infinite.cursorParam)) return null;
|
|
1178
|
-
const content =
|
|
1179
|
-
let resolved = (content?.find((item) =>
|
|
1278
|
+
const content = findPrimary(node)?.content;
|
|
1279
|
+
let resolved = (content?.find((item) => isJson(item)) ?? content?.[0])?.schema;
|
|
1180
1280
|
while (resolved?.type === "ref" || resolved?.type === "intersection" && resolved.members?.length === 1) resolved = resolved.type === "ref" ? resolved.schema : resolved.members?.[0];
|
|
1181
1281
|
if (!resolved || resolved.type === "array") return null;
|
|
1182
1282
|
return `${node.operationId}: the default infinite page params expect an array response and never end for this one. Set \`infinite.getNextPageParam\` (or \`nextParam\`) to read the next page from the response.`;
|
|
@@ -1231,7 +1331,7 @@ function resolveMutationRequestType(node, resolver) {
|
|
|
1231
1331
|
if (!buildGroupedRequestParam(node, { resolver })) return "undefined";
|
|
1232
1332
|
const optionsName = resolver.response.options(node);
|
|
1233
1333
|
const response = getResponseContentTypeInfo(node);
|
|
1234
|
-
if (!
|
|
1334
|
+
if (!getRequestGroups(node).hasContentTypeChoice || !response.isMultipleContentTypes) return optionsName;
|
|
1235
1335
|
return `${/^[\w$]+$/.test(optionsName) ? optionsName : `(${optionsName})`} & { contentType?: string | { response?: ${response.contentTypeUnion} } }`;
|
|
1236
1336
|
}
|
|
1237
1337
|
// ../../internals/tanstack-query/src/components/InfiniteQueryOptions.tsx
|
|
@@ -1292,26 +1392,20 @@ function InfiniteQueryOptions({ name, clientName, initialPageParam, hasExplicitI
|
|
|
1292
1392
|
getNextPageParamExpr,
|
|
1293
1393
|
getPreviousPageParamExpr
|
|
1294
1394
|
].filter(Boolean);
|
|
1295
|
-
|
|
1296
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1395
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
1297
1396
|
name,
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
children:
|
|
1301
|
-
name,
|
|
1302
|
-
export: true,
|
|
1303
|
-
params: paramsSignature,
|
|
1304
|
-
children: `
|
|
1397
|
+
export: true,
|
|
1398
|
+
params: paramsSignature,
|
|
1399
|
+
children: `
|
|
1305
1400
|
const queryKey = ${queryKeyName}(${queryKeyParamsCall})
|
|
1306
1401
|
return infiniteQueryOptions<${queryFnDataType}, ${errorType}, InfiniteData<${queryFnDataType}>, ${queryKeyType}, ${pageParamType}>({
|
|
1307
1402
|
queryKey,
|
|
1308
|
-
queryFn: async (${
|
|
1403
|
+
queryFn: async (${pageParam ? "{ signal, pageParam }" : "{ signal }"}) => {
|
|
1309
1404
|
${queryFnBody}
|
|
1310
1405
|
},
|
|
1311
1406
|
${queryOptionsArr.join(",\n ")}
|
|
1312
1407
|
})
|
|
1313
1408
|
`
|
|
1314
|
-
})
|
|
1315
1409
|
});
|
|
1316
1410
|
}
|
|
1317
1411
|
// ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
@@ -1338,27 +1432,16 @@ function MutationKey({ name, node, transformer, typeName }) {
|
|
|
1338
1432
|
casing: "camelcase",
|
|
1339
1433
|
variant: "mutation"
|
|
1340
1434
|
});
|
|
1341
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.
|
|
1435
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function.Arrow, {
|
|
1342
1436
|
name,
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
singleLine: true,
|
|
1350
|
-
children: `[${keys.join(", ")}] as const`
|
|
1351
|
-
})
|
|
1352
|
-
}), typeName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1437
|
+
export: true,
|
|
1438
|
+
params: paramsSignature,
|
|
1439
|
+
singleLine: true,
|
|
1440
|
+
children: `[${keys.join(", ")}] as const`
|
|
1441
|
+
}), typeName && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
|
|
1442
|
+
export: true,
|
|
1353
1443
|
name: typeName,
|
|
1354
|
-
|
|
1355
|
-
isIndexable: true,
|
|
1356
|
-
isTypeOnly: true,
|
|
1357
|
-
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
|
|
1358
|
-
export: true,
|
|
1359
|
-
name: typeName,
|
|
1360
|
-
children: `ReturnType<typeof ${name}>`
|
|
1361
|
-
})
|
|
1444
|
+
children: `ReturnType<typeof ${name}>`
|
|
1362
1445
|
})] });
|
|
1363
1446
|
}
|
|
1364
1447
|
// ../../internals/tanstack-query/src/resolver.ts
|
|
@@ -1448,14 +1531,14 @@ const declarationPrinter$3 = (0, _kubb_plugin_ts.functionPrinter)({ mode: "decla
|
|
|
1448
1531
|
*/
|
|
1449
1532
|
const queryKeyTransformer = ({ node, variant }) => {
|
|
1450
1533
|
if (!node.path) return [];
|
|
1451
|
-
const { path, query } =
|
|
1534
|
+
const { path, query } = groupParameters(node);
|
|
1452
1535
|
const isInfinite = variant === "infiniteQuery" || variant === "suspenseInfiniteQuery";
|
|
1453
1536
|
const urlFields = [`url: '${_kubb_kit.Url.toPath(node.path)}'`];
|
|
1454
1537
|
if (path.length > 0) urlFields.push("params: path");
|
|
1455
1538
|
if (isInfinite) urlFields.push("infinite: true");
|
|
1456
1539
|
const result = [`{ ${urlFields.join(", ")} }`];
|
|
1457
1540
|
if (query.length > 0) result.push("...(query ? [query] : [])");
|
|
1458
|
-
if (
|
|
1541
|
+
if (getSchema(node)) result.push("...(body !== undefined ? [body] : [])");
|
|
1459
1542
|
return result;
|
|
1460
1543
|
};
|
|
1461
1544
|
function QueryKey({ name, node, tsResolver, typeName, transformer, variant = "query", memberTypeWrapper, exportType }) {
|
|
@@ -1469,27 +1552,16 @@ function QueryKey({ name, node, tsResolver, typeName, transformer, variant = "qu
|
|
|
1469
1552
|
casing: "camelcase",
|
|
1470
1553
|
variant
|
|
1471
1554
|
});
|
|
1472
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.
|
|
1555
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function.Arrow, {
|
|
1473
1556
|
name,
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
params: paramsSignature,
|
|
1480
|
-
singleLine: true,
|
|
1481
|
-
children: `[${keys.join(", ")}] as const`
|
|
1482
|
-
})
|
|
1483
|
-
}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
|
|
1557
|
+
export: true,
|
|
1558
|
+
params: paramsSignature,
|
|
1559
|
+
singleLine: true,
|
|
1560
|
+
children: `[${keys.join(", ")}] as const`
|
|
1561
|
+
}), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
|
|
1484
1562
|
name: typeName,
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
isTypeOnly: true,
|
|
1488
|
-
children: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Type, {
|
|
1489
|
-
name: typeName,
|
|
1490
|
-
export: exportType,
|
|
1491
|
-
children: `ReturnType<typeof ${name}>`
|
|
1492
|
-
})
|
|
1563
|
+
export: exportType,
|
|
1564
|
+
children: `ReturnType<typeof ${name}>`
|
|
1493
1565
|
})] });
|
|
1494
1566
|
}
|
|
1495
1567
|
// src/components/QueryOptions.tsx
|
|
@@ -1521,15 +1593,11 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, client
|
|
|
1521
1593
|
clientReturnType,
|
|
1522
1594
|
returnType
|
|
1523
1595
|
});
|
|
1524
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.
|
|
1596
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
1525
1597
|
name,
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
children:
|
|
1529
|
-
name,
|
|
1530
|
-
export: true,
|
|
1531
|
-
params: paramsSignature,
|
|
1532
|
-
children: `
|
|
1598
|
+
export: true,
|
|
1599
|
+
params: paramsSignature,
|
|
1600
|
+
children: `
|
|
1533
1601
|
const queryKey = ${queryKeyName}(${queryKeyParamsCall})
|
|
1534
1602
|
return queryOptions<${TData}, ${TError}, ${TData}>({
|
|
1535
1603
|
queryKey,
|
|
@@ -1538,7 +1606,6 @@ function QueryOptions({ name, clientName, node, tsResolver, queryKeyName, client
|
|
|
1538
1606
|
},
|
|
1539
1607
|
})
|
|
1540
1608
|
`
|
|
1541
|
-
})
|
|
1542
1609
|
});
|
|
1543
1610
|
}
|
|
1544
1611
|
// src/components/Query.tsx
|
|
@@ -1599,17 +1666,13 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1599
1666
|
}`
|
|
1600
1667
|
});
|
|
1601
1668
|
const paramsSignature = declarationPrinter$1.print(paramsNode) ?? "";
|
|
1602
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.
|
|
1669
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
1603
1670
|
name,
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
generics: generics.join(", "),
|
|
1610
|
-
params: paramsSignature,
|
|
1611
|
-
JSDoc: { comments: buildOperationComments(node) },
|
|
1612
|
-
children: `
|
|
1671
|
+
export: true,
|
|
1672
|
+
generics: generics.join(", "),
|
|
1673
|
+
params: paramsSignature,
|
|
1674
|
+
JSDoc: { comments: buildOperationComments(node) },
|
|
1675
|
+
children: `
|
|
1613
1676
|
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
1614
1677
|
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
1615
1678
|
const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParamsCall})
|
|
@@ -1624,7 +1687,6 @@ function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, node, t
|
|
|
1624
1687
|
|
|
1625
1688
|
return queryResult
|
|
1626
1689
|
`
|
|
1627
|
-
})
|
|
1628
1690
|
});
|
|
1629
1691
|
}
|
|
1630
1692
|
// src/generators/infiniteQueryGenerator.tsx
|
|
@@ -1639,7 +1701,7 @@ const infiniteQueryGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
1639
1701
|
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
1640
1702
|
match(node, ctx) {
|
|
1641
1703
|
const operationNode = node;
|
|
1642
|
-
if (!
|
|
1704
|
+
if (!isOperation(operationNode)) return false;
|
|
1643
1705
|
const { query, mutation, infinite, hooks } = ctx.options;
|
|
1644
1706
|
const { isQuery, isMutation } = classifyOperation(operationNode, {
|
|
1645
1707
|
query,
|
|
@@ -1650,7 +1712,7 @@ const infiniteQueryGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
1650
1712
|
return matchesInfinite(operationNode, infiniteOptions);
|
|
1651
1713
|
},
|
|
1652
1714
|
operation(node, ctx) {
|
|
1653
|
-
if (!
|
|
1715
|
+
if (!isOperation(node)) return null;
|
|
1654
1716
|
const { resolver, root } = ctx;
|
|
1655
1717
|
const { output, query, infinite, client, group } = ctx.options;
|
|
1656
1718
|
const infiniteOptions = infinite && typeof infinite === "object" ? infinite : null;
|
|
@@ -1821,17 +1883,13 @@ function Mutation({ name, clientName, node, tsResolver, mutationKeyName, clientR
|
|
|
1821
1883
|
typedHeaders
|
|
1822
1884
|
});
|
|
1823
1885
|
const paramsSignature = declarationPrinter.print(paramsNode) ?? "";
|
|
1824
|
-
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.
|
|
1886
|
+
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.Function, {
|
|
1825
1887
|
name,
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
params: paramsSignature,
|
|
1832
|
-
JSDoc: { comments: buildOperationComments(node) },
|
|
1833
|
-
generics: ["TContext"],
|
|
1834
|
-
children: `
|
|
1888
|
+
export: true,
|
|
1889
|
+
params: paramsSignature,
|
|
1890
|
+
JSDoc: { comments: buildOperationComments(node) },
|
|
1891
|
+
generics: ["TContext"],
|
|
1892
|
+
children: `
|
|
1835
1893
|
const { mutation = {}, client: config = {} } = options ?? {}
|
|
1836
1894
|
const { client: queryClient, ...mutationOptions } = mutation;
|
|
1837
1895
|
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}()
|
|
@@ -1844,7 +1902,6 @@ function Mutation({ name, clientName, node, tsResolver, mutationKeyName, clientR
|
|
|
1844
1902
|
...mutationOptions
|
|
1845
1903
|
}, queryClient)
|
|
1846
1904
|
`
|
|
1847
|
-
})
|
|
1848
1905
|
});
|
|
1849
1906
|
}
|
|
1850
1907
|
// src/generators/mutationGenerator.tsx
|
|
@@ -1857,7 +1914,7 @@ const mutationGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
1857
1914
|
name: "vue-query-mutation",
|
|
1858
1915
|
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
1859
1916
|
operation(node, ctx) {
|
|
1860
|
-
if (!
|
|
1917
|
+
if (!isOperation(node)) return null;
|
|
1861
1918
|
const { resolver, root } = ctx;
|
|
1862
1919
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1863
1920
|
const { isMutation } = classifyOperation(node, {
|
|
@@ -1883,7 +1940,8 @@ const mutationGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
1883
1940
|
contractOp,
|
|
1884
1941
|
returnType: ctx.options.returnType
|
|
1885
1942
|
});
|
|
1886
|
-
const
|
|
1943
|
+
const groups = getRequestGroups(node);
|
|
1944
|
+
const hasRequestGroups = requestGroupOrder.some((key) => groups[key]);
|
|
1887
1945
|
return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(HookFile, {
|
|
1888
1946
|
hook,
|
|
1889
1947
|
imports: /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [hasRequestGroups && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
|
|
@@ -1932,7 +1990,7 @@ const queryGenerator = (0, _kubb_kit.defineGenerator)({
|
|
|
1932
1990
|
name: "vue-query",
|
|
1933
1991
|
renderer: _kubb_renderer_jsx.jsxRenderer,
|
|
1934
1992
|
operation(node, ctx) {
|
|
1935
|
-
if (!
|
|
1993
|
+
if (!isOperation(node)) return null;
|
|
1936
1994
|
const { resolver, root } = ctx;
|
|
1937
1995
|
const { output, query, mutation, client, group, hooks } = ctx.options;
|
|
1938
1996
|
const { isQuery, isMutation } = classifyOperation(node, {
|