@kimposoft/plugin-sdk 0.0.0-stage → 1.1.0-tp.22
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/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +48 -2
- package/package.json +145 -4
- package/src/action-designer.ts +267 -0
- package/src/attachment-open.ts +574 -0
- package/src/attachment-url.ts +235 -0
- package/src/auth/index.ts +6 -0
- package/src/auth/qrcode.ts +519 -0
- package/src/auth/types.ts +261 -0
- package/src/display-style.ts +532 -0
- package/src/editor-frame.ts +625 -0
- package/src/editor-session.ts +1214 -0
- package/src/editor-testing.ts +838 -0
- package/src/editor.ts +1720 -0
- package/src/frame-transport.ts +516 -0
- package/src/frontend-routes.ts +99 -0
- package/src/hooks.ts +48 -0
- package/src/host-caps.ts +93 -0
- package/src/i18n.ts +238 -0
- package/src/im-panel.ts +132 -0
- package/src/image-tools.ts +91 -0
- package/src/index.ts +125 -0
- package/src/interactive-session.ts +94 -0
- package/src/nahida-im.ts +391 -0
- package/src/nahida-ws.ts +23 -0
- package/src/org-directory.ts +78 -0
- package/src/oz-realtime.ts +144 -0
- package/src/page.ts +591 -0
- package/src/print.ts +393 -0
- package/src/surface.ts +310 -0
- package/src/theme-mocks.ts +140 -0
- package/src/theme.ts +125 -0
- package/src/ui-fixtures/attachment.ts +24 -0
- package/src/ui-fixtures/confirm.ts +16 -0
- package/src/ui-fixtures/entity-picker.ts +24 -0
- package/src/ui-fixtures/expression-editor.ts +52 -0
- package/src/ui-fixtures/image-cropper.ts +23 -0
- package/src/ui-fixtures/index.ts +17 -0
- package/src/ui-fixtures/org-tri-picker.ts +19 -0
- package/src/ui-fixtures/prompt.ts +19 -0
- package/src/ui-fixtures/record-picker.ts +17 -0
- package/src/ui-fixtures/template-picker.ts +13 -0
- package/src/ui-mocks.ts +264 -0
- package/src/ui.ts +491 -0
- package/src/workflow-designer.ts +475 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow-designer.ts —— 流程设计器插件(surfaceType='workflow-designer')的公开契约。
|
|
3
|
+
*
|
|
4
|
+
* 链路归属:SDK 公开契约面(kimpo 宿主 ↔ 流程设计器插件,设计层)。
|
|
5
|
+
*
|
|
6
|
+
* 宿主在独立路由页「流程设计」里挂载 workflow-designer surface,向插件提供:
|
|
7
|
+
* - hostBridge['domain:workflow-designer']:WorkflowDesignerHostApi(宿主实现以编译期断言绑定本接口,
|
|
8
|
+
* 接口漂移时宿主编译失败);
|
|
9
|
+
* - hostBridge['domain:alice-v4'] / ['domain:expression']:按模板 id 现场取表达式宿主桥的两个裸函数;
|
|
10
|
+
* - hostBridge.interactiveSession:Host 交互会话 handle(未保存状态上报走它);
|
|
11
|
+
* - hostContext:WorkflowDesignerHostContext({ appId, definitionId, readOnly, enginePluginId? })。
|
|
12
|
+
* 本 surface 不经组件 prop `input` 传业务形状(与 action-designer 不同),宿主传入的 props 为空对象,
|
|
13
|
+
* 业务上下文全部在 hostContext。
|
|
14
|
+
* 草稿文档 WorkflowDocument(schema 'workflow/1')是插件保存给宿主、流程引擎编译发布的结构。SDK 1.1.0-tp.13 起
|
|
15
|
+
* 各节点 config 的内部结构也进入公开契约(下方 Workflow*Config 类型,与 Go SDK 发布的 JSON Schema
|
|
16
|
+
* schema/workflow/workflow-1.schema.json 同口径);WorkflowNode.config 仍声明为宽松的 Record,按 kind 收窄请用
|
|
17
|
+
* WorkflowNodeConfigByKind / WorkflowTypedNode。版本规则:workflow/1 内只加可选字段,读者须容忍未知键。
|
|
18
|
+
*
|
|
19
|
+
* 本文件只承诺列出的方法与字段;宿主实现可能有更多方法(如 createAliceV4Host / createExpressionHost),
|
|
20
|
+
* 不在公开契约内的不要依赖。来源:kimpo 宿主流程设计器承载页的实际实现 + 官方流程插件设计器前端的实际消费面。
|
|
21
|
+
*/
|
|
22
|
+
import type { HostI18n } from './i18n';
|
|
23
|
+
import type { InteractiveSessionHandle } from './interactive-session';
|
|
24
|
+
import type { HostResult } from './action-designer';
|
|
25
|
+
|
|
26
|
+
export type { HostResult } from './action-designer';
|
|
27
|
+
|
|
28
|
+
// ── workflow/1 草稿文档外层 ─────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
/** 草稿文档唯一承认的 schema 取值(对齐流程引擎 model.SchemaVersion)。 */
|
|
31
|
+
export const WORKFLOW_DOCUMENT_SCHEMA = 'workflow/1' as const;
|
|
32
|
+
|
|
33
|
+
/** 节点类型闭集:开始 / 办理 / 审批 / 抄送 / 子流程 / 结束。 */
|
|
34
|
+
export type WorkflowNodeKind = 'start' | 'handle' | 'approve' | 'cc' | 'subflow' | 'end';
|
|
35
|
+
|
|
36
|
+
/** 画布坐标点(连线折点)。 */
|
|
37
|
+
export interface WorkflowPoint {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 流程草稿文档(workflow/1)外层。约束:nodes 恰含一个 kind==='start';id 在文档内唯一;
|
|
44
|
+
* 由流程引擎在保存/校验/发布时判定,宿主不解析。
|
|
45
|
+
*/
|
|
46
|
+
export interface WorkflowDocument {
|
|
47
|
+
schema: typeof WORKFLOW_DOCUMENT_SCHEMA;
|
|
48
|
+
/** 流程定义名称。 */
|
|
49
|
+
name: string;
|
|
50
|
+
nodes: WorkflowNode[];
|
|
51
|
+
links: WorkflowLink[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 节点通用信封;config 按 kind 区分,形状见 WorkflowNodeConfigByKind(按 kind 收窄用 WorkflowTypedNode)。 */
|
|
55
|
+
export interface WorkflowNode {
|
|
56
|
+
id: string;
|
|
57
|
+
kind: WorkflowNodeKind;
|
|
58
|
+
name?: string;
|
|
59
|
+
config?: Record<string, unknown>;
|
|
60
|
+
/** 画布坐标,引擎不关心,随文档整体保存。 */
|
|
61
|
+
position_x?: number;
|
|
62
|
+
position_y?: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 连线通用信封;condition_doc 是判断表达式文档(形状见 WorkflowExpressionDocument,不填即无条件),引擎原样存取。 */
|
|
66
|
+
export interface WorkflowLink {
|
|
67
|
+
id: string;
|
|
68
|
+
from: string;
|
|
69
|
+
to: string;
|
|
70
|
+
condition_doc?: unknown;
|
|
71
|
+
/** 连线名称,至多 20 字,仅用于画布标识,不参与选路。 */
|
|
72
|
+
name?: string;
|
|
73
|
+
vertices?: WorkflowPoint[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ── workflow/1 节点配置(SDK 1.1.0-tp.13 起公开)──────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
/** 表达式文档信封:引擎不解析,发布时交宿主表达式服务冻结为发布物。判断用 mode='condition',取值用 mode='value'。 */
|
|
79
|
+
export interface WorkflowExpressionDocument {
|
|
80
|
+
schema_version: 'kimpo.report-expression/v4';
|
|
81
|
+
mode: 'condition' | 'value';
|
|
82
|
+
expression: {
|
|
83
|
+
expression_id: string;
|
|
84
|
+
purpose?: string;
|
|
85
|
+
source_text?: string;
|
|
86
|
+
refs?: unknown[];
|
|
87
|
+
normalized_digest?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 字段权限档位:继承模板 / 编辑 / 只读 / 隐藏(只看型节点不用 edit)。 */
|
|
92
|
+
export type WorkflowFieldGrade = 'inherit' | 'edit' | 'readonly' | 'hidden';
|
|
93
|
+
|
|
94
|
+
/** 字段权限清单的一条。 */
|
|
95
|
+
export interface WorkflowFieldPermission {
|
|
96
|
+
table_id?: string;
|
|
97
|
+
field_id: string;
|
|
98
|
+
grade: WorkflowFieldGrade;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** 字段引用(回退时清空清单)。 */
|
|
102
|
+
export interface WorkflowFieldRef {
|
|
103
|
+
table_id?: string;
|
|
104
|
+
field_id: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 处理人 / 收件人来源种类;'relation' 只为读兼容旧文档(关系已改为 relation_filters 过滤器)。 */
|
|
108
|
+
export type WorkflowAssigneeSourceKind = 'user' | 'role' | 'department' | 'main_field' | 'initiator' | 'relation';
|
|
109
|
+
|
|
110
|
+
/** 「与上步处理人的关系」五档。 */
|
|
111
|
+
export type WorkflowAssigneeRelation =
|
|
112
|
+
| 'same_department'
|
|
113
|
+
| 'parent_department'
|
|
114
|
+
| 'child_department'
|
|
115
|
+
| 'department_manager'
|
|
116
|
+
| 'parent_department_manager';
|
|
117
|
+
|
|
118
|
+
/** 主表字段来源的匹配依据:用户名 / 登录名。 */
|
|
119
|
+
export type WorkflowAssigneeMatchBy = 'display_name' | 'login_name';
|
|
120
|
+
|
|
121
|
+
/** 用户 id 列表:写入用十进制字符串(19 位整数按 JSON 数字传会丢精度),读时兼容数字。 */
|
|
122
|
+
export type WorkflowUserIdList = Array<string | number>;
|
|
123
|
+
|
|
124
|
+
/** 来源清单的一条;多条取并集。 */
|
|
125
|
+
export interface WorkflowAssigneeSource {
|
|
126
|
+
kind: WorkflowAssigneeSourceKind;
|
|
127
|
+
user_ids?: WorkflowUserIdList;
|
|
128
|
+
role_ids?: string[];
|
|
129
|
+
department_ids?: string[];
|
|
130
|
+
main_field_id?: string;
|
|
131
|
+
match_by?: WorkflowAssigneeMatchBy;
|
|
132
|
+
/** 旧形状 kind='relation' 时生效。 */
|
|
133
|
+
relation?: WorkflowAssigneeRelation;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** 发起权限:用户 / 角色 / 部门 / 主表字段四种来源取并集;全空 = 仅超级管理员可发起。 */
|
|
137
|
+
export interface WorkflowStartGrant {
|
|
138
|
+
user_ids?: WorkflowUserIdList;
|
|
139
|
+
role_ids?: string[];
|
|
140
|
+
department_ids?: string[];
|
|
141
|
+
main_field_id?: string;
|
|
142
|
+
match_by?: WorkflowAssigneeMatchBy;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** 办理方式:任一人 / 全部(会签)/ 按比例(percentage_bp 为万分比,缺省 10000)。 */
|
|
146
|
+
export interface WorkflowCompleteMode {
|
|
147
|
+
kind: 'any' | 'all' | 'percentage';
|
|
148
|
+
percentage_bp?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** 回退方式:上一步 / 发起人 / 指定步骤。 */
|
|
152
|
+
export type WorkflowWithdrawMethod = 'previous_step' | 'initiator' | 'specified_step';
|
|
153
|
+
|
|
154
|
+
/** 节点级通知:开关缺省 = 开,渠道缺省 = 仅 system。各类节点只读取自己有意义的开关。 */
|
|
155
|
+
export interface WorkflowNodeNotify {
|
|
156
|
+
on_assigned?: boolean;
|
|
157
|
+
on_returned?: boolean;
|
|
158
|
+
on_withdrawn?: boolean;
|
|
159
|
+
on_terminated?: boolean;
|
|
160
|
+
on_ended?: boolean;
|
|
161
|
+
channels?: WorkflowNotifyChannelKey[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** 审批按钮动作:提交通过 / 回退上一步 / 回退发起人 / 回退指定步骤 / 不通过并结束流程。 */
|
|
165
|
+
export type WorkflowButtonAction =
|
|
166
|
+
| 'submit_approve'
|
|
167
|
+
| 'withdraw_previous_step'
|
|
168
|
+
| 'withdraw_initiator'
|
|
169
|
+
| 'withdraw_specified_step'
|
|
170
|
+
| 'end_flow';
|
|
171
|
+
|
|
172
|
+
/** 审批按钮。color 建议取 primary / success / danger / warning / neutral。 */
|
|
173
|
+
export interface WorkflowApprovalButton {
|
|
174
|
+
id: string;
|
|
175
|
+
name?: string;
|
|
176
|
+
color?: string;
|
|
177
|
+
action: WorkflowButtonAction;
|
|
178
|
+
result_tag?: string;
|
|
179
|
+
require_reason?: boolean;
|
|
180
|
+
/** action='end_flow' 时的目标结束节点。 */
|
|
181
|
+
end_node_id?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** 子流程传递字段:来源字段(本流程模板主表或同一张扩展表)→ 目标流程模板主表字段。 */
|
|
185
|
+
export interface WorkflowSubflowFieldMapping {
|
|
186
|
+
source_table_id?: string;
|
|
187
|
+
source_field_id: string;
|
|
188
|
+
target_field_id: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** 发起节点配置。 */
|
|
192
|
+
export interface WorkflowStartConfig {
|
|
193
|
+
target_template_id?: string;
|
|
194
|
+
start_permission?: WorkflowStartGrant | null;
|
|
195
|
+
/** 允许人工发起,缺省按开。 */
|
|
196
|
+
allow_manual_start?: boolean;
|
|
197
|
+
field_permissions?: WorkflowFieldPermission[];
|
|
198
|
+
no_route_hint?: string;
|
|
199
|
+
summary_expr?: WorkflowExpressionDocument | null;
|
|
200
|
+
start_condition?: WorkflowExpressionDocument | null;
|
|
201
|
+
start_condition_hint?: string;
|
|
202
|
+
notify?: WorkflowNodeNotify | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** 办理节点配置。 */
|
|
206
|
+
export interface WorkflowHandleConfig {
|
|
207
|
+
assignees?: WorkflowAssigneeSource[];
|
|
208
|
+
relation_filters?: WorkflowAssigneeRelation[];
|
|
209
|
+
complete_mode?: WorkflowCompleteMode;
|
|
210
|
+
field_permissions?: WorkflowFieldPermission[];
|
|
211
|
+
allowed_withdraw_methods?: WorkflowWithdrawMethod[];
|
|
212
|
+
clear_on_withdraw?: WorkflowFieldRef[];
|
|
213
|
+
no_route_hint?: string;
|
|
214
|
+
auto_complete_condition?: WorkflowExpressionDocument | null;
|
|
215
|
+
summary_expr?: WorkflowExpressionDocument | null;
|
|
216
|
+
notify?: WorkflowNodeNotify | null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** 审批节点配置。 */
|
|
220
|
+
export interface WorkflowApproveConfig {
|
|
221
|
+
approvers?: WorkflowAssigneeSource[];
|
|
222
|
+
relation_filters?: WorkflowAssigneeRelation[];
|
|
223
|
+
complete_mode?: WorkflowCompleteMode;
|
|
224
|
+
field_permissions?: WorkflowFieldPermission[];
|
|
225
|
+
buttons?: WorkflowApprovalButton[] | null;
|
|
226
|
+
result_field_id?: string;
|
|
227
|
+
reason_field_id?: string;
|
|
228
|
+
clear_on_withdraw?: WorkflowFieldRef[];
|
|
229
|
+
no_route_hint?: string;
|
|
230
|
+
auto_complete_condition?: WorkflowExpressionDocument | null;
|
|
231
|
+
summary_expr?: WorkflowExpressionDocument | null;
|
|
232
|
+
notify?: WorkflowNodeNotify | null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** 抄送节点配置。 */
|
|
236
|
+
export interface WorkflowCcConfig {
|
|
237
|
+
recipients?: WorkflowAssigneeSource[];
|
|
238
|
+
relation_filters?: WorkflowAssigneeRelation[];
|
|
239
|
+
channels?: WorkflowNotifyChannelKey[] | null;
|
|
240
|
+
/** 标题与正文是取值表达式;未配置时写 null。 */
|
|
241
|
+
title_expr?: WorkflowExpressionDocument | null;
|
|
242
|
+
content_expr?: WorkflowExpressionDocument | null;
|
|
243
|
+
field_permissions?: WorkflowFieldPermission[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** 结束节点配置。 */
|
|
247
|
+
export interface WorkflowEndConfig {
|
|
248
|
+
end_flag?: string;
|
|
249
|
+
write_field_id?: string;
|
|
250
|
+
notify?: WorkflowNodeNotify | null;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** 子流程节点配置。 */
|
|
254
|
+
export interface WorkflowSubflowConfig {
|
|
255
|
+
target_workflow_id?: string;
|
|
256
|
+
field_mappings?: WorkflowSubflowFieldMapping[];
|
|
257
|
+
wait?: boolean;
|
|
258
|
+
/** 父流程结束后子流程的处置(仅不等待时):不管 / 强制结束。 */
|
|
259
|
+
disposition?: 'ignore' | 'force_end';
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** 节点种类 → 配置类型。 */
|
|
263
|
+
export interface WorkflowNodeConfigByKind {
|
|
264
|
+
start: WorkflowStartConfig;
|
|
265
|
+
handle: WorkflowHandleConfig;
|
|
266
|
+
approve: WorkflowApproveConfig;
|
|
267
|
+
cc: WorkflowCcConfig;
|
|
268
|
+
subflow: WorkflowSubflowConfig;
|
|
269
|
+
end: WorkflowEndConfig;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** 按 kind 收窄 config 的节点。 */
|
|
273
|
+
export type WorkflowTypedNode<K extends WorkflowNodeKind = WorkflowNodeKind> = K extends WorkflowNodeKind
|
|
274
|
+
? Omit<WorkflowNode, 'kind' | 'config'> & { kind: K; config?: WorkflowNodeConfigByKind[K] | null }
|
|
275
|
+
: never;
|
|
276
|
+
|
|
277
|
+
// ── 宿主方法的入参与返回信封 ───────────────────────────────────────────────────────────
|
|
278
|
+
|
|
279
|
+
/** 校验 / 发布返回的诊断条目(message 已按请求语言翻译,找不到译文时回落 message_key)。 */
|
|
280
|
+
export interface WorkflowDiagnostic {
|
|
281
|
+
code: string;
|
|
282
|
+
message_key?: string;
|
|
283
|
+
message?: string;
|
|
284
|
+
node_id?: string;
|
|
285
|
+
link_id?: string;
|
|
286
|
+
arguments?: Record<string, string>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** 流程定义头。 */
|
|
290
|
+
export interface WorkflowDefinitionWire {
|
|
291
|
+
definition_id: string;
|
|
292
|
+
template_id: string;
|
|
293
|
+
name: string;
|
|
294
|
+
/** 引擎原样值 enabled | disabled;判断请用 enabled 布尔投影。 */
|
|
295
|
+
status_code: string;
|
|
296
|
+
enabled: boolean;
|
|
297
|
+
/** 草稿 JSON(WorkflowDocument 形状,可能为空或为旧形状,插件自行容错);仅 getDefinition / saveDraft 下发。 */
|
|
298
|
+
draft?: unknown;
|
|
299
|
+
draft_updated_at?: string;
|
|
300
|
+
/** 最新已发布版本号,0 = 从未发布。 */
|
|
301
|
+
latest_version_no: number;
|
|
302
|
+
/** 定义行乐观锁版本号:saveDraft / publish 的 expectedVersionNo 传这个。 */
|
|
303
|
+
version_no: number;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** 已发布版本头(versions[] 一项)。 */
|
|
307
|
+
export interface WorkflowDefinitionVersionHead {
|
|
308
|
+
version_id: string;
|
|
309
|
+
definition_id: string;
|
|
310
|
+
version_no: number;
|
|
311
|
+
template_id: string;
|
|
312
|
+
name: string;
|
|
313
|
+
allow_manual_start: boolean;
|
|
314
|
+
published_at?: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** 读、保存草稿、启停用的公共返回形状。 */
|
|
318
|
+
export interface WorkflowDefinitionWithVersions {
|
|
319
|
+
definition: WorkflowDefinitionWire;
|
|
320
|
+
versions: WorkflowDefinitionVersionHead[];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** 发布成功回执。 */
|
|
324
|
+
export interface WorkflowDefinitionPublishResult {
|
|
325
|
+
/** 新发布出来的版本号。 */
|
|
326
|
+
version_no: number;
|
|
327
|
+
version_id: string;
|
|
328
|
+
/** 发布后定义行的乐观锁版本号(发布会推进定义行一版);缺省时插件应保持原 expectedVersionNo。 */
|
|
329
|
+
definition_version_no?: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/** 模板目录条目。 */
|
|
333
|
+
export interface WorkflowDesignerTemplateBrief {
|
|
334
|
+
template_id: string;
|
|
335
|
+
template_name: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** 模板详情:has_active_bundle=false 表示模板尚未发布可用的设计,domain:alice-v4 桥不可用(返回 null)。 */
|
|
339
|
+
export interface WorkflowDesignerTemplateDetail {
|
|
340
|
+
template_id: string;
|
|
341
|
+
template_name: string;
|
|
342
|
+
has_active_bundle?: boolean;
|
|
343
|
+
active_version_no?: string;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface WorkflowDesignerTemplateTable {
|
|
347
|
+
data_table_id: string;
|
|
348
|
+
table_name: string;
|
|
349
|
+
/** 'main' = 主表,其余为明细 / 扩展表。 */
|
|
350
|
+
table_role?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface WorkflowDesignerTemplateField {
|
|
354
|
+
field_id: string;
|
|
355
|
+
field_name: string;
|
|
356
|
+
data_type: string;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** 字段在该模板全部授权项里是否被设过隐藏 / 只读 / 禁止导出(设计者视角总览,不按用户裁决)。 */
|
|
360
|
+
export interface WorkflowDesignerFieldRestriction {
|
|
361
|
+
field_id: string;
|
|
362
|
+
hidden: boolean;
|
|
363
|
+
readonly: boolean;
|
|
364
|
+
no_export: boolean;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** 流程可配的三档通知渠道。 */
|
|
368
|
+
export type WorkflowNotifyChannelKey = 'system' | 'email' | 'sms';
|
|
369
|
+
|
|
370
|
+
export interface WorkflowNotifyChannelCapability {
|
|
371
|
+
channel: WorkflowNotifyChannelKey;
|
|
372
|
+
available: boolean;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** 本应用已发布的流程定义(宿主已按 latest_version_no > 0 过滤)。 */
|
|
376
|
+
export interface WorkflowDesignerPublishedDefinition {
|
|
377
|
+
definition_id: string;
|
|
378
|
+
name: string;
|
|
379
|
+
template_id: string;
|
|
380
|
+
enabled: boolean;
|
|
381
|
+
published: true;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ── 绑定引擎能力────────────────────────────────────
|
|
385
|
+
|
|
386
|
+
/** 引擎能力声明里的节点种类闭集(大写,与 manifest capabilities.workflow_engine.node_kinds、编译产物 node_kind 同口径)。 */
|
|
387
|
+
export type WorkflowEngineNodeKind = 'START' | 'HANDLE' | 'APPROVE' | 'CC' | 'SUBFLOW' | 'END';
|
|
388
|
+
|
|
389
|
+
/** 引擎能力声明里的能力闭集:撤回 / 回退 / 事故恢复 / 子流程 / 自动办理 / 按比例通过。 */
|
|
390
|
+
export type WorkflowEngineFeature = 'withdraw' | 'back' | 'resume_incident' | 'subflow' | 'auto_handle' | 'ratio_pass';
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* 当前定义绑定引擎的能力(getEngineInfo 返回)。数据来自引擎 manifest 的 capabilities.workflow_engine 声明,
|
|
394
|
+
* 由宿主按定义绑定的 engine_plugin_id 取出。设计器据此在节点面板禁用不支持的节点(提示「当前引擎不支持」),
|
|
395
|
+
* available=false 时只读并横幅提示「绑定引擎不可用」。
|
|
396
|
+
*/
|
|
397
|
+
export interface WorkflowEngineInfo {
|
|
398
|
+
/** 绑定的引擎插件 ID。 */
|
|
399
|
+
enginePluginId: string;
|
|
400
|
+
/** 引擎显示名(宿主已按当前界面语言从四语声明里取好)。 */
|
|
401
|
+
displayName: string;
|
|
402
|
+
/** 引擎当前是否合格可派发(已激活、已获授 workflow.engine、声明完整)。 */
|
|
403
|
+
available: boolean;
|
|
404
|
+
/** 接受的草稿文档 schema,必含 'workflow/1'。 */
|
|
405
|
+
documentSchemas: string[];
|
|
406
|
+
/** 支持的节点种类,必含 START 与 END。 */
|
|
407
|
+
nodeKinds: WorkflowEngineNodeKind[];
|
|
408
|
+
/** 支持的能力。 */
|
|
409
|
+
features: WorkflowEngineFeature[];
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* domain:workflow-designer 公开方法。appId / definitionId / 交互会话由宿主在构造期绑定,方法不再传。
|
|
414
|
+
* 写方法(saveDraft / publish)要求本页已取得编辑绑定;只读打开(hostContext.readOnly=true)时调用会被后端拒绝。
|
|
415
|
+
*/
|
|
416
|
+
export interface WorkflowDesignerHostApi {
|
|
417
|
+
getDefinition(): Promise<HostResult<WorkflowDefinitionWithVersions>>;
|
|
418
|
+
/** 保存草稿(乐观锁);版本冲突返回 error.code='VERSION_CONFLICT'。 */
|
|
419
|
+
saveDraft(draft: WorkflowDocument, expectedVersionNo: number): Promise<HostResult<WorkflowDefinitionWithVersions>>;
|
|
420
|
+
/** 纯校验不落库;diagnostics 非空即代表发布会被拒。 */
|
|
421
|
+
validate(draft: WorkflowDocument): Promise<HostResult<{ ok: boolean; diagnostics: WorkflowDiagnostic[] }>>;
|
|
422
|
+
/**
|
|
423
|
+
* 发布当前已保存的草稿。发布期检查未过时 error.code='PUBLISH_REJECTED',诊断放在与 data/error 同级的
|
|
424
|
+
* diagnostics 上(不在 data 内)。
|
|
425
|
+
*/
|
|
426
|
+
publish(
|
|
427
|
+
expectedVersionNo: number
|
|
428
|
+
): Promise<HostResult<WorkflowDefinitionPublishResult> & { diagnostics?: WorkflowDiagnostic[] }>;
|
|
429
|
+
setEnabled(enabled: boolean): Promise<HostResult<WorkflowDefinitionWithVersions>>;
|
|
430
|
+
listAppTemplates(keyword?: string): Promise<HostResult<{ items: WorkflowDesignerTemplateBrief[] }>>;
|
|
431
|
+
getTemplate(templateId: string): Promise<HostResult<WorkflowDesignerTemplateDetail>>;
|
|
432
|
+
/** templateId 为空时宿主直接回空列表、不发请求。 */
|
|
433
|
+
listTemplateTables(templateId: string): Promise<HostResult<{ items: WorkflowDesignerTemplateTable[] }>>;
|
|
434
|
+
listTemplateFields(
|
|
435
|
+
templateId: string,
|
|
436
|
+
dataTableId: string
|
|
437
|
+
): Promise<HostResult<{ items: WorkflowDesignerTemplateField[] }>>;
|
|
438
|
+
templateFieldRestrictions(templateId: string): Promise<HostResult<{ fields: WorkflowDesignerFieldRestriction[] }>>;
|
|
439
|
+
listAppWorkflows(): Promise<HostResult<{ definitions: WorkflowDesignerPublishedDefinition[] }>>;
|
|
440
|
+
channelCapabilities(): Promise<HostResult<{ channels: WorkflowNotifyChannelCapability[] }>>;
|
|
441
|
+
/**
|
|
442
|
+
* 当前定义绑定引擎的能力。只增不改,标为可选——
|
|
443
|
+
* 旧宿主没有本方法,插件调用前先判断是否存在;不存在时按「官方引擎、全部能力可用」处理。
|
|
444
|
+
*/
|
|
445
|
+
getEngineInfo?(): Promise<HostResult<WorkflowEngineInfo>>;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// ── surface 挂载输入 ──────────────────────────────────────────────────────────────────
|
|
449
|
+
|
|
450
|
+
/** createSurface 收到的 hostContext 形状(宿主承载页传入)。 */
|
|
451
|
+
export interface WorkflowDesignerHostContext {
|
|
452
|
+
appId: string;
|
|
453
|
+
/** 当前设计的流程定义 id(子流程目标候选应排除自己)。 */
|
|
454
|
+
definitionId: string;
|
|
455
|
+
/** true = 只读打开(他人正在编辑或绑定失败),插件应禁用保存 / 发布。 */
|
|
456
|
+
readOnly: boolean;
|
|
457
|
+
/** 当前定义绑定的引擎插件 ID;旧宿主不传。 */
|
|
458
|
+
enginePluginId?: string;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* hostBridge 上与流程设计器相关的键(经 hostCaps 白名单裁剪,manifest 须声明
|
|
463
|
+
* platform.interactiveSession / domain:workflow-designer / domain:alice-v4 / domain:expression / i18n)。
|
|
464
|
+
* SDK 不依赖表达式编辑器包,两个表达式桥的类型以泛型留给插件(官方插件用 @kimposoft/expression-editor 的
|
|
465
|
+
* AliceV4Host / ExpressionHost)。
|
|
466
|
+
*/
|
|
467
|
+
export interface WorkflowDesignerHostBridge<TAliceV4Host = unknown, TExpressionHost = unknown> {
|
|
468
|
+
interactiveSession?: InteractiveSessionHandle;
|
|
469
|
+
i18n?: HostI18n;
|
|
470
|
+
'domain:workflow-designer'?: WorkflowDesignerHostApi;
|
|
471
|
+
/** 按模板 id 取 V4 表达式数据桥;模板从未发布时返回 null(插件应提示先发布模板)。 */
|
|
472
|
+
'domain:alice-v4'?: (templateId: string) => Promise<TAliceV4Host | null>;
|
|
473
|
+
/** 按模板 id 取表达式编辑器宿主桥(同步返回)。 */
|
|
474
|
+
'domain:expression'?: (templateId: string) => TExpressionHost;
|
|
475
|
+
}
|