trigger_system 1.2.0 → 1.2.4

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.
Files changed (123) hide show
  1. package/dist/browser/index.browser.js +185 -42
  2. package/dist/browser/index.browser.js.map +116 -17
  3. package/dist/core/action-registry.d.ts +29 -3
  4. package/dist/core/action-registry.d.ts.map +1 -1
  5. package/dist/core/base-engine.d.ts +3 -3
  6. package/dist/core/constants.d.ts +95 -0
  7. package/dist/core/constants.d.ts.map +1 -0
  8. package/dist/core/dependency-graph/analyzer.d.ts +60 -0
  9. package/dist/core/dependency-graph/analyzer.d.ts.map +1 -0
  10. package/dist/core/dependency-graph/builder.d.ts +28 -0
  11. package/dist/core/dependency-graph/builder.d.ts.map +1 -0
  12. package/dist/core/dependency-graph/cycles.d.ts +28 -0
  13. package/dist/core/dependency-graph/cycles.d.ts.map +1 -0
  14. package/dist/core/dependency-graph/index.d.ts +11 -0
  15. package/dist/core/dependency-graph/index.d.ts.map +1 -0
  16. package/dist/core/dependency-graph/types.d.ts +72 -0
  17. package/dist/core/dependency-graph/types.d.ts.map +1 -0
  18. package/dist/core/dependency-graph/utils.d.ts +39 -0
  19. package/dist/core/dependency-graph/utils.d.ts.map +1 -0
  20. package/dist/core/dependency-graph/validator.d.ts +28 -0
  21. package/dist/core/dependency-graph/validator.d.ts.map +1 -0
  22. package/dist/core/dependency-graph.d.ts +64 -13
  23. package/dist/core/dependency-graph.d.ts.map +1 -1
  24. package/dist/core/engine-utils.d.ts +45 -0
  25. package/dist/core/engine-utils.d.ts.map +1 -0
  26. package/dist/core/engine.d.ts +0 -8
  27. package/dist/core/engine.d.ts.map +1 -1
  28. package/dist/core/expression-engine.d.ts +52 -10
  29. package/dist/core/expression-engine.d.ts.map +1 -1
  30. package/dist/core/index.d.ts +2 -4
  31. package/dist/core/index.d.ts.map +1 -1
  32. package/dist/core/operators.d.ts +48 -0
  33. package/dist/core/operators.d.ts.map +1 -0
  34. package/dist/core/persistence-browser.d.ts +25 -2
  35. package/dist/core/persistence-browser.d.ts.map +1 -1
  36. package/dist/core/persistence.node.d.ts +25 -2
  37. package/dist/core/persistence.node.d.ts.map +1 -1
  38. package/dist/core/rule-engine-new.d.ts +2 -1
  39. package/dist/core/rule-engine-new.d.ts.map +1 -1
  40. package/dist/core/rule-engine.d.ts +22 -35
  41. package/dist/core/rule-engine.d.ts.map +1 -1
  42. package/dist/core/trigger-engine.d.ts +18 -25
  43. package/dist/core/trigger-engine.d.ts.map +1 -1
  44. package/dist/domain/validator.d.ts +36043 -5067
  45. package/dist/domain/validator.d.ts.map +1 -1
  46. package/dist/index.browser.d.ts +1 -0
  47. package/dist/index.browser.d.ts.map +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/io/index.d.ts +6 -1
  51. package/dist/io/index.d.ts.map +1 -1
  52. package/dist/io/loader/index.d.ts +48 -0
  53. package/dist/io/loader/index.d.ts.map +1 -0
  54. package/dist/io/loader/persistence.d.ts +41 -0
  55. package/dist/io/loader/persistence.d.ts.map +1 -0
  56. package/dist/io/loader/query.d.ts +49 -0
  57. package/dist/io/loader/query.d.ts.map +1 -0
  58. package/dist/io/loader/registry.d.ts +91 -0
  59. package/dist/io/loader/registry.d.ts.map +1 -0
  60. package/dist/io/loader/types.d.ts +32 -0
  61. package/dist/io/loader/types.d.ts.map +1 -0
  62. package/dist/io/loader/watch.d.ts +36 -0
  63. package/dist/io/loader/watch.d.ts.map +1 -0
  64. package/dist/io/loader.node.d.ts +1 -13
  65. package/dist/io/loader.node.d.ts.map +1 -1
  66. package/dist/lsp/hover-constants.d.ts +42 -0
  67. package/dist/lsp/hover-constants.d.ts.map +1 -0
  68. package/dist/lsp/server.bundle.d.ts +2 -0
  69. package/dist/lsp/server.bundle.d.ts.map +1 -0
  70. package/dist/node/index.js +183 -170
  71. package/dist/node/index.js.map +116 -91
  72. package/dist/node/node.js +183 -171
  73. package/dist/node/node.js.map +118 -93
  74. package/dist/sdk/builder.d.ts +177 -21
  75. package/dist/sdk/builder.d.ts.map +1 -1
  76. package/dist/sdk/builders/action-builder.d.ts +24 -0
  77. package/dist/sdk/builders/action-builder.d.ts.map +1 -0
  78. package/dist/sdk/builders/condition-builder.d.ts +26 -0
  79. package/dist/sdk/builders/condition-builder.d.ts.map +1 -0
  80. package/dist/sdk/builders/index.d.ts +5 -0
  81. package/dist/sdk/builders/index.d.ts.map +1 -0
  82. package/dist/sdk/builders/params-builder.d.ts +59 -0
  83. package/dist/sdk/builders/params-builder.d.ts.map +1 -0
  84. package/dist/sdk/constants.d.ts +44 -0
  85. package/dist/sdk/constants.d.ts.map +1 -0
  86. package/dist/sdk/exporter.d.ts +16 -0
  87. package/dist/sdk/exporter.d.ts.map +1 -1
  88. package/dist/sdk/graph/action-resolver.d.ts +103 -0
  89. package/dist/sdk/graph/action-resolver.d.ts.map +1 -0
  90. package/dist/sdk/graph/condition-resolver.d.ts +87 -0
  91. package/dist/sdk/graph/condition-resolver.d.ts.map +1 -0
  92. package/dist/sdk/graph/converters.d.ts +152 -0
  93. package/dist/sdk/graph/converters.d.ts.map +1 -0
  94. package/dist/sdk/graph/index.d.ts +12 -0
  95. package/dist/sdk/graph/index.d.ts.map +1 -0
  96. package/dist/sdk/graph/node-filters.d.ts +96 -0
  97. package/dist/sdk/graph/node-filters.d.ts.map +1 -0
  98. package/dist/sdk/graph/traversal.d.ts +105 -0
  99. package/dist/sdk/graph/traversal.d.ts.map +1 -0
  100. package/dist/sdk/graph/types.d.ts +28 -0
  101. package/dist/sdk/graph/types.d.ts.map +1 -0
  102. package/dist/sdk/graph-parser.d.ts +40 -0
  103. package/dist/sdk/graph-parser.d.ts.map +1 -0
  104. package/dist/sdk/index.d.ts +3 -0
  105. package/dist/sdk/index.d.ts.map +1 -1
  106. package/dist/sdk/optimize.d.ts +27 -0
  107. package/dist/sdk/optimize.d.ts.map +1 -0
  108. package/dist/sdk/yaml/converter.d.ts +81 -0
  109. package/dist/sdk/yaml/converter.d.ts.map +1 -0
  110. package/dist/sdk/yaml/index.d.ts +39 -0
  111. package/dist/sdk/yaml/index.d.ts.map +1 -0
  112. package/dist/sdk/yaml/normalizer.d.ts +44 -0
  113. package/dist/sdk/yaml/normalizer.d.ts.map +1 -0
  114. package/dist/sdk/yaml/types.d.ts +198 -0
  115. package/dist/sdk/yaml/types.d.ts.map +1 -0
  116. package/dist/sdk/yaml/utils.d.ts +131 -0
  117. package/dist/sdk/yaml/utils.d.ts.map +1 -0
  118. package/dist/sdk/yaml-parser.d.ts +18 -0
  119. package/dist/sdk/yaml-parser.d.ts.map +1 -0
  120. package/dist/types.d.ts +40 -2
  121. package/dist/types.d.ts.map +1 -1
  122. package/dist/utils/utils.d.ts.map +1 -1
  123. package/package.json +6 -1
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Graph Converters - Interfaces for data transformation
3
+ * Provides interfaces for converting between graph data and rule structures
4
+ */
5
+ import type { SDKGraphNode, SDKGraphEdge, TriggerRule, RuleCondition, Action, ComparisonOperator } from '../../types';
6
+ /**
7
+ * Data transformation options
8
+ */
9
+ export interface TransformOptions {
10
+ /** Enable debug logging */
11
+ debug?: boolean;
12
+ /** Strict mode - throw on errors */
13
+ strict?: boolean;
14
+ }
15
+ /**
16
+ * Base converter interface for node data transformation
17
+ */
18
+ export interface INodeConverter<TNodeData, TOutput> {
19
+ /** Convert node data to output format */
20
+ convert(nodeData: TNodeData, context: ConverterContext): TOutput;
21
+ /** Validate the input data */
22
+ validate?(nodeData: TNodeData): ValidationResult;
23
+ }
24
+ /**
25
+ * Validation result
26
+ */
27
+ export interface ValidationResult {
28
+ valid: boolean;
29
+ errors?: string[];
30
+ warnings?: string[];
31
+ }
32
+ /**
33
+ * Context passed to converters
34
+ */
35
+ export interface ConverterContext {
36
+ /** All nodes in the graph */
37
+ nodes: SDKGraphNode[];
38
+ /** All edges in the graph */
39
+ edges: SDKGraphEdge[];
40
+ /** Current node being processed */
41
+ currentNode?: SDKGraphNode;
42
+ /** Additional metadata */
43
+ metadata?: Record<string, unknown>;
44
+ /** Options for transformation */
45
+ options?: TransformOptions;
46
+ }
47
+ /**
48
+ * Condition data from a graph node
49
+ */
50
+ export interface ConditionNodeData {
51
+ field?: string;
52
+ operator?: ComparisonOperator;
53
+ value?: unknown;
54
+ }
55
+ /**
56
+ * Action data from a graph node
57
+ */
58
+ export interface ActionNodeData {
59
+ type?: string;
60
+ params?: Record<string, unknown> | string;
61
+ delay?: number;
62
+ probability?: number;
63
+ }
64
+ /**
65
+ * Event data from a graph node
66
+ */
67
+ export interface EventNodeData {
68
+ id?: string;
69
+ name?: string;
70
+ description?: string;
71
+ event?: string;
72
+ priority?: number | string;
73
+ enabled?: boolean;
74
+ cooldown?: number | string;
75
+ tags?: string[];
76
+ }
77
+ /**
78
+ * Condition group data
79
+ */
80
+ export interface ConditionGroupData {
81
+ operator?: 'AND' | 'OR';
82
+ }
83
+ /**
84
+ * Action group data
85
+ */
86
+ export interface ActionGroupData {
87
+ mode?: 'ALL' | 'FIRST' | 'RANDOM';
88
+ }
89
+ /**
90
+ * DO node data
91
+ */
92
+ export interface DoNodeData {
93
+ branchType?: 'do' | 'else';
94
+ }
95
+ /**
96
+ * Condition converter - converts condition nodes to RuleCondition
97
+ */
98
+ export declare class ConditionConverter implements INodeConverter<ConditionNodeData, RuleCondition> {
99
+ convert(nodeData: ConditionNodeData, _context: ConverterContext): RuleCondition;
100
+ validate(nodeData: ConditionNodeData): ValidationResult;
101
+ }
102
+ /**
103
+ * Action converter - converts action nodes to Action
104
+ */
105
+ export declare class ActionConverter implements INodeConverter<ActionNodeData, Action> {
106
+ convert(nodeData: ActionNodeData, _context: ConverterContext): Action;
107
+ validate(nodeData: ActionNodeData): ValidationResult;
108
+ }
109
+ /**
110
+ * Event converter - converts event nodes to TriggerRule metadata
111
+ */
112
+ export declare class EventConverter implements INodeConverter<EventNodeData, Partial<TriggerRule>> {
113
+ convert(nodeData: EventNodeData, _context: ConverterContext): Partial<TriggerRule>;
114
+ validate(nodeData: EventNodeData): ValidationResult;
115
+ }
116
+ /**
117
+ * Factory for creating converters
118
+ */
119
+ export declare class ConverterFactory {
120
+ private conditionConverter;
121
+ private actionConverter;
122
+ private eventConverter;
123
+ /** Get condition converter */
124
+ getConditionConverter(): ConditionConverter;
125
+ /** Get action converter */
126
+ getActionConverter(): ActionConverter;
127
+ /** Get event converter */
128
+ getEventConverter(): EventConverter;
129
+ /** Create converter context */
130
+ createContext(nodes: SDKGraphNode[], edges: SDKGraphEdge[], currentNode?: SDKGraphNode, options?: TransformOptions): ConverterContext;
131
+ }
132
+ /**
133
+ * Default converter factory instance
134
+ */
135
+ export declare const converterFactory: ConverterFactory;
136
+ /**
137
+ * Convert action params from string to object
138
+ */
139
+ export declare function parseActionParams(params: Record<string, unknown> | string | undefined): Record<string, unknown>;
140
+ /**
141
+ * Convert node data to condition
142
+ */
143
+ export declare function nodeToCondition(node: SDKGraphNode): RuleCondition;
144
+ /**
145
+ * Convert node data to action
146
+ */
147
+ export declare function nodeToAction(node: SDKGraphNode): Action;
148
+ /**
149
+ * Convert node data to event data
150
+ */
151
+ export declare function nodeToEventData(node: SDKGraphNode): Partial<TriggerRule>;
152
+ //# sourceMappingURL=converters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/sdk/graph/converters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,MAAM,EAGN,kBAAkB,EAGnB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,SAAS,EAAE,OAAO;IAChD,yCAAyC;IACzC,OAAO,CAAC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ChD,OAAO,CAAC,cAAc,CAAwB;IAE9C,8BAA8B;IAC9B,qBAAqB,IAAI,kBAAkB;IAI3C,2BAA2B;IAC3B,kBAAkB,IAAI,eAAe;IAIrC,0BAA0B;IAC1B,iBAAiB,IAAI,cAAc;IAInC,+BAA+B;IAC/B,aAAa,CACX,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,YAAY,EAAE,EACrB,WAAW,CAAC,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,gBAAgB;CAGpB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,kBAAyB,CAAC;AAEvD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,GACnD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,aAAa,CAGjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAGvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAGxE"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Graph Utilities Index
3
+ * Re-exports all graph-related utilities for easy importing
4
+ */
5
+ export { NodeFilter, createNodeFilterConfig, defaultIsEventNode, defaultIsDoNode, isConditionGroup, isActionGroup, getDoBranchType, isElseBranch, isDoBranch, extractEventData, type NodePredicate, type NodeFilterConfig } from './node-filters';
6
+ export { defaultIsCondNode, defaultIsActNode } from './node-filters';
7
+ export * from './traversal';
8
+ export * from './converters';
9
+ export { ConditionResolver, collectConditionsForGroup, resolveCondition, findTerminalConditions, type ConditionResolverContext, type ConditionTransformer, type CollectedConditions, type TerminalActions } from './condition-resolver';
10
+ export { ActionResolver, collectActionsForGroup, resolveAction, categorizeDoNodesByBranch, type ActionResolverContext, type ActionResolverOptions, type ActionTransformer, type CollectedActions, type DoBranches } from './action-resolver';
11
+ export type { GraphResolverContextBase } from './condition-resolver';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/graph/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGrE,cAAc,aAAa,CAAC;AAG5B,cAAc,cAAc,CAAC;AAG7B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,aAAa,EACb,yBAAyB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Node Filters - Type checking utilities for graph nodes
3
+ * Provides centralized node type detection for the graph parser
4
+ */
5
+ import { BranchType } from '../constants';
6
+ import type { SDKGraphNode, TriggerRule } from '../../types';
7
+ /**
8
+ * Type predicates for node classification
9
+ */
10
+ export type NodePredicate = (node: SDKGraphNode) => boolean;
11
+ /**
12
+ * Configuration for node type detection
13
+ */
14
+ export interface NodeFilterConfig {
15
+ /** Custom predicate for event nodes */
16
+ isEventNode?: NodePredicate;
17
+ /** Custom predicate for condition nodes */
18
+ isCondNode?: NodePredicate;
19
+ /** Custom predicate for action nodes */
20
+ isActNode?: NodePredicate;
21
+ /** Custom function to extract event data */
22
+ extractEventData?: (node: SDKGraphNode) => Partial<TriggerRule>;
23
+ }
24
+ /**
25
+ * Default event node detector
26
+ */
27
+ export declare const defaultIsEventNode: NodePredicate;
28
+ /**
29
+ * Default condition node detector (single condition or condition group)
30
+ */
31
+ export declare const defaultIsCondNode: NodePredicate;
32
+ /**
33
+ * Default action node detector (single action, action group, or DO node)
34
+ */
35
+ export declare const defaultIsActNode: NodePredicate;
36
+ /**
37
+ * Default DO node detector
38
+ */
39
+ export declare const defaultIsDoNode: NodePredicate;
40
+ /**
41
+ * Check if a node is a condition group
42
+ */
43
+ export declare const isConditionGroup: (node: SDKGraphNode) => boolean;
44
+ /**
45
+ * Check if a node is an action group
46
+ */
47
+ export declare const isActionGroup: (node: SDKGraphNode) => boolean;
48
+ /**
49
+ * Get the branch type for a DO node
50
+ */
51
+ export declare const getDoBranchType: (node: SDKGraphNode) => BranchType;
52
+ /**
53
+ * Check if a DO node is an else branch
54
+ */
55
+ export declare const isElseBranch: (node: SDKGraphNode) => boolean;
56
+ /**
57
+ * Check if a DO node is a do branch (then path)
58
+ */
59
+ export declare const isDoBranch: (node: SDKGraphNode) => boolean;
60
+ /**
61
+ * Default event data extractor
62
+ */
63
+ export declare function extractEventData(node: SDKGraphNode): Partial<TriggerRule>;
64
+ /**
65
+ * Create a filter configuration with defaults
66
+ */
67
+ export declare function createNodeFilterConfig(overrides?: NodeFilterConfig): Required<NodeFilterConfig>;
68
+ /**
69
+ * NodeFilter class - Fluent interface for node type checking
70
+ */
71
+ export declare class NodeFilter {
72
+ private _isEvent;
73
+ private _isCond;
74
+ private _isAct;
75
+ private _extractEvent;
76
+ constructor(config?: NodeFilterConfig);
77
+ /** Check if node is an event */
78
+ isEvent(node: SDKGraphNode): boolean;
79
+ /** Check if node is a condition (single or group) */
80
+ isCondition(node: SDKGraphNode): boolean;
81
+ /** Check if node is an action (single or group or DO) */
82
+ isAction(node: SDKGraphNode): boolean;
83
+ /** Check if node is a DO node */
84
+ isDo(node: SDKGraphNode): boolean;
85
+ /** Extract event data from node */
86
+ extractEvent(node: SDKGraphNode): Partial<TriggerRule>;
87
+ /** Set custom event node predicate */
88
+ withEventPredicate(predicate: NodePredicate): this;
89
+ /** Set custom condition node predicate */
90
+ withConditionPredicate(predicate: NodePredicate): this;
91
+ /** Set custom action node predicate */
92
+ withActionPredicate(predicate: NodePredicate): this;
93
+ /** Set custom event data extractor */
94
+ withEventExtractor(extractor: (node: SDKGraphNode) => Partial<TriggerRule>): this;
95
+ }
96
+ //# sourceMappingURL=node-filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-filters.d.ts","sourceRoot":"","sources":["../../../src/sdk/graph/node-filters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,UAAU,EAAY,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,2CAA2C;IAC3C,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,wCAAwC;IACxC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,aACN,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM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AW,CAAC;IAItD,sCAAsC;IACtC,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAKlD,0CAA0C;IAC1C,sBAAsB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAKtD,uCAAuC;IACvC,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAKnD,sCAAsC;IACtC,kBAAkB,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI;CAIlF"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Graph Traversal Utilities
3
+ * Provides utilities for traversing and finding nodes in the graph
4
+ */
5
+ import type { SDKGraphNode, SDKGraphEdge } from '../../types';
6
+ /**
7
+ * Context for graph traversal operations
8
+ */
9
+ export interface GraphTraversalContext {
10
+ nodes: SDKGraphNode[];
11
+ edges: SDKGraphEdge[];
12
+ }
13
+ /** Type for handle arrays - accepts both mutable and readonly */
14
+ export type HandleArray = readonly string[] | string[];
15
+ /**
16
+ * Find a node by ID in the context
17
+ */
18
+ export declare function findNodeById(ctx: GraphTraversalContext, nodeId: string): SDKGraphNode | undefined;
19
+ /**
20
+ * Find edges matching a specific source node and handle
21
+ */
22
+ export declare function findEdgesBySource(ctx: GraphTraversalContext, sourceId: string, handles: HandleArray): SDKGraphEdge[];
23
+ /**
24
+ * Find edges matching a specific target node
25
+ */
26
+ export declare function findEdgesByTarget(ctx: GraphTraversalContext, targetId: string): SDKGraphEdge[];
27
+ /**
28
+ * Find all nodes connected from a source node via specific handles
29
+ */
30
+ export declare function findConnectedNodeIds(ctx: GraphTraversalContext, sourceId: string, handles: HandleArray): string[];
31
+ /**
32
+ * Find all nodes of a specific type connected from a source node
33
+ */
34
+ export declare function findConnectedNodes<T extends SDKGraphNode>(ctx: GraphTraversalContext, sourceId: string, handles: HandleArray, typeFilter: (node: SDKGraphNode) => boolean): T[];
35
+ /**
36
+ * Find nodes directly connected to a source node (any handle)
37
+ */
38
+ export declare function findDirectSuccessors(ctx: GraphTraversalContext, sourceId: string): SDKGraphNode[];
39
+ /**
40
+ * Find nodes that connect to a target node
41
+ */
42
+ export declare function findDirectPredecessors(ctx: GraphTraversalContext, targetId: string): SDKGraphNode[];
43
+ /**
44
+ * Get all outgoing edges from a node
45
+ */
46
+ export declare function getOutgoingEdges(ctx: GraphTraversalContext, nodeId: string): SDKGraphEdge[];
47
+ /**
48
+ * Get all incoming edges to a node
49
+ */
50
+ export declare function getIncomingEdges(ctx: GraphTraversalContext, nodeId: string): SDKGraphEdge[];
51
+ /**
52
+ * Get connected edges with optional handle filtering
53
+ */
54
+ export declare function getConnectedEdges(ctx: GraphTraversalContext, nodeId: string, options?: {
55
+ direction?: 'outgoing' | 'incoming' | 'both';
56
+ sourceHandles?: HandleArray;
57
+ targetHandles?: HandleArray;
58
+ }): SDKGraphEdge[];
59
+ /**
60
+ * Common handle arrays for graph traversal
61
+ */
62
+ export declare const HandleFilters: {
63
+ /** All condition output handles (for chaining conditions) */
64
+ readonly CONDITION_OUTPUT: readonly ["output", "condition-output"];
65
+ /** All action output handles */
66
+ readonly ACTION_OUTPUT: readonly ["action-output", "action-group-output"];
67
+ /** All DO output handles */
68
+ readonly DO_OUTPUT: readonly ["do-output", ""];
69
+ /** Then/else outputs from conditions (for terminal actions) */
70
+ readonly THEN_ELSE: readonly ["then-output", "else-output"];
71
+ /** DO condition output for inline conditionals */
72
+ readonly DO_CONDITION: readonly ["do-condition-output"];
73
+ /** All condition/thence outputs - includes then-output for condition→action_group */
74
+ readonly CONDITION_CHAIN: readonly ["output", "condition-output", "then-output", "else-output"];
75
+ /** Any output handle */
76
+ readonly ANY: readonly ["output", "condition-output", ""];
77
+ };
78
+ /**
79
+ * GraphTraversal class - Fluent interface for graph traversal
80
+ */
81
+ export declare class GraphTraversal {
82
+ private ctx;
83
+ constructor(nodes: SDKGraphNode[], edges: SDKGraphEdge[]);
84
+ /** Find a node by ID */
85
+ node(id: string): SDKGraphNode | undefined;
86
+ /** Get outgoing edges from a node */
87
+ outgoing(nodeId: string): SDKGraphEdge[];
88
+ /** Get incoming edges to a node */
89
+ incoming(nodeId: string): SDKGraphEdge[];
90
+ /** Get connected edges with filtering */
91
+ connected(nodeId: string, options?: {
92
+ direction?: 'outgoing' | 'incoming' | 'both';
93
+ sourceHandles?: string[];
94
+ targetHandles?: string[];
95
+ }): SDKGraphEdge[];
96
+ /** Find connected node IDs by handles */
97
+ successors(nodeId: string, handles: HandleArray): string[];
98
+ /** Find connected nodes by type filter */
99
+ find<T extends SDKGraphNode>(sourceId: string, handles: HandleArray, typeFilter: (node: SDKGraphNode) => boolean): T[];
100
+ /** Get direct successors (any handle) */
101
+ directSuccessors(nodeId: string): SDKGraphNode[];
102
+ /** Get direct predecessors */
103
+ directPredecessors(nodeId: string): SDKGraphNode[];
104
+ }
105
+ //# sourceMappingURL=traversal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../../../src/sdk/graph/traversal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;AAEvD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,qBAAqB,EAC1B,MAAM,EAAE,MAAM,GACb,YAAY,GAAG,SAAS,CAE1B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GACnB,YAAY,EAAE,CAMhB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG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D,kDAAkD;;IAGlD,qFAAqF;;IAGrF,wBAAwB;;CAEhB,CAAC;AAEX;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAwB;gBAEvB,KAAK,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;IAIxD,wBAAwB;IACxB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAI1C,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE;IAIxC,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE;IAIxC,yCAAyC;IACzC,SAAS,CACP,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;QAC7C,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;QACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,GACL,YAAY,EAAE;IAIjB,yCAAyC;IACzC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,MAAM,EAAE;IAI1D,0CAA0C;IAC1C,IAAI,CAAC,CAAC,SAAS,YAAY,EACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,GAC1C,CAAC,EAAE;IAIN,yCAAyC;IACzC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE;IAIhD,8BAA8B;IAC9B,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE;CAGnD"}
@@ -0,0 +1,28 @@
1
+ import type { TriggerRule, RuleCondition, Action, ActionGroup, SDKGraphNode, SDKGraphEdge } from '../../types';
2
+ import type { OptimizeOptions } from '../builder';
3
+ export interface GraphParserOptions {
4
+ isEventNode?: (n: SDKGraphNode) => boolean;
5
+ isCondNode?: (n: SDKGraphNode) => boolean;
6
+ isActNode?: (n: SDKGraphNode) => boolean;
7
+ extractEventData?: (n: SDKGraphNode) => Partial<TriggerRule>;
8
+ resolveCondition?: (id: string, ctx: GraphParserContext) => RuleCondition | null;
9
+ resolveAction?: (id: string, ctx: GraphParserContext) => Action | ActionGroup | null;
10
+ /**
11
+ * Options to control deduplication behavior.
12
+ * Use this to keep intentional duplicates (for templates) or use uniqueIdField
13
+ * to differentiate items that should not be merged.
14
+ */
15
+ optimizeOptions?: OptimizeOptions;
16
+ }
17
+ export interface GraphParserContext {
18
+ nodes: SDKGraphNode[];
19
+ edges: SDKGraphEdge[];
20
+ visitedConds?: Set<string>;
21
+ visitedActs?: Set<string>;
22
+ options: GraphParserOptions;
23
+ transformers?: {
24
+ condition?: (cond: RuleCondition, node: SDKGraphNode) => RuleCondition | null;
25
+ action?: (act: Action | ActionGroup, node: SDKGraphNode) => Action | ActionGroup | null;
26
+ };
27
+ }
28
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sdk/graph/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,MAAM,EACN,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC;IAC1C,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC;IACzC,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7D,gBAAgB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,KAAK,aAAa,GAAG,IAAI,CAAC;IACjF,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,kBAAkB,KAAK,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACrF;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,KAAK,aAAa,GAAG,IAAI,CAAC;QAC9E,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,IAAI,EAAE,YAAY,KAAK,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;KACzF,CAAA;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Graph Parser - Main entry point for parsing graph structures into rules
3
+ * This module coordinates the conversion of SDKGraphNode/SDKGraphEdge to TriggerRule
4
+ */
5
+ import { RuleBuilder } from './builder';
6
+ import { BranchType } from './constants';
7
+ import type { TriggerRule, Action, ActionGroup, SDKGraphNode, SDKGraphEdge, InlineConditionalAction } from '../types';
8
+ import { extractEventData } from './graph';
9
+ import type { GraphParserOptions, GraphParserContext } from './graph/types';
10
+ export type { GraphParserOptions, GraphParserContext } from './graph/types';
11
+ export declare function createParserContext(nodes: SDKGraphNode[], edges: SDKGraphEdge[], options?: GraphParserOptions, transformers?: GraphParserContext['transformers']): GraphParserContext;
12
+ export declare const defaultGetDoBranchType: (node: SDKGraphNode) => BranchType;
13
+ export declare const defaultExtractEventData: typeof extractEventData;
14
+ /**
15
+ * Collect all actions from a DO node, including:
16
+ * - Direct actions via do-output
17
+ * - Inline conditionals via do-condition-output
18
+ * Returns an array of actions that should be executed in order (mode: ALL)
19
+ */
20
+ export declare function collectDoActions(doNodeId: string, ctx: GraphParserContext, sourceConditionId?: string): (Action | ActionGroup | InlineConditionalAction)[];
21
+ /**
22
+ * Find the terminal condition(s) in a condition chain (where actions connect).
23
+ * Returns then/else action IDs.
24
+ */
25
+ export declare function findTerminalActions(startConditionId: string, ctx: GraphParserContext): {
26
+ thenActionId?: string;
27
+ elseActionId?: string;
28
+ };
29
+ export declare function parseGraph(nodes: SDKGraphNode[], edges: SDKGraphEdge[], options?: GraphParserOptions, transformers?: GraphParserContext['transformers']): RuleBuilder;
30
+ /**
31
+ * Parse a graph with multiple event nodes and return multiple rules.
32
+ * This allows editing multiple rules in a single editor view.
33
+ *
34
+ * Each Event node in the graph becomes a separate TriggerRule.
35
+ */
36
+ export declare function parseGraphToRules(nodes: SDKGraphNode[], edges: SDKGraphEdge[], options?: GraphParserOptions, transformers?: GraphParserContext['transformers']): {
37
+ rules: TriggerRule[];
38
+ errors: string[];
39
+ };
40
+ //# sourceMappingURL=graph-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-parser.d.ts","sourceRoot":"","sources":["../../src/sdk/graph-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAY,UAAU,EAAY,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAML,gBAAgB,EAQjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,kBAAkB,EAAC,kBAAkB,EAAE,MAAM,eAAe,CA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
+ export * from "./graph-parser";
5
+ export * from "./constants";
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { RuleCondition, Action, ActionGroup } from "../types";
2
+ /**
3
+ * Options for controlling deduplication behavior.
4
+ */
5
+ export interface OptimizeOptions {
6
+ /**
7
+ * Whether to deduplicate conditions/actions.
8
+ * Default: true (for conditions), false (for actions) - backward compatible
9
+ * Set to false to keep all duplicates (useful for templates where repetition is intentional)
10
+ */
11
+ deduplicate?: boolean;
12
+ /**
13
+ * Unique identifier field to use for comparing items.
14
+ * If provided, items with different IDs are considered different even if other fields match.
15
+ * This allows intentional duplicates (same content, different IDs) to be preserved.
16
+ */
17
+ uniqueIdField?: string;
18
+ }
19
+ /**
20
+ * Optimize conditions by deduplicating and flattening nested groups.
21
+ */
22
+ export declare function optimizeCondition(cond: RuleCondition | RuleCondition[], options?: OptimizeOptions): RuleCondition | RuleCondition[] | undefined;
23
+ /**
24
+ * Optimize actions by deduplicating and flattening nested groups.
25
+ */
26
+ export declare function optimizeAction(act: Action | ActionGroup | (Action | ActionGroup)[], options?: OptimizeOptions): Action | ActionGroup | (Action | ActionGroup)[] | undefined;
27
+ //# sourceMappingURL=optimize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimize.d.ts","sourceRoot":"","sources":["../../src/sdk/optimize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AA6BD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,aAAa,GAAG,aAAa,EAAE,EACrC,OAAO,GAAE,eAAoB,GAC5B,aAAa,GAAG,aAAa,EAAE,GAAG,SAAS,CAqD7C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,EACpD,OAAO,GAAE,eAAoB,GAC5B,MAAM,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,EAAE,GAAG,SAAS,CAwF7D"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * YAML to Editor Node/Edge Converter
3
+ *
4
+ * This module converts TriggerRule objects to React Flow editor nodes and edges.
5
+ * It supports all node types including:
6
+ * - Event nodes
7
+ * - Condition nodes (including groups)
8
+ * - Action nodes (including inline conditionals)
9
+ * - Action groups
10
+ * - DO nodes (for graph-based representation)
11
+ */
12
+ import type { TriggerRule, Action, ExecutionMode, InlineConditionalAction } from '../../types';
13
+ import type { EditorNode, EditorEdge, TriggerRuleToNodesResult } from './types';
14
+ /**
15
+ * Build an Event node from TriggerRule
16
+ */
17
+ export declare function buildEventNode(rule: TriggerRule, nodeId: string, position: {
18
+ x: number;
19
+ y: number;
20
+ }): EditorNode;
21
+ /**
22
+ * Build a Condition Group node
23
+ */
24
+ export declare function buildConditionGroupNode(operator: 'AND' | 'OR', nodeId: string, position: {
25
+ x: number;
26
+ y: number;
27
+ }): EditorNode;
28
+ /**
29
+ * Build a single Condition node
30
+ */
31
+ export declare function buildConditionNode(field: string, operator: string, value: unknown, nodeId: string, position: {
32
+ x: number;
33
+ y: number;
34
+ }): EditorNode;
35
+ /**
36
+ * Build a DO node (for inline conditionals in graph)
37
+ */
38
+ export declare function buildDoNode(branchType: 'do' | 'else', nodeId: string, position: {
39
+ x: number;
40
+ y: number;
41
+ }): EditorNode;
42
+ /**
43
+ * Build an Action node
44
+ */
45
+ export declare function buildActionNode(action: Action | InlineConditionalAction, nodeId: string, position: {
46
+ x: number;
47
+ y: number;
48
+ }): EditorNode;
49
+ /**
50
+ * Build an Action Group node
51
+ */
52
+ export declare function buildActionGroupNode(mode: ExecutionMode, nodeId: string, position: {
53
+ x: number;
54
+ y: number;
55
+ }): EditorNode;
56
+ /**
57
+ * Build an edge between two nodes
58
+ */
59
+ export declare function buildEdge(source: string, target: string, sourceHandle?: string | null, targetHandle?: string | null, edgeIdGenerator?: () => string): EditorEdge;
60
+ /**
61
+ * Convert a TriggerRule to editor nodes and edges
62
+ */
63
+ export declare function triggerRuleToNodes(rule: TriggerRule, options?: {
64
+ startNodeId?: string;
65
+ startPosition?: {
66
+ x: number;
67
+ y: number;
68
+ };
69
+ }): TriggerRuleToNodesResult;
70
+ declare const _default: {
71
+ triggerRuleToNodes: typeof triggerRuleToNodes;
72
+ buildEventNode: typeof buildEventNode;
73
+ buildConditionGroupNode: typeof buildConditionGroupNode;
74
+ buildConditionNode: typeof buildConditionNode;
75
+ buildDoNode: typeof buildDoNode;
76
+ buildActionNode: typeof buildActionNode;
77
+ buildActionGroupNode: typeof buildActionGroupNode;
78
+ buildEdge: typeof buildEdge;
79
+ };
80
+ export default _default;
81
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../../src/sdk/yaml/converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EAGN,aAAa,EACb,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAEV,wBAAwB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G;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,EAC5B,eAAe,CAAC,EAAE,MAAM,MAAM,GAC7B,UAAU,CAQZ;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACrC,GACL,wBAAwB,CA0H1B;;;;;;;;;;;AAsUD,wBASE"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * YAML Parser Module
3
+ *
4
+ * This is the main entry point for the modularized YAML parser.
5
+ * It provides:
6
+ * - Type definitions (types.ts)
7
+ * - Utility functions (utils.ts)
8
+ * - Rule normalization (normalizer.ts)
9
+ * - Node/edge conversion (converter.ts)
10
+ *
11
+ * Re-exports from the main yaml-parser.ts for backward compatibility.
12
+ */
13
+ import type { TriggerRule } from '../../types';
14
+ import type { YamlParserOptions, YamlParserResult } from './types';
15
+ export type { YamlParserOptions, YamlParserResult, YamlParserError, EditorNodeType, EditorNode, EditorEdge, TriggerRuleToNodesResult, RawCondition, RawAction, RawRule } from './types';
16
+ export type { ComparisonOperator, ExecutionMode } from '../../types';
17
+ export { isObject, isNonEmptyString, isValidNumber, isBoolean, isConditionGroup, isSimpleCondition, isActionGroup, hasConditionalExecution, isSimpleAction, isValidExecutionMode, isValidConditionOperator, isValidComparisonOperator, getActionType, getActionParams, getConditionField, getConditionOperator, getConditionValue, createNodeIdGenerator, createEdgeIdGenerator, createPositionCalculator, ensureArray, normalizeActions, normalizeConditions as normalizeConditionsUtils, generateRuleIdFromFilename, normalizeOperator, requireField, validateFieldType, validateFieldValue } from './utils';
18
+ export { normalizeRule, normalizeConditions, normalizeDoField, normalizeElseField, normalizeAction, normalizeRuleAdvanced, validateRule } from './normalizer';
19
+ export { triggerRuleToNodes, buildEventNode, buildConditionGroupNode, buildConditionNode, buildDoNode, buildActionNode, buildActionGroupNode, buildEdge } from './converter';
20
+ /**
21
+ * Parse a YAML string into TriggerRule objects
22
+ */
23
+ export declare function parseYamlRules(yamlContent: string, options?: {
24
+ autoId?: boolean | string;
25
+ filename?: string;
26
+ throwOnError?: boolean;
27
+ multiDocument?: boolean;
28
+ }): YamlParserResult;
29
+ /**
30
+ * Parse a single YAML document (not multi-document)
31
+ * Shorthand for parseYamlRules with multiDocument: false
32
+ */
33
+ export declare function parseYamlRule(yamlContent: string, options?: Omit<YamlParserOptions, 'multiDocument'>): YamlParserResult;
34
+ /**
35
+ * Parse YAML and return the first valid rule
36
+ * Throws if there are errors or no rules
37
+ */
38
+ export declare function parseYamlRuleStrict(yamlContent: string, options?: Omit<YamlParserOptions, 'throwOnError'>): TriggerRule;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk/yaml/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAyE,MAAM,aAAa,CAAC;AAItH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAMpF,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EACV,wBAAwB,EACxB,YAAY,EACZ,SAAS,EACT,OAAO,EACR,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,cAAc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