@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
61 lines (59 loc) • 2.49 kB
text/typescript
import { BooleanField } from "./boolean.cjs";
import { ColorField } from "./color.cjs";
import { GroupField } from "./group.cjs";
import { ContentRelationshipField } from "./contentRelationship.cjs";
import { DateField } from "./date.cjs";
import { EmbedField } from "./embed.cjs";
import { GeoPointField } from "./geoPoint.cjs";
import { ImageField } from "./image.cjs";
import { KeyTextField } from "./keyText.cjs";
import { LinkToMediaField } from "./linkToMedia.cjs";
import { LinkField } from "./link.cjs";
import { NumberField } from "./number.cjs";
import { RichTextField } from "./richText.cjs";
import { SelectField } from "./select.cjs";
import { TableField } from "./table.cjs";
import { TimestampField } from "./timestamp.cjs";
import { TitleField } from "./title.cjs";
import { IntegrationField } from "./integration.cjs";
//#region src/types/value/types.d.ts
/**
* Empty state for object-shaped fields.
*/
type EmptyObjectField = Record<string, never>;
/**
* Valid states for fields. Not all fields use this type (e.g. BooleanField).
*/
type FieldState = "empty" | "filled";
/**
* Any regular field that can be nested in a group-like field.
*/
type AnyRegularField = TitleField | RichTextField | ImageField | ContentRelationshipField | LinkField | Repeatable<LinkField> | LinkToMediaField | EmbedField | DateField | TimestampField | ColorField | NumberField | KeyTextField | SelectField | BooleanField | GeoPointField | IntegrationField | TableField;
/**
* Any field that can be used in a slice's primary section.
*/
type AnySlicePrimaryField = GroupField | AnyRegularField;
/**
* A list of repeatable fields.
*/
type Repeatable<Field extends LinkField, State extends FieldState = FieldState> = State extends "empty" ? [] : [WithKey<Field>, ...WithKey<Field>[]];
/**
* Wrapper to add a key to a field when inside a repeatable.
*/
type WithKey<Field extends LinkField> = Field & {
key: string;
};
/**
* Useful to flatten the type output to improve type hints shown in editors. And
* also to transform an interface into a type to aide with assignability.
*
* Taken from the `type-fest` package.
*
* @typeParam T - The type to simplify.
*
* @see https://github.com/sindresorhus/type-fest/blob/cbd7ec510bd136ac045bbc74e391ee686b8a9a2f/source/simplify.d.ts
*/
type Simplify<T> = { [P in keyof T]: T[P] };
//#endregion
export { AnyRegularField, AnySlicePrimaryField, EmptyObjectField, FieldState, Repeatable, Simplify };
//# sourceMappingURL=types.d.cts.map