@prismicio/client 7.23.0-pr.489.0e99b11 → 7.23.1-pr.491.de51fc9

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 CHANGED
@@ -220,15 +220,14 @@ var Client = class {
220
220
  let latestResult;
221
221
  while ((!latestResult || latestResult.next_page) && documents.length < limit) {
222
222
  const page = latestResult ? latestResult.page + 1 : void 0;
223
- const requestedAt = Date.now();
224
223
  const response = await this.#internalGet({
225
224
  ...resolvedParams,
226
225
  page
227
226
  });
228
227
  latestResult = await response.json();
229
228
  documents.push(...latestResult.results);
230
- const isCached = response.headers.get("x-cache")?.startsWith("Hit") || Date.parse(response.headers.get("date") ?? "") < requestedAt - 5e3;
231
- if (latestResult.next_page && !isCached) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
229
+ const isCached = () => response.headers.get("x-cache")?.startsWith("Hit") || Date.parse(response.headers.get("date") ?? "") < Date.now() - 5e3;
230
+ if (latestResult.next_page && !isCached()) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
232
231
  }
233
232
  return documents.slice(0, limit);
234
233
  }
@@ -444,14 +443,14 @@ var Client = class {
444
443
  * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
445
444
  */
446
445
  async getRepository(params) {
447
- if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
446
+ if (this.#cachedRepository && this.#cachedRepositoryExpiration > performance.now()) return this.#cachedRepository;
448
447
  const url = new URL(this.documentAPIEndpoint);
449
448
  const accessToken = params?.accessToken || this.accessToken;
450
449
  if (accessToken) url.searchParams.set("access_token", accessToken);
451
450
  const response = await this.#request(url, params);
452
451
  if (response.ok) {
453
452
  this.#cachedRepository = await response.json();
454
- this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
453
+ this.#cachedRepositoryExpiration = performance.now() + REPOSITORY_CACHE_TTL;
455
454
  return this.#cachedRepository;
456
455
  }
457
456
  if (response.status === 404) throw new require_errors.RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"Client.cjs","names":["isRepositoryEndpoint","getRepositoryName","devMsg","getRepositoryEndpoint","PrismicError","NotFoundError","filter","RepositoryNotFoundError","buildQueryURL","asLink","getPreviewCookie","RefNotFoundError","RefExpiredError","ParsingError","ForbiddenError","PreviewTokenExpiredError","request"],"sources":["../src/Client.ts"],"sourcesContent":["import { type BuildQueryURLArgs, buildQueryURL } from \"./buildQueryURL\"\nimport {\n\tForbiddenError,\n\tNotFoundError,\n\tParsingError,\n\tPreviewTokenExpiredError,\n\tPrismicError,\n\tRefExpiredError,\n\tRefNotFoundError,\n\tRepositoryNotFoundError,\n} from \"./errors\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { type LinkResolverFunction, asLink } from \"./helpers/asLink\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type AbortSignalLike, type FetchLike, type RequestInitLike, request } from \"./lib/request\"\nimport { throttledWarn } from \"./lib/throttledWarn\"\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\nconst MAX_PAGE_SIZE = 100\nconst REPOSITORY_CACHE_TTL = 5000\nconst GET_ALL_QUERY_DELAY = 500\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/** Extracts a document type with a matching `type` property from a union of document types. */\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 Prismic preview\n * support.\n */\nexport type HttpRequestLike =\n\t| // Web API Request\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\t// Express-style request\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 queries content\n * from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/** Parameters for client methods that use `fetch()`. */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These options will be\n\t * merged with internally required options. They can also be overriden on a per-query basis using\n\t * the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\t/** @deprecated Move to `fetchOptions.signal`: */\n\t// TODO: Remove in v8.\n\tsignal?: AbortSignalLike\n}\n\n/** Prismic client configuration. */\nexport type ClientConfig = {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint?: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * The version of the repository's content. It can optionally be a function that returns a ref.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tref?: string | GetRef\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetch?: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods start with `getAll`\n * (e.g. `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried.\n\t *\n\t * @default No limit.\n\t */\n\tlimit?: number\n}\n\n/**\n * A client for fetching content from a Prismic repository.\n *\n * @see {@link https://prismic.io/docs/fetch-content}\n * @see {@link https://prismic.io/docs/technical-reference/prismicio-client}\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<BuildQueryURLArgs, \"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\">\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchFn: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0 // Timestamp\n\n\t/**\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n\t * the repository.\n\t * @param config - Client configuration.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, config: 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} = config\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(this.documentAPIEndpoint)\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname) &&\n\t\t\t!/\\.cdn\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname)\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/** The Prismic repository's name. */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\t/** The Prismic repository's name. */\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/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\t/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\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 * \t;```ts\n\t * \tclient.enableAutoPreviews()\n\t * \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 using an HTTP request\n\t * object.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.enableAutoPreviewsFromReq(req)\n\t * \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 session.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.disableAutoPreviews()\n\t * \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 * \t;```ts\n\t * \tconst response = await client.get({ pageSize: 10 })\n\t * \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 * \t;```ts\n\t * \tconst page = await client.getFirst()\n\t * \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?.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(\"No documents were returned\", response.url, undefined)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.dangerouslyGetAll()\n\t * \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\">> & GetAllParams & FetchParams = {},\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 ((!latestResult || latestResult.next_page) && documents.length < limit) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tconst requestedAt = Date.now()\n\t\t\tconst response = await this.#internalGet({ ...resolvedParams, page })\n\t\t\tlatestResult = (await response.json()) as Query<TDocument>\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\t// Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even\n\t\t\t// when they also replay an `x-cache: Miss`. The margin covers clock skew.\n\t\t\tconst isCached =\n\t\t\t\tresponse.headers.get(\"x-cache\")?.startsWith(\"Hit\") ||\n\t\t\t\tDate.parse(response.headers.get(\"date\") ?? \"\") < requestedAt - 5000\n\t\t\tif (latestResult.next_page && !isCached) {\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 * \t;```ts\n\t * \tconst page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * \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>(appendFilters(params, filter.at(\"document.id\", id)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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>(appendFilters(params, filter.in(\"document.id\", ids)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network requests to fetch all\n\t * matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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\">> & GetAllParams & FetchParams,\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 * \t;```ts\n\t * \tconst page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst page = await client.getSingle(\"settings\")\n\t * \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, filter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst response = await client.getByType(\"blog_post\")\n\t * \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, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByType(\"blog_post\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByTag(\"featured\")\n\t * \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, filter.any(\"document.tags\", [tag])))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByTag(\"featured\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", [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 * \t;```ts\n\t * \tconst response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.at(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.tags\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.any(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", 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 * \t;```ts\n\t * \tconst repository = await client.getRepository()\n\t * \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 (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) {\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 * \t;```ts\n\t * \tconst refs = await client.getRefs()\n\t * \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 * \t;```ts\n\t * \tconst ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.id === id)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst ref = await client.getRefByLabel(\"My Release\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.label === label)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with label \"${label}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst masterRef = await client.getMasterRef()\n\t * \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\t\tconst ref = refs.find((ref) => ref.isMasterRef)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(\"Master ref could not be found.\", undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst releases = await client.getReleases()\n\t * \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 * \t;```ts\n\t * \tconst release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst release = releases.find((ref) => ref.id === id)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(`Release with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst release = await client.getReleaseByLabel(\"My Release\")\n\t * \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\t\tconst release = releases.find((ref) => ref.label === label)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`Release with label \"${label}\" could not be found.`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst tags = await client.getTags()\n\t * \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 * \t;```ts\n\t * \tconst url = await client.buildQueryURL({\n\t * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * \t})\n\t * \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 * \t;```ts\n\t * \tconst url = await client.resolvePreviewURL({\n\t * \t\tlinkResolver,\n\t * \t\tdefaultURL: \"/\",\n\t * \t})\n\t * \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: {\n\t\t\t/** A function converts a document to a URL in your website. */\n\t\t\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\t\t\t/** A fallback URL used when the document does not have a URL. */\n\t\t\tdefaultURL: string\n\t\t\t/** The preview token for the preview session. */\n\t\t\tpreviewToken?: string\n\t\t\t/** The previewed document's ID. */\n\t\t\tdocumentID?: string\n\t\t} & 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 = documentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken = previewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\"url\" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {\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(this.#autoPreviewsRequest.url, \"missing-host://\").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 client's default mode.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryLatestContent()\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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 label.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryContentFromReleaseByLabel(\"My Release\")\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromRef(\"my-ref\")\n\t * \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 provided to GraphQL\n\t * clients.\n\t *\n\t * @example\n\t * \t```ts\n\t * \timport { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * \tconst client = createClient(\"example-prismic-repo\")\n\t * \tconst graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \tfetch: client.graphQLFetch,\n\t * \t// Using GET is required.\n\t * \tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * \t})\n\t * \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 params = {\n\t\t\taccessToken: this.accessToken,\n\t\t\tfetchOptions: this.fetchOptions,\n\t\t}\n\t\tconst repository = await this.getRepository(params)\n\t\tconst ref = await this.#getResolvedRef(params)\n\n\t\tconst headers: NonNullable<RequestInitLike[\"headers\"]> = {}\n\t\theaders[\"prismic-ref\"] = ref\n\t\tif (this.accessToken) {\n\t\t\theaders[\"authorization\"] = `Token ${this.accessToken}`\n\t\t}\n\t\tif (repository.integrationFieldsRef) {\n\t\t\theaders[\"prismic-integration-field-ref\"] = repository.integrationFieldsRef\n\t\t}\n\t\tfor (const [key, value] of Object.entries(init?.headers ?? {})) {\n\t\t\theaders[key.toLowerCase()] = value\n\t\t}\n\n\t\tconst url = new URL(typeof input === \"string\" ? input : input.url)\n\t\tconst query = (url.searchParams.get(\"query\") ?? \"\").replace(\n\t\t\t// Minify the query\n\t\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t\t(_chars, _spaces, brackets) => brackets,\n\t\t)\n\t\turl.searchParams.set(\"query\", query)\n\t\t// Only used to prevent caching; caches ignore header differences\n\t\turl.searchParams.set(\"ref\", ref)\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 method may make a\n\t * network request to fetch a ref or resolve the user's ref thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority.\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. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new master ref is fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref. The ref is cached\n\t * for 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back to the master ref if\n\t * the ref is not a string.\n\t */\n\tasync #getResolvedRef(params?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams) {\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 * Performs a low-level Content API request with the given parameters. Automatically retries if an\n\t * invalid ref is used.\n\t */\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 || error 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)?.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\tthrottledWarn(\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)\n\n\t\t\t\treturn await this.#internalGet({ ...params, ref: masterRef }, attempt + 1)\n\t\t\t}\n\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/** Throws an error based on a Content API response. Only call in known-errored states. */\n\tasync #throwContentAPIError(response: ResponseLike, url: string): 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/** Performs a low-level network request with the client's fetch options. */\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: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n}\n\n/** Appends filters to a params object. */\nfunction appendFilters<T extends Pick<BuildQueryURLArgs, \"filters\">>(\n\tparams = {} as T,\n\t...filters: string[]\n): T & { filters: string[] } {\n\treturn { ...params, filters: [...(params.filters ?? []), ...filters] }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC;;;;;;;AAmIvC,IAAa,SAAb,MAA0E;;;;;;CAMzE;;;;;;CAMA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;CAEA;CAEA;CACA,gBAAgB;CAChB;CAEA;CACA,8BAA8B;;;;;;CAO9B,YAAY,0BAAkC,SAAuB,CAAC,GAAG;EACxE,MAAM,EACL,qBACA,aACA,KACA,QACA,aACA,eACA,eAAe,CAAC,GAChB,QAAQ,WAAW,OAAO,KAAK,UAAU,MACtC;EAEJ,IAAIA,6BAAAA,qBAAqB,wBAAwB,GAAG;GACnD,IAAI;IACH,KAAK,iBAAiBC,0BAAAA,kBAAkB,wBAAwB;GACjE,QAAQ;IACP,QAAQ,KACP,6FAA6F,yB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c;GAC1B;GACA,QAAQ,QAAQ,cAAc,UAAU,QAAQ,UAAU,KAAK,cAAc;EAC9E,GACA,KAAK,OACN;CACD;AACD;;AAGA,SAAS,cACR,SAAS,CAAC,GACV,GAAG,SACyB;CAC5B,OAAO;EAAE,GAAG;EAAQ,SAAS,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,GAAG,OAAO;CAAE;AACtE"}
1
+ {"version":3,"file":"Client.cjs","names":["isRepositoryEndpoint","getRepositoryName","devMsg","getRepositoryEndpoint","PrismicError","NotFoundError","filter","RepositoryNotFoundError","buildQueryURL","asLink","getPreviewCookie","RefNotFoundError","RefExpiredError","ParsingError","ForbiddenError","PreviewTokenExpiredError","request"],"sources":["../src/Client.ts"],"sourcesContent":["import { type BuildQueryURLArgs, buildQueryURL } from \"./buildQueryURL\"\nimport {\n\tForbiddenError,\n\tNotFoundError,\n\tParsingError,\n\tPreviewTokenExpiredError,\n\tPrismicError,\n\tRefExpiredError,\n\tRefNotFoundError,\n\tRepositoryNotFoundError,\n} from \"./errors\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { type LinkResolverFunction, asLink } from \"./helpers/asLink\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type AbortSignalLike, type FetchLike, type RequestInitLike, request } from \"./lib/request\"\nimport { throttledWarn } from \"./lib/throttledWarn\"\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\nconst MAX_PAGE_SIZE = 100\nconst REPOSITORY_CACHE_TTL = 5000\nconst GET_ALL_QUERY_DELAY = 500\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/** Extracts a document type with a matching `type` property from a union of document types. */\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 Prismic preview\n * support.\n */\nexport type HttpRequestLike =\n\t| // Web API Request\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\t// Express-style request\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 queries content\n * from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/** Parameters for client methods that use `fetch()`. */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These options will be\n\t * merged with internally required options. They can also be overriden on a per-query basis using\n\t * the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\t/** @deprecated Move to `fetchOptions.signal`: */\n\t// TODO: Remove in v8.\n\tsignal?: AbortSignalLike\n}\n\n/** Prismic client configuration. */\nexport type ClientConfig = {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint?: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * The version of the repository's content. It can optionally be a function that returns a ref.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tref?: string | GetRef\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetch?: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods start with `getAll`\n * (e.g. `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried.\n\t *\n\t * @default No limit.\n\t */\n\tlimit?: number\n}\n\n/**\n * A client for fetching content from a Prismic repository.\n *\n * @see {@link https://prismic.io/docs/fetch-content}\n * @see {@link https://prismic.io/docs/technical-reference/prismicio-client}\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<BuildQueryURLArgs, \"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\">\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchFn: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0 // Timestamp\n\n\t/**\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n\t * the repository.\n\t * @param config - Client configuration.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, config: 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} = config\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(this.documentAPIEndpoint)\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname) &&\n\t\t\t!/\\.cdn\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname)\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/** The Prismic repository's name. */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\t/** The Prismic repository's name. */\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/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\t/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\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 * \t;```ts\n\t * \tclient.enableAutoPreviews()\n\t * \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 using an HTTP request\n\t * object.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.enableAutoPreviewsFromReq(req)\n\t * \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 session.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.disableAutoPreviews()\n\t * \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 * \t;```ts\n\t * \tconst response = await client.get({ pageSize: 10 })\n\t * \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 * \t;```ts\n\t * \tconst page = await client.getFirst()\n\t * \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?.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(\"No documents were returned\", response.url, undefined)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.dangerouslyGetAll()\n\t * \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\">> & GetAllParams & FetchParams = {},\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 ((!latestResult || latestResult.next_page) && documents.length < limit) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tconst response = await this.#internalGet({ ...resolvedParams, page })\n\t\t\tlatestResult = (await response.json()) as Query<TDocument>\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\t// Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even\n\t\t\t// when they also replay an `x-cache: Miss`. The margin covers clock skew.\n\t\t\t// Lazy, because Next.js forbids `Date.now()` during a prerender.\n\t\t\tconst isCached = () =>\n\t\t\t\tresponse.headers.get(\"x-cache\")?.startsWith(\"Hit\") ||\n\t\t\t\tDate.parse(response.headers.get(\"date\") ?? \"\") < Date.now() - 5000\n\t\t\tif (latestResult.next_page && !isCached()) {\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 * \t;```ts\n\t * \tconst page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * \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>(appendFilters(params, filter.at(\"document.id\", id)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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>(appendFilters(params, filter.in(\"document.id\", ids)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network requests to fetch all\n\t * matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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\">> & GetAllParams & FetchParams,\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 * \t;```ts\n\t * \tconst page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst page = await client.getSingle(\"settings\")\n\t * \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, filter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst response = await client.getByType(\"blog_post\")\n\t * \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, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByType(\"blog_post\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByTag(\"featured\")\n\t * \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, filter.any(\"document.tags\", [tag])))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByTag(\"featured\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", [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 * \t;```ts\n\t * \tconst response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.at(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.tags\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.any(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", 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 * \t;```ts\n\t * \tconst repository = await client.getRepository()\n\t * \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 (this.#cachedRepository && this.#cachedRepositoryExpiration > performance.now()) {\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 = performance.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 * \t;```ts\n\t * \tconst refs = await client.getRefs()\n\t * \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 * \t;```ts\n\t * \tconst ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.id === id)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst ref = await client.getRefByLabel(\"My Release\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.label === label)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with label \"${label}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst masterRef = await client.getMasterRef()\n\t * \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\t\tconst ref = refs.find((ref) => ref.isMasterRef)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(\"Master ref could not be found.\", undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst releases = await client.getReleases()\n\t * \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 * \t;```ts\n\t * \tconst release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst release = releases.find((ref) => ref.id === id)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(`Release with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst release = await client.getReleaseByLabel(\"My Release\")\n\t * \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\t\tconst release = releases.find((ref) => ref.label === label)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`Release with label \"${label}\" could not be found.`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst tags = await client.getTags()\n\t * \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 * \t;```ts\n\t * \tconst url = await client.buildQueryURL({\n\t * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * \t})\n\t * \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 * \t;```ts\n\t * \tconst url = await client.resolvePreviewURL({\n\t * \t\tlinkResolver,\n\t * \t\tdefaultURL: \"/\",\n\t * \t})\n\t * \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: {\n\t\t\t/** A function converts a document to a URL in your website. */\n\t\t\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\t\t\t/** A fallback URL used when the document does not have a URL. */\n\t\t\tdefaultURL: string\n\t\t\t/** The preview token for the preview session. */\n\t\t\tpreviewToken?: string\n\t\t\t/** The previewed document's ID. */\n\t\t\tdocumentID?: string\n\t\t} & 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 = documentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken = previewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\"url\" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {\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(this.#autoPreviewsRequest.url, \"missing-host://\").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 client's default mode.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryLatestContent()\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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 label.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryContentFromReleaseByLabel(\"My Release\")\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromRef(\"my-ref\")\n\t * \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 provided to GraphQL\n\t * clients.\n\t *\n\t * @example\n\t * \t```ts\n\t * \timport { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * \tconst client = createClient(\"example-prismic-repo\")\n\t * \tconst graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \tfetch: client.graphQLFetch,\n\t * \t// Using GET is required.\n\t * \tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * \t})\n\t * \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 params = {\n\t\t\taccessToken: this.accessToken,\n\t\t\tfetchOptions: this.fetchOptions,\n\t\t}\n\t\tconst repository = await this.getRepository(params)\n\t\tconst ref = await this.#getResolvedRef(params)\n\n\t\tconst headers: NonNullable<RequestInitLike[\"headers\"]> = {}\n\t\theaders[\"prismic-ref\"] = ref\n\t\tif (this.accessToken) {\n\t\t\theaders[\"authorization\"] = `Token ${this.accessToken}`\n\t\t}\n\t\tif (repository.integrationFieldsRef) {\n\t\t\theaders[\"prismic-integration-field-ref\"] = repository.integrationFieldsRef\n\t\t}\n\t\tfor (const [key, value] of Object.entries(init?.headers ?? {})) {\n\t\t\theaders[key.toLowerCase()] = value\n\t\t}\n\n\t\tconst url = new URL(typeof input === \"string\" ? input : input.url)\n\t\tconst query = (url.searchParams.get(\"query\") ?? \"\").replace(\n\t\t\t// Minify the query\n\t\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t\t(_chars, _spaces, brackets) => brackets,\n\t\t)\n\t\turl.searchParams.set(\"query\", query)\n\t\t// Only used to prevent caching; caches ignore header differences\n\t\turl.searchParams.set(\"ref\", ref)\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 method may make a\n\t * network request to fetch a ref or resolve the user's ref thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority.\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. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new master ref is fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref. The ref is cached\n\t * for 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back to the master ref if\n\t * the ref is not a string.\n\t */\n\tasync #getResolvedRef(params?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams) {\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 * Performs a low-level Content API request with the given parameters. Automatically retries if an\n\t * invalid ref is used.\n\t */\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 || error 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)?.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\tthrottledWarn(\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)\n\n\t\t\t\treturn await this.#internalGet({ ...params, ref: masterRef }, attempt + 1)\n\t\t\t}\n\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/** Throws an error based on a Content API response. Only call in known-errored states. */\n\tasync #throwContentAPIError(response: ResponseLike, url: string): 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/** Performs a low-level network request with the client's fetch options. */\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: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n}\n\n/** Appends filters to a params object. */\nfunction appendFilters<T extends Pick<BuildQueryURLArgs, \"filters\">>(\n\tparams = {} as T,\n\t...filters: string[]\n): T & { filters: string[] } {\n\treturn { ...params, filters: [...(params.filters ?? []), ...filters] }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC;;;;;;;AAmIvC,IAAa,SAAb,MAA0E;;;;;;CAMzE;;;;;;CAMA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;CAEA;CAEA;CACA,gBAAgB;CAChB;CAEA;CACA,8BAA8B;;;;;;CAO9B,YAAY,0BAAkC,SAAuB,CAAC,GAAG;EACxE,MAAM,EACL,qBACA,aACA,KACA,QACA,aACA,eACA,eAAe,CAAC,GAChB,QAAQ,WAAW,OAAO,KAAK,UAAU,MACtC;EAEJ,IAAI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AO,MAAMY,gBAAAA,QACZ,KACA;GACC,GAAG,KAAK;GACR,GAAG,QAAQ;GACX,SAAS;IACR,GAAG,KAAK,cAAc;IACtB,GAAG,QAAQ,cAAc;GAC1B;GACA,QAAQ,QAAQ,cAAc,UAAU,QAAQ,UAAU,KAAK,cAAc;EAC9E,GACA,KAAK,OACN;CACD;AACD;;AAGA,SAAS,cACR,SAAS,CAAC,GACV,GAAG,SACyB;CAC5B,OAAO;EAAE,GAAG;EAAQ,SAAS,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,GAAG,OAAO;CAAE;AACtE"}
package/dist/Client.js CHANGED
@@ -220,15 +220,14 @@ var Client = class {
220
220
  let latestResult;
221
221
  while ((!latestResult || latestResult.next_page) && documents.length < limit) {
222
222
  const page = latestResult ? latestResult.page + 1 : void 0;
223
- const requestedAt = Date.now();
224
223
  const response = await this.#internalGet({
225
224
  ...resolvedParams,
226
225
  page
227
226
  });
228
227
  latestResult = await response.json();
229
228
  documents.push(...latestResult.results);
230
- const isCached = response.headers.get("x-cache")?.startsWith("Hit") || Date.parse(response.headers.get("date") ?? "") < requestedAt - 5e3;
231
- if (latestResult.next_page && !isCached) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
229
+ const isCached = () => response.headers.get("x-cache")?.startsWith("Hit") || Date.parse(response.headers.get("date") ?? "") < Date.now() - 5e3;
230
+ if (latestResult.next_page && !isCached()) await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
232
231
  }
233
232
  return documents.slice(0, limit);
234
233
  }
@@ -444,14 +443,14 @@ var Client = class {
444
443
  * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#getrepository}
445
444
  */
446
445
  async getRepository(params) {
447
- if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) return this.#cachedRepository;
446
+ if (this.#cachedRepository && this.#cachedRepositoryExpiration > performance.now()) return this.#cachedRepository;
448
447
  const url = new URL(this.documentAPIEndpoint);
449
448
  const accessToken = params?.accessToken || this.accessToken;
450
449
  if (accessToken) url.searchParams.set("access_token", accessToken);
451
450
  const response = await this.#request(url, params);
452
451
  if (response.ok) {
453
452
  this.#cachedRepository = await response.json();
454
- this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
453
+ this.#cachedRepositoryExpiration = performance.now() + REPOSITORY_CACHE_TTL;
455
454
  return this.#cachedRepository;
456
455
  }
457
456
  if (response.status === 404) throw new RepositoryNotFoundError(`Prismic repository not found. Check that "${this.documentAPIEndpoint}" is pointing to the correct repository.`, url.toString(), void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","names":[],"sources":["../src/Client.ts"],"sourcesContent":["import { type BuildQueryURLArgs, buildQueryURL } from \"./buildQueryURL\"\nimport {\n\tForbiddenError,\n\tNotFoundError,\n\tParsingError,\n\tPreviewTokenExpiredError,\n\tPrismicError,\n\tRefExpiredError,\n\tRefNotFoundError,\n\tRepositoryNotFoundError,\n} from \"./errors\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { type LinkResolverFunction, asLink } from \"./helpers/asLink\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type AbortSignalLike, type FetchLike, type RequestInitLike, request } from \"./lib/request\"\nimport { throttledWarn } from \"./lib/throttledWarn\"\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\nconst MAX_PAGE_SIZE = 100\nconst REPOSITORY_CACHE_TTL = 5000\nconst GET_ALL_QUERY_DELAY = 500\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/** Extracts a document type with a matching `type` property from a union of document types. */\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 Prismic preview\n * support.\n */\nexport type HttpRequestLike =\n\t| // Web API Request\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\t// Express-style request\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 queries content\n * from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/** Parameters for client methods that use `fetch()`. */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These options will be\n\t * merged with internally required options. They can also be overriden on a per-query basis using\n\t * the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\t/** @deprecated Move to `fetchOptions.signal`: */\n\t// TODO: Remove in v8.\n\tsignal?: AbortSignalLike\n}\n\n/** Prismic client configuration. */\nexport type ClientConfig = {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint?: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * The version of the repository's content. It can optionally be a function that returns a ref.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tref?: string | GetRef\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetch?: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods start with `getAll`\n * (e.g. `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried.\n\t *\n\t * @default No limit.\n\t */\n\tlimit?: number\n}\n\n/**\n * A client for fetching content from a Prismic repository.\n *\n * @see {@link https://prismic.io/docs/fetch-content}\n * @see {@link https://prismic.io/docs/technical-reference/prismicio-client}\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<BuildQueryURLArgs, \"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\">\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchFn: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0 // Timestamp\n\n\t/**\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n\t * the repository.\n\t * @param config - Client configuration.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, config: 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} = config\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(this.documentAPIEndpoint)\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname) &&\n\t\t\t!/\\.cdn\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname)\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/** The Prismic repository's name. */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\t/** The Prismic repository's name. */\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/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\t/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\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 * \t;```ts\n\t * \tclient.enableAutoPreviews()\n\t * \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 using an HTTP request\n\t * object.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.enableAutoPreviewsFromReq(req)\n\t * \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 session.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.disableAutoPreviews()\n\t * \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 * \t;```ts\n\t * \tconst response = await client.get({ pageSize: 10 })\n\t * \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 * \t;```ts\n\t * \tconst page = await client.getFirst()\n\t * \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?.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(\"No documents were returned\", response.url, undefined)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.dangerouslyGetAll()\n\t * \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\">> & GetAllParams & FetchParams = {},\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 ((!latestResult || latestResult.next_page) && documents.length < limit) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tconst requestedAt = Date.now()\n\t\t\tconst response = await this.#internalGet({ ...resolvedParams, page })\n\t\t\tlatestResult = (await response.json()) as Query<TDocument>\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\t// Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even\n\t\t\t// when they also replay an `x-cache: Miss`. The margin covers clock skew.\n\t\t\tconst isCached =\n\t\t\t\tresponse.headers.get(\"x-cache\")?.startsWith(\"Hit\") ||\n\t\t\t\tDate.parse(response.headers.get(\"date\") ?? \"\") < requestedAt - 5000\n\t\t\tif (latestResult.next_page && !isCached) {\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 * \t;```ts\n\t * \tconst page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * \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>(appendFilters(params, filter.at(\"document.id\", id)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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>(appendFilters(params, filter.in(\"document.id\", ids)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network requests to fetch all\n\t * matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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\">> & GetAllParams & FetchParams,\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 * \t;```ts\n\t * \tconst page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst page = await client.getSingle(\"settings\")\n\t * \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, filter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst response = await client.getByType(\"blog_post\")\n\t * \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, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByType(\"blog_post\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByTag(\"featured\")\n\t * \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, filter.any(\"document.tags\", [tag])))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByTag(\"featured\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", [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 * \t;```ts\n\t * \tconst response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.at(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.tags\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.any(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", 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 * \t;```ts\n\t * \tconst repository = await client.getRepository()\n\t * \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 (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) {\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 * \t;```ts\n\t * \tconst refs = await client.getRefs()\n\t * \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 * \t;```ts\n\t * \tconst ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.id === id)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst ref = await client.getRefByLabel(\"My Release\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.label === label)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with label \"${label}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst masterRef = await client.getMasterRef()\n\t * \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\t\tconst ref = refs.find((ref) => ref.isMasterRef)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(\"Master ref could not be found.\", undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst releases = await client.getReleases()\n\t * \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 * \t;```ts\n\t * \tconst release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst release = releases.find((ref) => ref.id === id)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(`Release with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst release = await client.getReleaseByLabel(\"My Release\")\n\t * \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\t\tconst release = releases.find((ref) => ref.label === label)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`Release with label \"${label}\" could not be found.`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst tags = await client.getTags()\n\t * \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 * \t;```ts\n\t * \tconst url = await client.buildQueryURL({\n\t * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * \t})\n\t * \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 * \t;```ts\n\t * \tconst url = await client.resolvePreviewURL({\n\t * \t\tlinkResolver,\n\t * \t\tdefaultURL: \"/\",\n\t * \t})\n\t * \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: {\n\t\t\t/** A function converts a document to a URL in your website. */\n\t\t\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\t\t\t/** A fallback URL used when the document does not have a URL. */\n\t\t\tdefaultURL: string\n\t\t\t/** The preview token for the preview session. */\n\t\t\tpreviewToken?: string\n\t\t\t/** The previewed document's ID. */\n\t\t\tdocumentID?: string\n\t\t} & 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 = documentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken = previewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\"url\" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {\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(this.#autoPreviewsRequest.url, \"missing-host://\").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 client's default mode.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryLatestContent()\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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 label.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryContentFromReleaseByLabel(\"My Release\")\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromRef(\"my-ref\")\n\t * \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 provided to GraphQL\n\t * clients.\n\t *\n\t * @example\n\t * \t```ts\n\t * \timport { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * \tconst client = createClient(\"example-prismic-repo\")\n\t * \tconst graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \tfetch: client.graphQLFetch,\n\t * \t// Using GET is required.\n\t * \tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * \t})\n\t * \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 params = {\n\t\t\taccessToken: this.accessToken,\n\t\t\tfetchOptions: this.fetchOptions,\n\t\t}\n\t\tconst repository = await this.getRepository(params)\n\t\tconst ref = await this.#getResolvedRef(params)\n\n\t\tconst headers: NonNullable<RequestInitLike[\"headers\"]> = {}\n\t\theaders[\"prismic-ref\"] = ref\n\t\tif (this.accessToken) {\n\t\t\theaders[\"authorization\"] = `Token ${this.accessToken}`\n\t\t}\n\t\tif (repository.integrationFieldsRef) {\n\t\t\theaders[\"prismic-integration-field-ref\"] = repository.integrationFieldsRef\n\t\t}\n\t\tfor (const [key, value] of Object.entries(init?.headers ?? {})) {\n\t\t\theaders[key.toLowerCase()] = value\n\t\t}\n\n\t\tconst url = new URL(typeof input === \"string\" ? input : input.url)\n\t\tconst query = (url.searchParams.get(\"query\") ?? \"\").replace(\n\t\t\t// Minify the query\n\t\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t\t(_chars, _spaces, brackets) => brackets,\n\t\t)\n\t\turl.searchParams.set(\"query\", query)\n\t\t// Only used to prevent caching; caches ignore header differences\n\t\turl.searchParams.set(\"ref\", ref)\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 method may make a\n\t * network request to fetch a ref or resolve the user's ref thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority.\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. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new master ref is fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref. The ref is cached\n\t * for 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back to the master ref if\n\t * the ref is not a string.\n\t */\n\tasync #getResolvedRef(params?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams) {\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 * Performs a low-level Content API request with the given parameters. Automatically retries if an\n\t * invalid ref is used.\n\t */\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 || error 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)?.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\tthrottledWarn(\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)\n\n\t\t\t\treturn await this.#internalGet({ ...params, ref: masterRef }, attempt + 1)\n\t\t\t}\n\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/** Throws an error based on a Content API response. Only call in known-errored states. */\n\tasync #throwContentAPIError(response: ResponseLike, url: string): 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/** Performs a low-level network request with the client's fetch options. */\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: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n}\n\n/** Appends filters to a params object. */\nfunction appendFilters<T extends Pick<BuildQueryURLArgs, \"filters\">>(\n\tparams = {} as T,\n\t...filters: string[]\n): T & { filters: string[] } {\n\treturn { ...params, filters: [...(params.filters ?? []), ...filters] }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC;;;;;;;AAmIvC,IAAa,SAAb,MAA0E;;;;;;CAMzE;;;;;;CAMA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;CAEA;CAEA;CACA,gBAAgB;CAChB;CAEA;CACA,8BAA8B;;;;;;CAO9B,YAAY,0BAAkC,SAAuB,CAAC,GAAG;EACxE,MAAM,EACL,qBACA,aACA,KACA,QACA,aACA,eACA,eAAe,CAAC,GAChB,QAAQ,WAAW,OAAO,KAAK,UAAU,MACtC;EAEJ,IAAI,qBAAqB,wBAAwB,GAAG;GACnD,IAAI;IACH,KAAK,iBAAiB,kBAAkB,wBAAw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Aa,KAAK,SAAS,KAAK,IAAI;GAC/C;GACA,KAAK,KAAK;IACT,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;IACzC,MAAM,IAAI,eAAe,KAAK,SAAS,KAAK,IAAI;GACjD;GACA,KAAK,KAAK;IACT,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;IACzC,QAAQ,KAAK,MAAb;KACC,KAAK,sBACJ,MAAM,IAAI,iBAAiB,KAAK,SAAS,KAAK,IAAI;KAEnD,KAAK,sBACJ,IAAI,0BAA0B,KAAK,KAAK,OAAO,GAC9C,MAAM,IAAI,yBAAyB,KAAK,SAAS,KAAK,IAAI;KAG5D,SACC,MAAM,IAAI,cAAc,KAAK,SAAS,KAAK,IAAI;IAEjD;GACD;GACA,KAAK,KAAK;IACT,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;IACzC,MAAM,IAAI,gBAAgB,KAAK,SAAS,KAAK,IAAI;GAClD;GACA,SACC,MAAM,IAAI,aAAa,KAAA,GAAW,KAAK,MAAM,SAAS,KAAK,CAAC;EAE9D;CACD;;CAGA,MAAM,SAAS,KAAU,QAA6C;EACrE,OAAO,MAAM,QACZ,KACA;GACC,GAAG,KAAK;GACR,GAAG,QAAQ;GACX,SAAS;IACR,GAAG,KAAK,cAAc;IACtB,GAAG,QAAQ,cAAc;GAC1B;GACA,QAAQ,QAAQ,cAAc,UAAU,QAAQ,UAAU,KAAK,cAAc;EAC9E,GACA,KAAK,OACN;CACD;AACD;;AAGA,SAAS,cACR,SAAS,CAAC,GACV,GAAG,SACyB;CAC5B,OAAO;EAAE,GAAG;EAAQ,SAAS,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,GAAG,OAAO;CAAE;AACtE"}
1
+ {"version":3,"file":"Client.js","names":[],"sources":["../src/Client.ts"],"sourcesContent":["import { type BuildQueryURLArgs, buildQueryURL } from \"./buildQueryURL\"\nimport {\n\tForbiddenError,\n\tNotFoundError,\n\tParsingError,\n\tPreviewTokenExpiredError,\n\tPrismicError,\n\tRefExpiredError,\n\tRefNotFoundError,\n\tRepositoryNotFoundError,\n} from \"./errors\"\nimport { filter } from \"./filter\"\nimport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\"\nimport { getRepositoryName } from \"./getRepositoryName\"\nimport { type LinkResolverFunction, asLink } from \"./helpers/asLink\"\nimport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\"\nimport { devMsg } from \"./lib/devMsg\"\nimport { getPreviewCookie } from \"./lib/getPreviewCookie\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type AbortSignalLike, type FetchLike, type RequestInitLike, request } from \"./lib/request\"\nimport { throttledWarn } from \"./lib/throttledWarn\"\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\nconst MAX_PAGE_SIZE = 100\nconst REPOSITORY_CACHE_TTL = 5000\nconst GET_ALL_QUERY_DELAY = 500\nconst MAX_INVALID_REF_RETRY_ATTEMPTS = 3\n\n/** Extracts a document type with a matching `type` property from a union of document types. */\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 Prismic preview\n * support.\n */\nexport type HttpRequestLike =\n\t| // Web API Request\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\t// Express-style request\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 queries content\n * from.\n */\ntype GetRef = (\n\tparams?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams,\n) => string | undefined | Promise<string | undefined>\n\n/** Parameters for client methods that use `fetch()`. */\nexport type FetchParams = {\n\t/**\n\t * Options provided to the client's `fetch()` on all network requests. These options will be\n\t * merged with internally required options. They can also be overriden on a per-query basis using\n\t * the query's `fetchOptions` parameter.\n\t */\n\tfetchOptions?: RequestInitLike\n\t/** @deprecated Move to `fetchOptions.signal`: */\n\t// TODO: Remove in v8.\n\tsignal?: AbortSignalLike\n}\n\n/** Prismic client configuration. */\nexport type ClientConfig = {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint?: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * The version of the repository's content. It can optionally be a function that returns a ref.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tref?: string | GetRef\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<\n\t\tBuildQueryURLArgs,\n\t\t\"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\" | \"brokenRoute\"\n\t>\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetch?: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions?: RequestInitLike\n}\n\n/**\n * Parameters specific to client methods that fetch all documents. These methods start with `getAll`\n * (e.g. `getAllByType`).\n */\ntype GetAllParams = {\n\t/**\n\t * Limit the number of documents queried.\n\t *\n\t * @default No limit.\n\t */\n\tlimit?: number\n}\n\n/**\n * A client for fetching content from a Prismic repository.\n *\n * @see {@link https://prismic.io/docs/fetch-content}\n * @see {@link https://prismic.io/docs/technical-reference/prismicio-client}\n */\nexport class Client<TDocuments extends PrismicDocument = PrismicDocument> {\n\t/**\n\t * The client's Content API endpoint.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdocumentAPIEndpoint: string\n\t/**\n\t * The secure token used for the Content API.\n\t *\n\t * @see {@link https://prismic.io/docs/fetch-content#content-visibility}\n\t */\n\taccessToken?: string\n\t/**\n\t * A list of route resolver objects that define how a document's `url` property is resolved.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\troutes?: NonNullable<BuildQueryURLArgs[\"routes\"]>\n\t/**\n\t * The URL used for link or content relationship fields that point to an archived or deleted page.\n\t *\n\t * @see {@link https://prismic.io/docs/routes}\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tbrokenRoute?: NonNullable<BuildQueryURLArgs[\"brokenRoute\"]>\n\t/**\n\t * Default parameters sent with each Content API request. These parameters can be overridden on\n\t * each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tdefaultParams?: Omit<BuildQueryURLArgs, \"ref\" | \"integrationFieldsRef\" | \"accessToken\" | \"routes\">\n\t/**\n\t * The `fetch` function used to make network requests.\n\t *\n\t * @default The global `fetch` function.\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchFn: FetchLike\n\t/**\n\t * The default `fetch` options sent with each Content API request. These parameters can be\n\t * overriden on each method.\n\t *\n\t * @see {@link https://prismic.io/docs/technical-reference/prismicio-client/v7#config-options}\n\t */\n\tfetchOptions: RequestInitLike\n\n\t#repositoryName: string | undefined\n\n\t#getRef?: GetRef\n\t#autoPreviews = true\n\t#autoPreviewsRequest?: HttpRequestLike\n\n\t#cachedRepository: Repository | undefined\n\t#cachedRepositoryExpiration = 0 // Timestamp\n\n\t/**\n\t * @param repositoryNameOrEndpoint - The Prismic repository name or full Content API endpoint for\n\t * the repository.\n\t * @param config - Client configuration.\n\t */\n\tconstructor(repositoryNameOrEndpoint: string, config: 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} = config\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io\\/(?!api\\/v2\\/?)/i.test(this.documentAPIEndpoint)\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\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\t/\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname) &&\n\t\t\t!/\\.cdn\\.prismic\\.io$/i.test(new URL(this.documentAPIEndpoint).hostname)\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/** The Prismic repository's name. */\n\tset repositoryName(value: string) {\n\t\tthis.#repositoryName = value\n\t}\n\t/** The Prismic repository's name. */\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/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tset endpoint(value: string) {\n\t\tthis.documentAPIEndpoint = value\n\t}\n\t/** @deprecated Replace with `documentAPIEndpoint`. */\n\t// TODO: Remove in v8.\n\tget endpoint(): string {\n\t\treturn this.documentAPIEndpoint\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 * \t;```ts\n\t * \tclient.enableAutoPreviews()\n\t * \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 using an HTTP request\n\t * object.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.enableAutoPreviewsFromReq(req)\n\t * \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 session.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.disableAutoPreviews()\n\t * \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 * \t;```ts\n\t * \tconst response = await client.get({ pageSize: 10 })\n\t * \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 * \t;```ts\n\t * \tconst page = await client.getFirst()\n\t * \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?.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(\"No documents were returned\", response.url, undefined)\n\t}\n\n\t/**\n\t * Fetches all pages based on the `params` argument. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.dangerouslyGetAll()\n\t * \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\">> & GetAllParams & FetchParams = {},\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 ((!latestResult || latestResult.next_page) && documents.length < limit) {\n\t\t\tconst page = latestResult ? latestResult.page + 1 : undefined\n\n\t\t\tconst response = await this.#internalGet({ ...resolvedParams, page })\n\t\t\tlatestResult = (await response.json()) as Query<TDocument>\n\t\t\tdocuments.push(...latestResult.results)\n\n\t\t\t// Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even\n\t\t\t// when they also replay an `x-cache: Miss`. The margin covers clock skew.\n\t\t\t// Lazy, because Next.js forbids `Date.now()` during a prerender.\n\t\t\tconst isCached = () =>\n\t\t\t\tresponse.headers.get(\"x-cache\")?.startsWith(\"Hit\") ||\n\t\t\t\tDate.parse(response.headers.get(\"date\") ?? \"\") < Date.now() - 5000\n\t\t\tif (latestResult.next_page && !isCached()) {\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 * \t;```ts\n\t * \tconst page = await client.getByID(\"WW4bKScAAMAqmluX\")\n\t * \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>(appendFilters(params, filter.at(\"document.id\", id)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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>(appendFilters(params, filter.in(\"document.id\", ids)))\n\t}\n\n\t/**\n\t * Fetches pages with specific IDs. This method may make multiple network requests to fetch all\n\t * matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByIDs([\"WW4bKScAAMAqmluX\", \"U1kTRgEAAC8A5ldS\"])\n\t * \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\">> & GetAllParams & FetchParams,\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 * \t;```ts\n\t * \tconst page = await client.getByUID(\"blog_post\", \"my-first-post\")\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByUIDs(\"blog_post\", [\"my-first-post\", \"my-second-post\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(\n\t\t\t\tparams,\n\t\t\t\tfilter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst page = await client.getSingle(\"settings\")\n\t * \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, filter.at(\"document.type\", 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 * \t;```ts\n\t * \tconst response = await client.getByType(\"blog_post\")\n\t * \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, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific type. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByType(\"blog_post\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {\n\t\treturn await this.dangerouslyGetAll<ExtractDocumentType<TDocument, TDocumentType>>(\n\t\t\tappendFilters(params, filter.at(\"document.type\", documentType)),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. Results are paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getByTag(\"featured\")\n\t * \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, filter.any(\"document.tags\", [tag])))\n\t}\n\n\t/**\n\t * Fetches pages with a specific tag. This method may make multiple network requests to fetch all\n\t * matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByTag(\"featured\")\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", [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 * \t;```ts\n\t * \tconst response = await client.getByEveryTag([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.at(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with every tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching pages.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllByEveryTag([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.at(\"document.tags\", 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 paginated.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst response = await client.getBySomeTags([\"featured\", \"homepage\"])\n\t * \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>(appendFilters(params, filter.any(\"document.tags\", tags)))\n\t}\n\n\t/**\n\t * Fetches pages with at least one tag from a list of tags. This method may make multiple network\n\t * requests to fetch all matching documents.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst pages = await client.getAllBySomeTags([\"featured\", \"homepage\"])\n\t * \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\">> & GetAllParams & FetchParams,\n\t): Promise<TDocument[]> {\n\t\treturn await this.dangerouslyGetAll<TDocument>(\n\t\t\tappendFilters(params, filter.any(\"document.tags\", 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 * \t;```ts\n\t * \tconst repository = await client.getRepository()\n\t * \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 (this.#cachedRepository && this.#cachedRepositoryExpiration > performance.now()) {\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 = performance.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 * \t;```ts\n\t * \tconst refs = await client.getRefs()\n\t * \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 * \t;```ts\n\t * \tconst ref = await client.getRefByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.id === id)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches a ref by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst ref = await client.getRefByLabel(\"My Release\")\n\t * \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\t\tconst ref = refs.find((ref) => ref.label === label)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(`Ref with label \"${label}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's master ref.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst masterRef = await client.getMasterRef()\n\t * \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\t\tconst ref = refs.find((ref) => ref.isMasterRef)\n\n\t\tif (!ref) {\n\t\t\tthrow new PrismicError(\"Master ref could not be found.\", undefined, undefined)\n\t\t}\n\n\t\treturn ref\n\t}\n\n\t/**\n\t * Fetches the repository's active releases.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst releases = await client.getReleases()\n\t * \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 * \t;```ts\n\t * \tconst release = await client.getReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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\t\tconst release = releases.find((ref) => ref.id === id)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(`Release with ID \"${id}\" could not be found.`, undefined, undefined)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches a release by its label. A release ref's label is its name shown in the Page Builder.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst release = await client.getReleaseByLabel(\"My Release\")\n\t * \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\t\tconst release = releases.find((ref) => ref.label === label)\n\n\t\tif (!release) {\n\t\t\tthrow new PrismicError(\n\t\t\t\t`Release with label \"${label}\" could not be found.`,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t)\n\t\t}\n\n\t\treturn release\n\t}\n\n\t/**\n\t * Fetches the repository's page tags.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tconst tags = await client.getTags()\n\t * \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 * \t;```ts\n\t * \tconst url = await client.buildQueryURL({\n\t * \t\tfilters: [filter.at(\"document.type\", \"blog_post\")],\n\t * \t})\n\t * \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 * \t;```ts\n\t * \tconst url = await client.resolvePreviewURL({\n\t * \t\tlinkResolver,\n\t * \t\tdefaultURL: \"/\",\n\t * \t})\n\t * \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: {\n\t\t\t/** A function converts a document to a URL in your website. */\n\t\t\tlinkResolver?: LinkResolverFunction<LinkResolverReturnType>\n\t\t\t/** A fallback URL used when the document does not have a URL. */\n\t\t\tdefaultURL: string\n\t\t\t/** The preview token for the preview session. */\n\t\t\tpreviewToken?: string\n\t\t\t/** The previewed document's ID. */\n\t\t\tdocumentID?: string\n\t\t} & 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 = documentID || (this.#autoPreviewsRequest.query?.documentId as string)\n\t\t\t\tpreviewToken = previewToken || (this.#autoPreviewsRequest.query?.token as string)\n\t\t\t} else if (\"url\" in this.#autoPreviewsRequest && this.#autoPreviewsRequest.url) {\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(this.#autoPreviewsRequest.url, \"missing-host://\").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 client's default mode.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryLatestContent()\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromReleaseByID(\"YhE3YhEAACIA4321\")\n\t * \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 label.\n\t *\n\t * @example\n\t * \t;```ts\n\t * \tclient.queryContentFromReleaseByLabel(\"My Release\")\n\t * \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 * \t;```ts\n\t * \tclient.queryContentFromRef(\"my-ref\")\n\t * \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 provided to GraphQL\n\t * clients.\n\t *\n\t * @example\n\t * \t```ts\n\t * \timport { createClient, getGraphQLEndpoint } from \"@prismicio/client\"\n\t *\n\t * \tconst client = createClient(\"example-prismic-repo\")\n\t * \tconst graphQLClient = new ApolloClient({\n\t * \tlink: new HttpLink({\n\t * \turi: getGraphQLEndpoint(client.repositoryName),\n\t * \t// Provide `client.graphQLFetch` as the fetch implementation.\n\t * \tfetch: client.graphQLFetch,\n\t * \t// Using GET is required.\n\t * \tuseGETForQueries: true,\n\t * \t}),\n\t * \tcache: new InMemoryCache(),\n\t * \t})\n\t * \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 params = {\n\t\t\taccessToken: this.accessToken,\n\t\t\tfetchOptions: this.fetchOptions,\n\t\t}\n\t\tconst repository = await this.getRepository(params)\n\t\tconst ref = await this.#getResolvedRef(params)\n\n\t\tconst headers: NonNullable<RequestInitLike[\"headers\"]> = {}\n\t\theaders[\"prismic-ref\"] = ref\n\t\tif (this.accessToken) {\n\t\t\theaders[\"authorization\"] = `Token ${this.accessToken}`\n\t\t}\n\t\tif (repository.integrationFieldsRef) {\n\t\t\theaders[\"prismic-integration-field-ref\"] = repository.integrationFieldsRef\n\t\t}\n\t\tfor (const [key, value] of Object.entries(init?.headers ?? {})) {\n\t\t\theaders[key.toLowerCase()] = value\n\t\t}\n\n\t\tconst url = new URL(typeof input === \"string\" ? input : input.url)\n\t\tconst query = (url.searchParams.get(\"query\") ?? \"\").replace(\n\t\t\t// Minify the query\n\t\t\t/(\\n| )*( |{|})(\\n| )*/gm,\n\t\t\t(_chars, _spaces, brackets) => brackets,\n\t\t)\n\t\turl.searchParams.set(\"query\", query)\n\t\t// Only used to prevent caching; caches ignore header differences\n\t\turl.searchParams.set(\"ref\", ref)\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 method may make a\n\t * network request to fetch a ref or resolve the user's ref thunk.\n\t *\n\t * If auto previews are enabled, the preview ref takes priority.\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. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new master ref is fetched.\n\t * - If the user called `queryContentFromReleaseByID`: Use the release's ref. The ref is cached for\n\t * 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref. The ref is cached\n\t * for 5 seconds. After 5 seconds, a new ref for the release is fetched.\n\t * - If the user called `queryContentFromRef`: Use the provided ref. Fall back to the master ref if\n\t * the ref is not a string.\n\t */\n\tasync #getResolvedRef(params?: Pick<BuildQueryURLArgs, \"accessToken\"> & FetchParams) {\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 * Performs a low-level Content API request with the given parameters. Automatically retries if an\n\t * invalid ref is used.\n\t */\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 || error 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)?.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\tthrottledWarn(\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)\n\n\t\t\t\treturn await this.#internalGet({ ...params, ref: masterRef }, attempt + 1)\n\t\t\t}\n\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t/** Throws an error based on a Content API response. Only call in known-errored states. */\n\tasync #throwContentAPIError(response: ResponseLike, url: string): 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/** Performs a low-level network request with the client's fetch options. */\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: params?.fetchOptions?.signal || params?.signal || this.fetchOptions?.signal,\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n}\n\n/** Appends filters to a params object. */\nfunction appendFilters<T extends Pick<BuildQueryURLArgs, \"filters\">>(\n\tparams = {} as T,\n\t...filters: string[]\n): T & { filters: string[] } {\n\treturn { ...params, filters: [...(params.filters ?? []), ...filters] }\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,iCAAiC;;;;;;;AAmIvC,IAAa,SAAb,MAA0E;;;;;;CAMzE;;;;;;CAMA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;;;;;;;CAOA;CAEA;CAEA;CACA,gBAAgB;CAChB;CAEA;CACA,8BAA8B;;;;;;CAO9B,YAAY,0BAAkC,SAAuB,CAAC,GAAG;EACxE,MAAM,EACL,qBACA,aACA,KACA,QACA,aACA,eACA,eAAe,CAAC,GAChB,QAAQ,WAAW,OAAO,KAAK,UAAU,MACtC;EAEJ,IAAI,qBAAqB,wBAAwB,GAAG;GACnD,IAAI;IACH,KAAK,iBAAiB,kBAAkB,wBAAwB;GACjE,QAAQ;IACP,QAAQ,KACP,6FAA6F,yBAAyB,+HAA+H,OAAO,wBAAwB,GACrR;GACD;GACA,KAAK,sBAAsB,uBAAuB;EACnD,OAAO;GACN,KAAK,iBAAiB;GACtB,KAAK,sBACJ,uBAAuB,sBAAsB,wBAAwB;EACvE;EAEA,IAAI,CAAC,OACJ,MAAM,IAAI,aACT,8KACA,KAAA,GACA,KAAA,CACD;EAED,IAAI,OAAO,UAAU,YACpB,MAAM,IAAI,aACT,2CAA2C,OAAO,SAClD,KAAA,GACA,KAAA,CACD;EAGD,IAAI,CAAC,qBAAqB,KAAK,mBAAmB,GACjD,MAAM,IAAI,aACT,2CAA2C,uBAC3C,KAAA,GACA,KAAA,CACD;EAED,IACC,qBAAqB,wBAAw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;GACA,KAAK,KAAK;IACT,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;IACzC,MAAM,IAAI,gBAAgB,KAAK,SAAS,KAAK,IAAI;GAClD;GACA,SACC,MAAM,IAAI,aAAa,KAAA,GAAW,KAAK,MAAM,SAAS,KAAK,CAAC;EAE9D;CACD;;CAGA,MAAM,SAAS,KAAU,QAA6C;EACrE,OAAO,MAAM,QACZ,KACA;GACC,GAAG,KAAK;GACR,GAAG,QAAQ;GACX,SAAS;IACR,GAAG,KAAK,cAAc;IACtB,GAAG,QAAQ,cAAc;GAC1B;GACA,QAAQ,QAAQ,cAAc,UAAU,QAAQ,UAAU,KAAK,cAAc;EAC9E,GACA,KAAK,OACN;CACD;AACD;;AAGA,SAAS,cACR,SAAS,CAAC,GACV,GAAG,SACyB;CAC5B,OAAO;EAAE,GAAG;EAAQ,SAAS,CAAC,GAAI,OAAO,WAAW,CAAC,GAAI,GAAG,OAAO;CAAE;AACtE"}
@@ -11,7 +11,7 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
11
11
  const pLimit = ({ interval } = {}) => {
12
12
  const queue = [];
13
13
  let busy = false;
14
- let lastCompletion = 0;
14
+ let lastCompletion = -Infinity;
15
15
  const resumeNext = () => {
16
16
  if (!busy && queue.length > 0) {
17
17
  queue.shift()?.();
@@ -23,14 +23,14 @@ const pLimit = ({ interval } = {}) => {
23
23
  resumeNext();
24
24
  };
25
25
  const run = async (function_, resolve, arguments_) => {
26
- const timeSinceLastCompletion = Date.now() - lastCompletion;
26
+ const timeSinceLastCompletion = performance.now() - lastCompletion;
27
27
  if (interval && timeSinceLastCompletion < interval) await sleep(interval - timeSinceLastCompletion);
28
28
  const result = (async () => function_(...arguments_))();
29
29
  resolve(result);
30
30
  try {
31
31
  await result;
32
32
  } catch {}
33
- lastCompletion = Date.now();
33
+ lastCompletion = performance.now();
34
34
  next();
35
35
  };
36
36
  const enqueue = (function_, resolve, arguments_) => {
@@ -1 +1 @@
1
- {"version":3,"file":"pLimit.cjs","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the\n * `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't\n * need this optimization unless you're pushing a lot of functions.\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (...arguments_: TArguments) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and respect a given\n * interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to wait between each\n * promise execution.\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;;;;AAsB9E,MAAa,UAAU,EAAE,aAAoC,CAAC,MAAqB;CAClF,MAAM,QAAuB,CAAC;CAC9B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;EACxB,IAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;GAC9B,MAAM,MAAM,CAAC,GAAG;GAChB,OAAO;EACR;CACD;CAEA,MAAM,aAAa;EAClB,OAAO;EAEP,WAAW;CACZ;CAEA,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,KAAK,IAAI,IAAI;EAE7C,IAAI,YAAY,0BAA0B,UACzC,MAAM,MAAM,WAAW,uBAAuB;EAE/C,MAAM,UAAU,YAAY,UAAU,GAAG,UAAU,EAAA,CAAG;EAEtD,QAAQ,MAAM;EAEd,IAAI;GACH,MAAM;EACP,QAAQ,CAAC;EAET,iBAAiB,KAAK,IAAI;EAE1B,KAAK;CACN;CAEA,MAAM,WACL,WACA,SACA,eACI;EAGJ,IAAI,SAAS,oBAAoB;GAChC,MAAM,KAAK,eAAe;EAC3B,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,UAAU,CAAC;EAC1D,CAAC,YAAY;GAKb,MAAM,QAAQ,QAAQ;GAEtB,IAAI,CAAC,MACJ,WAAW;EAEb,EAAA,CAAG;CACJ;CAEA,SAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;EACjC,QAAQ,WAAW,SAAS,UAAU;CACvC,CAAC;AACH"}
1
+ {"version":3,"file":"pLimit.cjs","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the\n * `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't\n * need this optimization unless you're pushing a lot of functions.\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (...arguments_: TArguments) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and respect a given\n * interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to wait between each\n * promise execution.\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = -Infinity\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = performance.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = performance.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;;;;AAsB9E,MAAa,UAAU,EAAE,aAAoC,CAAC,MAAqB;CAClF,MAAM,QAAuB,CAAC;CAC9B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;EACxB,IAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;GAC9B,MAAM,MAAM,CAAC,GAAG;GAChB,OAAO;EACR;CACD;CAEA,MAAM,aAAa;EAClB,OAAO;EAEP,WAAW;CACZ;CAEA,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,YAAY,IAAI,IAAI;EAEpD,IAAI,YAAY,0BAA0B,UACzC,MAAM,MAAM,WAAW,uBAAuB;EAE/C,MAAM,UAAU,YAAY,UAAU,GAAG,UAAU,EAAA,CAAG;EAEtD,QAAQ,MAAM;EAEd,IAAI;GACH,MAAM;EACP,QAAQ,CAAC;EAET,iBAAiB,YAAY,IAAI;EAEjC,KAAK;CACN;CAEA,MAAM,WACL,WACA,SACA,eACI;EAGJ,IAAI,SAAS,oBAAoB;GAChC,MAAM,KAAK,eAAe;EAC3B,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,UAAU,CAAC;EAC1D,CAAC,YAAY;GAKb,MAAM,QAAQ,QAAQ;GAEtB,IAAI,CAAC,MACJ,WAAW;EAEb,EAAA,CAAG;CACJ;CAEA,SAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;EACjC,QAAQ,WAAW,SAAS,UAAU;CACvC,CAAC;AACH"}
@@ -11,7 +11,7 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
11
11
  const pLimit = ({ interval } = {}) => {
12
12
  const queue = [];
13
13
  let busy = false;
14
- let lastCompletion = 0;
14
+ let lastCompletion = -Infinity;
15
15
  const resumeNext = () => {
16
16
  if (!busy && queue.length > 0) {
17
17
  queue.shift()?.();
@@ -23,14 +23,14 @@ const pLimit = ({ interval } = {}) => {
23
23
  resumeNext();
24
24
  };
25
25
  const run = async (function_, resolve, arguments_) => {
26
- const timeSinceLastCompletion = Date.now() - lastCompletion;
26
+ const timeSinceLastCompletion = performance.now() - lastCompletion;
27
27
  if (interval && timeSinceLastCompletion < interval) await sleep(interval - timeSinceLastCompletion);
28
28
  const result = (async () => function_(...arguments_))();
29
29
  resolve(result);
30
30
  try {
31
31
  await result;
32
32
  } catch {}
33
- lastCompletion = Date.now();
33
+ lastCompletion = performance.now();
34
34
  next();
35
35
  };
36
36
  const enqueue = (function_, resolve, arguments_) => {
@@ -1 +1 @@
1
- {"version":3,"file":"pLimit.js","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the\n * `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't\n * need this optimization unless you're pushing a lot of functions.\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (...arguments_: TArguments) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and respect a given\n * interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to wait between each\n * promise execution.\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = 0\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = Date.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = Date.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;;;;AAsB9E,MAAa,UAAU,EAAE,aAAoC,CAAC,MAAqB;CAClF,MAAM,QAAuB,CAAC;CAC9B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;EACxB,IAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;GAC9B,MAAM,MAAM,CAAC,GAAG;GAChB,OAAO;EACR;CACD;CAEA,MAAM,aAAa;EAClB,OAAO;EAEP,WAAW;CACZ;CAEA,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,KAAK,IAAI,IAAI;EAE7C,IAAI,YAAY,0BAA0B,UACzC,MAAM,MAAM,WAAW,uBAAuB;EAE/C,MAAM,UAAU,YAAY,UAAU,GAAG,UAAU,EAAA,CAAG;EAEtD,QAAQ,MAAM;EAEd,IAAI;GACH,MAAM;EACP,QAAQ,CAAC;EAET,iBAAiB,KAAK,IAAI;EAE1B,KAAK;CACN;CAEA,MAAM,WACL,WACA,SACA,eACI;EAGJ,IAAI,SAAS,oBAAoB;GAChC,MAAM,KAAK,eAAe;EAC3B,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,UAAU,CAAC;EAC1D,CAAC,YAAY;GAKb,MAAM,QAAQ,QAAQ;GAEtB,IAAI,CAAC,MACJ,WAAW;EAEb,EAAA,CAAG;CACJ;CAEA,SAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;EACjC,QAAQ,WAAW,SAAS,UAAU;CACvC,CAAC;AACH"}
1
+ {"version":3,"file":"pLimit.js","names":[],"sources":["../../src/lib/pLimit.ts"],"sourcesContent":["/*\n ** Core logic from https://github.com/sindresorhus/p-limit\n ** Many thanks to @sindresorhus\n */\n\n// oxlint-disable-next-line no-explicit-any\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * @param fn - Promise-returning/async function.\n * @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the\n * `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't\n * need this optimization unless you're pushing a lot of functions.\n * @returns The promise returned by calling `fn(...arguments)`.\n */\nexport type LimitFunction = <TArguments extends unknown[], TReturnType>(\n\tfunction_: (...arguments_: TArguments) => PromiseLike<TReturnType> | TReturnType,\n\t...arguments_: TArguments\n) => Promise<TReturnType>\n\n/**\n * Creates a limiting function that will only execute one promise at a time and respect a given\n * interval between each call.\n *\n * @param args - Options for the function, `interval` is the minimum time to wait between each\n * promise execution.\n * @returns A limiting function as per configuration, see {@link LimitFunction}.\n */\nexport const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction => {\n\tconst queue: AnyFunction[] = []\n\tlet busy = false\n\tlet lastCompletion = -Infinity\n\n\tconst resumeNext = () => {\n\t\tif (!busy && queue.length > 0) {\n\t\t\tqueue.shift()?.()\n\t\t\tbusy = true\n\t\t}\n\t}\n\n\tconst next = () => {\n\t\tbusy = false\n\n\t\tresumeNext()\n\t}\n\n\tconst run = async (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\tconst timeSinceLastCompletion = performance.now() - lastCompletion\n\n\t\tif (interval && timeSinceLastCompletion < interval) {\n\t\t\tawait sleep(interval - timeSinceLastCompletion)\n\t\t}\n\t\tconst result = (async () => function_(...arguments_))()\n\n\t\tresolve(result)\n\n\t\ttry {\n\t\t\tawait result\n\t\t} catch {}\n\n\t\tlastCompletion = performance.now()\n\n\t\tnext()\n\t}\n\n\tconst enqueue = (\n\t\tfunction_: AnyFunction,\n\t\tresolve: (value: unknown) => void,\n\t\targuments_: unknown[],\n\t) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise((internalResolve) => {\n\t\t\tqueue.push(internalResolve)\n\t\t}).then(run.bind(undefined, function_, resolve, arguments_))\n\t\t;(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve()\n\n\t\t\tif (!busy) {\n\t\t\t\tresumeNext()\n\t\t\t}\n\t\t})()\n\t}\n\n\treturn ((function_: AnyFunction, ...arguments_: unknown[]) =>\n\t\tnew Promise<unknown>((resolve) => {\n\t\t\tenqueue(function_, resolve, arguments_)\n\t\t})) as LimitFunction\n}\n"],"mappings":";AAQA,MAAM,SAAS,OAAe,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;;;;;;;;;AAsB9E,MAAa,UAAU,EAAE,aAAoC,CAAC,MAAqB;CAClF,MAAM,QAAuB,CAAC;CAC9B,IAAI,OAAO;CACX,IAAI,iBAAiB;CAErB,MAAM,mBAAmB;EACxB,IAAI,CAAC,QAAQ,MAAM,SAAS,GAAG;GAC9B,MAAM,MAAM,CAAC,GAAG;GAChB,OAAO;EACR;CACD;CAEA,MAAM,aAAa;EAClB,OAAO;EAEP,WAAW;CACZ;CAEA,MAAM,MAAM,OACX,WACA,SACA,eACI;EACJ,MAAM,0BAA0B,YAAY,IAAI,IAAI;EAEpD,IAAI,YAAY,0BAA0B,UACzC,MAAM,MAAM,WAAW,uBAAuB;EAE/C,MAAM,UAAU,YAAY,UAAU,GAAG,UAAU,EAAA,CAAG;EAEtD,QAAQ,MAAM;EAEd,IAAI;GACH,MAAM;EACP,QAAQ,CAAC;EAET,iBAAiB,YAAY,IAAI;EAEjC,KAAK;CACN;CAEA,MAAM,WACL,WACA,SACA,eACI;EAGJ,IAAI,SAAS,oBAAoB;GAChC,MAAM,KAAK,eAAe;EAC3B,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,KAAA,GAAW,WAAW,SAAS,UAAU,CAAC;EAC1D,CAAC,YAAY;GAKb,MAAM,QAAQ,QAAQ;GAEtB,IAAI,CAAC,MACJ,WAAW;EAEb,EAAA,CAAG;CACJ;CAEA,SAAS,WAAwB,GAAG,eACnC,IAAI,SAAkB,YAAY;EACjC,QAAQ,WAAW,SAAS,UAAU;CACvC,CAAC;AACH"}
@@ -11,11 +11,11 @@ let lastCalledAt = 0;
11
11
  * @param config - Configuration for the log.
12
12
  */
13
13
  const throttledWarn = (message) => {
14
- if (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
15
- lastCalledAt = Date.now();
14
+ if (message === lastMessage && performance.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
15
+ lastCalledAt = performance.now();
16
16
  return;
17
17
  }
18
- lastCalledAt = Date.now();
18
+ lastCalledAt = performance.now();
19
19
  lastMessage = message;
20
20
  console.warn(message);
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.cjs","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,KAAK,IAAI,IAAI,eAAe,uBAAuB;EACjF,eAAe,KAAK,IAAI;EAExB;CACD;CAEA,eAAe,KAAK,IAAI;CACxB,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
1
+ {"version":3,"file":"throttledWarn.cjs","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && performance.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = performance.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = performance.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,YAAY,IAAI,IAAI,eAAe,uBAAuB;EACxF,eAAe,YAAY,IAAI;EAE/B;CACD;CAEA,eAAe,YAAY,IAAI;CAC/B,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
@@ -11,11 +11,11 @@ let lastCalledAt = 0;
11
11
  * @param config - Configuration for the log.
12
12
  */
13
13
  const throttledWarn = (message) => {
14
- if (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
15
- lastCalledAt = Date.now();
14
+ if (message === lastMessage && performance.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
15
+ lastCalledAt = performance.now();
16
16
  return;
17
17
  }
18
- lastCalledAt = Date.now();
18
+ lastCalledAt = performance.now();
19
19
  lastMessage = message;
20
20
  console.warn(message);
21
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"throttledWarn.js","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = Date.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = Date.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,KAAK,IAAI,IAAI,eAAe,uBAAuB;EACjF,eAAe,KAAK,IAAI;EAExB;CACD;CAEA,eAAe,KAAK,IAAI;CACxB,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
1
+ {"version":3,"file":"throttledWarn.js","names":[],"sources":["../../src/lib/throttledWarn.ts"],"sourcesContent":["const THROTTLE_THRESHOLD_MS = 5000\n\nlet lastMessage: string | undefined\nlet lastCalledAt = 0\n\n/**\n * Logs a warning. If the message is identical the immediate previous logged message and that\n * message was logged within 5 seconds of the current call, the log is ignored. This throttle\n * behavior prevents identical messages from flooding the console.\n *\n * @param message - A message to log.\n * @param config - Configuration for the log.\n */\nexport const throttledWarn = (message: string): void => {\n\tif (message === lastMessage && performance.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {\n\t\tlastCalledAt = performance.now()\n\n\t\treturn\n\t}\n\n\tlastCalledAt = performance.now()\n\tlastMessage = message\n\n\tconsole.warn(message)\n}\n"],"mappings":";AAAA,MAAM,wBAAwB;AAE9B,IAAI;AACJ,IAAI,eAAe;;;;;;;;;AAUnB,MAAa,iBAAiB,YAA0B;CACvD,IAAI,YAAY,eAAe,YAAY,IAAI,IAAI,eAAe,uBAAuB;EACxF,eAAe,YAAY,IAAI;EAE/B;CACD;CAEA,eAAe,YAAY,IAAI;CAC/B,cAAc;CAEd,QAAQ,KAAK,OAAO;AACrB"}
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.23.0-pr.489.0e99b11";
3
+ var version = "7.23.1-pr.491.de51fc9";
4
4
  Object.defineProperty(exports, "name", {
5
5
  enumerable: true,
6
6
  get: function() {
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.23.0-pr.489.0e99b11";
3
+ var version = "7.23.1-pr.491.de51fc9";
4
4
  export { name, version };
5
5
 
6
6
  //# sourceMappingURL=package.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.23.0-pr.489.0e99b11",
3
+ "version": "7.23.1-pr.491.de51fc9",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "client",
@@ -72,8 +72,8 @@
72
72
  "@prismicio/types-internal": "^3.17.2",
73
73
  "@types/node": "^26.6.6",
74
74
  "@vitest/coverage-v8": "^5.1.0",
75
- "oxfmt": "^0.77.0",
76
- "oxlint": "^1.92.0",
75
+ "oxfmt": "^0.78.0",
76
+ "oxlint": "^1.93.0",
77
77
  "tsdown": "^0.23.5",
78
78
  "typescript": "^7.0.2",
79
79
  "vitest": "^5.1.0"
package/src/Client.ts CHANGED
@@ -457,17 +457,17 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
457
457
  while ((!latestResult || latestResult.next_page) && documents.length < limit) {
458
458
  const page = latestResult ? latestResult.page + 1 : undefined
459
459
 
460
- const requestedAt = Date.now()
461
460
  const response = await this.#internalGet({ ...resolvedParams, page })
462
461
  latestResult = (await response.json()) as Query<TDocument>
463
462
  documents.push(...latestResult.results)
464
463
 
465
464
  // Caches (CDN, Next.js Data Cache) replay the origin's `Date` header, even
466
465
  // when they also replay an `x-cache: Miss`. The margin covers clock skew.
467
- const isCached =
466
+ // Lazy, because Next.js forbids `Date.now()` during a prerender.
467
+ const isCached = () =>
468
468
  response.headers.get("x-cache")?.startsWith("Hit") ||
469
- Date.parse(response.headers.get("date") ?? "") < requestedAt - 5000
470
- if (latestResult.next_page && !isCached) {
469
+ Date.parse(response.headers.get("date") ?? "") < Date.now() - 5000
470
+ if (latestResult.next_page && !isCached()) {
471
471
  await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY))
472
472
  }
473
473
  }
@@ -802,7 +802,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
802
802
  async getRepository(
803
803
  params?: Pick<BuildQueryURLArgs, "accessToken"> & FetchParams,
804
804
  ): Promise<Repository> {
805
- if (this.#cachedRepository && this.#cachedRepositoryExpiration > Date.now()) {
805
+ if (this.#cachedRepository && this.#cachedRepositoryExpiration > performance.now()) {
806
806
  return this.#cachedRepository
807
807
  }
808
808
 
@@ -817,7 +817,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
817
817
 
818
818
  if (response.ok) {
819
819
  this.#cachedRepository = (await response.json()) as Repository
820
- this.#cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL
820
+ this.#cachedRepositoryExpiration = performance.now() + REPOSITORY_CACHE_TTL
821
821
 
822
822
  return this.#cachedRepository
823
823
  }
package/src/lib/pLimit.ts CHANGED
@@ -31,7 +31,7 @@ export type LimitFunction = <TArguments extends unknown[], TReturnType>(
31
31
  export const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction => {
32
32
  const queue: AnyFunction[] = []
33
33
  let busy = false
34
- let lastCompletion = 0
34
+ let lastCompletion = -Infinity
35
35
 
36
36
  const resumeNext = () => {
37
37
  if (!busy && queue.length > 0) {
@@ -51,7 +51,7 @@ export const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction
51
51
  resolve: (value: unknown) => void,
52
52
  arguments_: unknown[],
53
53
  ) => {
54
- const timeSinceLastCompletion = Date.now() - lastCompletion
54
+ const timeSinceLastCompletion = performance.now() - lastCompletion
55
55
 
56
56
  if (interval && timeSinceLastCompletion < interval) {
57
57
  await sleep(interval - timeSinceLastCompletion)
@@ -64,7 +64,7 @@ export const pLimit = ({ interval }: { interval?: number } = {}): LimitFunction
64
64
  await result
65
65
  } catch {}
66
66
 
67
- lastCompletion = Date.now()
67
+ lastCompletion = performance.now()
68
68
 
69
69
  next()
70
70
  }
@@ -12,13 +12,13 @@ let lastCalledAt = 0
12
12
  * @param config - Configuration for the log.
13
13
  */
14
14
  export const throttledWarn = (message: string): void => {
15
- if (message === lastMessage && Date.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
16
- lastCalledAt = Date.now()
15
+ if (message === lastMessage && performance.now() - lastCalledAt < THROTTLE_THRESHOLD_MS) {
16
+ lastCalledAt = performance.now()
17
17
 
18
18
  return
19
19
  }
20
20
 
21
- lastCalledAt = Date.now()
21
+ lastCalledAt = performance.now()
22
22
  lastMessage = message
23
23
 
24
24
  console.warn(message)