@f-o-t/rules-engine 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1166,57 +1166,57 @@ var executeWithTimeout = async (hookName, hookFn, hooks, timeoutMs) => {
1166
1166
  var executeBeforeEvaluation = async (hooks, context, rules, timeoutMs) => {
1167
1167
  if (!hooks.beforeEvaluation)
1168
1168
  return;
1169
- await executeWithTimeout("beforeEvaluation", () => hooks.beforeEvaluation(context, rules), hooks, timeoutMs);
1169
+ await executeWithTimeout("beforeEvaluation", () => hooks.beforeEvaluation?.(context, rules), hooks, timeoutMs);
1170
1170
  };
1171
1171
  var executeAfterEvaluation = async (hooks, result, timeoutMs) => {
1172
1172
  if (!hooks.afterEvaluation)
1173
1173
  return;
1174
- await executeWithTimeout("afterEvaluation", () => hooks.afterEvaluation(result), hooks, timeoutMs);
1174
+ await executeWithTimeout("afterEvaluation", () => hooks.afterEvaluation?.(result), hooks, timeoutMs);
1175
1175
  };
1176
1176
  var executeBeforeRuleEvaluation = async (hooks, rule2, context, timeoutMs) => {
1177
1177
  if (!hooks.beforeRuleEvaluation)
1178
1178
  return;
1179
- await executeWithTimeout("beforeRuleEvaluation", () => hooks.beforeRuleEvaluation(rule2, context), hooks, timeoutMs);
1179
+ await executeWithTimeout("beforeRuleEvaluation", () => hooks.beforeRuleEvaluation?.(rule2, context), hooks, timeoutMs);
1180
1180
  };
1181
1181
  var executeAfterRuleEvaluation = async (hooks, rule2, result, timeoutMs) => {
1182
1182
  if (!hooks.afterRuleEvaluation)
1183
1183
  return;
1184
- await executeWithTimeout("afterRuleEvaluation", () => hooks.afterRuleEvaluation(rule2, result), hooks, timeoutMs);
1184
+ await executeWithTimeout("afterRuleEvaluation", () => hooks.afterRuleEvaluation?.(rule2, result), hooks, timeoutMs);
1185
1185
  };
1186
1186
  var executeOnRuleMatch = async (hooks, rule2, context, timeoutMs) => {
1187
1187
  if (!hooks.onRuleMatch)
1188
1188
  return;
1189
- await executeWithTimeout("onRuleMatch", () => hooks.onRuleMatch(rule2, context), hooks, timeoutMs);
1189
+ await executeWithTimeout("onRuleMatch", () => hooks.onRuleMatch?.(rule2, context), hooks, timeoutMs);
1190
1190
  };
1191
1191
  var executeOnRuleSkip = async (hooks, rule2, reason, timeoutMs) => {
1192
1192
  if (!hooks.onRuleSkip)
1193
1193
  return;
1194
- await executeWithTimeout("onRuleSkip", () => hooks.onRuleSkip(rule2, reason), hooks, timeoutMs);
1194
+ await executeWithTimeout("onRuleSkip", () => hooks.onRuleSkip?.(rule2, reason), hooks, timeoutMs);
1195
1195
  };
1196
1196
  var executeOnRuleError = async (hooks, rule2, ruleError, timeoutMs) => {
1197
1197
  if (!hooks.onRuleError)
1198
1198
  return;
1199
- await executeWithTimeout("onRuleError", () => hooks.onRuleError(rule2, ruleError), hooks, timeoutMs);
1199
+ await executeWithTimeout("onRuleError", () => hooks.onRuleError?.(rule2, ruleError), hooks, timeoutMs);
1200
1200
  };
1201
1201
  var executeOnConsequenceCollected = async (hooks, rule2, consequence, timeoutMs) => {
1202
1202
  if (!hooks.onConsequenceCollected)
1203
1203
  return;
1204
- await executeWithTimeout("onConsequenceCollected", () => hooks.onConsequenceCollected(rule2, consequence), hooks, timeoutMs);
1204
+ await executeWithTimeout("onConsequenceCollected", () => hooks.onConsequenceCollected?.(rule2, consequence), hooks, timeoutMs);
1205
1205
  };
1206
1206
  var executeOnCacheHit = async (hooks, key, result, timeoutMs) => {
1207
1207
  if (!hooks.onCacheHit)
1208
1208
  return;
1209
- await executeWithTimeout("onCacheHit", () => hooks.onCacheHit(key, result), hooks, timeoutMs);
1209
+ await executeWithTimeout("onCacheHit", () => hooks.onCacheHit?.(key, result), hooks, timeoutMs);
1210
1210
  };
1211
1211
  var executeOnCacheMiss = async (hooks, key, timeoutMs) => {
1212
1212
  if (!hooks.onCacheMiss)
1213
1213
  return;
1214
- await executeWithTimeout("onCacheMiss", () => hooks.onCacheMiss(key), hooks, timeoutMs);
1214
+ await executeWithTimeout("onCacheMiss", () => hooks.onCacheMiss?.(key), hooks, timeoutMs);
1215
1215
  };
1216
1216
  var executeOnSlowRule = async (hooks, rule2, timeMs, threshold, timeoutMs) => {
1217
1217
  if (!hooks.onSlowRule)
1218
1218
  return;
1219
- await executeWithTimeout("onSlowRule", () => hooks.onSlowRule(rule2, timeMs, threshold), hooks, timeoutMs);
1219
+ await executeWithTimeout("onSlowRule", () => hooks.onSlowRule?.(rule2, timeMs, threshold), hooks, timeoutMs);
1220
1220
  };
1221
1221
 
1222
1222
  // src/engine/state.ts
@@ -1590,7 +1590,6 @@ var createEngine = (config = {}) => {
1590
1590
  }),
1591
1591
  getStats: () => {
1592
1592
  const enabledRules = Array.from(state.rules.values()).filter((r) => r.enabled).length;
1593
- const _cacheStats = cache.getStats();
1594
1593
  return {
1595
1594
  totalRules: state.rules.size,
1596
1595
  enabledRules,
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArrayCondition, ArrayOperator, BooleanCondition, BooleanOperator, Condition as Condition3, ConditionGroup as ConditionGroup6, ConditionGroupInput, CustomCondition, DateCondition, DateOperator, EvaluationResult, GroupEvaluationResult as GroupEvaluationResult2, GroupEvaluationResultInput, LogicalOperator, NumberCondition, NumberOperator, StringCondition, StringOperator } from "@f-o-t/condition-evaluator";
1
+ import { ArrayCondition, ArrayOperator, BooleanCondition, BooleanOperator, Condition as Condition2, ConditionGroup as ConditionGroup6, CustomCondition, DateCondition, DateOperator, EvaluationResult, GroupEvaluationResult as GroupEvaluationResult2, LogicalOperator, NumberCondition, NumberOperator, StringCondition, StringOperator } from "@f-o-t/condition-evaluator";
2
2
  import { ConditionGroup as ConditionGroup7, isConditionGroup } from "@f-o-t/condition-evaluator";
3
3
  import { z } from "zod";
4
4
  type ConsequenceDefinitions = Record<string, z.ZodType>;
@@ -91,60 +91,8 @@ type RuleFilters = {
91
91
  readonly ruleSetId?: string;
92
92
  readonly ids?: ReadonlyArray<string>;
93
93
  };
94
- declare const RuleSchema: z2.ZodObject<{
95
- id: z2.ZodString;
96
- name: z2.ZodString;
97
- description: z2.ZodOptional<z2.ZodString>;
98
- conditions: z2.ZodCustom<{
99
- id: string;
100
- operator: "AND" | "OR";
101
- scoringMode?: "binary" | "weighted" | undefined;
102
- threshold?: number | undefined;
103
- weight?: number | undefined;
104
- } & {
105
- conditions: (import("@f-o-t/condition-evaluator").Condition | ({
106
- id: string;
107
- operator: "AND" | "OR";
108
- scoringMode?: "binary" | "weighted" | undefined;
109
- threshold?: number | undefined;
110
- weight?: number | undefined;
111
- } & any))[];
112
- }, {
113
- id: string;
114
- operator: "AND" | "OR";
115
- scoringMode?: "binary" | "weighted" | undefined;
116
- threshold?: number | undefined;
117
- weight?: number | undefined;
118
- } & {
119
- conditions: (import("@f-o-t/condition-evaluator").Condition | ({
120
- id: string;
121
- operator: "AND" | "OR";
122
- scoringMode?: "binary" | "weighted" | undefined;
123
- threshold?: number | undefined;
124
- weight?: number | undefined;
125
- } & any))[];
126
- }>;
127
- consequences: z2.ZodArray<z2.ZodObject<{
128
- type: z2.ZodString;
129
- payload: z2.ZodUnknown;
130
- }, z2.core.$strip>>;
131
- priority: z2.ZodDefault<z2.ZodNumber>;
132
- enabled: z2.ZodDefault<z2.ZodBoolean>;
133
- stopOnMatch: z2.ZodDefault<z2.ZodBoolean>;
134
- tags: z2.ZodDefault<z2.ZodArray<z2.ZodString>>;
135
- category: z2.ZodOptional<z2.ZodString>;
136
- metadata: z2.ZodOptional<z2.ZodRecord<z2.ZodString, z2.ZodUnknown>>;
137
- createdAt: z2.ZodDefault<z2.ZodDate>;
138
- updatedAt: z2.ZodDefault<z2.ZodDate>;
139
- }, z2.core.$strip>;
140
- declare const RuleSetSchema: z2.ZodObject<{
141
- id: z2.ZodString;
142
- name: z2.ZodString;
143
- description: z2.ZodOptional<z2.ZodString>;
144
- ruleIds: z2.ZodArray<z2.ZodString>;
145
- enabled: z2.ZodDefault<z2.ZodBoolean>;
146
- metadata: z2.ZodOptional<z2.ZodRecord<z2.ZodString, z2.ZodUnknown>>;
147
- }, z2.core.$strip>;
94
+ declare const RuleSchema: any;
95
+ declare const RuleSetSchema: any;
148
96
  type RuleSchemaType = z2.infer<typeof RuleSchema>;
149
97
  type RuleSetSchemaType = z2.infer<typeof RuleSetSchema>;
150
98
  type RuleComplexity = {
@@ -237,9 +185,9 @@ declare const findLeastUsedFields: <
237
185
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
238
186
  >(rules: ReadonlyArray<Rule<TContext, TConsequences>>, limit?: number) => ReadonlyArray<FieldUsage>;
239
187
  declare const formatRuleSetAnalysis: (analysis: RuleSetAnalysis) => string;
240
- import { Condition as Condition2, ConditionGroup as ConditionGroup2 } from "@f-o-t/condition-evaluator";
188
+ import { Condition, ConditionGroup as ConditionGroup2 } from "@f-o-t/condition-evaluator";
241
189
  type ConditionBuilderState = {
242
- readonly conditions: (Condition2 | ConditionGroup2)[];
190
+ readonly conditions: (Condition | ConditionGroup2)[];
243
191
  };
244
192
  type ConditionBuilder = {
245
193
  readonly number: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => ConditionBuilder;
@@ -250,21 +198,21 @@ type ConditionBuilder = {
250
198
  readonly ref: (field: string, operator: string, valueRef: string) => ConditionBuilder;
251
199
  readonly and: (builder: (cb: ConditionBuilder) => ConditionBuilder) => ConditionBuilder;
252
200
  readonly or: (builder: (cb: ConditionBuilder) => ConditionBuilder) => ConditionBuilder;
253
- readonly raw: (condition: Condition2 | ConditionGroup2) => ConditionBuilder;
201
+ readonly raw: (condition: Condition | ConditionGroup2) => ConditionBuilder;
254
202
  readonly build: () => ConditionGroup2;
255
- readonly getConditions: () => ReadonlyArray<Condition2 | ConditionGroup2>;
203
+ readonly getConditions: () => ReadonlyArray<Condition | ConditionGroup2>;
256
204
  };
257
205
  declare const resetBuilderIds: () => void;
258
206
  declare const conditions: () => ConditionBuilder;
259
207
  declare const and: (builderFn: (cb: ConditionBuilder) => ConditionBuilder) => ConditionGroup2;
260
208
  declare const or: (builderFn: (cb: ConditionBuilder) => ConditionBuilder) => ConditionGroup2;
261
- declare const all: (...items: (Condition2 | ConditionGroup2)[]) => ConditionGroup2;
262
- declare const any: (...items: (Condition2 | ConditionGroup2)[]) => ConditionGroup2;
263
- declare const num: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => Condition2;
264
- declare const str: (field: string, operator: "eq" | "neq" | "contains" | "not_contains" | "starts_with" | "ends_with" | "in" | "not_in" | "like" | "not_like" | "ilike" | "not_ilike" | "regex" | "not_regex", value: string | string[]) => Condition2;
265
- declare const bool: (field: string, operator: "eq" | "neq", value: boolean) => Condition2;
266
- declare const date: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between", value: string | Date | [string | Date, string | Date]) => Condition2;
267
- declare const arr: (field: string, operator: "contains" | "not_contains" | "contains_all" | "contains_any" | "is_empty" | "is_not_empty" | "length_eq" | "length_gt" | "length_lt", value?: unknown) => Condition2;
209
+ declare const all: (...items: (Condition | ConditionGroup2)[]) => ConditionGroup2;
210
+ declare const any: (...items: (Condition | ConditionGroup2)[]) => ConditionGroup2;
211
+ declare const num: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => Condition;
212
+ declare const str: (field: string, operator: "eq" | "neq" | "contains" | "not_contains" | "starts_with" | "ends_with" | "in" | "not_in" | "like" | "not_like" | "ilike" | "not_ilike" | "regex" | "not_regex", value: string | string[]) => Condition;
213
+ declare const bool: (field: string, operator: "eq" | "neq", value: boolean) => Condition;
214
+ declare const date: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between", value: string | Date | [string | Date, string | Date]) => Condition;
215
+ declare const arr: (field: string, operator: "contains" | "not_contains" | "contains_all" | "contains_any" | "is_empty" | "is_not_empty" | "length_eq" | "length_gt" | "length_lt", value?: unknown) => Condition;
268
216
  import { ConditionGroup as ConditionGroup3 } from "@f-o-t/condition-evaluator";
269
217
  import { z as z3 } from "zod";
270
218
  type RuleBuilderState<
@@ -314,37 +262,11 @@ declare const createRule: <
314
262
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
315
263
  >(builderFn: (rb: RuleBuilder<TContext, TConsequences>) => RuleBuilder<TContext, TConsequences>) => RuleInput<TContext, TConsequences>;
316
264
  import { z as z4 } from "zod";
317
- declare const RuleStatsSchema: z4.ZodObject<{
318
- evaluations: z4.ZodNumber;
319
- matches: z4.ZodNumber;
320
- errors: z4.ZodNumber;
321
- totalTimeMs: z4.ZodNumber;
322
- avgTimeMs: z4.ZodNumber;
323
- lastEvaluated: z4.ZodOptional<z4.ZodDate>;
324
- }, z4.core.$strip>;
265
+ declare const RuleStatsSchema: any;
325
266
  type RuleStats = z4.infer<typeof RuleStatsSchema>;
326
- declare const CacheStatsSchema: z4.ZodObject<{
327
- size: z4.ZodNumber;
328
- maxSize: z4.ZodNumber;
329
- hits: z4.ZodNumber;
330
- misses: z4.ZodNumber;
331
- hitRate: z4.ZodNumber;
332
- evictions: z4.ZodNumber;
333
- }, z4.core.$strip>;
267
+ declare const CacheStatsSchema: any;
334
268
  type CacheStats = z4.infer<typeof CacheStatsSchema>;
335
- declare const EngineStatsSchema: z4.ZodObject<{
336
- totalRules: z4.ZodNumber;
337
- enabledRules: z4.ZodNumber;
338
- disabledRules: z4.ZodNumber;
339
- totalRuleSets: z4.ZodNumber;
340
- totalEvaluations: z4.ZodNumber;
341
- totalMatches: z4.ZodNumber;
342
- totalErrors: z4.ZodNumber;
343
- avgEvaluationTimeMs: z4.ZodNumber;
344
- cacheHits: z4.ZodNumber;
345
- cacheMisses: z4.ZodNumber;
346
- cacheHitRate: z4.ZodNumber;
347
- }, z4.core.$strip>;
269
+ declare const EngineStatsSchema: any;
348
270
  type EngineStats = z4.infer<typeof EngineStatsSchema>;
349
271
  type EngineState<
350
272
  TContext = unknown,
@@ -406,39 +328,11 @@ declare const createCache: <T>(options: CacheOptions) => Cache<T>;
406
328
  declare const createNoopCache: <T>() => Cache<T>;
407
329
  import { GroupEvaluationResult } from "@f-o-t/condition-evaluator";
408
330
  import { z as z5 } from "zod";
409
- declare const ConflictResolutionStrategySchema: z5.ZodEnum<{
410
- priority: "priority";
411
- "first-match": "first-match";
412
- all: "all";
413
- "most-specific": "most-specific";
414
- }>;
331
+ declare const ConflictResolutionStrategySchema: any;
415
332
  type ConflictResolutionStrategy = z5.infer<typeof ConflictResolutionStrategySchema>;
416
- declare const EvaluateOptionsSchema: z5.ZodObject<{
417
- conflictResolution: z5.ZodOptional<z5.ZodEnum<{
418
- priority: "priority";
419
- "first-match": "first-match";
420
- all: "all";
421
- "most-specific": "most-specific";
422
- }>>;
423
- maxRules: z5.ZodOptional<z5.ZodNumber>;
424
- timeout: z5.ZodOptional<z5.ZodNumber>;
425
- skipDisabled: z5.ZodOptional<z5.ZodBoolean>;
426
- tags: z5.ZodOptional<z5.ZodArray<z5.ZodString>>;
427
- category: z5.ZodOptional<z5.ZodString>;
428
- ruleSetId: z5.ZodOptional<z5.ZodString>;
429
- bypassCache: z5.ZodOptional<z5.ZodBoolean>;
430
- }, z5.core.$strip>;
333
+ declare const EvaluateOptionsSchema: any;
431
334
  type EvaluateOptions = z5.infer<typeof EvaluateOptionsSchema>;
432
- declare const EvaluateConfigSchema: z5.ZodObject<{
433
- conflictResolution: z5.ZodEnum<{
434
- priority: "priority";
435
- "first-match": "first-match";
436
- all: "all";
437
- "most-specific": "most-specific";
438
- }>;
439
- continueOnError: z5.ZodBoolean;
440
- collectAllConsequences: z5.ZodBoolean;
441
- }, z5.core.$strip>;
335
+ declare const EvaluateConfigSchema: any;
442
336
  type EvaluateConfig = z5.infer<typeof EvaluateConfigSchema>;
443
337
  type EvaluationContext<TContext = unknown> = {
444
338
  readonly data: TContext;
@@ -578,29 +472,13 @@ declare const sortByUpdatedAt: <
578
472
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
579
473
  >(direction?: SortDirection) => (rules: readonly Rule<TContext, TConsequences>[]) => readonly Rule<TContext, TConsequences>[];
580
474
  import { z as z6 } from "zod";
581
- declare const LogLevelSchema: z6.ZodEnum<{
582
- error: "error";
583
- none: "none";
584
- warn: "warn";
585
- info: "info";
586
- debug: "debug";
587
- }>;
475
+ declare const LogLevelSchema: any;
588
476
  type LogLevel = z6.infer<typeof LogLevelSchema>;
589
- declare const CacheConfigSchema: z6.ZodObject<{
590
- enabled: z6.ZodDefault<z6.ZodBoolean>;
591
- ttl: z6.ZodDefault<z6.ZodNumber>;
592
- maxSize: z6.ZodDefault<z6.ZodNumber>;
593
- }, z6.core.$strip>;
477
+ declare const CacheConfigSchema: any;
594
478
  type CacheConfig = z6.infer<typeof CacheConfigSchema>;
595
- declare const ValidationConfigSchema: z6.ZodObject<{
596
- enabled: z6.ZodDefault<z6.ZodBoolean>;
597
- strict: z6.ZodDefault<z6.ZodBoolean>;
598
- }, z6.core.$strip>;
479
+ declare const ValidationConfigSchema: any;
599
480
  type ValidationConfig = z6.infer<typeof ValidationConfigSchema>;
600
- declare const VersioningConfigSchema: z6.ZodObject<{
601
- enabled: z6.ZodDefault<z6.ZodBoolean>;
602
- maxVersions: z6.ZodDefault<z6.ZodNumber>;
603
- }, z6.core.$strip>;
481
+ declare const VersioningConfigSchema: any;
604
482
  type VersioningConfig = z6.infer<typeof VersioningConfigSchema>;
605
483
  type Logger = {
606
484
  readonly error: (...args: unknown[]) => void;
@@ -1143,26 +1021,11 @@ declare const getUsedOperators: <
1143
1021
  declare const formatIntegrityResult: (result: IntegrityCheckResult) => string;
1144
1022
  import { ConditionGroup as ConditionGroup5 } from "@f-o-t/condition-evaluator";
1145
1023
  import { z as z7 } from "zod";
1146
- declare const ValidationErrorSchema: z7.ZodObject<{
1147
- path: z7.ZodString;
1148
- message: z7.ZodString;
1149
- code: z7.ZodString;
1150
- }, z7.core.$strip>;
1024
+ declare const ValidationErrorSchema: any;
1151
1025
  type ValidationError = z7.infer<typeof ValidationErrorSchema>;
1152
- declare const ValidationResultSchema: z7.ZodObject<{
1153
- valid: z7.ZodBoolean;
1154
- errors: z7.ZodArray<z7.ZodObject<{
1155
- path: z7.ZodString;
1156
- message: z7.ZodString;
1157
- code: z7.ZodString;
1158
- }, z7.core.$strip>>;
1159
- }, z7.core.$strip>;
1026
+ declare const ValidationResultSchema: any;
1160
1027
  type ValidationResult = z7.infer<typeof ValidationResultSchema>;
1161
- declare const ValidationOptionsSchema: z7.ZodObject<{
1162
- validateConditions: z7.ZodOptional<z7.ZodBoolean>;
1163
- validateConsequences: z7.ZodOptional<z7.ZodBoolean>;
1164
- strictMode: z7.ZodOptional<z7.ZodBoolean>;
1165
- }, z7.core.$strip>;
1028
+ declare const ValidationOptionsSchema: any;
1166
1029
  type ValidationOptions = z7.infer<typeof ValidationOptionsSchema>;
1167
1030
  type ResolvedValidationOptions = {
1168
1031
  validateConditions: boolean;
@@ -1205,14 +1068,7 @@ declare const createRuleValidator: <
1205
1068
  TContext = unknown,
1206
1069
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
1207
1070
  >(consequenceSchemas: TConsequences, defaultOptions?: ValidationOptions) => {
1208
- validate: (rule: unknown, options?: ValidationOptions) => {
1209
- valid: boolean;
1210
- errors: {
1211
- path: string;
1212
- message: string;
1213
- code: string;
1214
- }[];
1215
- };
1071
+ validate: (rule: unknown, options?: ValidationOptions) => z7.infer<any>;
1216
1072
  parse: (rule: unknown, options?: ValidationOptions) => Rule<TContext, TConsequences>;
1217
1073
  safeParse: (rule: unknown, options?: ValidationOptions) => {
1218
1074
  success: false;
@@ -1314,4 +1170,4 @@ declare const formatVersionHistory: <
1314
1170
  TContext = unknown,
1315
1171
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
1316
1172
  >(history: VersionHistory<TContext, TConsequences>) => string;
1317
- export { withTimeout, whatIf, validateRules, validateRuleSet, validateRule, validateConditions, updateRule2 as updateRule, str, sortRules, sortByUpdatedAt, sortByPriority, sortByName, sortByCreatedAt, simulateSingleRule, simulate, serializeRuleSet, serializeRule, safeParseRule, rule, rollbackToVersion, resetBuilderIds, removeRuleSet2 as removeRuleSet, removeRule2 as removeRule, pruneOldVersions, parseVersioningConfig, parseValidationConfig, parseRule, parseCacheConfig, or, num, mergeRuleSets, measureTimeAsync, measureTime, isConditionGroup, importRules, importFromJson, hashRules, hashContext, hasErrors, hasConflicts, groupRules, groupByPriority, groupByEnabled, groupByCustom, groupByCategory, getVersionsByDateRange, getVersionsByChangeType, getVersion, getUsedOperators, getUsedFields, getRulesInSet, getRulesByTags, getRulesByTag, getRulesByPriorityRange, getRulesByPriority, getRulesByFields, getRulesByField, getRulesByCategory, getRules2 as getRules, getRuleSets2 as getRuleSets, getRuleSet2 as getRuleSet, getRuleById, getRule2 as getRule, getLatestVersion, getIndexStats, getHistory, getDefaultVersioningConfig, getDefaultValidationConfig, getDefaultLogLevel, getDefaultConflictResolution, getDefaultCacheConfig, getConflictsByType, getConflictsBySeverity, getAllVersions, generateId, formatVersionHistory, formatSimulationResult, formatRuleSetAnalysis, formatIntegrityResult, formatConflicts, findRulesAffectedByContextChange, findMostComplexRules, findLeastUsedFields, filterRulesForContext, filterRules, filterByTags, filterByIds, filterByEnabled, filterByCategory, exportToJson, exportRules, evaluateRules, evaluateRule, enableRule2 as enableRule, disableRule2 as disableRule, diffRuleSets, detectConflicts, deserializeRuleSet, deserializeRule, date, createVersionStore, createRuleValidator, createRule, createNoopCache, createInitialState, createInitialRuleStats, createInitialOptimizerState, createEngine, createCache, conditions, compareVersions, cloneState, cloneRule, clearRules2 as clearRules, checkRuleFieldCoverage, checkIntegrity, buildIndex, bool, batchSimulate, arr, any, and, analyzeRuleSet, analyzeRuleComplexity, analyzeOptimizations, analyzeOperatorUsage, analyzeFieldUsage, analyzeConsequenceUsage, all, addVersion, addRules2 as addRules, addRuleSet2 as addRuleSet, addRule2 as addRule, WhatIfResult, VersioningConfigSchema, VersioningConfig, VersionStore, VersionHistory, ValidationResultSchema, ValidationResult, ValidationOptionsSchema, ValidationOptions, ValidationErrorSchema, ValidationError, ValidationConfigSchema, ValidationConfig, TimingResult, TagIndex, StringOperator, StringCondition, SortOptions, SortField, SortDirection, SimulationResult, SimulationContext, SerializedRuleSet, SerializedRule, RuleVersion, RuleStatsSchema, RuleStats, RuleSetSchemaType, RuleSetSchema, RuleSetInput, RuleSetAnalysis, RuleSet, RuleSchemaType, RuleSchema, RuleInput, RuleIndex, RuleFilters, RuleEvaluationResult, RuleComplexity, RuleBuilderState, RuleBuilder, Rule, ResolvedValidationOptions, ResolvedEngineConfig, PriorityIndex, OrphanedReference, OptimizerState, OptimizationSuggestion, OperatorUsage, NumberOperator, NumberCondition, LogicalOperator, Logger, LogLevelSchema, LogLevel, IntegrityIssue, IntegrityCheckResult, IntegrityCheckOptions, InferConsequenceType, InferConsequencePayload, IndexOptions, ImportResult, ImportOptions, GroupedRules, GroupEvaluationResultInput, GroupEvaluationResult2 as GroupEvaluationResult, GroupByField, FieldUsage, FieldIndex, ExportFormat, EvaluationResult, EvaluationContext, EvaluateRulesResult, EvaluateRulesOptions, EvaluateRuleOptions, EvaluateOptionsSchema, EvaluateOptions, EvaluateConfigSchema, EvaluateConfig, EngineStatsSchema, EngineStats, EngineState, EngineHooks, EngineExecutionResult, EngineConfig, Engine, DefaultConsequences, DateOperator, DateCondition, CustomCondition, ConsequenceUsage, ConsequenceInput, ConsequenceDefinitions, Consequence, ConflictType, ConflictResolutionStrategySchema, ConflictResolutionStrategy, ConflictDetectionOptions, Conflict, ConditionGroup7 as ConditionGroupSchema, ConditionGroupInput, ConditionGroup6 as ConditionGroup, ConditionBuilderState, ConditionBuilder, Condition3 as Condition, CategoryIndex, CacheStatsSchema, CacheStats, CacheOptions, CacheEntry, CacheConfigSchema, CacheConfig, Cache, BooleanOperator, BooleanCondition, BatchSimulationResult, ArrayOperator, ArrayCondition, AggregatedConsequence };
1173
+ export { withTimeout, whatIf, validateRules, validateRuleSet, validateRule, validateConditions, updateRule2 as updateRule, str, sortRules, sortByUpdatedAt, sortByPriority, sortByName, sortByCreatedAt, simulateSingleRule, simulate, serializeRuleSet, serializeRule, safeParseRule, rule, rollbackToVersion, resetBuilderIds, removeRuleSet2 as removeRuleSet, removeRule2 as removeRule, pruneOldVersions, parseVersioningConfig, parseValidationConfig, parseRule, parseCacheConfig, or, num, mergeRuleSets, measureTimeAsync, measureTime, isConditionGroup, importRules, importFromJson, hashRules, hashContext, hasErrors, hasConflicts, groupRules, groupByPriority, groupByEnabled, groupByCustom, groupByCategory, getVersionsByDateRange, getVersionsByChangeType, getVersion, getUsedOperators, getUsedFields, getRulesInSet, getRulesByTags, getRulesByTag, getRulesByPriorityRange, getRulesByPriority, getRulesByFields, getRulesByField, getRulesByCategory, getRules2 as getRules, getRuleSets2 as getRuleSets, getRuleSet2 as getRuleSet, getRuleById, getRule2 as getRule, getLatestVersion, getIndexStats, getHistory, getDefaultVersioningConfig, getDefaultValidationConfig, getDefaultLogLevel, getDefaultConflictResolution, getDefaultCacheConfig, getConflictsByType, getConflictsBySeverity, getAllVersions, generateId, formatVersionHistory, formatSimulationResult, formatRuleSetAnalysis, formatIntegrityResult, formatConflicts, findRulesAffectedByContextChange, findMostComplexRules, findLeastUsedFields, filterRulesForContext, filterRules, filterByTags, filterByIds, filterByEnabled, filterByCategory, exportToJson, exportRules, evaluateRules, evaluateRule, enableRule2 as enableRule, disableRule2 as disableRule, diffRuleSets, detectConflicts, deserializeRuleSet, deserializeRule, date, createVersionStore, createRuleValidator, createRule, createNoopCache, createInitialState, createInitialRuleStats, createInitialOptimizerState, createEngine, createCache, conditions, compareVersions, cloneState, cloneRule, clearRules2 as clearRules, checkRuleFieldCoverage, checkIntegrity, buildIndex, bool, batchSimulate, arr, any, and, analyzeRuleSet, analyzeRuleComplexity, analyzeOptimizations, analyzeOperatorUsage, analyzeFieldUsage, analyzeConsequenceUsage, all, addVersion, addRules2 as addRules, addRuleSet2 as addRuleSet, addRule2 as addRule, WhatIfResult, VersioningConfigSchema, VersioningConfig, VersionStore, VersionHistory, ValidationResultSchema, ValidationResult, ValidationOptionsSchema, ValidationOptions, ValidationErrorSchema, ValidationError, ValidationConfigSchema, ValidationConfig, TimingResult, TagIndex, StringOperator, StringCondition, SortOptions, SortField, SortDirection, SimulationResult, SimulationContext, SerializedRuleSet, SerializedRule, RuleVersion, RuleStatsSchema, RuleStats, RuleSetSchemaType, RuleSetSchema, RuleSetInput, RuleSetAnalysis, RuleSet, RuleSchemaType, RuleSchema, RuleInput, RuleIndex, RuleFilters, RuleEvaluationResult, RuleComplexity, RuleBuilderState, RuleBuilder, Rule, ResolvedValidationOptions, ResolvedEngineConfig, PriorityIndex, OrphanedReference, OptimizerState, OptimizationSuggestion, OperatorUsage, NumberOperator, NumberCondition, LogicalOperator, Logger, LogLevelSchema, LogLevel, IntegrityIssue, IntegrityCheckResult, IntegrityCheckOptions, InferConsequenceType, InferConsequencePayload, IndexOptions, ImportResult, ImportOptions, GroupedRules, GroupEvaluationResult2 as GroupEvaluationResult, GroupByField, FieldUsage, FieldIndex, ExportFormat, EvaluationResult, EvaluationContext, EvaluateRulesResult, EvaluateRulesOptions, EvaluateRuleOptions, EvaluateOptionsSchema, EvaluateOptions, EvaluateConfigSchema, EvaluateConfig, EngineStatsSchema, EngineStats, EngineState, EngineHooks, EngineExecutionResult, EngineConfig, Engine, DefaultConsequences, DateOperator, DateCondition, CustomCondition, ConsequenceUsage, ConsequenceInput, ConsequenceDefinitions, Consequence, ConflictType, ConflictResolutionStrategySchema, ConflictResolutionStrategy, ConflictDetectionOptions, Conflict, ConditionGroup7 as ConditionGroupSchema, ConditionGroup6 as ConditionGroup, ConditionBuilderState, ConditionBuilder, Condition2 as Condition, CategoryIndex, CacheStatsSchema, CacheStats, CacheOptions, CacheEntry, CacheConfigSchema, CacheConfig, Cache, BooleanOperator, BooleanCondition, BatchSimulationResult, ArrayOperator, ArrayCondition, AggregatedConsequence };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArrayCondition, ArrayOperator, BooleanCondition, BooleanOperator, Condition as Condition3, ConditionGroup as ConditionGroup6, ConditionGroupInput, CustomCondition, DateCondition, DateOperator, EvaluationResult, GroupEvaluationResult as GroupEvaluationResult2, GroupEvaluationResultInput, LogicalOperator, NumberCondition, NumberOperator, StringCondition, StringOperator } from "@f-o-t/condition-evaluator";
1
+ import { ArrayCondition, ArrayOperator, BooleanCondition, BooleanOperator, Condition as Condition2, ConditionGroup as ConditionGroup6, CustomCondition, DateCondition, DateOperator, EvaluationResult, GroupEvaluationResult as GroupEvaluationResult2, LogicalOperator, NumberCondition, NumberOperator, StringCondition, StringOperator } from "@f-o-t/condition-evaluator";
2
2
  import { ConditionGroup as ConditionGroup7, isConditionGroup } from "@f-o-t/condition-evaluator";
3
3
  import { z } from "zod";
4
4
  type ConsequenceDefinitions = Record<string, z.ZodType>;
@@ -91,60 +91,8 @@ type RuleFilters = {
91
91
  readonly ruleSetId?: string;
92
92
  readonly ids?: ReadonlyArray<string>;
93
93
  };
94
- declare const RuleSchema: z2.ZodObject<{
95
- id: z2.ZodString;
96
- name: z2.ZodString;
97
- description: z2.ZodOptional<z2.ZodString>;
98
- conditions: z2.ZodCustom<{
99
- id: string;
100
- operator: "AND" | "OR";
101
- scoringMode?: "binary" | "weighted" | undefined;
102
- threshold?: number | undefined;
103
- weight?: number | undefined;
104
- } & {
105
- conditions: (import("@f-o-t/condition-evaluator").Condition | ({
106
- id: string;
107
- operator: "AND" | "OR";
108
- scoringMode?: "binary" | "weighted" | undefined;
109
- threshold?: number | undefined;
110
- weight?: number | undefined;
111
- } & any))[];
112
- }, {
113
- id: string;
114
- operator: "AND" | "OR";
115
- scoringMode?: "binary" | "weighted" | undefined;
116
- threshold?: number | undefined;
117
- weight?: number | undefined;
118
- } & {
119
- conditions: (import("@f-o-t/condition-evaluator").Condition | ({
120
- id: string;
121
- operator: "AND" | "OR";
122
- scoringMode?: "binary" | "weighted" | undefined;
123
- threshold?: number | undefined;
124
- weight?: number | undefined;
125
- } & any))[];
126
- }>;
127
- consequences: z2.ZodArray<z2.ZodObject<{
128
- type: z2.ZodString;
129
- payload: z2.ZodUnknown;
130
- }, z2.core.$strip>>;
131
- priority: z2.ZodDefault<z2.ZodNumber>;
132
- enabled: z2.ZodDefault<z2.ZodBoolean>;
133
- stopOnMatch: z2.ZodDefault<z2.ZodBoolean>;
134
- tags: z2.ZodDefault<z2.ZodArray<z2.ZodString>>;
135
- category: z2.ZodOptional<z2.ZodString>;
136
- metadata: z2.ZodOptional<z2.ZodRecord<z2.ZodString, z2.ZodUnknown>>;
137
- createdAt: z2.ZodDefault<z2.ZodDate>;
138
- updatedAt: z2.ZodDefault<z2.ZodDate>;
139
- }, z2.core.$strip>;
140
- declare const RuleSetSchema: z2.ZodObject<{
141
- id: z2.ZodString;
142
- name: z2.ZodString;
143
- description: z2.ZodOptional<z2.ZodString>;
144
- ruleIds: z2.ZodArray<z2.ZodString>;
145
- enabled: z2.ZodDefault<z2.ZodBoolean>;
146
- metadata: z2.ZodOptional<z2.ZodRecord<z2.ZodString, z2.ZodUnknown>>;
147
- }, z2.core.$strip>;
94
+ declare const RuleSchema: any;
95
+ declare const RuleSetSchema: any;
148
96
  type RuleSchemaType = z2.infer<typeof RuleSchema>;
149
97
  type RuleSetSchemaType = z2.infer<typeof RuleSetSchema>;
150
98
  type RuleComplexity = {
@@ -237,9 +185,9 @@ declare const findLeastUsedFields: <
237
185
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
238
186
  >(rules: ReadonlyArray<Rule<TContext, TConsequences>>, limit?: number) => ReadonlyArray<FieldUsage>;
239
187
  declare const formatRuleSetAnalysis: (analysis: RuleSetAnalysis) => string;
240
- import { Condition as Condition2, ConditionGroup as ConditionGroup2 } from "@f-o-t/condition-evaluator";
188
+ import { Condition, ConditionGroup as ConditionGroup2 } from "@f-o-t/condition-evaluator";
241
189
  type ConditionBuilderState = {
242
- readonly conditions: (Condition2 | ConditionGroup2)[];
190
+ readonly conditions: (Condition | ConditionGroup2)[];
243
191
  };
244
192
  type ConditionBuilder = {
245
193
  readonly number: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => ConditionBuilder;
@@ -250,21 +198,21 @@ type ConditionBuilder = {
250
198
  readonly ref: (field: string, operator: string, valueRef: string) => ConditionBuilder;
251
199
  readonly and: (builder: (cb: ConditionBuilder) => ConditionBuilder) => ConditionBuilder;
252
200
  readonly or: (builder: (cb: ConditionBuilder) => ConditionBuilder) => ConditionBuilder;
253
- readonly raw: (condition: Condition2 | ConditionGroup2) => ConditionBuilder;
201
+ readonly raw: (condition: Condition | ConditionGroup2) => ConditionBuilder;
254
202
  readonly build: () => ConditionGroup2;
255
- readonly getConditions: () => ReadonlyArray<Condition2 | ConditionGroup2>;
203
+ readonly getConditions: () => ReadonlyArray<Condition | ConditionGroup2>;
256
204
  };
257
205
  declare const resetBuilderIds: () => void;
258
206
  declare const conditions: () => ConditionBuilder;
259
207
  declare const and: (builderFn: (cb: ConditionBuilder) => ConditionBuilder) => ConditionGroup2;
260
208
  declare const or: (builderFn: (cb: ConditionBuilder) => ConditionBuilder) => ConditionGroup2;
261
- declare const all: (...items: (Condition2 | ConditionGroup2)[]) => ConditionGroup2;
262
- declare const any: (...items: (Condition2 | ConditionGroup2)[]) => ConditionGroup2;
263
- declare const num: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => Condition2;
264
- declare const str: (field: string, operator: "eq" | "neq" | "contains" | "not_contains" | "starts_with" | "ends_with" | "in" | "not_in" | "like" | "not_like" | "ilike" | "not_ilike" | "regex" | "not_regex", value: string | string[]) => Condition2;
265
- declare const bool: (field: string, operator: "eq" | "neq", value: boolean) => Condition2;
266
- declare const date: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between", value: string | Date | [string | Date, string | Date]) => Condition2;
267
- declare const arr: (field: string, operator: "contains" | "not_contains" | "contains_all" | "contains_any" | "is_empty" | "is_not_empty" | "length_eq" | "length_gt" | "length_lt", value?: unknown) => Condition2;
209
+ declare const all: (...items: (Condition | ConditionGroup2)[]) => ConditionGroup2;
210
+ declare const any: (...items: (Condition | ConditionGroup2)[]) => ConditionGroup2;
211
+ declare const num: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq", value: number) => Condition;
212
+ declare const str: (field: string, operator: "eq" | "neq" | "contains" | "not_contains" | "starts_with" | "ends_with" | "in" | "not_in" | "like" | "not_like" | "ilike" | "not_ilike" | "regex" | "not_regex", value: string | string[]) => Condition;
213
+ declare const bool: (field: string, operator: "eq" | "neq", value: boolean) => Condition;
214
+ declare const date: (field: string, operator: "gt" | "gte" | "lt" | "lte" | "eq" | "neq" | "between", value: string | Date | [string | Date, string | Date]) => Condition;
215
+ declare const arr: (field: string, operator: "contains" | "not_contains" | "contains_all" | "contains_any" | "is_empty" | "is_not_empty" | "length_eq" | "length_gt" | "length_lt", value?: unknown) => Condition;
268
216
  import { ConditionGroup as ConditionGroup3 } from "@f-o-t/condition-evaluator";
269
217
  import { z as z3 } from "zod";
270
218
  type RuleBuilderState<
@@ -314,37 +262,11 @@ declare const createRule: <
314
262
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
315
263
  >(builderFn: (rb: RuleBuilder<TContext, TConsequences>) => RuleBuilder<TContext, TConsequences>) => RuleInput<TContext, TConsequences>;
316
264
  import { z as z4 } from "zod";
317
- declare const RuleStatsSchema: z4.ZodObject<{
318
- evaluations: z4.ZodNumber;
319
- matches: z4.ZodNumber;
320
- errors: z4.ZodNumber;
321
- totalTimeMs: z4.ZodNumber;
322
- avgTimeMs: z4.ZodNumber;
323
- lastEvaluated: z4.ZodOptional<z4.ZodDate>;
324
- }, z4.core.$strip>;
265
+ declare const RuleStatsSchema: any;
325
266
  type RuleStats = z4.infer<typeof RuleStatsSchema>;
326
- declare const CacheStatsSchema: z4.ZodObject<{
327
- size: z4.ZodNumber;
328
- maxSize: z4.ZodNumber;
329
- hits: z4.ZodNumber;
330
- misses: z4.ZodNumber;
331
- hitRate: z4.ZodNumber;
332
- evictions: z4.ZodNumber;
333
- }, z4.core.$strip>;
267
+ declare const CacheStatsSchema: any;
334
268
  type CacheStats = z4.infer<typeof CacheStatsSchema>;
335
- declare const EngineStatsSchema: z4.ZodObject<{
336
- totalRules: z4.ZodNumber;
337
- enabledRules: z4.ZodNumber;
338
- disabledRules: z4.ZodNumber;
339
- totalRuleSets: z4.ZodNumber;
340
- totalEvaluations: z4.ZodNumber;
341
- totalMatches: z4.ZodNumber;
342
- totalErrors: z4.ZodNumber;
343
- avgEvaluationTimeMs: z4.ZodNumber;
344
- cacheHits: z4.ZodNumber;
345
- cacheMisses: z4.ZodNumber;
346
- cacheHitRate: z4.ZodNumber;
347
- }, z4.core.$strip>;
269
+ declare const EngineStatsSchema: any;
348
270
  type EngineStats = z4.infer<typeof EngineStatsSchema>;
349
271
  type EngineState<
350
272
  TContext = unknown,
@@ -406,39 +328,11 @@ declare const createCache: <T>(options: CacheOptions) => Cache<T>;
406
328
  declare const createNoopCache: <T>() => Cache<T>;
407
329
  import { GroupEvaluationResult } from "@f-o-t/condition-evaluator";
408
330
  import { z as z5 } from "zod";
409
- declare const ConflictResolutionStrategySchema: z5.ZodEnum<{
410
- priority: "priority";
411
- "first-match": "first-match";
412
- all: "all";
413
- "most-specific": "most-specific";
414
- }>;
331
+ declare const ConflictResolutionStrategySchema: any;
415
332
  type ConflictResolutionStrategy = z5.infer<typeof ConflictResolutionStrategySchema>;
416
- declare const EvaluateOptionsSchema: z5.ZodObject<{
417
- conflictResolution: z5.ZodOptional<z5.ZodEnum<{
418
- priority: "priority";
419
- "first-match": "first-match";
420
- all: "all";
421
- "most-specific": "most-specific";
422
- }>>;
423
- maxRules: z5.ZodOptional<z5.ZodNumber>;
424
- timeout: z5.ZodOptional<z5.ZodNumber>;
425
- skipDisabled: z5.ZodOptional<z5.ZodBoolean>;
426
- tags: z5.ZodOptional<z5.ZodArray<z5.ZodString>>;
427
- category: z5.ZodOptional<z5.ZodString>;
428
- ruleSetId: z5.ZodOptional<z5.ZodString>;
429
- bypassCache: z5.ZodOptional<z5.ZodBoolean>;
430
- }, z5.core.$strip>;
333
+ declare const EvaluateOptionsSchema: any;
431
334
  type EvaluateOptions = z5.infer<typeof EvaluateOptionsSchema>;
432
- declare const EvaluateConfigSchema: z5.ZodObject<{
433
- conflictResolution: z5.ZodEnum<{
434
- priority: "priority";
435
- "first-match": "first-match";
436
- all: "all";
437
- "most-specific": "most-specific";
438
- }>;
439
- continueOnError: z5.ZodBoolean;
440
- collectAllConsequences: z5.ZodBoolean;
441
- }, z5.core.$strip>;
335
+ declare const EvaluateConfigSchema: any;
442
336
  type EvaluateConfig = z5.infer<typeof EvaluateConfigSchema>;
443
337
  type EvaluationContext<TContext = unknown> = {
444
338
  readonly data: TContext;
@@ -578,29 +472,13 @@ declare const sortByUpdatedAt: <
578
472
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
579
473
  >(direction?: SortDirection) => (rules: readonly Rule<TContext, TConsequences>[]) => readonly Rule<TContext, TConsequences>[];
580
474
  import { z as z6 } from "zod";
581
- declare const LogLevelSchema: z6.ZodEnum<{
582
- error: "error";
583
- none: "none";
584
- warn: "warn";
585
- info: "info";
586
- debug: "debug";
587
- }>;
475
+ declare const LogLevelSchema: any;
588
476
  type LogLevel = z6.infer<typeof LogLevelSchema>;
589
- declare const CacheConfigSchema: z6.ZodObject<{
590
- enabled: z6.ZodDefault<z6.ZodBoolean>;
591
- ttl: z6.ZodDefault<z6.ZodNumber>;
592
- maxSize: z6.ZodDefault<z6.ZodNumber>;
593
- }, z6.core.$strip>;
477
+ declare const CacheConfigSchema: any;
594
478
  type CacheConfig = z6.infer<typeof CacheConfigSchema>;
595
- declare const ValidationConfigSchema: z6.ZodObject<{
596
- enabled: z6.ZodDefault<z6.ZodBoolean>;
597
- strict: z6.ZodDefault<z6.ZodBoolean>;
598
- }, z6.core.$strip>;
479
+ declare const ValidationConfigSchema: any;
599
480
  type ValidationConfig = z6.infer<typeof ValidationConfigSchema>;
600
- declare const VersioningConfigSchema: z6.ZodObject<{
601
- enabled: z6.ZodDefault<z6.ZodBoolean>;
602
- maxVersions: z6.ZodDefault<z6.ZodNumber>;
603
- }, z6.core.$strip>;
481
+ declare const VersioningConfigSchema: any;
604
482
  type VersioningConfig = z6.infer<typeof VersioningConfigSchema>;
605
483
  type Logger = {
606
484
  readonly error: (...args: unknown[]) => void;
@@ -1143,26 +1021,11 @@ declare const getUsedOperators: <
1143
1021
  declare const formatIntegrityResult: (result: IntegrityCheckResult) => string;
1144
1022
  import { ConditionGroup as ConditionGroup5 } from "@f-o-t/condition-evaluator";
1145
1023
  import { z as z7 } from "zod";
1146
- declare const ValidationErrorSchema: z7.ZodObject<{
1147
- path: z7.ZodString;
1148
- message: z7.ZodString;
1149
- code: z7.ZodString;
1150
- }, z7.core.$strip>;
1024
+ declare const ValidationErrorSchema: any;
1151
1025
  type ValidationError = z7.infer<typeof ValidationErrorSchema>;
1152
- declare const ValidationResultSchema: z7.ZodObject<{
1153
- valid: z7.ZodBoolean;
1154
- errors: z7.ZodArray<z7.ZodObject<{
1155
- path: z7.ZodString;
1156
- message: z7.ZodString;
1157
- code: z7.ZodString;
1158
- }, z7.core.$strip>>;
1159
- }, z7.core.$strip>;
1026
+ declare const ValidationResultSchema: any;
1160
1027
  type ValidationResult = z7.infer<typeof ValidationResultSchema>;
1161
- declare const ValidationOptionsSchema: z7.ZodObject<{
1162
- validateConditions: z7.ZodOptional<z7.ZodBoolean>;
1163
- validateConsequences: z7.ZodOptional<z7.ZodBoolean>;
1164
- strictMode: z7.ZodOptional<z7.ZodBoolean>;
1165
- }, z7.core.$strip>;
1028
+ declare const ValidationOptionsSchema: any;
1166
1029
  type ValidationOptions = z7.infer<typeof ValidationOptionsSchema>;
1167
1030
  type ResolvedValidationOptions = {
1168
1031
  validateConditions: boolean;
@@ -1205,14 +1068,7 @@ declare const createRuleValidator: <
1205
1068
  TContext = unknown,
1206
1069
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
1207
1070
  >(consequenceSchemas: TConsequences, defaultOptions?: ValidationOptions) => {
1208
- validate: (rule: unknown, options?: ValidationOptions) => {
1209
- valid: boolean;
1210
- errors: {
1211
- path: string;
1212
- message: string;
1213
- code: string;
1214
- }[];
1215
- };
1071
+ validate: (rule: unknown, options?: ValidationOptions) => z7.infer<any>;
1216
1072
  parse: (rule: unknown, options?: ValidationOptions) => Rule<TContext, TConsequences>;
1217
1073
  safeParse: (rule: unknown, options?: ValidationOptions) => {
1218
1074
  success: false;
@@ -1314,4 +1170,4 @@ declare const formatVersionHistory: <
1314
1170
  TContext = unknown,
1315
1171
  TConsequences extends ConsequenceDefinitions = DefaultConsequences
1316
1172
  >(history: VersionHistory<TContext, TConsequences>) => string;
1317
- export { withTimeout, whatIf, validateRules, validateRuleSet, validateRule, validateConditions, updateRule2 as updateRule, str, sortRules, sortByUpdatedAt, sortByPriority, sortByName, sortByCreatedAt, simulateSingleRule, simulate, serializeRuleSet, serializeRule, safeParseRule, rule, rollbackToVersion, resetBuilderIds, removeRuleSet2 as removeRuleSet, removeRule2 as removeRule, pruneOldVersions, parseVersioningConfig, parseValidationConfig, parseRule, parseCacheConfig, or, num, mergeRuleSets, measureTimeAsync, measureTime, isConditionGroup, importRules, importFromJson, hashRules, hashContext, hasErrors, hasConflicts, groupRules, groupByPriority, groupByEnabled, groupByCustom, groupByCategory, getVersionsByDateRange, getVersionsByChangeType, getVersion, getUsedOperators, getUsedFields, getRulesInSet, getRulesByTags, getRulesByTag, getRulesByPriorityRange, getRulesByPriority, getRulesByFields, getRulesByField, getRulesByCategory, getRules2 as getRules, getRuleSets2 as getRuleSets, getRuleSet2 as getRuleSet, getRuleById, getRule2 as getRule, getLatestVersion, getIndexStats, getHistory, getDefaultVersioningConfig, getDefaultValidationConfig, getDefaultLogLevel, getDefaultConflictResolution, getDefaultCacheConfig, getConflictsByType, getConflictsBySeverity, getAllVersions, generateId, formatVersionHistory, formatSimulationResult, formatRuleSetAnalysis, formatIntegrityResult, formatConflicts, findRulesAffectedByContextChange, findMostComplexRules, findLeastUsedFields, filterRulesForContext, filterRules, filterByTags, filterByIds, filterByEnabled, filterByCategory, exportToJson, exportRules, evaluateRules, evaluateRule, enableRule2 as enableRule, disableRule2 as disableRule, diffRuleSets, detectConflicts, deserializeRuleSet, deserializeRule, date, createVersionStore, createRuleValidator, createRule, createNoopCache, createInitialState, createInitialRuleStats, createInitialOptimizerState, createEngine, createCache, conditions, compareVersions, cloneState, cloneRule, clearRules2 as clearRules, checkRuleFieldCoverage, checkIntegrity, buildIndex, bool, batchSimulate, arr, any, and, analyzeRuleSet, analyzeRuleComplexity, analyzeOptimizations, analyzeOperatorUsage, analyzeFieldUsage, analyzeConsequenceUsage, all, addVersion, addRules2 as addRules, addRuleSet2 as addRuleSet, addRule2 as addRule, WhatIfResult, VersioningConfigSchema, VersioningConfig, VersionStore, VersionHistory, ValidationResultSchema, ValidationResult, ValidationOptionsSchema, ValidationOptions, ValidationErrorSchema, ValidationError, ValidationConfigSchema, ValidationConfig, TimingResult, TagIndex, StringOperator, StringCondition, SortOptions, SortField, SortDirection, SimulationResult, SimulationContext, SerializedRuleSet, SerializedRule, RuleVersion, RuleStatsSchema, RuleStats, RuleSetSchemaType, RuleSetSchema, RuleSetInput, RuleSetAnalysis, RuleSet, RuleSchemaType, RuleSchema, RuleInput, RuleIndex, RuleFilters, RuleEvaluationResult, RuleComplexity, RuleBuilderState, RuleBuilder, Rule, ResolvedValidationOptions, ResolvedEngineConfig, PriorityIndex, OrphanedReference, OptimizerState, OptimizationSuggestion, OperatorUsage, NumberOperator, NumberCondition, LogicalOperator, Logger, LogLevelSchema, LogLevel, IntegrityIssue, IntegrityCheckResult, IntegrityCheckOptions, InferConsequenceType, InferConsequencePayload, IndexOptions, ImportResult, ImportOptions, GroupedRules, GroupEvaluationResultInput, GroupEvaluationResult2 as GroupEvaluationResult, GroupByField, FieldUsage, FieldIndex, ExportFormat, EvaluationResult, EvaluationContext, EvaluateRulesResult, EvaluateRulesOptions, EvaluateRuleOptions, EvaluateOptionsSchema, EvaluateOptions, EvaluateConfigSchema, EvaluateConfig, EngineStatsSchema, EngineStats, EngineState, EngineHooks, EngineExecutionResult, EngineConfig, Engine, DefaultConsequences, DateOperator, DateCondition, CustomCondition, ConsequenceUsage, ConsequenceInput, ConsequenceDefinitions, Consequence, ConflictType, ConflictResolutionStrategySchema, ConflictResolutionStrategy, ConflictDetectionOptions, Conflict, ConditionGroup7 as ConditionGroupSchema, ConditionGroupInput, ConditionGroup6 as ConditionGroup, ConditionBuilderState, ConditionBuilder, Condition3 as Condition, CategoryIndex, CacheStatsSchema, CacheStats, CacheOptions, CacheEntry, CacheConfigSchema, CacheConfig, Cache, BooleanOperator, BooleanCondition, BatchSimulationResult, ArrayOperator, ArrayCondition, AggregatedConsequence };
1173
+ export { withTimeout, whatIf, validateRules, validateRuleSet, validateRule, validateConditions, updateRule2 as updateRule, str, sortRules, sortByUpdatedAt, sortByPriority, sortByName, sortByCreatedAt, simulateSingleRule, simulate, serializeRuleSet, serializeRule, safeParseRule, rule, rollbackToVersion, resetBuilderIds, removeRuleSet2 as removeRuleSet, removeRule2 as removeRule, pruneOldVersions, parseVersioningConfig, parseValidationConfig, parseRule, parseCacheConfig, or, num, mergeRuleSets, measureTimeAsync, measureTime, isConditionGroup, importRules, importFromJson, hashRules, hashContext, hasErrors, hasConflicts, groupRules, groupByPriority, groupByEnabled, groupByCustom, groupByCategory, getVersionsByDateRange, getVersionsByChangeType, getVersion, getUsedOperators, getUsedFields, getRulesInSet, getRulesByTags, getRulesByTag, getRulesByPriorityRange, getRulesByPriority, getRulesByFields, getRulesByField, getRulesByCategory, getRules2 as getRules, getRuleSets2 as getRuleSets, getRuleSet2 as getRuleSet, getRuleById, getRule2 as getRule, getLatestVersion, getIndexStats, getHistory, getDefaultVersioningConfig, getDefaultValidationConfig, getDefaultLogLevel, getDefaultConflictResolution, getDefaultCacheConfig, getConflictsByType, getConflictsBySeverity, getAllVersions, generateId, formatVersionHistory, formatSimulationResult, formatRuleSetAnalysis, formatIntegrityResult, formatConflicts, findRulesAffectedByContextChange, findMostComplexRules, findLeastUsedFields, filterRulesForContext, filterRules, filterByTags, filterByIds, filterByEnabled, filterByCategory, exportToJson, exportRules, evaluateRules, evaluateRule, enableRule2 as enableRule, disableRule2 as disableRule, diffRuleSets, detectConflicts, deserializeRuleSet, deserializeRule, date, createVersionStore, createRuleValidator, createRule, createNoopCache, createInitialState, createInitialRuleStats, createInitialOptimizerState, createEngine, createCache, conditions, compareVersions, cloneState, cloneRule, clearRules2 as clearRules, checkRuleFieldCoverage, checkIntegrity, buildIndex, bool, batchSimulate, arr, any, and, analyzeRuleSet, analyzeRuleComplexity, analyzeOptimizations, analyzeOperatorUsage, analyzeFieldUsage, analyzeConsequenceUsage, all, addVersion, addRules2 as addRules, addRuleSet2 as addRuleSet, addRule2 as addRule, WhatIfResult, VersioningConfigSchema, VersioningConfig, VersionStore, VersionHistory, ValidationResultSchema, ValidationResult, ValidationOptionsSchema, ValidationOptions, ValidationErrorSchema, ValidationError, ValidationConfigSchema, ValidationConfig, TimingResult, TagIndex, StringOperator, StringCondition, SortOptions, SortField, SortDirection, SimulationResult, SimulationContext, SerializedRuleSet, SerializedRule, RuleVersion, RuleStatsSchema, RuleStats, RuleSetSchemaType, RuleSetSchema, RuleSetInput, RuleSetAnalysis, RuleSet, RuleSchemaType, RuleSchema, RuleInput, RuleIndex, RuleFilters, RuleEvaluationResult, RuleComplexity, RuleBuilderState, RuleBuilder, Rule, ResolvedValidationOptions, ResolvedEngineConfig, PriorityIndex, OrphanedReference, OptimizerState, OptimizationSuggestion, OperatorUsage, NumberOperator, NumberCondition, LogicalOperator, Logger, LogLevelSchema, LogLevel, IntegrityIssue, IntegrityCheckResult, IntegrityCheckOptions, InferConsequenceType, InferConsequencePayload, IndexOptions, ImportResult, ImportOptions, GroupedRules, GroupEvaluationResult2 as GroupEvaluationResult, GroupByField, FieldUsage, FieldIndex, ExportFormat, EvaluationResult, EvaluationContext, EvaluateRulesResult, EvaluateRulesOptions, EvaluateRuleOptions, EvaluateOptionsSchema, EvaluateOptions, EvaluateConfigSchema, EvaluateConfig, EngineStatsSchema, EngineStats, EngineState, EngineHooks, EngineExecutionResult, EngineConfig, Engine, DefaultConsequences, DateOperator, DateCondition, CustomCondition, ConsequenceUsage, ConsequenceInput, ConsequenceDefinitions, Consequence, ConflictType, ConflictResolutionStrategySchema, ConflictResolutionStrategy, ConflictDetectionOptions, Conflict, ConditionGroup7 as ConditionGroupSchema, ConditionGroup6 as ConditionGroup, ConditionBuilderState, ConditionBuilder, Condition2 as Condition, CategoryIndex, CacheStatsSchema, CacheStats, CacheOptions, CacheEntry, CacheConfigSchema, CacheConfig, Cache, BooleanOperator, BooleanCondition, BatchSimulationResult, ArrayOperator, ArrayCondition, AggregatedConsequence };
package/dist/index.js CHANGED
@@ -993,57 +993,57 @@ var executeWithTimeout = async (hookName, hookFn, hooks, timeoutMs) => {
993
993
  var executeBeforeEvaluation = async (hooks, context, rules, timeoutMs) => {
994
994
  if (!hooks.beforeEvaluation)
995
995
  return;
996
- await executeWithTimeout("beforeEvaluation", () => hooks.beforeEvaluation(context, rules), hooks, timeoutMs);
996
+ await executeWithTimeout("beforeEvaluation", () => hooks.beforeEvaluation?.(context, rules), hooks, timeoutMs);
997
997
  };
998
998
  var executeAfterEvaluation = async (hooks, result, timeoutMs) => {
999
999
  if (!hooks.afterEvaluation)
1000
1000
  return;
1001
- await executeWithTimeout("afterEvaluation", () => hooks.afterEvaluation(result), hooks, timeoutMs);
1001
+ await executeWithTimeout("afterEvaluation", () => hooks.afterEvaluation?.(result), hooks, timeoutMs);
1002
1002
  };
1003
1003
  var executeBeforeRuleEvaluation = async (hooks, rule2, context, timeoutMs) => {
1004
1004
  if (!hooks.beforeRuleEvaluation)
1005
1005
  return;
1006
- await executeWithTimeout("beforeRuleEvaluation", () => hooks.beforeRuleEvaluation(rule2, context), hooks, timeoutMs);
1006
+ await executeWithTimeout("beforeRuleEvaluation", () => hooks.beforeRuleEvaluation?.(rule2, context), hooks, timeoutMs);
1007
1007
  };
1008
1008
  var executeAfterRuleEvaluation = async (hooks, rule2, result, timeoutMs) => {
1009
1009
  if (!hooks.afterRuleEvaluation)
1010
1010
  return;
1011
- await executeWithTimeout("afterRuleEvaluation", () => hooks.afterRuleEvaluation(rule2, result), hooks, timeoutMs);
1011
+ await executeWithTimeout("afterRuleEvaluation", () => hooks.afterRuleEvaluation?.(rule2, result), hooks, timeoutMs);
1012
1012
  };
1013
1013
  var executeOnRuleMatch = async (hooks, rule2, context, timeoutMs) => {
1014
1014
  if (!hooks.onRuleMatch)
1015
1015
  return;
1016
- await executeWithTimeout("onRuleMatch", () => hooks.onRuleMatch(rule2, context), hooks, timeoutMs);
1016
+ await executeWithTimeout("onRuleMatch", () => hooks.onRuleMatch?.(rule2, context), hooks, timeoutMs);
1017
1017
  };
1018
1018
  var executeOnRuleSkip = async (hooks, rule2, reason, timeoutMs) => {
1019
1019
  if (!hooks.onRuleSkip)
1020
1020
  return;
1021
- await executeWithTimeout("onRuleSkip", () => hooks.onRuleSkip(rule2, reason), hooks, timeoutMs);
1021
+ await executeWithTimeout("onRuleSkip", () => hooks.onRuleSkip?.(rule2, reason), hooks, timeoutMs);
1022
1022
  };
1023
1023
  var executeOnRuleError = async (hooks, rule2, ruleError, timeoutMs) => {
1024
1024
  if (!hooks.onRuleError)
1025
1025
  return;
1026
- await executeWithTimeout("onRuleError", () => hooks.onRuleError(rule2, ruleError), hooks, timeoutMs);
1026
+ await executeWithTimeout("onRuleError", () => hooks.onRuleError?.(rule2, ruleError), hooks, timeoutMs);
1027
1027
  };
1028
1028
  var executeOnConsequenceCollected = async (hooks, rule2, consequence, timeoutMs) => {
1029
1029
  if (!hooks.onConsequenceCollected)
1030
1030
  return;
1031
- await executeWithTimeout("onConsequenceCollected", () => hooks.onConsequenceCollected(rule2, consequence), hooks, timeoutMs);
1031
+ await executeWithTimeout("onConsequenceCollected", () => hooks.onConsequenceCollected?.(rule2, consequence), hooks, timeoutMs);
1032
1032
  };
1033
1033
  var executeOnCacheHit = async (hooks, key, result, timeoutMs) => {
1034
1034
  if (!hooks.onCacheHit)
1035
1035
  return;
1036
- await executeWithTimeout("onCacheHit", () => hooks.onCacheHit(key, result), hooks, timeoutMs);
1036
+ await executeWithTimeout("onCacheHit", () => hooks.onCacheHit?.(key, result), hooks, timeoutMs);
1037
1037
  };
1038
1038
  var executeOnCacheMiss = async (hooks, key, timeoutMs) => {
1039
1039
  if (!hooks.onCacheMiss)
1040
1040
  return;
1041
- await executeWithTimeout("onCacheMiss", () => hooks.onCacheMiss(key), hooks, timeoutMs);
1041
+ await executeWithTimeout("onCacheMiss", () => hooks.onCacheMiss?.(key), hooks, timeoutMs);
1042
1042
  };
1043
1043
  var executeOnSlowRule = async (hooks, rule2, timeMs, threshold, timeoutMs) => {
1044
1044
  if (!hooks.onSlowRule)
1045
1045
  return;
1046
- await executeWithTimeout("onSlowRule", () => hooks.onSlowRule(rule2, timeMs, threshold), hooks, timeoutMs);
1046
+ await executeWithTimeout("onSlowRule", () => hooks.onSlowRule?.(rule2, timeMs, threshold), hooks, timeoutMs);
1047
1047
  };
1048
1048
 
1049
1049
  // src/engine/state.ts
@@ -1417,7 +1417,6 @@ var createEngine = (config = {}) => {
1417
1417
  }),
1418
1418
  getStats: () => {
1419
1419
  const enabledRules = Array.from(state.rules.values()).filter((r) => r.enabled).length;
1420
- const _cacheStats = cache.getStats();
1421
1420
  return {
1422
1421
  totalRules: state.rules.size,
1423
1422
  enabledRules,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Type-safe, functional rules orchestration engine for TypeScript",
6
6
  "dependencies": {
7
7
  "@f-o-t/condition-evaluator": "2.0.0",
8
- "zod": "4.2.1"
8
+ "zod": "4.3.4"
9
9
  },
10
10
  "devDependencies": {
11
11
  "@biomejs/biome": "2.3.10",
@@ -65,5 +65,5 @@
65
65
  },
66
66
  "type": "module",
67
67
  "types": "./dist/index.d.ts",
68
- "version": "2.0.0"
68
+ "version": "2.0.2"
69
69
  }