@prismicio/client 7.3.0 → 7.4.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 (34) hide show
  1. package/dist/createClient.cjs +10 -2
  2. package/dist/createClient.cjs.map +1 -1
  3. package/dist/createClient.js +10 -2
  4. package/dist/createClient.js.map +1 -1
  5. package/dist/errors/PreviewTokenExpired.cjs +7 -0
  6. package/dist/errors/PreviewTokenExpired.cjs.map +1 -0
  7. package/dist/errors/PreviewTokenExpired.d.ts +8 -0
  8. package/dist/errors/PreviewTokenExpired.js +7 -0
  9. package/dist/errors/PreviewTokenExpired.js.map +1 -0
  10. package/dist/errors/RepositoryNotFoundError.cjs +7 -0
  11. package/dist/errors/RepositoryNotFoundError.cjs.map +1 -0
  12. package/dist/errors/RepositoryNotFoundError.d.ts +3 -0
  13. package/dist/errors/RepositoryNotFoundError.js +7 -0
  14. package/dist/errors/RepositoryNotFoundError.js.map +1 -0
  15. package/dist/helpers/{unstable_mapSliceZone.cjs → mapSliceZone.cjs} +7 -4
  16. package/dist/helpers/mapSliceZone.cjs.map +1 -0
  17. package/dist/helpers/{unstable_mapSliceZone.d.ts → mapSliceZone.d.ts} +17 -23
  18. package/dist/helpers/{unstable_mapSliceZone.js → mapSliceZone.js} +7 -4
  19. package/dist/helpers/mapSliceZone.js.map +1 -0
  20. package/dist/index.cjs +8 -2
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +9 -1
  23. package/dist/index.js +7 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/package.json.cjs +1 -1
  26. package/dist/package.json.js +1 -1
  27. package/package.json +1 -1
  28. package/src/createClient.ts +20 -6
  29. package/src/errors/PreviewTokenExpired.ts +12 -0
  30. package/src/errors/RepositoryNotFoundError.ts +5 -0
  31. package/src/helpers/{unstable_mapSliceZone.ts → mapSliceZone.ts} +70 -57
  32. package/src/index.ts +10 -1
  33. package/dist/helpers/unstable_mapSliceZone.cjs.map +0 -1
  34. package/dist/helpers/unstable_mapSliceZone.js.map +0 -1
@@ -10,6 +10,7 @@ type LazyModule<T> = () => Promise<T | {
10
10
  * Mark a type as potentially lazy-loaded via a module.
11
11
  */
12
12
  type MaybeLazyModule<T> = T | LazyModule<T>;
13
+ type AnyFunction = (...args: any[]) => any;
13
14
  /**
14
15
  * Returns the type of a `SliceLike` type.
15
16
  *
@@ -18,14 +19,14 @@ type MaybeLazyModule<T> = T | LazyModule<T>;
18
19
  type ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
19
20
  /**
20
21
  * The minimum required properties to represent a Prismic Slice from the Prismic
21
- * Rest API V2 for the `unstable_mapSliceZone()` helper.
22
+ * Rest API V2 for the `mapSliceZone()` helper.
22
23
  *
23
24
  * @typeParam SliceType - Type name of the Slice.
24
25
  */
25
26
  type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
26
27
  /**
27
28
  * The minimum required properties to represent a Prismic Slice from the Prismic
28
- * GraphQL API for the `unstable_mapSliceZone()` helper.
29
+ * GraphQL API for the `mapSliceZone()` helper.
29
30
  *
30
31
  * @typeParam SliceType - Type name of the Slice.
31
32
  */
@@ -34,7 +35,7 @@ type SliceLikeGraphQL<TSliceType extends string = string> = {
34
35
  };
35
36
  /**
36
37
  * The minimum required properties to represent a Prismic Slice for the
37
- * `unstable_mapSliceZone()` helper.
38
+ * `mapSliceZone()` helper.
38
39
  *
39
40
  * If using Prismic's Rest API V2, use the `Slice` export from
40
41
  * `@prismicio/client` for a full interface.
@@ -68,11 +69,11 @@ type MappedSliceLike = {
68
69
  };
69
70
  /**
70
71
  * Arguments for a function mapping content from a Prismic Slice using the
71
- * `unstable_mapSliceZone()` helper.
72
+ * `mapSliceZone()` helper.
72
73
  *
73
74
  * @typeParam TSlice - The Slice passed as a prop.
74
- * @typeParam TContext - Arbitrary data passed to `unstable_mapSliceZone()` and
75
- * made available to all Slice mappers.
75
+ * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made
76
+ * available to all Slice mappers.
76
77
  */
77
78
  type SliceMapperArgs<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
78
79
  /**
@@ -88,36 +89,32 @@ type SliceMapperArgs<TSlice extends SliceLike = SliceLike, TContext = unknown> =
88
89
  */
89
90
  slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
90
91
  /**
91
- * Arbitrary data passed to `unstable_mapSliceZone()` and made available to
92
- * all Slice mappers.
92
+ * Arbitrary data passed to `mapSliceZone()` and made available to all Slice
93
+ * mappers.
93
94
  */
94
95
  context: TContext;
95
96
  };
96
97
  /**
97
98
  * A record of mappers.
98
99
  */
99
- export type Mappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
100
- [P in ExtractSliceType<TSlice>]: MaybeLazyModule<Mapper<Extract<TSlice, SliceLike<P>>, any, TContext>>;
100
+ type SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
101
+ [P in ExtractSliceType<TSlice>]?: MaybeLazyModule<SliceMapper<Extract<TSlice, SliceLike<P>>, any, TContext>>;
101
102
  };
102
103
  /**
103
104
  * A function that maps a Slice and its metadata to a modified version. The
104
105
  * return value will replace the Slice in the Slice Zone.
105
106
  */
106
- export type Mapper<TSlice extends SliceLike = SliceLike, TMappedSlice extends Record<string, unknown> | undefined | void = Record<string, unknown> | undefined | void, TContext = unknown> = (args: MapperArgs<TSlice, TContext>) => TMappedSlice | Promise<TMappedSlice>;
107
- /**
108
- * Arguments provided to a mapper function.
109
- */
110
- export type MapperArgs<TSlice extends SliceLike = SliceLike, TContext = unknown> = SliceMapperArgs<TSlice, TContext>;
107
+ export type SliceMapper<TSlice extends SliceLike = SliceLike, TMappedSlice extends Record<string, unknown> | undefined | void = Record<string, unknown> | undefined | void, TContext = unknown> = (args: SliceMapperArgs<TSlice, TContext>) => TMappedSlice | Promise<TMappedSlice>;
111
108
  /**
112
109
  * Unwraps a lazily loaded mapper module.
113
110
  */
114
- type ResolveLazyMapperModule<TMapper extends Mapper | LazyModule<Mapper>> = TMapper extends LazyModule<Mapper> ? Awaited<ReturnType<TMapper>> extends {
111
+ type ResolveLazySliceMapperModule<TSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>> = TSliceMapper extends LazyModule<SliceMapper> ? Awaited<ReturnType<TSliceMapper>> extends {
115
112
  default: unknown;
116
- } ? Awaited<ReturnType<TMapper>>["default"] : Awaited<ReturnType<TMapper>> : TMapper;
113
+ } ? Awaited<ReturnType<TSliceMapper>>["default"] : Awaited<ReturnType<TSliceMapper>> : TSliceMapper;
117
114
  /**
118
115
  * Transforms a Slice into its mapped version.
119
116
  */
120
- type MapSliceLike<TSliceLike extends SliceLike, TMappers extends Mappers> = TSliceLike extends Slice ? TSliceLike["slice_type"] extends keyof TMappers ? SliceLikeRestV2<TSliceLike["slice_type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["slice_type"]]>>> : TSliceLike : TSliceLike extends SliceLikeGraphQL ? TSliceLike["type"] extends keyof TMappers ? SliceLikeGraphQL<TSliceLike["type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazyMapperModule<TMappers[TSliceLike["type"]]>>> : TSliceLike : never;
117
+ type MapSliceLike<TSliceLike extends SliceLike<any>, TSliceMappers extends SliceMappers<SliceLike<ExtractSliceType<TSliceLike>>, any>> = TSliceLike extends Slice ? TSliceLike["slice_type"] extends keyof TSliceMappers ? TSliceMappers[TSliceLike["slice_type"]] extends AnyFunction ? SliceLikeRestV2<TSliceLike["slice_type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazySliceMapperModule<TSliceMappers[TSliceLike["slice_type"]]>>> : TSliceLike : TSliceLike : TSliceLike extends SliceLikeGraphQL ? TSliceLike["type"] extends keyof TSliceMappers ? TSliceMappers[TSliceLike["type"]] extends AnyFunction ? SliceLikeGraphQL<TSliceLike["type"]> & MappedSliceLike & Awaited<ReturnType<ResolveLazySliceMapperModule<TSliceMappers[TSliceLike["type"]]>>> : TSliceLike : TSliceLike : never;
121
118
  /**
122
119
  * Transforms a Slice Zone using a set of mapping functions, one for each type
123
120
  * of Slice. Mapping functions can be async.
@@ -128,15 +125,12 @@ type MapSliceLike<TSliceLike extends SliceLike, TMappers extends Mappers> = TSli
128
125
  * @example
129
126
  *
130
127
  * ```typescript
131
- * const mappedSliceZone = await unstable_mapSliceZone(page.data.slices, {
128
+ * const mappedSliceZone = await mapSliceZone(page.data.slices, {
132
129
  * code_block: ({ slice }) => ({
133
130
  * codeHTML: await highlight(slice.primary.code),
134
131
  * }),
135
132
  * });
136
133
  * ```
137
- *
138
- * @experimental Names and implementations may change in the future.
139
- * `unstable_mapSliceZone()` does not follow SemVer.
140
134
  */
141
- export declare function unstable_mapSliceZone<TSliceLike extends SliceLike, TMappers extends Mappers, TContext = unknown>(sliceZone: SliceZoneLike<TSliceLike>, mappers: TMappers, context?: TContext): Promise<MapSliceLike<TSliceLike, TMappers>[]>;
135
+ export declare function mapSliceZone<TSliceLike extends SliceLike, TSliceMappers extends SliceMappers<TSliceLike, TContext>, TContext = unknown>(sliceZone: SliceZoneLike<TSliceLike>, mappers: TSliceMappers, context?: TContext): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]>;
142
136
  export {};
@@ -1,4 +1,4 @@
1
- function unstable_mapSliceZone(sliceZone, mappers, context) {
1
+ function mapSliceZone(sliceZone, mappers, context) {
2
2
  return Promise.all(sliceZone.map(async (slice, index, slices) => {
3
3
  const isRestSliceType = "slice_type" in slice;
4
4
  const sliceType = isRestSliceType ? slice.slice_type : slice.type;
@@ -7,7 +7,10 @@ function unstable_mapSliceZone(sliceZone, mappers, context) {
7
7
  return slice;
8
8
  }
9
9
  const mapperArgs = { slice, slices, index, context };
10
- let result = await mapper(mapperArgs);
10
+ let result = await mapper(
11
+ // @ts-expect-error - I don't know how to fix this type
12
+ mapperArgs
13
+ );
11
14
  if (
12
15
  // `mapper.length < 1` ensures the given
13
16
  // function is something of the form:
@@ -34,6 +37,6 @@ function unstable_mapSliceZone(sliceZone, mappers, context) {
34
37
  }));
35
38
  }
36
39
  export {
37
- unstable_mapSliceZone
40
+ mapSliceZone
38
41
  };
39
- //# sourceMappingURL=unstable_mapSliceZone.js.map
42
+ //# sourceMappingURL=mapSliceZone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapSliceZone.js","sources":["../../../src/helpers/mapSliceZone.ts"],"sourcesContent":["import { Slice } from \"../types/value/slice\";\n\n/**\n * Convert a value to a lazyily loaded module. This is useful when using\n * functions like `() => import(\"...\")`.\n */\ntype LazyModule<T> = () => Promise<T | { default: T }>;\n\n/**\n * Mark a type as potentially lazy-loaded via a module.\n */\ntype MaybeLazyModule<T> = T | LazyModule<T>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => any;\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\ntype SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\ntype SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];\n\n/**\n * A set of properties that identify a Slice as having been mapped. Consumers of\n * the mapped Slice Zone can use these properties to detect and specially handle\n * mapped Slices.\n */\ntype MappedSliceLike = {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper.\n\t *\n\t * @internal\n\t */\n\t__mapped: true;\n};\n\n/**\n * Arguments for a function mapping content from a Prismic Slice using the\n * `mapSliceZone()` helper.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `mapSliceZone()` and made\n * available to all Slice mappers.\n */\ntype SliceMapperArgs<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `mapSliceZone()` and made available to all Slice\n\t * mappers.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A record of mappers.\n */\ntype SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {\n\t[P in ExtractSliceType<TSlice>]?: MaybeLazyModule<\n\t\tSliceMapper<\n\t\t\tExtract<TSlice, SliceLike<P>>,\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\tany,\n\t\t\tTContext\n\t\t>\n\t>;\n};\n\n/**\n * A function that maps a Slice and its metadata to a modified version. The\n * return value will replace the Slice in the Slice Zone.\n */\nexport type SliceMapper<\n\tTSlice extends SliceLike = SliceLike,\n\tTMappedSlice extends Record<string, unknown> | undefined | void =\n\t\t| Record<string, unknown>\n\t\t| undefined\n\t\t| void,\n\tTContext = unknown,\n> = (\n\targs: SliceMapperArgs<TSlice, TContext>,\n) => TMappedSlice | Promise<TMappedSlice>;\n\n/**\n * Unwraps a lazily loaded mapper module.\n */\ntype ResolveLazySliceMapperModule<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceMapper extends SliceMapper<any, any> | LazyModule<SliceMapper>,\n> = TSliceMapper extends LazyModule<SliceMapper>\n\t? Awaited<ReturnType<TSliceMapper>> extends {\n\t\t\tdefault: unknown;\n\t }\n\t\t? Awaited<ReturnType<TSliceMapper>>[\"default\"]\n\t\t: Awaited<ReturnType<TSliceMapper>>\n\t: TSliceMapper;\n\n/**\n * Transforms a Slice into its mapped version.\n */\ntype MapSliceLike<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSliceLike extends SliceLike<any>,\n\tTSliceMappers extends SliceMappers<\n\t\tSliceLike<ExtractSliceType<TSliceLike>>,\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tany\n\t>,\n> = TSliceLike extends Slice\n\t? TSliceLike[\"slice_type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"slice_type\"]] extends AnyFunction\n\t\t\t? SliceLikeRestV2<TSliceLike[\"slice_type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<\n\t\t\t\t\t\t\t\tTSliceMappers[TSliceLike[\"slice_type\"]]\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: TSliceLike extends SliceLikeGraphQL\n\t? TSliceLike[\"type\"] extends keyof TSliceMappers\n\t\t? TSliceMappers[TSliceLike[\"type\"]] extends AnyFunction\n\t\t\t? SliceLikeGraphQL<TSliceLike[\"type\"]> &\n\t\t\t\t\tMappedSliceLike &\n\t\t\t\t\tAwaited<\n\t\t\t\t\t\tReturnType<\n\t\t\t\t\t\t\tResolveLazySliceMapperModule<TSliceMappers[TSliceLike[\"type\"]]>\n\t\t\t\t\t\t>\n\t\t\t\t\t>\n\t\t\t: TSliceLike\n\t\t: TSliceLike\n\t: never;\n\n/**\n * Transforms a Slice Zone using a set of mapping functions, one for each type\n * of Slice. Mapping functions can be async.\n *\n * Whenever possible, use this function on the server to minimize client-side\n * processing.\n *\n * @example\n *\n * ```typescript\n * const mappedSliceZone = await mapSliceZone(page.data.slices, {\n * \tcode_block: ({ slice }) => ({\n * \t\tcodeHTML: await highlight(slice.primary.code),\n * \t}),\n * });\n * ```\n */\nexport function mapSliceZone<\n\tTSliceLike extends SliceLike,\n\tTSliceMappers extends SliceMappers<TSliceLike, TContext>,\n\tTContext = unknown,\n>(\n\tsliceZone: SliceZoneLike<TSliceLike>,\n\tmappers: TSliceMappers,\n\tcontext?: TContext,\n): Promise<\n\tMapSliceLike<\n\t\tTSliceLike,\n\t\t// @ts-expect-error - I don't know how to fix this type\n\t\tTSliceMappers\n\t>[]\n> {\n\treturn Promise.all(\n\t\tsliceZone.map(async (slice, index, slices) => {\n\t\t\tconst isRestSliceType = \"slice_type\" in slice;\n\t\t\tconst sliceType = isRestSliceType ? slice.slice_type : slice.type;\n\n\t\t\tconst mapper = mappers[sliceType as keyof typeof mappers];\n\n\t\t\tif (!mapper) {\n\t\t\t\treturn slice;\n\t\t\t}\n\n\t\t\tconst mapperArgs = { slice, slices, index, context };\n\n\t\t\t// `result` may be a mapper function OR a module\n\t\t\t// containing a mapper function.\n\t\t\tlet result = await mapper(\n\t\t\t\t// @ts-expect-error - I don't know how to fix this type\n\t\t\t\tmapperArgs,\n\t\t\t);\n\n\t\t\t// `result` is a module containing a mapper function,\n\t\t\t// we need to dig out the mapper function. `result`\n\t\t\t// will be reassigned with the mapper function's value.\n\t\t\tif (\n\t\t\t\t// `mapper.length < 1` ensures the given\n\t\t\t\t// function is something of the form:\n\t\t\t\t// `() => import(...)`\n\t\t\t\tmapper.length < 1 &&\n\t\t\t\t(typeof result === \"function\" ||\n\t\t\t\t\t(typeof result === \"object\" && \"default\" in result))\n\t\t\t) {\n\t\t\t\tresult = \"default\" in result ? result.default : result;\n\t\t\t\tresult = await result(mapperArgs);\n\t\t\t}\n\n\t\t\tif (isRestSliceType) {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\tid: slice.id,\n\t\t\t\t\tslice_type: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\treturn {\n\t\t\t\t\t__mapped: true,\n\t\t\t\t\ttype: sliceType,\n\t\t\t\t\t...result,\n\t\t\t\t};\n\t\t\t}\n\t\t}),\n\t);\n}\n"],"names":[],"mappings":"AAkOgB,SAAA,aAKf,WACA,SACA,SAAkB;AAQlB,SAAO,QAAQ,IACd,UAAU,IAAI,OAAO,OAAO,OAAO,WAAU;AAC5C,UAAM,kBAAkB,gBAAgB;AACxC,UAAM,YAAY,kBAAkB,MAAM,aAAa,MAAM;AAEvD,UAAA,SAAS,QAAQ,SAAiC;AAExD,QAAI,CAAC,QAAQ;AACL,aAAA;AAAA,IACP;AAED,UAAM,aAAa,EAAE,OAAO,QAAQ,OAAO,QAAO;AAIlD,QAAI,SAAS,MAAM;AAAA;AAAA,MAElB;AAAA,IAAA;AAMD;AAAA;AAAA;AAAA;AAAA,MAIC,OAAO,SAAS,MACf,OAAO,WAAW,cACjB,OAAO,WAAW,YAAY,aAAa;AAAA,MAC5C;AACQ,eAAA,aAAa,SAAS,OAAO,UAAU;AACvC,eAAA,MAAM,OAAO,UAAU;AAAA,IAChC;AAED,QAAI,iBAAiB;AACb,aAAA;AAAA,QACN,UAAU;AAAA,QACV,IAAI,MAAM;AAAA,QACV,YAAY;AAAA,QACZ,GAAG;AAAA,MAAA;AAAA,WAEE;AACC,aAAA;AAAA,QACN,UAAU;AAAA,QACV,MAAM;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEJ;AAAA,EACD,CAAA,CAAC;AAEJ;"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const richText = require("./types/value/richText.cjs");
4
+ const mapSliceZone = require("./helpers/mapSliceZone.cjs");
4
5
  const filter = require("./filter.cjs");
5
6
  const createClient = require("./createClient.cjs");
6
7
  const getRepositoryEndpoint = require("./getRepositoryEndpoint.cjs");
@@ -19,7 +20,6 @@ const asHTML = require("./helpers/asHTML.cjs");
19
20
  const asImageSrc = require("./helpers/asImageSrc.cjs");
20
21
  const asImageWidthSrcSet = require("./helpers/asImageWidthSrcSet.cjs");
21
22
  const asImagePixelDensitySrcSet = require("./helpers/asImagePixelDensitySrcSet.cjs");
22
- const unstable_mapSliceZone = require("./helpers/unstable_mapSliceZone.cjs");
23
23
  const isFilled = require("./helpers/isFilled.cjs");
24
24
  const documentToLinkField = require("./helpers/documentToLinkField.cjs");
25
25
  const PrismicError = require("./errors/PrismicError.cjs");
@@ -27,7 +27,9 @@ const ForbiddenError = require("./errors/ForbiddenError.cjs");
27
27
  const NotFoundError = require("./errors/NotFoundError.cjs");
28
28
  const RefNotFoundError = require("./errors/RefNotFoundError.cjs");
29
29
  const RefExpiredError = require("./errors/RefExpiredError.cjs");
30
+ const PreviewTokenExpired = require("./errors/PreviewTokenExpired.cjs");
30
31
  const ParsingError = require("./errors/ParsingError.cjs");
32
+ const RepositoryNotFoundError = require("./errors/RepositoryNotFoundError.cjs");
31
33
  const link = require("./types/value/link.cjs");
32
34
  const embed = require("./types/value/embed.cjs");
33
35
  const types = require("./types/model/types.cjs");
@@ -36,8 +38,10 @@ const sliceZone = require("./types/model/sliceZone.cjs");
36
38
  const slice = require("./types/model/slice.cjs");
37
39
  const types$1 = require("./types/webhook/types.cjs");
38
40
  const predicate = filter.filter;
41
+ const unstable_mapSliceZone = mapSliceZone.mapSliceZone;
39
42
  const Element = richText.RichTextNodeType;
40
43
  exports.RichTextNodeType = richText.RichTextNodeType;
44
+ exports.mapSliceZone = mapSliceZone.mapSliceZone;
41
45
  exports.filter = filter.filter;
42
46
  exports.Client = createClient.Client;
43
47
  exports.createClient = createClient.createClient;
@@ -57,7 +61,6 @@ exports.asHTML = asHTML.asHTML;
57
61
  exports.asImageSrc = asImageSrc.asImageSrc;
58
62
  exports.asImageWidthSrcSet = asImageWidthSrcSet.asImageWidthSrcSet;
59
63
  exports.asImagePixelDensitySrcSet = asImagePixelDensitySrcSet.asImagePixelDensitySrcSet;
60
- exports.unstable_mapSliceZone = unstable_mapSliceZone.unstable_mapSliceZone;
61
64
  exports.isFilled = isFilled;
62
65
  exports.documentToLinkField = documentToLinkField.documentToLinkField;
63
66
  exports.PrismicError = PrismicError.PrismicError;
@@ -65,7 +68,9 @@ exports.ForbiddenError = ForbiddenError.ForbiddenError;
65
68
  exports.NotFoundError = NotFoundError.NotFoundError;
66
69
  exports.RefNotFoundError = RefNotFoundError.RefNotFoundError;
67
70
  exports.RefExpiredError = RefExpiredError.RefExpiredError;
71
+ exports.PreviewTokenExpiredError = PreviewTokenExpired.PreviewTokenExpiredError;
68
72
  exports.ParsingError = ParsingError.ParsingError;
73
+ exports.RepositoryNotFoundError = RepositoryNotFoundError.RepositoryNotFoundError;
69
74
  exports.LinkType = link.LinkType;
70
75
  exports.OEmbedType = embed.OEmbedType;
71
76
  exports.CustomTypeModelFieldType = types.CustomTypeModelFieldType;
@@ -75,4 +80,5 @@ exports.CustomTypeModelSliceDisplay = slice.CustomTypeModelSliceDisplay;
75
80
  exports.WebhookType = types$1.WebhookType;
76
81
  exports.Element = Element;
77
82
  exports.predicate = predicate;
83
+ exports.unstable_mapSliceZone = unstable_mapSliceZone;
78
84
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\";\nimport type { IntegrationField } from \"./types/value/integration\";\nimport { RichTextNodeType } from \"./types/value/richText\";\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\";\n\nimport { filter } from \"./filter\";\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient, Client } from \"./createClient\";\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\";\nexport { getRepositoryName } from \"./getRepositoryName\";\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\";\nexport { isRepositoryName } from \"./isRepositoryName\";\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\";\nexport { buildQueryURL } from \"./buildQueryURL\";\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\";\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter;\nexport { filter, predicate };\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\";\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type {\n\tAbortSignalLike,\n\tClientConfig,\n\tCreateClient,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./createClient\";\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\";\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\";\nexport { asLink } from \"./helpers/asLink\";\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\";\nexport { asText } from \"./helpers/asText\";\nexport { asHTML } from \"./helpers/asHTML\";\nexport { asImageSrc } from \"./helpers/asImageSrc\";\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\";\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\";\nexport { unstable_mapSliceZone } from \"./helpers/unstable_mapSliceZone\";\nexport * as isFilled from \"./helpers/isFilled\";\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\";\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\";\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\";\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer;\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer;\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n};\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\";\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\nexport { PrismicError } from \"./errors/PrismicError\";\nexport { ForbiddenError } from \"./errors/ForbiddenError\";\nexport { NotFoundError } from \"./errors/NotFoundError\";\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\";\nexport { RefExpiredError } from \"./errors/RefExpiredError\";\nexport { ParsingError } from \"./errors/ParsingError\";\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType;\nexport { RichTextNodeType, Element };\nexport { LinkType } from \"./types/value/link\";\nexport { OEmbedType } from \"./types/value/embed\";\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\";\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n} from \"./types/value/richText\";\nexport type { TitleField } from \"./types/value/title\";\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\";\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\";\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\";\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\";\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\";\n\nexport type { BooleanField } from \"./types/value/boolean\";\nexport type { ColorField } from \"./types/value/color\";\nexport type { DateField } from \"./types/value/date\";\nexport type { KeyTextField } from \"./types/value/keyText\";\nexport type { NumberField } from \"./types/value/number\";\nexport type { SelectField } from \"./types/value/select\";\nexport type { TimestampField } from \"./types/value/timestamp\";\nexport type { GeoPointField } from \"./types/value/geoPoint\";\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField;\nexport { IntegrationField, IntegrationFields };\n\nexport type { GroupField } from \"./types/value/group\";\n\nexport type { SliceZone } from \"./types/value/sliceZone\";\nexport type { Slice } from \"./types/value/slice\";\nexport type { SharedSlice } from \"./types/value/sharedSlice\";\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\";\n\nexport type { FieldState, AnyRegularField } from \"./types/value/types\";\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\";\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\";\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\";\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\";\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\";\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\";\nexport type { CustomTypeModelTitleField } from \"./types/model/title\";\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\";\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\";\nexport type { CustomTypeModelLinkField } from \"./types/model/link\";\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\";\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\";\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\";\nexport type { CustomTypeModelColorField } from \"./types/model/color\";\nexport type { CustomTypeModelDateField } from \"./types/model/date\";\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\";\nexport type { CustomTypeModelNumberField } from \"./types/model/number\";\nexport type { CustomTypeModelSelectField } from \"./types/model/select\";\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\";\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\";\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField;\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n};\nexport type { CustomTypeModelGroupField } from \"./types/model/group\";\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\";\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\";\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\";\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\";\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\";\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\";\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\";\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n} from \"./types/model/types\";\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\";\n\nexport type { Ref } from \"./types/api/ref\";\n\nexport type { Release } from \"./types/api/release\";\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\";\n\nexport type { Tags } from \"./types/api/tags\";\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\";\n\nexport type { WebhookBody } from \"./types/webhook/types\";\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\";\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\";\n"],"names":["filter","RichTextNodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,YAAYA,OAAA;AAiFlB,MAAM,UAAUC,SAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\";\nimport type { IntegrationField } from \"./types/value/integration\";\nimport { RichTextNodeType } from \"./types/value/richText\";\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\";\nimport { mapSliceZone } from \"./helpers/mapSliceZone\";\n\nimport { filter } from \"./filter\";\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient, Client } from \"./createClient\";\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\";\nexport { getRepositoryName } from \"./getRepositoryName\";\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\";\nexport { isRepositoryName } from \"./isRepositoryName\";\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\";\nexport { buildQueryURL } from \"./buildQueryURL\";\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\";\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter;\nexport { filter, predicate };\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\";\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type {\n\tAbortSignalLike,\n\tClientConfig,\n\tCreateClient,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./createClient\";\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\";\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\";\nexport { asLink } from \"./helpers/asLink\";\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\";\nexport { asText } from \"./helpers/asText\";\nexport { asHTML } from \"./helpers/asHTML\";\nexport { asImageSrc } from \"./helpers/asImageSrc\";\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\";\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\";\nexport * as isFilled from \"./helpers/isFilled\";\n\n/**\n * @deprecated Renamed to `mapSliceZone`\n */\nconst unstable_mapSliceZone = mapSliceZone;\nexport { mapSliceZone, unstable_mapSliceZone };\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\";\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\";\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\";\nexport type { SliceMapper } from \"./helpers/mapSliceZone\";\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer;\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer;\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n};\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\";\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\nexport { PrismicError } from \"./errors/PrismicError\";\nexport { ForbiddenError } from \"./errors/ForbiddenError\";\nexport { NotFoundError } from \"./errors/NotFoundError\";\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\";\nexport { RefExpiredError } from \"./errors/RefExpiredError\";\nexport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\";\nexport { ParsingError } from \"./errors/ParsingError\";\nexport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\";\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType;\nexport { RichTextNodeType, Element };\nexport { LinkType } from \"./types/value/link\";\nexport { OEmbedType } from \"./types/value/embed\";\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\";\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n} from \"./types/value/richText\";\nexport type { TitleField } from \"./types/value/title\";\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\";\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\";\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\";\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\";\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\";\n\nexport type { BooleanField } from \"./types/value/boolean\";\nexport type { ColorField } from \"./types/value/color\";\nexport type { DateField } from \"./types/value/date\";\nexport type { KeyTextField } from \"./types/value/keyText\";\nexport type { NumberField } from \"./types/value/number\";\nexport type { SelectField } from \"./types/value/select\";\nexport type { TimestampField } from \"./types/value/timestamp\";\nexport type { GeoPointField } from \"./types/value/geoPoint\";\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField;\nexport { IntegrationField, IntegrationFields };\n\nexport type { GroupField } from \"./types/value/group\";\n\nexport type { SliceZone } from \"./types/value/sliceZone\";\nexport type { Slice } from \"./types/value/slice\";\nexport type { SharedSlice } from \"./types/value/sharedSlice\";\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\";\n\nexport type { FieldState, AnyRegularField } from \"./types/value/types\";\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\";\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\";\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\";\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\";\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\";\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\";\nexport type { CustomTypeModelTitleField } from \"./types/model/title\";\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\";\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\";\nexport type { CustomTypeModelLinkField } from \"./types/model/link\";\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\";\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\";\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\";\nexport type { CustomTypeModelColorField } from \"./types/model/color\";\nexport type { CustomTypeModelDateField } from \"./types/model/date\";\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\";\nexport type { CustomTypeModelNumberField } from \"./types/model/number\";\nexport type { CustomTypeModelSelectField } from \"./types/model/select\";\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\";\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\";\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField;\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n};\nexport type { CustomTypeModelGroupField } from \"./types/model/group\";\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\";\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\";\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\";\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\";\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\";\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\";\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\";\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n} from \"./types/model/types\";\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\";\n\nexport type { Ref } from \"./types/api/ref\";\n\nexport type { Release } from \"./types/api/release\";\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\";\n\nexport type { Tags } from \"./types/api/tags\";\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\";\n\nexport type { WebhookBody } from \"./types/webhook/types\";\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\";\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\";\n"],"names":["filter","mapSliceZone","RichTextNodeType"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YAAYA,OAAA;AAyClB,MAAM,wBAAwBC,aAAA;AAgD9B,MAAM,UAAUC,SAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { CustomTypeModelIntegrationField } from "./types/model/integration"
2
2
  import type { IntegrationField } from "./types/value/integration";
3
3
  import { RichTextNodeType } from "./types/value/richText";
4
4
  import type { HTMLRichTextFunctionSerializer, HTMLRichTextMapSerializer } from "./helpers/asHTML";
5
+ import { mapSliceZone } from "./helpers/mapSliceZone";
5
6
  import { filter } from "./filter";
6
7
  export { createClient, Client } from "./createClient";
7
8
  export { getRepositoryEndpoint } from "./getRepositoryEndpoint";
@@ -56,11 +57,16 @@ export { asHTML } from "./helpers/asHTML";
56
57
  export { asImageSrc } from "./helpers/asImageSrc";
57
58
  export { asImageWidthSrcSet } from "./helpers/asImageWidthSrcSet";
58
59
  export { asImagePixelDensitySrcSet } from "./helpers/asImagePixelDensitySrcSet";
59
- export { unstable_mapSliceZone } from "./helpers/unstable_mapSliceZone";
60
60
  export * as isFilled from "./helpers/isFilled";
61
+ /**
62
+ * @deprecated Renamed to `mapSliceZone`
63
+ */
64
+ declare const unstable_mapSliceZone: typeof mapSliceZone;
65
+ export { mapSliceZone, unstable_mapSliceZone };
61
66
  export { documentToLinkField } from "./helpers/documentToLinkField";
62
67
  export type { LinkResolverFunction } from "./helpers/asLink";
63
68
  export type { AsLinkAttrsConfig } from "./helpers/asLinkAttrs";
69
+ export type { SliceMapper } from "./helpers/mapSliceZone";
64
70
  /**
65
71
  * @deprecated Renamed to `HTMLRichTextMapSerializer`
66
72
  */
@@ -76,7 +82,9 @@ export { ForbiddenError } from "./errors/ForbiddenError";
76
82
  export { NotFoundError } from "./errors/NotFoundError";
77
83
  export { RefNotFoundError } from "./errors/RefNotFoundError";
78
84
  export { RefExpiredError } from "./errors/RefExpiredError";
85
+ export { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired";
79
86
  export { ParsingError } from "./errors/ParsingError";
87
+ export { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError";
80
88
  /**
81
89
  * @deprecated Use {@link RichTextNodeType} instead.
82
90
  */
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RichTextNodeType } from "./types/value/richText.js";
2
+ import { mapSliceZone } from "./helpers/mapSliceZone.js";
2
3
  import { filter } from "./filter.js";
3
4
  import { Client, createClient } from "./createClient.js";
4
5
  import { getRepositoryEndpoint } from "./getRepositoryEndpoint.js";
@@ -17,7 +18,6 @@ import { asHTML } from "./helpers/asHTML.js";
17
18
  import { asImageSrc } from "./helpers/asImageSrc.js";
18
19
  import { asImageWidthSrcSet } from "./helpers/asImageWidthSrcSet.js";
19
20
  import { asImagePixelDensitySrcSet } from "./helpers/asImagePixelDensitySrcSet.js";
20
- import { unstable_mapSliceZone } from "./helpers/unstable_mapSliceZone.js";
21
21
  import * as isFilled from "./helpers/isFilled.js";
22
22
  import { documentToLinkField } from "./helpers/documentToLinkField.js";
23
23
  import { PrismicError } from "./errors/PrismicError.js";
@@ -25,7 +25,9 @@ import { ForbiddenError } from "./errors/ForbiddenError.js";
25
25
  import { NotFoundError } from "./errors/NotFoundError.js";
26
26
  import { RefNotFoundError } from "./errors/RefNotFoundError.js";
27
27
  import { RefExpiredError } from "./errors/RefExpiredError.js";
28
+ import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired.js";
28
29
  import { ParsingError } from "./errors/ParsingError.js";
30
+ import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError.js";
29
31
  import { LinkType } from "./types/value/link.js";
30
32
  import { OEmbedType } from "./types/value/embed.js";
31
33
  import { CustomTypeModelFieldType } from "./types/model/types.js";
@@ -34,6 +36,7 @@ import { CustomTypeModelSliceType } from "./types/model/sliceZone.js";
34
36
  import { CustomTypeModelSliceDisplay } from "./types/model/slice.js";
35
37
  import { WebhookType } from "./types/webhook/types.js";
36
38
  const predicate = filter;
39
+ const unstable_mapSliceZone = mapSliceZone;
37
40
  const Element = RichTextNodeType;
38
41
  export {
39
42
  Client,
@@ -47,9 +50,11 @@ export {
47
50
  NotFoundError,
48
51
  OEmbedType,
49
52
  ParsingError,
53
+ PreviewTokenExpiredError,
50
54
  PrismicError,
51
55
  RefExpiredError,
52
56
  RefNotFoundError,
57
+ RepositoryNotFoundError,
53
58
  RichTextNodeType,
54
59
  WebhookType,
55
60
  asDate,
@@ -72,6 +77,7 @@ export {
72
77
  isFilled,
73
78
  isRepositoryEndpoint,
74
79
  isRepositoryName,
80
+ mapSliceZone,
75
81
  predicate,
76
82
  unstable_mapSliceZone
77
83
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\";\nimport type { IntegrationField } from \"./types/value/integration\";\nimport { RichTextNodeType } from \"./types/value/richText\";\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\";\n\nimport { filter } from \"./filter\";\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient, Client } from \"./createClient\";\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\";\nexport { getRepositoryName } from \"./getRepositoryName\";\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\";\nexport { isRepositoryName } from \"./isRepositoryName\";\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\";\nexport { buildQueryURL } from \"./buildQueryURL\";\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\";\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter;\nexport { filter, predicate };\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\";\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type {\n\tAbortSignalLike,\n\tClientConfig,\n\tCreateClient,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./createClient\";\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\";\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\";\nexport { asLink } from \"./helpers/asLink\";\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\";\nexport { asText } from \"./helpers/asText\";\nexport { asHTML } from \"./helpers/asHTML\";\nexport { asImageSrc } from \"./helpers/asImageSrc\";\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\";\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\";\nexport { unstable_mapSliceZone } from \"./helpers/unstable_mapSliceZone\";\nexport * as isFilled from \"./helpers/isFilled\";\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\";\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\";\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\";\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer;\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer;\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n};\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\";\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\nexport { PrismicError } from \"./errors/PrismicError\";\nexport { ForbiddenError } from \"./errors/ForbiddenError\";\nexport { NotFoundError } from \"./errors/NotFoundError\";\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\";\nexport { RefExpiredError } from \"./errors/RefExpiredError\";\nexport { ParsingError } from \"./errors/ParsingError\";\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType;\nexport { RichTextNodeType, Element };\nexport { LinkType } from \"./types/value/link\";\nexport { OEmbedType } from \"./types/value/embed\";\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\";\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n} from \"./types/value/richText\";\nexport type { TitleField } from \"./types/value/title\";\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\";\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\";\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\";\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\";\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\";\n\nexport type { BooleanField } from \"./types/value/boolean\";\nexport type { ColorField } from \"./types/value/color\";\nexport type { DateField } from \"./types/value/date\";\nexport type { KeyTextField } from \"./types/value/keyText\";\nexport type { NumberField } from \"./types/value/number\";\nexport type { SelectField } from \"./types/value/select\";\nexport type { TimestampField } from \"./types/value/timestamp\";\nexport type { GeoPointField } from \"./types/value/geoPoint\";\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField;\nexport { IntegrationField, IntegrationFields };\n\nexport type { GroupField } from \"./types/value/group\";\n\nexport type { SliceZone } from \"./types/value/sliceZone\";\nexport type { Slice } from \"./types/value/slice\";\nexport type { SharedSlice } from \"./types/value/sharedSlice\";\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\";\n\nexport type { FieldState, AnyRegularField } from \"./types/value/types\";\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\";\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\";\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\";\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\";\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\";\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\";\nexport type { CustomTypeModelTitleField } from \"./types/model/title\";\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\";\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\";\nexport type { CustomTypeModelLinkField } from \"./types/model/link\";\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\";\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\";\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\";\nexport type { CustomTypeModelColorField } from \"./types/model/color\";\nexport type { CustomTypeModelDateField } from \"./types/model/date\";\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\";\nexport type { CustomTypeModelNumberField } from \"./types/model/number\";\nexport type { CustomTypeModelSelectField } from \"./types/model/select\";\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\";\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\";\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField;\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n};\nexport type { CustomTypeModelGroupField } from \"./types/model/group\";\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\";\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\";\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\";\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\";\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\";\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\";\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\";\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n} from \"./types/model/types\";\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\";\n\nexport type { Ref } from \"./types/api/ref\";\n\nexport type { Release } from \"./types/api/release\";\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\";\n\nexport type { Tags } from \"./types/api/tags\";\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\";\n\nexport type { WebhookBody } from \"./types/webhook/types\";\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\";\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,YAAY;AAiFlB,MAAM,UAAU;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["// Imports are used for deprecations.\nimport type { CustomTypeModelIntegrationField } from \"./types/model/integration\";\nimport type { IntegrationField } from \"./types/value/integration\";\nimport { RichTextNodeType } from \"./types/value/richText\";\n\nimport type {\n\tHTMLRichTextFunctionSerializer,\n\tHTMLRichTextMapSerializer,\n} from \"./helpers/asHTML\";\nimport { mapSliceZone } from \"./helpers/mapSliceZone\";\n\nimport { filter } from \"./filter\";\n\n//=============================================================================\n// Client - Query content from Prismic.\n//=============================================================================\n\n// Primary Client API.\nexport { createClient, Client } from \"./createClient\";\n\n// API endpoint helpers.\nexport { getRepositoryEndpoint } from \"./getRepositoryEndpoint\";\nexport { getRepositoryName } from \"./getRepositoryName\";\nexport { getGraphQLEndpoint } from \"./getGraphQLEndpoint\";\nexport { isRepositoryName } from \"./isRepositoryName\";\nexport { isRepositoryEndpoint } from \"./isRepositoryEndpoint\";\nexport { buildQueryURL } from \"./buildQueryURL\";\n\n// Toolbar helpers.\nexport { getToolbarSrc } from \"./getToolbarSrc\";\n\n// Query filters API.\n/**\n * @deprecated Renamed to `filter`\n */\n// TODO: Remove when we remove support for deprecated `predicate` export.\nconst predicate = filter;\nexport { filter, predicate };\n\n// A collection of well-known cookie names shared between Prismic libraries and systems.\nexport * as cookie from \"./cookie\";\n\n// General types used to query content from Prismic. These are made public to allow users to better type their projects.\nexport type {\n\tAbortSignalLike,\n\tClientConfig,\n\tCreateClient,\n\tFetchLike,\n\tHttpRequestLike,\n\tRequestInitLike,\n\tResponseLike,\n} from \"./createClient\";\nexport type {\n\tBuildQueryURLArgs,\n\tOrdering,\n\tQueryParams,\n\tRoute,\n} from \"./buildQueryURL\";\n\n//=============================================================================\n// Helpers - Manipulate content from Prismic.\n//=============================================================================\n\n// Primary Helpers API.\nexport { asDate } from \"./helpers/asDate\";\nexport { asLink } from \"./helpers/asLink\";\nexport { asLinkAttrs } from \"./helpers/asLinkAttrs\";\nexport { asText } from \"./helpers/asText\";\nexport { asHTML } from \"./helpers/asHTML\";\nexport { asImageSrc } from \"./helpers/asImageSrc\";\nexport { asImageWidthSrcSet } from \"./helpers/asImageWidthSrcSet\";\nexport { asImagePixelDensitySrcSet } from \"./helpers/asImagePixelDensitySrcSet\";\nexport * as isFilled from \"./helpers/isFilled\";\n\n/**\n * @deprecated Renamed to `mapSliceZone`\n */\nconst unstable_mapSliceZone = mapSliceZone;\nexport { mapSliceZone, unstable_mapSliceZone };\n\n// Conversion helper.\nexport { documentToLinkField } from \"./helpers/documentToLinkField\";\n\nexport type { LinkResolverFunction } from \"./helpers/asLink\";\nexport type { AsLinkAttrsConfig } from \"./helpers/asLinkAttrs\";\nexport type { SliceMapper } from \"./helpers/mapSliceZone\";\n\n/**\n * @deprecated Renamed to `HTMLRichTextMapSerializer`\n */\ntype HTMLMapSerializer = HTMLRichTextMapSerializer;\n/**\n * @deprecated Renamed to `HTMLRichTextFunctionSerializer`\n */\ntype HTMLFunctionSerializer = HTMLRichTextFunctionSerializer;\nexport type {\n\tHTMLRichTextMapSerializer,\n\tHTMLRichTextFunctionSerializer,\n\tHTMLMapSerializer,\n\tHTMLFunctionSerializer,\n};\nexport type { HTMLRichTextSerializer } from \"./helpers/asHTML\";\n\n//=============================================================================\n// Errors - Custom errors for Prismic APIs.\n//=============================================================================\n\nexport { PrismicError } from \"./errors/PrismicError\";\nexport { ForbiddenError } from \"./errors/ForbiddenError\";\nexport { NotFoundError } from \"./errors/NotFoundError\";\nexport { RefNotFoundError } from \"./errors/RefNotFoundError\";\nexport { RefExpiredError } from \"./errors/RefExpiredError\";\nexport { PreviewTokenExpiredError } from \"./errors/PreviewTokenExpired\";\nexport { ParsingError } from \"./errors/ParsingError\";\nexport { RepositoryNotFoundError } from \"./errors/RepositoryNotFoundError\";\n\n//=============================================================================\n// Types - Types representing Prismic content, models, and API payloads.\n//=============================================================================\n\n// Values - Types representing Prismic content.\n/**\n * @deprecated Use {@link RichTextNodeType} instead.\n */\n// TODO: Remove in v8.\nconst Element = RichTextNodeType;\nexport { RichTextNodeType, Element };\nexport { LinkType } from \"./types/value/link\";\nexport { OEmbedType } from \"./types/value/embed\";\n\nexport type {\n\tPrismicDocument,\n\tPrismicDocumentWithUID,\n\tPrismicDocumentWithoutUID,\n\tPrismicDocumentHeader,\n\tAlternateLanguage,\n} from \"./types/value/document\";\n\nexport type {\n\t// RichText & Title\n\tRichTextField,\n\t// RichText & Title (block nodes)\n\tRTTextNodeBase,\n\tRTHeading1Node,\n\tRTHeading2Node,\n\tRTHeading3Node,\n\tRTHeading4Node,\n\tRTHeading5Node,\n\tRTHeading6Node,\n\tRTParagraphNode,\n\tRTPreformattedNode,\n\tRTListItemNode,\n\tRTOListItemNode,\n\t// RichText & Title (span nodes)\n\tRTSpanNodeBase,\n\tRTStrongNode,\n\tRTEmNode,\n\tRTLabelNode,\n\t// RichText & Title (media nodes)\n\tRTImageNode,\n\tRTEmbedNode,\n\t// RichText & Title (link nodes)\n\tRTLinkNode,\n\t// RichText & Title (serialization related nodes)\n\tRTListNode,\n\tRTOListNode,\n\tRTSpanNode,\n\t// RichText & Title (helpers)\n\tRTNode,\n\tRTTextNode,\n\tRTBlockNode,\n\tRTInlineNode,\n\tRTAnyNode,\n} from \"./types/value/richText\";\nexport type { TitleField } from \"./types/value/title\";\n\nexport type {\n\tImageField,\n\tImageFieldImage,\n\tFilledImageFieldImage,\n\tEmptyImageFieldImage,\n} from \"./types/value/image\";\n\nexport type {\n\tEmptyLinkField,\n\tLinkField,\n\tFilledLinkToWebField,\n} from \"./types/value/link\";\nexport type {\n\tContentRelationshipField,\n\tFilledContentRelationshipField,\n} from \"./types/value/contentRelationship\";\nexport type {\n\tLinkToMediaField,\n\tFilledLinkToMediaField,\n} from \"./types/value/linkToMedia\";\n\nexport type {\n\tOEmbedExtra,\n\tPhotoOEmbed,\n\tVideoOEmbed,\n\tLinkOEmbed,\n\tRichOEmbed,\n\tAnyOEmbed,\n\tEmbedField,\n} from \"./types/value/embed\";\n\nexport type { BooleanField } from \"./types/value/boolean\";\nexport type { ColorField } from \"./types/value/color\";\nexport type { DateField } from \"./types/value/date\";\nexport type { KeyTextField } from \"./types/value/keyText\";\nexport type { NumberField } from \"./types/value/number\";\nexport type { SelectField } from \"./types/value/select\";\nexport type { TimestampField } from \"./types/value/timestamp\";\nexport type { GeoPointField } from \"./types/value/geoPoint\";\n\n/**\n * @deprecated Renamed to `IntegrationField`\n */\n// TODO: Remove when we remove support for deprecated `IntegrationFields` export.\ntype IntegrationFields = IntegrationField;\nexport { IntegrationField, IntegrationFields };\n\nexport type { GroupField } from \"./types/value/group\";\n\nexport type { SliceZone } from \"./types/value/sliceZone\";\nexport type { Slice } from \"./types/value/slice\";\nexport type { SharedSlice } from \"./types/value/sharedSlice\";\nexport type { SharedSliceVariation } from \"./types/value/sharedSliceVariation\";\n\nexport type { FieldState, AnyRegularField } from \"./types/value/types\";\n\n// Models - Types representing Prismic content models.\nexport { CustomTypeModelFieldType } from \"./types/model/types\";\nexport { CustomTypeModelLinkSelectType } from \"./types/model/link\";\nexport { CustomTypeModelSliceType } from \"./types/model/sliceZone\";\nexport { CustomTypeModelSliceDisplay } from \"./types/model/slice\";\n\nexport type {\n\tCustomTypeModel,\n\tCustomTypeModelDefinition,\n\tCustomTypeModelTab,\n} from \"./types/model/customType\";\n\nexport type {\n\tCustomTypeModelRichTextField,\n\tCustomTypeModelRichTextMultiField,\n\tCustomTypeModelRichTextSingleField,\n} from \"./types/model/richText\";\nexport type { CustomTypeModelTitleField } from \"./types/model/title\";\n\nexport type {\n\tCustomTypeModelImageField,\n\tCustomTypeModelImageConstraint,\n\tCustomTypeModelImageThumbnail,\n} from \"./types/model/image\";\n\nexport type { CustomTypeModelContentRelationshipField } from \"./types/model/contentRelationship\";\nexport type { CustomTypeModelLinkField } from \"./types/model/link\";\nexport type { CustomTypeModelLinkToMediaField } from \"./types/model/linkToMedia\";\n\nexport type { CustomTypeModelEmbedField } from \"./types/model/embed\";\n\nexport type { CustomTypeModelBooleanField } from \"./types/model/boolean\";\nexport type { CustomTypeModelColorField } from \"./types/model/color\";\nexport type { CustomTypeModelDateField } from \"./types/model/date\";\nexport type { CustomTypeModelKeyTextField } from \"./types/model/keyText\";\nexport type { CustomTypeModelNumberField } from \"./types/model/number\";\nexport type { CustomTypeModelSelectField } from \"./types/model/select\";\nexport type { CustomTypeModelTimestampField } from \"./types/model/timestamp\";\nexport type { CustomTypeModelGeoPointField } from \"./types/model/geoPoint\";\n\n/**\n * @deprecated Renamed to `CustomTypeModelIntegrationField`.\n */\n// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.\ntype CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField;\nexport {\n\tCustomTypeModelIntegrationField,\n\tCustomTypeModelIntegrationFieldsField,\n};\nexport type { CustomTypeModelGroupField } from \"./types/model/group\";\nexport type {\n\tCustomTypeModelSliceZoneField,\n\tCustomTypeModelSliceLabel,\n\tCustomTypeModelSharedSlice,\n} from \"./types/model/sliceZone\";\nexport type {\n\tCustomTypeModelSlice,\n\tCustomTypeModelLegacySlice,\n} from \"./types/model/slice\";\nexport type { SharedSliceModel } from \"./types/model/sharedSlice\";\nexport type { SharedSliceModelVariation } from \"./types/model/sharedSliceVariation\";\n\nexport type { CustomTypeModelUIDField } from \"./types/model/uid\";\n\nexport type { CustomTypeModelRangeField } from \"./types/model/range\";\nexport type { CustomTypeModelSeparatorField } from \"./types/model/separator\";\n\nexport type {\n\tCustomTypeModelField,\n\tCustomTypeModelFieldForGroup,\n} from \"./types/model/types\";\n\n// API - Types representing Prismic Rest API V2 responses.\nexport type { Query } from \"./types/api/query\";\n\nexport type { Ref } from \"./types/api/ref\";\n\nexport type { Release } from \"./types/api/release\";\n\nexport type {\n\tRepository,\n\tLanguage,\n\tForm,\n\tFormField,\n} from \"./types/api/repository\";\n\nexport type { Tags } from \"./types/api/tags\";\n\n// Webhook - Types representing Prismic webhooks.\nexport { WebhookType } from \"./types/webhook/types\";\n\nexport type { WebhookBody } from \"./types/webhook/types\";\n\nexport type { WebhookBodyAPIUpdate } from \"./types/webhook/apiUpdate\";\n\nexport type { WebhookBodyTestTrigger } from \"./types/webhook/testTrigger\";\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YAAY;AAyClB,MAAM,wBAAwB;AAgD9B,MAAM,UAAU;"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "7.3.0";
3
+ const version = "7.4.0";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "7.3.0";
1
+ const version = "7.4.0";
2
2
  export {
3
3
  version
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/client",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "The official JavaScript + TypeScript client library for Prismic",
5
5
  "keywords": [
6
6
  "typescript",
@@ -18,9 +18,11 @@ import type { PrismicDocument } from "./types/value/document";
18
18
  import { ForbiddenError } from "./errors/ForbiddenError";
19
19
  import { NotFoundError } from "./errors/NotFoundError";
20
20
  import { ParsingError } from "./errors/ParsingError";
21
+ import { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired";
21
22
  import { PrismicError } from "./errors/PrismicError";
22
23
  import { RefExpiredError } from "./errors/RefExpiredError";
23
24
  import { RefNotFoundError } from "./errors/RefNotFoundError";
25
+ import { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError";
24
26
 
25
27
  import { LinkResolverFunction, asLink } from "./helpers/asLink";
26
28
 
@@ -1911,16 +1913,28 @@ export class Client<TDocuments extends PrismicDocument = PrismicDocument> {
1911
1913
  // Not Found
1912
1914
  // - Incorrect repository name (this response has an empty body)
1913
1915
  // - Ref does not exist
1916
+ // - Preview token is expired
1914
1917
  case 404: {
1915
- if (res.json && res.json.type === "api_notfound_error") {
1918
+ if (res.json === undefined) {
1919
+ throw new RepositoryNotFoundError(
1920
+ `Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`,
1921
+ url,
1922
+ undefined,
1923
+ );
1924
+ }
1925
+
1926
+ if (res.json.type === "api_notfound_error") {
1916
1927
  throw new RefNotFoundError(res.json.message, url, res.json);
1917
1928
  }
1918
1929
 
1919
- throw new NotFoundError(
1920
- `Prismic repository not found. Check that "${this.endpoint}" is pointing to the correct repository.`,
1921
- url,
1922
- undefined, // res.json is empty
1923
- );
1930
+ if (
1931
+ res.json.type === "api_security_error" &&
1932
+ /preview token.*expired/i.test(res.json.message)
1933
+ ) {
1934
+ throw new PreviewTokenExpiredError(res.json.message, url, res.json);
1935
+ }
1936
+
1937
+ throw new NotFoundError(res.json.message, url, res.json);
1924
1938
  }
1925
1939
 
1926
1940
  // Gone
@@ -0,0 +1,12 @@
1
+ import { ForbiddenError } from "./ForbiddenError";
2
+
3
+ type PreviewTokenExpiredErrorAPIResponse = {
4
+ type: "api_security_error";
5
+ message: string;
6
+ };
7
+
8
+ // This error extends `ForbiddenError` for backwards compatibility.
9
+ // TODO: Extend this error from `PrismicError` in v8.
10
+ export class PreviewTokenExpiredError<
11
+ TResponse = PreviewTokenExpiredErrorAPIResponse,
12
+ > extends ForbiddenError<TResponse> {}
@@ -0,0 +1,5 @@
1
+ import { NotFoundError } from "./NotFoundError";
2
+
3
+ export class RepositoryNotFoundError<
4
+ TResponse = undefined,
5
+ > extends NotFoundError<TResponse> {}