@prismicio/client 7.21.0-canary.bd2c015 → 7.21.0-canary.cd31858
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/Client.cjs +76 -106
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.cts +1 -19
- package/dist/Client.d.cts.map +1 -1
- package/dist/Client.d.ts +1 -19
- package/dist/Client.d.ts.map +1 -1
- package/dist/Client.js +76 -106
- package/dist/Client.js.map +1 -1
- package/dist/WriteClient.cjs +8 -5
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.js +8 -5
- package/dist/WriteClient.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +1 -1
- package/src/Client.ts +192 -205
- package/src/WriteClient.ts +10 -6
package/dist/Client.cjs
CHANGED
|
@@ -155,35 +155,33 @@ var Client = class {
|
|
|
155
155
|
* @returns A client that can query content from the repository.
|
|
156
156
|
*/
|
|
157
157
|
constructor(repositoryNameOrEndpoint, options = {}) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
else if (typeof globalThis.fetch === "function") this.fetchFn = globalThis.fetch;
|
|
161
|
-
else throw new require_PrismicError.PrismicError("A valid fetch implementation was not provided. In environments where fetch is not available (including Node.js), a fetch implementation must be provided via a polyfill or the `fetch` option.", void 0, void 0);
|
|
162
|
-
if (this.fetchFn === globalThis.fetch) this.fetchFn = this.fetchFn.bind(globalThis);
|
|
163
|
-
if ((options.documentAPIEndpoint || require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint)) && process.env.NODE_ENV === "development") {
|
|
164
|
-
const documentAPIEndpoint = options.documentAPIEndpoint || repositoryNameOrEndpoint;
|
|
165
|
-
if (/\.prismic\.io\/(?!api\/v2\/?)/i.test(documentAPIEndpoint)) throw new require_PrismicError.PrismicError("@prismicio/client only supports Prismic Rest API V2. Please provide only the repository name to the first createClient() parameter or use the getRepositoryEndpoint() helper to generate a valid Rest API V2 endpoint URL.", void 0, void 0);
|
|
166
|
-
const hostname = new URL(documentAPIEndpoint).hostname.toLowerCase();
|
|
167
|
-
if (hostname.endsWith(".prismic.io") && !hostname.endsWith(".cdn.prismic.io")) console.warn(`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${require_devMsg.devMsg("endpoint-must-use-cdn")}`);
|
|
168
|
-
if (options.documentAPIEndpoint && require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint) && repositoryNameOrEndpoint !== options.documentAPIEndpoint) console.warn(`[@prismicio/client] Multiple incompatible endpoints were provided. Create the client using a repository name to prevent this error. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`);
|
|
169
|
-
}
|
|
158
|
+
var _globalThis$fetch;
|
|
159
|
+
const { documentAPIEndpoint, accessToken, ref, routes, brokenRoute, defaultParams, fetchOptions = {}, fetch = (_globalThis$fetch = globalThis.fetch) === null || _globalThis$fetch === void 0 ? void 0 : _globalThis$fetch.bind(globalThis) } = options;
|
|
170
160
|
if (require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint)) {
|
|
171
|
-
this.documentAPIEndpoint = repositoryNameOrEndpoint;
|
|
172
161
|
try {
|
|
173
162
|
this.repositoryName = require_getRepositoryName.getRepositoryName(repositoryNameOrEndpoint);
|
|
174
163
|
} catch {
|
|
175
164
|
console.warn(`[@prismicio/client] A repository name could not be inferred from the provided endpoint (\`${repositoryNameOrEndpoint}\`). Some methods will be disabled. Create the client using a repository name to prevent this warning. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`);
|
|
176
165
|
}
|
|
166
|
+
this.documentAPIEndpoint = documentAPIEndpoint || repositoryNameOrEndpoint;
|
|
177
167
|
} else {
|
|
178
|
-
this.documentAPIEndpoint = options.documentAPIEndpoint || require_getRepositoryEndpoint.getRepositoryEndpoint(repositoryNameOrEndpoint);
|
|
179
168
|
this.repositoryName = repositoryNameOrEndpoint;
|
|
169
|
+
this.documentAPIEndpoint = documentAPIEndpoint || require_getRepositoryEndpoint.getRepositoryEndpoint(repositoryNameOrEndpoint);
|
|
180
170
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
185
|
-
if (
|
|
171
|
+
if (!fetch) throw new require_PrismicError.PrismicError("A valid fetch implementation was not provided. In environments where fetch is not available, a fetch implementation must be provided via a polyfill or the `fetch` option.", void 0, void 0);
|
|
172
|
+
if (typeof fetch !== "function") throw new require_PrismicError.PrismicError(`fetch must be a function, but received: ${typeof fetch}`, void 0, void 0);
|
|
173
|
+
if (!require_isRepositoryEndpoint.isRepositoryEndpoint(this.documentAPIEndpoint)) throw new require_PrismicError.PrismicError(`documentAPIEndpoint is not a valid URL: ${documentAPIEndpoint}`, void 0, void 0);
|
|
174
|
+
if (require_isRepositoryEndpoint.isRepositoryEndpoint(repositoryNameOrEndpoint) && documentAPIEndpoint && repositoryNameOrEndpoint !== documentAPIEndpoint) console.warn(`[@prismicio/client] Multiple incompatible endpoints were provided. Create the client using a repository name to prevent this error. For more details, see ${require_devMsg.devMsg("prefer-repository-name")}`);
|
|
175
|
+
if (/\.prismic\.io\/(?!api\/v2\/?)/i.test(this.documentAPIEndpoint) && process.env.NODE_ENV === "development") throw new require_PrismicError.PrismicError("@prismicio/client only supports Prismic Rest API V2. Please provide only the repository name to the first createClient() parameter or use the getRepositoryEndpoint() helper to generate a valid Rest API V2 endpoint URL.", void 0, void 0);
|
|
176
|
+
if (/(?<!\.cdn)\.prismic\.io$/i.test(new URL(this.documentAPIEndpoint).hostname) && process.env.NODE_ENV === "development") console.warn(`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${require_devMsg.devMsg("endpoint-must-use-cdn")}`);
|
|
177
|
+
this.accessToken = accessToken;
|
|
178
|
+
this.routes = routes;
|
|
179
|
+
this.brokenRoute = brokenRoute;
|
|
180
|
+
this.defaultParams = defaultParams;
|
|
181
|
+
this.fetchOptions = fetchOptions;
|
|
182
|
+
this.fetchFn = fetch;
|
|
186
183
|
this.graphQLFetch = this.graphQLFetch.bind(this);
|
|
184
|
+
if (ref) this.queryContentFromRef(ref);
|
|
187
185
|
}
|
|
188
186
|
/**
|
|
189
187
|
* Enables the client to automatically query content from a preview session.
|
|
@@ -243,8 +241,7 @@ var Client = class {
|
|
|
243
241
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}
|
|
244
242
|
*/
|
|
245
243
|
async get(params) {
|
|
246
|
-
|
|
247
|
-
return data;
|
|
244
|
+
return await (await this.#internalGet(params)).json();
|
|
248
245
|
}
|
|
249
246
|
/**
|
|
250
247
|
* Fetches the first page returned based on the `params` argument.
|
|
@@ -258,15 +255,14 @@ var Client = class {
|
|
|
258
255
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}
|
|
259
256
|
*/
|
|
260
257
|
async getFirst(params) {
|
|
261
|
-
const actualParams =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
throw new require_NotFoundError.NotFoundError("No documents were returned", url, void 0);
|
|
258
|
+
const actualParams = (params === null || params === void 0 ? void 0 : params.page) || (params === null || params === void 0 ? void 0 : params.pageSize) ? params : {
|
|
259
|
+
...params,
|
|
260
|
+
pageSize: 1
|
|
261
|
+
};
|
|
262
|
+
const response = await this.#internalGet(actualParams);
|
|
263
|
+
const { results } = await response.clone().json();
|
|
264
|
+
if (results[0]) return results[0];
|
|
265
|
+
throw new require_NotFoundError.NotFoundError("No documents were returned", response.url, void 0);
|
|
270
266
|
}
|
|
271
267
|
/**
|
|
272
268
|
* Fetches all pages based on the `params` argument. This method may make
|
|
@@ -281,11 +277,11 @@ var Client = class {
|
|
|
281
277
|
* @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}
|
|
282
278
|
*/
|
|
283
279
|
async dangerouslyGetAll(params = {}) {
|
|
284
|
-
var _this$
|
|
280
|
+
var _this$defaultParams;
|
|
285
281
|
const { limit = Infinity,...actualParams } = params;
|
|
286
282
|
const resolvedParams = {
|
|
287
283
|
...actualParams,
|
|
288
|
-
pageSize: Math.min(limit, actualParams.pageSize || ((_this$
|
|
284
|
+
pageSize: Math.min(limit, actualParams.pageSize || ((_this$defaultParams = this.defaultParams) === null || _this$defaultParams === void 0 ? void 0 : _this$defaultParams.pageSize) || MAX_PAGE_SIZE)
|
|
289
285
|
};
|
|
290
286
|
const documents = [];
|
|
291
287
|
let latestResult;
|
|
@@ -547,18 +543,13 @@ var Client = class {
|
|
|
547
543
|
const accessToken = (params === null || params === void 0 ? void 0 : params.accessToken) || this.accessToken;
|
|
548
544
|
if (accessToken) url.searchParams.set("access_token", accessToken);
|
|
549
545
|
const response = await this.#request(url, params);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
return this.#cachedRepository;
|
|
555
|
-
case 401: {
|
|
556
|
-
const json = await response.json();
|
|
557
|
-
throw new require_ForbiddenError.ForbiddenError(json.error, url.toString(), json);
|
|
558
|
-
}
|
|
559
|
-
case 404: throw new require_RepositoryNotFoundError.RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
|
|
560
|
-
default: throw new require_PrismicError.PrismicError(void 0, url.toString(), await response.text());
|
|
546
|
+
if (response.ok) {
|
|
547
|
+
this.#cachedRepository = await response.json();
|
|
548
|
+
this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
|
|
549
|
+
return this.#cachedRepository;
|
|
561
550
|
}
|
|
551
|
+
if (response.status === 404) throw new require_RepositoryNotFoundError.RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
|
|
552
|
+
return await this.#throwContentAPIError(response, url.toString());
|
|
562
553
|
}
|
|
563
554
|
/**
|
|
564
555
|
* Fetches the repository's active refs.
|
|
@@ -899,68 +890,50 @@ var Client = class {
|
|
|
899
890
|
if (ref) return ref;
|
|
900
891
|
return (await this.getMasterRef(params)).ref;
|
|
901
892
|
}
|
|
902
|
-
|
|
903
|
-
* The private implementation of `this.get`. It returns the API response and
|
|
904
|
-
* the URL used to make the request. The URL is sometimes used in the public
|
|
905
|
-
* method to include in thrown errors.
|
|
906
|
-
*
|
|
907
|
-
* This method retries requests that throw `RefNotFoundError` or
|
|
908
|
-
* `RefExpiredError`. It contains special logic to retry with the latest
|
|
909
|
-
* master ref, provided in the API's error message.
|
|
910
|
-
*
|
|
911
|
-
* @typeParam TDocument - Type of Prismic documents returned.
|
|
912
|
-
*
|
|
913
|
-
* @param params - Parameters to filter, sort, and paginate results.
|
|
914
|
-
*
|
|
915
|
-
* @returns An object containing the paginated response containing the result
|
|
916
|
-
* of the query and the URL used to make the API request.
|
|
917
|
-
*/
|
|
918
|
-
async _get(params, attemptCount = 0) {
|
|
893
|
+
async #internalGet(params, attempt = 1) {
|
|
919
894
|
const url = await this.buildQueryURL(params);
|
|
895
|
+
const response = await this.#request(new URL(url), params);
|
|
896
|
+
if (response.ok) return response;
|
|
920
897
|
try {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
898
|
+
return await this.#throwContentAPIError(response, url);
|
|
899
|
+
} catch (error) {
|
|
900
|
+
if ((error instanceof require_RefNotFoundError.RefNotFoundError || error instanceof require_RefExpiredError.RefExpiredError) && attempt < MAX_INVALID_REF_RETRY_ATTEMPTS) {
|
|
901
|
+
var _error$message$match;
|
|
902
|
+
if (!(params === null || params === void 0 ? void 0 : params.ref)) this.#cachedRepository = void 0;
|
|
903
|
+
const masterRef = (_error$message$match = error.message.match(/master ref is: (?<ref>.*)$/i)) === null || _error$message$match === void 0 || (_error$message$match = _error$message$match.groups) === null || _error$message$match === void 0 ? void 0 : _error$message$match.ref;
|
|
904
|
+
if (!masterRef) throw error;
|
|
905
|
+
require_throttledLog.throttledLog(`[@prismicio/client] The ref (${new URL(url).searchParams.get("ref")}) was ${error instanceof require_RefNotFoundError.RefNotFoundError ? "invalid" : "expired"}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`, { level: "warn" });
|
|
906
|
+
return await this.#internalGet({
|
|
907
|
+
...params,
|
|
908
|
+
ref: masterRef
|
|
909
|
+
}, attempt + 1);
|
|
910
|
+
}
|
|
911
|
+
throw error;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
async #throwContentAPIError(response, url) {
|
|
915
|
+
switch (response.status) {
|
|
916
|
+
case 400: {
|
|
917
|
+
const json = await response.clone().json();
|
|
918
|
+
throw new require_ParsingError.ParsingError(json.message, url, json);
|
|
919
|
+
}
|
|
920
|
+
case 401: {
|
|
921
|
+
const json = await response.clone().json();
|
|
922
|
+
throw new require_ForbiddenError.ForbiddenError(json.message, url, json);
|
|
923
|
+
}
|
|
924
|
+
case 404: {
|
|
925
|
+
const json = await response.clone().json();
|
|
926
|
+
switch (json.type) {
|
|
927
|
+
case "api_notfound_error": throw new require_RefNotFoundError.RefNotFoundError(json.message, url, json);
|
|
928
|
+
case "api_security_error": if (/preview token.*expired/i.test(json.message)) throw new require_PreviewTokenExpired.PreviewTokenExpiredError(json.message, url, json);
|
|
929
|
+
default: throw new require_NotFoundError.NotFoundError(json.message, url, json);
|
|
950
930
|
}
|
|
951
|
-
default: throw new require_PrismicError.PrismicError(void 0, url, await response.text());
|
|
952
931
|
}
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
if (!masterRef) throw error;
|
|
959
|
-
require_throttledLog.throttledLog(`[@prismicio/client] The ref (${new URL(url).searchParams.get("ref")}) was ${error instanceof require_RefNotFoundError.RefNotFoundError ? "invalid" : "expired"}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`, { level: "warn" });
|
|
960
|
-
return await this._get({
|
|
961
|
-
...params,
|
|
962
|
-
ref: masterRef
|
|
963
|
-
}, attemptCount + 1);
|
|
932
|
+
case 410: {
|
|
933
|
+
const json = await response.clone().json();
|
|
934
|
+
throw new require_RefExpiredError.RefExpiredError(json.message, url, json);
|
|
935
|
+
}
|
|
936
|
+
default: throw new require_PrismicError.PrismicError(void 0, url, await response.text());
|
|
964
937
|
}
|
|
965
938
|
}
|
|
966
939
|
/**
|
|
@@ -973,11 +946,8 @@ var Client = class {
|
|
|
973
946
|
* @returns The response from the fetch request.
|
|
974
947
|
*/
|
|
975
948
|
async #request(url, params) {
|
|
976
|
-
return await require_request.request(url, this._buildRequestInit(params), this.fetchFn);
|
|
977
|
-
}
|
|
978
|
-
_buildRequestInit(params) {
|
|
979
949
|
var _this$fetchOptions, _params$fetchOptions, _params$fetchOptions2, _this$fetchOptions2;
|
|
980
|
-
return {
|
|
950
|
+
return await require_request.request(url, {
|
|
981
951
|
...this.fetchOptions,
|
|
982
952
|
...params === null || params === void 0 ? void 0 : params.fetchOptions,
|
|
983
953
|
headers: {
|
|
@@ -985,7 +955,7 @@ var Client = class {
|
|
|
985
955
|
...params === null || params === void 0 || (_params$fetchOptions = params.fetchOptions) === null || _params$fetchOptions === void 0 ? void 0 : _params$fetchOptions.headers
|
|
986
956
|
},
|
|
987
957
|
signal: (params === null || params === void 0 || (_params$fetchOptions2 = params.fetchOptions) === null || _params$fetchOptions2 === void 0 ? void 0 : _params$fetchOptions2.signal) || (params === null || params === void 0 ? void 0 : params.signal) || ((_this$fetchOptions2 = this.fetchOptions) === null || _this$fetchOptions2 === void 0 ? void 0 : _this$fetchOptions2.signal)
|
|
988
|
-
};
|
|
958
|
+
}, this.fetchFn);
|
|
989
959
|
}
|
|
990
960
|
};
|
|
991
961
|
|
package/dist/Client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.cjs","names":["#repositoryName","PrismicError","devMsg","isRepositoryEndpoint","getRepositoryName","getRepositoryEndpoint","#autoPreviews","#autoPreviewsRequest","request","NotFoundError","documents: TDocument[]","latestResult: Query<TDocument> | undefined","appendFilters","filter","typeFilter","someTagsFilter","everyTagFilter","#cachedRepository","#cachedRepositoryExpiration","#request","ForbiddenError","RepositoryNotFoundError","findRefByID","findRefByLabel","findMasterRef","#getResolvedRef","buildQueryURL","documentID: string | undefined | null","previewToken: string | undefined | null","asLink","#getRef","unsanitizedHeaders: Record<string, string>","headers: Record<string, string>","minifyGraphQLQuery","getPreviewCookie","ParsingError","RefNotFoundError","PreviewTokenExpiredError","RefExpiredError"],"sources":["../src/Client.ts"],"sourcesContent":["import { appendFilters } from \"./lib/appendFilters\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { everyTagFilter } from \"./lib/everyTagFilter\"\nimport { findMasterRef } from \"./lib/findMasterRef\"\nimport { findRefByID } from \"./lib/findRefByID\"\nimport { findRefByLabel } from \"./lib/findRefByLabel\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport { minifyGraphQLQuery } from \"./lib/minifyGraphQLQuery\"\nimport type { ResponseLike } from \"./lib/request\"\nimport {\n\ttype AbortSignalLike,\n\ttype FetchLike,\n\ttype RequestInitLike,\n\trequest,\n} from \"./lib/request\"\nimport { someTagsFilter } from \"./lib/someTagsFilter\"\nimport { throttledLog } from \"./lib/throttledLog\"\nimport { typeFilter } from \"./lib/typeFilter\"\n\nimport type { Query } from \"./types/api/query\"\nimport type { Ref } from \"./types/api/ref\"\nimport type { Repository } from \"./types/api/repository\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nimport { ForbiddenError } from \"./errors/ForbiddenError\"\nimport { NotFoundError } from \"./errors/NotFoundError\"\nimport { ParsingError } from \"./errors/ParsingError\"\nimport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\"\nimport { PrismicError } from \"./errors/PrismicError\"\nimport { RefExpiredError } from \"./errors/RefExpiredError\"\nimport { RefNotFoundError } from \"./errors/RefNotFoundError\"\nimport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\"\n\nimport type { LinkResolverFunction } from \"./helpers/asLink\"\nimport { asLink } from \"./helpers/asLink\"\n\nimport type { BuildQueryURLArgs } from \"./buildQueryURL\"\nimport { buildQueryURL } from \"./buildQueryURL\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\n\n/**\n * The largest page size allowed by the Prismic REST API V2. This value is used\n * to minimize the number of requests required to query content.\n */\nconst MAX_PAGE_SIZE = 100\n\n/**\n * The number of milliseconds in which repository metadata is considered valid.\n * A ref can be invalidated quickly depending on how frequently content is\n * updated in the Prismic repository. As such, repository's metadata can only be\n * considered valid for a short amount of time.\n */\nexport const REPOSITORY_CACHE_TTL = 5000\n\n/**\n * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,\n * `getAllByType`, `getAllByTag`) will wait between individual page requests.\n *\n * This is done to ensure API performance is sustainable and reduces the chance\n * of a failed API request due to overloading.\n */\nexport const GET_ALL_QUERY_DELAY = 500\n\n/**\n * The maximum number of attempts to retry a query with an invalid ref. We allow\n * multiple attempts since each attempt may use a different (and possibly\n * invalid) ref. Capping the number of attempts prevents infinite loops.\n */\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends PrismicDocument,\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * The minimum required properties to treat as an HTTP Request for automatic\n * Prismic preview support.\n */\nexport type HttpRequestLike =\n\t| /**\n\t * Web API Request\n\t *\n\t * @see http://developer.mozilla.org/en-US/docs/Web/API/Request\n\t */\n\t{\n\t\t\theaders?: {\n\t\t\t\tget(name: string): string | null\n\t\t\t}\n\t\t\turl?: string\n\t }\n\n\t/**\n\t * Express-style Request\n\t */\n\t| {\n\t\t\theaders?: {\n\t\t\t\tcookie?: string\n\t\t\t}\n\t\t\tquery?: Record<string, unknown>\n\t }\n\n/**\n * A function that returns a ref string. Used to configure which ref the client\n * queries content from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/**\n * Parameters for any client method that use `fetch()`.\n */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These\n\t * options will be merged with internally required options. They can also be\n\t * overriden on a per-query basis using the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\n\t/**\n\t * An `AbortSignal` provided by an `AbortController`. This allows the network\n\t * request to be cancelled if necessary.\n\t *\n\t * @deprecated Move the `signal` parameter into `fetchOptions.signal`:\n\t *\n\t * @see \\<https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\\>\n\t */\n\tsignal?: AbortSignalLike\n}\n\n/**\n * Configuration for clients that determine how content is queried.\n */\nexport type ClientConfig = {\n\t/**\n\t * The full Rest API V2 endpoint for the repository. This is only helpful if\n\t * you're using Prismic behind a proxy which we do not recommend.\n\t *\n\t * @defaultValue `getRepositoryEndpoint(repositoryNameOrEndpoint)`\n\t */\n\tdocumentAPIEndpoint?: string\n\n\t/**\n\t * The secure token for accessing the Prismic repository. This is only\n\t * required if the repository is set to private.\n\t */\n\taccessToken?: string\n\n\t/**\n\t * A string representing a version of the Prismic repository's content. This\n\t * may point to the latest version (called the \"master ref\"), or a preview\n\t * with draft content.\n\t */\n\tref?: string | GetRef\n\n\t/**\n\t * A list of route resolver objects that define how a document's `url`\n\t * property is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\n\t/**\n\t * Default parameters that will be sent with each query. These parameters can\n\t * be overridden on each query if needed.\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\n\t/**\n\t * The function used to make network requests to the Prismic REST API. In\n\t * environments where a global `fetch` function does not exist, such as\n\t * Node.js, this function must be provided.\n\t */\n\tfetch?: FetchLike\n\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These\n\t * options will be merged with internally required options. They can also be\n\t * overriden on a per-query basis using the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods\n * start with `getAll` (for example, `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried. If a number is not provided, there\n\t * will be no limit and all matching documents will be returned.\n\t */\n\tlimit?: number\n}\n\n/**\n * Arguments to determine how the URL for a preview session is resolved.\n */\ntype ResolvePreviewArgs<LinkResolverReturnType> = {\n\t/**\n\t * A function that maps a Prismic document to a URL within your app.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\n\t/**\n\t * A fallback URL if the link resolver does not return a value.\n\t */\n\tdefaultURL: string\n\n\t/**\n\t * The preview token (also known as a ref) that will be used to query preview\n\t * content from the Prismic repository.\n\t */\n\tpreviewToken?: string\n\n\t/**\n\t * The previewed document that will be used to determine the destination URL.\n\t */\n\tdocumentID?: string\n}\n\n/**\n * A client that allows querying content from a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable,\n * such as Node.js, the `fetch` option must be provided as part of the `options`\n * parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The function used to make network requests to the Prismic REST API. In\n\t * environments where a global `fetch` function does not exist, such as\n\t * Node.js, this function must be provided.\n\t */\n\tfetchFn: FetchLike\n\n\tfetchOptions?: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t/**\n\t * The Prismic repository's name.\n\t */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\n\t/**\n\t * The Prismic repository's name.\n\t */\n\tget repositoryName(): string {\n\t\tif (!this.#repositoryName) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`A repository name is required for this method but one could not be inferred from the provided API endpoint (\\`${this.documentAPIEndpoint}\\`). To fix this error, provide a repository name when creating the client. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn this.#repositoryName\n\t}\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t */\n\tdocumentAPIEndpoint: string\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t *\n\t * @deprecated Use `documentAPIEndpoint` instead.\n\t */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t *\n\t * @deprecated Use `documentAPIEndpoint` instead.\n\t */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\n\t}\n\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * A list of route resolver objects that define how a document's `url` field\n\t * is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\n\t/**\n\t * Default parameters that will be sent with each query. These parameters can\n\t * be overridden on each query if needed.\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\"\n\t>\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0\n\n\t/**\n\t * Creates a Prismic client that can be used to query a repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable,\n\t * such as in some Node.js versions, the `fetch` option must be provided as\n\t * part of the `options` parameter.\n\t *\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest\n\t * API V2 endpoint for the repository.\n\t * @param options - Configuration that determines how content will be queried\n\t * from the Prismic repository.\n\t *\n\t * @returns A client that can query content from the repository.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, options: ClientConfig = {}) {\n\t\tthis.fetchOptions = options.fetchOptions\n\n\t\tif (typeof options.fetch === \"function\") {\n\t\t\tthis.fetchFn = options.fetch\n\t\t} else if (typeof globalThis.fetch === \"function\") {\n\t\t\tthis.fetchFn = globalThis.fetch as FetchLike\n\t\t} else {\n\t\t\tthrow new PrismicError(\n\t\t\t\t\"A valid fetch implementation was not provided. In environments where fetch is not available (including Node.js), a fetch implementation must be provided via a polyfill or the `fetch` option.\",\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\t// If the global fetch function is used, we must bind it to the global scope.\n\t\tif (this.fetchFn === globalThis.fetch) {\n\t\t\tthis.fetchFn = this.fetchFn.bind(globalThis)\n\t\t}\n\n\t\tif (\n\t\t\t(options.documentAPIEndpoint ||\n\t\t\t\tisRepositoryEndpoint(repositoryNameOrEndpoint)) &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tconst documentAPIEndpoint =\n\t\t\t\toptions.documentAPIEndpoint || repositoryNameOrEndpoint\n\n\t\t\t// Matches non-API v2 `.prismic.io` endpoints, see: https://regex101.com/r/xRsavu/1\n\t\t\tif (/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(documentAPIEndpoint)) {\n\t\t\t\tthrow new PrismicError(\n\t\t\t\t\t\"@prismicio/client only supports Prismic Rest API V2. Please provide only the repository name to the first createClient() parameter or use the getRepositoryEndpoint() helper to generate a valid Rest API V2 endpoint URL.\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tconst hostname = new URL(documentAPIEndpoint).hostname.toLowerCase()\n\n\t\t\t// Matches non-.cdn `.prismic.io` endpoints\n\t\t\tif (\n\t\t\t\thostname.endsWith(\".prismic.io\") &&\n\t\t\t\t!hostname.endsWith(\".cdn.prismic.io\")\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${devMsg(\"endpoint-must-use-cdn\")}`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\t// Warn if the user provided both a repository endpoint and an `documentAPIEndpoint` and they are different\n\t\t\tif (\n\t\t\t\toptions.documentAPIEndpoint &&\n\t\t\t\tisRepositoryEndpoint(repositoryNameOrEndpoint) &&\n\t\t\t\trepositoryNameOrEndpoint !== options.documentAPIEndpoint\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[@prismicio/client] Multiple incompatible endpoints were provided. Create the client using a repository name to prevent this error. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\tif (isRepositoryEndpoint(repositoryNameOrEndpoint)) {\n\t\t\tthis.documentAPIEndpoint = repositoryNameOrEndpoint\n\t\t\ttry {\n\t\t\t\tthis.repositoryName = getRepositoryName(repositoryNameOrEndpoint)\n\t\t\t} catch {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[@prismicio/client] A repository name could not be inferred from the provided endpoint (\\`${repositoryNameOrEndpoint}\\`). Some methods will be disabled. Create the client using a repository name to prevent this warning. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\tthis.documentAPIEndpoint =\n\t\t\t\toptions.documentAPIEndpoint ||\n\t\t\t\tgetRepositoryEndpoint(repositoryNameOrEndpoint)\n\t\t\tthis.repositoryName = repositoryNameOrEndpoint\n\t\t}\n\n\t\tthis.accessToken = options.accessToken\n\t\tthis.routes = options.routes\n\t\tthis.brokenRoute = options.brokenRoute\n\t\tthis.defaultParams = options.defaultParams\n\n\t\tif (options.ref) {\n\t\t\tthis.queryContentFromRef(options.ref)\n\t\t}\n\n\t\tthis.graphQLFetch = this.graphQLFetch.bind(this)\n\t}\n\n\t/**\n\t * Enables the client to automatically query content from a preview session.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.enableAutoPreviews()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}\n\t */\n\tenableAutoPreviews(): void {\n\t\tthis.#autoPreviews = true\n\t}\n\n\t/**\n\t * Enables the client to automatically query content from a preview session\n\t * using an HTTP request object.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.enableAutoPreviewsFromReq(req)\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}\n\t */\n\tenableAutoPreviewsFromReq(request: HttpRequestLike): void {\n\t\tthis.enableAutoPreviews()\n\t\tthis.#autoPreviewsRequest = request\n\t}\n\n\t/**\n\t * Disables the client from automatically querying content from a preview\n\t * session.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.disableAutoPreviews()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}\n\t */\n\tdisableAutoPreviews(): void {\n\t\tthis.#autoPreviews = false\n\t\tthis.#autoPreviewsRequest = undefined\n\t}\n\n\t/**\n\t * Fetches pages based on the `params` argument. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.get({ pageSize: 10 })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}\n\t */\n\tasync get<TDocument extends TDocuments>(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\tconst { data } = await this._get<TDocument>(params)\n\n\t\treturn data\n\t}\n\n\t/**\n\t * Fetches the first page returned based on the `params` argument.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getFirst()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}\n\t */\n\tasync getFirst<TDocument extends TDocuments>(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<TDocument> {\n\t\tconst actualParams = { ...params }\n\t\tif (!(params && params.page) && !params?.pageSize) {\n\t\t\tactualParams.pageSize = this.defaultParams?.pageSize ?? 1\n\t\t}\n\t\tconst { data, url } = await this._get<TDocument>(actualParams)\n\n\t\tconst firstResult = data.results[0]\n\n\t\tif (firstResult) {\n\t\t\treturn firstResult\n\t\t}\n\n\t\tthrow new NotFoundError(\"No documents were returned\", url, undefined)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.dangerouslyGetAll()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}\n\t */\n\tasync dangerouslyGetAll<TDocument extends TDocuments>(\n\t\tparams: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams = {},\n\t): Promise<TDocument[]> {\n\t\tconst { limit = Infinity, ...actualParams } = params\n\t\tconst resolvedParams = {\n\t\t\t...actualParams,\n\t\t\tpageSize: Math.min(\n\t\t\t\tlimit,\n\t\t\t\tactualParams.pageSize || this.defaultParams?.pageSize || MAX_PAGE_SIZE,\n\t\t\t),\n\t\t}\n\n\t\tconst documents: TDocument[] = []\n\t\tlet latestResult: Query<TDocument> | undefined\n\n\t\twhile (\n\t\t\t(!latestResult || latestResult.next_page) &&\n\t\t\tdocuments.length < limit\n\t\t) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tlatestResult = await this.get<TDocument>({ ...resolvedParams, page })\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\tif (latestResult.next_page) {\n\t\t\t\tawait new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY))\n\t\t\t}\n\t\t}\n\n\t\treturn documents.slice(0, limit)\n\t}\n\n\t/**\n\t * Fetches a page with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}\n\t */\n\tasync getByID<TDocument extends TDocuments>(\n\t\tid: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<TDocument> {\n\t\treturn await this.getFirst<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.id\", id)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByIDs([\n\t * \t\"WW4bKScAAMAqmluX\",\n\t * \t\"U1kTRgEAAC8A5ldS\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}\n\t */\n\tasync getByIDs<TDocument extends TDocuments>(\n\t\tids: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, filter.in(\"document.id\", ids)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByIDs([\n\t * \t\"WW4bKScAAMAqmluX\",\n\t * \t\"U1kTRgEAAC8A5ldS\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}\n\t */\n\tasync getAllByIDs<TDocument extends TDocuments>(\n\t\tids: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.in(\"document.id\", ids)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches a page with a specific UID and type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}\n\t */\n\tasync getByUID<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuid: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>> {\n\t\treturn await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.at(`my.${documentType}.uid`, uid),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific UIDs and a specific type. Results are\n\t * paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByUIDs(\"blog_post\", [\n\t * \t\"my-first-post\",\n\t * \t\"my-second-post\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}\n\t */\n\tasync getByUIDs<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuids: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>> {\n\t\treturn await this.get<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.in(`my.${documentType}.uid`, uids),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific UIDs and a specific type. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByUIDs(\"blog_post\", [\n\t * \t\"my-first-post\",\n\t * \t\"my-second-post\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}\n\t */\n\tasync getAllByUIDs<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuids: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<\n\t\t\tExtractDocumentType<TDocument, TDocumentType>\n\t\t>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.in(`my.${documentType}.uid`, uids),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches a specific single type page.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getSingle(\"settings\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}\n\t */\n\tasync getSingle<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>> {\n\t\treturn await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, typeFilter(documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByType(\"blog_post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}\n\t */\n\tasync getByType<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>> {\n\t\treturn await this.get<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, typeFilter(documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByType(\"blog_post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}\n\t */\n\tasync getAllByType<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<\n\t\t\tExtractDocumentType<TDocument, TDocumentType>\n\t\t>(appendFilters(params, typeFilter(documentType)))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByTag(\"featured\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}\n\t */\n\tasync getByTag<TDocument extends TDocuments>(\n\t\ttag: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(appendFilters(params, someTagsFilter(tag)))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByTag(\"featured\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}\n\t */\n\tasync getAllByTag<TDocument extends TDocuments>(\n\t\ttag: string,\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tag)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}\n\t */\n\tasync getByEveryTag<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, everyTagFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}\n\t */\n\tasync getAllByEveryTag<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, everyTagFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. Results are\n\t * paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}\n\t */\n\tasync getBySomeTags<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may\n\t * make multiple network requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}\n\t */\n\tasync getAllBySomeTags<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches metadata about the client's Prismic repository.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const repository = await client.getRepository()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}\n\t */\n\tasync getRepository(\n\t\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n\t): Promise<Repository> {\n\t\tif (\n\t\t\tthis.#cachedRepository &&\n\t\t\tthis.#cachedRepositoryExpiration > Date.now()\n\t\t) {\n\t\t\treturn this.#cachedRepository\n\t\t}\n\n\t\tconst url = new URL(this.documentAPIEndpoint)\n\n\t\tconst accessToken = params?.accessToken || this.accessToken\n\t\tif (accessToken) {\n\t\t\turl.searchParams.set(\"access_token\", accessToken)\n\t\t}\n\n\t\tconst response = await this.#request(url, params)\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tthis.#cachedRepository = (await response.json()) as Repository\n\t\t\t\tthis.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL\n\n\t\t\t\treturn this.#cachedRepository\n\t\t\t}\n\t\t\tcase 401: {\n\t\t\t\tconst json = await response.json()\n\t\t\t\tthrow new ForbiddenError(json.error, url.toString(), json)\n\t\t\t}\n\t\t\tcase 404: {\n\t\t\t\tthrow new RepositoryNotFoundError(\n\t\t\t\t\t`Prismic repository not found. Check that \"${this.documentAPIEndpoint}\" is pointing to the correct repository.`,\n\t\t\t\t\turl.toString(),\n\t\t\t\t\tundefined,\n\t\t\t\t)\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new PrismicError(undefined, url.toString(), await response.text())\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Fetches the repository's active refs.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const refs = await client.getRefs()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}\n\t */\n\tasync getRefs(params?: FetchParams): Promise<Ref[]> {\n\t\tconst repository = await this.getRepository(params)\n\n\t\treturn repository.refs\n\t}\n\n\t/**\n\t * Fetches a ref by its ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}\n\t */\n\tasync getRefByID(id: string, params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findRefByID(refs, id)\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the\n\t * Page Builder.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const ref = await client.getRefByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}\n\t */\n\tasync getRefByLabel(label: string, params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findRefByLabel(refs, label)\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const masterRef = await client.getMasterRef()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}\n\t */\n\tasync getMasterRef(params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findMasterRef(refs)\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const releases = await client.getReleases()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}\n\t */\n\tasync getReleases(params?: FetchParams): Promise<Ref[]> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn refs.filter((ref) => !ref.isMasterRef)\n\t}\n\n\t/**\n\t * Fetches a release with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}\n\t */\n\tasync getReleaseByID(id: string, params?: FetchParams): Promise<Ref> {\n\t\tconst releases = await this.getReleases(params)\n\n\t\treturn findRefByID(releases, id)\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in\n\t * the Page Builder.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const release = await client.getReleaseByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}\n\t */\n\tasync getReleaseByLabel(label: string, params?: FetchParams): Promise<Ref> {\n\t\tconst releases = await this.getReleases(params)\n\n\t\treturn findRefByLabel(releases, label)\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const tags = await client.getTags()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}\n\t */\n\tasync getTags(params?: FetchParams): Promise<string[]> {\n\t\tconst repository = await this.getRepository(params)\n\t\tconst form = repository.forms.tags\n\t\tif (form) {\n\t\t\tconst url = new URL(form.action)\n\t\t\tif (this.accessToken) {\n\t\t\t\turl.searchParams.set(\"access_token\", this.accessToken)\n\t\t\t}\n\n\t\t\tconst response = await this.#request(url, params)\n\t\t\tif (response.ok) {\n\t\t\t\treturn (await response.json()) as string[]\n\t\t\t}\n\t\t}\n\n\t\treturn repository.tags\n\t}\n\n\t/**\n\t * Builds a Content API query URL with a set of parameters.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = await client.buildQueryURL({\n\t * \tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}\n\t */\n\tasync buildQueryURL({\n\t\tsignal,\n\t\tfetchOptions,\n\t\t...params\n\t}: Partial<BuildQueryURLArgs> & FetchParams = {}): Promise<string> {\n\t\tconst ref =\n\t\t\tparams.ref ||\n\t\t\t(await this.#getResolvedRef({\n\t\t\t\taccessToken: params.accessToken,\n\t\t\t\tsignal,\n\t\t\t\tfetchOptions,\n\t\t\t}))\n\t\tconst integrationFieldsRef =\n\t\t\tparams.integrationFieldsRef ||\n\t\t\t(\n\t\t\t\tawait this.getRepository({\n\t\t\t\t\taccessToken: params.accessToken,\n\t\t\t\t\tsignal,\n\t\t\t\t\tfetchOptions,\n\t\t\t\t})\n\t\t\t).integrationFieldsRef ||\n\t\t\tundefined\n\n\t\treturn buildQueryURL(this.documentAPIEndpoint, {\n\t\t\t...this.defaultParams,\n\t\t\t...params,\n\t\t\tref,\n\t\t\tintegrationFieldsRef,\n\t\t\troutes: params.routes || this.routes,\n\t\t\tbrokenRoute: params.brokenRoute || this.brokenRoute,\n\t\t\taccessToken: params.accessToken || this.accessToken,\n\t\t})\n\t}\n\n\t/**\n\t * Fetches a previewed page's URL using a preview token and page ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = await client.resolvePreviewURL({\n\t * \tlinkResolver,\n\t * \tdefaultURL: \"/\",\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}\n\t */\n\tasync resolvePreviewURL<LinkResolverReturnType>(\n\t\targs: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams,\n\t): Promise<string> {\n\t\tlet documentID: string | undefined | null = args.documentID\n\t\tlet previewToken: string | undefined | null = args.previewToken\n\n\t\tif (typeof globalThis.location !== \"undefined\") {\n\t\t\tconst searchParams = new URLSearchParams(globalThis.location.search)\n\n\t\t\tdocumentID = documentID || searchParams.get(\"documentId\")\n\t\t\tpreviewToken = previewToken || searchParams.get(\"token\")\n\t\t} else if (this.#autoPreviewsRequest) {\n\t\t\tif (\"query\" in this.#autoPreviewsRequest) {\n\t\t\t\tdocumentID =\n\t\t\t\t\tdocumentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken =\n\t\t\t\t\tpreviewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\n\t\t\t\t\"url\" in this.#autoPreviewsRequest &&\n\t\t\t\tthis.#autoPreviewsRequest.url\n\t\t\t) {\n\t\t\t\t// Including \"missing-host://\" by default\n\t\t\t\t// handles a case where Next.js Route Handlers\n\t\t\t\t// only provide the pathname and search\n\t\t\t\t// parameters in the `url` property\n\t\t\t\t// (e.g. `/api/preview?foo=bar`).\n\t\t\t\tconst searchParams = new URL(\n\t\t\t\t\tthis.#autoPreviewsRequest.url,\n\t\t\t\t\t\"missing-host://\",\n\t\t\t\t).searchParams\n\n\t\t\t\tdocumentID = documentID || searchParams.get(\"documentId\")\n\t\t\t\tpreviewToken = previewToken || searchParams.get(\"token\")\n\t\t\t}\n\t\t}\n\n\t\tif (documentID != null && previewToken != null) {\n\t\t\tconst document = await this.getByID(documentID, {\n\t\t\t\tref: previewToken,\n\t\t\t\tlang: \"*\",\n\t\t\t\tsignal: args.signal,\n\t\t\t\tfetchOptions: args.fetchOptions,\n\t\t\t})\n\n\t\t\tconst url = asLink(document, { linkResolver: args.linkResolver })\n\n\t\t\tif (typeof url === \"string\") {\n\t\t\t\treturn url\n\t\t\t}\n\t\t}\n\n\t\treturn args.defaultURL\n\t}\n\n\t/**\n\t * Configures the client to query the latest published content. This is the\n\t * client's default mode.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryLatestContent()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}\n\t */\n\tqueryLatestContent(): void {\n\t\tthis.#getRef = undefined\n\t}\n\n\t/**\n\t * Configures the client to query content from a release with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}\n\t */\n\tqueryContentFromReleaseByID(id: string): void {\n\t\tthis.#getRef = async (params) => {\n\t\t\tconst release = await this.getReleaseByID(id, params)\n\t\t\treturn release.ref\n\t\t}\n\t}\n\n\t/**\n\t * Configures the client to query content from a release with a specific\n\t * label.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromReleaseByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}\n\t */\n\tqueryContentFromReleaseByLabel(label: string): void {\n\t\tthis.#getRef = async (params) => {\n\t\t\tconst release = await this.getReleaseByLabel(label, params)\n\t\t\treturn release.ref\n\t\t}\n\t}\n\n\t/**\n\t * Configures the client to query content from a specific ref.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromRef(\"my-ref\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}\n\t */\n\tqueryContentFromRef(ref: string | GetRef): void {\n\t\tthis.#getRef = typeof ref === \"string\" ? () => ref : ref\n\t}\n\n\t/**\n\t * A preconfigured `fetch()` function for Prismic's GraphQL API that can be\n\t * provided to GraphQL clients.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * import { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * const client = createClient(\"example-prismic-repo\")\n\t * const graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \t\turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t\t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \t\tfetch: client.graphQLFetch,\n\t * \t\t// Using GET is required.\n\t * \t\tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}\n\t */\n\tasync graphQLFetch(\n\t\tinput: RequestInfo,\n\t\tinit?: Omit<RequestInit, \"signal\"> & { signal?: AbortSignalLike },\n\t): Promise<Response> {\n\t\tconst repository = await this.getRepository()\n\t\tconst ref = await this.#getResolvedRef()\n\n\t\tconst unsanitizedHeaders: Record<string, string> = {\n\t\t\t\"Prismic-ref\": ref,\n\t\t\tAuthorization: this.accessToken ? `Token ${this.accessToken}` : \"\",\n\t\t\t// Asserting `init.headers` is a Record since popular GraphQL\n\t\t\t// libraries pass this as a Record. Header objects as input\n\t\t\t// are unsupported.\n\t\t\t...(init ? (init.headers as Record<string, string>) : {}),\n\t\t}\n\n\t\tif (repository.integrationFieldsRef) {\n\t\t\tunsanitizedHeaders[\"Prismic-integration-field-ref\"] =\n\t\t\t\trepository.integrationFieldsRef\n\t\t}\n\n\t\t// Normalize header keys to lowercase. This prevents header\n\t\t// conflicts between the Prismic client and the GraphQL\n\t\t// client.\n\t\tconst headers: Record<string, string> = {}\n\t\tfor (const key in unsanitizedHeaders) {\n\t\t\tif (unsanitizedHeaders[key]) {\n\t\t\t\theaders[key.toLowerCase()] =\n\t\t\t\t\tunsanitizedHeaders[key as keyof typeof unsanitizedHeaders]\n\t\t\t}\n\t\t}\n\n\t\tconst url = new URL(\n\t\t\t// Asserting `input` is a string since popular GraphQL\n\t\t\t// libraries pass this as a string. Request objects as\n\t\t\t// input are unsupported.\n\t\t\tinput as string,\n\t\t)\n\n\t\t// This prevents the request from being cached unnecessarily.\n\t\t// Without adding this `ref` param, re-running a query\n\t\t// could return a locally cached response, even if the\n\t\t// `ref` changed. This happens because the URL is\n\t\t// identical when the `ref` is not included. Caches may ignore\n\t\t// headers.\n\t\t//\n\t\t// The Prismic GraphQL API ignores the `ref` param.\n\t\turl.searchParams.set(\"ref\", ref)\n\n\t\tconst query = url.searchParams.get(\"query\")\n\t\tif (query) {\n\t\t\turl.searchParams.set(\n\t\t\t\t\"query\",\n\t\t\t\t// Compress the GraphQL query (if it exists) by\n\t\t\t\t// removing whitespace. This is done to\n\t\t\t\t// optimize the query size and avoid\n\t\t\t\t// hitting the upper limit of GET requests\n\t\t\t\t// (2048 characters).\n\t\t\t\tminifyGraphQLQuery(query),\n\t\t\t)\n\t\t}\n\n\t\treturn (await this.fetchFn(url.toString(), {\n\t\t\t...init,\n\t\t\theaders,\n\t\t})) as Response\n\t}\n\n\t/**\n\t * Returns the ref needed to query based on the client's current state. This\n\t * method may make a network request to fetch a ref or resolve the user's ref\n\t * thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority if available.\n\t *\n\t * The following strategies are used depending on the client's state:\n\t *\n\t * - If the user called `queryLatestContent`: Use the repository's master ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new master ref is\n\t * fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new ref for the\n\t * release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new ref for the\n\t * release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back\n\t * to the master ref if the ref is not a string.\n\t *\n\t * @returns The ref to use during a query.\n\t */\n\tasync #getResolvedRef(\n\t\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n\t) {\n\t\tif (this.#autoPreviews) {\n\t\t\tconst cookies = this.#autoPreviewsRequest?.headers\n\t\t\t\t? \"get\" in this.#autoPreviewsRequest.headers\n\t\t\t\t\t? this.#autoPreviewsRequest.headers.get(\"cookie\")\n\t\t\t\t\t: this.#autoPreviewsRequest.headers.cookie\n\t\t\t\t: globalThis.document?.cookie\n\t\t\tconst previewRef = getPreviewCookie(cookies ?? \"\")\n\t\t\tif (previewRef) {\n\t\t\t\treturn previewRef\n\t\t\t}\n\t\t}\n\n\t\tconst ref = await this.#getRef?.(params)\n\t\tif (ref) {\n\t\t\treturn ref\n\t\t}\n\n\t\tconst masterRef = await this.getMasterRef(params)\n\t\treturn masterRef.ref\n\t}\n\n\t/**\n\t * The private implementation of `this.get`. It returns the API response and\n\t * the URL used to make the request. The URL is sometimes used in the public\n\t * method to include in thrown errors.\n\t *\n\t * This method retries requests that throw `RefNotFoundError` or\n\t * `RefExpiredError`. It contains special logic to retry with the latest\n\t * master ref, provided in the API's error message.\n\t *\n\t * @typeParam TDocument - Type of Prismic documents returned.\n\t *\n\t * @param params - Parameters to filter, sort, and paginate results.\n\t *\n\t * @returns An object containing the paginated response containing the result\n\t * of the query and the URL used to make the API request.\n\t */\n\tprivate async _get<TDocument extends TDocuments>(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t\tattemptCount = 0,\n\t): Promise<{ data: Query<TDocument>; url: string }> {\n\t\tconst url = await this.buildQueryURL(params)\n\n\t\ttry {\n\t\t\tconst response = await this.#request(new URL(url), params)\n\t\t\tswitch (response.status) {\n\t\t\t\tcase 200: {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tdata: (await response.clone().json()) as Query<TDocument>,\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tthrow new PrismicError(undefined, url, await response.text())\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase 400: {\n\t\t\t\t\tconst json = await response.json()\n\t\t\t\t\tthrow new ParsingError(json.message, url, json)\n\t\t\t\t}\n\t\t\t\tcase 401: {\n\t\t\t\t\tconst json = await response.json()\n\t\t\t\t\tthrow new ForbiddenError(json.message, url, json)\n\t\t\t\t}\n\t\t\t\tcase 404: {\n\t\t\t\t\tconst json = await response.json()\n\t\t\t\t\tswitch (json.type) {\n\t\t\t\t\t\tcase \"api_notfound_error\": {\n\t\t\t\t\t\t\tthrow new RefNotFoundError(json.message, url, json)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase \"api_security_error\": {\n\t\t\t\t\t\t\tif (/preview token.*expired/i.test(json.message)) {\n\t\t\t\t\t\t\t\tthrow new PreviewTokenExpiredError(json.message, url, json)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tthrow new NotFoundError(json.message, url, json)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcase 410: {\n\t\t\t\t\tconst json = await response.json()\n\t\t\t\t\tthrow new RefExpiredError(json.message, url, json)\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new PrismicError(undefined, url, await response.text())\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t!(\n\t\t\t\t\terror instanceof RefNotFoundError || error instanceof RefExpiredError\n\t\t\t\t) ||\n\t\t\t\tattemptCount >= MAX_INVALID_REF_RETRY_ATTEMPTS - 1\n\t\t\t) {\n\t\t\t\tthrow error\n\t\t\t}\n\n\t\t\t// If no explicit ref is given (i.e. the master ref from\n\t\t\t// /api/v2 is used), clear the cached repository value.\n\t\t\t// Clearing the cached value prevents other methods from\n\t\t\t// using a known-stale ref.\n\t\t\tif (!params?.ref) {\n\t\t\t\tthis.#cachedRepository = undefined\n\t\t\t}\n\n\t\t\tconst masterRef = error.message.match(/master ref is: (?<ref>.*)$/i)\n\t\t\t\t?.groups?.ref\n\t\t\tif (!masterRef) {\n\t\t\t\tthrow error\n\t\t\t}\n\n\t\t\tconst badRef = new URL(url).searchParams.get(\"ref\")\n\t\t\tconst issue = error instanceof RefNotFoundError ? \"invalid\" : \"expired\"\n\t\t\tthrottledLog(\n\t\t\t\t`[@prismicio/client] The ref (${badRef}) was ${issue}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`,\n\t\t\t\t{ level: \"warn\" },\n\t\t\t)\n\n\t\t\treturn await this._get({ ...params, ref: masterRef }, attemptCount + 1)\n\t\t}\n\t}\n\n\t/**\n\t * Makes an HTTP request using the client's configured fetch function and\n\t * options.\n\t *\n\t * @param url - The URL to request.\n\t * @param params - Fetch options.\n\t *\n\t * @returns The response from the fetch request.\n\t */\n\tasync #request(url: URL, params?: RequestInitLike): Promise<ResponseLike> {\n\t\treturn await request(url, this._buildRequestInit(params), this.fetchFn)\n\t}\n\n\tprotected _buildRequestInit(params?: FetchParams): RequestInitLike {\n\t\treturn {\n\t\t\t...this.fetchOptions,\n\t\t\t...params?.fetchOptions,\n\t\t\theaders: {\n\t\t\t\t...this.fetchOptions?.headers,\n\t\t\t\t...params?.fetchOptions?.headers,\n\t\t\t},\n\t\t\tsignal:\n\t\t\t\tparams?.fetchOptions?.signal ||\n\t\t\t\tparams?.signal ||\n\t\t\t\tthis.fetchOptions?.signal,\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,gBAAgB;;;;;;;AAQtB,MAAa,uBAAuB;;;;;;;;AASpC,MAA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QAAiD;AACzE,SAAO,MAAMX,wBAAQ,KAAK,KAAK,kBAAkB,OAAO,EAAE,KAAK,QAAQ;;CAGxE,AAAU,kBAAkB,QAAuC;;AAClE,SAAO;GACN,GAAG,KAAK;GACR,mDAAG,OAAQ;GACX,SAAS;IACR,yBAAG,KAAK,sFAAc;IACtB,mEAAG,OAAQ,0FAAc;IACzB;GACD,0EACC,OAAQ,4FAAc,4DACtB,OAAQ,mCACR,KAAK,wFAAc;GACpB"}
|
|
1
|
+
{"version":3,"file":"Client.cjs","names":["#repositoryName","PrismicError","devMsg","isRepositoryEndpoint","getRepositoryName","getRepositoryEndpoint","#autoPreviews","#autoPreviewsRequest","request","#internalGet","NotFoundError","documents: TDocument[]","latestResult: Query<TDocument> | undefined","appendFilters","filter","typeFilter","someTagsFilter","everyTagFilter","#cachedRepository","#cachedRepositoryExpiration","#request","RepositoryNotFoundError","#throwContentAPIError","findRefByID","findRefByLabel","findMasterRef","#getResolvedRef","buildQueryURL","documentID: string | undefined | null","previewToken: string | undefined | null","asLink","#getRef","unsanitizedHeaders: Record<string, string>","headers: Record<string, string>","minifyGraphQLQuery","getPreviewCookie","RefNotFoundError","RefExpiredError","ParsingError","ForbiddenError","PreviewTokenExpiredError"],"sources":["../src/Client.ts"],"sourcesContent":["import { appendFilters } from \"./lib/appendFilters\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { everyTagFilter } from \"./lib/everyTagFilter\"\nimport { findMasterRef } from \"./lib/findMasterRef\"\nimport { findRefByID } from \"./lib/findRefByID\"\nimport { findRefByLabel } from \"./lib/findRefByLabel\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport { minifyGraphQLQuery } from \"./lib/minifyGraphQLQuery\"\nimport type { ResponseLike } from \"./lib/request\"\nimport {\n\ttype AbortSignalLike,\n\ttype FetchLike,\n\ttype RequestInitLike,\n\trequest,\n} from \"./lib/request\"\nimport { someTagsFilter } from \"./lib/someTagsFilter\"\nimport { throttledLog } from \"./lib/throttledLog\"\nimport { typeFilter } from \"./lib/typeFilter\"\n\nimport type { Query } from \"./types/api/query\"\nimport type { Ref } from \"./types/api/ref\"\nimport type { Repository } from \"./types/api/repository\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nimport { ForbiddenError } from \"./errors/ForbiddenError\"\nimport { NotFoundError } from \"./errors/NotFoundError\"\nimport { ParsingError } from \"./errors/ParsingError\"\nimport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\"\nimport { PrismicError } from \"./errors/PrismicError\"\nimport { RefExpiredError } from \"./errors/RefExpiredError\"\nimport { RefNotFoundError } from \"./errors/RefNotFoundError\"\nimport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\"\n\nimport type { LinkResolverFunction } from \"./helpers/asLink\"\nimport { asLink } from \"./helpers/asLink\"\n\nimport type { BuildQueryURLArgs } from \"./buildQueryURL\"\nimport { buildQueryURL } from \"./buildQueryURL\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\n\n/**\n * The largest page size allowed by the Prismic REST API V2. This value is used\n * to minimize the number of requests required to query content.\n */\nconst MAX_PAGE_SIZE = 100\n\n/**\n * The number of milliseconds in which repository metadata is considered valid.\n * A ref can be invalidated quickly depending on how frequently content is\n * updated in the Prismic repository. As such, repository's metadata can only be\n * considered valid for a short amount of time.\n */\nexport const REPOSITORY_CACHE_TTL = 5000\n\n/**\n * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,\n * `getAllByType`, `getAllByTag`) will wait between individual page requests.\n *\n * This is done to ensure API performance is sustainable and reduces the chance\n * of a failed API request due to overloading.\n */\nexport const GET_ALL_QUERY_DELAY = 500\n\n/**\n * The maximum number of attempts to retry a query with an invalid ref. We allow\n * multiple attempts since each attempt may use a different (and possibly\n * invalid) ref. Capping the number of attempts prevents infinite loops.\n */\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends PrismicDocument,\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * The minimum required properties to treat as an HTTP Request for automatic\n * Prismic preview support.\n */\nexport type HttpRequestLike =\n\t| /**\n\t * Web API Request\n\t *\n\t * @see http://developer.mozilla.org/en-US/docs/Web/API/Request\n\t */\n\t{\n\t\t\theaders?: {\n\t\t\t\tget(name: string): string | null\n\t\t\t}\n\t\t\turl?: string\n\t }\n\n\t/**\n\t * Express-style Request\n\t */\n\t| {\n\t\t\theaders?: {\n\t\t\t\tcookie?: string\n\t\t\t}\n\t\t\tquery?: Record<string, unknown>\n\t }\n\n/**\n * A function that returns a ref string. Used to configure which ref the client\n * queries content from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/**\n * Parameters for any client method that use `fetch()`.\n */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These\n\t * options will be merged with internally required options. They can also be\n\t * overriden on a per-query basis using the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\n\t/**\n\t * An `AbortSignal` provided by an `AbortController`. This allows the network\n\t * request to be cancelled if necessary.\n\t *\n\t * @deprecated Move the `signal` parameter into `fetchOptions.signal`:\n\t *\n\t * @see \\<https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\\>\n\t */\n\tsignal?: AbortSignalLike\n}\n\n/**\n * Configuration for clients that determine how content is queried.\n */\nexport type ClientConfig = {\n\t/**\n\t * The full Rest API V2 endpoint for the repository. This is only helpful if\n\t * you're using Prismic behind a proxy which we do not recommend.\n\t *\n\t * @defaultValue `getRepositoryEndpoint(repositoryNameOrEndpoint)`\n\t */\n\tdocumentAPIEndpoint?: string\n\n\t/**\n\t * The secure token for accessing the Prismic repository. This is only\n\t * required if the repository is set to private.\n\t */\n\taccessToken?: string\n\n\t/**\n\t * A string representing a version of the Prismic repository's content. This\n\t * may point to the latest version (called the \"master ref\"), or a preview\n\t * with draft content.\n\t */\n\tref?: string | GetRef\n\n\t/**\n\t * A list of route resolver objects that define how a document's `url`\n\t * property is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\n\t/**\n\t * Default parameters that will be sent with each query. These parameters can\n\t * be overridden on each query if needed.\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\n\t/**\n\t * The function used to make network requests to the Prismic REST API. In\n\t * environments where a global `fetch` function does not exist, such as\n\t * Node.js, this function must be provided.\n\t */\n\tfetch?: FetchLike\n\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These\n\t * options will be merged with internally required options. They can also be\n\t * overriden on a per-query basis using the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods\n * start with `getAll` (for example, `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried. If a number is not provided, there\n\t * will be no limit and all matching documents will be returned.\n\t */\n\tlimit?: number\n}\n\n/**\n * Arguments to determine how the URL for a preview session is resolved.\n */\ntype ResolvePreviewArgs<LinkResolverReturnType> = {\n\t/**\n\t * A function that maps a Prismic document to a URL within your app.\n\t */\n\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\n\t/**\n\t * A fallback URL if the link resolver does not return a value.\n\t */\n\tdefaultURL: string\n\n\t/**\n\t * The preview token (also known as a ref) that will be used to query preview\n\t * content from the Prismic repository.\n\t */\n\tpreviewToken?: string\n\n\t/**\n\t * The previewed document that will be used to determine the destination URL.\n\t */\n\tdocumentID?: string\n}\n\n/**\n * A client that allows querying content from a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable,\n * such as Node.js, the `fetch` option must be provided as part of the `options`\n * parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The function used to make network requests to the Prismic REST API. In\n\t * environments where a global `fetch` function does not exist, such as\n\t * Node.js, this function must be provided.\n\t */\n\tfetchFn: FetchLike\n\n\tfetchOptions: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t/**\n\t * The Prismic repository's name.\n\t */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\n\t/**\n\t * The Prismic repository's name.\n\t */\n\tget repositoryName(): string {\n\t\tif (!this.#repositoryName) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`A repository name is required for this method but one could not be inferred from the provided API endpoint (\\`${this.documentAPIEndpoint}\\`). To fix this error, provide a repository name when creating the client. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn this.#repositoryName\n\t}\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t */\n\tdocumentAPIEndpoint: string\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t *\n\t * @deprecated Use `documentAPIEndpoint` instead.\n\t */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\n\t/**\n\t * The Prismic REST API V2 endpoint for the repository (use\n\t * `prismic.getRepositoryEndpoint` for the default endpoint).\n\t *\n\t * @deprecated Use `documentAPIEndpoint` instead.\n\t */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\n\t}\n\n\t/**\n\t * The secure token for accessing the API (only needed if your repository is\n\t * set to private).\n\t *\n\t * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}\n\t */\n\taccessToken?: string\n\n\t/**\n\t * A list of route resolver objects that define how a document's `url` field\n\t * is resolved.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\n\t/**\n\t * The `brokenRoute` option allows you to define the route populated in the\n\t * `url` property for broken link or content relationship fields. A broken\n\t * link is a link or content relationship field whose linked document has been\n\t * unpublished or deleted.\n\t *\n\t * {@link https://prismic.io/docs/route-resolver}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\n\t/**\n\t * Default parameters that will be sent with each query. These parameters can\n\t * be overridden on each query if needed.\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\"\n\t>\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0\n\n\t/**\n\t * Creates a Prismic client that can be used to query a repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable,\n\t * such as in some Node.js versions, the `fetch` option must be provided as\n\t * part of the `options` parameter.\n\t *\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest\n\t * API V2 endpoint for the repository.\n\t * @param options - Configuration that determines how content will be queried\n\t * from the Prismic repository.\n\t *\n\t * @returns A client that can query content from the repository.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, options: ClientConfig = {}) {\n\t\tconst {\n\t\t\tdocumentAPIEndpoint,\n\t\t\taccessToken,\n\t\t\tref,\n\t\t\troutes,\n\t\t\tbrokenRoute,\n\t\t\tdefaultParams,\n\t\t\tfetchOptions = {},\n\t\t\tfetch = globalThis.fetch?.bind(globalThis),\n\t\t} = options\n\n\t\tif (isRepositoryEndpoint(repositoryNameOrEndpoint)) {\n\t\t\ttry {\n\t\t\t\tthis.repositoryName = getRepositoryName(repositoryNameOrEndpoint)\n\t\t\t} catch {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[@prismicio/client] A repository name could not be inferred from the provided endpoint (\\`${repositoryNameOrEndpoint}\\`). Some methods will be disabled. Create the client using a repository name to prevent this warning. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t\t)\n\t\t\t}\n\t\t\tthis.documentAPIEndpoint = documentAPIEndpoint || repositoryNameOrEndpoint\n\t\t} else {\n\t\t\tthis.repositoryName = repositoryNameOrEndpoint\n\t\t\tthis.documentAPIEndpoint =\n\t\t\t\tdocumentAPIEndpoint || getRepositoryEndpoint(repositoryNameOrEndpoint)\n\t\t}\n\n\t\tif (!fetch) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t\"A valid fetch implementation was not provided. In environments where fetch is not available, a fetch implementation must be provided via a polyfill or the `fetch` option.\",\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\t\tif (typeof fetch !== \"function\") {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`fetch must be a function, but received: ${typeof fetch}`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\tif (!isRepositoryEndpoint(this.documentAPIEndpoint)) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`documentAPIEndpoint is not a valid URL: ${documentAPIEndpoint}`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\tisRepositoryEndpoint(repositoryNameOrEndpoint) &&\n\t\t\tdocumentAPIEndpoint &&\n\t\t\trepositoryNameOrEndpoint !== documentAPIEndpoint\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] Multiple incompatible endpoints were provided. Create the client using a repository name to prevent this error. For more details, see ${devMsg(\"prefer-repository-name\")}`,\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\t/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(this.documentAPIEndpoint) &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t\"@prismicio/client only supports Prismic Rest API V2. Please provide only the repository name to the first createClient() parameter or use the getRepositoryEndpoint() helper to generate a valid Rest API V2 endpoint URL.\",\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\t\tif (\n\t\t\t/(?<!\\.cdn)\\.prismic\\.io$/i.test(\n\t\t\t\tnew URL(this.documentAPIEndpoint).hostname,\n\t\t\t) &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] The client was created with a non-CDN endpoint. Convert it to the CDN endpoint for better performance. For more details, see ${devMsg(\"endpoint-must-use-cdn\")}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.accessToken = accessToken\n\t\tthis.routes = routes\n\t\tthis.brokenRoute = brokenRoute\n\t\tthis.defaultParams = defaultParams\n\t\tthis.fetchOptions = fetchOptions\n\t\tthis.fetchFn = fetch\n\n\t\tthis.graphQLFetch = this.graphQLFetch.bind(this)\n\n\t\tif (ref) {\n\t\t\tthis.queryContentFromRef(ref)\n\t\t}\n\t}\n\n\t/**\n\t * Enables the client to automatically query content from a preview session.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.enableAutoPreviews()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviews}\n\t */\n\tenableAutoPreviews(): void {\n\t\tthis.#autoPreviews = true\n\t}\n\n\t/**\n\t * Enables the client to automatically query content from a preview session\n\t * using an HTTP request object.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.enableAutoPreviewsFromReq(req)\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#enableautopreviewsfromreq}\n\t */\n\tenableAutoPreviewsFromReq(request: HttpRequestLike): void {\n\t\tthis.enableAutoPreviews()\n\t\tthis.#autoPreviewsRequest = request\n\t}\n\n\t/**\n\t * Disables the client from automatically querying content from a preview\n\t * session.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.disableAutoPreviews()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#disableautopreviews}\n\t */\n\tdisableAutoPreviews(): void {\n\t\tthis.#autoPreviews = false\n\t\tthis.#autoPreviewsRequest = undefined\n\t}\n\n\t/**\n\t * Fetches pages based on the `params` argument. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.get({ pageSize: 10 })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#get}\n\t */\n\tasync get<TDocument extends TDocuments>(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\tconst response = await this.#internalGet(params)\n\n\t\treturn await response.json()\n\t}\n\n\t/**\n\t * Fetches the first page returned based on the `params` argument.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getFirst()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getfirst}\n\t */\n\tasync getFirst<TDocument extends TDocuments>(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<TDocument> {\n\t\tconst actualParams =\n\t\t\tparams?.page || params?.pageSize ? params : { ...params, pageSize: 1 }\n\t\tconst response = await this.#internalGet(actualParams)\n\t\tconst { results }: Query<TDocument> = await response.clone().json()\n\n\t\tif (results[0]) {\n\t\t\treturn results[0]\n\t\t}\n\n\t\tthrow new NotFoundError(\n\t\t\t\"No documents were returned\",\n\t\t\tresponse.url,\n\t\t\tundefined,\n\t\t)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.dangerouslyGetAll()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#dangerouslygetall}\n\t */\n\tasync dangerouslyGetAll<TDocument extends TDocuments>(\n\t\tparams: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams = {},\n\t): Promise<TDocument[]> {\n\t\tconst { limit = Infinity, ...actualParams } = params\n\t\tconst resolvedParams = {\n\t\t\t...actualParams,\n\t\t\tpageSize: Math.min(\n\t\t\t\tlimit,\n\t\t\t\tactualParams.pageSize || this.defaultParams?.pageSize || MAX_PAGE_SIZE,\n\t\t\t),\n\t\t}\n\n\t\tconst documents: TDocument[] = []\n\t\tlet latestResult: Query<TDocument> | undefined\n\n\t\twhile (\n\t\t\t(!latestResult || latestResult.next_page) &&\n\t\t\tdocuments.length < limit\n\t\t) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tlatestResult = await this.get<TDocument>({ ...resolvedParams, page })\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\tif (latestResult.next_page) {\n\t\t\t\tawait new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY))\n\t\t\t}\n\t\t}\n\n\t\treturn documents.slice(0, limit)\n\t}\n\n\t/**\n\t * Fetches a page with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyid}\n\t */\n\tasync getByID<TDocument extends TDocuments>(\n\t\tid: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<TDocument> {\n\t\treturn await this.getFirst<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.id\", id)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByIDs([\n\t * \t\"WW4bKScAAMAqmluX\",\n\t * \t\"U1kTRgEAAC8A5ldS\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyids}\n\t */\n\tasync getByIDs<TDocument extends TDocuments>(\n\t\tids: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, filter.in(\"document.id\", ids)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByIDs([\n\t * \t\"WW4bKScAAMAqmluX\",\n\t * \t\"U1kTRgEAAC8A5ldS\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyids}\n\t */\n\tasync getAllByIDs<TDocument extends TDocuments>(\n\t\tids: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.in(\"document.id\", ids)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches a page with a specific UID and type.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuid}\n\t */\n\tasync getByUID<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuid: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>> {\n\t\treturn await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.at(`my.${documentType}.uid`, uid),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific UIDs and a specific type. Results are\n\t * paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByUIDs(\"blog_post\", [\n\t * \t\"my-first-post\",\n\t * \t\"my-second-post\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyuids}\n\t */\n\tasync getByUIDs<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuids: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>> {\n\t\treturn await this.get<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.in(`my.${documentType}.uid`, uids),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with specific UIDs and a specific type. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByUIDs(\"blog_post\", [\n\t * \t\"my-first-post\",\n\t * \t\"my-second-post\",\n\t * ])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyuids}\n\t */\n\tasync getAllByUIDs<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tuids: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<\n\t\t\tExtractDocumentType<TDocument, TDocumentType>\n\t\t>(\n\t\t\tappendFilters(params, [\n\t\t\t\ttypeFilter(documentType),\n\t\t\t\tfilter.in(`my.${documentType}.uid`, uids),\n\t\t\t]),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches a specific single type page.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const page = await client.getSingle(\"settings\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getsingle}\n\t */\n\tasync getSingle<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>> {\n\t\treturn await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, typeFilter(documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByType(\"blog_post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytype}\n\t */\n\tasync getByType<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>> {\n\t\treturn await this.get<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, typeFilter(documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByType(\"blog_post\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytype}\n\t */\n\tasync getAllByType<\n\t\tTDocument extends TDocuments,\n\t\tTDocumentType extends TDocument[\"type\"] = TDocument[\"type\"],\n\t>(\n\t\tdocumentType: TDocumentType,\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<\n\t\t\tExtractDocumentType<TDocument, TDocumentType>\n\t\t>(appendFilters(params, typeFilter(documentType)))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByTag(\"featured\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbytag}\n\t */\n\tasync getByTag<TDocument extends TDocuments>(\n\t\ttag: string,\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(appendFilters(params, someTagsFilter(tag)))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByTag(\"featured\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbytag}\n\t */\n\tasync getAllByTag<TDocument extends TDocuments>(\n\t\ttag: string,\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tag)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. Results are paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbyeverytag}\n\t */\n\tasync getByEveryTag<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, everyTagFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make\n\t * multiple network requests to fetch all matching pages.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbyeverytag}\n\t */\n\tasync getAllByEveryTag<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, everyTagFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. Results are\n\t * paginated.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getbysometags}\n\t */\n\tasync getBySomeTags<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t): Promise<Query<TDocument>> {\n\t\treturn await this.get<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may\n\t * make multiple network requests to fetch all matching documents.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getallbysometags}\n\t */\n\tasync getAllBySomeTags<TDocument extends TDocuments>(\n\t\ttags: string[],\n\t\tparams?: Partial<Omit<BuildQueryURLArgs, \"page\">> &\n\t\t\tGetAllParams &\n\t\t\tFetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, someTagsFilter(tags)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches metadata about the client's Prismic repository.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const repository = await client.getRepository()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}\n\t */\n\tasync getRepository(\n\t\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n\t): Promise<Repository> {\n\t\tif (\n\t\t\tthis.#cachedRepository &&\n\t\t\tthis.#cachedRepositoryExpiration > Date.now()\n\t\t) {\n\t\t\treturn this.#cachedRepository\n\t\t}\n\n\t\tconst url = new URL(this.documentAPIEndpoint)\n\n\t\tconst accessToken = params?.accessToken || this.accessToken\n\t\tif (accessToken) {\n\t\t\turl.searchParams.set(\"access_token\", accessToken)\n\t\t}\n\n\t\tconst response = await this.#request(url, params)\n\n\t\tif (response.ok) {\n\t\t\tthis.#cachedRepository = (await response.json()) as Repository\n\t\t\tthis.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL\n\n\t\t\treturn this.#cachedRepository\n\t\t}\n\n\t\tif (response.status === 404) {\n\t\t\tthrow new RepositoryNotFoundError(\n\t\t\t\t`Prismic repository not found. Check that \"${this.documentAPIEndpoint}\" is pointing to the correct repository.`,\n\t\t\t\turl.toString(),\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn await this.#throwContentAPIError(response, url.toString())\n\t}\n\n\t/**\n\t * Fetches the repository's active refs.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const refs = await client.getRefs()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefs}\n\t */\n\tasync getRefs(params?: FetchParams): Promise<Ref[]> {\n\t\tconst repository = await this.getRepository(params)\n\n\t\treturn repository.refs\n\t}\n\n\t/**\n\t * Fetches a ref by its ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbyid}\n\t */\n\tasync getRefByID(id: string, params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findRefByID(refs, id)\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the\n\t * Page Builder.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const ref = await client.getRefByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrefbylabel}\n\t */\n\tasync getRefByLabel(label: string, params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findRefByLabel(refs, label)\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const masterRef = await client.getMasterRef()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getmasterref}\n\t */\n\tasync getMasterRef(params?: FetchParams): Promise<Ref> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn findMasterRef(refs)\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const releases = await client.getReleases()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleases}\n\t */\n\tasync getReleases(params?: FetchParams): Promise<Ref[]> {\n\t\tconst refs = await this.getRefs(params)\n\n\t\treturn refs.filter((ref) => !ref.isMasterRef)\n\t}\n\n\t/**\n\t * Fetches a release with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebyid}\n\t */\n\tasync getReleaseByID(id: string, params?: FetchParams): Promise<Ref> {\n\t\tconst releases = await this.getReleases(params)\n\n\t\treturn findRefByID(releases, id)\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in\n\t * the Page Builder.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const release = await client.getReleaseByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getreleasebylabel}\n\t */\n\tasync getReleaseByLabel(label: string, params?: FetchParams): Promise<Ref> {\n\t\tconst releases = await this.getReleases(params)\n\n\t\treturn findRefByLabel(releases, label)\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const tags = await client.getTags()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#gettags}\n\t */\n\tasync getTags(params?: FetchParams): Promise<string[]> {\n\t\tconst repository = await this.getRepository(params)\n\t\tconst form = repository.forms.tags\n\t\tif (form) {\n\t\t\tconst url = new URL(form.action)\n\t\t\tif (this.accessToken) {\n\t\t\t\turl.searchParams.set(\"access_token\", this.accessToken)\n\t\t\t}\n\n\t\t\tconst response = await this.#request(url, params)\n\t\t\tif (response.ok) {\n\t\t\t\treturn (await response.json()) as string[]\n\t\t\t}\n\t\t}\n\n\t\treturn repository.tags\n\t}\n\n\t/**\n\t * Builds a Content API query URL with a set of parameters.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = await client.buildQueryURL({\n\t * \tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#buildqueryurl}\n\t */\n\tasync buildQueryURL({\n\t\tsignal,\n\t\tfetchOptions,\n\t\t...params\n\t}: Partial<BuildQueryURLArgs> & FetchParams = {}): Promise<string> {\n\t\tconst ref =\n\t\t\tparams.ref ||\n\t\t\t(await this.#getResolvedRef({\n\t\t\t\taccessToken: params.accessToken,\n\t\t\t\tsignal,\n\t\t\t\tfetchOptions,\n\t\t\t}))\n\t\tconst integrationFieldsRef =\n\t\t\tparams.integrationFieldsRef ||\n\t\t\t(\n\t\t\t\tawait this.getRepository({\n\t\t\t\t\taccessToken: params.accessToken,\n\t\t\t\t\tsignal,\n\t\t\t\t\tfetchOptions,\n\t\t\t\t})\n\t\t\t).integrationFieldsRef ||\n\t\t\tundefined\n\n\t\treturn buildQueryURL(this.documentAPIEndpoint, {\n\t\t\t...this.defaultParams,\n\t\t\t...params,\n\t\t\tref,\n\t\t\tintegrationFieldsRef,\n\t\t\troutes: params.routes || this.routes,\n\t\t\tbrokenRoute: params.brokenRoute || this.brokenRoute,\n\t\t\taccessToken: params.accessToken || this.accessToken,\n\t\t})\n\t}\n\n\t/**\n\t * Fetches a previewed page's URL using a preview token and page ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * const url = await client.resolvePreviewURL({\n\t * \tlinkResolver,\n\t * \tdefaultURL: \"/\",\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#resolvepreviewurl}\n\t */\n\tasync resolvePreviewURL<LinkResolverReturnType>(\n\t\targs: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams,\n\t): Promise<string> {\n\t\tlet documentID: string | undefined | null = args.documentID\n\t\tlet previewToken: string | undefined | null = args.previewToken\n\n\t\tif (typeof globalThis.location !== \"undefined\") {\n\t\t\tconst searchParams = new URLSearchParams(globalThis.location.search)\n\n\t\t\tdocumentID = documentID || searchParams.get(\"documentId\")\n\t\t\tpreviewToken = previewToken || searchParams.get(\"token\")\n\t\t} else if (this.#autoPreviewsRequest) {\n\t\t\tif (\"query\" in this.#autoPreviewsRequest) {\n\t\t\t\tdocumentID =\n\t\t\t\t\tdocumentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken =\n\t\t\t\t\tpreviewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\n\t\t\t\t\"url\" in this.#autoPreviewsRequest &&\n\t\t\t\tthis.#autoPreviewsRequest.url\n\t\t\t) {\n\t\t\t\t// Including \"missing-host://\" by default\n\t\t\t\t// handles a case where Next.js Route Handlers\n\t\t\t\t// only provide the pathname and search\n\t\t\t\t// parameters in the `url` property\n\t\t\t\t// (e.g. `/api/preview?foo=bar`).\n\t\t\t\tconst searchParams = new URL(\n\t\t\t\t\tthis.#autoPreviewsRequest.url,\n\t\t\t\t\t\"missing-host://\",\n\t\t\t\t).searchParams\n\n\t\t\t\tdocumentID = documentID || searchParams.get(\"documentId\")\n\t\t\t\tpreviewToken = previewToken || searchParams.get(\"token\")\n\t\t\t}\n\t\t}\n\n\t\tif (documentID != null && previewToken != null) {\n\t\t\tconst document = await this.getByID(documentID, {\n\t\t\t\tref: previewToken,\n\t\t\t\tlang: \"*\",\n\t\t\t\tsignal: args.signal,\n\t\t\t\tfetchOptions: args.fetchOptions,\n\t\t\t})\n\n\t\t\tconst url = asLink(document, { linkResolver: args.linkResolver })\n\n\t\t\tif (typeof url === \"string\") {\n\t\t\t\treturn url\n\t\t\t}\n\t\t}\n\n\t\treturn args.defaultURL\n\t}\n\n\t/**\n\t * Configures the client to query the latest published content. This is the\n\t * client's default mode.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryLatestContent()\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querylatestcontent}\n\t */\n\tqueryLatestContent(): void {\n\t\tthis.#getRef = undefined\n\t}\n\n\t/**\n\t * Configures the client to query content from a release with a specific ID.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebyid}\n\t */\n\tqueryContentFromReleaseByID(id: string): void {\n\t\tthis.#getRef = async (params) => {\n\t\t\tconst release = await this.getReleaseByID(id, params)\n\t\t\treturn release.ref\n\t\t}\n\t}\n\n\t/**\n\t * Configures the client to query content from a release with a specific\n\t * label.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromReleaseByLabel(\"My Release\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromreleasebylabel}\n\t */\n\tqueryContentFromReleaseByLabel(label: string): void {\n\t\tthis.#getRef = async (params) => {\n\t\t\tconst release = await this.getReleaseByLabel(label, params)\n\t\t\treturn release.ref\n\t\t}\n\t}\n\n\t/**\n\t * Configures the client to query content from a specific ref.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * client.queryContentFromRef(\"my-ref\")\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#querycontentfromref}\n\t */\n\tqueryContentFromRef(ref: string | GetRef): void {\n\t\tthis.#getRef = typeof ref === \"string\" ? () => ref : ref\n\t}\n\n\t/**\n\t * A preconfigured `fetch()` function for Prismic's GraphQL API that can be\n\t * provided to GraphQL clients.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * import { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * const client = createClient(\"example-prismic-repo\")\n\t * const graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \t\turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t\t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \t\tfetch: client.graphQLFetch,\n\t * \t\t// Using GET is required.\n\t * \t\tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * })\n\t * ```\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#graphqlfetch}\n\t */\n\tasync graphQLFetch(\n\t\tinput: RequestInfo,\n\t\tinit?: Omit<RequestInit, \"signal\"> & { signal?: AbortSignalLike },\n\t): Promise<Response> {\n\t\tconst repository = await this.getRepository()\n\t\tconst ref = await this.#getResolvedRef()\n\n\t\tconst unsanitizedHeaders: Record<string, string> = {\n\t\t\t\"Prismic-ref\": ref,\n\t\t\tAuthorization: this.accessToken ? `Token ${this.accessToken}` : \"\",\n\t\t\t// Asserting `init.headers` is a Record since popular GraphQL\n\t\t\t// libraries pass this as a Record. Header objects as input\n\t\t\t// are unsupported.\n\t\t\t...(init ? (init.headers as Record<string, string>) : {}),\n\t\t}\n\n\t\tif (repository.integrationFieldsRef) {\n\t\t\tunsanitizedHeaders[\"Prismic-integration-field-ref\"] =\n\t\t\t\trepository.integrationFieldsRef\n\t\t}\n\n\t\t// Normalize header keys to lowercase. This prevents header\n\t\t// conflicts between the Prismic client and the GraphQL\n\t\t// client.\n\t\tconst headers: Record<string, string> = {}\n\t\tfor (const key in unsanitizedHeaders) {\n\t\t\tif (unsanitizedHeaders[key]) {\n\t\t\t\theaders[key.toLowerCase()] =\n\t\t\t\t\tunsanitizedHeaders[key as keyof typeof unsanitizedHeaders]\n\t\t\t}\n\t\t}\n\n\t\tconst url = new URL(\n\t\t\t// Asserting `input` is a string since popular GraphQL\n\t\t\t// libraries pass this as a string. Request objects as\n\t\t\t// input are unsupported.\n\t\t\tinput as string,\n\t\t)\n\n\t\t// This prevents the request from being cached unnecessarily.\n\t\t// Without adding this `ref` param, re-running a query\n\t\t// could return a locally cached response, even if the\n\t\t// `ref` changed. This happens because the URL is\n\t\t// identical when the `ref` is not included. Caches may ignore\n\t\t// headers.\n\t\t//\n\t\t// The Prismic GraphQL API ignores the `ref` param.\n\t\turl.searchParams.set(\"ref\", ref)\n\n\t\tconst query = url.searchParams.get(\"query\")\n\t\tif (query) {\n\t\t\turl.searchParams.set(\n\t\t\t\t\"query\",\n\t\t\t\t// Compress the GraphQL query (if it exists) by\n\t\t\t\t// removing whitespace. This is done to\n\t\t\t\t// optimize the query size and avoid\n\t\t\t\t// hitting the upper limit of GET requests\n\t\t\t\t// (2048 characters).\n\t\t\t\tminifyGraphQLQuery(query),\n\t\t\t)\n\t\t}\n\n\t\treturn (await this.fetchFn(url.toString(), {\n\t\t\t...init,\n\t\t\theaders,\n\t\t})) as Response\n\t}\n\n\t/**\n\t * Returns the ref needed to query based on the client's current state. This\n\t * method may make a network request to fetch a ref or resolve the user's ref\n\t * thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority if available.\n\t *\n\t * The following strategies are used depending on the client's state:\n\t *\n\t * - If the user called `queryLatestContent`: Use the repository's master ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new master ref is\n\t * fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new ref for the\n\t * release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.\n\t * The ref is cached for 5 seconds. After 5 seconds, a new ref for the\n\t * release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back\n\t * to the master ref if the ref is not a string.\n\t *\n\t * @returns The ref to use during a query.\n\t */\n\tasync #getResolvedRef(\n\t\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n\t) {\n\t\tif (this.#autoPreviews) {\n\t\t\tconst cookies = this.#autoPreviewsRequest?.headers\n\t\t\t\t? \"get\" in this.#autoPreviewsRequest.headers\n\t\t\t\t\t? this.#autoPreviewsRequest.headers.get(\"cookie\")\n\t\t\t\t\t: this.#autoPreviewsRequest.headers.cookie\n\t\t\t\t: globalThis.document?.cookie\n\t\t\tconst previewRef = getPreviewCookie(cookies ?? \"\")\n\t\t\tif (previewRef) {\n\t\t\t\treturn previewRef\n\t\t\t}\n\t\t}\n\n\t\tconst ref = await this.#getRef?.(params)\n\t\tif (ref) {\n\t\t\treturn ref\n\t\t}\n\n\t\tconst masterRef = await this.getMasterRef(params)\n\t\treturn masterRef.ref\n\t}\n\n\tasync #internalGet(\n\t\tparams?: Partial<BuildQueryURLArgs> & FetchParams,\n\t\tattempt = 1,\n\t): Promise<ResponseLike> {\n\t\tconst url = await this.buildQueryURL(params)\n\t\tconst response = await this.#request(new URL(url), params)\n\n\t\tif (response.ok) {\n\t\t\treturn response\n\t\t}\n\n\t\ttry {\n\t\t\treturn await this.#throwContentAPIError(response, url)\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\t(error instanceof RefNotFoundError ||\n\t\t\t\t\terror instanceof RefExpiredError) &&\n\t\t\t\tattempt < MAX_INVALID_REF_RETRY_ATTEMPTS\n\t\t\t) {\n\t\t\t\t// If no explicit ref is given (i.e. the master ref from\n\t\t\t\t// /api/v2 is used), clear the cached repository value.\n\t\t\t\t// Clearing the cached value prevents other methods from\n\t\t\t\t// using a known-stale ref.\n\t\t\t\tif (!params?.ref) {\n\t\t\t\t\tthis.#cachedRepository = undefined\n\t\t\t\t}\n\n\t\t\t\tconst masterRef = error.message.match(/master ref is: (?<ref>.*)$/i)\n\t\t\t\t\t?.groups?.ref\n\t\t\t\tif (!masterRef) {\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tconst badRef = new URL(url).searchParams.get(\"ref\")\n\t\t\t\tconst issue = error instanceof RefNotFoundError ? \"invalid\" : \"expired\"\n\t\t\t\tthrottledLog(\n\t\t\t\t\t`[@prismicio/client] The ref (${badRef}) was ${issue}. Now retrying with the latest master ref (${masterRef}). If you were previewing content, the response will not include draft content.`,\n\t\t\t\t\t{ level: \"warn\" },\n\t\t\t\t)\n\n\t\t\t\treturn await this.#internalGet(\n\t\t\t\t\t{ ...params, ref: masterRef },\n\t\t\t\t\tattempt + 1,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #throwContentAPIError(\n\t\tresponse: ResponseLike,\n\t\turl: string,\n\t): Promise<never> {\n\t\tswitch (response.status) {\n\t\t\tcase 400: {\n\t\t\t\tconst json = await response.clone().json()\n\t\t\t\tthrow new ParsingError(json.message, url, json)\n\t\t\t}\n\t\t\tcase 401: {\n\t\t\t\tconst json = await response.clone().json()\n\t\t\t\tthrow new ForbiddenError(json.message, url, json)\n\t\t\t}\n\t\t\tcase 404: {\n\t\t\t\tconst json = await response.clone().json()\n\t\t\t\tswitch (json.type) {\n\t\t\t\t\tcase \"api_notfound_error\": {\n\t\t\t\t\t\tthrow new RefNotFoundError(json.message, url, json)\n\t\t\t\t\t}\n\t\t\t\t\tcase \"api_security_error\": {\n\t\t\t\t\t\tif (/preview token.*expired/i.test(json.message)) {\n\t\t\t\t\t\t\tthrow new PreviewTokenExpiredError(json.message, url, json)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NotFoundError(json.message, url, json)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase 410: {\n\t\t\t\tconst json = await response.clone().json()\n\t\t\t\tthrow new RefExpiredError(json.message, url, json)\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new PrismicError(undefined, url, await response.text())\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Makes an HTTP request using the client's configured fetch function and\n\t * options.\n\t *\n\t * @param url - The URL to request.\n\t * @param params - Fetch options.\n\t *\n\t * @returns The response from the fetch request.\n\t */\n\tasync #request(url: URL, params?: FetchParams): Promise<ResponseLike> {\n\t\treturn await request(\n\t\t\turl,\n\t\t\t{\n\t\t\t\t...this.fetchOptions,\n\t\t\t\t...params?.fetchOptions,\n\t\t\t\theaders: {\n\t\t\t\t\t...this.fetchOptions?.headers,\n\t\t\t\t\t...params?.fetchOptions?.headers,\n\t\t\t\t},\n\t\t\t\tsignal:\n\t\t\t\t\tparams?.fetchOptions?.signal ||\n\t\t\t\t\tparams?.signal ||\n\t\t\t\t\tthis.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,gBAAgB;;;;;;;AAQtB,MAAa,uBAAuB;;;;;;;;AASpC,MAAa,sBAAsB;;;;;;AAOnC,MAAM,iCAAiC;;;;;;;;;;;AA8LvC,IAAa,SAAb,MAA0E;;;;;;CAMzE;CAEA;CAEA;;;;CAKA,IAAI,eAAe,OAAe;AACjC,QAAKA,iBAAkB;;;;;CAMxB,IAAI,iBAAyB;AAC5B,MAAI,CAAC,MAAKA,eACT,OAAM,IAAIC,kCACT,iHAAiH,KAAK,oBAAoB,oGAAoGC,sBAAO,yBAAyB,IAC9Q,QACA,OACA;AAGF,SAAO,MAAKF;;;;;;CAOb;;;;;;;CASA,IAAI,SAAS,OAAe;AAC3B,OAAK,sBAAsB;;;;;;;;CAU5B,IAAI,WAAmB;AACtB,SAAO,KAAK;;;;;;;;CASb;;;;;;;CAQA;;;;;;;;;CAUA;;;;;CAMA;CAKA;CACA,gBAAgB;CAChB;CAEA;CACA,8BAA8B;;;;;;;;;;;;;;;CAgB9B,YAAY,0BAAkC,UAAwB,EAAE,EAAE;;EACzE,MAAM,EACL,qBACA,aACA,KACA,QACA,aACA,eACA,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,KAAK,QAAQ,CAC/C,OAAM,IAAII,qDAAyB,KAAK,SAAS,KAAK,KAAK;KAG7D,QACC,OAAM,IAAI9B,oCAAc,KAAK,SAAS,KAAK,KAAK;;;GAInD,KAAK,KAAK;IACT,MAAM,OAAO,MAAM,SAAS,OAAO,CAAC,MAAM;AAC1C,UAAM,IAAI2B,wCAAgB,KAAK,SAAS,KAAK,KAAK;;GAEnD,QACC,OAAM,IAAIpC,kCAAa,QAAW,KAAK,MAAM,SAAS,MAAM,CAAC;;;;;;;;;;;;CAchE,OAAMmB,QAAS,KAAU,QAA6C;;AACrE,SAAO,MAAMZ,wBACZ,KACA;GACC,GAAG,KAAK;GACR,mDAAG,OAAQ;GACX,SAAS;IACR,yBAAG,KAAK,sFAAc;IACtB,mEAAG,OAAQ,0FAAc;IACzB;GACD,0EACC,OAAQ,4FAAc,4DACtB,OAAQ,mCACR,KAAK,wFAAc;GACpB,EACD,KAAK,QACL"}
|
package/dist/Client.d.cts
CHANGED
|
@@ -177,7 +177,7 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
177
177
|
* Node.js, this function must be provided.
|
|
178
178
|
*/
|
|
179
179
|
fetchFn: FetchLike;
|
|
180
|
-
fetchOptions
|
|
180
|
+
fetchOptions: RequestInitLike;
|
|
181
181
|
/**
|
|
182
182
|
* The Prismic repository's name.
|
|
183
183
|
*/
|
|
@@ -743,24 +743,6 @@ declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
743
743
|
graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
|
|
744
744
|
signal?: AbortSignalLike;
|
|
745
745
|
}): Promise<Response>;
|
|
746
|
-
/**
|
|
747
|
-
* The private implementation of `this.get`. It returns the API response and
|
|
748
|
-
* the URL used to make the request. The URL is sometimes used in the public
|
|
749
|
-
* method to include in thrown errors.
|
|
750
|
-
*
|
|
751
|
-
* This method retries requests that throw `RefNotFoundError` or
|
|
752
|
-
* `RefExpiredError`. It contains special logic to retry with the latest
|
|
753
|
-
* master ref, provided in the API's error message.
|
|
754
|
-
*
|
|
755
|
-
* @typeParam TDocument - Type of Prismic documents returned.
|
|
756
|
-
*
|
|
757
|
-
* @param params - Parameters to filter, sort, and paginate results.
|
|
758
|
-
*
|
|
759
|
-
* @returns An object containing the paginated response containing the result
|
|
760
|
-
* of the query and the URL used to make the API request.
|
|
761
|
-
*/
|
|
762
|
-
private _get;
|
|
763
|
-
protected _buildRequestInit(params?: FetchParams): RequestInitLike;
|
|
764
746
|
}
|
|
765
747
|
//#endregion
|
|
766
748
|
export { Client, ClientConfig, FetchParams, HttpRequestLike };
|