@prismicio/client 7.21.5-canary.826b079 → 7.21.5-pr.437.31f586f

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.
@@ -16,6 +16,32 @@ const THROTTLED_RUNNERS = {};
16
16
  * optional signal.
17
17
  */
18
18
  const DEDUPLICATED_JOBS = {};
19
+ async function memoizeResponse(response) {
20
+ const blobContent = await response.blob();
21
+ let text;
22
+ let json;
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 = await blobContent.text();
30
+ return text;
31
+ },
32
+ async json() {
33
+ if (!json) json = JSON.parse(await this.text());
34
+ return json;
35
+ },
36
+ async blob() {
37
+ return blobContent;
38
+ },
39
+ clone() {
40
+ return wrapper;
41
+ }
42
+ };
43
+ return wrapper;
44
+ }
19
45
  /**
20
46
  * Makes an HTTP request with automatic retry for rate limits and request
21
47
  * deduplication.
@@ -37,7 +63,7 @@ async function request(url, init, fetchFn) {
37
63
  const existingJob = (_DEDUPLICATED_JOBS$st = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st === void 0 ? void 0 : _DEDUPLICATED_JOBS$st.get(init === null || init === void 0 ? void 0 : init.signal);
38
64
  if (existingJob) job = existingJob;
39
65
  else {
40
- job = fetchFn(stringURL, init).finally(() => {
66
+ job = fetchFn(stringURL, init).then(memoizeResponse).finally(() => {
41
67
  var _DEDUPLICATED_JOBS$st2, _DEDUPLICATED_JOBS$st3;
42
68
  (_DEDUPLICATED_JOBS$st2 = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st2 === void 0 || _DEDUPLICATED_JOBS$st2.delete(init === null || init === void 0 ? void 0 : init.signal);
43
69
  if (((_DEDUPLICATED_JOBS$st3 = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st3 === void 0 ? void 0 : _DEDUPLICATED_JOBS$st3.size) === 0) delete DEDUPLICATED_JOBS[stringURL];
@@ -52,7 +78,7 @@ async function request(url, init, fetchFn) {
52
78
  await new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter));
53
79
  return request(url, init, fetchFn);
54
80
  }
55
- return response.clone();
81
+ return response;
56
82
  }
57
83
 
58
84
  //#endregion
@@ -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>","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\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).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\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.clone()\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;;;;;;;;;;;AAgGN,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,CAAC,cAAc;;AAC5C,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEF,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,SAAS,OAAO"}
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: string | undefined","json: unknown | undefined","wrapper: ResponseLike","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\nasync function memoizeResponse(response: ResponseLike): Promise<ResponseLike> {\n\t// Buffer as blob immediately - works for both binary (images) and text (JSON).\n\t// This avoids response.clone() backpressure issues in Node.js 22+.\n\t// See: https://github.com/node-fetch/node-fetch/issues/139\n\tconst blobContent = await response.blob()\n\n\tlet text: string | undefined\n\tlet json: unknown | 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 = await blobContent.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 = JSON.parse(await this.text())\n\t\t\t}\n\t\t\treturn json\n\t\t},\n\t\tasync blob() {\n\t\t\treturn blobContent\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,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,cAAc,MAAM,SAAS,MAAM;CAEzC,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,MAAM,YAAY,MAAM;AAEhC,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,KAAK,MAAM,MAAM,KAAK,MAAM,CAAC;AAErC,UAAO;;EAER,MAAM,OAAO;AACZ,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"}
@@ -16,6 +16,32 @@ const THROTTLED_RUNNERS = {};
16
16
  * optional signal.
17
17
  */
18
18
  const DEDUPLICATED_JOBS = {};
19
+ async function memoizeResponse(response) {
20
+ const blobContent = await response.blob();
21
+ let text;
22
+ let json;
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 = await blobContent.text();
30
+ return text;
31
+ },
32
+ async json() {
33
+ if (!json) json = JSON.parse(await this.text());
34
+ return json;
35
+ },
36
+ async blob() {
37
+ return blobContent;
38
+ },
39
+ clone() {
40
+ return wrapper;
41
+ }
42
+ };
43
+ return wrapper;
44
+ }
19
45
  /**
20
46
  * Makes an HTTP request with automatic retry for rate limits and request
21
47
  * deduplication.
@@ -37,7 +63,7 @@ async function request(url, init, fetchFn) {
37
63
  const existingJob = (_DEDUPLICATED_JOBS$st = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st === void 0 ? void 0 : _DEDUPLICATED_JOBS$st.get(init === null || init === void 0 ? void 0 : init.signal);
38
64
  if (existingJob) job = existingJob;
39
65
  else {
40
- job = fetchFn(stringURL, init).finally(() => {
66
+ job = fetchFn(stringURL, init).then(memoizeResponse).finally(() => {
41
67
  var _DEDUPLICATED_JOBS$st2, _DEDUPLICATED_JOBS$st3;
42
68
  (_DEDUPLICATED_JOBS$st2 = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st2 === void 0 || _DEDUPLICATED_JOBS$st2.delete(init === null || init === void 0 ? void 0 : init.signal);
43
69
  if (((_DEDUPLICATED_JOBS$st3 = DEDUPLICATED_JOBS[stringURL]) === null || _DEDUPLICATED_JOBS$st3 === void 0 ? void 0 : _DEDUPLICATED_JOBS$st3.size) === 0) delete DEDUPLICATED_JOBS[stringURL];
@@ -52,7 +78,7 @@ async function request(url, init, fetchFn) {
52
78
  await new Promise((resolve) => setTimeout(resolve, resolvedRetryAfter));
53
79
  return request(url, init, fetchFn);
54
80
  }
55
- return response.clone();
81
+ return response;
56
82
  }
57
83
 
58
84
  //#endregion
@@ -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>","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\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).finally(() => {\n\t\t\t\tDEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)\n\t\t\t\tif (DEDUPLICATED_JOBS[stringURL]?.size === 0) {\n\t\t\t\t\tdelete DEDUPLICATED_JOBS[stringURL]\n\t\t\t\t}\n\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.clone()\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,sBAAsB;;;;AAKnC,MAAMA,oBAA4D,EAAE;;;;;AAMpE,MAAMC,oBAEF,EAAE;;;;;;;;;;;AAgGN,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,CAAC,cAAc;;AAC5C,gDAAkB,oFAAY,mDAAO,KAAM,OAAO;AAClD,mCAAI,kBAAkB,4FAAY,UAAS,EAC1C,QAAO,kBAAkB;KAEzB;AAEF,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,SAAS,OAAO"}
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: string | undefined","json: unknown | undefined","wrapper: ResponseLike","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\nasync function memoizeResponse(response: ResponseLike): Promise<ResponseLike> {\n\t// Buffer as blob immediately - works for both binary (images) and text (JSON).\n\t// This avoids response.clone() backpressure issues in Node.js 22+.\n\t// See: https://github.com/node-fetch/node-fetch/issues/139\n\tconst blobContent = await response.blob()\n\n\tlet text: string | undefined\n\tlet json: unknown | 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 = await blobContent.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 = JSON.parse(await this.text())\n\t\t\t}\n\t\t\treturn json\n\t\t},\n\t\tasync blob() {\n\t\t\treturn blobContent\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,eAAe,gBAAgB,UAA+C;CAI7E,MAAM,cAAc,MAAM,SAAS,MAAM;CAEzC,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,MAAM,YAAY,MAAM;AAEhC,UAAO;;EAER,MAAM,OAAO;AACZ,OAAI,CAAC,KACJ,QAAO,KAAK,MAAM,MAAM,KAAK,MAAM,CAAC;AAErC,UAAO;;EAER,MAAM,OAAO;AACZ,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.5-canary.826b079";
4
+ var version = "7.21.5-pr.437.31f586f";
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.5-canary.826b079\",\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.5-pr.437.31f586f\",\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.5-canary.826b079";
3
+ var version = "7.21.5-pr.437.31f586f";
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.5-canary.826b079\",\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.5-pr.437.31f586f\",\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.5-canary.826b079",
3
+ "version": "7.21.5-pr.437.31f586f",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "typescript",
@@ -104,6 +104,43 @@ export interface HeadersLike {
104
104
  get(name: string): string | null
105
105
  }
106
106
 
107
+ async function memoizeResponse(response: ResponseLike): Promise<ResponseLike> {
108
+ // Buffer as blob immediately - works for both binary (images) and text (JSON).
109
+ // This avoids response.clone() backpressure issues in Node.js 22+.
110
+ // See: https://github.com/node-fetch/node-fetch/issues/139
111
+ const blobContent = await response.blob()
112
+
113
+ let text: string | undefined
114
+ let json: unknown | undefined
115
+
116
+ const wrapper: ResponseLike = {
117
+ ok: response.ok,
118
+ status: response.status,
119
+ headers: response.headers,
120
+ url: response.url,
121
+ async text() {
122
+ if (!text) {
123
+ text = await blobContent.text()
124
+ }
125
+ return text
126
+ },
127
+ async json() {
128
+ if (!json) {
129
+ json = JSON.parse(await this.text())
130
+ }
131
+ return json
132
+ },
133
+ async blob() {
134
+ return blobContent
135
+ },
136
+ clone() {
137
+ return wrapper
138
+ },
139
+ }
140
+
141
+ return wrapper
142
+ }
143
+
107
144
  /**
108
145
  * Makes an HTTP request with automatic retry for rate limits and request
109
146
  * deduplication.
@@ -137,12 +174,14 @@ export async function request(
137
174
  if (existingJob) {
138
175
  job = existingJob
139
176
  } else {
140
- job = fetchFn(stringURL, init).finally(() => {
141
- DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)
142
- if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
143
- delete DEDUPLICATED_JOBS[stringURL]
144
- }
145
- })
177
+ job = fetchFn(stringURL, init)
178
+ .then(memoizeResponse)
179
+ .finally(() => {
180
+ DEDUPLICATED_JOBS[stringURL]?.delete(init?.signal)
181
+ if (DEDUPLICATED_JOBS[stringURL]?.size === 0) {
182
+ delete DEDUPLICATED_JOBS[stringURL]
183
+ }
184
+ })
146
185
  const map = (DEDUPLICATED_JOBS[stringURL] ||= new Map())
147
186
  map.set(init?.signal, job)
148
187
  }
@@ -162,5 +201,5 @@ export async function request(
162
201
  return request(url, init, fetchFn)
163
202
  }
164
203
 
165
- return response.clone()
204
+ return response
166
205
  }