@prismicio/client 7.0.0-alpha.0 → 7.0.0-alpha.2

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 (396) hide show
  1. package/README.md +4 -4
  2. package/dist/buildQueryURL.cjs +26 -8
  3. package/dist/buildQueryURL.cjs.map +1 -1
  4. package/dist/buildQueryURL.d.ts +207 -130
  5. package/dist/buildQueryURL.js +25 -7
  6. package/dist/buildQueryURL.js.map +1 -1
  7. package/dist/cookie.cjs +1 -1
  8. package/dist/cookie.cjs.map +1 -1
  9. package/dist/cookie.d.ts +5 -5
  10. package/dist/cookie.js.map +1 -1
  11. package/dist/createClient.cjs +1142 -0
  12. package/dist/createClient.cjs.map +1 -0
  13. package/dist/{client.d.ts → createClient.d.ts} +980 -908
  14. package/dist/createClient.js +1142 -0
  15. package/dist/createClient.js.map +1 -0
  16. package/dist/{ForbiddenError.cjs → errors/ForbiddenError.cjs} +1 -1
  17. package/dist/errors/ForbiddenError.cjs.map +1 -0
  18. package/dist/{ForbiddenError.d.ts → errors/ForbiddenError.d.ts} +11 -11
  19. package/dist/errors/ForbiddenError.js.map +1 -0
  20. package/dist/{NotFoundError.cjs → errors/NotFoundError.cjs} +1 -1
  21. package/dist/errors/NotFoundError.cjs.map +1 -0
  22. package/dist/{NotFoundError.d.ts → errors/NotFoundError.d.ts} +3 -3
  23. package/dist/errors/NotFoundError.js.map +1 -0
  24. package/dist/{ParsingError.cjs → errors/ParsingError.cjs} +1 -1
  25. package/dist/errors/ParsingError.cjs.map +1 -0
  26. package/dist/{ParsingError.d.ts → errors/ParsingError.d.ts} +12 -12
  27. package/dist/errors/ParsingError.js.map +1 -0
  28. package/dist/{PrismicError.cjs → errors/PrismicError.cjs} +1 -1
  29. package/dist/errors/PrismicError.cjs.map +1 -0
  30. package/dist/{PrismicError.d.ts → errors/PrismicError.d.ts} +5 -5
  31. package/dist/errors/PrismicError.js.map +1 -0
  32. package/dist/filter.cjs +247 -0
  33. package/dist/filter.cjs.map +1 -0
  34. package/dist/filter.d.ts +209 -0
  35. package/dist/filter.js +247 -0
  36. package/dist/filter.js.map +1 -0
  37. package/dist/getGraphQLEndpoint.cjs +2 -2
  38. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  39. package/dist/getGraphQLEndpoint.d.ts +9 -9
  40. package/dist/getGraphQLEndpoint.js +1 -1
  41. package/dist/getGraphQLEndpoint.js.map +1 -1
  42. package/dist/getRepositoryEndpoint.cjs +2 -2
  43. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  44. package/dist/getRepositoryEndpoint.d.ts +10 -10
  45. package/dist/getRepositoryEndpoint.js +1 -1
  46. package/dist/getRepositoryEndpoint.js.map +1 -1
  47. package/dist/getRepositoryName.cjs +2 -2
  48. package/dist/getRepositoryName.cjs.map +1 -1
  49. package/dist/getRepositoryName.d.ts +13 -13
  50. package/dist/getRepositoryName.js +1 -1
  51. package/dist/getRepositoryName.js.map +1 -1
  52. package/dist/getToolbarSrc.cjs +13 -0
  53. package/dist/getToolbarSrc.cjs.map +1 -0
  54. package/dist/getToolbarSrc.d.ts +34 -0
  55. package/dist/getToolbarSrc.js +13 -0
  56. package/dist/getToolbarSrc.js.map +1 -0
  57. package/dist/helpers/asDate.cjs +1 -1
  58. package/dist/helpers/asDate.cjs.map +1 -1
  59. package/dist/helpers/asDate.d.ts +16 -16
  60. package/dist/helpers/asDate.js.map +1 -1
  61. package/dist/helpers/asHTML.cjs +7 -6
  62. package/dist/helpers/asHTML.cjs.map +1 -1
  63. package/dist/helpers/asHTML.d.ts +77 -20
  64. package/dist/helpers/asHTML.js +6 -5
  65. package/dist/helpers/asHTML.js.map +1 -1
  66. package/dist/helpers/asImagePixelDensitySrcSet.cjs +1 -1
  67. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  68. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +52 -52
  69. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  70. package/dist/helpers/asImageSrc.cjs +1 -1
  71. package/dist/helpers/asImageSrc.cjs.map +1 -1
  72. package/dist/helpers/asImageSrc.d.ts +27 -27
  73. package/dist/helpers/asImageSrc.js.map +1 -1
  74. package/dist/helpers/asImageWidthSrcSet.cjs +19 -14
  75. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  76. package/dist/helpers/asImageWidthSrcSet.d.ts +60 -60
  77. package/dist/helpers/asImageWidthSrcSet.js +18 -13
  78. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  79. package/dist/helpers/asLink.cjs +8 -2
  80. package/dist/helpers/asLink.cjs.map +1 -1
  81. package/dist/helpers/asLink.d.ts +34 -24
  82. package/dist/helpers/asLink.js +7 -1
  83. package/dist/helpers/asLink.js.map +1 -1
  84. package/dist/helpers/asLinkAttrs.cjs +28 -0
  85. package/dist/helpers/asLinkAttrs.cjs.map +1 -0
  86. package/dist/helpers/asLinkAttrs.d.ts +63 -0
  87. package/dist/helpers/asLinkAttrs.js +28 -0
  88. package/dist/helpers/asLinkAttrs.js.map +1 -0
  89. package/dist/helpers/asText.cjs +1 -1
  90. package/dist/helpers/asText.cjs.map +1 -1
  91. package/dist/helpers/asText.d.ts +16 -16
  92. package/dist/helpers/asText.js.map +1 -1
  93. package/dist/helpers/documentToLinkField.cjs +12 -5
  94. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  95. package/dist/helpers/documentToLinkField.d.ts +15 -15
  96. package/dist/helpers/documentToLinkField.js +11 -4
  97. package/dist/helpers/documentToLinkField.js.map +1 -1
  98. package/dist/helpers/isFilled.cjs +1 -1
  99. package/dist/helpers/isFilled.cjs.map +1 -1
  100. package/dist/helpers/isFilled.d.ts +172 -175
  101. package/dist/helpers/isFilled.js.map +1 -1
  102. package/dist/index.cjs +20 -14
  103. package/dist/index.cjs.map +1 -1
  104. package/dist/index.d.ts +139 -92
  105. package/dist/index.js +12 -6
  106. package/dist/index.js.map +1 -1
  107. package/dist/isRepositoryEndpoint.cjs +1 -1
  108. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  109. package/dist/isRepositoryEndpoint.d.ts +10 -10
  110. package/dist/isRepositoryEndpoint.js.map +1 -1
  111. package/dist/isRepositoryName.cjs +1 -1
  112. package/dist/isRepositoryName.cjs.map +1 -1
  113. package/dist/isRepositoryName.d.ts +9 -9
  114. package/dist/isRepositoryName.js.map +1 -1
  115. package/dist/lib/appendFilters.cjs +11 -0
  116. package/dist/lib/appendFilters.cjs.map +1 -0
  117. package/dist/lib/appendFilters.d.ts +18 -0
  118. package/dist/lib/appendFilters.js +11 -0
  119. package/dist/lib/appendFilters.js.map +1 -0
  120. package/dist/lib/castArray.cjs +4 -2
  121. package/dist/lib/castArray.cjs.map +1 -1
  122. package/dist/lib/castArray.d.ts +11 -11
  123. package/dist/lib/castArray.js +3 -1
  124. package/dist/lib/castArray.js.map +1 -1
  125. package/dist/lib/castThunk.cjs +4 -2
  126. package/dist/lib/castThunk.cjs.map +1 -1
  127. package/dist/lib/castThunk.d.ts +10 -10
  128. package/dist/lib/castThunk.js +3 -1
  129. package/dist/lib/castThunk.js.map +1 -1
  130. package/dist/lib/devMsg.cjs +8 -0
  131. package/dist/lib/devMsg.cjs.map +1 -0
  132. package/dist/lib/devMsg.d.ts +16 -0
  133. package/dist/lib/devMsg.js +8 -0
  134. package/dist/lib/devMsg.js.map +1 -0
  135. package/dist/lib/escapeHTML.cjs +43 -0
  136. package/dist/lib/escapeHTML.cjs.map +1 -0
  137. package/dist/lib/escapeHTML.d.ts +1 -0
  138. package/dist/lib/escapeHTML.js +43 -0
  139. package/dist/lib/escapeHTML.js.map +1 -0
  140. package/dist/lib/everyTagFilter.cjs +9 -0
  141. package/dist/lib/everyTagFilter.cjs.map +1 -0
  142. package/dist/lib/everyTagFilter.d.ts +9 -0
  143. package/dist/lib/everyTagFilter.js +9 -0
  144. package/dist/lib/everyTagFilter.js.map +1 -0
  145. package/dist/lib/findMasterRef.cjs +1 -1
  146. package/dist/lib/findMasterRef.cjs.map +1 -1
  147. package/dist/lib/findMasterRef.d.ts +10 -10
  148. package/dist/lib/findMasterRef.js.map +1 -1
  149. package/dist/lib/findRef.cjs +4 -4
  150. package/dist/lib/findRef.cjs.map +1 -1
  151. package/dist/lib/findRef.d.ts +13 -13
  152. package/dist/lib/findRef.js +3 -3
  153. package/dist/lib/findRef.js.map +1 -1
  154. package/dist/lib/findRefByID.cjs +1 -1
  155. package/dist/lib/findRefByID.cjs.map +1 -1
  156. package/dist/lib/findRefByID.d.ts +11 -11
  157. package/dist/lib/findRefByID.js.map +1 -1
  158. package/dist/lib/findRefByLabel.cjs +1 -1
  159. package/dist/lib/findRefByLabel.cjs.map +1 -1
  160. package/dist/lib/findRefByLabel.d.ts +11 -11
  161. package/dist/lib/findRefByLabel.js.map +1 -1
  162. package/dist/lib/getPreviewCookie.cjs +1 -1
  163. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  164. package/dist/lib/getPreviewCookie.d.ts +9 -9
  165. package/dist/lib/getPreviewCookie.js.map +1 -1
  166. package/dist/lib/isInternalURL.cjs +9 -0
  167. package/dist/lib/isInternalURL.cjs.map +1 -0
  168. package/dist/lib/isInternalURL.d.ts +8 -0
  169. package/dist/lib/isInternalURL.js +9 -0
  170. package/dist/lib/isInternalURL.js.map +1 -0
  171. package/dist/lib/minifyGraphQLQuery.cjs +1 -1
  172. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  173. package/dist/lib/minifyGraphQLQuery.d.ts +8 -8
  174. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  175. package/dist/lib/serializerHelpers.cjs +7 -9
  176. package/dist/lib/serializerHelpers.cjs.map +1 -1
  177. package/dist/lib/serializerHelpers.d.ts +9 -9
  178. package/dist/lib/serializerHelpers.js +6 -6
  179. package/dist/lib/serializerHelpers.js.map +1 -1
  180. package/dist/lib/someTagsFilter.cjs +9 -0
  181. package/dist/lib/someTagsFilter.cjs.map +1 -0
  182. package/dist/lib/someTagsFilter.d.ts +9 -0
  183. package/dist/lib/someTagsFilter.js +9 -0
  184. package/dist/lib/someTagsFilter.js.map +1 -0
  185. package/dist/lib/typeFilter.cjs +8 -0
  186. package/dist/lib/typeFilter.cjs.map +1 -0
  187. package/dist/lib/typeFilter.d.ts +8 -0
  188. package/dist/lib/typeFilter.js +8 -0
  189. package/dist/lib/typeFilter.js.map +1 -0
  190. package/dist/package.json.cjs +5 -0
  191. package/dist/package.json.cjs.map +1 -0
  192. package/dist/package.json.js +5 -0
  193. package/dist/package.json.js.map +1 -0
  194. package/dist/types/api/query.d.ts +42 -42
  195. package/dist/types/api/ref.d.ts +32 -32
  196. package/dist/types/api/release.d.ts +10 -10
  197. package/dist/types/api/repository.d.ts +100 -100
  198. package/dist/types/api/tags.d.ts +8 -8
  199. package/dist/types/model/boolean.d.ts +15 -15
  200. package/dist/types/model/color.d.ts +13 -13
  201. package/dist/types/model/contentRelationship.d.ts +18 -18
  202. package/dist/types/model/customType.d.ts +42 -42
  203. package/dist/types/model/date.d.ts +14 -14
  204. package/dist/types/model/embed.d.ts +13 -13
  205. package/dist/types/model/geoPoint.d.ts +12 -12
  206. package/dist/types/model/group.d.ts +15 -15
  207. package/dist/types/model/image.d.ts +31 -31
  208. package/dist/types/model/integrationFields.d.ts +14 -14
  209. package/dist/types/model/keyText.d.ts +13 -13
  210. package/dist/types/model/link.cjs +1 -1
  211. package/dist/types/model/link.cjs.map +1 -1
  212. package/dist/types/model/link.d.ts +27 -27
  213. package/dist/types/model/link.js.map +1 -1
  214. package/dist/types/model/linkToMedia.d.ts +16 -16
  215. package/dist/types/model/number.d.ts +15 -15
  216. package/dist/types/model/range.d.ts +14 -14
  217. package/dist/types/model/richText.d.ts +35 -35
  218. package/dist/types/model/select.d.ts +18 -18
  219. package/dist/types/model/separator.d.ts +10 -10
  220. package/dist/types/model/sharedSlice.d.ts +16 -19
  221. package/dist/types/model/sharedSliceVariation.d.ts +19 -22
  222. package/dist/types/model/slice.cjs +1 -1
  223. package/dist/types/model/slice.cjs.map +1 -1
  224. package/dist/types/model/slice.d.ts +33 -33
  225. package/dist/types/model/slice.js.map +1 -1
  226. package/dist/types/model/sliceZone.cjs +1 -1
  227. package/dist/types/model/sliceZone.cjs.map +1 -1
  228. package/dist/types/model/sliceZone.d.ts +41 -44
  229. package/dist/types/model/sliceZone.js.map +1 -1
  230. package/dist/types/model/timestamp.d.ts +14 -14
  231. package/dist/types/model/title.d.ts +7 -7
  232. package/dist/types/model/types.cjs +10 -1
  233. package/dist/types/model/types.cjs.map +1 -1
  234. package/dist/types/model/types.d.ts +62 -62
  235. package/dist/types/model/types.js +9 -0
  236. package/dist/types/model/types.js.map +1 -1
  237. package/dist/types/model/uid.d.ts +13 -13
  238. package/dist/types/value/boolean.d.ts +6 -6
  239. package/dist/types/value/color.d.ts +8 -8
  240. package/dist/types/value/contentRelationship.d.ts +29 -29
  241. package/dist/types/value/date.d.ts +8 -8
  242. package/dist/types/value/document.d.ts +113 -113
  243. package/dist/types/value/embed.cjs +1 -1
  244. package/dist/types/value/embed.cjs.map +1 -1
  245. package/dist/types/value/embed.d.ts +167 -167
  246. package/dist/types/value/embed.js.map +1 -1
  247. package/dist/types/value/geoPoint.d.ts +11 -11
  248. package/dist/types/value/group.d.ts +7 -7
  249. package/dist/types/value/image.d.ts +36 -36
  250. package/dist/types/value/integrationFields.d.ts +9 -9
  251. package/dist/types/value/keyText.d.ts +8 -8
  252. package/dist/types/value/link.cjs +1 -1
  253. package/dist/types/value/link.cjs.map +1 -1
  254. package/dist/types/value/link.d.ts +40 -40
  255. package/dist/types/value/link.js.map +1 -1
  256. package/dist/types/value/linkToMedia.d.ts +20 -20
  257. package/dist/types/value/number.d.ts +8 -8
  258. package/dist/types/value/richText.cjs +1 -1
  259. package/dist/types/value/richText.cjs.map +1 -1
  260. package/dist/types/value/richText.d.ts +203 -203
  261. package/dist/types/value/richText.js.map +1 -1
  262. package/dist/types/value/select.d.ts +9 -9
  263. package/dist/types/value/sharedSlice.d.ts +11 -11
  264. package/dist/types/value/sharedSliceVariation.d.ts +7 -7
  265. package/dist/types/value/slice.d.ts +13 -13
  266. package/dist/types/value/sliceZone.d.ts +12 -12
  267. package/dist/types/value/timestamp.d.ts +8 -8
  268. package/dist/types/value/title.d.ts +12 -12
  269. package/dist/types/value/types.d.ts +40 -40
  270. package/dist/types/webhook/apiUpdate.d.ts +52 -52
  271. package/dist/types/webhook/testTrigger.d.ts +9 -9
  272. package/dist/types/webhook/types.cjs +1 -1
  273. package/dist/types/webhook/types.cjs.map +1 -1
  274. package/dist/types/webhook/types.d.ts +18 -18
  275. package/dist/types/webhook/types.js.map +1 -1
  276. package/package.json +23 -24
  277. package/src/buildQueryURL.ts +179 -33
  278. package/src/{client.ts → createClient.ts} +214 -110
  279. package/src/filter.ts +356 -0
  280. package/src/getGraphQLEndpoint.ts +2 -1
  281. package/src/getRepositoryEndpoint.ts +2 -1
  282. package/src/getRepositoryName.ts +1 -1
  283. package/src/getToolbarSrc.ts +50 -0
  284. package/src/helpers/asDate.ts +3 -3
  285. package/src/helpers/asHTML.ts +122 -27
  286. package/src/helpers/asImagePixelDensitySrcSet.ts +1 -1
  287. package/src/helpers/asImageSrc.ts +1 -1
  288. package/src/helpers/asImageWidthSrcSet.ts +1 -1
  289. package/src/helpers/asLink.ts +37 -18
  290. package/src/helpers/asLinkAttrs.ts +127 -0
  291. package/src/helpers/asText.ts +4 -4
  292. package/src/helpers/documentToLinkField.ts +3 -3
  293. package/src/helpers/isFilled.ts +9 -11
  294. package/src/index.ts +60 -29
  295. package/src/lib/appendFilters.ts +26 -0
  296. package/src/lib/castArray.ts +3 -1
  297. package/src/lib/castThunk.ts +3 -2
  298. package/src/lib/devMsg.ts +20 -0
  299. package/src/lib/escapeHTML.ts +51 -0
  300. package/src/lib/everyTagFilter.ts +15 -0
  301. package/src/lib/findRef.ts +5 -5
  302. package/src/lib/isInternalURL.ts +14 -0
  303. package/src/lib/serializerHelpers.ts +20 -15
  304. package/src/lib/someTagsFilter.ts +15 -0
  305. package/src/lib/typeFilter.ts +12 -0
  306. package/src/types/api/query.ts +1 -1
  307. package/src/types/api/ref.ts +2 -2
  308. package/src/types/api/release.ts +1 -1
  309. package/src/types/api/repository.ts +1 -1
  310. package/src/types/api/tags.ts +1 -1
  311. package/src/types/model/boolean.ts +1 -1
  312. package/src/types/model/color.ts +1 -1
  313. package/src/types/model/contentRelationship.ts +2 -1
  314. package/src/types/model/date.ts +1 -1
  315. package/src/types/model/embed.ts +1 -1
  316. package/src/types/model/geoPoint.ts +1 -1
  317. package/src/types/model/group.ts +2 -2
  318. package/src/types/model/image.ts +3 -3
  319. package/src/types/model/integrationFields.ts +1 -1
  320. package/src/types/model/keyText.ts +1 -1
  321. package/src/types/model/link.ts +3 -3
  322. package/src/types/model/linkToMedia.ts +2 -1
  323. package/src/types/model/number.ts +1 -1
  324. package/src/types/model/richText.ts +3 -3
  325. package/src/types/model/select.ts +1 -1
  326. package/src/types/model/sharedSlice.ts +2 -5
  327. package/src/types/model/sharedSliceVariation.ts +1 -4
  328. package/src/types/model/slice.ts +5 -4
  329. package/src/types/model/sliceZone.ts +5 -7
  330. package/src/types/model/timestamp.ts +1 -1
  331. package/src/types/model/title.ts +1 -1
  332. package/src/types/model/types.ts +12 -16
  333. package/src/types/model/uid.ts +1 -1
  334. package/src/types/value/boolean.ts +1 -1
  335. package/src/types/value/color.ts +1 -1
  336. package/src/types/value/contentRelationship.ts +8 -9
  337. package/src/types/value/date.ts +1 -1
  338. package/src/types/value/document.ts +6 -5
  339. package/src/types/value/embed.ts +2 -2
  340. package/src/types/value/geoPoint.ts +1 -1
  341. package/src/types/value/group.ts +2 -2
  342. package/src/types/value/image.ts +1 -1
  343. package/src/types/value/integrationFields.ts +1 -1
  344. package/src/types/value/keyText.ts +1 -1
  345. package/src/types/value/link.ts +8 -8
  346. package/src/types/value/linkToMedia.ts +2 -1
  347. package/src/types/value/number.ts +1 -1
  348. package/src/types/value/richText.ts +6 -5
  349. package/src/types/value/select.ts +1 -1
  350. package/src/types/value/sharedSlice.ts +1 -1
  351. package/src/types/value/slice.ts +1 -1
  352. package/src/types/value/sliceZone.ts +2 -1
  353. package/src/types/value/timestamp.ts +1 -0
  354. package/src/types/value/title.ts +2 -1
  355. package/src/types/value/types.ts +9 -11
  356. package/src/types/webhook/apiUpdate.ts +4 -4
  357. package/src/types/webhook/testTrigger.ts +1 -1
  358. package/src/types/webhook/types.ts +2 -2
  359. package/dist/ForbiddenError.cjs.map +0 -1
  360. package/dist/ForbiddenError.js.map +0 -1
  361. package/dist/NotFoundError.cjs.map +0 -1
  362. package/dist/NotFoundError.js.map +0 -1
  363. package/dist/ParsingError.cjs.map +0 -1
  364. package/dist/ParsingError.js.map +0 -1
  365. package/dist/PrismicError.cjs.map +0 -1
  366. package/dist/PrismicError.js.map +0 -1
  367. package/dist/client.cjs +0 -414
  368. package/dist/client.cjs.map +0 -1
  369. package/dist/client.js +0 -414
  370. package/dist/client.js.map +0 -1
  371. package/dist/lib/appendPredicates.cjs +0 -14
  372. package/dist/lib/appendPredicates.cjs.map +0 -1
  373. package/dist/lib/appendPredicates.d.ts +0 -18
  374. package/dist/lib/appendPredicates.js +0 -14
  375. package/dist/lib/appendPredicates.js.map +0 -1
  376. package/dist/predicate.cjs +0 -68
  377. package/dist/predicate.cjs.map +0 -1
  378. package/dist/predicate.d.ts +0 -209
  379. package/dist/predicate.js +0 -68
  380. package/dist/predicate.js.map +0 -1
  381. package/dist/types/client.d.ts +0 -128
  382. package/dist/types/helpers.d.ts +0 -63
  383. package/dist/types/utils.d.ts +0 -28
  384. package/src/lib/appendPredicates.ts +0 -29
  385. package/src/predicate.ts +0 -359
  386. package/src/types/client.ts +0 -157
  387. package/src/types/helpers.ts +0 -103
  388. package/src/types/utils.ts +0 -34
  389. /package/dist/{ForbiddenError.js → errors/ForbiddenError.js} +0 -0
  390. /package/dist/{NotFoundError.js → errors/NotFoundError.js} +0 -0
  391. /package/dist/{ParsingError.js → errors/ParsingError.js} +0 -0
  392. /package/dist/{PrismicError.js → errors/PrismicError.js} +0 -0
  393. /package/src/{ForbiddenError.ts → errors/ForbiddenError.ts} +0 -0
  394. /package/src/{NotFoundError.ts → errors/NotFoundError.ts} +0 -0
  395. /package/src/{ParsingError.ts → errors/ParsingError.ts} +0 -0
  396. /package/src/{PrismicError.ts → errors/PrismicError.ts} +0 -0
@@ -1,908 +1,980 @@
1
- import type { AbortSignalLike, FetchLike, HttpRequestLike, ExtractDocumentType } from "./types/client";
2
- import type { LinkResolverFunction } from "./types/helpers";
3
- import type { PrismicDocument } from "./types/value/document";
4
- import type { Repository } from "./types/api/repository";
5
- import type { Query } from "./types/api/query";
6
- import type { Ref } from "./types/api/ref";
7
- import { BuildQueryURLArgs } from "./buildQueryURL";
8
- /**
9
- * The number of milliseconds in which repository metadata is considered valid.
10
- * A ref can be invalidated quickly depending on how frequently content is
11
- * updated in the Prismic repository. As such, repository's metadata can only be
12
- * considered valid for a short amount of time.
13
- */
14
- export declare const REPOSITORY_CACHE_TTL = 5000;
15
- /**
16
- * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
17
- * `getAllByType`, `getAllByTag`) will wait between individual page requests.
18
- *
19
- * This is done to ensure API performance is sustainable and reduces the chance
20
- * of a failed API request due to overloading.
21
- */
22
- export declare const GET_ALL_QUERY_DELAY = 500;
23
- /**
24
- * A ref or a function that returns a ref. If a static ref is known, one can be
25
- * given. If the ref must be fetched on-demand, a function can be provided. This
26
- * function can optionally be asynchronous.
27
- */
28
- declare type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
29
- /**
30
- * Configuration for clients that determine how content is queried.
31
- */
32
- export declare type ClientConfig = {
33
- /**
34
- * The secure token for accessing the Prismic repository. This is only
35
- * required if the repository is set to private.
36
- */
37
- accessToken?: string;
38
- /**
39
- * A string representing a version of the Prismic repository's content. This
40
- * may point to the latest version (called the "master ref"), or a preview
41
- * with draft content.
42
- */
43
- ref?: RefStringOrThunk;
44
- /**
45
- * A list of Route Resolver objects that define how a document's `url` field
46
- * is resolved.
47
- *
48
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
49
- */
50
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
51
- /**
52
- * The `brokenRoute` option allows you to define the route populated in the
53
- * `url` property for broken Link or Content Relationship fields. A broken
54
- * link is a Link or Content Relationship field whose linked document has been
55
- * unpublished or deleted.
56
- *
57
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
58
- */
59
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
60
- /**
61
- * Default parameters that will be sent with each query. These parameters can
62
- * be overridden on each query if needed.
63
- */
64
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute">;
65
- /**
66
- * The function used to make network requests to the Prismic REST API. In
67
- * environments where a global `fetch` function does not exist, such as
68
- * Node.js, this function must be provided.
69
- */
70
- fetch?: FetchLike;
71
- };
72
- /**
73
- * Parameters for any client method that use `fetch()`. Only a subset of
74
- * `fetch()` parameters are exposed.
75
- */
76
- declare type FetchParams = {
77
- /**
78
- * An `AbortSignal` provided by an `AbortController`. This allows the network
79
- * request to be cancelled if necessary.
80
- *
81
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
82
- */
83
- signal?: AbortSignalLike;
84
- };
85
- /**
86
- * Parameters specific to client methods that fetch all documents. These methods
87
- * start with `getAll` (for example, `getAllByType`).
88
- */
89
- declare type GetAllParams = {
90
- /**
91
- * Limit the number of documents queried. If a number is not provided, there
92
- * will be no limit and all matching documents will be returned.
93
- */
94
- limit?: number;
95
- };
96
- /**
97
- * Arguments to determine how the URL for a preview session is resolved.
98
- */
99
- declare type ResolvePreviewArgs<LinkResolverReturnType> = {
100
- /**
101
- * A function that maps a Prismic document to a URL within your app.
102
- */
103
- linkResolver?: LinkResolverFunction<LinkResolverReturnType>;
104
- /**
105
- * A fallback URL if the Link Resolver does not return a value.
106
- */
107
- defaultURL: string;
108
- /**
109
- * The preview token (also known as a ref) that will be used to query preview
110
- * content from the Prismic repository.
111
- */
112
- previewToken?: string;
113
- /**
114
- * The previewed document that will be used to determine the destination URL.
115
- */
116
- documentID?: string;
117
- };
118
- /**
119
- * Type definitions for the `createClient()` function. May be augmented by
120
- * third-party libraries.
121
- */
122
- export interface CreateClient {
123
- <TDocuments extends PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
124
- }
125
- /**
126
- * Creates a Prismic client that can be used to query a repository.
127
- *
128
- * @example
129
- *
130
- * ```ts
131
- * // With a repository name.
132
- * createClient("qwerty");
133
- *
134
- * // Or with a full Prismic Rest API V2 endpoint.
135
- * createClient("https://qwerty.cdn.prismic.io/api/v2");
136
- * ```
137
- *
138
- * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
139
- * TypeScript type.
140
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
141
- * API V2 endpoint for the repository.
142
- * @param options - Configuration that determines how content will be queried
143
- * from the Prismic repository.
144
- *
145
- * @returns A client that can query content from the repository.
146
- */
147
- export declare const createClient: CreateClient;
148
- /**
149
- * A client that allows querying content from a Prismic repository.
150
- *
151
- * If used in an environment where a global `fetch` function is unavailable,
152
- * such as Node.js, the `fetch` option must be provided as part of the `options`
153
- * parameter.
154
- *
155
- * @typeParam TDocuments - Document types that are registered for the Prismic
156
- * repository. Query methods will automatically be typed based on this type.
157
- */
158
- export declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
159
- /**
160
- * The Prismic REST API V2 endpoint for the repository (use
161
- * `prismic.getRepositoryEndpoint` for the default endpoint).
162
- */
163
- endpoint: string;
164
- /**
165
- * The secure token for accessing the API (only needed if your repository is
166
- * set to private).
167
- *
168
- * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
169
- */
170
- accessToken?: string;
171
- /**
172
- * A list of Route Resolver objects that define how a document's `url` field
173
- * is resolved.
174
- *
175
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
176
- */
177
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
178
- /**
179
- * The `brokenRoute` option allows you to define the route populated in the
180
- * `url` property for broken Link or Content Relationship fields. A broken
181
- * link is a Link or Content Relationship field whose linked document has been
182
- * unpublished or deleted.
183
- *
184
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
185
- */
186
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
187
- /**
188
- * The function used to make network requests to the Prismic REST API. In
189
- * environments where a global `fetch` function does not exist, such as
190
- * Node.js, this function must be provided.
191
- */
192
- fetchFn: FetchLike;
193
- /**
194
- * Default parameters that will be sent with each query. These parameters can
195
- * be overridden on each query if needed.
196
- */
197
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
198
- /**
199
- * The client's ref mode state. This determines which ref is used during
200
- * queries.
201
- */
202
- private refState;
203
- /**
204
- * Cached repository value.
205
- */
206
- private cachedRepository;
207
- /**
208
- * Timestamp at which the cached repository data is considered stale.
209
- */
210
- private cachedRepositoryExpiration;
211
- /**
212
- * Creates a Prismic client that can be used to query a repository.
213
- *
214
- * If used in an environment where a global `fetch` function is unavailable,
215
- * such as Node.js, the `fetch` option must be provided as part of the
216
- * `options` parameter.
217
- *
218
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
219
- * API V2 endpoint for the repository.
220
- * @param options - Configuration that determines how content will be queried
221
- * from the Prismic repository.
222
- *
223
- * @returns A client that can query content from the repository.
224
- */
225
- constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
226
- /**
227
- * Enables the client to automatically query content from a preview session if
228
- * one is active in browser environments. This is enabled by default in the
229
- * browser.
230
- *
231
- * For server environments, use `enableAutoPreviewsFromReq`.
232
- *
233
- * @example
234
- *
235
- * ```ts
236
- * client.enableAutoPreviews();
237
- * ```
238
- *
239
- * @see enableAutoPreviewsFromReq
240
- */
241
- enableAutoPreviews(): void;
242
- /**
243
- * Enables the client to automatically query content from a preview session if
244
- * one is active in server environments. This is disabled by default on the
245
- * server.
246
- *
247
- * For browser environments, use `enableAutoPreviews`.
248
- *
249
- * @example
250
- *
251
- * ```ts
252
- * // In an express app
253
- * app.get("/", function (req, res) {
254
- * client.enableAutoPreviewsFromReq(req);
255
- * });
256
- * ```
257
- *
258
- * @param req - An HTTP server request object containing the request's
259
- * cookies.
260
- */
261
- enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void;
262
- /**
263
- * Disables the client from automatically querying content from a preview
264
- * session if one is active.
265
- *
266
- * Automatic preview content querying is enabled by default unless this method
267
- * is called.
268
- *
269
- * @example
270
- *
271
- * ```ts
272
- * client.disableAutoPreviews();
273
- * ```
274
- */
275
- disableAutoPreviews(): void;
276
- /**
277
- * Queries content from the Prismic repository.
278
- *
279
- * @example
280
- *
281
- * ```ts
282
- * const response = await client.get();
283
- * ```
284
- *
285
- * @typeParam TDocument - Type of Prismic documents returned.
286
- * @param params - Parameters to filter, sort, and paginate results.
287
- *
288
- * @returns A paginated response containing the result of the query.
289
- */
290
- get<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
291
- /**
292
- * Queries content from the Prismic repository and returns only the first
293
- * result, if any.
294
- *
295
- * @example
296
- *
297
- * ```ts
298
- * const document = await client.getFirst();
299
- * ```
300
- *
301
- * @typeParam TDocument - Type of the Prismic document returned.
302
- * @param params - Parameters to filter, sort, and paginate results. @returns
303
- * The first result of the query, if any.
304
- */
305
- getFirst<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
306
- /**
307
- * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
308
- * require more resources than other methods. Prefer using other methods that
309
- * filter by predicates such as `getAllByType`.
310
- *
311
- * Queries content from the Prismic repository and returns all matching
312
- * content. If no predicates are provided, all documents will be fetched.
313
- *
314
- * This method may make multiple network requests to query all matching
315
- * content.
316
- *
317
- * @example
318
- *
319
- * ```ts
320
- * const response = await client.dangerouslyGetAll();
321
- * ```
322
- *
323
- * @typeParam TDocument - Type of Prismic documents returned.
324
- * @param params - Parameters to filter, sort, and paginate results.
325
- *
326
- * @returns A list of documents matching the query.
327
- */
328
- dangerouslyGetAll<TDocument extends TDocuments>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
329
- /**
330
- * Queries a document from the Prismic repository with a specific ID.
331
- *
332
- * @remarks
333
- * A document's UID is different from its ID. An ID is automatically generated
334
- * for all documents and is made available on its `id` property. A UID is
335
- * provided in the Prismic editor and is unique among all documents of its
336
- * Custom Type.
337
- * @example
338
- *
339
- * ```ts
340
- * const document = await client.getByID("WW4bKScAAMAqmluX");
341
- * ```
342
- *
343
- * @typeParam TDocument- Type of the Prismic document returned.
344
- * @param id - ID of the document.
345
- * @param params - Parameters to filter, sort, and paginate the results.
346
- *
347
- * @returns The document with an ID matching the `id` parameter, if a matching
348
- * document exists.
349
- */
350
- getByID<TDocument extends TDocuments>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
351
- /**
352
- * Queries documents from the Prismic repository with specific IDs.
353
- *
354
- * @remarks
355
- * A document's UID is different from its ID. An ID is automatically generated
356
- * for all documents and is made available on its `id` property. A UID is
357
- * provided in the Prismic editor and is unique among all documents of its
358
- * Custom Type.
359
- * @example
360
- *
361
- * ```ts
362
- * const response = await client.getByIDs([
363
- * "WW4bKScAAMAqmluX",
364
- * "U1kTRgEAAC8A5ldS",
365
- * ]);
366
- * ```
367
- *
368
- * @typeParam TDocument - Type of Prismic documents returned.
369
- * @param ids - A list of document IDs.
370
- * @param params - Parameters to filter, sort, and paginate the results.
371
- *
372
- * @returns A paginated response containing documents with IDs matching the
373
- * `ids` parameter.
374
- */
375
- getByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
376
- /**
377
- * Queries all documents from the Prismic repository with specific IDs.
378
- *
379
- * This method may make multiple network requests to query all matching
380
- * content.
381
- *
382
- * @remarks
383
- * A document's UID is different from its ID. An ID is automatically generated
384
- * for all documents and is made available on its `id` property. A UID is
385
- * provided in the Prismic editor and is unique among all documents of its
386
- * Custom Type.
387
- * @example
388
- *
389
- * ```ts
390
- * const response = await client.getAllByIDs([
391
- * "WW4bKScAAMAqmluX",
392
- * "U1kTRgEAAC8A5ldS",
393
- * ]);
394
- * ```
395
- *
396
- * @typeParam TDocument - Type of Prismic documents returned.
397
- * @param ids - A list of document IDs.
398
- * @param params - Parameters to filter, sort, and paginate the results.
399
- *
400
- * @returns A list of documents with IDs matching the `ids` parameter.
401
- */
402
- getAllByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<TDocument[]>;
403
- /**
404
- * Queries a document from the Prismic repository with a specific UID and
405
- * Custom Type.
406
- *
407
- * @remarks
408
- * A document's UID is different from its ID. An ID is automatically generated
409
- * for all documents and is made available on its `id` property. A UID is
410
- * provided in the Prismic editor and is unique among all documents of its
411
- * Custom Type.
412
- * @example
413
- *
414
- * ```ts
415
- * const document = await client.getByUID("blog_post", "my-first-post");
416
- * ```
417
- *
418
- * @typeParam TDocument - Type of the Prismic document returned.
419
- * @param documentType - The API ID of the document's Custom Type.
420
- * @param uid - UID of the document.
421
- * @param params - Parameters to filter, sort, and paginate the results.
422
- *
423
- * @returns The document with a UID matching the `uid` parameter, if a
424
- * matching document exists.
425
- */
426
- getByUID<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
427
- /**
428
- * Queries document from the Prismic repository with specific UIDs and Custom
429
- * Type.
430
- *
431
- * @remarks
432
- * A document's UID is different from its ID. An ID is automatically generated
433
- * for all documents and is made available on its `id` property. A UID is
434
- * provided in the Prismic editor and is unique among all documents of its
435
- * Custom Type.
436
- * @example
437
- *
438
- * ```ts
439
- * const document = await client.getByUIDs("blog_post", [
440
- * "my-first-post",
441
- * "my-second-post",
442
- * ]);
443
- * ```
444
- *
445
- * @typeParam TDocument - Type of the Prismic document returned.
446
- * @param documentType - The API ID of the document's Custom Type.
447
- * @param uids - A list of document UIDs.
448
- * @param params - Parameters to filter, sort, and paginate the results.
449
- *
450
- * @returns A paginated response containing documents with UIDs matching the
451
- * `uids` parameter.
452
- */
453
- getByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>>;
454
- /**
455
- * Queries all documents from the Prismic repository with specific UIDs and
456
- * Custom Type.
457
- *
458
- * This method may make multiple network requests to query all matching
459
- * content.
460
- *
461
- * @remarks
462
- * A document's UID is different from its ID. An ID is automatically generated
463
- * for all documents and is made available on its `id` property. A UID is
464
- * provided in the Prismic editor and is unique among all documents of its
465
- * Custom Type.
466
- * @example
467
- *
468
- * ```ts
469
- * const response = await client.getAllByUIDs([
470
- * "my-first-post",
471
- * "my-second-post",
472
- * ]);
473
- * ```
474
- *
475
- * @typeParam TDocument - Type of Prismic documents returned.
476
- * @param documentType - The API ID of the document's Custom Type.
477
- * @param uids - A list of document UIDs.
478
- * @param params - Parameters to filter, sort, and paginate the results.
479
- *
480
- * @returns A list of documents with UIDs matching the `uids` parameter.
481
- */
482
- getAllByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
483
- /**
484
- * Queries a singleton document from the Prismic repository for a specific
485
- * Custom Type.
486
- *
487
- * @remarks
488
- * A singleton document is one that is configured in Prismic to only allow one
489
- * instance. For example, a repository may be configured to contain just one
490
- * Settings document. This is in contrast to a repeatable Custom Type which
491
- * allows multiple instances of itself.
492
- * @example
493
- *
494
- * ```ts
495
- * const document = await client.getSingle("settings");
496
- * ```
497
- *
498
- * @typeParam TDocument - Type of the Prismic document returned.
499
- * @param documentType - The API ID of the singleton Custom Type.
500
- * @param params - Parameters to filter, sort, and paginate the results.
501
- *
502
- * @returns The singleton document for the Custom Type, if a matching document
503
- * exists.
504
- */
505
- getSingle<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
506
- /**
507
- * Queries documents from the Prismic repository for a specific Custom Type.
508
- *
509
- * Use `getAllByType` instead if you need to query all documents for a
510
- * specific Custom Type.
511
- *
512
- * @example
513
- *
514
- * ```ts
515
- * const response = await client.getByType("blog_post");
516
- * ```
517
- *
518
- * @typeParam TDocument - Type of Prismic documents returned.
519
- * @param documentType - The API ID of the Custom Type.
520
- * @param params - Parameters to filter, sort, and paginate the results.
521
- *
522
- * @returns A paginated response containing documents of the Custom Type.
523
- */
524
- getByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>>;
525
- /**
526
- * Queries all documents from the Prismic repository for a specific Custom
527
- * Type.
528
- *
529
- * This method may make multiple network requests to query all matching
530
- * content.
531
- *
532
- * @example
533
- *
534
- * ```ts
535
- * const response = await client.getByType("blog_post");
536
- * ```
537
- *
538
- * @typeParam TDocument - Type of Prismic documents returned.
539
- * @param documentType - The API ID of the Custom Type.
540
- * @param params - Parameters to filter, sort, and paginate the results.
541
- *
542
- * @returns A list of all documents of the Custom Type.
543
- */
544
- getAllByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
545
- /**
546
- * Queries documents from the Prismic repository with a specific tag.
547
- *
548
- * Use `getAllByTag` instead if you need to query all documents with a
549
- * specific tag.
550
- *
551
- * @example
552
- *
553
- * ```ts
554
- * const response = await client.getByTag("food");
555
- * ```
556
- *
557
- * @typeParam TDocument - Type of Prismic documents returned.
558
- * @param tag - The tag that must be included on a document.
559
- * @param params - Parameters to filter, sort, and paginate the results.
560
- *
561
- * @returns A paginated response containing documents with the tag.
562
- */
563
- getByTag<TDocument extends TDocuments>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
564
- /**
565
- * Queries all documents from the Prismic repository with a specific tag.
566
- *
567
- * This method may make multiple network requests to query all matching
568
- * content.
569
- *
570
- * @example
571
- *
572
- * ```ts
573
- * const response = await client.getAllByTag("food");
574
- * ```
575
- *
576
- * @typeParam TDocument - Type of Prismic documents returned.
577
- * @param tag - The tag that must be included on a document.
578
- * @param params - Parameters to filter, sort, and paginate the results.
579
- *
580
- * @returns A list of all documents with the tag.
581
- */
582
- getAllByTag<TDocument extends TDocuments>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
583
- /**
584
- * Queries documents from the Prismic repository with specific tags. A
585
- * document must be tagged with all of the queried tags to be included.
586
- *
587
- * @example
588
- *
589
- * ```ts
590
- * const response = await client.getByEveryTag(["food", "fruit"]);
591
- * ```
592
- *
593
- * @typeParam TDocument - Type of Prismic documents returned.
594
- * @param tags - A list of tags that must be included on a document.
595
- * @param params - Parameters to filter, sort, and paginate the results.
596
- *
597
- * @returns A paginated response containing documents with the tags.
598
- */
599
- getByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
600
- /**
601
- * Queries documents from the Prismic repository with specific tags. A
602
- * document must be tagged with all of the queried tags to be included.
603
- *
604
- * This method may make multiple network requests to query all matching
605
- * content.
606
- *
607
- * @example
608
- *
609
- * ```ts
610
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
611
- * ```
612
- *
613
- * @typeParam TDocument - Type of Prismic documents returned.
614
- * @param tags - A list of tags that must be included on a document.
615
- * @param params - Parameters to filter, sort, and paginate the results.
616
- *
617
- * @returns A list of all documents with the tags.
618
- */
619
- getAllByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
620
- /**
621
- * Queries documents from the Prismic repository with specific tags. A
622
- * document must be tagged with at least one of the queried tags to be
623
- * included.
624
- *
625
- * @example
626
- *
627
- * ```ts
628
- * const response = await client.getByEveryTag(["food", "fruit"]);
629
- * ```
630
- *
631
- * @typeParam TDocument - Type of Prismic documents returned.
632
- * @param tags - A list of tags that must be included on a document.
633
- * @param params - Parameters to filter, sort, and paginate the results.
634
- *
635
- * @returns A paginated response containing documents with at least one of the
636
- * tags.
637
- */
638
- getBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
639
- /**
640
- * Queries documents from the Prismic repository with specific tags. A
641
- * document must be tagged with at least one of the queried tags to be
642
- * included.
643
- *
644
- * This method may make multiple network requests to query all matching
645
- * content.
646
- *
647
- * @example
648
- *
649
- * ```ts
650
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
651
- * ```
652
- *
653
- * @typeParam TDocument - Type of Prismic documents returned.
654
- * @param tags - A list of tags that must be included on a document.
655
- * @param params - Parameters to filter, sort, and paginate the results.
656
- *
657
- * @returns A list of all documents with at least one of the tags.
658
- */
659
- getAllBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
660
- /**
661
- * Returns metadata about the Prismic repository, such as its refs, releases,
662
- * and custom types.
663
- *
664
- * @returns Repository metadata.
665
- */
666
- getRepository(params?: FetchParams): Promise<Repository>;
667
- /**
668
- * Returns a list of all refs for the Prismic repository.
669
- *
670
- * Refs are used to identify which version of the repository's content should
671
- * be queried. All repositories will have at least one ref pointing to the
672
- * latest published content called the "master ref".
673
- *
674
- * @returns A list of all refs for the Prismic repository.
675
- */
676
- getRefs(params?: FetchParams): Promise<Ref[]>;
677
- /**
678
- * Returns a ref for the Prismic repository with a matching ID.
679
- *
680
- * @param id - ID of the ref.
681
- *
682
- * @returns The ref with a matching ID, if it exists.
683
- */
684
- getRefByID(id: string, params?: FetchParams): Promise<Ref>;
685
- /**
686
- * Returns a ref for the Prismic repository with a matching label.
687
- *
688
- * @param label - Label of the ref.
689
- *
690
- * @returns The ref with a matching label, if it exists.
691
- */
692
- getRefByLabel(label: string, params?: FetchParams): Promise<Ref>;
693
- /**
694
- * Returns the master ref for the Prismic repository. The master ref points to
695
- * the repository's latest published content.
696
- *
697
- * @returns The repository's master ref.
698
- */
699
- getMasterRef(params?: FetchParams): Promise<Ref>;
700
- /**
701
- * Returns a list of all Releases for the Prismic repository. Releases are
702
- * used to group content changes before publishing.
703
- *
704
- * @returns A list of all Releases for the Prismic repository.
705
- */
706
- getReleases(params?: FetchParams): Promise<Ref[]>;
707
- /**
708
- * Returns a Release for the Prismic repository with a matching ID.
709
- *
710
- * @param id - ID of the Release.
711
- *
712
- * @returns The Release with a matching ID, if it exists.
713
- */
714
- getReleaseByID(id: string, params?: FetchParams): Promise<Ref>;
715
- /**
716
- * Returns a Release for the Prismic repository with a matching label.
717
- *
718
- * @param label - Label of the ref.
719
- *
720
- * @returns The ref with a matching label, if it exists.
721
- */
722
- getReleaseByLabel(label: string, params?: FetchParams): Promise<Ref>;
723
- /**
724
- * Returns a list of all tags used in the Prismic repository.
725
- *
726
- * @returns A list of all tags used in the repository.
727
- */
728
- getTags(params?: FetchParams): Promise<string[]>;
729
- /**
730
- * Builds a URL used to query content from the Prismic repository.
731
- *
732
- * @param params - Parameters to filter, sort, and paginate the results.
733
- *
734
- * @returns A URL string that can be requested to query content.
735
- */
736
- buildQueryURL({ signal, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
737
- /**
738
- * Determines the URL for a previewed document during an active preview
739
- * session. The result of this method should be used to redirect the user to
740
- * the document's URL.
741
- *
742
- * @example
743
- *
744
- * ```ts
745
- * const url = client.resolvePreviewURL({
746
- * linkResolver: (document) => `/${document.uid}`
747
- * defaultURL: '/'
748
- * })
749
- * ```
750
- *
751
- * @param args - Arguments to configure the URL resolving.
752
- *
753
- * @returns The URL for the previewed document during an active preview
754
- * session. The user should be redirected to this URL.
755
- */
756
- resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
757
- /**
758
- * Configures the client to query the latest published content for all future
759
- * queries.
760
- *
761
- * If the `ref` parameter is provided during a query, it takes priority for
762
- * that query.
763
- *
764
- * @example
765
- *
766
- * ```ts
767
- * await client.queryLatestContent();
768
- * const document = await client.getByID("WW4bKScAAMAqmluX");
769
- * ```
770
- */
771
- queryLatestContent(): void;
772
- /**
773
- * Configures the client to query content from a specific Release identified
774
- * by its ID for all future queries.
775
- *
776
- * If the `ref` parameter is provided during a query, it takes priority for
777
- * that query.
778
- *
779
- * @example
780
- *
781
- * ```ts
782
- * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
783
- * const document = await client.getByID("WW4bKScAAMAqmluX");
784
- * ```
785
- *
786
- * @param releaseID - The ID of the Release.
787
- */
788
- queryContentFromReleaseByID(releaseID: string): void;
789
- /**
790
- * Configures the client to query content from a specific Release identified
791
- * by its label for all future queries.
792
- *
793
- * If the `ref` parameter is provided during a query, it takes priority for
794
- * that query.
795
- *
796
- * @example
797
- *
798
- * ```ts
799
- * await client.queryContentFromReleaseByLabel("My Release");
800
- * const document = await client.getByID("WW4bKScAAMAqmluX");
801
- * ```
802
- *
803
- * @param releaseLabel - The label of the Release.
804
- */
805
- queryContentFromReleaseByLabel(releaseLabel: string): void;
806
- /**
807
- * Configures the client to query content from a specific ref. The ref can be
808
- * provided as a string or a function.
809
- *
810
- * If a function is provided, the ref is fetched lazily before each query. The
811
- * function may also be asynchronous.
812
- *
813
- * @example
814
- *
815
- * ```ts
816
- * await client.queryContentFromRef("my-ref");
817
- * const document = await client.getByID("WW4bKScAAMAqmluX");
818
- * ```
819
- *
820
- * @param ref - The ref or a function that returns the ref from which to query
821
- * content.
822
- */
823
- queryContentFromRef(ref: RefStringOrThunk): void;
824
- /**
825
- * A `fetch()` function to be used with GraphQL clients configured for
826
- * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
827
- * and Authorization headers. Queries will automatically be minified by
828
- * removing whitespace where possible.
829
- *
830
- * @example
831
- *
832
- * ```ts
833
- * const graphQLClient = new ApolloClient({
834
- * link: new HttpLink({
835
- * uri: prismic.getGraphQLEndpoint(repositoryName),
836
- * // Provide `client.graphQLFetch` as the fetch implementation.
837
- * fetch: client.graphQLFetch,
838
- * // Using GET is required.
839
- * useGETForQueries: true,
840
- * }),
841
- * cache: new InMemoryCache(),
842
- * });
843
- * ```
844
- *
845
- * @param input - The `fetch()` `input` parameter. Only strings are supported.
846
- * @param init - The `fetch()` `init` parameter. Only plain objects are
847
- * supported.
848
- *
849
- * @returns The `fetch()` Response for the request.
850
- * @experimental
851
- */
852
- graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
853
- signal?: AbortSignalLike;
854
- }): Promise<Response>;
855
- /**
856
- * Returns a cached version of `getRepository` with a TTL.
857
- *
858
- * @returns Cached repository metadata.
859
- */
860
- private getCachedRepository;
861
- /**
862
- * Returns a cached Prismic repository form. Forms are used to determine API
863
- * endpoints for types of repository data.
864
- *
865
- * @param name - Name of the form.
866
- *
867
- * @returns The repository form.
868
- * @throws If a matching form cannot be found.
869
- */
870
- private getCachedRepositoryForm;
871
- /**
872
- * Returns the ref needed to query based on the client's current state. This
873
- * method may make a network request to fetch a ref or resolve the user's ref
874
- * thunk.
875
- *
876
- * If auto previews are enabled, the preview ref takes priority if available.
877
- *
878
- * The following strategies are used depending on the client's state:
879
- *
880
- * - If the user called `queryLatestContent`: Use the repository's master ref.
881
- * The ref is cached for 5 seconds. After 5 seconds, a new master ref is
882
- * fetched.
883
- * - If the user called `queryContentFromReleaseByID`: Use the release's ref.
884
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
885
- * release is fetched.
886
- * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
887
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
888
- * release is fetched.
889
- * - If the user called `queryContentFromRef`: Use the provided ref. Fall back
890
- * to the master ref if the ref is not a string.
891
- *
892
- * @returns The ref to use during a query.
893
- */
894
- private getResolvedRefString;
895
- /**
896
- * Performs a network request using the configured `fetch` function. It
897
- * assumes all successful responses will have a JSON content type. It also
898
- * normalizes unsuccessful network requests.
899
- *
900
- * @typeParam T - The JSON response.
901
- * @param url - URL to the resource to fetch.
902
- * @param params - Prismic REST API parameters for the network request.
903
- *
904
- * @returns The JSON response from the network request.
905
- */
906
- private fetch;
907
- }
908
- export {};
1
+ import type { Query } from "./types/api/query";
2
+ import type { Ref } from "./types/api/ref";
3
+ import type { Repository } from "./types/api/repository";
4
+ import type { PrismicDocument } from "./types/value/document";
5
+ import { LinkResolverFunction } from "./helpers/asLink";
6
+ import { BuildQueryURLArgs } from "./buildQueryURL";
7
+ /**
8
+ * The number of milliseconds in which repository metadata is considered valid.
9
+ * A ref can be invalidated quickly depending on how frequently content is
10
+ * updated in the Prismic repository. As such, repository's metadata can only be
11
+ * considered valid for a short amount of time.
12
+ */
13
+ export declare const REPOSITORY_CACHE_TTL = 5000;
14
+ /**
15
+ * The number of milliseconds in which a multi-page `getAll` (e.g. `getAll`,
16
+ * `getAllByType`, `getAllByTag`) will wait between individual page requests.
17
+ *
18
+ * This is done to ensure API performance is sustainable and reduces the chance
19
+ * of a failed API request due to overloading.
20
+ */
21
+ export declare const GET_ALL_QUERY_DELAY = 500;
22
+ /**
23
+ * Extracts one or more Prismic document types that match a given Prismic
24
+ * document type. If no matches are found, no extraction is performed and the
25
+ * union of all provided Prismic document types are returned.
26
+ *
27
+ * @typeParam TDocuments - Prismic document types from which to extract.
28
+ * @typeParam TDocumentType - Type(s) to match `TDocuments` against.
29
+ */
30
+ type ExtractDocumentType<TDocuments extends PrismicDocument, TDocumentType extends TDocuments["type"]> = Extract<TDocuments, {
31
+ type: TDocumentType;
32
+ }> extends never ? TDocuments : Extract<TDocuments, {
33
+ type: TDocumentType;
34
+ }>;
35
+ /**
36
+ * A universal API to make network requests. A subset of the `fetch()` API.
37
+ *
38
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
39
+ */
40
+ export type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
41
+ /**
42
+ * An object that allows you to abort a `fetch()` request if needed via an
43
+ * `AbortController` object
44
+ *
45
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
46
+ */
47
+ export type AbortSignalLike = any;
48
+ /**
49
+ * The minimum required properties from RequestInit.
50
+ */
51
+ export interface RequestInitLike {
52
+ headers?: Record<string, string>;
53
+ /**
54
+ * An object that allows you to abort a `fetch()` request if needed via an
55
+ * `AbortController` object
56
+ *
57
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
58
+ */
59
+ signal?: AbortSignalLike;
60
+ }
61
+ /**
62
+ * The minimum required properties from Response.
63
+ */
64
+ export interface ResponseLike {
65
+ status: number;
66
+ json(): Promise<any>;
67
+ }
68
+ /**
69
+ * The minimum required properties to treat as an HTTP Request for automatic
70
+ * Prismic preview support.
71
+ */
72
+ export type HttpRequestLike = /**
73
+ * Web API Request
74
+ *
75
+ * @see http://developer.mozilla.org/en-US/docs/Web/API/Request
76
+ */ {
77
+ headers?: {
78
+ get(name: string): string | null;
79
+ };
80
+ url?: string;
81
+ }
82
+ /**
83
+ * Express-style Request
84
+ */
85
+ | {
86
+ headers?: {
87
+ cookie?: string;
88
+ };
89
+ query?: Record<string, unknown>;
90
+ };
91
+ /**
92
+ * A ref or a function that returns a ref. If a static ref is known, one can be
93
+ * given. If the ref must be fetched on-demand, a function can be provided. This
94
+ * function can optionally be asynchronous.
95
+ */
96
+ type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
97
+ /**
98
+ * Configuration for clients that determine how content is queried.
99
+ */
100
+ export type ClientConfig = {
101
+ /**
102
+ * The secure token for accessing the Prismic repository. This is only
103
+ * required if the repository is set to private.
104
+ */
105
+ accessToken?: string;
106
+ /**
107
+ * A string representing a version of the Prismic repository's content. This
108
+ * may point to the latest version (called the "master ref"), or a preview
109
+ * with draft content.
110
+ */
111
+ ref?: RefStringOrThunk;
112
+ /**
113
+ * A list of Route Resolver objects that define how a document's `url` field
114
+ * is resolved.
115
+ *
116
+ * {@link https://prismic.io/docs/route-resolver}
117
+ */
118
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>;
119
+ /**
120
+ * The `brokenRoute` option allows you to define the route populated in the
121
+ * `url` property for broken Link or Content Relationship fields. A broken
122
+ * link is a Link or Content Relationship field whose linked document has been
123
+ * unpublished or deleted.
124
+ *
125
+ * {@link https://prismic.io/docs/route-resolver}
126
+ */
127
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
128
+ /**
129
+ * Default parameters that will be sent with each query. These parameters can
130
+ * be overridden on each query if needed.
131
+ */
132
+ defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute">;
133
+ /**
134
+ * The function used to make network requests to the Prismic REST API. In
135
+ * environments where a global `fetch` function does not exist, such as
136
+ * Node.js, this function must be provided.
137
+ */
138
+ fetch?: FetchLike;
139
+ };
140
+ /**
141
+ * Parameters for any client method that use `fetch()`. Only a subset of
142
+ * `fetch()` parameters are exposed.
143
+ */
144
+ type FetchParams = {
145
+ /**
146
+ * An `AbortSignal` provided by an `AbortController`. This allows the network
147
+ * request to be cancelled if necessary.
148
+ *
149
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
150
+ */
151
+ signal?: AbortSignalLike;
152
+ };
153
+ /**
154
+ * Parameters specific to client methods that fetch all documents. These methods
155
+ * start with `getAll` (for example, `getAllByType`).
156
+ */
157
+ type GetAllParams = {
158
+ /**
159
+ * Limit the number of documents queried. If a number is not provided, there
160
+ * will be no limit and all matching documents will be returned.
161
+ */
162
+ limit?: number;
163
+ };
164
+ /**
165
+ * Arguments to determine how the URL for a preview session is resolved.
166
+ */
167
+ type ResolvePreviewArgs<LinkResolverReturnType> = {
168
+ /**
169
+ * A function that maps a Prismic document to a URL within your app.
170
+ */
171
+ linkResolver?: LinkResolverFunction<LinkResolverReturnType>;
172
+ /**
173
+ * A fallback URL if the Link Resolver does not return a value.
174
+ */
175
+ defaultURL: string;
176
+ /**
177
+ * The preview token (also known as a ref) that will be used to query preview
178
+ * content from the Prismic repository.
179
+ */
180
+ previewToken?: string;
181
+ /**
182
+ * The previewed document that will be used to determine the destination URL.
183
+ */
184
+ documentID?: string;
185
+ };
186
+ /**
187
+ * Type definitions for the `createClient()` function. May be augmented by
188
+ * third-party libraries.
189
+ */
190
+ export interface CreateClient {
191
+ <TDocuments extends PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
192
+ }
193
+ /**
194
+ * Creates a Prismic client that can be used to query a repository.
195
+ *
196
+ * @example
197
+ *
198
+ * ```ts
199
+ * // With a repository name.
200
+ * createClient("qwerty");
201
+ *
202
+ * // Or with a full Prismic Rest API V2 endpoint.
203
+ * createClient("https://qwerty.cdn.prismic.io/api/v2");
204
+ * ```
205
+ *
206
+ * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
207
+ * TypeScript type.
208
+ * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
209
+ * API V2 endpoint for the repository.
210
+ * @param options - Configuration that determines how content will be queried
211
+ * from the Prismic repository.
212
+ *
213
+ * @returns A client that can query content from the repository.
214
+ */
215
+ export declare const createClient: CreateClient;
216
+ /**
217
+ * A client that allows querying content from a Prismic repository.
218
+ *
219
+ * If used in an environment where a global `fetch` function is unavailable,
220
+ * such as Node.js, the `fetch` option must be provided as part of the `options`
221
+ * parameter.
222
+ *
223
+ * @typeParam TDocuments - Document types that are registered for the Prismic
224
+ * repository. Query methods will automatically be typed based on this type.
225
+ */
226
+ export declare class Client<TDocuments extends PrismicDocument = PrismicDocument> {
227
+ /**
228
+ * The Prismic REST API V2 endpoint for the repository (use
229
+ * `prismic.getRepositoryEndpoint` for the default endpoint).
230
+ */
231
+ endpoint: string;
232
+ /**
233
+ * The secure token for accessing the API (only needed if your repository is
234
+ * set to private).
235
+ *
236
+ * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
237
+ */
238
+ accessToken?: string;
239
+ /**
240
+ * A list of Route Resolver objects that define how a document's `url` field
241
+ * is resolved.
242
+ *
243
+ * {@link https://prismic.io/docs/route-resolver}
244
+ */
245
+ routes?: NonNullable<BuildQueryURLArgs["routes"]>;
246
+ /**
247
+ * The `brokenRoute` option allows you to define the route populated in the
248
+ * `url` property for broken Link or Content Relationship fields. A broken
249
+ * link is a Link or Content Relationship field whose linked document has been
250
+ * unpublished or deleted.
251
+ *
252
+ * {@link https://prismic.io/docs/route-resolver}
253
+ */
254
+ brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
255
+ /**
256
+ * The function used to make network requests to the Prismic REST API. In
257
+ * environments where a global `fetch` function does not exist, such as
258
+ * Node.js, this function must be provided.
259
+ */
260
+ fetchFn: FetchLike;
261
+ /**
262
+ * Default parameters that will be sent with each query. These parameters can
263
+ * be overridden on each query if needed.
264
+ */
265
+ defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
266
+ /**
267
+ * The client's ref mode state. This determines which ref is used during
268
+ * queries.
269
+ */
270
+ private refState;
271
+ /**
272
+ * Cached repository value.
273
+ */
274
+ private cachedRepository;
275
+ /**
276
+ * Timestamp at which the cached repository data is considered stale.
277
+ */
278
+ private cachedRepositoryExpiration;
279
+ /**
280
+ * Active `fetch()` jobs keyed by URL and AbortSignal (if it exists).
281
+ */
282
+ private fetchJobs;
283
+ /**
284
+ * Creates a Prismic client that can be used to query a repository.
285
+ *
286
+ * If used in an environment where a global `fetch` function is unavailable,
287
+ * such as Node.js, the `fetch` option must be provided as part of the
288
+ * `options` parameter.
289
+ *
290
+ * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
291
+ * API V2 endpoint for the repository.
292
+ * @param options - Configuration that determines how content will be queried
293
+ * from the Prismic repository.
294
+ *
295
+ * @returns A client that can query content from the repository.
296
+ */
297
+ constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
298
+ /**
299
+ * Enables the client to automatically query content from a preview session if
300
+ * one is active in browser environments. This is enabled by default in the
301
+ * browser.
302
+ *
303
+ * For server environments, use `enableAutoPreviewsFromReq`.
304
+ *
305
+ * @example
306
+ *
307
+ * ```ts
308
+ * client.enableAutoPreviews();
309
+ * ```
310
+ *
311
+ * @see enableAutoPreviewsFromReq
312
+ */
313
+ enableAutoPreviews(): void;
314
+ /**
315
+ * Enables the client to automatically query content from a preview session if
316
+ * one is active in server environments. This is disabled by default on the
317
+ * server.
318
+ *
319
+ * For browser environments, use `enableAutoPreviews`.
320
+ *
321
+ * @example
322
+ *
323
+ * ```ts
324
+ * // In an express app
325
+ * app.get("/", function (req, res) {
326
+ * client.enableAutoPreviewsFromReq(req);
327
+ * });
328
+ * ```
329
+ *
330
+ * @param req - An HTTP server request object containing the request's
331
+ * cookies.
332
+ */
333
+ enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void;
334
+ /**
335
+ * Disables the client from automatically querying content from a preview
336
+ * session if one is active.
337
+ *
338
+ * Automatic preview content querying is enabled by default unless this method
339
+ * is called.
340
+ *
341
+ * @example
342
+ *
343
+ * ```ts
344
+ * client.disableAutoPreviews();
345
+ * ```
346
+ */
347
+ disableAutoPreviews(): void;
348
+ /**
349
+ * Queries content from the Prismic repository.
350
+ *
351
+ * @example
352
+ *
353
+ * ```ts
354
+ * const response = await client.get();
355
+ * ```
356
+ *
357
+ * @typeParam TDocument - Type of Prismic documents returned.
358
+ * @param params - Parameters to filter, sort, and paginate results.
359
+ *
360
+ * @returns A paginated response containing the result of the query.
361
+ */
362
+ get<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
363
+ /**
364
+ * Queries content from the Prismic repository and returns only the first
365
+ * result, if any.
366
+ *
367
+ * @example
368
+ *
369
+ * ```ts
370
+ * const document = await client.getFirst();
371
+ * ```
372
+ *
373
+ * @typeParam TDocument - Type of the Prismic document returned.
374
+ * @param params - Parameters to filter, sort, and paginate results. @returns
375
+ * The first result of the query, if any.
376
+ */
377
+ getFirst<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
378
+ /**
379
+ * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
380
+ * require more resources than other methods. Prefer using other methods that
381
+ * filter by filters such as `getAllByType`.
382
+ *
383
+ * Queries content from the Prismic repository and returns all matching
384
+ * content. If no filters are provided, all documents will be fetched.
385
+ *
386
+ * This method may make multiple network requests to query all matching
387
+ * content.
388
+ *
389
+ * @example
390
+ *
391
+ * ```ts
392
+ * const response = await client.dangerouslyGetAll();
393
+ * ```
394
+ *
395
+ * @typeParam TDocument - Type of Prismic documents returned.
396
+ * @param params - Parameters to filter, sort, and paginate results.
397
+ *
398
+ * @returns A list of documents matching the query.
399
+ */
400
+ dangerouslyGetAll<TDocument extends TDocuments>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
401
+ /**
402
+ * Queries a document from the Prismic repository with a specific ID.
403
+ *
404
+ * @remarks
405
+ * A document's UID is different from its ID. An ID is automatically generated
406
+ * for all documents and is made available on its `id` property. A UID is
407
+ * provided in the Prismic editor and is unique among all documents of its
408
+ * Custom Type.
409
+ * @example
410
+ *
411
+ * ```ts
412
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
413
+ * ```
414
+ *
415
+ * @typeParam TDocument- Type of the Prismic document returned.
416
+ * @param id - ID of the document.
417
+ * @param params - Parameters to filter, sort, and paginate the results.
418
+ *
419
+ * @returns The document with an ID matching the `id` parameter, if a matching
420
+ * document exists.
421
+ */
422
+ getByID<TDocument extends TDocuments>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
423
+ /**
424
+ * Queries documents from the Prismic repository with specific IDs.
425
+ *
426
+ * @remarks
427
+ * A document's UID is different from its ID. An ID is automatically generated
428
+ * for all documents and is made available on its `id` property. A UID is
429
+ * provided in the Prismic editor and is unique among all documents of its
430
+ * Custom Type.
431
+ * @example
432
+ *
433
+ * ```ts
434
+ * const response = await client.getByIDs([
435
+ * "WW4bKScAAMAqmluX",
436
+ * "U1kTRgEAAC8A5ldS",
437
+ * ]);
438
+ * ```
439
+ *
440
+ * @typeParam TDocument - Type of Prismic documents returned.
441
+ * @param ids - A list of document IDs.
442
+ * @param params - Parameters to filter, sort, and paginate the results.
443
+ *
444
+ * @returns A paginated response containing documents with IDs matching the
445
+ * `ids` parameter.
446
+ */
447
+ getByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
448
+ /**
449
+ * Queries all documents from the Prismic repository with specific IDs.
450
+ *
451
+ * This method may make multiple network requests to query all matching
452
+ * content.
453
+ *
454
+ * @remarks
455
+ * A document's UID is different from its ID. An ID is automatically generated
456
+ * for all documents and is made available on its `id` property. A UID is
457
+ * provided in the Prismic editor and is unique among all documents of its
458
+ * Custom Type.
459
+ * @example
460
+ *
461
+ * ```ts
462
+ * const response = await client.getAllByIDs([
463
+ * "WW4bKScAAMAqmluX",
464
+ * "U1kTRgEAAC8A5ldS",
465
+ * ]);
466
+ * ```
467
+ *
468
+ * @typeParam TDocument - Type of Prismic documents returned.
469
+ * @param ids - A list of document IDs.
470
+ * @param params - Parameters to filter, sort, and paginate the results.
471
+ *
472
+ * @returns A list of documents with IDs matching the `ids` parameter.
473
+ */
474
+ getAllByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<TDocument[]>;
475
+ /**
476
+ * Queries a document from the Prismic repository with a specific UID and
477
+ * Custom Type.
478
+ *
479
+ * @remarks
480
+ * A document's UID is different from its ID. An ID is automatically generated
481
+ * for all documents and is made available on its `id` property. A UID is
482
+ * provided in the Prismic editor and is unique among all documents of its
483
+ * Custom Type.
484
+ * @example
485
+ *
486
+ * ```ts
487
+ * const document = await client.getByUID("blog_post", "my-first-post");
488
+ * ```
489
+ *
490
+ * @typeParam TDocument - Type of the Prismic document returned.
491
+ * @param documentType - The API ID of the document's Custom Type.
492
+ * @param uid - UID of the document.
493
+ * @param params - Parameters to filter, sort, and paginate the results.
494
+ *
495
+ * @returns The document with a UID matching the `uid` parameter, if a
496
+ * matching document exists.
497
+ */
498
+ getByUID<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
499
+ /**
500
+ * Queries document from the Prismic repository with specific UIDs and Custom
501
+ * Type.
502
+ *
503
+ * @remarks
504
+ * A document's UID is different from its ID. An ID is automatically generated
505
+ * for all documents and is made available on its `id` property. A UID is
506
+ * provided in the Prismic editor and is unique among all documents of its
507
+ * Custom Type.
508
+ * @example
509
+ *
510
+ * ```ts
511
+ * const document = await client.getByUIDs("blog_post", [
512
+ * "my-first-post",
513
+ * "my-second-post",
514
+ * ]);
515
+ * ```
516
+ *
517
+ * @typeParam TDocument - Type of the Prismic document returned.
518
+ * @param documentType - The API ID of the document's Custom Type.
519
+ * @param uids - A list of document UIDs.
520
+ * @param params - Parameters to filter, sort, and paginate the results.
521
+ *
522
+ * @returns A paginated response containing documents with UIDs matching the
523
+ * `uids` parameter.
524
+ */
525
+ getByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>>;
526
+ /**
527
+ * Queries all documents from the Prismic repository with specific UIDs and
528
+ * Custom Type.
529
+ *
530
+ * This method may make multiple network requests to query all matching
531
+ * content.
532
+ *
533
+ * @remarks
534
+ * A document's UID is different from its ID. An ID is automatically generated
535
+ * for all documents and is made available on its `id` property. A UID is
536
+ * provided in the Prismic editor and is unique among all documents of its
537
+ * Custom Type.
538
+ * @example
539
+ *
540
+ * ```ts
541
+ * const response = await client.getAllByUIDs([
542
+ * "my-first-post",
543
+ * "my-second-post",
544
+ * ]);
545
+ * ```
546
+ *
547
+ * @typeParam TDocument - Type of Prismic documents returned.
548
+ * @param documentType - The API ID of the document's Custom Type.
549
+ * @param uids - A list of document UIDs.
550
+ * @param params - Parameters to filter, sort, and paginate the results.
551
+ *
552
+ * @returns A list of documents with UIDs matching the `uids` parameter.
553
+ */
554
+ getAllByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
555
+ /**
556
+ * Queries a singleton document from the Prismic repository for a specific
557
+ * Custom Type.
558
+ *
559
+ * @remarks
560
+ * A singleton document is one that is configured in Prismic to only allow one
561
+ * instance. For example, a repository may be configured to contain just one
562
+ * Settings document. This is in contrast to a repeatable Custom Type which
563
+ * allows multiple instances of itself.
564
+ * @example
565
+ *
566
+ * ```ts
567
+ * const document = await client.getSingle("settings");
568
+ * ```
569
+ *
570
+ * @typeParam TDocument - Type of the Prismic document returned.
571
+ * @param documentType - The API ID of the singleton Custom Type.
572
+ * @param params - Parameters to filter, sort, and paginate the results.
573
+ *
574
+ * @returns The singleton document for the Custom Type, if a matching document
575
+ * exists.
576
+ */
577
+ getSingle<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
578
+ /**
579
+ * Queries documents from the Prismic repository for a specific Custom Type.
580
+ *
581
+ * Use `getAllByType` instead if you need to query all documents for a
582
+ * specific Custom Type.
583
+ *
584
+ * @example
585
+ *
586
+ * ```ts
587
+ * const response = await client.getByType("blog_post");
588
+ * ```
589
+ *
590
+ * @typeParam TDocument - Type of Prismic documents returned.
591
+ * @param documentType - The API ID of the Custom Type.
592
+ * @param params - Parameters to filter, sort, and paginate the results.
593
+ *
594
+ * @returns A paginated response containing documents of the Custom Type.
595
+ */
596
+ getByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<ExtractDocumentType<TDocument, TDocumentType>>>;
597
+ /**
598
+ * Queries all documents from the Prismic repository for a specific Custom
599
+ * Type.
600
+ *
601
+ * This method may make multiple network requests to query all matching
602
+ * content.
603
+ *
604
+ * @example
605
+ *
606
+ * ```ts
607
+ * const response = await client.getByType("blog_post");
608
+ * ```
609
+ *
610
+ * @typeParam TDocument - Type of Prismic documents returned.
611
+ * @param documentType - The API ID of the Custom Type.
612
+ * @param params - Parameters to filter, sort, and paginate the results.
613
+ *
614
+ * @returns A list of all documents of the Custom Type.
615
+ */
616
+ getAllByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
617
+ /**
618
+ * Queries documents from the Prismic repository with a specific tag.
619
+ *
620
+ * Use `getAllByTag` instead if you need to query all documents with a
621
+ * specific tag.
622
+ *
623
+ * @example
624
+ *
625
+ * ```ts
626
+ * const response = await client.getByTag("food");
627
+ * ```
628
+ *
629
+ * @typeParam TDocument - Type of Prismic documents returned.
630
+ * @param tag - The tag that must be included on a document.
631
+ * @param params - Parameters to filter, sort, and paginate the results.
632
+ *
633
+ * @returns A paginated response containing documents with the tag.
634
+ */
635
+ getByTag<TDocument extends TDocuments>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
636
+ /**
637
+ * Queries all documents from the Prismic repository with a specific tag.
638
+ *
639
+ * This method may make multiple network requests to query all matching
640
+ * content.
641
+ *
642
+ * @example
643
+ *
644
+ * ```ts
645
+ * const response = await client.getAllByTag("food");
646
+ * ```
647
+ *
648
+ * @typeParam TDocument - Type of Prismic documents returned.
649
+ * @param tag - The tag that must be included on a document.
650
+ * @param params - Parameters to filter, sort, and paginate the results.
651
+ *
652
+ * @returns A list of all documents with the tag.
653
+ */
654
+ getAllByTag<TDocument extends TDocuments>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
655
+ /**
656
+ * Queries documents from the Prismic repository with specific tags. A
657
+ * document must be tagged with all of the queried tags to be included.
658
+ *
659
+ * @example
660
+ *
661
+ * ```ts
662
+ * const response = await client.getByEveryTag(["food", "fruit"]);
663
+ * ```
664
+ *
665
+ * @typeParam TDocument - Type of Prismic documents returned.
666
+ * @param tags - A list of tags that must be included on a document.
667
+ * @param params - Parameters to filter, sort, and paginate the results.
668
+ *
669
+ * @returns A paginated response containing documents with the tags.
670
+ */
671
+ getByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
672
+ /**
673
+ * Queries documents from the Prismic repository with specific tags. A
674
+ * document must be tagged with all of the queried tags to be included.
675
+ *
676
+ * This method may make multiple network requests to query all matching
677
+ * content.
678
+ *
679
+ * @example
680
+ *
681
+ * ```ts
682
+ * const response = await client.getAllByEveryTag(["food", "fruit"]);
683
+ * ```
684
+ *
685
+ * @typeParam TDocument - Type of Prismic documents returned.
686
+ * @param tags - A list of tags that must be included on a document.
687
+ * @param params - Parameters to filter, sort, and paginate the results.
688
+ *
689
+ * @returns A list of all documents with the tags.
690
+ */
691
+ getAllByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
692
+ /**
693
+ * Queries documents from the Prismic repository with specific tags. A
694
+ * document must be tagged with at least one of the queried tags to be
695
+ * included.
696
+ *
697
+ * @example
698
+ *
699
+ * ```ts
700
+ * const response = await client.getByEveryTag(["food", "fruit"]);
701
+ * ```
702
+ *
703
+ * @typeParam TDocument - Type of Prismic documents returned.
704
+ * @param tags - A list of tags that must be included on a document.
705
+ * @param params - Parameters to filter, sort, and paginate the results.
706
+ *
707
+ * @returns A paginated response containing documents with at least one of the
708
+ * tags.
709
+ */
710
+ getBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<Query<TDocument>>;
711
+ /**
712
+ * Queries documents from the Prismic repository with specific tags. A
713
+ * document must be tagged with at least one of the queried tags to be
714
+ * included.
715
+ *
716
+ * This method may make multiple network requests to query all matching
717
+ * content.
718
+ *
719
+ * @example
720
+ *
721
+ * ```ts
722
+ * const response = await client.getAllBySomeTags(["food", "fruit"]);
723
+ * ```
724
+ *
725
+ * @typeParam TDocument - Type of Prismic documents returned.
726
+ * @param tags - A list of tags that must be included on a document.
727
+ * @param params - Parameters to filter, sort, and paginate the results.
728
+ *
729
+ * @returns A list of all documents with at least one of the tags.
730
+ */
731
+ getAllBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
732
+ /**
733
+ * Returns metadata about the Prismic repository, such as its refs, releases,
734
+ * and custom types.
735
+ *
736
+ * @returns Repository metadata.
737
+ */
738
+ getRepository(params?: FetchParams): Promise<Repository>;
739
+ /**
740
+ * Returns a list of all refs for the Prismic repository.
741
+ *
742
+ * Refs are used to identify which version of the repository's content should
743
+ * be queried. All repositories will have at least one ref pointing to the
744
+ * latest published content called the "master ref".
745
+ *
746
+ * @returns A list of all refs for the Prismic repository.
747
+ */
748
+ getRefs(params?: FetchParams): Promise<Ref[]>;
749
+ /**
750
+ * Returns a ref for the Prismic repository with a matching ID.
751
+ *
752
+ * @param id - ID of the ref.
753
+ *
754
+ * @returns The ref with a matching ID, if it exists.
755
+ */
756
+ getRefByID(id: string, params?: FetchParams): Promise<Ref>;
757
+ /**
758
+ * Returns a ref for the Prismic repository with a matching label.
759
+ *
760
+ * @param label - Label of the ref.
761
+ *
762
+ * @returns The ref with a matching label, if it exists.
763
+ */
764
+ getRefByLabel(label: string, params?: FetchParams): Promise<Ref>;
765
+ /**
766
+ * Returns the master ref for the Prismic repository. The master ref points to
767
+ * the repository's latest published content.
768
+ *
769
+ * @returns The repository's master ref.
770
+ */
771
+ getMasterRef(params?: FetchParams): Promise<Ref>;
772
+ /**
773
+ * Returns a list of all Releases for the Prismic repository. Releases are
774
+ * used to group content changes before publishing.
775
+ *
776
+ * @returns A list of all Releases for the Prismic repository.
777
+ */
778
+ getReleases(params?: FetchParams): Promise<Ref[]>;
779
+ /**
780
+ * Returns a Release for the Prismic repository with a matching ID.
781
+ *
782
+ * @param id - ID of the Release.
783
+ *
784
+ * @returns The Release with a matching ID, if it exists.
785
+ */
786
+ getReleaseByID(id: string, params?: FetchParams): Promise<Ref>;
787
+ /**
788
+ * Returns a Release for the Prismic repository with a matching label.
789
+ *
790
+ * @param label - Label of the ref.
791
+ *
792
+ * @returns The ref with a matching label, if it exists.
793
+ */
794
+ getReleaseByLabel(label: string, params?: FetchParams): Promise<Ref>;
795
+ /**
796
+ * Returns a list of all tags used in the Prismic repository.
797
+ *
798
+ * @returns A list of all tags used in the repository.
799
+ */
800
+ getTags(params?: FetchParams): Promise<string[]>;
801
+ /**
802
+ * Builds a URL used to query content from the Prismic repository.
803
+ *
804
+ * @param params - Parameters to filter, sort, and paginate the results.
805
+ *
806
+ * @returns A URL string that can be requested to query content.
807
+ */
808
+ buildQueryURL({ signal, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
809
+ /**
810
+ * Determines the URL for a previewed document during an active preview
811
+ * session. The result of this method should be used to redirect the user to
812
+ * the document's URL.
813
+ *
814
+ * @example
815
+ *
816
+ * ```ts
817
+ * const url = client.resolvePreviewURL({
818
+ * linkResolver: (document) => `/${document.uid}`
819
+ * defaultURL: '/'
820
+ * })
821
+ * ```
822
+ *
823
+ * @param args - Arguments to configure the URL resolving.
824
+ *
825
+ * @returns The URL for the previewed document during an active preview
826
+ * session. The user should be redirected to this URL.
827
+ */
828
+ resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
829
+ /**
830
+ * Configures the client to query the latest published content for all future
831
+ * queries.
832
+ *
833
+ * If the `ref` parameter is provided during a query, it takes priority for
834
+ * that query.
835
+ *
836
+ * @example
837
+ *
838
+ * ```ts
839
+ * await client.queryLatestContent();
840
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
841
+ * ```
842
+ */
843
+ queryLatestContent(): void;
844
+ /**
845
+ * Configures the client to query content from a specific Release identified
846
+ * by its ID for all future queries.
847
+ *
848
+ * If the `ref` parameter is provided during a query, it takes priority for
849
+ * that query.
850
+ *
851
+ * @example
852
+ *
853
+ * ```ts
854
+ * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
855
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
856
+ * ```
857
+ *
858
+ * @param releaseID - The ID of the Release.
859
+ */
860
+ queryContentFromReleaseByID(releaseID: string): void;
861
+ /**
862
+ * Configures the client to query content from a specific Release identified
863
+ * by its label for all future queries.
864
+ *
865
+ * If the `ref` parameter is provided during a query, it takes priority for
866
+ * that query.
867
+ *
868
+ * @example
869
+ *
870
+ * ```ts
871
+ * await client.queryContentFromReleaseByLabel("My Release");
872
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
873
+ * ```
874
+ *
875
+ * @param releaseLabel - The label of the Release.
876
+ */
877
+ queryContentFromReleaseByLabel(releaseLabel: string): void;
878
+ /**
879
+ * Configures the client to query content from a specific ref. The ref can be
880
+ * provided as a string or a function.
881
+ *
882
+ * If a function is provided, the ref is fetched lazily before each query. The
883
+ * function may also be asynchronous.
884
+ *
885
+ * @example
886
+ *
887
+ * ```ts
888
+ * await client.queryContentFromRef("my-ref");
889
+ * const document = await client.getByID("WW4bKScAAMAqmluX");
890
+ * ```
891
+ *
892
+ * @param ref - The ref or a function that returns the ref from which to query
893
+ * content.
894
+ */
895
+ queryContentFromRef(ref: RefStringOrThunk): void;
896
+ /**
897
+ * A `fetch()` function to be used with GraphQL clients configured for
898
+ * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
899
+ * and Authorization headers. Queries will automatically be minified by
900
+ * removing whitespace where possible.
901
+ *
902
+ * @example
903
+ *
904
+ * ```ts
905
+ * const graphQLClient = new ApolloClient({
906
+ * link: new HttpLink({
907
+ * uri: prismic.getGraphQLEndpoint(repositoryName),
908
+ * // Provide `client.graphQLFetch` as the fetch implementation.
909
+ * fetch: client.graphQLFetch,
910
+ * // Using GET is required.
911
+ * useGETForQueries: true,
912
+ * }),
913
+ * cache: new InMemoryCache(),
914
+ * });
915
+ * ```
916
+ *
917
+ * @param input - The `fetch()` `input` parameter. Only strings are supported.
918
+ * @param init - The `fetch()` `init` parameter. Only plain objects are
919
+ * supported.
920
+ *
921
+ * @returns The `fetch()` Response for the request.
922
+ * @experimental
923
+ */
924
+ graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
925
+ signal?: AbortSignalLike;
926
+ }): Promise<Response>;
927
+ /**
928
+ * Returns a cached version of `getRepository` with a TTL.
929
+ *
930
+ * @returns Cached repository metadata.
931
+ */
932
+ private getCachedRepository;
933
+ /**
934
+ * Returns a cached Prismic repository form. Forms are used to determine API
935
+ * endpoints for types of repository data.
936
+ *
937
+ * @param name - Name of the form.
938
+ *
939
+ * @returns The repository form.
940
+ * @throws If a matching form cannot be found.
941
+ */
942
+ private getCachedRepositoryForm;
943
+ /**
944
+ * Returns the ref needed to query based on the client's current state. This
945
+ * method may make a network request to fetch a ref or resolve the user's ref
946
+ * thunk.
947
+ *
948
+ * If auto previews are enabled, the preview ref takes priority if available.
949
+ *
950
+ * The following strategies are used depending on the client's state:
951
+ *
952
+ * - If the user called `queryLatestContent`: Use the repository's master ref.
953
+ * The ref is cached for 5 seconds. After 5 seconds, a new master ref is
954
+ * fetched.
955
+ * - If the user called `queryContentFromReleaseByID`: Use the release's ref.
956
+ * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
957
+ * release is fetched.
958
+ * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
959
+ * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
960
+ * release is fetched.
961
+ * - If the user called `queryContentFromRef`: Use the provided ref. Fall back
962
+ * to the master ref if the ref is not a string.
963
+ *
964
+ * @returns The ref to use during a query.
965
+ */
966
+ private getResolvedRefString;
967
+ /**
968
+ * Performs a network request using the configured `fetch` function. It
969
+ * assumes all successful responses will have a JSON content type. It also
970
+ * normalizes unsuccessful network requests.
971
+ *
972
+ * @typeParam T - The JSON response.
973
+ * @param url - URL to the resource to fetch.
974
+ * @param params - Prismic REST API parameters for the network request.
975
+ *
976
+ * @returns The JSON response from the network request.
977
+ */
978
+ private fetch;
979
+ }
980
+ export {};