import type * as DmTypes from '../generated/dm-types'; import { DataType } from '../generated/dm-types'; export { DataType } from '../generated/dm-types'; /** * Viewer-derived fields added by the SDK to all link types. * - `displayName`: human-readable label resolved by editor * - `href`: resolved URL (viewer concern, not stored in DM) * - `rel`: normalized to space-separated string (DM stores as enum array) * - `pageRole`: for unresolved dynamic pages links - can be used to properly resolve link by applications */ type ElementLinkExtension = { displayName: string; href?: string; rel?: string; pageRole?: string; }; export type ElementPageLink = DmTypes.PageLink & ElementLinkExtension & { type: 'PageLink'; }; export type ElementExternalLink = DmTypes.ExternalLink & ElementLinkExtension & { type: 'ExternalLink'; }; export type ElementEmailLink = DmTypes.EmailLink & ElementLinkExtension & { type: 'EmailLink'; }; export type ElementPhoneLink = DmTypes.PhoneLink & ElementLinkExtension & { type: 'PhoneLink'; }; export type ElementWhatsAppLink = DmTypes.WhatsAppLink & ElementLinkExtension & { type: 'WhatsAppLink'; }; export type ElementAddressLink = DmTypes.AddressLink & ElementLinkExtension & { type: 'AddressLink'; }; export type ElementAnchorLink = DmTypes.AnchorLink & ElementLinkExtension & { type: 'AnchorLink'; }; export type ElementDocumentLink = DmTypes.DocumentLink & ElementLinkExtension & { type: 'DocumentLink'; }; export type ElementDynamicPageLink = DmTypes.DynamicPageLink & ElementLinkExtension & { type: 'DynamicPageLink'; }; export type ElementAppPageLink = DmTypes.AppPageLink & ElementLinkExtension & { type: 'AppPageLink'; }; export type ElementTpaPageLink = DmTypes.AppPageLink & ElementLinkExtension & { type: 'TpaPageLink'; }; export type ElementLoginToWixLink = DmTypes.LoginToWixLink & ElementLinkExtension & { type: 'LoginToWixLink'; }; export type ElementTextLink = DmTypes.TextLink & ElementLinkExtension & { type: 'TextLink'; }; export type ElementLink = ElementPageLink | ElementExternalLink | ElementEmailLink | ElementPhoneLink | ElementWhatsAppLink | ElementAddressLink | ElementAnchorLink | ElementDocumentLink | ElementDynamicPageLink | ElementTpaPageLink | ElementAppPageLink | ElementLoginToWixLink | ElementTextLink; export type ElementImage = DmTypes.Image; export interface ElementVideo { /** * Video media identifier. * @maxLength 1000 */ uri: string; /** * Available video sources in different qualities. * @maxSize 20 */ sources?: { quality: '1080p' | '720p' | '480p' | '360p'; width: number; height: number; types: { format: 'mp4' | 'mp4-luminance'; uri: string; }[]; }[]; /** * Adaptive streaming sources. * @maxSize 10 */ adaptiveSources?: { format: 'hls' | 'dash'; uri: string; }[]; /** Whether the video contains an audio track. */ hasAudio?: boolean; /** Frames per second. */ fps?: number; /** * ORIGINAL video poster field is a string URL */ poster?: { uri: string; name?: string; width?: number; height?: number; }; /** Duration in seconds. */ duration?: number; /** * Display name of the video. * @maxLength 100 */ name?: string; } export type ElementAudio = DmTypes.Audio; export type ElementVectorArt = DmTypes.VectorArt; export type ElementA11y = DmTypes.A11y; export type ElementDirection = DmTypes.Direction; export type ElementMenuItem = Omit & { link?: ElementLink; items?: ElementMenuItem[]; }; export type ElementMenuItems = Omit & { items?: ElementMenuItem[]; }; export type ElementRichText = Omit & { linkList?: ElementLink[]; }; export type ElementFunctionDefinition = DmTypes._Function; type ElementFilterPrimitive = boolean | number | string; type ElementFilterValue = ElementFilterPrimitive | boolean[] | number[] | string[]; type ElementFilterFieldConditions = Partial>; type ElementFilterLogicalClauses = { $and?: ElementFilter[]; $not?: ElementFilter[]; $or?: ElementFilter[]; }; export type ElementFilter = Record | ElementFilterLogicalClauses; type ElementSortOrder = Exclude; export type ElementSort = { fieldName: string; order: ElementSortOrder; }[]; export type ElementDataValue = string | number | boolean | ElementLink | ElementImage | ElementVideo | ElementAudio | ElementVectorArt | ElementMenuItems | ElementA11y | ElementRichText | ElementFunctionDefinition | ElementDirection | ElementFilter | ElementSort | ElementDataObject | ElementDataValue[] | null | undefined; export type ElementDataObject = { [key: string]: ElementDataValue; }; export type ElementData = T; export type ElementDataInput = Partial; export type ElementDataTypeMap = { [DataType.text]: string; [DataType.textEnum]: string; [DataType.number]: number; [DataType.booleanValue]: boolean; [DataType.a11y]: ElementA11y; [DataType.link]: ElementLink; [DataType.image]: ElementImage; [DataType.video]: ElementVideo; [DataType.vectorArt]: ElementVectorArt; [DataType.audio]: ElementAudio; [DataType.localDate]: string; [DataType.localTime]: string; [DataType.localDateTime]: string; [DataType.webUrl]: string; [DataType.email]: string; [DataType.phone]: string; [DataType.hostname]: string; [DataType.regex]: string; [DataType.guid]: string; [DataType.richText]: ElementRichText; [DataType.container]: ElementDataObject | string; [DataType.arrayItems]: ElementDataValue[]; [DataType.direction]: ElementDirection; [DataType.menuItems]: ElementMenuItems; [DataType.data]: ElementDataObject; [DataType.onClick]: ElementFunctionDefinition; [DataType.onChange]: ElementFunctionDefinition; [DataType.onKeyPress]: ElementFunctionDefinition; [DataType.onKeyUp]: ElementFunctionDefinition; [DataType.onSubmit]: ElementFunctionDefinition; [DataType.schema]: ElementDataValue; [DataType.UNKNOWN_DataType]: ElementDataValue; [DataType.filter]: ElementFilter; [DataType.sort]: ElementSort; ['function']: ElementFunctionDefinition; }; export type ElementDefaultValueFor = ElementDataTypeMap[TypeKey];