import { Addon } from './aop'; import { PromiseType } from './base'; import { Token } from './security'; export declare class Transaction { /** * 事务ID */ id: string; /** * 事务名称 */ name: string; /** * 上级事务 */ parentTransaction?: Transaction; /** * 子事务栈 */ subTransactions: Transaction[]; /** * 启动时间 */ startTime?: Date; /** * 执行开始时间 */ doingTime?: Date; /** * 执行完成时间 */ didTime?: Date; /** * 结束时间 */ endTime?: Date; /** * 错误信息 */ error?: Error; /** * 令牌信息 */ token?: Token; /** * 任务消息 */ taskMessage?: string; onCommit?: () => void; onRollback?: () => void; constructor(name: string, parentTransaction?: Transaction); /** * 提交 */ commit(): Promise; /** * 回滚 */ rollback(): Promise; /** * 获取根事务 */ getRoot(): Transaction | undefined; /** * 获取当前事务(堆栈中最低级的事务) */ getCurrentTransaction(): Transaction | undefined; /** * 执行 * @param task 执行的任务 * @param taskMessage 任务消息 */ do(task: () => void, taskMessage?: string): Promise; /** * 执行子事务 * @param name 事务名称 * @param task 任务 */ doTransaction(name: string, task: () => void, taskMessage?: string): Promise; getData?: (() => { id: string; parentID: string | undefined; name: string; error: string; startTime: Date | undefined; endTime: Date | undefined; doingTime: Date | undefined; didTime: Date | undefined; tokenID: string | undefined; userID: string | undefined; userName: string | undefined; }) | undefined; } /** * 执行事务 * @param transName 事务名称 * @param task 任务 * @param taskMessage 任务消息 */ export declare function doTransaction(transName: string, task: () => void, taskMessage?: string): Promise; export declare type TransactionAction = 'begin' | 'doing' | 'did' | 'exception' | 'commit' | 'rollback'; /** * 事务日志接口 */ export declare class ITransactionLog { /** * 记录日志: */ record?: (transaction: Transaction) => PromiseType; } /** * 事务日志 */ export declare class TransactionLog { static loggers: ITransactionLog[]; static log(transaction: Transaction): void; static addLogger(logger: TransactionLog): void; } export declare class CommonTransactionLog extends Addon implements ITransactionLog { /** * 记录事务日志 */ record?: ((transaction: Transaction) => void) | undefined; }