@digitalsee-ai/rcs 1.0.0 → 1.0.1

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 CHANGED
@@ -1,237 +1,69 @@
1
- ![logo](https://www.digitalsee.cn/_next/static/media/logo_purple.a1d68599.svg)
2
-
3
- # @digitalsee/rcs
4
-
5
- **数犀 React 组件库**
1
+ # @digitalsee-ai/rcs
6
2
 
7
-
8
- 为数犀内部提供跨工程运行的React组件服务
9
-
3
+ 数犀 React 组件库,当前主要提供工作流画布、DynamicForm 和 JsonRenderer。
10
4
 
11
- ---
5
+ ## 环境要求
12
6
 
13
- ## 📦 安装
7
+ - Node.js `>= 22`
8
+ - pnpm `10.12.1`
14
9
 
15
- 使用 pnpm(推荐):
16
- ```bash
17
- pnpm add @digitalsee/rcs
18
- ```
10
+ ## 安装与使用
19
11
 
20
- 使用 npm:
21
12
  ```bash
22
- npm install @digitalsee/rcs
13
+ pnpm add @digitalsee-ai/rcs
23
14
  ```
24
15
 
25
- 使用 yarn:
26
- ```bash
27
- yarn add @digitalsee/rcs
28
- ```
29
-
30
- ## ✨ 特性
31
-
32
- - 🎨 **工作流编辑器** - 基于 ReactFlow 的强大可视化工作流编辑器
33
- - 📊 **数据可视化** - 内置 JSON 渲染器和数据展示组件
34
- - 🌍 **国际化支持** - 内置中文(简体/繁体)和英文支持
35
- - 🎯 **TypeScript** - 完整的 TypeScript 类型支持
36
- - 🔧 **可定制** - 灵活的配置和主题定制
37
- - ⚡ **高性能** - 优化的渲染性能和内存使用
38
- - 📱 **响应式** - 适配各种屏幕尺寸
39
-
40
- ## 🚀 快速开始
41
-
42
- ### 基础使用
43
-
44
16
  ```tsx
45
- import { Workflow } from '@digitalsee/rcs';
46
- import '@digitalsee/rcs/styles.css';
47
-
48
- function App() {
49
- return (
50
- <Workflow
51
- workflowId="my-workflow"
52
- // 更多配置项...
53
- />
54
- );
17
+ import { DigitalseeWorkFlow } from '@digitalsee-ai/rcs';
18
+ import '@digitalsee-ai/rcs/styles.css';
19
+
20
+ export function WorkflowPage() {
21
+ return <DigitalseeWorkFlow workflowId="workflow-id" />;
55
22
  }
56
23
  ```
57
24
 
58
- ### 使用 JsonRenderer
25
+ DynamicForm 示例:
59
26
 
60
27
  ```tsx
61
- import { JsonRenderer } from '@digitalsee/rcs';
62
- import '@digitalsee/rcs/styles.css';
28
+ import { DynamicForm, DynamicFormField, type FormSchema } from '@digitalsee-ai/rcs';
29
+ import '@digitalsee-ai/rcs/styles.css';
63
30
 
64
- function App() {
65
- const data = {
66
- name: "示例数据",
67
- value: 123
68
- };
31
+ const schema: FormSchema = {
32
+ fields: [{ type: DynamicFormField.TEXT, name: 'name', label: '名称' }],
33
+ };
69
34
 
70
- return <JsonRenderer data={data} />;
35
+ export function FormPage() {
36
+ return <DynamicForm schema={schema} />;
71
37
  }
72
38
  ```
73
39
 
74
- ## 📚 主要组件
75
-
76
- ### 🔄 Workflow(工作流)
77
-
78
- 完整的可视化工作流编辑器,支持:
79
-
80
- - ✅ 节点的拖拽和连接
81
- - ✅ 自定义节点类型
82
- - ✅ 边的样式和交互
83
- - ✅ 撤销/重做功能
84
- - ✅ 小地图导航
85
- - ✅ 自动布局
86
- - ✅ 调试面板
87
- - ✅ 数据持久化
88
-
89
- **主要特性:**
90
- - 支持多种节点类型(触发器、动作、条件等)
91
- - 灵活的节点配置面板
92
- - 实时数据流调试
93
- - 节点搜索和筛选
94
- - 快捷键支持
95
-
96
- ### 📋 JsonRenderer
97
-
98
- 强大的 JSON 数据渲染组件:
99
- - 语法高亮
100
- - 可折叠/展开
101
- - 搜索功能
102
- - 复制功能
103
-
104
- ## 🔨 开发
105
-
106
- ### 环境要求
107
-
108
- - Node.js >= 22
109
- - pnpm >= 10.12.1
110
-
111
- ### 开发命令
40
+ ## 开发命令
112
41
 
113
42
  ```bash
114
- # 安装依赖
115
43
  pnpm install
116
-
117
- # 启动 Storybook 开发环境
118
- pnpm dev
119
-
120
- # 构建组件库
121
- pnpm build:vite
122
-
123
- # 运行测试
124
- pnpm test
125
-
126
- # 代码格式化
127
- pnpm format
128
-
129
- # 代码检查
130
- pnpm lint
131
- ```
132
-
133
- ### 构建输出
134
-
135
- ```bash
136
- # 构建并发布新版本
137
- pnpm update:version
138
- ```
139
-
140
- 构建产物包括:
141
- - `dist/rcs.es.js` - ES Module 格式
142
- - `dist/rcs.umd.js` - UMD 格式
143
- - `dist/rcs.css` - 样式文件
144
- - `dist/index.d.ts` - TypeScript 类型定义
145
-
146
- ## 🎨 技术栈
147
-
148
- - **核心框架**: React 19+
149
- - **状态管理**: Redux Toolkit
150
- - **流程图**: @xyflow/react
151
- - **UI 组件**: Ant Design 5+ / Ant Design Pro Components
152
- - **样式方案**: Tailwind CSS + Less
153
- - **代码编辑器**: Monaco Editor / CodeMirror
154
- - **富文本**: Slate.js
155
- - **构建工具**: Vite
156
- - **文档工具**: Storybook
157
- - **代码质量**: Biome
158
- - **测试框架**: Vitest
159
-
160
- ## 📖 依赖要求
161
-
162
- ### Peer Dependencies
163
-
164
- 确保你的项目中已安装以下依赖:
165
-
166
- - `react` >= 18.0.0
167
- - `react-dom` >= 18.0.0
168
- - `antd` >= 5.0.0
169
- - `@ant-design/icons` >= 5.0.0
170
- - `@ant-design/pro-components` >= 2.0.0
171
- - `@reduxjs/toolkit` >= 2.0.0
172
- - `react-redux` >= 9.0.0
173
- - `@xyflow/react` >= 12.0.0
174
- - `ahooks` >= 3.0.0
175
- - `lodash-es` >= 4.17.0
176
-
177
- ## 🌐 国际化
178
-
179
- 组件库内置多语言支持:
180
-
181
- ```tsx
182
- import { IntlProvider } from 'react-intl';
183
- import zhCN from '@digitalsee/rcs/locales/zh-CN';
184
-
185
- <IntlProvider locale="zh-CN" messages={zhCN}>
186
- <Workflow />
187
- </IntlProvider>
44
+ pnpm dev # Storybook,默认 http://localhost:8888
45
+ pnpm build:lib # tsc + Vite,生成 dist
46
+ pnpm build:vite # 仅 Vite 构建,适合快速联调
47
+ pnpm tsc # 类型检查
48
+ pnpm test # Vitest watch
49
+ pnpm test:cov # 单次运行并生成覆盖率
50
+ pnpm format # Biome 格式化 src
51
+ pnpm lint # Biome lint 并自动修复 src
188
52
  ```
189
53
 
190
- 支持的语言:
191
- - 🇨🇳 简体中文 (zh-CN)
192
- - 🇹🇼 繁体中文 (zh-TW)
193
- - 🇺🇸 英文 (en-US)
194
-
195
- ## 📝 版本管理
196
-
197
- ```bash
198
- # 补丁版本 (0.0.x)
199
- pnpm bump
200
-
201
- # 次要版本 (0.x.0)
202
- pnpm bump:minor
203
-
204
- # 主要版本 (x.0.0)
205
- pnpm bump:major
206
- ```
207
-
208
- ## 🤝 贡献
209
-
210
- 欢迎提交 Issue 和 Pull Request!
211
-
212
- ### 开发流程
213
-
214
- 1. Fork 本仓库
215
- 2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
216
- 3. 提交你的改动 (`git commit -m 'Add some AmazingFeature'`)
217
- 4. 推送到分支 (`git push origin feature/AmazingFeature`)
218
- 5. 提交 Pull Request
219
-
220
- ### 代码规范
221
-
222
- 项目使用 Biome 进行代码检查和格式化:
223
- ```bash
224
- pnpm format # 自动格式化代码
225
- pnpm lint # 检查代码问题
226
- ```
54
+ `dist/` 是 npm 包实际消费的构建产物。修改源码后,宿主项目不会自动获得更新,需重新构建。
227
55
 
56
+ ## 文档
228
57
 
229
- ## 🔗 相关链接
58
+ - [文档索引与维护状态](docs/README.md)
59
+ - [本地联调 npm 包](docs/development/local-package-debugging.md)
60
+ - [工作流组件集成](docs/guides/workflow-integration.md)
61
+ - [发布说明](docs/development/publishing.md)
230
62
 
231
- - [数犀官网](https://www.digitalsee.cn)
63
+ ## 包导出
232
64
 
233
- ---
65
+ - `@digitalsee-ai/rcs`:组件、类型与工具
66
+ - `@digitalsee-ai/rcs/styles.css`:组件库样式
234
67
 
235
- <div align="center">
236
- Made with ❤️ by <a href="https://www.digitalsee.cn">数犀 DigitalSee</a>
237
- </div>
68
+ 构建产物包括 `dist/rcs.es.js`、`dist/rcs.umd.js`、`dist/rcs.css` 和
69
+ `dist/index.d.ts`。
@@ -98,7 +98,7 @@ export declare function dipGetNodeSchema(nodeKey: string, version?: number): Pro
98
98
  * @param request - 节点测试请求参数
99
99
  * @returns 节点测试结果(含 outputData、resolvedParams、executionTimeMs)
100
100
  * @see POST /api/nodes/test
101
- * @see doc/node-test-api-guide.md
101
+ * @see docs/reference/node-test-api.md
102
102
  */
103
103
  export declare function dipTestNode(request: DipNodeTestRequest): Promise<DipNodeTestResult>;
104
104
  /**
@@ -937,7 +937,7 @@ export interface DipPageWorkflowDefinitionEntity {
937
937
  * 对应后端 {@link NodeTestRequest} record,提交给 `POST /api/nodes/test`。
938
938
  * 前端负责管理测试历史和上下文,后端完全无状态,支持集群部署。
939
939
  *
940
- * @see doc/node-test-api-guide.md
940
+ * @see docs/reference/node-test-api.md
941
941
  */
942
942
  export interface DipNodeTestRequest {
943
943
  /** 节点类型标识(必填),如 `"http_request"` */
@@ -11,7 +11,7 @@ interface GlobalWorkflowConfig {
11
11
  *
12
12
  * @example
13
13
  * ```typescript
14
- * import { configureWorkflow } from 'digitalsee-rcs';
14
+ * import { configureWorkflow } from '@digitalsee-ai/rcs';
15
15
  * import axios from 'axios';
16
16
  * import { useHistory } from 'react-router-dom';
17
17
  *
@@ -1,6 +1,5 @@
1
- import { default as React } from 'react';
2
1
  import { default as defaultCanvasEngineConfig } from './config/defaultCanvasEngineConfig';
3
- import { CanvasEngineConfig, HistoryNavigator, HttpClient } from './types/engine';
2
+ import { CanvasEngineConfig, DeepPartial, HistoryNavigator, HttpClient, CanvasAPI } from './types/engine';
4
3
  import { mergeConfig } from './utils/mergeConfig';
5
4
  import { LocaleType } from '../../../locales';
6
5
  import { EngineMode } from './enums/workflow';
@@ -46,12 +45,18 @@ export interface DigitalseeWorkFlowProps {
46
45
  * @param workflow 当前工作流数据
47
46
  */
48
47
  onSave?: (workflow: any) => void;
48
+ /**
49
+ * 画布初始化回调
50
+ *
51
+ * @param api 画布对外 API
52
+ */
53
+ onInit?: (api: CanvasAPI) => void;
49
54
  /**
50
55
  * 画布配置
51
56
  *
52
57
  * @description 支持传入局部配置,内部会与默认配置做深度合并
53
58
  */
54
- config?: Partial<CanvasEngineConfig>;
59
+ config?: DeepPartial<CanvasEngineConfig>;
55
60
  /**
56
61
  * Locale override for workflow translations
57
62
  *
@@ -95,11 +100,14 @@ export interface DigitalseeWorkFlowProps {
95
100
  *
96
101
  * @param props 组件参数
97
102
  */
98
- declare const DigitalseeWorkFlow: React.FC<DigitalseeWorkFlowProps>;
103
+ declare const DigitalseeWorkFlow: (props: DigitalseeWorkFlowProps) => any;
99
104
  export { DigitalseeWorkFlow };
100
105
  export type { WorkflowHttpClient } from './api';
101
- export type { CanvasEngineConfig, HistoryNavigator, HttpClient, } from './types/engine';
102
- export { EngineMode } from './enums/workflow';
106
+ export type { CanvasAPI, CanvasEngineConfig, DeepPartial, HistoryNavigator, HttpClient, } from './types/engine';
107
+ export { EngineMode, WorkflowOpStatus } from './enums/workflow';
108
+ export { NodeStatus, NodeType } from './enums/node';
109
+ export { useCanvasApi } from './context/canvasApiContext';
110
+ export { useCanvasConfig } from './context/canvasConfig';
103
111
  export { defaultCanvasEngineConfig, mergeConfig };
104
112
  export type { LocaleType as WorkflowLocale, TranslateFn as WorkflowTranslateFn, } from '../../../locales';
105
113
  export { createTranslator } from '../../../locales';
@@ -1,7 +1,7 @@
1
1
  import { ReactFlow } from '@xyflow/react';
2
2
  import { ComponentProps, ReactNode } from 'react';
3
3
  import { Rule } from 'antd/es/form';
4
- import { EngineMode } from '../enums/workflow';
4
+ import { EngineMode, WorkflowOpStatus } from '../enums/workflow';
5
5
  export type HttpClient = <T = any>(url: string, config: any) => Promise<T>;
6
6
  export interface HistoryNavigator {
7
7
  push(path: string, state?: any): void;
@@ -11,6 +11,9 @@ export interface HistoryNavigator {
11
11
  goForward(): void;
12
12
  listen?(listener: (location: any, action: any) => void): () => void;
13
13
  }
14
+ export type DeepPartial<T> = {
15
+ [P in keyof T]?: T[P] extends (...args: any[]) => any ? T[P] : T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends object ? DeepPartial<T[P]> : T[P];
16
+ };
14
17
  export interface CanvasEngineConfig {
15
18
  flowId: string;
16
19
  engineMode?: EngineMode;
@@ -58,6 +61,7 @@ export interface CanvasCoreConfig {
58
61
  }
59
62
  export interface NodeTypesRegistryConfig {
60
63
  types: Record<string, NodeTypeConfig>;
64
+ nodeBlackList?: string[];
61
65
  fixed?: {
62
66
  triggers?: string[];
63
67
  finalAction?: string;
@@ -148,6 +152,8 @@ export interface ToolbarButtonConfig {
148
152
  icon?: ReactNode;
149
153
  style?: Record<string, any>;
150
154
  type?: 'link' | 'text' | 'default' | 'primary' | 'dashed';
155
+ danger?: boolean;
156
+ loading?: boolean;
151
157
  onClick?: (ctx: CanvasAPI) => void;
152
158
  }
153
159
  export interface NodeConfigPanelConfig {
@@ -190,6 +196,7 @@ export interface CanvasAPI {
190
196
  init(): void;
191
197
  destroy(): void;
192
198
  refresh(): void;
199
+ setFlowOpStatus(status: WorkflowOpStatus): void;
193
200
  getData(): FlowData;
194
201
  setData(flow: FlowData): void;
195
202
  exportJSON(): any;
@@ -1,7 +1,4 @@
1
- /**
2
- * mergeConfig - Deep merge helper for CanvasEngineConfig
3
- * 支持深度合并、数组自定义合并策略、对象合并、函数覆盖
4
- */
1
+ import { DeepPartial } from '../types/engine';
5
2
  type MergeArrayStrategy = 'append' | 'override' | 'mergeById';
6
3
  /**
7
4
  * merge options
@@ -13,10 +10,10 @@ export interface MergeConfigOptions {
13
10
  /**
14
11
  * Deep merge core function
15
12
  */
16
- export declare function mergeDeep<T>(target: Partial<T>, source: Partial<T>, options?: MergeConfigOptions): T;
13
+ export declare function mergeDeep<T>(target: T | DeepPartial<T>, source: DeepPartial<T>, options?: MergeConfigOptions): T;
17
14
  /**
18
15
  * 业务常用:合并 CanvasEngineConfig
19
16
  * mergeConfig(defaultConfig, customConfig)
20
17
  */
21
- export declare function mergeConfig<T>(base: T, override: Partial<T>, options?: MergeConfigOptions): T;
18
+ export declare function mergeConfig<T>(base: T, override: DeepPartial<T>, options?: MergeConfigOptions): T;
22
19
  export default mergeConfig;