UNPKG

@nocobase/plugin-workflow

Version:

A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.

46 lines (45 loc) 1.82 kB
/** * 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 { Model, Transactionable } from '@nocobase/database'; 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 DateFieldScheduleTrigger { workflow: Plugin; events: Map<any, any>; private timer; private cache; cacheCycle: number; onAfterStart: () => void; onBeforeStop: () => void; constructor(workflow: Plugin); reload(): void; inspect(workflow: WorkflowModel): Promise<void>; loadRecordsToSchedule({ id, config: { collection, limit, startsOn, repeat, endsOn }, stats }: WorkflowModel, currentDate: Date): Promise<Model<any, any>[]>; getRecordNextTime(workflow: WorkflowModel, record: Model, nextSecond?: boolean): any; schedule(workflow: WorkflowModel, record: Model, nextTime: number, toggle?: boolean, options?: {}): Promise<void>; trigger(workflow: WorkflowModel, record: Model, nextTime: number, { transaction }?: Transactionable): Promise<void>; on(workflow: WorkflowModel): void; off(workflow: WorkflowModel): void; execute(workflow: any, values: any, options: any): Promise<void | import("../..").Processor>; validateContext(values: any): { data: string; }; }