/** * The state of prompt shared with the validate function */ export type PromptState = { type: string; name: string; message: string; value: T; }; /** * Shape of prompt validate function */ export type PromptValidationFunction> = (value: T['value'], state: T) => boolean | string | Promise; /** * Shape of prompt format function. It is called on every keystroke */ export type PromptFormatFunction = (value: T) => Result | Promise; /** * Shape of prompt result function. It is called before returning the result * and after validation */ export type PromptResultFunction = (value: T) => Result | Promise; /** * Prompt options for text based prompts */ export type TextPromptOptions = { default?: string; name?: string; hint?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction>; }; /** * Prompt options for list prompt */ export type ListPromptOptions = { default?: string; name?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction>; hint?: string; seperator?: string; }; /** * Prompt options for the choice prompt */ export type ChoicePromptOptions = { default?: string; name?: string; hint?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction & { choices: PromptChoice[]; }>; }; /** * Prompt options for the multiple prompt */ export type MultiplePromptOptions = { default?: string[]; name?: string; hint?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction & { choices: PromptChoice[]; }>; }; /** * Shape of boolean prompts */ export type BooleanPromptOptions = { default?: boolean; name?: string; hint?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction>; }; /** * Options for a toggle prompt */ export type TogglePromptOptions = { default?: boolean; name?: string; hint?: string; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction>; }; /** * Prompt options for the autocomplete prompt */ export type AutoCompletePromptOptions = { default?: number; limit?: number; name?: string; hint?: string; multiple?: Multiple; result?: PromptResultFunction; format?: PromptFormatFunction; validate?: PromptValidationFunction & { choices: PromptChoice[]; }>; footer?: () => string; }; /** * Shape of the prompt choice */ export type PromptChoice = { name: Choice; message?: string; hint?: string; disabled?: boolean; };