import { ServicesList } from "./services.type";

export type Fn<T> = (context: any, services?: ServicesList) => T;
export type CompensateFn<T> = (context: any, payload: any) => T;
export type Condition = Fn<boolean>;
export type Compensation = CompensateFn<void>;

export type InvokeAction = {
  name?: string;
  validate?: any;
  condition?: Condition;
  action: Fn<any>;
  withCompensation?: Compensation;
};

export type Invoke = Fn<any> | InvokeAction;
