@prismicio/client 7.21.3-pr.437.4958ca1 → 7.21.3-pr.437.8ac4c04

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.
@@ -17,31 +17,31 @@ const THROTTLED_RUNNERS = {};
17
17
  */
18
18
  const DEDUPLICATED_JOBS = {};
19
19
  function memoizeResponse(response) {
20
- const cache = {};
21
- function createWrapper(res) {
22
- return {
23
- ok: res.ok,
24
- status: res.status,
25
- headers: res.headers,
26
- url: res.url,
27
- async text() {
28
- if (!cache.text) cache.text = res.text();
29
- return cache.text;
30
- },
31
- async json() {
32
- if (!cache.json) cache.json = this.text().then((text) => ({ value: JSON.parse(text) }));
33
- return cache.json.then((cached) => cached.value);
34
- },
35
- async blob() {
36
- if (!cache.blob) cache.blob = res.blob();
37
- return cache.blob;
38
- },
39
- clone() {
40
- return createWrapper(res.clone());
41
- }
42
- };
43
- }
44
- return createWrapper(response);
20
+ let text;
21
+ let json;
22
+ let blob;
23
+ const wrapper = {
24
+ ok: response.ok,
25
+ status: response.status,
26
+ headers: response.headers,
27
+ url: response.url,
28
+ async text() {
29
+ if (!text) text = response.clone().text();
30
+ return text;
31
+ },
32
+ async json() {
33
+ if (!json) json = this.text().then((text$1) => JSON.parse(text$1));
34
+ return json;
35
+ },
36
+ async blob() {
37
+ if (!blob) blob = response.clone().blob();
38
+ return blob;
39
+ },
40
+ clone() {
41
+ return wrapper;
42
+ }
43
+ };
44
+ return wrapper;
45
45
  }
46
46
  /**
47
47
  * Makes an HTTP request with automatic retry for rate limits and request
@@ -1 +1 @@
1
- {"version":3,"file":"request.cjs","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","cache: {\n\t\ttext?: Promise<string>\n\t\tjson?: Promise<{ value: unknown }>\n\t\tblob?: Promise<Blob>\n\t}","job: Promise<ResponseLike>","pLimit"],"sources":["../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// oxlint-disable-next-line no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// oxlint-disable-next-line no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\nfunction memoizeResponse(response: ResponseLike): ResponseLike {\n\tconst cache: {\n\t\ttext?: Promise<string>\n\t\tjson?: Promise<{ value: unknown }>\n\t\tblob?: Promise<Blob>\n\t} = {}\n\n\tfunction createWrapper(res: ResponseLike): ResponseLike {\n\t\treturn {\n\t\t\tok: res.ok,\n\t\t\tstatus: res.status,\n\t\t\theaders: res.headers,\n\t\t\turl: res.url,\n\t\t\tasync text() {\n\t\t\t\tif (!cache.text) {\n\t\t\t\t\tcache.text = res.text()\n\t\t\t\t}\n\t\t\t\treturn cache.text\n\t\t\t},\n\t\t\tasync json() {\n\t\t\t\tif (!cache.json) {\n\t\t\t\t\tcache.json = this.text().then((text) => ({ value: JSON.parse(text) }))\n\t\t\t\t}\n\t\t\t\treturn cache.json.then((cached) => cached.value)\n\t\t\t},\n\t\t\tasync blob() {\n\t\t\t\tif (!cache.blob) {\n\t\t\t\t\tcache.blob = res.blob()\n\t\t\t\t}\n\t\t\t\treturn cache.blob\n\t\t\t},\n\t\t\tclone() {\n\t\t\t\treturn createWrapper(res.clone())\n\t\t\t},\n\t\t}\n\t}\n\n\treturn createWrapper(response)\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,SAAS,gBAAgB,UAAsC;CAC9D,MAAMC,QAIF,EAAE;CAEN,SAAS,cAAc,KAAiC;AACvD,SAAO;GACN,IAAI,IAAI;GACR,QAAQ,IAAI;GACZ,SAAS,IAAI;GACb,KAAK,IAAI;GACT,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,IAAI,MAAM;AAExB,WAAO,MAAM;;GAEd,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,KAAK,MAAM,CAAC,MAAM,UAAU,EAAE,OAAO,KAAK,MAAM,KAAK,EAAE,EAAE;AAEvE,WAAO,MAAM,KAAK,MAAM,WAAW,OAAO,MAAM;;GAEjD,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,IAAI,MAAM;AAExB,WAAO,MAAM;;GAEd,QAAQ;AACP,WAAO,cAAc,IAAI,OAAO,CAAC;;GAElC;;AAGF,QAAO,cAAc,SAAS;;;;;;;;;;;;AAa/B,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoCC,sBAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
1
+ {"version":3,"file":"request.cjs","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","text: Promise<string> | undefined","json: Promise<unknown> | undefined","blob: Promise<Blob> | undefined","wrapper: ResponseLike","text","job: Promise<ResponseLike>","pLimit"],"sources":["../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// oxlint-disable-next-line no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// oxlint-disable-next-line no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\nfunction memoizeResponse(response: ResponseLike): ResponseLike {\n\tlet text: Promise<string> | undefined\n\tlet json: Promise<unknown> | undefined\n\tlet blob: Promise<Blob> | undefined\n\n\tconst wrapper: ResponseLike = {\n\t\tok: response.ok,\n\t\tstatus: response.status,\n\t\theaders: response.headers,\n\t\turl: response.url,\n\t\tasync text() {\n\t\t\tif (!text) {\n\t\t\t\ttext = response.clone().text()\n\t\t\t}\n\t\t\treturn text\n\t\t},\n\t\tasync json() {\n\t\t\tif (!json) {\n\t\t\t\tjson = this.text().then((text) => JSON.parse(text))\n\t\t\t}\n\t\t\treturn json\n\t\t},\n\t\tasync blob() {\n\t\t\tif (!blob) {\n\t\t\t\tblob = response.clone().blob()\n\t\t\t}\n\t\t\treturn blob\n\t\t},\n\t\tclone() {\n\t\t\treturn wrapper\n\t\t},\n\t}\n\n\treturn wrapper\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,SAAS,gBAAgB,UAAsC;CAC9D,IAAIC;CACJ,IAAIC;CACJ,IAAIC;CAEJ,MAAMC,UAAwB;EAC7B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,SAAS,OAAO,CAAC,MAAM;AAE/B,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,KAAK,MAAM,CAAC,MAAM,WAAS,KAAK,MAAMC,OAAK,CAAC;AAEpD,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,SAAS,OAAO,CAAC,MAAM;AAE/B,UAAO;;EAER,QAAQ;AACP,UAAO;;EAER;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoCC,sBAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
@@ -17,31 +17,31 @@ const THROTTLED_RUNNERS = {};
17
17
  */
18
18
  const DEDUPLICATED_JOBS = {};
19
19
  function memoizeResponse(response) {
20
- const cache = {};
21
- function createWrapper(res) {
22
- return {
23
- ok: res.ok,
24
- status: res.status,
25
- headers: res.headers,
26
- url: res.url,
27
- async text() {
28
- if (!cache.text) cache.text = res.text();
29
- return cache.text;
30
- },
31
- async json() {
32
- if (!cache.json) cache.json = this.text().then((text) => ({ value: JSON.parse(text) }));
33
- return cache.json.then((cached) => cached.value);
34
- },
35
- async blob() {
36
- if (!cache.blob) cache.blob = res.blob();
37
- return cache.blob;
38
- },
39
- clone() {
40
- return createWrapper(res.clone());
41
- }
42
- };
43
- }
44
- return createWrapper(response);
20
+ let text;
21
+ let json;
22
+ let blob;
23
+ const wrapper = {
24
+ ok: response.ok,
25
+ status: response.status,
26
+ headers: response.headers,
27
+ url: response.url,
28
+ async text() {
29
+ if (!text) text = response.clone().text();
30
+ return text;
31
+ },
32
+ async json() {
33
+ if (!json) json = this.text().then((text$1) => JSON.parse(text$1));
34
+ return json;
35
+ },
36
+ async blob() {
37
+ if (!blob) blob = response.clone().blob();
38
+ return blob;
39
+ },
40
+ clone() {
41
+ return wrapper;
42
+ }
43
+ };
44
+ return wrapper;
45
45
  }
46
46
  /**
47
47
  * Makes an HTTP request with automatic retry for rate limits and request
@@ -1 +1 @@
1
- {"version":3,"file":"request.js","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","cache: {\n\t\ttext?: Promise<string>\n\t\tjson?: Promise<{ value: unknown }>\n\t\tblob?: Promise<Blob>\n\t}","job: Promise<ResponseLike>"],"sources":["../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// oxlint-disable-next-line no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// oxlint-disable-next-line no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\nfunction memoizeResponse(response: ResponseLike): ResponseLike {\n\tconst cache: {\n\t\ttext?: Promise<string>\n\t\tjson?: Promise<{ value: unknown }>\n\t\tblob?: Promise<Blob>\n\t} = {}\n\n\tfunction createWrapper(res: ResponseLike): ResponseLike {\n\t\treturn {\n\t\t\tok: res.ok,\n\t\t\tstatus: res.status,\n\t\t\theaders: res.headers,\n\t\t\turl: res.url,\n\t\t\tasync text() {\n\t\t\t\tif (!cache.text) {\n\t\t\t\t\tcache.text = res.text()\n\t\t\t\t}\n\t\t\t\treturn cache.text\n\t\t\t},\n\t\t\tasync json() {\n\t\t\t\tif (!cache.json) {\n\t\t\t\t\tcache.json = this.text().then((text) => ({ value: JSON.parse(text) }))\n\t\t\t\t}\n\t\t\t\treturn cache.json.then((cached) => cached.value)\n\t\t\t},\n\t\t\tasync blob() {\n\t\t\t\tif (!cache.blob) {\n\t\t\t\t\tcache.blob = res.blob()\n\t\t\t\t}\n\t\t\t\treturn cache.blob\n\t\t\t},\n\t\t\tclone() {\n\t\t\t\treturn createWrapper(res.clone())\n\t\t\t},\n\t\t}\n\t}\n\n\treturn createWrapper(response)\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,SAAS,gBAAgB,UAAsC;CAC9D,MAAMC,QAIF,EAAE;CAEN,SAAS,cAAc,KAAiC;AACvD,SAAO;GACN,IAAI,IAAI;GACR,QAAQ,IAAI;GACZ,SAAS,IAAI;GACb,KAAK,IAAI;GACT,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,IAAI,MAAM;AAExB,WAAO,MAAM;;GAEd,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,KAAK,MAAM,CAAC,MAAM,UAAU,EAAE,OAAO,KAAK,MAAM,KAAK,EAAE,EAAE;AAEvE,WAAO,MAAM,KAAK,MAAM,WAAW,OAAO,MAAM;;GAEjD,MAAM,OAAO;AACZ,QAAI,CAAC,MAAM,KACV,OAAM,OAAO,IAAI,MAAM;AAExB,WAAO,MAAM;;GAEd,QAAQ;AACP,WAAO,cAAc,IAAI,OAAO,CAAC;;GAElC;;AAGF,QAAO,cAAc,SAAS;;;;;;;;;;;;AAa/B,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoC,OAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
1
+ {"version":3,"file":"request.js","names":["THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>>","DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n>","text: Promise<string> | undefined","json: Promise<unknown> | undefined","blob: Promise<Blob> | undefined","wrapper: ResponseLike","text","job: Promise<ResponseLike>"],"sources":["../../src/lib/request.ts"],"sourcesContent":["import { type LimitFunction, pLimit } from \"./pLimit\"\n\n/**\n * The default number of milliseconds to wait before retrying a rate-limited\n * `fetch()` request (429 response code). The default value is only used if the\n * response does not include a `retry-after` header.\n */\nexport const DEFAULT_RETRY_AFTER = 1500 // ms\n\n/**\n * A record of URLs mapped to throttled task runners.\n */\nconst THROTTLED_RUNNERS: Partial<Record<string, LimitFunction>> = {}\n\n/**\n * A record of URLs mapped to active deduplicated jobs. Jobs are keyed by their\n * optional signal.\n */\nconst DEDUPLICATED_JOBS: Partial<\n\tRecord<string, Map<AbortSignalLike | undefined, Promise<ResponseLike>>>\n> = {}\n\n/**\n * A universal API to make network requests. A subset of the `fetch()` API.\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}\n */\nexport type FetchLike = (\n\tinput: string,\n\tinit?: RequestInitLike,\n) => Promise<ResponseLike>\n\n/**\n * An object that allows you to abort a `fetch()` request if needed via an\n * `AbortController` object\n *\n * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}\n */\n// `any` is used often here to ensure this type is universally valid among\n// different AbortSignal implementations. The types of each property are not\n// important to validate since it is blindly passed to a given `fetch()`\n// function.\n// oxlint-disable-next-line no-explicit-any\nexport type AbortSignalLike = any\n\n/**\n * A subset of RequestInit properties to configure a `fetch()` request.\n */\n// Only options relevant to the client are included. Extending from the full\n// RequestInit would cause issues, such as accepting Header objects.\n//\n// An interface is used to allow other libraries to augment the type with\n// environment-specific types.\nexport interface RequestInitLike extends Pick<RequestInit, \"cache\"> {\n\t/**\n\t * The HTTP method to use for the request.\n\t */\n\tmethod?: string\n\n\t/**\n\t * The request body to send with the request.\n\t */\n\t// We want to keep the body type as compatible as possible, so\n\t// we only declare the type we need and accept anything else.\n\t// oxlint-disable-next-line no-explicit-any\n\tbody?: any | FormData | string\n\n\t/**\n\t * An object literal to set the `fetch()` request's headers.\n\t */\n\theaders?: Record<string, string>\n\n\t/**\n\t * An AbortSignal to set the `fetch()` request's signal.\n\t *\n\t * See:\n\t * [https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\t */\n\t// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`\n\t// for backwards compatibility (the type is exported) and to signal to\n\t// other readers that this should be an AbortSignal-like object.\n\tsignal?: AbortSignalLike\n}\n\n/**\n * The minimum required properties from Response.\n */\nexport interface ResponseLike {\n\tok: boolean\n\tstatus: number\n\theaders: HeadersLike\n\turl: string\n\t// oxlint-disable-next-line no-explicit-any\n\tjson(): Promise<any>\n\ttext(): Promise<string>\n\tblob(): Promise<Blob>\n\tclone(): ResponseLike\n}\n\n/**\n * The minimum required properties from Headers.\n */\nexport interface HeadersLike {\n\tget(name: string): string | null\n}\n\nfunction memoizeResponse(response: ResponseLike): ResponseLike {\n\tlet text: Promise<string> | undefined\n\tlet json: Promise<unknown> | undefined\n\tlet blob: Promise<Blob> | undefined\n\n\tconst wrapper: ResponseLike = {\n\t\tok: response.ok,\n\t\tstatus: response.status,\n\t\theaders: response.headers,\n\t\turl: response.url,\n\t\tasync text() {\n\t\t\tif (!text) {\n\t\t\t\ttext = response.clone().text()\n\t\t\t}\n\t\t\treturn text\n\t\t},\n\t\tasync json() {\n\t\t\tif (!json) {\n\t\t\t\tjson = this.text().then((text) => JSON.parse(text))\n\t\t\t}\n\t\t\treturn json\n\t\t},\n\t\tasync blob() {\n\t\t\tif (!blob) {\n\t\t\t\tblob = response.clone().blob()\n\t\t\t}\n\t\t\treturn blob\n\t\t},\n\t\tclone() {\n\t\t\treturn wrapper\n\t\t},\n\t}\n\n\treturn wrapper\n}\n\n/**\n * Makes an HTTP request with automatic retry for rate limits and request\n * deduplication.\n *\n * @param url - The URL to request.\n * @param init - Fetch options.\n * @param fetchFn - The fetch function to use.\n *\n * @returns The response from the fetch request.\n */\nexport async function request(\n\turl: URL,\n\tinit: RequestInitLike | undefined,\n\tfetchFn: FetchLike,\n): Promise<ResponseLike> {\n\tconst stringURL = url.toString()\n\n\tlet job: Promise<ResponseLike>\n\n\t// Throttle requests with a body.\n\tif (init?.body) {\n\t\t// Rate limiting is done per hostname.\n\t\tconst runner = (THROTTLED_RUNNERS[url.hostname] ||= pLimit({\n\t\t\tinterval: DEFAULT_RETRY_AFTER,\n\t\t}))\n\n\t\tjob = runner(() => fetchFn(stringURL, init))\n\t} else {\n\t\t// Deduplicate all other requests.\n\t\tconst existingJob = DEDUPLICATED_JOBS[stringURL]?.get(init?.signal)\n\t\tif (existingJob) {\n\t\t\tjob = existingJob\n\t\t} else {\n\t\t\tjob = fetchFn(stringURL, init)\n\t\t\t\t.then(memoizeResponse)\n\t\t\t\t.finally(() => {\n\t\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\tconst map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())\n\t\t\tmap.set(init?.signal, job)\n\t\t}\n\t}\n\n\tconst response = await job\n\n\t// Retry rate limited requests.\n\tif (response.status === 429) {\n\t\tconst retryAfter = Number(response.headers.get(\"retry-after\"))\n\t\tconst resolvedRetryAfter = Number.isNaN(retryAfter)\n\t\t\t? DEFAULT_RETRY_AFTER\n\t\t\t: retryAfter * 1000\n\n\t\tawait new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter))\n\n\t\treturn request(url, init, fetchFn)\n\t}\n\n\treturn response\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;AAsFN,SAAS,gBAAgB,UAAsC;CAC9D,IAAIC;CACJ,IAAIC;CACJ,IAAIC;CAEJ,MAAMC,UAAwB;EAC7B,IAAI,SAAS;EACb,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB,KAAK,SAAS;EACd,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,SAAS,OAAO,CAAC,MAAM;AAE/B,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,KAAK,MAAM,CAAC,MAAM,WAAS,KAAK,MAAMC,OAAK,CAAC;AAEpD,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,SAAS,OAAO,CAAC,MAAM;AAE/B,UAAO;;EAER,QAAQ;AACP,UAAO;;EAER;AAED,QAAO;;;;;;;;;;;;AAaR,eAAsB,QACrB,KACA,MACA,SACwB;CACxB,MAAM,YAAY,IAAI,UAAU;CAEhC,IAAIC;AAGJ,iDAAI,KAAM,MAAM;;AAMf,SAJgB,kCAAkB,IAAI,cAAtB,mCAAoC,OAAO,EAC1D,UAAU,qBACV,CAAC,SAEiB,QAAQ,WAAW,KAAK,CAAC;QACtC;;EAEN,MAAM,uCAAc,kBAAkB,0FAAY,gDAAI,KAAM,OAAO;AACnE,MAAI,YACH,OAAM;OACA;AACN,SAAM,QAAQ,WAAW,KAAK,CAC5B,KAAK,gBAAgB,CACrB,cAAc;;AACd,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEH,IADa,kBAAkB,eAAlB,kBAAkB,6BAAe,IAAI,KAAK,GACnD,gDAAI,KAAM,QAAQ,IAAI;;;CAI5B,MAAM,WAAW,MAAM;AAGvB,KAAI,SAAS,WAAW,KAAK;EAC5B,MAAM,aAAa,OAAO,SAAS,QAAQ,IAAI,cAAc,CAAC;EAC9D,MAAM,qBAAqB,OAAO,MAAM,WAAW,GAChD,sBACA,aAAa;AAEhB,QAAM,IAAI,SAAS,YAAY,WAAW,SAAS,mBAAmB,CAAC;AAEvE,SAAO,QAAQ,KAAK,MAAM,QAAQ;;AAGnC,QAAO"}
package/dist/package.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  //#region package.json
3
3
  var name = "@prismicio/client";
4
- var version = "7.21.3-pr.437.4958ca1";
4
+ var version = "7.21.3-pr.437.8ac4c04";
5
5
 
6
6
  //#endregion
7
7
  Object.defineProperty(exports, 'name', {
@@ -1 +1 @@
1
- {"version":3,"file":"package.cjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.3-pr.437.4958ca1\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";;WACS;cACG"}
1
+ {"version":3,"file":"package.cjs","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.3-pr.437.8ac4c04\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";;WACS;cACG"}
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@prismicio/client";
3
- var version = "7.21.3-pr.437.4958ca1";
3
+ var version = "7.21.3-pr.437.8ac4c04";
4
4
 
5
5
  //#endregion
6
6
  export { name, version };
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.3-pr.437.4958ca1\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";WACS;cACG"}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":["{\n\t\"name\": \"@prismicio/client\",\n\t\"version\": \"7.21.3-pr.437.8ac4c04\",\n\t\"description\": \"The official JavaScript + TypeScript client library for Prismic\",\n\t\"keywords\": [\n\t\t\"typescript\",\n\t\t\"client\",\n\t\t\"helpers\",\n\t\t\"types\",\n\t\t\"utils\",\n\t\t\"toolbox\",\n\t\t\"cms\",\n\t\t\"prismic\",\n\t\t\"prismic.io\"\n\t],\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"ssh://git@github.com/prismicio/prismic-client.git\"\n\t},\n\t\"license\": \"Apache-2.0\",\n\t\"author\": \"Prismic <contact@prismic.io> (https://prismic.io)\",\n\t\"sideEffects\": false,\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": \"./dist/index.js\",\n\t\t\t\"require\": \"./dist/index.cjs\"\n\t\t},\n\t\t\"./richtext\": {\n\t\t\t\"import\": \"./dist/richtext.js\",\n\t\t\t\"require\": \"./dist/richtext.cjs\"\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"main\": \"./dist/index.cjs\",\n\t\"module\": \"./dist/index.js\",\n\t\"react-native\": \"./dist/index.js\",\n\t\"types\": \"./dist/index.d.cts\",\n\t\"typesVersions\": {\n\t\t\"*\": {\n\t\t\t\"*\": [\n\t\t\t\t\"dist/index.d.ts\"\n\t\t\t],\n\t\t\t\"richtext\": [\n\t\t\t\t\"dist/richtext.d.ts\"\n\t\t\t]\n\t\t}\n\t},\n\t\"files\": [\n\t\t\"dist\",\n\t\t\"src\"\n\t],\n\t\"scripts\": {\n\t\t\"build\": \"tsdown\",\n\t\t\"dev\": \"tsdown --watch\",\n\t\t\"format\": \"prettier --write .\",\n\t\t\"prepare\": \"npm run build\",\n\t\t\"lint\": \"oxlint --deny-warnings\",\n\t\t\"types\": \"tsc --noEmit\",\n\t\t\"unit\": \"vitest run --coverage\",\n\t\t\"unit:watch\": \"vitest watch\",\n\t\t\"test\": \"npm run lint && npm run types && npm run unit && npm run build\"\n\t},\n\t\"dependencies\": {\n\t\t\"imgix-url-builder\": \"^0.0.6\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@prismicio/e2e-tests-utils\": \"^1.14.0\",\n\t\t\"@prismicio/types-internal\": \"^3.16.1\",\n\t\t\"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n\t\t\"@types/node\": \"^24.10.0\",\n\t\t\"@vitest/coverage-v8\": \"^4.0.6\",\n\t\t\"oxlint\": \"^1.26.0\",\n\t\t\"prettier\": \"^3.6.2\",\n\t\t\"prettier-plugin-jsdoc\": \"1.3.3\",\n\t\t\"tsdown\": \"^0.16.1\",\n\t\t\"typescript\": \"^5.9.3\",\n\t\t\"vitest\": \"^4.0.6\"\n\t},\n\t\"engines\": {\n\t\t\"node\": \">=14.15.0\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t}\n}\n"],"mappings":";WACS;cACG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.21.3-pr.437.4958ca1",
3
+ "version": "7.21.3-pr.437.8ac4c04",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "typescript",
@@ -105,43 +105,39 @@ export interface HeadersLike {
105
105
  }
106
106
 
107
107
  function memoizeResponse(response: ResponseLike): ResponseLike {
108
- const cache: {
109
- text?: Promise<string>
110
- json?: Promise<{ value: unknown }>
111
- blob?: Promise<Blob>
112
- } = {}
113
-
114
- function createWrapper(res: ResponseLike): ResponseLike {
115
- return {
116
- ok: res.ok,
117
- status: res.status,
118
- headers: res.headers,
119
- url: res.url,
120
- async text() {
121
- if (!cache.text) {
122
- cache.text = res.text()
123
- }
124
- return cache.text
125
- },
126
- async json() {
127
- if (!cache.json) {
128
- cache.json = this.text().then((text) => ({ value: JSON.parse(text) }))
129
- }
130
- return cache.json.then((cached) => cached.value)
131
- },
132
- async blob() {
133
- if (!cache.blob) {
134
- cache.blob = res.blob()
135
- }
136
- return cache.blob
137
- },
138
- clone() {
139
- return createWrapper(res.clone())
140
- },
141
- }
108
+ let text: Promise<string> | undefined
109
+ let json: Promise<unknown> | undefined
110
+ let blob: Promise<Blob> | undefined
111
+
112
+ const wrapper: ResponseLike = {
113
+ ok: response.ok,
114
+ status: response.status,
115
+ headers: response.headers,
116
+ url: response.url,
117
+ async text() {
118
+ if (!text) {
119
+ text = response.clone().text()
120
+ }
121
+ return text
122
+ },
123
+ async json() {
124
+ if (!json) {
125
+ json = this.text().then((text) => JSON.parse(text))
126
+ }
127
+ return json
128
+ },
129
+ async blob() {
130
+ if (!blob) {
131
+ blob = response.clone().blob()
132
+ }
133
+ return blob
134
+ },
135
+ clone() {
136
+ return wrapper
137
+ },
142
138
  }
143
139
 
144
- return createWrapper(response)
140
+ return wrapper
145
141
  }
146
142
 
147
143
  /**