@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,286 @@
1
+ import type { EmbedField } from "./embed";
2
+ import type { FieldState } from "./types";
3
+ import type { FilledContentRelationshipField } from "./contentRelationship";
4
+ import type { FilledLinkToMediaField } from "./linkToMedia";
5
+ import type { FilledLinkToWebField } from "./link";
6
+
7
+ /**
8
+ * Types for RichTextNodes
9
+ *
10
+ * @see More details: {@link https://prismic.io/docs/core-concepts/rich-text-title}
11
+ */
12
+ export const RichTextNodeType = {
13
+ heading1: "heading1",
14
+ heading2: "heading2",
15
+ heading3: "heading3",
16
+ heading4: "heading4",
17
+ heading5: "heading5",
18
+ heading6: "heading6",
19
+ paragraph: "paragraph",
20
+ preformatted: "preformatted",
21
+ strong: "strong",
22
+ em: "em",
23
+ listItem: "list-item",
24
+ oListItem: "o-list-item",
25
+ list: "group-list-item",
26
+ oList: "group-o-list-item",
27
+ image: "image",
28
+ embed: "embed",
29
+ hyperlink: "hyperlink",
30
+ label: "label",
31
+ span: "span",
32
+ } as const;
33
+
34
+ // Text nodes
35
+
36
+ /**
37
+ * Base to be extended by other RT Nodes.
38
+ */
39
+ export interface RTTextNodeBase {
40
+ text: string;
41
+ spans: RTInlineNode[];
42
+ }
43
+
44
+ /**
45
+ * Rich Text `heading1` node
46
+ */
47
+ export interface RTHeading1Node extends RTTextNodeBase {
48
+ type: typeof RichTextNodeType.heading1;
49
+ }
50
+
51
+ /**
52
+ * Rich Text `heading2` node
53
+ */
54
+ export interface RTHeading2Node extends RTTextNodeBase {
55
+ type: typeof RichTextNodeType.heading2;
56
+ }
57
+
58
+ /**
59
+ * Rich Text `heading3` node
60
+ */
61
+ export interface RTHeading3Node extends RTTextNodeBase {
62
+ type: typeof RichTextNodeType.heading3;
63
+ }
64
+
65
+ /**
66
+ * Rich Text `heading4` node
67
+ */
68
+ export interface RTHeading4Node extends RTTextNodeBase {
69
+ type: typeof RichTextNodeType.heading4;
70
+ }
71
+
72
+ /**
73
+ * Rich Text `heading5` node
74
+ */
75
+ export interface RTHeading5Node extends RTTextNodeBase {
76
+ type: typeof RichTextNodeType.heading5;
77
+ }
78
+
79
+ /**
80
+ * Rich Text `heading6` node
81
+ */
82
+ export interface RTHeading6Node extends RTTextNodeBase {
83
+ type: typeof RichTextNodeType.heading6;
84
+ }
85
+
86
+ /**
87
+ * Rich Text `paragraph` node
88
+ */
89
+ export interface RTParagraphNode extends RTTextNodeBase {
90
+ type: typeof RichTextNodeType.paragraph;
91
+ }
92
+
93
+ /**
94
+ * Rich Text `preformatted` node
95
+ */
96
+ export interface RTPreformattedNode extends RTTextNodeBase {
97
+ type: typeof RichTextNodeType.preformatted;
98
+ }
99
+
100
+ /**
101
+ * Rich Text `list-item` node
102
+ */
103
+ export interface RTListItemNode extends RTTextNodeBase {
104
+ type: typeof RichTextNodeType.listItem;
105
+ }
106
+
107
+ /**
108
+ * Rich Text `o-list-item` node for ordered lists
109
+ */
110
+ export interface RTOListItemNode extends RTTextNodeBase {
111
+ type: typeof RichTextNodeType.oListItem;
112
+ }
113
+
114
+ // Span nodes
115
+
116
+ /**
117
+ * @internal Span Node base to be extended for other Span nodes
118
+ */
119
+ export interface RTSpanNodeBase {
120
+ start: number;
121
+ end: number;
122
+ }
123
+ /**
124
+ * Rich Text `strong` node
125
+ */
126
+ export interface RTStrongNode extends RTSpanNodeBase {
127
+ type: typeof RichTextNodeType.strong;
128
+ }
129
+
130
+ /**
131
+ * Rich Text `embed` node
132
+ */
133
+ export interface RTEmNode extends RTSpanNodeBase {
134
+ type: typeof RichTextNodeType.em;
135
+ }
136
+
137
+ /**
138
+ * Rich Text `label` node
139
+ */
140
+ export interface RTLabelNode extends RTSpanNodeBase {
141
+ type: typeof RichTextNodeType.label;
142
+ data: {
143
+ label: string;
144
+ };
145
+ }
146
+
147
+ // Media nodes
148
+
149
+ /**
150
+ * Rich Text `image` nodes. They could link to other documents, external web
151
+ * links and media fields
152
+ */
153
+ export type RTImageNode = {
154
+ type: typeof RichTextNodeType.image;
155
+ url: string;
156
+ alt: string | null;
157
+ copyright: string | null;
158
+ dimensions: {
159
+ width: number;
160
+ height: number;
161
+ };
162
+ linkTo?:
163
+ | FilledContentRelationshipField
164
+ | FilledLinkToWebField
165
+ | FilledLinkToMediaField;
166
+ };
167
+
168
+ /**
169
+ * Rich Text `embed` node
170
+ */
171
+ export type RTEmbedNode = {
172
+ type: typeof RichTextNodeType.embed;
173
+ oembed: EmbedField;
174
+ };
175
+
176
+ // Link nodes
177
+
178
+ /**
179
+ * Rich Text `a` node
180
+ *
181
+ * @see More details: {@link https://prismic.io/docs/core-concepts/edit-rich-text#add-links}
182
+ */
183
+ export interface RTLinkNode extends RTSpanNodeBase {
184
+ type: typeof RichTextNodeType.hyperlink;
185
+ data:
186
+ | FilledContentRelationshipField
187
+ | FilledLinkToWebField
188
+ | FilledLinkToMediaField;
189
+ }
190
+
191
+ // Serialization related nodes
192
+
193
+ /**
194
+ * Rich Text `list` node
195
+ */
196
+ export interface RTListNode {
197
+ type: typeof RichTextNodeType.list;
198
+ items: RTListItemNode[];
199
+ }
200
+
201
+ /**
202
+ * Rich Text o-lost node
203
+ */
204
+ export interface RTOListNode {
205
+ type: typeof RichTextNodeType.oList;
206
+ items: RTOListItemNode[];
207
+ }
208
+
209
+ // This one is confusing but it's actually the inner content of a block
210
+ /**
211
+ * Rich Text `span` node
212
+ */
213
+ export interface RTSpanNode extends RTTextNodeBase {
214
+ type: typeof RichTextNodeType.span;
215
+ }
216
+
217
+ // Helpers
218
+
219
+ /**
220
+ * Nodes from a Rich Text Field
221
+ */
222
+ export type RTNode =
223
+ | RTHeading1Node
224
+ | RTHeading2Node
225
+ | RTHeading3Node
226
+ | RTHeading4Node
227
+ | RTHeading5Node
228
+ | RTHeading6Node
229
+ | RTParagraphNode
230
+ | RTPreformattedNode
231
+ | RTListItemNode
232
+ | RTOListItemNode
233
+ | RTImageNode
234
+ | RTEmbedNode;
235
+
236
+ /**
237
+ * Rich text nodes with text
238
+ */
239
+ export type RTTextNode =
240
+ | RTHeading1Node
241
+ | RTHeading2Node
242
+ | RTHeading3Node
243
+ | RTHeading4Node
244
+ | RTHeading5Node
245
+ | RTHeading6Node
246
+ | RTParagraphNode
247
+ | RTPreformattedNode
248
+ | RTListItemNode
249
+ | RTOListItemNode;
250
+
251
+ /**
252
+ * Rich Text block nodes
253
+ */
254
+ export type RTBlockNode =
255
+ | RTHeading1Node
256
+ | RTHeading2Node
257
+ | RTHeading3Node
258
+ | RTHeading4Node
259
+ | RTHeading5Node
260
+ | RTHeading6Node
261
+ | RTParagraphNode
262
+ | RTPreformattedNode
263
+ | RTListItemNode
264
+ | RTOListItemNode
265
+ | RTListNode
266
+ | RTOListNode
267
+ | RTImageNode
268
+ | RTEmbedNode;
269
+
270
+ /**
271
+ * Inline Rich Text Nodes
272
+ */
273
+ export type RTInlineNode = RTStrongNode | RTEmNode | RTLabelNode | RTLinkNode;
274
+
275
+ /**
276
+ * All Rich Text nodes
277
+ */
278
+ export type RTAnyNode = RTBlockNode | RTInlineNode | RTSpanNode;
279
+
280
+ /**
281
+ * Rich Text Field
282
+ *
283
+ * @see Rich Text field documentation: {@link https://prismic.io/docs/core-concepts/rich-text-title}
284
+ */
285
+ export type RichTextField<State extends FieldState = FieldState> =
286
+ State extends "empty" ? [] : [RTNode, ...RTNode[]];
@@ -0,0 +1,13 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ /**
4
+ * A Select field
5
+ *
6
+ * @typeParam Enum - Selectable options for the field.
7
+ * @typeParam State - State of the field which determines its shape.
8
+ * @see More details: {@link https://prismic.io/docs/core-concepts/select}
9
+ */
10
+ export type SelectField<
11
+ Enum extends string = string,
12
+ State extends FieldState = FieldState,
13
+ > = State extends "empty" ? null : Enum;
@@ -0,0 +1,15 @@
1
+ import type { SharedSliceVariation } from "./sharedSliceVariation";
2
+
3
+ /**
4
+ * Shared Slice
5
+ *
6
+ * @see More details: {@link https://prismic.io/docs/core-concepts/reusing-slices#shared-slices}
7
+ */
8
+ export type SharedSlice<
9
+ SliceType = string,
10
+ Variations extends SharedSliceVariation = SharedSliceVariation,
11
+ > = {
12
+ slice_type: SliceType;
13
+ slice_label: null;
14
+ id?: string;
15
+ } & Variations;
@@ -0,0 +1,18 @@
1
+ import type { AnyRegularField } from "./types";
2
+
3
+ export interface SharedSliceVariation<
4
+ Variation = string,
5
+ PrimaryFields extends Record<string, AnyRegularField> = Record<
6
+ string,
7
+ AnyRegularField
8
+ >,
9
+ ItemsFields extends Record<string, AnyRegularField> = Record<
10
+ string,
11
+ AnyRegularField
12
+ >,
13
+ > {
14
+ variation: Variation;
15
+ version: string;
16
+ primary: PrimaryFields;
17
+ items: ItemsFields[];
18
+ }
@@ -0,0 +1,24 @@
1
+ import type { AnyRegularField } from "./types";
2
+
3
+ /**
4
+ * Slice - Sections of your website
5
+ *
6
+ * @see More details: {@link https://prismic.io/docs/core-concepts/slices}
7
+ */
8
+ export interface Slice<
9
+ SliceType = string,
10
+ PrimaryFields extends Record<string, AnyRegularField> = Record<
11
+ string,
12
+ AnyRegularField
13
+ >,
14
+ ItemsFields extends Record<string, AnyRegularField> = Record<
15
+ string,
16
+ AnyRegularField
17
+ >,
18
+ > {
19
+ slice_type: SliceType;
20
+ slice_label: string | null;
21
+ id?: string;
22
+ primary: PrimaryFields;
23
+ items: ItemsFields[];
24
+ }
@@ -0,0 +1,16 @@
1
+ import type { FieldState } from "./types";
2
+ import type { SharedSlice } from "./sharedSlice";
3
+ import type { Slice } from "./slice";
4
+
5
+ /**
6
+ * Prismic Slices are sections of your website. Prismic documents contain a
7
+ * dynamic "Slice Zone" that allows content creators to add, edit, and rearrange
8
+ * Slices to compose dynamic layouts for any page design, such as blog posts,
9
+ * landing pages, case studies, and tutorials.
10
+ *
11
+ * @see More details: {@link https://prismic.io/docs/technologies/adding-the-slicezone-component-nextjs}
12
+ */
13
+ export type SliceZone<
14
+ Slices extends Slice | SharedSlice = Slice | SharedSlice,
15
+ State extends FieldState = FieldState,
16
+ > = State extends "empty" ? [] : [Slices, ...Slices[]];
@@ -0,0 +1,12 @@
1
+ import type { FieldState } from "./types";
2
+ import type { DateField } from "./date";
3
+
4
+ /**
5
+ * Simple Timestamp Field
6
+ *
7
+ * @typeParam State - State of the field which determines its shape.
8
+ */
9
+ export type TimestampField<State extends FieldState = FieldState> =
10
+ State extends "empty"
11
+ ? null
12
+ : `${DateField<"filled">}T${number}:${number}:${number}+${number}`;
@@ -0,0 +1,31 @@
1
+ import type { FieldState } from "./types";
2
+ import type {
3
+ RTHeading1Node,
4
+ RTHeading2Node,
5
+ RTHeading3Node,
6
+ RTHeading4Node,
7
+ RTHeading5Node,
8
+ RTHeading6Node,
9
+ } from "./richText";
10
+
11
+ /**
12
+ * Title Field
13
+ *
14
+ * @see Title field documentation: {@link https://prismic.io/docs/core-concepts/rich-text-title}
15
+ */
16
+ export type TitleField<State extends FieldState = FieldState> =
17
+ State extends "empty"
18
+ ? []
19
+ : [
20
+ Omit<
21
+ | RTHeading1Node
22
+ | RTHeading2Node
23
+ | RTHeading3Node
24
+ | RTHeading4Node
25
+ | RTHeading5Node
26
+ | RTHeading6Node,
27
+ "spans"
28
+ > & {
29
+ spans: [];
30
+ },
31
+ ];
@@ -0,0 +1,60 @@
1
+ import type { RichTextField } from "./richText";
2
+ import type { TitleField } from "./title";
3
+ import type { ImageField } from "./image";
4
+ import type { ContentRelationshipField } from "./contentRelationship";
5
+ import type { LinkField } from "./link";
6
+ import type { LinkToMediaField } from "./linkToMedia";
7
+ import type { EmbedField } from "./embed";
8
+
9
+ import type { BooleanField } from "./boolean";
10
+ import type { ColorField } from "./color";
11
+ import type { DateField } from "./date";
12
+ import type { KeyTextField } from "./keyText";
13
+ import type { NumberField } from "./number";
14
+ import type { SelectField } from "./select";
15
+ import type { TimestampField } from "./timestamp";
16
+ import type { GeoPointField } from "./geoPoint";
17
+
18
+ import type { IntegrationFields } from "./integrationFields";
19
+
20
+ /**
21
+ * Empty state for object-shaped fields.
22
+ */
23
+ export type EmptyObjectField = Record<string, never>;
24
+
25
+ /**
26
+ * Valid states for fields. Not all fields use this type (e.g. BooleanField).
27
+ */
28
+ export type FieldState = "empty" | "filled";
29
+
30
+ /**
31
+ * Any regular field that can be nested in a group-like field.
32
+ */
33
+ export type AnyRegularField =
34
+ | TitleField
35
+ | RichTextField
36
+ | ImageField
37
+ | ContentRelationshipField
38
+ | LinkField
39
+ | LinkToMediaField
40
+ | EmbedField
41
+ | DateField
42
+ | TimestampField
43
+ | ColorField
44
+ | NumberField
45
+ | KeyTextField
46
+ | SelectField
47
+ | BooleanField
48
+ | GeoPointField
49
+ | IntegrationFields;
50
+
51
+ /**
52
+ * Useful to flatten the type output to improve type hints shown in editors. And
53
+ * also to transform an interface into a type to aide with assignability.
54
+ *
55
+ * Taken from the `type-fest` package.
56
+ *
57
+ * @typeParam T - The type to simplify.
58
+ * @see https://github.com/sindresorhus/type-fest/blob/cbd7ec510bd136ac045bbc74e391ee686b8a9a2f/source/simplify.d.ts
59
+ */
60
+ export type Simplify<T> = { [P in keyof T]: T[P] };
@@ -0,0 +1,56 @@
1
+ import { WebhookBodyBase, WebhookType } from "./types";
2
+
3
+ /**
4
+ * Webhook payload sent when a Prismic repository content is updated.
5
+ *
6
+ * @see More details: {@link https://prismic.io/docs/core-concepts/webhooks}
7
+ */
8
+ export interface WebhookBodyAPIUpdate extends WebhookBodyBase {
9
+ type: typeof WebhookType.APIUpdate;
10
+ masterRef?: string;
11
+ releases: WebhookBodyAPIUpdateOperations<WebhookBodyAPIUpdateRelease>;
12
+ masks: WebhookBodyAPIUpdateOperations<WebhookBodyAPIUpdateMask>;
13
+ tags: WebhookBodyAPIUpdateOperations<WebhookBodyAPIUpdateTag>;
14
+ documents: string[];
15
+ /**
16
+ * @deprecated Experiments are no longer supported by Prismic.
17
+ */
18
+ experiments?: WebhookBodyAPIUpdateOperations<unknown>;
19
+ }
20
+
21
+ interface WebhookBodyAPIUpdateOperations<T> {
22
+ update?: T[];
23
+ addition?: T[];
24
+ deletion?: T[];
25
+ }
26
+
27
+ /**
28
+ * Metadata representing a mask (also called a Custom Type).
29
+ *
30
+ * @see More details: {@link https://prismic.io/docs/core-concepts/custom-types}
31
+ */
32
+ interface WebhookBodyAPIUpdateMask {
33
+ id: string;
34
+ label: string;
35
+ }
36
+
37
+ /**
38
+ * Metadata representing a tag.
39
+ *
40
+ * @see More details: {@link https://prismic.io/docs/core-concepts/document-tags}
41
+ */
42
+ interface WebhookBodyAPIUpdateTag {
43
+ id: string;
44
+ }
45
+
46
+ /**
47
+ * Metadata representing a Release.
48
+ *
49
+ * @see More details: {@link https://prismic.io/docs/core-concepts/draft-plan-and-schedule-content#releases}
50
+ */
51
+ interface WebhookBodyAPIUpdateRelease {
52
+ id: string;
53
+ ref: string;
54
+ label: string;
55
+ documents: string[];
56
+ }
@@ -0,0 +1,10 @@
1
+ import { WebhookBodyBase, WebhookType } from "./types";
2
+
3
+ /**
4
+ * Webhook payload sent when a test webhook action is triggered.
5
+ *
6
+ * @see More details: {@link https://prismic.io/docs/core-concepts/webhooks}
7
+ */
8
+ export interface WebhookBodyTestTrigger extends WebhookBodyBase {
9
+ type: typeof WebhookType.TestTrigger;
10
+ }
@@ -0,0 +1,21 @@
1
+ import { WebhookBodyAPIUpdate } from "./apiUpdate";
2
+ import { WebhookBodyTestTrigger } from "./testTrigger";
3
+
4
+ export type WebhookBody = WebhookBodyAPIUpdate | WebhookBodyTestTrigger;
5
+
6
+ /**
7
+ * Types of Prismic Webhooks.
8
+ *
9
+ * @see More details: {@link https://prismic.io/docs/core-concepts/webhooks}
10
+ */
11
+ export const WebhookType = {
12
+ APIUpdate: "api-update",
13
+ TestTrigger: "test-trigger",
14
+ } as const;
15
+
16
+ export interface WebhookBodyBase {
17
+ type: typeof WebhookType[keyof typeof WebhookType];
18
+ domain: string;
19
+ apiUrl: string;
20
+ secret: string | null;
21
+ }
@@ -1,17 +0,0 @@
1
- /**
2
- * Throws an error if a given value is nullish.
3
- *
4
- * @typeParam Nullable - Value to check.
5
- * @param a -Nullable value to check.
6
- * @param error - Error to throw if `a` is nullish.
7
- *
8
- * @returns `a`, whose type is narrowed to be non-nullable.
9
- * @throws Throws the given error if `a` is nullish.
10
- */
11
- export const orElseThrow = <T>(a: T | null | undefined, error: Error): T => {
12
- if (a == null) {
13
- throw error;
14
- }
15
-
16
- return a;
17
- };