@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.
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.ts +15 -14
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/createClient.cjs +63 -30
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +95 -48
- package/dist/createClient.js +63 -30
- package/dist/createClient.js.map +1 -1
- package/dist/filter.cjs +39 -39
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.d.ts +39 -39
- package/dist/filter.js +39 -39
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.d.ts +1 -0
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.d.ts +2 -0
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.d.ts +1 -0
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.d.ts +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.d.ts +3 -2
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +34 -28
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +5 -5
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +3 -3
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +6 -6
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +32 -23
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +12 -7
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +18 -14
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.d.ts +2 -0
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs +3 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +24 -20
- package/dist/helpers/isFilled.js +3 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/appendFilters.cjs.map +1 -1
- package/dist/lib/appendFilters.d.ts +4 -4
- package/dist/lib/appendFilters.js.map +1 -1
- package/dist/lib/castArray.cjs.map +1 -1
- package/dist/lib/castArray.d.ts +1 -0
- package/dist/lib/castArray.js.map +1 -1
- package/dist/lib/castThunk.cjs.map +1 -1
- package/dist/lib/castThunk.d.ts +2 -1
- package/dist/lib/castThunk.js.map +1 -1
- package/dist/lib/everyTagFilter.cjs.map +1 -1
- package/dist/lib/everyTagFilter.d.ts +2 -2
- package/dist/lib/everyTagFilter.js.map +1 -1
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findMasterRef.d.ts +1 -0
- package/dist/lib/findMasterRef.js.map +1 -1
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.d.ts +3 -2
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/findRefByID.cjs.map +1 -1
- package/dist/lib/findRefByID.d.ts +1 -0
- package/dist/lib/findRefByID.js.map +1 -1
- package/dist/lib/findRefByLabel.cjs.map +1 -1
- package/dist/lib/findRefByLabel.d.ts +1 -0
- package/dist/lib/findRefByLabel.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/api/query.d.ts +1 -0
- package/dist/types/api/release.d.ts +1 -0
- package/dist/types/api/repository.d.ts +2 -2
- package/dist/types/api/tags.d.ts +1 -0
- package/dist/types/model/boolean.d.ts +1 -1
- package/dist/types/model/color.d.ts +1 -1
- package/dist/types/model/contentRelationship.d.ts +2 -3
- package/dist/types/model/customType.d.ts +11 -11
- package/dist/types/model/date.d.ts +1 -1
- package/dist/types/model/embed.d.ts +1 -1
- package/dist/types/model/geoPoint.d.ts +1 -1
- package/dist/types/model/group.d.ts +1 -1
- package/dist/types/model/image.d.ts +3 -3
- package/dist/types/model/{integrationFields.d.ts → integration.d.ts} +3 -3
- package/dist/types/model/keyText.d.ts +1 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.d.ts +4 -6
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/linkToMedia.d.ts +2 -3
- package/dist/types/model/number.d.ts +1 -1
- package/dist/types/model/richText.d.ts +3 -3
- package/dist/types/model/select.d.ts +1 -1
- package/dist/types/model/sharedSlice.d.ts +2 -2
- package/dist/types/model/sharedSliceVariation.d.ts +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.d.ts +1 -1
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.d.ts +2 -2
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/timestamp.d.ts +1 -1
- package/dist/types/model/title.d.ts +1 -1
- package/dist/types/model/types.cjs +5 -1
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.d.ts +10 -6
- package/dist/types/model/types.js +5 -1
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/model/uid.d.ts +1 -1
- package/dist/types/value/boolean.d.ts +1 -1
- package/dist/types/value/color.d.ts +2 -1
- package/dist/types/value/contentRelationship.d.ts +1 -1
- package/dist/types/value/date.d.ts +2 -1
- package/dist/types/value/document.d.ts +4 -4
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.d.ts +2 -1
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/geoPoint.d.ts +2 -1
- package/dist/types/value/group.d.ts +1 -1
- package/dist/types/value/image.d.ts +5 -3
- package/dist/types/value/{integrationFields.d.ts → integration.d.ts} +3 -2
- package/dist/types/value/keyText.d.ts +2 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.d.ts +2 -2
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/linkToMedia.d.ts +2 -2
- package/dist/types/value/number.d.ts +2 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.d.ts +26 -26
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/value/select.d.ts +2 -1
- package/dist/types/value/sharedSlice.d.ts +1 -1
- package/dist/types/value/sharedSliceVariation.d.ts +3 -0
- package/dist/types/value/slice.d.ts +1 -1
- package/dist/types/value/timestamp.d.ts +1 -1
- package/dist/types/value/title.d.ts +1 -1
- package/dist/types/value/types.d.ts +3 -2
- package/dist/types/webhook/apiUpdate.d.ts +1 -1
- package/package.json +4 -4
- package/src/buildQueryURL.ts +15 -14
- package/src/createClient.ts +112 -55
- package/src/filter.ts +43 -43
- package/src/getGraphQLEndpoint.ts +1 -0
- package/src/getRepositoryEndpoint.ts +2 -0
- package/src/getRepositoryName.ts +1 -0
- package/src/getToolbarSrc.ts +1 -1
- package/src/helpers/asDate.ts +3 -2
- package/src/helpers/asHTML.ts +36 -30
- package/src/helpers/asImagePixelDensitySrcSet.ts +5 -5
- package/src/helpers/asImageSrc.ts +3 -3
- package/src/helpers/asImageWidthSrcSet.ts +6 -6
- package/src/helpers/asLink.ts +36 -27
- package/src/helpers/asLinkAttrs.ts +12 -7
- package/src/helpers/asText.ts +18 -14
- package/src/helpers/documentToLinkField.ts +3 -1
- package/src/helpers/isFilled.ts +27 -22
- package/src/index.ts +20 -3
- package/src/lib/appendFilters.ts +4 -4
- package/src/lib/castArray.ts +1 -0
- package/src/lib/castThunk.ts +9 -2
- package/src/lib/everyTagFilter.ts +2 -2
- package/src/lib/findMasterRef.ts +1 -0
- package/src/lib/findRef.ts +3 -2
- package/src/lib/findRefByID.ts +1 -0
- package/src/lib/findRefByLabel.ts +1 -0
- package/src/types/api/query.ts +1 -0
- package/src/types/api/release.ts +1 -0
- package/src/types/api/repository.ts +2 -2
- package/src/types/api/tags.ts +1 -0
- package/src/types/model/boolean.ts +1 -1
- package/src/types/model/color.ts +1 -1
- package/src/types/model/contentRelationship.ts +2 -3
- package/src/types/model/customType.ts +11 -11
- package/src/types/model/date.ts +1 -1
- package/src/types/model/embed.ts +1 -1
- package/src/types/model/geoPoint.ts +1 -1
- package/src/types/model/group.ts +1 -1
- package/src/types/model/image.ts +3 -3
- package/src/types/model/{integrationFields.ts → integration.ts} +3 -3
- package/src/types/model/keyText.ts +1 -1
- package/src/types/model/link.ts +4 -6
- package/src/types/model/linkToMedia.ts +2 -3
- package/src/types/model/number.ts +1 -1
- package/src/types/model/richText.ts +3 -3
- package/src/types/model/select.ts +1 -1
- package/src/types/model/sharedSlice.ts +2 -2
- package/src/types/model/sharedSliceVariation.ts +1 -1
- package/src/types/model/slice.ts +1 -1
- package/src/types/model/sliceZone.ts +2 -2
- package/src/types/model/timestamp.ts +1 -1
- package/src/types/model/title.ts +1 -1
- package/src/types/model/types.ts +10 -6
- package/src/types/model/uid.ts +1 -1
- package/src/types/value/boolean.ts +1 -1
- package/src/types/value/color.ts +2 -1
- package/src/types/value/contentRelationship.ts +1 -1
- package/src/types/value/date.ts +2 -1
- package/src/types/value/document.ts +4 -4
- package/src/types/value/embed.ts +2 -1
- package/src/types/value/geoPoint.ts +2 -1
- package/src/types/value/group.ts +1 -1
- package/src/types/value/image.ts +6 -4
- package/src/types/value/{integrationFields.ts → integration.ts} +3 -2
- package/src/types/value/keyText.ts +2 -1
- package/src/types/value/link.ts +2 -2
- package/src/types/value/linkToMedia.ts +2 -2
- package/src/types/value/number.ts +2 -1
- package/src/types/value/richText.ts +26 -26
- package/src/types/value/select.ts +2 -1
- package/src/types/value/sharedSlice.ts +1 -1
- package/src/types/value/sharedSliceVariation.ts +3 -0
- package/src/types/value/slice.ts +1 -1
- package/src/types/value/timestamp.ts +1 -1
- package/src/types/value/title.ts +1 -1
- package/src/types/value/types.ts +3 -2
- 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
|
|
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://`),
|
|
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 -
|
|
76
|
+
* @typeParam LinkResolverFunctionReturnType - link resolver function return
|
|
74
77
|
* type
|
|
75
|
-
* @typeParam Field - Link field or Prismic document to resolve to link
|
|
76
|
-
*
|
|
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
|
|
80
|
-
*
|
|
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 = <
|
package/src/helpers/asText.ts
CHANGED
|
@@ -28,13 +28,21 @@ type AsTextReturnType<Field extends RichTextField | null | undefined> =
|
|
|
28
28
|
|
|
29
29
|
export const asText: {
|
|
30
30
|
/**
|
|
31
|
-
* Serializes a
|
|
31
|
+
* Serializes a rich text or title field to a plain text string.
|
|
32
32
|
*
|
|
33
|
-
* @
|
|
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
|
|
37
|
-
*
|
|
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
|
|
53
|
+
* Serializes a rich text or title field to a plain text string.
|
|
46
54
|
*
|
|
47
|
-
* @
|
|
48
|
-
* @param separator - Separator used to join each element, defaults to a space
|
|
55
|
+
* @deprecated Use object-style configuration instead.
|
|
49
56
|
*
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
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
|
-
* @
|
|
60
|
+
* @returns Plain text equivalent of the provided rich text or title field
|
|
54
61
|
*
|
|
55
|
-
*
|
|
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
|
|
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
|
//
|
package/src/helpers/isFilled.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
47
|
+
* Determines if a rich text field is filled.
|
|
48
48
|
*
|
|
49
|
-
* @param field -
|
|
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
|
|
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
|
|
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
|
|
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
|
|
122
|
+
* Determines if a link to media field is filled.
|
|
123
123
|
*
|
|
124
|
-
* @param field - Link to
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
252
|
+
* Determines if an integration field is filled.
|
|
253
253
|
*
|
|
254
|
-
* @param field - Integration
|
|
254
|
+
* @param field - Integration field to check.
|
|
255
255
|
*
|
|
256
256
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
257
257
|
*/
|
|
258
|
-
export const
|
|
258
|
+
export const integrationField = isNonNullish as <
|
|
259
259
|
Data extends Record<string, unknown>,
|
|
260
260
|
>(
|
|
261
|
-
field:
|
|
262
|
-
) => field is
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
package/src/lib/appendFilters.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
13
|
-
*
|
|
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.
|
package/src/lib/castArray.ts
CHANGED
package/src/lib/castThunk.ts
CHANGED
|
@@ -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 = <
|
|
11
|
-
|
|
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
|
-
*
|
|
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
|
*
|
package/src/lib/findMasterRef.ts
CHANGED
package/src/lib/findRef.ts
CHANGED
|
@@ -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
|
-
*
|
|
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 => {
|
package/src/lib/findRefByID.ts
CHANGED
|
@@ -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 => {
|
package/src/types/api/query.ts
CHANGED
|
@@ -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> {
|
package/src/types/api/release.ts
CHANGED
|
@@ -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
|
|
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
|
|
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>;
|
package/src/types/api/tags.ts
CHANGED
|
@@ -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[];
|
package/src/types/model/color.ts
CHANGED
|
@@ -3,10 +3,9 @@ import type { CustomTypeModelFieldType } from "./types";
|
|
|
3
3
|
import type { CustomTypeModelLinkSelectType } from "./link";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A
|
|
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
|
|
4
|
+
* A Prismic custom type model.
|
|
5
5
|
*
|
|
6
|
-
* @typeParam ID - API ID of the
|
|
7
|
-
* @typeParam Definition - The
|
|
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
|
|
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
|
|
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
|
|
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
|
|
30
|
+
* The custom type model definition.
|
|
31
31
|
*/
|
|
32
32
|
json: Definition;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* Determines if new documents for the
|
|
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
|
|
41
|
+
* A Prismic custom type's tabs and their fields.
|
|
42
42
|
*
|
|
43
|
-
* @typeParam TabName - Names of
|
|
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
|
|
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.
|
package/src/types/model/date.ts
CHANGED
package/src/types/model/embed.ts
CHANGED
package/src/types/model/group.ts
CHANGED
package/src/types/model/image.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CustomTypeModelFieldType } from "./types";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Dimension constraints for an
|
|
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
|
|
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
|
|
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
|
|
4
|
+
* An integration custom type field.
|
|
5
5
|
*
|
|
6
6
|
* More details: {@link https://prismic.io/docs/integration-fields}
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
9
|
-
type: typeof CustomTypeModelFieldType.
|
|
8
|
+
export interface CustomTypeModelIntegrationField {
|
|
9
|
+
type: typeof CustomTypeModelFieldType.Integration;
|
|
10
10
|
config?: {
|
|
11
11
|
label?: string | null;
|
|
12
12
|
placeholder?: string;
|