@huanban/rulego-editor-core 1.0.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 +211 -0
- package/dist/api/RuleChainAPI.d.ts +163 -0
- package/dist/api/RuleChainAPI.d.ts.map +1 -0
- package/dist/api/index.d.ts +15 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/types.d.ts +244 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/core/ComponentRegistry.d.ts +141 -0
- package/dist/core/ComponentRegistry.d.ts.map +1 -0
- package/dist/core/DataAdapter.d.ts +129 -0
- package/dist/core/DataAdapter.d.ts.map +1 -0
- package/dist/core/EditorCore.d.ts +251 -0
- package/dist/core/EditorCore.d.ts.map +1 -0
- package/dist/core/EventBus.d.ts +101 -0
- package/dist/core/EventBus.d.ts.map +1 -0
- package/dist/core/HistoryManager.d.ts +166 -0
- package/dist/core/HistoryManager.d.ts.map +1 -0
- package/dist/core/I18nManager.d.ts +130 -0
- package/dist/core/I18nManager.d.ts.map +1 -0
- package/dist/core/StateStore.d.ts +160 -0
- package/dist/core/StateStore.d.ts.map +1 -0
- package/dist/core/ThemeManager.d.ts +175 -0
- package/dist/core/ThemeManager.d.ts.map +1 -0
- package/dist/core/ValidationEngine.d.ts +139 -0
- package/dist/core/ValidationEngine.d.ts.map +1 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/defaults/components.d.ts +30 -0
- package/dist/defaults/components.d.ts.map +1 -0
- package/dist/defaults/index.d.ts +18 -0
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/defaults/locale-en-US.d.ts +26 -0
- package/dist/defaults/locale-en-US.d.ts.map +1 -0
- package/dist/defaults/locale-zh-CN.d.ts +41 -0
- package/dist/defaults/locale-zh-CN.d.ts.map +1 -0
- package/dist/iconRegistry.d.ts +17 -0
- package/dist/iconRegistry.d.ts.map +1 -0
- package/dist/index.cjs.js +2490 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +59608 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.umd.js +2490 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/standalone/HuanbanRulegoEditor.d.ts +392 -0
- package/dist/standalone/HuanbanRulegoEditor.d.ts.map +1 -0
- package/dist/standalone/code-editor.d.ts +95 -0
- package/dist/standalone/code-editor.d.ts.map +1 -0
- package/dist/standalone/custom-nodes.d.ts +26 -0
- package/dist/standalone/custom-nodes.d.ts.map +1 -0
- package/dist/standalone/editor-chain-info.d.ts +46 -0
- package/dist/standalone/editor-chain-info.d.ts.map +1 -0
- package/dist/standalone/editor-context-menu.d.ts +21 -0
- package/dist/standalone/editor-context-menu.d.ts.map +1 -0
- package/dist/standalone/editor-debug-ws.d.ts +170 -0
- package/dist/standalone/editor-debug-ws.d.ts.map +1 -0
- package/dist/standalone/editor-dialogs.d.ts +73 -0
- package/dist/standalone/editor-dialogs.d.ts.map +1 -0
- package/dist/standalone/editor-events.d.ts +28 -0
- package/dist/standalone/editor-events.d.ts.map +1 -0
- package/dist/standalone/editor-property-drawers.d.ts +78 -0
- package/dist/standalone/editor-property-drawers.d.ts.map +1 -0
- package/dist/standalone/editor-route-settings.d.ts +49 -0
- package/dist/standalone/editor-route-settings.d.ts.map +1 -0
- package/dist/standalone/editor-sidebar.d.ts +19 -0
- package/dist/standalone/editor-sidebar.d.ts.map +1 -0
- package/dist/standalone/editor-styles.d.ts +12 -0
- package/dist/standalone/editor-styles.d.ts.map +1 -0
- package/dist/standalone/editor-toolbar.d.ts +89 -0
- package/dist/standalone/editor-toolbar.d.ts.map +1 -0
- package/dist/standalone/group-node.d.ts +52 -0
- package/dist/standalone/group-node.d.ts.map +1 -0
- package/dist/standalone/icon-utils.d.ts +19 -0
- package/dist/standalone/icon-utils.d.ts.map +1 -0
- package/dist/standalone/index.d.ts +9 -0
- package/dist/standalone/index.d.ts.map +1 -0
- package/dist/standalone/logger.d.ts +35 -0
- package/dist/standalone/logger.d.ts.map +1 -0
- package/dist/standalone/node-definitions.d.ts +74 -0
- package/dist/standalone/node-definitions.d.ts.map +1 -0
- package/dist/standalone/node-views-data.d.ts +21 -0
- package/dist/standalone/node-views-data.d.ts.map +1 -0
- package/dist/standalone/themes.d.ts +54 -0
- package/dist/standalone/themes.d.ts.map +1 -0
- package/dist/types/component.d.ts +120 -0
- package/dist/types/component.d.ts.map +1 -0
- package/dist/types/editor.d.ts +246 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/events.d.ts +199 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rule-chain.d.ts +141 -0
- package/dist/types/rule-chain.d.ts.map +1 -0
- package/dist/utils/helpers.d.ts +100 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/pinyin-search.d.ts +60 -0
- package/dist/utils/pinyin-search.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file events.ts
|
|
3
|
+
* @description 编辑器事件类型定义 - 强类型事件系统
|
|
4
|
+
*
|
|
5
|
+
* 定义编辑器所有事件的名称和对应的负载类型。
|
|
6
|
+
* 通过 TypeScript 泛型约束,确保事件触发和监听的类型安全。
|
|
7
|
+
*
|
|
8
|
+
* 事件分类:
|
|
9
|
+
* - 节点事件 (node:*)
|
|
10
|
+
* - 边事件 (edge:*)
|
|
11
|
+
* - 画布事件 (canvas:*)
|
|
12
|
+
* - 编辑器事件 (editor:*)
|
|
13
|
+
* - 历史事件 (history:*)
|
|
14
|
+
*/
|
|
15
|
+
import type { RuleNodeConfig, RuleConnectionConfig, RuleChainData, RuleChainConfig } from './rule-chain';
|
|
16
|
+
import type { ComponentGroup } from './component';
|
|
17
|
+
/**
|
|
18
|
+
* 节点点击/选择事件的负载
|
|
19
|
+
*/
|
|
20
|
+
export interface NodeEventPayload {
|
|
21
|
+
/** 节点的 LogicFlow ID */
|
|
22
|
+
id: string;
|
|
23
|
+
/** 节点类型 (simple-node, start-node, chain-node, group-node) */
|
|
24
|
+
type: string;
|
|
25
|
+
/** 节点 X 坐标 */
|
|
26
|
+
x: number;
|
|
27
|
+
/** 节点 Y 坐标 */
|
|
28
|
+
y: number;
|
|
29
|
+
/** 节点显示文本 */
|
|
30
|
+
text: string;
|
|
31
|
+
/** 节点属性 (包含 model 和 view) */
|
|
32
|
+
properties: {
|
|
33
|
+
model: RuleNodeConfig;
|
|
34
|
+
view?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 边点击/选择事件的负载
|
|
39
|
+
*/
|
|
40
|
+
export interface EdgeEventPayload {
|
|
41
|
+
/** 边的 LogicFlow ID */
|
|
42
|
+
id: string;
|
|
43
|
+
/** 边类型 */
|
|
44
|
+
type: string;
|
|
45
|
+
/** 源节点 ID */
|
|
46
|
+
sourceNodeId: string;
|
|
47
|
+
/** 目标节点 ID */
|
|
48
|
+
targetNodeId: string;
|
|
49
|
+
/** 边显示文本 */
|
|
50
|
+
text: string;
|
|
51
|
+
/** 边属性 (包含 model) */
|
|
52
|
+
properties: {
|
|
53
|
+
model: RuleConnectionConfig;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 保存事件负载
|
|
58
|
+
*/
|
|
59
|
+
export interface SaveEventPayload {
|
|
60
|
+
/** 保存的规则链数据 */
|
|
61
|
+
data: RuleChainData;
|
|
62
|
+
/** 是否保存成功 */
|
|
63
|
+
success: boolean;
|
|
64
|
+
/** 错误信息 (如果失败) */
|
|
65
|
+
error?: Error;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 历史变更事件负载
|
|
69
|
+
*/
|
|
70
|
+
export interface HistoryChangePayload {
|
|
71
|
+
/** 是否可以撤销 */
|
|
72
|
+
canUndo: boolean;
|
|
73
|
+
/** 是否可以重做 */
|
|
74
|
+
canRedo: boolean;
|
|
75
|
+
/** 撤销栈深度 */
|
|
76
|
+
undoCount: number;
|
|
77
|
+
/** 重做栈深度 */
|
|
78
|
+
redoCount: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 验证事件负载
|
|
82
|
+
*/
|
|
83
|
+
export interface ValidationPayload {
|
|
84
|
+
/** 验证是否通过 */
|
|
85
|
+
valid: boolean;
|
|
86
|
+
/** 验证错误列表 */
|
|
87
|
+
errors: Array<{
|
|
88
|
+
/** 规则名称 */
|
|
89
|
+
rule: string;
|
|
90
|
+
/** 错误消息 */
|
|
91
|
+
message: string;
|
|
92
|
+
/** 相关的节点/边 ID */
|
|
93
|
+
elementId?: string;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 编辑器事件映射表
|
|
98
|
+
* Key 为事件名称, Value 为事件负载类型
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // 使用:
|
|
103
|
+
* editor.on('node:click', (payload: NodeEventPayload) => { ... })
|
|
104
|
+
* editor.emit('editor:save', { data, success: true })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export interface EditorEventMap {
|
|
108
|
+
/** 节点被点击 */
|
|
109
|
+
'node:click': NodeEventPayload;
|
|
110
|
+
/** 节点被双击 (触发编辑) */
|
|
111
|
+
'node:dbclick': NodeEventPayload;
|
|
112
|
+
/** 节点被选中 */
|
|
113
|
+
'node:selected': NodeEventPayload;
|
|
114
|
+
/** 节点被拖入画布 (外部拖入) */
|
|
115
|
+
'node:dnd-add': NodeEventPayload;
|
|
116
|
+
/** 节点被添加到画布 */
|
|
117
|
+
'node:add': NodeEventPayload;
|
|
118
|
+
/** 节点被删除 */
|
|
119
|
+
'node:delete': {
|
|
120
|
+
id: string;
|
|
121
|
+
};
|
|
122
|
+
/** 节点被拖动/移动 */
|
|
123
|
+
'node:drop': NodeEventPayload;
|
|
124
|
+
/** 节点属性被更新 */
|
|
125
|
+
'node:property-update': {
|
|
126
|
+
id: string;
|
|
127
|
+
properties: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
/** 边被点击 */
|
|
130
|
+
'edge:click': EdgeEventPayload;
|
|
131
|
+
/** 边被双击 (触发编辑) */
|
|
132
|
+
'edge:dbclick': EdgeEventPayload;
|
|
133
|
+
/** 边被添加 */
|
|
134
|
+
'edge:add': EdgeEventPayload;
|
|
135
|
+
/** 边被删除 */
|
|
136
|
+
'edge:delete': {
|
|
137
|
+
id: string;
|
|
138
|
+
};
|
|
139
|
+
/** 边属性被更新 */
|
|
140
|
+
'edge:property-update': {
|
|
141
|
+
id: string;
|
|
142
|
+
properties: Record<string, unknown>;
|
|
143
|
+
};
|
|
144
|
+
/** 画布空白区被点击 (取消选择) */
|
|
145
|
+
'blank:click': void;
|
|
146
|
+
/** 画布缩放 */
|
|
147
|
+
'canvas:zoom': {
|
|
148
|
+
scale: number;
|
|
149
|
+
};
|
|
150
|
+
/** 组件列表加载完成 */
|
|
151
|
+
'editor:components-loaded': ComponentGroup[];
|
|
152
|
+
/** 数据加载完成 (通知适配层渲染 LogicFlow 数据) */
|
|
153
|
+
'editor:data-loaded': {
|
|
154
|
+
lfData: import('../core/DataAdapter').LFGraphData;
|
|
155
|
+
ruleChain: RuleChainConfig;
|
|
156
|
+
};
|
|
157
|
+
/** 编辑器就绪 */
|
|
158
|
+
'editor:ready': void;
|
|
159
|
+
/** 编辑器销毁 */
|
|
160
|
+
'editor:destroy': void;
|
|
161
|
+
/** 保存请求 */
|
|
162
|
+
'editor:save': SaveEventPayload;
|
|
163
|
+
/** 保存成功 */
|
|
164
|
+
'editor:save-ok': RuleChainData;
|
|
165
|
+
/** 保存失败 */
|
|
166
|
+
'editor:save-error': {
|
|
167
|
+
data: RuleChainData;
|
|
168
|
+
error: Error;
|
|
169
|
+
};
|
|
170
|
+
/** 新建规则链 */
|
|
171
|
+
'editor:new': RuleChainConfig;
|
|
172
|
+
/** 打开规则链 */
|
|
173
|
+
'editor:open': RuleChainData;
|
|
174
|
+
/** 配置变更 */
|
|
175
|
+
'editor:setting': Record<string, unknown>;
|
|
176
|
+
/** 全屏切换 */
|
|
177
|
+
'editor:fullscreen': void;
|
|
178
|
+
/** 重置 */
|
|
179
|
+
'editor:reset': void;
|
|
180
|
+
/** 删除选中元素 */
|
|
181
|
+
'editor:delete-selected': void;
|
|
182
|
+
/** 元素已被删除 */
|
|
183
|
+
'editor:deleted': void;
|
|
184
|
+
/** 编辑面板请求 */
|
|
185
|
+
'editor:show-edit-panel': void;
|
|
186
|
+
/** 历史记录变更 */
|
|
187
|
+
'history:change': HistoryChangePayload;
|
|
188
|
+
/** 验证完成 */
|
|
189
|
+
'validation:complete': ValidationPayload;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 事件名称联合类型
|
|
193
|
+
*/
|
|
194
|
+
export type EditorEventName = keyof EditorEventMap;
|
|
195
|
+
/**
|
|
196
|
+
* 通用事件监听器类型
|
|
197
|
+
*/
|
|
198
|
+
export type EventListener<T = unknown> = (payload: T) => void;
|
|
199
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACxG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAMjD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc;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,gBAAgB,EAAE,IAAI,CAAA;IACtB,WAAW;IACX,aAAa,EAAE,gBAAgB,CAAA;IAC/B,WAAW;IACX,gBAAgB,EAAE,aAAa,CAAA;IAC/B,WAAW;IACX,mBAAmB,EAAE;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAAA;IAC1D,YAAY;IACZ,YAAY,EAAE,eAAe,CAAA;IAC7B,YAAY;IACZ,aAAa,EAAE,aAAa,CAAA;IAC5B,WAAW;IACX,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzC,WAAW;IACX,mBAAmB,EAAE,IAAI,CAAA;IACzB,SAAS;IACT,cAAc,EAAE,IAAI,CAAA;IACpB,aAAa;IACb,wBAAwB,EAAE,IAAI,CAAA;IAC9B,aAAa;IACb,gBAAgB,EAAE,IAAI,CAAA;IACtB,aAAa;IACb,wBAAwB,EAAE,IAAI,CAAA;IAG9B,aAAa;IACb,gBAAgB,EAAE,oBAAoB,CAAA;IAGtC,WAAW;IACX,qBAAqB,EAAE,iBAAiB,CAAA;CACzC;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,cAAc,CAAA;AAElD;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file types/index.ts
|
|
3
|
+
* @description 类型统一导出入口
|
|
4
|
+
*
|
|
5
|
+
* 所有类型定义从这里集中导出,
|
|
6
|
+
* 方便外部使用: import type { RuleChainData, EditorOptions } from '@huanban/rulego-editor-core'
|
|
7
|
+
*/
|
|
8
|
+
export type { LayoutInfo, AdditionalInfo, RuleChainConfig, RuleNodeConfig, RuleConnectionConfig, RuleEndpointConfig, RuleChainMetadata, RuleChainData, } from './rule-chain';
|
|
9
|
+
export type { FieldValidation, ComponentField, ComponentCategory, ComponentDefinition, ComponentGroup, RawComponentData, ComponentRegistryOptions, } from './component';
|
|
10
|
+
export type { ApiEndpoints, RequestConfig, ToolbarConfig, GridConfig, EditorOptions, PanelType, EditorState, EditorPlugin, EditorInternalData, } from './editor';
|
|
11
|
+
export type { NodeEventPayload, EdgeEventPayload, SaveEventPayload, HistoryChangePayload, ValidationPayload, EditorEventMap, EditorEventName, EventListener, } from './events';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,YAAY,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,cAAc,CAAA;AAGrB,YAAY,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AAGpB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,YAAY,EACZ,kBAAkB,GACnB,MAAM,UAAU,CAAA;AAGjB,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file rule-chain.ts
|
|
3
|
+
* @description RuleGo 规则链数据格式类型定义
|
|
4
|
+
*
|
|
5
|
+
* 对应 RuleGo 后端的 JSON 数据结构,用于前后端数据交互。
|
|
6
|
+
* 包含规则链元信息、节点定义、连接定义等完整类型。
|
|
7
|
+
*
|
|
8
|
+
* @see https://rulego.cc/pages/a2a7a9/ RuleGo 官方文档
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* 节点在画布上的布局信息
|
|
12
|
+
* 存储于 additionalInfo 中,用于还原节点位置
|
|
13
|
+
*/
|
|
14
|
+
export interface LayoutInfo {
|
|
15
|
+
/** 节点 X 坐标 */
|
|
16
|
+
layoutX: number;
|
|
17
|
+
/** 节点 Y 坐标 */
|
|
18
|
+
layoutY: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 节点附加信息
|
|
22
|
+
* 用于存储与业务逻辑无关的元数据(如布局、描述、自定义属性)
|
|
23
|
+
*/
|
|
24
|
+
export interface AdditionalInfo extends LayoutInfo {
|
|
25
|
+
/** 节点描述 */
|
|
26
|
+
description?: string;
|
|
27
|
+
/** 其他自定义属性 */
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 规则链头部配置
|
|
32
|
+
* 定义规则链的基本标识信息
|
|
33
|
+
*/
|
|
34
|
+
export interface RuleChainConfig {
|
|
35
|
+
/** 规则链唯一 ID (UUID 格式) */
|
|
36
|
+
id: string;
|
|
37
|
+
/** 规则链名称 */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** 是否为根规则链 */
|
|
40
|
+
root?: boolean;
|
|
41
|
+
/** 是否启用调试模式 */
|
|
42
|
+
debugMode?: boolean;
|
|
43
|
+
/** 附加配置 */
|
|
44
|
+
additionalInfo?: Record<string, unknown>;
|
|
45
|
+
/** 是否禁用 (disabled=true 表示停用中) */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** 创建时间 (ISO 8601) */
|
|
48
|
+
createTime?: string;
|
|
49
|
+
/** 更新时间 (ISO 8601) */
|
|
50
|
+
updateTime?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 规则链中的节点定义
|
|
54
|
+
* 对应 metadata.nodes[] 中的每一项
|
|
55
|
+
*/
|
|
56
|
+
export interface RuleNodeConfig {
|
|
57
|
+
/** 节点唯一 ID (格式: node_1, node_2, ...) */
|
|
58
|
+
id: string;
|
|
59
|
+
/** 节点类型 (对应注册的组件类型, 如 jsFilter, restApiCall 等) */
|
|
60
|
+
type: string;
|
|
61
|
+
/** 节点显示名称 */
|
|
62
|
+
name: string;
|
|
63
|
+
/** 节点配置参数 (JSON 格式, 根据节点类型不同有不同结构) */
|
|
64
|
+
configuration?: Record<string, unknown>;
|
|
65
|
+
/** 节点附加信息 (包含布局位置等) */
|
|
66
|
+
additionalInfo?: AdditionalInfo;
|
|
67
|
+
/** 是否启用调试 */
|
|
68
|
+
debugMode?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 节点间的连接定义
|
|
72
|
+
* 对应 metadata.connections[] 中的每一项
|
|
73
|
+
*/
|
|
74
|
+
export interface RuleConnectionConfig {
|
|
75
|
+
/** 源节点 ID */
|
|
76
|
+
fromId: string;
|
|
77
|
+
/** 目标节点 ID */
|
|
78
|
+
toId: string;
|
|
79
|
+
/** 关系类型 (如 True, False, Success, Failure) */
|
|
80
|
+
type: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 端点 (Endpoint) 节点定义
|
|
84
|
+
* 对应 metadata.endpoints[] 中的每一项
|
|
85
|
+
* 端点是规则链的输入/输出接口 (如 HTTP、MQTT、Cron 等)
|
|
86
|
+
*/
|
|
87
|
+
export interface RuleEndpointConfig {
|
|
88
|
+
/** 端点节点 ID (格式: node_N) */
|
|
89
|
+
id: string;
|
|
90
|
+
/** 端点类型 (如 endpoint/http, endpoint/mqtt) */
|
|
91
|
+
type: string;
|
|
92
|
+
/** 端点显示名称 */
|
|
93
|
+
name: string;
|
|
94
|
+
/** 端点配置参数 */
|
|
95
|
+
configuration?: Record<string, unknown>;
|
|
96
|
+
/** 附加信息 (包含布局位置等) */
|
|
97
|
+
additionalInfo?: AdditionalInfo;
|
|
98
|
+
/** 是否启用调试 */
|
|
99
|
+
debugMode?: boolean;
|
|
100
|
+
/** 路由配置 (HTTP 端点特有) */
|
|
101
|
+
routers?: unknown[];
|
|
102
|
+
/** 处理器列表 */
|
|
103
|
+
processors?: unknown[] | null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 规则链元数据
|
|
107
|
+
* 包含所有节点和连接信息
|
|
108
|
+
*/
|
|
109
|
+
export interface RuleChainMetadata {
|
|
110
|
+
/** 节点列表 */
|
|
111
|
+
nodes: RuleNodeConfig[];
|
|
112
|
+
/** 连接列表 */
|
|
113
|
+
connections: RuleConnectionConfig[];
|
|
114
|
+
/** 端点列表 (输入/输出接口节点) */
|
|
115
|
+
endpoints?: RuleEndpointConfig[];
|
|
116
|
+
/** 第一个节点的索引 (指向 nodes 数组中的下标) */
|
|
117
|
+
firstNodeIndex?: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 完整的规则链数据结构
|
|
121
|
+
* 用于前后端数据交互的顶层结构
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```json
|
|
125
|
+
* {
|
|
126
|
+
* "ruleChain": { "id": "xxx", "name": "test" },
|
|
127
|
+
* "metadata": {
|
|
128
|
+
* "nodes": [...],
|
|
129
|
+
* "connections": [...],
|
|
130
|
+
* "firstNodeIndex": 0
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export interface RuleChainData {
|
|
136
|
+
/** 规则链头部配置 */
|
|
137
|
+
ruleChain: RuleChainConfig;
|
|
138
|
+
/** 规则链元数据 (节点和连接) */
|
|
139
|
+
metadata: RuleChainMetadata;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=rule-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-chain.d.ts","sourceRoot":"","sources":["../../src/types/rule-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,cAAc;I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MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa;IACb,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,qBAAqB;IACrB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,aAAa;IACb,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,uBAAuB;IACvB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;IACnB,YAAY;IACZ,UAAU,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW;IACX,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,WAAW;IACX,WAAW,EAAE,oBAAoB,EAAE,CAAA;IACnC,uBAAuB;IACvB,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAChC,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa;IAC5B,cAAc;IACd,SAAS,EAAE,eAAe,CAAA;IAC1B,qBAAqB;IACrB,QAAQ,EAAE,iBAAiB,CAAA;CAC5B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file utils/helpers.ts
|
|
3
|
+
* @description 通用工具函数
|
|
4
|
+
*
|
|
5
|
+
* 从原版 util.js 移植的功能函数, 去除 Vue 依赖。
|
|
6
|
+
* 包含:
|
|
7
|
+
* - 文本宽度计算
|
|
8
|
+
* - 节点/边查找
|
|
9
|
+
* - 节点 ID 序号提取
|
|
10
|
+
* - UUID 生成
|
|
11
|
+
*
|
|
12
|
+
* @see 原版: src/components/utils/util.js
|
|
13
|
+
*/
|
|
14
|
+
import type { ComponentDefinition, ComponentGroup, RawComponentData } from '../types/component';
|
|
15
|
+
/**
|
|
16
|
+
* 从节点数组中根据 ID 查找节点
|
|
17
|
+
*
|
|
18
|
+
* @param nodes - 节点数组
|
|
19
|
+
* @param id - 目标节点 ID
|
|
20
|
+
* @returns 找到的节点, 未找到返回 undefined
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNodeByID<T extends {
|
|
23
|
+
id: string;
|
|
24
|
+
}>(nodes: T[], id: string): T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* 从边数组中根据源/目标节点 ID 查找边
|
|
27
|
+
*
|
|
28
|
+
* @param edges - 边数组
|
|
29
|
+
* @param sourceNodeId - 源节点 ID
|
|
30
|
+
* @param targetNodeId - 目标节点 ID
|
|
31
|
+
* @returns 找到的边, 未找到返回 undefined
|
|
32
|
+
*/
|
|
33
|
+
export declare function getEdgeBySourceNodeIdAndTargetNodeId<T extends {
|
|
34
|
+
sourceNodeId: string;
|
|
35
|
+
targetNodeId: string;
|
|
36
|
+
}>(edges: T[], sourceNodeId: string, targetNodeId: string): T | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* 从节点 ID 中提取序号
|
|
39
|
+
*
|
|
40
|
+
* 节点 ID 格式: node_1, node_23 等
|
|
41
|
+
* 返回数字部分, 如果格式不匹配返回 0
|
|
42
|
+
*
|
|
43
|
+
* @param nodeId - 节点 ID
|
|
44
|
+
* @returns 序号数字
|
|
45
|
+
*/
|
|
46
|
+
export declare function getNodeSeq(nodeId: string): number;
|
|
47
|
+
/**
|
|
48
|
+
* 计算字符串的字节长度 (中文算 2, 英文算 1)
|
|
49
|
+
* 用于估算节点文本的显示宽度
|
|
50
|
+
*
|
|
51
|
+
* @param str - 输入字符串
|
|
52
|
+
* @returns 字节长度
|
|
53
|
+
*/
|
|
54
|
+
export declare function getBytesLength(str: string): number;
|
|
55
|
+
/**
|
|
56
|
+
* 生成 UUID v4
|
|
57
|
+
*
|
|
58
|
+
* 如果浏览器支持 crypto.randomUUID() 则优先使用,
|
|
59
|
+
* 否则使用 Math.random() 回退方案。
|
|
60
|
+
*
|
|
61
|
+
* @returns UUID 字符串
|
|
62
|
+
*/
|
|
63
|
+
export declare function generateUUID(): string;
|
|
64
|
+
/**
|
|
65
|
+
* 将后端 API 返回的原始组件数据转换为按分类分组的格式
|
|
66
|
+
*
|
|
67
|
+
* 对应原版 util.js 中的 adapterComponents 函数。
|
|
68
|
+
* 按 category 字段分组, 并附加分类颜色和标签信息。
|
|
69
|
+
*
|
|
70
|
+
* @param rawData - 后端返回的原始组件列表
|
|
71
|
+
* @param categoryConfig - 自定义分类配置 (可选)
|
|
72
|
+
* @returns 分组后的组件列表
|
|
73
|
+
*/
|
|
74
|
+
export declare function adapterComponents(rawData: RawComponentData, categoryConfig?: Record<string, {
|
|
75
|
+
label: string;
|
|
76
|
+
color: string;
|
|
77
|
+
}>): ComponentGroup[];
|
|
78
|
+
/**
|
|
79
|
+
* 将分组后的组件列表转换为扁平的 type => definition 映射
|
|
80
|
+
*
|
|
81
|
+
* 对应原版的 toComponentList 函数。
|
|
82
|
+
*
|
|
83
|
+
* @param componentGroups - 分组后的组件列表
|
|
84
|
+
* @returns type => ComponentDefinition 的映射
|
|
85
|
+
*/
|
|
86
|
+
export declare function toComponentMap(componentGroups: ComponentGroup[]): Record<string, ComponentDefinition>;
|
|
87
|
+
/**
|
|
88
|
+
* 默认的 ID 生成器
|
|
89
|
+
*
|
|
90
|
+
* 基于计数器的简单 ID 生成 (对应原版 options.idGenerator)
|
|
91
|
+
*
|
|
92
|
+
* @param type - 元素类型 ('flow-link' 为边, 其他为节点)
|
|
93
|
+
* @param counters - 计数器引用 (nodeCount, edgeCount)
|
|
94
|
+
* @returns 生成的 ID 字符串
|
|
95
|
+
*/
|
|
96
|
+
export declare function defaultIdGenerator(type: string, counters: {
|
|
97
|
+
nodeCount: number;
|
|
98
|
+
edgeCount: number;
|
|
99
|
+
}): string;
|
|
100
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 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ACZ,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,MAAM,CAQR"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file utils/index.ts
|
|
3
|
+
* @description 工具函数统一导出入口
|
|
4
|
+
*/
|
|
5
|
+
export { getNodeByID, getEdgeBySourceNodeIdAndTargetNodeId, getNodeSeq, getBytesLength, generateUUID, adapterComponents, toComponentMap, defaultIdGenerator, } from './helpers';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,oCAAoC,EACpC,UAAU,EACV,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file utils/pinyin-search.ts
|
|
3
|
+
* @description 拼音搜索工具 — 支持中文拼音首字母和模糊匹配
|
|
4
|
+
*
|
|
5
|
+
* 功能:
|
|
6
|
+
* - 中文汉字 → 拼音首字母映射(轻量级,无需外部依赖)
|
|
7
|
+
* - 模糊匹配(支持关键字分词、首字母匹配)
|
|
8
|
+
* - 用于侧边栏组件搜索的增强搜索
|
|
9
|
+
*
|
|
10
|
+
* 使用方式:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { fuzzyMatch } from './pinyin-search'
|
|
13
|
+
*
|
|
14
|
+
* fuzzyMatch('JS过滤器', 'jsgl') // true (首字母匹配)
|
|
15
|
+
* fuzzyMatch('JS过滤器', '过滤') // true (中文包含)
|
|
16
|
+
* fuzzyMatch('JS过滤器', 'guolv') // true (拼音匹配)
|
|
17
|
+
* fuzzyMatch('数据库', 'sjk') // true (首字母)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* 获取单个汉字的拼音首字母
|
|
22
|
+
*
|
|
23
|
+
* @param char - 单个汉字
|
|
24
|
+
* @returns 拼音首字母(小写),非汉字返回原字符
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCharPinyin(char: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* 获取字符串的拼音首字母串
|
|
29
|
+
* 中文提取首字母,英文/数字保持原样
|
|
30
|
+
*
|
|
31
|
+
* @param str - 输入字符串
|
|
32
|
+
* @returns 拼音首字母组成的字符串(全小写)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* getPinyinInitials('JS过滤器') // 'jsglq'
|
|
36
|
+
* getPinyinInitials('数据库') // 'sjk'
|
|
37
|
+
* getPinyinInitials('REST') // 'rest'
|
|
38
|
+
*/
|
|
39
|
+
export declare function getPinyinInitials(str: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* 模糊匹配函数 — 支持多种匹配策略
|
|
42
|
+
*
|
|
43
|
+
* 匹配策略(按优先级):
|
|
44
|
+
* 1. 精确包含匹配(原文包含关键字)
|
|
45
|
+
* 2. 拼音首字母匹配(关键字 = 拼音首字母缩写)
|
|
46
|
+
* 3. 分词匹配(关键字以空格分隔,每个词都需要匹配)
|
|
47
|
+
*
|
|
48
|
+
* @param text - 被搜索的文本
|
|
49
|
+
* @param keyword - 搜索关键字(已小写化)
|
|
50
|
+
* @returns 是否匹配
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* fuzzyMatch('JS过滤器', 'jsgl') // true — 拼音首字母
|
|
54
|
+
* fuzzyMatch('JS过滤器', '过滤') // true — 包含匹配
|
|
55
|
+
* fuzzyMatch('数据库', 'sjk') // true — 拼音首字母
|
|
56
|
+
* fuzzyMatch('REST API', 'rest') // true — 包含匹配
|
|
57
|
+
* fuzzyMatch('发邮件', 'fy') // true — 拼音首字母
|
|
58
|
+
*/
|
|
59
|
+
export declare function fuzzyMatch(text: string, keyword: string): boolean;
|
|
60
|
+
//# sourceMappingURL=pinyin-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinyin-search.d.ts","sourceRoot":"","sources":["../../src/utils/pinyin-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA0DH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAoBlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAqBjE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@huanban/rulego-editor-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "RuleGo 规则链编辑器核心库 - 框架无关的 Headless 编辑器引擎 + API 抽象层 (WorkflowFetcher)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.cjs.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"registry": "https://registry.npmjs.org",
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/openclaw/rulego-editor",
|
|
26
|
+
"directory": "packages/editor-core"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/openclaw/rulego-editor#readme",
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "vite build --watch",
|
|
31
|
+
"build": "vite build && tsc --emitDeclarationOnly --outDir dist",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:watch": "vitest",
|
|
34
|
+
"lint": "tsc --noEmit",
|
|
35
|
+
"clean": "rm -rf dist"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@codemirror/autocomplete": "^6.20.1",
|
|
39
|
+
"@codemirror/lang-javascript": "^6.2.5",
|
|
40
|
+
"@codemirror/lang-json": "^6.0.2",
|
|
41
|
+
"@codemirror/language": "^6.12.2",
|
|
42
|
+
"@codemirror/lint": "^6.9.5",
|
|
43
|
+
"@codemirror/search": "^6.6.0",
|
|
44
|
+
"@codemirror/state": "^6.6.0",
|
|
45
|
+
"@codemirror/theme-one-dark": "^6.1.3",
|
|
46
|
+
"@codemirror/view": "^6.40.0",
|
|
47
|
+
"@logicflow/core": "2.1.11",
|
|
48
|
+
"@logicflow/extension": "2.1.11",
|
|
49
|
+
"codemirror": "^6.0.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"typescript": "^5.4.0",
|
|
53
|
+
"vite": "^5.4.0",
|
|
54
|
+
"vite-plugin-dts": "^4.0.0",
|
|
55
|
+
"vitest": "^2.0.0"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"rulego",
|
|
59
|
+
"editor-core",
|
|
60
|
+
"headless",
|
|
61
|
+
"logicflow",
|
|
62
|
+
"rule-chain",
|
|
63
|
+
"rule-engine",
|
|
64
|
+
"workflow",
|
|
65
|
+
"fetcher",
|
|
66
|
+
"api-client"
|
|
67
|
+
],
|
|
68
|
+
"author": "HuanBan Team",
|
|
69
|
+
"license": "Apache-2.0"
|
|
70
|
+
}
|