@kubb/plugin-react-query 5.9.0 → 5.9.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 +33 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/kubb-extension.json +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -85,12 +85,18 @@ function getPrimarySuccessContentType(node) {
|
|
|
85
85
|
return contentTypes[0].split(";")[0].trim().toLowerCase();
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
88
|
+
* The `text/event-stream` content of the primary success response, when it is the only content type. A response that also
|
|
89
|
+
* declares another type stays a normal call with its query hooks.
|
|
90
|
+
*/
|
|
91
|
+
function getEventStreamContent(node) {
|
|
92
|
+
return getPrimarySuccessContentType(node) === "text/event-stream" ? getPrimarySuccessResponse(node)?.content?.[0] : void 0;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Whether an operation streams its primary success response as Server-Sent Events (`text/event-stream`). The client
|
|
96
|
+
* generator uses this to return a typed event stream instead of a one-shot `RequestResult`.
|
|
91
97
|
*/
|
|
92
98
|
function isEventStream(node) {
|
|
93
|
-
return
|
|
99
|
+
return getEventStreamContent(node) !== void 0;
|
|
94
100
|
}
|
|
95
101
|
const requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`;
|
|
96
102
|
function buildRequestConfigType(node) {
|
|
@@ -158,6 +164,22 @@ function buildOperationComments(node, options = {}) {
|
|
|
158
164
|
}
|
|
159
165
|
const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
160
166
|
/**
|
|
167
|
+
* An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
|
|
168
|
+
* per property, typed and serialized like any other.
|
|
169
|
+
* Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
|
|
170
|
+
*/
|
|
171
|
+
function spreadQuerystring(param) {
|
|
172
|
+
const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
|
|
173
|
+
const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
|
|
174
|
+
if (schema?.type !== "object" || !formEncoded) return [param];
|
|
175
|
+
return schema.properties.map((property) => ast.factory.createParameter({
|
|
176
|
+
name: property.name,
|
|
177
|
+
in: "query",
|
|
178
|
+
schema: property.schema,
|
|
179
|
+
required: param.required && property.required
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
161
183
|
* Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
|
|
162
184
|
* group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
|
|
163
185
|
* (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
|
|
@@ -166,17 +188,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
|
|
|
166
188
|
function getOperationParameters(node) {
|
|
167
189
|
const cached = operationParameterGroupsByNode.get(node);
|
|
168
190
|
if (cached) return cached;
|
|
169
|
-
const
|
|
191
|
+
const dedupe = (params) => {
|
|
170
192
|
const seen = /* @__PURE__ */ new Set();
|
|
171
|
-
return
|
|
172
|
-
if (
|
|
193
|
+
return params.filter((param) => {
|
|
194
|
+
if (seen.has(param.name)) return false;
|
|
173
195
|
seen.add(param.name);
|
|
174
196
|
return true;
|
|
175
197
|
});
|
|
176
198
|
};
|
|
199
|
+
const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
|
|
177
200
|
const groups = {
|
|
178
201
|
path: group("path"),
|
|
179
|
-
query: group("query"),
|
|
202
|
+
query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
|
|
180
203
|
header: group("header"),
|
|
181
204
|
cookie: group("cookie")
|
|
182
205
|
};
|
|
@@ -479,11 +502,11 @@ function createGroupConfig(group) {
|
|
|
479
502
|
}
|
|
480
503
|
// kubb-extension.json
|
|
481
504
|
var compatibility = {
|
|
482
|
-
"kubb": ">=5.
|
|
505
|
+
"kubb": ">=5.16.0",
|
|
483
506
|
"node": ">=22.22"
|
|
484
507
|
};
|
|
485
508
|
// package.json
|
|
486
|
-
var version = "5.9.
|
|
509
|
+
var version = "5.9.1";
|
|
487
510
|
// ../../internals/client/src/resolveOperationTypes.ts
|
|
488
511
|
/**
|
|
489
512
|
* A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`
|