trigger_system 1.2.5 → 1.3.0
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/README.md +2 -12
- package/dist/browser/index.browser.js +116 -116
- package/dist/browser/index.browser.js.map +19 -20
- package/dist/core/action-registry.d.ts +1 -8
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/constants.d.ts +2 -18
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/engine-utils.d.ts.map +1 -1
- package/dist/core/event-queue.d.ts.map +1 -1
- package/dist/core/expression-engine.d.ts +0 -1
- package/dist/core/expression-engine.d.ts.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/persistence.d.ts +0 -1
- package/dist/core/persistence.d.ts.map +1 -1
- package/dist/core/rule-engine.d.ts +0 -12
- package/dist/core/rule-engine.d.ts.map +1 -1
- package/dist/core/trigger-engine.d.ts +56 -6
- package/dist/core/trigger-engine.d.ts.map +1 -1
- package/dist/core/vars-context.d.ts +138 -0
- package/dist/core/vars-context.d.ts.map +1 -0
- package/dist/io/loader/index.d.ts +2 -1
- package/dist/io/loader/index.d.ts.map +1 -1
- package/dist/io/loader/persistence.d.ts +13 -2
- package/dist/io/loader/persistence.d.ts.map +1 -1
- package/dist/io/loader/registry.d.ts +46 -3
- package/dist/io/loader/registry.d.ts.map +1 -1
- package/dist/io/loader/types.d.ts +12 -0
- package/dist/io/loader/types.d.ts.map +1 -1
- package/dist/lsp/hover-constants.d.ts.map +1 -1
- package/dist/node/index.js +135 -135
- package/dist/node/index.js.map +20 -21
- package/dist/node/node.js +140 -140
- package/dist/node/node.js.map +23 -24
- package/dist/sdk/builder.d.ts +2 -2
- package/dist/sdk/builder.d.ts.map +1 -1
- package/dist/sdk/graph/action-resolver.d.ts.map +1 -1
- package/dist/sdk/graph/condition-resolver.d.ts.map +1 -1
- package/dist/sdk/graph-parser.d.ts +15 -1
- package/dist/sdk/graph-parser.d.ts.map +1 -1
- package/dist/sdk/yaml/converter.d.ts.map +1 -1
- package/dist/sdk/yaml/types.d.ts +0 -1
- package/dist/sdk/yaml/types.d.ts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -7,16 +7,9 @@ export type ActionHandler = (action: TriggerAction, context: TriggerContext) =>
|
|
|
7
7
|
export declare const BuiltInAction: {
|
|
8
8
|
readonly LOG: "LOG";
|
|
9
9
|
readonly MATH: "MATH";
|
|
10
|
-
readonly RESPONSE: "RESPONSE";
|
|
11
|
-
readonly EXECUTE: "EXECUTE";
|
|
12
10
|
readonly FORWARD: "FORWARD";
|
|
13
|
-
readonly
|
|
14
|
-
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
15
|
-
readonly STATE_GET: "STATE_GET";
|
|
16
|
-
readonly STATE_DELETE: "STATE_DELETE";
|
|
11
|
+
readonly FETCH: "FETCH";
|
|
17
12
|
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
18
|
-
readonly NOTIFY: "NOTIFY";
|
|
19
|
-
readonly STATE_OP: "STATE_OP";
|
|
20
13
|
};
|
|
21
14
|
export interface ActionDefinition {
|
|
22
15
|
handler: ActionHandler;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAS,MAAM,UAAU,CAAC;AAErE,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;;;;;;CAMhB,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;AA4FD,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;CA4BzB"}
|
package/dist/core/constants.d.ts
CHANGED
|
@@ -5,16 +5,9 @@ import { EngineEvent, RuleEvent } from "../utils/emitter";
|
|
|
5
5
|
export declare const Actions: {
|
|
6
6
|
readonly LOG: "LOG";
|
|
7
7
|
readonly MATH: "MATH";
|
|
8
|
-
readonly RESPONSE: "RESPONSE";
|
|
9
|
-
readonly EXECUTE: "EXECUTE";
|
|
10
8
|
readonly FORWARD: "FORWARD";
|
|
11
|
-
readonly
|
|
12
|
-
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
13
|
-
readonly STATE_GET: "STATE_GET";
|
|
14
|
-
readonly STATE_DELETE: "STATE_DELETE";
|
|
9
|
+
readonly FETCH: "FETCH";
|
|
15
10
|
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
16
|
-
readonly NOTIFY: "NOTIFY";
|
|
17
|
-
readonly STATE_OP: "STATE_OP";
|
|
18
11
|
};
|
|
19
12
|
export declare const Events: typeof EngineEvent;
|
|
20
13
|
export declare const RuleEvents: typeof RuleEvent;
|
|
@@ -29,7 +22,6 @@ export declare const ControlFlow: {
|
|
|
29
22
|
readonly CONTINUE: "continue";
|
|
30
23
|
readonly MODE: "mode";
|
|
31
24
|
readonly ACTIONS: "actions";
|
|
32
|
-
readonly RUN: "run";
|
|
33
25
|
readonly DELAY: "delay";
|
|
34
26
|
readonly PROBABILITY: "probability";
|
|
35
27
|
readonly PARAMS: "params";
|
|
@@ -51,16 +43,9 @@ export declare const TriggerSystem: {
|
|
|
51
43
|
Actions: {
|
|
52
44
|
readonly LOG: "LOG";
|
|
53
45
|
readonly MATH: "MATH";
|
|
54
|
-
readonly RESPONSE: "RESPONSE";
|
|
55
|
-
readonly EXECUTE: "EXECUTE";
|
|
56
46
|
readonly FORWARD: "FORWARD";
|
|
57
|
-
readonly
|
|
58
|
-
readonly STATE_INCREMENT: "STATE_INCREMENT";
|
|
59
|
-
readonly STATE_GET: "STATE_GET";
|
|
60
|
-
readonly STATE_DELETE: "STATE_DELETE";
|
|
47
|
+
readonly FETCH: "FETCH";
|
|
61
48
|
readonly EMIT_EVENT: "EMIT_EVENT";
|
|
62
|
-
readonly NOTIFY: "NOTIFY";
|
|
63
|
-
readonly STATE_OP: "STATE_OP";
|
|
64
49
|
};
|
|
65
50
|
Events: typeof EngineEvent;
|
|
66
51
|
RuleEvents: typeof RuleEvent;
|
|
@@ -72,7 +57,6 @@ export declare const TriggerSystem: {
|
|
|
72
57
|
readonly CONTINUE: "continue";
|
|
73
58
|
readonly MODE: "mode";
|
|
74
59
|
readonly ACTIONS: "actions";
|
|
75
|
-
readonly RUN: "run";
|
|
76
60
|
readonly DELAY: "delay";
|
|
77
61
|
readonly PROBABILITY: "probability";
|
|
78
62
|
readonly PARAMS: "params";
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;CAad,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"}
|
|
@@ -1 +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,U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E,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.d.ts","sourceRoot":"","sources":["../../src/core/event-queue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,gBAA6D;IAKrG;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE,cAAc;IAU5B;;OAEG;IACG,YAAY;
|
|
1
|
+
{"version":3,"file":"event-queue.d.ts","sourceRoot":"","sources":["../../src/core/event-queue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,gBAAgB;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,UAAU;IACnB,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,UAAU,EAAE,MAAM,GAAE,gBAA6D;IAKrG;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE,cAAc;IAU5B;;OAEG;IACG,YAAY;IAkClB,cAAc,IAAI,MAAM;CAG3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression-engine.d.ts","sourceRoot":"","sources":["../../src/core/expression-engine.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"expression-engine.d.ts","sourceRoot":"","sources":["../../src/core/expression-engine.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;CAQd,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAOtE;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;CAahB,CAAC;AAuCX,qBAAa,gBAAgB;IAC3B;;;OAGG;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO;IA0BxF;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM;IAerE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAUrC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;IA8BjC;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO;IAcrE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAmBpC;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM;CAkDzE"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { ITriggerEngine, EngineActionHandler } from "./base-engine";
|
|
|
7
7
|
export { TriggerEngine } from "./trigger-engine";
|
|
8
8
|
export { RuleEngine } from "./rule-engine";
|
|
9
9
|
export * from "./action-registry";
|
|
10
|
-
export * from "./context-adapter";
|
|
11
|
-
export * from "./state-manager";
|
|
12
10
|
export { TriggerEngine as Engine } from "./trigger-engine";
|
|
11
|
+
export { vars, createVarsContext } from "./vars-context";
|
|
12
|
+
export type { VarsStore, VarsAPI, VarsValue, VarsPrimitive, VarsObject, VarsCallback, MergeOptions } from "./vars-context";
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,uBAAuB,CAAC;AAGtC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,uBAAuB,CAAC;AAGtC,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../src/core/persistence.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../src/core/persistence.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtD;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,kBAAkB;IAC5D,OAAO,CAAC,KAAK,CAA8B;IAErC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAI1C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RuleEngine - Extension of TriggerEngine with advanced features
|
|
3
|
-
* Adds observability, persistent state, and integrated ActionRegistry
|
|
4
3
|
*/
|
|
5
4
|
import type { TriggerContext, TriggerResult, RuleEngineConfig } from "../types";
|
|
6
5
|
import { TriggerEngine } from "./trigger-engine";
|
|
7
6
|
import { ActionRegistry } from "./action-registry";
|
|
8
|
-
import { StateManager } from "./state-manager";
|
|
9
7
|
export declare class RuleEngine extends TriggerEngine {
|
|
10
8
|
private actionRegistry;
|
|
11
|
-
private stateManager;
|
|
12
9
|
constructor(config: RuleEngineConfig);
|
|
13
10
|
/**
|
|
14
11
|
* Evaluates all rules against the provided context
|
|
15
|
-
* This is the main entry point for evaluating rules with state management
|
|
16
12
|
*/
|
|
17
13
|
evaluateContext(context: TriggerContext): Promise<TriggerResult[]>;
|
|
18
14
|
/**
|
|
@@ -21,15 +17,7 @@ export declare class RuleEngine extends TriggerEngine {
|
|
|
21
17
|
* Can accept either a full TriggerContext or a string event type with data/vars
|
|
22
18
|
*/
|
|
23
19
|
processEvent(contextOrType: TriggerContext | string, data?: Record<string, unknown>, vars?: Record<string, unknown>): Promise<TriggerResult[]>;
|
|
24
|
-
/**
|
|
25
|
-
* Overrides getStateContext to use StateManager
|
|
26
|
-
*/
|
|
27
|
-
protected getStateContext(): Record<string, any>;
|
|
28
20
|
get ActionRegistry(): ActionRegistry;
|
|
29
|
-
/**
|
|
30
|
-
* Get the state manager instance
|
|
31
|
-
*/
|
|
32
|
-
get StateManager(): StateManager;
|
|
33
21
|
}
|
|
34
22
|
export { RuleEngine as AdvancedEngine };
|
|
35
23
|
//# sourceMappingURL=rule-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-engine.d.ts","sourceRoot":"","sources":["../../src/core/rule-engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rule-engine.d.ts","sourceRoot":"","sources":["../../src/core/rule-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAEV,cAAc,EACd,aAAa,EACb,gBAAgB,EAMjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,qBAAa,UAAW,SAAQ,aAAa;IAC3C,OAAO,CAAC,cAAc,CAAiB;gBAE3B,MAAM,EAAE,gBAAgB;IAQpC;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAqBxE;;;;OAIG;IACY,YAAY,CACzB,aAAa,EAAE,cAAc,GAAG,MAAM,EACtC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAClC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,aAAa,EAAE,CAAC;IAkC3B,IAAI,cAAc,IAAI,cAAc,CAEnC;CACF;AAGD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -4,26 +4,69 @@
|
|
|
4
4
|
* Can be extended to add additional features
|
|
5
5
|
*/
|
|
6
6
|
import type { TriggerRule, TriggerContext, TriggerResult, Action, ActionGroup, RuleCondition, RuleEngineConfig, ActionParams, EngineActionHandler, ExecutedAction } from "../types";
|
|
7
|
+
import type { VarsStore, VarsAPI, MergeOptions } from "./vars-context";
|
|
7
8
|
export declare class TriggerEngine {
|
|
8
9
|
protected _rules: TriggerRule[];
|
|
9
10
|
protected actionHandlers: Map<string, EngineActionHandler>;
|
|
10
11
|
protected lastExecution: Map<string, number>;
|
|
11
12
|
protected _config?: RuleEngineConfig;
|
|
13
|
+
/** Per-engine reactive variable store (values + callbacks, separate buckets) */
|
|
14
|
+
protected _vars: VarsStore & VarsAPI;
|
|
12
15
|
constructor(rulesOrConfig?: TriggerRule[] | RuleEngineConfig);
|
|
13
16
|
/**
|
|
14
17
|
* Sorts rules by priority (highest first)
|
|
15
18
|
*/
|
|
16
19
|
protected sortRules(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Single handler for all var operations. Registered as action type `'vars'`.
|
|
22
|
+
*
|
|
23
|
+
* Rule usage:
|
|
24
|
+
* { type: 'vars', params: { op: 'set', key: 'x', value: 42 } }
|
|
25
|
+
* { type: 'vars', params: { op: 'increment', key: 'x', delta: 2 } }
|
|
26
|
+
* { type: 'vars', params: { op: 'decrement', key: 'x', delta: 1 } }
|
|
27
|
+
* { type: 'vars', params: { op: 'delete', key: 'x' } }
|
|
28
|
+
* { type: 'vars', params: { op: 'merge', data: { a: 1, b: 2 }, overwrite: false } }
|
|
29
|
+
* { type: 'vars', params: { op: 'reset' } }
|
|
30
|
+
*/
|
|
31
|
+
private _registerVarActions;
|
|
17
32
|
/**
|
|
18
33
|
* Registers a handler for a specific action type
|
|
19
34
|
*/
|
|
20
35
|
registerAction(type: string, handler: EngineActionHandler): void;
|
|
21
36
|
/**
|
|
22
|
-
*
|
|
37
|
+
* Register values and/or callbacks into the engine's vars store in one call.
|
|
38
|
+
* Functions are automatically routed to the callbacks bucket;
|
|
39
|
+
* everything else goes to the values bucket.
|
|
40
|
+
*
|
|
41
|
+
* By default existing keys are NOT overwritten (same as VarsContext.merge).
|
|
42
|
+
* Pass `overwrite: true` to force replacement.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* engine.registerVars({
|
|
46
|
+
* maxRetries: 3, // → values
|
|
47
|
+
* label: 'v1', // → values
|
|
48
|
+
* onFire: (ctx) => { ... }, // → callbacks
|
|
49
|
+
* });
|
|
50
|
+
*/
|
|
51
|
+
registerVars(data: Record<string, unknown>, options?: MergeOptions | boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Splits a mixed record into values / callbacks and merges each
|
|
54
|
+
* into the appropriate bucket of `this._vars`.
|
|
55
|
+
*/
|
|
56
|
+
private _mergeWithCallbackRouting;
|
|
57
|
+
/**
|
|
58
|
+
* Processes an event with full context.
|
|
59
|
+
* Injects the engine's persistent vars into context.vars before evaluation,
|
|
60
|
+
* so conditions and interpolations can reference ${vars.x} freely.
|
|
61
|
+
*
|
|
62
|
+
* Any callbacks mixed into `context.vars` are automatically extracted and
|
|
63
|
+
* registerd into `_vars._callbacks` before the plain snapshot is built.
|
|
23
64
|
*/
|
|
24
65
|
processEvent(context: TriggerContext): Promise<TriggerResult[]>;
|
|
25
66
|
/**
|
|
26
|
-
* Convenience method to process simple events
|
|
67
|
+
* Convenience method to process simple events.
|
|
68
|
+
* `vars` may contain a mix of plain values and callbacks —
|
|
69
|
+
* callbacks are automatically routed to the `_callbacks` bucket.
|
|
27
70
|
*/
|
|
28
71
|
processEventSimple(eventType: string, data?: Record<string, unknown>, vars?: Record<string, unknown>): Promise<TriggerResult[]>;
|
|
29
72
|
/**
|
|
@@ -46,10 +89,6 @@ export declare class TriggerEngine {
|
|
|
46
89
|
* Determines whether to evaluate all rules or just the first match
|
|
47
90
|
*/
|
|
48
91
|
protected shouldEvaluateAll(): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Gets the state context (can be overridden by subclasses)
|
|
51
|
-
*/
|
|
52
|
-
protected getStateContext?(): Record<string, any>;
|
|
53
92
|
/**
|
|
54
93
|
* Evaluates rule conditions (overridable)
|
|
55
94
|
*/
|
|
@@ -72,6 +111,17 @@ export declare class TriggerEngine {
|
|
|
72
111
|
protected interpolateParams(params: ActionParams, context: TriggerContext): ActionParams;
|
|
73
112
|
get rules(): TriggerRule[];
|
|
74
113
|
get config(): RuleEngineConfig | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* The reactive variable store for this engine instance.
|
|
116
|
+
* Values (primitives/objects) and callbacks live in separate internal buckets.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* engine.vars.hits = 0;
|
|
120
|
+
* engine.vars.increment('hits'); // → 1
|
|
121
|
+
* engine.vars.merge({ maxRetries: 3 }); // non-overwriting
|
|
122
|
+
* engine.vars.interpolate('total: ${vars.hits}'); // → "total: 1"
|
|
123
|
+
*/
|
|
124
|
+
get vars(): VarsStore & VarsAPI;
|
|
75
125
|
set rules(newRules: TriggerRule[]);
|
|
76
126
|
}
|
|
77
127
|
export type { TriggerEngine as BaseEngine };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-engine.d.ts","sourceRoot":"","sources":["../../src/core/trigger-engine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EAGb,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EAKnB,cAAc,EACf,MAAM,UAAU,CAAC;AAQlB,qBAAa,aAAa;IACxB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAM;IACrC,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAa;IACvE,SAAS,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAa;IACzD,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"trigger-engine.d.ts","sourceRoot":"","sources":["../../src/core/trigger-engine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,MAAM,EACN,WAAW,EACX,aAAa,EAGb,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EAKnB,cAAc,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independent buckets:
|
|
5
|
+
* · _values — primitives, plain objects, arrays (never functions)
|
|
6
|
+
* · _callbacks — functions / callbacks only
|
|
7
|
+
*
|
|
8
|
+
* The Proxy routes automatically based on `typeof value`:
|
|
9
|
+
* vars.count = 5 → _values
|
|
10
|
+
* vars.onFire = () => {} → _callbacks
|
|
11
|
+
*
|
|
12
|
+
* String interpolation is powered by ExpressionEngine.interpolate so that
|
|
13
|
+
* templates like "${vars.count} events fired" resolve against the store.
|
|
14
|
+
*
|
|
15
|
+
* Merge is NON-overwriting by default. Use { overwrite: true } or vars.set()
|
|
16
|
+
* for explicit replacement. vars.delete('key') is the only way to remove a key.
|
|
17
|
+
*/
|
|
18
|
+
import type { TriggerContext } from "../types";
|
|
19
|
+
export type VarsCallback = (...args: unknown[]) => unknown;
|
|
20
|
+
export type VarsPrimitive = string | number | boolean | null;
|
|
21
|
+
export type VarsObject = Record<string, unknown> | unknown[];
|
|
22
|
+
export type VarsValue = VarsPrimitive | VarsObject;
|
|
23
|
+
export type VarsStore = Record<string, VarsValue>;
|
|
24
|
+
export interface MergeOptions {
|
|
25
|
+
/** When true, existing keys are overwritten. Default: false */
|
|
26
|
+
overwrite?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface VarsAPI {
|
|
29
|
+
/**
|
|
30
|
+
* Merge plain values (non-function) into the store.
|
|
31
|
+
* Callbacks inside the object are silently skipped — use mergeCallbacks() for those.
|
|
32
|
+
* By default existing keys are NOT overwritten.
|
|
33
|
+
*/
|
|
34
|
+
merge(data: VarsStore, options?: MergeOptions | boolean): void;
|
|
35
|
+
/**
|
|
36
|
+
* Merge callbacks into the callbacks bucket.
|
|
37
|
+
* By default existing keys are NOT overwritten.
|
|
38
|
+
*/
|
|
39
|
+
mergeCallbacks(data: Record<string, VarsCallback>, options?: MergeOptions | boolean): void;
|
|
40
|
+
/**
|
|
41
|
+
* Explicitly set a value (always overwrites). Only for non-function values.
|
|
42
|
+
*/
|
|
43
|
+
set<T extends VarsValue = VarsValue>(key: string, value: T): void;
|
|
44
|
+
/**
|
|
45
|
+
* Explicitly register a callback (always overwrites).
|
|
46
|
+
*/
|
|
47
|
+
setCallback(key: string, fn: VarsCallback): void;
|
|
48
|
+
/**
|
|
49
|
+
* Delete a key from values OR callbacks.
|
|
50
|
+
* This is the ONLY way to remove a key.
|
|
51
|
+
*/
|
|
52
|
+
delete(key: string): boolean;
|
|
53
|
+
/** Check whether a key exists in values or callbacks. */
|
|
54
|
+
has(key: string): boolean;
|
|
55
|
+
/** Retrieve a stored value (typed convenience). */
|
|
56
|
+
get<T extends VarsValue = VarsValue>(key: string): T | undefined;
|
|
57
|
+
/** Retrieve a stored callback. */
|
|
58
|
+
getCallback(key: string): VarsCallback | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Call a stored callback by key with the given arguments.
|
|
61
|
+
* Throws if the key is not a registered callback.
|
|
62
|
+
*/
|
|
63
|
+
call(key: string, ...args: unknown[]): unknown;
|
|
64
|
+
/**
|
|
65
|
+
* Interpolate a template string against the current value store.
|
|
66
|
+
* Uses ExpressionEngine.interpolate internally.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* vars.count = 42;
|
|
70
|
+
* vars.interpolate("fired ${vars.count} times"); // → "fired 42 times"
|
|
71
|
+
*/
|
|
72
|
+
interpolate(template: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Increment a numeric value by delta (default 1).
|
|
75
|
+
* Initialises to 0 if the key does not exist or is not a number.
|
|
76
|
+
*/
|
|
77
|
+
increment(key: string, delta?: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* Decrement a numeric value by delta (default 1).
|
|
80
|
+
* Initialises to 0 if the key does not exist or is not a number.
|
|
81
|
+
*/
|
|
82
|
+
decrement(key: string, delta?: number): number;
|
|
83
|
+
/** Shallow copy of the current value store. */
|
|
84
|
+
snapshot(): VarsStore;
|
|
85
|
+
/** Shallow copy of the current callback registry. */
|
|
86
|
+
snapshotCallbacks(): Record<string, VarsCallback>;
|
|
87
|
+
/**
|
|
88
|
+
* Reset value store (and optionally the callback store) to a new initial state.
|
|
89
|
+
* By default callbacks are preserved unless resetCallbacks is true.
|
|
90
|
+
*/
|
|
91
|
+
reset(initial?: VarsStore, resetCallbacks?: boolean): void;
|
|
92
|
+
/** Keys present in the value store. */
|
|
93
|
+
keys(): string[];
|
|
94
|
+
/** Keys present in the callback store. */
|
|
95
|
+
callbackKeys(): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Build a minimal TriggerContext from the current value store so it can be
|
|
98
|
+
* passed directly to ExpressionEngine or EngineUtils methods.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const ctx = vars.toContext({ event: 'tick', data: payload });
|
|
102
|
+
* EngineUtils.evaluateConditions(rule.if, ctx);
|
|
103
|
+
*/
|
|
104
|
+
toContext(overrides?: Partial<TriggerContext>): TriggerContext;
|
|
105
|
+
}
|
|
106
|
+
declare function createVarsContext(): VarsStore & VarsAPI;
|
|
107
|
+
/**
|
|
108
|
+
* Global vars proxy — single shared instance across the engine lifecycle.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* import { vars } from './vars-context';
|
|
112
|
+
*
|
|
113
|
+
* // --- values (primitives / objects / arrays) ---
|
|
114
|
+
* vars.count = 0;
|
|
115
|
+
* vars.increment('count'); // → 1
|
|
116
|
+
* vars.count++; // → 2 (via proxy set)
|
|
117
|
+
*
|
|
118
|
+
* vars.merge({ maxRetries: 3, label: 'v1' }); // non-overwriting
|
|
119
|
+
* vars.set('label', 'v2'); // explicit overwrite
|
|
120
|
+
* vars.delete('label');
|
|
121
|
+
*
|
|
122
|
+
* // --- callbacks ---
|
|
123
|
+
* vars.onFire = (ctx) => console.log(ctx); // auto-routed to callbacks
|
|
124
|
+
* vars.call('onFire', someContext);
|
|
125
|
+
* vars.setCallback('onFire', newFn); // explicit overwrite
|
|
126
|
+
*
|
|
127
|
+
* // --- interpolation via ExpressionEngine ---
|
|
128
|
+
* vars.name = 'World';
|
|
129
|
+
* vars.interpolate('Hello ${vars.name}!'); // → "Hello World!"
|
|
130
|
+
*
|
|
131
|
+
* // --- build a TriggerContext to use with EngineUtils ---
|
|
132
|
+
* const ctx = vars.toContext({ event: 'tick', data: payload });
|
|
133
|
+
* EngineUtils.evaluateConditions(rule.if, ctx);
|
|
134
|
+
*/
|
|
135
|
+
export declare const vars: VarsStore & VarsAPI;
|
|
136
|
+
/** Create an isolated instance (per-engine scope, per-test isolation, etc.) */
|
|
137
|
+
export { createVarsContext };
|
|
138
|
+
//# sourceMappingURL=vars-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vars-context.d.ts","sourceRoot":"","sources":["../../src/core/vars-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,UAAU,GAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;AAChE,MAAM,MAAM,SAAS,GAAO,aAAa,GAAG,UAAU,CAAC;AACvD,MAAM,MAAM,SAAS,GAAO,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,GAAG,IAAI,CAAC;IAE/D;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAA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C;IACvC,IAAI,IAAI,MAAM,EAAE,CAAC;IAEjB,0CAA0C;IAC1C,YAAY,IAAI,MAAM,EAAE,CAAC;IAEzB;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;CAChE;AAiBD,iBAAS,iBAAiB,IAAI,SAAS,GAAG,OAAO,CA4OhD;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,IAAI,EAAE,SAAS,GAAG,OAA6B,CAAC;AAE7D,+EAA+E;AAC/E,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -28,7 +28,7 @@ export { RuleRegistry } from "./registry";
|
|
|
28
28
|
export { RulePersistence } from "./persistence";
|
|
29
29
|
export { RuleQuery } from "./query";
|
|
30
30
|
export { RuleWatcher } from "./watch";
|
|
31
|
-
export type { RegistryEntry, LoaderOptions, RuleFileInfo } from "./types";
|
|
31
|
+
export type { RegistryEntry, FileEntry, LoaderOptions, RuleFileInfo } from "./types";
|
|
32
32
|
export declare class TriggerLoader {
|
|
33
33
|
private static defaultDir;
|
|
34
34
|
private static watcher;
|
|
@@ -40,6 +40,7 @@ export declare class TriggerLoader {
|
|
|
40
40
|
static loadRulesFromDir(dirPath: string): Promise<TriggerRule[]>;
|
|
41
41
|
/**
|
|
42
42
|
* Loads rules from a YAML file (supports multi-document)
|
|
43
|
+
* Assigns ruleIndex for multi-rule files
|
|
43
44
|
*/
|
|
44
45
|
static loadRule(filePath: string, debug?: (_err: YamlParserError | unknown) => void): Promise<TriggerRule[]>;
|
|
45
46
|
static watchRules(dirPath: string, onUpdate: (rules: TriggerRule[]) => void): fs.FSWatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/io/loader/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,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WAAW,EAAE,CAAC;IAoCtE;;;OAGG;WACU,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,MAAM,eAAe,GAAG,OAAO,SAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAkChH,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,IAAI,GAAG,EAAE,CAAC,SAAS;IAkB1F,MAAM,CAAC,YAAY,IAAI,IAAI;CAO5B"}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* TriggerLoader Persistence
|
|
3
3
|
*
|
|
4
4
|
* File system operations for loading and saving rules.
|
|
5
|
+
* Supports multiple rules per file.
|
|
5
6
|
*/
|
|
6
7
|
import type { TriggerRule } from "../../types";
|
|
7
8
|
import { type YamlParserError } from "../../sdk/yaml-parser";
|
|
8
9
|
/**
|
|
9
10
|
* Persistence operations for rules
|
|
11
|
+
* Supports grouping rules by file
|
|
10
12
|
*/
|
|
11
13
|
export declare class RulePersistence {
|
|
12
14
|
/**
|
|
@@ -18,13 +20,22 @@ export declare class RulePersistence {
|
|
|
18
20
|
*/
|
|
19
21
|
static loadFile(filePath: string, debug?: (err: YamlParserError | unknown) => void): Promise<TriggerRule[]>;
|
|
20
22
|
/**
|
|
21
|
-
* Save a rule to file
|
|
23
|
+
* Save a single rule to file (overwrites existing file)
|
|
22
24
|
*/
|
|
23
25
|
static saveRule(rule: TriggerRule, filePath: string): Promise<void>;
|
|
24
26
|
/**
|
|
25
|
-
* Save multiple rules
|
|
27
|
+
* Save multiple rules to a single file
|
|
28
|
+
*/
|
|
29
|
+
static saveRulesToFile(rules: TriggerRule[], filePath: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Save multiple rules, grouping by file path
|
|
32
|
+
* Rules with the same filePath are saved together in one file
|
|
26
33
|
*/
|
|
27
34
|
static saveAll(rules: TriggerRule[], baseDir: string, getFilePath?: (ruleId: string) => string): Promise<string[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Save all rules from a file entry
|
|
37
|
+
*/
|
|
38
|
+
static saveFile(rules: TriggerRule[], filePath: string): Promise<void>;
|
|
28
39
|
/**
|
|
29
40
|
* Delete a rule file
|
|
30
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/io/loader/persistence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/io/loader/persistence.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7E;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;OAEG;WACU,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAoCjE;;OAEG;WACU,QAAQ,CACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,KAAK,IAAe,GACzD,OAAO,CAAC,WAAW,EAAE,CAAC;IAqBzB;;OAEG;WACU,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzE;;OAEG;WACU,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnF;;;OAGG;WACU,OAAO,CAClB,KAAK,EAAE,WAAW,EAAE,EACpB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAwC,GACxE,OAAO,CAAC,MAAM,EAAE,CAAC;IA0BpB;;OAEG;WACU,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5E;;OAEG;WACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3D;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI5C;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAKxC"}
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* TriggerLoader Registry
|
|
3
3
|
*
|
|
4
4
|
* In-memory registry for managing rules.
|
|
5
|
+
* Supports multiple rules per file.
|
|
5
6
|
*/
|
|
6
7
|
import type { TriggerRule } from "../../types";
|
|
7
|
-
import type { RegistryEntry } from "./types";
|
|
8
|
+
import type { RegistryEntry, FileEntry } from "./types";
|
|
8
9
|
/**
|
|
9
10
|
* Registry class for managing rules in memory
|
|
11
|
+
* Supports grouping rules by file
|
|
10
12
|
*/
|
|
11
13
|
export declare class RuleRegistry {
|
|
12
14
|
private registry;
|
|
15
|
+
private fileRegistry;
|
|
13
16
|
private defaultDir;
|
|
14
17
|
/**
|
|
15
18
|
* Clear the registry
|
|
@@ -26,11 +29,15 @@ export declare class RuleRegistry {
|
|
|
26
29
|
/**
|
|
27
30
|
* Register a rule
|
|
28
31
|
*/
|
|
29
|
-
register(rule: TriggerRule, filePath?: string): void;
|
|
32
|
+
register(rule: TriggerRule, filePath?: string, ruleIndex?: number): void;
|
|
30
33
|
/**
|
|
31
34
|
* Register multiple rules
|
|
35
|
+
* Groups rules by file when they share the same filePath
|
|
36
|
+
* @param rules - Array of rules to register
|
|
37
|
+
* @param sourceFilePath - Optional: The actual file path where these rules came from
|
|
38
|
+
* If provided, all rules will be grouped under this file path
|
|
32
39
|
*/
|
|
33
|
-
registerAll(rules: TriggerRule[],
|
|
40
|
+
registerAll(rules: TriggerRule[], sourceFilePath?: string): void;
|
|
34
41
|
/**
|
|
35
42
|
* Get a rule by ID
|
|
36
43
|
*/
|
|
@@ -51,6 +58,26 @@ export declare class RuleRegistry {
|
|
|
51
58
|
* Get registry entry
|
|
52
59
|
*/
|
|
53
60
|
getEntry(ruleId: string): RegistryEntry | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Get file entry by file path
|
|
63
|
+
*/
|
|
64
|
+
getFileEntry(filePath: string): FileEntry | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Get all rules from a specific file
|
|
67
|
+
*/
|
|
68
|
+
getRulesByFile(filePath: string): TriggerRule[];
|
|
69
|
+
/**
|
|
70
|
+
* Get all file entries
|
|
71
|
+
*/
|
|
72
|
+
getAllFileEntries(): FileEntry[];
|
|
73
|
+
/**
|
|
74
|
+
* Get file path for a rule
|
|
75
|
+
*/
|
|
76
|
+
getFilePath(ruleId: string): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Check if a file has multiple rules
|
|
79
|
+
*/
|
|
80
|
+
isMultiRuleFile(filePath: string): boolean;
|
|
54
81
|
/**
|
|
55
82
|
* Add a new rule
|
|
56
83
|
*/
|
|
@@ -75,6 +102,14 @@ export declare class RuleRegistry {
|
|
|
75
102
|
* Mark as saved
|
|
76
103
|
*/
|
|
77
104
|
markAsSaved(ruleId: string, filePath?: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Mark all rules in a file as saved
|
|
107
|
+
*/
|
|
108
|
+
markFileAsSaved(filePath: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Mark a file as modified
|
|
111
|
+
*/
|
|
112
|
+
markFileAsModified(filePath: string): void;
|
|
78
113
|
/**
|
|
79
114
|
* Generate unique ID
|
|
80
115
|
*/
|
|
@@ -87,5 +122,13 @@ export declare class RuleRegistry {
|
|
|
87
122
|
* Get values iterator
|
|
88
123
|
*/
|
|
89
124
|
values(): IterableIterator<RegistryEntry>;
|
|
125
|
+
/**
|
|
126
|
+
* Get file registry entries iterator
|
|
127
|
+
*/
|
|
128
|
+
fileEntries(): IterableIterator<FileEntry>;
|
|
129
|
+
/**
|
|
130
|
+
* Get file registry size
|
|
131
|
+
*/
|
|
132
|
+
fileCount(): number;
|
|
90
133
|
}
|
|
91
134
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/io/loader/registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/io/loader/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,UAAU,CAAqB;IAEvC;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIpC;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAuCxE;;;;;;OAMG;IACH,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IA8ChE;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI5C;;OAEG;IACH,MAAM,IAAI,WAAW,EAAE;IAIvB;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAI5B;;OAEG;IACH,IAAI,IAAI,MAAM;IAId;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,aA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