@topcli/prompts 3.0.0 → 4.0.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 DELETED
@@ -1,121 +0,0 @@
1
- type ValidResponseObject = {
2
- isValid?: true;
3
- };
4
- type InvalidResponseObject = {
5
- isValid: false;
6
- error: string;
7
- };
8
- type ValidationResponseObject = ValidResponseObject | InvalidResponseObject;
9
- type ValidationResponse = InvalidResponse | ValidResponse;
10
- type InvalidResponse = string | InvalidResponseObject;
11
- type ValidResponse = null | undefined | true | ValidResponseObject;
12
- type ValidTransformationResponse<T> = {
13
- isValid: true;
14
- transformed: T;
15
- };
16
- type TransformationResponse<T> = InvalidResponse | ValidTransformationResponse<T>;
17
- interface PromptValidator<T extends string | string[]> {
18
- validate: (input: T) => ValidationResponse | Promise<ValidationResponse>;
19
- }
20
- interface PromptTransformer<T> {
21
- transform: (input: string) => TransformationResponse<T> | Promise<TransformationResponse<T>>;
22
- }
23
- declare function required(): PromptValidator<any>;
24
-
25
- declare class PromptAgent<T = string> {
26
- #private;
27
- /**
28
- * The prompts answers queue.
29
- * When not empty, any prompt will be answered by the first answer in this list.
30
- */
31
- nextAnswers: T[];
32
- static agent<T>(): PromptAgent<T>;
33
- constructor(instancier: symbol);
34
- /**
35
- * Programmatically set the next answer for any prompt (`question()`, `confirm()`, `select()`)
36
- *
37
- * This is useful for testing.
38
- *
39
- * @example
40
- * ```js
41
- * const promptAgent = PromptAgent.agent();
42
- * promptAgent.nextAnswer("toto");
43
- *
44
- * const input = await question("what is your name?");
45
- * assert.equal(input, "toto");
46
- * ```
47
- */
48
- nextAnswer(value: T): void;
49
- }
50
-
51
- declare function number(): PromptTransformer<number>;
52
- declare function integer(): PromptTransformer<number>;
53
- declare function url(): PromptTransformer<URL>;
54
-
55
- interface Choice<T extends string> {
56
- value: T;
57
- label: string;
58
- description?: string;
59
- }
60
-
61
- type Stdin = NodeJS.ReadStream & {
62
- fd: 0;
63
- };
64
- type Stdout = NodeJS.WriteStream & {
65
- fd: 1;
66
- };
67
- interface AbstractPromptOptions {
68
- stdin?: Stdin;
69
- stdout?: Stdout;
70
- message: string;
71
- skip?: boolean;
72
- signal?: AbortSignal;
73
- }
74
-
75
- interface QuestionOptions<T = string> extends AbstractPromptOptions {
76
- defaultValue?: string;
77
- validators?: PromptValidator<string>[];
78
- transformer?: PromptTransformer<T>;
79
- secure?: boolean | {
80
- placeholder: string;
81
- };
82
- }
83
-
84
- interface ConfirmOptions extends AbstractPromptOptions {
85
- initial?: boolean;
86
- }
87
-
88
- interface SelectOptions<T extends string> extends AbstractPromptOptions {
89
- choices: (Choice<T> | T)[];
90
- maxVisible?: number;
91
- ignoreValues?: (T | number | boolean)[];
92
- validators?: PromptValidator<string>[];
93
- autocomplete?: boolean;
94
- caseSensitive?: boolean;
95
- }
96
-
97
- interface MultiselectOptions<T extends string> extends AbstractPromptOptions {
98
- choices: (Choice<T> | T)[];
99
- maxVisible?: number;
100
- preSelectedChoices?: (Choice<T> | T)[];
101
- validators?: PromptValidator<string[]>[];
102
- autocomplete?: boolean;
103
- caseSensitive?: boolean;
104
- showHint?: boolean;
105
- }
106
-
107
- declare function question<T = string>(message: string, options?: Omit<QuestionOptions<T>, "message">): Promise<T>;
108
- declare function select<T extends string>(message: string, options: Omit<SelectOptions<T>, "message">): Promise<T>;
109
- declare function confirm(message: string, options?: Omit<ConfirmOptions, "message">): Promise<boolean>;
110
- declare function multiselect<T extends string>(message: string, options: Omit<MultiselectOptions<T>, "message">): Promise<T[]>;
111
-
112
- declare const validators: {
113
- required: typeof required;
114
- };
115
- declare const transformers: {
116
- number: typeof number;
117
- integer: typeof integer;
118
- url: typeof url;
119
- };
120
-
121
- export { type AbstractPromptOptions, type Choice, type ConfirmOptions, type InvalidResponse, type InvalidResponseObject, type MultiselectOptions, PromptAgent, type PromptTransformer, type PromptValidator, type QuestionOptions, type SelectOptions, type TransformationResponse, type ValidResponse, type ValidResponseObject, type ValidTransformationResponse, type ValidationResponse, type ValidationResponseObject, confirm, multiselect, question, select, transformers, validators };
package/dist/index.d.ts DELETED
@@ -1,121 +0,0 @@
1
- type ValidResponseObject = {
2
- isValid?: true;
3
- };
4
- type InvalidResponseObject = {
5
- isValid: false;
6
- error: string;
7
- };
8
- type ValidationResponseObject = ValidResponseObject | InvalidResponseObject;
9
- type ValidationResponse = InvalidResponse | ValidResponse;
10
- type InvalidResponse = string | InvalidResponseObject;
11
- type ValidResponse = null | undefined | true | ValidResponseObject;
12
- type ValidTransformationResponse<T> = {
13
- isValid: true;
14
- transformed: T;
15
- };
16
- type TransformationResponse<T> = InvalidResponse | ValidTransformationResponse<T>;
17
- interface PromptValidator<T extends string | string[]> {
18
- validate: (input: T) => ValidationResponse | Promise<ValidationResponse>;
19
- }
20
- interface PromptTransformer<T> {
21
- transform: (input: string) => TransformationResponse<T> | Promise<TransformationResponse<T>>;
22
- }
23
- declare function required(): PromptValidator<any>;
24
-
25
- declare class PromptAgent<T = string> {
26
- #private;
27
- /**
28
- * The prompts answers queue.
29
- * When not empty, any prompt will be answered by the first answer in this list.
30
- */
31
- nextAnswers: T[];
32
- static agent<T>(): PromptAgent<T>;
33
- constructor(instancier: symbol);
34
- /**
35
- * Programmatically set the next answer for any prompt (`question()`, `confirm()`, `select()`)
36
- *
37
- * This is useful for testing.
38
- *
39
- * @example
40
- * ```js
41
- * const promptAgent = PromptAgent.agent();
42
- * promptAgent.nextAnswer("toto");
43
- *
44
- * const input = await question("what is your name?");
45
- * assert.equal(input, "toto");
46
- * ```
47
- */
48
- nextAnswer(value: T): void;
49
- }
50
-
51
- declare function number(): PromptTransformer<number>;
52
- declare function integer(): PromptTransformer<number>;
53
- declare function url(): PromptTransformer<URL>;
54
-
55
- interface Choice<T extends string> {
56
- value: T;
57
- label: string;
58
- description?: string;
59
- }
60
-
61
- type Stdin = NodeJS.ReadStream & {
62
- fd: 0;
63
- };
64
- type Stdout = NodeJS.WriteStream & {
65
- fd: 1;
66
- };
67
- interface AbstractPromptOptions {
68
- stdin?: Stdin;
69
- stdout?: Stdout;
70
- message: string;
71
- skip?: boolean;
72
- signal?: AbortSignal;
73
- }
74
-
75
- interface QuestionOptions<T = string> extends AbstractPromptOptions {
76
- defaultValue?: string;
77
- validators?: PromptValidator<string>[];
78
- transformer?: PromptTransformer<T>;
79
- secure?: boolean | {
80
- placeholder: string;
81
- };
82
- }
83
-
84
- interface ConfirmOptions extends AbstractPromptOptions {
85
- initial?: boolean;
86
- }
87
-
88
- interface SelectOptions<T extends string> extends AbstractPromptOptions {
89
- choices: (Choice<T> | T)[];
90
- maxVisible?: number;
91
- ignoreValues?: (T | number | boolean)[];
92
- validators?: PromptValidator<string>[];
93
- autocomplete?: boolean;
94
- caseSensitive?: boolean;
95
- }
96
-
97
- interface MultiselectOptions<T extends string> extends AbstractPromptOptions {
98
- choices: (Choice<T> | T)[];
99
- maxVisible?: number;
100
- preSelectedChoices?: (Choice<T> | T)[];
101
- validators?: PromptValidator<string[]>[];
102
- autocomplete?: boolean;
103
- caseSensitive?: boolean;
104
- showHint?: boolean;
105
- }
106
-
107
- declare function question<T = string>(message: string, options?: Omit<QuestionOptions<T>, "message">): Promise<T>;
108
- declare function select<T extends string>(message: string, options: Omit<SelectOptions<T>, "message">): Promise<T>;
109
- declare function confirm(message: string, options?: Omit<ConfirmOptions, "message">): Promise<boolean>;
110
- declare function multiselect<T extends string>(message: string, options: Omit<MultiselectOptions<T>, "message">): Promise<T[]>;
111
-
112
- declare const validators: {
113
- required: typeof required;
114
- };
115
- declare const transformers: {
116
- number: typeof number;
117
- integer: typeof integer;
118
- url: typeof url;
119
- };
120
-
121
- export { type AbstractPromptOptions, type Choice, type ConfirmOptions, type InvalidResponse, type InvalidResponseObject, type MultiselectOptions, PromptAgent, type PromptTransformer, type PromptValidator, type QuestionOptions, type SelectOptions, type TransformationResponse, type ValidResponse, type ValidResponseObject, type ValidTransformationResponse, type ValidationResponse, type ValidationResponseObject, confirm, multiselect, question, select, transformers, validators };