import { Context, FunctionsTable, Expression, StringPaths, RequireOnlyOne } from './evaluator'; export interface RuleConsequenceMessageParrContextRef { ref: StringPaths; } export type RuleConsequenceMessagePart = string | RuleConsequenceMessageParrContextRef; export interface ResolvedConsequence { message: string; custom: ConsequencePayload; } export interface RuleConsequence { message: string | RuleConsequenceMessagePart[]; custom: ConsequencePayload; } export interface RuleDefinition, Ignore, CustomEngineRuleFuncRunOptions> { condition: Expression; consequence: RuleConsequence; } export type EngineRuleFuncRunOptions = { custom: CustomEngineRuleFuncRunOptions; validation: boolean; }; export type RuleFunc = (param: any, context: C, runOptions: EngineRuleFuncRunOptions) => void | ResolvedConsequence | Promise<(void | ResolvedConsequence)>; export type RuleFunctionsTable = Record>; export type RuleFunctionParam, K extends keyof RF, CustomEngineRuleFuncRunOptions> = Awaited[0]>; export type RuleFunctionsParams, CustomEngineRuleFuncRunOptions> = { [K in keyof RF]: RuleFunctionParam; }; export type Rule, C extends Context, F extends FunctionsTable, Ignore = never, CustomEngineRuleFuncRunOptions = undefined> = RuleDefinition | RequireOnlyOne>;