@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.
Files changed (66) hide show
  1. package/dist/buildQueryURL.cjs.map +1 -1
  2. package/dist/buildQueryURL.d.ts +1 -0
  3. package/dist/buildQueryURL.js.map +1 -1
  4. package/dist/createClient.cjs +8 -1
  5. package/dist/createClient.cjs.map +1 -1
  6. package/dist/createClient.d.ts +8 -0
  7. package/dist/createClient.js +8 -1
  8. package/dist/createClient.js.map +1 -1
  9. package/dist/filter.cjs.map +1 -1
  10. package/dist/filter.js.map +1 -1
  11. package/dist/getGraphQLEndpoint.cjs.map +1 -1
  12. package/dist/getGraphQLEndpoint.js.map +1 -1
  13. package/dist/getRepositoryEndpoint.cjs.map +1 -1
  14. package/dist/getRepositoryEndpoint.js.map +1 -1
  15. package/dist/getRepositoryName.cjs.map +1 -1
  16. package/dist/getRepositoryName.d.ts +1 -0
  17. package/dist/getRepositoryName.js.map +1 -1
  18. package/dist/getToolbarSrc.cjs.map +1 -1
  19. package/dist/getToolbarSrc.js.map +1 -1
  20. package/dist/helpers/asHTML.cjs.map +1 -1
  21. package/dist/helpers/asHTML.d.ts +0 -6
  22. package/dist/helpers/asHTML.js.map +1 -1
  23. package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  24. package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -1
  25. package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  26. package/dist/helpers/asImageSrc.cjs.map +1 -1
  27. package/dist/helpers/asImageSrc.d.ts +2 -1
  28. package/dist/helpers/asImageSrc.js.map +1 -1
  29. package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  30. package/dist/helpers/asImageWidthSrcSet.d.ts +2 -1
  31. package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  32. package/dist/helpers/asLink.cjs.map +1 -1
  33. package/dist/helpers/asLink.d.ts +3 -4
  34. package/dist/helpers/asLink.js.map +1 -1
  35. package/dist/helpers/asLinkAttrs.cjs.map +1 -1
  36. package/dist/helpers/asLinkAttrs.d.ts +3 -1
  37. package/dist/helpers/asLinkAttrs.js.map +1 -1
  38. package/dist/helpers/asText.cjs.map +1 -1
  39. package/dist/helpers/asText.d.ts +0 -4
  40. package/dist/helpers/asText.js.map +1 -1
  41. package/dist/helpers/isFilled.d.ts +13 -10
  42. package/dist/helpers/unstable_mapSliceZone.cjs.map +1 -1
  43. package/dist/helpers/unstable_mapSliceZone.d.ts +12 -5
  44. package/dist/helpers/unstable_mapSliceZone.js.map +1 -1
  45. package/dist/isRepositoryEndpoint.cjs.map +1 -1
  46. package/dist/isRepositoryEndpoint.js.map +1 -1
  47. package/dist/lib/devMsg.cjs.map +1 -1
  48. package/dist/lib/devMsg.js.map +1 -1
  49. package/dist/lib/serializerHelpers.cjs.map +1 -1
  50. package/dist/lib/serializerHelpers.js.map +1 -1
  51. package/dist/package.json.cjs +1 -1
  52. package/dist/package.json.js +1 -1
  53. package/dist/types/api/repository.d.ts +6 -1
  54. package/package.json +20 -20
  55. package/src/buildQueryURL.ts +1 -0
  56. package/src/createClient.ts +9 -1
  57. package/src/getRepositoryName.ts +1 -0
  58. package/src/helpers/asHTML.ts +0 -6
  59. package/src/helpers/asImagePixelDensitySrcSet.ts +1 -0
  60. package/src/helpers/asImageSrc.ts +1 -0
  61. package/src/helpers/asImageWidthSrcSet.ts +1 -0
  62. package/src/helpers/asLink.ts +3 -4
  63. package/src/helpers/asLinkAttrs.ts +2 -0
  64. package/src/helpers/asText.ts +0 -4
  65. package/src/helpers/unstable_mapSliceZone.ts +19 -8
  66. 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.0",
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.3"
63
+ "imgix-url-builder": "^0.0.4"
64
64
  },
65
65
  "devDependencies": {
66
- "@prismicio/mock": "^0.3.0",
67
- "@prismicio/types-internal": "2.0.0-alpha.11",
68
- "@size-limit/preset-small-lib": "^8.2.4",
69
- "@trivago/prettier-plugin-sort-imports": "^4.1.1",
70
- "@typescript-eslint/eslint-plugin": "^5.59.0",
71
- "@typescript-eslint/parser": "^5.59.0",
72
- "@vitest/coverage-c8": "^0.30.1",
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.38.0",
75
- "eslint-config-prettier": "^8.8.0",
76
- "eslint-plugin-prettier": "^4.2.1",
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.1",
79
- "node-fetch": "^3.3.1",
80
- "prettier": "^2.8.7",
81
- "prettier-plugin-jsdoc": "^0.4.2",
82
- "size-limit": "^8.2.4",
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": "^5.0.4",
86
- "vite": "^4.3.1",
85
+ "typescript": "^4.9.5",
86
+ "vite": "^4.4.9",
87
87
  "vite-plugin-sdk": "^0.1.1",
88
- "vitest": "^0.30.1"
88
+ "vitest": "^0.34.1"
89
89
  },
90
90
  "engines": {
91
91
  "node": ">=14.15.0"
@@ -160,6 +160,7 @@ export interface QueryParams {
160
160
  * Strings and arrays of strings are deprecated as of
161
161
  * `@prismicio/client@7.0.0`. Please migrate to the more explicit array of
162
162
  * objects.
163
+ *
163
164
  * @example
164
165
  *
165
166
  * ```typescript
@@ -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 PrismicError("No documents were returned", url, undefined);
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
@@ -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.
@@ -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 = <
@@ -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
  */
@@ -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 SliceGraphQLLike
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 SliceGraphQLLike<TSliceType extends string = string> = {
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
- | Slice<TSliceType>
46
- | SliceGraphQLLike<TSliceType>;
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 SliceGraphQLLike ? SliceGraphQLLike : Slice
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
- ? Slice<TSliceLike["slice_type"]> &
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 SliceGraphQLLike
193
+ : TSliceLike extends SliceLikeGraphQL
183
194
  ? TSliceLike["type"] extends keyof TMappers
184
- ? SliceGraphQLLike<TSliceLike["type"]> &
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
- * A list of tags for the repository.
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
- // TODO: Describe this field
55
+ /**
56
+ * The token used for the OAuth process for the repository.
57
+ */
54
58
  oauth_token: string;
55
59
 
56
60
  /**