@rytass/bpm-core-shared 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +3 -2
  3. package/src/index.js +13 -0
  4. package/src/index.js.map +1 -0
  5. package/src/lib/condition.d.ts +43 -0
  6. package/src/lib/condition.js +3 -0
  7. package/src/lib/condition.js.map +1 -0
  8. package/src/lib/form.d.ts +48 -0
  9. package/src/lib/form.js +3 -0
  10. package/src/lib/form.js.map +1 -0
  11. package/src/lib/identity.d.ts +24 -0
  12. package/src/lib/identity.js +3 -0
  13. package/src/lib/identity.js.map +1 -0
  14. package/src/lib/organization.d.ts +47 -0
  15. package/src/lib/organization.js +3 -0
  16. package/src/lib/organization.js.map +1 -0
  17. package/src/lib/status.d.ts +7 -0
  18. package/src/lib/status.js +3 -0
  19. package/src/lib/status.js.map +1 -0
  20. package/src/lib/workflow-command.d.ts +156 -0
  21. package/src/lib/workflow-command.js +292 -0
  22. package/src/lib/workflow-command.js.map +1 -0
  23. package/src/lib/workflow-graph.d.ts +96 -0
  24. package/src/lib/workflow-graph.js +605 -0
  25. package/src/lib/workflow-graph.js.map +1 -0
  26. package/src/lib/workflow-toolset.d.ts +105 -0
  27. package/src/lib/workflow-toolset.js +702 -0
  28. package/src/lib/workflow-toolset.js.map +1 -0
  29. package/src/lib/workflow.d.ts +160 -0
  30. package/src/lib/workflow.js +3 -0
  31. package/src/lib/workflow.js.map +1 -0
  32. package/eslint.config.mjs +0 -19
  33. package/jest.config.cts +0 -10
  34. package/project.json +0 -49
  35. package/src/lib/condition.ts +0 -55
  36. package/src/lib/form.ts +0 -77
  37. package/src/lib/identity.ts +0 -25
  38. package/src/lib/organization.ts +0 -52
  39. package/src/lib/shared.spec.ts +0 -13
  40. package/src/lib/status.ts +0 -29
  41. package/src/lib/workflow-command.spec.ts +0 -278
  42. package/src/lib/workflow-command.ts +0 -848
  43. package/src/lib/workflow-graph.ts +0 -974
  44. package/src/lib/workflow-toolset.spec.ts +0 -230
  45. package/src/lib/workflow-toolset.ts +0 -1083
  46. package/src/lib/workflow.ts +0 -216
  47. package/tsconfig.json +0 -23
  48. package/tsconfig.lib.json +0 -16
  49. package/tsconfig.spec.json +0 -16
  50. /package/src/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyWorkflowCommand = applyWorkflowCommand;
4
+ exports.applyWorkflowMacroCommand = applyWorkflowMacroCommand;
5
+ exports.applyWorkflowCommands = applyWorkflowCommands;
6
+ exports.expandMacroCommand = expandMacroCommand;
7
+ const workflow_graph_1 = require("./workflow-graph");
8
+ const NO_EFFECTS = { layout: false };
9
+ const LAYOUT_EFFECTS = { layout: true };
10
+ function finalize(state, changed, effects, error = null) {
11
+ return {
12
+ changed,
13
+ effects,
14
+ error,
15
+ issue: (0, workflow_graph_1.readWorkflowDefinitionIssue)(state.definition),
16
+ state,
17
+ };
18
+ }
19
+ function reject(state, error) {
20
+ return finalize(state, false, NO_EFFECTS, error);
21
+ }
22
+ /**
23
+ * Apply a single primitive command. Pure: same input → same output (given a
24
+ * deterministic edge id factory). Topology-changing commands set
25
+ * `effects.layout` so the controller can run dagre afterwards.
26
+ */
27
+ function applyWorkflowCommand(state, command, options = {}) {
28
+ var _a;
29
+ const createEdgeId = (_a = options.createEdgeId) !== null && _a !== void 0 ? _a : workflow_graph_1.defaultWorkflowEdgeId;
30
+ switch (command.type) {
31
+ case 'addNode':
32
+ return applyAddNode(state, command, createEdgeId);
33
+ case 'renameNode':
34
+ return applyRenameNode(state, command);
35
+ case 'deleteNode':
36
+ return applyDeleteNode(state, command);
37
+ case 'setNodeTriggerMode':
38
+ return applySetNodeTriggerMode(state, command);
39
+ case 'setUserTaskApprover':
40
+ return applySetUserTaskApprover(state, command);
41
+ case 'setUserTaskReturnResubmitStrategy':
42
+ return applySetUserTaskReturnResubmitStrategy(state, command);
43
+ case 'setUserTaskOptions':
44
+ return applySetUserTaskOptions(state, command);
45
+ case 'setServiceAction':
46
+ return applySetServiceAction(state, command);
47
+ case 'setEndState':
48
+ return applySetEndState(state, command);
49
+ case 'connectEdge':
50
+ return applyConnectEdge(state, command, createEdgeId);
51
+ case 'deleteEdge':
52
+ return applyDeleteEdge(state, command);
53
+ case 'setEdgeCondition':
54
+ return applySetEdgeCondition(state, command);
55
+ case 'setEdgeDefault':
56
+ return applySetEdgeDefault(state, command);
57
+ case 'bindForm':
58
+ return applyBindForm(state, command);
59
+ case 'setInitiatorPolicyCel':
60
+ return applySetInitiatorPolicyCel(state, command);
61
+ case 'selectNode':
62
+ return finalize(Object.assign(Object.assign({}, state), { selectedNodeId: command.nodeId, selectedEdgeIds: [] }), true, NO_EFFECTS);
63
+ case 'selectEdges':
64
+ return finalize(Object.assign(Object.assign({}, state), { selectedEdgeIds: command.edgeIds, selectedNodeId: null }), true, NO_EFFECTS);
65
+ case 'autoLayout':
66
+ return finalize(state, true, LAYOUT_EFFECTS);
67
+ default:
68
+ return assertNever(command);
69
+ }
70
+ }
71
+ /**
72
+ * Apply a high-level macro by expanding it into primitive commands. The added
73
+ * node's id is deterministic (`<nodeType>_<nextIndex>`), so follow-up commands
74
+ * can target it without depending on the post-insert selection.
75
+ */
76
+ function applyWorkflowMacroCommand(state, command, options = {}) {
77
+ return applyWorkflowCommands(state, expandMacroCommand(state, command), options);
78
+ }
79
+ /** Apply a batch of primitive commands in order, threading state. */
80
+ function applyWorkflowCommands(state, commands, options = {}) {
81
+ return commands.reduce((accumulator, command) => {
82
+ var _a;
83
+ const next = applyWorkflowCommand(accumulator.state, command, options);
84
+ return Object.assign(Object.assign({}, next), { changed: accumulator.changed || next.changed, effects: {
85
+ layout: accumulator.effects.layout || next.effects.layout,
86
+ },
87
+ // Keep the first hard error encountered.
88
+ error: (_a = accumulator.error) !== null && _a !== void 0 ? _a : next.error });
89
+ }, finalize(state, false, NO_EFFECTS));
90
+ }
91
+ /**
92
+ * Expand a high-level macro into the primitive command sequence that realises
93
+ * it. The next node id is derived from the same deterministic rule
94
+ * {@link applyAddNode} uses, so post-add commands can target it directly.
95
+ */
96
+ function expandMacroCommand(state, command) {
97
+ if (command.type === 'insertApprovalStep') {
98
+ const nodeId = readNextWorkflowNodeId(state, 'userTask');
99
+ return [
100
+ { type: 'addNode', nodeType: 'userTask', anchor: command.anchor },
101
+ {
102
+ type: 'setUserTaskApprover',
103
+ nodeId,
104
+ approverResolver: command.approverResolver,
105
+ },
106
+ ...(command.label === undefined
107
+ ? []
108
+ : [{ type: 'renameNode', nodeId, label: command.label }]),
109
+ ];
110
+ }
111
+ if (command.type === 'insertNotification') {
112
+ const nodeId = readNextWorkflowNodeId(state, 'serviceTask');
113
+ return [
114
+ { type: 'addNode', nodeType: 'serviceTask', anchor: command.anchor },
115
+ { type: 'setServiceAction', nodeId, action: command.action },
116
+ ...(command.label === undefined
117
+ ? []
118
+ : [{ type: 'renameNode', nodeId, label: command.label }]),
119
+ ];
120
+ }
121
+ const nodeId = readNextWorkflowNodeId(state, 'exclusiveGateway');
122
+ return [
123
+ { type: 'addNode', nodeType: 'exclusiveGateway', anchor: command.anchor },
124
+ ...(command.label === undefined
125
+ ? []
126
+ : [{ type: 'renameNode', nodeId, label: command.label }]),
127
+ ];
128
+ }
129
+ /** The id {@link applyAddNode} will assign to the next node of this type. */
130
+ function readNextWorkflowNodeId(state, nodeType) {
131
+ return `${nodeType}_${(0, workflow_graph_1.readNextWorkflowNodeIndex)(state.definition.nodes, nodeType)}`;
132
+ }
133
+ // ── Node command handlers ──────────────────────────────────────────────────
134
+ function applyAddNode(state, command, createEdgeId) {
135
+ var _a, _b, _c, _d, _e;
136
+ const nodeIndex = (0, workflow_graph_1.readNextWorkflowNodeIndex)(state.definition.nodes, command.nodeType);
137
+ const node = (0, workflow_graph_1.createWorkflowNode)(command.nodeType, nodeIndex);
138
+ const selectedEdgeId = (_b = (_a = command.anchor) === null || _a === void 0 ? void 0 : _a.edgeId) !== null && _b !== void 0 ? _b : (state.selectedEdgeIds.length === 1 ? state.selectedEdgeIds[0] : null);
139
+ const selectedNodeId = (_d = (_c = command.anchor) === null || _c === void 0 ? void 0 : _c.afterNodeId) !== null && _d !== void 0 ? _d : (((_e = command.anchor) === null || _e === void 0 ? void 0 : _e.edgeId) ? null : state.selectedNodeId);
140
+ const inserted = (0, workflow_graph_1.insertWorkflowNodeIntoDefinition)({
141
+ createId: createEdgeId,
142
+ definition: state.definition,
143
+ node,
144
+ selectedEdgeId,
145
+ selectedNodeId,
146
+ });
147
+ return finalize(Object.assign(Object.assign({}, state), { definition: (0, workflow_graph_1.normalizeDesignerWorkflowDefinition)(inserted.definition), editingEdgeId: inserted.editingEdgeId, selectedEdgeIds: inserted.selectedEdgeIds, selectedNodeId: inserted.selectedNodeId }), true, LAYOUT_EFFECTS);
148
+ }
149
+ function applyRenameNode(state, command) {
150
+ return mapNode(state, command.nodeId, (node) => (0, workflow_graph_1.renameWorkflowNode)(node, command.label));
151
+ }
152
+ function applyDeleteNode(state, command) {
153
+ const node = state.definition.nodes.find((candidate) => candidate.id === command.nodeId);
154
+ if (!node) {
155
+ return reject(state, `找不到節點:${command.nodeId}`);
156
+ }
157
+ if (!(0, workflow_graph_1.isWorkflowNodeRemovable)(node)) {
158
+ return reject(state, '開始與結束節點無法刪除。');
159
+ }
160
+ const definition = (0, workflow_graph_1.normalizeDesignerWorkflowDefinition)(Object.assign(Object.assign({}, state.definition), { edges: state.definition.edges.filter((edge) => edge.source !== node.id && edge.target !== node.id), nodes: state.definition.nodes.filter((candidate) => candidate.id !== node.id) }));
161
+ // Deleting preserves the remaining nodes' manual positions (matches the
162
+ // original designer); tidying is an explicit `autoLayout` step.
163
+ return finalize(Object.assign(Object.assign({}, state), { definition, editingEdgeId: null, selectedEdgeIds: [], selectedNodeId: 'start' }), true, NO_EFFECTS);
164
+ }
165
+ function applySetNodeTriggerMode(state, command) {
166
+ const node = state.definition.nodes.find((n) => n.id === command.nodeId);
167
+ if ((node === null || node === void 0 ? void 0 : node.type) === 'startEvent') {
168
+ return reject(state, '開始節點沒有觸發模式。');
169
+ }
170
+ return mapNode(state, command.nodeId, (target) => (0, workflow_graph_1.applyWorkflowNodeTriggerMode)(target, command.triggerMode));
171
+ }
172
+ function applySetUserTaskApprover(state, command) {
173
+ return mapNode(state, command.nodeId, (node) => node.type === 'userTask'
174
+ ? Object.assign(Object.assign({}, node), { data: Object.assign(Object.assign({}, node.data), { approverResolver: command.approverResolver, decisionPolicy: { type: 'SINGLE' } }) }) : node, 'userTask');
175
+ }
176
+ function applySetUserTaskReturnResubmitStrategy(state, command) {
177
+ return mapNode(state, command.nodeId, (node) => node.type === 'userTask'
178
+ ? Object.assign(Object.assign({}, node), { data: Object.assign(Object.assign({}, node.data), { returnBehavior: Object.assign(Object.assign({}, node.data.returnBehavior), { resubmitStrategy: command.resubmitStrategy }) }) }) : node, 'userTask');
179
+ }
180
+ function applySetUserTaskOptions(state, command) {
181
+ return mapNode(state, command.nodeId, (node) => node.type === 'userTask'
182
+ ? Object.assign(Object.assign({}, node), { data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, node.data), (command.allowAddSigner === undefined
183
+ ? {}
184
+ : { allowAddSigner: command.allowAddSigner })), (command.allowReject === undefined
185
+ ? {}
186
+ : { allowReject: command.allowReject })), (command.allowTransfer === undefined
187
+ ? {}
188
+ : { allowTransfer: command.allowTransfer })), (command.description === undefined
189
+ ? {}
190
+ : { description: command.description })) }) : node, 'userTask');
191
+ }
192
+ function applySetServiceAction(state, command) {
193
+ const result = mapNode(state, command.nodeId, (node) => node.type === 'serviceTask'
194
+ ? Object.assign(Object.assign({}, node), { data: Object.assign(Object.assign({}, node.data), { action: command.action }) }) : node, 'serviceTask');
195
+ if (!result.changed) {
196
+ return result;
197
+ }
198
+ // Switching a service task to async NOTIFY drops its outgoing edges
199
+ // (normalizeDesignerWorkflowDefinition). The original designer did not
200
+ // relayout here, so neither do we — positions are preserved.
201
+ return finalize(Object.assign(Object.assign({}, result.state), { definition: (0, workflow_graph_1.normalizeDesignerWorkflowDefinition)(result.state.definition) }), true, NO_EFFECTS);
202
+ }
203
+ function applySetEndState(state, command) {
204
+ return mapNode(state, command.nodeId, (node) => node.type === 'endEvent'
205
+ ? Object.assign(Object.assign({}, node), { data: Object.assign(Object.assign({}, node.data), { endState: command.endState }) }) : node, 'endEvent');
206
+ }
207
+ // ── Edge command handlers ──────────────────────────────────────────────────
208
+ function applyConnectEdge(state, command, createEdgeId) {
209
+ const connection = {
210
+ source: command.source,
211
+ sourceHandle: workflow_graph_1.WORKFLOW_OUTPUT_HANDLE_ID,
212
+ target: command.target,
213
+ targetHandle: workflow_graph_1.WORKFLOW_INPUT_HANDLE_ID,
214
+ };
215
+ if (!(0, workflow_graph_1.isWorkflowConnectionValid)(connection, state.definition.nodes)) {
216
+ return reject(state, `無法連線:${command.source} → ${command.target}(來源/目標不可連接或不存在)。`);
217
+ }
218
+ const shouldOpenConditionSettings = state.definition.nodes.some((node) => node.id === command.source && node.type === 'exclusiveGateway');
219
+ const nextEdge = (0, workflow_graph_1.createWorkflowEdge)(command.source, command.target, {}, createEdgeId);
220
+ const definition = (0, workflow_graph_1.normalizeDesignerWorkflowDefinition)(Object.assign(Object.assign({}, state.definition), { edges: [...state.definition.edges, nextEdge] }));
221
+ // Connecting two already-positioned nodes preserves their manual layout
222
+ // (matches the original designer); the LLM/user can call `autoLayout` to tidy.
223
+ return finalize(Object.assign(Object.assign({}, state), { definition, editingEdgeId: shouldOpenConditionSettings ? nextEdge.id : null, selectedEdgeIds: [nextEdge.id], selectedNodeId: null }), true, NO_EFFECTS);
224
+ }
225
+ function applyDeleteEdge(state, command) {
226
+ if (!state.definition.edges.some((edge) => edge.id === command.edgeId)) {
227
+ return reject(state, `找不到連線:${command.edgeId}`);
228
+ }
229
+ const definition = (0, workflow_graph_1.normalizeDesignerWorkflowDefinition)(Object.assign(Object.assign({}, state.definition), { edges: state.definition.edges.filter((edge) => edge.id !== command.edgeId) }));
230
+ return finalize(Object.assign(Object.assign({}, state), { definition, editingEdgeId: state.editingEdgeId === command.edgeId ? null : state.editingEdgeId, selectedEdgeIds: state.selectedEdgeIds.filter((edgeId) => edgeId !== command.edgeId) }), true, NO_EFFECTS);
231
+ }
232
+ function applySetEdgeCondition(state, command) {
233
+ var _a, _b, _c, _d, _e, _f;
234
+ const targetEdge = state.definition.edges.find((edge) => edge.id === command.edgeId);
235
+ if (!targetEdge) {
236
+ return reject(state, `找不到連線:${command.edgeId}`);
237
+ }
238
+ const schema = state.formSchema;
239
+ const nextFieldKey = (_b = (_a = command.fieldKey) !== null && _a !== void 0 ? _a : targetEdge.data.conditionFieldKey) !== null && _b !== void 0 ? _b : null;
240
+ const field = (0, workflow_graph_1.readConditionField)(schema, nextFieldKey);
241
+ const nextOperator = (0, workflow_graph_1.readNextConditionOperator)(field, (_d = (_c = command.operator) !== null && _c !== void 0 ? _c : targetEdge.data.conditionOperator) !== null && _d !== void 0 ? _d : null);
242
+ const nextValue = (0, workflow_graph_1.readNextConditionValue)(field, nextOperator, (_f = (_e = command.value) !== null && _e !== void 0 ? _e : targetEdge.data.conditionValue) !== null && _f !== void 0 ? _f : null);
243
+ const nextLabel = (0, workflow_graph_1.readConditionLabel)(field, nextOperator, nextValue);
244
+ const definition = Object.assign(Object.assign({}, state.definition), { edges: state.definition.edges.map((edge) => edge.id === command.edgeId
245
+ ? Object.assign(Object.assign({}, edge), { data: Object.assign(Object.assign({}, edge.data), { condition: (0, workflow_graph_1.readConditionExpression)(field, nextOperator, nextValue), conditionFieldKey: field === null || field === void 0 ? void 0 : field.fieldKey, conditionOperator: nextOperator, conditionValue: nextValue, isDefault: false, label: nextLabel }) }) : edge) });
246
+ return finalize(Object.assign(Object.assign({}, state), { definition }), true, NO_EFFECTS);
247
+ }
248
+ function applySetEdgeDefault(state, command) {
249
+ const targetEdge = state.definition.edges.find((edge) => edge.id === command.edgeId);
250
+ if (!targetEdge) {
251
+ return reject(state, `找不到連線:${command.edgeId}`);
252
+ }
253
+ const definition = Object.assign(Object.assign({}, state.definition), { edges: state.definition.edges.map((edge) => {
254
+ if (command.isDefault &&
255
+ edge.source === targetEdge.source &&
256
+ edge.id !== targetEdge.id &&
257
+ (0, workflow_graph_1.isExclusiveGatewaySourceEdge)(edge, state.definition.nodes)) {
258
+ return Object.assign(Object.assign({}, edge), { data: Object.assign(Object.assign({}, edge.data), { isDefault: false }) });
259
+ }
260
+ if (edge.id !== targetEdge.id) {
261
+ return edge;
262
+ }
263
+ // Becoming the default ("其他情況") means it carries no condition; clear
264
+ // any stale condition so the edge reads cleanly as the else path.
265
+ return command.isDefault
266
+ ? Object.assign(Object.assign({}, edge), { data: Object.assign(Object.assign({}, edge.data), { condition: undefined, conditionFieldKey: undefined, conditionOperator: undefined, conditionValue: undefined, isDefault: true, label: undefined }) }) : Object.assign(Object.assign({}, edge), { data: Object.assign(Object.assign({}, edge.data), { isDefault: false }) });
267
+ }) });
268
+ return finalize(Object.assign(Object.assign({}, state), { definition }), true, NO_EFFECTS);
269
+ }
270
+ // ── Form / policy handlers ─────────────────────────────────────────────────
271
+ function applyBindForm(state, command) {
272
+ return finalize(Object.assign(Object.assign({}, state), { formDefinitionVersionId: command.formDefinitionVersionId, formSchema: command.formSchema }), true, NO_EFFECTS);
273
+ }
274
+ function applySetInitiatorPolicyCel(state, command) {
275
+ return finalize(Object.assign(Object.assign({}, state), { initiatorPolicyCel: command.cel }), true, NO_EFFECTS);
276
+ }
277
+ // ── Helpers ────────────────────────────────────────────────────────────────
278
+ function mapNode(state, nodeId, updater, expectedType) {
279
+ const node = state.definition.nodes.find((candidate) => candidate.id === nodeId);
280
+ if (!node) {
281
+ return reject(state, `找不到節點:${nodeId}`);
282
+ }
283
+ if (expectedType && node.type !== expectedType) {
284
+ return reject(state, `節點 ${nodeId} 的型別為 ${node.type},預期為 ${expectedType}。`);
285
+ }
286
+ const definition = Object.assign(Object.assign({}, state.definition), { nodes: state.definition.nodes.map((candidate) => candidate.id === nodeId ? updater(candidate) : candidate) });
287
+ return finalize(Object.assign(Object.assign({}, state), { definition }), true, NO_EFFECTS);
288
+ }
289
+ function assertNever(command) {
290
+ throw new Error(`未支援的 workflow command:${JSON.stringify(command)}`);
291
+ }
292
+ //# sourceMappingURL=workflow-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-command.js","sourceRoot":"","sources":["../../../../../libs/shared/src/lib/workflow-command.ts"],"names":[],"mappings":";;AAqNA,oDAuDC;AAOD,8DAUC;AAGD,sDAqBC;AAOD,gDAwCC;AA3VD,qDAsB0B;AAwJ1B,MAAM,UAAU,GAA2B,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC7D,MAAM,cAAc,GAA2B,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAEhE,SAAS,QAAQ,CACf,KAA4B,EAC5B,OAAgB,EAChB,OAA+B,EAC/B,QAAuB,IAAI;IAE3B,OAAO;QACL,OAAO;QACP,OAAO;QACP,KAAK;QACL,KAAK,EAAE,IAAA,4CAA2B,EAAC,KAAK,CAAC,UAAU,CAAC;QACpD,KAAK;KACN,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CACb,KAA4B,EAC5B,KAAa;IAEb,OAAO,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,KAA4B,EAC5B,OAAwB,EACxB,UAAkC,EAAE;;IAEpC,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,YAAY,mCAAI,sCAAqB,CAAC;IAEnE,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACZ,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACpD,KAAK,YAAY;YACf,OAAO,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC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EAA8E;AAE9E,SAAS,OAAO,CACd,KAA4B,EAC5B,MAAc,EACd,OAEwC,EACxC,YAA0D;IAE1D,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,MAAM,CACvC,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/C,OAAO,MAAM,CACX,KAAK,EACL,MAAM,MAAM,SAAS,IAAI,CAAC,IAAI,QAAQ,YAAY,GAAG,CACtD,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,mCACX,KAAK,CAAC,UAAU,KACnB,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAC9C,SAAS,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CACzD,GACF,CAAC;IAEF,OAAO,QAAQ,iCAAM,KAAK,KAAE,UAAU,KAAI,IAAI,EAAE,UAAU,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,WAAW,CAAC,OAAc;IACjC,MAAM,IAAI,KAAK,CACb,yBAAyB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CACnD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { FormDefinitionSchema, FormFieldDefinition, FormFieldOption } from './form';
2
+ import { ApproverResolver, ServiceAction, WorkflowDefinition, WorkflowEdge, WorkflowEdgeConditionOperator, WorkflowEdgeData, WorkflowNode, WorkflowNodeTriggerMode } from './workflow';
3
+ /**
4
+ * Pure, framework-agnostic structural operations over a {@link WorkflowDefinition}.
5
+ *
6
+ * This module is the canonical home for every transform that the template
7
+ * designer performs on the workflow graph. It intentionally contains **no**
8
+ * React, DOM, or layout (dagre) dependency so that both the frontend designer
9
+ * and the backend can share the exact same semantics, and so the LLM command
10
+ * layer ({@link ./workflow-command}) can be built on top of it.
11
+ *
12
+ * Pixel layout (dagre) and ReactFlow node/edge mapping stay in the React lib;
13
+ * the structures here only describe the logical graph.
14
+ */
15
+ /** Node types a user can add from the palette (start/end are implicit). */
16
+ export type NodePaletteType = 'exclusiveGateway' | 'serviceTask' | 'userTask';
17
+ export declare const WORKFLOW_INPUT_HANDLE_ID = "input";
18
+ export declare const WORKFLOW_OUTPUT_HANDLE_ID = "output";
19
+ export declare const WORKFLOW_NODE_TYPE_LABELS: Readonly<Record<WorkflowNode['type'], string>>;
20
+ export interface ConditionOperatorOption {
21
+ readonly id: WorkflowEdgeConditionOperator;
22
+ readonly name: string;
23
+ }
24
+ export declare const CONDITION_OPERATOR_OPTIONS: readonly ConditionOperatorOption[];
25
+ export declare const CONDITION_OPERATORS_REQUIRING_VALUE: readonly WorkflowEdgeConditionOperator[];
26
+ export interface WorkflowConnectionCandidate {
27
+ readonly source?: string | null;
28
+ readonly sourceHandle?: string | null;
29
+ readonly target?: string | null;
30
+ readonly targetHandle?: string | null;
31
+ }
32
+ /** Result of inserting a node, including the post-insert selection intent. */
33
+ export interface WorkflowNodeInsertResult {
34
+ readonly definition: WorkflowDefinition;
35
+ readonly editingEdgeId: string | null;
36
+ readonly selectedEdgeIds: readonly string[];
37
+ readonly selectedNodeId: string | null;
38
+ }
39
+ /**
40
+ * Factory used to mint workflow edge ids. Injectable so callers (e.g. tests or
41
+ * a deterministic reducer run) can supply stable ids; defaults to a
42
+ * time + random suffix to match the original designer behaviour.
43
+ */
44
+ export type WorkflowEdgeIdFactory = (source: string, target: string) => string;
45
+ export declare function defaultWorkflowEdgeId(source: string, target: string): string;
46
+ export declare function renameWorkflowNode(node: WorkflowNode, label: string): WorkflowNode;
47
+ export declare function applyWorkflowNodeTriggerMode(node: WorkflowNode, triggerMode: WorkflowNodeTriggerMode): WorkflowNode;
48
+ export declare function normalizeDesignerWorkflowDefinition(definition: WorkflowDefinition): WorkflowDefinition;
49
+ export declare function removeAsyncNotifyOutgoingEdges(definition: WorkflowDefinition): WorkflowDefinition;
50
+ export declare function normalizeSingleIncomingTriggerModes(definition: WorkflowDefinition): WorkflowDefinition;
51
+ export declare function createWorkflowNode(type: NodePaletteType, index: number): WorkflowNode;
52
+ export declare function readNextWorkflowNodeIndex(nodes: readonly WorkflowNode[], type: NodePaletteType): number;
53
+ export declare function createWorkflowEdge(source: string, target: string, data: WorkflowEdgeData, createId?: WorkflowEdgeIdFactory): WorkflowEdge;
54
+ export declare function readInsertedOutgoingEdgeData(node: WorkflowNode): WorkflowEdgeData;
55
+ export declare function insertWorkflowNodeIntoDefinition({ createId, definition, node, selectedEdgeId, selectedNodeId, }: {
56
+ readonly createId?: WorkflowEdgeIdFactory;
57
+ readonly definition: WorkflowDefinition;
58
+ readonly node: WorkflowNode;
59
+ readonly selectedEdgeId: string | null;
60
+ readonly selectedNodeId: string | null;
61
+ }): WorkflowNodeInsertResult;
62
+ export declare function insertWorkflowNodeAtEdge(definition: WorkflowDefinition, node: WorkflowNode, edge: WorkflowEdge, createId?: WorkflowEdgeIdFactory): WorkflowNodeInsertResult;
63
+ export declare function insertWorkflowNodeAfterNode(definition: WorkflowDefinition, node: WorkflowNode, sourceNode: WorkflowNode, createId?: WorkflowEdgeIdFactory): WorkflowNodeInsertResult;
64
+ export declare function readFallbackWorkflowDefinition(): WorkflowDefinition;
65
+ export declare function isEmptyDesignerWorkflowDefinition(definition: WorkflowDefinition): boolean;
66
+ export declare function isWorkflowConnectionValid(connection: WorkflowConnectionCandidate, nodes: readonly WorkflowNode[]): boolean;
67
+ export declare function isWorkflowNodeRemovable(node: WorkflowNode): boolean;
68
+ export declare function isWorkflowNodeInputConnectable(node: WorkflowNode): boolean;
69
+ export declare function isWorkflowNodeOutputConnectable(node: WorkflowNode): boolean;
70
+ export declare function isAsyncNotifyServiceTask(node: WorkflowNode): boolean;
71
+ export declare function isExclusiveGatewaySourceEdge(edge: WorkflowEdge, nodes: readonly WorkflowNode[]): boolean;
72
+ export declare function isParallelGatewaySourceEdge(edge: WorkflowEdge, nodes: readonly WorkflowNode[]): boolean;
73
+ export declare function toggleSelectedEdgeId(edgeIds: readonly string[], edgeId: string): readonly string[];
74
+ export declare function readWorkflowDefinitionIssue(definition: WorkflowDefinition): string | null;
75
+ export declare function readApproverResolverIssue(resolver: ApproverResolver): string | null;
76
+ export declare function hasConfiguredConditionEdges(definition: WorkflowDefinition): boolean;
77
+ export declare function readServiceTaskMemberIds(action: ServiceAction): readonly string[];
78
+ export declare function readConditionField(schema: FormDefinitionSchema | null, fieldKey: string | null): FormFieldDefinition | null;
79
+ export declare function readConditionOperator(value: string | null): WorkflowEdgeConditionOperator | null;
80
+ export declare function readConditionOperatorIds(field: FormFieldDefinition): readonly WorkflowEdgeConditionOperator[];
81
+ export interface ConditionValueOption {
82
+ readonly id: string;
83
+ readonly name: string;
84
+ }
85
+ export declare function readConditionValueOptions(field: FormFieldDefinition | null): readonly ConditionValueOption[];
86
+ export declare function readNextConditionOperator(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | null): WorkflowEdgeConditionOperator | undefined;
87
+ export declare function readNextConditionValue(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | null): string | undefined;
88
+ export declare function shouldConditionOperatorUseValue(operator: WorkflowEdgeConditionOperator): boolean;
89
+ export declare function readConditionLabel(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | undefined): string | undefined;
90
+ export declare function readConditionOperatorLabel(operator: WorkflowEdgeConditionOperator): string;
91
+ export declare function readConditionValueLabel(field: FormFieldDefinition, value: string): string;
92
+ export declare function readFormFieldOption(options: readonly FormFieldOption[], value: string): FormFieldOption | null;
93
+ export declare function readConditionExpression(field: FormFieldDefinition | null, operator: WorkflowEdgeConditionOperator | undefined, value: string | undefined): string | undefined;
94
+ export declare function readFormFieldReference(fieldKey: string): string;
95
+ export declare function readConditionExpressionOperator(operator: WorkflowEdgeConditionOperator): string;
96
+ export declare function readConditionExpressionValue(field: FormFieldDefinition, value: string): string;