@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 CHANGED
@@ -112,12 +112,18 @@ function getPrimarySuccessContentType(node) {
112
112
  return contentTypes[0].split(";")[0].trim().toLowerCase();
113
113
  }
114
114
  /**
115
- * Whether an operation streams its primary success response as Server-Sent Events
116
- * (`text/event-stream`). The client generator uses this to return a typed event stream instead of a
117
- * one-shot `RequestResult`.
115
+ * The `text/event-stream` content of the primary success response, when it is the only content type. A response that also
116
+ * declares another type stays a normal call with its query hooks.
117
+ */
118
+ function getEventStreamContent(node) {
119
+ return getPrimarySuccessContentType(node) === "text/event-stream" ? getPrimarySuccessResponse(node)?.content?.[0] : void 0;
120
+ }
121
+ /**
122
+ * Whether an operation streams its primary success response as Server-Sent Events (`text/event-stream`). The client
123
+ * generator uses this to return a typed event stream instead of a one-shot `RequestResult`.
118
124
  */
119
125
  function isEventStream(node) {
120
- return getPrimarySuccessContentType(node) === "text/event-stream";
126
+ return getEventStreamContent(node) !== void 0;
121
127
  }
122
128
  const requestConfigBaseType = `Partial<Omit<RequestConfig, 'path' | 'query' | 'body' | 'headers' | 'url'>>`;
123
129
  function buildRequestConfigType(node) {
@@ -185,6 +191,22 @@ function buildOperationComments(node, options = {}) {
185
191
  }
186
192
  const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
187
193
  /**
194
+ * An OpenAPI 3.2 `querystring` parameter is the whole query string, so a form-encoded object becomes one query parameter
195
+ * per property, typed and serialized like any other.
196
+ * Another content type, such as JSON, stays one parameter named after it, and the runtime sends its value as the whole query string.
197
+ */
198
+ function spreadQuerystring(param) {
199
+ const schema = param.schema.type === "ref" ? param.schema.schema : param.schema;
200
+ const formEncoded = !param.contentType || param.contentType.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded";
201
+ if (schema?.type !== "object" || !formEncoded) return [param];
202
+ return schema.properties.map((property) => _kubb_kit.ast.factory.createParameter({
203
+ name: property.name,
204
+ in: "query",
205
+ schema: property.schema,
206
+ required: param.required && property.required
207
+ }));
208
+ }
209
+ /**
188
210
  * Groups an operation's parameters by location (`path`/`query`/`header`/`cookie`), deduping each
189
211
  * group by name. Every plugin generator visiting the same `OperationNode` shares one AST instance
190
212
  * (see `KubbDriver`), so the result is cached per node to avoid re-filtering and re-deduping the
@@ -193,17 +215,18 @@ const operationParameterGroupsByNode = /* @__PURE__ */ new WeakMap();
193
215
  function getOperationParameters(node) {
194
216
  const cached = operationParameterGroupsByNode.get(node);
195
217
  if (cached) return cached;
196
- const group = (location) => {
218
+ const dedupe = (params) => {
197
219
  const seen = /* @__PURE__ */ new Set();
198
- return node.parameters.filter((param) => {
199
- if (param.in !== location || seen.has(param.name)) return false;
220
+ return params.filter((param) => {
221
+ if (seen.has(param.name)) return false;
200
222
  seen.add(param.name);
201
223
  return true;
202
224
  });
203
225
  };
226
+ const group = (location) => dedupe(node.parameters.filter((param) => param.in === location));
204
227
  const groups = {
205
228
  path: group("path"),
206
- query: group("query"),
229
+ query: dedupe([...group("query"), ...group("querystring").flatMap(spreadQuerystring)]),
207
230
  header: group("header"),
208
231
  cookie: group("cookie")
209
232
  };
@@ -506,11 +529,11 @@ function createGroupConfig(group) {
506
529
  }
507
530
  // kubb-extension.json
508
531
  var compatibility = {
509
- "kubb": ">=5.14.6",
532
+ "kubb": ">=5.16.0",
510
533
  "node": ">=22.22"
511
534
  };
512
535
  // package.json
513
- var version = "5.9.0";
536
+ var version = "5.9.1";
514
537
  // ../../internals/client/src/resolveOperationTypes.ts
515
538
  /**
516
539
  * A `plugin-ts` shaped resolver whose operation type names point at the types `pluginZod({ inferred })`