export type FlowVersion = '3.0' | '3.1' | '4.0' | '5.0' | '6.0'; export type DataApiVersion = '3.0' | '4.0'; export type ScreenDataRef = `\${data.${K}}`; export type FormRef = `\${form.${K}}`; export type ScreenRef = `\${screen.${S}.data.${K}}`; export type DynamicRef = ScreenDataRef | FormRef | ScreenRef; export type DynamicValue = T | DynamicRef; export type DataSourceType = 'string' | 'number' | 'boolean' | 'object' | 'array'; export interface DataSource { type: DataSourceType; __example__?: unknown; } export interface BaseComponentSchema { type: string; name?: string; visible?: boolean | DynamicRef; } export interface FormSchema extends BaseComponentSchema { type: 'Form'; name: string; children: ComponentSchema[]; 'init-values'?: Record; 'error-messages'?: Record; } export interface TextInputSchema extends BaseComponentSchema { type: 'TextInput'; name: string; label: string | DynamicRef; required?: boolean; 'input-type'?: 'text' | 'number' | 'email' | 'password' | 'passcode' | 'phone'; 'min-chars'?: number; 'max-chars'?: number; 'helper-text'?: string | DynamicRef; enabled?: boolean | DynamicRef; 'init-value'?: string | DynamicRef; 'error-message'?: string | DynamicRef; } export interface TextAreaSchema extends BaseComponentSchema { type: 'TextArea'; name: string; label: string | DynamicRef; required?: boolean; 'max-length'?: number; 'helper-text'?: string | DynamicRef; enabled?: boolean | DynamicRef; 'init-value'?: string | DynamicRef; 'error-message'?: string | DynamicRef; } export interface DropdownOptionSchema { id: string; title: string; description?: string; enabled?: boolean; } export interface DropdownSchema extends BaseComponentSchema { type: 'Dropdown'; name: string; label: string | DynamicRef; required?: boolean; 'data-source': DynamicRef | DropdownOptionSchema[]; enabled?: boolean | DynamicRef; 'init-value'?: string | DynamicRef; 'error-message'?: string | DynamicRef; } export interface RadioOptionSchema { id: string; title: string; description?: string; } export interface RadioButtonsGroupSchema extends BaseComponentSchema { type: 'RadioButtonsGroup'; name: string; label: string | DynamicRef; required?: boolean; 'data-source': DynamicRef | RadioOptionSchema[]; enabled?: boolean | DynamicRef; 'init-value'?: string | DynamicRef; 'error-message'?: string | DynamicRef; } export interface CheckboxOptionSchema { id: string; title: string; description?: string; } export interface CheckboxGroupSchema extends BaseComponentSchema { type: 'CheckboxGroup'; name: string; label: string | DynamicRef; required?: boolean; 'min-selected-items'?: number; 'max-selected-items'?: number; 'data-source': DynamicRef | CheckboxOptionSchema[]; enabled?: boolean | DynamicRef; 'init-value'?: string[] | DynamicRef; 'error-message'?: string | DynamicRef; } export interface DatePickerSchema extends BaseComponentSchema { type: 'DatePicker'; name: string; label: string | DynamicRef; required?: boolean; 'min-date'?: string | DynamicRef; 'max-date'?: string | DynamicRef; 'unavailable-dates'?: string[] | DynamicRef; 'helper-text'?: string | DynamicRef; enabled?: boolean | DynamicRef; 'init-value'?: string | DynamicRef; 'error-message'?: string | DynamicRef; } export interface TextHeadingSchema extends BaseComponentSchema { type: 'TextHeading'; text: string | DynamicRef; } export interface TextSubheadingSchema extends BaseComponentSchema { type: 'TextSubheading'; text: string | DynamicRef; } export interface TextBodySchema extends BaseComponentSchema { type: 'TextBody'; text: string | DynamicRef; 'font-weight'?: 'normal' | 'bold'; strikethrough?: boolean; } export interface TextCaptionSchema extends BaseComponentSchema { type: 'TextCaption'; text: string | DynamicRef; 'font-weight'?: 'normal' | 'bold'; strikethrough?: boolean; } export interface ImageSchema extends BaseComponentSchema { type: 'Image'; src: string | DynamicRef; width?: number; height?: number; 'scale-type'?: 'cover' | 'contain'; 'aspect-ratio'?: number; 'alt-text'?: string; } export interface EmbeddedLinkSchema extends BaseComponentSchema { type: 'EmbeddedLink'; text: string | DynamicRef; 'on-click-action': ActionSchema; } export type ActionType = 'navigate' | 'data_exchange' | 'complete' | 'open_url'; export interface NavigateActionSchema { name: 'navigate'; next: { type: 'screen'; name: string; }; payload?: Record; } export interface DataExchangeActionSchema { name: 'data_exchange'; payload?: Record; } export interface CompleteActionSchema { name: 'complete'; payload?: Record; } export interface OpenUrlActionSchema { name: 'open_url'; url: string | DynamicRef; } export type ActionSchema = NavigateActionSchema | DataExchangeActionSchema | CompleteActionSchema | OpenUrlActionSchema; export interface FooterSchema extends BaseComponentSchema { type: 'Footer'; label: string | DynamicRef; 'on-click-action': ActionSchema; 'left-caption'?: string | DynamicRef; 'center-caption'?: string | DynamicRef; enabled?: boolean | DynamicRef; } export type ComponentSchema = FormSchema | TextInputSchema | TextAreaSchema | DropdownSchema | RadioButtonsGroupSchema | CheckboxGroupSchema | DatePickerSchema | TextHeadingSchema | TextSubheadingSchema | TextBodySchema | TextCaptionSchema | ImageSchema | EmbeddedLinkSchema | FooterSchema; export type LayoutType = 'SingleColumnLayout'; export interface LayoutSchema { type: LayoutType; children: ComponentSchema[]; } export interface ScreenSchema { id: string; title?: string; terminal?: boolean; refresh_on_back?: boolean; data?: Record; layout: LayoutSchema; } export interface FlowJSONSchema { version: FlowVersion; data_api_version?: DataApiVersion; routing_model?: Record; screens: ScreenSchema[]; }