@prismicio/client 6.7.0 → 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} +16 -52
- 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,96 @@
|
|
|
1
|
+
import escapeHtml from "escape-html";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
RTBlockNode,
|
|
5
|
+
RTInlineNode,
|
|
6
|
+
RTPreformattedNode,
|
|
7
|
+
RTImageNode,
|
|
8
|
+
RTEmbedNode,
|
|
9
|
+
RTLinkNode,
|
|
10
|
+
RichTextNodeType,
|
|
11
|
+
} from "../types/value/richText";
|
|
12
|
+
import { LinkType } from "../types/value/link";
|
|
13
|
+
import { LinkResolverFunction } from "../types/helpers";
|
|
14
|
+
|
|
15
|
+
import { asLink } from "../helpers/asLink";
|
|
16
|
+
|
|
17
|
+
export const getLabel = (node: RTBlockNode | RTInlineNode): string => {
|
|
18
|
+
return "data" in node && "label" in node.data
|
|
19
|
+
? ` class="${node.data.label}"`
|
|
20
|
+
: "";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const serializeStandardTag = (
|
|
24
|
+
tag: string,
|
|
25
|
+
node: RTBlockNode | RTInlineNode,
|
|
26
|
+
children: string[],
|
|
27
|
+
): string => {
|
|
28
|
+
return `<${tag}${getLabel(node)}>${children.join("")}</${tag}>`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const serializePreFormatted = (node: RTPreformattedNode): string => {
|
|
32
|
+
return `<pre${getLabel(node)}>${escapeHtml(node.text)}</pre>`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const serializeImage = (
|
|
36
|
+
linkResolver: LinkResolverFunction<string> | undefined | null,
|
|
37
|
+
node: RTImageNode,
|
|
38
|
+
): string => {
|
|
39
|
+
let imageTag = `<img src="${node.url}" alt="${escapeHtml(node.alt)}"${
|
|
40
|
+
node.copyright ? ` copyright="${escapeHtml(node.copyright)}"` : ""
|
|
41
|
+
} />`;
|
|
42
|
+
|
|
43
|
+
// If the image has a link, we wrap it with an anchor tag
|
|
44
|
+
if (node.linkTo) {
|
|
45
|
+
imageTag = serializeHyperlink(
|
|
46
|
+
linkResolver,
|
|
47
|
+
{
|
|
48
|
+
type: RichTextNodeType.hyperlink,
|
|
49
|
+
data: node.linkTo,
|
|
50
|
+
start: 0,
|
|
51
|
+
end: 0,
|
|
52
|
+
},
|
|
53
|
+
[imageTag],
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `<p class="block-img">${imageTag}</p>`;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const serializeEmbed = (node: RTEmbedNode): string => {
|
|
61
|
+
return `<div data-oembed="${node.oembed.embed_url}" data-oembed-type="${
|
|
62
|
+
node.oembed.type
|
|
63
|
+
}" data-oembed-provider="${node.oembed.provider_name}"${getLabel(node)}>${
|
|
64
|
+
node.oembed.html
|
|
65
|
+
}</div>`;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const serializeHyperlink = (
|
|
69
|
+
linkResolver: LinkResolverFunction | undefined | null,
|
|
70
|
+
node: RTLinkNode,
|
|
71
|
+
children: string[],
|
|
72
|
+
): string => {
|
|
73
|
+
switch (node.data.link_type) {
|
|
74
|
+
case LinkType.Web: {
|
|
75
|
+
return `<a href="${escapeHtml(node.data.url)}" ${
|
|
76
|
+
node.data.target ? `target="${node.data.target}" ` : ""
|
|
77
|
+
}rel="noopener noreferrer"${getLabel(node)}>${children.join("")}</a>`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
case LinkType.Document: {
|
|
81
|
+
return `<a href="${asLink(node.data, linkResolver)}"${getLabel(
|
|
82
|
+
node,
|
|
83
|
+
)}>${children.join("")}</a>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case LinkType.Media: {
|
|
87
|
+
return `<a href="${node.data.url}"${getLabel(node)}>${children.join(
|
|
88
|
+
"",
|
|
89
|
+
)}</a>`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const serializeSpan = (content?: string): string => {
|
|
95
|
+
return content ? escapeHtml(content).replace(/\n/g, "<br />") : "";
|
|
96
|
+
};
|
package/src/predicate.ts
CHANGED
|
@@ -30,7 +30,8 @@ const formatValue = (
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* Creates a predicate builder function for predicates with a path and
|
|
33
|
+
* Creates a predicate builder function for predicates with a path and
|
|
34
|
+
* arguments.
|
|
34
35
|
*
|
|
35
36
|
* @typeParam Args - Arguments for the predicate.
|
|
36
37
|
* @param name - Name of the predicate used in the resulting string.
|
|
@@ -72,7 +73,8 @@ const pathPredicate = (name: string) => {
|
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
|
-
* Creates a predicate builder function for predicates with only arguments and
|
|
76
|
+
* Creates a predicate builder function for predicates with only arguments and
|
|
77
|
+
* no path.
|
|
76
78
|
*
|
|
77
79
|
* @param name - Name of the predicate used in the resulting string.
|
|
78
80
|
*
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PrismicDocument } from "../value/document";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A query response from the Prismic REST API V2. The response contains
|
|
5
|
+
* paginated metadata and a list of matching results for the query.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam Document - The type(s) of Prismic document that can be returned.
|
|
8
|
+
* @see More details on querying: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api}
|
|
9
|
+
*/
|
|
10
|
+
export interface Query<Document extends PrismicDocument = PrismicDocument> {
|
|
11
|
+
/**
|
|
12
|
+
* The page number for this page of results.
|
|
13
|
+
*/
|
|
14
|
+
page: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of results per page.
|
|
18
|
+
*/
|
|
19
|
+
results_per_page: number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Number of results in this page.
|
|
23
|
+
*/
|
|
24
|
+
results_size: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Total number of results within all pages.
|
|
28
|
+
*/
|
|
29
|
+
total_results_size: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Total number of pages.
|
|
33
|
+
*/
|
|
34
|
+
total_pages: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The Prismic REST API V2 URL to the next page, if one exists.
|
|
38
|
+
*/
|
|
39
|
+
next_page: string | null;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The Prismic REST API V2 URL to the previous page, if one exists.
|
|
43
|
+
*/
|
|
44
|
+
prev_page: string | null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A paginated list of documents matching the query.
|
|
48
|
+
*/
|
|
49
|
+
results: Document[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata for a reference to a version of a repository's content.
|
|
3
|
+
*
|
|
4
|
+
* @see More details on refs: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#prismic-api-ref}
|
|
5
|
+
*/
|
|
6
|
+
export interface Ref {
|
|
7
|
+
/**
|
|
8
|
+
* The unique identifier for the ref.
|
|
9
|
+
*/
|
|
10
|
+
id: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The identifier that should be provided to the API to select a content
|
|
14
|
+
* version.
|
|
15
|
+
*/
|
|
16
|
+
ref: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A human-readable name for the ref. The master ref is always named "Master".
|
|
20
|
+
*/
|
|
21
|
+
label: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Determines if the ref is the master ref. The master ref contains the latest
|
|
25
|
+
* published content.
|
|
26
|
+
*/
|
|
27
|
+
isMasterRef: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* If the ref is associated with a Release, this field contains the timestamp
|
|
31
|
+
* at which the Release will be automatically published, if set.
|
|
32
|
+
*
|
|
33
|
+
* @see More details on Releases: {@link https://prismic.io/docs/core-concepts/draft-plan-and-schedule-content#releases}
|
|
34
|
+
*/
|
|
35
|
+
scheduledAt?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from "./ref";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Metadata for a Release.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This is an alias for `Ref`.
|
|
8
|
+
* @see {@link Ref}
|
|
9
|
+
* @see More details on Releases: {@link https://prismic.io/docs/core-concepts/draft-plan-and-schedule-content#releases}
|
|
10
|
+
*/
|
|
11
|
+
export type Release = Ref;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Ref } from "./ref";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Repository metadata returned from the Prismic REST API V2. This data can be
|
|
5
|
+
* fetched by sending a `GET` a request to a repository's `/api/v2` endpoint.
|
|
6
|
+
*
|
|
7
|
+
* @see More details on the `/api/v2` endpoint: {@link https://prismic.io/docs/technologies/introduction-to-the-content-query-api#the-api-endpoint-2}
|
|
8
|
+
*/
|
|
9
|
+
export interface Repository {
|
|
10
|
+
/**
|
|
11
|
+
* A list of refs for the repository.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link Ref}
|
|
14
|
+
*/
|
|
15
|
+
refs: Ref[];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An identifier used to query content with the latest Integration Fields
|
|
19
|
+
* data.
|
|
20
|
+
*/
|
|
21
|
+
integrationFieldsRef: string | null;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A list of languages for the repository.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link Language}
|
|
27
|
+
*/
|
|
28
|
+
languages: Language[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A list of the repository's Custom Type API IDs mapped to their
|
|
32
|
+
* human-readable name.
|
|
33
|
+
*/
|
|
34
|
+
types: Record<string, string>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A list of tags for the repository.
|
|
38
|
+
*/
|
|
39
|
+
tags: string[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An internally-used list of REST API features for the repository.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
forms: Record<string, Form>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The URL used to begin the OAuth process for the repository.
|
|
50
|
+
*/
|
|
51
|
+
oauth_initiate: string;
|
|
52
|
+
|
|
53
|
+
// TODO: Describe this field
|
|
54
|
+
oauth_token: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The version of the API.
|
|
58
|
+
*/
|
|
59
|
+
version: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Licensing information for the repository content.
|
|
63
|
+
*/
|
|
64
|
+
license: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Experiments are no longer part of Prismic.
|
|
68
|
+
*/
|
|
69
|
+
experiments: unknown;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Bookmarks are not longer part of Prismic.
|
|
73
|
+
*/
|
|
74
|
+
bookmarks: Record<string, string>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Metadata for a language that has been configured for a repository.
|
|
79
|
+
*/
|
|
80
|
+
export interface Language {
|
|
81
|
+
/**
|
|
82
|
+
* A unique identifier for the language.
|
|
83
|
+
*/
|
|
84
|
+
id: string;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The name of the language.
|
|
88
|
+
*/
|
|
89
|
+
name: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A Prismic REST API V2 feature supported by the repository. It contains
|
|
94
|
+
* metadata about the feature and how to interact with it via the API.
|
|
95
|
+
*
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
export interface Form {
|
|
99
|
+
method: "GET";
|
|
100
|
+
enctype: string;
|
|
101
|
+
action: string;
|
|
102
|
+
name?: string;
|
|
103
|
+
rel?: string;
|
|
104
|
+
fields: Record<string, FormField>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A field for a feature of the Prismic REST API V2. It contains metadata about
|
|
109
|
+
* the feature's field and how to interact with it via the API.
|
|
110
|
+
*
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
export interface FormField {
|
|
114
|
+
type: "String" | "Integer";
|
|
115
|
+
multiple: boolean;
|
|
116
|
+
default?: string;
|
|
117
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of tags returned from the Prismic Tags API. This data can be fetched by
|
|
3
|
+
* sending a `GET` request to a repository's `/api/tags` endpoint.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam Tag - Tags that are returned by the Tags API.
|
|
6
|
+
* @see More details on the Tags API: {@link https://prismic.io/docs/technologies/tags-api-technical-reference}
|
|
7
|
+
*/
|
|
8
|
+
export type Tags<Tag extends string = string> = Tag[];
|
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create a union of the given object's values, and optionally specify which
|
|
5
|
-
* keys to get the values from.
|
|
6
|
-
*
|
|
7
|
-
* Taken from the `type-fest` package.
|
|
8
|
-
*
|
|
9
|
-
* See:
|
|
10
|
-
* https://github.com/sindresorhus/type-fest/blob/61c35052f09caa23de5eef96d95196375d8ed498/source/value-of.d.ts
|
|
11
|
-
*/
|
|
12
|
-
export type ValueOf<
|
|
13
|
-
ObjectType,
|
|
14
|
-
ValueType extends keyof ObjectType = keyof ObjectType,
|
|
15
|
-
> = ObjectType[ValueType];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Functions like TypeScript's native `Extract` utility type with added support
|
|
19
|
-
* to fall back to a value if the resulting union is `never`.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* ExtractOrFallback<"a" | "b", "a"> // => "a"
|
|
25
|
-
* ExtractOrFallback<"a" | "b", "c"> // => "a" | "b"
|
|
26
|
-
* ExtractOrFallback<"a" | "b", "c", "foo"> // => "foo"
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @typeParam T - The union from which values will be extracted.
|
|
30
|
-
* @typeParam U - The extraction condition.
|
|
31
|
-
* @typeParam Fallback - The value to return if the resulting union is `never`.
|
|
32
|
-
* Defaults to `T`.
|
|
33
|
-
*/
|
|
34
|
-
type ExtractOrFallback<T, U, Fallback = T> = Extract<T, U> extends never
|
|
35
|
-
? Fallback
|
|
36
|
-
: Extract<T, U>;
|
|
1
|
+
import { PrismicDocument } from "./value/document";
|
|
2
|
+
import { ExtractOrFallback } from "./utils";
|
|
37
3
|
|
|
38
4
|
/**
|
|
39
5
|
* Extracts one or more Prismic document types that match a given Prismic
|
|
@@ -44,7 +10,7 @@ type ExtractOrFallback<T, U, Fallback = T> = Extract<T, U> extends never
|
|
|
44
10
|
* @typeParam TDocumentType - Type(s) to match `TDocuments` against.
|
|
45
11
|
*/
|
|
46
12
|
export type ExtractDocumentType<
|
|
47
|
-
TDocuments extends
|
|
13
|
+
TDocuments extends PrismicDocument,
|
|
48
14
|
TDocumentType extends TDocuments["type"],
|
|
49
15
|
> = ExtractOrFallback<TDocuments, { type: TDocumentType }>;
|
|
50
16
|
|
|
@@ -68,27 +34,25 @@ export type FetchLike = (
|
|
|
68
34
|
// different AbortSignal implementations. The types of each property are not
|
|
69
35
|
// important to validate since it is blindly passed to a given `fetch()`
|
|
70
36
|
// function.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
aborted: any;
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
addEventListener: any;
|
|
76
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
removeEventListener: any;
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
dispatchEvent: any;
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
onabort: any;
|
|
82
|
-
};
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
export type AbortSignalLike = any;
|
|
83
39
|
|
|
84
40
|
/**
|
|
85
41
|
* The minimum required properties from RequestInit.
|
|
86
42
|
*/
|
|
87
43
|
export interface RequestInitLike {
|
|
88
44
|
headers?: Record<string, string>;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* An object that allows you to abort a `fetch()` request if needed via an
|
|
48
|
+
* `AbortController` object
|
|
49
|
+
*
|
|
50
|
+
* {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal}
|
|
51
|
+
*/
|
|
52
|
+
// NOTE: `AbortSignalLike` is `any`! It is left as `AbortSignalLike`
|
|
53
|
+
// for backwards compatibility (the type is exported) and to signal to
|
|
54
|
+
// other readers that this should be an AbortSignal-like object.
|
|
55
|
+
signal?: AbortSignalLike;
|
|
92
56
|
}
|
|
93
57
|
|
|
94
58
|
/**
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RichTextFunctionSerializer,
|
|
3
|
+
RichTextMapSerializer,
|
|
4
|
+
RichTextMapSerializerFunction,
|
|
5
|
+
} from "@prismicio/richtext";
|
|
6
|
+
|
|
7
|
+
import { FilledContentRelationshipField } from "./value/contentRelationship";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resolves a link to a Prismic document to a URL
|
|
11
|
+
*
|
|
12
|
+
* @typeParam ReturnType - Return type of your link resolver function, useful if
|
|
13
|
+
* you prefer to return a complex object
|
|
14
|
+
* @param linkToDocumentField - A document link field to resolve
|
|
15
|
+
*
|
|
16
|
+
* @returns Resolved URL
|
|
17
|
+
* @see Prismic link resolver documentation: {@link https://prismic.io/docs/technologies/link-resolver-javascript}
|
|
18
|
+
*/
|
|
19
|
+
export type LinkResolverFunction<ReturnType = string> = (
|
|
20
|
+
linkToDocumentField: FilledContentRelationshipField,
|
|
21
|
+
) => ReturnType;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Serializes a node from a rich text or title field with a function to HTML
|
|
25
|
+
*
|
|
26
|
+
* Unlike a typical `@prismicio/richtext` function serializer, this serializer
|
|
27
|
+
* converts the `children` argument to a single string rather than an array of
|
|
28
|
+
* strings.
|
|
29
|
+
*
|
|
30
|
+
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
31
|
+
*/
|
|
32
|
+
export type HTMLFunctionSerializer = (
|
|
33
|
+
type: Parameters<RichTextFunctionSerializer<string>>[0],
|
|
34
|
+
node: Parameters<RichTextFunctionSerializer<string>>[1],
|
|
35
|
+
text: Parameters<RichTextFunctionSerializer<string>>[2],
|
|
36
|
+
children: Parameters<RichTextFunctionSerializer<string>>[3][number],
|
|
37
|
+
key: Parameters<RichTextFunctionSerializer<string>>[4],
|
|
38
|
+
) => string | null | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Serializes a node from a rich text or title field with a map to HTML
|
|
42
|
+
*
|
|
43
|
+
* Unlike a typical `@prismicio/richtext` map serializer, this serializer
|
|
44
|
+
* converts the `children` property to a single string rather than an array of
|
|
45
|
+
* strings.
|
|
46
|
+
*
|
|
47
|
+
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
|
|
48
|
+
*/
|
|
49
|
+
export type HTMLMapSerializer = {
|
|
50
|
+
[P in keyof RichTextMapSerializer<string>]: (payload: {
|
|
51
|
+
type: Parameters<HTMLMapSerializerFunction<P>>[0]["type"];
|
|
52
|
+
node: Parameters<HTMLMapSerializerFunction<P>>[0]["node"];
|
|
53
|
+
text: Parameters<HTMLMapSerializerFunction<P>>[0]["text"];
|
|
54
|
+
children: Parameters<HTMLMapSerializerFunction<P>>[0]["children"][number];
|
|
55
|
+
key: Parameters<HTMLMapSerializerFunction<P>>[0]["key"];
|
|
56
|
+
}) => string | null | undefined;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A {@link RichTextMapSerializerFunction} type specifically for
|
|
61
|
+
* {@link HTMLMapSerializer}.
|
|
62
|
+
*
|
|
63
|
+
* @typeParam BlockName - The serializer's Rich Text block type.
|
|
64
|
+
*/
|
|
65
|
+
type HTMLMapSerializerFunction<
|
|
66
|
+
BlockType extends keyof RichTextMapSerializer<string>,
|
|
67
|
+
> = RichTextMapSerializerFunction<
|
|
68
|
+
string,
|
|
69
|
+
ExtractNodeGeneric<RichTextMapSerializer<string>[BlockType]>,
|
|
70
|
+
ExtractTextTypeGeneric<RichTextMapSerializer<string>[BlockType]>
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the `Node` generic from {@link RichTextMapSerializerFunction}.
|
|
75
|
+
*
|
|
76
|
+
* @typeParam T - The `RichTextMapSerializerFunction` containing the needed
|
|
77
|
+
* `Node` generic.
|
|
78
|
+
*/
|
|
79
|
+
type ExtractNodeGeneric<T> = T extends RichTextMapSerializerFunction<
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
any,
|
|
82
|
+
infer U,
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
any
|
|
85
|
+
>
|
|
86
|
+
? U
|
|
87
|
+
: never;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns the `TextType` generic from {@link RichTextMapSerializerFunction}.
|
|
91
|
+
*
|
|
92
|
+
* @typeParam T - The `RichTextMapSerializerFunction` containing the needed
|
|
93
|
+
* `TextType` generic.
|
|
94
|
+
*/
|
|
95
|
+
type ExtractTextTypeGeneric<T> = T extends RichTextMapSerializerFunction<
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
any,
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
any,
|
|
100
|
+
infer U
|
|
101
|
+
>
|
|
102
|
+
? U
|
|
103
|
+
: never;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CustomTypeModelFieldType } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Boolean Custom Type field.
|
|
5
|
+
*
|
|
6
|
+
* More details: {@link https://prismic.io/docs/core-concepts/boolean}
|
|
7
|
+
*/
|
|
8
|
+
export interface CustomTypeModelBooleanField {
|
|
9
|
+
type: typeof CustomTypeModelFieldType.Boolean;
|
|
10
|
+
config?: {
|
|
11
|
+
label?: string | null;
|
|
12
|
+
default_value?: boolean;
|
|
13
|
+
placeholder_true?: string;
|
|
14
|
+
placeholder_false?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CustomTypeModelFieldType } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Color Custom Type field.
|
|
5
|
+
*
|
|
6
|
+
* More details: {@link https://prismic.io/docs/core-concepts/color}
|
|
7
|
+
*/
|
|
8
|
+
export interface CustomTypeModelColorField {
|
|
9
|
+
type: typeof CustomTypeModelFieldType.Color;
|
|
10
|
+
config?: {
|
|
11
|
+
label?: string | null;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CustomTypeModelFieldType } from "./types";
|
|
2
|
+
import type { CustomTypeModelLinkSelectType } from "./link";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A Content Relationship Custom Type field.
|
|
6
|
+
*
|
|
7
|
+
* More details:
|
|
8
|
+
* {@link https://prismic.io/docs/core-concepts/link-content-relationship}
|
|
9
|
+
*/
|
|
10
|
+
export interface CustomTypeModelContentRelationshipField<
|
|
11
|
+
CustomTypeIDs extends string = string,
|
|
12
|
+
Tags extends string = string,
|
|
13
|
+
> {
|
|
14
|
+
type: typeof CustomTypeModelFieldType.Link;
|
|
15
|
+
config?: {
|
|
16
|
+
label?: string | null;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
select: typeof CustomTypeModelLinkSelectType.Document;
|
|
19
|
+
customtypes?: readonly CustomTypeIDs[];
|
|
20
|
+
tags?: readonly Tags[];
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CustomTypeModelField } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Prismic Custom Type model.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam ID - API ID of the Custom Type.
|
|
7
|
+
* @typeParam Definition - The Custom Type's tabs and their fields.
|
|
8
|
+
*/
|
|
9
|
+
export interface CustomTypeModel<
|
|
10
|
+
ID extends string = string,
|
|
11
|
+
Definition extends CustomTypeModelDefinition = CustomTypeModelDefinition,
|
|
12
|
+
> {
|
|
13
|
+
/**
|
|
14
|
+
* The ID of the Custom Type model.
|
|
15
|
+
*/
|
|
16
|
+
id: ID;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The human readable name of the Custom Type Model.
|
|
20
|
+
*/
|
|
21
|
+
// TODO: Revert to `label?: string | null` if `label` can be partial in: https://github.com/prismicio/prismic-types-internal/blob/HEAD/src/customtypes/CustomType.ts#L39
|
|
22
|
+
label: string | null | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Determines if more than one document for the Custom Type can be created.
|
|
26
|
+
*/
|
|
27
|
+
repeatable: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The Custom Type model definition.
|
|
31
|
+
*/
|
|
32
|
+
json: Definition;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Determines if new documents for the Custom Type can be created.
|
|
36
|
+
*/
|
|
37
|
+
status: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A Prismic Custom Type's tabs and their fields.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam TabName - Names of Custom Type tabs.
|
|
44
|
+
*/
|
|
45
|
+
export type CustomTypeModelDefinition<TabName extends string = string> = Record<
|
|
46
|
+
TabName,
|
|
47
|
+
CustomTypeModelTab
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A Custom Type's tab. Each tab can contain any number of fields but is limited
|
|
52
|
+
* to one Slice Zone.
|
|
53
|
+
*
|
|
54
|
+
* @typeParam FieldName - API IDs of the fields.
|
|
55
|
+
*/
|
|
56
|
+
export type CustomTypeModelTab<
|
|
57
|
+
Fields extends Record<string, CustomTypeModelField> = Record<
|
|
58
|
+
string,
|
|
59
|
+
CustomTypeModelField
|
|
60
|
+
>,
|
|
61
|
+
> = Fields;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CustomTypeModelFieldType } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Date Custom Type field.
|
|
5
|
+
*
|
|
6
|
+
* More details: {@link https://prismic.io/docs/core-concepts/date}
|
|
7
|
+
*/
|
|
8
|
+
export interface CustomTypeModelDateField {
|
|
9
|
+
type: typeof CustomTypeModelFieldType.Date;
|
|
10
|
+
config?: {
|
|
11
|
+
label?: string | null;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
default?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CustomTypeModelFieldType } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An Embed Custom Type field.
|
|
5
|
+
*
|
|
6
|
+
* More details: {@link https://prismic.io/docs/core-concepts/embed}
|
|
7
|
+
*/
|
|
8
|
+
export interface CustomTypeModelEmbedField {
|
|
9
|
+
type: typeof CustomTypeModelFieldType.Embed;
|
|
10
|
+
config?: {
|
|
11
|
+
label?: string | null;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|