@kubb/plugin-vue-query 5.13.0-canary.20261122T213936 → 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.js CHANGED
@@ -10,7 +10,7 @@ var compatibility = {
10
10
  "node": ">=22.22"
11
11
  };
12
12
  // package.json
13
- var version = "5.13.0-canary.20261122T213936";
13
+ var version = "5.13.0";
14
14
  // ../../internals/client/src/resolveClient.ts
15
15
  /**
16
16
  * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
@@ -900,8 +900,7 @@ function maybeRefOrGetter(type) {
900
900
  /**
901
901
  * Builds the grouped `{ path, query, body, headers, cookies }` parameter that mirrors the client
902
902
  * function signature. Only the groups the operation carries are emitted, typed from the
903
- * operation's `Options`. `keys` narrows the emitted groups, used by the query key which
904
- * never carries `headers`.
903
+ * operation's `Options`. `keys` narrows the emitted groups.
905
904
  *
906
905
  * By default the whole group is typed as the single `Options` reference. When
907
906
  * `memberTypeWrapper` is set, each group is emitted as its own member typed from the matching
@@ -909,7 +908,7 @@ function maybeRefOrGetter(type) {
909
908
  * `MaybeRefOrGetter` per group.
910
909
  */
911
910
  function buildGroupedRequestParam(node, options) {
912
- const { resolver, keys = requestGroupOrder, memberTypeWrapper, withContentType = false } = options;
911
+ const { resolver, keys = requestGroupOrder, memberTypeWrapper, optionalHeaders = false, withContentType = false } = options;
913
912
  const groups = getRequestGroups(node);
914
913
  const names = keys.filter((key) => groups[key]);
915
914
  if (names.length === 0) return null;
@@ -917,7 +916,7 @@ function buildGroupedRequestParam(node, options) {
917
916
  path: groups.required.path,
918
917
  query: groups.required.query,
919
918
  body: groups.body,
920
- headers: groups.required.headers,
919
+ headers: !optionalHeaders && groups.required.headers,
921
920
  cookies: false
922
921
  };
923
922
  const isOptional = names.every((name) => !requiredByGroup[name]);
@@ -927,8 +926,9 @@ function buildGroupedRequestParam(node, options) {
927
926
  type: optionsName,
928
927
  optional: false
929
928
  });
930
- const omittedKeys = requestGroupOrder.filter((key) => !keys.includes(key) && (key !== "cookies" || groups.cookies));
929
+ const omittedKeys = requestGroupOrder.filter((key) => (!keys.includes(key) || optionalHeaders && key === "headers" && !groups.headers) && (key !== "cookies" || groups.cookies));
931
930
  const optionsType = omittedKeys.length > 0 ? `Omit<${optionsName}, ${omittedKeys.map((key) => `'${key}'`).join(" | ")}>` : optionsName;
931
+ const paramType = optionalHeaders && names.includes("headers") ? `Omit<${optionsType}, 'headers'> & { headers?: ${optionsType}['headers'] }` : optionsType;
932
932
  if (memberTypeWrapper) {
933
933
  const members = names.map((name) => ({
934
934
  name,
@@ -944,7 +944,7 @@ function buildGroupedRequestParam(node, options) {
944
944
  }
945
945
  return createFunctionParameter({
946
946
  name: createObjectBindingPattern({ elements: names.map((name) => ({ name })) }),
947
- type: optionsType,
947
+ type: paramType,
948
948
  optional: false,
949
949
  ...isOptional ? { default: "{}" } : {}
950
950
  });
@@ -1179,27 +1179,26 @@ function getDefaultPageParamsWarning(node, infinite) {
1179
1179
  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.`;
1180
1180
  }
1181
1181
  /**
1182
- * The request groups a query key is built from, matching `buildQueryKeyParams`. Headers are
1183
- * deliberately absent: they do not identify a cache entry, so the key factory takes no parameter
1184
- * for an operation that only carries headers. Cookies are left out too: they often hold a session token, and a query key
1185
- * is stored in SSR payloads, persisted caches, and devtools.
1182
+ * The request groups available to a query key transformer. Headers are available for custom keys
1183
+ * but excluded from the default key. Cookies stay excluded.
1186
1184
  */
1187
1185
  const queryKeyGroupOrder = [
1188
1186
  "path",
1189
1187
  "query",
1190
- "body"
1188
+ "body",
1189
+ "headers"
1191
1190
  ];
1192
1191
  /**
1193
- * Build QueryKey params as the grouped `{ path, query, body }` object (NO headers, NO cookies, NO config),
1194
- * typed from the operation's `Options` minus `url`. The query key transformer reads the
1195
- * grouped `path`/`query`/`body` bindings.
1192
+ * Builds query key bindings for path, query, body, and optional headers. Custom transformers
1193
+ * can reference `headers` in returned code without changing the default key.
1196
1194
  */
1197
1195
  function buildQueryKeyParams(node, options) {
1198
1196
  const { resolver, memberTypeWrapper } = options;
1199
1197
  const groupedParam = buildGroupedRequestParam(node, {
1200
1198
  resolver,
1201
1199
  keys: queryKeyGroupOrder,
1202
- memberTypeWrapper
1200
+ memberTypeWrapper,
1201
+ optionalHeaders: true
1203
1202
  });
1204
1203
  return createFunctionParameters({ params: groupedParam ? [groupedParam] : [] });
1205
1204
  }