@tachybase/module-workflow
Version:
A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.
32 lines (31 loc) • 1.29 kB
TypeScript
import { Transactionable } from '@tego/server';
import type Plugin from '../../Plugin';
import type { WorkflowModel } from '../../types';
export type ScheduleOnField = {
field: string;
offset?: number;
unit?: 1000 | 60000 | 3600000 | 86400000;
};
export interface ScheduleTriggerConfig {
mode: number;
repeat?: string | number | null;
limit?: number;
startsOn?: ScheduleOnField;
endsOn?: string | ScheduleOnField;
}
export default class ScheduleTrigger {
workflow: Plugin;
events: Map<any, any>;
private timer;
private cache;
cacheCycle: number;
constructor(workflow: Plugin);
reload(): Promise<void>;
inspect(workflows: WorkflowModel[]): void;
loadRecordsToSchedule({ config: { collection, limit, startsOn, repeat, endsOn }, allExecuted }: WorkflowModel, currentDate: Date): Promise<import("@tego/server").Model<any, any>[]>;
getRecordNextTime(workflow: WorkflowModel, record: any, nextSecond?: boolean): any;
schedule(workflow: WorkflowModel, record: any, nextTime: any, toggle?: boolean, options?: {}): Promise<void>;
trigger(workflow: WorkflowModel, record: any, nextTime: any, { transaction }?: Transactionable): Promise<void>;
on(workflow: WorkflowModel): void;
off(workflow: WorkflowModel): void;
}