Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/inquirer

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/inquirer - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

248

inquirer/index.d.ts

@@ -12,17 +12,19 @@ // Type definitions for Inquirer.js 6.x

// Richard Lea <https://github.com/chigix>
// Jed Mao <https://github.com/jedmao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.3
// TypeScript Version: 2.8
import through = require('through');
import { ThroughStream } from 'through';
import { Observable } from 'rxjs';
import * as readline from 'readline';
import { Interface as ReadlineInterface } from 'readline';
declare namespace inquirer {
type Prompts = { [name: string]: prompts.Base };
type ChoiceType = string | objects.ChoiceOption | objects.Separator;
type Questions<T = Answers> =
| Question<T>
| ReadonlyArray<Question<T>>
| Observable<Question<T>>;
type ChoiceType<A> = string | objects.ChoiceOption<A> | objects.Separator;
type Questions<A extends Answers = Answers> =
| Question<A>
| Question<A>[]
| ReadonlyArray<Question<A>>
| Observable<Question<A>>;
type Answers = Record<string, any>
type StreamOptions = {

@@ -61,3 +63,3 @@ input?: NodeJS.ReadStream,

interface PromptModule {
<T>(questions: Questions<T>): Promise<T> & { ui: ui.PromptUI };
<A>(questions: Questions<A>): Promise<A> & { ui: ui.PromptUI };
/**

@@ -75,86 +77,154 @@ * Register a prompt type

interface Question<T = Answers> {
interface QuestionCommon<A> {
/**
* Type of the prompt.
* Possible values:
* <ul>
* <li>input</li>
* <li>number</li>
* <li>confirm</li>
* <li>list</li>
* <li>rawlist</li>
* <li>password</li>
* </ul>
* @defaults: 'input'
* The name to use when storing the answer in the answers hash.
* If the name contains periods, it will define a path in the answers hash.
*/
type?: string;
name?: string;
/**
* The name to use when storing the answer in the anwers hash.
* The question to print. If defined as a function, the first parameter will be
* the current inquirer session answers.
* Defaults to the value of `name` (followed by a colon).
*/
name?: string;
message?: string | ((answers: A) => string);
/**
* The question to print. If defined as a function,
* the first parameter will be the current inquirer session answers.
* Default value(s) to use if nothing is entered, or a function that returns
* the default value(s). If defined as a function, the first parameter will be
* the current inquirer session answers.
*/
message?: string | ((answers: T) => string);
default?: string | number | boolean | any[] | ((answers: A) => any) | ((answers: A) => Promise<any>);
/**
* Default value(s) to use if nothing is entered, or a function that returns the default value(s).
* If defined as a function, the first parameter will be the current inquirer session answers.
* Change the default _prefix_ message.
*/
default?: any | ((answers: T) => any) | ((answers: T) => Promise<any>);
prefix?: string;
/**
* Change the default _suffix_ message.
*/
suffix?: string;
/**
* Receive the current user answers hash and should return `true` or `false` depending
* on whether or not this question should be asked. The value can also be a simple boolean.
*/
when?: boolean | ((answers: A) => boolean | Promise<boolean>);
}
interface QuestionOptions<A> {
/**
* Choices array or a function returning a choices array. If defined as a function,
* the first parameter will be the current inquirer session answers.
* Array values can be simple strings, or objects containing a name (to display) and a value properties
* (to save in the answers hash). Values can also be a Separator.
* the first parameter will be the current inquirer session answers. Array values can
* be simple `numbers`, `strings`, or `objects` containing a `name` (to display in list),
* a `value` (to save in the answers hash) and a `short` (to display after selection)
* properties. The choices array can also contain
* [a Separator](https://github.com/SBoudrias/Inquirer.js#separator).
*/
choices?:
| ReadonlyArray<ChoiceType>
| ((answers: T) => ReadonlyArray<ChoiceType>)
| ((answers: T) => Promise<ReadonlyArray<ChoiceType>>);
| ReadonlyArray<ChoiceType<A>>
| ((answers: A) => ReadonlyArray<ChoiceType<A>>)
| ((answers: A) => Promise<ReadonlyArray<ChoiceType<A>>>);
/**
* Receive the user input and should return true if the value is valid, and an error message (String)
* otherwise. If false is returned, a default error message is provided.
*/
validate?(input: any, answers?: T): boolean | string | Promise<boolean | string>;
/**
* Receive the user input and return the filtered value to be used inside the program.
* The value returned will be added to the Answers hash.
* The value returned will be added to the _Answers_ hash.
*/
filter?(input: string): any;
/**
* Receive the user input and return the transformed value to be displayed to the user. The
* transformation only impacts what is shown while editing. It does not impact the answers
* hash.
* Receive the user input, answers hash and option flags, and return a transformed value
* to display to the user. The transformation only impacts what is shown while editing.
* It does not modify the answers hash.
*/
transformer?(input: string): string;
transformer?(input: string, answers: A, flags: any): string;
/**
* Receive the current user answers hash and should return true or false depending on whether or
* not this question should be asked. The value can also be a simple boolean.
* Change the number of lines that will be rendered when using `list`, `rawList`,
* `expand` or `checkbox`.
*/
when?: boolean | ((answers: T) => boolean) | ((answers: T) => Promise<boolean>);
paginated?: boolean;
pageSize?: number;
}
type Question<A extends Answers = Answers> = (
ListQuestion<A> |
RawListQuestion<A> |
ExpandQuestion<A> |
CheckboxQuestion<A> |
ConfirmQuestion<A> |
InputQuestion<A> |
NumberQuestion<A> |
PasswordQuestion<A> |
EditorQuestion<A>
)
interface ListQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'choices' | 'filter' | 'pageSize'> {
type: 'list'
}
interface RawListQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'choices' | 'filter' | 'pageSize'> {
type: 'rawlist'
}
interface ExpandQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'choices' | 'pageSize'> {
type: 'expand'
}
interface CheckboxQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'choices' | 'filter' | 'pageSize'> {
type: 'checkbox'
/**
* Change the number of lines that will be rendered when using list, rawList, expand or checkbox.
* Receive the user input and answers hash. Should return `true` if the value is valid,
* and an error message (`String`) otherwise. If `false` is returned, a default error
* message is provided.
*/
pageSize?: number;
validate?(input: string, answers?: A): boolean | string | Promise<boolean | string>;
}
interface ConfirmQuestion<A> extends QuestionCommon<A>, QuestionOptions<A> {
type: 'confirm'
}
interface InputQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'filter' | 'transformer'> {
type?: 'input'
/**
* Add a mask when password will entered
* Receive the user input and answers hash. Should return `true` if the value is valid,
* and an error message (`String`) otherwise. If `false` is returned, a default error
* message is provided.
*/
mask?: string;
validate?(input: string, answers?: A): boolean | string | Promise<boolean | string>;
}
interface NumberQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'filter' | 'transformer'> {
type: 'number'
/**
* Change the default prefix message.
* Receive the user input and answers hash. Should return `true` if the value is valid,
* and an error message (`String`) otherwise. If `false` is returned, a default error
* message is provided.
*/
prefix?: string;
validate?(input: number, answers?: A): boolean | string | Promise<boolean | string>;
}
interface PasswordQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'filter' | 'transformer'> {
type: 'password'
/**
* Change the default suffix message.
* Hides the user input.
*/
suffix?: string;
mask?: string;
/**
* Receive the user input and answers hash. Should return `true` if the value is valid,
* and an error message (`String`) otherwise. If `false` is returned, a default error
* message is provided.
*/
validate?(input: string, answers?: A): boolean | string | Promise<boolean | string>;
}
/**
* A key/value hash containing the client answers in each prompt.
*/
interface Answers {
[key: string]: any;
interface EditorQuestion<A> extends QuestionCommon<A>,
Pick<QuestionOptions<A>, 'filter'> {
type: 'editor'
/**
* Receive the user input and answers hash. Should return `true` if the value is valid,
* and an error message (`String`) otherwise. If `false` is returned, a default error
* message is provided.
*/
validate?(input: string, answers?: A): boolean | string | Promise<boolean | string>;
}

@@ -179,3 +249,3 @@

interface Base {
new <T>(question: Question<T>, rl: readline.Interface, answers: Answers): Base;
new <A>(question: Question<A>, rl: ReadlineInterface, answers: A): Base;
/**

@@ -205,3 +275,3 @@ * Start the Inquiry session and manage output value filtering

interface BaseUI {
rl: readline.Interface;
rl: ReadlineInterface;
new(opt: StreamOptions): BaseUI;

@@ -224,3 +294,3 @@ /**

new(prompts: Prompts, opt: StreamOptions): PromptUI;
run<T>(questions: Questions<T>): Promise<Answers>;
run<A>(questions: Questions<A>): Promise<A>;
/**

@@ -230,6 +300,6 @@ * Once all prompt are over

onCompletion(): void;
processQuestion<T>(question: Question<T>): Observable<Question<T>>;
fetchAnswer<T>(question: Question<T>): Observable<Question<T>>;
setDefaultType<T>(question: Question<T>): Observable<Question<T>>;
filterIfRunnable<T>(question: Question<T>): Observable<Question<T>>;
processQuestion<A>(question: Question<A>): Observable<Question<A>>;
fetchAnswer<A>(question: Question<A>): Observable<Question<A>>;
setDefaultType<A>(question: Question<A>): Observable<Question<A>>;
filterIfRunnable<A>(question: Question<A>): Observable<Question<A>>;
}

@@ -271,3 +341,3 @@

write(message: string): void;
log: through.ThroughStream;
log: ThroughStream;
}

@@ -285,9 +355,9 @@

*/
interface Choice {
new (str: string): Choice;
new (separator: Separator): Choice;
new (option: ChoiceOption): Choice;
interface Choice<A> {
new (str: string): Choice<A>;
new (separator: Separator): Choice<A>;
new (option: ChoiceOption<A>): Choice<A>;
}
interface ChoiceOption {
interface ChoiceOption<A> {
name?: string;

@@ -300,3 +370,3 @@ value?: any;

checked?: boolean;
disabled?: string | (<T = Answers>(answers: T) => any);
disabled?: string | (<A>(answers: A) => any);
}

@@ -310,9 +380,9 @@

*/
interface Choices {
new <T = Answers>(
choices: ReadonlyArray<string | Separator | ChoiceOption>,
answers?: T
): Choices;
choices: ReadonlyArray<Choice>;
realChoices: ReadonlyArray<Choice>;
interface Choices<A> {
new (
choices: ReadonlyArray<string | Separator | ChoiceOption<A>>,
answers?: A
): Choices<A>;
choices: ReadonlyArray<Choice<A>>;
realChoices: ReadonlyArray<Choice<A>>;
length: number;

@@ -325,3 +395,3 @@ realLength: number;

*/
getChoice(selector: number): Choice;
getChoice(selector: number): Choice<A>;
/**

@@ -332,3 +402,3 @@ * Get a raw element from the collection

*/
get(selector: number): Choice;
get(selector: number): Choice<A>;
/**

@@ -339,3 +409,3 @@ * Match the valid choices against a where clause

*/
where<U extends {}>(whereClause: U): Choice[];
where<U extends {}>(whereClause: U): Choice<A>[];
/**

@@ -347,3 +417,3 @@ * Pluck a particular key from the choices

pluck(propertyName: string): any[];
forEach<T>(application: (choice: Choice) => T): T[];
forEach<T>(application: (choice: Choice<A>) => T): T[];
}

@@ -350,0 +420,0 @@

{
"name": "@types/inquirer",
"version": "6.0.2",
"version": "6.0.3",
"description": "TypeScript definitions for Inquirer.js",

@@ -51,2 +51,7 @@ "license": "MIT",

"githubUsername": "chigix"
},
{
"name": "Jed Mao",
"url": "https://github.com/jedmao",
"githubUsername": "jedmao"
}

@@ -64,6 +69,6 @@ ],

"@types/through": "*",
"rxjs": ">=6.4.0"
"rxjs": "^6.4.0"
},
"typesPublisherContentHash": "14f2b716dd699bc9890874eb1572eaa5fdcc6d2cdeb48d17fa22c437d5e0881d",
"typeScriptVersion": "2.0"
"typesPublisherContentHash": "7469f6c5bf9811728d2bc8f62b248ab2cec11d43a243c38be5587c1fb2de2a16",
"typeScriptVersion": "3.3"
}

@@ -11,3 +11,3 @@ # Installation

Additional Details
* Last updated: Tue, 14 May 2019 21:36:51 GMT
* Last updated: Wed, 22 May 2019 15:30:00 GMT
* Dependencies: @types/through, @types/rxjs

@@ -17,2 +17,2 @@ * Global values: none

# Credits
These definitions were written by Qubo <https://github.com/tkQubo>, Parvez <https://github.com/ppathan>, Jouderian <https://github.com/jouderianjr>, Qibang <https://github.com/bang88>, Jason Dreyzehner <https://github.com/bitjson>, Synarque <https://github.com/synarque>, Justin Rockwood <https://github.com/jrockwood>, Keith Kelly <https://github.com/kwkelly>, Richard Lea <https://github.com/chigix>.
These definitions were written by Qubo <https://github.com/tkQubo>, Parvez <https://github.com/ppathan>, Jouderian <https://github.com/jouderianjr>, Qibang <https://github.com/bang88>, Jason Dreyzehner <https://github.com/bitjson>, Synarque <https://github.com/synarque>, Justin Rockwood <https://github.com/jrockwood>, Keith Kelly <https://github.com/kwkelly>, Richard Lea <https://github.com/chigix>, Jed Mao <https://github.com/jedmao>.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc