openapi-typesafe-react-query 1.0.0-rc.6 → 1.0.0-rc.8

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/CHANGELOG.md CHANGED
@@ -2,6 +2,44 @@
2
2
 
3
3
  This package is a fork of `openapi-react-query`. The entries above `0.5.4` are releases of openapi-typesafe-react-query; `0.5.4` and the entries below it are the upstream history up to the fork point (upstream commit `d46a319a`), with `openapi-react-query` versions.
4
4
 
5
+ ## 1.0.0-rc.8
6
+
7
+ ### Patch Changes
8
+
9
+ - [#104](https://github.com/openapi-typesafe/openapi-typesafe/pull/104) [`9522871`](https://github.com/openapi-typesafe/openapi-typesafe/commit/9522871194184d8a7c9f2f556a40702a5d1ff5f3) Thanks [@fedorello](https://github.com/fedorello)! - A body that is not an object literal, such as an instance of a form class, an object made with
10
+ `Object.create` or one from another realm, is now part of the query key by the members the fetch
11
+ client sends, with a `File` in it by its type, size and name. Before, such a multipart body held
12
+ every file as `{}`, so a query for a second file showed the cached result of the first.
13
+
14
+ - [#104](https://github.com/openapi-typesafe/openapi-typesafe/pull/104) [`9522871`](https://github.com/openapi-typesafe/openapi-typesafe/commit/9522871194184d8a7c9f2f556a40702a5d1ff5f3) Thanks [@fedorello](https://github.com/fedorello)! - A React Native `FormData` body is now part of the query key by its fields, the parts its
15
+ `getParts` gives (each field's name and text, or the `uri`, `name` and `type` of a file). React Native's FormData has no
16
+ `entries`, so before every such body of one path had the same key and showed the same result.
17
+
18
+ - [#104](https://github.com/openapi-typesafe/openapi-typesafe/pull/104) [`9522871`](https://github.com/openapi-typesafe/openapi-typesafe/commit/9522871194184d8a7c9f2f556a40702a5d1ff5f3) Thanks [@fedorello](https://github.com/fedorello)! - `useInfiniteQuery` with a `pageParamName` other than `"cursor"` now has it in its query key, as
19
+ `[method, path, init, "infinite", { pageParamName }]`. Two infinite queries that differed only in
20
+ `pageParamName` send different requests but shared one cache entry, so the second showed the
21
+ pages of the first. Keys of queries with the default name stay the same.
22
+ - Updated dependencies [[`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721), [`091b864`](https://github.com/openapi-typesafe/openapi-typesafe/commit/091b864cdb6dd9e1ff5810d4d44cebee8a01a721)]:
23
+ - openapi-typesafe-fetch@1.0.0-rc.8
24
+
25
+ ## 1.0.0-rc.7
26
+
27
+ ### Patch Changes
28
+
29
+ - [#97](https://github.com/openapi-typesafe/openapi-typesafe/pull/97) [`d2bac1c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d2bac1c48c46b8cc39f516645c2fef1cfe9473db) Thanks [@fedorello](https://github.com/fedorello)! - An init whose `params` or `headers` send nothing now has the query key of no init:
30
+ `{ params: {} }`, `{ params: { query: { cursor: undefined } } }`, `{ params: { query: filters } }`
31
+ with `filters` undefined, and `{ headers: { "X-Tenant": undefined } }`. Each had its own key, so
32
+ `setQueryData`, `getQueryData` and server prefetches of one were not seen by the others, and each
33
+ fetched again. `null`, `[]` and `{}` parameter values still count, and so does an empty JSON body.
34
+
35
+ - [#97](https://github.com/openapi-typesafe/openapi-typesafe/pull/97) [`d2bac1c`](https://github.com/openapi-typesafe/openapi-typesafe/commit/d2bac1c48c46b8cc39f516645c2fef1cfe9473db) Thanks [@fedorello](https://github.com/fedorello)! - A `File`, `Blob`, bytes, `FormData` or `URLSearchParams` value inside an object or array body,
36
+ such as a multipart body written as `{ image: file }`, is now part of the query key by its
37
+ content (a file by its type, size and name). Every file had the same key before, so a query for
38
+ a second file showed the cached result of the first. The key names the kinds of such values in
39
+ `bodyType`, by member name or index (`{ image: "Blob" }`).
40
+ - Updated dependencies [[`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5), [`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5), [`171fa71`](https://github.com/openapi-typesafe/openapi-typesafe/commit/171fa71311107e4e26a9ae7a62b431662fb13de5)]:
41
+ - openapi-typesafe-fetch@1.0.0-rc.7
42
+
5
43
  ## 1.0.0-rc.6
6
44
 
7
45
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # openapi-typesafe-react-query
2
2
 
3
- openapi-typesafe-react-query is a small, type-safe wrapper (about 2 kB minified, 1 kB gzipped) around [@tanstack/react-query](https://tanstack.com/query/latest/docs/framework/react/overview) to work with OpenAPI schema.
3
+ openapi-typesafe-react-query is a small, type-safe wrapper (about 3.8 kB minified, 1.7 kB gzipped) around [@tanstack/react-query](https://tanstack.com/query/latest/docs/framework/react/overview) to work with OpenAPI schema.
4
4
 
5
5
  It works by using [openapi-typesafe-fetch](../openapi-typesafe-fetch) and [openapi-typesafe](../openapi-typesafe) so URLs, parameters, request bodies and responses are checked against your schema, with no manual types,
6
6
  no `any` and no `as` assertions.
package/dist/index.cjs CHANGED
@@ -10,6 +10,61 @@ function isClass(value, name) {
10
10
  const type = globalThis[name];
11
11
  return typeof type === "function" && value instanceof type || Object.prototype.toString.call(value).slice(TYPE_TAG_START, TYPE_TAG_END) === name;
12
12
  }
13
+ function blobKey(blob) {
14
+ const { name } = blob;
15
+ return { type: blob.type, size: blob.size, name };
16
+ }
17
+ function formDataKey(form) {
18
+ if (typeof form.entries === "function") {
19
+ return Array.from(form.entries(), ([name, value]) => [
20
+ name,
21
+ typeof value === "string" ? value : blobKey(value)
22
+ ]);
23
+ }
24
+ return form.getParts?.() ?? [];
25
+ }
26
+ function valueBytes(value) {
27
+ if (ArrayBuffer.isView(value)) {
28
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
29
+ }
30
+ return isClass(value, "ArrayBuffer") ? new Uint8Array(value) : null;
31
+ }
32
+ function rawValueKey(value) {
33
+ if (isClass(value, "URLSearchParams")) {
34
+ return { body: String(value), bodyType: "URLSearchParams" };
35
+ }
36
+ if (isClass(value, "FormData")) {
37
+ return { body: formDataKey(value), bodyType: "FormData" };
38
+ }
39
+ if (isClass(value, "Blob") || isClass(value, "File")) {
40
+ return { body: blobKey(value), bodyType: "Blob" };
41
+ }
42
+ const bytes = valueBytes(value);
43
+ return bytes === null ? void 0 : { body: Array.from(bytes), bodyType: "bytes" };
44
+ }
45
+ function membersKey(members) {
46
+ const body = Array.isArray(members) ? [] : {};
47
+ const kinds = {};
48
+ for (const [name, value] of Object.entries(members)) {
49
+ const member = bodyKey(value);
50
+ body[name] = member.body;
51
+ if (member.bodyType !== void 0) {
52
+ kinds[name] = member.bodyType;
53
+ }
54
+ }
55
+ return Object.keys(kinds).length === 0 ? { body } : { body, bodyType: kinds };
56
+ }
57
+ function bodyKey(body) {
58
+ if (typeof body !== "object" || body === null) {
59
+ return { body };
60
+ }
61
+ return rawValueKey(body) ?? (typeof body.toJSON === "function" ? { body } : membersKey(body));
62
+ }
63
+
64
+ function isPlainRecord(value) {
65
+ const prototype = typeof value === "object" && value !== null ? Object.getPrototypeOf(value) : void 0;
66
+ return prototype === Object.prototype || prototype === null;
67
+ }
13
68
  function plainHeaders(headers) {
14
69
  if (!(Symbol.iterator in headers)) {
15
70
  return headers;
@@ -22,60 +77,37 @@ function plainHeaders(headers) {
22
77
  }
23
78
  return record;
24
79
  }
25
- function blobKey(blob) {
26
- const { name } = blob;
27
- return { type: blob.type, size: blob.size, name };
80
+ function definedMembers(record) {
81
+ const members = Object.entries(record).filter(([, value]) => value !== void 0);
82
+ return members.length === 0 ? void 0 : Object.fromEntries(members);
28
83
  }
29
- function formDataKey(form) {
30
- if (typeof form.entries !== "function") {
31
- return [];
84
+ function paramsKey(params) {
85
+ if (!isPlainRecord(params)) {
86
+ return params;
32
87
  }
33
- return Array.from(form.entries(), ([name, value]) => [
34
- name,
35
- typeof value === "string" ? value : blobKey(value)
88
+ const records = Object.entries(params).map(([location, record]) => [
89
+ location,
90
+ isPlainRecord(record) ? definedMembers(record) : record
36
91
  ]);
92
+ return definedMembers(Object.fromEntries(records));
37
93
  }
38
- function bodyBytes(body) {
39
- if (ArrayBuffer.isView(body)) {
40
- return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
41
- }
42
- return isClass(body, "ArrayBuffer") ? new Uint8Array(body) : null;
43
- }
44
- function rawBodyKey(body) {
45
- if (typeof body !== "object" || body === null) {
46
- return void 0;
47
- }
48
- if (isClass(body, "URLSearchParams")) {
49
- return { body: String(body), bodyType: "URLSearchParams" };
50
- }
51
- if (isClass(body, "FormData")) {
52
- return { body: formDataKey(body), bodyType: "FormData" };
53
- }
54
- if (isClass(body, "Blob") || isClass(body, "File")) {
55
- return { body: blobKey(body), bodyType: "Blob" };
56
- }
57
- const bytes = bodyBytes(body);
58
- return bytes === null ? void 0 : { body: Array.from(bytes), bodyType: "bytes" };
59
- }
60
- function definedFields(fields) {
61
- return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== void 0));
94
+ function headersKey(headers) {
95
+ return typeof headers === "object" && headers !== null ? definedMembers(plainHeaders(headers)) : headers;
62
96
  }
63
97
  function queryKeyInit(init, client) {
64
98
  const { signal: _signal, ...rest } = init ?? {};
65
- const keyInit = definedFields(rest);
66
- if (typeof rest.headers === "object" && rest.headers !== null) {
67
- keyInit.headers = plainHeaders(rest.headers);
68
- }
69
- const rawBody = rawBodyKey(rest.body);
70
- if (rawBody !== void 0) {
71
- Object.assign(keyInit, rawBody);
72
- }
99
+ const keyInit = {
100
+ ...rest,
101
+ params: paramsKey(rest.params),
102
+ headers: headersKey(rest.headers),
103
+ ...rest.body === void 0 ? {} : bodyKey(rest.body)
104
+ };
73
105
  if (client.keyScope !== void 0) {
74
106
  keyInit.keyScope = client.keyScope;
75
107
  } else if (!rest.baseUrl && client.baseUrl) {
76
108
  keyInit.baseUrl = client.baseUrl;
77
109
  }
78
- return Object.keys(keyInit).length === 0 ? void 0 : keyInit;
110
+ return definedMembers(keyInit);
79
111
  }
80
112
 
81
113
  const ABORT_EVENT = "abort";
@@ -139,6 +171,13 @@ function pageInit(init, { pageParamName, pageParam }) {
139
171
  const page = pageParam === void 0 ? {} : { [pageParamName]: pageParam };
140
172
  return { ...rest, params: { ...params, query: { ...params?.query, ...page } } };
141
173
  }
174
+ function infiniteQueryKey(queryKey, pageParamName) {
175
+ return [
176
+ ...queryKey,
177
+ INFINITE_QUERY_KEY_MARKER,
178
+ ...pageParamName === DEFAULT_PAGE_PARAM_NAME ? [] : [{ pageParamName }]
179
+ ];
180
+ }
142
181
  function createClient(client, { keyScope } = {}) {
143
182
  const keyClient = { baseUrl: client.baseUrl, keyScope };
144
183
  const fetchPage = async (method, path, init, signal) => {
@@ -188,7 +227,7 @@ function createClient(client, { keyScope } = {}) {
188
227
  const { queryKey } = queryOptions(method, path, init);
189
228
  return reactQuery.useInfiniteQuery(
190
229
  {
191
- queryKey: [...queryKey, INFINITE_QUERY_KEY_MARKER],
230
+ queryKey: infiniteQueryKey(queryKey, pageParamName),
192
231
  // An empty page stays `undefined`, as in upstream: TanStack Query rejects only
193
232
  // `undefined` query data, and the infinite query data is the `{ pages }` object.
194
233
  queryFn: ({ pageParam, signal }) => fetchPage(method, path, pageInit(init, { pageParamName, pageParam }), signal),
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/query-key.ts","../src/query-signal.ts","../src/index.ts"],"sourcesContent":["/**\n * The request part of a query key (ADR-046). TanStack Query hashes a key as JSON: a `Headers`\n * object or a list of header pairs hashed as `{}` or by its order, and so did a FormData, a Blob,\n * an ArrayBuffer or a URLSearchParams body. Two requests that differed in them shared one cache\n * entry, and the `queryFn` of that entry sent the request of the first. Two clients with\n * different base URLs shared entries too. The key's init holds the headers and such a body as\n * plain values, and the base URL the request goes to or the client's key scope, so the key names\n * what was fetched.\n */\n\n/** Headers as a plain object, which TanStack Query hashes by its names and values. */\ntype HeadersRecord = Readonly<Record<string, unknown>>;\n\n/** What the key takes from the fetch client and the options of `createClient`. */\nexport interface KeyClient {\n /** The fetch client's base URL, `\"\"` without one. */\n readonly baseUrl: string;\n /** The name of the API in every key, in place of the base URL. */\n readonly keyScope?: string | undefined;\n}\n\n/** `[object Name]`: the type tag is between these indexes of `Object.prototype.toString`. */\nconst TYPE_TAG_START = \"[object \".length;\nconst TYPE_TAG_END = -1;\n\n/**\n * Whether a value is of the class `name`: an instance of this realm's global class of that name\n * (React Native's classes have no type tag), or a value with its type tag (a class of another\n * realm or of the `undici` package), as the fetch client tells bodies (ADR-030).\n */\nfunction isClass(value: object, name: string): boolean {\n const type = (globalThis as Record<string, unknown>)[name];\n return (\n (typeof type === \"function\" && value instanceof type) ||\n Object.prototype.toString.call(value).slice(TYPE_TAG_START, TYPE_TAG_END) === name\n );\n}\n\n/**\n * The headers of an init as a plain object. A `Headers` object and a list of pairs, which are both\n * iterable, become the names and values the request sends: names in lowercase, a repeated one\n * joined with `, `, as `Headers` writes them. They are read without `Headers`, which threw for an\n * invalid name or value while the component rendered; the request reports it as a query error. A\n * plain object stays as it is, since its `null` and array values mean more than a string.\n */\nfunction plainHeaders(headers: object): HeadersRecord {\n if (!(Symbol.iterator in headers)) {\n return headers as HeadersRecord;\n }\n const record: Record<string, string> = {};\n for (const pair of headers as Iterable<unknown>) {\n const [name, value] = Array.from(pair as ArrayLike<unknown>);\n const key = String(name).toLowerCase();\n record[key] = key in record ? `${record[key]}, ${String(value)}` : String(value);\n }\n return record;\n}\n\n/**\n * A Blob or a File in a key: its type, size, and the name of a File. Its bytes cannot be read while\n * the component renders, so two Blobs of the same type and size share an entry. The date of a File\n * is left out: `FormData.append` and `new File` set it to the current time, so a body built while\n * rendering got a new key, and a new request, on every render.\n */\nfunction blobKey(blob: Blob): object {\n const { name } = blob as Partial<File>;\n return { type: blob.type, size: blob.size, name };\n}\n\n/** The fields of a FormData in a key, in order, with a file as `blobKey`. */\nfunction formDataKey(form: FormData): unknown[] {\n // React Native's FormData has no `entries`, so its fields cannot be read.\n if (typeof form.entries !== \"function\") {\n return [];\n }\n return Array.from(form.entries(), ([name, value]) => [\n name,\n typeof value === \"string\" ? value : blobKey(value),\n ]);\n}\n\n/** The bytes of an ArrayBuffer or a typed array, or null for another value. */\nfunction bodyBytes(body: object): Uint8Array | null {\n if (ArrayBuffer.isView(body)) {\n return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);\n }\n return isClass(body, \"ArrayBuffer\") ? new Uint8Array(body as ArrayBuffer) : null;\n}\n\n/** A body that JSON cannot hold, as a value TanStack Query hashes, and the name of its kind. */\ninterface RawBodyKey {\n readonly body: unknown;\n readonly bodyType: \"URLSearchParams\" | \"FormData\" | \"Blob\" | \"bytes\";\n}\n\n/**\n * A body that JSON cannot hold by its content: a URLSearchParams as its text, a FormData as its\n * fields, a Blob as `blobKey` and bytes as their numbers. Undefined for any other body.\n */\nfunction rawBodyKey(body: unknown): RawBodyKey | undefined {\n if (typeof body !== \"object\" || body === null) {\n return undefined;\n }\n if (isClass(body, \"URLSearchParams\")) {\n return { body: String(body), bodyType: \"URLSearchParams\" };\n }\n if (isClass(body, \"FormData\")) {\n return { body: formDataKey(body as FormData), bodyType: \"FormData\" };\n }\n if (isClass(body, \"Blob\") || isClass(body, \"File\")) {\n return { body: blobKey(body as Blob), bodyType: \"Blob\" };\n }\n const bytes = bodyBytes(body);\n return bytes === null ? undefined : { body: Array.from(bytes), bodyType: \"bytes\" };\n}\n\n/**\n * The init fields that are not `undefined`. A field set to `undefined` (`headers: token ? … :\n * undefined`) sends the same request as none, so it must not make the init count as not empty.\n */\nfunction definedFields(fields: object): Record<string, unknown> {\n return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));\n}\n\n/**\n * The init of a query key: the request init with its headers and body as plain values, and the\n * client's key scope, or its base URL when the init has none. The `signal` is left out: TanStack\n * Query gives each request its own. A body that JSON cannot hold also names its kind in\n * `bodyType`, a field no init has, so it never shares a key with a JSON body of the same content.\n * Undefined when nothing is left, so a call without an init and one with an empty init, or one\n * of only `undefined` fields, have the key `[method, path]`.\n */\nexport function queryKeyInit(init: unknown, client: KeyClient): object | undefined {\n const { signal: _signal, ...rest } = (init ?? {}) as {\n signal?: unknown;\n headers?: unknown;\n baseUrl?: unknown;\n body?: unknown;\n };\n const keyInit = definedFields(rest);\n if (typeof rest.headers === \"object\" && rest.headers !== null) {\n keyInit.headers = plainHeaders(rest.headers);\n }\n const rawBody = rawBodyKey(rest.body);\n if (rawBody !== undefined) {\n Object.assign(keyInit, rawBody);\n }\n if (client.keyScope !== undefined) {\n keyInit.keyScope = client.keyScope;\n } else if (!rest.baseUrl && client.baseUrl) {\n keyInit.baseUrl = client.baseUrl;\n }\n return Object.keys(keyInit).length === 0 ? undefined : keyInit;\n}\n","/**\n * The signal of a query's request. TanStack Query gives every request a signal, which it aborts\n * when the query is cancelled or no longer used; the init of the call may bring its own. The hooks\n * sent one of them: `useQuery` the call's, so a cancelled query kept its request, and\n * `useInfiniteQuery` TanStack's, so the call's signal did nothing. The request now stops when\n * either is aborted.\n */\n\n/** The init to send, and how to stop listening to the signals once the request has settled. */\nexport interface QueryRequest {\n readonly init: Record<string, unknown>;\n readonly release: () => void;\n}\n\nconst ABORT_EVENT = \"abort\";\n\nfunction withoutRelease(init: Record<string, unknown>): QueryRequest {\n return { init, release: () => undefined };\n}\n\n/** The init with a signal that aborts when the init's own signal or the query's does. */\nexport function withQuerySignal(init: unknown, querySignal: AbortSignal): QueryRequest {\n const { signal: ownSignal, ...rest } = (init ?? {}) as { signal?: AbortSignal | null };\n if (!ownSignal) {\n return withoutRelease({ ...rest, signal: querySignal });\n }\n const controller = new AbortController();\n const sources = [ownSignal, querySignal];\n const aborted = sources.find((source) => source.aborted);\n if (aborted !== undefined) {\n controller.abort(aborted.reason);\n return withoutRelease({ ...rest, signal: controller.signal });\n }\n const listeners = sources.map((source) => {\n const listener = () => controller.abort(source.reason);\n source.addEventListener(ABORT_EVENT, listener, { once: true });\n return () => source.removeEventListener(ABORT_EVENT, listener);\n });\n return {\n init: { ...rest, signal: controller.signal },\n release: () => {\n for (const remove of listeners) {\n remove();\n }\n },\n };\n}\n","import {\n type DataTag,\n type DefaultError,\n type DefinedUseQueryResult,\n type InfiniteData,\n type QueryClient,\n type QueryFunctionContext,\n type SkipToken,\n type UseInfiniteQueryOptions,\n type UseInfiniteQueryResult,\n type UseMutationOptions,\n type UseMutationResult,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useSuspenseQuery,\n} from \"@tanstack/react-query\";\nimport type {\n ClientMethod,\n DefaultParamsOption,\n Client as FetchClient,\n FetchResponse,\n MaybeOptionalInit,\n PathOperation,\n} from \"openapi-typesafe-fetch\";\n// The helper types come from the client, which declares them: types inferred from the hooks then\n// print the client's `helpers` entry, of a peer every user has, and not `openapi-typesafe-helpers`,\n// which Yarn PnP does not let a library reach (ADR-034).\nimport type {\n HttpMethod,\n MediaType,\n PathsWithMethod,\n RequiredKeysOf,\n} from \"openapi-typesafe-fetch/helpers\";\nimport { queryKeyInit } from \"./query-key.js\";\nimport { withQuerySignal } from \"./query-signal.js\";\n\n// Helper type to dynamically infer the type from the `select` property\ntype InferSelectReturnType<TData, TSelect> = TSelect extends (data: TData) => infer R ? R : TData;\n\n/**\n * Query data of a response type: a success without a body is `undefined` in the fetch client and\n * `null` in the query, as `queryFn` resolves it (upstream #2234, #2464).\n */\ntype QueryData<Data> = undefined extends Data ? Exclude<Data, undefined> | null : Data;\n\n/**\n * What the hooks throw when a request fails and the response has no error body: a non-OK status\n * with an empty body, a JSON `null` body, or one whose operation declares no content for it. The\n * fetch client gives `error: undefined` (or `null`) then; throwing that left `error` empty in\n * TanStack Query while its type said there was an error body. Tell it apart with\n * `isResponseError(error)`: `error instanceof Error` also matches a network or parse error. The\n * message names the status, not the URL, which can carry secrets.\n */\nexport interface ResponseError extends Error {\n readonly name: \"ResponseError\";\n /** The response that failed. */\n readonly response: Response;\n /** Its HTTP status, as `response.status`. */\n readonly status: number;\n}\n\n/**\n * The error of a hook: the error body of a failed response, a `ResponseError` when it has none, or\n * what the request threw before there was a response to read: a network error (`TypeError`), an\n * abort, a body that is not JSON (`SyntaxError`) or a middleware error. TanStack Query types that\n * last part as `DefaultError` (`Error` unless `Register` says otherwise; a registered `unknown`\n * makes the whole type `unknown`, as for TanStack's own hooks). `undefined` and `null` are left\n * out: a failed response without an error body throws a `ResponseError`.\n */\nexport type QueryError<ErrorBody> =\n | Exclude<ErrorBody, undefined | null>\n | ResponseError\n | DefaultError;\n\n/**\n * An object whose `queryKey` is tagged with the query's data and error types: the type that\n * TanStack Query 5.102 exports as `QueryKeyWithDataTag`, for the whole peer range. A named object\n * type, so the declarations of an exported `queryOptions` result print it by name. Spelled out,\n * the tag prints TanStack's `dataTagSymbol` keys, which a declaration file cannot import, and\n * the library's users get TS2304, or `any` cached data with `skipLibCheck`.\n */\nexport type QueryKeyWithDataTag<Key, Data, Error> = {\n queryKey: DataTag<Key, Data, Error>;\n};\n\ntype InitWithUnknowns<Init> = Init & { [key: string]: unknown };\n\n/**\n * The arguments after the path: the init, required when the operation requires a parameter or a\n * body, then `Rest`. The condition is openapi-react-query's, as `InitParam` of the fetch client\n * is openapi-fetch's (ADR-030, decision 2): TypeScript relates two conditional types only when\n * their `extends` types are the same, so a hook type copied from openapi-react-query takes these\n * hooks. For a union of inits, `MaybeOptionalInit` leaves out `undefined` when one is required,\n * so `Parameters<typeof $api.queryOptions>` still requires it then (upstream #2178).\n */\ntype InitArguments<Init, Rest extends unknown[]> =\n RequiredKeysOf<Init> extends never\n ? [InitWithUnknowns<Init>?, ...Rest]\n : [InitWithUnknowns<Init>, ...Rest];\n\n/**\n * The key of a query: the method, the path and the request. Its init is the init of the call with\n * the headers and the body as plain values, and the client's `keyScope`, or its `baseUrl` when the\n * init has none, so two requests never share a key; it is left out when nothing is left. Read a\n * query's key from `queryOptions(...).queryKey` rather than writing it out.\n */\nexport type QueryKey<\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init = MaybeOptionalInit<Paths[Path], Method>,\n> = Init extends undefined ? readonly [Method, Path] : readonly [Method, Path, Init];\n\n/**\n * The last element of an infinite query's key. `useQuery` and `useInfiniteQuery` cache different\n * data (`TData` and `InfiniteData<TData>`), so the same request must not share one key (upstream\n * #2184, ADR-022). A prefix such as `[method, path]` still matches both. Not exported: it is not\n * needed outside the package, and a named export is public API; `InfiniteQueryKey` types the key.\n */\nconst INFINITE_QUERY_KEY_MARKER = \"infinite\";\n\nexport type InfiniteQueryKey<\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER];\n\n/**\n * Whether the options give an `initialData` that is never `undefined`: a value, or a function that\n * never returns `undefined`. Then `data` is never `undefined` either, as for TanStack Query's own\n * `useQuery` with `DefinedInitialDataOptions`.\n */\ntype HasDefinedInitialData<Options> = Options extends { initialData: infer Initial }\n ? Initial extends (...args: never) => infer Returned\n ? undefined extends Returned\n ? false\n : true\n : undefined extends Initial\n ? false\n : true\n : false;\n\n/** The result of `useQuery`: its `data` is defined when the options give defined initial data. */\ntype QueryResult<Data, Error, Options> =\n HasDefinedInitialData<Options> extends true\n ? DefinedUseQueryResult<Data, Error>\n : UseQueryResult<Data, Error>;\n\n/**\n * A defined `initialData` of the options, in the type `queryOptions` returns, so TanStack Query's\n * `useQuery` takes the result as options with defined initial data. It is typed as the query data,\n * as TanStack's `DefinedInitialDataOptions` types it: the type of a literal such as `[{ id: 1 }]`\n * lacks the optional properties of the data, and TanStack's overload rejected it.\n */\ntype InitialDataOf<Options, Data> =\n HasDefinedInitialData<Options> extends true ? { initialData: Data | (() => Data) } : unknown;\n\nexport type QueryOptionsFunction<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n path: Path,\n ...[init, options]: InitArguments<Init, [Options?]>\n) => NoInfer<\n Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryFn\" | \"queryKey\"\n > &\n QueryKeyWithDataTag<\n QueryKey<Paths, Method, Path>,\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>\n > &\n InitialDataOf<Options, QueryData<Response[\"data\"]>> & {\n queryFn: Exclude<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >[\"queryFn\"],\n SkipToken | undefined\n >;\n }\n>;\n\nexport type UseQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n url: Path,\n ...[init, options, queryClient]: InitArguments<Init, [Options?, QueryClient?]>\n) => QueryResult<\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryError<Response[\"error\"]>,\n Options\n>;\n\n/**\n * The type of the page params: the initial one and the ones `getNextPageParam` and\n * `getPreviousPageParam` return (upstream #2458). It was `unknown`. It stays `unknown` when a\n * return type is untyped, so code that compiled still compiles (roadmap §3): TypeScript cannot\n * infer the return type of a callback that computes it from an unannotated `lastPageParam`,\n * whose type depends on that return type, and gives `never` or `unknown`.\n */\ntype PageParam<Initial, Next, Previous> =\n IsUntyped<Next> extends true\n ? unknown\n : [Previous] extends [NoPreviousPageParam]\n ? NullishToUnknown<Initial | NonNullable<Next>>\n : IsUntyped<Previous> extends true\n ? unknown\n : NullishToUnknown<Initial | NonNullable<Next> | NonNullable<Previous>>;\n\n/** The `Previous` type parameter when the options have no `getPreviousPageParam`. */\ndeclare const NO_PREVIOUS_PAGE_PARAM: unique symbol;\ntype NoPreviousPageParam = typeof NO_PREVIOUS_PAGE_PARAM;\n\ntype IsUntyped<T> = [T] extends [never] ? true : unknown extends T ? true : false;\n\n/** Only `undefined` or `null` names no type: a cursor API's `initialPageParam: undefined`. */\ntype NullishToUnknown<T> = [T] extends [undefined | null] ? unknown : T;\n\n/** Read only for the return type; `never` arguments add no inference for TanStack's page param. */\ntype PageParamFunction<Result> = (...args: never) => Result;\n\n/**\n * Inference sites of the page param types. Intersected before `Options`, so TanStack's own\n * inference in the implementation reads the full signatures of `Options`.\n */\ninterface PageParamSources<Initial, Next, Previous> {\n initialPageParam: Initial;\n getNextPageParam: PageParamFunction<Next>;\n getPreviousPageParam?: PageParamFunction<Previous>;\n}\n\n/**\n * `placeholderData` of `useInfiniteQuery`, with an `unknown` page param as before: TypeScript types\n * a `(previousData) => previousData` callback while it still infers the page param, so it got\n * `unknown` there and failed against the typed page param.\n */\ntype InfinitePlaceholderData<\n Data,\n Error,\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n> = UseInfiniteQueryOptions<\n Data,\n Error,\n InfiniteData<Data, unknown>,\n InfiniteQueryKey<Paths, Method, Path>,\n unknown\n>[\"placeholderData\"];\n\nexport type UseInfiniteQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseInfiniteQueryOptions<\n Response[\"data\"],\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<\n InfiniteData<Response[\"data\"], PageParam<Initial, Next, Previous>>,\n Options[\"select\"]\n >,\n InfiniteQueryKey<Paths, Method, Path>,\n PageParam<Initial, Next, Previous>\n >,\n \"queryKey\" | \"queryFn\" | \"placeholderData\"\n > & {\n placeholderData?: InfinitePlaceholderData<\n Response[\"data\"],\n QueryError<Response[\"error\"]>,\n Paths,\n Method,\n Path\n >;\n pageParamName?: string;\n },\n Initial = unknown,\n Next = never,\n Previous = NoPreviousPageParam,\n // biome-ignore lint/complexity/useMaxParams: public signature of 1.x (ADR-036)\n>(\n method: Method,\n url: Path,\n init: InitWithUnknowns<Init>,\n options: PageParamSources<Initial, Next, Previous> & Options,\n queryClient?: QueryClient,\n) => UseInfiniteQueryResult<\n InferSelectReturnType<\n InfiniteData<Response[\"data\"], PageParam<Initial, Next, Previous>>,\n Options[\"select\"]\n >,\n QueryError<Response[\"error\"]>\n>;\n\nexport type UseSuspenseQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseSuspenseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n url: Path,\n ...[init, options, queryClient]: InitArguments<Init, [Options?, QueryClient?]>\n) => UseSuspenseQueryResult<\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryError<Response[\"error\"]>\n>;\n\nexport type UseMutationMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n TOnMutateResult = unknown,\n>(\n method: Method,\n url: Path,\n options?: Omit<\n UseMutationOptions<Response[\"data\"], QueryError<Response[\"error\"]>, Init, TOnMutateResult>,\n \"mutationKey\" | \"mutationFn\"\n >,\n queryClient?: QueryClient,\n) => UseMutationResult<Response[\"data\"], QueryError<Response[\"error\"]>, Init, TOnMutateResult>;\n\nexport interface OpenapiQueryClient<Paths extends {}, Media extends MediaType = MediaType> {\n queryOptions: QueryOptionsFunction<Paths, Media>;\n useQuery: UseQueryMethod<Paths, Media>;\n useSuspenseQuery: UseSuspenseQueryMethod<Paths, Media>;\n useInfiniteQuery: UseInfiniteQueryMethod<Paths, Media>;\n useMutation: UseMutationMethod<Paths, Media>;\n}\n\nexport type MethodResponse<\n // biome-ignore lint/suspicious/noExplicitAny: matches a client of any paths, as upstream's\n CreatedClient extends OpenapiQueryClient<any, any>,\n Method extends HttpMethod,\n Path extends CreatedClient extends OpenapiQueryClient<infer Paths, infer _Media>\n ? PathsWithMethod<Paths, Method>\n : never,\n Options = object,\n> =\n CreatedClient extends OpenapiQueryClient<\n // biome-ignore lint/suspicious/noExplicitAny: unknown rejects the generated interfaces\n infer Paths extends { [key: string]: any },\n infer Media extends MediaType\n >\n ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>[\"data\"]>\n : never;\n\n/** The `name` of every `ResponseError`. */\nconst RESPONSE_ERROR_NAME = \"ResponseError\";\n\n/** The `ResponseError` of a failed response without an error body. */\nclass ResponseWithoutErrorBody extends Error implements ResponseError {\n override readonly name = RESPONSE_ERROR_NAME;\n readonly response: Response;\n readonly status: number;\n\n constructor(response: Response) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n super(`Request failed with status ${response.status}${statusText} and no error body`);\n this.response = response;\n this.status = response.status;\n }\n}\n\n/**\n * Whether `error` is the `ResponseError` of a failed response without an error body. It narrows a\n * hook's `error`, where `error instanceof Error` also matches network and parse errors. It checks\n * the `name`, not the class, so a `ResponseError` of another copy of this package (its CommonJS and\n * ES module builds loaded side by side) is one too. An error body from JSON is never an `Error`.\n */\nexport function isResponseError(error: unknown): error is ResponseError {\n return error instanceof Error && error.name === RESPONSE_ERROR_NAME;\n}\n\n/**\n * Throw the error of a failed fetch result. `if (error)` missed two failures: a non-OK response\n * with an empty body (`error` is `undefined`, upstream #2070, #2829) and a falsy error body such as\n * `0`. Without an error body a `ResponseError` is thrown, so the hooks' `error` is never\n * `undefined` (ADR-013, decision 3). A JSON `null` body is no error body either: thrown as is, it\n * left `error` `null` while the query's status was `\"error\"`.\n */\nfunction throwIfFailed(result: { error?: unknown; response: Response }): void {\n if (result.error !== undefined && result.error !== null) {\n throw result.error;\n }\n if (!result.response.ok) {\n throw new ResponseWithoutErrorBody(result.response);\n }\n}\n\n/** The query parameter that carries the page param unless `pageParamName` names another. */\nconst DEFAULT_PAGE_PARAM_NAME = \"cursor\";\n\ninterface PageRequest {\n readonly pageParamName: string;\n readonly pageParam: unknown;\n}\n\n/**\n * The request init of one page. An `undefined` page param (the first page with\n * `initialPageParam: undefined`) is left out instead of being sent as `0` (upstream #2715, #2340,\n * ADR-022), so a cursor API gets no cursor on the first page.\n */\nfunction pageInit(init: unknown, { pageParamName, pageParam }: PageRequest) {\n const { params, ...rest } = (init ?? {}) as { params?: { query?: DefaultParamsOption } };\n const page = pageParam === undefined ? {} : { [pageParamName]: pageParam };\n return { ...rest, params: { ...params, query: { ...params?.query, ...page } } };\n}\n\n/** Options of `createClient`. */\nexport interface CreateClientOptions {\n /**\n * The name of the API in every query key, in place of the fetch client's `baseUrl`. Give the\n * same name where the server and the browser reach one API by different URLs, so the browser\n * reads the data the server rendered with; give different names to clients of one base URL that\n * fetch different data, such as one per tenant header.\n */\n keyScope?: string;\n}\n\n/**\n * Hooks and query options for a fetch client. A `QueryClient` other than the one from the React\n * context is passed to each hook as its last argument; `createClient` does not take one.\n */\n// biome-ignore lint/complexity/noExcessiveLinesPerFunction: inherited, kept until 1.1 (ADR-036)\nexport default function createClient<Paths extends {}, Media extends MediaType = MediaType>(\n client: FetchClient<Paths, Media>,\n { keyScope }: CreateClientOptions = {},\n): OpenapiQueryClient<Paths, Media> {\n const keyClient = { baseUrl: client.baseUrl, keyScope };\n /**\n * Send one request of a query: the call's own init, with a signal that TanStack Query can abort.\n * The key only names the cache entry, as for `useInfiniteQuery`: a function in the init (a\n * `fetch`, a `middleware`) cannot be part of a key, so the request is read from the call.\n */\n const fetchPage = async <Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>>(\n method: Method,\n path: Path,\n init: unknown,\n signal: AbortSignal,\n ) => {\n const mth = method.toUpperCase() as Uppercase<typeof method>;\n const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;\n const request = withQuerySignal(init, signal);\n try {\n // The init is `unknown` here. An `any` init lets the call infer the generic response type\n // that `queryOptions` declares; a typed init makes TypeScript compare two unresolved\n // conditional types, which it cannot do.\n // biome-ignore lint/suspicious/noExplicitAny: see the comment above\n const result = await fn(path, request.init as any);\n throwIfFailed(result);\n return result.data;\n } finally {\n request.release();\n }\n };\n\n const queryOptions: QueryOptionsFunction<Paths, Media> = (method, path, ...[init, options]) => {\n const keyInit = queryKeyInit(init, keyClient);\n return {\n queryKey: (keyInit === undefined\n ? ([method, path] as const)\n : ([method, path, keyInit] as const)) as DataTag<\n QueryKey<Paths, typeof method, typeof path>,\n // biome-ignore lint/suspicious/noExplicitAny: the declared return type sets the data type\n any,\n // biome-ignore lint/suspicious/noExplicitAny: the declared return type sets the error type\n any\n >,\n // TanStack Query rejects `undefined` query data. The fetch client gives `undefined` for\n // every success without a body: a 204, `Content-Length: 0`, an empty chunked body, a HEAD\n // request (upstream #2234). A parsed body is never `undefined`, so this changes nothing else.\n queryFn: async ({ signal }: QueryFunctionContext) =>\n (await fetchPage(method, path, init, signal)) ?? null,\n // Without options, `Options` is its constraint, which has no `initialData` to keep.\n ...(options as typeof options & {}),\n // The declared type types a defined `initialData` as the query data, a conditional type of\n // the generic options that TypeScript cannot relate to the object; it is the same object.\n } as never;\n };\n\n return {\n queryOptions,\n useQuery: (method, path, ...[init, options, queryClient]) =>\n // TanStack Query's `useQuery` returns `DefinedUseQueryResult` for options with defined\n // `initialData`; while `Options` is generic it cannot pick that overload, and the declared\n // `QueryResult` gives the caller the same answer. Both are the same object at runtime.\n useQuery(\n queryOptions(method, path, init as InitWithUnknowns<typeof init>, options),\n queryClient,\n ) as never,\n useSuspenseQuery: (method, path, ...[init, options, queryClient]) =>\n useSuspenseQuery(\n queryOptions(method, path, init as InitWithUnknowns<typeof init>, options),\n queryClient,\n ),\n // biome-ignore lint/complexity/useMaxParams: public signature of 1.x (ADR-036)\n useInfiniteQuery: (method, path, init, options, queryClient) => {\n const { pageParamName = DEFAULT_PAGE_PARAM_NAME, placeholderData, ...restOptions } = options;\n const { queryKey } = queryOptions(method, path, init);\n return useInfiniteQuery(\n {\n queryKey: [...queryKey, INFINITE_QUERY_KEY_MARKER] as const,\n // An empty page stays `undefined`, as in upstream: TanStack Query rejects only\n // `undefined` query data, and the infinite query data is the `{ pages }` object.\n queryFn: ({ pageParam, signal }) =>\n fetchPage(method, path, pageInit(init, { pageParamName, pageParam }), signal),\n ...restOptions,\n // Typed with an `unknown` page param for the caller (`InfinitePlaceholderData`). TanStack\n // passes the previous data of this query, with its own page params, and takes it back.\n // biome-ignore lint/suspicious/noExplicitAny: TanStack's type carries its own page params\n placeholderData: placeholderData as any,\n },\n queryClient,\n );\n },\n useMutation: (method, path, options, queryClient) =>\n useMutation(\n {\n mutationKey: [method, path],\n mutationFn: async (init) => {\n const mth = method.toUpperCase() as Uppercase<typeof method>;\n const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;\n const result = await fn(path, init as InitWithUnknowns<typeof init>);\n throwIfFailed(result);\n // TanStack Query accepts `undefined` mutation data, so a success without a body stays\n // `undefined`, as in upstream; only query data needs `null` (upstream #2234). The cast\n // only bridges the generic types: `Response[\"data\"]` still has `undefined` for an\n // operation with a response without a body.\n const { data } = result;\n return data as Exclude<typeof data, undefined>;\n },\n ...options,\n },\n queryClient,\n ),\n };\n}\n"],"names":["useQuery","useSuspenseQuery","useInfiniteQuery","useMutation"],"mappings":";;;;;;AAsBA,MAAM,iBAAiB,UAAA,CAAW,MAAA;AAClC,MAAM,YAAA,GAAe,EAAA;AAOrB,SAAS,OAAA,CAAQ,OAAe,IAAA,EAAuB;AACrD,EAAA,MAAM,IAAA,GAAQ,WAAuC,IAAI,CAAA;AACzD,EAAA,OACG,OAAO,IAAA,KAAS,UAAA,IAAc,KAAA,YAAiB,QAChD,MAAA,CAAO,SAAA,CAAU,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA,CAAE,KAAA,CAAM,cAAA,EAAgB,YAAY,CAAA,KAAM,IAAA;AAElF;AASA,SAAS,aAAa,OAAA,EAAgC;AACpD,EAAA,IAAI,EAAE,MAAA,CAAO,QAAA,IAAY,OAAA,CAAA,EAAU;AACjC,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,MAAM,SAAiC,EAAC;AACxC,EAAA,KAAA,MAAW,QAAQ,OAAA,EAA8B;AAC/C,IAAA,MAAM,CAAC,IAAA,EAAM,KAAK,CAAA,GAAI,KAAA,CAAM,KAAK,IAA0B,CAAA;AAC3D,IAAA,MAAM,GAAA,GAAM,MAAA,CAAO,IAAI,CAA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A,GAAgB,uBAAA,EAAyB,eAAA,EAAiB,GAAG,aAAY,GAAI,OAAA;AACrF,MAAA,MAAM,EAAE,QAAA,EAAS,GAAI,YAAA,CAAa,MAAA,EAAQ,MAAM,IAAI,CAAA;AACpD,MAAA,OAAOC,2BAAA;AAAA,QACL;AAAA,UACE,QAAA,EAAU,CAAC,GAAG,QAAA,EAAU,yBAAyB,CAAA;AAAA;AAAA;AAAA,UAGjD,SAAS,CAAC,EAAE,SAAA,EAAW,MAAA,OACrB,SAAA,CAAU,MAAA,EAAQ,IAAA,EAAM,QAAA,CAAS,MAAM,EAAE,aAAA,EAAe,SAAA,EAAW,GAAG,MAAM,CAAA;AAAA,UAC9E,GAAG,WAAA;AAAA;AAAA;AAAA;AAAA,UAIH;AAAA,SACF;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,WAAA,EAAa,CAAC,MAAA,EAAQ,IAAA,EAAM,SAAS,WAAA,KACnCC,sBAAA;AAAA,MACE;AAAA,QACE,WAAA,EAAa,CAAC,MAAA,EAAQ,IAAI,CAAA;AAAA,QAC1B,UAAA,EAAY,OAAO,IAAA,KAAS;AAC1B,UAAA,MAAM,GAAA,GAAM,OAAO,WAAA,EAAY;AAC/B,UAAA,MAAM,EAAA,GAAK,OAAO,GAAG,CAAA;AACrB,UAAA,MAAM,MAAA,GAAS,MAAM,EAAA,CAAG,IAAA,EAAM,IAAqC,CAAA;AACnE,UAAA,aAAA,CAAc,MAAM,CAAA;AAKpB,UAAA,MAAM,EAAE,MAAK,GAAI,MAAA;AACjB,UAAA,OAAO,IAAA;AAAA,QACT,CAAA;AAAA,QACA,GAAG;AAAA,OACL;AAAA,MACA;AAAA;AACF,GACJ;AACF;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/body-key.ts","../src/query-key.ts","../src/query-signal.ts","../src/index.ts"],"sourcesContent":["/**\n * The body part of a query key (ADR-046). TanStack Query hashes a key as JSON, which writes a\n * FormData, a Blob, an ArrayBuffer or a URLSearchParams as `{}`, as the whole body or as a field\n * of an object body (a multipart body written as `{ image: file }`). The key holds each such value\n * by its content and names its kind beside the body, so the key names what is sent.\n */\n\n/** `[object Name]`: the type tag is between these indexes of `Object.prototype.toString`. */\nconst TYPE_TAG_START = \"[object \".length;\nconst TYPE_TAG_END = -1;\n\n/** The kind of a value that JSON cannot hold. */\ntype RawKind = \"URLSearchParams\" | \"FormData\" | \"Blob\" | \"bytes\";\n\n/**\n * The kinds of the values JSON cannot hold in a body: the kind of a body that is one, or, for an\n * object or an array body, the kinds of its members by their names or indexes, only where there\n * are some.\n */\ntype BodyKinds = RawKind | { readonly [member: string]: BodyKinds };\n\n/** A body as a value TanStack Query hashes, and the kinds of the values JSON cannot hold in it. */\nexport interface BodyKey {\n readonly body: unknown;\n readonly bodyType?: BodyKinds;\n}\n\n/**\n * Whether a value is of the class `name`: an instance of this realm's global class of that name\n * (React Native's classes have no type tag), or a value with its type tag (a class of another\n * realm or of the `undici` package), as the fetch client tells bodies (ADR-030).\n */\nfunction isClass(value: object, name: string): boolean {\n const type = (globalThis as Record<string, unknown>)[name];\n return (\n (typeof type === \"function\" && value instanceof type) ||\n Object.prototype.toString.call(value).slice(TYPE_TAG_START, TYPE_TAG_END) === name\n );\n}\n\n/**\n * A Blob or a File in a key: its type, size, and the name of a File. Its bytes cannot be read while\n * the component renders, so two Blobs of the same type and size share an entry. The date of a File\n * is left out: `FormData.append` and `new File` set it to the current time, so a body built while\n * rendering got a new key, and a new request, on every render.\n */\nfunction blobKey(blob: Blob): object {\n const { name } = blob as Partial<File>;\n return { type: blob.type, size: blob.size, name };\n}\n\n/**\n * React Native's FormData: `append`, `getAll` and `getParts`, and no `entries`. `getParts` gives\n * each field as a plain object: its `fieldName`, its `headers`, and its text as `string` or the\n * members of the appended file object (`uri`, `name`, `type`). Its network layer sends these.\n */\ninterface NativeFormData {\n readonly getParts?: () => readonly object[];\n}\n\n/**\n * The fields of a FormData in a key, in order, with a file as `blobKey`. React Native's FormData\n * has no `entries`; its fields are the parts of `getParts`, as they are what it sends. A FormData\n * with neither has no fields to read.\n */\nfunction formDataKey(form: FormData): readonly unknown[] {\n if (typeof form.entries === \"function\") {\n return Array.from(form.entries(), ([name, value]) => [\n name,\n typeof value === \"string\" ? value : blobKey(value),\n ]);\n }\n return (form as NativeFormData).getParts?.() ?? [];\n}\n\n/** The bytes of an ArrayBuffer or a typed array, or null for another value. */\nfunction valueBytes(value: object): Uint8Array | null {\n if (ArrayBuffer.isView(value)) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n }\n return isClass(value, \"ArrayBuffer\") ? new Uint8Array(value as ArrayBuffer) : null;\n}\n\n/**\n * A value that JSON cannot hold, by its content: a URLSearchParams as its text, a FormData as its\n * fields, a Blob as `blobKey` and bytes as their numbers. Undefined for any other value.\n */\nfunction rawValueKey(value: object): BodyKey | undefined {\n if (isClass(value, \"URLSearchParams\")) {\n return { body: String(value), bodyType: \"URLSearchParams\" };\n }\n if (isClass(value, \"FormData\")) {\n return { body: formDataKey(value as FormData), bodyType: \"FormData\" };\n }\n if (isClass(value, \"Blob\") || isClass(value, \"File\")) {\n return { body: blobKey(value as Blob), bodyType: \"Blob\" };\n }\n const bytes = valueBytes(value);\n return bytes === null ? undefined : { body: Array.from(bytes), bodyType: \"bytes\" };\n}\n\n/**\n * The own enumerable members of an object or an array body, each as `bodyKey`, and their kinds by\n * name or index.\n * An empty object or array stays: a JSON `{}` or `[]` is a body, unlike none.\n */\nfunction membersKey(members: object): BodyKey {\n const body: Record<string, unknown> | unknown[] = Array.isArray(members) ? [] : {};\n const kinds: Record<string, BodyKinds> = {};\n for (const [name, value] of Object.entries(members)) {\n const member = bodyKey(value);\n (body as Record<string, unknown>)[name] = member.body;\n if (member.bodyType !== undefined) {\n kinds[name] = member.bodyType;\n }\n }\n return Object.keys(kinds).length === 0 ? { body } : { body, bodyType: kinds };\n}\n\n/**\n * A body in a key: a value JSON cannot hold by its content, wherever it is in the body, and the\n * kinds of such values in `bodyType`, a field no init has. A JSON body has no `bodyType`, so it\n * never shares a key with a body that holds such a value written as the same JSON. Any other\n * object, also a class instance or an object of another realm, is walked by its own enumerable\n * members, which are what `JSON.stringify` and the fetch client's multipart body send. An object\n * with its own JSON form, such as a Date, stays as it is: `JSON.stringify` and TanStack Query's\n * hash write what its `toJSON` returns.\n */\nexport function bodyKey(body: unknown): BodyKey {\n if (typeof body !== \"object\" || body === null) {\n return { body };\n }\n return (\n rawValueKey(body) ??\n (typeof (body as { toJSON?: unknown }).toJSON === \"function\" ? { body } : membersKey(body))\n );\n}\n","/**\n * The request part of a query key (ADR-046). TanStack Query hashes a key as JSON: a `Headers`\n * object or a list of header pairs hashed as `{}` or by its order, and so did a FormData, a Blob,\n * an ArrayBuffer or a URLSearchParams body. Two requests that differed in them shared one cache\n * entry, and the `queryFn` of that entry sent the request of the first. Two clients with\n * different base URLs shared entries too. The key's init holds the headers and such a body as\n * plain values, and the base URL the request goes to or the client's key scope, so the key names\n * what was fetched.\n */\nimport { bodyKey } from \"./body-key.js\";\n\n/**\n * Whether a value is an object literal, such as the `params` of an init and its records, which\n * the fetch client reads by their members.\n */\nfunction isPlainRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n const prototype: unknown =\n typeof value === \"object\" && value !== null ? Object.getPrototypeOf(value) : undefined;\n return prototype === Object.prototype || prototype === null;\n}\n\n/** Headers as a plain object, which TanStack Query hashes by its names and values. */\ntype HeadersRecord = Readonly<Record<string, unknown>>;\n\n/** What the key takes from the fetch client and the options of `createClient`. */\nexport interface KeyClient {\n /** The fetch client's base URL, `\"\"` without one. */\n readonly baseUrl: string;\n /** The name of the API in every key, in place of the base URL. */\n readonly keyScope?: string | undefined;\n}\n\n/**\n * The headers of an init as a plain object. A `Headers` object and a list of pairs, which are both\n * iterable, become the names and values the request sends: names in lowercase, a repeated one\n * joined with `, `, as `Headers` writes them. They are read without `Headers`, which threw for an\n * invalid name or value while the component rendered; the request reports it as a query error. A\n * plain object stays as it is, since its `null` and array values mean more than a string.\n */\nfunction plainHeaders(headers: object): HeadersRecord {\n if (!(Symbol.iterator in headers)) {\n return headers as HeadersRecord;\n }\n const record: Record<string, string> = {};\n for (const pair of headers as Iterable<unknown>) {\n const [name, value] = Array.from(pair as ArrayLike<unknown>);\n const key = String(name).toLowerCase();\n record[key] = key in record ? `${record[key]}, ${String(value)}` : String(value);\n }\n return record;\n}\n\n/**\n * The members of an object that are not `undefined`, or undefined when none is. A member set to\n * `undefined` (`headers: token ? … : undefined`, `query: { cursor: undefined }`) sends the same\n * request as none, and TanStack Query's hash leaves it out too, so a record of only such members\n * sends nothing and must not count as one. `null`, `[]` and `{}` members stay: `null` removes a\n * header, and a query serializer of the client may send them.\n */\nfunction definedMembers(record: object): Record<string, unknown> | undefined {\n const members = Object.entries(record).filter(([, value]) => value !== undefined);\n return members.length === 0 ? undefined : Object.fromEntries(members);\n}\n\n/**\n * The `params` of an init without the records that send nothing: `{}`, `{ query: {} }` and\n * `{ query: { cursor: undefined } }` send the request of no `params`, since the fetch client reads\n * a missing record as an empty one. Undefined when no record is left.\n */\nfunction paramsKey(params: unknown): unknown {\n if (!isPlainRecord(params)) {\n return params;\n }\n const records = Object.entries(params).map(([location, record]) => [\n location,\n isPlainRecord(record) ? definedMembers(record) : record,\n ]);\n return definedMembers(Object.fromEntries(records));\n}\n\n/** The headers of an init as `plainHeaders`, or undefined when they set none. */\nfunction headersKey(headers: unknown): unknown {\n return typeof headers === \"object\" && headers !== null\n ? definedMembers(plainHeaders(headers))\n : headers;\n}\n\n/**\n * The init of a query key: the request init with its params and headers without what sends\n * nothing, its body as `bodyKey`, and the client's key scope, or its base URL when the init has\n * none. The `signal` is left out: TanStack Query gives each request its own. Undefined when\n * nothing is left, so a call without an init and one with an init that sends nothing more, such\n * as `{}` or `{ params: { query: { cursor: undefined } } }`, have the key `[method, path]`.\n */\nexport function queryKeyInit(init: unknown, client: KeyClient): object | undefined {\n const { signal: _signal, ...rest } = (init ?? {}) as {\n signal?: unknown;\n params?: unknown;\n headers?: unknown;\n baseUrl?: unknown;\n body?: unknown;\n };\n const keyInit: Record<string, unknown> = {\n ...rest,\n params: paramsKey(rest.params),\n headers: headersKey(rest.headers),\n ...(rest.body === undefined ? {} : bodyKey(rest.body)),\n };\n if (client.keyScope !== undefined) {\n keyInit.keyScope = client.keyScope;\n } else if (!rest.baseUrl && client.baseUrl) {\n keyInit.baseUrl = client.baseUrl;\n }\n return definedMembers(keyInit);\n}\n","/**\n * The signal of a query's request. TanStack Query gives every request a signal, which it aborts\n * when the query is cancelled or no longer used; the init of the call may bring its own. The hooks\n * sent one of them: `useQuery` the call's, so a cancelled query kept its request, and\n * `useInfiniteQuery` TanStack's, so the call's signal did nothing. The request now stops when\n * either is aborted.\n */\n\n/** The init to send, and how to stop listening to the signals once the request has settled. */\nexport interface QueryRequest {\n readonly init: Record<string, unknown>;\n readonly release: () => void;\n}\n\nconst ABORT_EVENT = \"abort\";\n\nfunction withoutRelease(init: Record<string, unknown>): QueryRequest {\n return { init, release: () => undefined };\n}\n\n/** The init with a signal that aborts when the init's own signal or the query's does. */\nexport function withQuerySignal(init: unknown, querySignal: AbortSignal): QueryRequest {\n const { signal: ownSignal, ...rest } = (init ?? {}) as { signal?: AbortSignal | null };\n if (!ownSignal) {\n return withoutRelease({ ...rest, signal: querySignal });\n }\n const controller = new AbortController();\n const sources = [ownSignal, querySignal];\n const aborted = sources.find((source) => source.aborted);\n if (aborted !== undefined) {\n controller.abort(aborted.reason);\n return withoutRelease({ ...rest, signal: controller.signal });\n }\n const listeners = sources.map((source) => {\n const listener = () => controller.abort(source.reason);\n source.addEventListener(ABORT_EVENT, listener, { once: true });\n return () => source.removeEventListener(ABORT_EVENT, listener);\n });\n return {\n init: { ...rest, signal: controller.signal },\n release: () => {\n for (const remove of listeners) {\n remove();\n }\n },\n };\n}\n","import {\n type DataTag,\n type DefaultError,\n type DefinedUseQueryResult,\n type InfiniteData,\n type QueryClient,\n type QueryFunctionContext,\n type SkipToken,\n type UseInfiniteQueryOptions,\n type UseInfiniteQueryResult,\n type UseMutationOptions,\n type UseMutationResult,\n type UseQueryOptions,\n type UseQueryResult,\n type UseSuspenseQueryOptions,\n type UseSuspenseQueryResult,\n useInfiniteQuery,\n useMutation,\n useQuery,\n useSuspenseQuery,\n} from \"@tanstack/react-query\";\nimport type {\n ClientMethod,\n DefaultParamsOption,\n Client as FetchClient,\n FetchResponse,\n MaybeOptionalInit,\n PathOperation,\n} from \"openapi-typesafe-fetch\";\n// The helper types come from the client, which declares them: types inferred from the hooks then\n// print the client's `helpers` entry, of a peer every user has, and not `openapi-typesafe-helpers`,\n// which Yarn PnP does not let a library reach (ADR-034).\nimport type {\n HttpMethod,\n MediaType,\n PathsWithMethod,\n RequiredKeysOf,\n} from \"openapi-typesafe-fetch/helpers\";\nimport { queryKeyInit } from \"./query-key.js\";\nimport { withQuerySignal } from \"./query-signal.js\";\n\n// Helper type to dynamically infer the type from the `select` property\ntype InferSelectReturnType<TData, TSelect> = TSelect extends (data: TData) => infer R ? R : TData;\n\n/**\n * Query data of a response type: a success without a body is `undefined` in the fetch client and\n * `null` in the query, as `queryFn` resolves it (upstream #2234, #2464).\n */\ntype QueryData<Data> = undefined extends Data ? Exclude<Data, undefined> | null : Data;\n\n/**\n * What the hooks throw when a request fails and the response has no error body: a non-OK status\n * with an empty body, a JSON `null` body, or one whose operation declares no content for it. The\n * fetch client gives `error: undefined` (or `null`) then; throwing that left `error` empty in\n * TanStack Query while its type said there was an error body. Tell it apart with\n * `isResponseError(error)`: `error instanceof Error` also matches a network or parse error. The\n * message names the status, not the URL, which can carry secrets.\n */\nexport interface ResponseError extends Error {\n readonly name: \"ResponseError\";\n /** The response that failed. */\n readonly response: Response;\n /** Its HTTP status, as `response.status`. */\n readonly status: number;\n}\n\n/**\n * The error of a hook: the error body of a failed response, a `ResponseError` when it has none, or\n * what the request threw before there was a response to read: a network error (`TypeError`), an\n * abort, a body that is not JSON (`SyntaxError`) or a middleware error. TanStack Query types that\n * last part as `DefaultError` (`Error` unless `Register` says otherwise; a registered `unknown`\n * makes the whole type `unknown`, as for TanStack's own hooks). `undefined` and `null` are left\n * out: a failed response without an error body throws a `ResponseError`.\n */\nexport type QueryError<ErrorBody> =\n | Exclude<ErrorBody, undefined | null>\n | ResponseError\n | DefaultError;\n\n/**\n * An object whose `queryKey` is tagged with the query's data and error types: the type that\n * TanStack Query 5.102 exports as `QueryKeyWithDataTag`, for the whole peer range. A named object\n * type, so the declarations of an exported `queryOptions` result print it by name. Spelled out,\n * the tag prints TanStack's `dataTagSymbol` keys, which a declaration file cannot import, and\n * the library's users get TS2304, or `any` cached data with `skipLibCheck`.\n */\nexport type QueryKeyWithDataTag<Key, Data, Error> = {\n queryKey: DataTag<Key, Data, Error>;\n};\n\ntype InitWithUnknowns<Init> = Init & { [key: string]: unknown };\n\n/**\n * The arguments after the path: the init, required when the operation requires a parameter or a\n * body, then `Rest`. The condition is openapi-react-query's, as `InitParam` of the fetch client\n * is openapi-fetch's (ADR-030, decision 2): TypeScript relates two conditional types only when\n * their `extends` types are the same, so a hook type copied from openapi-react-query takes these\n * hooks. For a union of inits, `MaybeOptionalInit` leaves out `undefined` when one is required,\n * so `Parameters<typeof $api.queryOptions>` still requires it then (upstream #2178).\n */\ntype InitArguments<Init, Rest extends unknown[]> =\n RequiredKeysOf<Init> extends never\n ? [InitWithUnknowns<Init>?, ...Rest]\n : [InitWithUnknowns<Init>, ...Rest];\n\n/**\n * The key of a query: the method, the path and the request. Its init is the init of the call with\n * the headers and the body as plain values, and the client's `keyScope`, or its `baseUrl` when the\n * init has none, so two requests never share a key; it is left out when nothing is left. Read a\n * query's key from `queryOptions(...).queryKey` rather than writing it out.\n */\nexport type QueryKey<\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init = MaybeOptionalInit<Paths[Path], Method>,\n> = Init extends undefined ? readonly [Method, Path] : readonly [Method, Path, Init];\n\n/**\n * The last element of an infinite query's key. `useQuery` and `useInfiniteQuery` cache different\n * data (`TData` and `InfiniteData<TData>`), so the same request must not share one key (upstream\n * #2184, ADR-022). A prefix such as `[method, path]` still matches both. A `pageParamName` other\n * than the default follows it (`infiniteQueryKey`). Not exported: it is not\n * needed outside the package, and a named export is public API; `InfiniteQueryKey` types the key.\n */\nconst INFINITE_QUERY_KEY_MARKER = \"infinite\";\n\nexport type InfiniteQueryKey<\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n> =\n | readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER]\n | readonly [\n ...QueryKey<Paths, Method, Path>,\n typeof INFINITE_QUERY_KEY_MARKER,\n { readonly pageParamName: string },\n ];\n\n/**\n * Whether the options give an `initialData` that is never `undefined`: a value, or a function that\n * never returns `undefined`. Then `data` is never `undefined` either, as for TanStack Query's own\n * `useQuery` with `DefinedInitialDataOptions`.\n */\ntype HasDefinedInitialData<Options> = Options extends { initialData: infer Initial }\n ? Initial extends (...args: never) => infer Returned\n ? undefined extends Returned\n ? false\n : true\n : undefined extends Initial\n ? false\n : true\n : false;\n\n/** The result of `useQuery`: its `data` is defined when the options give defined initial data. */\ntype QueryResult<Data, Error, Options> =\n HasDefinedInitialData<Options> extends true\n ? DefinedUseQueryResult<Data, Error>\n : UseQueryResult<Data, Error>;\n\n/**\n * A defined `initialData` of the options, in the type `queryOptions` returns, so TanStack Query's\n * `useQuery` takes the result as options with defined initial data. It is typed as the query data,\n * as TanStack's `DefinedInitialDataOptions` types it: the type of a literal such as `[{ id: 1 }]`\n * lacks the optional properties of the data, and TanStack's overload rejected it.\n */\ntype InitialDataOf<Options, Data> =\n HasDefinedInitialData<Options> extends true ? { initialData: Data | (() => Data) } : unknown;\n\nexport type QueryOptionsFunction<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n path: Path,\n ...[init, options]: InitArguments<Init, [Options?]>\n) => NoInfer<\n Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryFn\" | \"queryKey\"\n > &\n QueryKeyWithDataTag<\n QueryKey<Paths, Method, Path>,\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>\n > &\n InitialDataOf<Options, QueryData<Response[\"data\"]>> & {\n queryFn: Exclude<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >[\"queryFn\"],\n SkipToken | undefined\n >;\n }\n>;\n\nexport type UseQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n url: Path,\n ...[init, options, queryClient]: InitArguments<Init, [Options?, QueryClient?]>\n) => QueryResult<\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryError<Response[\"error\"]>,\n Options\n>;\n\n/**\n * The type of the page params: the initial one and the ones `getNextPageParam` and\n * `getPreviousPageParam` return (upstream #2458). It was `unknown`. It stays `unknown` when a\n * return type is untyped, so code that compiled still compiles (roadmap §3): TypeScript cannot\n * infer the return type of a callback that computes it from an unannotated `lastPageParam`,\n * whose type depends on that return type, and gives `never` or `unknown`.\n */\ntype PageParam<Initial, Next, Previous> =\n IsUntyped<Next> extends true\n ? unknown\n : [Previous] extends [NoPreviousPageParam]\n ? NullishToUnknown<Initial | NonNullable<Next>>\n : IsUntyped<Previous> extends true\n ? unknown\n : NullishToUnknown<Initial | NonNullable<Next> | NonNullable<Previous>>;\n\n/** The `Previous` type parameter when the options have no `getPreviousPageParam`. */\ndeclare const NO_PREVIOUS_PAGE_PARAM: unique symbol;\ntype NoPreviousPageParam = typeof NO_PREVIOUS_PAGE_PARAM;\n\ntype IsUntyped<T> = [T] extends [never] ? true : unknown extends T ? true : false;\n\n/** Only `undefined` or `null` names no type: a cursor API's `initialPageParam: undefined`. */\ntype NullishToUnknown<T> = [T] extends [undefined | null] ? unknown : T;\n\n/** Read only for the return type; `never` arguments add no inference for TanStack's page param. */\ntype PageParamFunction<Result> = (...args: never) => Result;\n\n/**\n * Inference sites of the page param types. Intersected before `Options`, so TanStack's own\n * inference in the implementation reads the full signatures of `Options`.\n */\ninterface PageParamSources<Initial, Next, Previous> {\n initialPageParam: Initial;\n getNextPageParam: PageParamFunction<Next>;\n getPreviousPageParam?: PageParamFunction<Previous>;\n}\n\n/**\n * `placeholderData` of `useInfiniteQuery`, with an `unknown` page param as before: TypeScript types\n * a `(previousData) => previousData` callback while it still infers the page param, so it got\n * `unknown` there and failed against the typed page param.\n */\ntype InfinitePlaceholderData<\n Data,\n Error,\n Paths extends {},\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n> = UseInfiniteQueryOptions<\n Data,\n Error,\n InfiniteData<Data, unknown>,\n InfiniteQueryKey<Paths, Method, Path>,\n unknown\n>[\"placeholderData\"];\n\nexport type UseInfiniteQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseInfiniteQueryOptions<\n Response[\"data\"],\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<\n InfiniteData<Response[\"data\"], PageParam<Initial, Next, Previous>>,\n Options[\"select\"]\n >,\n InfiniteQueryKey<Paths, Method, Path>,\n PageParam<Initial, Next, Previous>\n >,\n \"queryKey\" | \"queryFn\" | \"placeholderData\"\n > & {\n placeholderData?: InfinitePlaceholderData<\n Response[\"data\"],\n QueryError<Response[\"error\"]>,\n Paths,\n Method,\n Path\n >;\n pageParamName?: string;\n },\n Initial = unknown,\n Next = never,\n Previous = NoPreviousPageParam,\n // biome-ignore lint/complexity/useMaxParams: public signature of 1.x (ADR-036)\n>(\n method: Method,\n url: Path,\n init: InitWithUnknowns<Init>,\n options: PageParamSources<Initial, Next, Previous> & Options,\n queryClient?: QueryClient,\n) => UseInfiniteQueryResult<\n InferSelectReturnType<\n InfiniteData<Response[\"data\"], PageParam<Initial, Next, Previous>>,\n Options[\"select\"]\n >,\n QueryError<Response[\"error\"]>\n>;\n\nexport type UseSuspenseQueryMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n Options extends Omit<\n UseSuspenseQueryOptions<\n QueryData<Response[\"data\"]>,\n QueryError<Response[\"error\"]>,\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryKey<Paths, Method, Path>\n >,\n \"queryKey\" | \"queryFn\"\n >,\n>(\n method: Method,\n url: Path,\n ...[init, options, queryClient]: InitArguments<Init, [Options?, QueryClient?]>\n) => UseSuspenseQueryResult<\n InferSelectReturnType<QueryData<Response[\"data\"]>, Options[\"select\"]>,\n QueryError<Response[\"error\"]>\n>;\n\nexport type UseMutationMethod<Paths extends {}, Media extends MediaType> = <\n Method extends HttpMethod,\n Path extends PathsWithMethod<Paths, Method>,\n Init extends MaybeOptionalInit<Paths[Path], Method>,\n // note: Required is used to avoid repeating NonNullable in UseQuery types\n Response extends Required<FetchResponse<PathOperation<Paths, Path, Method>, Init, Media>>,\n TOnMutateResult = unknown,\n>(\n method: Method,\n url: Path,\n options?: Omit<\n UseMutationOptions<Response[\"data\"], QueryError<Response[\"error\"]>, Init, TOnMutateResult>,\n \"mutationKey\" | \"mutationFn\"\n >,\n queryClient?: QueryClient,\n) => UseMutationResult<Response[\"data\"], QueryError<Response[\"error\"]>, Init, TOnMutateResult>;\n\nexport interface OpenapiQueryClient<Paths extends {}, Media extends MediaType = MediaType> {\n queryOptions: QueryOptionsFunction<Paths, Media>;\n useQuery: UseQueryMethod<Paths, Media>;\n useSuspenseQuery: UseSuspenseQueryMethod<Paths, Media>;\n useInfiniteQuery: UseInfiniteQueryMethod<Paths, Media>;\n useMutation: UseMutationMethod<Paths, Media>;\n}\n\nexport type MethodResponse<\n // biome-ignore lint/suspicious/noExplicitAny: matches a client of any paths, as upstream's\n CreatedClient extends OpenapiQueryClient<any, any>,\n Method extends HttpMethod,\n Path extends CreatedClient extends OpenapiQueryClient<infer Paths, infer _Media>\n ? PathsWithMethod<Paths, Method>\n : never,\n Options = object,\n> =\n CreatedClient extends OpenapiQueryClient<\n // biome-ignore lint/suspicious/noExplicitAny: unknown rejects the generated interfaces\n infer Paths extends { [key: string]: any },\n infer Media extends MediaType\n >\n ? NonNullable<FetchResponse<Paths[Path][Method], Options, Media>[\"data\"]>\n : never;\n\n/** The `name` of every `ResponseError`. */\nconst RESPONSE_ERROR_NAME = \"ResponseError\";\n\n/** The `ResponseError` of a failed response without an error body. */\nclass ResponseWithoutErrorBody extends Error implements ResponseError {\n override readonly name = RESPONSE_ERROR_NAME;\n readonly response: Response;\n readonly status: number;\n\n constructor(response: Response) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n super(`Request failed with status ${response.status}${statusText} and no error body`);\n this.response = response;\n this.status = response.status;\n }\n}\n\n/**\n * Whether `error` is the `ResponseError` of a failed response without an error body. It narrows a\n * hook's `error`, where `error instanceof Error` also matches network and parse errors. It checks\n * the `name`, not the class, so a `ResponseError` of another copy of this package (its CommonJS and\n * ES module builds loaded side by side) is one too. An error body from JSON is never an `Error`.\n */\nexport function isResponseError(error: unknown): error is ResponseError {\n return error instanceof Error && error.name === RESPONSE_ERROR_NAME;\n}\n\n/**\n * Throw the error of a failed fetch result. `if (error)` missed two failures: a non-OK response\n * with an empty body (`error` is `undefined`, upstream #2070, #2829) and a falsy error body such as\n * `0`. Without an error body a `ResponseError` is thrown, so the hooks' `error` is never\n * `undefined` (ADR-013, decision 3). A JSON `null` body is no error body either: thrown as is, it\n * left `error` `null` while the query's status was `\"error\"`.\n */\nfunction throwIfFailed(result: { error?: unknown; response: Response }): void {\n if (result.error !== undefined && result.error !== null) {\n throw result.error;\n }\n if (!result.response.ok) {\n throw new ResponseWithoutErrorBody(result.response);\n }\n}\n\n/** The query parameter that carries the page param unless `pageParamName` names another. */\nconst DEFAULT_PAGE_PARAM_NAME = \"cursor\";\n\ninterface PageRequest {\n readonly pageParamName: string;\n readonly pageParam: unknown;\n}\n\n/**\n * The request init of one page. An `undefined` page param (the first page with\n * `initialPageParam: undefined`) is left out instead of being sent as `0` (upstream #2715, #2340,\n * ADR-022), so a cursor API gets no cursor on the first page.\n */\nfunction pageInit(init: unknown, { pageParamName, pageParam }: PageRequest) {\n const { params, ...rest } = (init ?? {}) as { params?: { query?: DefaultParamsOption } };\n const page = pageParam === undefined ? {} : { [pageParamName]: pageParam };\n return { ...rest, params: { ...params, query: { ...params?.query, ...page } } };\n}\n\n/**\n * The key of an infinite query: the key of its request, the marker, and the `pageParamName` when\n * it is not the default one. The name is the query parameter each page is sent with, so queries\n * that differ only in it send different requests. The default name adds nothing, so the key of a\n * call without one is the key of a call that names the default.\n */\nfunction infiniteQueryKey<Key extends readonly unknown[]>(queryKey: Key, pageParamName: string) {\n return [\n ...queryKey,\n INFINITE_QUERY_KEY_MARKER,\n ...(pageParamName === DEFAULT_PAGE_PARAM_NAME ? ([] as const) : ([{ pageParamName }] as const)),\n ] as const;\n}\n\n/** Options of `createClient`. */\nexport interface CreateClientOptions {\n /**\n * The name of the API in every query key, in place of the fetch client's `baseUrl`. Give the\n * same name where the server and the browser reach one API by different URLs, so the browser\n * reads the data the server rendered with; give different names to clients of one base URL that\n * fetch different data, such as one per tenant header.\n */\n keyScope?: string;\n}\n\n/**\n * Hooks and query options for a fetch client. A `QueryClient` other than the one from the React\n * context is passed to each hook as its last argument; `createClient` does not take one.\n */\n// biome-ignore lint/complexity/noExcessiveLinesPerFunction: inherited, kept until 1.1 (ADR-036)\nexport default function createClient<Paths extends {}, Media extends MediaType = MediaType>(\n client: FetchClient<Paths, Media>,\n { keyScope }: CreateClientOptions = {},\n): OpenapiQueryClient<Paths, Media> {\n const keyClient = { baseUrl: client.baseUrl, keyScope };\n /**\n * Send one request of a query: the call's own init, with a signal that TanStack Query can abort.\n * The key only names the cache entry, as for `useInfiniteQuery`: a function in the init (a\n * `fetch`, a `middleware`) cannot be part of a key, so the request is read from the call.\n */\n const fetchPage = async <Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>>(\n method: Method,\n path: Path,\n init: unknown,\n signal: AbortSignal,\n ) => {\n const mth = method.toUpperCase() as Uppercase<typeof method>;\n const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;\n const request = withQuerySignal(init, signal);\n try {\n // The init is `unknown` here. An `any` init lets the call infer the generic response type\n // that `queryOptions` declares; a typed init makes TypeScript compare two unresolved\n // conditional types, which it cannot do.\n // biome-ignore lint/suspicious/noExplicitAny: see the comment above\n const result = await fn(path, request.init as any);\n throwIfFailed(result);\n return result.data;\n } finally {\n request.release();\n }\n };\n\n const queryOptions: QueryOptionsFunction<Paths, Media> = (method, path, ...[init, options]) => {\n const keyInit = queryKeyInit(init, keyClient);\n return {\n queryKey: (keyInit === undefined\n ? ([method, path] as const)\n : ([method, path, keyInit] as const)) as DataTag<\n QueryKey<Paths, typeof method, typeof path>,\n // biome-ignore lint/suspicious/noExplicitAny: the declared return type sets the data type\n any,\n // biome-ignore lint/suspicious/noExplicitAny: the declared return type sets the error type\n any\n >,\n // TanStack Query rejects `undefined` query data. The fetch client gives `undefined` for\n // every success without a body: a 204, `Content-Length: 0`, an empty chunked body, a HEAD\n // request (upstream #2234). A parsed body is never `undefined`, so this changes nothing else.\n queryFn: async ({ signal }: QueryFunctionContext) =>\n (await fetchPage(method, path, init, signal)) ?? null,\n // Without options, `Options` is its constraint, which has no `initialData` to keep.\n ...(options as typeof options & {}),\n // The declared type types a defined `initialData` as the query data, a conditional type of\n // the generic options that TypeScript cannot relate to the object; it is the same object.\n } as never;\n };\n\n return {\n queryOptions,\n useQuery: (method, path, ...[init, options, queryClient]) =>\n // TanStack Query's `useQuery` returns `DefinedUseQueryResult` for options with defined\n // `initialData`; while `Options` is generic it cannot pick that overload, and the declared\n // `QueryResult` gives the caller the same answer. Both are the same object at runtime.\n useQuery(\n queryOptions(method, path, init as InitWithUnknowns<typeof init>, options),\n queryClient,\n ) as never,\n useSuspenseQuery: (method, path, ...[init, options, queryClient]) =>\n useSuspenseQuery(\n queryOptions(method, path, init as InitWithUnknowns<typeof init>, options),\n queryClient,\n ),\n // biome-ignore lint/complexity/useMaxParams: public signature of 1.x (ADR-036)\n useInfiniteQuery: (method, path, init, options, queryClient) => {\n const { pageParamName = DEFAULT_PAGE_PARAM_NAME, placeholderData, ...restOptions } = options;\n const { queryKey } = queryOptions(method, path, init);\n return useInfiniteQuery(\n {\n queryKey: infiniteQueryKey(queryKey, pageParamName),\n // An empty page stays `undefined`, as in upstream: TanStack Query rejects only\n // `undefined` query data, and the infinite query data is the `{ pages }` object.\n queryFn: ({ pageParam, signal }) =>\n fetchPage(method, path, pageInit(init, { pageParamName, pageParam }), signal),\n ...restOptions,\n // Typed with an `unknown` page param for the caller (`InfinitePlaceholderData`). TanStack\n // passes the previous data of this query, with its own page params, and takes it back.\n // biome-ignore lint/suspicious/noExplicitAny: TanStack's type carries its own page params\n placeholderData: placeholderData as any,\n },\n queryClient,\n );\n },\n useMutation: (method, path, options, queryClient) =>\n useMutation(\n {\n mutationKey: [method, path],\n mutationFn: async (init) => {\n const mth = method.toUpperCase() as Uppercase<typeof method>;\n const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;\n const result = await fn(path, init as InitWithUnknowns<typeof init>);\n throwIfFailed(result);\n // TanStack Query accepts `undefined` mutation data, so a success without a body stays\n // `undefined`, as in upstream; only query data needs `null` (upstream #2234). The cast\n // only bridges the generic types: `Response[\"data\"]` still has `undefined` for an\n // operation with a response without a body.\n const { data } = result;\n return data as Exclude<typeof data, undefined>;\n },\n ...options,\n },\n queryClient,\n ),\n };\n}\n"],"names":["useQuery","useSuspenseQuery","useInfiniteQuery","useMutation"],"mappings":";;;;;;AAQA,MAAM,iBAAiB,UAAA,CAAW,MAAA;AAClC,MAAM,YAAA,GAAe,EAAA;AAuBrB,SAAS,OAAA,CAAQ,OAAe,IAAA,EAAuB;AACrD,EAAA,MAAM,IAAA,GAAQ,WAAuC,IAAI,CAAA;AACzD,EAAA,OACG,OAAO,IAAA,KAAS,UAAA,IAAc,KAAA,YAAiB,QAChD,MAAA,CAAO,SAAA,CAAU,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA,CAAE,KAAA,CAAM,cAAA,EAAgB,YAAY,CAAA,KAAM,IAAA;AAElF;AAQA,SAAS,QAAQ,IAAA,EAAoB;AACnC,EAAA,MAAM,EAAE,MAAK,GAAI,IAAA;AACjB,EAAA,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,MAA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H;AAAA,SACF;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,WAAA,EAAa,CAAC,MAAA,EAAQ,IAAA,EAAM,SAAS,WAAA,KACnCC,sBAAA;AAAA,MACE;AAAA,QACE,WAAA,EAAa,CAAC,MAAA,EAAQ,IAAI,CAAA;AAAA,QAC1B,UAAA,EAAY,OAAO,IAAA,KAAS;AAC1B,UAAA,MAAM,GAAA,GAAM,OAAO,WAAA,EAAY;AAC/B,UAAA,MAAM,EAAA,GAAK,OAAO,GAAG,CAAA;AACrB,UAAA,MAAM,MAAA,GAAS,MAAM,EAAA,CAAG,IAAA,EAAM,IAAqC,CAAA;AACnE,UAAA,aAAA,CAAc,MAAM,CAAA;AAKpB,UAAA,MAAM,EAAE,MAAK,GAAI,MAAA;AACjB,UAAA,OAAO,IAAA;AAAA,QACT,CAAA;AAAA,QACA,GAAG;AAAA,OACL;AAAA,MACA;AAAA;AACF,GACJ;AACF;;;;"}
package/dist/index.d.cts CHANGED
@@ -64,11 +64,18 @@ type QueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWit
64
64
  /**
65
65
  * The last element of an infinite query's key. `useQuery` and `useInfiniteQuery` cache different
66
66
  * data (`TData` and `InfiniteData<TData>`), so the same request must not share one key (upstream
67
- * #2184, ADR-022). A prefix such as `[method, path]` still matches both. Not exported: it is not
67
+ * #2184, ADR-022). A prefix such as `[method, path]` still matches both. A `pageParamName` other
68
+ * than the default follows it (`infiniteQueryKey`). Not exported: it is not
68
69
  * needed outside the package, and a named export is public API; `InfiniteQueryKey` types the key.
69
70
  */
70
71
  declare const INFINITE_QUERY_KEY_MARKER = "infinite";
71
- type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER];
72
+ type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER] | readonly [
73
+ ...QueryKey<Paths, Method, Path>,
74
+ typeof INFINITE_QUERY_KEY_MARKER,
75
+ {
76
+ readonly pageParamName: string;
77
+ }
78
+ ];
72
79
  /**
73
80
  * Whether the options give an `initialData` that is never `undefined`: a value, or a function that
74
81
  * never returns `undefined`. Then `data` is never `undefined` either, as for TanStack Query's own
package/dist/index.d.mts CHANGED
@@ -64,11 +64,18 @@ type QueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWit
64
64
  /**
65
65
  * The last element of an infinite query's key. `useQuery` and `useInfiniteQuery` cache different
66
66
  * data (`TData` and `InfiniteData<TData>`), so the same request must not share one key (upstream
67
- * #2184, ADR-022). A prefix such as `[method, path]` still matches both. Not exported: it is not
67
+ * #2184, ADR-022). A prefix such as `[method, path]` still matches both. A `pageParamName` other
68
+ * than the default follows it (`infiniteQueryKey`). Not exported: it is not
68
69
  * needed outside the package, and a named export is public API; `InfiniteQueryKey` types the key.
69
70
  */
70
71
  declare const INFINITE_QUERY_KEY_MARKER = "infinite";
71
- type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER];
72
+ type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER] | readonly [
73
+ ...QueryKey<Paths, Method, Path>,
74
+ typeof INFINITE_QUERY_KEY_MARKER,
75
+ {
76
+ readonly pageParamName: string;
77
+ }
78
+ ];
72
79
  /**
73
80
  * Whether the options give an `initialData` that is never `undefined`: a value, or a function that
74
81
  * never returns `undefined`. Then `data` is never `undefined` either, as for TanStack Query's own
package/dist/index.d.ts CHANGED
@@ -64,11 +64,18 @@ type QueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWit
64
64
  /**
65
65
  * The last element of an infinite query's key. `useQuery` and `useInfiniteQuery` cache different
66
66
  * data (`TData` and `InfiniteData<TData>`), so the same request must not share one key (upstream
67
- * #2184, ADR-022). A prefix such as `[method, path]` still matches both. Not exported: it is not
67
+ * #2184, ADR-022). A prefix such as `[method, path]` still matches both. A `pageParamName` other
68
+ * than the default follows it (`infiniteQueryKey`). Not exported: it is not
68
69
  * needed outside the package, and a named export is public API; `InfiniteQueryKey` types the key.
69
70
  */
70
71
  declare const INFINITE_QUERY_KEY_MARKER = "infinite";
71
- type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER];
72
+ type InfiniteQueryKey<Paths extends {}, Method extends HttpMethod, Path extends PathsWithMethod<Paths, Method>> = readonly [...QueryKey<Paths, Method, Path>, typeof INFINITE_QUERY_KEY_MARKER] | readonly [
73
+ ...QueryKey<Paths, Method, Path>,
74
+ typeof INFINITE_QUERY_KEY_MARKER,
75
+ {
76
+ readonly pageParamName: string;
77
+ }
78
+ ];
72
79
  /**
73
80
  * Whether the options give an `initialData` that is never `undefined`: a value, or a function that
74
81
  * never returns `undefined`. Then `data` is never `undefined` either, as for TanStack Query's own