import { ActionType, ParamDefinitionAny, ParamDefinitionsMap, TaskArguments, TaskDefinition } from "../../../types"; import * as types from "../params/argument-types"; /** * This class creates a task definition, which consists of: * * a name, that should be unique and will be used to call the task. * * a description. This is optional. * * the action that the task will execute. * * a set of parameters that can be used by the action. * */ export declare class SimpleTaskDefinition implements TaskDefinition { readonly name: string; readonly isInternal: boolean; get description(): (string | undefined); readonly paramDefinitions: ParamDefinitionsMap; readonly positionalParamDefinitions: ParamDefinitionAny[]; action: ActionType; private readonly _positionalParamNames; private _hasVariadicParam; private _hasOptionalPositionalParam; private _description?; /** * Creates an empty task definition. * * This definition will have no params, and will throw a ALGORAND_BUILDER205 if executed. * * @param name The task's name. * @param isInternal `true` if the task is internal, `false` otherwise. */ constructor(name: string, isInternal?: boolean); /** * Sets the task's description. * @param description The description. */ setDescription(description: string): this; /** * Sets the task's action. * @param action The action. */ setAction(action: ActionType): this; /** * Adds a paramater to the task's definition. * * @remarks This will throw if the `name` is already used by this task or * by Builder's global parameters. * * @param name The parameter's name. * @param description The parameter's description. * @param defaultValue A default value. This must be `undefined` if `isOptional` is `true`. * @param type The param's `ArgumentType`. It will parse and validate the user's input. * @param isOptional `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`. */ addParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean): this; /** * Adds an optional paramater to the task's definition. * * @see addParam. * * @param name the parameter's name. * @param description the parameter's description. * @param defaultValue a default value. * @param type param's type. */ addOptionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType): this; /** * Adds a boolean paramater or flag to the task's definition. * * Flags are params with default value set to `false`, and that don't expect * values to be set in the CLI. A normal boolean param must be called with * `--param true`, while a flag is called with `--flag`. * * @param name the parameter's name. * @param description the parameter's description. */ addFlag(name: string, description?: string): this; /** * Adds a positional paramater to the task's definition. * * @remarks This will throw if the `name` is already used by this task or * by Builder's global parameters. * @remarks This will throw if `isOptional` is `false` and an optional positional * param was already set. * @remarks This will throw if a variadic positional param is already set. * * @param name The parameter's name. * @param description The parameter's description. * @param defaultValue A default value. This must be `undefined` if `isOptional` is `true`. * @param type The param's `ArgumentType`. It will parse and validate the user's input. * @param isOptional `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`. */ addPositionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean): this; /** * Adds an optional positional paramater to the task's definition. * * @see addPositionalParam. * * @param name the parameter's name. * @param description the parameter's description. * @param defaultValue a default value. * @param type param's type. */ addOptionalPositionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType): this; /** * Adds a variadic positional paramater to the task's definition. Variadic * positional params act as `...rest` parameters in JavaScript. * * @param name The parameter's name. * @param description The parameter's description. * @param defaultValue A default value. This must be `undefined` if `isOptional` is `true`. * @param type The param's `ArgumentType`. It will parse and validate the user's input. * @param isOptional `true` if the parameter is optional. It's default value is `true` if `defaultValue` is not `undefined`. */ addVariadicPositionalParam(name: string, description?: string, defaultValue?: T[] | T, type?: types.ArgumentType, isOptional?: boolean): this; /** * Adds a positional paramater to the task's definition. * * This will check if the `name` is already used and * if the parameter is being added after a varidic argument. * * @param name the parameter's name. * @param description the parameter's description. * @param defaultValue a default value. * @param type param's type. */ addOptionalVariadicPositionalParam(name: string, description?: string, defaultValue?: T[] | T, type?: types.ArgumentType): this; /** * Adds a positional paramater to the task's definition. * * @param definition the param's definition */ private _addPositionalParamDefinition; /** * Validates if the given param's name is after a variadic parameter. * @param name the param's name. * @throws ALGORAND_BUILDER200 */ private _validateNotAfterVariadicParam; /** * Validates if the param's name is already used. * @param name the param's name. * * @throws ALGORAND_BUILDER201 if `name` is already used as a param. * @throws ALGORAND_BUILDER202 if `name` is already used as a param by Builder */ private _validateNameNotUsed; /** * Checks if the given name is already used. * @param name the param's name. */ private _hasParamDefined; /** * Validates if a mandatory param is being added after optional params. * * @param name the param's name to be added. * @param isOptional true if the new param is optional, false otherwise. * * @throws ALGORAND_BUILDER203 if validation fail */ private _validateNoMandatoryParamAfterOptionalOnes; private _validateParamNameCasing; private _validateNoDefaultValueForMandatoryParam; private _isStringArray; } /** * Allows you to override a previously defined task. * * When overriding a task you can: * * flag it as internal * * set a new description * * set a new action * */ export declare class OverriddenTaskDefinition implements TaskDefinition { readonly parentTaskDefinition: TaskDefinition; readonly isInternal: boolean; private _description?; private _action?; constructor(parentTaskDefinition: TaskDefinition, isInternal?: boolean); setDescription(description: string): this; /** * Overrides the parent task's action. * @param action the action. */ setAction(action: ActionType): this; /** * Retrieves the parent task's name. */ get name(): string; /** * Retrieves, if defined, the description of the overriden task, * otherwise retrieves the description of the parent task. */ get description(): string; /** * Retrieves, if defined, the action of the overriden task, * otherwise retrieves the action of the parent task. */ get action(): ActionType; /** * Retrieves the parent task's param definitions. */ get paramDefinitions(): ParamDefinitionsMap; /** * Retrieves the parent task's positional param definitions. */ get positionalParamDefinitions(): ParamDefinitionAny[]; /** * Overriden tasks can't add new parameters. */ addParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean): this; /** * Overriden tasks can't add new parameters. */ addOptionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType): this; /** * Overriden tasks can't add new parameters. */ addPositionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType, isOptional?: boolean): this; /** * Overriden tasks can't add new parameters. */ addOptionalPositionalParam(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType): this; /** * Overriden tasks can't add new parameters. */ addVariadicPositionalParam(name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType, isOptional?: boolean): this; /** * Overriden tasks can't add new parameters. */ addOptionalVariadicPositionalParam(name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType): this; /** * Add a flag param to the overridden task. * @throws ALGORAND_BUILDER201 if param name was already defined in any parent task. * @throws ALGORAND_BUILDER209 if param name is not in camelCase. */ addFlag(name: string, description?: string): this; private _throwNoParamsOverrideError; }