@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
@@ -66,18 +66,23 @@ type AsLinkAttrsReturnType<
66
66
  };
67
67
 
68
68
  /**
69
- * Resolves any type of Link field or Prismic document to a set of link attributes. The attributes are designed to be passed to link HTML elements, like `<a>`.
69
+ * Resolves any type of link field or Prismic document to a set of link
70
+ * attributes. The attributes are designed to be passed to link HTML elements,
71
+ * like `<a>`.
70
72
  *
71
- * If a resolved URL is external (i.e. starts with a protocol like `https://`), `rel` is returned as `"noreferrer"`.
73
+ * If a resolved URL is external (i.e. starts with a protocol like `https://`),
74
+ * `rel` is returned as `"noreferrer"`.
72
75
  *
73
- * @typeParam LinkResolverFunctionReturnType - Link Resolver function return
76
+ * @typeParam LinkResolverFunctionReturnType - link resolver function return
74
77
  * type
75
- * @typeParam Field - Link field or Prismic document to resolve to link attributes
76
- * @param linkFieldOrDocument - Any kind of Link field or a document to resolve
78
+ * @typeParam Field - Link field or Prismic document to resolve to link
79
+ * attributes
80
+ * @param linkFieldOrDocument - Any kind of link field or a document to resolve
77
81
  * @param config - Configuration that determines the output of `asLinkAttrs()`
78
82
  *
79
- * @returns Resolved set of link attributes or, if the provided Link field or document is empty, and empty object
80
- * @see Prismic Link Resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
83
+ * @returns Resolved set of link attributes or, if the provided link field or
84
+ * document is empty, and empty object
85
+ * @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
81
86
  * @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
82
87
  */
83
88
  export const asLinkAttrs = <
@@ -28,13 +28,21 @@ type AsTextReturnType<Field extends RichTextField | null | undefined> =
28
28
 
29
29
  export const asText: {
30
30
  /**
31
- * Serializes a Rich Text or Title field to a plain text string.
31
+ * Serializes a rich text or title field to a plain text string.
32
32
  *
33
- * @param richTextField - A Rich Text or Title field from Prismic
33
+ * @example
34
+ *
35
+ * ```ts
36
+ * asText(field);
37
+ * asText(field, { separator });
38
+ * ```
39
+ *
40
+ * @param richTextField - A rich text or title field from Prismic
34
41
  * @param config - Configuration that determines the output of `asText()`
35
42
  *
36
- * @returns Plain text equivalent of the provided Rich Text or Title field
37
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
43
+ * @returns Plain text equivalent of the provided rich text or title field
44
+ *
45
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
38
46
  */
39
47
  <Field extends RichTextField | null | undefined>(
40
48
  richTextField: Field,
@@ -42,20 +50,16 @@ export const asText: {
42
50
  ): AsTextReturnType<Field>;
43
51
 
44
52
  /**
45
- * Serializes a Rich Text or Title field to a plain text string.
53
+ * Serializes a rich text or title field to a plain text string.
46
54
  *
47
- * @param richTextField - A Rich Text or Title field from Prismic
48
- * @param separator - Separator used to join each element, defaults to a space
55
+ * @deprecated Use object-style configuration instead.
49
56
  *
50
- * @returns Plain text equivalent of the provided Rich Text or Title field
51
- * @see Templating Rich Text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
57
+ * @param richTextField - A rich text or title field from Prismic
58
+ * @param separator - Separator used to join each element, defaults to a space
52
59
  *
53
- * @deprecated Use object-style configuration instead.
60
+ * @returns Plain text equivalent of the provided rich text or title field
54
61
  *
55
- * ```ts
56
- * asText(field);
57
- * asText(field, { separator });
58
- * ```
62
+ * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/template-content-vanilla-javascript#rich-text-and-title}
59
63
  */
60
64
  <Field extends RichTextField | null | undefined>(
61
65
  richTextField: Field,
@@ -10,9 +10,11 @@ type SetOptional<T, Keys extends keyof T> = Omit<T, Keys> &
10
10
  * for document links
11
11
  *
12
12
  * @typeParam TDocument - Specific interface of the provided document
13
+ *
13
14
  * @param prismicDocument - A document coming from Prismic
14
15
  *
15
16
  * @returns The equivalent link field to use with `asLink()`
17
+ *
16
18
  * @internal
17
19
  */
18
20
  export const documentToLinkField = <
@@ -32,7 +34,7 @@ export const documentToLinkField = <
32
34
  tags: prismicDocument.tags,
33
35
  lang: prismicDocument.lang,
34
36
  url: prismicDocument.url == null ? undefined : prismicDocument.url,
35
- slug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQl
37
+ slug: prismicDocument.slugs?.[0], // Slug field is not available with GraphQL
36
38
  // The REST API does not include a `data` property if the data
37
39
  // object is empty.
38
40
  //
@@ -5,7 +5,7 @@ import type { AnyOEmbed, EmbedField } from "../types/value/embed";
5
5
  import type { GeoPointField } from "../types/value/geoPoint";
6
6
  import type { GroupField } from "../types/value/group";
7
7
  import type { ImageField, ImageFieldImage } from "../types/value/image";
8
- import type { IntegrationFields } from "../types/value/integrationFields";
8
+ import type { IntegrationField } from "../types/value/integration";
9
9
  import type { KeyTextField } from "../types/value/keyText";
10
10
  import type { LinkField } from "../types/value/link";
11
11
  import type { LinkToMediaField } from "../types/value/linkToMedia";
@@ -44,9 +44,9 @@ const isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {
44
44
  };
45
45
 
46
46
  /**
47
- * Determines if a Rich Text field is filled.
47
+ * Determines if a rich text field is filled.
48
48
  *
49
- * @param field - Rich Text field to check.
49
+ * @param field - rich text field to check.
50
50
  *
51
51
  * @returns `true` if `field` is filled, `false` otherwise.
52
52
  */
@@ -63,7 +63,7 @@ export const richText = (
63
63
  };
64
64
 
65
65
  /**
66
- * Determines if a Title field is filled.
66
+ * Determines if a title field is filled.
67
67
  *
68
68
  * @param field - Title field to check.
69
69
  *
@@ -87,7 +87,7 @@ export const imageThumbnail = (
87
87
  };
88
88
 
89
89
  /**
90
- * Determines if an Image field is filled.
90
+ * Determines if an image field is filled.
91
91
  *
92
92
  * @param field - Image field to check.
93
93
  *
@@ -100,7 +100,7 @@ export const image = imageThumbnail as <
100
100
  ) => field is ImageField<ThumbnailNames, "filled">;
101
101
 
102
102
  /**
103
- * Determines if a Link field is filled.
103
+ * Determines if a link field is filled.
104
104
  *
105
105
  * @param field - Link field to check.
106
106
  *
@@ -119,9 +119,9 @@ export const link = <
119
119
  };
120
120
 
121
121
  /**
122
- * Determines if a Link to Media field is filled.
122
+ * Determines if a link to media field is filled.
123
123
  *
124
- * @param field - Link to Media field to check.
124
+ * @param field - Link to media field to check.
125
125
  *
126
126
  * @returns `true` if `field` is filled, `false` otherwise.
127
127
  */
@@ -130,7 +130,7 @@ export const linkToMedia = link as (
130
130
  ) => field is LinkToMediaField<"filled">;
131
131
 
132
132
  /**
133
- * Determines if a Content Relationship field is filled.
133
+ * Determines if a content relationship field is filled.
134
134
  *
135
135
  * @param field - Content Relationship field to check.
136
136
  *
@@ -155,7 +155,7 @@ export const contentRelationship = link as <
155
155
  >;
156
156
 
157
157
  /**
158
- * Determines if a Date field is filled.
158
+ * Determines if a date field is filled.
159
159
  *
160
160
  * @param field - Date field to check.
161
161
  *
@@ -166,7 +166,7 @@ export const date = isNonNullish as (
166
166
  ) => field is DateField<"filled">;
167
167
 
168
168
  /**
169
- * Determines if a Timestamp field is filled.
169
+ * Determines if a timestamp field is filled.
170
170
  *
171
171
  * @param field - Timestamp field to check.
172
172
  *
@@ -177,7 +177,7 @@ export const timestamp = isNonNullish as (
177
177
  ) => field is TimestampField<"filled">;
178
178
 
179
179
  /**
180
- * Determines if a Color field is filled.
180
+ * Determines if a color field is filled.
181
181
  *
182
182
  * @param field - Color field to check.
183
183
  *
@@ -188,7 +188,7 @@ export const color = isNonNullish as (
188
188
  ) => field is ColorField<"filled">;
189
189
 
190
190
  /**
191
- * Determines if a Number field is filled.
191
+ * Determines if a number field is filled.
192
192
  *
193
193
  * @param field - Number field to check.
194
194
  *
@@ -199,7 +199,7 @@ export const number = isNonNullish as (
199
199
  ) => field is NumberField<"filled">;
200
200
 
201
201
  /**
202
- * Determines if a Key Text field is filled.
202
+ * Determines if a key text field is filled.
203
203
  *
204
204
  * @param field - Key Text field to check.
205
205
  *
@@ -212,7 +212,7 @@ export const keyText = (
212
212
  };
213
213
 
214
214
  /**
215
- * Determines if a Select field is filled.
215
+ * Determines if a select field is filled.
216
216
  *
217
217
  * @param field - Select field to check.
218
218
  *
@@ -223,7 +223,7 @@ export const select = isNonNullish as <Enum extends string>(
223
223
  ) => field is SelectField<Enum, "filled">;
224
224
 
225
225
  /**
226
- * Determines if an Embed field is filled.
226
+ * Determines if an embed field is filled.
227
227
  *
228
228
  * @param field - Embed field to check.
229
229
  *
@@ -236,7 +236,7 @@ export const embed = <Field extends EmbedField<AnyOEmbed>>(
236
236
  };
237
237
 
238
238
  /**
239
- * Determines if a GeoPoint field is filled.
239
+ * Determines if a geopoint field is filled.
240
240
  *
241
241
  * @param field - GeoPoint field to check.
242
242
  *
@@ -249,17 +249,22 @@ export const geoPoint = (
249
249
  };
250
250
 
251
251
  /**
252
- * Determines if an Integration Fields field is filled.
252
+ * Determines if an integration field is filled.
253
253
  *
254
- * @param field - Integration Fields field to check.
254
+ * @param field - Integration field to check.
255
255
  *
256
256
  * @returns `true` if `field` is filled, `false` otherwise.
257
257
  */
258
- export const integrationFields = isNonNullish as <
258
+ export const integrationField = isNonNullish as <
259
259
  Data extends Record<string, unknown>,
260
260
  >(
261
- field: IntegrationFields<Data> | null | undefined,
262
- ) => field is IntegrationFields<Data, "filled">;
261
+ field: IntegrationField<Data> | null | undefined,
262
+ ) => field is IntegrationField<Data, "filled">;
263
+ /**
264
+ * @deprecated Renamed to `integrationField`.
265
+ */
266
+ // TODO: Remove when we remove support for deprecated `integrationFields` export.
267
+ export const integrationFields = integrationField;
263
268
 
264
269
  /**
265
270
  * Determines if a Group has at least one item.
package/src/index.ts CHANGED
@@ -1,4 +1,7 @@
1
- // Use for deprecations.
1
+ // Imports are used for deprecations.
2
+ import type { CustomTypeModelIntegrationField } from "./types/model/integration";
3
+ import type { IntegrationField } from "./types/value/integration";
4
+
2
5
  import type {
3
6
  HTMLRichTextFunctionSerializer,
4
7
  HTMLRichTextMapSerializer,
@@ -43,6 +46,7 @@ export type {
43
46
  FetchLike,
44
47
  HttpRequestLike,
45
48
  RequestInitLike,
49
+ RequestInitLikeOrThunk,
46
50
  ResponseLike,
47
51
  } from "./createClient";
48
52
  export type {
@@ -196,7 +200,12 @@ export type { SelectField } from "./types/value/select";
196
200
  export type { TimestampField } from "./types/value/timestamp";
197
201
  export type { GeoPointField } from "./types/value/geoPoint";
198
202
 
199
- export type { IntegrationFields } from "./types/value/integrationFields";
203
+ /**
204
+ * @deprecated Renamed to `IntegrationField`
205
+ */
206
+ // TODO: Remove when we remove support for deprecated `IntegrationFields` export.
207
+ type IntegrationFields = IntegrationField;
208
+ export { IntegrationField, IntegrationFields };
200
209
 
201
210
  export type { GroupField } from "./types/value/group";
202
211
 
@@ -247,7 +256,15 @@ export type { CustomTypeModelSelectField } from "./types/model/select";
247
256
  export type { CustomTypeModelTimestampField } from "./types/model/timestamp";
248
257
  export type { CustomTypeModelGeoPointField } from "./types/model/geoPoint";
249
258
 
250
- export type { CustomTypeModelIntegrationFieldsField } from "./types/model/integrationFields";
259
+ /**
260
+ * @deprecated Renamed to `CustomTypeModelIntegrationField`.
261
+ */
262
+ // TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.
263
+ type CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField;
264
+ export {
265
+ CustomTypeModelIntegrationField,
266
+ CustomTypeModelIntegrationFieldsField,
267
+ };
251
268
  export type { CustomTypeModelGroupField } from "./types/model/group";
252
269
  export type {
253
270
  CustomTypeModelSliceZoneField,
@@ -5,12 +5,12 @@ interface WithFilters {
5
5
  }
6
6
 
7
7
  /**
8
- * Adds one or more filters to an object with a `filters` property.
9
- * Appended filters are added to the end of the existing list.
8
+ * Adds one or more filters to an object with a `filters` property. Appended
9
+ * filters are added to the end of the existing list.
10
10
  *
11
11
  * @typeParam T - Object to which filters will be append.
12
- * @param objWithFilters - Object to append filters on the `filters`
13
- * property.
12
+ *
13
+ * @param objWithFilters - Object to append filters on the `filters` property.
14
14
  * @param filters - One or more filters to append.
15
15
  *
16
16
  * @returns The object with the appended filters.
@@ -4,6 +4,7 @@
4
4
  * only element.
5
5
  *
6
6
  * @typeParam A - Element of the array.
7
+ *
7
8
  * @param a - Value to ensure is an array.
8
9
  *
9
10
  * @returns `a` as an array.
@@ -3,10 +3,17 @@
3
3
  * is. If it is not a thunk, it is converted to a thunk.
4
4
  *
5
5
  * @typeParam A - Value returned by the thunk.
6
+ *
6
7
  * @param a - Value to ensure is a thunk.
7
8
  *
8
9
  * @returns `a` as a a thunk.
9
10
  */
10
- export const castThunk = <A>(a: A | (() => A)): (() => A) => {
11
- return typeof a === "function" ? (a as () => A) : () => a;
11
+ export const castThunk = <
12
+ A,
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ TArgs extends any[],
15
+ >(
16
+ a: A | ((...args: TArgs) => A),
17
+ ): ((...args: TArgs) => A) => {
18
+ return typeof a === "function" ? (a as (...args: TArgs) => A) : () => a;
12
19
  };
@@ -3,8 +3,8 @@ import { filter } from "../filter";
3
3
  import { castArray } from "./castArray";
4
4
 
5
5
  /**
6
- * Creates a filter to filter content by document tags. All tags are required
7
- * on the document.
6
+ * Creates a filter to filter content by document tags. All tags are required on
7
+ * the document.
8
8
  *
9
9
  * @param tags - Document tags to filter queried content.
10
10
  *
@@ -8,6 +8,7 @@ import { findRef } from "./findRef";
8
8
  * @param refs - A list of refs to search.
9
9
  *
10
10
  * @returns The master ref from the list.
11
+ *
11
12
  * @throws If a matching ref cannot be found.
12
13
  */
13
14
  export const findMasterRef = (refs: Ref[]): Ref => {
@@ -7,10 +7,11 @@ import { PrismicError } from "../errors/PrismicError";
7
7
  * returns true).
8
8
  *
9
9
  * @param refs - A list of refs to search.
10
- * @param filter - A function that determines if a ref from the list matches
11
- * the criteria.
10
+ * @param filter - A function that determines if a ref from the list matches the
11
+ * criteria.
12
12
  *
13
13
  * @returns The first matching ref.
14
+ *
14
15
  * @throws If a matching ref cannot be found.
15
16
  */
16
17
  export const findRef = (refs: Ref[], filter: (ref: Ref) => boolean): Ref => {
@@ -9,6 +9,7 @@ import { findRef } from "./findRef";
9
9
  * @param id - The ID of the ref to find.
10
10
  *
11
11
  * @returns The ref with a matching ID from the list.
12
+ *
12
13
  * @throws If a matching ref cannot be found.
13
14
  */
14
15
  export const findRefByID = (refs: Ref[], id: string): Ref => {
@@ -9,6 +9,7 @@ import { findRef } from "./findRef";
9
9
  * @param id - The label of the ref to find.
10
10
  *
11
11
  * @returns The ref with a matching label from the list.
12
+ *
12
13
  * @throws If a matching ref cannot be found.
13
14
  */
14
15
  export const findRefByLabel = (refs: Ref[], label: string): Ref => {
@@ -5,6 +5,7 @@ import { PrismicDocument } from "../value/document";
5
5
  * paginated metadata and a list of matching results for the query.
6
6
  *
7
7
  * @typeParam Document - The type(s) of Prismic document that can be returned.
8
+ *
8
9
  * @see More details on querying: {@link https://prismic.io/docs/api}
9
10
  */
10
11
  export interface Query<Document extends PrismicDocument = PrismicDocument> {
@@ -5,6 +5,7 @@ import { Ref } from "./ref";
5
5
  *
6
6
  * @remarks
7
7
  * This is an alias for `Ref`.
8
+ *
8
9
  * @see {@link Ref}
9
10
  * @see More details on Releases: {@link https://prismic.io/docs/guides/draft-plan-and-schedule-content#releases}
10
11
  */
@@ -15,7 +15,7 @@ export interface Repository {
15
15
  refs: Ref[];
16
16
 
17
17
  /**
18
- * An identifier used to query content with the latest Integration Fields
18
+ * An identifier used to query content with the latest integration fields
19
19
  * data.
20
20
  */
21
21
  integrationFieldsRef: string | null;
@@ -28,7 +28,7 @@ export interface Repository {
28
28
  languages: Language[];
29
29
 
30
30
  /**
31
- * A list of the repository's Custom Type API IDs mapped to their
31
+ * A list of the repository's custom type API IDs mapped to their
32
32
  * human-readable name.
33
33
  */
34
34
  types: Record<string, string>;
@@ -3,6 +3,7 @@
3
3
  * sending a `GET` request to a repository's `/api/tags` endpoint.
4
4
  *
5
5
  * @typeParam Tag - Tags that are returned by the Tags API.
6
+ *
6
7
  * @see More details on the Tags API: {@link https://prismic.io/docs/tags-api-technical-reference}
7
8
  */
8
9
  export type Tags<Tag extends string = string> = Tag[];
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * A Boolean Custom Type field.
4
+ * A boolean custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/boolean}
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * A Color Custom Type field.
4
+ * A color custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/color}
7
7
  */
@@ -3,10 +3,9 @@ import type { CustomTypeModelFieldType } from "./types";
3
3
  import type { CustomTypeModelLinkSelectType } from "./link";
4
4
 
5
5
  /**
6
- * A Content Relationship Custom Type field.
6
+ * A content relationship custom type field.
7
7
  *
8
- * More details:
9
- * {@link https://prismic.io/docs/content-relationship}
8
+ * More details: {@link https://prismic.io/docs/content-relationship}
10
9
  */
11
10
  export interface CustomTypeModelContentRelationshipField<
12
11
  CustomTypeIDs extends string = string,
@@ -1,46 +1,46 @@
1
1
  import { CustomTypeModelField } from "./types";
2
2
 
3
3
  /**
4
- * A Prismic Custom Type model.
4
+ * A Prismic custom type model.
5
5
  *
6
- * @typeParam ID - API ID of the Custom Type.
7
- * @typeParam Definition - The Custom Type's tabs and their fields.
6
+ * @typeParam ID - API ID of the custom type.
7
+ * @typeParam Definition - The custom type's tabs and their fields.
8
8
  */
9
9
  export interface CustomTypeModel<
10
10
  ID extends string = string,
11
11
  Definition extends CustomTypeModelDefinition = CustomTypeModelDefinition,
12
12
  > {
13
13
  /**
14
- * The ID of the Custom Type model.
14
+ * The ID of the custom type model.
15
15
  */
16
16
  id: ID;
17
17
 
18
18
  /**
19
- * The human readable name of the Custom Type Model.
19
+ * The human readable name of the custom type model.
20
20
  */
21
21
  // TODO: Revert to `label?: string | null` if `label` can be partial in: https://github.com/prismicio/prismic-types-internal/blob/HEAD/src/customtypes/CustomType.ts#L39
22
22
  label: string | null | undefined;
23
23
 
24
24
  /**
25
- * Determines if more than one document for the Custom Type can be created.
25
+ * Determines if more than one document for the custom type can be created.
26
26
  */
27
27
  repeatable: boolean;
28
28
 
29
29
  /**
30
- * The Custom Type model definition.
30
+ * The custom type model definition.
31
31
  */
32
32
  json: Definition;
33
33
 
34
34
  /**
35
- * Determines if new documents for the Custom Type can be created.
35
+ * Determines if new documents for the custom type can be created.
36
36
  */
37
37
  status: boolean;
38
38
  }
39
39
 
40
40
  /**
41
- * A Prismic Custom Type's tabs and their fields.
41
+ * A Prismic custom type's tabs and their fields.
42
42
  *
43
- * @typeParam TabName - Names of Custom Type tabs.
43
+ * @typeParam TabName - Names of custom type tabs.
44
44
  */
45
45
  export type CustomTypeModelDefinition<TabName extends string = string> = Record<
46
46
  TabName,
@@ -48,7 +48,7 @@ export type CustomTypeModelDefinition<TabName extends string = string> = Record<
48
48
  >;
49
49
 
50
50
  /**
51
- * A Custom Type's tab. Each tab can contain any number of fields but is limited
51
+ * A custom type's tab. Each tab can contain any number of fields but is limited
52
52
  * to one Slice Zone.
53
53
  *
54
54
  * @typeParam FieldName - API IDs of the fields.
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * A Date Custom Type field.
4
+ * A date custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/date}
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * An Embed Custom Type field.
4
+ * An embed custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/embed}
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * A GeoPoint Custom Type field.
4
+ * A geopoint custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/geopoint}
7
7
  */
@@ -4,7 +4,7 @@ import type {
4
4
  } from "./types";
5
5
 
6
6
  /**
7
- * A Group Custom Type field.
7
+ * A group custom type field.
8
8
  *
9
9
  * More details: {@link https://prismic.io/docs/group}
10
10
  *
@@ -1,7 +1,7 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * Dimension constraints for an Image Custom Type field.
4
+ * Dimension constraints for an image custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/image}
7
7
  */
@@ -11,7 +11,7 @@ export interface CustomTypeModelImageConstraint {
11
11
  }
12
12
 
13
13
  /**
14
- * A thumbnail for an Image Custom Type field.
14
+ * A thumbnail for an image custom type field.
15
15
  *
16
16
  * More details: {@link https://prismic.io/docs/image}
17
17
  */
@@ -21,7 +21,7 @@ export interface CustomTypeModelImageThumbnail<Name extends string = string>
21
21
  }
22
22
 
23
23
  /**
24
- * An Image Custom Type field.
24
+ * An image custom type field.
25
25
  *
26
26
  * More details: {@link https://prismic.io/docs/image}
27
27
  */
@@ -1,12 +1,12 @@
1
1
  import type { CustomTypeModelFieldType } from "./types";
2
2
 
3
3
  /**
4
- * An Integration Fields Custom Type field.
4
+ * An integration custom type field.
5
5
  *
6
6
  * More details: {@link https://prismic.io/docs/integration-fields}
7
7
  */
8
- export interface CustomTypeModelIntegrationFieldsField {
9
- type: typeof CustomTypeModelFieldType.IntegrationFields;
8
+ export interface CustomTypeModelIntegrationField {
9
+ type: typeof CustomTypeModelFieldType.Integration;
10
10
  config?: {
11
11
  label?: string | null;
12
12
  placeholder?: string;