@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,13 +1,13 @@
1
- import { PrismicError } from "./PrismicError";
1
+ import { PrismicError } from "./PrismicError"
2
2
 
3
3
  type ForbiddenErrorRepositoryAPIResponse = {
4
- type: string;
5
- message: string;
6
- };
4
+ type: string
5
+ message: string
6
+ }
7
7
 
8
8
  type ForbiddenErrorQueryAPIResponse = {
9
- error: string;
10
- };
9
+ error: string
10
+ }
11
11
 
12
12
  export class ForbiddenError<
13
13
  TResponse =
@@ -1,4 +1,4 @@
1
- import { PrismicError } from "./PrismicError";
1
+ import { PrismicError } from "./PrismicError"
2
2
 
3
3
  export class NotFoundError<
4
4
  TResponse = undefined,
@@ -1,13 +1,13 @@
1
- import { PrismicError } from "./PrismicError";
1
+ import { PrismicError } from "./PrismicError"
2
2
 
3
3
  type ParsingErrorAPIResponse = {
4
- type: "parsing-error";
5
- message: string;
6
- line: number;
7
- column: number;
8
- id: number;
9
- location: string;
10
- };
4
+ type: "parsing-error"
5
+ message: string
6
+ line: number
7
+ column: number
8
+ id: number
9
+ location: string
10
+ }
11
11
 
12
12
  export class ParsingError<
13
13
  TResponse = ParsingErrorAPIResponse,
@@ -1,9 +1,9 @@
1
- import { ForbiddenError } from "./ForbiddenError";
1
+ import { ForbiddenError } from "./ForbiddenError"
2
2
 
3
3
  type PreviewTokenExpiredErrorAPIResponse = {
4
- type: "api_security_error";
5
- message: string;
6
- };
4
+ type: "api_security_error"
5
+ message: string
6
+ }
7
7
 
8
8
  // This error extends `ForbiddenError` for backwards compatibility.
9
9
  // TODO: Extend this error from `PrismicError` in v8.
@@ -1,15 +1,15 @@
1
1
  export class PrismicError<Response> extends Error {
2
- url?: string;
3
- response: Response;
2
+ url?: string
3
+ response: Response
4
4
 
5
5
  constructor(
6
6
  message = "An invalid API response was returned",
7
7
  url: string | undefined,
8
8
  response: Response,
9
9
  ) {
10
- super(message);
10
+ super(message)
11
11
 
12
- this.url = url;
13
- this.response = response;
12
+ this.url = url
13
+ this.response = response
14
14
  }
15
15
  }
@@ -1,3 +1,3 @@
1
- import { PrismicRichTextError } from "./PrismicRichTextError";
1
+ import { PrismicRichTextError } from "./PrismicRichTextError"
2
2
 
3
3
  export class PrismicRichTextSerializerError extends PrismicRichTextError {}
@@ -1,9 +1,9 @@
1
- import { ForbiddenError } from "./ForbiddenError";
1
+ import { ForbiddenError } from "./ForbiddenError"
2
2
 
3
3
  type RefExpiredErrorAPIResponse = {
4
- type: "api_validation_error";
5
- message: string;
6
- };
4
+ type: "api_validation_error"
5
+ message: string
6
+ }
7
7
 
8
8
  // This error extends `ForbiddenError` for backwards compatibility. Before the
9
9
  // API started returning 410 for expired refs, it returnd 403, which threw a
@@ -1,9 +1,9 @@
1
- import { ForbiddenError } from "./ForbiddenError";
1
+ import { ForbiddenError } from "./ForbiddenError"
2
2
 
3
3
  type RefNotFoundErrorAPIResponse = {
4
- type: "api_notfound_error";
5
- message: string;
6
- };
4
+ type: "api_notfound_error"
5
+ message: string
6
+ }
7
7
 
8
8
  // This error extends `ForbiddenError` for backwards compatibility. Before the
9
9
  // API started returning 404 for not found refs, it returnd 403, which threw a
@@ -1,4 +1,4 @@
1
- import { NotFoundError } from "./NotFoundError";
1
+ import { NotFoundError } from "./NotFoundError"
2
2
 
3
3
  export class RepositoryNotFoundError<
4
4
  TResponse = undefined,
package/src/filter.ts CHANGED
@@ -15,19 +15,19 @@ const formatValue = (
15
15
  | (string | number | Date | unknown)[],
16
16
  ): string => {
17
17
  if (Array.isArray(value)) {
18
- return `[${value.map(formatValue).join(", ")}]`;
18
+ return `[${value.map(formatValue).join(", ")}]`
19
19
  }
20
20
 
21
21
  if (typeof value === "string") {
22
- return `"${value}"`;
22
+ return `"${value}"`
23
23
  }
24
24
 
25
25
  if (value instanceof Date) {
26
- return `${value.getTime()}`;
26
+ return `${value.getTime()}`
27
27
  }
28
28
 
29
- return `${value}`;
30
- };
29
+ return `${value}`
30
+ }
31
31
 
32
32
  /**
33
33
  * Creates a filter builder function for filters with a path and arguments.
@@ -43,14 +43,14 @@ const pathWithArgsFilter = <Args extends unknown[]>(name: string) => {
43
43
  * @param path - Path to the value to be compared.
44
44
  */
45
45
  const fn = (path: string, ...args: Args): string => {
46
- const formattedArgs = args.map(formatValue).join(", ");
47
- const joiner = path && args.length ? ", " : "";
46
+ const formattedArgs = args.map(formatValue).join(", ")
47
+ const joiner = path && args.length ? ", " : ""
48
48
 
49
- return `[${name}(${path}${joiner}${formattedArgs})]`;
50
- };
49
+ return `[${name}(${path}${joiner}${formattedArgs})]`
50
+ }
51
51
 
52
- return fn;
53
- };
52
+ return fn
53
+ }
54
54
 
55
55
  /**
56
56
  * Creates a filter builder function for filters with only a path.
@@ -60,17 +60,17 @@ const pathWithArgsFilter = <Args extends unknown[]>(name: string) => {
60
60
  * @returns Filter builder function for the given name.
61
61
  */
62
62
  const pathFilter = (name: string) => {
63
- const filterFn = pathWithArgsFilter(name);
63
+ const filterFn = pathWithArgsFilter(name)
64
64
 
65
65
  /**
66
66
  * @param path - Path for the filter.
67
67
  */
68
68
  const fn = (path: string): string => {
69
- return filterFn(path);
70
- };
69
+ return filterFn(path)
70
+ }
71
71
 
72
- return fn;
73
- };
72
+ return fn
73
+ }
74
74
 
75
75
  /**
76
76
  * Creates a filter builder function for filters with only arguments and no
@@ -81,17 +81,17 @@ const pathFilter = (name: string) => {
81
81
  * @returns Filter builder function for the given name.
82
82
  */
83
83
  const argsFilter = <Args extends unknown[]>(name: string) => {
84
- const filterFn = pathWithArgsFilter<Args>(name);
84
+ const filterFn = pathWithArgsFilter<Args>(name)
85
85
 
86
86
  /**
87
87
  * @param args - Arguments for the filter.
88
88
  */
89
89
  const fn = (...args: Args): string => {
90
- return filterFn("", ...args);
91
- };
90
+ return filterFn("", ...args)
91
+ }
92
92
 
93
- return fn;
94
- };
93
+ return fn
94
+ }
95
95
 
96
96
  export const filter = {
97
97
  /**
@@ -353,4 +353,4 @@ export const filter = {
353
353
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
354
354
  */
355
355
  dateHourBefore: pathWithArgsFilter<[hour: number]>("date.hour-before"),
356
- };
356
+ }
@@ -1,6 +1,6 @@
1
- import { PrismicError } from "./errors/PrismicError";
1
+ import { PrismicError } from "./errors/PrismicError"
2
2
 
3
- import { isRepositoryName } from "./isRepositoryName";
3
+ import { isRepositoryName } from "./isRepositoryName"
4
4
 
5
5
  /**
6
6
  * Get a repository's Prismic GraphQL endpoint.
@@ -15,12 +15,12 @@ export const getGraphQLEndpoint = <RepositoryName extends string>(
15
15
  repositoryName: RepositoryName,
16
16
  ): `https://${RepositoryName}.cdn.prismic.io/graphql` => {
17
17
  if (isRepositoryName(repositoryName)) {
18
- return `https://${repositoryName}.cdn.prismic.io/graphql` as const;
18
+ return `https://${repositoryName}.cdn.prismic.io/graphql` as const
19
19
  } else {
20
20
  throw new PrismicError(
21
21
  `An invalid Prismic repository name was given: ${repositoryName}`,
22
22
  undefined,
23
23
  undefined,
24
- );
24
+ )
25
25
  }
26
- };
26
+ }
@@ -1,6 +1,6 @@
1
- import { PrismicError } from "./errors/PrismicError";
1
+ import { PrismicError } from "./errors/PrismicError"
2
2
 
3
- import { isRepositoryName } from "./isRepositoryName";
3
+ import { isRepositoryName } from "./isRepositoryName"
4
4
 
5
5
  /**
6
6
  * Get a repository's Prismic Rest API V2 endpoint.
@@ -17,12 +17,12 @@ export const getRepositoryEndpoint = <RepositoryName extends string>(
17
17
  repositoryName: RepositoryName,
18
18
  ): `https://${RepositoryName}.cdn.prismic.io/api/v2` => {
19
19
  if (isRepositoryName(repositoryName)) {
20
- return `https://${repositoryName}.cdn.prismic.io/api/v2` as const;
20
+ return `https://${repositoryName}.cdn.prismic.io/api/v2` as const
21
21
  } else {
22
22
  throw new PrismicError(
23
23
  `An invalid Prismic repository name was given: ${repositoryName}`,
24
24
  undefined,
25
25
  undefined,
26
- );
26
+ )
27
27
  }
28
- };
28
+ }
@@ -1,4 +1,4 @@
1
- import { PrismicError } from "./errors/PrismicError";
1
+ import { PrismicError } from "./errors/PrismicError"
2
2
 
3
3
  /**
4
4
  * Get a Prismic repository's name from its standard Prismic Rest API V2 or
@@ -16,12 +16,12 @@ import { PrismicError } from "./errors/PrismicError";
16
16
  */
17
17
  export const getRepositoryName = (repositoryEndpoint: string): string => {
18
18
  try {
19
- return new URL(repositoryEndpoint).hostname.split(".")[0];
19
+ return new URL(repositoryEndpoint).hostname.split(".")[0]
20
20
  } catch {
21
21
  throw new PrismicError(
22
22
  `An invalid Prismic Rest API V2 endpoint was provided: ${repositoryEndpoint}`,
23
23
  undefined,
24
24
  undefined,
25
- );
25
+ )
26
26
  }
27
- };
27
+ }
@@ -1,6 +1,6 @@
1
- import { PrismicError } from "./errors/PrismicError";
1
+ import { PrismicError } from "./errors/PrismicError"
2
2
 
3
- import { isRepositoryName } from "./isRepositoryName";
3
+ import { isRepositoryName } from "./isRepositoryName"
4
4
 
5
5
  /**
6
6
  * Returns the URL for a Prismic repository's Prismic Toolbar script. Use the
@@ -39,12 +39,12 @@ export const getToolbarSrc = <TRepositoryName extends string>(
39
39
  repositoryName: TRepositoryName,
40
40
  ): `https://static.cdn.prismic.io/prismic.js?new=true&repo=${TRepositoryName}` => {
41
41
  if (isRepositoryName(repositoryName)) {
42
- return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const;
42
+ return `https://static.cdn.prismic.io/prismic.js?new=true&repo=${repositoryName}` as const
43
43
  } else {
44
44
  throw new PrismicError(
45
45
  `An invalid Prismic repository name was given: ${repositoryName}`,
46
46
  undefined,
47
47
  undefined,
48
- );
48
+ )
49
49
  }
50
- };
50
+ }
@@ -1,12 +1,12 @@
1
- import type { DateField } from "../types/value/date";
2
- import type { TimestampField } from "../types/value/timestamp";
1
+ import type { DateField } from "../types/value/date"
2
+ import type { TimestampField } from "../types/value/timestamp"
3
3
 
4
4
  /**
5
5
  * The return type of `asDate()`.
6
6
  */
7
7
  type AsDateReturnType<
8
8
  Field extends DateField | TimestampField | null | undefined,
9
- > = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null;
9
+ > = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null
10
10
 
11
11
  /**
12
12
  * Transforms a date or timestamp field into a JavaScript Date object
@@ -23,7 +23,7 @@ export const asDate = <
23
23
  dateOrTimestampField: Field,
24
24
  ): AsDateReturnType<Field> => {
25
25
  if (!dateOrTimestampField) {
26
- return null as AsDateReturnType<Field>;
26
+ return null as AsDateReturnType<Field>
27
27
  }
28
28
 
29
29
  // If field is a timestamp field...
@@ -41,9 +41,9 @@ export const asDate = <
41
41
  */
42
42
  return new Date(
43
43
  dateOrTimestampField.replace(/(\+|-)(\d{2})(\d{2})$/, ".000$1$2:$3"),
44
- ) as AsDateReturnType<Field>;
44
+ ) as AsDateReturnType<Field>
45
45
  } else {
46
46
  // ...else field is a date field
47
- return new Date(dateOrTimestampField) as AsDateReturnType<Field>;
47
+ return new Date(dateOrTimestampField) as AsDateReturnType<Field>
48
48
  }
49
- };
49
+ }
@@ -5,20 +5,18 @@ import {
5
5
  serializePreFormatted,
6
6
  serializeSpan,
7
7
  serializeStandardTag,
8
- } from "../lib/serializerHelpers";
8
+ } from "../lib/serializerHelpers"
9
9
 
10
- import type { RichTextField } from "../types/value/richText";
10
+ import type { RichTextField } from "../types/value/richText"
11
11
 
12
- import {
12
+ import type {
13
13
  RichTextFunctionSerializer,
14
14
  RichTextMapSerializer,
15
15
  RichTextMapSerializerFunction,
16
- composeSerializers,
17
- serialize,
18
- wrapMapSerializer,
19
- } from "../richtext";
16
+ } from "../richtext"
17
+ import { composeSerializers, serialize, wrapMapSerializer } from "../richtext"
20
18
 
21
- import { LinkResolverFunction } from "./asLink";
19
+ import type { LinkResolverFunction } from "./asLink"
22
20
 
23
21
  /**
24
22
  * Serializes a node from a rich text or title field with a function to HTML.
@@ -35,7 +33,7 @@ export type HTMLRichTextFunctionSerializer = (
35
33
  text: Parameters<RichTextFunctionSerializer<string>>[2],
36
34
  children: Parameters<RichTextFunctionSerializer<string>>[3][number],
37
35
  key: Parameters<RichTextFunctionSerializer<string>>[4],
38
- ) => string | null | undefined;
36
+ ) => string | null | undefined
39
37
 
40
38
  /**
41
39
  * Serializes a node from a rich text or title field with a map to HTML
@@ -49,8 +47,8 @@ export type HTMLRichTextFunctionSerializer = (
49
47
  export type HTMLRichTextMapSerializer = {
50
48
  [P in keyof RichTextMapSerializer<string>]: P extends RichTextMapSerializer<string>["span"]
51
49
  ? HTMLStrictRichTextMapSerializer[P]
52
- : HTMLStrictRichTextMapSerializer[P] | HTMLRichTextMapSerializerShorthand;
53
- };
50
+ : HTMLStrictRichTextMapSerializer[P] | HTMLRichTextMapSerializerShorthand
51
+ }
54
52
 
55
53
  /**
56
54
  * Serializes a node from a rich text or title field with a map to HTML
@@ -63,15 +61,15 @@ export type HTMLRichTextMapSerializer = {
63
61
  */
64
62
  export type HTMLStrictRichTextMapSerializer = {
65
63
  [P in keyof RichTextMapSerializer<string>]: (payload: {
66
- type: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["type"];
67
- node: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["node"];
68
- text: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["text"];
64
+ type: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["type"]
65
+ node: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["node"]
66
+ text: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["text"]
69
67
  children: Parameters<
70
68
  HTMLRichTextMapSerializerFunction<P>
71
- >[0]["children"][number];
72
- key: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["key"];
73
- }) => string | null | undefined;
74
- };
69
+ >[0]["children"][number]
70
+ key: Parameters<HTMLRichTextMapSerializerFunction<P>>[0]["key"]
71
+ }) => string | null | undefined
72
+ }
75
73
 
76
74
  /**
77
75
  * A {@link RichTextMapSerializerFunction} type specifically for
@@ -85,7 +83,7 @@ type HTMLRichTextMapSerializerFunction<
85
83
  string,
86
84
  ExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,
87
85
  ExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>
88
- >;
86
+ >
89
87
 
90
88
  /**
91
89
  * Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
@@ -102,7 +100,7 @@ type ExtractNodeGeneric<T> =
102
100
  any
103
101
  >
104
102
  ? U
105
- : never;
103
+ : never
106
104
 
107
105
  /**
108
106
  * Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
@@ -119,7 +117,7 @@ type ExtractTextTypeGeneric<T> =
119
117
  infer U
120
118
  >
121
119
  ? U
122
- : never;
120
+ : never
123
121
 
124
122
  /**
125
123
  * A shorthand definition for {@link HTMLRichTextMapSerializer} element types.
@@ -128,13 +126,13 @@ export type HTMLRichTextMapSerializerShorthand = {
128
126
  /**
129
127
  * Classes to apply to the element type.
130
128
  */
131
- class?: string;
129
+ class?: string
132
130
 
133
131
  /**
134
132
  * Other attributes to apply to the element type.
135
133
  */
136
- [Attribute: string]: string | boolean | null | undefined;
137
- };
134
+ [Attribute: string]: string | boolean | null | undefined
135
+ }
138
136
 
139
137
  /**
140
138
  * Serializes a node from a rich text or title field with a map or a function to
@@ -145,7 +143,7 @@ export type HTMLRichTextMapSerializerShorthand = {
145
143
  */
146
144
  export type HTMLRichTextSerializer =
147
145
  | HTMLRichTextMapSerializer
148
- | HTMLRichTextFunctionSerializer;
146
+ | HTMLRichTextFunctionSerializer
149
147
 
150
148
  /**
151
149
  * Creates a HTML rich text serializer with a given link resolver and provide
@@ -171,12 +169,12 @@ const createHTMLRichTextSerializer = (
171
169
  (
172
170
  nodeSerializerOrShorthand as HTMLStrictRichTextMapSerializer[BlockType]
173
171
  )?.(payload) || defaultWithShorthand(payload)
174
- );
175
- }) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>;
172
+ )
173
+ }) as NonNullable<HTMLStrictRichTextMapSerializer[BlockType]>
176
174
  }
177
175
 
178
- return defaultWithShorthand;
179
- };
176
+ return defaultWithShorthand
177
+ }
180
178
 
181
179
  const mapSerializer: Required<HTMLStrictRichTextMapSerializer> = {
182
180
  heading1: useSerializerOrDefault<"heading1">(
@@ -252,10 +250,10 @@ const createHTMLRichTextSerializer = (
252
250
  serializeStandardTag<"label">("span", serializer?.label),
253
251
  ),
254
252
  span: useSerializerOrDefault<"span">(serializer?.span, serializeSpan()),
255
- };
253
+ }
256
254
 
257
- return wrapMapSerializerWithStringChildren(mapSerializer);
258
- };
255
+ return wrapMapSerializerWithStringChildren(mapSerializer)
256
+ }
259
257
 
260
258
  /**
261
259
  * Wraps a map serializer into a regular function serializer. The given map
@@ -269,10 +267,10 @@ const createHTMLRichTextSerializer = (
269
267
  const wrapMapSerializerWithStringChildren = (
270
268
  mapSerializer: HTMLStrictRichTextMapSerializer,
271
269
  ): RichTextFunctionSerializer<string> => {
272
- const modifiedMapSerializer = {} as RichTextMapSerializer<string>;
270
+ const modifiedMapSerializer = {} as RichTextMapSerializer<string>
273
271
 
274
272
  for (const tag in mapSerializer) {
275
- const tagSerializer = mapSerializer[tag as keyof typeof mapSerializer];
273
+ const tagSerializer = mapSerializer[tag as keyof typeof mapSerializer]
276
274
 
277
275
  if (tagSerializer) {
278
276
  modifiedMapSerializer[tag as keyof typeof mapSerializer] = (payload) => {
@@ -280,13 +278,13 @@ const wrapMapSerializerWithStringChildren = (
280
278
  ...payload,
281
279
  // @ts-expect-error - merging blockSerializer types causes TS to bail to a never type
282
280
  children: payload.children.join(""),
283
- });
284
- };
281
+ })
282
+ }
285
283
  }
286
284
  }
287
285
 
288
- return wrapMapSerializer(modifiedMapSerializer);
289
- };
286
+ return wrapMapSerializer(modifiedMapSerializer)
287
+ }
290
288
 
291
289
  /**
292
290
  * Configuration that determines the output of `asHTML()`.
@@ -296,14 +294,14 @@ type AsHTMLConfig = {
296
294
  * An optional link resolver function to resolve links. Without it you're
297
295
  * expected to use the `routes` options from the API.
298
296
  */
299
- linkResolver?: LinkResolverFunction | null;
297
+ linkResolver?: LinkResolverFunction | null
300
298
 
301
299
  /**
302
300
  * An optional rich text serializer, unhandled cases will fallback to the
303
301
  * default serializer
304
302
  */
305
- serializer?: HTMLRichTextSerializer | null;
306
- };
303
+ serializer?: HTMLRichTextSerializer | null
304
+ }
307
305
 
308
306
  // TODO: Remove when we remove support for deprecated tuple-style configuration.
309
307
  /**
@@ -312,13 +310,13 @@ type AsHTMLConfig = {
312
310
  type AsHTMLDeprecatedTupleConfig = [
313
311
  linkResolver?: LinkResolverFunction | null,
314
312
  serializer?: HTMLRichTextSerializer | null,
315
- ];
313
+ ]
316
314
 
317
315
  /**
318
316
  * The return type of `asHTML()`.
319
317
  */
320
318
  type AsHTMLReturnType<Field extends RichTextField | null | undefined> =
321
- Field extends RichTextField ? string : null;
319
+ Field extends RichTextField ? string : null
322
320
 
323
321
  // TODO: Remove overload when we remove support for deprecated tuple-style configuration.
324
322
  export const asHTML: {
@@ -335,7 +333,7 @@ export const asHTML: {
335
333
  <Field extends RichTextField | null | undefined>(
336
334
  richTextField: Field,
337
335
  config?: AsHTMLConfig,
338
- ): AsHTMLReturnType<Field>;
336
+ ): AsHTMLReturnType<Field>
339
337
 
340
338
  /**
341
339
  * Serializes a rich text or title field to an HTML string.
@@ -355,7 +353,7 @@ export const asHTML: {
355
353
  <Field extends RichTextField | null | undefined>(
356
354
  richTextField: Field,
357
355
  ...config: AsHTMLDeprecatedTupleConfig
358
- ): AsHTMLReturnType<Field>;
356
+ ): AsHTMLReturnType<Field>
359
357
  } = <Field extends RichTextField | null | undefined>(
360
358
  richTextField: Field,
361
359
  // TODO: Rename to `config` when we remove support for deprecated tuple-style configuration.
@@ -363,8 +361,8 @@ export const asHTML: {
363
361
  ): AsHTMLReturnType<Field> => {
364
362
  if (richTextField) {
365
363
  // TODO: Remove when we remove support for deprecated tuple-style configuration.
366
- const [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple;
367
- let config: AsHTMLConfig;
364
+ const [configObjectOrLinkResolver, maybeSerializer] = configObjectOrTuple
365
+ let config: AsHTMLConfig
368
366
  if (
369
367
  typeof configObjectOrLinkResolver === "function" ||
370
368
  configObjectOrLinkResolver == null
@@ -372,12 +370,12 @@ export const asHTML: {
372
370
  config = {
373
371
  linkResolver: configObjectOrLinkResolver,
374
372
  serializer: maybeSerializer,
375
- };
373
+ }
376
374
  } else {
377
- config = { ...configObjectOrLinkResolver };
375
+ config = { ...configObjectOrLinkResolver }
378
376
  }
379
377
 
380
- let serializer: RichTextFunctionSerializer<string>;
378
+ let serializer: RichTextFunctionSerializer<string>
381
379
  if (config.serializer) {
382
380
  if (typeof config.serializer === "function") {
383
381
  serializer = composeSerializers(
@@ -391,21 +389,21 @@ export const asHTML: {
391
389
  key,
392
390
  ),
393
391
  createHTMLRichTextSerializer(config.linkResolver),
394
- );
392
+ )
395
393
  } else {
396
394
  serializer = createHTMLRichTextSerializer(
397
395
  config.linkResolver,
398
396
  config.serializer,
399
- );
397
+ )
400
398
  }
401
399
  } else {
402
- serializer = createHTMLRichTextSerializer(config.linkResolver);
400
+ serializer = createHTMLRichTextSerializer(config.linkResolver)
403
401
  }
404
402
 
405
403
  return serialize(richTextField, serializer).join(
406
404
  "",
407
- ) as AsHTMLReturnType<Field>;
405
+ ) as AsHTMLReturnType<Field>
408
406
  } else {
409
- return null as AsHTMLReturnType<Field>;
407
+ return null as AsHTMLReturnType<Field>
410
408
  }
411
- };
409
+ }