@kubb/plugin-vue-query 5.13.0-canary.20261122T212521 → 5.13.0

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
@@ -36,7 +36,7 @@ var compatibility = {
36
36
  "node": ">=22.22"
37
37
  };
38
38
  // package.json
39
- var version = "5.13.0-canary.20261122T212521";
39
+ var version = "5.13.0";
40
40
  // ../../internals/client/src/resolveClient.ts
41
41
  /**
42
42
  * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
@@ -926,8 +926,7 @@ function maybeRefOrGetter(type) {
926
926
  /**
927
927
  * Builds the grouped `{ path, query, body, headers, cookies }` parameter that mirrors the client
928
928
  * function signature. Only the groups the operation carries are emitted, typed from the
929
- * operation's `Options`. `keys` narrows the emitted groups, used by the query key which
930
- * never carries `headers`.
929
+ * operation's `Options`. `keys` narrows the emitted groups.
931
930
  *
932
931
  * By default the whole group is typed as the single `Options` reference. When
933
932
  * `memberTypeWrapper` is set, each group is emitted as its own member typed from the matching
@@ -935,7 +934,7 @@ function maybeRefOrGetter(type) {
935
934
  * `MaybeRefOrGetter` per group.
936
935
  */
937
936
  function buildGroupedRequestParam(node, options) {
938
- const { resolver, keys = requestGroupOrder, memberTypeWrapper, withContentType = false } = options;
937
+ const { resolver, keys = requestGroupOrder, memberTypeWrapper, optionalHeaders = false, withContentType = false } = options;
939
938
  const groups = getRequestGroups(node);
940
939
  const names = keys.filter((key) => groups[key]);
941
940
  if (names.length === 0) return null;
@@ -943,7 +942,7 @@ function buildGroupedRequestParam(node, options) {
943
942
  path: groups.required.path,
944
943
  query: groups.required.query,
945
944
  body: groups.body,
946
- headers: groups.required.headers,
945
+ headers: !optionalHeaders && groups.required.headers,
947
946
  cookies: false
948
947
  };
949
948
  const isOptional = names.every((name) => !requiredByGroup[name]);
@@ -953,8 +952,9 @@ function buildGroupedRequestParam(node, options) {
953
952
  type: optionsName,
954
953
  optional: false
955
954
  });
956
- const omittedKeys = requestGroupOrder.filter((key) => !keys.includes(key) && (key !== "cookies" || groups.cookies));
955
+ const omittedKeys = requestGroupOrder.filter((key) => (!keys.includes(key) || optionalHeaders && key === "headers" && !groups.headers) && (key !== "cookies" || groups.cookies));
957
956
  const optionsType = omittedKeys.length > 0 ? `Omit<${optionsName}, ${omittedKeys.map((key) => `'${key}'`).join(" | ")}>` : optionsName;
957
+ const paramType = optionalHeaders && names.includes("headers") ? `Omit<${optionsType}, 'headers'> & { headers?: ${optionsType}['headers'] }` : optionsType;
958
958
  if (memberTypeWrapper) {
959
959
  const members = names.map((name) => ({
960
960
  name,
@@ -970,7 +970,7 @@ function buildGroupedRequestParam(node, options) {
970
970
  }
971
971
  return (0, _kubb_plugin_ts.createFunctionParameter)({
972
972
  name: (0, _kubb_plugin_ts.createObjectBindingPattern)({ elements: names.map((name) => ({ name })) }),
973
- type: optionsType,
973
+ type: paramType,
974
974
  optional: false,
975
975
  ...isOptional ? { default: "{}" } : {}
976
976
  });
@@ -1205,27 +1205,26 @@ function getDefaultPageParamsWarning(node, infinite) {
1205
1205
  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.`;
1206
1206
  }
1207
1207
  /**
1208
- * The request groups a query key is built from, matching `buildQueryKeyParams`. Headers are
1209
- * deliberately absent: they do not identify a cache entry, so the key factory takes no parameter
1210
- * for an operation that only carries headers. Cookies are left out too: they often hold a session token, and a query key
1211
- * is stored in SSR payloads, persisted caches, and devtools.
1208
+ * The request groups available to a query key transformer. Headers are available for custom keys
1209
+ * but excluded from the default key. Cookies stay excluded.
1212
1210
  */
1213
1211
  const queryKeyGroupOrder = [
1214
1212
  "path",
1215
1213
  "query",
1216
- "body"
1214
+ "body",
1215
+ "headers"
1217
1216
  ];
1218
1217
  /**
1219
- * Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO cookies, NO config),
1220
- * typed from the operation's `Options` minus `url`. The query key transformer reads the
1221
- * grouped `path`/`query`/`body` bindings.
1218
+ * Builds query key bindings for path, query, body, and optional headers. Custom transformers
1219
+ * can reference `headers` in returned code without changing the default key.
1222
1220
  */
1223
1221
  function buildQueryKeyParams(node, options) {
1224
1222
  const { resolver, memberTypeWrapper } = options;
1225
1223
  const groupedParam = buildGroupedRequestParam(node, {
1226
1224
  resolver,
1227
1225
  keys: queryKeyGroupOrder,
1228
- memberTypeWrapper
1226
+ memberTypeWrapper,
1227
+ optionalHeaders: true
1229
1228
  });
1230
1229
  return (0, _kubb_plugin_ts.createFunctionParameters)({ params: groupedParam ? [groupedParam] : [] });
1231
1230
  }