@prismicio/client 6.7.1 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ForbiddenError.cjs +7 -0
- package/dist/ForbiddenError.cjs.map +1 -0
- package/dist/ForbiddenError.d.ts +11 -0
- package/dist/ForbiddenError.js +7 -0
- package/dist/ForbiddenError.js.map +1 -0
- package/dist/NotFoundError.cjs +7 -0
- package/dist/NotFoundError.cjs.map +1 -0
- package/dist/NotFoundError.d.ts +3 -0
- package/dist/NotFoundError.js +7 -0
- package/dist/NotFoundError.js.map +1 -0
- package/dist/ParsingError.cjs +7 -0
- package/dist/ParsingError.cjs.map +1 -0
- package/dist/ParsingError.d.ts +12 -0
- package/dist/ParsingError.js +7 -0
- package/dist/ParsingError.js.map +1 -0
- package/dist/PrismicError.cjs +19 -0
- package/dist/PrismicError.cjs.map +1 -0
- package/dist/PrismicError.d.ts +5 -0
- package/dist/PrismicError.js +19 -0
- package/dist/PrismicError.js.map +1 -0
- package/dist/buildQueryURL.cjs +41 -0
- package/dist/buildQueryURL.cjs.map +1 -0
- package/dist/buildQueryURL.d.ts +130 -0
- package/dist/buildQueryURL.js +41 -0
- package/dist/buildQueryURL.js.map +1 -0
- package/dist/client.cjs +414 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.ts +908 -0
- package/dist/client.js +414 -0
- package/dist/client.js.map +1 -0
- package/dist/cookie.cjs +5 -0
- package/dist/cookie.cjs.map +1 -0
- package/dist/cookie.d.ts +5 -0
- package/dist/cookie.js +5 -0
- package/dist/cookie.js.map +1 -0
- package/dist/getGraphQLEndpoint.cjs +13 -0
- package/dist/getGraphQLEndpoint.cjs.map +1 -0
- package/dist/getGraphQLEndpoint.d.ts +9 -0
- package/dist/getGraphQLEndpoint.js +13 -0
- package/dist/getGraphQLEndpoint.js.map +1 -0
- package/dist/getRepositoryEndpoint.cjs +13 -0
- package/dist/getRepositoryEndpoint.cjs.map +1 -0
- package/dist/getRepositoryEndpoint.d.ts +10 -0
- package/dist/getRepositoryEndpoint.js +13 -0
- package/dist/getRepositoryEndpoint.js.map +1 -0
- package/dist/getRepositoryName.cjs +12 -0
- package/dist/getRepositoryName.cjs.map +1 -0
- package/dist/getRepositoryName.d.ts +13 -0
- package/dist/getRepositoryName.js +12 -0
- package/dist/getRepositoryName.js.map +1 -0
- package/dist/helpers/asDate.cjs +14 -0
- package/dist/helpers/asDate.cjs.map +1 -0
- package/dist/helpers/asDate.d.ts +16 -0
- package/dist/helpers/asDate.js +14 -0
- package/dist/helpers/asDate.js.map +1 -0
- package/dist/helpers/asHTML.cjs +79 -0
- package/dist/helpers/asHTML.cjs.map +1 -0
- package/dist/helpers/asHTML.d.ts +20 -0
- package/dist/helpers/asHTML.js +79 -0
- package/dist/helpers/asHTML.js.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs +21 -0
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -0
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +52 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js +21 -0
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -0
- package/dist/helpers/asImageSrc.cjs +13 -0
- package/dist/helpers/asImageSrc.cjs.map +1 -0
- package/dist/helpers/asImageSrc.d.ts +27 -0
- package/dist/helpers/asImageSrc.js +13 -0
- package/dist/helpers/asImageSrc.js.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.cjs +40 -0
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -0
- package/dist/helpers/asImageWidthSrcSet.d.ts +60 -0
- package/dist/helpers/asImageWidthSrcSet.js +40 -0
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -0
- package/dist/helpers/asLink.cjs +32 -0
- package/dist/helpers/asLink.cjs.map +1 -0
- package/dist/helpers/asLink.d.ts +24 -0
- package/dist/helpers/asLink.js +32 -0
- package/dist/helpers/asLink.js.map +1 -0
- package/dist/helpers/asText.cjs +12 -0
- package/dist/helpers/asText.cjs.map +1 -0
- package/dist/helpers/asText.d.ts +16 -0
- package/dist/helpers/asText.js +12 -0
- package/dist/helpers/asText.js.map +1 -0
- package/dist/helpers/documentToLinkField.cjs +19 -0
- package/dist/helpers/documentToLinkField.cjs.map +1 -0
- package/dist/helpers/documentToLinkField.d.ts +15 -0
- package/dist/helpers/documentToLinkField.js +19 -0
- package/dist/helpers/documentToLinkField.js.map +1 -0
- package/dist/helpers/isFilled.cjs +67 -0
- package/dist/helpers/isFilled.cjs.map +1 -0
- package/dist/helpers/isFilled.d.ts +175 -0
- package/dist/helpers/isFilled.js +67 -0
- package/dist/helpers/isFilled.js.map +1 -0
- package/dist/index.cjs +67 -721
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +92 -1526
- package/dist/index.js +64 -681
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs +12 -0
- package/dist/isRepositoryEndpoint.cjs.map +1 -0
- package/dist/isRepositoryEndpoint.d.ts +10 -0
- package/dist/isRepositoryEndpoint.js +12 -0
- package/dist/isRepositoryEndpoint.js.map +1 -0
- package/dist/isRepositoryName.cjs +7 -0
- package/dist/isRepositoryName.cjs.map +1 -0
- package/dist/isRepositoryName.d.ts +9 -0
- package/dist/isRepositoryName.js +7 -0
- package/dist/isRepositoryName.js.map +1 -0
- package/dist/lib/appendPredicates.cjs +14 -0
- package/dist/lib/appendPredicates.cjs.map +1 -0
- package/dist/lib/appendPredicates.d.ts +18 -0
- package/dist/lib/appendPredicates.js +14 -0
- package/dist/lib/appendPredicates.js.map +1 -0
- package/dist/lib/castArray.cjs +5 -0
- package/dist/lib/castArray.cjs.map +1 -0
- package/dist/lib/castArray.d.ts +11 -0
- package/dist/lib/castArray.js +5 -0
- package/dist/lib/castArray.js.map +1 -0
- package/dist/lib/castThunk.cjs +5 -0
- package/dist/lib/castThunk.cjs.map +1 -0
- package/dist/lib/castThunk.d.ts +10 -0
- package/dist/lib/castThunk.js +5 -0
- package/dist/lib/castThunk.js.map +1 -0
- package/dist/lib/findMasterRef.cjs +8 -0
- package/dist/lib/findMasterRef.cjs.map +1 -0
- package/dist/lib/findMasterRef.d.ts +10 -0
- package/dist/lib/findMasterRef.js +8 -0
- package/dist/lib/findMasterRef.js.map +1 -0
- package/dist/lib/findRef.cjs +12 -0
- package/dist/lib/findRef.cjs.map +1 -0
- package/dist/lib/findRef.d.ts +13 -0
- package/dist/lib/findRef.js +12 -0
- package/dist/lib/findRef.js.map +1 -0
- package/dist/lib/findRefByID.cjs +8 -0
- package/dist/lib/findRefByID.cjs.map +1 -0
- package/dist/lib/findRefByID.d.ts +11 -0
- package/dist/lib/findRefByID.js +8 -0
- package/dist/lib/findRefByID.js.map +1 -0
- package/dist/lib/findRefByLabel.cjs +8 -0
- package/dist/lib/findRefByLabel.cjs.map +1 -0
- package/dist/lib/findRefByLabel.d.ts +11 -0
- package/dist/lib/findRefByLabel.js +8 -0
- package/dist/lib/findRefByLabel.js.map +1 -0
- package/dist/lib/getPreviewCookie.cjs +21 -0
- package/dist/lib/getPreviewCookie.cjs.map +1 -0
- package/dist/lib/getPreviewCookie.d.ts +9 -0
- package/dist/lib/getPreviewCookie.js +21 -0
- package/dist/lib/getPreviewCookie.js.map +1 -0
- package/dist/lib/minifyGraphQLQuery.cjs +7 -0
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -0
- package/dist/lib/minifyGraphQLQuery.d.ts +8 -0
- package/dist/lib/minifyGraphQLQuery.js +7 -0
- package/dist/lib/minifyGraphQLQuery.js.map +1 -0
- package/dist/lib/serializerHelpers.cjs +56 -0
- package/dist/lib/serializerHelpers.cjs.map +1 -0
- package/dist/lib/serializerHelpers.d.ts +9 -0
- package/dist/lib/serializerHelpers.js +54 -0
- package/dist/lib/serializerHelpers.js.map +1 -0
- package/dist/predicate.cjs +68 -0
- package/dist/predicate.cjs.map +1 -0
- package/dist/predicate.d.ts +209 -0
- package/dist/predicate.js +68 -0
- package/dist/predicate.js.map +1 -0
- package/dist/types/api/query.d.ts +42 -0
- package/dist/types/api/ref.d.ts +32 -0
- package/dist/types/api/release.d.ts +10 -0
- package/dist/types/api/repository.d.ts +100 -0
- package/dist/types/api/tags.d.ts +8 -0
- package/dist/types/client.d.ts +128 -0
- package/dist/types/helpers.d.ts +63 -0
- package/dist/types/model/boolean.d.ts +15 -0
- package/dist/types/model/color.d.ts +13 -0
- package/dist/types/model/contentRelationship.d.ts +18 -0
- package/dist/types/model/customType.d.ts +42 -0
- package/dist/types/model/date.d.ts +14 -0
- package/dist/types/model/embed.d.ts +13 -0
- package/dist/types/model/geoPoint.d.ts +12 -0
- package/dist/types/model/group.d.ts +15 -0
- package/dist/types/model/image.d.ts +31 -0
- package/dist/types/model/integrationFields.d.ts +14 -0
- package/dist/types/model/keyText.d.ts +13 -0
- package/dist/types/model/link.cjs +9 -0
- package/dist/types/model/link.cjs.map +1 -0
- package/dist/types/model/link.d.ts +27 -0
- package/dist/types/model/link.js +9 -0
- package/dist/types/model/link.js.map +1 -0
- package/dist/types/model/linkToMedia.d.ts +16 -0
- package/dist/types/model/number.d.ts +15 -0
- package/dist/types/model/range.d.ts +14 -0
- package/dist/types/model/richText.d.ts +35 -0
- package/dist/types/model/select.d.ts +18 -0
- package/dist/types/model/separator.d.ts +10 -0
- package/dist/types/model/sharedSlice.d.ts +19 -0
- package/dist/types/model/sharedSliceVariation.d.ts +22 -0
- package/dist/types/model/slice.cjs +8 -0
- package/dist/types/model/slice.cjs.map +1 -0
- package/dist/types/model/slice.d.ts +33 -0
- package/dist/types/model/slice.js +8 -0
- package/dist/types/model/slice.js.map +1 -0
- package/dist/types/model/sliceZone.cjs +8 -0
- package/dist/types/model/sliceZone.cjs.map +1 -0
- package/dist/types/model/sliceZone.d.ts +44 -0
- package/dist/types/model/sliceZone.js +8 -0
- package/dist/types/model/sliceZone.js.map +1 -0
- package/dist/types/model/timestamp.d.ts +14 -0
- package/dist/types/model/title.d.ts +7 -0
- package/dist/types/model/types.cjs +25 -0
- package/dist/types/model/types.cjs.map +1 -0
- package/dist/types/model/types.d.ts +62 -0
- package/dist/types/model/types.js +25 -0
- package/dist/types/model/types.js.map +1 -0
- package/dist/types/model/uid.d.ts +13 -0
- package/dist/types/utils.d.ts +28 -0
- package/dist/types/value/boolean.d.ts +6 -0
- package/dist/types/value/color.d.ts +8 -0
- package/dist/types/value/contentRelationship.d.ts +29 -0
- package/dist/types/value/date.d.ts +8 -0
- package/dist/types/value/document.d.ts +113 -0
- package/dist/types/value/embed.cjs +10 -0
- package/dist/types/value/embed.cjs.map +1 -0
- package/dist/types/value/embed.d.ts +167 -0
- package/dist/types/value/embed.js +10 -0
- package/dist/types/value/embed.js.map +1 -0
- package/dist/types/value/geoPoint.d.ts +11 -0
- package/dist/types/value/group.d.ts +7 -0
- package/dist/types/value/image.d.ts +36 -0
- package/dist/types/value/integrationFields.d.ts +9 -0
- package/dist/types/value/keyText.d.ts +8 -0
- package/dist/types/value/link.cjs +10 -0
- package/dist/types/value/link.cjs.map +1 -0
- package/dist/types/value/link.d.ts +40 -0
- package/dist/types/value/link.js +10 -0
- package/dist/types/value/link.js.map +1 -0
- package/dist/types/value/linkToMedia.d.ts +20 -0
- package/dist/types/value/number.d.ts +8 -0
- package/dist/types/value/richText.cjs +25 -0
- package/dist/types/value/richText.cjs.map +1 -0
- package/dist/types/value/richText.d.ts +203 -0
- package/dist/types/value/richText.js +25 -0
- package/dist/types/value/richText.js.map +1 -0
- package/dist/types/value/select.d.ts +9 -0
- package/dist/types/value/sharedSlice.d.ts +11 -0
- package/dist/types/value/sharedSliceVariation.d.ts +7 -0
- package/dist/types/value/slice.d.ts +13 -0
- package/dist/types/value/sliceZone.d.ts +12 -0
- package/dist/types/value/timestamp.d.ts +8 -0
- package/dist/types/value/title.d.ts +12 -0
- package/dist/types/value/types.d.ts +40 -0
- package/dist/types/webhook/apiUpdate.d.ts +52 -0
- package/dist/types/webhook/testTrigger.d.ts +9 -0
- package/dist/types/webhook/types.cjs +8 -0
- package/dist/types/webhook/types.cjs.map +1 -0
- package/dist/types/webhook/types.d.ts +18 -0
- package/dist/types/webhook/types.js +8 -0
- package/dist/types/webhook/types.js.map +1 -0
- package/package.json +40 -33
- package/src/buildQueryURL.ts +8 -4
- package/src/client.ts +111 -118
- package/src/cookie.ts +2 -1
- package/src/getRepositoryName.ts +4 -2
- package/src/helpers/asDate.ts +48 -0
- package/src/helpers/asHTML.ts +154 -0
- package/src/helpers/asImagePixelDensitySrcSet.ts +96 -0
- package/src/helpers/asImageSrc.ts +41 -0
- package/src/helpers/asImageWidthSrcSet.ts +139 -0
- package/src/helpers/asLink.ts +99 -0
- package/src/helpers/asText.ts +29 -0
- package/src/helpers/documentToLinkField.ts +47 -0
- package/src/helpers/isFilled.ts +290 -0
- package/src/index.ts +237 -21
- package/src/isRepositoryEndpoint.ts +2 -1
- package/src/isRepositoryName.ts +2 -1
- package/src/lib/appendPredicates.ts +2 -1
- package/src/lib/findMasterRef.ts +2 -2
- package/src/lib/findRef.ts +2 -5
- package/src/lib/findRefByID.ts +2 -2
- package/src/lib/findRefByLabel.ts +2 -5
- package/src/lib/getPreviewCookie.ts +3 -2
- package/src/lib/serializerHelpers.ts +96 -0
- package/src/predicate.ts +4 -2
- package/src/types/api/query.ts +50 -0
- package/src/types/api/ref.ts +36 -0
- package/src/types/api/release.ts +11 -0
- package/src/types/api/repository.ts +117 -0
- package/src/types/api/tags.ts +8 -0
- package/src/{types.ts → types/client.ts} +3 -37
- package/src/types/helpers.ts +103 -0
- package/src/types/model/boolean.ts +16 -0
- package/src/types/model/color.ts +14 -0
- package/src/types/model/contentRelationship.ts +22 -0
- package/src/types/model/customType.ts +61 -0
- package/src/types/model/date.ts +15 -0
- package/src/types/model/embed.ts +14 -0
- package/src/types/model/geoPoint.ts +13 -0
- package/src/types/model/group.ts +24 -0
- package/src/types/model/image.ts +37 -0
- package/src/types/model/integrationFields.ts +15 -0
- package/src/types/model/keyText.ts +14 -0
- package/src/types/model/link.ts +31 -0
- package/src/types/model/linkToMedia.ts +17 -0
- package/src/types/model/number.ts +16 -0
- package/src/types/model/range.ts +15 -0
- package/src/types/model/richText.ts +40 -0
- package/src/types/model/select.ts +22 -0
- package/src/types/model/separator.ts +11 -0
- package/src/types/model/sharedSlice.ts +23 -0
- package/src/types/model/sharedSliceVariation.ts +33 -0
- package/src/types/model/slice.ts +49 -0
- package/src/types/model/sliceZone.ts +62 -0
- package/src/types/model/timestamp.ts +15 -0
- package/src/types/model/title.ts +8 -0
- package/src/types/model/types.ts +91 -0
- package/src/types/model/uid.ts +14 -0
- package/src/types/utils.ts +34 -0
- package/src/types/value/boolean.ts +6 -0
- package/src/types/value/color.ts +10 -0
- package/src/types/value/contentRelationship.ts +48 -0
- package/src/types/value/date.ts +10 -0
- package/src/types/value/document.ts +142 -0
- package/src/types/value/embed.ts +196 -0
- package/src/types/value/geoPoint.ts +15 -0
- package/src/types/value/group.ts +14 -0
- package/src/types/value/image.ts +67 -0
- package/src/types/value/integrationFields.ts +13 -0
- package/src/types/value/keyText.ts +10 -0
- package/src/types/value/link.ts +59 -0
- package/src/types/value/linkToMedia.ts +25 -0
- package/src/types/value/number.ts +10 -0
- package/src/types/value/richText.ts +286 -0
- package/src/types/value/select.ts +13 -0
- package/src/types/value/sharedSlice.ts +15 -0
- package/src/types/value/sharedSliceVariation.ts +18 -0
- package/src/types/value/slice.ts +24 -0
- package/src/types/value/sliceZone.ts +16 -0
- package/src/types/value/timestamp.ts +12 -0
- package/src/types/value/title.ts +31 -0
- package/src/types/value/types.ts +60 -0
- package/src/types/webhook/apiUpdate.ts +56 -0
- package/src/types/webhook/testTrigger.ts +10 -0
- package/src/types/webhook/types.ts +21 -0
- package/src/lib/orElseThrow.ts +0 -17
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { AnyRegularField } from "./types";
|
|
2
|
+
import { GroupField } from "./group";
|
|
3
|
+
import { SliceZone } from "./sliceZone";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Document metadata for a translation of a Prismic document.
|
|
7
|
+
*/
|
|
8
|
+
export interface AlternateLanguage<TypeEnum = string, LangEnum = string> {
|
|
9
|
+
id: string;
|
|
10
|
+
uid?: string;
|
|
11
|
+
type: TypeEnum;
|
|
12
|
+
lang: LangEnum;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Metadata for Prismic Document
|
|
17
|
+
*/
|
|
18
|
+
export interface PrismicDocumentHeader<TypeEnum = string, LangEnum = string> {
|
|
19
|
+
/**
|
|
20
|
+
* The unique identifier for the document. Guaranteed to be unique among all
|
|
21
|
+
* documents in the Prismic repository.
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
* The unique identifier for the document. Guaranteed to be unique among all
|
|
26
|
+
* Prismic documents of the same type.
|
|
27
|
+
*/
|
|
28
|
+
uid: string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Url that refers to document.
|
|
31
|
+
*/
|
|
32
|
+
url: string | null;
|
|
33
|
+
/**
|
|
34
|
+
* Type of the document.
|
|
35
|
+
*/
|
|
36
|
+
type: TypeEnum;
|
|
37
|
+
/**
|
|
38
|
+
* Href for document.
|
|
39
|
+
*/
|
|
40
|
+
href: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tags associated with document.
|
|
43
|
+
*/
|
|
44
|
+
tags: string[];
|
|
45
|
+
/**
|
|
46
|
+
* The timestamp at which the document was first published.
|
|
47
|
+
*/
|
|
48
|
+
first_publication_date: string;
|
|
49
|
+
/**
|
|
50
|
+
* The timestamp at which the document was last published.
|
|
51
|
+
*/
|
|
52
|
+
last_publication_date: string;
|
|
53
|
+
/**
|
|
54
|
+
* Slugs associated with document.
|
|
55
|
+
*
|
|
56
|
+
* @deprecated Slugs are a deprecated feature used before the UID field was
|
|
57
|
+
* introduced. Migrate to the UID field. For more details, see
|
|
58
|
+
* https://community.prismic.io/t/what-are-slugs/6493
|
|
59
|
+
*/
|
|
60
|
+
slugs: string[];
|
|
61
|
+
/**
|
|
62
|
+
* Documents that are related to this document.
|
|
63
|
+
*/
|
|
64
|
+
linked_documents: unknown[]; // TODO: Not sure of the type for this one
|
|
65
|
+
/**
|
|
66
|
+
* Language of document.
|
|
67
|
+
*/
|
|
68
|
+
lang: LangEnum;
|
|
69
|
+
/**
|
|
70
|
+
* Array to access alternate language versions for document.
|
|
71
|
+
*/
|
|
72
|
+
alternate_languages: AlternateLanguage<TypeEnum, LangEnum>[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A Prismic document served through REST API v2.
|
|
77
|
+
*
|
|
78
|
+
* @see More details on Custom Types: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
79
|
+
*/
|
|
80
|
+
export interface PrismicDocument<
|
|
81
|
+
DataInterface extends Record<
|
|
82
|
+
string,
|
|
83
|
+
AnyRegularField | GroupField | SliceZone
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
> = Record<string, any>,
|
|
86
|
+
TypeEnum = string,
|
|
87
|
+
LangEnum = string,
|
|
88
|
+
> extends PrismicDocumentHeader<TypeEnum, LangEnum> {
|
|
89
|
+
/**
|
|
90
|
+
* Data contained in the document.
|
|
91
|
+
*/
|
|
92
|
+
data: DataInterface;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A Prismic document served through REST API v2. Does not contain a UID (a
|
|
97
|
+
* unique identifier).
|
|
98
|
+
*
|
|
99
|
+
* @see More details on Custom Types: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
100
|
+
* @see More details on the UID field: {@link https://prismic.io/docs/core-concepts/uid}
|
|
101
|
+
*/
|
|
102
|
+
export interface PrismicDocumentWithoutUID<
|
|
103
|
+
DataInterface extends Record<
|
|
104
|
+
string,
|
|
105
|
+
AnyRegularField | GroupField | SliceZone
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
> = Record<string, any>,
|
|
108
|
+
TypeEnum = string,
|
|
109
|
+
LangEnum = string,
|
|
110
|
+
> extends PrismicDocument<DataInterface, TypeEnum, LangEnum> {
|
|
111
|
+
/**
|
|
112
|
+
* This document does not have a UID field. This property will always be
|
|
113
|
+
* `null`.
|
|
114
|
+
*
|
|
115
|
+
* The unique identifier for the document. Guaranteed to be unique among all
|
|
116
|
+
* Prismic documents of the same type.
|
|
117
|
+
*/
|
|
118
|
+
uid: null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A Prismic document served through REST API v2. Contains a UID (a unique
|
|
123
|
+
* identifier).
|
|
124
|
+
*
|
|
125
|
+
* @see More details on Custom Types: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
126
|
+
* @see More details on the UID field: {@link https://prismic.io/docs/core-concepts/uid}
|
|
127
|
+
*/
|
|
128
|
+
export interface PrismicDocumentWithUID<
|
|
129
|
+
DataInterface extends Record<
|
|
130
|
+
string,
|
|
131
|
+
AnyRegularField | GroupField | SliceZone
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
> = Record<string, any>,
|
|
134
|
+
TypeEnum = string,
|
|
135
|
+
LangEnum = string,
|
|
136
|
+
> extends PrismicDocument<DataInterface, TypeEnum, LangEnum> {
|
|
137
|
+
/**
|
|
138
|
+
* The unique identifier for the document. Guaranteed to be unique among all
|
|
139
|
+
* Prismic documents of the same type.
|
|
140
|
+
*/
|
|
141
|
+
uid: string;
|
|
142
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { EmptyObjectField, FieldState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* oEmbed 1.0 possible types.
|
|
5
|
+
*
|
|
6
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
7
|
+
*/
|
|
8
|
+
export const OEmbedType = {
|
|
9
|
+
Photo: "photo",
|
|
10
|
+
Video: "video",
|
|
11
|
+
Link: "link",
|
|
12
|
+
Rich: "rich",
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* oEmbed response base fields. Those are every mandatory fields an oEmbed
|
|
17
|
+
* response must feature.
|
|
18
|
+
*
|
|
19
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
20
|
+
*/
|
|
21
|
+
type OEmbedBase<TType extends typeof OEmbedType[keyof typeof OEmbedType]> = {
|
|
22
|
+
/**
|
|
23
|
+
* oEmbed resource type.
|
|
24
|
+
*/
|
|
25
|
+
type: TType;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* oEmbed version number, this must be "1.0".
|
|
29
|
+
*/
|
|
30
|
+
version: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* oEmbed response extra fields. Those are every non-mandatory and unknown
|
|
35
|
+
* fields an oEmbed response can feature.
|
|
36
|
+
*
|
|
37
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
38
|
+
*/
|
|
39
|
+
export type OEmbedExtra = {
|
|
40
|
+
/**
|
|
41
|
+
* oEmbed text title, describing the resource.
|
|
42
|
+
*/
|
|
43
|
+
title?: string | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* oEmbed resource author/owner name.
|
|
47
|
+
*/
|
|
48
|
+
author_name?: string | null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* oEmbed resource author/owner URL.
|
|
52
|
+
*/
|
|
53
|
+
author_url?: string | null;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* oEmbed resource provider name.
|
|
57
|
+
*/
|
|
58
|
+
provider_name?: string | null;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* oEmbed resource provider URL.
|
|
62
|
+
*/
|
|
63
|
+
provider_url?: string | null;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* oEmbed suggested cache lifetime for the resource, in seconds.
|
|
67
|
+
*/
|
|
68
|
+
cache_age?: number | null;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* oEmbed resource thumbnail URL.
|
|
72
|
+
*/
|
|
73
|
+
thumbnail_url?: string | null;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* oEmbed resource thumbnail width.
|
|
77
|
+
*/
|
|
78
|
+
thumbnail_width?: number | null;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* oEmbed resource thumbnail height.
|
|
82
|
+
*/
|
|
83
|
+
thumbnail_height?: number | null;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Providers may optionally include any parameters not specified in this
|
|
87
|
+
* document (so long as they use the same key-value format) and consumers may
|
|
88
|
+
* choose to ignore these. Consumers must ignore parameters they do not
|
|
89
|
+
* understand.
|
|
90
|
+
*
|
|
91
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
92
|
+
*/
|
|
93
|
+
[key: string]: unknown | null;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* oEmbed photo type. Those are every mandatory fields an oEmbed photo response
|
|
98
|
+
* must feature.
|
|
99
|
+
*
|
|
100
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
101
|
+
*/
|
|
102
|
+
export type PhotoOEmbed = OEmbedBase<typeof OEmbedType.Photo> & {
|
|
103
|
+
/**
|
|
104
|
+
* oEmbed source URL of the image.
|
|
105
|
+
*/
|
|
106
|
+
url: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* oEmbed width in pixels of the image.
|
|
110
|
+
*/
|
|
111
|
+
width: number;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* oEmbed height in pixels of the image.
|
|
115
|
+
*/
|
|
116
|
+
height: number;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* oEmbed video type. Those are every mandatory fields an oEmbed video response
|
|
121
|
+
* must feature.
|
|
122
|
+
*
|
|
123
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
124
|
+
*/
|
|
125
|
+
export type VideoOEmbed = OEmbedBase<typeof OEmbedType.Video> & {
|
|
126
|
+
/**
|
|
127
|
+
* oEmbed HTML required to embed a video player.
|
|
128
|
+
*/
|
|
129
|
+
html: string;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* oEmbed width in pixels required to display the HTML.
|
|
133
|
+
*/
|
|
134
|
+
width: number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* oEmbed height in pixels required to display the HTML.
|
|
138
|
+
*/
|
|
139
|
+
height: number;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* oEmbed link type. Those are every mandatory fields an oEmbed link response
|
|
144
|
+
* must feature.
|
|
145
|
+
*
|
|
146
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
147
|
+
*/
|
|
148
|
+
export type LinkOEmbed = OEmbedBase<typeof OEmbedType.Link>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* oEmbed rich type. Those are every mandatory fields an oEmbed rich response
|
|
152
|
+
* must feature.
|
|
153
|
+
*
|
|
154
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
155
|
+
*/
|
|
156
|
+
export type RichOEmbed = OEmbedBase<typeof OEmbedType.Rich> & {
|
|
157
|
+
/**
|
|
158
|
+
* oEmbed HTML required to display the resource.
|
|
159
|
+
*/
|
|
160
|
+
html: string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* oEmbed width in pixels required to display the HTML.
|
|
164
|
+
*/
|
|
165
|
+
width: number;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* oEmbed height in pixels required to display the HTML.
|
|
169
|
+
*/
|
|
170
|
+
height: number;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Any of the possible types of oEmbed response. Those contains only mandatory
|
|
175
|
+
* fields their respective oEmbed response type must feature.
|
|
176
|
+
*
|
|
177
|
+
* @see oEmbed specification: {@link https://oembed.com}
|
|
178
|
+
*/
|
|
179
|
+
export type AnyOEmbed = PhotoOEmbed | VideoOEmbed | LinkOEmbed | RichOEmbed;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* An Embed field.
|
|
183
|
+
*
|
|
184
|
+
* @typeParam Data - Data provided by the URL's oEmbed provider.
|
|
185
|
+
* @typeParam State - State of the field which determines its shape.
|
|
186
|
+
* @see More details: {@link https://prismic.io/docs/core-concepts/embed}
|
|
187
|
+
*/
|
|
188
|
+
export type EmbedField<
|
|
189
|
+
Data extends AnyOEmbed = AnyOEmbed & OEmbedExtra,
|
|
190
|
+
State extends FieldState = FieldState,
|
|
191
|
+
> = State extends "empty"
|
|
192
|
+
? EmptyObjectField
|
|
193
|
+
: Data & {
|
|
194
|
+
embed_url: string;
|
|
195
|
+
html: string | null;
|
|
196
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EmptyObjectField, FieldState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Geopoint field.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam State - State of the field which determines its shape.
|
|
7
|
+
* @see More details: {@link https://prismic.io/docs/core-concepts/geopoint}
|
|
8
|
+
*/
|
|
9
|
+
export type GeoPointField<State extends FieldState = FieldState> =
|
|
10
|
+
State extends "empty"
|
|
11
|
+
? EmptyObjectField
|
|
12
|
+
: {
|
|
13
|
+
latitude: number;
|
|
14
|
+
longitude: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FieldState, AnyRegularField } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Group field.
|
|
5
|
+
*
|
|
6
|
+
* More details: {@link https://prismic.io/docs/core-concepts/group}
|
|
7
|
+
*/
|
|
8
|
+
export type GroupField<
|
|
9
|
+
Fields extends Record<string, AnyRegularField> = Record<
|
|
10
|
+
string,
|
|
11
|
+
AnyRegularField
|
|
12
|
+
>,
|
|
13
|
+
State extends FieldState = FieldState,
|
|
14
|
+
> = State extends "empty" ? [] : [Fields, ...Fields[]];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { FieldState, Simplify } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An individual image within an Image field. The base image and each thumbnail
|
|
5
|
+
* uses this type.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam State - State of the field which determines its shape.
|
|
8
|
+
* @see {@link ImageField} for a full Image field type.
|
|
9
|
+
*/
|
|
10
|
+
export type ImageFieldImage<State extends FieldState = FieldState> =
|
|
11
|
+
State extends "empty" ? EmptyImageFieldImage : FilledImageFieldImage;
|
|
12
|
+
|
|
13
|
+
export interface FilledImageFieldImage {
|
|
14
|
+
url: string;
|
|
15
|
+
dimensions: {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
alt: string | null;
|
|
20
|
+
copyright: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EmptyImageFieldImage {
|
|
24
|
+
url?: null;
|
|
25
|
+
dimensions?: null;
|
|
26
|
+
alt?: null;
|
|
27
|
+
copyright?: null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Image Field
|
|
32
|
+
*
|
|
33
|
+
* **Note**: Passing `null` to the `ThumbnailNames` parameter is deprecated and
|
|
34
|
+
* will be removed in a future version. Use `never` instead.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam ThumbnailNames - Names of thumbnails. If the field does not
|
|
37
|
+
* contain thumbnails, `never` can be used to "disable" thumbnail fields.
|
|
38
|
+
* @typeParam State - State of the field which determines its shape.
|
|
39
|
+
* @see Image field documentation: {@link https://prismic.io/docs/core-concepts/image}
|
|
40
|
+
*/
|
|
41
|
+
export type ImageField<
|
|
42
|
+
// `null` is included for backwards compatibility with older versions of
|
|
43
|
+
// this package. `null` should be treated as deprecated. `never` is
|
|
44
|
+
// preferred.
|
|
45
|
+
ThumbnailNames extends string | null = never,
|
|
46
|
+
State extends FieldState = FieldState,
|
|
47
|
+
> =
|
|
48
|
+
// Simplify is necessary. Without it, Group and Slice types break for
|
|
49
|
+
// unknown reasons. If you know why, please update this comment with an
|
|
50
|
+
// explanation. :)
|
|
51
|
+
Simplify<
|
|
52
|
+
// This `extends` and duplicated type is necessary. Without it,
|
|
53
|
+
// TypeScript cannot correct narrow "filled" and "empty" types with the
|
|
54
|
+
// `isFilled.image()` helper.
|
|
55
|
+
//
|
|
56
|
+
// Futhermore, duplicating rather than abstracting the type to
|
|
57
|
+
// a secondary "_ImageFieldImage"-like type is preferred. If the
|
|
58
|
+
// type was abstracted, TypeScript's language server would
|
|
59
|
+
// return the abstracted type's name rather than the clearer
|
|
60
|
+
// version written below. This version leads to a better code
|
|
61
|
+
// editor experience.
|
|
62
|
+
State extends "filled"
|
|
63
|
+
? ImageFieldImage<State> &
|
|
64
|
+
Record<Extract<ThumbnailNames, string>, ImageFieldImage<State>>
|
|
65
|
+
: ImageFieldImage<State> &
|
|
66
|
+
Record<Extract<ThumbnailNames, string>, ImageFieldImage<State>>
|
|
67
|
+
>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FieldState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Integration Fields for Custom APIs
|
|
5
|
+
*
|
|
6
|
+
* @typeParam Data - Data from the integrated API.
|
|
7
|
+
* @typeParam State - State of the field which determines its shape.
|
|
8
|
+
* @see More details: {@link https://prismic.io/docs/core-concepts/integration-fields-setup}
|
|
9
|
+
*/
|
|
10
|
+
export type IntegrationFields<
|
|
11
|
+
Data extends Record<string, unknown> = Record<string, unknown>,
|
|
12
|
+
State extends FieldState = FieldState,
|
|
13
|
+
> = State extends "empty" ? null : Data;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FieldState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Key text field
|
|
5
|
+
*
|
|
6
|
+
* @typeParam State - State of the field which determines its shape.
|
|
7
|
+
* @see More details: {@link https://prismic.io/docs/core-concepts/key-text}
|
|
8
|
+
*/
|
|
9
|
+
export type KeyTextField<State extends FieldState = FieldState> =
|
|
10
|
+
State extends "empty" ? null | "" : string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FieldState, AnyRegularField } from "./types";
|
|
2
|
+
import type { GroupField } from "./group";
|
|
3
|
+
import type { SliceZone } from "./sliceZone";
|
|
4
|
+
import type { ContentRelationshipField } from "./contentRelationship";
|
|
5
|
+
import type { LinkToMediaField } from "./linkToMedia";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Link Types
|
|
9
|
+
*/
|
|
10
|
+
export const LinkType = {
|
|
11
|
+
Any: "Any",
|
|
12
|
+
Document: "Document",
|
|
13
|
+
Media: "Media",
|
|
14
|
+
Web: "Web",
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* For link fields that haven't been filled
|
|
19
|
+
*
|
|
20
|
+
* @typeParam Type - The type of link.
|
|
21
|
+
*/
|
|
22
|
+
export type EmptyLinkField<
|
|
23
|
+
Type extends typeof LinkType[keyof typeof LinkType] = typeof LinkType.Any,
|
|
24
|
+
> = {
|
|
25
|
+
link_type: Type | string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Link that points to external website
|
|
30
|
+
*/
|
|
31
|
+
export interface FilledLinkToWebField {
|
|
32
|
+
link_type: typeof LinkType.Web;
|
|
33
|
+
url: string;
|
|
34
|
+
target?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Link Field
|
|
39
|
+
*
|
|
40
|
+
* @typeParam TypeEnum - Type API ID of the document.
|
|
41
|
+
* @typeParam LangEnum - Language API ID of the document.
|
|
42
|
+
* @typeParam DataInterface - Data fields for the document (filled in via
|
|
43
|
+
* GraphQuery of `fetchLinks`).
|
|
44
|
+
* @typeParam State - State of the field which determines its shape.
|
|
45
|
+
*/
|
|
46
|
+
export type LinkField<
|
|
47
|
+
TypeEnum = string,
|
|
48
|
+
LangEnum = string,
|
|
49
|
+
DataInterface extends Record<
|
|
50
|
+
string,
|
|
51
|
+
AnyRegularField | GroupField | SliceZone
|
|
52
|
+
> = never,
|
|
53
|
+
State extends FieldState = FieldState,
|
|
54
|
+
> = State extends "empty"
|
|
55
|
+
? EmptyLinkField<typeof LinkType.Any>
|
|
56
|
+
:
|
|
57
|
+
| ContentRelationshipField<TypeEnum, LangEnum, DataInterface, State>
|
|
58
|
+
| FilledLinkToWebField
|
|
59
|
+
| LinkToMediaField<State>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EmptyLinkField, LinkType } from "./link";
|
|
2
|
+
import type { FieldState } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Link field that points to media
|
|
6
|
+
*
|
|
7
|
+
* @typeParam State - State of the field which determines its shape.
|
|
8
|
+
*/
|
|
9
|
+
export type LinkToMediaField<State extends FieldState = FieldState> =
|
|
10
|
+
State extends "empty"
|
|
11
|
+
? EmptyLinkField<typeof LinkType.Media>
|
|
12
|
+
: FilledLinkToMediaField;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Link that points to media
|
|
16
|
+
*/
|
|
17
|
+
export interface FilledLinkToMediaField {
|
|
18
|
+
link_type: typeof LinkType.Media;
|
|
19
|
+
name: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
url: string;
|
|
22
|
+
size: string;
|
|
23
|
+
height?: string | null;
|
|
24
|
+
width?: string | null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FieldState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Number field
|
|
5
|
+
*
|
|
6
|
+
* @typeParam State - State of the field which determines its shape.
|
|
7
|
+
* @see More details: {@link https://prismic.io/docs/core-concepts/number}
|
|
8
|
+
*/
|
|
9
|
+
export type NumberField<State extends FieldState = FieldState> =
|
|
10
|
+
State extends "empty" ? null : number;
|