| 92 | return { name, buildFromUserInput, summarizeForEdit, updateFromUserInput } |
| 93 | } |
| 94 | export const integerDef = (name: string, options?: NumberDefOptions): InputDefinition<number> => { |
| 95 | const buildFromUserInput = async (context?: unknown[]): Promise<number> => |
| 96 | integerInput(name, { |
| 97 | ...options, |
| 98 | default: defaultWithContextFn(options?.default, context), |
| 99 | validate: validateWithContextFn<number | undefined>(options?.validate, context), |
| 100 | }) |
| 101 | const summarizeForEdit = (value: number): string => String(value) |
| 102 | const updateFromUserInput = (original: number | undefined, context?: unknown[]): Promise<number> => |
| 103 | integerInput(name, |
| 104 | { ...options, default: original, validate: validateWithContextFn<number | undefined>(options?.validate, context) }) |
| 105 | |
| 106 | return { name, buildFromUserInput, summarizeForEdit, updateFromUserInput } |
| 107 | } |
| 108 | |
| 109 | export type BooleanDefOptions = BooleanInputOptions |
| 110 | export const booleanDef = (name: string, options?: BooleanDefOptions): InputDefinition<boolean> => { |