UNPKG

lidex-mongo

Version:
33 lines (32 loc) 1.4 kB
type Status = "idle" | "running" | "failed" | "finished" | "aborted"; interface Workflow { id: string; handler: string; input: unknown; status: Status; timeoutAt?: Date; failures?: number; lastError?: string; steps?: { [key: string]: unknown; }; naps?: { [key: string]: Date; }; } type RunData = Pick<Workflow, "handler" | "input" | "failures">; export declare function makeMongoPersistence(url: string): { init: () => Promise<void>; insert: (workflowId: string, handler: string, input: unknown) => Promise<boolean>; claim: (now: Date, timeoutAt: Date) => Promise<string | undefined>; findOutput: (workflowId: string, stepId: string) => Promise<unknown>; findWakeUpAt: (workflowId: string, napId: string) => Promise<Date | undefined>; findRunData: (workflowId: string) => Promise<RunData | undefined>; setAsFinished: (workflowId: string) => Promise<void>; findStatus: (workflowId: string) => Promise<Status | undefined>; updateStatus: (workflowId: string, status: Status, timeoutAt: Date, failures: number, lastError: string) => Promise<void>; updateOutput: (workflowId: string, stepId: string, output: unknown, timeoutAt: Date) => Promise<void>; updateWakeUpAt: (workflowId: string, napId: string, wakeUpAt: Date, timeoutAt: Date) => Promise<void>; terminate: () => Promise<void>; }; export {};