ice-entity-designer 0.0.20 → 0.0.21
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 +51 -2
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/react.cjs +3 -3
- package/dist/react.mjs +3 -3
- package/dist/types/designer/EntityDesigner.d.mts +1 -1
- package/dist/types/designer/EntityDesigner.d.ts +1 -1
- package/dist/types/er-component/Entity.d.mts +5 -0
- package/dist/types/er-component/Entity.d.ts +5 -0
- package/dist/types/er-component/Relation.d.mts +2 -0
- package/dist/types/er-component/Relation.d.ts +2 -0
- package/dist/types/flow/FlowDesigner.d.mts +25 -14
- package/dist/types/flow/FlowDesigner.d.ts +25 -14
- package/dist/types/flow/FlowEdge.d.mts +2 -15
- package/dist/types/flow/FlowEdge.d.ts +2 -15
- package/dist/types/flow/FlowNode.d.mts +5 -15
- package/dist/types/flow/FlowNode.d.ts +5 -15
- package/dist/types/ice-render/graphic/ICEComponent.d.mts +12 -0
- package/dist/types/ice-render/graphic/ICEComponent.d.ts +12 -0
- package/dist/types/ice-render/index.d.mts +2 -0
- package/dist/types/ice-render/index.d.ts +2 -0
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/react/FlowDesignerCanvas.d.mts +14 -0
- package/dist/types/react/FlowDesignerCanvas.d.ts +14 -0
- package/dist/types/react/context.d.mts +18 -1
- package/dist/types/react/context.d.ts +18 -1
- package/dist/types/react/index.d.mts +8 -1
- package/dist/types/react/index.d.ts +8 -1
- package/dist/types/react/reportLoadError.d.mts +8 -0
- package/dist/types/react/reportLoadError.d.ts +8 -0
- package/dist/types/react/session.d.mts +22 -1
- package/dist/types/react/session.d.ts +22 -1
- package/dist/types/react/types.d.mts +59 -1
- package/dist/types/react/types.d.ts +59 -1
- package/dist/types/utils/project_codec.d.mts +66 -0
- package/dist/types/utils/project_codec.d.ts +66 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* React 绑定层的类型定义。
|
|
3
3
|
*/
|
|
4
|
-
import type { EntityDesigner, ProjectLoadReport } from '../index.mjs';
|
|
4
|
+
import type { EntityDesigner, FlowDesigner, FlowLoadReport, FlowNodeKind, ProjectLoadReport } from '../index.mjs';
|
|
5
5
|
export declare type EntityDesignerChangePayload = {
|
|
6
6
|
/** 项目快照,等价于 designer.serializeProject() 的结果 */
|
|
7
7
|
snapshot: string;
|
|
@@ -62,3 +62,61 @@ export declare type EntityDesignerCanvasProps = {
|
|
|
62
62
|
/** 子节点渲染在上下文内部,可直接使用 useEntityDesigner() */
|
|
63
63
|
children?: any;
|
|
64
64
|
};
|
|
65
|
+
export declare type FlowDesignerChangePayload = {
|
|
66
|
+
/** 流程图快照,等价于 designer.serialize() 的结果 */
|
|
67
|
+
snapshot: string;
|
|
68
|
+
/** 当前节点 / 连线条数,便于直接渲染统计信息 */
|
|
69
|
+
counts: {
|
|
70
|
+
nodes: number;
|
|
71
|
+
edges: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export declare type FlowDesignerHandle = {
|
|
75
|
+
/** 底层 ICE 实例(卸载后为 null) */
|
|
76
|
+
ice: any;
|
|
77
|
+
/** 底层 FlowDesigner 实例(卸载后为 null) */
|
|
78
|
+
designer: FlowDesigner | null;
|
|
79
|
+
addNode(kind: FlowNodeKind, props?: any): any;
|
|
80
|
+
connect(props: any): any;
|
|
81
|
+
updateNode(id: string, patch: any): any;
|
|
82
|
+
updateEdge(id: string, patch: any): any;
|
|
83
|
+
remove(id: string): void;
|
|
84
|
+
load(json: string): FlowLoadReport;
|
|
85
|
+
undo(): void;
|
|
86
|
+
redo(): void;
|
|
87
|
+
serialize(): string;
|
|
88
|
+
toSnapshot(): any;
|
|
89
|
+
fitViewport(padding?: number): void;
|
|
90
|
+
};
|
|
91
|
+
export declare type FlowDesignerCanvasProps = {
|
|
92
|
+
/**
|
|
93
|
+
* 受控模式:流程图快照。变化时会同步进画布(内部变更通过 onChange 上报,带循环保护)。
|
|
94
|
+
* 与 defaultValue 互斥,value 优先。
|
|
95
|
+
*/
|
|
96
|
+
value?: string;
|
|
97
|
+
/** 非受控模式:初始流程图快照(等价于 load(defaultValue)) */
|
|
98
|
+
defaultValue?: string;
|
|
99
|
+
/** 渲染模式,默认 dirty-rect */
|
|
100
|
+
renderMode?: 'dirty-rect' | 'full';
|
|
101
|
+
/**
|
|
102
|
+
* 流程变更回调(建节点 / 连线 / 改属性 / 画布拖动 / 载入 / undo / redo 之后触发)。
|
|
103
|
+
* 注意:画布上拖动节点也会触发(FlowDesigner 订阅了引擎的 BEFORE_MOVE / AFTER_MOVE),
|
|
104
|
+
* 因此依赖它的自动保存能拿到拖拽后的最新坐标。
|
|
105
|
+
*/
|
|
106
|
+
onChange?: (payload: FlowDesignerChangePayload) => void;
|
|
107
|
+
/**
|
|
108
|
+
* 快照载入失败回调(非法 / 结构不合法)。不传时默认 console.error;
|
|
109
|
+
* 组件内部已捕获,不会把错误抛进 React 渲染树。
|
|
110
|
+
*/
|
|
111
|
+
onError?: (payload: EntityDesignerErrorPayload) => void;
|
|
112
|
+
/** 实例就绪回调,回调里拿到命令式句柄 */
|
|
113
|
+
onReady?: (handle: FlowDesignerHandle) => void;
|
|
114
|
+
className?: string;
|
|
115
|
+
/** 容器内联样式(与 width/height 合并) */
|
|
116
|
+
style?: any;
|
|
117
|
+
/** 画布宽高(像素),同时作为容器尺寸,默认 1200 x 800 */
|
|
118
|
+
width?: number;
|
|
119
|
+
height?: number;
|
|
120
|
+
/** 子节点渲染在上下文内部,可直接使用 useFlowDesigner() */
|
|
121
|
+
children?: any;
|
|
122
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* React 绑定层的类型定义。
|
|
3
3
|
*/
|
|
4
|
-
import type { EntityDesigner, ProjectLoadReport } from '../index';
|
|
4
|
+
import type { EntityDesigner, FlowDesigner, FlowLoadReport, FlowNodeKind, ProjectLoadReport } from '../index';
|
|
5
5
|
export declare type EntityDesignerChangePayload = {
|
|
6
6
|
/** 项目快照,等价于 designer.serializeProject() 的结果 */
|
|
7
7
|
snapshot: string;
|
|
@@ -62,3 +62,61 @@ export declare type EntityDesignerCanvasProps = {
|
|
|
62
62
|
/** 子节点渲染在上下文内部,可直接使用 useEntityDesigner() */
|
|
63
63
|
children?: any;
|
|
64
64
|
};
|
|
65
|
+
export declare type FlowDesignerChangePayload = {
|
|
66
|
+
/** 流程图快照,等价于 designer.serialize() 的结果 */
|
|
67
|
+
snapshot: string;
|
|
68
|
+
/** 当前节点 / 连线条数,便于直接渲染统计信息 */
|
|
69
|
+
counts: {
|
|
70
|
+
nodes: number;
|
|
71
|
+
edges: number;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export declare type FlowDesignerHandle = {
|
|
75
|
+
/** 底层 ICE 实例(卸载后为 null) */
|
|
76
|
+
ice: any;
|
|
77
|
+
/** 底层 FlowDesigner 实例(卸载后为 null) */
|
|
78
|
+
designer: FlowDesigner | null;
|
|
79
|
+
addNode(kind: FlowNodeKind, props?: any): any;
|
|
80
|
+
connect(props: any): any;
|
|
81
|
+
updateNode(id: string, patch: any): any;
|
|
82
|
+
updateEdge(id: string, patch: any): any;
|
|
83
|
+
remove(id: string): void;
|
|
84
|
+
load(json: string): FlowLoadReport;
|
|
85
|
+
undo(): void;
|
|
86
|
+
redo(): void;
|
|
87
|
+
serialize(): string;
|
|
88
|
+
toSnapshot(): any;
|
|
89
|
+
fitViewport(padding?: number): void;
|
|
90
|
+
};
|
|
91
|
+
export declare type FlowDesignerCanvasProps = {
|
|
92
|
+
/**
|
|
93
|
+
* 受控模式:流程图快照。变化时会同步进画布(内部变更通过 onChange 上报,带循环保护)。
|
|
94
|
+
* 与 defaultValue 互斥,value 优先。
|
|
95
|
+
*/
|
|
96
|
+
value?: string;
|
|
97
|
+
/** 非受控模式:初始流程图快照(等价于 load(defaultValue)) */
|
|
98
|
+
defaultValue?: string;
|
|
99
|
+
/** 渲染模式,默认 dirty-rect */
|
|
100
|
+
renderMode?: 'dirty-rect' | 'full';
|
|
101
|
+
/**
|
|
102
|
+
* 流程变更回调(建节点 / 连线 / 改属性 / 画布拖动 / 载入 / undo / redo 之后触发)。
|
|
103
|
+
* 注意:画布上拖动节点也会触发(FlowDesigner 订阅了引擎的 BEFORE_MOVE / AFTER_MOVE),
|
|
104
|
+
* 因此依赖它的自动保存能拿到拖拽后的最新坐标。
|
|
105
|
+
*/
|
|
106
|
+
onChange?: (payload: FlowDesignerChangePayload) => void;
|
|
107
|
+
/**
|
|
108
|
+
* 快照载入失败回调(非法 / 结构不合法)。不传时默认 console.error;
|
|
109
|
+
* 组件内部已捕获,不会把错误抛进 React 渲染树。
|
|
110
|
+
*/
|
|
111
|
+
onError?: (payload: EntityDesignerErrorPayload) => void;
|
|
112
|
+
/** 实例就绪回调,回调里拿到命令式句柄 */
|
|
113
|
+
onReady?: (handle: FlowDesignerHandle) => void;
|
|
114
|
+
className?: string;
|
|
115
|
+
/** 容器内联样式(与 width/height 合并) */
|
|
116
|
+
style?: any;
|
|
117
|
+
/** 画布宽高(像素),同时作为容器尺寸,默认 1200 x 800 */
|
|
118
|
+
width?: number;
|
|
119
|
+
height?: number;
|
|
120
|
+
/** 子节点渲染在上下文内部,可直接使用 useFlowDesigner() */
|
|
121
|
+
children?: any;
|
|
122
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 项目快照的**唯一字段定义**(codec)。
|
|
3
|
+
*
|
|
4
|
+
* 设计原则(与引擎的序列化机制保持一致):
|
|
5
|
+
* 1. 真相源是组件的 `state`,这里只声明「哪些键要进文档、以及它们的类型」;
|
|
6
|
+
* 2. 写(serializeProject)与校验(validateProjectSnapshot)**共用这一份定义**,
|
|
7
|
+
* 不允许 snapshot 与 validator 各写一套字段清单(历史上正是这样漂移出 bug 的);
|
|
8
|
+
* 3. 新增 state 字段却忘了登记时,`tests/designer/codec-completeness.test.ts`
|
|
9
|
+
* 会以「未覆盖的 state 键」形态报红,逼迫补登记或明确列入运行时字段。
|
|
10
|
+
*
|
|
11
|
+
* 与引擎的关系:引擎的 Serializer 是「遍历 state 减黑名单」,天然不会漏字段;
|
|
12
|
+
* 应用层因为要输出**扁平的领域文档**(AI/DSL/工具链消费),才需要这份显式契约,
|
|
13
|
+
* 但实现方式与引擎保持同构:类型分派走 typeId、可选值缺省即合法、未知类型跳过。
|
|
14
|
+
*/
|
|
15
|
+
export declare type CodecFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any';
|
|
16
|
+
export declare type CodecField = {
|
|
17
|
+
key: string;
|
|
18
|
+
/** 出现时校验的类型;缺省表示 any(透传) */
|
|
19
|
+
type?: CodecFieldType;
|
|
20
|
+
/** 该键必须存在(缺省即合法只对非必填字段成立) */
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/** 嵌套结构校验钩子(与字段定义同处一份,避免校验器另起一套) */
|
|
23
|
+
validate?: (value: any, prefix: string, errors: string[]) => void;
|
|
24
|
+
/** 文档用途说明(给人看) */
|
|
25
|
+
doc?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 应用层自定义 JSON 的透传键。
|
|
29
|
+
*
|
|
30
|
+
* 应用层可以把业务元数据挂在 `component.state.data` 上(任意 JSON),
|
|
31
|
+
* 它会原样写进项目快照并在载入时回填 —— 与引擎序列化对 state 的处理一致。
|
|
32
|
+
*/
|
|
33
|
+
export declare const PASS_THROUGH_KEY = "data";
|
|
34
|
+
/** 引擎运行时派生字段:不写进项目快照,载入后由引擎重算(与 Serializer 的黑名单同源) */
|
|
35
|
+
export declare const DERIVED_STATE_KEYS: string[];
|
|
36
|
+
/** 引擎默认值字段:不入文档,构造时由引擎按默认值补齐(值不变,故不算丢失) */
|
|
37
|
+
export declare const CONSTRUCTOR_DEFAULT_STATE_KEYS: string[];
|
|
38
|
+
/** Entity / Relation 通用字段 */
|
|
39
|
+
export declare const COMPONENT_BASE_FIELDS: CodecField[];
|
|
40
|
+
/** Entity 专有字段 */
|
|
41
|
+
export declare const ENTITY_FIELDS: CodecField[];
|
|
42
|
+
/** Relation 专有字段 */
|
|
43
|
+
export declare const RELATION_FIELDS: CodecField[];
|
|
44
|
+
/** 组装 Entity / Relation 的字段定义(专有 + 通用 + 透传) */
|
|
45
|
+
export declare const ENTITY_DOCUMENT_FIELDS: CodecField[];
|
|
46
|
+
export declare const RELATION_DOCUMENT_FIELDS: CodecField[];
|
|
47
|
+
/**
|
|
48
|
+
* 按字段定义从 state 里取值,组装成文档节点。
|
|
49
|
+
*
|
|
50
|
+
* - 只写「定义里列了、且 state 里不是 undefined」的键(保持文档紧凑、可读);
|
|
51
|
+
* - `data` 透传键原样带上。
|
|
52
|
+
*/
|
|
53
|
+
export declare function pickDocumentNode(state: any, fields: CodecField[]): Record<string, any>;
|
|
54
|
+
/**
|
|
55
|
+
* 按同一份字段定义校验文档节点。
|
|
56
|
+
*
|
|
57
|
+
* 约定与引擎一致:**可选值缺省即合法**,只有「出现了但类型不对」才报错 —— 这样
|
|
58
|
+
* `pickDocumentNode()` 的产物永远能通过校验(读写共用一份定义带来的自洽)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateDocumentNode(node: any, prefix: string, fields: CodecField[], errors: string[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* 找出 state 里既没被字段定义覆盖、也不属于运行时/默认值的那批键。
|
|
63
|
+
*
|
|
64
|
+
* 供 codec 完整性测试使用:返回非空即说明「新增了 state 字段但忘了登记」。
|
|
65
|
+
*/
|
|
66
|
+
export declare function uncoveredStateKeys(state: any, fields: CodecField[]): string[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 项目快照的**唯一字段定义**(codec)。
|
|
3
|
+
*
|
|
4
|
+
* 设计原则(与引擎的序列化机制保持一致):
|
|
5
|
+
* 1. 真相源是组件的 `state`,这里只声明「哪些键要进文档、以及它们的类型」;
|
|
6
|
+
* 2. 写(serializeProject)与校验(validateProjectSnapshot)**共用这一份定义**,
|
|
7
|
+
* 不允许 snapshot 与 validator 各写一套字段清单(历史上正是这样漂移出 bug 的);
|
|
8
|
+
* 3. 新增 state 字段却忘了登记时,`tests/designer/codec-completeness.test.ts`
|
|
9
|
+
* 会以「未覆盖的 state 键」形态报红,逼迫补登记或明确列入运行时字段。
|
|
10
|
+
*
|
|
11
|
+
* 与引擎的关系:引擎的 Serializer 是「遍历 state 减黑名单」,天然不会漏字段;
|
|
12
|
+
* 应用层因为要输出**扁平的领域文档**(AI/DSL/工具链消费),才需要这份显式契约,
|
|
13
|
+
* 但实现方式与引擎保持同构:类型分派走 typeId、可选值缺省即合法、未知类型跳过。
|
|
14
|
+
*/
|
|
15
|
+
export declare type CodecFieldType = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any';
|
|
16
|
+
export declare type CodecField = {
|
|
17
|
+
key: string;
|
|
18
|
+
/** 出现时校验的类型;缺省表示 any(透传) */
|
|
19
|
+
type?: CodecFieldType;
|
|
20
|
+
/** 该键必须存在(缺省即合法只对非必填字段成立) */
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/** 嵌套结构校验钩子(与字段定义同处一份,避免校验器另起一套) */
|
|
23
|
+
validate?: (value: any, prefix: string, errors: string[]) => void;
|
|
24
|
+
/** 文档用途说明(给人看) */
|
|
25
|
+
doc?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 应用层自定义 JSON 的透传键。
|
|
29
|
+
*
|
|
30
|
+
* 应用层可以把业务元数据挂在 `component.state.data` 上(任意 JSON),
|
|
31
|
+
* 它会原样写进项目快照并在载入时回填 —— 与引擎序列化对 state 的处理一致。
|
|
32
|
+
*/
|
|
33
|
+
export declare const PASS_THROUGH_KEY = "data";
|
|
34
|
+
/** 引擎运行时派生字段:不写进项目快照,载入后由引擎重算(与 Serializer 的黑名单同源) */
|
|
35
|
+
export declare const DERIVED_STATE_KEYS: string[];
|
|
36
|
+
/** 引擎默认值字段:不入文档,构造时由引擎按默认值补齐(值不变,故不算丢失) */
|
|
37
|
+
export declare const CONSTRUCTOR_DEFAULT_STATE_KEYS: string[];
|
|
38
|
+
/** Entity / Relation 通用字段 */
|
|
39
|
+
export declare const COMPONENT_BASE_FIELDS: CodecField[];
|
|
40
|
+
/** Entity 专有字段 */
|
|
41
|
+
export declare const ENTITY_FIELDS: CodecField[];
|
|
42
|
+
/** Relation 专有字段 */
|
|
43
|
+
export declare const RELATION_FIELDS: CodecField[];
|
|
44
|
+
/** 组装 Entity / Relation 的字段定义(专有 + 通用 + 透传) */
|
|
45
|
+
export declare const ENTITY_DOCUMENT_FIELDS: CodecField[];
|
|
46
|
+
export declare const RELATION_DOCUMENT_FIELDS: CodecField[];
|
|
47
|
+
/**
|
|
48
|
+
* 按字段定义从 state 里取值,组装成文档节点。
|
|
49
|
+
*
|
|
50
|
+
* - 只写「定义里列了、且 state 里不是 undefined」的键(保持文档紧凑、可读);
|
|
51
|
+
* - `data` 透传键原样带上。
|
|
52
|
+
*/
|
|
53
|
+
export declare function pickDocumentNode(state: any, fields: CodecField[]): Record<string, any>;
|
|
54
|
+
/**
|
|
55
|
+
* 按同一份字段定义校验文档节点。
|
|
56
|
+
*
|
|
57
|
+
* 约定与引擎一致:**可选值缺省即合法**,只有「出现了但类型不对」才报错 —— 这样
|
|
58
|
+
* `pickDocumentNode()` 的产物永远能通过校验(读写共用一份定义带来的自洽)。
|
|
59
|
+
*/
|
|
60
|
+
export declare function validateDocumentNode(node: any, prefix: string, fields: CodecField[], errors: string[]): void;
|
|
61
|
+
/**
|
|
62
|
+
* 找出 state 里既没被字段定义覆盖、也不属于运行时/默认值的那批键。
|
|
63
|
+
*
|
|
64
|
+
* 供 codec 完整性测试使用:返回非空即说明「新增了 state 字段但忘了登记」。
|
|
65
|
+
*/
|
|
66
|
+
export declare function uncoveredStateKeys(state: any, fields: CodecField[]): string[];
|