/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */
import Joi from 'joi';
import { Transactionable } from '@nocobase/database';
import type Plugin from '../Plugin';
import type Processor from '../Processor';
import type { FlowNodeModel, WorkflowModel } from '../types';
export interface IJob {
    status: number;
    result?: unknown;
    log?: string;
    [key: string]: unknown;
}
/**
 * The result of an instruction execution.
 *
 * Different type of result will cause according behavior in the workflow engine:
 * 1. IJob | Promise<IJob>: processor will continue default processing by checking the status.
 * 2. `null` | Promise<null>: processor will do exit process.
 * 3. `void` | Promise<void>: processor will do nothing, and terminate the current execution without any action.
 */
export type InstructionResult = IJob | null | void;
export type Runner = (node: FlowNodeModel, input: any, processor: Processor, options?: {
    rerun?: true;
    signal?: AbortSignal;
}) => InstructionResult | Promise<InstructionResult>;
export type InstructionInterface = {
    run: Runner;
    resume?: Runner;
    getScope?: (node: FlowNodeModel, data: any, processor: Processor) => any;
    duplicateConfig?: (node: FlowNodeModel, options: Transactionable & {
        origin?: FlowNodeModel;
    }) => object | Promise<object>;
    validateConfig?: (config: Record<string, any>) => Record<string, string> | null;
    isAvailable?: (workflow: WorkflowModel, node: FlowNodeModel) => boolean;
    test?: (config: Record<string, any>) => IJob | Promise<IJob>;
};
export declare abstract class Instruction implements InstructionInterface {
    workflow: Plugin;
    configSchema?: Joi.ObjectSchema;
    constructor(workflow: Plugin);
    validateConfig(config: Record<string, any>): Record<string, string> | null;
    abstract run(node: FlowNodeModel, input: any, processor: Processor, options?: {
        rerun?: true;
        signal?: AbortSignal;
    }): InstructionResult | Promise<InstructionResult>;
}
export default Instruction;
