import { ValidationResult } from '@fajarnugraha37/error'; type ValidatorFn = (data: unknown) => boolean; type validateExpressionFn = (data: T) => ValidationResult; type ValidateErrorGetter = () => unknown; interface ExpressionSchema { readonly id: string; readonly name: string; readonly description: string; readonly multipleOperations: CombinationOperator; readonly operations: readonly Operation[]; readonly metadata?: ExpressionMetadata; readonly version?: string; } interface ExpressionMetadata { readonly author?: string; readonly createdAt?: string; readonly updatedAt?: string; readonly tags?: readonly string[]; readonly category?: string; readonly priority?: number; } type CombinationOperator = "and" | "or"; interface VarOperand { readonly var: string; readonly defaultValue?: unknown; } interface ValOperand { readonly val: readonly string[]; } interface RefOperand { readonly ref: string; } interface LiteralOperand { readonly literal: unknown; } type ValueOperand = string | number | boolean | null | undefined | Date; type OperandOption = VarOperand | ValOperand | RefOperand | LiteralOperand | ValueOperand; type MathOperators = "+" | "-" | "*" | "/" | "%" | "**" | "min" | "max" | "abs" | "round" | "floor" | "ceil" | "sqrt" | "log" | "sin" | "cos" | "tan"; type LogicOperators = ">" | ">=" | "<" | "<=" | "not" | "!" | "!!" | "and" | "or" | "xor" | "??" | "==" | "===" | "!=" | "!==" | "if" | "?:" | "switch" | "case"; type StringOperators = "cat" | "concat" | "join" | "in" | "contains" | "startsWith" | "endsWith" | "substr" | "substring" | "slice" | "length" | "trim" | "toLowerCase" | "toUpperCase" | "replace" | "replaceAll" | "split" | "match" | "test" | "pad" | "padStart" | "padEnd"; type ArrayOperators = "in" | "contains" | "includes" | "merge" | "concat" | "join" | "length" | "count" | "size" | "get" | "at" | "first" | "last" | "push" | "pop" | "shift" | "unshift" | "slice" | "splice" | "reverse" | "sort" | "unique" | "flatten" | "groupBy" | "partition"; type ObjectOperators = "get" | "set" | "has" | "delete" | "keys" | "values" | "entries" | "assign" | "merge" | "pick" | "omit" | "clone" | "deepClone"; type DateOperators = "now" | "today" | "date" | "year" | "month" | "day" | "hour" | "minute" | "second" | "addYears" | "addMonths" | "addDays" | "addHours" | "format" | "parse" | "isValid" | "isBefore" | "isAfter" | "isSame" | "diff" | "duration"; type ValidationOperators = "isNull" | "isUndefined" | "isDefined" | "isEmpty" | "isString" | "isNumber" | "isBoolean" | "isArray" | "isObject" | "isEmail" | "isUrl" | "isUuid" | "isJson" | "matches" | "validate" | "assert"; type ContextOperators = "var" | "val" | "ref" | "literal" | "exists" | "missing" | "missing_some" | "context" | "scope" | "env" | "cache" | "memo"; type HigherOrderOperators = "map" | "filter" | "reduce" | "find" | "findIndex" | "every" | "all" | "some" | "none" | "forEach" | "eachKey" | "eachValue" | "pipe" | "compose" | "curry" | "debounce" | "throttle"; type ControlFlowOperators = "if" | "ifElse" | "unless" | "when" | "switch" | "case" | "default" | "try" | "catch" | "finally" | "loop" | "while" | "until" | "for" | "break" | "continue" | "return"; type AsyncOperators = "await" | "promise" | "resolve" | "reject" | "timeout" | "delay" | "race" | "all" | "allSettled" | "retry" | "fallback"; type OperatorOption = MathOperators | LogicOperators | StringOperators | ArrayOperators | ObjectOperators | DateOperators | ValidationOperators | ContextOperators | HigherOrderOperators | ControlFlowOperators | AsyncOperators; type OperationOperand = Operation | OperandOption; type Operation = Partial<{ readonly [K in OperatorOption]: OperationOperand | readonly OperationOperand[]; }>; interface ExecutionContext { readonly data: unknown; readonly variables?: Record; readonly functions?: Record; readonly metadata?: Record; readonly parent?: ExecutionContext; } interface ExecutionResult { readonly value: T; readonly success: boolean; readonly error?: Error; readonly metadata?: ExecutionMetadata; } interface ExecutionMetadata { readonly duration: number; readonly operations: number; readonly cacheHits: number; readonly cacheMisses: number; readonly depth: number; } interface EvaluatorConfig { readonly cache?: CacheConfig; readonly timeout?: number; readonly maxDepth?: number; readonly strictMode?: boolean; readonly asyncMode?: boolean; readonly debug?: boolean; } interface CacheConfig { readonly maxEntries?: number; readonly maxSize?: number; readonly ttl?: number; readonly sweepInterval?: number; } type DeepReadonly = { readonly [P in keyof T]: T[P] extends object ? DeepReadonly : T[P]; }; type Optional = Omit & Partial>; type ExperssionSchema = ExpressionSchema; export type { ArrayOperators, AsyncOperators, CacheConfig, CombinationOperator, ContextOperators, ControlFlowOperators, DateOperators, DeepReadonly, EvaluatorConfig, ExecutionContext, ExecutionMetadata, ExecutionResult, ExperssionSchema, ExpressionMetadata, ExpressionSchema, HigherOrderOperators, LiteralOperand, LogicOperators, MathOperators, ObjectOperators, OperandOption, Operation, OperationOperand, OperatorOption, Optional, RefOperand, StringOperators, ValOperand, ValidateErrorGetter, ValidationOperators, ValidatorFn, ValueOperand, VarOperand, validateExpressionFn };