@prismicio/client 6.7.0 → 7.0.0-alpha.0

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 (343) hide show
  1. package/dist/ForbiddenError.cjs +7 -0
  2. package/dist/ForbiddenError.cjs.map +1 -0
  3. package/dist/ForbiddenError.d.ts +11 -0
  4. package/dist/ForbiddenError.js +7 -0
  5. package/dist/ForbiddenError.js.map +1 -0
  6. package/dist/NotFoundError.cjs +7 -0
  7. package/dist/NotFoundError.cjs.map +1 -0
  8. package/dist/NotFoundError.d.ts +3 -0
  9. package/dist/NotFoundError.js +7 -0
  10. package/dist/NotFoundError.js.map +1 -0
  11. package/dist/ParsingError.cjs +7 -0
  12. package/dist/ParsingError.cjs.map +1 -0
  13. package/dist/ParsingError.d.ts +12 -0
  14. package/dist/ParsingError.js +7 -0
  15. package/dist/ParsingError.js.map +1 -0
  16. package/dist/PrismicError.cjs +19 -0
  17. package/dist/PrismicError.cjs.map +1 -0
  18. package/dist/PrismicError.d.ts +5 -0
  19. package/dist/PrismicError.js +19 -0
  20. package/dist/PrismicError.js.map +1 -0
  21. package/dist/buildQueryURL.cjs +41 -0
  22. package/dist/buildQueryURL.cjs.map +1 -0
  23. package/dist/buildQueryURL.d.ts +130 -0
  24. package/dist/buildQueryURL.js +41 -0
  25. package/dist/buildQueryURL.js.map +1 -0
  26. package/dist/client.cjs +414 -0
  27. package/dist/client.cjs.map +1 -0
  28. package/dist/client.d.ts +908 -0
  29. package/dist/client.js +414 -0
  30. package/dist/client.js.map +1 -0
  31. package/dist/cookie.cjs +5 -0
  32. package/dist/cookie.cjs.map +1 -0
  33. package/dist/cookie.d.ts +5 -0
  34. package/dist/cookie.js +5 -0
  35. package/dist/cookie.js.map +1 -0
  36. package/dist/getGraphQLEndpoint.cjs +13 -0
  37. package/dist/getGraphQLEndpoint.cjs.map +1 -0
  38. package/dist/getGraphQLEndpoint.d.ts +9 -0
  39. package/dist/getGraphQLEndpoint.js +13 -0
  40. package/dist/getGraphQLEndpoint.js.map +1 -0
  41. package/dist/getRepositoryEndpoint.cjs +13 -0
  42. package/dist/getRepositoryEndpoint.cjs.map +1 -0
  43. package/dist/getRepositoryEndpoint.d.ts +10 -0
  44. package/dist/getRepositoryEndpoint.js +13 -0
  45. package/dist/getRepositoryEndpoint.js.map +1 -0
  46. package/dist/getRepositoryName.cjs +12 -0
  47. package/dist/getRepositoryName.cjs.map +1 -0
  48. package/dist/getRepositoryName.d.ts +13 -0
  49. package/dist/getRepositoryName.js +12 -0
  50. package/dist/getRepositoryName.js.map +1 -0
  51. package/dist/helpers/asDate.cjs +14 -0
  52. package/dist/helpers/asDate.cjs.map +1 -0
  53. package/dist/helpers/asDate.d.ts +16 -0
  54. package/dist/helpers/asDate.js +14 -0
  55. package/dist/helpers/asDate.js.map +1 -0
  56. package/dist/helpers/asHTML.cjs +79 -0
  57. package/dist/helpers/asHTML.cjs.map +1 -0
  58. package/dist/helpers/asHTML.d.ts +20 -0
  59. package/dist/helpers/asHTML.js +79 -0
  60. package/dist/helpers/asHTML.js.map +1 -0
  61. package/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -0
  62. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
  63. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +52 -0
  64. package/dist/helpers/asImagePixelDensitySrcSet.js +21 -0
  65. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
  66. package/dist/helpers/asImageSrc.cjs +13 -0
  67. package/dist/helpers/asImageSrc.cjs.map +1 -0
  68. package/dist/helpers/asImageSrc.d.ts +27 -0
  69. package/dist/helpers/asImageSrc.js +13 -0
  70. package/dist/helpers/asImageSrc.js.map +1 -0
  71. package/dist/helpers/asImageWidthSrcSet.cjs +40 -0
  72. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
  73. package/dist/helpers/asImageWidthSrcSet.d.ts +60 -0
  74. package/dist/helpers/asImageWidthSrcSet.js +40 -0
  75. package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
  76. package/dist/helpers/asLink.cjs +32 -0
  77. package/dist/helpers/asLink.cjs.map +1 -0
  78. package/dist/helpers/asLink.d.ts +24 -0
  79. package/dist/helpers/asLink.js +32 -0
  80. package/dist/helpers/asLink.js.map +1 -0
  81. package/dist/helpers/asText.cjs +12 -0
  82. package/dist/helpers/asText.cjs.map +1 -0
  83. package/dist/helpers/asText.d.ts +16 -0
  84. package/dist/helpers/asText.js +12 -0
  85. package/dist/helpers/asText.js.map +1 -0
  86. package/dist/helpers/documentToLinkField.cjs +19 -0
  87. package/dist/helpers/documentToLinkField.cjs.map +1 -0
  88. package/dist/helpers/documentToLinkField.d.ts +15 -0
  89. package/dist/helpers/documentToLinkField.js +19 -0
  90. package/dist/helpers/documentToLinkField.js.map +1 -0
  91. package/dist/helpers/isFilled.cjs +67 -0
  92. package/dist/helpers/isFilled.cjs.map +1 -0
  93. package/dist/helpers/isFilled.d.ts +175 -0
  94. package/dist/helpers/isFilled.js +67 -0
  95. package/dist/helpers/isFilled.js.map +1 -0
  96. package/dist/index.cjs +67 -721
  97. package/dist/index.cjs.map +1 -1
  98. package/dist/index.d.ts +92 -1526
  99. package/dist/index.js +64 -681
  100. package/dist/index.js.map +1 -1
  101. package/dist/isRepositoryEndpoint.cjs +12 -0
  102. package/dist/isRepositoryEndpoint.cjs.map +1 -0
  103. package/dist/isRepositoryEndpoint.d.ts +10 -0
  104. package/dist/isRepositoryEndpoint.js +12 -0
  105. package/dist/isRepositoryEndpoint.js.map +1 -0
  106. package/dist/isRepositoryName.cjs +7 -0
  107. package/dist/isRepositoryName.cjs.map +1 -0
  108. package/dist/isRepositoryName.d.ts +9 -0
  109. package/dist/isRepositoryName.js +7 -0
  110. package/dist/isRepositoryName.js.map +1 -0
  111. package/dist/lib/appendPredicates.cjs +14 -0
  112. package/dist/lib/appendPredicates.cjs.map +1 -0
  113. package/dist/lib/appendPredicates.d.ts +18 -0
  114. package/dist/lib/appendPredicates.js +14 -0
  115. package/dist/lib/appendPredicates.js.map +1 -0
  116. package/dist/lib/castArray.cjs +5 -0
  117. package/dist/lib/castArray.cjs.map +1 -0
  118. package/dist/lib/castArray.d.ts +11 -0
  119. package/dist/lib/castArray.js +5 -0
  120. package/dist/lib/castArray.js.map +1 -0
  121. package/dist/lib/castThunk.cjs +5 -0
  122. package/dist/lib/castThunk.cjs.map +1 -0
  123. package/dist/lib/castThunk.d.ts +10 -0
  124. package/dist/lib/castThunk.js +5 -0
  125. package/dist/lib/castThunk.js.map +1 -0
  126. package/dist/lib/findMasterRef.cjs +8 -0
  127. package/dist/lib/findMasterRef.cjs.map +1 -0
  128. package/dist/lib/findMasterRef.d.ts +10 -0
  129. package/dist/lib/findMasterRef.js +8 -0
  130. package/dist/lib/findMasterRef.js.map +1 -0
  131. package/dist/lib/findRef.cjs +12 -0
  132. package/dist/lib/findRef.cjs.map +1 -0
  133. package/dist/lib/findRef.d.ts +13 -0
  134. package/dist/lib/findRef.js +12 -0
  135. package/dist/lib/findRef.js.map +1 -0
  136. package/dist/lib/findRefByID.cjs +8 -0
  137. package/dist/lib/findRefByID.cjs.map +1 -0
  138. package/dist/lib/findRefByID.d.ts +11 -0
  139. package/dist/lib/findRefByID.js +8 -0
  140. package/dist/lib/findRefByID.js.map +1 -0
  141. package/dist/lib/findRefByLabel.cjs +8 -0
  142. package/dist/lib/findRefByLabel.cjs.map +1 -0
  143. package/dist/lib/findRefByLabel.d.ts +11 -0
  144. package/dist/lib/findRefByLabel.js +8 -0
  145. package/dist/lib/findRefByLabel.js.map +1 -0
  146. package/dist/lib/getPreviewCookie.cjs +21 -0
  147. package/dist/lib/getPreviewCookie.cjs.map +1 -0
  148. package/dist/lib/getPreviewCookie.d.ts +9 -0
  149. package/dist/lib/getPreviewCookie.js +21 -0
  150. package/dist/lib/getPreviewCookie.js.map +1 -0
  151. package/dist/lib/minifyGraphQLQuery.cjs +7 -0
  152. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -0
  153. package/dist/lib/minifyGraphQLQuery.d.ts +8 -0
  154. package/dist/lib/minifyGraphQLQuery.js +7 -0
  155. package/dist/lib/minifyGraphQLQuery.js.map +1 -0
  156. package/dist/lib/serializerHelpers.cjs +56 -0
  157. package/dist/lib/serializerHelpers.cjs.map +1 -0
  158. package/dist/lib/serializerHelpers.d.ts +9 -0
  159. package/dist/lib/serializerHelpers.js +54 -0
  160. package/dist/lib/serializerHelpers.js.map +1 -0
  161. package/dist/predicate.cjs +68 -0
  162. package/dist/predicate.cjs.map +1 -0
  163. package/dist/predicate.d.ts +209 -0
  164. package/dist/predicate.js +68 -0
  165. package/dist/predicate.js.map +1 -0
  166. package/dist/types/api/query.d.ts +42 -0
  167. package/dist/types/api/ref.d.ts +32 -0
  168. package/dist/types/api/release.d.ts +10 -0
  169. package/dist/types/api/repository.d.ts +100 -0
  170. package/dist/types/api/tags.d.ts +8 -0
  171. package/dist/types/client.d.ts +128 -0
  172. package/dist/types/helpers.d.ts +63 -0
  173. package/dist/types/model/boolean.d.ts +15 -0
  174. package/dist/types/model/color.d.ts +13 -0
  175. package/dist/types/model/contentRelationship.d.ts +18 -0
  176. package/dist/types/model/customType.d.ts +42 -0
  177. package/dist/types/model/date.d.ts +14 -0
  178. package/dist/types/model/embed.d.ts +13 -0
  179. package/dist/types/model/geoPoint.d.ts +12 -0
  180. package/dist/types/model/group.d.ts +15 -0
  181. package/dist/types/model/image.d.ts +31 -0
  182. package/dist/types/model/integrationFields.d.ts +14 -0
  183. package/dist/types/model/keyText.d.ts +13 -0
  184. package/dist/types/model/link.cjs +9 -0
  185. package/dist/types/model/link.cjs.map +1 -0
  186. package/dist/types/model/link.d.ts +27 -0
  187. package/dist/types/model/link.js +9 -0
  188. package/dist/types/model/link.js.map +1 -0
  189. package/dist/types/model/linkToMedia.d.ts +16 -0
  190. package/dist/types/model/number.d.ts +15 -0
  191. package/dist/types/model/range.d.ts +14 -0
  192. package/dist/types/model/richText.d.ts +35 -0
  193. package/dist/types/model/select.d.ts +18 -0
  194. package/dist/types/model/separator.d.ts +10 -0
  195. package/dist/types/model/sharedSlice.d.ts +19 -0
  196. package/dist/types/model/sharedSliceVariation.d.ts +22 -0
  197. package/dist/types/model/slice.cjs +8 -0
  198. package/dist/types/model/slice.cjs.map +1 -0
  199. package/dist/types/model/slice.d.ts +33 -0
  200. package/dist/types/model/slice.js +8 -0
  201. package/dist/types/model/slice.js.map +1 -0
  202. package/dist/types/model/sliceZone.cjs +8 -0
  203. package/dist/types/model/sliceZone.cjs.map +1 -0
  204. package/dist/types/model/sliceZone.d.ts +44 -0
  205. package/dist/types/model/sliceZone.js +8 -0
  206. package/dist/types/model/sliceZone.js.map +1 -0
  207. package/dist/types/model/timestamp.d.ts +14 -0
  208. package/dist/types/model/title.d.ts +7 -0
  209. package/dist/types/model/types.cjs +25 -0
  210. package/dist/types/model/types.cjs.map +1 -0
  211. package/dist/types/model/types.d.ts +62 -0
  212. package/dist/types/model/types.js +25 -0
  213. package/dist/types/model/types.js.map +1 -0
  214. package/dist/types/model/uid.d.ts +13 -0
  215. package/dist/types/utils.d.ts +28 -0
  216. package/dist/types/value/boolean.d.ts +6 -0
  217. package/dist/types/value/color.d.ts +8 -0
  218. package/dist/types/value/contentRelationship.d.ts +29 -0
  219. package/dist/types/value/date.d.ts +8 -0
  220. package/dist/types/value/document.d.ts +113 -0
  221. package/dist/types/value/embed.cjs +10 -0
  222. package/dist/types/value/embed.cjs.map +1 -0
  223. package/dist/types/value/embed.d.ts +167 -0
  224. package/dist/types/value/embed.js +10 -0
  225. package/dist/types/value/embed.js.map +1 -0
  226. package/dist/types/value/geoPoint.d.ts +11 -0
  227. package/dist/types/value/group.d.ts +7 -0
  228. package/dist/types/value/image.d.ts +36 -0
  229. package/dist/types/value/integrationFields.d.ts +9 -0
  230. package/dist/types/value/keyText.d.ts +8 -0
  231. package/dist/types/value/link.cjs +10 -0
  232. package/dist/types/value/link.cjs.map +1 -0
  233. package/dist/types/value/link.d.ts +40 -0
  234. package/dist/types/value/link.js +10 -0
  235. package/dist/types/value/link.js.map +1 -0
  236. package/dist/types/value/linkToMedia.d.ts +20 -0
  237. package/dist/types/value/number.d.ts +8 -0
  238. package/dist/types/value/richText.cjs +25 -0
  239. package/dist/types/value/richText.cjs.map +1 -0
  240. package/dist/types/value/richText.d.ts +203 -0
  241. package/dist/types/value/richText.js +25 -0
  242. package/dist/types/value/richText.js.map +1 -0
  243. package/dist/types/value/select.d.ts +9 -0
  244. package/dist/types/value/sharedSlice.d.ts +11 -0
  245. package/dist/types/value/sharedSliceVariation.d.ts +7 -0
  246. package/dist/types/value/slice.d.ts +13 -0
  247. package/dist/types/value/sliceZone.d.ts +12 -0
  248. package/dist/types/value/timestamp.d.ts +8 -0
  249. package/dist/types/value/title.d.ts +12 -0
  250. package/dist/types/value/types.d.ts +40 -0
  251. package/dist/types/webhook/apiUpdate.d.ts +52 -0
  252. package/dist/types/webhook/testTrigger.d.ts +9 -0
  253. package/dist/types/webhook/types.cjs +8 -0
  254. package/dist/types/webhook/types.cjs.map +1 -0
  255. package/dist/types/webhook/types.d.ts +18 -0
  256. package/dist/types/webhook/types.js +8 -0
  257. package/dist/types/webhook/types.js.map +1 -0
  258. package/package.json +40 -33
  259. package/src/buildQueryURL.ts +8 -4
  260. package/src/client.ts +111 -118
  261. package/src/cookie.ts +2 -1
  262. package/src/getRepositoryName.ts +4 -2
  263. package/src/helpers/asDate.ts +48 -0
  264. package/src/helpers/asHTML.ts +154 -0
  265. package/src/helpers/asImagePixelDensitySrcSet.ts +96 -0
  266. package/src/helpers/asImageSrc.ts +41 -0
  267. package/src/helpers/asImageWidthSrcSet.ts +139 -0
  268. package/src/helpers/asLink.ts +99 -0
  269. package/src/helpers/asText.ts +29 -0
  270. package/src/helpers/documentToLinkField.ts +47 -0
  271. package/src/helpers/isFilled.ts +290 -0
  272. package/src/index.ts +237 -21
  273. package/src/isRepositoryEndpoint.ts +2 -1
  274. package/src/isRepositoryName.ts +2 -1
  275. package/src/lib/appendPredicates.ts +2 -1
  276. package/src/lib/findMasterRef.ts +2 -2
  277. package/src/lib/findRef.ts +2 -5
  278. package/src/lib/findRefByID.ts +2 -2
  279. package/src/lib/findRefByLabel.ts +2 -5
  280. package/src/lib/getPreviewCookie.ts +3 -2
  281. package/src/lib/serializerHelpers.ts +96 -0
  282. package/src/predicate.ts +4 -2
  283. package/src/types/api/query.ts +50 -0
  284. package/src/types/api/ref.ts +36 -0
  285. package/src/types/api/release.ts +11 -0
  286. package/src/types/api/repository.ts +117 -0
  287. package/src/types/api/tags.ts +8 -0
  288. package/src/{types.ts → types/client.ts} +16 -52
  289. package/src/types/helpers.ts +103 -0
  290. package/src/types/model/boolean.ts +16 -0
  291. package/src/types/model/color.ts +14 -0
  292. package/src/types/model/contentRelationship.ts +22 -0
  293. package/src/types/model/customType.ts +61 -0
  294. package/src/types/model/date.ts +15 -0
  295. package/src/types/model/embed.ts +14 -0
  296. package/src/types/model/geoPoint.ts +13 -0
  297. package/src/types/model/group.ts +24 -0
  298. package/src/types/model/image.ts +37 -0
  299. package/src/types/model/integrationFields.ts +15 -0
  300. package/src/types/model/keyText.ts +14 -0
  301. package/src/types/model/link.ts +31 -0
  302. package/src/types/model/linkToMedia.ts +17 -0
  303. package/src/types/model/number.ts +16 -0
  304. package/src/types/model/range.ts +15 -0
  305. package/src/types/model/richText.ts +40 -0
  306. package/src/types/model/select.ts +22 -0
  307. package/src/types/model/separator.ts +11 -0
  308. package/src/types/model/sharedSlice.ts +23 -0
  309. package/src/types/model/sharedSliceVariation.ts +33 -0
  310. package/src/types/model/slice.ts +49 -0
  311. package/src/types/model/sliceZone.ts +62 -0
  312. package/src/types/model/timestamp.ts +15 -0
  313. package/src/types/model/title.ts +8 -0
  314. package/src/types/model/types.ts +91 -0
  315. package/src/types/model/uid.ts +14 -0
  316. package/src/types/utils.ts +34 -0
  317. package/src/types/value/boolean.ts +6 -0
  318. package/src/types/value/color.ts +10 -0
  319. package/src/types/value/contentRelationship.ts +48 -0
  320. package/src/types/value/date.ts +10 -0
  321. package/src/types/value/document.ts +142 -0
  322. package/src/types/value/embed.ts +196 -0
  323. package/src/types/value/geoPoint.ts +15 -0
  324. package/src/types/value/group.ts +14 -0
  325. package/src/types/value/image.ts +67 -0
  326. package/src/types/value/integrationFields.ts +13 -0
  327. package/src/types/value/keyText.ts +10 -0
  328. package/src/types/value/link.ts +59 -0
  329. package/src/types/value/linkToMedia.ts +25 -0
  330. package/src/types/value/number.ts +10 -0
  331. package/src/types/value/richText.ts +286 -0
  332. package/src/types/value/select.ts +13 -0
  333. package/src/types/value/sharedSlice.ts +15 -0
  334. package/src/types/value/sharedSliceVariation.ts +18 -0
  335. package/src/types/value/slice.ts +24 -0
  336. package/src/types/value/sliceZone.ts +16 -0
  337. package/src/types/value/timestamp.ts +12 -0
  338. package/src/types/value/title.ts +31 -0
  339. package/src/types/value/types.ts +60 -0
  340. package/src/types/webhook/apiUpdate.ts +56 -0
  341. package/src/types/webhook/testTrigger.ts +10 -0
  342. package/src/types/webhook/types.ts +21 -0
  343. package/src/lib/orElseThrow.ts +0 -17
package/dist/index.d.ts CHANGED
@@ -1,1526 +1,92 @@
1
- import * as prismicT from '@prismicio/types';
2
- import * as prismicH from '@prismicio/helpers';
3
-
4
- /**
5
- * Get a repository's Prismic Rest API V2 endpoint.
6
- *
7
- * @typeParam RepositoryName - Name of the Prismic repository.
8
- * @param repositoryName - Name of the repository.
9
- *
10
- * @returns The repository's Prismic Rest API V2 endpoint
11
- * @throws {@link Error} Thrown if an invalid repository name is provided.
12
- */
13
- declare const getRepositoryEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/api/v2`;
14
-
15
- /**
16
- * Get a Prismic repository's name from its standard Prismic Rest API V2 or
17
- * GraphQL endpoint.
18
- *
19
- * @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
20
- * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
21
- *
22
- * @returns The Prismic repository's name.
23
- * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is provided.
24
- */
25
- declare const getRepositoryName: (repositoryEndpoint: string) => string;
26
-
27
- /**
28
- * Get a repository's Prismic GraphQL endpoint.
29
- *
30
- * @typeParam RepositoryName - Name of the Prismic repository.
31
- * @param repositoryName - Name of the repository.
32
- *
33
- * @returns The repository's Prismic REST API V2 endpoint
34
- */
35
- declare const getGraphQLEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/graphql`;
36
-
37
- /**
38
- * Determines if an input is a valid Prismic repository name.
39
- *
40
- * @param input - Input to test.
41
- *
42
- * @returns `true` if `input` is a valid Prismic repository name, `false` otherwise.
43
- */
44
- declare const isRepositoryName: (input: string) => boolean;
45
-
46
- /**
47
- * Determines if a string if a Prismic Rest API V2 endpoint. Note that any valid
48
- * URL is a valid endpoint to support network proxies.
49
- *
50
- * @param input - Input to test.
51
- *
52
- * @returns `true` if `input` is a valid Prismic Rest API V2 endpoint, `false` otherwise.
53
- */
54
- declare const isRepositoryEndpoint: (input: string) => boolean;
55
-
56
- /**
57
- * Functions like TypeScript's native `Extract` utility type with added support
58
- * to fall back to a value if the resulting union is `never`.
59
- *
60
- * @example
61
- *
62
- * ```ts
63
- * ExtractOrFallback<"a" | "b", "a"> // => "a"
64
- * ExtractOrFallback<"a" | "b", "c"> // => "a" | "b"
65
- * ExtractOrFallback<"a" | "b", "c", "foo"> // => "foo"
66
- * ```
67
- *
68
- * @typeParam T - The union from which values will be extracted.
69
- * @typeParam U - The extraction condition.
70
- * @typeParam Fallback - The value to return if the resulting union is `never`.
71
- * Defaults to `T`.
72
- */
73
- declare type ExtractOrFallback<T, U, Fallback = T> = Extract<T, U> extends never ? Fallback : Extract<T, U>;
74
- /**
75
- * Extracts one or more Prismic document types that match a given Prismic
76
- * document type. If no matches are found, no extraction is performed and the
77
- * union of all provided Prismic document types are returned.
78
- *
79
- * @typeParam TDocuments - Prismic document types from which to extract.
80
- * @typeParam TDocumentType - Type(s) to match `TDocuments` against.
81
- */
82
- declare type ExtractDocumentType<TDocuments extends prismicT.PrismicDocument, TDocumentType extends TDocuments["type"]> = ExtractOrFallback<TDocuments, {
83
- type: TDocumentType;
84
- }>;
85
- /**
86
- * A universal API to make network requests. A subset of the `fetch()` API.
87
- *
88
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
89
- */
90
- declare type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
91
- /**
92
- * An object that allows you to abort a `fetch()` request if needed via an
93
- * `AbortController` object
94
- *
95
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
96
- */
97
- declare type AbortSignalLike = {
98
- aborted: any;
99
- addEventListener: any;
100
- removeEventListener: any;
101
- dispatchEvent: any;
102
- onabort: any;
103
- };
104
- /**
105
- * The minimum required properties from RequestInit.
106
- */
107
- interface RequestInitLike {
108
- headers?: Record<string, string>;
109
- signal?: AbortSignalLike | null;
110
- }
111
- /**
112
- * The minimum required properties from Response.
113
- */
114
- interface ResponseLike {
115
- status: number;
116
- json(): Promise<any>;
117
- }
118
- /**
119
- * The minimum required properties to treat as an HTTP Request for automatic
120
- * Prismic preview support.
121
- */
122
- declare type HttpRequestLike = /**
123
- * Web API Request
124
- *
125
- * @see http://developer.mozilla.org/en-US/docs/Web/API/Request
126
- */ {
127
- headers?: {
128
- get(name: string): string | null;
129
- };
130
- url?: string;
131
- }
132
- /**
133
- * Express-style Request
134
- */
135
- | {
136
- headers?: {
137
- cookie?: string;
138
- };
139
- query?: Record<string, unknown>;
140
- };
141
- /**
142
- * An `orderings` parameter that orders the results by the specified field.
143
- *
144
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
145
- */
146
- interface Ordering {
147
- field: string;
148
- direction?: "asc" | "desc";
149
- }
150
- /**
151
- * A `routes` parameter that determines how a document's URL field is resolved.
152
- *
153
- * @example With a document's UID field.
154
- *
155
- * ```ts
156
- * {
157
- * "type": "page",
158
- * "path": "/:uid"
159
- * }
160
- * ```
161
- *
162
- * @example With a Content Relationship `parent` field.
163
- *
164
- * ```ts
165
- * {
166
- * "type": "page",
167
- * "path": "/:parent?/:uid",
168
- * "resolvers": {
169
- * "parent": "parent"
170
- * }
171
- * }
172
- * ```
173
- *
174
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
175
- */
176
- interface Route {
177
- /**
178
- * The Custom Type of the document.
179
- */
180
- type: string;
181
- /**
182
- * A specific UID to which this route definition is scoped. The route is only
183
- * defined for the document whose UID matches the given UID.
184
- */
185
- uid?: string;
186
- /**
187
- * A specific language to which this route definition is scoped. The route is
188
- * only defined for documents whose language matches the given language.
189
- */
190
- lang?: string;
191
- /**
192
- * The resolved path of the document with optional placeholders.
193
- */
194
- path: string;
195
- /**
196
- * An object that lists the API IDs of the Content Relationships in the route.
197
- */
198
- resolvers?: Record<string, string>;
199
- }
200
-
201
- /**
202
- * Parameters for the Prismic REST API V2.
203
- *
204
- * {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
205
- */
206
- interface QueryParams {
207
- /**
208
- * The secure token for accessing the API (only needed if your repository is
209
- * set to private).
210
- *
211
- * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
212
- */
213
- accessToken?: string;
214
- /**
215
- * The `pageSize` parameter defines the maximum number of documents that the
216
- * API will return for your query.
217
- *
218
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#pagesize}
219
- */
220
- pageSize?: number;
221
- /**
222
- * The `page` parameter defines the pagination for the result of your query.
223
- *
224
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#page}
225
- */
226
- page?: number;
227
- /**
228
- * The `after` parameter can be used along with the orderings option. It will
229
- * remove all the documents except for those after the specified document in the list.
230
- *
231
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#after}
232
- */
233
- after?: string;
234
- /**
235
- * The `fetch` parameter is used to make queries faster by only retrieving the
236
- * specified field(s).
237
- *
238
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetch}
239
- */
240
- fetch?: string | string[];
241
- /**
242
- * The `fetchLinks` parameter allows you to retrieve a specific content field
243
- * from a linked document and add it to the document response object.
244
- *
245
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#fetchlinks}
246
- */
247
- fetchLinks?: string | string[];
248
- /**
249
- * The `graphQuery` parameter allows you to specify which fields to retrieve
250
- * and what content to retrieve from Linked Documents / Content Relationships.
251
- *
252
- * {@link https://prismic.io/docs/technologies/graphquery-rest-api}
253
- */
254
- graphQuery?: string;
255
- /**
256
- * The `lang` option defines the language code for the results of your query.
257
- *
258
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#lang}
259
- */
260
- lang?: string;
261
- /**
262
- * The `orderings` parameter orders the results by the specified field(s). You
263
- * can specify as many fields as you want.
264
- *
265
- * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
266
- */
267
- orderings?: Ordering | string | (Ordering | string)[];
268
- /**
269
- * The `routes` option allows you to define how a document's `url` field is resolved.
270
- *
271
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
272
- */
273
- routes?: Route | string | (Route | string)[];
274
- /**
275
- * The `brokenRoute` option allows you to define the route populated in the
276
- * `url` property for broken Link or Content Relationship fields. A broken
277
- * link is a Link or Content Relationship field whose linked document has been
278
- * unpublished or deleted.
279
- *
280
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
281
- */
282
- brokenRoute?: string;
283
- }
284
- /**
285
- * Arguments for `buildQueryURL` to construct a Query URL.
286
- */
287
- declare type BuildQueryURLParams = {
288
- /**
289
- * Ref used to query documents.
290
- *
291
- * {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
292
- */
293
- ref: string;
294
- /**
295
- * Ref used to populate Integration Fields with the latest content.
296
- *
297
- * {@link https://prismic.io/docs/core-concepts/integration-fields}
298
- */
299
- integrationFieldsRef?: string;
300
- /**
301
- * One or more predicates to filter documents for the query.
302
- *
303
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
304
- */
305
- predicates?: string | string[];
306
- };
307
- declare type BuildQueryURLArgs = QueryParams & BuildQueryURLParams;
308
- /**
309
- * Build a Prismic REST API V2 URL to request documents from a repository. The
310
- * paginated response for this URL includes documents matching the parameters.
311
- *
312
- * A ref is required to make a request. Request the `endpoint` URL to retrieve a
313
- * list of available refs.
314
- *
315
- * Type the JSON response with `Query`.
316
- *
317
- * {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
318
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api}
319
- *
320
- * @param endpoint - URL to the repository's REST API V2.
321
- * @param args - Arguments to filter and scope the query.
322
- *
323
- * @returns URL that can be used to request documents from the repository.
324
- */
325
- declare const buildQueryURL: (endpoint: string, args: BuildQueryURLArgs) => string;
326
-
327
- /**
328
- * A ref or a function that returns a ref. If a static ref is known, one can be
329
- * given. If the ref must be fetched on-demand, a function can be provided. This
330
- * function can optionally be asynchronous.
331
- */
332
- declare type RefStringOrThunk = string | (() => string | undefined | Promise<string | undefined>);
333
- /**
334
- * Configuration for clients that determine how content is queried.
335
- */
336
- declare type ClientConfig = {
337
- /**
338
- * The secure token for accessing the Prismic repository. This is only
339
- * required if the repository is set to private.
340
- */
341
- accessToken?: string;
342
- /**
343
- * A string representing a version of the Prismic repository's content. This
344
- * may point to the latest version (called the "master ref"), or a preview
345
- * with draft content.
346
- */
347
- ref?: RefStringOrThunk;
348
- /**
349
- * A list of Route Resolver objects that define how a document's `url` field
350
- * is resolved.
351
- *
352
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
353
- */
354
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
355
- /**
356
- * The `brokenRoute` option allows you to define the route populated in the
357
- * `url` property for broken Link or Content Relationship fields. A broken
358
- * link is a Link or Content Relationship field whose linked document has been
359
- * unpublished or deleted.
360
- *
361
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
362
- */
363
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
364
- /**
365
- * Default parameters that will be sent with each query. These parameters can
366
- * be overridden on each query if needed.
367
- */
368
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes" | "brokenRoute">;
369
- /**
370
- * The function used to make network requests to the Prismic REST API. In
371
- * environments where a global `fetch` function does not exist, such as
372
- * Node.js, this function must be provided.
373
- */
374
- fetch?: FetchLike;
375
- };
376
- /**
377
- * Parameters for any client method that use `fetch()`. Only a subset of
378
- * `fetch()` parameters are exposed.
379
- */
380
- declare type FetchParams = {
381
- /**
382
- * An `AbortSignal` provided by an `AbortController`. This allows the network
383
- * request to be cancelled if necessary.
384
- *
385
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
386
- */
387
- signal?: AbortSignalLike;
388
- };
389
- /**
390
- * Parameters specific to client methods that fetch all documents. These methods
391
- * start with `getAll` (for example, `getAllByType`).
392
- */
393
- declare type GetAllParams = {
394
- /**
395
- * Limit the number of documents queried. If a number is not provided, there
396
- * will be no limit and all matching documents will be returned.
397
- */
398
- limit?: number;
399
- };
400
- /**
401
- * Arguments to determine how the URL for a preview session is resolved.
402
- */
403
- declare type ResolvePreviewArgs<LinkResolverReturnType> = {
404
- /**
405
- * A function that maps a Prismic document to a URL within your app.
406
- */
407
- linkResolver?: prismicH.LinkResolverFunction<LinkResolverReturnType>;
408
- /**
409
- * A fallback URL if the Link Resolver does not return a value.
410
- */
411
- defaultURL: string;
412
- /**
413
- * The preview token (also known as a ref) that will be used to query preview
414
- * content from the Prismic repository.
415
- */
416
- previewToken?: string;
417
- /**
418
- * The previewed document that will be used to determine the destination URL.
419
- */
420
- documentID?: string;
421
- };
422
- /**
423
- * Type definitions for the `createClient()` function. May be augmented by
424
- * third-party libraries.
425
- */
426
- interface CreateClient {
427
- <TDocuments extends prismicT.PrismicDocument>(...args: ConstructorParameters<typeof Client>): Client<TDocuments>;
428
- }
429
- /**
430
- * Creates a Prismic client that can be used to query a repository.
431
- *
432
- * @example
433
- *
434
- * ```ts
435
- * // With a repository name.
436
- * createClient("qwerty");
437
- *
438
- * // Or with a full Prismic Rest API V2 endpoint.
439
- * createClient("https://qwerty.cdn.prismic.io/api/v2");
440
- * ```
441
- *
442
- * @typeParam TDocuments - A map of Prismic document type IDs mapped to their
443
- * TypeScript type.
444
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
445
- * API V2 endpoint for the repository.
446
- * @param options - Configuration that determines how content will be queried
447
- * from the Prismic repository.
448
- *
449
- * @returns A client that can query content from the repository.
450
- */
451
- declare const createClient: CreateClient;
452
- /**
453
- * A client that allows querying content from a Prismic repository.
454
- *
455
- * If used in an environment where a global `fetch` function is unavailable,
456
- * such as Node.js, the `fetch` option must be provided as part of the `options`
457
- * parameter.
458
- *
459
- * @typeParam TDocuments - Document types that are registered for the Prismic
460
- * repository. Query methods will automatically be typed based on this type.
461
- */
462
- declare class Client<TDocuments extends prismicT.PrismicDocument = prismicT.PrismicDocument> {
463
- /**
464
- * The Prismic REST API V2 endpoint for the repository (use
465
- * `prismic.getRepositoryEndpoint` for the default endpoint).
466
- */
467
- endpoint: string;
468
- /**
469
- * The secure token for accessing the API (only needed if your repository is
470
- * set to private).
471
- *
472
- * {@link https://user-guides.prismic.io/en/articles/1036153-generating-an-access-token}
473
- */
474
- accessToken?: string;
475
- /**
476
- * A list of Route Resolver objects that define how a document's `url` field
477
- * is resolved.
478
- *
479
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
480
- */
481
- routes?: NonNullable<BuildQueryURLArgs["routes"]>;
482
- /**
483
- * The `brokenRoute` option allows you to define the route populated in the
484
- * `url` property for broken Link or Content Relationship fields. A broken
485
- * link is a Link or Content Relationship field whose linked document has been
486
- * unpublished or deleted.
487
- *
488
- * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
489
- */
490
- brokenRoute?: NonNullable<BuildQueryURLArgs["brokenRoute"]>;
491
- /**
492
- * The function used to make network requests to the Prismic REST API. In
493
- * environments where a global `fetch` function does not exist, such as
494
- * Node.js, this function must be provided.
495
- */
496
- fetchFn: FetchLike;
497
- /**
498
- * Default parameters that will be sent with each query. These parameters can
499
- * be overridden on each query if needed.
500
- */
501
- defaultParams?: Omit<BuildQueryURLArgs, "ref" | "integrationFieldsRef" | "accessToken" | "routes">;
502
- /**
503
- * The client's ref mode state. This determines which ref is used during queries.
504
- */
505
- private refState;
506
- /**
507
- * Cached repository value.
508
- */
509
- private cachedRepository;
510
- /**
511
- * Timestamp at which the cached repository data is considered stale.
512
- */
513
- private cachedRepositoryExpiration;
514
- /**
515
- * Creates a Prismic client that can be used to query a repository.
516
- *
517
- * If used in an environment where a global `fetch` function is unavailable,
518
- * such as Node.js, the `fetch` option must be provided as part of the
519
- * `options` parameter.
520
- *
521
- * @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
522
- * API V2 endpoint for the repository.
523
- * @param options - Configuration that determines how content will be queried
524
- * from the Prismic repository.
525
- *
526
- * @returns A client that can query content from the repository.
527
- */
528
- constructor(repositoryNameOrEndpoint: string, options?: ClientConfig);
529
- /**
530
- * Enables the client to automatically query content from a preview session if
531
- * one is active in browser environments. This is enabled by default in the browser.
532
- *
533
- * For server environments, use `enableAutoPreviewsFromReq`.
534
- *
535
- * @example
536
- *
537
- * ```ts
538
- * client.enableAutoPreviews();
539
- * ```
540
- *
541
- * @see enableAutoPreviewsFromReq
542
- */
543
- enableAutoPreviews(): void;
544
- /**
545
- * Enables the client to automatically query content from a preview session if
546
- * one is active in server environments. This is disabled by default on the server.
547
- *
548
- * For browser environments, use `enableAutoPreviews`.
549
- *
550
- * @example
551
- *
552
- * ```ts
553
- * // In an express app
554
- * app.get("/", function (req, res) {
555
- * client.enableAutoPreviewsFromReq(req);
556
- * });
557
- * ```
558
- *
559
- * @param req - An HTTP server request object containing the request's cookies.
560
- */
561
- enableAutoPreviewsFromReq<R extends HttpRequestLike>(req: R): void;
562
- /**
563
- * Disables the client from automatically querying content from a preview
564
- * session if one is active.
565
- *
566
- * Automatic preview content querying is enabled by default unless this method
567
- * is called.
568
- *
569
- * @example
570
- *
571
- * ```ts
572
- * client.disableAutoPreviews();
573
- * ```
574
- */
575
- disableAutoPreviews(): void;
576
- /**
577
- * Queries content from the Prismic repository.
578
- *
579
- * @deprecated Use `get` instead.
580
- * @example
581
- *
582
- * ```ts
583
- * const response = await client.query(
584
- * prismic.predicate.at("document.type", "page"),
585
- * );
586
- * ```
587
- *
588
- * @typeParam TDocument - Type of Prismic documents returned.
589
- * @param params - Parameters to filter, sort, and paginate results.
590
- *
591
- * @returns A paginated response containing the result of the query.
592
- */
593
- query<TDocument extends TDocuments>(predicates: NonNullable<BuildQueryURLArgs["predicates"]>, params?: Partial<Omit<BuildQueryURLArgs, "predicates">> & FetchParams): Promise<prismicT.Query<TDocument>>;
594
- /**
595
- * Queries content from the Prismic repository.
596
- *
597
- * @example
598
- *
599
- * ```ts
600
- * const response = await client.get();
601
- * ```
602
- *
603
- * @typeParam TDocument - Type of Prismic documents returned.
604
- * @param params - Parameters to filter, sort, and paginate results.
605
- *
606
- * @returns A paginated response containing the result of the query.
607
- */
608
- get<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
609
- /**
610
- * Queries content from the Prismic repository and returns only the first
611
- * result, if any.
612
- *
613
- * @example
614
- *
615
- * ```ts
616
- * const document = await client.getFirst();
617
- * ```
618
- *
619
- * @typeParam TDocument - Type of the Prismic document returned.
620
- * @param params - Parameters to filter, sort, and paginate results. @returns
621
- * The first result of the query, if any.
622
- */
623
- getFirst<TDocument extends TDocuments>(params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
624
- /**
625
- * **IMPORTANT**: Avoid using `dangerouslyGetAll` as it may be slower and
626
- * require more resources than other methods. Prefer using other methods that
627
- * filter by predicates such as `getAllByType`.
628
- *
629
- * Queries content from the Prismic repository and returns all matching
630
- * content. If no predicates are provided, all documents will be fetched.
631
- *
632
- * This method may make multiple network requests to query all matching content.
633
- *
634
- * @example
635
- *
636
- * ```ts
637
- * const response = await client.dangerouslyGetAll();
638
- * ```
639
- *
640
- * @typeParam TDocument - Type of Prismic documents returned.
641
- * @param params - Parameters to filter, sort, and paginate results.
642
- *
643
- * @returns A list of documents matching the query.
644
- */
645
- dangerouslyGetAll<TDocument extends TDocuments>(params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
646
- /**
647
- * Queries a document from the Prismic repository with a specific ID.
648
- *
649
- * @remarks
650
- * A document's UID is different from its ID. An ID is automatically generated
651
- * for all documents and is made available on its `id` property. A UID is
652
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
653
- * @example
654
- *
655
- * ```ts
656
- * const document = await client.getByID("WW4bKScAAMAqmluX");
657
- * ```
658
- *
659
- * @typeParam TDocument- Type of the Prismic document returned.
660
- * @param id - ID of the document.
661
- * @param params - Parameters to filter, sort, and paginate the results.
662
- *
663
- * @returns The document with an ID matching the `id` parameter, if a matching
664
- * document exists.
665
- */
666
- getByID<TDocument extends TDocuments>(id: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<TDocument>;
667
- /**
668
- * Queries documents from the Prismic repository with specific IDs.
669
- *
670
- * @remarks
671
- * A document's UID is different from its ID. An ID is automatically generated
672
- * for all documents and is made available on its `id` property. A UID is
673
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
674
- * @example
675
- *
676
- * ```ts
677
- * const response = await client.getByIDs([
678
- * "WW4bKScAAMAqmluX",
679
- * "U1kTRgEAAC8A5ldS",
680
- * ]);
681
- * ```
682
- *
683
- * @typeParam TDocument - Type of Prismic documents returned.
684
- * @param ids - A list of document IDs.
685
- * @param params - Parameters to filter, sort, and paginate the results.
686
- *
687
- * @returns A paginated response containing documents with IDs matching the
688
- * `ids` parameter.
689
- */
690
- getByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
691
- /**
692
- * Queries all documents from the Prismic repository with specific IDs.
693
- *
694
- * This method may make multiple network requests to query all matching content.
695
- *
696
- * @remarks
697
- * A document's UID is different from its ID. An ID is automatically generated
698
- * for all documents and is made available on its `id` property. A UID is
699
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
700
- * @example
701
- *
702
- * ```ts
703
- * const response = await client.getAllByIDs([
704
- * "WW4bKScAAMAqmluX",
705
- * "U1kTRgEAAC8A5ldS",
706
- * ]);
707
- * ```
708
- *
709
- * @typeParam TDocument - Type of Prismic documents returned.
710
- * @param ids - A list of document IDs.
711
- * @param params - Parameters to filter, sort, and paginate the results.
712
- *
713
- * @returns A list of documents with IDs matching the `ids` parameter.
714
- */
715
- getAllByIDs<TDocument extends TDocuments>(ids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<TDocument[]>;
716
- /**
717
- * Queries a document from the Prismic repository with a specific UID and Custom Type.
718
- *
719
- * @remarks
720
- * A document's UID is different from its ID. An ID is automatically generated
721
- * for all documents and is made available on its `id` property. A UID is
722
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
723
- * @example
724
- *
725
- * ```ts
726
- * const document = await client.getByUID("blog_post", "my-first-post");
727
- * ```
728
- *
729
- * @typeParam TDocument - Type of the Prismic document returned.
730
- * @param documentType - The API ID of the document's Custom Type.
731
- * @param uid - UID of the document.
732
- * @param params - Parameters to filter, sort, and paginate the results.
733
- *
734
- * @returns The document with a UID matching the `uid` parameter, if a
735
- * matching document exists.
736
- */
737
- getByUID<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uid: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
738
- /**
739
- * Queries document from the Prismic repository with specific UIDs and Custom Type.
740
- *
741
- * @remarks
742
- * A document's UID is different from its ID. An ID is automatically generated
743
- * for all documents and is made available on its `id` property. A UID is
744
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
745
- * @example
746
- *
747
- * ```ts
748
- * const document = await client.getByUIDs("blog_post", [
749
- * "my-first-post",
750
- * "my-second-post",
751
- * ]);
752
- * ```
753
- *
754
- * @typeParam TDocument - Type of the Prismic document returned.
755
- * @param documentType - The API ID of the document's Custom Type.
756
- * @param uids - A list of document UIDs.
757
- * @param params - Parameters to filter, sort, and paginate the results.
758
- *
759
- * @returns A paginated response containing documents with UIDs matching the
760
- * `uids` parameter.
761
- */
762
- getByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
763
- /**
764
- * Queries all documents from the Prismic repository with specific UIDs and Custom Type.
765
- *
766
- * This method may make multiple network requests to query all matching content.
767
- *
768
- * @remarks
769
- * A document's UID is different from its ID. An ID is automatically generated
770
- * for all documents and is made available on its `id` property. A UID is
771
- * provided in the Prismic editor and is unique among all documents of its Custom Type.
772
- * @example
773
- *
774
- * ```ts
775
- * const response = await client.getAllByUIDs([
776
- * "my-first-post",
777
- * "my-second-post",
778
- * ]);
779
- * ```
780
- *
781
- * @typeParam TDocument - Type of Prismic documents returned.
782
- * @param documentType - The API ID of the document's Custom Type.
783
- * @param uids - A list of document UIDs.
784
- * @param params - Parameters to filter, sort, and paginate the results.
785
- *
786
- * @returns A list of documents with UIDs matching the `uids` parameter.
787
- */
788
- getAllByUIDs<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, uids: string[], params?: Partial<BuildQueryURLArgs> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
789
- /**
790
- * Queries a singleton document from the Prismic repository for a specific Custom Type.
791
- *
792
- * @remarks
793
- * A singleton document is one that is configured in Prismic to only allow one
794
- * instance. For example, a repository may be configured to contain just one
795
- * Settings document. This is in contrast to a repeatable Custom Type which
796
- * allows multiple instances of itself.
797
- * @example
798
- *
799
- * ```ts
800
- * const document = await client.getSingle("settings");
801
- * ```
802
- *
803
- * @typeParam TDocument - Type of the Prismic document returned.
804
- * @param documentType - The API ID of the singleton Custom Type.
805
- * @param params - Parameters to filter, sort, and paginate the results.
806
- *
807
- * @returns The singleton document for the Custom Type, if a matching document exists.
808
- */
809
- getSingle<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>>;
810
- /**
811
- * Queries documents from the Prismic repository for a specific Custom Type.
812
- *
813
- * Use `getAllByType` instead if you need to query all documents for a
814
- * specific Custom Type.
815
- *
816
- * @example
817
- *
818
- * ```ts
819
- * const response = await client.getByType("blog_post");
820
- * ```
821
- *
822
- * @typeParam TDocument - Type of Prismic documents returned.
823
- * @param documentType - The API ID of the Custom Type.
824
- * @param params - Parameters to filter, sort, and paginate the results.
825
- *
826
- * @returns A paginated response containing documents of the Custom Type.
827
- */
828
- getByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<ExtractDocumentType<TDocument, TDocumentType>>>;
829
- /**
830
- * Queries all documents from the Prismic repository for a specific Custom Type.
831
- *
832
- * This method may make multiple network requests to query all matching content.
833
- *
834
- * @example
835
- *
836
- * ```ts
837
- * const response = await client.getByType("blog_post");
838
- * ```
839
- *
840
- * @typeParam TDocument - Type of Prismic documents returned.
841
- * @param documentType - The API ID of the Custom Type.
842
- * @param params - Parameters to filter, sort, and paginate the results.
843
- *
844
- * @returns A list of all documents of the Custom Type.
845
- */
846
- getAllByType<TDocument extends TDocuments, TDocumentType extends TDocument["type"] = TDocument["type"]>(documentType: TDocumentType, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<ExtractDocumentType<TDocument, TDocumentType>[]>;
847
- /**
848
- * Queries documents from the Prismic repository with a specific tag.
849
- *
850
- * Use `getAllByTag` instead if you need to query all documents with a specific tag.
851
- *
852
- * @example
853
- *
854
- * ```ts
855
- * const response = await client.getByTag("food");
856
- * ```
857
- *
858
- * @typeParam TDocument - Type of Prismic documents returned.
859
- * @param tag - The tag that must be included on a document.
860
- * @param params - Parameters to filter, sort, and paginate the results.
861
- *
862
- * @returns A paginated response containing documents with the tag.
863
- */
864
- getByTag<TDocument extends TDocuments>(tag: string, params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
865
- /**
866
- * Queries all documents from the Prismic repository with a specific tag.
867
- *
868
- * This method may make multiple network requests to query all matching content.
869
- *
870
- * @example
871
- *
872
- * ```ts
873
- * const response = await client.getAllByTag("food");
874
- * ```
875
- *
876
- * @typeParam TDocument - Type of Prismic documents returned.
877
- * @param tag - The tag that must be included on a document.
878
- * @param params - Parameters to filter, sort, and paginate the results.
879
- *
880
- * @returns A list of all documents with the tag.
881
- */
882
- getAllByTag<TDocument extends TDocuments>(tag: string, params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
883
- /**
884
- * Queries documents from the Prismic repository with specific tags. A
885
- * document must be tagged with all of the queried tags to be included.
886
- *
887
- * @example
888
- *
889
- * ```ts
890
- * const response = await client.getByEveryTag(["food", "fruit"]);
891
- * ```
892
- *
893
- * @typeParam TDocument - Type of Prismic documents returned.
894
- * @param tags - A list of tags that must be included on a document.
895
- * @param params - Parameters to filter, sort, and paginate the results.
896
- *
897
- * @returns A paginated response containing documents with the tags.
898
- */
899
- getByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
900
- /**
901
- * Queries documents from the Prismic repository with specific tags. A
902
- * document must be tagged with all of the queried tags to be included.
903
- *
904
- * This method may make multiple network requests to query all matching content.
905
- *
906
- * @example
907
- *
908
- * ```ts
909
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
910
- * ```
911
- *
912
- * @typeParam TDocument - Type of Prismic documents returned.
913
- * @param tags - A list of tags that must be included on a document.
914
- * @param params - Parameters to filter, sort, and paginate the results.
915
- *
916
- * @returns A list of all documents with the tags.
917
- */
918
- getAllByEveryTag<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
919
- /**
920
- * Queries documents from the Prismic repository with specific tags. A
921
- * document must be tagged with at least one of the queried tags to be included.
922
- *
923
- * @example
924
- *
925
- * ```ts
926
- * const response = await client.getByEveryTag(["food", "fruit"]);
927
- * ```
928
- *
929
- * @typeParam TDocument - Type of Prismic documents returned.
930
- * @param tags - A list of tags that must be included on a document.
931
- * @param params - Parameters to filter, sort, and paginate the results.
932
- *
933
- * @returns A paginated response containing documents with at least one of the tags.
934
- */
935
- getBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<BuildQueryURLArgs> & FetchParams): Promise<prismicT.Query<TDocument>>;
936
- /**
937
- * Queries documents from the Prismic repository with specific tags. A
938
- * document must be tagged with at least one of the queried tags to be included.
939
- *
940
- * This method may make multiple network requests to query all matching content.
941
- *
942
- * @example
943
- *
944
- * ```ts
945
- * const response = await client.getAllByEveryTag(["food", "fruit"]);
946
- * ```
947
- *
948
- * @typeParam TDocument - Type of Prismic documents returned.
949
- * @param tags - A list of tags that must be included on a document.
950
- * @param params - Parameters to filter, sort, and paginate the results.
951
- *
952
- * @returns A list of all documents with at least one of the tags.
953
- */
954
- getAllBySomeTags<TDocument extends TDocuments>(tags: string[], params?: Partial<Omit<BuildQueryURLArgs, "page">> & GetAllParams & FetchParams): Promise<TDocument[]>;
955
- /**
956
- * Returns metadata about the Prismic repository, such as its refs, releases,
957
- * and custom types.
958
- *
959
- * @returns Repository metadata.
960
- */
961
- getRepository(params?: FetchParams): Promise<prismicT.Repository>;
962
- /**
963
- * Returns a list of all refs for the Prismic repository.
964
- *
965
- * Refs are used to identify which version of the repository's content should
966
- * be queried. All repositories will have at least one ref pointing to the
967
- * latest published content called the "master ref".
968
- *
969
- * @returns A list of all refs for the Prismic repository.
970
- */
971
- getRefs(params?: FetchParams): Promise<prismicT.Ref[]>;
972
- /**
973
- * Returns a ref for the Prismic repository with a matching ID.
974
- *
975
- * @param id - ID of the ref.
976
- *
977
- * @returns The ref with a matching ID, if it exists.
978
- */
979
- getRefByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
980
- /**
981
- * Returns a ref for the Prismic repository with a matching label.
982
- *
983
- * @param label - Label of the ref.
984
- *
985
- * @returns The ref with a matching label, if it exists.
986
- */
987
- getRefByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
988
- /**
989
- * Returns the master ref for the Prismic repository. The master ref points to
990
- * the repository's latest published content.
991
- *
992
- * @returns The repository's master ref.
993
- */
994
- getMasterRef(params?: FetchParams): Promise<prismicT.Ref>;
995
- /**
996
- * Returns a list of all Releases for the Prismic repository. Releases are
997
- * used to group content changes before publishing.
998
- *
999
- * @returns A list of all Releases for the Prismic repository.
1000
- */
1001
- getReleases(params?: FetchParams): Promise<prismicT.Ref[]>;
1002
- /**
1003
- * Returns a Release for the Prismic repository with a matching ID.
1004
- *
1005
- * @param id - ID of the Release.
1006
- *
1007
- * @returns The Release with a matching ID, if it exists.
1008
- */
1009
- getReleaseByID(id: string, params?: FetchParams): Promise<prismicT.Ref>;
1010
- /**
1011
- * Returns a Release for the Prismic repository with a matching label.
1012
- *
1013
- * @param label - Label of the ref.
1014
- *
1015
- * @returns The ref with a matching label, if it exists.
1016
- */
1017
- getReleaseByLabel(label: string, params?: FetchParams): Promise<prismicT.Ref>;
1018
- /**
1019
- * Returns a list of all tags used in the Prismic repository.
1020
- *
1021
- * @returns A list of all tags used in the repository.
1022
- */
1023
- getTags(params?: FetchParams): Promise<string[]>;
1024
- /**
1025
- * Builds a URL used to query content from the Prismic repository.
1026
- *
1027
- * @param params - Parameters to filter, sort, and paginate the results.
1028
- *
1029
- * @returns A URL string that can be requested to query content.
1030
- */
1031
- buildQueryURL({ signal, ...params }?: Partial<BuildQueryURLArgs> & FetchParams): Promise<string>;
1032
- /**
1033
- * Determines the URL for a previewed document during an active preview
1034
- * session. The result of this method should be used to redirect the user to
1035
- * the document's URL.
1036
- *
1037
- * @example
1038
- *
1039
- * ```ts
1040
- * const url = client.resolvePreviewURL({
1041
- * linkResolver: (document) => `/${document.uid}`
1042
- * defaultURL: '/'
1043
- * })
1044
- * ```
1045
- *
1046
- * @param args - Arguments to configure the URL resolving.
1047
- *
1048
- * @returns The URL for the previewed document during an active preview
1049
- * session. The user should be redirected to this URL.
1050
- */
1051
- resolvePreviewURL<LinkResolverReturnType>(args: ResolvePreviewArgs<LinkResolverReturnType> & FetchParams): Promise<string>;
1052
- /**
1053
- * Configures the client to query the latest published content for all future queries.
1054
- *
1055
- * If the `ref` parameter is provided during a query, it takes priority for that query.
1056
- *
1057
- * @example
1058
- *
1059
- * ```ts
1060
- * await client.queryLatestContent();
1061
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1062
- * ```
1063
- */
1064
- queryLatestContent(): void;
1065
- /**
1066
- * Configures the client to query content from a specific Release identified
1067
- * by its ID for all future queries.
1068
- *
1069
- * If the `ref` parameter is provided during a query, it takes priority for that query.
1070
- *
1071
- * @example
1072
- *
1073
- * ```ts
1074
- * await client.queryContentFromReleaseByID("YLB7OBAAACMA7Cpa");
1075
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1076
- * ```
1077
- *
1078
- * @param releaseID - The ID of the Release.
1079
- */
1080
- queryContentFromReleaseByID(releaseID: string): void;
1081
- /**
1082
- * Configures the client to query content from a specific Release identified
1083
- * by its label for all future queries.
1084
- *
1085
- * If the `ref` parameter is provided during a query, it takes priority for that query.
1086
- *
1087
- * @example
1088
- *
1089
- * ```ts
1090
- * await client.queryContentFromReleaseByLabel("My Release");
1091
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1092
- * ```
1093
- *
1094
- * @param releaseLabel - The label of the Release.
1095
- */
1096
- queryContentFromReleaseByLabel(releaseLabel: string): void;
1097
- /**
1098
- * Configures the client to query content from a specific ref. The ref can be
1099
- * provided as a string or a function.
1100
- *
1101
- * If a function is provided, the ref is fetched lazily before each query. The
1102
- * function may also be asynchronous.
1103
- *
1104
- * @example
1105
- *
1106
- * ```ts
1107
- * await client.queryContentFromRef("my-ref");
1108
- * const document = await client.getByID("WW4bKScAAMAqmluX");
1109
- * ```
1110
- *
1111
- * @param ref - The ref or a function that returns the ref from which to query content.
1112
- */
1113
- queryContentFromRef(ref: RefStringOrThunk): void;
1114
- /**
1115
- * @deprecated Renamed to `graphQLFetch()` (note the capitalization of "QL").
1116
- */
1117
- graphqlFetch: (input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
1118
- signal?: AbortSignalLike;
1119
- }) => Promise<Response>;
1120
- /**
1121
- * A `fetch()` function to be used with GraphQL clients configured for
1122
- * Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
1123
- * and Authorization headers. Queries will automatically be minified by
1124
- * removing whitespace where possible.
1125
- *
1126
- * @example
1127
- *
1128
- * ```ts
1129
- * const graphqlClient = new ApolloClient({
1130
- * link: new HttpLink({
1131
- * uri: prismic.getGraphQLEndpoint(repositoryName),
1132
- * // Provide `client.graphqlFetch` as the fetch implementation.
1133
- * fetch: client.graphqlFetch,
1134
- * // Using GET is required.
1135
- * useGETForQueries: true,
1136
- * }),
1137
- * cache: new InMemoryCache(),
1138
- * });
1139
- * ```
1140
- *
1141
- * @param input - The `fetch()` `input` parameter. Only strings are supported.
1142
- * @param init - The `fetch()` `init` parameter. Only plain objects are supported.
1143
- *
1144
- * @returns The `fetch()` Response for the request.
1145
- * @experimental
1146
- */
1147
- graphQLFetch(input: RequestInfo, init?: Omit<RequestInit, "signal"> & {
1148
- signal?: AbortSignalLike;
1149
- }): Promise<Response>;
1150
- /**
1151
- * Returns a cached version of `getRepository` with a TTL.
1152
- *
1153
- * @returns Cached repository metadata.
1154
- */
1155
- private getCachedRepository;
1156
- /**
1157
- * Returns a cached Prismic repository form. Forms are used to determine API
1158
- * endpoints for types of repository data.
1159
- *
1160
- * @param name - Name of the form.
1161
- *
1162
- * @returns The repository form.
1163
- * @throws If a matching form cannot be found.
1164
- */
1165
- private getCachedRepositoryForm;
1166
- /**
1167
- * Returns the ref needed to query based on the client's current state. This
1168
- * method may make a network request to fetch a ref or resolve the user's ref thunk.
1169
- *
1170
- * If auto previews are enabled, the preview ref takes priority if available.
1171
- *
1172
- * The following strategies are used depending on the client's state:
1173
- *
1174
- * - If the user called `queryLatestContent`: Use the repository's master ref.
1175
- * The ref is cached for 5 seconds. After 5 seconds, a new master ref is fetched.
1176
- * - If the user called `queryContentFromReleaseByID`: Use the release's ref.
1177
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
1178
- * release is fetched.
1179
- * - If the user called `queryContentFromReleaseByLabel`: Use the release's ref.
1180
- * The ref is cached for 5 seconds. After 5 seconds, a new ref for the
1181
- * release is fetched.
1182
- * - If the user called `queryContentFromRef`: Use the provided ref. Fall back
1183
- * to the master ref if the ref is not a string.
1184
- *
1185
- * @returns The ref to use during a query.
1186
- */
1187
- private getResolvedRefString;
1188
- /**
1189
- * Performs a network request using the configured `fetch` function. It
1190
- * assumes all successful responses will have a JSON content type. It also
1191
- * normalizes unsuccessful network requests.
1192
- *
1193
- * @typeParam T - The JSON response.
1194
- * @param url - URL to the resource to fetch.
1195
- * @param params - Prismic REST API parameters for the network request.
1196
- *
1197
- * @returns The JSON response from the network request.
1198
- */
1199
- private fetch;
1200
- }
1201
-
1202
- declare const predicate: {
1203
- /**
1204
- * The `at` predicate checks that the path matches the described value
1205
- * exactly. It takes a single value for a field or an array (only for tags).
1206
- *
1207
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}
1208
- */
1209
- at: (path: string, value: string | number | boolean | Date | string[]) => string;
1210
- /**
1211
- * The `not` predicate checks that the path doesn't match the provided value
1212
- * exactly. It takes a single value for a field or an array (only for tags).
1213
- *
1214
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}
1215
- */
1216
- not: (path: string, value: string | number | boolean | Date | string[]) => string;
1217
- /**
1218
- * The `any` predicate takes an array of values. It works exactly the same way
1219
- * as the `at` operator, but checks whether the fragment matches any of the
1220
- * values in the array.
1221
- *
1222
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}
1223
- */
1224
- any: (path: string, values: (string | number | boolean | Date)[]) => string;
1225
- /**
1226
- * The `in` predicate is used specifically to retrieve an array of documents
1227
- * by their IDs or UIDs. This predicate is much more efficient at this than
1228
- * the any predicate.
1229
- *
1230
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}
1231
- */
1232
- in: (path: string, values: string[]) => string;
1233
- /**
1234
- * The `fulltext` predicate provides two capabilities:
1235
- *
1236
- * 1. Checking if a certain string is anywhere inside a document (this is what
1237
- * you should use to make your project's search engine feature)
1238
- * 2. Checking if the string is contained inside a specific custom type’s Rich
1239
- * Text or Key Text fragment.
1240
- *
1241
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}
1242
- */
1243
- fulltext: (path: string, searchTerms: string) => string;
1244
- /**
1245
- * The `has` predicate checks whether a fragment has a value. It will return
1246
- * all the documents of the specified type that contain a value for the
1247
- * specified field.
1248
- *
1249
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}
1250
- */
1251
- has: (path: string) => string;
1252
- /**
1253
- * The `missing` predicate checks if a fragment doesn't have a value. It will
1254
- * return all the documents of the specified type that do not contain a value
1255
- * for the specified field.
1256
- *
1257
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}
1258
- */
1259
- missing: (path: string) => string;
1260
- /**
1261
- * The `similar` predicate takes the ID of a document, and returns a list of
1262
- * documents with similar content. This allows you to build an automated
1263
- * content discovery feature (for example, a "Related posts" section).
1264
- *
1265
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}
1266
- */
1267
- similar: (id: string, value: number) => string;
1268
- /**
1269
- * The `geopoint.near` predicate checks that the value in the path is within
1270
- * the radius of the given coordinates.
1271
- *
1272
- * This predicate will only work for a GeoPoint field.
1273
- *
1274
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}
1275
- */
1276
- geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1277
- /**
1278
- * The `number.lt` predicate checks that the value in the number field is less
1279
- * than the value passed into the predicate.
1280
- *
1281
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}
1282
- */
1283
- numberLessThan: (path: string, value: number) => string;
1284
- /**
1285
- * The `number.gt` predicate checks that the value in the number field is
1286
- * greater than the value passed into the predicate.
1287
- *
1288
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}
1289
- */
1290
- numberGreaterThan: (path: string, value: number) => string;
1291
- /**
1292
- * The `number.inRange` predicate checks that the value in the path is within
1293
- * the two values passed into the predicate.
1294
- *
1295
- * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}
1296
- */
1297
- numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1298
- /**
1299
- * The `date.after` predicate checks that the value in the path is after the
1300
- * date value passed into the predicate.
1301
- *
1302
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}
1303
- */
1304
- dateAfter: (path: string, date: string | number | Date) => string;
1305
- /**
1306
- * The `date.before` predicate checks that the value in the path is before the
1307
- * date value passed into the predicate.
1308
- *
1309
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}
1310
- */
1311
- dateBefore: (path: string, date: string | number | Date) => string;
1312
- /**
1313
- * The `date.between` predicate checks that the value in the path is within
1314
- * the date values passed into the predicate.
1315
- *
1316
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}
1317
- */
1318
- dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1319
- /**
1320
- * The `date.day-of-month` predicate checks that the value in the path is
1321
- * equal to the day of the month passed into the predicate.
1322
- *
1323
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}
1324
- */
1325
- dateDayOfMonth: (path: string, day: number) => string;
1326
- /**
1327
- * The `date.day-of-month-after` predicate checks that the value in the path
1328
- * is after the day of the month passed into the predicate.
1329
- *
1330
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}
1331
- */
1332
- dateDayOfMonthAfter: (path: string, day: number) => string;
1333
- /**
1334
- * The `date.day-of-month-before` predicate checks that the value in the path
1335
- * is before the day of the month passed into the predicate.
1336
- *
1337
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}
1338
- */
1339
- dateDayOfMonthBefore: (path: string, day: number) => string;
1340
- /**
1341
- * The `date.day-of-week` predicate checks that the value in the path is equal
1342
- * to the day of the week passed into the predicate.
1343
- *
1344
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}
1345
- */
1346
- dateDayOfWeek: (path: string, day: string | number) => string;
1347
- /**
1348
- * The `date.day-of-week-after` predicate checks that the value in the path is
1349
- * after the day of the week passed into the predicate.
1350
- *
1351
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}
1352
- */
1353
- dateDayOfWeekAfter: (path: string, day: string | number) => string;
1354
- /**
1355
- * The date.day-of-week-before predicate checks that the value in the path is
1356
- * before the day of the week passed into the predicate.
1357
- *
1358
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}
1359
- */
1360
- dateDayOfWeekBefore: (path: string, day: string | number) => string;
1361
- /**
1362
- * The `date.month` predicate checks that the value in the path occurs in the
1363
- * month value passed into the predicate.
1364
- *
1365
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}
1366
- */
1367
- dateMonth: (path: string, month: string | number) => string;
1368
- /**
1369
- * The `date.month-after` predicate checks that the value in the path occurs
1370
- * in any month after the value passed into the predicate.
1371
- *
1372
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}
1373
- */
1374
- dateMonthAfter: (path: string, month: string | number) => string;
1375
- /**
1376
- * The `date.month-before` predicate checks that the value in the path occurs
1377
- * in any month before the value passed into the predicate.
1378
- *
1379
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}
1380
- */
1381
- dateMonthBefore: (path: string, month: string | number) => string;
1382
- /**
1383
- * The `date.year` predicate checks that the value in the path occurs in the
1384
- * year value passed into the predicate.
1385
- *
1386
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}
1387
- */
1388
- dateYear: (path: string, year: number) => string;
1389
- /**
1390
- * The `date.hour` predicate checks that the value in the path occurs within
1391
- * the hour value passed into the predicate.
1392
- *
1393
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}
1394
- */
1395
- dateHour: (path: string, hour: number) => string;
1396
- /**
1397
- * The `date.hour-after` predicate checks that the value in the path occurs
1398
- * after the hour value passed into the predicate.
1399
- *
1400
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}
1401
- */
1402
- dateHourAfter: (path: string, hour: number) => string;
1403
- /**
1404
- * The `date.hour-before` predicate checks that the value in the path occurs
1405
- * before the hour value passed into the predicate.
1406
- *
1407
- * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}
1408
- */
1409
- dateHourBefore: (path: string, hour: number) => string;
1410
- };
1411
-
1412
- declare class PrismicError<Response> extends Error {
1413
- url?: string;
1414
- response: Response;
1415
- constructor(message: string | undefined, url: string | undefined, response: Response);
1416
- }
1417
-
1418
- declare type ForbiddenErrorRepositoryAPIResponse = {
1419
- type: string;
1420
- message: string;
1421
- };
1422
- declare type ForbiddenErrorQueryAPIResponse = {
1423
- error: string;
1424
- };
1425
- declare class ForbiddenError extends PrismicError<ForbiddenErrorRepositoryAPIResponse | ForbiddenErrorQueryAPIResponse> {
1426
- }
1427
-
1428
- declare type ParsingErrorAPIResponse = {
1429
- type: "parsing-error";
1430
- message: string;
1431
- line: number;
1432
- column: number;
1433
- id: number;
1434
- location: string;
1435
- };
1436
- declare class ParsingError extends PrismicError<ParsingErrorAPIResponse> {
1437
- }
1438
-
1439
- declare class NotFoundError extends PrismicError<undefined> {
1440
- }
1441
-
1442
- /**
1443
- * The well-known name of the cookie used to store a Prismic preview session's ref.
1444
- */
1445
- declare const preview = "io.prismic.preview";
1446
-
1447
- declare const cookie_preview: typeof preview;
1448
- declare namespace cookie {
1449
- export {
1450
- cookie_preview as preview,
1451
- };
1452
- }
1453
-
1454
- /**
1455
- * @deprecated Renamed to `getRepositoryEndpoint`.
1456
- */
1457
- declare const getEndpoint: <RepositoryName extends string>(repositoryName: RepositoryName) => `https://${RepositoryName}.cdn.prismic.io/api/v2`;
1458
-
1459
- /**
1460
- * @deprecated Renamed to `predicate` (without an "s").
1461
- */
1462
- declare const predicates: {
1463
- at: (path: string, value: string | number | boolean | Date | string[]) => string;
1464
- not: (path: string, value: string | number | boolean | Date | string[]) => string;
1465
- any: (path: string, values: (string | number | boolean | Date)[]) => string;
1466
- in: (path: string, values: string[]) => string;
1467
- fulltext: (path: string, searchTerms: string) => string;
1468
- has: (path: string) => string;
1469
- missing: (path: string) => string;
1470
- similar: (id: string, value: number) => string;
1471
- geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1472
- numberLessThan: (path: string, value: number) => string;
1473
- numberGreaterThan: (path: string, value: number) => string;
1474
- numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1475
- dateAfter: (path: string, date: string | number | Date) => string;
1476
- dateBefore: (path: string, date: string | number | Date) => string;
1477
- dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1478
- dateDayOfMonth: (path: string, day: number) => string;
1479
- dateDayOfMonthAfter: (path: string, day: number) => string;
1480
- dateDayOfMonthBefore: (path: string, day: number) => string;
1481
- dateDayOfWeek: (path: string, day: string | number) => string;
1482
- dateDayOfWeekAfter: (path: string, day: string | number) => string;
1483
- dateDayOfWeekBefore: (path: string, day: string | number) => string;
1484
- dateMonth: (path: string, month: string | number) => string;
1485
- dateMonthAfter: (path: string, month: string | number) => string;
1486
- dateMonthBefore: (path: string, month: string | number) => string;
1487
- dateYear: (path: string, year: number) => string;
1488
- dateHour: (path: string, hour: number) => string;
1489
- dateHourAfter: (path: string, hour: number) => string;
1490
- dateHourBefore: (path: string, hour: number) => string;
1491
- };
1492
- /**
1493
- * @deprecated Renamed to `predicate` (lowercase and without an "s").
1494
- */
1495
- declare const Predicates: {
1496
- at: (path: string, value: string | number | boolean | Date | string[]) => string;
1497
- not: (path: string, value: string | number | boolean | Date | string[]) => string;
1498
- any: (path: string, values: (string | number | boolean | Date)[]) => string;
1499
- in: (path: string, values: string[]) => string;
1500
- fulltext: (path: string, searchTerms: string) => string;
1501
- has: (path: string) => string;
1502
- missing: (path: string) => string;
1503
- similar: (id: string, value: number) => string;
1504
- geopointNear: (path: string, latitude: number, longitude: number, radius: number) => string;
1505
- numberLessThan: (path: string, value: number) => string;
1506
- numberGreaterThan: (path: string, value: number) => string;
1507
- numberInRange: (path: string, lowerLimit: number, upperLimit: number) => string;
1508
- dateAfter: (path: string, date: string | number | Date) => string;
1509
- dateBefore: (path: string, date: string | number | Date) => string;
1510
- dateBetween: (path: string, startDate: string | number | Date, endDate: string | number | Date) => string;
1511
- dateDayOfMonth: (path: string, day: number) => string;
1512
- dateDayOfMonthAfter: (path: string, day: number) => string;
1513
- dateDayOfMonthBefore: (path: string, day: number) => string;
1514
- dateDayOfWeek: (path: string, day: string | number) => string;
1515
- dateDayOfWeekAfter: (path: string, day: string | number) => string;
1516
- dateDayOfWeekBefore: (path: string, day: string | number) => string;
1517
- dateMonth: (path: string, month: string | number) => string;
1518
- dateMonthAfter: (path: string, month: string | number) => string;
1519
- dateMonthBefore: (path: string, month: string | number) => string;
1520
- dateYear: (path: string, year: number) => string;
1521
- dateHour: (path: string, hour: number) => string;
1522
- dateHourAfter: (path: string, hour: number) => string;
1523
- dateHourBefore: (path: string, hour: number) => string;
1524
- };
1525
-
1526
- export { AbortSignalLike, BuildQueryURLArgs, Client, ClientConfig, CreateClient, FetchLike, ForbiddenError, HttpRequestLike, NotFoundError, Ordering, ParsingError, Predicates, PrismicError, QueryParams, RequestInitLike, ResponseLike, Route, buildQueryURL, cookie, createClient, getEndpoint, getGraphQLEndpoint, getRepositoryEndpoint, getRepositoryName, isRepositoryEndpoint, isRepositoryName, predicate, predicates };
1
+ export { getRepositoryEndpoint } from "./getRepositoryEndpoint";
2
+ export { getRepositoryName } from "./getRepositoryName";
3
+ export { getGraphQLEndpoint } from "./getGraphQLEndpoint";
4
+ export { isRepositoryName } from "./isRepositoryName";
5
+ export { isRepositoryEndpoint } from "./isRepositoryEndpoint";
6
+ export { buildQueryURL } from "./buildQueryURL";
7
+ export { createClient, Client } from "./client";
8
+ export { predicate } from "./predicate";
9
+ export { PrismicError } from "./PrismicError";
10
+ export { ForbiddenError } from "./ForbiddenError";
11
+ export { ParsingError } from "./ParsingError";
12
+ export { NotFoundError } from "./NotFoundError";
13
+ export * as cookie from "./cookie";
14
+ export type { CreateClient, ClientConfig } from "./client";
15
+ export type { QueryParams, BuildQueryURLArgs } from "./buildQueryURL";
16
+ export type { AbortSignalLike, FetchLike, HttpRequestLike, Ordering, RequestInitLike, ResponseLike, Route, } from "./types/client";
17
+ export { asDate } from "./helpers/asDate";
18
+ export { asLink } from "./helpers/asLink";
19
+ export { asText } from "./helpers/asText";
20
+ export { asHTML } from "./helpers/asHTML";
21
+ export { asImageSrc } from "./helpers/asImageSrc";
22
+ export { asImageWidthSrcSet } from "./helpers/asImageWidthSrcSet";
23
+ export { asImagePixelDensitySrcSet } from "./helpers/asImagePixelDensitySrcSet";
24
+ export * as isFilled from "./helpers/isFilled";
25
+ export { documentToLinkField } from "./helpers/documentToLinkField";
26
+ export { Element } from "@prismicio/richtext";
27
+ export type { LinkResolverFunction, HTMLFunctionSerializer, HTMLMapSerializer, } from "./types/helpers";
28
+ export { RichTextNodeType } from "./types/value/richText";
29
+ export { LinkType } from "./types/value/link";
30
+ export { OEmbedType } from "./types/value/embed";
31
+ export type { PrismicDocument, PrismicDocumentWithUID, PrismicDocumentWithoutUID, PrismicDocumentHeader, AlternateLanguage, } from "./types/value/document";
32
+ export type { RichTextField, RTTextNodeBase, RTHeading1Node, RTHeading2Node, RTHeading3Node, RTHeading4Node, RTHeading5Node, RTHeading6Node, RTParagraphNode, RTPreformattedNode, RTListItemNode, RTOListItemNode, RTSpanNodeBase, RTStrongNode, RTEmNode, RTLabelNode, RTImageNode, RTEmbedNode, RTLinkNode, RTListNode, RTOListNode, RTSpanNode, RTNode, RTTextNode, RTBlockNode, RTInlineNode, RTAnyNode, } from "./types/value/richText";
33
+ export type { TitleField } from "./types/value/title";
34
+ export type { ImageField, ImageFieldImage, FilledImageFieldImage, EmptyImageFieldImage, } from "./types/value/image";
35
+ export type { EmptyLinkField, LinkField, FilledLinkToWebField, } from "./types/value/link";
36
+ export type { ContentRelationshipField, FilledContentRelationshipField, } from "./types/value/contentRelationship";
37
+ export type { LinkToMediaField, FilledLinkToMediaField, } from "./types/value/linkToMedia";
38
+ export type { OEmbedExtra, PhotoOEmbed, VideoOEmbed, LinkOEmbed, RichOEmbed, AnyOEmbed, EmbedField, } from "./types/value/embed";
39
+ export type { BooleanField } from "./types/value/boolean";
40
+ export type { ColorField } from "./types/value/color";
41
+ export type { DateField } from "./types/value/date";
42
+ export type { KeyTextField } from "./types/value/keyText";
43
+ export type { NumberField } from "./types/value/number";
44
+ export type { SelectField } from "./types/value/select";
45
+ export type { TimestampField } from "./types/value/timestamp";
46
+ export type { GeoPointField } from "./types/value/geoPoint";
47
+ export type { IntegrationFields } from "./types/value/integrationFields";
48
+ export type { GroupField } from "./types/value/group";
49
+ export type { SliceZone } from "./types/value/sliceZone";
50
+ export type { Slice } from "./types/value/slice";
51
+ export type { SharedSlice } from "./types/value/sharedSlice";
52
+ export type { SharedSliceVariation } from "./types/value/sharedSliceVariation";
53
+ export type { FieldState, AnyRegularField } from "./types/value/types";
54
+ export { CustomTypeModelFieldType } from "./types/model/types";
55
+ export { CustomTypeModelLinkSelectType } from "./types/model/link";
56
+ export { CustomTypeModelSliceType } from "./types/model/sliceZone";
57
+ export { CustomTypeModelSliceDisplay } from "./types/model/slice";
58
+ export type { CustomTypeModel, CustomTypeModelDefinition, CustomTypeModelTab, } from "./types/model/customType";
59
+ export type { CustomTypeModelRichTextField, CustomTypeModelRichTextMultiField, CustomTypeModelRichTextSingleField, } from "./types/model/richText";
60
+ export type { CustomTypeModelTitleField } from "./types/model/title";
61
+ export type { CustomTypeModelImageField, CustomTypeModelImageConstraint, CustomTypeModelImageThumbnail, } from "./types/model/image";
62
+ export type { CustomTypeModelContentRelationshipField } from "./types/model/contentRelationship";
63
+ export type { CustomTypeModelLinkField } from "./types/model/link";
64
+ export type { CustomTypeModelLinkToMediaField } from "./types/model/linkToMedia";
65
+ export type { CustomTypeModelEmbedField } from "./types/model/embed";
66
+ export type { CustomTypeModelBooleanField } from "./types/model/boolean";
67
+ export type { CustomTypeModelColorField } from "./types/model/color";
68
+ export type { CustomTypeModelDateField } from "./types/model/date";
69
+ export type { CustomTypeModelKeyTextField } from "./types/model/keyText";
70
+ export type { CustomTypeModelNumberField } from "./types/model/number";
71
+ export type { CustomTypeModelSelectField } from "./types/model/select";
72
+ export type { CustomTypeModelTimestampField } from "./types/model/timestamp";
73
+ export type { CustomTypeModelGeoPointField } from "./types/model/geoPoint";
74
+ export type { CustomTypeModelIntegrationFieldsField } from "./types/model/integrationFields";
75
+ export type { CustomTypeModelGroupField } from "./types/model/group";
76
+ export type { CustomTypeModelSliceZoneField, CustomTypeModelSliceLabel, CustomTypeModelSharedSlice, } from "./types/model/sliceZone";
77
+ export type { CustomTypeModelSlice, CustomTypeModelLegacySlice, } from "./types/model/slice";
78
+ export type { SharedSliceModel } from "./types/model/sharedSlice";
79
+ export type { SharedSliceModelVariation } from "./types/model/sharedSliceVariation";
80
+ export type { CustomTypeModelUIDField } from "./types/model/uid";
81
+ export type { CustomTypeModelRangeField } from "./types/model/range";
82
+ export type { CustomTypeModelSeparatorField } from "./types/model/separator";
83
+ export type { CustomTypeModelField, CustomTypeModelFieldForGroup, } from "./types/model/types";
84
+ export type { Query } from "./types/api/query";
85
+ export type { Ref } from "./types/api/ref";
86
+ export type { Release } from "./types/api/release";
87
+ export type { Repository, Language, Form, FormField, } from "./types/api/repository";
88
+ export type { Tags } from "./types/api/tags";
89
+ export { WebhookType } from "./types/webhook/types";
90
+ export type { WebhookBody } from "./types/webhook/types";
91
+ export type { WebhookBodyAPIUpdate } from "./types/webhook/apiUpdate";
92
+ export type { WebhookBodyTestTrigger } from "./types/webhook/testTrigger";