@prismicio/client 6.7.3 → 7.0.0-alpha.1

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 (400) hide show
  1. package/README.md +4 -4
  2. package/dist/buildQueryURL.cjs +25 -6
  3. package/dist/buildQueryURL.cjs.map +1 -1
  4. package/dist/buildQueryURL.d.ts +207 -130
  5. package/dist/buildQueryURL.js +25 -6
  6. package/dist/buildQueryURL.js.map +1 -1
  7. package/dist/cookie.d.ts +5 -5
  8. package/dist/createClient.cjs +1142 -0
  9. package/dist/createClient.cjs.map +1 -0
  10. package/dist/{client.d.ts → createClient.d.ts} +980 -929
  11. package/dist/createClient.js +1142 -0
  12. package/dist/createClient.js.map +1 -0
  13. package/dist/errors/ForbiddenError.cjs.map +1 -0
  14. package/dist/{ForbiddenError.d.ts → errors/ForbiddenError.d.ts} +11 -11
  15. package/dist/errors/ForbiddenError.js.map +1 -0
  16. package/dist/errors/NotFoundError.cjs.map +1 -0
  17. package/dist/{NotFoundError.d.ts → errors/NotFoundError.d.ts} +3 -3
  18. package/dist/errors/NotFoundError.js.map +1 -0
  19. package/dist/errors/ParsingError.cjs.map +1 -0
  20. package/dist/{ParsingError.d.ts → errors/ParsingError.d.ts} +12 -12
  21. package/dist/errors/ParsingError.js.map +1 -0
  22. package/dist/errors/PrismicError.cjs.map +1 -0
  23. package/dist/{PrismicError.d.ts → errors/PrismicError.d.ts} +5 -5
  24. package/dist/errors/PrismicError.js.map +1 -0
  25. package/dist/filter.cjs +247 -0
  26. package/dist/filter.cjs.map +1 -0
  27. package/dist/filter.d.ts +209 -0
  28. package/dist/filter.js +247 -0
  29. package/dist/filter.js.map +1 -0
  30. package/dist/getGraphQLEndpoint.cjs +1 -1
  31. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  32. package/dist/getGraphQLEndpoint.d.ts +9 -9
  33. package/dist/getGraphQLEndpoint.js +1 -1
  34. package/dist/getGraphQLEndpoint.js.map +1 -1
  35. package/dist/getRepositoryEndpoint.cjs +1 -1
  36. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  37. package/dist/getRepositoryEndpoint.d.ts +10 -10
  38. package/dist/getRepositoryEndpoint.js +1 -1
  39. package/dist/getRepositoryEndpoint.js.map +1 -1
  40. package/dist/getRepositoryName.cjs +1 -1
  41. package/dist/getRepositoryName.cjs.map +1 -1
  42. package/dist/getRepositoryName.d.ts +13 -13
  43. package/dist/getRepositoryName.js +1 -1
  44. package/dist/getRepositoryName.js.map +1 -1
  45. package/dist/getToolbarSrc.cjs +13 -0
  46. package/dist/getToolbarSrc.cjs.map +1 -0
  47. package/dist/getToolbarSrc.d.ts +34 -0
  48. package/dist/getToolbarSrc.js +13 -0
  49. package/dist/getToolbarSrc.js.map +1 -0
  50. package/dist/helpers/asDate.cjs +14 -0
  51. package/dist/helpers/asDate.cjs.map +1 -0
  52. package/dist/helpers/asDate.d.ts +16 -0
  53. package/dist/helpers/asDate.js +14 -0
  54. package/dist/helpers/asDate.js.map +1 -0
  55. package/dist/helpers/asHTML.cjs +80 -0
  56. package/dist/helpers/asHTML.cjs.map +1 -0
  57. package/dist/helpers/asHTML.d.ts +77 -0
  58. package/dist/helpers/asHTML.js +80 -0
  59. package/dist/helpers/asHTML.js.map +1 -0
  60. package/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -0
  61. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
  62. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +52 -0
  63. package/dist/helpers/asImagePixelDensitySrcSet.js +21 -0
  64. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
  65. package/dist/helpers/asImageSrc.cjs +13 -0
  66. package/dist/helpers/asImageSrc.cjs.map +1 -0
  67. package/dist/helpers/asImageSrc.d.ts +27 -0
  68. package/dist/helpers/asImageSrc.js +13 -0
  69. package/dist/helpers/asImageSrc.js.map +1 -0
  70. package/dist/helpers/asImageWidthSrcSet.cjs +45 -0
  71. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
  72. package/dist/helpers/asImageWidthSrcSet.d.ts +60 -0
  73. package/dist/helpers/asImageWidthSrcSet.js +45 -0
  74. package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
  75. package/dist/helpers/asLink.cjs +38 -0
  76. package/dist/helpers/asLink.cjs.map +1 -0
  77. package/dist/helpers/asLink.d.ts +34 -0
  78. package/dist/helpers/asLink.js +38 -0
  79. package/dist/helpers/asLink.js.map +1 -0
  80. package/dist/helpers/asLinkAttrs.cjs +28 -0
  81. package/dist/helpers/asLinkAttrs.cjs.map +1 -0
  82. package/dist/helpers/asLinkAttrs.d.ts +63 -0
  83. package/dist/helpers/asLinkAttrs.js +28 -0
  84. package/dist/helpers/asLinkAttrs.js.map +1 -0
  85. package/dist/helpers/asText.cjs +12 -0
  86. package/dist/helpers/asText.cjs.map +1 -0
  87. package/dist/helpers/asText.d.ts +16 -0
  88. package/dist/helpers/asText.js +12 -0
  89. package/dist/helpers/asText.js.map +1 -0
  90. package/dist/helpers/documentToLinkField.cjs +26 -0
  91. package/dist/helpers/documentToLinkField.cjs.map +1 -0
  92. package/dist/helpers/documentToLinkField.d.ts +15 -0
  93. package/dist/helpers/documentToLinkField.js +26 -0
  94. package/dist/helpers/documentToLinkField.js.map +1 -0
  95. package/dist/helpers/isFilled.cjs +67 -0
  96. package/dist/helpers/isFilled.cjs.map +1 -0
  97. package/dist/helpers/isFilled.d.ts +172 -0
  98. package/dist/helpers/isFilled.js +67 -0
  99. package/dist/helpers/isFilled.js.map +1 -0
  100. package/dist/index.cjs +56 -17
  101. package/dist/index.cjs.map +1 -1
  102. package/dist/index.d.ts +138 -88
  103. package/dist/index.js +50 -16
  104. package/dist/index.js.map +1 -1
  105. package/dist/isRepositoryEndpoint.d.ts +10 -10
  106. package/dist/isRepositoryName.d.ts +9 -9
  107. package/dist/lib/appendFilters.cjs +11 -0
  108. package/dist/lib/appendFilters.cjs.map +1 -0
  109. package/dist/lib/appendFilters.d.ts +18 -0
  110. package/dist/lib/appendFilters.js +11 -0
  111. package/dist/lib/appendFilters.js.map +1 -0
  112. package/dist/lib/castArray.cjs +3 -1
  113. package/dist/lib/castArray.cjs.map +1 -1
  114. package/dist/lib/castArray.d.ts +11 -11
  115. package/dist/lib/castArray.js +3 -1
  116. package/dist/lib/castArray.js.map +1 -1
  117. package/dist/lib/castThunk.cjs +3 -1
  118. package/dist/lib/castThunk.cjs.map +1 -1
  119. package/dist/lib/castThunk.d.ts +10 -10
  120. package/dist/lib/castThunk.js +3 -1
  121. package/dist/lib/castThunk.js.map +1 -1
  122. package/dist/lib/devMsg.cjs +8 -0
  123. package/dist/lib/devMsg.cjs.map +1 -0
  124. package/dist/lib/devMsg.d.ts +16 -0
  125. package/dist/lib/devMsg.js +8 -0
  126. package/dist/lib/devMsg.js.map +1 -0
  127. package/dist/lib/escapeHTML.cjs +43 -0
  128. package/dist/lib/escapeHTML.cjs.map +1 -0
  129. package/dist/lib/escapeHTML.d.ts +1 -0
  130. package/dist/lib/escapeHTML.js +43 -0
  131. package/dist/lib/escapeHTML.js.map +1 -0
  132. package/dist/lib/everyTagFilter.cjs +9 -0
  133. package/dist/lib/everyTagFilter.cjs.map +1 -0
  134. package/dist/lib/everyTagFilter.d.ts +9 -0
  135. package/dist/lib/everyTagFilter.js +9 -0
  136. package/dist/lib/everyTagFilter.js.map +1 -0
  137. package/dist/lib/findMasterRef.cjs.map +1 -1
  138. package/dist/lib/findMasterRef.d.ts +10 -10
  139. package/dist/lib/findMasterRef.js.map +1 -1
  140. package/dist/lib/findRef.cjs +3 -3
  141. package/dist/lib/findRef.cjs.map +1 -1
  142. package/dist/lib/findRef.d.ts +13 -13
  143. package/dist/lib/findRef.js +3 -3
  144. package/dist/lib/findRef.js.map +1 -1
  145. package/dist/lib/findRefByID.cjs.map +1 -1
  146. package/dist/lib/findRefByID.d.ts +11 -11
  147. package/dist/lib/findRefByID.js.map +1 -1
  148. package/dist/lib/findRefByLabel.cjs.map +1 -1
  149. package/dist/lib/findRefByLabel.d.ts +11 -11
  150. package/dist/lib/findRefByLabel.js.map +1 -1
  151. package/dist/lib/getPreviewCookie.cjs +1 -1
  152. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  153. package/dist/lib/getPreviewCookie.d.ts +9 -9
  154. package/dist/lib/getPreviewCookie.js +1 -1
  155. package/dist/lib/getPreviewCookie.js.map +1 -1
  156. package/dist/lib/isInternalURL.cjs +9 -0
  157. package/dist/lib/isInternalURL.cjs.map +1 -0
  158. package/dist/lib/isInternalURL.d.ts +8 -0
  159. package/dist/lib/isInternalURL.js +9 -0
  160. package/dist/lib/isInternalURL.js.map +1 -0
  161. package/dist/lib/minifyGraphQLQuery.d.ts +8 -8
  162. package/dist/lib/serializerHelpers.cjs +54 -0
  163. package/dist/lib/serializerHelpers.cjs.map +1 -0
  164. package/dist/lib/serializerHelpers.d.ts +9 -0
  165. package/dist/lib/serializerHelpers.js +54 -0
  166. package/dist/lib/serializerHelpers.js.map +1 -0
  167. package/dist/lib/someTagsFilter.cjs +9 -0
  168. package/dist/lib/someTagsFilter.cjs.map +1 -0
  169. package/dist/lib/someTagsFilter.d.ts +9 -0
  170. package/dist/lib/someTagsFilter.js +9 -0
  171. package/dist/lib/someTagsFilter.js.map +1 -0
  172. package/dist/lib/typeFilter.cjs +8 -0
  173. package/dist/lib/typeFilter.cjs.map +1 -0
  174. package/dist/lib/typeFilter.d.ts +8 -0
  175. package/dist/lib/typeFilter.js +8 -0
  176. package/dist/lib/typeFilter.js.map +1 -0
  177. package/dist/package.json.cjs +5 -0
  178. package/dist/package.json.cjs.map +1 -0
  179. package/dist/package.json.js +5 -0
  180. package/dist/package.json.js.map +1 -0
  181. package/dist/types/api/query.d.ts +42 -0
  182. package/dist/types/api/ref.d.ts +32 -0
  183. package/dist/types/api/release.d.ts +10 -0
  184. package/dist/types/api/repository.d.ts +100 -0
  185. package/dist/types/api/tags.d.ts +8 -0
  186. package/dist/types/model/boolean.d.ts +15 -0
  187. package/dist/types/model/color.d.ts +13 -0
  188. package/dist/types/model/contentRelationship.d.ts +18 -0
  189. package/dist/types/model/customType.d.ts +42 -0
  190. package/dist/types/model/date.d.ts +14 -0
  191. package/dist/types/model/embed.d.ts +13 -0
  192. package/dist/types/model/geoPoint.d.ts +12 -0
  193. package/dist/types/model/group.d.ts +15 -0
  194. package/dist/types/model/image.d.ts +31 -0
  195. package/dist/types/model/integrationFields.d.ts +14 -0
  196. package/dist/types/model/keyText.d.ts +13 -0
  197. package/dist/types/model/link.cjs +9 -0
  198. package/dist/types/model/link.cjs.map +1 -0
  199. package/dist/types/model/link.d.ts +27 -0
  200. package/dist/types/model/link.js +9 -0
  201. package/dist/types/model/link.js.map +1 -0
  202. package/dist/types/model/linkToMedia.d.ts +16 -0
  203. package/dist/types/model/number.d.ts +15 -0
  204. package/dist/types/model/range.d.ts +14 -0
  205. package/dist/types/model/richText.d.ts +35 -0
  206. package/dist/types/model/select.d.ts +18 -0
  207. package/dist/types/model/separator.d.ts +10 -0
  208. package/dist/types/model/sharedSlice.d.ts +16 -0
  209. package/dist/types/model/sharedSliceVariation.d.ts +19 -0
  210. package/dist/types/model/slice.cjs +8 -0
  211. package/dist/types/model/slice.cjs.map +1 -0
  212. package/dist/types/model/slice.d.ts +33 -0
  213. package/dist/types/model/slice.js +8 -0
  214. package/dist/types/model/slice.js.map +1 -0
  215. package/dist/types/model/sliceZone.cjs +8 -0
  216. package/dist/types/model/sliceZone.cjs.map +1 -0
  217. package/dist/types/model/sliceZone.d.ts +41 -0
  218. package/dist/types/model/sliceZone.js +8 -0
  219. package/dist/types/model/sliceZone.js.map +1 -0
  220. package/dist/types/model/timestamp.d.ts +14 -0
  221. package/dist/types/model/title.d.ts +7 -0
  222. package/dist/types/model/types.cjs +34 -0
  223. package/dist/types/model/types.cjs.map +1 -0
  224. package/dist/types/model/types.d.ts +62 -0
  225. package/dist/types/model/types.js +34 -0
  226. package/dist/types/model/types.js.map +1 -0
  227. package/dist/types/model/uid.d.ts +13 -0
  228. package/dist/types/value/boolean.d.ts +6 -0
  229. package/dist/types/value/color.d.ts +8 -0
  230. package/dist/types/value/contentRelationship.d.ts +29 -0
  231. package/dist/types/value/date.d.ts +8 -0
  232. package/dist/types/value/document.d.ts +113 -0
  233. package/dist/types/value/embed.cjs +10 -0
  234. package/dist/types/value/embed.cjs.map +1 -0
  235. package/dist/types/value/embed.d.ts +167 -0
  236. package/dist/types/value/embed.js +10 -0
  237. package/dist/types/value/embed.js.map +1 -0
  238. package/dist/types/value/geoPoint.d.ts +11 -0
  239. package/dist/types/value/group.d.ts +7 -0
  240. package/dist/types/value/image.d.ts +36 -0
  241. package/dist/types/value/integrationFields.d.ts +9 -0
  242. package/dist/types/value/keyText.d.ts +8 -0
  243. package/dist/types/value/link.cjs +10 -0
  244. package/dist/types/value/link.cjs.map +1 -0
  245. package/dist/types/value/link.d.ts +40 -0
  246. package/dist/types/value/link.js +10 -0
  247. package/dist/types/value/link.js.map +1 -0
  248. package/dist/types/value/linkToMedia.d.ts +20 -0
  249. package/dist/types/value/number.d.ts +8 -0
  250. package/dist/types/value/richText.cjs +25 -0
  251. package/dist/types/value/richText.cjs.map +1 -0
  252. package/dist/types/value/richText.d.ts +203 -0
  253. package/dist/types/value/richText.js +25 -0
  254. package/dist/types/value/richText.js.map +1 -0
  255. package/dist/types/value/select.d.ts +9 -0
  256. package/dist/types/value/sharedSlice.d.ts +11 -0
  257. package/dist/types/value/sharedSliceVariation.d.ts +7 -0
  258. package/dist/types/value/slice.d.ts +13 -0
  259. package/dist/types/value/sliceZone.d.ts +12 -0
  260. package/dist/types/value/timestamp.d.ts +8 -0
  261. package/dist/types/value/title.d.ts +12 -0
  262. package/dist/types/value/types.d.ts +40 -0
  263. package/dist/types/webhook/apiUpdate.d.ts +52 -0
  264. package/dist/types/webhook/testTrigger.d.ts +9 -0
  265. package/dist/types/webhook/types.cjs +8 -0
  266. package/dist/types/webhook/types.cjs.map +1 -0
  267. package/dist/types/webhook/types.d.ts +18 -0
  268. package/dist/types/webhook/types.js +8 -0
  269. package/dist/types/webhook/types.js.map +1 -0
  270. package/package.json +42 -36
  271. package/src/buildQueryURL.ts +179 -32
  272. package/src/{client.ts → createClient.ts} +248 -186
  273. package/src/filter.ts +356 -0
  274. package/src/getGraphQLEndpoint.ts +2 -1
  275. package/src/getRepositoryEndpoint.ts +2 -1
  276. package/src/getRepositoryName.ts +1 -1
  277. package/src/getToolbarSrc.ts +50 -0
  278. package/src/helpers/asDate.ts +48 -0
  279. package/src/helpers/asHTML.ts +249 -0
  280. package/src/helpers/asImagePixelDensitySrcSet.ts +96 -0
  281. package/src/helpers/asImageSrc.ts +41 -0
  282. package/src/helpers/asImageWidthSrcSet.ts +139 -0
  283. package/src/helpers/asLink.ts +118 -0
  284. package/src/helpers/asLinkAttrs.ts +127 -0
  285. package/src/helpers/asText.ts +29 -0
  286. package/src/helpers/documentToLinkField.ts +47 -0
  287. package/src/helpers/isFilled.ts +288 -0
  288. package/src/index.ts +277 -31
  289. package/src/lib/appendFilters.ts +26 -0
  290. package/src/lib/castArray.ts +3 -1
  291. package/src/lib/castThunk.ts +3 -2
  292. package/src/lib/devMsg.ts +20 -0
  293. package/src/lib/escapeHTML.ts +51 -0
  294. package/src/lib/everyTagFilter.ts +15 -0
  295. package/src/lib/findMasterRef.ts +2 -2
  296. package/src/lib/findRef.ts +6 -9
  297. package/src/lib/findRefByID.ts +2 -2
  298. package/src/lib/findRefByLabel.ts +2 -5
  299. package/src/lib/getPreviewCookie.ts +1 -1
  300. package/src/lib/isInternalURL.ts +14 -0
  301. package/src/lib/serializerHelpers.ts +101 -0
  302. package/src/lib/someTagsFilter.ts +15 -0
  303. package/src/lib/typeFilter.ts +12 -0
  304. package/src/types/api/query.ts +50 -0
  305. package/src/types/api/ref.ts +36 -0
  306. package/src/types/api/release.ts +11 -0
  307. package/src/types/api/repository.ts +117 -0
  308. package/src/types/api/tags.ts +8 -0
  309. package/src/types/model/boolean.ts +16 -0
  310. package/src/types/model/color.ts +14 -0
  311. package/src/types/model/contentRelationship.ts +23 -0
  312. package/src/types/model/customType.ts +61 -0
  313. package/src/types/model/date.ts +15 -0
  314. package/src/types/model/embed.ts +14 -0
  315. package/src/types/model/geoPoint.ts +13 -0
  316. package/src/types/model/group.ts +24 -0
  317. package/src/types/model/image.ts +37 -0
  318. package/src/types/model/integrationFields.ts +15 -0
  319. package/src/types/model/keyText.ts +14 -0
  320. package/src/types/model/link.ts +31 -0
  321. package/src/types/model/linkToMedia.ts +18 -0
  322. package/src/types/model/number.ts +16 -0
  323. package/src/types/model/range.ts +15 -0
  324. package/src/types/model/richText.ts +40 -0
  325. package/src/types/model/select.ts +22 -0
  326. package/src/types/model/separator.ts +11 -0
  327. package/src/types/model/sharedSlice.ts +20 -0
  328. package/src/types/model/sharedSliceVariation.ts +30 -0
  329. package/src/types/model/slice.ts +50 -0
  330. package/src/types/model/sliceZone.ts +60 -0
  331. package/src/types/model/timestamp.ts +15 -0
  332. package/src/types/model/title.ts +8 -0
  333. package/src/types/model/types.ts +87 -0
  334. package/src/types/model/uid.ts +14 -0
  335. package/src/types/value/boolean.ts +6 -0
  336. package/src/types/value/color.ts +10 -0
  337. package/src/types/value/contentRelationship.ts +47 -0
  338. package/src/types/value/date.ts +10 -0
  339. package/src/types/value/document.ts +143 -0
  340. package/src/types/value/embed.ts +196 -0
  341. package/src/types/value/geoPoint.ts +15 -0
  342. package/src/types/value/group.ts +14 -0
  343. package/src/types/value/image.ts +67 -0
  344. package/src/types/value/integrationFields.ts +13 -0
  345. package/src/types/value/keyText.ts +10 -0
  346. package/src/types/value/link.ts +59 -0
  347. package/src/types/value/linkToMedia.ts +26 -0
  348. package/src/types/value/number.ts +10 -0
  349. package/src/types/value/richText.ts +287 -0
  350. package/src/types/value/select.ts +13 -0
  351. package/src/types/value/sharedSlice.ts +15 -0
  352. package/src/types/value/sharedSliceVariation.ts +18 -0
  353. package/src/types/value/slice.ts +24 -0
  354. package/src/types/value/sliceZone.ts +17 -0
  355. package/src/types/value/timestamp.ts +13 -0
  356. package/src/types/value/title.ts +32 -0
  357. package/src/types/value/types.ts +58 -0
  358. package/src/types/webhook/apiUpdate.ts +56 -0
  359. package/src/types/webhook/testTrigger.ts +10 -0
  360. package/src/types/webhook/types.ts +21 -0
  361. package/dist/ForbiddenError.cjs.map +0 -1
  362. package/dist/ForbiddenError.js.map +0 -1
  363. package/dist/NotFoundError.cjs.map +0 -1
  364. package/dist/NotFoundError.js.map +0 -1
  365. package/dist/ParsingError.cjs.map +0 -1
  366. package/dist/ParsingError.js.map +0 -1
  367. package/dist/PrismicError.cjs.map +0 -1
  368. package/dist/PrismicError.js.map +0 -1
  369. package/dist/client.cjs +0 -436
  370. package/dist/client.cjs.map +0 -1
  371. package/dist/client.js +0 -419
  372. package/dist/client.js.map +0 -1
  373. package/dist/lib/appendPredicates.cjs +0 -14
  374. package/dist/lib/appendPredicates.cjs.map +0 -1
  375. package/dist/lib/appendPredicates.d.ts +0 -18
  376. package/dist/lib/appendPredicates.js +0 -14
  377. package/dist/lib/appendPredicates.js.map +0 -1
  378. package/dist/lib/orElseThrow.d.ts +0 -11
  379. package/dist/predicate.cjs +0 -68
  380. package/dist/predicate.cjs.map +0 -1
  381. package/dist/predicate.d.ts +0 -209
  382. package/dist/predicate.js +0 -68
  383. package/dist/predicate.js.map +0 -1
  384. package/dist/types.d.ts +0 -156
  385. package/src/lib/appendPredicates.ts +0 -29
  386. package/src/lib/orElseThrow.ts +0 -17
  387. package/src/predicate.ts +0 -359
  388. package/src/types.ts +0 -191
  389. /package/dist/{ForbiddenError.cjs → errors/ForbiddenError.cjs} +0 -0
  390. /package/dist/{ForbiddenError.js → errors/ForbiddenError.js} +0 -0
  391. /package/dist/{NotFoundError.cjs → errors/NotFoundError.cjs} +0 -0
  392. /package/dist/{NotFoundError.js → errors/NotFoundError.js} +0 -0
  393. /package/dist/{ParsingError.cjs → errors/ParsingError.cjs} +0 -0
  394. /package/dist/{ParsingError.js → errors/ParsingError.js} +0 -0
  395. /package/dist/{PrismicError.cjs → errors/PrismicError.cjs} +0 -0
  396. /package/dist/{PrismicError.js → errors/PrismicError.js} +0 -0
  397. /package/src/{ForbiddenError.ts → errors/ForbiddenError.ts} +0 -0
  398. /package/src/{NotFoundError.ts → errors/NotFoundError.ts} +0 -0
  399. /package/src/{ParsingError.ts → errors/ParsingError.ts} +0 -0
  400. /package/src/{PrismicError.ts → errors/PrismicError.ts} +0 -0
@@ -0,0 +1,14 @@
1
+ import type { AnyRegularField, FieldState } from "./types";
2
+
3
+ /**
4
+ * A Group field.
5
+ *
6
+ * More details: {@link https://prismic.io/docs/group}
7
+ */
8
+ export type GroupField<
9
+ Fields extends Record<string, AnyRegularField> = Record<
10
+ string,
11
+ AnyRegularField
12
+ >,
13
+ State extends FieldState = FieldState,
14
+ > = State extends "empty" ? [] : [Fields, ...Fields[]];
@@ -0,0 +1,67 @@
1
+ import type { FieldState, Simplify } from "./types";
2
+
3
+ /**
4
+ * An individual image within an Image field. The base image and each thumbnail
5
+ * uses this type.
6
+ *
7
+ * @typeParam State - State of the field which determines its shape.
8
+ * @see {@link ImageField} for a full Image field type.
9
+ */
10
+ export type ImageFieldImage<State extends FieldState = FieldState> =
11
+ State extends "empty" ? EmptyImageFieldImage : FilledImageFieldImage;
12
+
13
+ export interface FilledImageFieldImage {
14
+ url: string;
15
+ dimensions: {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ alt: string | null;
20
+ copyright: string | null;
21
+ }
22
+
23
+ export interface EmptyImageFieldImage {
24
+ url?: null;
25
+ dimensions?: null;
26
+ alt?: null;
27
+ copyright?: null;
28
+ }
29
+
30
+ /**
31
+ * Image Field
32
+ *
33
+ * **Note**: Passing `null` to the `ThumbnailNames` parameter is deprecated and
34
+ * will be removed in a future version. Use `never` instead.
35
+ *
36
+ * @typeParam ThumbnailNames - Names of thumbnails. If the field does not
37
+ * contain thumbnails, `never` can be used to "disable" thumbnail fields.
38
+ * @typeParam State - State of the field which determines its shape.
39
+ * @see Image field documentation: {@link https://prismic.io/docs/image}
40
+ */
41
+ export type ImageField<
42
+ // `null` is included for backwards compatibility with older versions of
43
+ // this package. `null` should be treated as deprecated. `never` is
44
+ // preferred.
45
+ ThumbnailNames extends string | null = never,
46
+ State extends FieldState = FieldState,
47
+ > =
48
+ // Simplify is necessary. Without it, Group and Slice types break for
49
+ // unknown reasons. If you know why, please update this comment with an
50
+ // explanation. :)
51
+ Simplify<
52
+ // This `extends` and duplicated type is necessary. Without it,
53
+ // TypeScript cannot correct narrow "filled" and "empty" types with the
54
+ // `isFilled.image()` helper.
55
+ //
56
+ // Futhermore, duplicating rather than abstracting the type to
57
+ // a secondary "_ImageFieldImage"-like type is preferred. If the
58
+ // type was abstracted, TypeScript's language server would
59
+ // return the abstracted type's name rather than the clearer
60
+ // version written below. This version leads to a better code
61
+ // editor experience.
62
+ State extends "filled"
63
+ ? ImageFieldImage<State> &
64
+ Record<Extract<ThumbnailNames, string>, ImageFieldImage<State>>
65
+ : ImageFieldImage<State> &
66
+ Record<Extract<ThumbnailNames, string>, ImageFieldImage<State>>
67
+ >;
@@ -0,0 +1,13 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ /**
4
+ * Integration Fields for Custom APIs
5
+ *
6
+ * @typeParam Data - Data from the integrated API.
7
+ * @typeParam State - State of the field which determines its shape.
8
+ * @see More details: {@link https://prismic.io/docs/integration-fields}
9
+ */
10
+ export type IntegrationFields<
11
+ Data extends Record<string, unknown> = Record<string, unknown>,
12
+ State extends FieldState = FieldState,
13
+ > = State extends "empty" ? null : Data;
@@ -0,0 +1,10 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ /**
4
+ * A Key text field
5
+ *
6
+ * @typeParam State - State of the field which determines its shape.
7
+ * @see More details: {@link https://prismic.io/docs/key-text}
8
+ */
9
+ export type KeyTextField<State extends FieldState = FieldState> =
10
+ State extends "empty" ? null | "" : string;
@@ -0,0 +1,59 @@
1
+ import type { AnyRegularField, FieldState } from "./types";
2
+
3
+ import type { ContentRelationshipField } from "./contentRelationship";
4
+ import type { GroupField } from "./group";
5
+ import type { LinkToMediaField } from "./linkToMedia";
6
+ import type { SliceZone } from "./sliceZone";
7
+
8
+ /**
9
+ * Link Types
10
+ */
11
+ export const LinkType = {
12
+ Any: "Any",
13
+ Document: "Document",
14
+ Media: "Media",
15
+ Web: "Web",
16
+ } as const;
17
+
18
+ /**
19
+ * For link fields that haven't been filled
20
+ *
21
+ * @typeParam Type - The type of link.
22
+ */
23
+ export type EmptyLinkField<
24
+ Type extends (typeof LinkType)[keyof typeof LinkType] = typeof LinkType.Any,
25
+ > = {
26
+ link_type: Type | string;
27
+ };
28
+
29
+ /**
30
+ * Link that points to external website
31
+ */
32
+ export interface FilledLinkToWebField {
33
+ link_type: typeof LinkType.Web;
34
+ url: string;
35
+ target?: string;
36
+ }
37
+
38
+ /**
39
+ * Link Field
40
+ *
41
+ * @typeParam TypeEnum - Type API ID of the document.
42
+ * @typeParam LangEnum - Language API ID of the document.
43
+ * @typeParam DataInterface - Data fields for the document (filled in via
44
+ * GraphQuery of `fetchLinks`).
45
+ * @typeParam State - State of the field which determines its shape.
46
+ */
47
+ export type LinkField<
48
+ TypeEnum = string,
49
+ LangEnum = string,
50
+ DataInterface extends
51
+ | Record<string, AnyRegularField | GroupField | SliceZone>
52
+ | unknown = unknown,
53
+ State extends FieldState = FieldState,
54
+ > = State extends "empty"
55
+ ? EmptyLinkField<typeof LinkType.Any>
56
+ :
57
+ | ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
58
+ | FilledLinkToWebField
59
+ | LinkToMediaField<State>;
@@ -0,0 +1,26 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ import type { EmptyLinkField, LinkType } from "./link";
4
+
5
+ /**
6
+ * Link field that points to media
7
+ *
8
+ * @typeParam State - State of the field which determines its shape.
9
+ */
10
+ export type LinkToMediaField<State extends FieldState = FieldState> =
11
+ State extends "empty"
12
+ ? EmptyLinkField<typeof LinkType.Media>
13
+ : FilledLinkToMediaField;
14
+
15
+ /**
16
+ * Link that points to media
17
+ */
18
+ export interface FilledLinkToMediaField {
19
+ link_type: typeof LinkType.Media;
20
+ name: string;
21
+ kind: string;
22
+ url: string;
23
+ size: string;
24
+ height?: string | null;
25
+ width?: string | null;
26
+ }
@@ -0,0 +1,10 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ /**
4
+ * A Number field
5
+ *
6
+ * @typeParam State - State of the field which determines its shape.
7
+ * @see More details: {@link https://prismic.io/docs/number}
8
+ */
9
+ export type NumberField<State extends FieldState = FieldState> =
10
+ State extends "empty" ? null : number;
@@ -0,0 +1,287 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ import type { FilledContentRelationshipField } from "./contentRelationship";
4
+ import type { EmbedField } from "./embed";
5
+ import type { FilledLinkToWebField } from "./link";
6
+ import type { FilledLinkToMediaField } from "./linkToMedia";
7
+
8
+ /**
9
+ * Types for RichTextNodes
10
+ *
11
+ * @see More details: {@link https://prismic.io/docs/rich-text-title}
12
+ */
13
+ export const RichTextNodeType = {
14
+ heading1: "heading1",
15
+ heading2: "heading2",
16
+ heading3: "heading3",
17
+ heading4: "heading4",
18
+ heading5: "heading5",
19
+ heading6: "heading6",
20
+ paragraph: "paragraph",
21
+ preformatted: "preformatted",
22
+ strong: "strong",
23
+ em: "em",
24
+ listItem: "list-item",
25
+ oListItem: "o-list-item",
26
+ list: "group-list-item",
27
+ oList: "group-o-list-item",
28
+ image: "image",
29
+ embed: "embed",
30
+ hyperlink: "hyperlink",
31
+ label: "label",
32
+ span: "span",
33
+ } as const;
34
+
35
+ // Text nodes
36
+
37
+ /**
38
+ * Base to be extended by other RT Nodes.
39
+ */
40
+ export interface RTTextNodeBase {
41
+ text: string;
42
+ spans: RTInlineNode[];
43
+ }
44
+
45
+ /**
46
+ * Rich Text `heading1` node
47
+ */
48
+ export interface RTHeading1Node extends RTTextNodeBase {
49
+ type: typeof RichTextNodeType.heading1;
50
+ }
51
+
52
+ /**
53
+ * Rich Text `heading2` node
54
+ */
55
+ export interface RTHeading2Node extends RTTextNodeBase {
56
+ type: typeof RichTextNodeType.heading2;
57
+ }
58
+
59
+ /**
60
+ * Rich Text `heading3` node
61
+ */
62
+ export interface RTHeading3Node extends RTTextNodeBase {
63
+ type: typeof RichTextNodeType.heading3;
64
+ }
65
+
66
+ /**
67
+ * Rich Text `heading4` node
68
+ */
69
+ export interface RTHeading4Node extends RTTextNodeBase {
70
+ type: typeof RichTextNodeType.heading4;
71
+ }
72
+
73
+ /**
74
+ * Rich Text `heading5` node
75
+ */
76
+ export interface RTHeading5Node extends RTTextNodeBase {
77
+ type: typeof RichTextNodeType.heading5;
78
+ }
79
+
80
+ /**
81
+ * Rich Text `heading6` node
82
+ */
83
+ export interface RTHeading6Node extends RTTextNodeBase {
84
+ type: typeof RichTextNodeType.heading6;
85
+ }
86
+
87
+ /**
88
+ * Rich Text `paragraph` node
89
+ */
90
+ export interface RTParagraphNode extends RTTextNodeBase {
91
+ type: typeof RichTextNodeType.paragraph;
92
+ }
93
+
94
+ /**
95
+ * Rich Text `preformatted` node
96
+ */
97
+ export interface RTPreformattedNode extends RTTextNodeBase {
98
+ type: typeof RichTextNodeType.preformatted;
99
+ }
100
+
101
+ /**
102
+ * Rich Text `list-item` node
103
+ */
104
+ export interface RTListItemNode extends RTTextNodeBase {
105
+ type: typeof RichTextNodeType.listItem;
106
+ }
107
+
108
+ /**
109
+ * Rich Text `o-list-item` node for ordered lists
110
+ */
111
+ export interface RTOListItemNode extends RTTextNodeBase {
112
+ type: typeof RichTextNodeType.oListItem;
113
+ }
114
+
115
+ // Span nodes
116
+
117
+ /**
118
+ * @internal Span Node base to be extended for other Span nodes
119
+ */
120
+ export interface RTSpanNodeBase {
121
+ start: number;
122
+ end: number;
123
+ }
124
+ /**
125
+ * Rich Text `strong` node
126
+ */
127
+ export interface RTStrongNode extends RTSpanNodeBase {
128
+ type: typeof RichTextNodeType.strong;
129
+ }
130
+
131
+ /**
132
+ * Rich Text `embed` node
133
+ */
134
+ export interface RTEmNode extends RTSpanNodeBase {
135
+ type: typeof RichTextNodeType.em;
136
+ }
137
+
138
+ /**
139
+ * Rich Text `label` node
140
+ */
141
+ export interface RTLabelNode extends RTSpanNodeBase {
142
+ type: typeof RichTextNodeType.label;
143
+ data: {
144
+ label: string;
145
+ };
146
+ }
147
+
148
+ // Media nodes
149
+
150
+ /**
151
+ * Rich Text `image` nodes. They could link to other documents, external web
152
+ * links and media fields
153
+ */
154
+ export type RTImageNode = {
155
+ type: typeof RichTextNodeType.image;
156
+ url: string;
157
+ alt: string | null;
158
+ copyright: string | null;
159
+ dimensions: {
160
+ width: number;
161
+ height: number;
162
+ };
163
+ linkTo?:
164
+ | FilledContentRelationshipField
165
+ | FilledLinkToWebField
166
+ | FilledLinkToMediaField;
167
+ };
168
+
169
+ /**
170
+ * Rich Text `embed` node
171
+ */
172
+ export type RTEmbedNode = {
173
+ type: typeof RichTextNodeType.embed;
174
+ oembed: EmbedField;
175
+ };
176
+
177
+ // Link nodes
178
+
179
+ /**
180
+ * Rich Text `a` node
181
+ *
182
+ * @see More details: {@link https://prismic.io/docs/rich-text-title#elements-and-styles}
183
+ */
184
+ export interface RTLinkNode extends RTSpanNodeBase {
185
+ type: typeof RichTextNodeType.hyperlink;
186
+ data:
187
+ | FilledContentRelationshipField
188
+ | FilledLinkToWebField
189
+ | FilledLinkToMediaField;
190
+ }
191
+
192
+ // Serialization related nodes
193
+
194
+ /**
195
+ * Rich Text `list` node
196
+ */
197
+ export interface RTListNode {
198
+ type: typeof RichTextNodeType.list;
199
+ items: RTListItemNode[];
200
+ }
201
+
202
+ /**
203
+ * Rich Text o-lost node
204
+ */
205
+ export interface RTOListNode {
206
+ type: typeof RichTextNodeType.oList;
207
+ items: RTOListItemNode[];
208
+ }
209
+
210
+ // This one is confusing but it's actually the inner content of a block
211
+ /**
212
+ * Rich Text `span` node
213
+ */
214
+ export interface RTSpanNode extends RTTextNodeBase {
215
+ type: typeof RichTextNodeType.span;
216
+ }
217
+
218
+ // Helpers
219
+
220
+ /**
221
+ * Nodes from a Rich Text Field
222
+ */
223
+ export type RTNode =
224
+ | RTHeading1Node
225
+ | RTHeading2Node
226
+ | RTHeading3Node
227
+ | RTHeading4Node
228
+ | RTHeading5Node
229
+ | RTHeading6Node
230
+ | RTParagraphNode
231
+ | RTPreformattedNode
232
+ | RTListItemNode
233
+ | RTOListItemNode
234
+ | RTImageNode
235
+ | RTEmbedNode;
236
+
237
+ /**
238
+ * Rich text nodes with text
239
+ */
240
+ export type RTTextNode =
241
+ | RTHeading1Node
242
+ | RTHeading2Node
243
+ | RTHeading3Node
244
+ | RTHeading4Node
245
+ | RTHeading5Node
246
+ | RTHeading6Node
247
+ | RTParagraphNode
248
+ | RTPreformattedNode
249
+ | RTListItemNode
250
+ | RTOListItemNode;
251
+
252
+ /**
253
+ * Rich Text block nodes
254
+ */
255
+ export type RTBlockNode =
256
+ | RTHeading1Node
257
+ | RTHeading2Node
258
+ | RTHeading3Node
259
+ | RTHeading4Node
260
+ | RTHeading5Node
261
+ | RTHeading6Node
262
+ | RTParagraphNode
263
+ | RTPreformattedNode
264
+ | RTListItemNode
265
+ | RTOListItemNode
266
+ | RTListNode
267
+ | RTOListNode
268
+ | RTImageNode
269
+ | RTEmbedNode;
270
+
271
+ /**
272
+ * Inline Rich Text Nodes
273
+ */
274
+ export type RTInlineNode = RTStrongNode | RTEmNode | RTLabelNode | RTLinkNode;
275
+
276
+ /**
277
+ * All Rich Text nodes
278
+ */
279
+ export type RTAnyNode = RTBlockNode | RTInlineNode | RTSpanNode;
280
+
281
+ /**
282
+ * Rich Text Field
283
+ *
284
+ * @see Rich Text field documentation: {@link https://prismic.io/docs/rich-text-title}
285
+ */
286
+ export type RichTextField<State extends FieldState = FieldState> =
287
+ 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/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/slice}
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/slice}
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,17 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ import type { SharedSlice } from "./sharedSlice";
4
+ import type { Slice } from "./slice";
5
+
6
+ /**
7
+ * Prismic Slices are sections of your website. Prismic documents contain a
8
+ * dynamic "Slice Zone" that allows content creators to add, edit, and rearrange
9
+ * Slices to compose dynamic layouts for any page design, such as blog posts,
10
+ * landing pages, case studies, and tutorials.
11
+ *
12
+ * @see More details: {@link https://prismic.io/docs/slice}
13
+ */
14
+ export type SliceZone<
15
+ Slices extends Slice | SharedSlice = Slice | SharedSlice,
16
+ State extends FieldState = FieldState,
17
+ > = State extends "empty" ? [] : [Slices, ...Slices[]];
@@ -0,0 +1,13 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ import type { DateField } from "./date";
4
+
5
+ /**
6
+ * Simple Timestamp Field
7
+ *
8
+ * @typeParam State - State of the field which determines its shape.
9
+ */
10
+ export type TimestampField<State extends FieldState = FieldState> =
11
+ State extends "empty"
12
+ ? null
13
+ : `${DateField<"filled">}T${number}:${number}:${number}+${number}`;
@@ -0,0 +1,32 @@
1
+ import type { FieldState } from "./types";
2
+
3
+ import type {
4
+ RTHeading1Node,
5
+ RTHeading2Node,
6
+ RTHeading3Node,
7
+ RTHeading4Node,
8
+ RTHeading5Node,
9
+ RTHeading6Node,
10
+ } from "./richText";
11
+
12
+ /**
13
+ * Title Field
14
+ *
15
+ * @see Title field documentation: {@link https://prismic.io/docs/rich-text-title}
16
+ */
17
+ export type TitleField<State extends FieldState = FieldState> =
18
+ State extends "empty"
19
+ ? []
20
+ : [
21
+ Omit<
22
+ | RTHeading1Node
23
+ | RTHeading2Node
24
+ | RTHeading3Node
25
+ | RTHeading4Node
26
+ | RTHeading5Node
27
+ | RTHeading6Node,
28
+ "spans"
29
+ > & {
30
+ spans: [];
31
+ },
32
+ ];
@@ -0,0 +1,58 @@
1
+ import type { BooleanField } from "./boolean";
2
+ import type { ColorField } from "./color";
3
+ import type { ContentRelationshipField } from "./contentRelationship";
4
+ import type { DateField } from "./date";
5
+ import type { EmbedField } from "./embed";
6
+ import type { GeoPointField } from "./geoPoint";
7
+ import type { ImageField } from "./image";
8
+ import type { IntegrationFields } from "./integrationFields";
9
+ import type { KeyTextField } from "./keyText";
10
+ import type { LinkField } from "./link";
11
+ import type { LinkToMediaField } from "./linkToMedia";
12
+ import type { NumberField } from "./number";
13
+ import type { RichTextField } from "./richText";
14
+ import type { SelectField } from "./select";
15
+ import type { TimestampField } from "./timestamp";
16
+ import type { TitleField } from "./title";
17
+
18
+ /**
19
+ * Empty state for object-shaped fields.
20
+ */
21
+ export type EmptyObjectField = Record<string, never>;
22
+
23
+ /**
24
+ * Valid states for fields. Not all fields use this type (e.g. BooleanField).
25
+ */
26
+ export type FieldState = "empty" | "filled";
27
+
28
+ /**
29
+ * Any regular field that can be nested in a group-like field.
30
+ */
31
+ export type AnyRegularField =
32
+ | TitleField
33
+ | RichTextField
34
+ | ImageField
35
+ | ContentRelationshipField
36
+ | LinkField
37
+ | LinkToMediaField
38
+ | EmbedField
39
+ | DateField
40
+ | TimestampField
41
+ | ColorField
42
+ | NumberField
43
+ | KeyTextField
44
+ | SelectField
45
+ | BooleanField
46
+ | GeoPointField
47
+ | IntegrationFields;
48
+
49
+ /**
50
+ * Useful to flatten the type output to improve type hints shown in editors. And
51
+ * also to transform an interface into a type to aide with assignability.
52
+ *
53
+ * Taken from the `type-fest` package.
54
+ *
55
+ * @typeParam T - The type to simplify.
56
+ * @see https://github.com/sindresorhus/type-fest/blob/cbd7ec510bd136ac045bbc74e391ee686b8a9a2f/source/simplify.d.ts
57
+ */
58
+ export type Simplify<T> = { [P in keyof T]: T[P] };