@topcli/prompts 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -30,31 +30,36 @@ declare class PromptAgent<T = string> {
30
30
  nextAnswer(value: T): void;
31
31
  }
32
32
 
33
- interface SharedOptions {
34
- stdin?: NodeJS.ReadStream & {
35
- fd: 0;
36
- };
37
- stdout?: NodeJS.WriteStream & {
38
- fd: 1;
39
- };
33
+ type Stdin = NodeJS.ReadStream & {
34
+ fd: 0;
35
+ };
36
+ type Stdout = NodeJS.WriteStream & {
37
+ fd: 1;
38
+ };
39
+ interface AbstractPromptOptions {
40
+ stdin?: Stdin;
41
+ stdout?: Stdout;
42
+ message: string;
43
+ signal?: AbortSignal;
40
44
  }
45
+
41
46
  interface Choice<T = any> {
42
47
  value: T;
43
48
  label: string;
44
49
  description?: string;
45
50
  }
46
51
 
47
- interface QuestionOptions extends SharedOptions {
52
+ interface QuestionOptions extends AbstractPromptOptions {
48
53
  defaultValue?: string;
49
54
  validators?: PromptValidator[];
50
55
  secure?: boolean;
51
56
  }
52
57
 
53
- interface ConfirmOptions extends SharedOptions {
58
+ interface ConfirmOptions extends AbstractPromptOptions {
54
59
  initial?: boolean;
55
60
  }
56
61
 
57
- interface MultiselectOptions extends SharedOptions {
62
+ interface MultiselectOptions extends AbstractPromptOptions {
58
63
  choices: (Choice | string)[];
59
64
  maxVisible?: number;
60
65
  preSelectedChoices?: (Choice | string)[];
@@ -64,17 +69,18 @@ interface MultiselectOptions extends SharedOptions {
64
69
  showHint?: boolean;
65
70
  }
66
71
 
67
- interface SelectOptions extends SharedOptions {
72
+ interface SelectOptions extends AbstractPromptOptions {
68
73
  choices: (Choice | string)[];
69
74
  maxVisible?: number;
70
75
  ignoreValues?: (string | number | boolean)[];
76
+ validators?: PromptValidator[];
71
77
  autocomplete?: boolean;
72
78
  caseSensitive?: boolean;
73
79
  }
74
80
 
75
- declare function question(message: string, options?: QuestionOptions): Promise<string>;
76
- declare function select(message: string, options: SelectOptions): Promise<string>;
77
- declare function confirm(message: string, options: ConfirmOptions): Promise<boolean>;
78
- declare function multiselect(message: string, options: MultiselectOptions): Promise<string[]>;
81
+ declare function question(message: string, options?: Omit<QuestionOptions, "message">): Promise<string>;
82
+ declare function select(message: string, options: Omit<SelectOptions, "message">): Promise<string>;
83
+ declare function confirm(message: string, options: Omit<ConfirmOptions, "message">): Promise<boolean>;
84
+ declare function multiselect(message: string, options: Omit<MultiselectOptions, "message">): Promise<string[]>;
79
85
 
80
- export { type Choice, type ConfirmOptions, type MultiselectOptions, PromptAgent, type PromptValidator, type QuestionOptions, type SelectOptions, type SharedOptions, confirm, multiselect, question, required, select };
86
+ export { type AbstractPromptOptions, type Choice, type ConfirmOptions, type MultiselectOptions, PromptAgent, type PromptValidator, type QuestionOptions, type SelectOptions, confirm, multiselect, question, required, select };
package/dist/index.d.ts CHANGED
@@ -30,31 +30,36 @@ declare class PromptAgent<T = string> {
30
30
  nextAnswer(value: T): void;
31
31
  }
32
32
 
33
- interface SharedOptions {
34
- stdin?: NodeJS.ReadStream & {
35
- fd: 0;
36
- };
37
- stdout?: NodeJS.WriteStream & {
38
- fd: 1;
39
- };
33
+ type Stdin = NodeJS.ReadStream & {
34
+ fd: 0;
35
+ };
36
+ type Stdout = NodeJS.WriteStream & {
37
+ fd: 1;
38
+ };
39
+ interface AbstractPromptOptions {
40
+ stdin?: Stdin;
41
+ stdout?: Stdout;
42
+ message: string;
43
+ signal?: AbortSignal;
40
44
  }
45
+
41
46
  interface Choice<T = any> {
42
47
  value: T;
43
48
  label: string;
44
49
  description?: string;
45
50
  }
46
51
 
47
- interface QuestionOptions extends SharedOptions {
52
+ interface QuestionOptions extends AbstractPromptOptions {
48
53
  defaultValue?: string;
49
54
  validators?: PromptValidator[];
50
55
  secure?: boolean;
51
56
  }
52
57
 
53
- interface ConfirmOptions extends SharedOptions {
58
+ interface ConfirmOptions extends AbstractPromptOptions {
54
59
  initial?: boolean;
55
60
  }
56
61
 
57
- interface MultiselectOptions extends SharedOptions {
62
+ interface MultiselectOptions extends AbstractPromptOptions {
58
63
  choices: (Choice | string)[];
59
64
  maxVisible?: number;
60
65
  preSelectedChoices?: (Choice | string)[];
@@ -64,17 +69,18 @@ interface MultiselectOptions extends SharedOptions {
64
69
  showHint?: boolean;
65
70
  }
66
71
 
67
- interface SelectOptions extends SharedOptions {
72
+ interface SelectOptions extends AbstractPromptOptions {
68
73
  choices: (Choice | string)[];
69
74
  maxVisible?: number;
70
75
  ignoreValues?: (string | number | boolean)[];
76
+ validators?: PromptValidator[];
71
77
  autocomplete?: boolean;
72
78
  caseSensitive?: boolean;
73
79
  }
74
80
 
75
- declare function question(message: string, options?: QuestionOptions): Promise<string>;
76
- declare function select(message: string, options: SelectOptions): Promise<string>;
77
- declare function confirm(message: string, options: ConfirmOptions): Promise<boolean>;
78
- declare function multiselect(message: string, options: MultiselectOptions): Promise<string[]>;
81
+ declare function question(message: string, options?: Omit<QuestionOptions, "message">): Promise<string>;
82
+ declare function select(message: string, options: Omit<SelectOptions, "message">): Promise<string>;
83
+ declare function confirm(message: string, options: Omit<ConfirmOptions, "message">): Promise<boolean>;
84
+ declare function multiselect(message: string, options: Omit<MultiselectOptions, "message">): Promise<string[]>;
79
85
 
80
- export { type Choice, type ConfirmOptions, type MultiselectOptions, PromptAgent, type PromptValidator, type QuestionOptions, type SelectOptions, type SharedOptions, confirm, multiselect, question, required, select };
86
+ export { type AbstractPromptOptions, type Choice, type ConfirmOptions, type MultiselectOptions, PromptAgent, type PromptValidator, type QuestionOptions, type SelectOptions, confirm, multiselect, question, required, select };