import { DeferableFunction, DeferredFunction } from "./index"; export type ExecutionState = "created" | "started" | "succeed" | "failed" | "cancelled" | "aborting" | "aborted" | "discarded"; export type ExecutionErrorCode = "ER0000" | "ER0001" | "ER0002" | "ER0003"; export interface Execution { id: string; state: ExecutionState; functionName: string; functionId: string; scheduledAt: Date; createdAt: Date; updatedAt: Date; } export interface PageInfo { hasNextPage: boolean; hasPrevPage: boolean; startCursor: string | undefined; endCursor: string | undefined; } export interface PageResult { data: T[]; pageInfo: PageInfo; } export interface PageRequest { first?: number; after?: string; last?: number; before?: string; } export interface DateInterval { from: Date; to: Date; } export interface ExecutionFilters { states?: ExecutionState[]; functionIds?: string[]; errorCodes?: ExecutionErrorCode[]; executedBy?: string; startedAt?: DateInterval; scheduleAt?: DateInterval; metadata?: { key: string; values: string[]; }[]; } export type EnqueueResult = Execution; export type GetExecutionResult = Execution; export type CancelExecutionResult = Execution; export type RescheduleExecutionResult = Execution; export type ReRunExecutionResult = Execution; export type ListExecutionsResult = PageResult; export type ListExecutionAttemptsResult = PageResult; export declare const errorMessage: (error: Error) => string; export declare class DeferError extends Error { constructor(msg: string); } export declare class ExecutionNotFound extends DeferError { constructor(msg: string); } export declare class ExecutionNotCancellable extends DeferError { constructor(msg: string); } export declare class ExecutionAbortingAlreadyInProgress extends DeferError { constructor(msg: string); } export declare class ExecutionNotReschedulable extends DeferError { constructor(state: string); } export declare class ExecutionResultNotAvailable extends DeferError { constructor(); } export declare class ExecutionResultNotAvailableYet extends DeferError { constructor(); } export interface Backend { enqueue(func: DeferredFunction, args: Parameters, scheduleFor: Date, discardAfter: Date | undefined, metadata: { [key: string]: string; } | undefined): Promise; getExecution(id: string): Promise; getExecutionResult(id: string): Promise; cancelExecution(id: string, force: boolean): Promise; reRunExecution(id: string): Promise; rescheduleExecution(id: string, scheduleFor: Date): Promise; listExecutions(page?: PageRequest, filters?: ExecutionFilters): Promise; listExecutionAttempts(id: string, page?: PageRequest, filters?: ExecutionFilters): Promise; }