types.ts
3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// 本体可视化中间表示(IR)。
// 这是把当前项目的 M0–M8 / ME / MetaRule 本体“投影”成一份统一、视图友好的对象模型;
// 由 build.ts 从后端 /api/meta/model/{code} 返回的解析后 YAML(JSON)在浏览器端合成,
// 供 ER 图 / 本体网络图 / 场景流程图三个视图共用(等价于 onto-app 里 Python 侧的 IR,改为 TS 实现)。
export type RelKind = 'ONE_TO_ONE' | 'ONE_TO_MANY' | 'MANY_TO_ONE' | 'MANY_TO_MANY'
/** 属性(字段)。identifier / localIdentifier 会被前置成 is_primary_key 的合成属性。 */
export interface OntoAttribute {
name: string
label?: string
type: string
required?: boolean
unique?: boolean
is_primary_key?: boolean
is_foreign_key?: boolean
/** 跨聚合引用目标(来自 M1 refAggregate/refRoot/refIdentifier)。 */
ref?: { aggregate: string; root: string; identifier: string }
constraints?: Record<string, any>
/** 瞬态字段:无 M3 列,不落库(据 description 启发式识别,仅作展示标注)。 */
transient?: boolean
description?: string
}
/** 对象间关联:跨聚合引用(reference)或聚合内组合(composition)。 */
export interface OntoRelationship {
name: string
label?: string
target_object_id: string
kind: RelKind
refType: 'reference' | 'composition'
/** reference 时为持有外键的字段名(在源对象 attributes 内)。 */
fk_field?: string
}
/** 一个业务对象:聚合根(parent_id 为空)或其组合子实体(parent_id 指向根)。 */
export interface OntoObject {
id: string
name: string
alias: string
description?: string
is_aggregate_root: boolean
parent_id?: string | null
aggregateId: string
attributes: OntoAttribute[]
relationships: OntoRelationship[]
}
/** 行为(M2 命令)。 */
export interface OntoBehavior {
id: string
name: string
owner_object_id: string
type: 'COMMAND' | 'QUERY'
commandType?: string
description?: string
applied_rules: string[]
produced_events: string[]
preconditions: string[]
effects: string[]
}
/** 规则(MetaRule ruleGroups[].rules[])。 */
export interface OntoRule {
id: string
name: string
type: string // effect: REJECT / ALERT / COMPENSATE
expression?: string // matchCondition
enforced?: boolean
bindScene?: string
description?: string
}
/** 领域事件(ME aggregateEventDefinitions)。 */
export interface OntoEvent {
id: string
name: string
description?: string
topic?: string
aggregate?: string
payload?: string[]
consumers?: string[]
}
/** 导航目录节点(本项目无显式导航树,可为空;网络图退化为按聚合平铺)。 */
export interface NavNode {
id: string
name: string
zh: string
link?: string | null
children: NavNode[]
}
/** BPMN 语义骨架(由 M4 flowSteps 合成,不含坐标)。 */
export interface ProcessNode {
id: string
type: 'startEvent' | 'endEvent' | 'task' | 'userTask' | 'exclusiveGateway' | 'parallelGateway' | 'intermediateCatchEvent'
name: string
behaviorId?: string
lane?: string
}
export interface ProcessFlow {
id: string
source: string
target: string
name?: string
condition?: string
}
export interface ProcessModel {
id: string
name: string
nodes: ProcessNode[]
flows: ProcessFlow[]
}
/** 顶层:一个本体 = 全部建模产物的视图投影。 */
export interface Ontology {
domain: string
version: string
objects: OntoObject[]
behaviors: OntoBehavior[]
rules: OntoRule[]
events: OntoEvent[]
navigations: NavNode[]
processModels: ProcessModel[]
}