trigger_system 1.2.1 → 1.2.5
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/browser/index.browser.js +183 -40
- package/dist/browser/index.browser.js.map +116 -17
- package/dist/core/action-registry.d.ts +29 -3
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/base-engine.d.ts +3 -3
- package/dist/core/constants.d.ts +95 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/dependency-graph/analyzer.d.ts +60 -0
- package/dist/core/dependency-graph/analyzer.d.ts.map +1 -0
- package/dist/core/dependency-graph/builder.d.ts +28 -0
- package/dist/core/dependency-graph/builder.d.ts.map +1 -0
- package/dist/core/dependency-graph/cycles.d.ts +28 -0
- package/dist/core/dependency-graph/cycles.d.ts.map +1 -0
- package/dist/core/dependency-graph/index.d.ts +11 -0
- package/dist/core/dependency-graph/index.d.ts.map +1 -0
- package/dist/core/dependency-graph/types.d.ts +72 -0
- package/dist/core/dependency-graph/types.d.ts.map +1 -0
- package/dist/core/dependency-graph/utils.d.ts +39 -0
- package/dist/core/dependency-graph/utils.d.ts.map +1 -0
- package/dist/core/dependency-graph/validator.d.ts +28 -0
- package/dist/core/dependency-graph/validator.d.ts.map +1 -0
- package/dist/core/dependency-graph.d.ts +64 -13
- package/dist/core/dependency-graph.d.ts.map +1 -1
- package/dist/core/engine-utils.d.ts +45 -0
- package/dist/core/engine-utils.d.ts.map +1 -0
- package/dist/core/engine.d.ts +0 -8
- package/dist/core/engine.d.ts.map +1 -1
- package/dist/core/expression-engine.d.ts +52 -10
- package/dist/core/expression-engine.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/operators.d.ts +48 -0
- package/dist/core/operators.d.ts.map +1 -0
- package/dist/core/persistence-browser.d.ts +25 -2
- package/dist/core/persistence-browser.d.ts.map +1 -1
- package/dist/core/persistence.node.d.ts +25 -2
- package/dist/core/persistence.node.d.ts.map +1 -1
- package/dist/core/rule-engine-new.d.ts +2 -1
- package/dist/core/rule-engine-new.d.ts.map +1 -1
- package/dist/core/rule-engine.d.ts +22 -35
- package/dist/core/rule-engine.d.ts.map +1 -1
- package/dist/core/trigger-engine.d.ts +18 -25
- package/dist/core/trigger-engine.d.ts.map +1 -1
- package/dist/domain/validator.d.ts +36043 -5067
- package/dist/domain/validator.d.ts.map +1 -1
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/io/index.d.ts +6 -1
- package/dist/io/index.d.ts.map +1 -1
- package/dist/io/loader/index.d.ts +48 -0
- package/dist/io/loader/index.d.ts.map +1 -0
- package/dist/io/loader/persistence.d.ts +41 -0
- package/dist/io/loader/persistence.d.ts.map +1 -0
- package/dist/io/loader/query.d.ts +49 -0
- package/dist/io/loader/query.d.ts.map +1 -0
- package/dist/io/loader/registry.d.ts +91 -0
- package/dist/io/loader/registry.d.ts.map +1 -0
- package/dist/io/loader/types.d.ts +32 -0
- package/dist/io/loader/types.d.ts.map +1 -0
- package/dist/io/loader/watch.d.ts +36 -0
- package/dist/io/loader/watch.d.ts.map +1 -0
- package/dist/io/loader.node.d.ts +1 -13
- package/dist/io/loader.node.d.ts.map +1 -1
- package/dist/lsp/hover-constants.d.ts +42 -0
- package/dist/lsp/hover-constants.d.ts.map +1 -0
- package/dist/lsp/server.bundle.d.ts +2 -0
- package/dist/lsp/server.bundle.d.ts.map +1 -0
- package/dist/node/index.js +183 -170
- package/dist/node/index.js.map +116 -91
- package/dist/node/node.js +185 -173
- package/dist/node/node.js.map +122 -93
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/sdk/builder.d.ts +177 -21
- package/dist/sdk/builder.d.ts.map +1 -1
- package/dist/sdk/builders/action-builder.d.ts +24 -0
- package/dist/sdk/builders/action-builder.d.ts.map +1 -0
- package/dist/sdk/builders/condition-builder.d.ts +26 -0
- package/dist/sdk/builders/condition-builder.d.ts.map +1 -0
- package/dist/sdk/builders/index.d.ts +5 -0
- package/dist/sdk/builders/index.d.ts.map +1 -0
- package/dist/sdk/builders/params-builder.d.ts +59 -0
- package/dist/sdk/builders/params-builder.d.ts.map +1 -0
- package/dist/sdk/constants.d.ts +44 -0
- package/dist/sdk/constants.d.ts.map +1 -0
- package/dist/sdk/exporter.d.ts +16 -0
- package/dist/sdk/exporter.d.ts.map +1 -1
- package/dist/sdk/graph/action-resolver.d.ts +103 -0
- package/dist/sdk/graph/action-resolver.d.ts.map +1 -0
- package/dist/sdk/graph/condition-resolver.d.ts +87 -0
- package/dist/sdk/graph/condition-resolver.d.ts.map +1 -0
- package/dist/sdk/graph/converters.d.ts +152 -0
- package/dist/sdk/graph/converters.d.ts.map +1 -0
- package/dist/sdk/graph/index.d.ts +12 -0
- package/dist/sdk/graph/index.d.ts.map +1 -0
- package/dist/sdk/graph/node-filters.d.ts +96 -0
- package/dist/sdk/graph/node-filters.d.ts.map +1 -0
- package/dist/sdk/graph/traversal.d.ts +105 -0
- package/dist/sdk/graph/traversal.d.ts.map +1 -0
- package/dist/sdk/graph/types.d.ts +28 -0
- package/dist/sdk/graph/types.d.ts.map +1 -0
- package/dist/sdk/graph-parser.d.ts +40 -0
- package/dist/sdk/graph-parser.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/optimize.d.ts +27 -0
- package/dist/sdk/optimize.d.ts.map +1 -0
- package/dist/sdk/yaml/converter.d.ts +81 -0
- package/dist/sdk/yaml/converter.d.ts.map +1 -0
- package/dist/sdk/yaml/index.d.ts +39 -0
- package/dist/sdk/yaml/index.d.ts.map +1 -0
- package/dist/sdk/yaml/normalizer.d.ts +44 -0
- package/dist/sdk/yaml/normalizer.d.ts.map +1 -0
- package/dist/sdk/yaml/types.d.ts +198 -0
- package/dist/sdk/yaml/types.d.ts.map +1 -0
- package/dist/sdk/yaml/utils.d.ts +131 -0
- package/dist/sdk/yaml/utils.d.ts.map +1 -0
- package/dist/sdk/yaml-parser.d.ts +18 -0
- package/dist/sdk/yaml-parser.d.ts.map +1 -0
- package/dist/types.d.ts +40 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -1
|
@@ -1,12 +1,38 @@
|
|
|
1
|
+
import { type Type } from "arktype";
|
|
1
2
|
import type { TriggerAction, TriggerContext } from "../types";
|
|
2
3
|
export type ActionHandler = (action: TriggerAction, context: TriggerContext) => Promise<any> | any;
|
|
4
|
+
/**
|
|
5
|
+
* Built-in action types to avoid magic strings
|
|
6
|
+
*/
|
|
7
|
+
export declare const BuiltInAction: {
|
|
8
|
+
readonly LOG: "LOG";
|
|
9
|
+
readonly MATH: "MATH";
|
|
10
|
+
readonly RESPONSE: "RESPONSE";
|
|
11
|
+
readonly EXECUTE: "EXECUTE";
|
|
12
|
+
readonly FORWARD: "FORWARD";
|
|
13
|
+
readonly STATE_SET: "STATE_SET";
|
|
14
|
+
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
15
|
+
readonly STATE_GET: "STATE_GET";
|
|
16
|
+
readonly STATE_DELETE: "STATE_DELETE";
|
|
17
|
+
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
18
|
+
readonly NOTIFY: "NOTIFY";
|
|
19
|
+
readonly STATE_OP: "STATE_OP";
|
|
20
|
+
};
|
|
21
|
+
export interface ActionDefinition {
|
|
22
|
+
handler: ActionHandler;
|
|
23
|
+
description?: string;
|
|
24
|
+
params?: Type;
|
|
25
|
+
returns?: Type;
|
|
26
|
+
}
|
|
3
27
|
export declare class ActionRegistry {
|
|
4
28
|
private static instance;
|
|
5
|
-
private
|
|
29
|
+
private actions;
|
|
6
30
|
private constructor();
|
|
7
|
-
static getInstance(): ActionRegistry;
|
|
8
|
-
register(type: string,
|
|
31
|
+
static getInstance(autoRegisterDefaults?: boolean): ActionRegistry;
|
|
32
|
+
register(type: string, handlerOrDef: ActionHandler | ActionDefinition): void;
|
|
9
33
|
get(type: string): ActionHandler | undefined;
|
|
34
|
+
getDefinition(type: string): ActionDefinition | undefined;
|
|
35
|
+
getDefinitions(): Record<string, ActionDefinition>;
|
|
10
36
|
get Handlers(): Map<string, ActionHandler>;
|
|
11
37
|
private registerDefaults;
|
|
12
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-registry.d.ts","sourceRoot":"","sources":["../../src/core/action-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI9D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEnG,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"action-registry.d.ts","sourceRoot":"","sources":["../../src/core/action-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI9D,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEnG;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;CAahB,CAAC;AAEX,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO,CAAC,OAAO,CAAuC;IAEtD,OAAO;IAMP,MAAM,CAAC,WAAW,CAAC,oBAAoB,GAAE,OAAc,GAAG,cAAc;IAOxE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,GAAG,gBAAgB;IASrE,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI5C,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAIzD,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAQlD,IAAI,QAAQ,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAMzC;IAED,OAAO,CAAC,gBAAgB;CAkQzB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Base Engine Interface -
|
|
3
|
-
* Platform-agnostic
|
|
2
|
+
* Base Engine Interface - Defines the common interface for all engines
|
|
3
|
+
* Platform-agnostic and extensible
|
|
4
4
|
*/
|
|
5
5
|
import type { TriggerRule, TriggerContext, TriggerResult, RuleEngineConfig, ActionParams } from "../types";
|
|
6
6
|
export type EngineActionHandler = (params: ActionParams, context: TriggerContext) => Promise<unknown> | unknown;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Base interface that all engines must implement
|
|
9
9
|
*/
|
|
10
10
|
export interface ITriggerEngine {
|
|
11
11
|
readonly rules: TriggerRule[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { EngineEvent, RuleEvent } from "../utils/emitter";
|
|
2
|
+
/**
|
|
3
|
+
* Global constants for the Trigger System to avoid magic strings.
|
|
4
|
+
*/
|
|
5
|
+
export declare const Actions: {
|
|
6
|
+
readonly LOG: "LOG";
|
|
7
|
+
readonly MATH: "MATH";
|
|
8
|
+
readonly RESPONSE: "RESPONSE";
|
|
9
|
+
readonly EXECUTE: "EXECUTE";
|
|
10
|
+
readonly FORWARD: "FORWARD";
|
|
11
|
+
readonly STATE_SET: "STATE_SET";
|
|
12
|
+
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
13
|
+
readonly STATE_GET: "STATE_GET";
|
|
14
|
+
readonly STATE_DELETE: "STATE_DELETE";
|
|
15
|
+
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
16
|
+
readonly NOTIFY: "NOTIFY";
|
|
17
|
+
readonly STATE_OP: "STATE_OP";
|
|
18
|
+
};
|
|
19
|
+
export declare const Events: typeof EngineEvent;
|
|
20
|
+
export declare const RuleEvents: typeof RuleEvent;
|
|
21
|
+
/**
|
|
22
|
+
* Control flow property names
|
|
23
|
+
*/
|
|
24
|
+
export declare const ControlFlow: {
|
|
25
|
+
readonly IF: "if";
|
|
26
|
+
readonly THEN: "then";
|
|
27
|
+
readonly ELSE: "else";
|
|
28
|
+
readonly BREAK: "break";
|
|
29
|
+
readonly CONTINUE: "continue";
|
|
30
|
+
readonly MODE: "mode";
|
|
31
|
+
readonly ACTIONS: "actions";
|
|
32
|
+
readonly RUN: "run";
|
|
33
|
+
readonly DELAY: "delay";
|
|
34
|
+
readonly PROBABILITY: "probability";
|
|
35
|
+
readonly PARAMS: "params";
|
|
36
|
+
readonly TYPE: "type";
|
|
37
|
+
readonly ON: "on";
|
|
38
|
+
};
|
|
39
|
+
export declare const ErrorMessages: {
|
|
40
|
+
readonly UNKNOWN_ACTION: "Unknown or generic action type";
|
|
41
|
+
readonly MISSING_ACTION_TYPE: "Action has no type and no control flow properties";
|
|
42
|
+
readonly PROBABILITY_FAILED: "probability check failed";
|
|
43
|
+
readonly BUN_REQUIRED: "Bun is required for 'execute' action";
|
|
44
|
+
readonly MISSING_KEY: "Missing key for state operation";
|
|
45
|
+
};
|
|
46
|
+
export declare const DebugMessages: {
|
|
47
|
+
readonly RULE_ENGINE_EVALUATING: (count: number, event: string) => string;
|
|
48
|
+
readonly TRIGGER_ENGINE_EVALUATING: (count: number, event: string) => string;
|
|
49
|
+
};
|
|
50
|
+
export declare const TriggerSystem: {
|
|
51
|
+
Actions: {
|
|
52
|
+
readonly LOG: "LOG";
|
|
53
|
+
readonly MATH: "MATH";
|
|
54
|
+
readonly RESPONSE: "RESPONSE";
|
|
55
|
+
readonly EXECUTE: "EXECUTE";
|
|
56
|
+
readonly FORWARD: "FORWARD";
|
|
57
|
+
readonly STATE_SET: "STATE_SET";
|
|
58
|
+
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
59
|
+
readonly STATE_GET: "STATE_GET";
|
|
60
|
+
readonly STATE_DELETE: "STATE_DELETE";
|
|
61
|
+
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
62
|
+
readonly NOTIFY: "NOTIFY";
|
|
63
|
+
readonly STATE_OP: "STATE_OP";
|
|
64
|
+
};
|
|
65
|
+
Events: typeof EngineEvent;
|
|
66
|
+
RuleEvents: typeof RuleEvent;
|
|
67
|
+
ControlFlow: {
|
|
68
|
+
readonly IF: "if";
|
|
69
|
+
readonly THEN: "then";
|
|
70
|
+
readonly ELSE: "else";
|
|
71
|
+
readonly BREAK: "break";
|
|
72
|
+
readonly CONTINUE: "continue";
|
|
73
|
+
readonly MODE: "mode";
|
|
74
|
+
readonly ACTIONS: "actions";
|
|
75
|
+
readonly RUN: "run";
|
|
76
|
+
readonly DELAY: "delay";
|
|
77
|
+
readonly PROBABILITY: "probability";
|
|
78
|
+
readonly PARAMS: "params";
|
|
79
|
+
readonly TYPE: "type";
|
|
80
|
+
readonly ON: "on";
|
|
81
|
+
};
|
|
82
|
+
ErrorMessages: {
|
|
83
|
+
readonly UNKNOWN_ACTION: "Unknown or generic action type";
|
|
84
|
+
readonly MISSING_ACTION_TYPE: "Action has no type and no control flow properties";
|
|
85
|
+
readonly PROBABILITY_FAILED: "probability check failed";
|
|
86
|
+
readonly BUN_REQUIRED: "Bun is required for 'execute' action";
|
|
87
|
+
readonly MISSING_KEY: "Missing key for state operation";
|
|
88
|
+
};
|
|
89
|
+
DebugMessages: {
|
|
90
|
+
readonly RULE_ENGINE_EVALUATING: (count: number, event: string) => string;
|
|
91
|
+
readonly TRIGGER_ENGINE_EVALUATING: (count: number, event: string) => string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export default TriggerSystem;
|
|
95
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAAgB,CAAC;AACrC,eAAO,MAAM,MAAM,oBAAc,CAAC;AAClC,eAAO,MAAM,UAAU,kBAAY,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;CAcd,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX,eAAO,MAAM,aAAa;6CACU,MAAM,SAAS,MAAM;gDAClB,MAAM,SAAS,MAAM;CAClD,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iDAJU,MAAM,SAAS,MAAM;oDAClB,MAAM,SAAS,MAAM;;CAU3D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DependencyAnalyzer
|
|
3
|
+
* Analyzes static rules to detect circular dependencies (infinite loops)
|
|
4
|
+
* and provides detailed JSON export with full rule information.
|
|
5
|
+
*
|
|
6
|
+
* This class provides backwards compatibility while delegating to modular functions.
|
|
7
|
+
*
|
|
8
|
+
* Graph:
|
|
9
|
+
* - Nodes: Rules
|
|
10
|
+
* - Edges: Rule A -> Rule B (if A emits an event that B listens for)
|
|
11
|
+
*/
|
|
12
|
+
import type { TriggerRule } from "../../types";
|
|
13
|
+
import type { DependencyGraph, DependencyAnalysisResult, RuleDependencies, ValidationResult } from "./types";
|
|
14
|
+
/**
|
|
15
|
+
* DependencyAnalyzer - Main class for dependency analysis
|
|
16
|
+
* Provides backwards compatibility for existing code
|
|
17
|
+
*/
|
|
18
|
+
export declare class DependencyAnalyzer {
|
|
19
|
+
/**
|
|
20
|
+
* Build complete dependency graph with full rule information
|
|
21
|
+
* @returns JSON-serializable DependencyGraph object
|
|
22
|
+
*/
|
|
23
|
+
static buildGraph(rules: TriggerRule[]): DependencyGraph;
|
|
24
|
+
/**
|
|
25
|
+
* Detects cycles in a list of rules (legacy method for compatibility)
|
|
26
|
+
* @returns Array of cycles, where each cycle is an array of Rule IDs.
|
|
27
|
+
*/
|
|
28
|
+
static detectCycles(rules: TriggerRule[]): string[][];
|
|
29
|
+
/**
|
|
30
|
+
* Complete dependency analysis with JSON export
|
|
31
|
+
* @returns DependencyAnalysisResult with full information
|
|
32
|
+
*/
|
|
33
|
+
static analyze(rules: TriggerRule[]): DependencyAnalysisResult;
|
|
34
|
+
/**
|
|
35
|
+
* Export dependency graph as JSON string
|
|
36
|
+
*/
|
|
37
|
+
static toJSON(rules: TriggerRule[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Export dependency graph as compact JSON string
|
|
40
|
+
*/
|
|
41
|
+
static toJSONCompact(rules: TriggerRule[]): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get dependency info for a specific rule
|
|
44
|
+
*/
|
|
45
|
+
static getRuleDependencies(rules: TriggerRule[], ruleId: string): RuleDependencies | null;
|
|
46
|
+
/**
|
|
47
|
+
* Get all rules that listen to a specific event
|
|
48
|
+
*/
|
|
49
|
+
static getRulesListeningToEvent(rules: TriggerRule[], event: string): TriggerRule[];
|
|
50
|
+
/**
|
|
51
|
+
* Get all rules that emit a specific event
|
|
52
|
+
*/
|
|
53
|
+
static getRulesEmittingEvent(rules: TriggerRule[], event: string): TriggerRule[];
|
|
54
|
+
/**
|
|
55
|
+
* Validate rules and return validation result
|
|
56
|
+
*/
|
|
57
|
+
static validate(rules: TriggerRule[]): ValidationResult;
|
|
58
|
+
private static getEmittedEvents;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA6BjB;;;GAGG;AACH,qBAAa,kBAAkB;IAE7B;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,eAAe;IAIxD;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,EAAE;IAIrD;;;OAGG;IACH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,wBAAwB;IAI9D;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM;IAK3C;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM;IAKlD;;OAEG;IACH,MAAM,CAAC,mBAAmB,CACxB,KAAK,EAAE,WAAW,EAAE,EACpB,MAAM,EAAE,MAAM,GACb,gBAAgB,GAAG,IAAI;IAmB1B;;OAEG;IACH,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE;IAInF;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE;IAIhF;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,gBAAgB;IAKvD,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAGhC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Graph Builder
|
|
3
|
+
* Functions for building the dependency graph from rules
|
|
4
|
+
*/
|
|
5
|
+
import type { TriggerRule } from "../../types";
|
|
6
|
+
import type { DependencyGraph, DependencyNode, DependencyEdge } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Build complete dependency graph with full rule information
|
|
9
|
+
* @returns JSON-serializable DependencyGraph object
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildGraph(rules: TriggerRule[]): DependencyGraph;
|
|
12
|
+
/**
|
|
13
|
+
* Build an adjacency list from rules (simplified version)
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildAdjacencyList(rules: TriggerRule[]): Record<string, string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Build a reverse adjacency list from rules (simplified version)
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildReverseAdjacencyList(rules: TriggerRule[]): Record<string, string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get all edges in the graph
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAllEdges(rules: TriggerRule[]): DependencyEdge[];
|
|
24
|
+
/**
|
|
25
|
+
* Get all nodes in the graph
|
|
26
|
+
*/
|
|
27
|
+
export declare function getAllNodes(rules: TriggerRule[]): DependencyNode[];
|
|
28
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/E;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,eAAe,CAuEhE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAGjF;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAGxF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAGlE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAGlE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cycle Detection Module
|
|
3
|
+
* Functions for detecting cycles in the dependency graph
|
|
4
|
+
*/
|
|
5
|
+
import type { TriggerRule } from "../../types";
|
|
6
|
+
import type { DependencyGraph, CycleInfo } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Detect cycles in a list of rules (legacy method for compatibility)
|
|
9
|
+
* @returns Array of cycles, where each cycle is an array of Rule IDs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectCycles(rules: TriggerRule[]): string[][];
|
|
12
|
+
/**
|
|
13
|
+
* Detect cycles with full rule information
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectCyclesWithInfo(rules: TriggerRule[], graph: DependencyGraph): CycleInfo[];
|
|
16
|
+
/**
|
|
17
|
+
* Check if adding a rule would create a cycle
|
|
18
|
+
*/
|
|
19
|
+
export declare function wouldCreateCycle(existingRules: TriggerRule[], newRule: TriggerRule): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get all rules involved in any cycle
|
|
22
|
+
*/
|
|
23
|
+
export declare function getRulesInCycles(rules: TriggerRule[]): Set<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Calculate maximum cycle length
|
|
26
|
+
*/
|
|
27
|
+
export declare function getMaxCycleLength(rules: TriggerRule[]): number;
|
|
28
|
+
//# sourceMappingURL=cycles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycles.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/cycles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAG1D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,EAAE,CAwC7D;AAqCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,EAAE,CAqE9F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,WAAW,EAAE,EAC5B,OAAO,EAAE,WAAW,GACnB,OAAO,CAIT;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAelE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAK9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Graph Module
|
|
3
|
+
* Main entry point for the dependency graph analysis system
|
|
4
|
+
*/
|
|
5
|
+
export type { DependencyEdge, DependencyNode, DependencyGraph, CycleInfo, DependencyAnalysisResult, ValidationResult, RuleDependencies, EventToRulesMap } from './types';
|
|
6
|
+
export { getEmittedEvents, buildEventToRulesMap, getRulesListeningToEvent, getRulesEmittingEvent, findOrphanedRules, isRuleValid, createRuleMap } from './utils';
|
|
7
|
+
export { buildGraph, buildAdjacencyList, buildReverseAdjacencyList, getAllEdges, getAllNodes } from './builder';
|
|
8
|
+
export { detectCycles, detectCyclesWithInfo, wouldCreateCycle, getRulesInCycles, getMaxCycleLength } from './cycles';
|
|
9
|
+
export { validate, analyze, isValid, getErrors, getWarnings } from './validator';
|
|
10
|
+
export { DependencyAnalyzer } from './analyzer';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,SAAS,EACT,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,yBAAyB,EACzB,WAAW,EACX,WAAW,EACZ,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Graph Types
|
|
3
|
+
* JSON-serializable types for dependency analysis results
|
|
4
|
+
*/
|
|
5
|
+
import type { TriggerRule, ActionGroup } from "../../types";
|
|
6
|
+
/** Alias for TriggerAction */
|
|
7
|
+
export type { TriggerRule, ActionGroup as TriggerActionGroup };
|
|
8
|
+
/** Represents a single dependency edge in the graph */
|
|
9
|
+
export interface DependencyEdge {
|
|
10
|
+
sourceRuleId: string;
|
|
11
|
+
targetRuleId: string;
|
|
12
|
+
emittedEvent: string;
|
|
13
|
+
sourceRule: TriggerRule;
|
|
14
|
+
targetRule: TriggerRule;
|
|
15
|
+
}
|
|
16
|
+
/** Represents a node in the dependency graph */
|
|
17
|
+
export interface DependencyNode {
|
|
18
|
+
ruleId: string;
|
|
19
|
+
rule: TriggerRule;
|
|
20
|
+
listensTo: string[];
|
|
21
|
+
emits: string[];
|
|
22
|
+
}
|
|
23
|
+
/** Complete dependency graph structure */
|
|
24
|
+
export interface DependencyGraph {
|
|
25
|
+
nodes: DependencyNode[];
|
|
26
|
+
edges: DependencyEdge[];
|
|
27
|
+
adjacencyList: Record<string, string[]>;
|
|
28
|
+
reverseAdjacencyList: Record<string, string[]>;
|
|
29
|
+
}
|
|
30
|
+
/** Cycle information with full rule details */
|
|
31
|
+
export interface CycleInfo {
|
|
32
|
+
cycleId: string;
|
|
33
|
+
rules: TriggerRule[];
|
|
34
|
+
ruleIds: string[];
|
|
35
|
+
events: string[];
|
|
36
|
+
length: number;
|
|
37
|
+
}
|
|
38
|
+
/** Complete analysis result */
|
|
39
|
+
export interface DependencyAnalysisResult {
|
|
40
|
+
graph: DependencyGraph;
|
|
41
|
+
cycles: CycleInfo[];
|
|
42
|
+
orphanedRules: TriggerRule[];
|
|
43
|
+
potentialInfiniteLoops: CycleInfo[];
|
|
44
|
+
summary: {
|
|
45
|
+
totalRules: number;
|
|
46
|
+
totalEdges: number;
|
|
47
|
+
cyclesCount: number;
|
|
48
|
+
orphanedCount: number;
|
|
49
|
+
maxCycleLength: number;
|
|
50
|
+
};
|
|
51
|
+
raw: {
|
|
52
|
+
rules: TriggerRule[];
|
|
53
|
+
adjacencyList: Record<string, string[]>;
|
|
54
|
+
eventToRules: Record<string, string[]>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Validation result */
|
|
58
|
+
export interface ValidationResult {
|
|
59
|
+
valid: boolean;
|
|
60
|
+
errors: string[];
|
|
61
|
+
warnings: string[];
|
|
62
|
+
analysis: DependencyAnalysisResult;
|
|
63
|
+
}
|
|
64
|
+
/** Rule dependencies result */
|
|
65
|
+
export interface RuleDependencies {
|
|
66
|
+
dependsOn: TriggerRule[];
|
|
67
|
+
dependedBy: TriggerRule[];
|
|
68
|
+
graph: DependencyGraph;
|
|
69
|
+
}
|
|
70
|
+
/** Event to rules mapping */
|
|
71
|
+
export type EventToRulesMap = Record<string, string[]>;
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE5D,8BAA8B;AAC9B,YAAY,EAAE,WAAW,EAAE,WAAW,IAAI,kBAAkB,EAAE,CAAC;AAE/D,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC;IACxB,UAAU,EAAE,WAAW,CAAC;CACzB;AAED,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAChD;AAED,+CAA+C;AAC/C,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+BAA+B;AAC/B,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,sBAAsB,EAAE,SAAS,EAAE,CAAC;IACpC,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,GAAG,EAAE;QACH,KAAK,EAAE,WAAW,EAAE,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KACxC,CAAC;CACH;AAED,wBAAwB;AACxB,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,wBAAwB,CAAC;CACpC;AAED,+BAA+B;AAC/B,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,6BAA6B;AAC7B,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Graph Utilities
|
|
3
|
+
* Helper functions for extracting events from rules and other utilities
|
|
4
|
+
*/
|
|
5
|
+
import type { TriggerRule } from "../../types";
|
|
6
|
+
/**
|
|
7
|
+
* Extract all events emitted by a rule.
|
|
8
|
+
* Recursively traverses action groups and arrays to find EMIT_EVENT actions.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getEmittedEvents(rule: TriggerRule): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Build an event-to-rules mapping from a list of rules.
|
|
13
|
+
* Maps each event to the list of rule IDs that listen to it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildEventToRulesMap(rules: TriggerRule[]): Record<string, string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Get rules that listen to a specific event
|
|
18
|
+
*/
|
|
19
|
+
export declare function getRulesListeningToEvent(rules: TriggerRule[], event: string): TriggerRule[];
|
|
20
|
+
/**
|
|
21
|
+
* Get rules that emit a specific event
|
|
22
|
+
*/
|
|
23
|
+
export declare function getRulesEmittingEvent(rules: TriggerRule[], event: string): TriggerRule[];
|
|
24
|
+
/**
|
|
25
|
+
* Find rules that are orphaned (no dependencies in or out)
|
|
26
|
+
*/
|
|
27
|
+
export declare function findOrphanedRules(rules: TriggerRule[], adjacencyList: Record<string, string[]>, reverseAdjacencyList: Record<string, string[]>): TriggerRule[];
|
|
28
|
+
/**
|
|
29
|
+
* Check if a rule has a valid 'on' event
|
|
30
|
+
*/
|
|
31
|
+
export declare function isRuleValid(rule: TriggerRule): {
|
|
32
|
+
valid: boolean;
|
|
33
|
+
error?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Create a rule map for quick lookups
|
|
37
|
+
*/
|
|
38
|
+
export declare function createRuleMap(rules: TriggerRule[]): Map<string, TriggerRule>;
|
|
39
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA8B,MAAM,aAAa,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,CA6B5D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAWnF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAE3F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,EAAE,CAKxF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAAE,EACpB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACvC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAC7C,WAAW,EAAE,CA0Bf;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAKjF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAM5E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation Module
|
|
3
|
+
* Functions for validating rules and their dependencies
|
|
4
|
+
*/
|
|
5
|
+
import type { TriggerRule } from "../../types";
|
|
6
|
+
import type { DependencyAnalysisResult, ValidationResult } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Validate rules and return validation result
|
|
9
|
+
*/
|
|
10
|
+
export declare function validate(rules: TriggerRule[]): ValidationResult;
|
|
11
|
+
/**
|
|
12
|
+
* Complete dependency analysis with JSON export
|
|
13
|
+
* @returns DependencyAnalysisResult with full information
|
|
14
|
+
*/
|
|
15
|
+
export declare function analyze(rules: TriggerRule[]): DependencyAnalysisResult;
|
|
16
|
+
/**
|
|
17
|
+
* Check if rules are valid (no cycles)
|
|
18
|
+
*/
|
|
19
|
+
export declare function isValid(rules: TriggerRule[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get all validation errors for rules
|
|
22
|
+
*/
|
|
23
|
+
export declare function getErrors(rules: TriggerRule[]): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Get all validation warnings for rules
|
|
26
|
+
*/
|
|
27
|
+
export declare function getWarnings(rules: TriggerRule[]): string[];
|
|
28
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/core/dependency-graph/validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAK1E;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAkC/D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,wBAAwB,CAuCtE;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAExD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE,CAE1D"}
|
|
@@ -1,18 +1,69 @@
|
|
|
1
|
-
import type { TriggerRule } from "../types";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Dependency Graph Module
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point that re-exports all functionality from the
|
|
5
|
+
* modular sub-modules for backwards compatibility.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
|
|
7
|
+
* New code should import from 'src/core/dependency-graph/index.ts' for better
|
|
8
|
+
* tree-shaking and type safety.
|
|
9
|
+
*/
|
|
10
|
+
import type { TriggerRule } from "../types";
|
|
11
|
+
export type { DependencyEdge, DependencyNode, DependencyGraph, CycleInfo, DependencyAnalysisResult, ValidationResult, RuleDependencies, EventToRulesMap } from './dependency-graph/types';
|
|
12
|
+
export { getEmittedEvents, buildEventToRulesMap, getRulesListeningToEvent, getRulesEmittingEvent, findOrphanedRules, isRuleValid, createRuleMap } from './dependency-graph/utils';
|
|
13
|
+
export { buildGraph, buildAdjacencyList, buildReverseAdjacencyList, getAllEdges, getAllNodes } from './dependency-graph/builder';
|
|
14
|
+
export { detectCycles, detectCyclesWithInfo, wouldCreateCycle, getRulesInCycles, getMaxCycleLength } from './dependency-graph/cycles';
|
|
15
|
+
export { validate, analyze, isValid, getErrors, getWarnings } from './dependency-graph/validator';
|
|
16
|
+
export { DependencyAnalyzer } from './dependency-graph/analyzer';
|
|
17
|
+
/**
|
|
18
|
+
* Legacy re-exports for backwards compatibility
|
|
19
|
+
* @deprecated Use named imports from this module instead
|
|
9
20
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
export type { TriggerRule, TriggerAction, ActionGroup } from "../types";
|
|
22
|
+
/**
|
|
23
|
+
* Legacy interface aliases - now delegate to modular types
|
|
24
|
+
*/
|
|
25
|
+
export interface LegacyDependencyEdge {
|
|
26
|
+
sourceRuleId: string;
|
|
27
|
+
targetRuleId: string;
|
|
28
|
+
emittedEvent: string;
|
|
29
|
+
sourceRule: TriggerRule;
|
|
30
|
+
targetRule: TriggerRule;
|
|
31
|
+
}
|
|
32
|
+
export interface LegacyDependencyNode {
|
|
33
|
+
ruleId: string;
|
|
34
|
+
rule: TriggerRule;
|
|
35
|
+
listensTo: string[];
|
|
36
|
+
emits: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface LegacyDependencyGraph {
|
|
39
|
+
nodes: LegacyDependencyNode[];
|
|
40
|
+
edges: LegacyDependencyEdge[];
|
|
41
|
+
adjacencyList: Record<string, string[]>;
|
|
42
|
+
reverseAdjacencyList: Record<string, string[]>;
|
|
43
|
+
}
|
|
44
|
+
export interface LegacyCycleInfo {
|
|
45
|
+
cycleId: string;
|
|
46
|
+
rules: TriggerRule[];
|
|
47
|
+
ruleIds: string[];
|
|
48
|
+
events: string[];
|
|
49
|
+
length: number;
|
|
50
|
+
}
|
|
51
|
+
export interface LegacyDependencyAnalysisResult {
|
|
52
|
+
graph: LegacyDependencyGraph;
|
|
53
|
+
cycles: LegacyCycleInfo[];
|
|
54
|
+
orphanedRules: TriggerRule[];
|
|
55
|
+
potentialInfiniteLoops: LegacyCycleInfo[];
|
|
56
|
+
summary: {
|
|
57
|
+
totalRules: number;
|
|
58
|
+
totalEdges: number;
|
|
59
|
+
cyclesCount: number;
|
|
60
|
+
orphanedCount: number;
|
|
61
|
+
maxCycleLength: number;
|
|
62
|
+
};
|
|
63
|
+
raw: {
|
|
64
|
+
rules: TriggerRule[];
|
|
65
|
+
adjacencyList: Record<string, string[]>;
|
|
66
|
+
eventToRules: Record<string, string[]>;
|
|
67
|
+
};
|
|
17
68
|
}
|
|
18
69
|
//# sourceMappingURL=dependency-graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../../src/core/dependency-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../../src/core/dependency-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA8B,MAAM,UAAU,CAAC;AAGxE,YAAY,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,SAAS,EACT,wBAAwB,EACxB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACd,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,yBAAyB,EACzB,WAAW,EACX,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;GAGG;AAGH,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC;IACxB,UAAU,EAAE,WAAW,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,qBAAqB,CAAC;IAC7B,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,sBAAsB,EAAE,eAAe,EAAE,CAAC;IAC1C,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,GAAG,EAAE;QACH,KAAK,EAAE,WAAW,EAAE,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KACxC,CAAC;CACH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TriggerContext, RuleCondition, Action, ActionGroup, ExecutedAction, ActionParams, ExecutionMode } from "../types";
|
|
2
|
+
import { ActionRegistry } from "./action-registry";
|
|
3
|
+
/**
|
|
4
|
+
* Common utilities for engine logic to avoid repetition across different engine implementations
|
|
5
|
+
*/
|
|
6
|
+
export declare class EngineUtils {
|
|
7
|
+
/**
|
|
8
|
+
* Evaluates a set of conditions against a context
|
|
9
|
+
*/
|
|
10
|
+
static evaluateConditions(conditions: RuleCondition | RuleCondition[] | undefined, context: TriggerContext): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluates a single condition or a condition group recursively
|
|
13
|
+
*/
|
|
14
|
+
private static evaluateRecursiveCondition;
|
|
15
|
+
/**
|
|
16
|
+
* Handles action execution common logic including:
|
|
17
|
+
* - Probability checks
|
|
18
|
+
* - Delay handling
|
|
19
|
+
* - Parameter interpolation
|
|
20
|
+
* - Control flow (break/continue)
|
|
21
|
+
* - 'run' block execution
|
|
22
|
+
* - Shorthand syntax normalization
|
|
23
|
+
*/
|
|
24
|
+
static processSingleActionBase(action: Action, context: TriggerContext, actionRegistry?: ActionRegistry): Promise<{
|
|
25
|
+
shouldExecute: boolean;
|
|
26
|
+
executedAction?: ExecutedAction;
|
|
27
|
+
normalizedAction: Action;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Selects an action to execute based on mode and random weights
|
|
31
|
+
*/
|
|
32
|
+
static selectActions(actions: Action | Action[] | ActionGroup | (Action | ActionGroup)[]): {
|
|
33
|
+
actionsToExecute: (Action | ActionGroup)[];
|
|
34
|
+
mode: ExecutionMode;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Deeply interpolates parameters with context variables
|
|
38
|
+
*/
|
|
39
|
+
static interpolateParams(params: ActionParams, context: TriggerContext): ActionParams;
|
|
40
|
+
/**
|
|
41
|
+
* Recursive interpolation for objects and arrays
|
|
42
|
+
*/
|
|
43
|
+
static interpolateDeep(val: unknown, context: TriggerContext): unknown;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=engine-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-utils.d.ts","sourceRoot":"","sources":["../../src/core/engine-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,aAAa,EAGb,MAAM,EACN,WAAW,EACX,cAAc,EACd,YAAY,EAEZ,aAAa,EACd,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD;;GAEG;AACH,qBAAa,WAAW;IAEtB;;OAEG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,SAAS,EACvD,OAAO,EAAE,cAAc,GACtB,OAAO;IAWV;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAkCzC;;;;;;;;OAQG;WACU,uBAAuB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,cAAc,EACvB,cAAc,CAAC,EAAE,cAAc,GAC9B,OAAO,CAAC;QACT,aAAa,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAC;IAkGF;;OAEG;IACH,MAAM,CAAC,aAAa,CAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,GAClE;QAAE,gBAAgB,EAAE,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;QAAC,IAAI,EAAE,aAAa,CAAA;KAAE;IAiCtE;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,YAAY;IAQrF;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO;CAgBvE"}
|
package/dist/core/engine.d.ts
CHANGED
|
@@ -18,14 +18,6 @@ export declare class TriggerEngine {
|
|
|
18
18
|
private evaluateConditions;
|
|
19
19
|
private evaluateSingleCondition;
|
|
20
20
|
private executeRuleActions;
|
|
21
|
-
/**
|
|
22
|
-
* Execute nested actions (then/else branches)
|
|
23
|
-
*/
|
|
24
|
-
private executeNestedActions;
|
|
25
|
-
/**
|
|
26
|
-
* Execute a single action with delay and probability support
|
|
27
|
-
*/
|
|
28
|
-
private executeSingleAction;
|
|
29
21
|
private interpolateParams;
|
|
30
22
|
private interpolateDeep;
|
|
31
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EAMb,YAAY,EAGb,MAAM,UAAU,CAAC;AAKlB,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEhH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,aAAa,CAAkC;gBAG3C,KAAK,GAAE,WAAW,EAAO;IAMrC,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB;IAIzD;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA+BrE,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,uBAAuB;YAuBjB,kBAAkB;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EAMb,YAAY,EAGb,MAAM,UAAU,CAAC;AAKlB,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEhH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,cAAc,CAA+C;IACrE,OAAO,CAAC,aAAa,CAAkC;gBAG3C,KAAK,GAAE,WAAW,EAAO;IAMrC,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB;IAIzD;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA+BrE,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,uBAAuB;YAuBjB,kBAAkB;IAwFhC,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,eAAe;CAUxB"}
|