/** * @file User prompt utilities for interactive scripts. Provides inquirer.js * integration with spinner support, context handling, and theming. */ import type { ThemeName } from '../term/themes/presets.js'; import type { Theme } from '../term/themes/types.js'; import type { CheckboxPrompt, ConfirmPrompt, InputPrompt, PasswordPrompt, SearchPrompt, SelectPrompt, SeparatorType } from './prompts-types.js'; export type { CheckboxChoice, CheckboxConfig, CheckboxPrompt, Choice, ConfirmConfig, ConfirmPrompt, Context, InputConfig, InputPrompt, InquirerContext, PasswordConfig, PasswordPrompt, PromptTheme, SearchConfig, SearchPrompt, SelectConfig, SelectPrompt, SeparatorType, } from './prompts-types.js'; export type Separator = SeparatorType; /** * Convert Socket theme to @inquirer theme format. Maps our theme colors to * inquirer's style functions. Handles theme names, Theme objects, and passes * through @inquirer themes. * * @example * ;```ts * // Socket theme name * createInquirerTheme('sunset') * * // Socket Theme object * createInquirerTheme(SUNSET_THEME) * * // @inquirer theme (passes through) * createInquirerTheme({ style: {...}, icon: {...} }) * ``` * * @param theme - Socket theme name, Theme object, or @inquirer theme. * * @returns @inquirer theme object */ export declare function createInquirerTheme(theme: Theme | ThemeName | unknown): Record; /** * Create a separator for select prompts. Creates a visual separator line in * choice lists. * * @example * import { select, createSeparator } from '@socketsecurity/lib/stdio/prompts' * * const choice = await select({ * message: 'Choose an option:', * choices: [ * { name: 'Option 1', value: 1 }, * createSeparator(), * { name: 'Option 2', value: 2 }, * ], * }) * * @param text - Optional separator text (defaults to '───────') * * @returns Separator instance */ export declare function createSeparator(text?: string | undefined): SeparatorType; /** * Check if value is a Socket Theme object. * * @param value - Value to check. * * @returns True if value is a Socket Theme */ export declare function isSocketTheme(value: unknown): value is Theme; /** * Resolve theme name or object to Theme. * * @param theme - Theme name or object. * * @returns Resolved Theme */ export declare function resolveTheme(theme: Theme | ThemeName): Theme; /** * Wrap an inquirer prompt with spinner handling, theme injection, and signal * injection. Automatically stops/starts spinners during prompt display, injects * the current theme, and injects abort signals. Trims string results and * handles cancellation gracefully. * * @example * const myPrompt = wrapPrompt(rawInquirerPrompt) * const result = await myPrompt({ message: 'Enter name:' }) * * @template T - Type of the prompt result. * * @param inquirerPrompt - The inquirer prompt function to wrap. * * @returns Wrapped prompt function with spinner, theme, and signal handling */ export declare function wrapPrompt(inquirerPrompt: (...args: unknown[]) => Promise): (...args: unknown[]) => Promise; /** * Prompt to select multiple items from a list of choices. Wrapped with spinner * handling and abort signal support. * * @example * const choices = await checkbox({ * message: 'Select options:', * choices: [ * { name: 'Option 1', value: 'opt1' }, * { name: 'Option 2', value: 'opt2' }, * { name: 'Option 3', value: 'opt3' }, * ], * }) */ export declare const checkbox: CheckboxPrompt; /** * Prompt for a yes/no confirmation. Wrapped with spinner handling and abort * signal support. * * @example * const answer = await confirm({ message: 'Continue?' }) * if (answer) { // user confirmed } */ export declare const confirm: ConfirmPrompt; /** * Prompt for text input. Wrapped with spinner handling and abort signal * support. Result is automatically trimmed. * * @example * const name = await input({ message: 'Enter your name:' }) */ export declare const input: InputPrompt; /** * Prompt for password input with hidden characters. Wrapped with spinner * handling and abort signal support. * * @example * const token = await password({ message: 'Enter API token:' }) */ export declare const password: PasswordPrompt; /** * Prompt with searchable/filterable choices. Wrapped with spinner handling and * abort signal support. * * @example * const result = await search({ * message: 'Select a package:', * source: async input => fetchPackages(input), * }) */ export declare const search: SearchPrompt; /** * Prompt to select from a list of choices. Wrapped with spinner handling and * abort signal support. * * @example * const choice = await select({ * message: 'Choose an option:', * choices: [ * { name: 'Option 1', value: 'opt1' }, * { name: 'Option 2', value: 'opt2' }, * ], * }) */ export declare const select: SelectPrompt; export declare const Separator: typeof SeparatorType;