import type * as client from '@botpress/client'; import { AsyncCollection } from '../../utils/api-paging-utils'; import type * as typeUtils from '../../utils/type-utils'; import type * as commonTypes from '../common'; export type WorkflowProxy = Readonly<{ [TWorkflowName in typeUtils.StringKeys]: Readonly<{ startNewInstance: (x: Pick & { tags?: typeUtils.AtLeastOneProperty; input: TBot['workflows'][TWorkflowName]['input']; }) => Promise & { workflow: ActionableWorkflow; }>>; listInstances: (x?: Pick & { tags?: typeUtils.AtLeastOneProperty; /** * Filter by statuses: * * - `pending` - Workflow is created but not started yet * - `in_progress` - Workflow is currently running * - `failed` - Workflow finished with errors * - `completed` - Workflow finished successfully * - `cancelled` - Workflow finished due to cancellation through the API * - `timedout` - Workflow finished due to timeout * - `listening` - Workflow is waiting for an event to continue * - `paused` - Workflow was paused through the API */ statuses?: client.Workflow['status'][]; }) => AsyncCollection>; }>; }>; export type ActionableWorkflow> = Readonly['input']; output: Partial['output']>; tags: Partial; /** * Updates the current workflow instance */ update(x: typeUtils.AtLeastOneProperty & { tags?: typeUtils.AtLeastOneProperty; output?: typeUtils.Cast['output']; }>): Promise<{ workflow: ActionableWorkflow; }>; /** * Acknowledges the start of processing for a pending workflow instance. * If the workflow is not in pending status or has already been * acknowledged, this is a no-op. * * This method **should be called in every workflow handler** as soon as the * workflow **starts doing work**. If no work needs to be done, setCompleted * or setFailed should be called instead. * * Should a workflow not be acknowledged **in a timely fashion**, it will be * retriggered 3 times before being marked as failed. */ acknowledgeStartOfProcessing(): Promise<{ workflow: ActionableWorkflow; }>; /** * Marks the current workflow instance as failed and stops execution */ setFailed(x: Required>): Promise<{ workflow: ActionableWorkflow; }>; /** * Marks the current workflow instance as completed and stops execution */ setCompleted(x?: { output?: typeUtils.Cast['output']; }): Promise<{ workflow: ActionableWorkflow; }>; /** * Discards all output data and cancels the current workflow instance */ cancel(): Promise<{ workflow: ActionableWorkflow; }>; }>;