UNPKG

torotask

Version:

Task queue processing in NodeJS based on BullMQ and Redis

30 lines 1.77 kB
import type { JobNode } from 'bullmq'; import type { TaskJobOptions, TaskJobState } from './job.js'; import { Task } from '../task.js'; import type { TaskGroupDefinitionRegistry, TaskGroupRegistry } from './task-group.js'; export type TaskFlowRunBaseOptions = Omit<TaskJobOptions, 'repeat' | 'parent'>; export type TaskFlowRunOptions = TaskFlowRunBaseOptions & Pick<TaskJobOptions, 'parent'>; export type TaskFlowRunChildOptions = TaskFlowRunBaseOptions; interface SpecificFlowRunConfig<TAllTaskGroupsDefs extends TaskGroupDefinitionRegistry, // Original raw schema GName extends keyof TaskGroupRegistry<TAllTaskGroupsDefs>, // A specific group name TName extends keyof TaskGroupRegistry<TAllTaskGroupsDefs>[GName]['tasks'], // A specific task name TOptions = TaskFlowRunOptions, Payload = TaskGroupRegistry<TAllTaskGroupsDefs>[GName]['tasks'][TName] extends Task<any, any, any, infer P> ? P : unknown> { taskGroup: GName; taskName: TName; name?: string; payload?: Payload; state?: TaskJobState; options?: TOptions; children?: TaskFlowRun<TAllTaskGroupsDefs, TaskFlowRunChildOptions>[]; } export type TaskFlowRun<TAllTaskGroupsDefs extends TaskGroupDefinitionRegistry = TaskGroupDefinitionRegistry, TOptions extends TaskFlowRunBaseOptions = TaskFlowRunOptions> = { [GKey in keyof TaskGroupRegistry<TAllTaskGroupsDefs>]: { [TKey in keyof TaskGroupRegistry<TAllTaskGroupsDefs>[GKey]['tasks']]: SpecificFlowRunConfig<TAllTaskGroupsDefs, GKey, TKey, TOptions>; }[keyof TaskGroupRegistry<TAllTaskGroupsDefs>[GKey]['tasks']]; }[keyof TaskGroupRegistry<TAllTaskGroupsDefs>]; export type TaskFlowGroupRun = TaskFlowRun<any> & { taskGroup?: string; }; export type TaskFlowRunNode = JobNode; export {}; //# sourceMappingURL=flow.d.ts.map