import type { Task } from "./Task"; import type { LogLevel } from "./diagnostics/logging"; import type ActivityContext from "./execution/ActivityContext"; import type Bluebird from "bluebird"; /** * Implemented by activity handlers. * @public */ export interface IActivityHandler { /** Executes the logic for an activity. */ execute(inputs: object, context: IActivityContext, ...args: any[]): PromiseLike | object; } /** * Describes ambient-level state. * @public */ export interface IAmbientState { /** Indicates the ActivityContexts with group name monikers that are in scope. */ activityContexts: Record; /** Indicates the completion object. */ completion: Bluebird; /** Indicates the environment for expressions evaluation. */ environment: Record; /** Indicates the error given to the workflow consumer. */ error?: Error; /** Indicates the inputs given to the workflow consumer. */ inputs: Record; /** Indicates the current workflow locale. */ locale?: string; /** Indicates the current workflow log level. */ logLevel?: LogLevel; /** Indicates the outputs that the workflow should return. */ outputs: Record; /** The printing engine URL used for sending print requests. */ printingServiceUrl?: string; /** Indicates the resources for expression evaluation. */ resources?: Record; /** Indicates the trivia for storing ambient-level state. */ trivia?: Record; /** Immediately completes the workflow. */ complete(outputs?: Record): void; /** Immediately completes the workflow with an error. */ reject(error?: Error): void; } /** * Describes something that can be aborted via an `AbortController`. */ export interface Abortable { /** * An `AbortSignal` to be passed to Esri's web-based APIs. * When aborted, the operation will be cancelled. */ signal?: AbortSignal; } /** * Describes an activity currently being executed. * @public */ export interface IActivityContext { /** Indicates the action being executed. */ action?: string; /** Indicates the ambient state. */ ambient: IAmbientState; /** Indicates the branch being executed. */ branch?: boolean | number | string; /** Indicates the cancellation token. */ cancellationToken: Task & Abortable; /** Indicates the error that was caught. */ caught?: Error; /** Indicates the locally-unique identifier that changes per-run per-activity. */ luid: any; /** Indicates the number of passes on the current step. */ passes: number; /** Indicates the state that was persisted. */ state: any; /** Attempts to call on a transition chain. */ call(branch?: boolean | number | string): void; /** Attempts to fork to a transition chain. */ fork(branch?: boolean | number | string): void; /** Attempts to restart the workflow at the context. */ goto(): void; /** Indicates if any transitions are available for the given branch. */ hasBranch(branch?: boolean | number | string): boolean; /** Attempts to jump to a transition chain. */ jump(branch?: boolean | number | string): void; /** Persists state across invocations. */ persist(state: any): void; /** Instructs the engine to allow the activity to handle errors. */ registerForErrors(): void; } /** * Indicates an activity has no inputs. Should only be used in * an activity's execute method signature. * @public */ export interface EmptyInputs { } /** * Indicates an activity has no outputs. Should only be used in * an activity's execute method signature. * @public */ export interface EmptyOutputs { }