UNPKG

@prismicio/helpers

Version:
157 lines (156 loc) 7.73 kB
import type { AnyOEmbed, AnyRegularField, ColorField, DateField, GeoPointField, GroupField, ImageField, ImageFieldImage, IntegrationFields, KeyTextField, LinkField, LinkToMediaField, NumberField, RelationField, RichTextField, SelectField, SharedSlice, Slice, SliceZone, TimestampField, TitleField } from "@prismicio/types"; /** * Determines if a Rich Text field is filled. * * @param field - Rich Text field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const richText: (field: RichTextField | null | undefined) => field is [import("@prismicio/types").RTNode, ...import("@prismicio/types").RTNode[]]; /** * Determines if a Title field is filled. * * @param field - Title field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const title: (field: TitleField | null | undefined) => field is [Omit<import("@prismicio/types").RTHeading1Node | import("@prismicio/types").RTHeading2Node | import("@prismicio/types").RTHeading3Node | import("@prismicio/types").RTHeading4Node | import("@prismicio/types").RTHeading5Node | import("@prismicio/types").RTHeading6Node, "spans"> & { spans: []; }]; /** * Determines if an Image thumbnail is filled. * * @param thumbnail - Image thumbnail to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const imageThumbnail: (thumbnail: ImageFieldImage | null | undefined) => thumbnail is import("@prismicio/types").FilledImageFieldImage; /** * Determines if an Image field is filled. * * @param field - Image field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const image: <ThumbnailNames extends string | null = never>(field: import("@prismicio/types/dist/value/types").Simplify<(import("@prismicio/types").EmptyImageFieldImage | import("@prismicio/types").FilledImageFieldImage) & Record<Exclude<Extract<ThumbnailNames, string>, "url" | "dimensions" | "alt" | "copyright">, import("@prismicio/types").EmptyImageFieldImage | import("@prismicio/types").FilledImageFieldImage>> | null | undefined) => field is import("@prismicio/types/dist/value/types").Simplify<import("@prismicio/types").FilledImageFieldImage & Record<Exclude<Extract<ThumbnailNames, string>, "url" | "dimensions" | "alt" | "copyright">, import("@prismicio/types").FilledImageFieldImage>>; /** * Determines if a Link field is filled. * * @param field - Link field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const link: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: import("@prismicio/types").EmptyLinkField<"Any"> | import("@prismicio/types").FilledLinkToWebField | import("@prismicio/types").FilledLinkToMediaField | import("@prismicio/types").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("@prismicio/types").FilledLinkToWebField | import("@prismicio/types").FilledLinkToMediaField | import("@prismicio/types").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>; /** * Determines if a Link to Media field is filled. * * @param field - Link to Media field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const linkToMedia: (field: LinkToMediaField | null | undefined) => field is import("@prismicio/types").FilledLinkToMediaField; /** * Determines if a Content Relationship field is filled. * * @param field - Content Relationship field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const contentRelationship: <TypeEnum = string, LangEnum = string, DataInterface extends unknown = unknown>(field: import("@prismicio/types").EmptyLinkField<"Document"> | import("@prismicio/types").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface> | null | undefined) => field is import("@prismicio/types").FilledContentRelationshipField<TypeEnum, LangEnum, DataInterface>; /** * Determines if a Date field is filled. * * @param field - Date field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const date: (field: DateField | null | undefined) => field is `${number}-${number}-${number}`; /** * Determines if a Timestamp field is filled. * * @param field - Timestamp field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const timestamp: (field: TimestampField | null | undefined) => field is `${number}-${number}-${number}T${number}:${number}:${number}+${number}`; /** * Determines if a Color field is filled. * * @param field - Color field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const color: (field: ColorField | null | undefined) => field is `#${string}`; /** * Determines if a Number field is filled. * * @param field - Number field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const number: (field: NumberField | null | undefined) => field is number; /** * Determines if a Key Text field is filled. * * @param field - Key Text field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const keyText: (field: KeyTextField | null | undefined) => field is string; /** * Determines if a Select field is filled. * * @param field - Select field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const select: <Enum extends string>(field: Enum | null | undefined) => field is Enum; /** * Determines if an Embed field is filled. * * @param field - Embed field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const embed: <Field extends import("@prismicio/types/dist/value/types").EmptyObjectField | (AnyOEmbed & { embed_url: string; html: string | null; })>(field: Field | null | undefined) => field is Extract<Field, AnyOEmbed & { embed_url: string; html: string | null; }>; /** * Determines if a GeoPoint field is filled. * * @param field - GeoPoint field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const geoPoint: (field: GeoPointField | null | undefined) => field is { latitude: number; longitude: number; }; /** * Determines if an Integration Fields field is filled. * * @param field - Integration Fields field to check. * * @returns `true` if `field` is filled, `false` otherwise. */ export declare const integrationFields: <Data extends Record<string, unknown>>(field: Data | null | undefined) => field is Data; /** * Determines if a Group has at least one item. * * @param group - Group to check. * * @returns `true` if `group` contains at least one item, `false` otherwise. */ export declare const group: <Fields extends Record<string, AnyRegularField>>(group: [] | [Fields, ...Fields[]] | null | undefined) => group is [Fields, ...Fields[]]; /** * Determines if a Slice Zone has at least one Slice. * * @param slices - Slice Zone to check. * * @returns `true` if `slices` contains at least one Slice, `false` otherwise. */ export declare const sliceZone: <Slices extends Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, import("@prismicio/types").SharedSliceVariation<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>>>>(slices: [] | [Slices, ...Slices[]] | null | undefined) => slices is [Slices, ...Slices[]];