@prismicio/client 7.1.0 → 7.1.1
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 +1 -0
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/createClient.cjs +8 -1
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +8 -0
- package/dist/createClient.js +8 -1
- package/dist/createClient.js.map +1 -1
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- 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.js.map +1 -1
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +0 -6
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -1
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +2 -1
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +2 -1
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +3 -4
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +3 -1
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +0 -4
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/isFilled.d.ts +13 -10
- package/dist/helpers/unstable_mapSliceZone.cjs.map +1 -1
- package/dist/helpers/unstable_mapSliceZone.d.ts +12 -5
- package/dist/helpers/unstable_mapSliceZone.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/api/repository.d.ts +6 -1
- package/package.json +20 -20
- package/src/buildQueryURL.ts +1 -0
- package/src/createClient.ts +9 -1
- package/src/getRepositoryName.ts +1 -0
- package/src/helpers/asHTML.ts +0 -6
- package/src/helpers/asImagePixelDensitySrcSet.ts +1 -0
- package/src/helpers/asImageSrc.ts +1 -0
- package/src/helpers/asImageWidthSrcSet.ts +1 -0
- package/src/helpers/asLink.ts +3 -4
- package/src/helpers/asLinkAttrs.ts +2 -0
- package/src/helpers/asText.ts +0 -4
- package/src/helpers/unstable_mapSliceZone.ts +19 -8
- package/src/types/api/repository.ts +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/client",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "The official JavaScript + TypeScript client library for Prismic",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -60,32 +60,32 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@prismicio/richtext": "^2.1.5",
|
|
63
|
-
"imgix-url-builder": "^0.0.
|
|
63
|
+
"imgix-url-builder": "^0.0.4"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@prismicio/mock": "^0.3.
|
|
67
|
-
"@prismicio/types-internal": "2.0.0
|
|
68
|
-
"@size-limit/preset-small-lib": "^8.2.
|
|
69
|
-
"@trivago/prettier-plugin-sort-imports": "^4.
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
71
|
-
"@typescript-eslint/parser": "^
|
|
72
|
-
"@vitest/coverage-
|
|
66
|
+
"@prismicio/mock": "^0.3.1",
|
|
67
|
+
"@prismicio/types-internal": "2.0.0",
|
|
68
|
+
"@size-limit/preset-small-lib": "^8.2.6",
|
|
69
|
+
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
71
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
72
|
+
"@vitest/coverage-v8": "^0.34.1",
|
|
73
73
|
"abort-controller": "^3.0.0",
|
|
74
|
-
"eslint": "^8.
|
|
75
|
-
"eslint-config-prettier": "^
|
|
76
|
-
"eslint-plugin-prettier": "^
|
|
74
|
+
"eslint": "^8.47.0",
|
|
75
|
+
"eslint-config-prettier": "^9.0.0",
|
|
76
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
77
77
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
78
|
-
"msw": "^1.2.
|
|
79
|
-
"node-fetch": "^3.3.
|
|
80
|
-
"prettier": "^
|
|
81
|
-
"prettier-plugin-jsdoc": "^0.
|
|
82
|
-
"size-limit": "^8.2.
|
|
78
|
+
"msw": "^1.2.3",
|
|
79
|
+
"node-fetch": "^3.3.2",
|
|
80
|
+
"prettier": "^3.0.1",
|
|
81
|
+
"prettier-plugin-jsdoc": "^1.0.1",
|
|
82
|
+
"size-limit": "^8.2.6",
|
|
83
83
|
"standard-version": "^9.5.0",
|
|
84
84
|
"ts-expect": "^1.3.0",
|
|
85
|
-
"typescript": "^
|
|
86
|
-
"vite": "^4.
|
|
85
|
+
"typescript": "^4.9.5",
|
|
86
|
+
"vite": "^4.4.9",
|
|
87
87
|
"vite-plugin-sdk": "^0.1.1",
|
|
88
|
-
"vitest": "^0.
|
|
88
|
+
"vitest": "^0.34.1"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=14.15.0"
|
package/src/buildQueryURL.ts
CHANGED
package/src/createClient.ts
CHANGED
|
@@ -370,6 +370,7 @@ export interface CreateClient {
|
|
|
370
370
|
*
|
|
371
371
|
* @typeParam TDocuments - A map of Prismic document type IDs mapped to their
|
|
372
372
|
* TypeScript type.
|
|
373
|
+
*
|
|
373
374
|
* @param repositoryNameOrEndpoint - The Prismic repository name or full Rest
|
|
374
375
|
* API V2 endpoint for the repository.
|
|
375
376
|
* @param options - Configuration that determines how content will be queried
|
|
@@ -664,7 +665,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
664
665
|
return firstResult;
|
|
665
666
|
}
|
|
666
667
|
|
|
667
|
-
throw new
|
|
668
|
+
throw new NotFoundError("No documents were returned", url, undefined);
|
|
668
669
|
}
|
|
669
670
|
|
|
670
671
|
/**
|
|
@@ -732,6 +733,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
732
733
|
* for all documents and is made available on its `id` property. A UID is
|
|
733
734
|
* provided in the Prismic editor and is unique among all documents of its
|
|
734
735
|
* custom type.
|
|
736
|
+
*
|
|
735
737
|
* @example
|
|
736
738
|
*
|
|
737
739
|
* ```ts
|
|
@@ -763,6 +765,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
763
765
|
* for all documents and is made available on its `id` property. A UID is
|
|
764
766
|
* provided in the Prismic editor and is unique among all documents of its
|
|
765
767
|
* custom type.
|
|
768
|
+
*
|
|
766
769
|
* @example
|
|
767
770
|
*
|
|
768
771
|
* ```ts
|
|
@@ -800,6 +803,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
800
803
|
* for all documents and is made available on its `id` property. A UID is
|
|
801
804
|
* provided in the Prismic editor and is unique among all documents of its
|
|
802
805
|
* custom type.
|
|
806
|
+
*
|
|
803
807
|
* @example
|
|
804
808
|
*
|
|
805
809
|
* ```ts
|
|
@@ -834,6 +838,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
834
838
|
* for all documents and is made available on its `id` property. A UID is
|
|
835
839
|
* provided in the Prismic editor and is unique among all documents of its
|
|
836
840
|
* custom type.
|
|
841
|
+
*
|
|
837
842
|
* @example
|
|
838
843
|
*
|
|
839
844
|
* ```ts
|
|
@@ -874,6 +879,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
874
879
|
* for all documents and is made available on its `id` property. A UID is
|
|
875
880
|
* provided in the Prismic editor and is unique among all documents of its
|
|
876
881
|
* custom type.
|
|
882
|
+
*
|
|
877
883
|
* @example
|
|
878
884
|
*
|
|
879
885
|
* ```ts
|
|
@@ -920,6 +926,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
920
926
|
* for all documents and is made available on its `id` property. A UID is
|
|
921
927
|
* provided in the Prismic editor and is unique among all documents of its
|
|
922
928
|
* custom type.
|
|
929
|
+
*
|
|
923
930
|
* @example
|
|
924
931
|
*
|
|
925
932
|
* ```ts
|
|
@@ -964,6 +971,7 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
|
|
|
964
971
|
* instance. For example, a repository may be configured to contain just one
|
|
965
972
|
* Settings document. This is in contrast to a repeatable custom type which
|
|
966
973
|
* allows multiple instances of itself.
|
|
974
|
+
*
|
|
967
975
|
* @example
|
|
968
976
|
*
|
|
969
977
|
* ```ts
|
package/src/getRepositoryName.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { PrismicError } from "./errors/PrismicError";
|
|
|
6
6
|
*
|
|
7
7
|
* @typeParam RepositoryEndpoint - Prismic Rest API V2 endpoint for the
|
|
8
8
|
* repository.
|
|
9
|
+
*
|
|
9
10
|
* @param repositoryEndpoint - Prismic Rest API V2 endpoint for the repository.
|
|
10
11
|
*
|
|
11
12
|
* @returns The Prismic repository's name.
|
package/src/helpers/asHTML.ts
CHANGED
|
@@ -255,12 +255,6 @@ export const asHTML: {
|
|
|
255
255
|
*
|
|
256
256
|
* @deprecated Use object-style configuration instead.
|
|
257
257
|
*
|
|
258
|
-
* ```ts
|
|
259
|
-
* asHTML(field);
|
|
260
|
-
* asHTML(field, { linkResolver });
|
|
261
|
-
* asHTML(field, { serializer });
|
|
262
|
-
* asHTML(field, { linkResolver, serializer });
|
|
263
|
-
* ```
|
|
264
258
|
* @param richTextField - A rich text or title field from Prismic
|
|
265
259
|
* @param linkResolver - An optional link resolver function to resolve links,
|
|
266
260
|
* without it you're expected to use the `routes` options from the API
|
|
@@ -70,6 +70,7 @@ type AsImagePixelDensitySrcSetReturnType<
|
|
|
70
70
|
*
|
|
71
71
|
* @returns A `srcset` attribute value for the image field with Imgix URL
|
|
72
72
|
* parameters (if given). If the image field is empty, `null` is returned.
|
|
73
|
+
*
|
|
73
74
|
* @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
|
|
74
75
|
*/
|
|
75
76
|
export const asImagePixelDensitySrcSet = <
|
|
@@ -27,6 +27,7 @@ type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> =
|
|
|
27
27
|
*
|
|
28
28
|
* @returns The image field's image URL with transformations applied (if given).
|
|
29
29
|
* If the image field is empty, `null` is returned.
|
|
30
|
+
*
|
|
30
31
|
* @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
|
|
31
32
|
*/
|
|
32
33
|
export const asImageSrc = <Field extends ImageFieldImage | null | undefined>(
|
|
@@ -74,6 +74,7 @@ type AsImageWidthSrcSetConfig = Omit<BuildWidthSrcSetParams, "widths"> & {
|
|
|
74
74
|
*
|
|
75
75
|
* @returns A `srcset` attribute value for the image field with Imgix URL
|
|
76
76
|
* parameters (if given). If the image field is empty, `null` is returned.
|
|
77
|
+
*
|
|
77
78
|
* @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
|
|
78
79
|
*/
|
|
79
80
|
export const asImageWidthSrcSet = <
|
package/src/helpers/asLink.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { documentToLinkField } from "./documentToLinkField";
|
|
|
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
|
+
*
|
|
13
14
|
* @param linkToDocumentField - A document link field to resolve
|
|
14
15
|
*
|
|
15
16
|
* @returns Resolved URL
|
|
@@ -75,6 +76,7 @@ export const asLink: {
|
|
|
75
76
|
*
|
|
76
77
|
* @returns Resolved URL or, if the provided link field or document is empty,
|
|
77
78
|
* `null`
|
|
79
|
+
*
|
|
78
80
|
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
|
|
79
81
|
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
80
82
|
*/
|
|
@@ -95,10 +97,6 @@ export const asLink: {
|
|
|
95
97
|
*
|
|
96
98
|
* @deprecated Use object-style configuration instead.
|
|
97
99
|
*
|
|
98
|
-
* ```ts
|
|
99
|
-
* asLink(field);
|
|
100
|
-
* asLink(field, { linkResolver });
|
|
101
|
-
* ```
|
|
102
100
|
* @typeParam LinkResolverFunctionReturnType - link resolver function return
|
|
103
101
|
* type
|
|
104
102
|
* @typeParam Field - Link field or Prismic document to resolve to a URL
|
|
@@ -110,6 +108,7 @@ export const asLink: {
|
|
|
110
108
|
*
|
|
111
109
|
* @returns Resolved URL or, if the provided link field or document is empty,
|
|
112
110
|
* `null`
|
|
111
|
+
*
|
|
113
112
|
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
|
|
114
113
|
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
115
114
|
*/
|
|
@@ -77,11 +77,13 @@ type AsLinkAttrsReturnType<
|
|
|
77
77
|
* type
|
|
78
78
|
* @typeParam Field - Link field or Prismic document to resolve to link
|
|
79
79
|
* attributes
|
|
80
|
+
*
|
|
80
81
|
* @param linkFieldOrDocument - Any kind of link field or a document to resolve
|
|
81
82
|
* @param config - Configuration that determines the output of `asLinkAttrs()`
|
|
82
83
|
*
|
|
83
84
|
* @returns Resolved set of link attributes or, if the provided link field or
|
|
84
85
|
* document is empty, and empty object
|
|
86
|
+
*
|
|
85
87
|
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/route-resolver#link-resolver}
|
|
86
88
|
* @see Prismic API `routes` options documentation: {@link https://prismic.io/docs/route-resolver}
|
|
87
89
|
*/
|
package/src/helpers/asText.ts
CHANGED
|
@@ -47,10 +47,6 @@ export const asText: {
|
|
|
47
47
|
*
|
|
48
48
|
* @deprecated Use object-style configuration instead.
|
|
49
49
|
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* asText(field);
|
|
52
|
-
* asText(field, { separator });
|
|
53
|
-
* ```
|
|
54
50
|
* @param richTextField - A rich text or title field from Prismic
|
|
55
51
|
* @param separator - Separator used to join each element, defaults to a space
|
|
56
52
|
*
|
|
@@ -18,17 +18,28 @@ type MaybeLazyModule<T> = T | LazyModule<T>;
|
|
|
18
18
|
*/
|
|
19
19
|
type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice
|
|
20
20
|
? TSlice["slice_type"]
|
|
21
|
-
: TSlice extends
|
|
21
|
+
: TSlice extends SliceLikeGraphQL
|
|
22
22
|
? TSlice["type"]
|
|
23
23
|
: never;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
27
|
+
* Rest API V2 for the `unstable_mapSliceZone()` helper.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam SliceType - Type name of the Slice.
|
|
30
|
+
*/
|
|
31
|
+
type SliceLikeRestV2<TSliceType extends string = string> = Pick<
|
|
32
|
+
Slice<TSliceType>,
|
|
33
|
+
"id" | "slice_type"
|
|
34
|
+
>;
|
|
35
|
+
|
|
25
36
|
/**
|
|
26
37
|
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
27
38
|
* GraphQL API for the `unstable_mapSliceZone()` helper.
|
|
28
39
|
*
|
|
29
40
|
* @typeParam SliceType - Type name of the Slice.
|
|
30
41
|
*/
|
|
31
|
-
type
|
|
42
|
+
type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
32
43
|
type: Slice<TSliceType>["slice_type"];
|
|
33
44
|
};
|
|
34
45
|
|
|
@@ -42,8 +53,8 @@ type SliceGraphQLLike<TSliceType extends string = string> = {
|
|
|
42
53
|
* @typeParam SliceType - Type name of the Slice.
|
|
43
54
|
*/
|
|
44
55
|
type SliceLike<TSliceType extends string = string> =
|
|
45
|
-
|
|
|
46
|
-
|
|
|
56
|
+
| SliceLikeRestV2<TSliceType>
|
|
57
|
+
| SliceLikeGraphQL<TSliceType>;
|
|
47
58
|
|
|
48
59
|
/**
|
|
49
60
|
* A looser version of the `SliceZone` type from `@prismicio/client` using
|
|
@@ -101,7 +112,7 @@ type SliceMapperArgs<
|
|
|
101
112
|
// union of Slice types, it would include TSlice. This causes TypeScript to
|
|
102
113
|
// throw a compilation error.
|
|
103
114
|
slices: SliceZoneLike<
|
|
104
|
-
TSlice extends
|
|
115
|
+
TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2
|
|
105
116
|
>;
|
|
106
117
|
|
|
107
118
|
/**
|
|
@@ -171,7 +182,7 @@ type MapSliceLike<
|
|
|
171
182
|
TMappers extends Mappers,
|
|
172
183
|
> = TSliceLike extends Slice
|
|
173
184
|
? TSliceLike["slice_type"] extends keyof TMappers
|
|
174
|
-
?
|
|
185
|
+
? SliceLikeRestV2<TSliceLike["slice_type"]> &
|
|
175
186
|
MappedSliceLike &
|
|
176
187
|
Awaited<
|
|
177
188
|
ReturnType<
|
|
@@ -179,9 +190,9 @@ type MapSliceLike<
|
|
|
179
190
|
>
|
|
180
191
|
>
|
|
181
192
|
: TSliceLike
|
|
182
|
-
: TSliceLike extends
|
|
193
|
+
: TSliceLike extends SliceLikeGraphQL
|
|
183
194
|
? TSliceLike["type"] extends keyof TMappers
|
|
184
|
-
?
|
|
195
|
+
? SliceLikeGraphQL<TSliceLike["type"]> &
|
|
185
196
|
MappedSliceLike &
|
|
186
197
|
Awaited<
|
|
187
198
|
ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["type"]]>>
|
|
@@ -34,7 +34,9 @@ export interface Repository {
|
|
|
34
34
|
types: Record<string, string>;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* @deprecated Tags are only available in the forms object.
|
|
38
|
+
*
|
|
39
|
+
* @see More details in the blog post "A change to how the Prismic API handles tags": {@link https://prismic.io/blog/a-change-to-how-the-prismic-api-handles-tags}
|
|
38
40
|
*/
|
|
39
41
|
tags: string[];
|
|
40
42
|
|
|
@@ -50,7 +52,9 @@ export interface Repository {
|
|
|
50
52
|
*/
|
|
51
53
|
oauth_initiate: string;
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The token used for the OAuth process for the repository.
|
|
57
|
+
*/
|
|
54
58
|
oauth_token: string;
|
|
55
59
|
|
|
56
60
|
/**
|