@prismicio/client 6.7.1 → 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} +3 -37
  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
@@ -0,0 +1,68 @@
1
+ const formatValue = (value) => {
2
+ if (Array.isArray(value)) {
3
+ return `[${value.map(formatValue).join(", ")}]`;
4
+ }
5
+ if (typeof value === "string") {
6
+ return `"${value}"`;
7
+ }
8
+ if (value instanceof Date) {
9
+ return `${value.getTime()}`;
10
+ }
11
+ return `${value}`;
12
+ };
13
+ const pathWithArgsPredicate = (name) => {
14
+ const fn = (path, ...args) => {
15
+ const formattedArgs = args.map(formatValue).join(", ");
16
+ const joiner = path && args.length ? ", " : "";
17
+ return `[${name}(${path}${joiner}${formattedArgs})]`;
18
+ };
19
+ return fn;
20
+ };
21
+ const pathPredicate = (name) => {
22
+ const predicateFn = pathWithArgsPredicate(name);
23
+ const fn = (path) => {
24
+ return predicateFn(path);
25
+ };
26
+ return fn;
27
+ };
28
+ const argsPredicate = (name) => {
29
+ const predicateFn = pathWithArgsPredicate(name);
30
+ const fn = (...args) => {
31
+ return predicateFn("", ...args);
32
+ };
33
+ return fn;
34
+ };
35
+ const predicate = {
36
+ at: pathWithArgsPredicate("at"),
37
+ not: pathWithArgsPredicate("not"),
38
+ any: pathWithArgsPredicate("any"),
39
+ in: pathWithArgsPredicate("in"),
40
+ fulltext: pathWithArgsPredicate("fulltext"),
41
+ has: pathPredicate("has"),
42
+ missing: pathPredicate("missing"),
43
+ similar: argsPredicate("similar"),
44
+ geopointNear: pathWithArgsPredicate("geopoint.near"),
45
+ numberLessThan: pathWithArgsPredicate("number.lt"),
46
+ numberGreaterThan: pathWithArgsPredicate("number.gt"),
47
+ numberInRange: pathWithArgsPredicate("number.inRange"),
48
+ dateAfter: pathWithArgsPredicate("date.after"),
49
+ dateBefore: pathWithArgsPredicate("date.before"),
50
+ dateBetween: pathWithArgsPredicate("date.between"),
51
+ dateDayOfMonth: pathWithArgsPredicate("date.day-of-month"),
52
+ dateDayOfMonthAfter: pathWithArgsPredicate("date.day-of-month-after"),
53
+ dateDayOfMonthBefore: pathWithArgsPredicate("date.day-of-month-before"),
54
+ dateDayOfWeek: pathWithArgsPredicate("date.day-of-week"),
55
+ dateDayOfWeekAfter: pathWithArgsPredicate("date.day-of-week-after"),
56
+ dateDayOfWeekBefore: pathWithArgsPredicate("date.day-of-week-before"),
57
+ dateMonth: pathWithArgsPredicate("date.month"),
58
+ dateMonthAfter: pathWithArgsPredicate("date.month-after"),
59
+ dateMonthBefore: pathWithArgsPredicate("date.month-before"),
60
+ dateYear: pathWithArgsPredicate("date.year"),
61
+ dateHour: pathWithArgsPredicate("date.hour"),
62
+ dateHourAfter: pathWithArgsPredicate("date.hour-after"),
63
+ dateHourBefore: pathWithArgsPredicate("date.hour-before")
64
+ };
65
+ export {
66
+ predicate
67
+ };
68
+ //# sourceMappingURL=predicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predicate.js","sources":["../src/predicate.ts"],"sourcesContent":["/**\n * Formats the value of a predicate element to a stringified version accepted by\n * the Prismic REST API.\n *\n * @param value - Value to format.\n *\n * @returns `value` formatted for the Prismic REST API.\n */\nconst formatValue = (\n\tvalue:\n\t\t| string\n\t\t| number\n\t\t| Date\n\t\t| unknown\n\t\t| (string | number | Date | unknown)[],\n): string => {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map(formatValue).join(\", \")}]`;\n\t}\n\n\tif (typeof value === \"string\") {\n\t\treturn `\"${value}\"`;\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn `${value.getTime()}`;\n\t}\n\n\treturn `${value}`;\n};\n\n/**\n * Creates a predicate builder function for predicates with a path and\n * arguments.\n *\n * @typeParam Args - Arguments for the predicate.\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathWithArgsPredicate = <Args extends unknown[]>(name: string) => {\n\t/**\n\t * @param path - Path to the value to be compared.\n\t */\n\tconst fn = (path: string, ...args: Args): string => {\n\t\tconst formattedArgs = args.map(formatValue).join(\", \");\n\t\tconst joiner = path && args.length ? \", \" : \"\";\n\n\t\treturn `[${name}(${path}${joiner}${formattedArgs})]`;\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only a path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst pathPredicate = (name: string) => {\n\tconst predicateFn = pathWithArgsPredicate(name);\n\n\t/**\n\t * @param path - Path for the predicate.\n\t */\n\tconst fn = (path: string): string => {\n\t\treturn predicateFn(path);\n\t};\n\n\treturn fn;\n};\n\n/**\n * Creates a predicate builder function for predicates with only arguments and\n * no path.\n *\n * @param name - Name of the predicate used in the resulting string.\n *\n * @returns Predicate builder function for the given name.\n */\nconst argsPredicate = <Args extends unknown[]>(name: string) => {\n\tconst predicateFn = pathWithArgsPredicate<Args>(name);\n\n\t/**\n\t * @param args - Arguments for the predicate.\n\t */\n\tconst fn = (...args: Args): string => {\n\t\treturn predicateFn(\"\", ...args);\n\t};\n\n\treturn fn;\n};\n\nexport const predicate = {\n\t/**\n\t * The `at` predicate checks that the path matches the described value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#at}\n\t */\n\tat: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"at\"),\n\n\t/**\n\t * The `not` predicate checks that the path doesn't match the provided value\n\t * exactly. It takes a single value for a field or an array (only for tags).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#not}\n\t */\n\tnot: pathWithArgsPredicate<\n\t\t[value: string | number | boolean | Date | string[]]\n\t>(\"not\"),\n\n\t/**\n\t * The `any` predicate takes an array of values. It works exactly the same way\n\t * as the `at` operator, but checks whether the fragment matches any of the\n\t * values in the array.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#any}\n\t */\n\tany: pathWithArgsPredicate<[values: (string | number | boolean | Date)[]]>(\n\t\t\"any\",\n\t),\n\n\t/**\n\t * The `in` predicate is used specifically to retrieve an array of documents\n\t * by their IDs or UIDs. This predicate is much more efficient at this than\n\t * the any predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#in}\n\t */\n\tin: pathWithArgsPredicate<[values: string[]]>(\"in\"),\n\n\t/**\n\t * The `fulltext` predicate provides two capabilities:\n\t *\n\t * 1. Checking if a certain string is anywhere inside a document (this is what\n\t * you should use to make your project's search engine feature)\n\t * 2. Checking if the string is contained inside a specific custom type’s Rich\n\t * Text or Key Text fragment.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#fulltext}\n\t */\n\tfulltext: pathWithArgsPredicate<[searchTerms: string]>(\"fulltext\"),\n\n\t/**\n\t * The `has` predicate checks whether a fragment has a value. It will return\n\t * all the documents of the specified type that contain a value for the\n\t * specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#has}\n\t */\n\thas: pathPredicate(\"has\"),\n\n\t/**\n\t * The `missing` predicate checks if a fragment doesn't have a value. It will\n\t * return all the documents of the specified type that do not contain a value\n\t * for the specified field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#missing}\n\t */\n\tmissing: pathPredicate(\"missing\"),\n\n\t/**\n\t * The `similar` predicate takes the ID of a document, and returns a list of\n\t * documents with similar content. This allows you to build an automated\n\t * content discovery feature (for example, a \"Related posts\" section).\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#similar}\n\t */\n\tsimilar: argsPredicate<[id: string, value: number]>(\"similar\"),\n\n\t/**\n\t * The `geopoint.near` predicate checks that the value in the path is within\n\t * the radius of the given coordinates.\n\t *\n\t * This predicate will only work for a GeoPoint field.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#near}\n\t */\n\tgeopointNear:\n\t\tpathWithArgsPredicate<\n\t\t\t[latitude: number, longitude: number, radius: number]\n\t\t>(\"geopoint.near\"),\n\n\t/**\n\t * The `number.lt` predicate checks that the value in the number field is less\n\t * than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#lt-less-than}\n\t */\n\tnumberLessThan: pathWithArgsPredicate<[value: number]>(\"number.lt\"),\n\n\t/**\n\t * The `number.gt` predicate checks that the value in the number field is\n\t * greater than the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#gt-greater-than}\n\t */\n\tnumberGreaterThan: pathWithArgsPredicate<[value: number]>(\"number.gt\"),\n\n\t/**\n\t * The `number.inRange` predicate checks that the value in the path is within\n\t * the two values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/query-predicates-reference-rest-api#inrange}\n\t */\n\tnumberInRange:\n\t\tpathWithArgsPredicate<[lowerLimit: number, upperLimit: number]>(\n\t\t\t\"number.inRange\",\n\t\t),\n\n\t/**\n\t * The `date.after` predicate checks that the value in the path is after the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#after}\n\t */\n\tdateAfter:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.after\"),\n\n\t/**\n\t * The `date.before` predicate checks that the value in the path is before the\n\t * date value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#before}\n\t */\n\tdateBefore:\n\t\tpathWithArgsPredicate<[date: string | number | Date]>(\"date.before\"),\n\n\t/**\n\t * The `date.between` predicate checks that the value in the path is within\n\t * the date values passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#between}\n\t */\n\tdateBetween:\n\t\tpathWithArgsPredicate<\n\t\t\t[startDate: string | number | Date, endDate: string | number | Date]\n\t\t>(\"date.between\"),\n\n\t/**\n\t * The `date.day-of-month` predicate checks that the value in the path is\n\t * equal to the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonth}\n\t */\n\tdateDayOfMonth: pathWithArgsPredicate<[day: number]>(\"date.day-of-month\"),\n\n\t/**\n\t * The `date.day-of-month-after` predicate checks that the value in the path\n\t * is after the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthafter}\n\t */\n\tdateDayOfMonthAfter: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-after\",\n\t),\n\n\t/**\n\t * The `date.day-of-month-before` predicate checks that the value in the path\n\t * is before the day of the month passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofmonthbefore}\n\t */\n\tdateDayOfMonthBefore: pathWithArgsPredicate<[day: number]>(\n\t\t\"date.day-of-month-before\",\n\t),\n\n\t/**\n\t * The `date.day-of-week` predicate checks that the value in the path is equal\n\t * to the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweek}\n\t */\n\tdateDayOfWeek:\n\t\tpathWithArgsPredicate<[day: string | number]>(\"date.day-of-week\"),\n\n\t/**\n\t * The `date.day-of-week-after` predicate checks that the value in the path is\n\t * after the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekafter}\n\t */\n\tdateDayOfWeekAfter: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-after\",\n\t),\n\n\t/**\n\t * The date.day-of-week-before predicate checks that the value in the path is\n\t * before the day of the week passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#dayofweekbefore}\n\t */\n\tdateDayOfWeekBefore: pathWithArgsPredicate<[day: string | number]>(\n\t\t\"date.day-of-week-before\",\n\t),\n\n\t/**\n\t * The `date.month` predicate checks that the value in the path occurs in the\n\t * month value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#month}\n\t */\n\tdateMonth: pathWithArgsPredicate<[month: string | number]>(\"date.month\"),\n\n\t/**\n\t * The `date.month-after` predicate checks that the value in the path occurs\n\t * in any month after the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthafter}\n\t */\n\tdateMonthAfter:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-after\"),\n\n\t/**\n\t * The `date.month-before` predicate checks that the value in the path occurs\n\t * in any month before the value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#monthbefore}\n\t */\n\tdateMonthBefore:\n\t\tpathWithArgsPredicate<[month: string | number]>(\"date.month-before\"),\n\n\t/**\n\t * The `date.year` predicate checks that the value in the path occurs in the\n\t * year value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#year}\n\t */\n\tdateYear: pathWithArgsPredicate<[year: number]>(\"date.year\"),\n\n\t/**\n\t * The `date.hour` predicate checks that the value in the path occurs within\n\t * the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hour}\n\t */\n\tdateHour: pathWithArgsPredicate<[hour: number]>(\"date.hour\"),\n\n\t/**\n\t * The `date.hour-after` predicate checks that the value in the path occurs\n\t * after the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourafter}\n\t */\n\tdateHourAfter: pathWithArgsPredicate<[hour: number]>(\"date.hour-after\"),\n\n\t/**\n\t * The `date.hour-before` predicate checks that the value in the path occurs\n\t * before the hour value passed into the predicate.\n\t *\n\t * {@link https://prismic.io/docs/technologies/date-and-time-based-predicate-reference-rest-api#hourbefore}\n\t */\n\tdateHourBefore: pathWithArgsPredicate<[hour: number]>(\"date.hour-before\"),\n};\n"],"names":[],"mappings":"AAQA,MAAM,cAAc,CACnB,UAMW;AACP,MAAA,MAAM,QAAQ,KAAK,GAAG;AACzB,WAAO,IAAI,MAAM,IAAI,WAAW,EAAE,KAAK,IAAI;AAAA,EAC3C;AAEG,MAAA,OAAO,UAAU,UAAU;AAC9B,WAAO,IAAI;AAAA,EACX;AAED,MAAI,iBAAiB,MAAM;AACnB,WAAA,GAAG,MAAM,QAAO;AAAA,EACvB;AAED,SAAO,GAAG;AACX;AAWA,MAAM,wBAAwB,CAAyB,SAAgB;AAIhE,QAAA,KAAK,CAAC,SAAiB,SAAsB;AAClD,UAAM,gBAAgB,KAAK,IAAI,WAAW,EAAE,KAAK,IAAI;AACrD,UAAM,SAAS,QAAQ,KAAK,SAAS,OAAO;AAErC,WAAA,IAAI,QAAQ,OAAO,SAAS;AAAA,EAAA;AAG7B,SAAA;AACR;AASA,MAAM,gBAAgB,CAAC,SAAgB;AAChC,QAAA,cAAc,sBAAsB,IAAI;AAKxC,QAAA,KAAK,CAAC,SAAwB;AACnC,WAAO,YAAY,IAAI;AAAA,EAAA;AAGjB,SAAA;AACR;AAUA,MAAM,gBAAgB,CAAyB,SAAgB;AACxD,QAAA,cAAc,sBAA4B,IAAI;AAK9C,QAAA,KAAK,IAAI,SAAsB;AAC7B,WAAA,YAAY,IAAI,GAAG,IAAI;AAAA,EAAA;AAGxB,SAAA;AACR;AAEO,MAAM,YAAY;AAAA,EAOxB,IAAI,sBAEF,IAAI;AAAA,EAQN,KAAK,sBAEH,KAAK;AAAA,EASP,KAAK,sBACJ,KAAK;AAAA,EAUN,IAAI,sBAA0C,IAAI;AAAA,EAYlD,UAAU,sBAA6C,UAAU;AAAA,EASjE,KAAK,cAAc,KAAK;AAAA,EASxB,SAAS,cAAc,SAAS;AAAA,EAShC,SAAS,cAA2C,SAAS;AAAA,EAU7D,cACC,sBAEE,eAAe;AAAA,EAQlB,gBAAgB,sBAAuC,WAAW;AAAA,EAQlE,mBAAmB,sBAAuC,WAAW;AAAA,EAQrE,eACC,sBACC,gBAAgB;AAAA,EASlB,WACC,sBAAsD,YAAY;AAAA,EAQnE,YACC,sBAAsD,aAAa;AAAA,EAQpE,aACC,sBAEE,cAAc;AAAA,EAQjB,gBAAgB,sBAAqC,mBAAmB;AAAA,EAQxE,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,sBAAsB,sBACrB,0BAA0B;AAAA,EAS3B,eACC,sBAA8C,kBAAkB;AAAA,EAQjE,oBAAoB,sBACnB,wBAAwB;AAAA,EASzB,qBAAqB,sBACpB,yBAAyB;AAAA,EAS1B,WAAW,sBAAgD,YAAY;AAAA,EAQvE,gBACC,sBAAgD,kBAAkB;AAAA,EAQnE,iBACC,sBAAgD,mBAAmB;AAAA,EAQpE,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,UAAU,sBAAsC,WAAW;AAAA,EAQ3D,eAAe,sBAAsC,iBAAiB;AAAA,EAQtE,gBAAgB,sBAAsC,kBAAkB;;"}
@@ -0,0 +1,42 @@
1
+ import { PrismicDocument } from "../value/document";
2
+ /**
3
+ * A query response from the Prismic REST API V2. The response contains
4
+ * paginated metadata and a list of matching results for the query.
5
+ *
6
+ * @typeParam Document - The type(s) of Prismic document that can be returned.
7
+ * @see More details on querying: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
8
+ */
9
+ export interface Query<Document extends PrismicDocument = PrismicDocument> {
10
+ /**
11
+ * The page number for this page of results.
12
+ */
13
+ page: number;
14
+ /**
15
+ * Maximum number of results per page.
16
+ */
17
+ results_per_page: number;
18
+ /**
19
+ * Number of results in this page.
20
+ */
21
+ results_size: number;
22
+ /**
23
+ * Total number of results within all pages.
24
+ */
25
+ total_results_size: number;
26
+ /**
27
+ * Total number of pages.
28
+ */
29
+ total_pages: number;
30
+ /**
31
+ * The Prismic REST API V2 URL to the next page, if one exists.
32
+ */
33
+ next_page: string | null;
34
+ /**
35
+ * The Prismic REST API V2 URL to the previous page, if one exists.
36
+ */
37
+ prev_page: string | null;
38
+ /**
39
+ * A paginated list of documents matching the query.
40
+ */
41
+ results: Document[];
42
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Metadata for a reference to a version of a repository's content.
3
+ *
4
+ * @see More details on refs: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
5
+ */
6
+ export interface Ref {
7
+ /**
8
+ * The unique identifier for the ref.
9
+ */
10
+ id: string;
11
+ /**
12
+ * The identifier that should be provided to the API to select a content
13
+ * version.
14
+ */
15
+ ref: string;
16
+ /**
17
+ * A human-readable name for the ref. The master ref is always named "Master".
18
+ */
19
+ label: string;
20
+ /**
21
+ * Determines if the ref is the master ref. The master ref contains the latest
22
+ * published content.
23
+ */
24
+ isMasterRef: boolean;
25
+ /**
26
+ * If the ref is associated with a Release, this field contains the timestamp
27
+ * at which the Release will be automatically published, if set.
28
+ *
29
+ * @see More details on Releases: {@link https://prismic.io/docs/core-concepts/draft-plan-and-schedule-content#releases}
30
+ */
31
+ scheduledAt?: string;
32
+ }
@@ -0,0 +1,10 @@
1
+ import { Ref } from "./ref";
2
+ /**
3
+ * Metadata for a Release.
4
+ *
5
+ * @remarks
6
+ * This is an alias for `Ref`.
7
+ * @see {@link Ref}
8
+ * @see More details on Releases: {@link https://prismic.io/docs/core-concepts/draft-plan-and-schedule-content#releases}
9
+ */
10
+ export declare type Release = Ref;
@@ -0,0 +1,100 @@
1
+ import { Ref } from "./ref";
2
+ /**
3
+ * Repository metadata returned from the Prismic REST API V2. This data can be
4
+ * fetched by sending a `GET` a request to a repository's `/api/v2` endpoint.
5
+ *
6
+ * @see More details on the `/api/v2` endpoint: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#the-api-endpoint-2}
7
+ */
8
+ export interface Repository {
9
+ /**
10
+ * A list of refs for the repository.
11
+ *
12
+ * @see {@link Ref}
13
+ */
14
+ refs: Ref[];
15
+ /**
16
+ * An identifier used to query content with the latest Integration Fields
17
+ * data.
18
+ */
19
+ integrationFieldsRef: string | null;
20
+ /**
21
+ * A list of languages for the repository.
22
+ *
23
+ * @see {@link Language}
24
+ */
25
+ languages: Language[];
26
+ /**
27
+ * A list of the repository's Custom Type API IDs mapped to their
28
+ * human-readable name.
29
+ */
30
+ types: Record<string, string>;
31
+ /**
32
+ * A list of tags for the repository.
33
+ */
34
+ tags: string[];
35
+ /**
36
+ * An internally-used list of REST API features for the repository.
37
+ *
38
+ * @internal
39
+ */
40
+ forms: Record<string, Form>;
41
+ /**
42
+ * The URL used to begin the OAuth process for the repository.
43
+ */
44
+ oauth_initiate: string;
45
+ oauth_token: string;
46
+ /**
47
+ * The version of the API.
48
+ */
49
+ version: string;
50
+ /**
51
+ * Licensing information for the repository content.
52
+ */
53
+ license: string;
54
+ /**
55
+ * @deprecated Experiments are no longer part of Prismic.
56
+ */
57
+ experiments: unknown;
58
+ /**
59
+ * @deprecated Bookmarks are not longer part of Prismic.
60
+ */
61
+ bookmarks: Record<string, string>;
62
+ }
63
+ /**
64
+ * Metadata for a language that has been configured for a repository.
65
+ */
66
+ export interface Language {
67
+ /**
68
+ * A unique identifier for the language.
69
+ */
70
+ id: string;
71
+ /**
72
+ * The name of the language.
73
+ */
74
+ name: string;
75
+ }
76
+ /**
77
+ * A Prismic REST API V2 feature supported by the repository. It contains
78
+ * metadata about the feature and how to interact with it via the API.
79
+ *
80
+ * @internal
81
+ */
82
+ export interface Form {
83
+ method: "GET";
84
+ enctype: string;
85
+ action: string;
86
+ name?: string;
87
+ rel?: string;
88
+ fields: Record<string, FormField>;
89
+ }
90
+ /**
91
+ * A field for a feature of the Prismic REST API V2. It contains metadata about
92
+ * the feature's field and how to interact with it via the API.
93
+ *
94
+ * @internal
95
+ */
96
+ export interface FormField {
97
+ type: "String" | "Integer";
98
+ multiple: boolean;
99
+ default?: string;
100
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * List of tags returned from the Prismic Tags API. This data can be fetched by
3
+ * sending a `GET` request to a repository's `/api/tags` endpoint.
4
+ *
5
+ * @typeParam Tag - Tags that are returned by the Tags API.
6
+ * @see More details on the Tags API: {@link https://prismic.io/docs/technologies/tags-api-technical-reference}
7
+ */
8
+ export declare type Tags<Tag extends string = string> = Tag[];
@@ -0,0 +1,128 @@
1
+ import { PrismicDocument } from "./value/document";
2
+ import { ExtractOrFallback } from "./utils";
3
+ /**
4
+ * Extracts one or more Prismic document types that match a given Prismic
5
+ * document type. If no matches are found, no extraction is performed and the
6
+ * union of all provided Prismic document types are returned.
7
+ *
8
+ * @typeParam TDocuments - Prismic document types from which to extract.
9
+ * @typeParam TDocumentType - Type(s) to match `TDocuments` against.
10
+ */
11
+ export declare type ExtractDocumentType<TDocuments extends PrismicDocument, TDocumentType extends TDocuments["type"]> = ExtractOrFallback<TDocuments, {
12
+ type: TDocumentType;
13
+ }>;
14
+ /**
15
+ * A universal API to make network requests. A subset of the `fetch()` API.
16
+ *
17
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/fetch}
18
+ */
19
+ export declare type FetchLike = (input: string, init?: RequestInitLike) => Promise<ResponseLike>;
20
+ /**
21
+ * An object that allows you to abort a `fetch()` request if needed via an
22
+ * `AbortController` object
23
+ *
24
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
25
+ */
26
+ export declare type AbortSignalLike = any;
27
+ /**
28
+ * The minimum required properties from RequestInit.
29
+ */
30
+ export interface RequestInitLike {
31
+ headers?: Record<string, string>;
32
+ /**
33
+ * An object that allows you to abort a `fetch()` request if needed via an
34
+ * `AbortController` object
35
+ *
36
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
37
+ */
38
+ signal?: AbortSignalLike;
39
+ }
40
+ /**
41
+ * The minimum required properties from Response.
42
+ */
43
+ export interface ResponseLike {
44
+ status: number;
45
+ json(): Promise<any>;
46
+ }
47
+ /**
48
+ * The minimum required properties to treat as an HTTP Request for automatic
49
+ * Prismic preview support.
50
+ */
51
+ export declare type HttpRequestLike = /**
52
+ * Web API Request
53
+ *
54
+ * @see http://developer.mozilla.org/en-US/docs/Web/API/Request
55
+ */ {
56
+ headers?: {
57
+ get(name: string): string | null;
58
+ };
59
+ url?: string;
60
+ }
61
+ /**
62
+ * Express-style Request
63
+ */
64
+ | {
65
+ headers?: {
66
+ cookie?: string;
67
+ };
68
+ query?: Record<string, unknown>;
69
+ };
70
+ /**
71
+ * An `orderings` parameter that orders the results by the specified field.
72
+ *
73
+ * {@link https://prismic.io/docs/technologies/search-parameters-reference-rest-api#orderings}
74
+ */
75
+ export interface Ordering {
76
+ field: string;
77
+ direction?: "asc" | "desc";
78
+ }
79
+ /**
80
+ * A `routes` parameter that determines how a document's URL field is resolved.
81
+ *
82
+ * @example With a document's UID field.
83
+ *
84
+ * ```ts
85
+ * {
86
+ * "type": "page",
87
+ * "path": "/:uid"
88
+ * }
89
+ * ```
90
+ *
91
+ * @example With a Content Relationship `parent` field.
92
+ *
93
+ * ```ts
94
+ * {
95
+ * "type": "page",
96
+ * "path": "/:parent?/:uid",
97
+ * "resolvers": {
98
+ * "parent": "parent"
99
+ * }
100
+ * }
101
+ * ```
102
+ *
103
+ * {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver#route-resolver}
104
+ */
105
+ export interface Route {
106
+ /**
107
+ * The Custom Type of the document.
108
+ */
109
+ type: string;
110
+ /**
111
+ * A specific UID to which this route definition is scoped. The route is only
112
+ * defined for the document whose UID matches the given UID.
113
+ */
114
+ uid?: string;
115
+ /**
116
+ * A specific language to which this route definition is scoped. The route is
117
+ * only defined for documents whose language matches the given language.
118
+ */
119
+ lang?: string;
120
+ /**
121
+ * The resolved path of the document with optional placeholders.
122
+ */
123
+ path: string;
124
+ /**
125
+ * An object that lists the API IDs of the Content Relationships in the route.
126
+ */
127
+ resolvers?: Record<string, string>;
128
+ }
@@ -0,0 +1,63 @@
1
+ import { RichTextFunctionSerializer, RichTextMapSerializer, RichTextMapSerializerFunction } from "@prismicio/richtext";
2
+ import { FilledContentRelationshipField } from "./value/contentRelationship";
3
+ /**
4
+ * Resolves a link to a Prismic document to a URL
5
+ *
6
+ * @typeParam ReturnType - Return type of your link resolver function, useful if
7
+ * you prefer to return a complex object
8
+ * @param linkToDocumentField - A document link field to resolve
9
+ *
10
+ * @returns Resolved URL
11
+ * @see Prismic link resolver documentation: {@link https://prismic.io/docs/technologies/link-resolver-javascript}
12
+ */
13
+ export declare type LinkResolverFunction<ReturnType = string> = (linkToDocumentField: FilledContentRelationshipField) => ReturnType;
14
+ /**
15
+ * Serializes a node from a rich text or title field with a function to HTML
16
+ *
17
+ * Unlike a typical `@prismicio/richtext` function serializer, this serializer
18
+ * converts the `children` argument to a single string rather than an array of
19
+ * strings.
20
+ *
21
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
22
+ */
23
+ export declare type HTMLFunctionSerializer = (type: Parameters<RichTextFunctionSerializer<string>>[0], node: Parameters<RichTextFunctionSerializer<string>>[1], text: Parameters<RichTextFunctionSerializer<string>>[2], children: Parameters<RichTextFunctionSerializer<string>>[3][number], key: Parameters<RichTextFunctionSerializer<string>>[4]) => string | null | undefined;
24
+ /**
25
+ * Serializes a node from a rich text or title field with a map to HTML
26
+ *
27
+ * Unlike a typical `@prismicio/richtext` map serializer, this serializer
28
+ * converts the `children` property to a single string rather than an array of
29
+ * strings.
30
+ *
31
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
32
+ */
33
+ export declare type HTMLMapSerializer = {
34
+ [P in keyof RichTextMapSerializer<string>]: (payload: {
35
+ type: Parameters<HTMLMapSerializerFunction<P>>[0]["type"];
36
+ node: Parameters<HTMLMapSerializerFunction<P>>[0]["node"];
37
+ text: Parameters<HTMLMapSerializerFunction<P>>[0]["text"];
38
+ children: Parameters<HTMLMapSerializerFunction<P>>[0]["children"][number];
39
+ key: Parameters<HTMLMapSerializerFunction<P>>[0]["key"];
40
+ }) => string | null | undefined;
41
+ };
42
+ /**
43
+ * A {@link RichTextMapSerializerFunction} type specifically for
44
+ * {@link HTMLMapSerializer}.
45
+ *
46
+ * @typeParam BlockName - The serializer's Rich Text block type.
47
+ */
48
+ declare type HTMLMapSerializerFunction<BlockType extends keyof RichTextMapSerializer<string>> = RichTextMapSerializerFunction<string, ExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>, ExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>>;
49
+ /**
50
+ * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
51
+ *
52
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
53
+ * `Node` generic.
54
+ */
55
+ declare type ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<any, infer U, any> ? U : never;
56
+ /**
57
+ * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
58
+ *
59
+ * @typeParam T - The `RichTextMapSerializerFunction` containing the needed
60
+ * `TextType` generic.
61
+ */
62
+ declare type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<any, any, infer U> ? U : never;
63
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ /**
3
+ * A Boolean Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/boolean}
6
+ */
7
+ export interface CustomTypeModelBooleanField {
8
+ type: typeof CustomTypeModelFieldType.Boolean;
9
+ config?: {
10
+ label?: string | null;
11
+ default_value?: boolean;
12
+ placeholder_true?: string;
13
+ placeholder_false?: string;
14
+ };
15
+ }
@@ -0,0 +1,13 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ /**
3
+ * A Color Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/color}
6
+ */
7
+ export interface CustomTypeModelColorField {
8
+ type: typeof CustomTypeModelFieldType.Color;
9
+ config?: {
10
+ label?: string | null;
11
+ placeholder?: string;
12
+ };
13
+ }
@@ -0,0 +1,18 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ import type { CustomTypeModelLinkSelectType } from "./link";
3
+ /**
4
+ * A Content Relationship Custom Type field.
5
+ *
6
+ * More details:
7
+ * {@link https://prismic.io/docs/core-concepts/link-content-relationship}
8
+ */
9
+ export interface CustomTypeModelContentRelationshipField<CustomTypeIDs extends string = string, Tags extends string = string> {
10
+ type: typeof CustomTypeModelFieldType.Link;
11
+ config?: {
12
+ label?: string | null;
13
+ placeholder?: string;
14
+ select: typeof CustomTypeModelLinkSelectType.Document;
15
+ customtypes?: readonly CustomTypeIDs[];
16
+ tags?: readonly Tags[];
17
+ };
18
+ }
@@ -0,0 +1,42 @@
1
+ import { CustomTypeModelField } from "./types";
2
+ /**
3
+ * A Prismic Custom Type model.
4
+ *
5
+ * @typeParam ID - API ID of the Custom Type.
6
+ * @typeParam Definition - The Custom Type's tabs and their fields.
7
+ */
8
+ export interface CustomTypeModel<ID extends string = string, Definition extends CustomTypeModelDefinition = CustomTypeModelDefinition> {
9
+ /**
10
+ * The ID of the Custom Type model.
11
+ */
12
+ id: ID;
13
+ /**
14
+ * The human readable name of the Custom Type Model.
15
+ */
16
+ label: string | null | undefined;
17
+ /**
18
+ * Determines if more than one document for the Custom Type can be created.
19
+ */
20
+ repeatable: boolean;
21
+ /**
22
+ * The Custom Type model definition.
23
+ */
24
+ json: Definition;
25
+ /**
26
+ * Determines if new documents for the Custom Type can be created.
27
+ */
28
+ status: boolean;
29
+ }
30
+ /**
31
+ * A Prismic Custom Type's tabs and their fields.
32
+ *
33
+ * @typeParam TabName - Names of Custom Type tabs.
34
+ */
35
+ export declare type CustomTypeModelDefinition<TabName extends string = string> = Record<TabName, CustomTypeModelTab>;
36
+ /**
37
+ * A Custom Type's tab. Each tab can contain any number of fields but is limited
38
+ * to one Slice Zone.
39
+ *
40
+ * @typeParam FieldName - API IDs of the fields.
41
+ */
42
+ export declare type CustomTypeModelTab<Fields extends Record<string, CustomTypeModelField> = Record<string, CustomTypeModelField>> = Fields;
@@ -0,0 +1,14 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ /**
3
+ * A Date Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/date}
6
+ */
7
+ export interface CustomTypeModelDateField {
8
+ type: typeof CustomTypeModelFieldType.Date;
9
+ config?: {
10
+ label?: string | null;
11
+ placeholder?: string;
12
+ default?: string;
13
+ };
14
+ }
@@ -0,0 +1,13 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ /**
3
+ * An Embed Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/embed}
6
+ */
7
+ export interface CustomTypeModelEmbedField {
8
+ type: typeof CustomTypeModelFieldType.Embed;
9
+ config?: {
10
+ label?: string | null;
11
+ placeholder?: string;
12
+ };
13
+ }
@@ -0,0 +1,12 @@
1
+ import type { CustomTypeModelFieldType } from "./types";
2
+ /**
3
+ * A GeoPoint Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/geopoint}
6
+ */
7
+ export interface CustomTypeModelGeoPointField {
8
+ type: typeof CustomTypeModelFieldType.GeoPoint;
9
+ config?: {
10
+ label?: string | null;
11
+ };
12
+ }
@@ -0,0 +1,15 @@
1
+ import type { CustomTypeModelFieldType, CustomTypeModelFieldForGroup } from "./types";
2
+ /**
3
+ * A Group Custom Type field.
4
+ *
5
+ * More details: {@link https://prismic.io/docs/core-concepts/group}
6
+ *
7
+ * @typeParam Fields - A record of fields that can be repeated.
8
+ */
9
+ export interface CustomTypeModelGroupField<Fields extends Record<string, CustomTypeModelFieldForGroup> = Record<string, CustomTypeModelFieldForGroup>> {
10
+ type: typeof CustomTypeModelFieldType.Group;
11
+ config?: {
12
+ label?: string | null;
13
+ fields?: Fields;
14
+ };
15
+ }