@prismicio/client 7.0.0-alpha.5 → 7.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/buildQueryURL.cjs.map +1 -1
  2. package/dist/buildQueryURL.d.ts +15 -14
  3. package/dist/buildQueryURL.js.map +1 -1
  4. package/dist/createClient.cjs +63 -30
  5. package/dist/createClient.cjs.map +1 -1
  6. package/dist/createClient.d.ts +95 -48
  7. package/dist/createClient.js +63 -30
  8. package/dist/createClient.js.map +1 -1
  9. package/dist/filter.cjs +39 -39
  10. package/dist/filter.cjs.map +1 -1
  11. package/dist/filter.d.ts +39 -39
  12. package/dist/filter.js +39 -39
  13. package/dist/filter.js.map +1 -1
  14. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  15. package/dist/getGraphQLEndpoint.d.ts +1 -0
  16. package/dist/getGraphQLEndpoint.js.map +1 -1
  17. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  18. package/dist/getRepositoryEndpoint.d.ts +2 -0
  19. package/dist/getRepositoryEndpoint.js.map +1 -1
  20. package/dist/getRepositoryName.cjs.map +1 -1
  21. package/dist/getRepositoryName.d.ts +1 -0
  22. package/dist/getRepositoryName.js.map +1 -1
  23. package/dist/getToolbarSrc.cjs.map +1 -1
  24. package/dist/getToolbarSrc.d.ts +1 -1
  25. package/dist/getToolbarSrc.js.map +1 -1
  26. package/dist/helpers/asDate.cjs.map +1 -1
  27. package/dist/helpers/asDate.d.ts +3 -2
  28. package/dist/helpers/asDate.js.map +1 -1
  29. package/dist/helpers/asHTML.cjs.map +1 -1
  30. package/dist/helpers/asHTML.d.ts +34 -28
  31. package/dist/helpers/asHTML.js.map +1 -1
  32. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  33. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +5 -5
  34. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  35. package/dist/helpers/asImageSrc.cjs.map +1 -1
  36. package/dist/helpers/asImageSrc.d.ts +3 -3
  37. package/dist/helpers/asImageSrc.js.map +1 -1
  38. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  39. package/dist/helpers/asImageWidthSrcSet.d.ts +6 -6
  40. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  41. package/dist/helpers/asLink.cjs.map +1 -1
  42. package/dist/helpers/asLink.d.ts +32 -23
  43. package/dist/helpers/asLink.js.map +1 -1
  44. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  45. package/dist/helpers/asLinkAttrs.d.ts +12 -7
  46. package/dist/helpers/asLinkAttrs.js.map +1 -1
  47. package/dist/helpers/asText.cjs.map +1 -1
  48. package/dist/helpers/asText.d.ts +18 -14
  49. package/dist/helpers/asText.js.map +1 -1
  50. package/dist/helpers/documentToLinkField.cjs.map +1 -1
  51. package/dist/helpers/documentToLinkField.d.ts +2 -0
  52. package/dist/helpers/documentToLinkField.js.map +1 -1
  53. package/dist/helpers/isFilled.cjs +3 -1
  54. package/dist/helpers/isFilled.cjs.map +1 -1
  55. package/dist/helpers/isFilled.d.ts +24 -20
  56. package/dist/helpers/isFilled.js +3 -1
  57. package/dist/helpers/isFilled.js.map +1 -1
  58. package/dist/index.cjs.map +1 -1
  59. package/dist/index.d.ts +13 -3
  60. package/dist/index.js.map +1 -1
  61. package/dist/lib/appendFilters.cjs.map +1 -1
  62. package/dist/lib/appendFilters.d.ts +4 -4
  63. package/dist/lib/appendFilters.js.map +1 -1
  64. package/dist/lib/castArray.cjs.map +1 -1
  65. package/dist/lib/castArray.d.ts +1 -0
  66. package/dist/lib/castArray.js.map +1 -1
  67. package/dist/lib/castThunk.cjs.map +1 -1
  68. package/dist/lib/castThunk.d.ts +2 -1
  69. package/dist/lib/castThunk.js.map +1 -1
  70. package/dist/lib/everyTagFilter.cjs.map +1 -1
  71. package/dist/lib/everyTagFilter.d.ts +2 -2
  72. package/dist/lib/everyTagFilter.js.map +1 -1
  73. package/dist/lib/findMasterRef.cjs.map +1 -1
  74. package/dist/lib/findMasterRef.d.ts +1 -0
  75. package/dist/lib/findMasterRef.js.map +1 -1
  76. package/dist/lib/findRef.cjs.map +1 -1
  77. package/dist/lib/findRef.d.ts +3 -2
  78. package/dist/lib/findRef.js.map +1 -1
  79. package/dist/lib/findRefByID.cjs.map +1 -1
  80. package/dist/lib/findRefByID.d.ts +1 -0
  81. package/dist/lib/findRefByID.js.map +1 -1
  82. package/dist/lib/findRefByLabel.cjs.map +1 -1
  83. package/dist/lib/findRefByLabel.d.ts +1 -0
  84. package/dist/lib/findRefByLabel.js.map +1 -1
  85. package/dist/package.json.cjs +1 -1
  86. package/dist/package.json.js +1 -1
  87. package/dist/types/api/query.d.ts +1 -0
  88. package/dist/types/api/release.d.ts +1 -0
  89. package/dist/types/api/repository.d.ts +2 -2
  90. package/dist/types/api/tags.d.ts +1 -0
  91. package/dist/types/model/boolean.d.ts +1 -1
  92. package/dist/types/model/color.d.ts +1 -1
  93. package/dist/types/model/contentRelationship.d.ts +2 -3
  94. package/dist/types/model/customType.d.ts +11 -11
  95. package/dist/types/model/date.d.ts +1 -1
  96. package/dist/types/model/embed.d.ts +1 -1
  97. package/dist/types/model/geoPoint.d.ts +1 -1
  98. package/dist/types/model/group.d.ts +1 -1
  99. package/dist/types/model/image.d.ts +3 -3
  100. package/dist/types/model/{integrationFields.d.ts → integration.d.ts} +3 -3
  101. package/dist/types/model/keyText.d.ts +1 -1
  102. package/dist/types/model/link.cjs.map +1 -1
  103. package/dist/types/model/link.d.ts +4 -6
  104. package/dist/types/model/link.js.map +1 -1
  105. package/dist/types/model/linkToMedia.d.ts +2 -3
  106. package/dist/types/model/number.d.ts +1 -1
  107. package/dist/types/model/richText.d.ts +3 -3
  108. package/dist/types/model/select.d.ts +1 -1
  109. package/dist/types/model/sharedSlice.d.ts +2 -2
  110. package/dist/types/model/sharedSliceVariation.d.ts +1 -1
  111. package/dist/types/model/slice.cjs.map +1 -1
  112. package/dist/types/model/slice.d.ts +1 -1
  113. package/dist/types/model/slice.js.map +1 -1
  114. package/dist/types/model/sliceZone.cjs.map +1 -1
  115. package/dist/types/model/sliceZone.d.ts +2 -2
  116. package/dist/types/model/sliceZone.js.map +1 -1
  117. package/dist/types/model/timestamp.d.ts +1 -1
  118. package/dist/types/model/title.d.ts +1 -1
  119. package/dist/types/model/types.cjs +5 -1
  120. package/dist/types/model/types.cjs.map +1 -1
  121. package/dist/types/model/types.d.ts +10 -6
  122. package/dist/types/model/types.js +5 -1
  123. package/dist/types/model/types.js.map +1 -1
  124. package/dist/types/model/uid.d.ts +1 -1
  125. package/dist/types/value/boolean.d.ts +1 -1
  126. package/dist/types/value/color.d.ts +2 -1
  127. package/dist/types/value/contentRelationship.d.ts +1 -1
  128. package/dist/types/value/date.d.ts +2 -1
  129. package/dist/types/value/document.d.ts +4 -4
  130. package/dist/types/value/embed.cjs.map +1 -1
  131. package/dist/types/value/embed.d.ts +2 -1
  132. package/dist/types/value/embed.js.map +1 -1
  133. package/dist/types/value/geoPoint.d.ts +2 -1
  134. package/dist/types/value/group.d.ts +1 -1
  135. package/dist/types/value/image.d.ts +5 -3
  136. package/dist/types/value/{integrationFields.d.ts → integration.d.ts} +3 -2
  137. package/dist/types/value/keyText.d.ts +2 -1
  138. package/dist/types/value/link.cjs.map +1 -1
  139. package/dist/types/value/link.d.ts +2 -2
  140. package/dist/types/value/link.js.map +1 -1
  141. package/dist/types/value/linkToMedia.d.ts +2 -2
  142. package/dist/types/value/number.d.ts +2 -1
  143. package/dist/types/value/richText.cjs.map +1 -1
  144. package/dist/types/value/richText.d.ts +26 -26
  145. package/dist/types/value/richText.js.map +1 -1
  146. package/dist/types/value/select.d.ts +2 -1
  147. package/dist/types/value/sharedSlice.d.ts +1 -1
  148. package/dist/types/value/sharedSliceVariation.d.ts +3 -0
  149. package/dist/types/value/slice.d.ts +1 -1
  150. package/dist/types/value/timestamp.d.ts +1 -1
  151. package/dist/types/value/title.d.ts +1 -1
  152. package/dist/types/value/types.d.ts +3 -2
  153. package/dist/types/webhook/apiUpdate.d.ts +1 -1
  154. package/package.json +4 -4
  155. package/src/buildQueryURL.ts +15 -14
  156. package/src/createClient.ts +112 -55
  157. package/src/filter.ts +43 -43
  158. package/src/getGraphQLEndpoint.ts +1 -0
  159. package/src/getRepositoryEndpoint.ts +2 -0
  160. package/src/getRepositoryName.ts +1 -0
  161. package/src/getToolbarSrc.ts +1 -1
  162. package/src/helpers/asDate.ts +3 -2
  163. package/src/helpers/asHTML.ts +36 -30
  164. package/src/helpers/asImagePixelDensitySrcSet.ts +5 -5
  165. package/src/helpers/asImageSrc.ts +3 -3
  166. package/src/helpers/asImageWidthSrcSet.ts +6 -6
  167. package/src/helpers/asLink.ts +36 -27
  168. package/src/helpers/asLinkAttrs.ts +12 -7
  169. package/src/helpers/asText.ts +18 -14
  170. package/src/helpers/documentToLinkField.ts +3 -1
  171. package/src/helpers/isFilled.ts +27 -22
  172. package/src/index.ts +20 -3
  173. package/src/lib/appendFilters.ts +4 -4
  174. package/src/lib/castArray.ts +1 -0
  175. package/src/lib/castThunk.ts +9 -2
  176. package/src/lib/everyTagFilter.ts +2 -2
  177. package/src/lib/findMasterRef.ts +1 -0
  178. package/src/lib/findRef.ts +3 -2
  179. package/src/lib/findRefByID.ts +1 -0
  180. package/src/lib/findRefByLabel.ts +1 -0
  181. package/src/types/api/query.ts +1 -0
  182. package/src/types/api/release.ts +1 -0
  183. package/src/types/api/repository.ts +2 -2
  184. package/src/types/api/tags.ts +1 -0
  185. package/src/types/model/boolean.ts +1 -1
  186. package/src/types/model/color.ts +1 -1
  187. package/src/types/model/contentRelationship.ts +2 -3
  188. package/src/types/model/customType.ts +11 -11
  189. package/src/types/model/date.ts +1 -1
  190. package/src/types/model/embed.ts +1 -1
  191. package/src/types/model/geoPoint.ts +1 -1
  192. package/src/types/model/group.ts +1 -1
  193. package/src/types/model/image.ts +3 -3
  194. package/src/types/model/{integrationFields.ts → integration.ts} +3 -3
  195. package/src/types/model/keyText.ts +1 -1
  196. package/src/types/model/link.ts +4 -6
  197. package/src/types/model/linkToMedia.ts +2 -3
  198. package/src/types/model/number.ts +1 -1
  199. package/src/types/model/richText.ts +3 -3
  200. package/src/types/model/select.ts +1 -1
  201. package/src/types/model/sharedSlice.ts +2 -2
  202. package/src/types/model/sharedSliceVariation.ts +1 -1
  203. package/src/types/model/slice.ts +1 -1
  204. package/src/types/model/sliceZone.ts +2 -2
  205. package/src/types/model/timestamp.ts +1 -1
  206. package/src/types/model/title.ts +1 -1
  207. package/src/types/model/types.ts +10 -6
  208. package/src/types/model/uid.ts +1 -1
  209. package/src/types/value/boolean.ts +1 -1
  210. package/src/types/value/color.ts +2 -1
  211. package/src/types/value/contentRelationship.ts +1 -1
  212. package/src/types/value/date.ts +2 -1
  213. package/src/types/value/document.ts +4 -4
  214. package/src/types/value/embed.ts +2 -1
  215. package/src/types/value/geoPoint.ts +2 -1
  216. package/src/types/value/group.ts +1 -1
  217. package/src/types/value/image.ts +6 -4
  218. package/src/types/value/{integrationFields.ts → integration.ts} +3 -2
  219. package/src/types/value/keyText.ts +2 -1
  220. package/src/types/value/link.ts +2 -2
  221. package/src/types/value/linkToMedia.ts +2 -2
  222. package/src/types/value/number.ts +2 -1
  223. package/src/types/value/richText.ts +26 -26
  224. package/src/types/value/select.ts +2 -1
  225. package/src/types/value/sharedSlice.ts +1 -1
  226. package/src/types/value/sharedSliceVariation.ts +3 -0
  227. package/src/types/value/slice.ts +1 -1
  228. package/src/types/value/timestamp.ts +1 -1
  229. package/src/types/value/title.ts +1 -1
  230. package/src/types/value/types.ts +3 -2
  231. package/src/types/webhook/apiUpdate.ts +1 -1
package/src/filter.ts CHANGED
@@ -30,10 +30,10 @@ const formatValue = (
30
30
  };
31
31
 
32
32
  /**
33
- * Creates a filter builder function for filters with a path and
34
- * arguments.
33
+ * Creates a filter builder function for filters with a path and arguments.
35
34
  *
36
35
  * @typeParam Args - Arguments for the filter.
36
+ *
37
37
  * @param name - Name of the filter used in the resulting string.
38
38
  *
39
39
  * @returns Filter builder function for the given name.
@@ -73,8 +73,8 @@ const pathFilter = (name: string) => {
73
73
  };
74
74
 
75
75
  /**
76
- * Creates a filter builder function for filters with only arguments and
77
- * no path.
76
+ * Creates a filter builder function for filters with only arguments and no
77
+ * path.
78
78
  *
79
79
  * @param name - Name of the filter used in the resulting string.
80
80
  *
@@ -95,8 +95,8 @@ const argsFilter = <Args extends unknown[]>(name: string) => {
95
95
 
96
96
  export const filter = {
97
97
  /**
98
- * The `at` filter checks that the path matches the described value
99
- * exactly. It takes a single value for a field or an array (only for tags).
98
+ * The `at` filter checks that the path matches the described value exactly.
99
+ * It takes a single value for a field or an array (only for tags).
100
100
  *
101
101
  * {@link https://prismic.io/docs/rest-api-technical-reference#at}
102
102
  */
@@ -115,8 +115,8 @@ export const filter = {
115
115
  ),
116
116
 
117
117
  /**
118
- * The `any` filter takes an array of values. It works exactly the same way
119
- * as the `at` operator, but checks whether the fragment matches any of the
118
+ * The `any` filter takes an array of values. It works exactly the same way as
119
+ * the `at` operator, but checks whether the fragment matches any of the
120
120
  * values in the array.
121
121
  *
122
122
  * {@link https://prismic.io/docs/rest-api-technical-reference#any}
@@ -126,9 +126,9 @@ export const filter = {
126
126
  ),
127
127
 
128
128
  /**
129
- * The `in` filter is used specifically to retrieve an array of documents
130
- * by their IDs or UIDs. This filter is much more efficient at this than
131
- * the any filter.
129
+ * The `in` filter is used specifically to retrieve an array of documents by
130
+ * their IDs or UIDs. This filter is much more efficient at this than the any
131
+ * filter.
132
132
  *
133
133
  * {@link https://prismic.io/docs/rest-api-technical-reference#in}
134
134
  */
@@ -147,9 +147,9 @@ export const filter = {
147
147
  fulltext: pathWithArgsFilter<[searchTerms: string]>("fulltext"),
148
148
 
149
149
  /**
150
- * The `has` filter checks whether a fragment has a value. It will return
151
- * all the documents of the specified type that contain a value for the
152
- * specified field.
150
+ * The `has` filter checks whether a fragment has a value. It will return all
151
+ * the documents of the specified type that contain a value for the specified
152
+ * field.
153
153
  *
154
154
  * {@link https://prismic.io/docs/rest-api-technical-reference#has}
155
155
  */
@@ -174,10 +174,10 @@ export const filter = {
174
174
  similar: argsFilter<[id: string, value: number]>("similar"),
175
175
 
176
176
  /**
177
- * The `geopoint.near` filter checks that the value in the path is within
178
- * the radius of the given coordinates.
177
+ * The `geopoint.near` filter checks that the value in the path is within the
178
+ * radius of the given coordinates.
179
179
  *
180
- * This filter will only work for a GeoPoint field.
180
+ * This filter will only work for a geopoint field.
181
181
  *
182
182
  * {@link https://prismic.io/docs/rest-api-technical-reference#geopointnear}
183
183
  */
@@ -195,16 +195,16 @@ export const filter = {
195
195
  numberLessThan: pathWithArgsFilter<[value: number]>("number.lt"),
196
196
 
197
197
  /**
198
- * The `number.gt` filter checks that the value in the number field is
199
- * greater than the value passed into the filter.
198
+ * The `number.gt` filter checks that the value in the number field is greater
199
+ * than the value passed into the filter.
200
200
  *
201
201
  * {@link https://prismic.io/docs/rest-api-technical-reference#numbergreaterthan}
202
202
  */
203
203
  numberGreaterThan: pathWithArgsFilter<[value: number]>("number.gt"),
204
204
 
205
205
  /**
206
- * The `number.inRange` filter checks that the value in the path is within
207
- * the two values passed into the filter.
206
+ * The `number.inRange` filter checks that the value in the path is within the
207
+ * two values passed into the filter.
208
208
  *
209
209
  * {@link https://prismic.io/docs/rest-api-technical-reference#numberinrange}
210
210
  */
@@ -214,8 +214,8 @@ export const filter = {
214
214
  ),
215
215
 
216
216
  /**
217
- * The `date.after` filter checks that the value in the path is after the
218
- * date value passed into the filter.
217
+ * The `date.after` filter checks that the value in the path is after the date
218
+ * value passed into the filter.
219
219
  *
220
220
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
221
221
  */
@@ -230,8 +230,8 @@ export const filter = {
230
230
  dateBefore: pathWithArgsFilter<[date: string | number | Date]>("date.before"),
231
231
 
232
232
  /**
233
- * The `date.between` filter checks that the value in the path is within
234
- * the date values passed into the filter.
233
+ * The `date.between` filter checks that the value in the path is within the
234
+ * date values passed into the filter.
235
235
  *
236
236
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
237
237
  */
@@ -241,16 +241,16 @@ export const filter = {
241
241
  >("date.between"),
242
242
 
243
243
  /**
244
- * The `date.day-of-month` filter checks that the value in the path is
245
- * equal to the day of the month passed into the filter.
244
+ * The `date.day-of-month` filter checks that the value in the path is equal
245
+ * to the day of the month passed into the filter.
246
246
  *
247
247
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
248
248
  */
249
249
  dateDayOfMonth: pathWithArgsFilter<[day: number]>("date.day-of-month"),
250
250
 
251
251
  /**
252
- * The `date.day-of-month-after` filter checks that the value in the path
253
- * is after the day of the month passed into the filter.
252
+ * The `date.day-of-month-after` filter checks that the value in the path is
253
+ * after the day of the month passed into the filter.
254
254
  *
255
255
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
256
256
  */
@@ -259,8 +259,8 @@ export const filter = {
259
259
  ),
260
260
 
261
261
  /**
262
- * The `date.day-of-month-before` filter checks that the value in the path
263
- * is before the day of the month passed into the filter.
262
+ * The `date.day-of-month-before` filter checks that the value in the path is
263
+ * before the day of the month passed into the filter.
264
264
  *
265
265
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
266
266
  */
@@ -269,8 +269,8 @@ export const filter = {
269
269
  ),
270
270
 
271
271
  /**
272
- * The `date.day-of-week` filter checks that the value in the path is equal
273
- * to the day of the week passed into the filter.
272
+ * The `date.day-of-week` filter checks that the value in the path is equal to
273
+ * the day of the week passed into the filter.
274
274
  *
275
275
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
276
276
  */
@@ -305,8 +305,8 @@ export const filter = {
305
305
  dateMonth: pathWithArgsFilter<[month: string | number]>("date.month"),
306
306
 
307
307
  /**
308
- * The `date.month-after` filter checks that the value in the path occurs
309
- * in any month after the value passed into the filter.
308
+ * The `date.month-after` filter checks that the value in the path occurs in
309
+ * any month after the value passed into the filter.
310
310
  *
311
311
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
312
312
  */
@@ -314,8 +314,8 @@ export const filter = {
314
314
  pathWithArgsFilter<[month: string | number]>("date.month-after"),
315
315
 
316
316
  /**
317
- * The `date.month-before` filter checks that the value in the path occurs
318
- * in any month before the value passed into the filter.
317
+ * The `date.month-before` filter checks that the value in the path occurs in
318
+ * any month before the value passed into the filter.
319
319
  *
320
320
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
321
321
  */
@@ -323,24 +323,24 @@ export const filter = {
323
323
  pathWithArgsFilter<[month: string | number]>("date.month-before"),
324
324
 
325
325
  /**
326
- * The `date.year` filter checks that the value in the path occurs in the
327
- * year value passed into the filter.
326
+ * The `date.year` filter checks that the value in the path occurs in the year
327
+ * value passed into the filter.
328
328
  *
329
329
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
330
330
  */
331
331
  dateYear: pathWithArgsFilter<[year: number]>("date.year"),
332
332
 
333
333
  /**
334
- * The `date.hour` filter checks that the value in the path occurs within
335
- * the hour value passed into the filter.
334
+ * The `date.hour` filter checks that the value in the path occurs within the
335
+ * hour value passed into the filter.
336
336
  *
337
337
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
338
338
  */
339
339
  dateHour: pathWithArgsFilter<[hour: number]>("date.hour"),
340
340
 
341
341
  /**
342
- * The `date.hour-after` filter checks that the value in the path occurs
343
- * after the hour value passed into the filter.
342
+ * The `date.hour-after` filter checks that the value in the path occurs after
343
+ * the hour value passed into the filter.
344
344
  *
345
345
  * {@link https://prismic.io/docs/rest-api-technical-reference#date-filters}
346
346
  */
@@ -6,6 +6,7 @@ import { isRepositoryName } from "./isRepositoryName";
6
6
  * Get a repository's Prismic GraphQL endpoint.
7
7
  *
8
8
  * @typeParam RepositoryName - Name of the Prismic repository.
9
+ *
9
10
  * @param repositoryName - Name of the repository.
10
11
  *
11
12
  * @returns The repository's Prismic REST API V2 endpoint
@@ -6,9 +6,11 @@ import { isRepositoryName } from "./isRepositoryName";
6
6
  * Get a repository's Prismic Rest API V2 endpoint.
7
7
  *
8
8
  * @typeParam RepositoryName - Name of the Prismic repository.
9
+ *
9
10
  * @param repositoryName - Name of the repository.
10
11
  *
11
12
  * @returns The repository's Prismic Rest API V2 endpoint
13
+ *
12
14
  * @throws {@link Error} Thrown if an invalid repository name is provided.
13
15
  */
14
16
  export const getRepositoryEndpoint = <RepositoryName extends string>(
@@ -9,6 +9,7 @@ import { PrismicError } from "./errors/PrismicError";
9
9
  * @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
10
10
  *
11
11
  * @returns The Prismic repository's name.
12
+ *
12
13
  * @throws {@link Error} Thrown if an invalid Prismic Rest API V2 endpoint is
13
14
  * provided.
14
15
  */
@@ -12,7 +12,7 @@ import { isRepositoryName } from "./isRepositoryName";
12
12
  * // In Next.js apps, use `next/script` in your `app/layout.tsx` file.
13
13
  *
14
14
  * import Script from "next/script";
15
- * import * as prismic from '@prismicio/client'
15
+ * import * as prismic from "@prismicio/client";
16
16
  *
17
17
  * export default function RootLayout({
18
18
  * children,
@@ -9,11 +9,12 @@ type AsDateReturnType<
9
9
  > = Field extends DateField<"filled"> | TimestampField<"filled"> ? Date : null;
10
10
 
11
11
  /**
12
- * Transforms a Date or Timestamp field into a JavaScript Date object
12
+ * Transforms a date or timestamp field into a JavaScript Date object
13
13
  *
14
- * @param dateOrTimestampField - A Date or Timestamp field from Prismic
14
+ * @param dateOrTimestampField - A date or timestamp field from Prismic
15
15
  *
16
16
  * @returns A Date object, null if provided date is falsy
17
+ *
17
18
  * @see Templating date field from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#date-and-timestamp}
18
19
  */
19
20
  export const asDate = <
@@ -22,13 +22,13 @@ import type { RichTextField } from "../types/value/richText";
22
22
  import { LinkResolverFunction } from "./asLink";
23
23
 
24
24
  /**
25
- * Serializes a node from a Rich Text or Title field with a function to HTML.
25
+ * Serializes a node from a rich text or title field with a function to HTML.
26
26
  *
27
27
  * Unlike a typical `@prismicio/richtext` function serializer, this serializer
28
28
  * converts the `children` argument to a single string rather than an array of
29
29
  * strings.
30
30
  *
31
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
31
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
32
32
  */
33
33
  export type HTMLRichTextFunctionSerializer = (
34
34
  type: Parameters<RichTextFunctionSerializer<string>>[0],
@@ -39,13 +39,13 @@ export type HTMLRichTextFunctionSerializer = (
39
39
  ) => string | null | undefined;
40
40
 
41
41
  /**
42
- * Serializes a node from a Rich Text or Title field with a map to HTML
42
+ * Serializes a node from a rich text or title field with a map to HTML
43
43
  *
44
44
  * Unlike a typical `@prismicio/richtext` map serializer, this serializer
45
45
  * converts the `children` property to a single string rather than an array of
46
46
  * strings.
47
47
  *
48
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
48
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
49
49
  */
50
50
  export type HTMLRichTextMapSerializer = {
51
51
  [P in keyof RichTextMapSerializer<string>]: (payload: {
@@ -63,7 +63,7 @@ export type HTMLRichTextMapSerializer = {
63
63
  * A {@link RichTextMapSerializerFunction} type specifically for
64
64
  * {@link HTMLRichTextMapSerializer}.
65
65
  *
66
- * @typeParam BlockName - The serializer's Rich Text block type.
66
+ * @typeParam BlockName - The serializer's rich text block type.
67
67
  */
68
68
  type HTMLRichTextMapSerializerFunction<
69
69
  BlockType extends keyof RichTextMapSerializer<string>,
@@ -106,18 +106,19 @@ type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<
106
106
  : never;
107
107
 
108
108
  /**
109
- * Serializes a node from a Rich Text or Title field with a map or a function to HTML
109
+ * Serializes a node from a rich text or title field with a map or a function to
110
+ * HTML
110
111
  *
111
112
  * @see {@link HTMLRichTextMapSerializer} and {@link HTMLRichTextFunctionSerializer}
112
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
113
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
113
114
  */
114
115
  export type HTMLRichTextSerializer =
115
116
  | HTMLRichTextMapSerializer
116
117
  | HTMLRichTextFunctionSerializer;
117
118
 
118
119
  /**
119
- * Creates a default HTML Rich Text Serializer with a given Link Resolver providing
120
- * sensible and safe defaults for every node type
120
+ * Creates a default HTML rich text serializer with a given link resolver
121
+ * providing sensible and safe defaults for every node type
121
122
  *
122
123
  * @internal
123
124
  */
@@ -205,13 +206,14 @@ const wrapMapSerializerWithStringChildren = (
205
206
  */
206
207
  type AsHTMLConfig = {
207
208
  /**
208
- * An optional link resolver function to resolve links.
209
- * Without it you're expected to use the `routes` options from the API.
209
+ * An optional link resolver function to resolve links. Without it you're
210
+ * expected to use the `routes` options from the API.
210
211
  */
211
212
  linkResolver?: LinkResolverFunction | null;
212
213
 
213
214
  /**
214
- * An optional Rich Text Serializer, unhandled cases will fallback to the default serializer
215
+ * An optional rich text serializer, unhandled cases will fallback to the
216
+ * default serializer
215
217
  */
216
218
  serializer?: HTMLRichTextSerializer | null;
217
219
  };
@@ -234,13 +236,23 @@ type AsHTMLReturnType<Field extends RichTextField | null | undefined> =
234
236
  // TODO: Remove overload when we remove support for deprecated tuple-style configuration.
235
237
  export const asHTML: {
236
238
  /**
237
- * Serializes a Rich Text or Title field to an HTML string.
239
+ * Serializes a rich text or title field to an HTML string.
238
240
  *
239
- * @param richTextField - A Rich Text or Title field from Prismic
241
+ * @example
242
+ *
243
+ * ```ts
244
+ * asHTML(field);
245
+ * asHTML(field, { linkResolver });
246
+ * asHTML(field, { serializer });
247
+ * asHTML(field, { linkResolver, serializer });
248
+ * ```
249
+ *
250
+ * @param richTextField - A rich text or title field from Prismic
240
251
  * @param config - Configuration that determines the output of `asHTML()`
241
252
  *
242
- * @returns HTML equivalent of the provided Rich Text or Title field
243
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
253
+ * @returns HTML equivalent of the provided rich text or title field
254
+ *
255
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
244
256
  */
245
257
  <Field extends RichTextField | null | undefined>(
246
258
  richTextField: Field,
@@ -248,25 +260,19 @@ export const asHTML: {
248
260
  ): AsHTMLReturnType<Field>;
249
261
 
250
262
  /**
251
- * Serializes a Rich Text or Title field to an HTML string.
263
+ * Serializes a rich text or title field to an HTML string.
252
264
  *
253
- * @param richTextField - A Rich Text or Title field from Prismic
265
+ * @deprecated Use object-style configuration instead.
266
+ *
267
+ * @param richTextField - A rich text or title field from Prismic
254
268
  * @param linkResolver - An optional link resolver function to resolve links,
255
269
  * without it you're expected to use the `routes` options from the API
256
- * @param serializer - An optional Rich Text Serializer, unhandled cases will fallback
257
- * to the default serializer
258
- *
259
- * @returns HTML equivalent of the provided Rich Text or Title field
260
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
270
+ * @param serializer - An optional rich text serializer, unhandled cases will
271
+ * fallback to the default serializer
261
272
  *
262
- * @deprecated Use object-style configuration instead.
273
+ * @returns HTML equivalent of the provided rich text or title field
263
274
  *
264
- * ```ts
265
- * asHTML(field);
266
- * asHTML(field, { linkResolver });
267
- * asHTML(field, { serializer });
268
- * asHTML(field, { linkResolver, serializer });
269
- * ```
275
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
270
276
  */
271
277
  <Field extends RichTextField | null | undefined>(
272
278
  richTextField: Field,
@@ -30,12 +30,12 @@ type AsImagePixelDensitySrcSetReturnType<
30
30
  > = Field extends ImageFieldImage<"filled">
31
31
  ? {
32
32
  /**
33
- * The Image field's image URL with Imgix URL parameters (if given).
33
+ * The image field's image URL with Imgix URL parameters (if given).
34
34
  */
35
35
  src: string;
36
36
 
37
37
  /**
38
- * A pixel-densitye-based `srcset` attribute value for the Image field's
38
+ * A pixel-densitye-based `srcset` attribute value for the image field's
39
39
  * image with Imgix URL parameters (if given).
40
40
  */
41
41
  srcset: string;
@@ -43,7 +43,7 @@ type AsImagePixelDensitySrcSetReturnType<
43
43
  : null;
44
44
 
45
45
  /**
46
- * Creates a pixel-density-based `srcset` from an Image field with optional
46
+ * Creates a pixel-density-based `srcset` from an image field with optional
47
47
  * image transformations (via Imgix URL parameters).
48
48
  *
49
49
  * If a `pixelDensities` parameter is not given, the following pixel densities
@@ -68,8 +68,8 @@ type AsImagePixelDensitySrcSetReturnType<
68
68
  * @param config - An object of Imgix URL API parameters. The `pixelDensities`
69
69
  * parameter defines the resulting `srcset` widths.
70
70
  *
71
- * @returns A `srcset` attribute value for the Image field with Imgix URL
72
- * parameters (if given). If the Image field is empty, `null` is returned.
71
+ * @returns A `srcset` attribute value for the image field with Imgix URL
72
+ * parameters (if given). If the image field is empty, `null` is returned.
73
73
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
74
74
  */
75
75
  export const asImagePixelDensitySrcSet = <
@@ -11,7 +11,7 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =
11
11
  Field extends ImageFieldImage<"filled"> ? string : null;
12
12
 
13
13
  /**
14
- * Returns the URL of an Image field with optional image transformations (via
14
+ * Returns the URL of an image field with optional image transformations (via
15
15
  * Imgix URL parameters).
16
16
  *
17
17
  * @example
@@ -25,8 +25,8 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =
25
25
  * an image URL.
26
26
  * @param config - An object of Imgix URL API parameters to transform the image.
27
27
  *
28
- * @returns The Image field's image URL with transformations applied (if given).
29
- * If the Image field is empty, `null` is returned.
28
+ * @returns The image field's image URL with transformations applied (if given).
29
+ * If the image field is empty, `null` is returned.
30
30
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
31
31
  */
32
32
  export const asImageSrc = <Field extends ImageFieldImage | null | undefined>(
@@ -21,12 +21,12 @@ type AsImageWidthSrcSetReturnType<
21
21
  > = Field extends ImageFieldImage<"filled">
22
22
  ? {
23
23
  /**
24
- * The Image field's image URL with Imgix URL parameters (if given).
24
+ * The image field's image URL with Imgix URL parameters (if given).
25
25
  */
26
26
  src: string;
27
27
 
28
28
  /**
29
- * A width-based `srcset` attribute value for the Image field's image with
29
+ * A width-based `srcset` attribute value for the image field's image with
30
30
  * Imgix URL parameters (if given).
31
31
  */
32
32
  srcset: string;
@@ -41,13 +41,13 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
41
41
  };
42
42
 
43
43
  /**
44
- * Creates a width-based `srcset` from an Image field with optional image
44
+ * Creates a width-based `srcset` from an image field with optional image
45
45
  * transformations (via Imgix URL parameters).
46
46
  *
47
47
  * If a `widths` parameter is not given, the following widths will be used by
48
48
  * default: 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
49
49
  *
50
- * If the Image field contains responsive views, each responsive view can be
50
+ * If the image field contains responsive views, each responsive view can be
51
51
  * used as a width in the resulting `srcset` by passing `"thumbnails"` as the
52
52
  * `widths` parameter.
53
53
  *
@@ -72,8 +72,8 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
72
72
  * defines the resulting `srcset` widths. Pass `"thumbnails"` to automatically
73
73
  * use the field's responsive views.
74
74
  *
75
- * @returns A `srcset` attribute value for the Image field with Imgix URL
76
- * parameters (if given). If the Image field is empty, `null` is returned.
75
+ * @returns A `srcset` attribute value for the image field with Imgix URL
76
+ * parameters (if given). If the image field is empty, `null` is returned.
77
77
  * @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
78
78
  */
79
79
  export const asImageWidthSrcSet = <
@@ -6,13 +6,14 @@ import type { FilledLinkToMediaField } from "../types/value/linkToMedia";
6
6
  import { documentToLinkField } from "./documentToLinkField";
7
7
 
8
8
  /**
9
- * Resolves a Link to a Prismic document to a URL
9
+ * Resolves a link to a Prismic document to a URL
10
10
  *
11
11
  * @typeParam ReturnType - Return type of your link resolver function, useful if
12
12
  * you prefer to return a complex object
13
- * @param linkToDocumentField - A document Link Field to resolve
13
+ * @param linkToDocumentField - A document link field to resolve
14
14
  *
15
15
  * @returns Resolved URL
16
+ *
16
17
  * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
17
18
  */
18
19
  export type LinkResolverFunction<ReturnType = string | null | undefined> = (
@@ -25,8 +26,8 @@ export type LinkResolverFunction<ReturnType = string | null | undefined> = (
25
26
  type AsLinkConfig<LinkResolverFunctionReturnType = string | null | undefined> =
26
27
  {
27
28
  /**
28
- * An optional Link Resolver function. Without it, you are
29
- * expected to use the `routes` options from the API.
29
+ * An optional link resolver function. Without it, you are expected to use
30
+ * the `routes` options from the API.
30
31
  */
31
32
  linkResolver?: LinkResolverFunction<LinkResolverFunctionReturnType> | null;
32
33
  };
@@ -62,16 +63,26 @@ export type AsLinkReturnType<
62
63
  // TODO: Remove overload when we remove support for deprecated tuple-style configuration.
63
64
  export const asLink: {
64
65
  /**
65
- * Resolves any type of Link field or Prismic document to a URL.
66
+ * Resolves any type of link field or Prismic document to a URL.
67
+ *
68
+ * @example
66
69
  *
67
- * @typeParam LinkResolverFunctionReturnType - Link Resolver function return
70
+ * ```ts
71
+ * asLink(field);
72
+ * asLink(field, { linkResolver });
73
+ * ```
74
+ *
75
+ * @typeParam LinkResolverFunctionReturnType - link resolver function return
68
76
  * type
69
77
  * @typeParam Field - Link field or Prismic document to resolve to a URL
70
- * @param linkFieldOrDocument - Any kind of Link field or a document to resolve
78
+ *
79
+ * @param linkFieldOrDocument - Any kind of link field or a document to
80
+ * resolve
71
81
  * @param config - Configuration that determines the output of `asLink()`
72
82
  *
73
- * @returns Resolved URL or, if the provided Link field or document is empty, `null`
74
- * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
83
+ * @returns Resolved URL or, if the provided link field or document is empty,
84
+ * `null`
85
+ * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
75
86
  * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
76
87
  */
77
88
  <
@@ -87,25 +98,23 @@ export const asLink: {
87
98
  ): AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
88
99
 
89
100
  /**
90
- * Resolves any type of Link field or Prismic document to a URL.
101
+ * Resolves any type of link field or Prismic document to a URL.
102
+ *
103
+ * @deprecated Use object-style configuration instead.
91
104
  *
92
- * @typeParam LinkResolverFunctionReturnType - Link Resolver function return
105
+ * @typeParam LinkResolverFunctionReturnType - link resolver function return
93
106
  * type
94
107
  * @typeParam Field - Link field or Prismic document to resolve to a URL
95
- * @param linkFieldOrDocument - Any kind of Link field or a document to resolve
96
- * @param linkResolver - An optional Link Resolver function. Without it, you are
97
- * expected to use the `routes` options from the API
98
108
  *
99
- * @returns Resolved URL or, if the provided Link field or document is empty, `null`
100
- * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
101
- * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
109
+ * @param linkFieldOrDocument - Any kind of link field or a document to
110
+ * resolve
111
+ * @param linkResolver - An optional link resolver function. Without it, you
112
+ * are expected to use the `routes` options from the API
102
113
  *
103
- * @deprecated Use object-style configuration instead.
104
- *
105
- * ```ts
106
- * asLink(field);
107
- * asLink(field, { linkResolver });
108
- * ```
114
+ * @returns Resolved URL or, if the provided link field or document is empty,
115
+ * `null`
116
+ * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
117
+ * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
109
118
  */
110
119
  <
111
120
  LinkResolverFunctionReturnType = string | null | undefined,
@@ -136,7 +145,7 @@ export const asLink: {
136
145
  return null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
137
146
  }
138
147
 
139
- // Converts document to Link Field if needed
148
+ // Converts document to link field if needed
140
149
  const linkField =
141
150
  // prettier-ignore
142
151
  (
@@ -172,7 +181,7 @@ export const asLink: {
172
181
 
173
182
  case LinkType.Document: {
174
183
  if ("id" in linkField && config.linkResolver) {
175
- // When using Link Resolver...
184
+ // When using link resolver...
176
185
  const resolvedURL = config.linkResolver(linkField);
177
186
 
178
187
  if (resolvedURL != null) {
@@ -184,14 +193,14 @@ export const asLink: {
184
193
  }
185
194
 
186
195
  if ("url" in linkField && linkField.url) {
187
- // When using Route Resolver...
196
+ // When using route resolver...
188
197
  return linkField.url as AsLinkReturnType<
189
198
  LinkResolverFunctionReturnType,
190
199
  Field
191
200
  >;
192
201
  }
193
202
 
194
- // When empty or Link Resolver and Route Resolver are not used...
203
+ // When empty or link resolver and route resolver are not used...
195
204
  return null as AsLinkReturnType<LinkResolverFunctionReturnType, Field>;
196
205
  }
197
206