smartrule/ts/smartrule.classes.rule.ts

27 lines
824 B
TypeScript
Raw Permalink Normal View History

2022-08-07 09:18:02 +00:00
import * as plugins from './smartrule.plugins.js';
import { SmartRule } from './smartrule.classes.smartrule.js';
2020-01-20 14:41:27 +00:00
export type TTreeActionResult = 'continue' | 'apply-continue' | 'apply-stop' | 'stop';
2022-08-07 09:18:02 +00:00
export type TActionFunc<T = any> = (objectArg: T) => Promise<any>;
2020-01-20 14:41:27 +00:00
export type TCheckFunc<T> = (objectArg: T) => Promise<TTreeActionResult>;
export class Rule<T> {
public smartRuleRef: SmartRule<T>;
public priority: number;
public checkFunction: TCheckFunc<T>;
public actionFunction: TActionFunc;
2020-01-24 07:11:25 +00:00
constructor(
smartRuleRef: SmartRule<T>,
priorityArg: number,
checkFunctionArg: TCheckFunc<T>,
actionFunctionArg: TActionFunc
) {
2020-01-20 14:41:27 +00:00
this.smartRuleRef = smartRuleRef;
this.priority = priorityArg;
this.checkFunction = checkFunctionArg;
this.actionFunction = actionFunctionArg;
}
2020-01-24 07:11:25 +00:00
}