UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

67 lines (66 loc) 2.27 kB
import { SendGridCredentials } from '../credentials/sendGrid'; import type { IExecuteSettings as IMinimumExecuteSettings, INextFunction, IReadyTask, IRunningTask } from '../eventEmitter/task'; import * as factory from '../factory'; import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/task'; import { Settings } from '../settings'; import { AggregationSettings } from '../settings/aggregation'; interface ICredentialSettings { sendGrid: SendGridCredentials; } interface IExecuteSettings extends IMinimumExecuteSettings { credentials: ICredentialSettings; settings: Settings; aggregationSettings?: AggregationSettings; } interface IExecuteOptions { executeById: boolean; executeByName: boolean; } type IOperation<T> = (settings: IExecuteSettings) => Promise<T>; type IOperationExecute<T> = (settings: IExecuteSettings, options: IExecuteOptions) => Promise<T>; type ICallResult = void | Pick<factory.task.IExecutionResult, 'error'>; export type ICallableTaskOperation = (task: IExecutableTask<factory.taskName>) => IOperationExecute<ICallResult>; /** * タスク変更イベントを受けて実行する */ declare function executeById(params: (IReadyTask | IRunningTask) & { executor: { /** * タスク実行者名称 */ name: string; }; }, next?: INextFunction): IOperation<void>; /** * support no name(2025-03-04~) */ declare function executeOneIfExists(params: { name?: { $eq?: factory.taskName; $nin?: factory.taskName[]; }; executor: { /** * タスク実行者名称 */ name: string; }; runsAt: { $lt: Date; }; }): IOperation<void>; /** * タスクを実行する */ declare function execute(task: IExecutableTask<factory.taskName>, next?: INextFunction): IOperationExecute<void>; /** * add(2025-03-13~) */ declare function notifyAbortedTasksByEmail(params: { dateAbortedGte: Date; }): (repos: { task: TaskRepo; }, settings: Pick<Settings, "abortedTasksWithoutReport">, credentials: { sendGrid: SendGridCredentials; }) => Promise<void>; export { ICallResult, IExecutableTaskKeys, IOperationExecute, executeById, executeOneIfExists, execute, notifyAbortedTasksByEmail };