| 1 | import type prompts from "prompts"; |
| 2 | import type { RunOptions } from "../types"; |
| 3 | |
| 4 | export type SingleOrArray<T> = T | T[]; |
| 5 | |
| 6 | export type PromptsName<Q> = prompts.PromptObject<Extract<keyof Q, string> & string>; |
| 7 | |
| 8 | // when a value is returned |
| 9 | export type ValueValidationResult<Q> = [value: Q, questions: undefined]; |
| 10 | // when questions are returned |
| 11 | export type QuestionsValidationResult<Q> = [value: undefined, questions: PromptsName<Q>[]]; |
| 12 | export type ValidationResult<Q> = ValueValidationResult<Q> | QuestionsValidationResult<Q>; |
| 13 | |
| 14 | export type Validator<Q> = (options: RunOptions) => Promise<ValidationResult<Q>>; |