@prismicio/client 7.7.3 → 7.7.4

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.
Files changed (304) hide show
  1. package/README.md +3 -3
  2. package/dist/buildQueryURL.cjs.map +1 -1
  3. package/dist/buildQueryURL.d.ts +1 -1
  4. package/dist/buildQueryURL.js.map +1 -1
  5. package/dist/cookie.cjs.map +1 -1
  6. package/dist/cookie.js.map +1 -1
  7. package/dist/createClient.cjs +31 -31
  8. package/dist/createClient.cjs.map +1 -1
  9. package/dist/createClient.d.ts +35 -35
  10. package/dist/createClient.js +31 -31
  11. package/dist/createClient.js.map +1 -1
  12. package/dist/errors/ForbiddenError.cjs.map +1 -1
  13. package/dist/errors/ForbiddenError.js.map +1 -1
  14. package/dist/errors/NotFoundError.cjs.map +1 -1
  15. package/dist/errors/NotFoundError.js.map +1 -1
  16. package/dist/errors/ParsingError.cjs.map +1 -1
  17. package/dist/errors/ParsingError.js.map +1 -1
  18. package/dist/errors/PreviewTokenExpired.cjs.map +1 -1
  19. package/dist/errors/PreviewTokenExpired.js.map +1 -1
  20. package/dist/errors/PrismicError.cjs.map +1 -1
  21. package/dist/errors/PrismicError.js.map +1 -1
  22. package/dist/errors/PrismicRichTextSerializerError.cjs.map +1 -1
  23. package/dist/errors/PrismicRichTextSerializerError.js.map +1 -1
  24. package/dist/errors/RefExpiredError.cjs.map +1 -1
  25. package/dist/errors/RefExpiredError.js.map +1 -1
  26. package/dist/errors/RefNotFoundError.cjs.map +1 -1
  27. package/dist/errors/RefNotFoundError.js.map +1 -1
  28. package/dist/errors/RepositoryNotFoundError.cjs.map +1 -1
  29. package/dist/errors/RepositoryNotFoundError.js.map +1 -1
  30. package/dist/filter.cjs.map +1 -1
  31. package/dist/filter.js.map +1 -1
  32. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  33. package/dist/getGraphQLEndpoint.js.map +1 -1
  34. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  35. package/dist/getRepositoryEndpoint.js.map +1 -1
  36. package/dist/getRepositoryName.cjs.map +1 -1
  37. package/dist/getRepositoryName.js.map +1 -1
  38. package/dist/getToolbarSrc.cjs.map +1 -1
  39. package/dist/getToolbarSrc.js.map +1 -1
  40. package/dist/helpers/asDate.cjs.map +1 -1
  41. package/dist/helpers/asDate.js.map +1 -1
  42. package/dist/helpers/asHTML.cjs.map +1 -1
  43. package/dist/helpers/asHTML.d.ts +2 -2
  44. package/dist/helpers/asHTML.js.map +1 -1
  45. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  46. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -2
  47. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  48. package/dist/helpers/asImageSrc.cjs.map +1 -1
  49. package/dist/helpers/asImageSrc.d.ts +2 -2
  50. package/dist/helpers/asImageSrc.js.map +1 -1
  51. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  52. package/dist/helpers/asImageWidthSrcSet.d.ts +2 -2
  53. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  54. package/dist/helpers/asLink.cjs.map +1 -1
  55. package/dist/helpers/asLink.d.ts +2 -4
  56. package/dist/helpers/asLink.js.map +1 -1
  57. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  58. package/dist/helpers/asLinkAttrs.d.ts +2 -2
  59. package/dist/helpers/asLinkAttrs.js.map +1 -1
  60. package/dist/helpers/asText.cjs.map +1 -1
  61. package/dist/helpers/asText.d.ts +1 -1
  62. package/dist/helpers/asText.js.map +1 -1
  63. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  64. package/dist/helpers/documentToLinkField.js.map +1 -1
  65. package/dist/helpers/isFilled.cjs.map +1 -1
  66. package/dist/helpers/isFilled.js.map +1 -1
  67. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  68. package/dist/helpers/mapSliceZone.d.ts +1 -1
  69. package/dist/helpers/mapSliceZone.js.map +1 -1
  70. package/dist/helpers/unstable_htmlAsRichText.cjs.map +1 -1
  71. package/dist/helpers/unstable_htmlAsRichText.d.ts +4 -4
  72. package/dist/helpers/unstable_htmlAsRichText.js.map +1 -1
  73. package/dist/helpers/unstable_markdownAsRichText.cjs.map +1 -1
  74. package/dist/helpers/unstable_markdownAsRichText.d.ts +2 -2
  75. package/dist/helpers/unstable_markdownAsRichText.js.map +1 -1
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  79. package/dist/isRepositoryEndpoint.js.map +1 -1
  80. package/dist/isRepositoryName.cjs.map +1 -1
  81. package/dist/isRepositoryName.js.map +1 -1
  82. package/dist/lib/RichTextFieldBuilder.cjs.map +1 -1
  83. package/dist/lib/RichTextFieldBuilder.d.ts +1 -1
  84. package/dist/lib/RichTextFieldBuilder.js.map +1 -1
  85. package/dist/lib/appendFilters.cjs.map +1 -1
  86. package/dist/lib/appendFilters.js.map +1 -1
  87. package/dist/lib/castArray.cjs.map +1 -1
  88. package/dist/lib/castArray.js.map +1 -1
  89. package/dist/lib/castThunk.cjs.map +1 -1
  90. package/dist/lib/castThunk.js.map +1 -1
  91. package/dist/lib/devMsg.cjs.map +1 -1
  92. package/dist/lib/devMsg.d.ts +1 -1
  93. package/dist/lib/devMsg.js.map +1 -1
  94. package/dist/lib/escapeHTML.cjs.map +1 -1
  95. package/dist/lib/escapeHTML.js.map +1 -1
  96. package/dist/lib/everyTagFilter.cjs.map +1 -1
  97. package/dist/lib/everyTagFilter.js.map +1 -1
  98. package/dist/lib/filterRichTextField.cjs.map +1 -1
  99. package/dist/lib/filterRichTextField.d.ts +3 -3
  100. package/dist/lib/filterRichTextField.js.map +1 -1
  101. package/dist/lib/findMasterRef.cjs.map +1 -1
  102. package/dist/lib/findMasterRef.d.ts +1 -1
  103. package/dist/lib/findMasterRef.js.map +1 -1
  104. package/dist/lib/findRef.cjs.map +1 -1
  105. package/dist/lib/findRef.d.ts +1 -1
  106. package/dist/lib/findRef.js.map +1 -1
  107. package/dist/lib/findRefByID.cjs.map +1 -1
  108. package/dist/lib/findRefByID.d.ts +1 -1
  109. package/dist/lib/findRefByID.js.map +1 -1
  110. package/dist/lib/findRefByLabel.cjs.map +1 -1
  111. package/dist/lib/findRefByLabel.d.ts +1 -1
  112. package/dist/lib/findRefByLabel.js.map +1 -1
  113. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  114. package/dist/lib/getPreviewCookie.js.map +1 -1
  115. package/dist/lib/hastSerializerHelpers.cjs.map +1 -1
  116. package/dist/lib/hastSerializerHelpers.d.ts +3 -3
  117. package/dist/lib/hastSerializerHelpers.js.map +1 -1
  118. package/dist/lib/hastToRichText.cjs +1 -2
  119. package/dist/lib/hastToRichText.cjs.map +1 -1
  120. package/dist/lib/hastToRichText.d.ts +4 -4
  121. package/dist/lib/hastToRichText.js +1 -2
  122. package/dist/lib/hastToRichText.js.map +1 -1
  123. package/dist/lib/isInternalURL.cjs.map +1 -1
  124. package/dist/lib/isInternalURL.js.map +1 -1
  125. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  126. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  127. package/dist/lib/rehypeRichText.cjs.map +1 -1
  128. package/dist/lib/rehypeRichText.d.ts +5 -5
  129. package/dist/lib/rehypeRichText.js.map +1 -1
  130. package/dist/lib/serializerHelpers.cjs.map +1 -1
  131. package/dist/lib/serializerHelpers.d.ts +2 -2
  132. package/dist/lib/serializerHelpers.js.map +1 -1
  133. package/dist/lib/someTagsFilter.cjs.map +1 -1
  134. package/dist/lib/someTagsFilter.js.map +1 -1
  135. package/dist/lib/typeFilter.cjs.map +1 -1
  136. package/dist/lib/typeFilter.js.map +1 -1
  137. package/dist/package.json.cjs +1 -1
  138. package/dist/package.json.js +1 -1
  139. package/dist/richtext/asText.cjs.map +1 -1
  140. package/dist/richtext/asText.d.ts +1 -1
  141. package/dist/richtext/asText.js.map +1 -1
  142. package/dist/richtext/asTree.cjs.map +1 -1
  143. package/dist/richtext/asTree.d.ts +2 -2
  144. package/dist/richtext/asTree.js.map +1 -1
  145. package/dist/richtext/composeSerializers.cjs.map +1 -1
  146. package/dist/richtext/composeSerializers.d.ts +1 -1
  147. package/dist/richtext/composeSerializers.js.map +1 -1
  148. package/dist/richtext/serialize.cjs.map +1 -1
  149. package/dist/richtext/serialize.d.ts +1 -1
  150. package/dist/richtext/serialize.js.map +1 -1
  151. package/dist/richtext/types.cjs.map +1 -1
  152. package/dist/richtext/types.d.ts +1 -1
  153. package/dist/richtext/types.js.map +1 -1
  154. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  155. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  156. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  157. package/dist/types/api/query.d.ts +1 -1
  158. package/dist/types/api/release.d.ts +1 -1
  159. package/dist/types/api/repository.d.ts +1 -1
  160. package/dist/types/model/customType.d.ts +1 -1
  161. package/dist/types/model/link.cjs.map +1 -1
  162. package/dist/types/model/link.js.map +1 -1
  163. package/dist/types/model/slice.cjs.map +1 -1
  164. package/dist/types/model/slice.js.map +1 -1
  165. package/dist/types/model/sliceZone.cjs.map +1 -1
  166. package/dist/types/model/sliceZone.js.map +1 -1
  167. package/dist/types/model/title.d.ts +1 -1
  168. package/dist/types/model/types.cjs.map +1 -1
  169. package/dist/types/model/types.js.map +1 -1
  170. package/dist/types/value/document.d.ts +4 -4
  171. package/dist/types/value/embed.cjs.map +1 -1
  172. package/dist/types/value/embed.js.map +1 -1
  173. package/dist/types/value/link.cjs.map +1 -1
  174. package/dist/types/value/link.js.map +1 -1
  175. package/dist/types/value/richText.cjs.map +1 -1
  176. package/dist/types/value/richText.js.map +1 -1
  177. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  178. package/dist/types/webhook/testTrigger.d.ts +1 -1
  179. package/dist/types/webhook/types.cjs.map +1 -1
  180. package/dist/types/webhook/types.d.ts +2 -2
  181. package/dist/types/webhook/types.js.map +1 -1
  182. package/package.json +1 -1
  183. package/src/buildQueryURL.ts +51 -51
  184. package/src/cookie.ts +1 -1
  185. package/src/createClient.ts +293 -293
  186. package/src/errors/ForbiddenError.ts +6 -6
  187. package/src/errors/NotFoundError.ts +1 -1
  188. package/src/errors/ParsingError.ts +8 -8
  189. package/src/errors/PreviewTokenExpired.ts +4 -4
  190. package/src/errors/PrismicError.ts +5 -5
  191. package/src/errors/PrismicRichTextSerializerError.ts +1 -1
  192. package/src/errors/RefExpiredError.ts +4 -4
  193. package/src/errors/RefNotFoundError.ts +4 -4
  194. package/src/errors/RepositoryNotFoundError.ts +1 -1
  195. package/src/filter.ts +22 -22
  196. package/src/getGraphQLEndpoint.ts +5 -5
  197. package/src/getRepositoryEndpoint.ts +5 -5
  198. package/src/getRepositoryName.ts +4 -4
  199. package/src/getToolbarSrc.ts +5 -5
  200. package/src/helpers/asDate.ts +7 -7
  201. package/src/helpers/asHTML.ts +54 -56
  202. package/src/helpers/asImagePixelDensitySrcSet.ts +14 -17
  203. package/src/helpers/asImageSrc.ts +9 -8
  204. package/src/helpers/asImageWidthSrcSet.ts +19 -22
  205. package/src/helpers/asLink.ts +26 -27
  206. package/src/helpers/asLinkAttrs.ts +30 -29
  207. package/src/helpers/asText.ts +15 -15
  208. package/src/helpers/documentToLinkField.ts +6 -6
  209. package/src/helpers/isFilled.ts +53 -53
  210. package/src/helpers/mapSliceZone.ts +34 -34
  211. package/src/helpers/unstable_htmlAsRichText.ts +23 -22
  212. package/src/helpers/unstable_markdownAsRichText.ts +14 -13
  213. package/src/index.ts +119 -119
  214. package/src/isRepositoryEndpoint.ts +4 -4
  215. package/src/isRepositoryName.ts +2 -2
  216. package/src/lib/RichTextFieldBuilder.ts +36 -41
  217. package/src/lib/appendFilters.ts +4 -4
  218. package/src/lib/castArray.ts +2 -2
  219. package/src/lib/castThunk.ts +2 -2
  220. package/src/lib/devMsg.ts +4 -4
  221. package/src/lib/escapeHTML.ts +24 -24
  222. package/src/lib/everyTagFilter.ts +4 -4
  223. package/src/lib/filterRichTextField.ts +31 -31
  224. package/src/lib/findMasterRef.ts +4 -4
  225. package/src/lib/findRef.ts +6 -6
  226. package/src/lib/findRefByID.ts +4 -4
  227. package/src/lib/findRefByLabel.ts +4 -4
  228. package/src/lib/getPreviewCookie.ts +11 -11
  229. package/src/lib/hastSerializerHelpers.ts +41 -37
  230. package/src/lib/hastToRichText.ts +74 -73
  231. package/src/lib/isInternalURL.ts +4 -4
  232. package/src/lib/minifyGraphQLQuery.ts +2 -2
  233. package/src/lib/rehypeRichText.ts +42 -41
  234. package/src/lib/serializerHelpers.ts +53 -54
  235. package/src/lib/someTagsFilter.ts +4 -4
  236. package/src/lib/typeFilter.ts +3 -3
  237. package/src/richtext/asText.ts +5 -5
  238. package/src/richtext/asTree.ts +53 -53
  239. package/src/richtext/composeSerializers.ts +6 -6
  240. package/src/richtext/index.ts +7 -7
  241. package/src/richtext/serialize.ts +11 -11
  242. package/src/richtext/types.ts +38 -38
  243. package/src/richtext/wrapMapSerializer.ts +6 -9
  244. package/src/types/api/query.ts +9 -9
  245. package/src/types/api/ref.ts +5 -5
  246. package/src/types/api/release.ts +2 -2
  247. package/src/types/api/repository.ts +24 -24
  248. package/src/types/api/tags.ts +1 -1
  249. package/src/types/model/boolean.ts +7 -7
  250. package/src/types/model/color.ts +5 -5
  251. package/src/types/model/contentRelationship.ts +9 -9
  252. package/src/types/model/customType.ts +9 -9
  253. package/src/types/model/date.ts +6 -6
  254. package/src/types/model/embed.ts +5 -5
  255. package/src/types/model/geoPoint.ts +4 -4
  256. package/src/types/model/group.ts +6 -6
  257. package/src/types/model/image.ts +9 -9
  258. package/src/types/model/integration.ts +6 -6
  259. package/src/types/model/keyText.ts +5 -5
  260. package/src/types/model/link.ts +8 -8
  261. package/src/types/model/linkToMedia.ts +7 -7
  262. package/src/types/model/number.ts +7 -7
  263. package/src/types/model/range.ts +8 -8
  264. package/src/types/model/richText.ts +16 -16
  265. package/src/types/model/select.ts +7 -7
  266. package/src/types/model/separator.ts +4 -4
  267. package/src/types/model/sharedSlice.ts +7 -7
  268. package/src/types/model/sharedSliceVariation.ts +9 -9
  269. package/src/types/model/slice.ts +12 -12
  270. package/src/types/model/sliceZone.ts +11 -11
  271. package/src/types/model/timestamp.ts +6 -6
  272. package/src/types/model/title.ts +2 -2
  273. package/src/types/model/types.ts +26 -26
  274. package/src/types/model/uid.ts +5 -5
  275. package/src/types/value/boolean.ts +1 -1
  276. package/src/types/value/color.ts +2 -2
  277. package/src/types/value/contentRelationship.ts +15 -15
  278. package/src/types/value/date.ts +2 -2
  279. package/src/types/value/document.ts +23 -23
  280. package/src/types/value/embed.ts +33 -33
  281. package/src/types/value/geoPoint.ts +4 -4
  282. package/src/types/value/group.ts +3 -3
  283. package/src/types/value/image.ts +21 -21
  284. package/src/types/value/integration.ts +2 -2
  285. package/src/types/value/keyText.ts +2 -2
  286. package/src/types/value/link.ts +12 -12
  287. package/src/types/value/linkToMedia.ts +11 -11
  288. package/src/types/value/number.ts +2 -2
  289. package/src/types/value/richText.ts +58 -58
  290. package/src/types/value/select.ts +2 -2
  291. package/src/types/value/sharedSlice.ts +5 -5
  292. package/src/types/value/sharedSliceVariation.ts +5 -5
  293. package/src/types/value/slice.ts +6 -6
  294. package/src/types/value/sliceZone.ts +4 -4
  295. package/src/types/value/timestamp.ts +3 -3
  296. package/src/types/value/title.ts +4 -4
  297. package/src/types/value/types.ts +22 -22
  298. package/src/types/webhook/apiUpdate.ts +18 -18
  299. package/src/types/webhook/testTrigger.ts +2 -2
  300. package/src/types/webhook/types.ts +8 -8
  301. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs +0 -11
  302. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs.map +0 -1
  303. package/dist/_node_modules/hast-util-whitespace/lib/index.js +0 -11
  304. package/dist/_node_modules/hast-util-whitespace/lib/index.js.map +0 -1
@@ -1,42 +1,44 @@
1
- import { appendFilters } from "./lib/appendFilters";
2
- import { castThunk } from "./lib/castThunk";
3
- import { devMsg } from "./lib/devMsg";
4
- import { everyTagFilter } from "./lib/everyTagFilter";
5
- import { findMasterRef } from "./lib/findMasterRef";
6
- import { findRefByID } from "./lib/findRefByID";
7
- import { findRefByLabel } from "./lib/findRefByLabel";
8
- import { getPreviewCookie } from "./lib/getPreviewCookie";
9
- import { minifyGraphQLQuery } from "./lib/minifyGraphQLQuery";
10
- import { someTagsFilter } from "./lib/someTagsFilter";
11
- import { typeFilter } from "./lib/typeFilter";
12
-
13
- import type { Query } from "./types/api/query";
14
- import type { Ref } from "./types/api/ref";
15
- import type { Form, Repository } from "./types/api/repository";
16
- import type { PrismicDocument } from "./types/value/document";
17
-
18
- import { ForbiddenError } from "./errors/ForbiddenError";
19
- import { NotFoundError } from "./errors/NotFoundError";
20
- import { ParsingError } from "./errors/ParsingError";
21
- import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired";
22
- import { PrismicError } from "./errors/PrismicError";
23
- import { RefExpiredError } from "./errors/RefExpiredError";
24
- import { RefNotFoundError } from "./errors/RefNotFoundError";
25
- import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError";
26
-
27
- import { LinkResolverFunction, asLink } from "./helpers/asLink";
28
-
29
- import { BuildQueryURLArgs, buildQueryURL } from "./buildQueryURL";
30
- import { filter } from "./filter";
31
- import { getRepositoryEndpoint } from "./getRepositoryEndpoint";
32
- import { getRepositoryName } from "./getRepositoryName";
33
- import { isRepositoryEndpoint } from "./isRepositoryEndpoint";
1
+ import { appendFilters } from "./lib/appendFilters"
2
+ import { castThunk } from "./lib/castThunk"
3
+ import { devMsg } from "./lib/devMsg"
4
+ import { everyTagFilter } from "./lib/everyTagFilter"
5
+ import { findMasterRef } from "./lib/findMasterRef"
6
+ import { findRefByID } from "./lib/findRefByID"
7
+ import { findRefByLabel } from "./lib/findRefByLabel"
8
+ import { getPreviewCookie } from "./lib/getPreviewCookie"
9
+ import { minifyGraphQLQuery } from "./lib/minifyGraphQLQuery"
10
+ import { someTagsFilter } from "./lib/someTagsFilter"
11
+ import { typeFilter } from "./lib/typeFilter"
12
+
13
+ import type { Query } from "./types/api/query"
14
+ import type { Ref } from "./types/api/ref"
15
+ import type { Form, Repository } from "./types/api/repository"
16
+ import type { PrismicDocument } from "./types/value/document"
17
+
18
+ import { ForbiddenError } from "./errors/ForbiddenError"
19
+ import { NotFoundError } from "./errors/NotFoundError"
20
+ import { ParsingError } from "./errors/ParsingError"
21
+ import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"
22
+ import { PrismicError } from "./errors/PrismicError"
23
+ import { RefExpiredError } from "./errors/RefExpiredError"
24
+ import { RefNotFoundError } from "./errors/RefNotFoundError"
25
+ import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"
26
+
27
+ import type { LinkResolverFunction } from "./helpers/asLink"
28
+ import { asLink } from "./helpers/asLink"
29
+
30
+ import type { BuildQueryURLArgs } from "./buildQueryURL"
31
+ import { buildQueryURL } from "./buildQueryURL"
32
+ import { filter } from "./filter"
33
+ import { getRepositoryEndpoint } from "./getRepositoryEndpoint"
34
+ import { getRepositoryName } from "./getRepositoryName"
35
+ import { isRepositoryEndpoint } from "./isRepositoryEndpoint"
34
36
 
35
37
  /**
36
38
  * The largest page size allowed by the Prismic REST API V2. This value is used
37
39
  * to minimize the number of requests required to query content.
38
40
  */
39
- const MAX_PAGE_SIZE = 100;
41
+ const MAX_PAGE_SIZE = 100
40
42
 
41
43
  /**
42
44
  * The number of milliseconds in which repository metadata is considered valid.
@@ -44,7 +46,7 @@ const MAX_PAGE_SIZE = 100;
44
46
  * updated in the Prismic repository. As such, repository's metadata can only be
45
47
  * considered valid for a short amount of time.
46
48
  */
47
- export const REPOSITORY_CACHE_TTL = 5000;
49
+ export const REPOSITORY_CACHE_TTL = 5000
48
50
 
49
51
  /**
50
52
  * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
@@ -53,7 +55,7 @@ export const REPOSITORY_CACHE_TTL = 5000;
53
55
  * This is done to ensure API performance is sustainable and reduces the chance
54
56
  * of a failed API request due to overloading.
55
57
  */
56
- export const GET_ALL_QUERY_DELAY = 500;
58
+ export const GET_ALL_QUERY_DELAY = 500
57
59
 
58
60
  /**
59
61
  * The default number of milliseconds to wait before retrying a rate-limited
@@ -62,7 +64,7 @@ export const GET_ALL_QUERY_DELAY = 500;
62
64
  *
63
65
  * The API allows up to 200 requests per second.
64
66
  */
65
- const DEFUALT_RETRY_AFTER_MS = 1000;
67
+ const DEFUALT_RETRY_AFTER_MS = 1000
66
68
 
67
69
  /**
68
70
  * Extracts one or more Prismic document types that match a given Prismic
@@ -78,7 +80,7 @@ type ExtractDocumentType<
78
80
  > =
79
81
  Extract<TDocuments, { type: TDocumentType }> extends never
80
82
  ? TDocuments
81
- : Extract<TDocuments, { type: TDocumentType }>;
83
+ : Extract<TDocuments, { type: TDocumentType }>
82
84
 
83
85
  /**
84
86
  * A universal API to make network requests. A subset of the `fetch()` API.
@@ -88,7 +90,7 @@ type ExtractDocumentType<
88
90
  export type FetchLike = (
89
91
  input: string,
90
92
  init?: RequestInitLike,
91
- ) => Promise<ResponseLike>;
93
+ ) => Promise<ResponseLike>
92
94
 
93
95
  /**
94
96
  * An object that allows you to abort a `fetch()` request if needed via an
@@ -101,7 +103,7 @@ export type FetchLike = (
101
103
  // important to validate since it is blindly passed to a given `fetch()`
102
104
  // function.
103
105
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
- export type AbortSignalLike = any;
106
+ export type AbortSignalLike = any
105
107
 
106
108
  /**
107
109
  * A subset of RequestInit properties to configure a `fetch()` request.
@@ -115,7 +117,7 @@ export interface RequestInitLike extends Pick<RequestInit, "cache"> {
115
117
  /**
116
118
  * An object literal to set the `fetch()` request's headers.
117
119
  */
118
- headers?: Record<string, string>;
120
+ headers?: Record<string, string>
119
121
 
120
122
  /**
121
123
  * An AbortSignal to set the `fetch()` request's signal.
@@ -126,24 +128,24 @@ export interface RequestInitLike extends Pick<RequestInit, "cache"> {
126
128
  // NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`
127
129
  // for backwards compatibility (the type is exported) and to signal to
128
130
  // other readers that this should be an AbortSignal-like object.
129
- signal?: AbortSignalLike;
131
+ signal?: AbortSignalLike
130
132
  }
131
133
 
132
134
  /**
133
135
  * The minimum required properties from Response.
134
136
  */
135
137
  export interface ResponseLike {
136
- status: number;
137
- headers: HeadersLike;
138
+ status: number
139
+ headers: HeadersLike
138
140
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
139
- json(): Promise<any>;
141
+ json(): Promise<any>
140
142
  }
141
143
 
142
144
  /**
143
145
  * The minimum required properties from Headers.
144
146
  */
145
147
  export interface HeadersLike {
146
- get(name: string): string | null;
148
+ get(name: string): string | null
147
149
  }
148
150
 
149
151
  /**
@@ -158,9 +160,9 @@ export type HttpRequestLike =
158
160
  */
159
161
  {
160
162
  headers?: {
161
- get(name: string): string | null;
162
- };
163
- url?: string;
163
+ get(name: string): string | null
164
+ }
165
+ url?: string
164
166
  }
165
167
 
166
168
  /**
@@ -168,10 +170,10 @@ export type HttpRequestLike =
168
170
  */
169
171
  | {
170
172
  headers?: {
171
- cookie?: string;
172
- };
173
- query?: Record<string, unknown>;
174
- };
173
+ cookie?: string
174
+ }
175
+ query?: Record<string, unknown>
176
+ }
175
177
 
176
178
  /**
177
179
  * Modes for client ref management.
@@ -205,30 +207,30 @@ type RefState = {
205
207
  /**
206
208
  * Determines if automatic preview support is enabled.
207
209
  */
208
- autoPreviewsEnabled: boolean;
210
+ autoPreviewsEnabled: boolean
209
211
 
210
212
  /**
211
213
  * An optional HTTP server request object used during previews if automatic
212
214
  * previews are enabled.
213
215
  */
214
- httpRequest?: HttpRequestLike;
216
+ httpRequest?: HttpRequestLike
215
217
  } & (
216
218
  | {
217
- mode: RefStateMode.Master;
219
+ mode: RefStateMode.Master
218
220
  }
219
221
  | {
220
- mode: RefStateMode.ReleaseID;
221
- releaseID: string;
222
+ mode: RefStateMode.ReleaseID
223
+ releaseID: string
222
224
  }
223
225
  | {
224
- mode: RefStateMode.ReleaseLabel;
225
- releaseLabel: string;
226
+ mode: RefStateMode.ReleaseLabel
227
+ releaseLabel: string
226
228
  }
227
229
  | {
228
- mode: RefStateMode.Manual;
229
- ref: RefStringOrThunk;
230
+ mode: RefStateMode.Manual
231
+ ref: RefStringOrThunk
230
232
  }
231
- );
233
+ )
232
234
 
233
235
  /**
234
236
  * A ref or a function that returns a ref. If a static ref is known, one can be
@@ -237,7 +239,7 @@ type RefState = {
237
239
  */
238
240
  type RefStringOrThunk =
239
241
  | string
240
- | (() => string | undefined | Promise<string | undefined>);
242
+ | (() => string | undefined | Promise<string | undefined>)
241
243
 
242
244
  /**
243
245
  * Configuration for clients that determine how content is queried.
@@ -247,14 +249,14 @@ export type ClientConfig = {
247
249
  * The secure token for accessing the Prismic repository. This is only
248
250
  * required if the repository is set to private.
249
251
  */
250
- accessToken?: string;
252
+ accessToken?: string
251
253
 
252
254
  /**
253
255
  * A string representing a version of the Prismic repository's content. This
254
256
  * may point to the latest version (called the "master ref"), or a preview
255
257
  * with draft content.
256
258
  */
257
- ref?: RefStringOrThunk;
259
+ ref?: RefStringOrThunk
258
260
 
259
261
  /**
260
262
  * A list of route resolver objects that define how a document's `url`
@@ -262,7 +264,7 @@ export type ClientConfig = {
262
264
  *
263
265
  * {@link https://prismic.io/docs/route-resolver}
264
266
  */
265
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
267
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>
266
268
 
267
269
  /**
268
270
  * The `brokenRoute` option allows you to define the route populated in the
@@ -272,7 +274,7 @@ export type ClientConfig = {
272
274
  *
273
275
  * {@link https://prismic.io/docs/route-resolver}
274
276
  */
275
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
277
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>
276
278
 
277
279
  /**
278
280
  * Default parameters that will be sent with each query. These parameters can
@@ -281,22 +283,22 @@ export type ClientConfig = {
281
283
  defaultParams?: Omit<
282
284
  BuildQueryURLArgs,
283
285
  "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute"
284
- >;
286
+ >
285
287
 
286
288
  /**
287
289
  * The function used to make network requests to the Prismic REST API. In
288
290
  * environments where a global `fetch` function does not exist, such as
289
291
  * Node.js, this function must be provided.
290
292
  */
291
- fetch?: FetchLike;
293
+ fetch?: FetchLike
292
294
 
293
295
  /**
294
296
  * Options provided to the client's `fetch()` on all network requests. These
295
297
  * options will be merged with internally required options. They can also be
296
298
  * overriden on a per-query basis using the query's `fetchOptions` parameter.
297
299
  */
298
- fetchOptions?: RequestInitLike;
299
- };
300
+ fetchOptions?: RequestInitLike
301
+ }
300
302
 
301
303
  /**
302
304
  * Parameters for any client method that use `fetch()`.
@@ -307,7 +309,7 @@ type FetchParams = {
307
309
  * options will be merged with internally required options. They can also be
308
310
  * overriden on a per-query basis using the query's `fetchOptions` parameter.
309
311
  */
310
- fetchOptions?: RequestInitLike;
312
+ fetchOptions?: RequestInitLike
311
313
 
312
314
  /**
313
315
  * An `AbortSignal` provided by an `AbortController`. This allows the network
@@ -317,8 +319,8 @@ type FetchParams = {
317
319
  *
318
320
  * @see \<https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal\>
319
321
  */
320
- signal?: AbortSignalLike;
321
- };
322
+ signal?: AbortSignalLike
323
+ }
322
324
 
323
325
  /**
324
326
  * Parameters specific to client methods that fetch all documents. These methods
@@ -329,8 +331,8 @@ type GetAllParams = {
329
331
  * Limit the number of documents queried. If a number is not provided, there
330
332
  * will be no limit and all matching documents will be returned.
331
333
  */
332
- limit?: number;
333
- };
334
+ limit?: number
335
+ }
334
336
 
335
337
  /**
336
338
  * Arguments to determine how the URL for a preview session is resolved.
@@ -339,34 +341,34 @@ type ResolvePreviewArgs<LinkResolverReturnType> = {
339
341
  /**
340
342
  * A function that maps a Prismic document to a URL within your app.
341
343
  */
342
- linkResolver?: LinkResolverFunction<LinkResolverReturnType>;
344
+ linkResolver?: LinkResolverFunction<LinkResolverReturnType>
343
345
 
344
346
  /**
345
347
  * A fallback URL if the link resolver does not return a value.
346
348
  */
347
- defaultURL: string;
349
+ defaultURL: string
348
350
 
349
351
  /**
350
352
  * The preview token (also known as a ref) that will be used to query preview
351
353
  * content from the Prismic repository.
352
354
  */
353
- previewToken?: string;
355
+ previewToken?: string
354
356
 
355
357
  /**
356
358
  * The previewed document that will be used to determine the destination URL.
357
359
  */
358
- documentID?: string;
359
- };
360
+ documentID?: string
361
+ }
360
362
 
361
363
  /**
362
364
  * The result of a `fetch()` job.
363
365
  */
364
366
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
367
  type FetchJobResult<TJSON = any> = {
366
- status: number;
367
- headers: HeadersLike;
368
- json: TJSON;
369
- };
368
+ status: number
369
+ headers: HeadersLike
370
+ json: TJSON
371
+ }
370
372
 
371
373
  /**
372
374
  * Type definitions for the `createClient()` function. May be augmented by
@@ -375,7 +377,7 @@ type FetchJobResult<TJSON = any> = {
375
377
  export interface CreateClient {
376
378
  <TDocuments extends PrismicDocument>(
377
379
  ...args: ConstructorParameters<typeof Client>
378
- ): Client<TDocuments>;
380
+ ): Client<TDocuments>
379
381
  }
380
382
 
381
383
  /**
@@ -385,10 +387,10 @@ export interface CreateClient {
385
387
  *
386
388
  * ```ts
387
389
  * // With a repository name.
388
- * createClient("qwerty");
390
+ * createClient("qwerty")
389
391
  *
390
392
  * // Or with a full Prismic Rest API V2 endpoint.
391
- * createClient("https://qwerty.cdn.prismic.io/api/v2");
393
+ * createClient("https://qwerty.cdn.prismic.io/api/v2")
392
394
  * ```
393
395
  *
394
396
  * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
@@ -404,7 +406,7 @@ export interface CreateClient {
404
406
  export const createClient: CreateClient = <TDocuments extends PrismicDocument>(
405
407
  repositoryNameOrEndpoint: string,
406
408
  options?: ClientConfig,
407
- ) => new Client<TDocuments>(repositoryNameOrEndpoint, options);
409
+ ) => new Client<TDocuments>(repositoryNameOrEndpoint, options)
408
410
 
409
411
  /**
410
412
  * A client that allows querying content from a Prismic repository.
@@ -421,7 +423,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
421
423
  * The Prismic REST API V2 endpoint for the repository (use
422
424
  * `prismic.getRepositoryEndpoint` for the default endpoint).
423
425
  */
424
- endpoint: string;
426
+ endpoint: string
425
427
 
426
428
  /**
427
429
  * The secure token for accessing the API (only needed if your repository is
@@ -429,7 +431,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
429
431
  *
430
432
  * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
431
433
  */
432
- accessToken?: string;
434
+ accessToken?: string
433
435
 
434
436
  /**
435
437
  * A list of route resolver objects that define how a document's `url` field
@@ -437,7 +439,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
437
439
  *
438
440
  * {@link https://prismic.io/docs/route-resolver}
439
441
  */
440
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
442
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>
441
443
 
442
444
  /**
443
445
  * The `brokenRoute` option allows you to define the route populated in the
@@ -447,16 +449,16 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
447
449
  *
448
450
  * {@link https://prismic.io/docs/route-resolver}
449
451
  */
450
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
452
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>
451
453
 
452
454
  /**
453
455
  * The function used to make network requests to the Prismic REST API. In
454
456
  * environments where a global `fetch` function does not exist, such as
455
457
  * Node.js, this function must be provided.
456
458
  */
457
- fetchFn: FetchLike;
459
+ fetchFn: FetchLike
458
460
 
459
- fetchOptions?: RequestInitLike;
461
+ fetchOptions?: RequestInitLike
460
462
 
461
463
  /**
462
464
  * Default parameters that will be sent with each query. These parameters can
@@ -465,7 +467,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
465
467
  defaultParams?: Omit<
466
468
  BuildQueryURLArgs,
467
469
  "ref" | "integrationFieldsRef" | "accessToken" | "routes"
468
- >;
470
+ >
469
471
 
470
472
  /**
471
473
  * The client's ref mode state. This determines which ref is used during
@@ -474,17 +476,17 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
474
476
  private refState: RefState = {
475
477
  mode: RefStateMode.Master,
476
478
  autoPreviewsEnabled: true,
477
- };
479
+ }
478
480
 
479
481
  /**
480
482
  * Cached repository value.
481
483
  */
482
- private cachedRepository: Repository | undefined;
484
+ private cachedRepository: Repository | undefined
483
485
 
484
486
  /**
485
487
  * Timestamp at which the cached repository data is considered stale.
486
488
  */
487
- private cachedRepositoryExpiration = 0;
489
+ private cachedRepositoryExpiration = 0
488
490
 
489
491
  /**
490
492
  * Active `fetch()` jobs keyed by URL and AbortSignal (if it exists).
@@ -492,7 +494,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
492
494
  private fetchJobs: Record<
493
495
  string,
494
496
  Map<AbortSignalLike | undefined, Promise<FetchJobResult>>
495
- > = {};
497
+ > = {}
496
498
 
497
499
  /**
498
500
  * Creates a Prismic client that can be used to query a repository.
@@ -517,61 +519,61 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
517
519
  "@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.",
518
520
  undefined,
519
521
  undefined,
520
- );
522
+ )
521
523
  }
522
524
 
523
525
  const hostname = new URL(
524
526
  repositoryNameOrEndpoint,
525
- ).hostname.toLowerCase();
527
+ ).hostname.toLowerCase()
526
528
 
527
529
  // Matches non-.cdn `.prismic.io` endpoints
528
530
  if (
529
531
  hostname.endsWith(".prismic.io") &&
530
532
  !hostname.endsWith(".cdn.prismic.io")
531
533
  ) {
532
- const repositoryName = getRepositoryName(repositoryNameOrEndpoint);
533
- const dotCDNEndpoint = getRepositoryEndpoint(repositoryName);
534
+ const repositoryName = getRepositoryName(repositoryNameOrEndpoint)
535
+ const dotCDNEndpoint = getRepositoryEndpoint(repositoryName)
534
536
  console.warn(
535
537
  `[@prismicio/client] A non-.cdn endpoint was provided to create a client with (\`${repositoryNameOrEndpoint}\`). Non-.cdn endpoints can have unexpected side-effects and cause performance issues when querying Prismic. Please convert it to the \`.cdn\` alternative (\`${dotCDNEndpoint}\`) or use the repository name directly instead (\`${repositoryName}\`). For more details, see ${devMsg(
536
538
  "endpoint-must-use-cdn",
537
539
  )}`,
538
- );
540
+ )
539
541
  }
540
542
  }
541
543
 
542
- this.endpoint = repositoryNameOrEndpoint;
544
+ this.endpoint = repositoryNameOrEndpoint
543
545
  } else {
544
- this.endpoint = getRepositoryEndpoint(repositoryNameOrEndpoint);
546
+ this.endpoint = getRepositoryEndpoint(repositoryNameOrEndpoint)
545
547
  }
546
548
 
547
- this.accessToken = options.accessToken;
548
- this.routes = options.routes;
549
- this.brokenRoute = options.brokenRoute;
550
- this.fetchOptions = options.fetchOptions;
551
- this.defaultParams = options.defaultParams;
549
+ this.accessToken = options.accessToken
550
+ this.routes = options.routes
551
+ this.brokenRoute = options.brokenRoute
552
+ this.fetchOptions = options.fetchOptions
553
+ this.defaultParams = options.defaultParams
552
554
 
553
555
  if (options.ref) {
554
- this.queryContentFromRef(options.ref);
556
+ this.queryContentFromRef(options.ref)
555
557
  }
556
558
 
557
559
  if (typeof options.fetch === "function") {
558
- this.fetchFn = options.fetch;
560
+ this.fetchFn = options.fetch
559
561
  } else if (typeof globalThis.fetch === "function") {
560
- this.fetchFn = globalThis.fetch as FetchLike;
562
+ this.fetchFn = globalThis.fetch as FetchLike
561
563
  } else {
562
564
  throw new PrismicError(
563
565
  "A valid fetch implementation was not provided. In environments where fetch is not available (including Node.js), a fetch implementation must be provided via a polyfill or the `fetch` option.",
564
566
  undefined,
565
567
  undefined,
566
- );
568
+ )
567
569
  }
568
570
 
569
571
  // If the global fetch function is used, we must bind it to the global scope.
570
572
  if (this.fetchFn === globalThis.fetch) {
571
- this.fetchFn = this.fetchFn.bind(globalThis);
573
+ this.fetchFn = this.fetchFn.bind(globalThis)
572
574
  }
573
575
 
574
- this.graphQLFetch = this.graphQLFetch.bind(this);
576
+ this.graphQLFetch = this.graphQLFetch.bind(this)
575
577
  }
576
578
 
577
579
  /**
@@ -584,13 +586,13 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
584
586
  * @example
585
587
  *
586
588
  * ```ts
587
- * client.enableAutoPreviews();
589
+ * client.enableAutoPreviews()
588
590
  * ```
589
591
  *
590
592
  * @see enableAutoPreviewsFromReq
591
593
  */
592
594
  enableAutoPreviews(): void {
593
- this.refState.autoPreviewsEnabled = true;
595
+ this.refState.autoPreviewsEnabled = true
594
596
  }
595
597
 
596
598
  /**
@@ -605,16 +607,16 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
605
607
  * ```ts
606
608
  * // In an express app
607
609
  * app.get("/", function (req, res) {
608
- * client.enableAutoPreviewsFromReq(req);
609
- * });
610
+ * client.enableAutoPreviewsFromReq(req)
611
+ * })
610
612
  * ```
611
613
  *
612
614
  * @param req - An HTTP server request object containing the request's
613
615
  * cookies.
614
616
  */
615
617
  enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void {
616
- this.refState.httpRequest = req;
617
- this.refState.autoPreviewsEnabled = true;
618
+ this.refState.httpRequest = req
619
+ this.refState.autoPreviewsEnabled = true
618
620
  }
619
621
 
620
622
  /**
@@ -627,11 +629,11 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
627
629
  * @example
628
630
  *
629
631
  * ```ts
630
- * client.disableAutoPreviews();
632
+ * client.disableAutoPreviews()
631
633
  * ```
632
634
  */
633
635
  disableAutoPreviews(): void {
634
- this.refState.autoPreviewsEnabled = false;
636
+ this.refState.autoPreviewsEnabled = false
635
637
  }
636
638
 
637
639
  /**
@@ -640,7 +642,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
640
642
  * @example
641
643
  *
642
644
  * ```ts
643
- * const response = await client.get();
645
+ * const response = await client.get()
644
646
  * ```
645
647
  *
646
648
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -652,9 +654,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
652
654
  async get<TDocument extends TDocuments>(
653
655
  params?: Partial<BuildQueryURLArgs> & FetchParams,
654
656
  ): Promise<Query<TDocument>> {
655
- const url = await this.buildQueryURL(params);
657
+ const url = await this.buildQueryURL(params)
656
658
 
657
- return await this.fetch<Query<TDocument>>(url, params);
659
+ return await this.fetch<Query<TDocument>>(url, params)
658
660
  }
659
661
 
660
662
  /**
@@ -664,7 +666,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
664
666
  * @example
665
667
  *
666
668
  * ```ts
667
- * const document = await client.getFirst();
669
+ * const document = await client.getFirst()
668
670
  * ```
669
671
  *
670
672
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -675,20 +677,20 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
675
677
  async getFirst<TDocument extends TDocuments>(
676
678
  params?: Partial<BuildQueryURLArgs> & FetchParams,
677
679
  ): Promise<TDocument> {
678
- const actualParams = { ...params };
680
+ const actualParams = { ...params }
679
681
  if (!(params && params.page) && !params?.pageSize) {
680
- actualParams.pageSize = this.defaultParams?.pageSize ?? 1;
682
+ actualParams.pageSize = this.defaultParams?.pageSize ?? 1
681
683
  }
682
- const url = await this.buildQueryURL(actualParams);
683
- const result = await this.fetch<Query<TDocument>>(url, params);
684
+ const url = await this.buildQueryURL(actualParams)
685
+ const result = await this.fetch<Query<TDocument>>(url, params)
684
686
 
685
- const firstResult = result.results[0];
687
+ const firstResult = result.results[0]
686
688
 
687
689
  if (firstResult) {
688
- return firstResult;
690
+ return firstResult
689
691
  }
690
692
 
691
- throw new NotFoundError("No documents were returned", url, undefined);
693
+ throw new NotFoundError("No documents were returned", url, undefined)
692
694
  }
693
695
 
694
696
  /**
@@ -705,7 +707,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
705
707
  * @example
706
708
  *
707
709
  * ```ts
708
- * const response = await client.dangerouslyGetAll();
710
+ * const response = await client.dangerouslyGetAll()
709
711
  * ```
710
712
  *
711
713
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -719,33 +721,33 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
719
721
  GetAllParams &
720
722
  FetchParams = {},
721
723
  ): Promise<TDocument[]> {
722
- const { limit = Infinity, ...actualParams } = params;
724
+ const { limit = Infinity, ...actualParams } = params
723
725
  const resolvedParams = {
724
726
  ...actualParams,
725
727
  pageSize: Math.min(
726
728
  limit,
727
729
  actualParams.pageSize || this.defaultParams?.pageSize || MAX_PAGE_SIZE,
728
730
  ),
729
- };
731
+ }
730
732
 
731
- const documents: TDocument[] = [];
732
- let latestResult: Query<TDocument> | undefined;
733
+ const documents: TDocument[] = []
734
+ let latestResult: Query<TDocument> | undefined
733
735
 
734
736
  while (
735
737
  (!latestResult || latestResult.next_page) &&
736
738
  documents.length < limit
737
739
  ) {
738
- const page = latestResult ? latestResult.page + 1 : undefined;
740
+ const page = latestResult ? latestResult.page + 1 : undefined
739
741
 
740
- latestResult = await this.get<TDocument>({ ...resolvedParams, page });
741
- documents.push(...latestResult.results);
742
+ latestResult = await this.get<TDocument>({ ...resolvedParams, page })
743
+ documents.push(...latestResult.results)
742
744
 
743
745
  if (latestResult.next_page) {
744
- await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY));
746
+ await new Promise((res) => setTimeout(res, GET_ALL_QUERY_DELAY))
745
747
  }
746
748
  }
747
749
 
748
- return documents.slice(0, limit);
750
+ return documents.slice(0, limit)
749
751
  }
750
752
 
751
753
  /**
@@ -760,7 +762,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
760
762
  * @example
761
763
  *
762
764
  * ```ts
763
- * const document = await client.getByID("WW4bKScAAMAqmluX");
765
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
764
766
  * ```
765
767
  *
766
768
  * @typeParam TDocument- Type of the Prismic document returned.
@@ -777,7 +779,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
777
779
  ): Promise<TDocument> {
778
780
  return await this.getFirst<TDocument>(
779
781
  appendFilters(params, filter.at("document.id", id)),
780
- );
782
+ )
781
783
  }
782
784
 
783
785
  /**
@@ -795,7 +797,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
795
797
  * const response = await client.getByIDs([
796
798
  * "WW4bKScAAMAqmluX",
797
799
  * "U1kTRgEAAC8A5ldS",
798
- * ]);
800
+ * ])
799
801
  * ```
800
802
  *
801
803
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -812,7 +814,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
812
814
  ): Promise<Query<TDocument>> {
813
815
  return await this.get<TDocument>(
814
816
  appendFilters(params, filter.in("document.id", ids)),
815
- );
817
+ )
816
818
  }
817
819
 
818
820
  /**
@@ -833,7 +835,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
833
835
  * const response = await client.getAllByIDs([
834
836
  * "WW4bKScAAMAqmluX",
835
837
  * "U1kTRgEAAC8A5ldS",
836
- * ]);
838
+ * ])
837
839
  * ```
838
840
  *
839
841
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -849,7 +851,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
849
851
  ): Promise<TDocument[]> {
850
852
  return await this.dangerouslyGetAll<TDocument>(
851
853
  appendFilters(params, filter.in("document.id", ids)),
852
- );
854
+ )
853
855
  }
854
856
 
855
857
  /**
@@ -865,7 +867,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
865
867
  * @example
866
868
  *
867
869
  * ```ts
868
- * const document = await client.getByUID("blog_post", "my-first-post");
870
+ * const document = await client.getByUID("blog_post", "my-first-post")
869
871
  * ```
870
872
  *
871
873
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -890,7 +892,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
890
892
  typeFilter(documentType),
891
893
  filter.at(`my.${documentType}.uid`, uid),
892
894
  ]),
893
- );
895
+ )
894
896
  }
895
897
 
896
898
  /**
@@ -909,7 +911,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
909
911
  * const document = await client.getByUIDs("blog_post", [
910
912
  * "my-first-post",
911
913
  * "my-second-post",
912
- * ]);
914
+ * ])
913
915
  * ```
914
916
  *
915
917
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -934,7 +936,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
934
936
  typeFilter(documentType),
935
937
  filter.in(`my.${documentType}.uid`, uids),
936
938
  ]),
937
- );
939
+ )
938
940
  }
939
941
 
940
942
  /**
@@ -956,7 +958,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
956
958
  * const response = await client.getAllByUIDs([
957
959
  * "my-first-post",
958
960
  * "my-second-post",
959
- * ]);
961
+ * ])
960
962
  * ```
961
963
  *
962
964
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -982,7 +984,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
982
984
  typeFilter(documentType),
983
985
  filter.in(`my.${documentType}.uid`, uids),
984
986
  ]),
985
- );
987
+ )
986
988
  }
987
989
 
988
990
  /**
@@ -998,7 +1000,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
998
1000
  * @example
999
1001
  *
1000
1002
  * ```ts
1001
- * const document = await client.getSingle("settings");
1003
+ * const document = await client.getSingle("settings")
1002
1004
  * ```
1003
1005
  *
1004
1006
  * @typeParam TDocument - Type of the Prismic document returned.
@@ -1018,7 +1020,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1018
1020
  ): Promise<ExtractDocumentType<TDocument, TDocumentType>> {
1019
1021
  return await this.getFirst<ExtractDocumentType<TDocument, TDocumentType>>(
1020
1022
  appendFilters(params, typeFilter(documentType)),
1021
- );
1023
+ )
1022
1024
  }
1023
1025
 
1024
1026
  /**
@@ -1030,7 +1032,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1030
1032
  * @example
1031
1033
  *
1032
1034
  * ```ts
1033
- * const response = await client.getByType("blog_post");
1035
+ * const response = await client.getByType("blog_post")
1034
1036
  * ```
1035
1037
  *
1036
1038
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1049,7 +1051,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1049
1051
  ): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>> {
1050
1052
  return await this.get<ExtractDocumentType<TDocument, TDocumentType>>(
1051
1053
  appendFilters(params, typeFilter(documentType)),
1052
- );
1054
+ )
1053
1055
  }
1054
1056
 
1055
1057
  /**
@@ -1062,7 +1064,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1062
1064
  * @example
1063
1065
  *
1064
1066
  * ```ts
1065
- * const response = await client.getByType("blog_post");
1067
+ * const response = await client.getByType("blog_post")
1066
1068
  * ```
1067
1069
  *
1068
1070
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1083,7 +1085,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1083
1085
  ): Promise<ExtractDocumentType<TDocument, TDocumentType>[]> {
1084
1086
  return await this.dangerouslyGetAll<
1085
1087
  ExtractDocumentType<TDocument, TDocumentType>
1086
- >(appendFilters(params, typeFilter(documentType)));
1088
+ >(appendFilters(params, typeFilter(documentType)))
1087
1089
  }
1088
1090
 
1089
1091
  /**
@@ -1095,7 +1097,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1095
1097
  * @example
1096
1098
  *
1097
1099
  * ```ts
1098
- * const response = await client.getByTag("food");
1100
+ * const response = await client.getByTag("food")
1099
1101
  * ```
1100
1102
  *
1101
1103
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1109,9 +1111,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1109
1111
  tag: string,
1110
1112
  params?: Partial<BuildQueryURLArgs> & FetchParams,
1111
1113
  ): Promise<Query<TDocument>> {
1112
- return await this.get<TDocument>(
1113
- appendFilters(params, someTagsFilter(tag)),
1114
- );
1114
+ return await this.get<TDocument>(appendFilters(params, someTagsFilter(tag)))
1115
1115
  }
1116
1116
 
1117
1117
  /**
@@ -1123,7 +1123,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1123
1123
  * @example
1124
1124
  *
1125
1125
  * ```ts
1126
- * const response = await client.getAllByTag("food");
1126
+ * const response = await client.getAllByTag("food")
1127
1127
  * ```
1128
1128
  *
1129
1129
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1141,7 +1141,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1141
1141
  ): Promise<TDocument[]> {
1142
1142
  return await this.dangerouslyGetAll<TDocument>(
1143
1143
  appendFilters(params, someTagsFilter(tag)),
1144
- );
1144
+ )
1145
1145
  }
1146
1146
 
1147
1147
  /**
@@ -1151,7 +1151,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1151
1151
  * @example
1152
1152
  *
1153
1153
  * ```ts
1154
- * const response = await client.getByEveryTag(["food", "fruit"]);
1154
+ * const response = await client.getByEveryTag(["food", "fruit"])
1155
1155
  * ```
1156
1156
  *
1157
1157
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1167,7 +1167,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1167
1167
  ): Promise<Query<TDocument>> {
1168
1168
  return await this.get<TDocument>(
1169
1169
  appendFilters(params, everyTagFilter(tags)),
1170
- );
1170
+ )
1171
1171
  }
1172
1172
 
1173
1173
  /**
@@ -1180,7 +1180,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1180
1180
  * @example
1181
1181
  *
1182
1182
  * ```ts
1183
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
1183
+ * const response = await client.getAllByEveryTag(["food", "fruit"])
1184
1184
  * ```
1185
1185
  *
1186
1186
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1198,7 +1198,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1198
1198
  ): Promise<TDocument[]> {
1199
1199
  return await this.dangerouslyGetAll<TDocument>(
1200
1200
  appendFilters(params, everyTagFilter(tags)),
1201
- );
1201
+ )
1202
1202
  }
1203
1203
 
1204
1204
  /**
@@ -1209,7 +1209,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1209
1209
  * @example
1210
1210
  *
1211
1211
  * ```ts
1212
- * const response = await client.getByEveryTag(["food", "fruit"]);
1212
+ * const response = await client.getByEveryTag(["food", "fruit"])
1213
1213
  * ```
1214
1214
  *
1215
1215
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1226,7 +1226,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1226
1226
  ): Promise<Query<TDocument>> {
1227
1227
  return await this.get<TDocument>(
1228
1228
  appendFilters(params, someTagsFilter(tags)),
1229
- );
1229
+ )
1230
1230
  }
1231
1231
 
1232
1232
  /**
@@ -1240,7 +1240,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1240
1240
  * @example
1241
1241
  *
1242
1242
  * ```ts
1243
- * const response = await client.getAllBySomeTags(["food", "fruit"]);
1243
+ * const response = await client.getAllBySomeTags(["food", "fruit"])
1244
1244
  * ```
1245
1245
  *
1246
1246
  * @typeParam TDocument - Type of Prismic documents returned.
@@ -1258,7 +1258,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1258
1258
  ): Promise<TDocument[]> {
1259
1259
  return await this.dangerouslyGetAll<TDocument>(
1260
1260
  appendFilters(params, someTagsFilter(tags)),
1261
- );
1261
+ )
1262
1262
  }
1263
1263
 
1264
1264
  /**
@@ -1271,13 +1271,13 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1271
1271
  // TODO: Restore when Authorization header support works in browsers with CORS.
1272
1272
  // return await this.fetch<Repository>(this.endpoint);
1273
1273
 
1274
- const url = new URL(this.endpoint);
1274
+ const url = new URL(this.endpoint)
1275
1275
 
1276
1276
  if (this.accessToken) {
1277
- url.searchParams.set("access_token", this.accessToken);
1277
+ url.searchParams.set("access_token", this.accessToken)
1278
1278
  }
1279
1279
 
1280
- return await this.fetch<Repository>(url.toString(), params);
1280
+ return await this.fetch<Repository>(url.toString(), params)
1281
1281
  }
1282
1282
 
1283
1283
  /**
@@ -1290,9 +1290,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1290
1290
  * @returns A list of all refs for the Prismic repository.
1291
1291
  */
1292
1292
  async getRefs(params?: FetchParams): Promise<Ref[]> {
1293
- const repository = await this.getRepository(params);
1293
+ const repository = await this.getRepository(params)
1294
1294
 
1295
- return repository.refs;
1295
+ return repository.refs
1296
1296
  }
1297
1297
 
1298
1298
  /**
@@ -1303,9 +1303,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1303
1303
  * @returns The ref with a matching ID, if it exists.
1304
1304
  */
1305
1305
  async getRefByID(id: string, params?: FetchParams): Promise<Ref> {
1306
- const refs = await this.getRefs(params);
1306
+ const refs = await this.getRefs(params)
1307
1307
 
1308
- return findRefByID(refs, id);
1308
+ return findRefByID(refs, id)
1309
1309
  }
1310
1310
 
1311
1311
  /**
@@ -1316,9 +1316,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1316
1316
  * @returns The ref with a matching label, if it exists.
1317
1317
  */
1318
1318
  async getRefByLabel(label: string, params?: FetchParams): Promise<Ref> {
1319
- const refs = await this.getRefs(params);
1319
+ const refs = await this.getRefs(params)
1320
1320
 
1321
- return findRefByLabel(refs, label);
1321
+ return findRefByLabel(refs, label)
1322
1322
  }
1323
1323
 
1324
1324
  /**
@@ -1328,9 +1328,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1328
1328
  * @returns The repository's master ref.
1329
1329
  */
1330
1330
  async getMasterRef(params?: FetchParams): Promise<Ref> {
1331
- const refs = await this.getRefs(params);
1331
+ const refs = await this.getRefs(params)
1332
1332
 
1333
- return findMasterRef(refs);
1333
+ return findMasterRef(refs)
1334
1334
  }
1335
1335
 
1336
1336
  /**
@@ -1340,9 +1340,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1340
1340
  * @returns A list of all Releases for the Prismic repository.
1341
1341
  */
1342
1342
  async getReleases(params?: FetchParams): Promise<Ref[]> {
1343
- const refs = await this.getRefs(params);
1343
+ const refs = await this.getRefs(params)
1344
1344
 
1345
- return refs.filter((ref) => !ref.isMasterRef);
1345
+ return refs.filter((ref) => !ref.isMasterRef)
1346
1346
  }
1347
1347
 
1348
1348
  /**
@@ -1353,9 +1353,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1353
1353
  * @returns The Release with a matching ID, if it exists.
1354
1354
  */
1355
1355
  async getReleaseByID(id: string, params?: FetchParams): Promise<Ref> {
1356
- const releases = await this.getReleases(params);
1356
+ const releases = await this.getReleases(params)
1357
1357
 
1358
- return findRefByID(releases, id);
1358
+ return findRefByID(releases, id)
1359
1359
  }
1360
1360
 
1361
1361
  /**
@@ -1366,9 +1366,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1366
1366
  * @returns The ref with a matching label, if it exists.
1367
1367
  */
1368
1368
  async getReleaseByLabel(label: string, params?: FetchParams): Promise<Ref> {
1369
- const releases = await this.getReleases(params);
1369
+ const releases = await this.getReleases(params)
1370
1370
 
1371
- return findRefByLabel(releases, label);
1371
+ return findRefByLabel(releases, label)
1372
1372
  }
1373
1373
 
1374
1374
  /**
@@ -1378,19 +1378,19 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1378
1378
  */
1379
1379
  async getTags(params?: FetchParams): Promise<string[]> {
1380
1380
  try {
1381
- const tagsForm = await this.getCachedRepositoryForm("tags", params);
1381
+ const tagsForm = await this.getCachedRepositoryForm("tags", params)
1382
1382
 
1383
- const url = new URL(tagsForm.action);
1383
+ const url = new URL(tagsForm.action)
1384
1384
 
1385
1385
  if (this.accessToken) {
1386
- url.searchParams.set("access_token", this.accessToken);
1386
+ url.searchParams.set("access_token", this.accessToken)
1387
1387
  }
1388
1388
 
1389
- return await this.fetch<string[]>(url.toString(), params);
1389
+ return await this.fetch<string[]>(url.toString(), params)
1390
1390
  } catch {
1391
- const repository = await this.getRepository(params);
1391
+ const repository = await this.getRepository(params)
1392
1392
 
1393
- return repository.tags;
1393
+ return repository.tags
1394
1394
  }
1395
1395
  }
1396
1396
 
@@ -1407,12 +1407,12 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1407
1407
  ...params
1408
1408
  }: Partial<BuildQueryURLArgs> & FetchParams = {}): Promise<string> {
1409
1409
  const ref =
1410
- params.ref || (await this.getResolvedRefString({ signal, fetchOptions }));
1410
+ params.ref || (await this.getResolvedRefString({ signal, fetchOptions }))
1411
1411
  const integrationFieldsRef =
1412
1412
  params.integrationFieldsRef ||
1413
1413
  (await this.getCachedRepository({ signal, fetchOptions }))
1414
1414
  .integrationFieldsRef ||
1415
- undefined;
1415
+ undefined
1416
1416
 
1417
1417
  return buildQueryURL(this.endpoint, {
1418
1418
  ...this.defaultParams,
@@ -1422,7 +1422,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1422
1422
  routes: params.routes || this.routes,
1423
1423
  brokenRoute: params.brokenRoute || this.brokenRoute,
1424
1424
  accessToken: params.accessToken || this.accessToken,
1425
- });
1425
+ })
1426
1426
  }
1427
1427
 
1428
1428
  /**
@@ -1447,20 +1447,20 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1447
1447
  async resolvePreviewURL<LinkResolverReturnType>(
1448
1448
  args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams,
1449
1449
  ): Promise<string> {
1450
- let documentID: string | undefined | null = args.documentID;
1451
- let previewToken: string | undefined | null = args.previewToken;
1450
+ let documentID: string | undefined | null = args.documentID
1451
+ let previewToken: string | undefined | null = args.previewToken
1452
1452
 
1453
1453
  if (typeof globalThis.location !== "undefined") {
1454
- const searchParams = new URLSearchParams(globalThis.location.search);
1454
+ const searchParams = new URLSearchParams(globalThis.location.search)
1455
1455
 
1456
- documentID = documentID || searchParams.get("documentId");
1457
- previewToken = previewToken || searchParams.get("token");
1456
+ documentID = documentID || searchParams.get("documentId")
1457
+ previewToken = previewToken || searchParams.get("token")
1458
1458
  } else if (this.refState.httpRequest) {
1459
1459
  if ("query" in this.refState.httpRequest) {
1460
1460
  documentID =
1461
- documentID || (this.refState.httpRequest.query?.documentId as string);
1461
+ documentID || (this.refState.httpRequest.query?.documentId as string)
1462
1462
  previewToken =
1463
- previewToken || (this.refState.httpRequest.query?.token as string);
1463
+ previewToken || (this.refState.httpRequest.query?.token as string)
1464
1464
  } else if (
1465
1465
  "url" in this.refState.httpRequest &&
1466
1466
  this.refState.httpRequest.url
@@ -1473,10 +1473,10 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1473
1473
  const searchParams = new URL(
1474
1474
  this.refState.httpRequest.url,
1475
1475
  "missing-host://",
1476
- ).searchParams;
1476
+ ).searchParams
1477
1477
 
1478
- documentID = documentID || searchParams.get("documentId");
1479
- previewToken = previewToken || searchParams.get("token");
1478
+ documentID = documentID || searchParams.get("documentId")
1479
+ previewToken = previewToken || searchParams.get("token")
1480
1480
  }
1481
1481
  }
1482
1482
 
@@ -1486,16 +1486,16 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1486
1486
  lang: "*",
1487
1487
  signal: args.signal,
1488
1488
  fetchOptions: args.fetchOptions,
1489
- });
1489
+ })
1490
1490
 
1491
- const url = asLink(document, { linkResolver: args.linkResolver });
1491
+ const url = asLink(document, { linkResolver: args.linkResolver })
1492
1492
 
1493
1493
  if (typeof url === "string") {
1494
- return url;
1494
+ return url
1495
1495
  }
1496
1496
  }
1497
1497
 
1498
- return args.defaultURL;
1498
+ return args.defaultURL
1499
1499
  }
1500
1500
 
1501
1501
  /**
@@ -1508,12 +1508,12 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1508
1508
  * @example
1509
1509
  *
1510
1510
  * ```ts
1511
- * await client.queryLatestContent();
1512
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1511
+ * await client.queryLatestContent()
1512
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
1513
1513
  * ```
1514
1514
  */
1515
1515
  queryLatestContent(): void {
1516
- this.refState.mode = RefStateMode.Master;
1516
+ this.refState.mode = RefStateMode.Master
1517
1517
  }
1518
1518
 
1519
1519
  /**
@@ -1526,8 +1526,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1526
1526
  * @example
1527
1527
  *
1528
1528
  * ```ts
1529
- * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
1530
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1529
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa")
1530
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
1531
1531
  * ```
1532
1532
  *
1533
1533
  * @param releaseID - The ID of the Release.
@@ -1537,7 +1537,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1537
1537
  ...this.refState,
1538
1538
  mode: RefStateMode.ReleaseID,
1539
1539
  releaseID,
1540
- };
1540
+ }
1541
1541
  }
1542
1542
 
1543
1543
  /**
@@ -1550,8 +1550,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1550
1550
  * @example
1551
1551
  *
1552
1552
  * ```ts
1553
- * await client.queryContentFromReleaseByLabel("My Release");
1554
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1553
+ * await client.queryContentFromReleaseByLabel("My Release")
1554
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
1555
1555
  * ```
1556
1556
  *
1557
1557
  * @param releaseLabel - The label of the Release.
@@ -1561,7 +1561,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1561
1561
  ...this.refState,
1562
1562
  mode: RefStateMode.ReleaseLabel,
1563
1563
  releaseLabel,
1564
- };
1564
+ }
1565
1565
  }
1566
1566
 
1567
1567
  /**
@@ -1574,8 +1574,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1574
1574
  * @example
1575
1575
  *
1576
1576
  * ```ts
1577
- * await client.queryContentFromRef("my-ref");
1578
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1577
+ * await client.queryContentFromRef("my-ref")
1578
+ * const document = await client.getByID("WW4bKScAAMAqmluX")
1579
1579
  * ```
1580
1580
  *
1581
1581
  * @param ref - The ref or a function that returns the ref from which to query
@@ -1586,7 +1586,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1586
1586
  ...this.refState,
1587
1587
  mode: RefStateMode.Manual,
1588
1588
  ref,
1589
- };
1589
+ }
1590
1590
  }
1591
1591
 
1592
1592
  /**
@@ -1607,7 +1607,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1607
1607
  * useGETForQueries: true,
1608
1608
  * }),
1609
1609
  * cache: new InMemoryCache(),
1610
- * });
1610
+ * })
1611
1611
  * ```
1612
1612
  *
1613
1613
  * @param input - The `fetch()` `input` parameter. Only strings are supported.
@@ -1622,8 +1622,8 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1622
1622
  input: RequestInfo,
1623
1623
  init?: Omit<RequestInit, "signal"> & { signal?: AbortSignalLike },
1624
1624
  ): Promise<Response> {
1625
- const cachedRepository = await this.getCachedRepository();
1626
- const ref = await this.getResolvedRefString();
1625
+ const cachedRepository = await this.getCachedRepository()
1626
+ const ref = await this.getResolvedRefString()
1627
1627
 
1628
1628
  const unsanitizedHeaders: Record<string, string> = {
1629
1629
  "Prismic-ref": ref,
@@ -1632,21 +1632,21 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1632
1632
  // libraries pass this as a Record. Header objects as input
1633
1633
  // are unsupported.
1634
1634
  ...(init ? (init.headers as Record<string, string>) : {}),
1635
- };
1635
+ }
1636
1636
 
1637
1637
  if (cachedRepository.integrationFieldsRef) {
1638
1638
  unsanitizedHeaders["Prismic-integration-field-ref"] =
1639
- cachedRepository.integrationFieldsRef;
1639
+ cachedRepository.integrationFieldsRef
1640
1640
  }
1641
1641
 
1642
1642
  // Normalize header keys to lowercase. This prevents header
1643
1643
  // conflicts between the Prismic client and the GraphQL
1644
1644
  // client.
1645
- const headers: Record<string, string> = {};
1645
+ const headers: Record<string, string> = {}
1646
1646
  for (const key in unsanitizedHeaders) {
1647
1647
  if (unsanitizedHeaders[key]) {
1648
1648
  headers[key.toLowerCase()] =
1649
- unsanitizedHeaders[key as keyof typeof unsanitizedHeaders];
1649
+ unsanitizedHeaders[key as keyof typeof unsanitizedHeaders]
1650
1650
  }
1651
1651
  }
1652
1652
 
@@ -1655,7 +1655,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1655
1655
  // libraries pass this as a string. Request objects as
1656
1656
  // input are unsupported.
1657
1657
  input as string,
1658
- );
1658
+ )
1659
1659
 
1660
1660
  // This prevents the request from being cached unnecessarily.
1661
1661
  // Without adding this `ref` param, re-running a query
@@ -1665,9 +1665,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1665
1665
  // headers.
1666
1666
  //
1667
1667
  // The Prismic GraphQL API ignores the `ref` param.
1668
- url.searchParams.set("ref", ref);
1668
+ url.searchParams.set("ref", ref)
1669
1669
 
1670
- const query = url.searchParams.get("query");
1670
+ const query = url.searchParams.get("query")
1671
1671
  if (query) {
1672
1672
  url.searchParams.set(
1673
1673
  "query",
@@ -1677,13 +1677,13 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1677
1677
  // hitting the upper limit of GET requests
1678
1678
  // (2048 characters).
1679
1679
  minifyGraphQLQuery(query),
1680
- );
1680
+ )
1681
1681
  }
1682
1682
 
1683
1683
  return (await this.fetchFn(url.toString(), {
1684
1684
  ...init,
1685
1685
  headers,
1686
- })) as Response;
1686
+ })) as Response
1687
1687
  }
1688
1688
 
1689
1689
  /**
@@ -1696,11 +1696,11 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1696
1696
  !this.cachedRepository ||
1697
1697
  Date.now() >= this.cachedRepositoryExpiration
1698
1698
  ) {
1699
- this.cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL;
1700
- this.cachedRepository = await this.getRepository(params);
1699
+ this.cachedRepositoryExpiration = Date.now() + REPOSITORY_CACHE_TTL
1700
+ this.cachedRepository = await this.getRepository(params)
1701
1701
  }
1702
1702
 
1703
- return this.cachedRepository;
1703
+ return this.cachedRepository
1704
1704
  }
1705
1705
 
1706
1706
  /**
@@ -1717,18 +1717,18 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1717
1717
  name: string,
1718
1718
  params?: FetchParams,
1719
1719
  ): Promise<Form> {
1720
- const cachedRepository = await this.getCachedRepository(params);
1721
- const form = cachedRepository.forms[name];
1720
+ const cachedRepository = await this.getCachedRepository(params)
1721
+ const form = cachedRepository.forms[name]
1722
1722
 
1723
1723
  if (!form) {
1724
1724
  throw new PrismicError(
1725
1725
  `Form with name "${name}" could not be found`,
1726
1726
  undefined,
1727
1727
  undefined,
1728
- );
1728
+ )
1729
1729
  }
1730
1730
 
1731
- return form;
1731
+ return form
1732
1732
  }
1733
1733
 
1734
1734
  /**
@@ -1756,9 +1756,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1756
1756
  */
1757
1757
  private async getResolvedRefString(params?: FetchParams): Promise<string> {
1758
1758
  if (this.refState.autoPreviewsEnabled) {
1759
- let previewRef: string | undefined;
1759
+ let previewRef: string | undefined
1760
1760
 
1761
- let cookieJar: string | null | undefined;
1761
+ let cookieJar: string | null | undefined
1762
1762
 
1763
1763
  if (this.refState.httpRequest?.headers) {
1764
1764
  if (
@@ -1766,41 +1766,41 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1766
1766
  typeof this.refState.httpRequest.headers.get === "function"
1767
1767
  ) {
1768
1768
  // Web API Headers
1769
- cookieJar = this.refState.httpRequest.headers.get("cookie");
1769
+ cookieJar = this.refState.httpRequest.headers.get("cookie")
1770
1770
  } else if ("cookie" in this.refState.httpRequest.headers) {
1771
1771
  // Express-style headers
1772
- cookieJar = this.refState.httpRequest.headers.cookie;
1772
+ cookieJar = this.refState.httpRequest.headers.cookie
1773
1773
  }
1774
1774
  } else if (globalThis.document?.cookie) {
1775
- cookieJar = globalThis.document.cookie;
1775
+ cookieJar = globalThis.document.cookie
1776
1776
  }
1777
1777
 
1778
1778
  if (cookieJar) {
1779
- previewRef = getPreviewCookie(cookieJar);
1779
+ previewRef = getPreviewCookie(cookieJar)
1780
1780
  }
1781
1781
 
1782
1782
  if (previewRef) {
1783
- return previewRef;
1783
+ return previewRef
1784
1784
  }
1785
1785
  }
1786
1786
 
1787
- const cachedRepository = await this.getCachedRepository(params);
1787
+ const cachedRepository = await this.getCachedRepository(params)
1788
1788
 
1789
- const refModeType = this.refState.mode;
1789
+ const refModeType = this.refState.mode
1790
1790
  if (refModeType === RefStateMode.ReleaseID) {
1791
- return findRefByID(cachedRepository.refs, this.refState.releaseID).ref;
1791
+ return findRefByID(cachedRepository.refs, this.refState.releaseID).ref
1792
1792
  } else if (refModeType === RefStateMode.ReleaseLabel) {
1793
1793
  return findRefByLabel(cachedRepository.refs, this.refState.releaseLabel)
1794
- .ref;
1794
+ .ref
1795
1795
  } else if (refModeType === RefStateMode.Manual) {
1796
- const res = await castThunk(this.refState.ref)();
1796
+ const res = await castThunk(this.refState.ref)()
1797
1797
 
1798
1798
  if (typeof res === "string") {
1799
- return res;
1799
+ return res
1800
1800
  }
1801
1801
  }
1802
1802
 
1803
- return findMasterRef(cachedRepository.refs).ref;
1803
+ return findMasterRef(cachedRepository.refs).ref
1804
1804
  }
1805
1805
 
1806
1806
  /**
@@ -1830,9 +1830,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1830
1830
  params.fetchOptions?.signal ||
1831
1831
  params.signal ||
1832
1832
  this.fetchOptions?.signal,
1833
- };
1833
+ }
1834
1834
 
1835
- let job: Promise<FetchJobResult>;
1835
+ let job: Promise<FetchJobResult>
1836
1836
 
1837
1837
  // `fetchJobs` is keyed twice: first by the URL and again by is
1838
1838
  // signal, if one exists.
@@ -1841,9 +1841,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1841
1841
  // equivalent URLs, but eject when we detect unique signals.
1842
1842
  if (this.fetchJobs[url] && this.fetchJobs[url].has(requestInit.signal)) {
1843
1843
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1844
- job = this.fetchJobs[url].get(requestInit.signal)!;
1844
+ job = this.fetchJobs[url].get(requestInit.signal)!
1845
1845
  } else {
1846
- this.fetchJobs[url] = this.fetchJobs[url] || new Map();
1846
+ this.fetchJobs[url] = this.fetchJobs[url] || new Map()
1847
1847
 
1848
1848
  job = this.fetchFn(url, requestInit)
1849
1849
  .then(async (res) => {
@@ -1853,9 +1853,9 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1853
1853
  // throw, signaling an invalid
1854
1854
  // response.
1855
1855
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1856
- let json: any = undefined;
1856
+ let json: any = undefined
1857
1857
  try {
1858
- json = await res.json();
1858
+ json = await res.json()
1859
1859
  } catch {
1860
1860
  // noop
1861
1861
  }
@@ -1864,36 +1864,36 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1864
1864
  status: res.status,
1865
1865
  headers: res.headers,
1866
1866
  json,
1867
- };
1867
+ }
1868
1868
  })
1869
1869
  .finally(() => {
1870
- this.fetchJobs[url].delete(requestInit.signal);
1870
+ this.fetchJobs[url].delete(requestInit.signal)
1871
1871
 
1872
1872
  if (this.fetchJobs[url].size === 0) {
1873
- delete this.fetchJobs[url];
1873
+ delete this.fetchJobs[url]
1874
1874
  }
1875
- });
1875
+ })
1876
1876
 
1877
- this.fetchJobs[url].set(requestInit.signal, job);
1877
+ this.fetchJobs[url].set(requestInit.signal, job)
1878
1878
  }
1879
1879
 
1880
- const res = await job;
1880
+ const res = await job
1881
1881
 
1882
1882
  if (res.status !== 404 && res.json == null) {
1883
- throw new PrismicError(undefined, url, res.json);
1883
+ throw new PrismicError(undefined, url, res.json)
1884
1884
  }
1885
1885
 
1886
1886
  switch (res.status) {
1887
1887
  // Successful
1888
1888
  case 200: {
1889
- return res.json;
1889
+ return res.json
1890
1890
  }
1891
1891
 
1892
1892
  // Bad Request
1893
1893
  // - Invalid filter syntax
1894
1894
  // - Ref not provided (ignored)
1895
1895
  case 400: {
1896
- throw new ParsingError(res.json.message, url, res.json);
1896
+ throw new ParsingError(res.json.message, url, res.json)
1897
1897
  }
1898
1898
 
1899
1899
  // Unauthorized
@@ -1908,7 +1908,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1908
1908
  res.json.error || res.json.message,
1909
1909
  url,
1910
1910
  res.json,
1911
- );
1911
+ )
1912
1912
  }
1913
1913
 
1914
1914
  // Not Found
@@ -1921,49 +1921,49 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1921
1921
  `Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`,
1922
1922
  url,
1923
1923
  undefined,
1924
- );
1924
+ )
1925
1925
  }
1926
1926
 
1927
1927
  if (res.json.type === "api_notfound_error") {
1928
- throw new RefNotFoundError(res.json.message, url, res.json);
1928
+ throw new RefNotFoundError(res.json.message, url, res.json)
1929
1929
  }
1930
1930
 
1931
1931
  if (
1932
1932
  res.json.type === "api_security_error" &&
1933
1933
  /preview token.*expired/i.test(res.json.message)
1934
1934
  ) {
1935
- throw new PreviewTokenExpiredError(res.json.message, url, res.json);
1935
+ throw new PreviewTokenExpiredError(res.json.message, url, res.json)
1936
1936
  }
1937
1937
 
1938
- throw new NotFoundError(res.json.message, url, res.json);
1938
+ throw new NotFoundError(res.json.message, url, res.json)
1939
1939
  }
1940
1940
 
1941
1941
  // Gone
1942
1942
  // - Ref is expired
1943
1943
  case 410: {
1944
- throw new RefExpiredError(res.json.message, url, res.json);
1944
+ throw new RefExpiredError(res.json.message, url, res.json)
1945
1945
  }
1946
1946
 
1947
1947
  // Too Many Requests
1948
1948
  // - Exceeded the maximum number of requests per second
1949
1949
  case 429: {
1950
- const parsedRetryAfter = Number(res.headers.get("retry-after"));
1950
+ const parsedRetryAfter = Number(res.headers.get("retry-after"))
1951
1951
  const delay = Number.isNaN(parsedRetryAfter)
1952
1952
  ? DEFUALT_RETRY_AFTER_MS
1953
- : parsedRetryAfter;
1953
+ : parsedRetryAfter
1954
1954
 
1955
1955
  return await new Promise((resolve, reject) => {
1956
1956
  setTimeout(async () => {
1957
1957
  try {
1958
- resolve(await this.fetch(url, params));
1958
+ resolve(await this.fetch(url, params))
1959
1959
  } catch (error) {
1960
- reject(error);
1960
+ reject(error)
1961
1961
  }
1962
- }, delay);
1963
- });
1962
+ }, delay)
1963
+ })
1964
1964
  }
1965
1965
  }
1966
1966
 
1967
- throw new PrismicError(undefined, url, res.json);
1967
+ throw new PrismicError(undefined, url, res.json)
1968
1968
  }
1969
1969
  }