openxiangda 1.0.106 → 1.0.107
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/openxiangda-skills/references/workflow-v3.md +35 -0
- package/package.json +1 -1
- package/packages/sdk/dist/workflow/index.cjs +243 -25
- package/packages/sdk/dist/workflow/index.cjs.map +1 -1
- package/packages/sdk/dist/workflow/index.d.mts +177 -1
- package/packages/sdk/dist/workflow/index.d.ts +177 -1
- package/packages/sdk/dist/workflow/index.mjs +243 -25
- package/packages/sdk/dist/workflow/index.mjs.map +1 -1
|
@@ -44,6 +44,41 @@ export default defineWorkflow({
|
|
|
44
44
|
});
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
For compact AI-authored drafts, `flow.define` is also exported. It accepts
|
|
48
|
+
declarative node and edge helpers, then compiles to the same v3 JSON:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { flow } from "openxiangda/workflow";
|
|
52
|
+
|
|
53
|
+
export default flow.define({
|
|
54
|
+
name: "费用审批",
|
|
55
|
+
formUuid: "FORM_UUID",
|
|
56
|
+
nodes: [
|
|
57
|
+
flow.start("start"),
|
|
58
|
+
flow.approval("manager_approval", {
|
|
59
|
+
label: "主管审批",
|
|
60
|
+
assignees: [flow.assignee.initiator()],
|
|
61
|
+
actions: [
|
|
62
|
+
flow.action.approve("通过"),
|
|
63
|
+
flow.action.returnToInitiator(),
|
|
64
|
+
flow.action.transfer(),
|
|
65
|
+
],
|
|
66
|
+
fieldPermissions: { amount: "readonly" },
|
|
67
|
+
}),
|
|
68
|
+
flow.functionCall("sync_budget", {
|
|
69
|
+
functionName: "sync_budget",
|
|
70
|
+
input: { amount: "${amount}" },
|
|
71
|
+
}),
|
|
72
|
+
flow.end("end"),
|
|
73
|
+
],
|
|
74
|
+
edges: [
|
|
75
|
+
flow.connect("start", "manager_approval"),
|
|
76
|
+
flow.connect("manager_approval", "sync_budget"),
|
|
77
|
+
flow.connect("sync_budget", "end"),
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
47
82
|
Resource manifest:
|
|
48
83
|
|
|
49
84
|
```json
|
package/package.json
CHANGED
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var workflow_exports = {};
|
|
22
22
|
__export(workflow_exports, {
|
|
23
23
|
WorkflowBuilder: () => WorkflowBuilder,
|
|
24
|
-
defineWorkflow: () => defineWorkflow
|
|
24
|
+
defineWorkflow: () => defineWorkflow,
|
|
25
|
+
flow: () => flow
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(workflow_exports);
|
|
27
28
|
function sanitizeId(value) {
|
|
@@ -37,6 +38,30 @@ function normalizeAction(action, label, extra = {}) {
|
|
|
37
38
|
...extra
|
|
38
39
|
};
|
|
39
40
|
}
|
|
41
|
+
var workflowActions = {
|
|
42
|
+
approve: (label = "\u540C\u610F", extra = {}) => normalizeAction("agree", label, extra),
|
|
43
|
+
reject: (label = "\u62D2\u7EDD", extra = {}) => normalizeAction("rejected", label, extra),
|
|
44
|
+
transfer: (label = "\u8F6C\u4EA4", extra = {}) => normalizeAction("transfer", label, {
|
|
45
|
+
remark: { popUp: true, required: false },
|
|
46
|
+
...extra
|
|
47
|
+
}),
|
|
48
|
+
return: (label = "\u9000\u56DE", extra = {}) => normalizeAction("return", label, {
|
|
49
|
+
remark: { popUp: true, required: false },
|
|
50
|
+
...extra
|
|
51
|
+
}),
|
|
52
|
+
returnToInitiator: (label = "\u9000\u56DE\u53D1\u8D77\u4EBA", extra = {}) => normalizeAction("return", label, {
|
|
53
|
+
remark: { popUp: true, required: false },
|
|
54
|
+
returnTarget: "initiator",
|
|
55
|
+
returnScope: "initiator",
|
|
56
|
+
...extra
|
|
57
|
+
}),
|
|
58
|
+
save: (label = "\u6682\u5B58", extra = {}) => normalizeAction("save", label, extra),
|
|
59
|
+
withdraw: (label = "\u64A4\u56DE", extra = {}) => normalizeAction("withdraw", label, extra),
|
|
60
|
+
resubmit: (label = "\u91CD\u65B0\u63D0\u4EA4", extra = {}) => normalizeAction("resubmit", label, extra),
|
|
61
|
+
callback: (label = "\u89E6\u53D1\u56DE\u8C03", extra = {}) => normalizeAction("callback", label, extra),
|
|
62
|
+
retryException: (label = "\u91CD\u8BD5\u5F02\u5E38", extra = {}) => normalizeAction("retryException", label, extra),
|
|
63
|
+
adminTransfer: (label = "\u7BA1\u7406\u5458\u8F6C\u4EA4", extra = {}) => normalizeAction("adminTransfer", label, extra)
|
|
64
|
+
};
|
|
40
65
|
function normalizeReturnConfig(value) {
|
|
41
66
|
if (value === false) return { enabled: false };
|
|
42
67
|
if (value === true || value === void 0) {
|
|
@@ -49,6 +74,94 @@ function normalizeReturnConfig(value) {
|
|
|
49
74
|
...value
|
|
50
75
|
};
|
|
51
76
|
}
|
|
77
|
+
function normalizeFieldBehavior(value) {
|
|
78
|
+
const normalized = String(value || "").trim().toLowerCase();
|
|
79
|
+
if (["normal", "edit", "editable", "write", "writable"].includes(normalized)) return "NORMAL";
|
|
80
|
+
if (["readonly", "read", "view", "visible"].includes(normalized)) return "READONLY";
|
|
81
|
+
if (["hidden", "hide", "invisible"].includes(normalized)) return "HIDDEN";
|
|
82
|
+
return String(value || "READONLY").toUpperCase();
|
|
83
|
+
}
|
|
84
|
+
function normalizeFieldPermissions(value) {
|
|
85
|
+
if (Array.isArray(value)) {
|
|
86
|
+
return value.map((item) => {
|
|
87
|
+
if (!item || typeof item !== "object") return item;
|
|
88
|
+
return {
|
|
89
|
+
...item,
|
|
90
|
+
fieldId: item.fieldId || item.field || item.id,
|
|
91
|
+
fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission)
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (value && typeof value === "object") {
|
|
96
|
+
return Object.entries(value).map(([fieldId, fieldBehavior]) => ({
|
|
97
|
+
fieldId,
|
|
98
|
+
fieldBehavior: normalizeFieldBehavior(fieldBehavior)
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
function createDeclarativeNode(type, id, data = {}) {
|
|
104
|
+
return {
|
|
105
|
+
__openxiangdaWorkflowNode: true,
|
|
106
|
+
id: sanitizeId(id),
|
|
107
|
+
type,
|
|
108
|
+
data
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function createDeclarativeEdge(source, target, data = {}) {
|
|
112
|
+
return {
|
|
113
|
+
__openxiangdaWorkflowEdge: true,
|
|
114
|
+
source,
|
|
115
|
+
target,
|
|
116
|
+
data
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function isDeclarativeInput(input) {
|
|
120
|
+
return input && Array.isArray(input.nodes);
|
|
121
|
+
}
|
|
122
|
+
function isWorkflowNodeDescriptor(value) {
|
|
123
|
+
return Boolean(value?.__openxiangdaWorkflowNode);
|
|
124
|
+
}
|
|
125
|
+
function normalizeAssignee(value) {
|
|
126
|
+
if (typeof value === "string") {
|
|
127
|
+
return { type: value === "originator" ? "originator" : "user", id: value, name: value };
|
|
128
|
+
}
|
|
129
|
+
return value || {};
|
|
130
|
+
}
|
|
131
|
+
function normalizeApprovalData(data = {}) {
|
|
132
|
+
const normalized = { ...data };
|
|
133
|
+
const assignees = Array.isArray(data.assignees) ? data.assignees.map(normalizeAssignee) : void 0;
|
|
134
|
+
if (assignees && !normalized.approverType) {
|
|
135
|
+
const supervisor = assignees.find((item) => item.type === "department_supervisor");
|
|
136
|
+
const initiatorSelect = assignees.find((item) => item.type === "initiator_select");
|
|
137
|
+
const roleAssignees = assignees.filter((item) => item.type === "role");
|
|
138
|
+
const userAssignees = assignees.filter((item) => item.type === "user" || item.type === "originator");
|
|
139
|
+
if (supervisor) {
|
|
140
|
+
normalized.approverType = "ext_target_approval_department_supervisor";
|
|
141
|
+
normalized.supervisorConfig = {
|
|
142
|
+
level: supervisor.level || 1,
|
|
143
|
+
fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,
|
|
144
|
+
...normalized.supervisorConfig || {}
|
|
145
|
+
};
|
|
146
|
+
normalized.approvals = normalized.approvals || [];
|
|
147
|
+
normalized.approvalNames = normalized.approvalNames || [];
|
|
148
|
+
} else if (initiatorSelect) {
|
|
149
|
+
normalized.approverType = "ext_target_approval_initiator_select";
|
|
150
|
+
normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || "all";
|
|
151
|
+
normalized.approvals = normalized.approvals || (Array.isArray(initiatorSelect.approvals) ? initiatorSelect.approvals : roleAssignees.map((item) => item.id).filter(Boolean));
|
|
152
|
+
normalized.approvalNames = normalized.approvalNames || (Array.isArray(initiatorSelect.approvalNames) ? initiatorSelect.approvalNames : roleAssignees.map((item) => item.name || item.id).filter(Boolean));
|
|
153
|
+
} else if (roleAssignees.length > 0 && userAssignees.length === 0) {
|
|
154
|
+
normalized.approverType = "ext_target_approval_role";
|
|
155
|
+
normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);
|
|
156
|
+
normalized.approvalNames = normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);
|
|
157
|
+
} else {
|
|
158
|
+
normalized.approverType = "ext_target_approval";
|
|
159
|
+
normalized.approvals = normalized.approvals || userAssignees.map((item) => item.type === "originator" ? "originator" : item.id).filter(Boolean);
|
|
160
|
+
normalized.approvalNames = normalized.approvalNames || userAssignees.map((item) => item.name || (item.type === "originator" ? "\u53D1\u8D77\u4EBA" : item.id)).filter(Boolean);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return normalized;
|
|
164
|
+
}
|
|
52
165
|
var WorkflowBuilder = class {
|
|
53
166
|
constructor(meta = {}) {
|
|
54
167
|
this.meta = meta;
|
|
@@ -56,19 +169,7 @@ var WorkflowBuilder = class {
|
|
|
56
169
|
this.edges = [];
|
|
57
170
|
this.flowConfig = {};
|
|
58
171
|
this.globalSettings = {};
|
|
59
|
-
this.action =
|
|
60
|
-
approve: (label = "\u540C\u610F", extra = {}) => normalizeAction("agree", label, extra),
|
|
61
|
-
reject: (label = "\u62D2\u7EDD", extra = {}) => normalizeAction("rejected", label, extra),
|
|
62
|
-
transfer: (label = "\u8F6C\u4EA4", extra = {}) => normalizeAction("transfer", label, {
|
|
63
|
-
remark: { popUp: true, required: false },
|
|
64
|
-
...extra
|
|
65
|
-
}),
|
|
66
|
-
return: (label = "\u9000\u56DE", extra = {}) => normalizeAction("return", label, {
|
|
67
|
-
remark: { popUp: true, required: false },
|
|
68
|
-
...extra
|
|
69
|
-
}),
|
|
70
|
-
save: (label = "\u6682\u5B58", extra = {}) => normalizeAction("save", label, extra)
|
|
71
|
-
};
|
|
172
|
+
this.action = workflowActions;
|
|
72
173
|
this.data = {
|
|
73
174
|
retrieveSingle: (id, data) => this.node("data_retrieve_single", id, {
|
|
74
175
|
type: "data_retrieve_single",
|
|
@@ -107,19 +208,20 @@ var WorkflowBuilder = class {
|
|
|
107
208
|
return this.node("end", id, { label: "\u7ED3\u675F\u8282\u70B9", ...data });
|
|
108
209
|
}
|
|
109
210
|
approval(id, data) {
|
|
110
|
-
const
|
|
211
|
+
const approvalData = normalizeApprovalData(data);
|
|
212
|
+
const actions = approvalData.buttons || approvalData.actions || [
|
|
111
213
|
this.action.approve(),
|
|
112
214
|
this.action.reject()
|
|
113
215
|
];
|
|
114
|
-
const returnConfig =
|
|
216
|
+
const returnConfig = approvalData.returnConfig !== void 0 ? normalizeReturnConfig(approvalData.returnConfig) : approvalData.returnPolicy !== void 0 ? normalizeReturnConfig(approvalData.returnPolicy) : void 0;
|
|
115
217
|
return this.node("approval", id, {
|
|
116
|
-
label:
|
|
117
|
-
value:
|
|
118
|
-
approverType:
|
|
119
|
-
approvals:
|
|
120
|
-
approvalNames:
|
|
121
|
-
multiApprove:
|
|
122
|
-
...
|
|
218
|
+
label: approvalData.label || "\u5BA1\u6279",
|
|
219
|
+
value: approvalData.value || "",
|
|
220
|
+
approverType: approvalData.approverType || "ext_target_approval",
|
|
221
|
+
approvals: approvalData.approvals || [],
|
|
222
|
+
approvalNames: approvalData.approvalNames || [],
|
|
223
|
+
multiApprove: approvalData.multiApprove || "or",
|
|
224
|
+
...approvalData,
|
|
123
225
|
actions,
|
|
124
226
|
...returnConfig ? { returnConfig } : {}
|
|
125
227
|
});
|
|
@@ -302,8 +404,9 @@ var WorkflowBuilder = class {
|
|
|
302
404
|
data,
|
|
303
405
|
position: createPosition(this.nodes.length)
|
|
304
406
|
});
|
|
305
|
-
|
|
306
|
-
|
|
407
|
+
const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);
|
|
408
|
+
if (fieldPermissions) {
|
|
409
|
+
this.flowConfig[nodeId] = fieldPermissions;
|
|
307
410
|
}
|
|
308
411
|
return nodeId;
|
|
309
412
|
}
|
|
@@ -369,4 +472,119 @@ function defineWorkflow(input) {
|
|
|
369
472
|
}
|
|
370
473
|
};
|
|
371
474
|
}
|
|
475
|
+
function addDeclarativeNode(builder, node) {
|
|
476
|
+
if (!isWorkflowNodeDescriptor(node)) {
|
|
477
|
+
throw new Error("workflow declarative nodes must be created by flow.* helpers");
|
|
478
|
+
}
|
|
479
|
+
switch (node.type) {
|
|
480
|
+
case "start":
|
|
481
|
+
builder.start(node.id, node.data);
|
|
482
|
+
return;
|
|
483
|
+
case "end":
|
|
484
|
+
builder.end(node.id, node.data);
|
|
485
|
+
return;
|
|
486
|
+
case "approval":
|
|
487
|
+
builder.approval(node.id, node.data);
|
|
488
|
+
return;
|
|
489
|
+
case "copy":
|
|
490
|
+
builder.copy(node.id, node.data);
|
|
491
|
+
return;
|
|
492
|
+
case "js_code":
|
|
493
|
+
builder.jsCode(node.id, node.data);
|
|
494
|
+
return;
|
|
495
|
+
case "function_call":
|
|
496
|
+
builder.functionCall(node.id, node.data);
|
|
497
|
+
return;
|
|
498
|
+
case "callback_wait":
|
|
499
|
+
builder.callbackWait(node.id, node.data);
|
|
500
|
+
return;
|
|
501
|
+
case "connector_call":
|
|
502
|
+
builder.connectorCall(node.id, node.data);
|
|
503
|
+
return;
|
|
504
|
+
case "work_notification":
|
|
505
|
+
builder.workNotification(node.id, node.data);
|
|
506
|
+
return;
|
|
507
|
+
case "condition_branch":
|
|
508
|
+
builder.condition(node.id, node.data);
|
|
509
|
+
return;
|
|
510
|
+
case "branch": {
|
|
511
|
+
builder.branch(node.id, node.data);
|
|
512
|
+
const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];
|
|
513
|
+
branches.forEach((branch, index) => {
|
|
514
|
+
const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);
|
|
515
|
+
builder.condition(conditionId, {
|
|
516
|
+
label: branch.label || (branch.else || branch.isElse ? "\u5176\u4ED6\u60C5\u51B5" : `\u6761\u4EF6 ${index + 1}`),
|
|
517
|
+
condition: branch.condition || {
|
|
518
|
+
ruleType: "group",
|
|
519
|
+
condition: "AND",
|
|
520
|
+
rules: []
|
|
521
|
+
},
|
|
522
|
+
isElse: branch.else === true || branch.isElse === true,
|
|
523
|
+
priority: String(index + 1)
|
|
524
|
+
});
|
|
525
|
+
builder.edge(node.id, conditionId, {
|
|
526
|
+
id: `edge_${node.id}_${conditionId}`,
|
|
527
|
+
label: branch.label
|
|
528
|
+
});
|
|
529
|
+
if (branch.next) {
|
|
530
|
+
builder.edge(conditionId, sanitizeId(branch.next), {
|
|
531
|
+
id: `edge_${conditionId}_${sanitizeId(branch.next)}`,
|
|
532
|
+
label: branch.label
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
default:
|
|
539
|
+
builder.node(node.type, node.id, node.data);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function defineDeclarativeWorkflow(input) {
|
|
543
|
+
return {
|
|
544
|
+
__openxiangdaWorkflow: true,
|
|
545
|
+
compile() {
|
|
546
|
+
const builder = new WorkflowBuilder(input);
|
|
547
|
+
input.nodes.forEach((node) => addDeclarativeNode(builder, node));
|
|
548
|
+
(input.edges || []).forEach((edge) => {
|
|
549
|
+
builder.edge(edge.source, edge.target, edge.data || {});
|
|
550
|
+
});
|
|
551
|
+
return builder.compile();
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
var flow = {
|
|
556
|
+
define(input) {
|
|
557
|
+
if (isDeclarativeInput(input)) {
|
|
558
|
+
return defineDeclarativeWorkflow(input);
|
|
559
|
+
}
|
|
560
|
+
return defineWorkflow(input);
|
|
561
|
+
},
|
|
562
|
+
action: workflowActions,
|
|
563
|
+
assignee: {
|
|
564
|
+
user: (id, name) => ({ type: "user", id, name: name || id }),
|
|
565
|
+
initiator: () => ({ type: "originator", id: "originator", name: "\u53D1\u8D77\u4EBA" }),
|
|
566
|
+
role: (id, name) => ({ type: "role", id, name: name || id }),
|
|
567
|
+
departmentSupervisor: (level = 1, extra = {}) => ({ type: "department_supervisor", level, ...extra }),
|
|
568
|
+
initiatorSelect: (scope = "all", extra = {}) => ({ type: "initiator_select", scope, ...extra })
|
|
569
|
+
},
|
|
570
|
+
start: (id = "start", data = {}) => createDeclarativeNode("start", id, data),
|
|
571
|
+
end: (id = "end", data = {}) => createDeclarativeNode("end", id, data),
|
|
572
|
+
approval: (id, data = {}) => createDeclarativeNode("approval", id, data),
|
|
573
|
+
copy: (id, data = {}) => createDeclarativeNode("copy", id, data),
|
|
574
|
+
jsCode: (id, data = {}) => createDeclarativeNode("js_code", id, data),
|
|
575
|
+
functionCall: (id, data = {}) => createDeclarativeNode("function_call", id, data),
|
|
576
|
+
callbackWait: (id, data = {}) => createDeclarativeNode("callback_wait", id, data),
|
|
577
|
+
connectorCall: (id, data = {}) => createDeclarativeNode("connector_call", id, data),
|
|
578
|
+
workNotification: (id, data = {}) => createDeclarativeNode("work_notification", id, data),
|
|
579
|
+
notification: (id, data = {}) => createDeclarativeNode("work_notification", id, data),
|
|
580
|
+
condition: (id, data = {}) => createDeclarativeNode("condition_branch", id, data),
|
|
581
|
+
branch: (id, data = {}) => createDeclarativeNode("branch", id, data),
|
|
582
|
+
data: {
|
|
583
|
+
retrieveSingle: (id, data = {}) => createDeclarativeNode("data_retrieve_single", id, data),
|
|
584
|
+
retrieveBatch: (id, data = {}) => createDeclarativeNode("data_retrieve_batch", id, data),
|
|
585
|
+
create: (id, data = {}) => createDeclarativeNode("data_create", id, data),
|
|
586
|
+
update: (id, data = {}) => createDeclarativeNode("data_update", id, data)
|
|
587
|
+
},
|
|
588
|
+
connect: createDeclarativeEdge
|
|
589
|
+
};
|
|
372
590
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n };\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const actions =\n data.buttons || data.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n data.returnConfig !== undefined\n ? normalizeReturnConfig(data.returnConfig)\n : data.returnPolicy !== undefined\n ? normalizeReturnConfig(data.returnPolicy)\n : undefined;\n return this.node(\"approval\", id, {\n label: data.label || \"审批\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n multiApprove: data.multiApprove || \"or\",\n ...data,\n actions,\n ...(returnConfig ? { returnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n if (Array.isArray(data.fieldPermissions)) {\n this.flowConfig[nodeId] = data.fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n return {\n definitionJson: {\n version: \"v3\",\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n },\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,WAAW,OAAe;AACjC,SAAO,OAAO,SAAS,EA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,QACf,EAAE;AAAA,QACF,OAAO,KAAK,MAAM,IAAI,CAAC,UAAU;AAAA,UAC/B,QAAQ,KAAK;AAAA,UACb,QAAQ,KAAK;AAAA,UACb,OAAO,KAAK;AAAA,QACd,EAAE;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,eAAe,OAAgC;AAC7D,SAAO;AAAA,IACL,uBAAuB;AAAA,IACvB,UAAU;AACR,YAAM,UAAU,IAAI,gBAAgB,KAAK;AACzC,YAAM,MAAM,OAAO;AACnB,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/workflow/index.ts"],"sourcesContent":["export type WorkflowNodeRef = string;\n\nexport interface WorkflowCompileResult {\n definitionJson: {\n version: \"v3\";\n nodes: any[];\n edges: any[];\n flowConfig: Record<string, any[]>;\n globalSettings: Record<string, any>;\n };\n previewJson: {\n kind: \"workflow_code_preview\";\n version: \"preview_v1\";\n steps: any[];\n edges: any[];\n sourceMode: \"workflow_code_ts\";\n };\n}\n\nexport interface WorkflowDefinitionInput {\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n build: (flow: WorkflowBuilder) => void;\n}\n\nexport interface WorkflowDeclarativeInput {\n id?: string;\n name?: string;\n formCode?: string;\n formUuid?: string;\n globalSettings?: Record<string, any>;\n nodes: WorkflowDeclarativeNode[];\n edges?: WorkflowDeclarativeEdge[];\n}\n\nexport interface WorkflowDeclarativeNode {\n __openxiangdaWorkflowNode: true;\n id: WorkflowNodeRef;\n type: string;\n data: NodeOptions;\n}\n\nexport interface WorkflowDeclarativeEdge {\n __openxiangdaWorkflowEdge: true;\n source: WorkflowNodeRef;\n target: WorkflowNodeRef;\n data?: NodeOptions;\n}\n\ntype NodeOptions = Record<string, any>;\n\nfunction sanitizeId(value: string) {\n return String(value || \"\")\n .trim()\n .replace(/[^a-zA-Z0-9_-]/g, \"_\");\n}\n\nfunction createPosition(index: number) {\n return { x: 400, y: 100 + index * 150 };\n}\n\nfunction normalizeAction(action: string, label: string, extra: NodeOptions = {}) {\n return {\n action,\n name: { zh_CN: label },\n ...extra,\n };\n}\n\nconst workflowActions = {\n approve: (label = \"同意\", extra: NodeOptions = {}) =>\n normalizeAction(\"agree\", label, extra),\n reject: (label = \"拒绝\", extra: NodeOptions = {}) =>\n normalizeAction(\"rejected\", label, extra),\n transfer: (label = \"转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"transfer\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n return: (label = \"退回\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n ...extra,\n }),\n returnToInitiator: (label = \"退回发起人\", extra: NodeOptions = {}) =>\n normalizeAction(\"return\", label, {\n remark: { popUp: true, required: false },\n returnTarget: \"initiator\",\n returnScope: \"initiator\",\n ...extra,\n }),\n save: (label = \"暂存\", extra: NodeOptions = {}) =>\n normalizeAction(\"save\", label, extra),\n withdraw: (label = \"撤回\", extra: NodeOptions = {}) =>\n normalizeAction(\"withdraw\", label, extra),\n resubmit: (label = \"重新提交\", extra: NodeOptions = {}) =>\n normalizeAction(\"resubmit\", label, extra),\n callback: (label = \"触发回调\", extra: NodeOptions = {}) =>\n normalizeAction(\"callback\", label, extra),\n retryException: (label = \"重试异常\", extra: NodeOptions = {}) =>\n normalizeAction(\"retryException\", label, extra),\n adminTransfer: (label = \"管理员转交\", extra: NodeOptions = {}) =>\n normalizeAction(\"adminTransfer\", label, extra),\n};\n\nfunction normalizeReturnConfig(value: any) {\n if (value === false) return { enabled: false };\n if (value === true || value === undefined) {\n return { enabled: true, scopeType: \"previous_all\" };\n }\n return {\n enabled: value.enabled !== false,\n scopeType: value.scopeType || value.scope || \"previous_all\",\n resubmitMode: value.resubmitMode || \"resume_current\",\n ...value,\n };\n}\n\nfunction normalizeFieldBehavior(value: any) {\n const normalized = String(value || \"\").trim().toLowerCase();\n if ([\"normal\", \"edit\", \"editable\", \"write\", \"writable\"].includes(normalized)) return \"NORMAL\";\n if ([\"readonly\", \"read\", \"view\", \"visible\"].includes(normalized)) return \"READONLY\";\n if ([\"hidden\", \"hide\", \"invisible\"].includes(normalized)) return \"HIDDEN\";\n return String(value || \"READONLY\").toUpperCase();\n}\n\nfunction normalizeFieldPermissions(value: any): any[] | undefined {\n if (Array.isArray(value)) {\n return value.map((item) => {\n if (!item || typeof item !== \"object\") return item;\n return {\n ...item,\n fieldId: item.fieldId || item.field || item.id,\n fieldBehavior: normalizeFieldBehavior(item.fieldBehavior || item.behavior || item.permission),\n };\n });\n }\n if (value && typeof value === \"object\") {\n return Object.entries(value).map(([fieldId, fieldBehavior]) => ({\n fieldId,\n fieldBehavior: normalizeFieldBehavior(fieldBehavior),\n }));\n }\n return undefined;\n}\n\nfunction createDeclarativeNode(\n type: string,\n id: string,\n data: NodeOptions = {},\n): WorkflowDeclarativeNode {\n return {\n __openxiangdaWorkflowNode: true,\n id: sanitizeId(id),\n type,\n data,\n };\n}\n\nfunction createDeclarativeEdge(\n source: WorkflowNodeRef,\n target: WorkflowNodeRef,\n data: NodeOptions = {},\n): WorkflowDeclarativeEdge {\n return {\n __openxiangdaWorkflowEdge: true,\n source,\n target,\n data,\n };\n}\n\nfunction isDeclarativeInput(input: any): input is WorkflowDeclarativeInput {\n return input && Array.isArray(input.nodes);\n}\n\nfunction isWorkflowNodeDescriptor(value: any): value is WorkflowDeclarativeNode {\n return Boolean(value?.__openxiangdaWorkflowNode);\n}\n\nfunction normalizeAssignee(value: any) {\n if (typeof value === \"string\") {\n return { type: value === \"originator\" ? \"originator\" : \"user\", id: value, name: value };\n }\n return value || {};\n}\n\nfunction normalizeApprovalData(data: NodeOptions = {}) {\n const normalized: NodeOptions = { ...data };\n const assignees = Array.isArray(data.assignees)\n ? data.assignees.map(normalizeAssignee)\n : undefined;\n\n if (assignees && !normalized.approverType) {\n const supervisor = assignees.find((item) => item.type === \"department_supervisor\");\n const initiatorSelect = assignees.find((item) => item.type === \"initiator_select\");\n const roleAssignees = assignees.filter((item) => item.type === \"role\");\n const userAssignees = assignees.filter((item) => item.type === \"user\" || item.type === \"originator\");\n\n if (supervisor) {\n normalized.approverType = \"ext_target_approval_department_supervisor\";\n normalized.supervisorConfig = {\n level: supervisor.level || 1,\n fallbackToAncestorSupervisor: supervisor.fallbackToAncestorSupervisor !== false,\n ...(normalized.supervisorConfig || {}),\n };\n normalized.approvals = normalized.approvals || [];\n normalized.approvalNames = normalized.approvalNames || [];\n } else if (initiatorSelect) {\n normalized.approverType = \"ext_target_approval_initiator_select\";\n normalized.initiatorSelectScope = initiatorSelect.scope || initiatorSelect.initiatorSelectScope || \"all\";\n normalized.approvals =\n normalized.approvals ||\n (Array.isArray(initiatorSelect.approvals)\n ? initiatorSelect.approvals\n : roleAssignees.map((item) => item.id).filter(Boolean));\n normalized.approvalNames =\n normalized.approvalNames ||\n (Array.isArray(initiatorSelect.approvalNames)\n ? initiatorSelect.approvalNames\n : roleAssignees.map((item) => item.name || item.id).filter(Boolean));\n } else if (roleAssignees.length > 0 && userAssignees.length === 0) {\n normalized.approverType = \"ext_target_approval_role\";\n normalized.approvals = normalized.approvals || roleAssignees.map((item) => item.id).filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames || roleAssignees.map((item) => item.name || item.id).filter(Boolean);\n } else {\n normalized.approverType = \"ext_target_approval\";\n normalized.approvals =\n normalized.approvals ||\n userAssignees\n .map((item) => (item.type === \"originator\" ? \"originator\" : item.id))\n .filter(Boolean);\n normalized.approvalNames =\n normalized.approvalNames ||\n userAssignees\n .map((item) => item.name || (item.type === \"originator\" ? \"发起人\" : item.id))\n .filter(Boolean);\n }\n }\n\n return normalized;\n}\n\nexport class WorkflowBuilder {\n private nodes: any[] = [];\n private edges: any[] = [];\n private flowConfig: Record<string, any[]> = {};\n private globalSettings: Record<string, any> = {};\n readonly action = workflowActions;\n\n constructor(private readonly meta: Omit<WorkflowDefinitionInput, \"build\"> = {}) {\n this.globalSettings = { ...(meta.globalSettings || {}) };\n }\n\n start(id = \"start\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"start\", id, { label: \"开始节点\", ...data });\n }\n\n end(id = \"end\", data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"end\", id, { label: \"结束节点\", ...data });\n }\n\n approval(id: string, data: NodeOptions): WorkflowNodeRef {\n const approvalData = normalizeApprovalData(data);\n const actions =\n approvalData.buttons || approvalData.actions || [\n this.action.approve(),\n this.action.reject(),\n ];\n const returnConfig =\n approvalData.returnConfig !== undefined\n ? normalizeReturnConfig(approvalData.returnConfig)\n : approvalData.returnPolicy !== undefined\n ? normalizeReturnConfig(approvalData.returnPolicy)\n : undefined;\n return this.node(\"approval\", id, {\n label: approvalData.label || \"审批\",\n value: approvalData.value || \"\",\n approverType: approvalData.approverType || \"ext_target_approval\",\n approvals: approvalData.approvals || [],\n approvalNames: approvalData.approvalNames || [],\n multiApprove: approvalData.multiApprove || \"or\",\n ...approvalData,\n actions,\n ...(returnConfig ? { returnConfig } : {}),\n });\n }\n\n copy(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"copy\", id, {\n label: data.label || \"抄送\",\n value: data.value || \"\",\n approverType: data.approverType || \"ext_target_approval\",\n approvals: data.approvals || [],\n approvalNames: data.approvalNames || [],\n ...data,\n });\n }\n\n jsCode(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"js_code\", id, {\n label: data.label || \"JS代码节点\",\n runtimeMode: \"trusted_node\",\n sourceType: data.sourceFile ? \"file_snapshot\" : data.sourceType || \"inline\",\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n functionCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"function_call\", id, {\n label: data.label || \"调用函数\",\n functionCode: data.functionCode || data.code,\n input: data.input || data.inputMapping || {},\n saveResponseTo: data.saveResponseTo || data.outputKey,\n timeout: data.timeout || data.timeoutMs || 30000,\n ...data,\n });\n }\n\n callbackWait(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"callback_wait\", id, {\n type: \"callback_wait\",\n label: data.label || \"回调等待\",\n timeoutSeconds: data.timeoutSeconds || 86400,\n timeoutStrategy: data.timeoutStrategy || \"FAIL\",\n ...data,\n });\n }\n\n connectorCall(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"connector_call\", id, {\n type: \"connector_call\",\n label: data.label || \"连接器\",\n timeout: data.timeout || 30000,\n ...data,\n });\n }\n\n workNotification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"work_notification\", id, {\n label: data.label || \"工作通知\",\n buttonText: data.buttonText || \"查看详情\",\n linkType: data.linkType || \"current_form\",\n ...data,\n });\n }\n\n notification(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.workNotification(id, data);\n }\n\n dingtalkCard(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"dingtalk_card\", id, {\n config: {\n type: \"dingtalk_card\",\n label: data.label || \"钉钉消息卡片\",\n sameFieldStrategy: \"create\",\n ...(data.config || data),\n },\n });\n }\n\n condition(id: string, data: NodeOptions): WorkflowNodeRef {\n return this.node(\"condition_branch\", id, {\n type: \"condition_branch\",\n label: data.label || \"条件分支\",\n condition: data.condition || { ruleType: \"group\", condition: \"AND\", rules: [] },\n isElse: data.isElse === true,\n priority: data.priority || \"1\",\n trueNodeId: data.trueNodeId,\n falseNodeId: data.falseNodeId,\n ...data,\n });\n }\n\n branch(id: string, data: NodeOptions = {}): WorkflowNodeRef {\n return this.node(\"branch\", id, {\n label: data.label || \"辅助分支\",\n isAuxNode: data.isAuxNode ?? true,\n branchType: data.branchType || \"controller\",\n ...data,\n });\n }\n\n parallel(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n nodes: WorkflowNodeRef[];\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_branch`, {\n label: data.label || \"并行分支\",\n branchType: \"parallel_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"并行汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length === 0) return;\n this.edge(entry, nodes[0], {\n id: `edge_${entry}_${sanitizeId(branch.id || String(index))}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${sanitizeId(branch.id || String(index))}_${converge}`,\n });\n });\n\n return { entry, converge };\n }\n\n conditionBranches(\n id: string,\n branches: Array<{\n id: string;\n label?: string;\n condition?: any;\n nodes: WorkflowNodeRef[];\n isElse?: boolean;\n }>,\n data: NodeOptions = {},\n ) {\n const entry = this.branch(`${id}_controller`, {\n label: data.label || \"条件分支\",\n branchType: \"condition_controller\",\n hidden: true,\n });\n const converge = this.branch(`${id}_converge`, {\n label: data.convergeLabel || \"条件汇聚\",\n branchType: \"converge\",\n hidden: true,\n });\n\n branches.forEach((branch, index) => {\n const condition = this.condition(`${id}_${branch.id}`, {\n label: branch.label || (branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.isElse === true,\n priority: String(index + 1),\n });\n this.edge(entry, condition, {\n id: `edge_${entry}_${condition}`,\n label: branch.label,\n });\n const nodes = branch.nodes.filter(Boolean);\n if (nodes.length > 0) {\n this.edge(condition, nodes[0], {\n id: `edge_${condition}_${nodes[0]}`,\n label: branch.label,\n });\n this.sequence(...nodes);\n this.edge(nodes[nodes.length - 1], converge, {\n id: `edge_${nodes[nodes.length - 1]}_${converge}`,\n });\n } else {\n this.edge(condition, converge, {\n id: `edge_${condition}_${converge}`,\n });\n }\n });\n\n if (!branches.some((branch) => branch.isElse)) {\n const elseNode = this.condition(`${id}_else`, {\n label: \"其他情况\",\n isElse: true,\n priority: String(branches.length + 1),\n condition: { ruleType: \"group\", condition: \"AND\", rules: [] },\n });\n this.edge(entry, elseNode, { id: `edge_${entry}_${elseNode}`, label: \"其他情况\" });\n this.edge(elseNode, converge, { id: `edge_${elseNode}_${converge}` });\n }\n\n return { entry, converge };\n }\n\n data = {\n retrieveSingle: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_single\", id, {\n type: \"data_retrieve_single\",\n label: data.label || \"获取单条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n retrieveBatch: (id: string, data: NodeOptions) =>\n this.node(\"data_retrieve_batch\", id, {\n type: \"data_retrieve_batch\",\n label: data.label || \"获取多条数据\",\n filterType: data.filterType || \"condition\",\n ...data,\n }),\n create: (id: string, data: NodeOptions) =>\n this.node(\"data_create\", id, {\n type: \"data_create\",\n label: data.label || \"新增数据\",\n insertType: data.insertType || \"form\",\n assignments: data.assignments || [],\n ...data,\n }),\n update: (id: string, data: NodeOptions) =>\n this.node(\"data_update\", id, {\n type: \"data_update\",\n label: data.label || \"更新数据\",\n updateType: data.updateType || \"direct_form\",\n assignments: data.assignments || [],\n noneOperation: data.noneOperation || \"ignored\",\n ...data,\n }),\n };\n\n node(type: string, id: string, data: NodeOptions): WorkflowNodeRef {\n const nodeId = sanitizeId(id);\n if (!nodeId) throw new Error(\"workflow node id is required\");\n if (this.nodes.some((node) => node.id === nodeId)) {\n throw new Error(`duplicate workflow node id: ${nodeId}`);\n }\n this.nodes.push({\n id: nodeId,\n type,\n data,\n position: createPosition(this.nodes.length),\n });\n const fieldPermissions = normalizeFieldPermissions(data.fieldPermissions);\n if (fieldPermissions) {\n this.flowConfig[nodeId] = fieldPermissions;\n }\n return nodeId;\n }\n\n edge(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n const id = data.id || `edge_${source}_${target}`;\n this.edges.push({\n id,\n source,\n target,\n type: data.type || \"custom\",\n ...(data.label ? { label: data.label } : {}),\n });\n }\n\n connect(source: WorkflowNodeRef, target: WorkflowNodeRef, data: NodeOptions = {}) {\n this.edge(source, target, data);\n }\n\n sequence(...refs: WorkflowNodeRef[]) {\n for (let index = 0; index < refs.length - 1; index += 1) {\n this.edge(refs[index], refs[index + 1]);\n }\n }\n\n setFieldPermissions(nodeId: WorkflowNodeRef, permissions: any[]) {\n this.flowConfig[nodeId] = permissions;\n }\n\n setGlobalSettings(settings: Record<string, any>) {\n this.globalSettings = { ...this.globalSettings, ...settings };\n }\n\n compile(): WorkflowCompileResult {\n return {\n definitionJson: {\n version: \"v3\",\n nodes: this.nodes,\n edges: this.edges,\n flowConfig: this.flowConfig,\n globalSettings: this.globalSettings,\n },\n previewJson: {\n kind: \"workflow_code_preview\",\n version: \"preview_v1\",\n sourceMode: \"workflow_code_ts\",\n steps: this.nodes.map((node) => ({\n id: node.id,\n type: node.type,\n label: node.data?.label || node.id,\n config: node.data,\n })),\n edges: this.edges.map((edge) => ({\n source: edge.source,\n target: edge.target,\n label: edge.label,\n })),\n },\n };\n }\n}\n\nexport function defineWorkflow(input: WorkflowDefinitionInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.build(builder);\n return builder.compile();\n },\n };\n}\n\nfunction addDeclarativeNode(builder: WorkflowBuilder, node: WorkflowDeclarativeNode) {\n if (!isWorkflowNodeDescriptor(node)) {\n throw new Error(\"workflow declarative nodes must be created by flow.* helpers\");\n }\n\n switch (node.type) {\n case \"start\":\n builder.start(node.id, node.data);\n return;\n case \"end\":\n builder.end(node.id, node.data);\n return;\n case \"approval\":\n builder.approval(node.id, node.data);\n return;\n case \"copy\":\n builder.copy(node.id, node.data);\n return;\n case \"js_code\":\n builder.jsCode(node.id, node.data);\n return;\n case \"function_call\":\n builder.functionCall(node.id, node.data);\n return;\n case \"callback_wait\":\n builder.callbackWait(node.id, node.data);\n return;\n case \"connector_call\":\n builder.connectorCall(node.id, node.data);\n return;\n case \"work_notification\":\n builder.workNotification(node.id, node.data);\n return;\n case \"condition_branch\":\n builder.condition(node.id, node.data);\n return;\n case \"branch\": {\n builder.branch(node.id, node.data);\n const branches = Array.isArray(node.data?.branches) ? node.data.branches : [];\n branches.forEach((branch: any, index: number) => {\n const conditionId = sanitizeId(`${node.id}_${branch.id || index + 1}`);\n builder.condition(conditionId, {\n label: branch.label || (branch.else || branch.isElse ? \"其他情况\" : `条件 ${index + 1}`),\n condition:\n branch.condition || {\n ruleType: \"group\",\n condition: \"AND\",\n rules: [],\n },\n isElse: branch.else === true || branch.isElse === true,\n priority: String(index + 1),\n });\n builder.edge(node.id, conditionId, {\n id: `edge_${node.id}_${conditionId}`,\n label: branch.label,\n });\n if (branch.next) {\n builder.edge(conditionId, sanitizeId(branch.next), {\n id: `edge_${conditionId}_${sanitizeId(branch.next)}`,\n label: branch.label,\n });\n }\n });\n return;\n }\n default:\n builder.node(node.type, node.id, node.data);\n }\n}\n\nfunction defineDeclarativeWorkflow(input: WorkflowDeclarativeInput) {\n return {\n __openxiangdaWorkflow: true,\n compile() {\n const builder = new WorkflowBuilder(input);\n input.nodes.forEach((node) => addDeclarativeNode(builder, node));\n (input.edges || []).forEach((edge) => {\n builder.edge(edge.source, edge.target, edge.data || {});\n });\n return builder.compile();\n },\n };\n}\n\nexport const flow = {\n define(input: WorkflowDefinitionInput | WorkflowDeclarativeInput) {\n if (isDeclarativeInput(input)) {\n return defineDeclarativeWorkflow(input);\n }\n return defineWorkflow(input);\n },\n action: workflowActions,\n assignee: {\n user: (id: string, name?: string) => ({ type: \"user\", id, name: name || id }),\n initiator: () => ({ type: \"originator\", id: \"originator\", name: \"发起人\" }),\n role: (id: string, name?: string) => ({ type: \"role\", id, name: name || id }),\n departmentSupervisor: (\n level = 1,\n extra: NodeOptions = {},\n ) => ({ type: \"department_supervisor\", level, ...extra }),\n initiatorSelect: (\n scope: \"all\" | \"members\" | \"roles\" = \"all\",\n extra: NodeOptions = {},\n ) => ({ type: \"initiator_select\", scope, ...extra }),\n },\n start: (id = \"start\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"start\", id, data),\n end: (id = \"end\", data: NodeOptions = {}) =>\n createDeclarativeNode(\"end\", id, data),\n approval: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"approval\", id, data),\n copy: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"copy\", id, data),\n jsCode: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"js_code\", id, data),\n functionCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"function_call\", id, data),\n callbackWait: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"callback_wait\", id, data),\n connectorCall: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"connector_call\", id, data),\n workNotification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n notification: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"work_notification\", id, data),\n condition: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"condition_branch\", id, data),\n branch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"branch\", id, data),\n data: {\n retrieveSingle: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_single\", id, data),\n retrieveBatch: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_retrieve_batch\", id, data),\n create: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_create\", id, data),\n update: (id: string, data: NodeOptions = {}) =>\n createDeclarativeNode(\"data_update\", id, data),\n },\n connect: createDeclarativeEdge,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqDA,SAAS,WAAW,OAAe;AACjC,SAAO,OAAO,SAAS,EAAE,EACtB,KAAK,EACL,QAAQ,mBAAmB,GAAG;AACnC;AAEA,SAAS,eAAe,OAAe;AACrC,SAAO,EAAE,GAAG,KAAK,GAAG,MAAM,QAAQ,IAAI;AACxC;AAEA,SAAS,gBAAgB,QAAgB,OAAe,QAAqB,CAAC,GAAG;AAC/E,SAAO;AAAA,IACL;AAAA,IACA,M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