import type { Evt } from 'evt'; import { T_IO_DISPLAY_METHOD_NAMES, T_IO_INPUT_METHOD_NAMES, T_IO_METHOD_NAMES, T_IO_MULTIPLEABLE_METHOD_NAMES, T_IO_PROPS, T_IO_RETURNS, T_IO_STATE } from '../ioSchema'; import IOComponent, { AnyIOComponent, ComponentReturnValue, MaybeMultipleComponentReturnValue } from './IOComponent'; import IOError from './IOError'; import { ComponentRenderer, ComponentsRenderer, GroupIOPromise, MaybeOptionalGroupIOPromise, OptionalGroupIOPromise, ButtonConfig, ChoiceButtonConfig, ChoiceButtonConfigOrShorthand, ComponentsRendererReturn } from '../types'; import { IOClientRenderReturnValues } from './IOClient'; interface IOPromiseProps = T_IO_PROPS, ComponentOutput = ComponentReturnValue> { renderer: ComponentRenderer; methodName: MethodName; label: string; props: Props; onPropsUpdate?: Evt>; valueGetter?: (response: ComponentReturnValue) => ComponentOutput; onStateChange?: (incomingState: T_IO_STATE) => Promise>; validator?: IOPromiseValidator | undefined; displayResolvesImmediately?: boolean; } /** * A custom wrapper class that handles creating the underlying component * model when the IO call is to be rendered, and optionally transforming * the value received from Interval to a custom component return type. * * Can be `await`ed, which renders its own component by itself, * or rendered as a group along with other IOPromises. */ export declare class IOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> { methodName: MethodName; renderer: ComponentRenderer; protected label: string; protected props: Props; protected valueGetter: ((response: ComponentReturnValue) => ComponentOutput) | undefined; protected onStateChange: ((incomingState: T_IO_STATE) => Promise>) | undefined; validator: IOPromiseValidator | undefined; protected displayResolvesImmediately: boolean | undefined; protected onPropsUpdate: Evt> | undefined; constructor({ renderer, methodName, label, props, valueGetter, onStateChange, validator, displayResolvesImmediately, onPropsUpdate, }: IOPromiseProps); then(resolve: (output: ComponentOutput) => void, reject?: (err: IOError) => void): void; getValue(result: ComponentReturnValue): ComponentOutput; get component(): IOComponent; } /** * A thin subtype of IOPromise that does nothing but mark the component * as "display" for display-only components. */ export declare class DisplayIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends IOPromise { withChoices(choiceButtons: ChoiceButtonConfigOrShorthand[]): WithChoicesIOPromise; } export declare class InputIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends IOPromise { get component(): IOComponent; handleValidation(returnValue: MaybeMultipleComponentReturnValue | undefined): Promise; validate(validator: IOPromiseValidator): this; optional(isOptional?: true): OptionalIOPromise; optional(isOptional?: false): InputIOPromise; optional(isOptional?: boolean): OptionalIOPromise | InputIOPromise; withChoices(choiceButtons: ChoiceButtonConfigOrShorthand[]): WithChoicesIOPromise; } /** * A thin subclass of IOPromise that marks its inner component as * "optional" and returns `undefined` if not provided by the action runner. */ export declare class OptionalIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends InputIOPromise { then(resolve: (output: ComponentOutput | undefined) => void, reject?: (err: IOError) => void): void; get component(): IOComponent; handleValidation(returnValue: MaybeMultipleComponentReturnValue | undefined): Promise; getValue(result: ComponentReturnValue | undefined): ComponentOutput | undefined; } export declare class MultipleableIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue, DefaultValue = T_IO_PROPS extends { defaultValue?: any; } ? ComponentOutput | null : never> extends InputIOPromise { defaultValueGetter: ((defaultValue: DefaultValue) => T_IO_RETURNS) | undefined; constructor({ defaultValueGetter, ...props }: { renderer: ComponentRenderer; methodName: MethodName; label: string; props: Props; valueGetter?: (response: ComponentReturnValue) => ComponentOutput; defaultValueGetter?: (defaultValue: DefaultValue) => T_IO_RETURNS; onStateChange?: (incomingState: T_IO_STATE) => Promise>; validator?: IOPromiseValidator | undefined; displayResolvesImmediately?: boolean; onPropsUpdate?: Evt>; }); multiple({ defaultValue, }?: { defaultValue?: DefaultValue[] | null; }): MultipleIOPromise; withChoices(choices: ChoiceButtonConfigOrShorthand[]): WithChoicesIOPromise; } export declare class MultipleIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends InputIOPromise { getSingleValue: ((response: ComponentReturnValue) => ComponentOutput) | undefined; defaultValue: T_IO_RETURNS[] | undefined | null; constructor({ defaultValue, valueGetter, ...rest }: { defaultValue?: T_IO_RETURNS[] | null; renderer: ComponentRenderer; methodName: MethodName; label: string; props: Props; valueGetter?: (response: ComponentReturnValue) => ComponentOutput; onStateChange?: (incomingState: T_IO_STATE) => Promise>; validator?: IOPromiseValidator | undefined; onPropsUpdate?: Evt>; }); then(resolve: (output: ComponentOutput[]) => void, reject?: (err: IOError) => void): void; validate(validator: IOPromiseValidator): this; getValue(results: MaybeMultipleComponentReturnValue): ComponentOutput[]; handleValidation(returnValues: MaybeMultipleComponentReturnValue | undefined): Promise; get component(): IOComponent; optional(isOptional?: true): OptionalMultipleIOPromise; optional(isOptional?: false): MultipleIOPromise; optional(isOptional?: boolean): OptionalMultipleIOPromise | MultipleIOPromise; } export declare class OptionalMultipleIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends OptionalIOPromise { getSingleValue: ((response: ComponentReturnValue) => ComponentOutput) | undefined; defaultValue: T_IO_RETURNS[] | undefined | null; constructor({ defaultValue, valueGetter, ...rest }: { defaultValue?: T_IO_RETURNS[] | null; renderer: ComponentRenderer; methodName: MethodName; label: string; props: Props; valueGetter?: (response: ComponentReturnValue) => ComponentOutput; onStateChange?: (incomingState: T_IO_STATE) => Promise>; validator?: IOPromiseValidator | undefined; onPropsUpdate?: Evt>; }); then(resolve: (output: ComponentOutput[] | undefined) => void, reject?: (err: IOError) => void): void; validate(validator: IOPromiseValidator): this; getValue(results: MaybeMultipleComponentReturnValue | undefined): ComponentOutput[] | undefined; handleValidation(returnValues: MaybeMultipleComponentReturnValue | undefined): Promise; get component(): IOComponent; } export declare class WithChoicesIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue, InnerPromise extends IOPromise = IOPromise, Choice extends string = string> { #private; innerPromise: InnerPromise; choiceButtons: ChoiceButtonConfig[]; constructor({ innerPromise, choiceButtons, }: { innerPromise: InnerPromise; choiceButtons: ChoiceButtonConfigOrShorthand[]; }); then(resolve: (output: { choice: Choice; returnValue: ComponentOutput; }) => void, reject?: (err: IOError) => void): void; get getValue(): (result: ComponentReturnValue) => ComponentOutput; get component(): IOComponent; validate(validator: WithChoicesIOPromiseValidator): this; handleValidation(returnValues: IOClientRenderReturnValues<[ AnyIOComponent, ...AnyIOComponent[] ]>): Promise; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: true): WithChoicesIOPromise, Choice>; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: false): WithChoicesIOPromise, Choice>; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: boolean): WithChoicesIOPromise, Choice> | WithChoicesIOPromise, Choice>; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: true): WithChoicesIOPromise, Choice>; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: false): WithChoicesIOPromise, Choice>; optional, ComponentOutput = ComponentReturnValue>(this: WithChoicesIOPromise, Choice>, isOptional?: boolean): WithChoicesIOPromise, Choice> | WithChoicesIOPromise, Choice>; multiple, ComponentOutput = ComponentReturnValue, DefaultValue = T_IO_PROPS extends { defaultValue?: any; } ? ComponentOutput | null : never>(this: WithChoicesIOPromise, Choice>, { defaultValue, }?: { defaultValue?: DefaultValue[] | null; }): WithChoicesIOPromise, Choice>; withChoices(choices: ChoiceButtonConfigOrShorthand[]): WithChoicesIOPromise; } /** * A thin subclass of IOPromise that does nothing but mark the component * as "exclusive" for components that cannot be rendered in a group. * Also cannot be optional at this time. */ export declare class ExclusiveIOPromise = T_IO_PROPS, ComponentOutput = ComponentReturnValue> extends IOPromise { get component(): IOComponent; handleValidation(returnValue: MaybeMultipleComponentReturnValue | undefined): Promise; validate(validator: IOPromiseValidator): this; } export declare type IOGroupReturnValues | [MaybeOptionalGroupIOPromise, ...MaybeOptionalGroupIOPromise[]]> = { [Idx in keyof IOPromises]: IOPromises[Idx] extends GroupIOPromise | OptionalGroupIOPromise ? ReturnType : IOPromises[Idx]; }; export declare type IOGroupComponents = { [Idx in keyof IOPromises]: IOPromises[Idx] extends GroupIOPromise | OptionalGroupIOPromise ? IOPromises[Idx]['component'] : IOPromises[Idx]; }; export declare type IOPromiseValidator = (returnValue: ComponentOutput) => string | undefined | Promise; export declare type WithChoicesIOPromiseValidator = (props: { choice: Choice; returnValue: ComponentOutput; }) => string | undefined | Promise; export declare class IOGroupPromise | MaybeOptionalGroupIOPromise[], ReturnValues = IOPromises extends Record ? { [K in keyof IOPromises]: ReturnType; } : IOPromises extends [ MaybeOptionalGroupIOPromise, ...MaybeOptionalGroupIOPromise[] ] ? IOGroupReturnValues : unknown[]> { #private; promises: IOPromises; renderer: ComponentsRenderer; validator: IOPromiseValidator | undefined; constructor(config: { promises: IOPromises; renderer: ComponentsRenderer; /** @deprecated Please use the chained .withSubmit() method instead. */ continueButton?: ButtonConfig; }); get components(): [AnyIOComponent, ...AnyIOComponent[]]; get promiseValues(): MaybeOptionalGroupIOPromise[]; then(resolve: (output: ReturnValues) => void, reject?: (err: IOError) => void): void; getValues({ returnValue, }: ComponentsRendererReturn<[ AnyIOComponent, ...AnyIOComponent[] ]>): ReturnValues; validate(validator: IOPromiseValidator | undefined): this; handleValidation(returnValues: IOClientRenderReturnValues<[ AnyIOComponent, ...AnyIOComponent[] ]>): Promise; withChoices(choices: ChoiceButtonConfigOrShorthand[]): WithChoicesIOGroupPromise; } export declare class WithChoicesIOGroupPromise | MaybeOptionalGroupIOPromise[], ReturnValues = IOPromises extends Record ? { [K in keyof IOPromises]: ReturnType; } : IOPromises extends [ MaybeOptionalGroupIOPromise, ...MaybeOptionalGroupIOPromise[] ] ? IOGroupReturnValues : unknown[], InnerPromise extends IOGroupPromise = IOGroupPromise, Choice extends string = string> { #private; validator: WithChoicesIOPromiseValidator | undefined; constructor(config: { innerPromise: InnerPromise; choiceButtons?: ChoiceButtonConfigOrShorthand[]; validator?: IOPromiseValidator; }); then(resolve: (output: { choice: Choice; returnValue: ReturnValues; }) => void, reject?: (err: IOError) => void): void; validate(validator: WithChoicesIOPromiseValidator | undefined): this; handleValidation(returnValues: IOClientRenderReturnValues<[ AnyIOComponent, ...AnyIOComponent[] ]>): Promise; withChoices(choices: ChoiceButtonConfigOrShorthand[]): WithChoicesIOGroupPromise; } export {};