import EventEmitter from "node:events"; import readline from "node:readline"; //#region src/validators.d.ts type ValidResponseObject = { isValid?: true; }; type InvalidResponseObject = { isValid: false; error: string; }; type ValidationResponseObject = ValidResponseObject | InvalidResponseObject; type ValidationResponse = InvalidResponse | ValidResponse; type InvalidResponse = string | InvalidResponseObject; type ValidResponse = null | undefined | true | ValidResponseObject; type ValidTransformationResponse = { isValid: true; transformed: T; }; type TransformationResponse = InvalidResponse | ValidTransformationResponse; interface PromptValidator { validate: (input: T) => ValidationResponse | Promise; } interface PromptTransformer { transform: (input: string) => TransformationResponse | Promise>; } declare function required(): PromptValidator; //#endregion //#region src/prompt-agent.d.ts declare class PromptAgent { #private; /** * The prompts answers queue. * When not empty, any prompt will be answered by the first answer in this list. */ nextAnswers: T[]; static shared(): PromptAgent; /** * Programmatically set the next answer for any prompt (`question()`, `confirm()`, `select()`) * * This is useful for testing. * * @example * ```js * const promptAgent = PromptAgent.shared(); * promptAgent.nextAnswer("toto"); * * const input = await question("what is your name?"); * assert.equal(input, "toto"); * ``` */ nextAnswer(value: T | T[]): void; clear(): void; } //#endregion //#region src/transformers.d.ts declare function number(): PromptTransformer; declare function integer(): PromptTransformer; declare function url(): PromptTransformer; //#endregion //#region src/types.d.ts interface Choice { value: T; label: string; description?: string; disabled?: boolean | string; } interface Separator { type: "separator"; label?: string; } //#endregion //#region src/prompts/abstract.d.ts type Stdin = NodeJS.ReadStream & { fd: 0; }; type Stdout = NodeJS.WriteStream & { fd: 1; }; interface AbstractPromptOptions { stdin?: Stdin; stdout?: Stdout; message: string; skip?: boolean; signal?: AbortSignal; agent?: PromptAgent; } //#endregion //#region src/prompts/question.d.ts interface QuestionOptions extends AbstractPromptOptions { defaultValue?: string; hint?: string; validators?: PromptValidator[]; transformer?: PromptTransformer; secure?: boolean | { placeholder: string; }; } //#endregion //#region src/prompts/confirm.d.ts interface ConfirmOptions extends AbstractPromptOptions { initial?: boolean; } //#endregion //#region src/prompts/select.d.ts interface SelectOptions extends AbstractPromptOptions { choices: (Choice | T | Separator)[]; maxVisible?: number; ignoreValues?: (T | number | boolean)[]; validators?: PromptValidator[]; autocomplete?: boolean; caseSensitive?: boolean; } //#endregion //#region src/prompts/multiselect.d.ts interface MultiselectOptions extends AbstractPromptOptions { choices: (Choice | T | Separator)[]; maxVisible?: number; preSelectedChoices?: (Choice | T)[]; validators?: PromptValidator[]; autocomplete?: boolean; caseSensitive?: boolean; showHint?: boolean; } //#endregion //#region src/index.d.ts declare function question(message: string, options?: Omit, "message">): Promise; declare function select(message: string, options: Omit, "message">): Promise; declare function confirm(message: string, options?: Omit): Promise; declare function multiselect(message: string, options: Omit, "message">): Promise; declare const validators: { required: typeof required; }; declare const transformers: { number: typeof number; integer: typeof integer; url: typeof url; }; //#endregion export { type AbstractPromptOptions, type Choice, type ConfirmOptions, type InvalidResponse, type InvalidResponseObject, type MultiselectOptions, PromptAgent, type PromptTransformer, type PromptValidator, type QuestionOptions, type SelectOptions, type Separator, type TransformationResponse, type ValidResponse, type ValidResponseObject, type ValidTransformationResponse, type ValidationResponse, type ValidationResponseObject, confirm, multiselect, question, select, transformers, validators };