@huanban/rulego-editor-core 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +190 -0
  2. package/dist/api/AIManager.d.ts +12 -0
  3. package/dist/api/ApiProvider.d.ts +83 -0
  4. package/dist/api/DebugSocketClient.d.ts +39 -0
  5. package/dist/api/RuleChainAPI.d.ts +5 -1
  6. package/dist/api/StreamParser.d.ts +13 -0
  7. package/dist/api/index.d.ts +5 -1
  8. package/dist/api/response-utils.d.ts +28 -0
  9. package/dist/api/types.d.ts +67 -0
  10. package/dist/core/AutoLayout.d.ts +1 -1
  11. package/dist/core/ComponentRegistry.d.ts +11 -1
  12. package/dist/core/EditorCore.d.ts +23 -1
  13. package/dist/core/I18nManager.d.ts +18 -0
  14. package/dist/core/Optimizations.d.ts +16 -0
  15. package/dist/core/RuleChainChatManager.d.ts +53 -0
  16. package/dist/core/component-payload.d.ts +12 -0
  17. package/dist/core/index.d.ts +4 -2
  18. package/dist/core/runtime-limits.d.ts +35 -0
  19. package/dist/defaults/components.d.ts +4 -23
  20. package/dist/defaults/official-component-fallbacks.d.ts +12 -0
  21. package/dist/extensions/ClipboardExtension.d.ts +28 -0
  22. package/dist/extensions/KeyboardExtension.d.ts +18 -0
  23. package/dist/extensions/MenuExtension.d.ts +29 -0
  24. package/dist/iconRegistry.d.ts +2 -2
  25. package/dist/index.cjs.js +5739 -922
  26. package/dist/index.d.ts +11 -6
  27. package/dist/index.esm.js +74892 -43118
  28. package/dist/index.umd.js +5739 -922
  29. package/dist/models/BaseNodeModel.d.ts +38 -0
  30. package/dist/models/index.d.ts +2 -0
  31. package/dist/nodes/AgentOrchestrationNode.d.ts +41 -0
  32. package/dist/nodes/GroupNode.d.ts +50 -0
  33. package/dist/nodes/HeadlessHtmlNode.d.ts +20 -0
  34. package/dist/nodes/SwitchNode.d.ts +27 -0
  35. package/dist/nodes/UnknownNodeModel.d.ts +24 -0
  36. package/dist/standalone/HuanbanRulegoEditor.d.ts +122 -12
  37. package/dist/standalone/ai-providers.d.ts +7 -0
  38. package/dist/standalone/auth-fetch.d.ts +6 -1
  39. package/dist/standalone/code-editor.d.ts +40 -4
  40. package/dist/standalone/custom-nodes.d.ts +4 -1
  41. package/dist/standalone/editor-context-menu.d.ts +3 -2
  42. package/dist/standalone/editor-debug-ws.d.ts +26 -6
  43. package/dist/standalone/editor-delete.d.ts +4 -0
  44. package/dist/standalone/editor-dialogs.d.ts +27 -4
  45. package/dist/standalone/editor-events.d.ts +2 -1
  46. package/dist/standalone/editor-property-drawers.d.ts +30 -2
  47. package/dist/standalone/editor-route-settings.d.ts +49 -0
  48. package/dist/standalone/editor-sidebar.d.ts +11 -0
  49. package/dist/standalone/editor-toast.d.ts +2 -0
  50. package/dist/standalone/editor-toolbar.d.ts +13 -1
  51. package/dist/standalone/group-node.d.ts +9 -1
  52. package/dist/standalone/index.d.ts +4 -2
  53. package/dist/standalone/layout-scheduler.d.ts +16 -0
  54. package/dist/standalone/lifecycle.d.ts +15 -0
  55. package/dist/standalone/models-dev-catalog.d.ts +53 -0
  56. package/dist/standalone/node-definitions.d.ts +25 -7
  57. package/dist/standalone/official-node-view-patches.d.ts +15 -0
  58. package/dist/standalone/security-utils.d.ts +45 -0
  59. package/dist/test/setup-dom.d.ts +3 -0
  60. package/dist/types/component.d.ts +10 -1
  61. package/dist/types/editor.d.ts +48 -2
  62. package/dist/types/events.d.ts +14 -0
  63. package/dist/types/rule-chain.d.ts +1 -1
  64. package/dist/utils/GraphUtils.d.ts +24 -0
  65. package/dist/utils/index.d.ts +1 -0
  66. package/dist/utils/relation-utils.d.ts +13 -0
  67. package/dist/utils/textUtils.d.ts +13 -0
  68. package/package.json +15 -13
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 OpenClaw
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,12 @@
1
+ export declare class AIManager {
2
+ private modelsCache;
3
+ private fetchPromise;
4
+ private lastFetchTime;
5
+ /**
6
+ * 获取可用大模型列表(带 60s 内存缓存与接口容灾探活)
7
+ */
8
+ getAvailableModels(): Promise<any>;
9
+ private fetchAvailableModels;
10
+ }
11
+ export declare const aiManager: AIManager;
12
+ //# sourceMappingURL=AIManager.d.ts.map
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @file ApiProvider.ts
3
+ * @description API 服务提供者,统一管理整个规则编辑器的 HTTP 请求与 WebSocket 连接生成。
4
+ * 允许外部主框架(如 HuanbanClaw)通过 updateConfig 动态替换 fetch 底层或注入 Token。
5
+ */
6
+ /**
7
+ * 引擎 API 基础配置接口
8
+ * @interface EditorApiConfig
9
+ */
10
+ export interface EditorApiConfig {
11
+ /** 后端 API 基础地址 (包含 context-path) */
12
+ baseUrl: string;
13
+ /**
14
+ * 动态的 HTTP 请求头。
15
+ * 支持传入对象或返回对象的函数,以应对频繁刷新的 AccessToken 场景。
16
+ */
17
+ fetchHeaders?: Record<string, string> | (() => Record<string, string>);
18
+ /**
19
+ * 完全自定义底层的 Fetch 函数实现。
20
+ * 如果外层有 axios 拦截器或需要特殊签名,可以通过该钩子替换。
21
+ */
22
+ customFetch?: (url: string, init?: RequestInit) => Promise<Response>;
23
+ }
24
+ /**
25
+ * 标准化给 ApiProvider 使用的服务根地址。
26
+ *
27
+ * HuanbanRulegoEditor 的 apiBase 约定通常包含 /api/v1(例如
28
+ * http://host:9090/api/v1),而 ApiProvider 内部方法会自己拼
29
+ * /api/v1/components、/api/v1/ai/models。这里剥离尾部 /api/v1,
30
+ * 防止真实后端调用时出现 /api/v1/api/v1 的重复路径。
31
+ */
32
+ export declare function normalizeApiProviderBaseUrl(baseUrl: string): string;
33
+ /**
34
+ * 标准化给编辑器内置对话框/抽屉使用的 API v1 地址。
35
+ *
36
+ * 这些模块直接请求 /components、/rules、/logs/debug 等 v1 下的路径;
37
+ * 调用方既可能传 http://host:9090,也可能传 http://host:9090/api/v1。
38
+ */
39
+ export declare function normalizeApiV1BaseUrl(baseUrl: string): string;
40
+ /**
41
+ * 全局 API 调度中心类
42
+ * @class ApiProvider
43
+ */
44
+ export declare class ApiProvider {
45
+ private config;
46
+ /**
47
+ * 更新 API 全局配置
48
+ * @param {Partial<EditorApiConfig>} newConfig - 要合并的新配置项
49
+ */
50
+ updateConfig(newConfig: Partial<EditorApiConfig>): void;
51
+ /**
52
+ * 获取当前配置的基础 URL
53
+ * @returns {string} baseUrl
54
+ */
55
+ getBaseUrl(): string;
56
+ /**
57
+ * 内部统一请求通道
58
+ * 负责拼装 URL、注入自定义 Headers,或派发至自定义 fetch 方法
59
+ * @private
60
+ */
61
+ request(path: string, init?: RequestInit): Promise<Response>;
62
+ /**
63
+ * 获取平台全量的节点组件注册列表
64
+ * (对应官方接口: /api/v1/components)
65
+ * @returns {Promise<any>} 返回 JSON 数据字典
66
+ */
67
+ fetchComponents(): Promise<unknown>;
68
+ /**
69
+ * 下发测试指令到规则引擎
70
+ * @param {string} chainId - 规则链ID
71
+ * @param {any} data - 需要灌入的 JSON 报文
72
+ * @returns {Promise<any>}
73
+ */
74
+ runDebug(chainId: string, data: any): Promise<unknown>;
75
+ /**
76
+ * 根据当前 HTTP 地址,自动换算获取 WebSocket 的连接地址
77
+ * @param {string} chainId - 规则链ID
78
+ * @returns {string} 完整的 ws:// 或 wss:// 地址
79
+ */
80
+ getDebugWsUrl(chainId: string): string;
81
+ }
82
+ export declare const apiProvider: ApiProvider;
83
+ //# sourceMappingURL=ApiProvider.d.ts.map
@@ -0,0 +1,39 @@
1
+ export declare class DebugSocketClient {
2
+ private endpoint;
3
+ private onMessage;
4
+ private onError;
5
+ /** 内部 WebSocket 实例 */
6
+ private ws;
7
+ /** 心跳定时器引用 */
8
+ private pingInterval;
9
+ /** 待执行的重连定时器 */
10
+ private reconnectTimer;
11
+ /** 当前重连尝试次数 */
12
+ private reconnectAttempts;
13
+ /** 最大重连尝试次数 */
14
+ private maxReconnectAttempts;
15
+ /** 客户端销毁状态标志 */
16
+ private isDestroyed;
17
+ /**
18
+ * 构造函数
19
+ * @param endpoint {string} WebSocket 服务端点 URL
20
+ * @param onMessage {(msg: any) => void} 接收到服务端消息时的回调
21
+ * @param onError {(err: any) => void} 出现异常或重连失败时的回调
22
+ */
23
+ constructor(endpoint: string, onMessage: (msg: any) => void, onError: (err: any) => void);
24
+ /**
25
+ * 建立连接并绑定生命周期事件
26
+ */
27
+ connect(): void;
28
+ /**
29
+ * 指数退避重连算法实现
30
+ * @private
31
+ */
32
+ private handleReconnect;
33
+ private closeSocket;
34
+ /**
35
+ * 彻底销毁客户端,断开连接并清空心跳
36
+ */
37
+ destroy(): void;
38
+ }
39
+ //# sourceMappingURL=DebugSocketClient.d.ts.map
@@ -28,7 +28,7 @@
28
28
  *
29
29
  * @module @huanban/rulego-editor-core/api
30
30
  */
31
- import type { WorkflowItem, PagedResponse, ApiResult, WorkflowFetcher, RuleChainAPIOptions } from './types';
31
+ import type { WorkflowItem, PagedResponse, ApiResult, WorkflowFetcher, RuleChainAPIOptions, RulePatchPreviewResponse, RuleRepairPlanResponse, RuleSchemaDiffResponse, RuleValidateUpstreamResponse, JSONPatchOperation } from './types';
32
32
  /**
33
33
  * 规则链 API 客户端
34
34
  *
@@ -154,6 +154,10 @@ export declare class RuleChainAPI implements WorkflowFetcher {
154
154
  * @returns 操作结果
155
155
  */
156
156
  saveConfig(id: string, configType: 'vars' | 'secrets', data: Record<string, string>): Promise<ApiResult>;
157
+ validateUpstream(id: string, dsl: Record<string, unknown>, options?: Record<string, unknown>): Promise<RuleValidateUpstreamResponse>;
158
+ getSchemaDiff(id: string): Promise<RuleSchemaDiffResponse>;
159
+ getRepairPlan(id: string, dsl: Record<string, unknown>, options?: Record<string, unknown>): Promise<RuleRepairPlanResponse>;
160
+ previewPatch(id: string, dsl: Record<string, unknown>, operations: JSONPatchOperation[]): Promise<RulePatchPreviewResponse>;
157
161
  /**
158
162
  * 获取当前 API 基础地址
159
163
  * @returns apiBase
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file StreamParser.ts
3
+ * @description Server-Sent Events (SSE) 流式解析器,用于大模型流式响应
4
+ */
5
+ export declare class StreamParser {
6
+ /**
7
+ * 解析标准的 SSE 响应
8
+ * @param response fetch Response
9
+ * @returns 异步生成器,产出解析后的 JSON 数据
10
+ */
11
+ static parseSSE(response: Response): AsyncGenerator<any, void, unknown>;
12
+ }
13
+ //# sourceMappingURL=StreamParser.d.ts.map
@@ -10,6 +10,10 @@
10
10
  * - 数据类型: WorkflowItem / PagedResponse / ApiResult
11
11
  */
12
12
  export { RuleChainAPI } from './RuleChainAPI';
13
+ export { normalizePagedResponse, unwrapApiEnvelope } from './response-utils';
13
14
  export { DEFAULT_ROUTES } from './types';
14
- export type { WorkflowItem, PagedResponse, ApiResult, WorkflowFetcher, RuleChainAPIOptions, RuleChainRoutes, WorkflowListIcons, WorkflowInfoIcons, WorkflowTheme, } from './types';
15
+ export type { WorkflowItem, PagedResponse, ApiResult, WorkflowFetcher, RuleChainAPIOptions, RuleChainRoutes, WorkflowListIcons, WorkflowInfoIcons, WorkflowTheme, RuleMaintenanceSeverity, RuleMaintenanceCategory, RuleMaintenanceIssue, RuleMaintenanceRuntimeInfo, RuleValidateUpstreamRequest, RuleValidateUpstreamResponse, RuleSchemaDiffResponse, RuleRepairPlanResponse, JSONPatchOperation, RulePatchPreviewResponse, } from './types';
16
+ export { ApiProvider, apiProvider, normalizeApiProviderBaseUrl, normalizeApiV1BaseUrl, type EditorApiConfig } from './ApiProvider';
17
+ export { AIManager, aiManager } from './AIManager';
18
+ export { DebugSocketClient } from './DebugSocketClient';
15
19
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Unwrap common backend envelopes while keeping native RuleGo payloads intact.
3
+ *
4
+ * Supported:
5
+ * - { code: 0, data: ... }
6
+ * - { success: true, data: ... }
7
+ * - { status: "ok", data: ... }
8
+ * - { data: ... }
9
+ */
10
+ export declare function unwrapApiEnvelope<T = unknown>(raw: unknown): T;
11
+ /**
12
+ * Normalize list responses used by RuleGo-compatible backends.
13
+ *
14
+ * Supported list shapes:
15
+ * - [...]
16
+ * - { items, total, page, size }
17
+ * - { records, total, current, size }
18
+ * - { rows, count }
19
+ * - { data: { items|records|rows|list, total } }
20
+ * - { code, data: ... }
21
+ */
22
+ export declare function normalizePagedResponse<T>(raw: unknown, mapItem: (item: unknown) => T, fallbackPage?: number, fallbackPageSize?: number): {
23
+ items: T[];
24
+ total: number;
25
+ page: number;
26
+ pageSize: number;
27
+ };
28
+ //# sourceMappingURL=response-utils.d.ts.map
@@ -59,6 +59,57 @@ export interface ApiResult {
59
59
  /** 可选数据 */
60
60
  data?: unknown;
61
61
  }
62
+ export type RuleMaintenanceSeverity = 'info' | 'warning' | 'error';
63
+ export type RuleMaintenanceCategory = 'request' | 'dsl' | 'component' | 'endpoint' | 'runtime' | 'security' | 'compatibility';
64
+ export interface RuleMaintenanceIssue {
65
+ id: string;
66
+ severity: RuleMaintenanceSeverity;
67
+ category: RuleMaintenanceCategory;
68
+ message: string;
69
+ nodeId?: string;
70
+ nodeType?: string;
71
+ endpointId?: string;
72
+ path?: string;
73
+ evidence?: string[];
74
+ suggestion?: string;
75
+ }
76
+ export interface RuleMaintenanceRuntimeInfo {
77
+ ruleGoVersion?: string;
78
+ componentCount?: number;
79
+ componentFamilies?: string[];
80
+ huanbanAdapters?: string[];
81
+ endpointDslVersion?: string;
82
+ }
83
+ export interface RuleValidateUpstreamRequest {
84
+ chainId: string;
85
+ dsl: Record<string, unknown>;
86
+ options?: Record<string, unknown>;
87
+ }
88
+ export interface RuleValidateUpstreamResponse {
89
+ valid: boolean;
90
+ issues: RuleMaintenanceIssue[];
91
+ runtimeInfo?: RuleMaintenanceRuntimeInfo;
92
+ }
93
+ export interface RuleSchemaDiffResponse {
94
+ changes: Array<Record<string, unknown>>;
95
+ issues?: RuleMaintenanceIssue[];
96
+ }
97
+ export interface RuleRepairPlanResponse {
98
+ plan: Array<Record<string, unknown>>;
99
+ issues: RuleMaintenanceIssue[];
100
+ summary?: string;
101
+ }
102
+ export interface JSONPatchOperation {
103
+ op: 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';
104
+ path: string;
105
+ from?: string;
106
+ value?: unknown;
107
+ }
108
+ export interface RulePatchPreviewResponse {
109
+ preview: Record<string, unknown>;
110
+ rejected: RuleMaintenanceIssue[];
111
+ issues?: RuleMaintenanceIssue[];
112
+ }
62
113
  /**
63
114
  * 工作流请求适配器接口
64
115
  *
@@ -112,6 +163,14 @@ export interface WorkflowFetcher {
112
163
  saveBaseInfo: (id: string, info: Record<string, unknown>) => Promise<ApiResult>;
113
164
  /** 保存配置(变量或秘钥) */
114
165
  saveConfig: (id: string, configType: 'vars' | 'secrets', data: Record<string, string>) => Promise<ApiResult>;
166
+ /** 运行上游兼容校验,只读,不保存、不部署 */
167
+ validateUpstream?: (id: string, dsl: Record<string, unknown>, options?: Record<string, unknown>) => Promise<RuleValidateUpstreamResponse>;
168
+ /** 获取结构差异,只读 */
169
+ getSchemaDiff?: (id: string) => Promise<RuleSchemaDiffResponse>;
170
+ /** 获取修复建议,只读,不保存 */
171
+ getRepairPlan?: (id: string, dsl: Record<string, unknown>, options?: Record<string, unknown>) => Promise<RuleRepairPlanResponse>;
172
+ /** 预览补丁结果,只读,不保存、不部署 */
173
+ previewPatch?: (id: string, dsl: Record<string, unknown>, operations: JSONPatchOperation[]) => Promise<RulePatchPreviewResponse>;
115
174
  }
116
175
  /**
117
176
  * 工作流列表图标映射
@@ -209,6 +268,14 @@ export interface RuleChainRoutes {
209
268
  saveBaseInfo: (id: string) => string;
210
269
  /** 保存配置路径,接收 (id, configType) => string,默认 '/rules/:id/config/:configType' */
211
270
  saveConfig: (id: string, configType: string) => string;
271
+ /** 上游兼容校验路径,默认 '/rules/:id/validate-upstream' */
272
+ validateUpstream: (id: string) => string;
273
+ /** 结构差异路径,默认 '/rules/:id/schema-diff' */
274
+ schemaDiff: (id: string) => string;
275
+ /** 修复建议路径,默认 '/rules/:id/repair-plan' */
276
+ repairPlan: (id: string) => string;
277
+ /** 补丁预览路径,默认 '/rules/:id/patch-preview' */
278
+ patchPreview: (id: string) => string;
212
279
  }
213
280
  /**
214
281
  * 默认路由映射
@@ -31,7 +31,7 @@ export interface AutoLayoutOptions {
31
31
  startX?: number;
32
32
  /** 起始 Y 坐标 (像素), 默认 200 */
33
33
  startY?: number;
34
- /** Start 节点 ID (固定在最左侧), 默认 'start' */
34
+ /** Start 节点 ID (固定在最左侧), 默认 '$node_start_input' */
35
35
  startNodeId?: string;
36
36
  /** 节点宽度 (用于计算连线端点), 默认 200 */
37
37
  nodeWidth?: number;
@@ -102,7 +102,10 @@ export declare class ComponentRegistry {
102
102
  *
103
103
  * @returns 分组后的组件列表
104
104
  */
105
- getGroups(): ComponentGroup[];
105
+ getGroups(options?: {
106
+ translateCategory?: (categoryKey: string, fallback: string) => string | undefined;
107
+ sort?: boolean;
108
+ }): ComponentGroup[];
106
109
  /**
107
110
  * 从后端 API 返回的原始数据加载组件
108
111
  *
@@ -137,5 +140,12 @@ export declare class ComponentRegistry {
137
140
  * 清空所有已注册组件
138
141
  */
139
142
  clear(): void;
143
+ /**
144
+ * 检查是否存在某个分类下的组件 (用于特性的平滑降级探测)
145
+ *
146
+ * @param categoryName - 分类名称
147
+ * @returns boolean
148
+ */
149
+ hasCategory(categoryName: string): boolean;
140
150
  }
141
151
  //# sourceMappingURL=ComponentRegistry.d.ts.map
@@ -74,7 +74,7 @@ import { I18nManager } from './I18nManager';
74
74
  import type { EditorOptions, EditorInternalData, EditorPlugin } from '../types/editor';
75
75
  import type { EditorEventMap, EditorEventName } from '../types/events';
76
76
  import type { RuleChainData, RuleChainConfig, RuleNodeConfig, RuleConnectionConfig } from '../types/rule-chain';
77
- import type { ComponentDefinition, ComponentGroup } from '../types/component';
77
+ import type { ComponentDefinition, ComponentGroup, RawComponentData } from '../types/component';
78
78
  /**
79
79
  * 编辑器内部使用的状态结构
80
80
  *
@@ -147,6 +147,8 @@ export declare class EditorCore {
147
147
  private plugins;
148
148
  /** 是否已初始化 */
149
149
  private initialized;
150
+ /** 语言变更取消监听 */
151
+ private disposeLocaleChange;
150
152
  /**
151
153
  * 创建编辑器核心实例
152
154
  *
@@ -173,6 +175,26 @@ export declare class EditorCore {
173
175
  * 必须在组件卸载时调用 (框架适配层的 unmounted/useEffect cleanup 中)
174
176
  */
175
177
  destroy(): void;
178
+ /**
179
+ * 加载组件定义并同步组件映射、分组状态。
180
+ *
181
+ * 框架适配层应优先使用该入口;直接操作 componentRegistry 只会更新注册表,
182
+ * 不会自动通知 React/Vue/DOM UI 订阅的 componentGroups。
183
+ *
184
+ * @param components - 组件定义列表,通常来自 /api/v1/components 或 options.components
185
+ * @returns 按分类分组后的组件列表
186
+ */
187
+ loadComponents(components: RawComponentData): ComponentGroup[];
188
+ /**
189
+ * 增量注册组件定义并同步组件分组状态。
190
+ *
191
+ * @param components - 需要追加或覆盖的组件定义
192
+ * @param overwrite - 已存在 type 时是否覆盖
193
+ * @returns 按分类分组后的组件列表
194
+ */
195
+ registerComponents(components: ComponentDefinition[], overwrite?: boolean): ComponentGroup[];
196
+ private syncComponentState;
197
+ private localizeComponentGroups;
176
198
  /**
177
199
  * 加载规则链数据并渲染到画布
178
200
  *
@@ -16,6 +16,24 @@
16
16
  * 语言包类型 (支持嵌套)
17
17
  */
18
18
  export type LocaleMessages = Record<string, string | Record<string, unknown>>;
19
+ /**
20
+ * 可提供翻译能力的对象或函数。
21
+ *
22
+ * I18nManager.t 在缺少 key 时会返回 key 本身;UI 代码需要区分“真实翻译”
23
+ * 和“缺失 key”,否则 `t(key) || fallback` 这类写法永远不会触发 fallback。
24
+ */
25
+ export type TranslationSource = {
26
+ t?: (key: string, params?: Record<string, string | number>) => string;
27
+ } | ((key: string, params?: Record<string, string | number>) => string) | null | undefined;
28
+ /**
29
+ * 获取带 fallback 的翻译文本。
30
+ *
31
+ * @param source - I18nManager、带 t 方法的对象,或翻译函数
32
+ * @param key - 翻译 key
33
+ * @param fallback - 缺少翻译时使用的文本
34
+ * @param params - 插值变量
35
+ */
36
+ export declare function i18nText(source: TranslationSource, key: string, fallback: string, params?: Record<string, string | number>): string;
19
37
  /**
20
38
  * 语言变更回调
21
39
  */
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Optimizations.ts
3
+ * @description 针对 LogicFlow 在复杂编排场景下(大批量算子重绘)的性能优化策略及内存泄漏防护。
4
+ */
5
+ import LogicFlow from '@logicflow/core';
6
+ /**
7
+ * 彻底销毁 LogicFlow 实例,阻断由于闭包引起的内存泄漏
8
+ *
9
+ * 核心优化:
10
+ * 官方的 RuleGoEditor 在生命周期销毁时仅调用了 `lf.destroy()`。
11
+ * 若在单页应用 (Vue/React) 中频繁切换路由,底层的 Mouse/Keyboard Listener 可能未被彻底释放。
12
+ *
13
+ * @param lf 实例
14
+ */
15
+ export declare const destroyEditor: (lf: LogicFlow | null) => void;
16
+ //# sourceMappingURL=Optimizations.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file RuleChainChatManager.ts
3
+ * @description 管理 AI 对话窗口状态,支持多规则链开窗的隔离状态
4
+ */
5
+ /**
6
+ * 聊天消息实体接口
7
+ * @interface ChatMessage
8
+ */
9
+ export interface ChatMessage {
10
+ /** 消息发送方角色 */
11
+ role: 'user' | 'assistant';
12
+ /** 消息文本内容 */
13
+ content: string;
14
+ /** 发送时间戳 (毫秒) */
15
+ timestamp: number;
16
+ }
17
+ /**
18
+ * AI Copilot 对话管理器
19
+ *
20
+ * @class RuleChainChatManager
21
+ * @description 负责集中化管理 AI 对话面板的状态。
22
+ * 该管理器支持多个规则链各自持有独立的对话历史(通过 ruleChainId 隔离隔离)。
23
+ * 底层利用 `localStorage` 自动落盘,刷新页面对话状态不丢失。
24
+ */
25
+ export declare class RuleChainChatManager {
26
+ private chatStates;
27
+ private storagePrefix;
28
+ /**
29
+ * 构造函数:初始化时自动恢复历史状态
30
+ */
31
+ constructor();
32
+ /**
33
+ * 获取指定规则链的全部聊天记录
34
+ * @param ruleChainId 规则链唯一标识
35
+ * @returns 聊天记录数组
36
+ */
37
+ getMessages(ruleChainId: string): ChatMessage[];
38
+ /**
39
+ * 向指定规则链对话追加一条消息
40
+ * @param ruleChainId 规则链唯一标识
41
+ * @param message 消息实体对象
42
+ */
43
+ addMessage(ruleChainId: string, message: ChatMessage): void;
44
+ /**
45
+ * 清除指定规则链的聊天记录 (包括本地存储)
46
+ * @param ruleChainId 规则链唯一标识
47
+ */
48
+ clear(ruleChainId: string): void;
49
+ private saveState;
50
+ private restoreAll;
51
+ }
52
+ export declare const ruleChainChatManager: RuleChainChatManager;
53
+ //# sourceMappingURL=RuleChainChatManager.d.ts.map