@prismicio/client 7.7.2 → 7.7.4

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 (304) hide show
  1. package/README.md +3 -3
  2. package/dist/buildQueryURL.cjs.map +1 -1
  3. package/dist/buildQueryURL.d.ts +1 -1
  4. package/dist/buildQueryURL.js.map +1 -1
  5. package/dist/cookie.cjs.map +1 -1
  6. package/dist/cookie.js.map +1 -1
  7. package/dist/createClient.cjs +31 -31
  8. package/dist/createClient.cjs.map +1 -1
  9. package/dist/createClient.d.ts +35 -35
  10. package/dist/createClient.js +31 -31
  11. package/dist/createClient.js.map +1 -1
  12. package/dist/errors/ForbiddenError.cjs.map +1 -1
  13. package/dist/errors/ForbiddenError.js.map +1 -1
  14. package/dist/errors/NotFoundError.cjs.map +1 -1
  15. package/dist/errors/NotFoundError.js.map +1 -1
  16. package/dist/errors/ParsingError.cjs.map +1 -1
  17. package/dist/errors/ParsingError.js.map +1 -1
  18. package/dist/errors/PreviewTokenExpired.cjs.map +1 -1
  19. package/dist/errors/PreviewTokenExpired.js.map +1 -1
  20. package/dist/errors/PrismicError.cjs.map +1 -1
  21. package/dist/errors/PrismicError.js.map +1 -1
  22. package/dist/errors/PrismicRichTextSerializerError.cjs.map +1 -1
  23. package/dist/errors/PrismicRichTextSerializerError.js.map +1 -1
  24. package/dist/errors/RefExpiredError.cjs.map +1 -1
  25. package/dist/errors/RefExpiredError.js.map +1 -1
  26. package/dist/errors/RefNotFoundError.cjs.map +1 -1
  27. package/dist/errors/RefNotFoundError.js.map +1 -1
  28. package/dist/errors/RepositoryNotFoundError.cjs.map +1 -1
  29. package/dist/errors/RepositoryNotFoundError.js.map +1 -1
  30. package/dist/filter.cjs.map +1 -1
  31. package/dist/filter.js.map +1 -1
  32. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  33. package/dist/getGraphQLEndpoint.js.map +1 -1
  34. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  35. package/dist/getRepositoryEndpoint.js.map +1 -1
  36. package/dist/getRepositoryName.cjs.map +1 -1
  37. package/dist/getRepositoryName.js.map +1 -1
  38. package/dist/getToolbarSrc.cjs.map +1 -1
  39. package/dist/getToolbarSrc.js.map +1 -1
  40. package/dist/helpers/asDate.cjs.map +1 -1
  41. package/dist/helpers/asDate.js.map +1 -1
  42. package/dist/helpers/asHTML.cjs.map +1 -1
  43. package/dist/helpers/asHTML.d.ts +2 -2
  44. package/dist/helpers/asHTML.js.map +1 -1
  45. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  46. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -2
  47. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  48. package/dist/helpers/asImageSrc.cjs.map +1 -1
  49. package/dist/helpers/asImageSrc.d.ts +2 -2
  50. package/dist/helpers/asImageSrc.js.map +1 -1
  51. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  52. package/dist/helpers/asImageWidthSrcSet.d.ts +2 -2
  53. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  54. package/dist/helpers/asLink.cjs.map +1 -1
  55. package/dist/helpers/asLink.d.ts +2 -4
  56. package/dist/helpers/asLink.js.map +1 -1
  57. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  58. package/dist/helpers/asLinkAttrs.d.ts +2 -2
  59. package/dist/helpers/asLinkAttrs.js.map +1 -1
  60. package/dist/helpers/asText.cjs.map +1 -1
  61. package/dist/helpers/asText.d.ts +1 -1
  62. package/dist/helpers/asText.js.map +1 -1
  63. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  64. package/dist/helpers/documentToLinkField.js.map +1 -1
  65. package/dist/helpers/isFilled.cjs.map +1 -1
  66. package/dist/helpers/isFilled.js.map +1 -1
  67. package/dist/helpers/mapSliceZone.cjs.map +1 -1
  68. package/dist/helpers/mapSliceZone.d.ts +1 -1
  69. package/dist/helpers/mapSliceZone.js.map +1 -1
  70. package/dist/helpers/unstable_htmlAsRichText.cjs.map +1 -1
  71. package/dist/helpers/unstable_htmlAsRichText.d.ts +4 -4
  72. package/dist/helpers/unstable_htmlAsRichText.js.map +1 -1
  73. package/dist/helpers/unstable_markdownAsRichText.cjs.map +1 -1
  74. package/dist/helpers/unstable_markdownAsRichText.d.ts +2 -2
  75. package/dist/helpers/unstable_markdownAsRichText.js.map +1 -1
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  79. package/dist/isRepositoryEndpoint.js.map +1 -1
  80. package/dist/isRepositoryName.cjs.map +1 -1
  81. package/dist/isRepositoryName.js.map +1 -1
  82. package/dist/lib/RichTextFieldBuilder.cjs.map +1 -1
  83. package/dist/lib/RichTextFieldBuilder.d.ts +1 -1
  84. package/dist/lib/RichTextFieldBuilder.js.map +1 -1
  85. package/dist/lib/appendFilters.cjs.map +1 -1
  86. package/dist/lib/appendFilters.js.map +1 -1
  87. package/dist/lib/castArray.cjs.map +1 -1
  88. package/dist/lib/castArray.js.map +1 -1
  89. package/dist/lib/castThunk.cjs.map +1 -1
  90. package/dist/lib/castThunk.js.map +1 -1
  91. package/dist/lib/devMsg.cjs.map +1 -1
  92. package/dist/lib/devMsg.d.ts +1 -1
  93. package/dist/lib/devMsg.js.map +1 -1
  94. package/dist/lib/escapeHTML.cjs.map +1 -1
  95. package/dist/lib/escapeHTML.js.map +1 -1
  96. package/dist/lib/everyTagFilter.cjs.map +1 -1
  97. package/dist/lib/everyTagFilter.js.map +1 -1
  98. package/dist/lib/filterRichTextField.cjs.map +1 -1
  99. package/dist/lib/filterRichTextField.d.ts +3 -3
  100. package/dist/lib/filterRichTextField.js.map +1 -1
  101. package/dist/lib/findMasterRef.cjs.map +1 -1
  102. package/dist/lib/findMasterRef.d.ts +1 -1
  103. package/dist/lib/findMasterRef.js.map +1 -1
  104. package/dist/lib/findRef.cjs.map +1 -1
  105. package/dist/lib/findRef.d.ts +1 -1
  106. package/dist/lib/findRef.js.map +1 -1
  107. package/dist/lib/findRefByID.cjs.map +1 -1
  108. package/dist/lib/findRefByID.d.ts +1 -1
  109. package/dist/lib/findRefByID.js.map +1 -1
  110. package/dist/lib/findRefByLabel.cjs.map +1 -1
  111. package/dist/lib/findRefByLabel.d.ts +1 -1
  112. package/dist/lib/findRefByLabel.js.map +1 -1
  113. package/dist/lib/getPreviewCookie.cjs.map +1 -1
  114. package/dist/lib/getPreviewCookie.js.map +1 -1
  115. package/dist/lib/hastSerializerHelpers.cjs.map +1 -1
  116. package/dist/lib/hastSerializerHelpers.d.ts +3 -3
  117. package/dist/lib/hastSerializerHelpers.js.map +1 -1
  118. package/dist/lib/hastToRichText.cjs +3 -4
  119. package/dist/lib/hastToRichText.cjs.map +1 -1
  120. package/dist/lib/hastToRichText.d.ts +4 -4
  121. package/dist/lib/hastToRichText.js +3 -4
  122. package/dist/lib/hastToRichText.js.map +1 -1
  123. package/dist/lib/isInternalURL.cjs.map +1 -1
  124. package/dist/lib/isInternalURL.js.map +1 -1
  125. package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
  126. package/dist/lib/minifyGraphQLQuery.js.map +1 -1
  127. package/dist/lib/rehypeRichText.cjs.map +1 -1
  128. package/dist/lib/rehypeRichText.d.ts +5 -5
  129. package/dist/lib/rehypeRichText.js.map +1 -1
  130. package/dist/lib/serializerHelpers.cjs.map +1 -1
  131. package/dist/lib/serializerHelpers.d.ts +2 -2
  132. package/dist/lib/serializerHelpers.js.map +1 -1
  133. package/dist/lib/someTagsFilter.cjs.map +1 -1
  134. package/dist/lib/someTagsFilter.js.map +1 -1
  135. package/dist/lib/typeFilter.cjs.map +1 -1
  136. package/dist/lib/typeFilter.js.map +1 -1
  137. package/dist/package.json.cjs +1 -1
  138. package/dist/package.json.js +1 -1
  139. package/dist/richtext/asText.cjs.map +1 -1
  140. package/dist/richtext/asText.d.ts +1 -1
  141. package/dist/richtext/asText.js.map +1 -1
  142. package/dist/richtext/asTree.cjs.map +1 -1
  143. package/dist/richtext/asTree.d.ts +2 -2
  144. package/dist/richtext/asTree.js.map +1 -1
  145. package/dist/richtext/composeSerializers.cjs.map +1 -1
  146. package/dist/richtext/composeSerializers.d.ts +1 -1
  147. package/dist/richtext/composeSerializers.js.map +1 -1
  148. package/dist/richtext/serialize.cjs.map +1 -1
  149. package/dist/richtext/serialize.d.ts +1 -1
  150. package/dist/richtext/serialize.js.map +1 -1
  151. package/dist/richtext/types.cjs.map +1 -1
  152. package/dist/richtext/types.d.ts +1 -1
  153. package/dist/richtext/types.js.map +1 -1
  154. package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
  155. package/dist/richtext/wrapMapSerializer.d.ts +1 -1
  156. package/dist/richtext/wrapMapSerializer.js.map +1 -1
  157. package/dist/types/api/query.d.ts +1 -1
  158. package/dist/types/api/release.d.ts +1 -1
  159. package/dist/types/api/repository.d.ts +1 -1
  160. package/dist/types/model/customType.d.ts +1 -1
  161. package/dist/types/model/link.cjs.map +1 -1
  162. package/dist/types/model/link.js.map +1 -1
  163. package/dist/types/model/slice.cjs.map +1 -1
  164. package/dist/types/model/slice.js.map +1 -1
  165. package/dist/types/model/sliceZone.cjs.map +1 -1
  166. package/dist/types/model/sliceZone.js.map +1 -1
  167. package/dist/types/model/title.d.ts +1 -1
  168. package/dist/types/model/types.cjs.map +1 -1
  169. package/dist/types/model/types.js.map +1 -1
  170. package/dist/types/value/document.d.ts +4 -4
  171. package/dist/types/value/embed.cjs.map +1 -1
  172. package/dist/types/value/embed.js.map +1 -1
  173. package/dist/types/value/link.cjs.map +1 -1
  174. package/dist/types/value/link.js.map +1 -1
  175. package/dist/types/value/richText.cjs.map +1 -1
  176. package/dist/types/value/richText.js.map +1 -1
  177. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  178. package/dist/types/webhook/testTrigger.d.ts +1 -1
  179. package/dist/types/webhook/types.cjs.map +1 -1
  180. package/dist/types/webhook/types.d.ts +2 -2
  181. package/dist/types/webhook/types.js.map +1 -1
  182. package/package.json +1 -1
  183. package/src/buildQueryURL.ts +51 -51
  184. package/src/cookie.ts +1 -1
  185. package/src/createClient.ts +293 -293
  186. package/src/errors/ForbiddenError.ts +6 -6
  187. package/src/errors/NotFoundError.ts +1 -1
  188. package/src/errors/ParsingError.ts +8 -8
  189. package/src/errors/PreviewTokenExpired.ts +4 -4
  190. package/src/errors/PrismicError.ts +5 -5
  191. package/src/errors/PrismicRichTextSerializerError.ts +1 -1
  192. package/src/errors/RefExpiredError.ts +4 -4
  193. package/src/errors/RefNotFoundError.ts +4 -4
  194. package/src/errors/RepositoryNotFoundError.ts +1 -1
  195. package/src/filter.ts +22 -22
  196. package/src/getGraphQLEndpoint.ts +5 -5
  197. package/src/getRepositoryEndpoint.ts +5 -5
  198. package/src/getRepositoryName.ts +4 -4
  199. package/src/getToolbarSrc.ts +5 -5
  200. package/src/helpers/asDate.ts +7 -7
  201. package/src/helpers/asHTML.ts +54 -56
  202. package/src/helpers/asImagePixelDensitySrcSet.ts +14 -17
  203. package/src/helpers/asImageSrc.ts +9 -8
  204. package/src/helpers/asImageWidthSrcSet.ts +19 -22
  205. package/src/helpers/asLink.ts +26 -27
  206. package/src/helpers/asLinkAttrs.ts +30 -29
  207. package/src/helpers/asText.ts +15 -15
  208. package/src/helpers/documentToLinkField.ts +6 -6
  209. package/src/helpers/isFilled.ts +53 -53
  210. package/src/helpers/mapSliceZone.ts +34 -34
  211. package/src/helpers/unstable_htmlAsRichText.ts +23 -22
  212. package/src/helpers/unstable_markdownAsRichText.ts +14 -13
  213. package/src/index.ts +119 -119
  214. package/src/isRepositoryEndpoint.ts +4 -4
  215. package/src/isRepositoryName.ts +2 -2
  216. package/src/lib/RichTextFieldBuilder.ts +36 -41
  217. package/src/lib/appendFilters.ts +4 -4
  218. package/src/lib/castArray.ts +2 -2
  219. package/src/lib/castThunk.ts +2 -2
  220. package/src/lib/devMsg.ts +4 -4
  221. package/src/lib/escapeHTML.ts +24 -24
  222. package/src/lib/everyTagFilter.ts +4 -4
  223. package/src/lib/filterRichTextField.ts +31 -31
  224. package/src/lib/findMasterRef.ts +4 -4
  225. package/src/lib/findRef.ts +6 -6
  226. package/src/lib/findRefByID.ts +4 -4
  227. package/src/lib/findRefByLabel.ts +4 -4
  228. package/src/lib/getPreviewCookie.ts +11 -11
  229. package/src/lib/hastSerializerHelpers.ts +41 -37
  230. package/src/lib/hastToRichText.ts +74 -73
  231. package/src/lib/isInternalURL.ts +4 -4
  232. package/src/lib/minifyGraphQLQuery.ts +2 -2
  233. package/src/lib/rehypeRichText.ts +42 -41
  234. package/src/lib/serializerHelpers.ts +53 -54
  235. package/src/lib/someTagsFilter.ts +4 -4
  236. package/src/lib/typeFilter.ts +3 -3
  237. package/src/richtext/asText.ts +5 -5
  238. package/src/richtext/asTree.ts +53 -53
  239. package/src/richtext/composeSerializers.ts +6 -6
  240. package/src/richtext/index.ts +7 -7
  241. package/src/richtext/serialize.ts +11 -11
  242. package/src/richtext/types.ts +38 -38
  243. package/src/richtext/wrapMapSerializer.ts +6 -9
  244. package/src/types/api/query.ts +9 -9
  245. package/src/types/api/ref.ts +5 -5
  246. package/src/types/api/release.ts +2 -2
  247. package/src/types/api/repository.ts +24 -24
  248. package/src/types/api/tags.ts +1 -1
  249. package/src/types/model/boolean.ts +7 -7
  250. package/src/types/model/color.ts +5 -5
  251. package/src/types/model/contentRelationship.ts +9 -9
  252. package/src/types/model/customType.ts +9 -9
  253. package/src/types/model/date.ts +6 -6
  254. package/src/types/model/embed.ts +5 -5
  255. package/src/types/model/geoPoint.ts +4 -4
  256. package/src/types/model/group.ts +6 -6
  257. package/src/types/model/image.ts +9 -9
  258. package/src/types/model/integration.ts +6 -6
  259. package/src/types/model/keyText.ts +5 -5
  260. package/src/types/model/link.ts +8 -8
  261. package/src/types/model/linkToMedia.ts +7 -7
  262. package/src/types/model/number.ts +7 -7
  263. package/src/types/model/range.ts +8 -8
  264. package/src/types/model/richText.ts +16 -16
  265. package/src/types/model/select.ts +7 -7
  266. package/src/types/model/separator.ts +4 -4
  267. package/src/types/model/sharedSlice.ts +7 -7
  268. package/src/types/model/sharedSliceVariation.ts +9 -9
  269. package/src/types/model/slice.ts +12 -12
  270. package/src/types/model/sliceZone.ts +11 -11
  271. package/src/types/model/timestamp.ts +6 -6
  272. package/src/types/model/title.ts +2 -2
  273. package/src/types/model/types.ts +26 -26
  274. package/src/types/model/uid.ts +5 -5
  275. package/src/types/value/boolean.ts +1 -1
  276. package/src/types/value/color.ts +2 -2
  277. package/src/types/value/contentRelationship.ts +15 -15
  278. package/src/types/value/date.ts +2 -2
  279. package/src/types/value/document.ts +23 -23
  280. package/src/types/value/embed.ts +33 -33
  281. package/src/types/value/geoPoint.ts +4 -4
  282. package/src/types/value/group.ts +3 -3
  283. package/src/types/value/image.ts +21 -21
  284. package/src/types/value/integration.ts +2 -2
  285. package/src/types/value/keyText.ts +2 -2
  286. package/src/types/value/link.ts +12 -12
  287. package/src/types/value/linkToMedia.ts +11 -11
  288. package/src/types/value/number.ts +2 -2
  289. package/src/types/value/richText.ts +58 -58
  290. package/src/types/value/select.ts +2 -2
  291. package/src/types/value/sharedSlice.ts +5 -5
  292. package/src/types/value/sharedSliceVariation.ts +5 -5
  293. package/src/types/value/slice.ts +6 -6
  294. package/src/types/value/sliceZone.ts +4 -4
  295. package/src/types/value/timestamp.ts +3 -3
  296. package/src/types/value/title.ts +4 -4
  297. package/src/types/value/types.ts +22 -22
  298. package/src/types/webhook/apiUpdate.ts +18 -18
  299. package/src/types/webhook/testTrigger.ts +2 -2
  300. package/src/types/webhook/types.ts +8 -8
  301. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs +0 -11
  302. package/dist/_node_modules/hast-util-whitespace/lib/index.cjs.map +0 -1
  303. package/dist/_node_modules/hast-util-whitespace/lib/index.js +0 -11
  304. package/dist/_node_modules/hast-util-whitespace/lib/index.js.map +0 -1
@@ -1,23 +1,23 @@
1
- import type { ColorField } from "../types/value/color";
2
- import type { ContentRelationshipField } from "../types/value/contentRelationship";
3
- import type { DateField } from "../types/value/date";
4
- import type { AnyOEmbed, EmbedField } from "../types/value/embed";
5
- import type { GeoPointField } from "../types/value/geoPoint";
6
- import type { GroupField, NestedGroupField } from "../types/value/group";
7
- import type { ImageField, ImageFieldImage } from "../types/value/image";
8
- import type { IntegrationField } from "../types/value/integration";
9
- import type { KeyTextField } from "../types/value/keyText";
10
- import type { LinkField } from "../types/value/link";
11
- import type { LinkToMediaField } from "../types/value/linkToMedia";
12
- import type { NumberField } from "../types/value/number";
13
- import type { RichTextField } from "../types/value/richText";
14
- import type { SelectField } from "../types/value/select";
15
- import type { SharedSlice } from "../types/value/sharedSlice";
16
- import type { Slice } from "../types/value/slice";
17
- import type { SliceZone } from "../types/value/sliceZone";
18
- import type { TimestampField } from "../types/value/timestamp";
19
- import type { TitleField } from "../types/value/title";
20
- import type { AnyRegularField } from "../types/value/types";
1
+ import type { ColorField } from "../types/value/color"
2
+ import type { ContentRelationshipField } from "../types/value/contentRelationship"
3
+ import type { DateField } from "../types/value/date"
4
+ import type { AnyOEmbed, EmbedField } from "../types/value/embed"
5
+ import type { GeoPointField } from "../types/value/geoPoint"
6
+ import type { GroupField, NestedGroupField } from "../types/value/group"
7
+ import type { ImageField, ImageFieldImage } from "../types/value/image"
8
+ import type { IntegrationField } from "../types/value/integration"
9
+ import type { KeyTextField } from "../types/value/keyText"
10
+ import type { LinkField } from "../types/value/link"
11
+ import type { LinkToMediaField } from "../types/value/linkToMedia"
12
+ import type { NumberField } from "../types/value/number"
13
+ import type { RichTextField } from "../types/value/richText"
14
+ import type { SelectField } from "../types/value/select"
15
+ import type { SharedSlice } from "../types/value/sharedSlice"
16
+ import type { Slice } from "../types/value/slice"
17
+ import type { SliceZone } from "../types/value/sliceZone"
18
+ import type { TimestampField } from "../types/value/timestamp"
19
+ import type { TitleField } from "../types/value/title"
20
+ import type { AnyRegularField } from "../types/value/types"
21
21
 
22
22
  /**
23
23
  * Determines if a value is not nullish (i.e. not `null` or `undefined`). This
@@ -28,8 +28,8 @@ import type { AnyRegularField } from "../types/value/types";
28
28
  * @returns `true` if `input` is not nullish, `false` otherwise.
29
29
  */
30
30
  const isNonNullish = <T>(input: T): input is NonNullable<T> => {
31
- return input != null;
32
- };
31
+ return input != null
32
+ }
33
33
 
34
34
  /**
35
35
  * Determines if an array is not empty. This is used to check if array-based
@@ -40,8 +40,8 @@ const isNonNullish = <T>(input: T): input is NonNullable<T> => {
40
40
  * @returns `true` if `input` has at least one element, `false` otherwise.
41
41
  */
42
42
  const isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {
43
- return !!input.length;
44
- };
43
+ return !!input.length
44
+ }
45
45
 
46
46
  /**
47
47
  * Determines if a rich text field is filled.
@@ -54,13 +54,13 @@ export const richText = (
54
54
  field: RichTextField | null | undefined,
55
55
  ): field is RichTextField<"filled"> => {
56
56
  if (!isNonNullish(field)) {
57
- return false;
57
+ return false
58
58
  } else if (field.length === 1 && "text" in field[0]) {
59
- return !!field[0].text;
59
+ return !!field[0].text
60
60
  } else {
61
- return !!field.length;
61
+ return !!field.length
62
62
  }
63
- };
63
+ }
64
64
 
65
65
  /**
66
66
  * Determines if a title field is filled.
@@ -71,7 +71,7 @@ export const richText = (
71
71
  */
72
72
  export const title = richText as (
73
73
  field: TitleField | null | undefined,
74
- ) => field is TitleField<"filled">;
74
+ ) => field is TitleField<"filled">
75
75
 
76
76
  /**
77
77
  * Determines if an Image thumbnail is filled.
@@ -83,8 +83,8 @@ export const title = richText as (
83
83
  export const imageThumbnail = (
84
84
  thumbnail: ImageFieldImage | null | undefined,
85
85
  ): thumbnail is ImageFieldImage<"filled"> => {
86
- return isNonNullish(thumbnail) && !!thumbnail.url;
87
- };
86
+ return isNonNullish(thumbnail) && !!thumbnail.url
87
+ }
88
88
 
89
89
  /**
90
90
  * Determines if an image field is filled.
@@ -97,7 +97,7 @@ export const image = imageThumbnail as <
97
97
  ThumbnailNames extends string | null = never,
98
98
  >(
99
99
  field: ImageField<ThumbnailNames> | null | undefined,
100
- ) => field is ImageField<ThumbnailNames, "filled">;
100
+ ) => field is ImageField<ThumbnailNames, "filled">
101
101
 
102
102
  /**
103
103
  * Determines if a link field is filled.
@@ -115,8 +115,8 @@ export const link = <
115
115
  >(
116
116
  field: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,
117
117
  ): field is LinkField<TypeEnum, LangEnum, DataInterface, "filled"> => {
118
- return isNonNullish(field) && ("id" in field || "url" in field);
119
- };
118
+ return isNonNullish(field) && ("id" in field || "url" in field)
119
+ }
120
120
 
121
121
  /**
122
122
  * Determines if a link to media field is filled.
@@ -127,7 +127,7 @@ export const link = <
127
127
  */
128
128
  export const linkToMedia = link as (
129
129
  field: LinkToMediaField | null | undefined,
130
- ) => field is LinkToMediaField<"filled">;
130
+ ) => field is LinkToMediaField<"filled">
131
131
 
132
132
  /**
133
133
  * Determines if a content relationship field is filled.
@@ -152,7 +152,7 @@ export const contentRelationship = link as <
152
152
  LangEnum,
153
153
  DataInterface,
154
154
  "filled"
155
- >;
155
+ >
156
156
 
157
157
  /**
158
158
  * Determines if a date field is filled.
@@ -163,7 +163,7 @@ export const contentRelationship = link as <
163
163
  */
164
164
  export const date = isNonNullish as (
165
165
  field: DateField | null | undefined,
166
- ) => field is DateField<"filled">;
166
+ ) => field is DateField<"filled">
167
167
 
168
168
  /**
169
169
  * Determines if a timestamp field is filled.
@@ -174,7 +174,7 @@ export const date = isNonNullish as (
174
174
  */
175
175
  export const timestamp = isNonNullish as (
176
176
  field: TimestampField | null | undefined,
177
- ) => field is TimestampField<"filled">;
177
+ ) => field is TimestampField<"filled">
178
178
 
179
179
  /**
180
180
  * Determines if a color field is filled.
@@ -185,7 +185,7 @@ export const timestamp = isNonNullish as (
185
185
  */
186
186
  export const color = isNonNullish as (
187
187
  field: ColorField | null | undefined,
188
- ) => field is ColorField<"filled">;
188
+ ) => field is ColorField<"filled">
189
189
 
190
190
  /**
191
191
  * Determines if a number field is filled.
@@ -196,7 +196,7 @@ export const color = isNonNullish as (
196
196
  */
197
197
  export const number = isNonNullish as (
198
198
  field: NumberField | null | undefined,
199
- ) => field is NumberField<"filled">;
199
+ ) => field is NumberField<"filled">
200
200
 
201
201
  /**
202
202
  * Determines if a key text field is filled.
@@ -208,8 +208,8 @@ export const number = isNonNullish as (
208
208
  export const keyText = (
209
209
  field: KeyTextField | null | undefined,
210
210
  ): field is KeyTextField<"filled"> => {
211
- return isNonNullish(keyText) && !!field;
212
- };
211
+ return isNonNullish(keyText) && !!field
212
+ }
213
213
 
214
214
  /**
215
215
  * Determines if a select field is filled.
@@ -220,7 +220,7 @@ export const keyText = (
220
220
  */
221
221
  export const select = isNonNullish as <Enum extends string>(
222
222
  field: SelectField<Enum> | null | undefined,
223
- ) => field is SelectField<Enum, "filled">;
223
+ ) => field is SelectField<Enum, "filled">
224
224
 
225
225
  /**
226
226
  * Determines if an embed field is filled.
@@ -232,8 +232,8 @@ export const select = isNonNullish as <Enum extends string>(
232
232
  export const embed = <Field extends EmbedField<AnyOEmbed>>(
233
233
  field: Field | null | undefined,
234
234
  ): field is Extract<Field, EmbedField<AnyOEmbed, "filled">> => {
235
- return isNonNullish(field) && !!field.embed_url;
236
- };
235
+ return isNonNullish(field) && !!field.embed_url
236
+ }
237
237
 
238
238
  /**
239
239
  * Determines if a geopoint field is filled.
@@ -245,8 +245,8 @@ export const embed = <Field extends EmbedField<AnyOEmbed>>(
245
245
  export const geoPoint = (
246
246
  field: GeoPointField | null | undefined,
247
247
  ): field is GeoPointField<"filled"> => {
248
- return isNonNullish(field) && "longitude" in field;
249
- };
248
+ return isNonNullish(field) && "longitude" in field
249
+ }
250
250
 
251
251
  /**
252
252
  * Determines if an integration field is filled.
@@ -259,12 +259,12 @@ export const integrationField = isNonNullish as <
259
259
  Data extends Record<string, unknown>,
260
260
  >(
261
261
  field: IntegrationField<Data> | null | undefined,
262
- ) => field is IntegrationField<Data, "filled">;
262
+ ) => field is IntegrationField<Data, "filled">
263
263
  /**
264
264
  * @deprecated Renamed to `integrationField`.
265
265
  */
266
266
  // TODO: Remove when we remove support for deprecated `integrationFields` export.
267
- export const integrationFields = integrationField;
267
+ export const integrationFields = integrationField
268
268
 
269
269
  /**
270
270
  * Determines if a Group has at least one item.
@@ -278,8 +278,8 @@ export const group = <
278
278
  >(
279
279
  group: GroupField<Fields> | null | undefined,
280
280
  ): group is GroupField<Fields, "filled"> => {
281
- return isNonNullish(group) && isNonEmptyArray(group);
282
- };
281
+ return isNonNullish(group) && isNonEmptyArray(group)
282
+ }
283
283
 
284
284
  /**
285
285
  * Determines if a Slice Zone has at least one Slice.
@@ -291,5 +291,5 @@ export const group = <
291
291
  export const sliceZone = <Slices extends Slice | SharedSlice>(
292
292
  slices: SliceZone<Slices> | null | undefined,
293
293
  ): slices is SliceZone<Slices, "filled"> => {
294
- return isNonNullish(slices) && isNonEmptyArray(slices);
295
- };
294
+ return isNonNullish(slices) && isNonEmptyArray(slices)
295
+ }
@@ -1,18 +1,18 @@
1
- import { Slice } from "../types/value/slice";
1
+ import type { Slice } from "../types/value/slice"
2
2
 
3
3
  /**
4
4
  * Convert a value to a lazyily loaded module. This is useful when using
5
5
  * functions like `() => import("...")`.
6
6
  */
7
- type LazyModule<T> = () => Promise<T | { default: T }>;
7
+ type LazyModule<T> = () => Promise<T | { default: T }>
8
8
 
9
9
  /**
10
10
  * Mark a type as potentially lazy-loaded via a module.
11
11
  */
12
- type MaybeLazyModule<T> = T | LazyModule<T>;
12
+ type MaybeLazyModule<T> = T | LazyModule<T>
13
13
 
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- type AnyFunction = (...args: any[]) => any;
15
+ type AnyFunction = (...args: any[]) => any
16
16
 
17
17
  /**
18
18
  * Returns the type of a `SliceLike` type.
@@ -23,7 +23,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
23
23
  ? TSlice["slice_type"]
24
24
  : TSlice extends SliceLikeGraphQL
25
25
  ? TSlice["type"]
26
- : never;
26
+ : never
27
27
 
28
28
  /**
29
29
  * The minimum required properties to represent a Prismic Slice from the Prismic
@@ -34,7 +34,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
34
34
  type SliceLikeRestV2<TSliceType extends string = string> = Pick<
35
35
  Slice<TSliceType>,
36
36
  "id" | "slice_type"
37
- >;
37
+ >
38
38
 
39
39
  /**
40
40
  * The minimum required properties to represent a Prismic Slice from the Prismic
@@ -43,8 +43,8 @@ type SliceLikeRestV2<TSliceType extends string = string> = Pick<
43
43
  * @typeParam SliceType - Type name of the Slice.
44
44
  */
45
45
  type SliceLikeGraphQL<TSliceType extends string = string> = {
46
- type: Slice<TSliceType>["slice_type"];
47
- };
46
+ type: Slice<TSliceType>["slice_type"]
47
+ }
48
48
 
49
49
  /**
50
50
  * The minimum required properties to represent a Prismic Slice for the
@@ -57,7 +57,7 @@ type SliceLikeGraphQL<TSliceType extends string = string> = {
57
57
  */
58
58
  type SliceLike<TSliceType extends string = string> =
59
59
  | SliceLikeRestV2<TSliceType>
60
- | SliceLikeGraphQL<TSliceType>;
60
+ | SliceLikeGraphQL<TSliceType>
61
61
 
62
62
  /**
63
63
  * A looser version of the `SliceZone` type from `@prismicio/client` using
@@ -68,7 +68,7 @@ type SliceLike<TSliceType extends string = string> =
68
68
  *
69
69
  * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
70
70
  */
71
- type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
71
+ type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]
72
72
 
73
73
  /**
74
74
  * A set of properties that identify a Slice as having been mapped. Consumers of
@@ -82,8 +82,8 @@ type MappedSliceLike = {
82
82
  *
83
83
  * @internal
84
84
  */
85
- __mapped: true;
86
- };
85
+ __mapped: true
86
+ }
87
87
 
88
88
  /**
89
89
  * Arguments for a function mapping content from a Prismic Slice using the
@@ -100,12 +100,12 @@ type SliceMapperArgs<
100
100
  /**
101
101
  * Slice data.
102
102
  */
103
- slice: TSlice;
103
+ slice: TSlice
104
104
 
105
105
  /**
106
106
  * The index of the Slice in the Slice Zone.
107
107
  */
108
- index: number;
108
+ index: number
109
109
 
110
110
  /**
111
111
  * All Slices from the Slice Zone to which the Slice belongs.
@@ -116,14 +116,14 @@ type SliceMapperArgs<
116
116
  // throw a compilation error.
117
117
  slices: SliceZoneLike<
118
118
  TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2
119
- >;
119
+ >
120
120
 
121
121
  /**
122
122
  * Arbitrary data passed to `mapSliceZone()` and made available to all Slice
123
123
  * mappers.
124
124
  */
125
- context: TContext;
126
- };
125
+ context: TContext
126
+ }
127
127
 
128
128
  /**
129
129
  * A record of mappers.
@@ -136,8 +136,8 @@ type SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
136
136
  any,
137
137
  TContext
138
138
  >
139
- >;
140
- };
139
+ >
140
+ }
141
141
 
142
142
  /**
143
143
  * A function that maps a Slice and its metadata to a modified version. The
@@ -152,7 +152,7 @@ export type SliceMapper<
152
152
  TContext = unknown,
153
153
  > = (
154
154
  args: SliceMapperArgs<TSlice, TContext>,
155
- ) => TMappedSlice | Promise<TMappedSlice>;
155
+ ) => TMappedSlice | Promise<TMappedSlice>
156
156
 
157
157
  /**
158
158
  * Unwraps a lazily loaded mapper module.
@@ -163,11 +163,11 @@ type ResolveLazySliceMapperModule<
163
163
  > =
164
164
  TSliceMapper extends LazyModule<SliceMapper>
165
165
  ? Awaited<ReturnType<TSliceMapper>> extends {
166
- default: unknown;
166
+ default: unknown
167
167
  }
168
168
  ? Awaited<ReturnType<TSliceMapper>>["default"]
169
169
  : Awaited<ReturnType<TSliceMapper>>
170
- : TSliceMapper;
170
+ : TSliceMapper
171
171
 
172
172
  /**
173
173
  * Transforms a Slice into its mapped version.
@@ -206,7 +206,7 @@ type MapSliceLike<
206
206
  >
207
207
  : TSliceLike
208
208
  : TSliceLike
209
- : never;
209
+ : never
210
210
 
211
211
  /**
212
212
  * Transforms a Slice Zone using a set of mapping functions, one for each type
@@ -236,23 +236,23 @@ export function mapSliceZone<
236
236
  ): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {
237
237
  return Promise.all(
238
238
  sliceZone.map(async (slice, index, slices) => {
239
- const isRestSliceType = "slice_type" in slice;
240
- const sliceType = isRestSliceType ? slice.slice_type : slice.type;
239
+ const isRestSliceType = "slice_type" in slice
240
+ const sliceType = isRestSliceType ? slice.slice_type : slice.type
241
241
 
242
- const mapper = mappers[sliceType as keyof typeof mappers];
242
+ const mapper = mappers[sliceType as keyof typeof mappers]
243
243
 
244
244
  if (!mapper) {
245
- return slice;
245
+ return slice
246
246
  }
247
247
 
248
- const mapperArgs = { slice, slices, index, context };
248
+ const mapperArgs = { slice, slices, index, context }
249
249
 
250
250
  // `result` may be a mapper function OR a module
251
251
  // containing a mapper function.
252
252
  let result = await mapper(
253
253
  // @ts-expect-error - I don't know how to fix this type
254
254
  mapperArgs,
255
- );
255
+ )
256
256
 
257
257
  // `result` is a module containing a mapper function,
258
258
  // we need to dig out the mapper function. `result`
@@ -265,8 +265,8 @@ export function mapSliceZone<
265
265
  (typeof result === "function" ||
266
266
  (typeof result === "object" && "default" in result))
267
267
  ) {
268
- result = "default" in result ? result.default : result;
269
- result = await result(mapperArgs);
268
+ result = "default" in result ? result.default : result
269
+ result = await result(mapperArgs)
270
270
  }
271
271
 
272
272
  if (isRestSliceType) {
@@ -275,14 +275,14 @@ export function mapSliceZone<
275
275
  id: slice.id,
276
276
  slice_type: sliceType,
277
277
  ...result,
278
- };
278
+ }
279
279
  } else {
280
280
  return {
281
281
  __mapped: true,
282
282
  type: sliceType,
283
283
  ...result,
284
- };
284
+ }
285
285
  }
286
286
  }),
287
- );
287
+ )
288
288
  }
@@ -1,20 +1,21 @@
1
- import { Element } from "hast";
2
- import rehypeParse from "rehype-parse";
3
- import { unified } from "unified";
1
+ import type { Element } from "hast"
2
+ import rehypeParse from "rehype-parse"
3
+ import { unified } from "unified"
4
4
 
5
- import { RTPartialInlineNode } from "../lib/RichTextFieldBuilder";
6
- import { RehypeRichTextConfig, rehypeRichText } from "../lib/rehypeRichText";
5
+ import type { RTPartialInlineNode } from "../lib/RichTextFieldBuilder"
6
+ import type { RehypeRichTextConfig } from "../lib/rehypeRichText"
7
+ import { rehypeRichText } from "../lib/rehypeRichText"
7
8
 
8
- import {
9
+ import type {
9
10
  RTInlineNode,
10
11
  RTNode,
11
12
  RichTextField,
12
13
  RichTextNodeTypes,
13
- } from "../types/value/richText";
14
+ } from "../types/value/richText"
14
15
 
15
16
  // Used for TSDocs only.
16
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
- import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML";
18
+ import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML"
18
19
 
19
20
  /**
20
21
  * A shorthand definition for {@link RichTextHTMLMapSerializer} rich text node
@@ -30,7 +31,7 @@ import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML";
30
31
  */
31
32
  export type RichTextHTMLMapSerializerShorthand =
32
33
  | Exclude<RichTextNodeTypes, "label" | "span">
33
- | { label: string };
34
+ | { label: string }
34
35
 
35
36
  /**
36
37
  * The payload provided to a {@link RichTextHTMLMapSerializerFunction}.
@@ -39,7 +40,7 @@ type RichTextHTMLMapSerializerFunctionPayload = {
39
40
  /**
40
41
  * The hast {@link Element} node to serialize.
41
42
  */
42
- node: Element;
43
+ node: Element
43
44
 
44
45
  /**
45
46
  * Additional context information to help with the serialization.
@@ -48,9 +49,9 @@ type RichTextHTMLMapSerializerFunctionPayload = {
48
49
  /**
49
50
  * The list type of the last list node encountered if any.
50
51
  */
51
- listType?: "group-list-item" | "group-o-list-item";
52
- };
53
- };
52
+ listType?: "group-list-item" | "group-o-list-item"
53
+ }
54
+ }
54
55
 
55
56
  /**
56
57
  * Serializes a hast {@link Element} node to a
@@ -68,7 +69,7 @@ export type RichTextHTMLMapSerializerFunction = (
68
69
  | RTNode
69
70
  | RTInlineNode
70
71
  | RTPartialInlineNode
71
- | undefined;
72
+ | undefined
72
73
 
73
74
  /**
74
75
  * Serializes a hast {@link Element} node matching the given HTML tag name or CSS
@@ -82,20 +83,20 @@ export type RichTextHTMLMapSerializerFunction = (
82
83
  export type RichTextHTMLMapSerializer = Record<
83
84
  string,
84
85
  RichTextHTMLMapSerializerShorthand | RichTextHTMLMapSerializerFunction
85
- >;
86
+ >
86
87
 
87
88
  /**
88
89
  * Configuration that determines the output of {@link htmlAsRichText}.
89
90
  */
90
- export type HTMLAsRichTextConfig = RehypeRichTextConfig;
91
+ export type HTMLAsRichTextConfig = RehypeRichTextConfig
91
92
 
92
93
  /**
93
94
  * The return type of {@link htmlAsRichText}.
94
95
  */
95
96
  type HTMLAsRichTextReturnType = {
96
- result: RichTextField;
97
- warnings: string[];
98
- };
97
+ result: RichTextField
98
+ warnings: string[]
99
+ }
99
100
 
100
101
  /**
101
102
  * Converts an HTML string to a rich text field.
@@ -115,7 +116,7 @@ export const unstable_htmlAsRichText = (
115
116
  const { result, messages } = unified()
116
117
  .use(rehypeParse, { emitParseErrors: true, missingDoctype: 0 })
117
118
  .use(rehypeRichText, config)
118
- .processSync(html);
119
+ .processSync(html)
119
120
 
120
- return { result, warnings: messages.map((message) => message.toString()) };
121
- };
121
+ return { result, warnings: messages.map((message) => message.toString()) }
122
+ }
@@ -1,27 +1,28 @@
1
- import remarkParse from "remark-parse";
2
- import remarkRehype from "remark-rehype";
3
- import { unified } from "unified";
1
+ import remarkParse from "remark-parse"
2
+ import remarkRehype from "remark-rehype"
3
+ import { unified } from "unified"
4
4
 
5
- import { RehypeRichTextConfig, rehypeRichText } from "../lib/rehypeRichText";
5
+ import type { RehypeRichTextConfig } from "../lib/rehypeRichText"
6
+ import { rehypeRichText } from "../lib/rehypeRichText"
6
7
 
7
- import { RichTextField } from "../types/value/richText";
8
+ import type { RichTextField } from "../types/value/richText"
8
9
 
9
10
  // Used for TSDocs only.
10
11
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- import type { unstable_htmlAsRichText } from "./unstable_htmlAsRichText";
12
+ import type { unstable_htmlAsRichText } from "./unstable_htmlAsRichText"
12
13
 
13
14
  /**
14
15
  * Configuration that determines the output of {@link markdownAsRichText}.
15
16
  */
16
- export type MarkdownAsRichTextConfig = RehypeRichTextConfig;
17
+ export type MarkdownAsRichTextConfig = RehypeRichTextConfig
17
18
 
18
19
  /**
19
20
  * The return type of {@link markdownAsRichText}.
20
21
  */
21
22
  type MarkdownAsRichTextReturnType = {
22
- result: RichTextField;
23
- warnings: string[];
24
- };
23
+ result: RichTextField
24
+ warnings: string[]
25
+ }
25
26
 
26
27
  /**
27
28
  * Converts a markdown string to a rich text field.
@@ -46,7 +47,7 @@ export const unstable_markdownAsRichText = (
46
47
  .use(remarkParse)
47
48
  .use(remarkRehype)
48
49
  .use(rehypeRichText, config)
49
- .processSync(markdown);
50
+ .processSync(markdown)
50
51
 
51
- return { result, warnings: messages.map((message) => message.toString()) };
52
- };
52
+ return { result, warnings: messages.map((message) => message.toString()) }
53
+ }