import { Separator } from '@inquirer/prompts'; export type BaseChoice = { value: T; name?: string; description?: string; short?: string; disabled?: boolean | string; }; /** * A simplified version of the type required by inquirer's `select` method which they don't export. */ export type Choice = BaseChoice | Separator; /** * A simplified version of the type required by inquirer's `checkbox` method which they don't export. */ export type CheckboxChoice = (BaseChoice & { checked?: boolean; }) | Separator; export declare const uneditable: unique symbol; export type Uneditable = typeof uneditable; /** * The core interface for an input definition. This interface describes a definition of an object * being input by the user. These definitions can be shared between creation and updating. * * T is the type of the object being entered. This can be anything from a simple string to a complex * object. * * The `context` in these objects is a chain of parent objects being created. The direct parent * will be `context[0]` and the root should be `context[context.length - 1]`. In the simplest * case of a primitive object being queried, there will never be any context. In the case of * a simple object with several primitives, the context will be an array of the object being * built when calling methods on `InputDefinition`s for the primitives. */ export type InputDefinition = { /** * A simple name for the item being requested from the user. This name will be used when * querying the user. */ name: string; /** * Ask the user for data needed to build an instance of `T` and return that instance. * * This method would normally be used in a `create` command to allow user input data. */ buildFromUserInput(context?: unknown[]): Promise; /** * Build a short, one-line string summary of the item to display to the user when listing items * for editing. */ summarizeForEdit(value: T, context?: unknown[]): string | Uneditable; /** * Present the user with the data in `original` and allow them to edit it. Return a new instance * with the updated values. (Unchanged values will be included as well; if the user does not * change anything, the returned value will be a deep copy of the original.) * * This method would normally be used in `create` after `buildFromUserInput` is called * and in `update` to allow editing of previously edited data. */ updateFromUserInput(original: T, context?: unknown[]): Promise; /** * If provided, this method will be called on subsequent items in an object definition * when a change is made to one. * * Use cases: * 1. computed values need to be recomputed when things they depend upon have changed * 2. when selection made for one field leads to a different set of later fields requiring input */ updateIfNeeded?: (original: U, updatedPropertyName: string | number | symbol, context?: unknown[]) => Promise; /** * Specific item types can include data here for reference outside the definition builder. * Currently this is used by object-type item definitions so parent definitions can access * child definition properties for rolled up properties. */ itemTypeData?: { type: 'object'; }; /** * Optional final validation. Most validation should be done on each field as it's entered * or updated but sometimes in a more complex object, a final validation needs to be used. * * Return true if the object is valid or a string error message if not. */ validateFinal?: (item: U, context?: unknown[]) => true | string; }; /** * Validation function specific to `ItemDefinition`. This can be considered to be an "extends" * of `ValidationFunction` since `context` is optional. i.e. Any function that conforms to * `ValidateFunction` will work for a `InputDefinitionValidateFunction` as well. */ export type InputDefinitionValidateFunction = (input: T, context?: unknown[]) => true | string; export type DefaultValueFunction = (context?: unknown[]) => T; export type InputDefinitionDefaultValueOrFn = T | DefaultValueFunction; export declare const addAction: unique symbol; export type AddAction = typeof addAction; export declare const addOption: (name: string) => Choice; export declare const editAction: unique symbol; export type EditAction = typeof editAction; export declare const editOption: (name: string) => Choice; export declare const deleteAction: unique symbol; export type DeleteAction = typeof deleteAction; export declare const deleteOption: (name: string) => Choice; export declare const cancelAction: unique symbol; export type CancelAction = typeof cancelAction; export declare const cancelOption: Choice; export declare const finishAction: unique symbol; export type FinishAction = typeof finishAction; export declare const finishOption: (name: string) => Choice; export declare const helpAction: unique symbol; export type HelpAction = typeof helpAction; export declare const helpOption: Choice; export declare const previewJSONAction: unique symbol; export declare const previewYAMLAction: unique symbol; export declare const maxItemValueLength = 60; export declare const inquirerPageSize = 20; //# sourceMappingURL=defs.d.ts.map