UNPKG

1.4 kBTypeScriptView Raw
1import { CommandContext, EventContext, HandlerStatus } from "./handler";
2/**
3 * Single step in the Skill execution
4 */
5export interface Step<C extends EventContext | CommandContext, G extends Record<string, any> = any> {
6 /** Name of the step */
7 name: string;
8 /** Function that gets called when the step should execute */
9 run: (context: C, parameters: G) => Promise<undefined | HandlerStatus>;
10 /** Optional function to indicate if the step should runSkill */
11 runWhen?: (context: C, parameters: G) => Promise<boolean>;
12}
13export interface StepListener<C extends EventContext | CommandContext, G extends Record<string, any> = any> {
14 starting?(step: Step<C>, parameters: G): Promise<void>;
15 skipped?(step: Step<C>, parameters: G): Promise<void>;
16 completed?(step: Step<C>, parameters: G, result: undefined | HandlerStatus): Promise<void>;
17 failed?(step: Step<C>, parameters: G, error: Error): Promise<void>;
18 done?(parameters: G, result: undefined | HandlerStatus): Promise<undefined | HandlerStatus>;
19}
20/**
21 * Execute provided skill steps in the order they are provided or until one fails
22 */
23export declare function runSteps<C extends EventContext | CommandContext>(options: {
24 context: C;
25 steps: Step<C> | Array<Step<C>>;
26 listeners?: StepListener<C> | Array<StepListener<C>>;
27}): Promise<undefined | HandlerStatus>;
28//# sourceMappingURL=steps.d.ts.map
\No newline at end of file