@camunda/copilot-chat 0.5.11 → 0.5.12-alpha.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.
- package/dist/bpmn-tools/index.js +7 -0
- package/dist/index-C02GS5vX.mjs +1314 -0
- package/dist/index.css +1 -1
- package/dist/index.js +285 -267
- package/dist/package.json +12 -1
- package/package.json +12 -1
|
@@ -0,0 +1,1314 @@
|
|
|
1
|
+
import { layoutProcess as w } from "bpmn-auto-layout";
|
|
2
|
+
const T = (e) => ({
|
|
3
|
+
name: "get_selected_element",
|
|
4
|
+
description: "Gets the currently selected BPMN element on the canvas. Returns the element ID, type, and name, or null if nothing is selected. Use this to understand which element the user is referring to.",
|
|
5
|
+
parameters: {},
|
|
6
|
+
type: "frontend",
|
|
7
|
+
contentType: "TEXT",
|
|
8
|
+
category: "BPMN_QUERY",
|
|
9
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
10
|
+
descriptionFormatter: () => "Reading selection",
|
|
11
|
+
handler: async (t, r) => {
|
|
12
|
+
try {
|
|
13
|
+
const n = e.modeler.getSelection().get();
|
|
14
|
+
if (!n || n.length === 0)
|
|
15
|
+
return { selected: null };
|
|
16
|
+
const o = n[0];
|
|
17
|
+
return {
|
|
18
|
+
selected: {
|
|
19
|
+
id: o.id,
|
|
20
|
+
type: o.type,
|
|
21
|
+
name: o.businessObject?.name ?? ""
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
} catch (n) {
|
|
25
|
+
throw r("get_selected_element", n), n;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}), v = (e) => e.includes(":") ? e : `bpmn:${e[0].toUpperCase()}${e.slice(1)}`, _ = (e) => ({
|
|
29
|
+
name: "find_elements_by_type",
|
|
30
|
+
description: "Finds all BPMN elements of a specific type in the current diagram. Returns a compact list with id, type, and name for each match. Supported types: userTask, serviceTask, startEvent, endEvent, exclusiveGateway, parallelGateway, subProcess, sequenceFlow, etc.",
|
|
31
|
+
parameters: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
bpmnType: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "The BPMN element type to search for (e.g., 'userTask', 'serviceTask', 'bpmn:UserTask', 'bpmn:SequenceFlow')"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
required: ["bpmnType"]
|
|
40
|
+
},
|
|
41
|
+
type: "frontend",
|
|
42
|
+
contentType: "TEXT",
|
|
43
|
+
category: "BPMN_QUERY",
|
|
44
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
45
|
+
descriptionFormatter: () => "Searching elements",
|
|
46
|
+
handler: async (t, r) => {
|
|
47
|
+
try {
|
|
48
|
+
const n = v(t.bpmnType);
|
|
49
|
+
return e.modeler.getElementRegistry().filter((o) => e.modeler.is(o, n)).map((o) => ({
|
|
50
|
+
id: o.id,
|
|
51
|
+
type: o.type,
|
|
52
|
+
name: o.businessObject?.name ?? ""
|
|
53
|
+
}));
|
|
54
|
+
} catch (n) {
|
|
55
|
+
throw r("find_elements_by_type", n), n;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}), N = (e, t) => {
|
|
59
|
+
const r = t(e);
|
|
60
|
+
return {
|
|
61
|
+
id: e.id,
|
|
62
|
+
type: e.type,
|
|
63
|
+
name: r.name ?? "",
|
|
64
|
+
incoming: (e.incoming ?? []).map((n) => n.id),
|
|
65
|
+
outgoing: (e.outgoing ?? []).map((n) => n.id)
|
|
66
|
+
};
|
|
67
|
+
}, P = (e) => ({
|
|
68
|
+
name: "get_process_summary",
|
|
69
|
+
description: "Gets a comprehensive summary of the current BPMN process including process ID, name, whether it is executable, counts of flow nodes/tasks/sequence flows, and a list of all flow nodes with their ID, type, name, and connections. Use this to understand the overall structure of the process.",
|
|
70
|
+
parameters: {},
|
|
71
|
+
type: "frontend",
|
|
72
|
+
contentType: "TEXT",
|
|
73
|
+
category: "BPMN_QUERY",
|
|
74
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
75
|
+
descriptionFormatter: () => "Analyzing process structure",
|
|
76
|
+
handler: async (t, r) => {
|
|
77
|
+
try {
|
|
78
|
+
const { is: n, getBusinessObject: o, getElementRegistry: i } = e.modeler, s = i(), a = s.filter((c) => n(c, "bpmn:Process"))[0], l = a ? o(a) : null, d = s.filter((c) => n(c, "bpmn:FlowNode")), m = s.filter((c) => n(c, "bpmn:Task")), p = s.filter((c) => n(c, "bpmn:SequenceFlow"));
|
|
79
|
+
return {
|
|
80
|
+
processId: l?.id ?? "",
|
|
81
|
+
name: l?.name ?? "",
|
|
82
|
+
isExecutable: l?.isExecutable ?? !1,
|
|
83
|
+
flowNodeCount: d.length,
|
|
84
|
+
taskCount: m.length,
|
|
85
|
+
flowCount: p.length,
|
|
86
|
+
flowNodes: d.map((c) => N(c, o))
|
|
87
|
+
};
|
|
88
|
+
} catch (n) {
|
|
89
|
+
throw r("get_process_summary", n), n;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}), f = (e, t) => {
|
|
93
|
+
const r = t(e).conditionExpression;
|
|
94
|
+
return {
|
|
95
|
+
flowId: e.id,
|
|
96
|
+
condition: r ? r.body ?? r.text ?? "" : null
|
|
97
|
+
};
|
|
98
|
+
}, M = (e) => ({
|
|
99
|
+
name: "get_element_connections",
|
|
100
|
+
description: "Gets all incoming and outgoing sequence flow connections for a specific BPMN element. Returns flow IDs, connected element IDs/names, and condition expressions if present.",
|
|
101
|
+
parameters: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {
|
|
104
|
+
elementId: {
|
|
105
|
+
type: "string",
|
|
106
|
+
description: "The ID of the BPMN element to get connections for"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
required: ["elementId"]
|
|
110
|
+
},
|
|
111
|
+
type: "frontend",
|
|
112
|
+
contentType: "TEXT",
|
|
113
|
+
category: "BPMN_QUERY",
|
|
114
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
115
|
+
descriptionFormatter: () => "Checking connections",
|
|
116
|
+
handler: async (t, r) => {
|
|
117
|
+
try {
|
|
118
|
+
const { is: n, getBusinessObject: o, getElementById: i } = e.modeler, s = i(t.elementId), a = (s.incoming ?? []).filter((d) => n(d, "bpmn:SequenceFlow")).map((d) => ({
|
|
119
|
+
...f(d, o),
|
|
120
|
+
sourceId: d.source?.id ?? null,
|
|
121
|
+
sourceName: d.source?.businessObject?.name ?? ""
|
|
122
|
+
})), l = (s.outgoing ?? []).filter((d) => n(d, "bpmn:SequenceFlow")).map((d) => ({
|
|
123
|
+
...f(d, o),
|
|
124
|
+
targetId: d.target?.id ?? null,
|
|
125
|
+
targetName: d.target?.businessObject?.name ?? ""
|
|
126
|
+
}));
|
|
127
|
+
return { incoming: a, outgoing: l };
|
|
128
|
+
} catch (n) {
|
|
129
|
+
throw r("get_element_connections", n), n;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}), y = (e, t) => typeof e.get == "function" ? e.get(t) : e[t], g = (e, t, r) => {
|
|
133
|
+
const n = y(e, "extensionElements");
|
|
134
|
+
return n ? y(n, "values")?.find((o) => r(o, t)) ?? null : null;
|
|
135
|
+
}, E = (e, t, r, n, o, i) => {
|
|
136
|
+
const s = n.get("modeling"), a = n.get("moddle"), l = o(e), d = y(l, "extensionElements");
|
|
137
|
+
if (!d) {
|
|
138
|
+
const p = a.create("bpmn:ExtensionElements"), c = a.create(t, r);
|
|
139
|
+
c.$parent = p, p.values = [c], s.updateProperties(e, { extensionElements: p });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const m = g(l, t, i);
|
|
143
|
+
if (!m) {
|
|
144
|
+
const p = a.create(t, r);
|
|
145
|
+
p.$parent = d;
|
|
146
|
+
const c = y(d, "values") ?? [];
|
|
147
|
+
s.updateModdleProperties(e, d, {
|
|
148
|
+
values: [...c, p]
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
s.updateModdleProperties(e, m, r);
|
|
153
|
+
}, B = (e, t) => {
|
|
154
|
+
const r = g(e, "zeebe:IoMapping", t);
|
|
155
|
+
if (!r)
|
|
156
|
+
return { inputs: [], outputs: [] };
|
|
157
|
+
const n = (o) => {
|
|
158
|
+
const i = o;
|
|
159
|
+
return { source: i.source, target: i.target };
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
inputs: (r.inputParameters ?? []).map(n),
|
|
163
|
+
outputs: (r.outputParameters ?? []).map(n)
|
|
164
|
+
};
|
|
165
|
+
}, F = (e, t) => {
|
|
166
|
+
const r = g(e, "zeebe:TaskDefinition", t);
|
|
167
|
+
return r ? {
|
|
168
|
+
type: r.type ?? "",
|
|
169
|
+
retries: r.retries ?? ""
|
|
170
|
+
} : null;
|
|
171
|
+
}, C = (e, t) => {
|
|
172
|
+
const r = g(e, "zeebe:FormDefinition", t);
|
|
173
|
+
return r ? {
|
|
174
|
+
formId: r.formId ?? null,
|
|
175
|
+
formKey: r.formKey ?? null,
|
|
176
|
+
bindingType: r.bindingType ?? "latest"
|
|
177
|
+
} : null;
|
|
178
|
+
}, k = (e, t) => {
|
|
179
|
+
const r = g(e, "zeebe:Properties", t);
|
|
180
|
+
return r ? (r.properties ?? []).reduce((n, o) => {
|
|
181
|
+
const i = o;
|
|
182
|
+
return { ...n, [i.name]: i.value };
|
|
183
|
+
}, {}) : {};
|
|
184
|
+
}, D = (e) => e.documentation?.[0]?.text ?? "", O = (e) => ({
|
|
185
|
+
name: "get_element_details",
|
|
186
|
+
description: "Gets detailed information about a specific BPMN element including ID, type, name, description, I/O mappings, Zeebe properties, task definition, and form binding. Use this to inspect a specific element in the process.",
|
|
187
|
+
parameters: {
|
|
188
|
+
type: "object",
|
|
189
|
+
properties: {
|
|
190
|
+
elementId: {
|
|
191
|
+
type: "string",
|
|
192
|
+
description: "The ID of the BPMN element to inspect"
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
required: ["elementId"]
|
|
196
|
+
},
|
|
197
|
+
type: "frontend",
|
|
198
|
+
contentType: "TEXT",
|
|
199
|
+
category: "BPMN_QUERY",
|
|
200
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
201
|
+
descriptionFormatter: () => "Inspecting element",
|
|
202
|
+
handler: async (t, r) => {
|
|
203
|
+
try {
|
|
204
|
+
const { is: n, getBusinessObject: o, getElementById: i } = e.modeler, s = i(t.elementId), a = o(s), l = a.conditionExpression;
|
|
205
|
+
return {
|
|
206
|
+
id: s.id,
|
|
207
|
+
type: s.type,
|
|
208
|
+
name: a.name ?? "",
|
|
209
|
+
description: D(a),
|
|
210
|
+
...n(s, "bpmn:Activity") ? {
|
|
211
|
+
ioMappings: B(a, n),
|
|
212
|
+
zeebeProperties: k(a, n),
|
|
213
|
+
taskDefinition: F(a, n)
|
|
214
|
+
} : {},
|
|
215
|
+
...n(s, "bpmn:UserTask") ? { formBinding: C(a, n) } : {},
|
|
216
|
+
...n(s, "bpmn:SequenceFlow") ? {
|
|
217
|
+
sourceId: a.sourceRef?.id ?? null,
|
|
218
|
+
targetId: a.targetRef?.id ?? null,
|
|
219
|
+
conditionExpression: l ? l.body ?? l.text ?? "" : null
|
|
220
|
+
} : {}
|
|
221
|
+
};
|
|
222
|
+
} catch (n) {
|
|
223
|
+
throw r("get_element_details", n), n;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}), q = (e, t, r, n) => {
|
|
227
|
+
const o = /* @__PURE__ */ new Set(), i = [[e]];
|
|
228
|
+
for (; i.length > 0; ) {
|
|
229
|
+
const s = i.shift();
|
|
230
|
+
if (!s)
|
|
231
|
+
break;
|
|
232
|
+
const a = s[s.length - 1];
|
|
233
|
+
if (a === t)
|
|
234
|
+
return s;
|
|
235
|
+
if (o.has(a))
|
|
236
|
+
continue;
|
|
237
|
+
o.add(a);
|
|
238
|
+
const l = r.get(a);
|
|
239
|
+
l && (l.outgoing ?? []).filter((d) => n(d, "bpmn:SequenceFlow")).map((d) => d.target?.id).filter((d) => d !== void 0 && !o.has(d)).forEach((d) => i.push([...s, d]));
|
|
240
|
+
}
|
|
241
|
+
return [];
|
|
242
|
+
}, x = (e) => ({
|
|
243
|
+
name: "get_path_between_elements",
|
|
244
|
+
description: "Finds the shortest path between two BPMN elements following sequence flows. Returns an ordered list of elements on the path with their IDs, types, and names. Returns an empty path if no route exists.",
|
|
245
|
+
parameters: {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: {
|
|
248
|
+
sourceId: {
|
|
249
|
+
type: "string",
|
|
250
|
+
description: "The ID of the source element (start of path)"
|
|
251
|
+
},
|
|
252
|
+
targetId: {
|
|
253
|
+
type: "string",
|
|
254
|
+
description: "The ID of the target element (end of path)"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
required: ["sourceId", "targetId"]
|
|
258
|
+
},
|
|
259
|
+
type: "frontend",
|
|
260
|
+
contentType: "TEXT",
|
|
261
|
+
category: "BPMN_QUERY",
|
|
262
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
263
|
+
descriptionFormatter: () => "Finding path",
|
|
264
|
+
handler: async (t, r) => {
|
|
265
|
+
try {
|
|
266
|
+
const { is: n, getElementById: o, getElementRegistry: i } = e.modeler;
|
|
267
|
+
o(t.sourceId), o(t.targetId);
|
|
268
|
+
const s = i(), a = q(t.sourceId, t.targetId, s, n);
|
|
269
|
+
return {
|
|
270
|
+
path: a.map((l) => {
|
|
271
|
+
const d = s.get(l);
|
|
272
|
+
return {
|
|
273
|
+
id: l,
|
|
274
|
+
type: d?.type ?? "unknown",
|
|
275
|
+
name: d?.businessObject?.name ?? ""
|
|
276
|
+
};
|
|
277
|
+
}),
|
|
278
|
+
length: a.length
|
|
279
|
+
};
|
|
280
|
+
} catch (n) {
|
|
281
|
+
throw r("get_path_between_elements", n), n;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}), R = {
|
|
285
|
+
userTask: "user task",
|
|
286
|
+
serviceTask: "service task",
|
|
287
|
+
sendTask: "send task",
|
|
288
|
+
receiveTask: "receive task",
|
|
289
|
+
businessRuleTask: "business rule task",
|
|
290
|
+
scriptTask: "script task",
|
|
291
|
+
manualTask: "manual task",
|
|
292
|
+
task: "task",
|
|
293
|
+
startEvent: "start event",
|
|
294
|
+
endEvent: "end event",
|
|
295
|
+
intermediateThrowEvent: "intermediate event",
|
|
296
|
+
intermediateCatchEvent: "intermediate event",
|
|
297
|
+
boundaryEvent: "boundary event",
|
|
298
|
+
exclusiveGateway: "decision gateway",
|
|
299
|
+
parallelGateway: "parallel gateway",
|
|
300
|
+
inclusiveGateway: "inclusive gateway",
|
|
301
|
+
eventBasedGateway: "event gateway",
|
|
302
|
+
subProcess: "sub-process",
|
|
303
|
+
adHocSubProcess: "AI agent",
|
|
304
|
+
callActivity: "call activity",
|
|
305
|
+
textAnnotation: "annotation",
|
|
306
|
+
dataObjectReference: "data object",
|
|
307
|
+
dataStoreReference: "data store",
|
|
308
|
+
participant: "pool"
|
|
309
|
+
}, A = (e) => R[e] ?? e?.replace(/([A-Z])/g, " $1").toLowerCase().trim() ?? "element", u = (e) => typeof e == "string" ? e : "", h = {
|
|
310
|
+
task: "bpmn:Task",
|
|
311
|
+
userTask: "bpmn:UserTask",
|
|
312
|
+
serviceTask: "bpmn:ServiceTask",
|
|
313
|
+
sendTask: "bpmn:SendTask",
|
|
314
|
+
receiveTask: "bpmn:ReceiveTask",
|
|
315
|
+
businessRuleTask: "bpmn:BusinessRuleTask",
|
|
316
|
+
manualTask: "bpmn:ManualTask",
|
|
317
|
+
scriptTask: "bpmn:ScriptTask",
|
|
318
|
+
startEvent: "bpmn:StartEvent",
|
|
319
|
+
endEvent: "bpmn:EndEvent",
|
|
320
|
+
intermediateThrowEvent: "bpmn:IntermediateThrowEvent",
|
|
321
|
+
intermediateCatchEvent: "bpmn:IntermediateCatchEvent",
|
|
322
|
+
boundaryEvent: "bpmn:BoundaryEvent",
|
|
323
|
+
exclusiveGateway: "bpmn:ExclusiveGateway",
|
|
324
|
+
inclusiveGateway: "bpmn:InclusiveGateway",
|
|
325
|
+
parallelGateway: "bpmn:ParallelGateway",
|
|
326
|
+
eventBasedGateway: "bpmn:EventBasedGateway",
|
|
327
|
+
subProcess: "bpmn:SubProcess",
|
|
328
|
+
adHocSubProcess: "bpmn:AdHocSubProcess",
|
|
329
|
+
callActivity: "bpmn:CallActivity",
|
|
330
|
+
textAnnotation: "bpmn:TextAnnotation",
|
|
331
|
+
dataObjectReference: "bpmn:DataObjectReference",
|
|
332
|
+
dataStoreReference: "bpmn:DataStoreReference",
|
|
333
|
+
participant: "bpmn:Participant"
|
|
334
|
+
}, b = {
|
|
335
|
+
message: "bpmn:MessageEventDefinition",
|
|
336
|
+
timer: "bpmn:TimerEventDefinition",
|
|
337
|
+
signal: "bpmn:SignalEventDefinition",
|
|
338
|
+
error: "bpmn:ErrorEventDefinition",
|
|
339
|
+
escalation: "bpmn:EscalationEventDefinition",
|
|
340
|
+
compensation: "bpmn:CompensateEventDefinition",
|
|
341
|
+
conditional: "bpmn:ConditionalEventDefinition",
|
|
342
|
+
link: "bpmn:LinkEventDefinition",
|
|
343
|
+
terminate: "bpmn:TerminateEventDefinition"
|
|
344
|
+
}, j = (e) => {
|
|
345
|
+
if (e.includes(":"))
|
|
346
|
+
return e;
|
|
347
|
+
const t = h[e];
|
|
348
|
+
if (!t)
|
|
349
|
+
throw new Error(`Unsupported element type: ${e}. Supported types: ${Object.keys(h).join(", ")}`);
|
|
350
|
+
return t;
|
|
351
|
+
}, S = (e, t) => {
|
|
352
|
+
if (!e)
|
|
353
|
+
return t.modeler.getCanvas().getRootElement();
|
|
354
|
+
const r = t.modeler.getElementById(e);
|
|
355
|
+
if (!(t.modeler.is(r, "bpmn:SubProcess") || t.modeler.is(r, "bpmn:AdHocSubProcess") || t.modeler.is(r, "bpmn:Process") || t.modeler.is(r, "bpmn:Participant")))
|
|
356
|
+
throw new Error(`Parent element ${e} must be a SubProcess, AdHocSubProcess, Process, or Participant`);
|
|
357
|
+
return r;
|
|
358
|
+
}, G = (e, t, r) => {
|
|
359
|
+
const n = (i) => i;
|
|
360
|
+
if (t) {
|
|
361
|
+
const i = n(t);
|
|
362
|
+
return { x: (i.x ?? 0) + (i.width ?? 100) + 100, y: i.y ?? 200 };
|
|
363
|
+
}
|
|
364
|
+
if (r) {
|
|
365
|
+
const i = n(r);
|
|
366
|
+
return { x: (i.x ?? 0) - 200, y: i.y ?? 200 };
|
|
367
|
+
}
|
|
368
|
+
const o = n(e);
|
|
369
|
+
return { x: (o.x ?? 0) + 200, y: (o.y ?? 0) + 100 };
|
|
370
|
+
}, L = (e, t, r) => ({
|
|
371
|
+
type: t,
|
|
372
|
+
...e.eventDefinition && b[e.eventDefinition] ? { eventDefinitionType: b[e.eventDefinition] } : {},
|
|
373
|
+
...t === "bpmn:BoundaryEvent" && e.attachedToRef ? {
|
|
374
|
+
host: r.modeler.getElementById(e.attachedToRef),
|
|
375
|
+
...e.cancelActivity !== void 0 ? { cancelActivity: e.cancelActivity } : {}
|
|
376
|
+
} : {},
|
|
377
|
+
...t === "bpmn:SubProcess" && e.triggeredByEvent ? { triggeredByEvent: !0, isExpanded: !0 } : {},
|
|
378
|
+
...t === "bpmn:AdHocSubProcess" ? { isExpanded: !0 } : {}
|
|
379
|
+
}), $ = (e) => ({
|
|
380
|
+
name: "add_bpmn_element",
|
|
381
|
+
description: "Adds a new BPMN element to the diagram. Optionally connects it to existing elements using afterElementId (incoming flow) and/or beforeElementId (outgoing flow). Auto-layouts the diagram and returns validation errors. Supported types: userTask, serviceTask, sendTask, receiveTask, businessRuleTask, manualTask, scriptTask, startEvent, endEvent, intermediateThrowEvent, intermediateCatchEvent, boundaryEvent, exclusiveGateway, inclusiveGateway, parallelGateway, eventBasedGateway, subProcess, adHocSubProcess, callActivity, textAnnotation.",
|
|
382
|
+
parameters: {
|
|
383
|
+
type: "object",
|
|
384
|
+
properties: {
|
|
385
|
+
type: {
|
|
386
|
+
type: "string",
|
|
387
|
+
description: "The BPMN element type (e.g., 'userTask', 'serviceTask', 'exclusiveGateway', 'startEvent')"
|
|
388
|
+
},
|
|
389
|
+
label: { type: "string", description: "Optional display name for the element" },
|
|
390
|
+
afterElementId: {
|
|
391
|
+
type: "string",
|
|
392
|
+
description: "Optional element ID to connect FROM (creates incoming sequence flow)"
|
|
393
|
+
},
|
|
394
|
+
beforeElementId: {
|
|
395
|
+
type: "string",
|
|
396
|
+
description: "Optional element ID to connect TO (creates outgoing sequence flow)"
|
|
397
|
+
},
|
|
398
|
+
parentElementId: {
|
|
399
|
+
type: "string",
|
|
400
|
+
description: "Optional parent element ID for adding inside a subProcess"
|
|
401
|
+
},
|
|
402
|
+
eventDefinition: {
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Optional event definition type for events: 'message', 'timer', 'signal', 'error', 'escalation', 'compensation', 'conditional', 'link', 'terminate'"
|
|
405
|
+
},
|
|
406
|
+
attachedToRef: {
|
|
407
|
+
type: "string",
|
|
408
|
+
description: "Required for boundaryEvent: the ID of the element this boundary event is attached to"
|
|
409
|
+
},
|
|
410
|
+
cancelActivity: {
|
|
411
|
+
type: "boolean",
|
|
412
|
+
description: "For boundaryEvent: whether it cancels the activity (default: true)"
|
|
413
|
+
},
|
|
414
|
+
triggeredByEvent: {
|
|
415
|
+
type: "boolean",
|
|
416
|
+
description: "For subProcess: whether it is an event sub-process"
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
required: ["type"]
|
|
420
|
+
},
|
|
421
|
+
type: "frontend",
|
|
422
|
+
contentType: "BPMN",
|
|
423
|
+
category: "BPMN_MODIFICATION",
|
|
424
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
425
|
+
descriptionFormatter: (t) => {
|
|
426
|
+
const r = u(t.label) || u(t.name);
|
|
427
|
+
if (r) return `Adding ${r}`;
|
|
428
|
+
const n = u(t.type);
|
|
429
|
+
return n ? `Adding ${A(n)}` : "Adding element";
|
|
430
|
+
},
|
|
431
|
+
handler: async (t, r) => {
|
|
432
|
+
try {
|
|
433
|
+
const n = e.modeler.getModeling(), o = e.modeler.getElementFactory(), i = j(t.type), s = S(t.parentElementId, e), a = t.afterElementId ? e.modeler.getElementById(t.afterElementId) : null, l = t.beforeElementId ? e.modeler.getElementById(t.beforeElementId) : null, d = G(s, a, l), m = L(t, i, e), p = o.createShape(m), c = n.createShape(p, d, s);
|
|
434
|
+
return t.label && n.updateProperties(c, { name: t.label }), a && e.modeler.is(a, "bpmn:FlowNode") && n.connect(a, c), l && e.modeler.is(l, "bpmn:FlowNode") && n.connect(c, l), {
|
|
435
|
+
elementId: c.id,
|
|
436
|
+
type: c.type,
|
|
437
|
+
label: t.label ?? ""
|
|
438
|
+
};
|
|
439
|
+
} catch (n) {
|
|
440
|
+
throw r("add_bpmn_element", n), new Error(`Failed to add BPMN element: ${n.message}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}), X = (e) => ({
|
|
444
|
+
name: "update_bpmn_element",
|
|
445
|
+
description: "Updates properties of an existing BPMN element (e.g., name). For Zeebe extension properties (task definition, I/O mappings, headers), use set_element_properties instead.",
|
|
446
|
+
parameters: {
|
|
447
|
+
type: "object",
|
|
448
|
+
properties: {
|
|
449
|
+
elementId: {
|
|
450
|
+
type: "string",
|
|
451
|
+
description: "The ID of the BPMN element to update"
|
|
452
|
+
},
|
|
453
|
+
name: {
|
|
454
|
+
type: "string",
|
|
455
|
+
description: "New display name for the element"
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
required: ["elementId"]
|
|
459
|
+
},
|
|
460
|
+
type: "frontend",
|
|
461
|
+
contentType: "BPMN",
|
|
462
|
+
category: "BPMN_MODIFICATION",
|
|
463
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
464
|
+
descriptionFormatter: (t) => {
|
|
465
|
+
const r = u(t.name);
|
|
466
|
+
return r ? `Renaming to "${r}"` : "Updating element";
|
|
467
|
+
},
|
|
468
|
+
handler: async (t, r) => {
|
|
469
|
+
try {
|
|
470
|
+
const n = e.modeler.getModeling(), o = e.modeler.getElementById(t.elementId), i = {
|
|
471
|
+
...t.name !== void 0 ? { name: t.name } : {}
|
|
472
|
+
};
|
|
473
|
+
Object.keys(i).length > 0 && n.updateProperties(o, i);
|
|
474
|
+
const s = e.modeler.getBusinessObject(o), a = Object.keys(i).reduce(
|
|
475
|
+
(l, d) => ({ ...l, [d]: s[d] }),
|
|
476
|
+
{}
|
|
477
|
+
);
|
|
478
|
+
return { elementId: o.id, updated: a };
|
|
479
|
+
} catch (n) {
|
|
480
|
+
throw r("update_bpmn_element", n), new Error(`Failed to update BPMN element: ${n.message}`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}), U = (e) => ({
|
|
484
|
+
name: "delete_bpmn_element",
|
|
485
|
+
description: "Deletes a BPMN element from the diagram. If the element has exactly one incoming and one outgoing sequence flow, the surrounding elements are automatically reconnected.",
|
|
486
|
+
parameters: {
|
|
487
|
+
type: "object",
|
|
488
|
+
properties: {
|
|
489
|
+
elementId: {
|
|
490
|
+
type: "string",
|
|
491
|
+
description: "The ID of the BPMN element to delete"
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
required: ["elementId"]
|
|
495
|
+
},
|
|
496
|
+
type: "frontend",
|
|
497
|
+
contentType: "BPMN",
|
|
498
|
+
category: "BPMN_MODIFICATION",
|
|
499
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
500
|
+
descriptionFormatter: () => "Removing element",
|
|
501
|
+
handler: async (t, r) => {
|
|
502
|
+
try {
|
|
503
|
+
const n = e.modeler.getModeling(), o = e.modeler.getElementById(t.elementId), i = o.id, s = (o.incoming ?? []).filter((c) => e.modeler.is(c, "bpmn:SequenceFlow")), a = (o.outgoing ?? []).filter((c) => e.modeler.is(c, "bpmn:SequenceFlow")), l = s.length === 1 && a.length === 1, d = l ? s[0].source : void 0, m = l ? a[0].target : void 0;
|
|
504
|
+
n.removeElements([o]);
|
|
505
|
+
const p = !!(l && d && m);
|
|
506
|
+
return p && n.connect(d, m), { elementId: i, reconnected: p };
|
|
507
|
+
} catch (n) {
|
|
508
|
+
throw r("delete_bpmn_element", n), new Error(`Failed to delete BPMN element: ${n.message}`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}), z = (e) => ({
|
|
512
|
+
name: "move_bpmn_element",
|
|
513
|
+
description: "Moves a BPMN element to a new position in the process flow by reconnecting sequence flows. The element is disconnected from its current neighbors (which are reconnected to each other) and connected at the new position. At least one of afterElementId or beforeElementId is required.",
|
|
514
|
+
parameters: {
|
|
515
|
+
type: "object",
|
|
516
|
+
properties: {
|
|
517
|
+
elementId: {
|
|
518
|
+
type: "string",
|
|
519
|
+
description: "The ID of the BPMN element to move"
|
|
520
|
+
},
|
|
521
|
+
afterElementId: {
|
|
522
|
+
type: "string",
|
|
523
|
+
description: "ID of the element that should be the new source (incoming flow)"
|
|
524
|
+
},
|
|
525
|
+
beforeElementId: {
|
|
526
|
+
type: "string",
|
|
527
|
+
description: "ID of the element that should be the new target (outgoing flow)"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
required: ["elementId"]
|
|
531
|
+
},
|
|
532
|
+
type: "frontend",
|
|
533
|
+
contentType: "BPMN",
|
|
534
|
+
category: "BPMN_MODIFICATION",
|
|
535
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
536
|
+
descriptionFormatter: () => "Reorganizing flow",
|
|
537
|
+
handler: async (t, r) => {
|
|
538
|
+
try {
|
|
539
|
+
const n = t.afterElementId, o = t.beforeElementId;
|
|
540
|
+
if (!n && !o)
|
|
541
|
+
throw new Error("At least one of afterElementId or beforeElementId must be provided");
|
|
542
|
+
const i = e.modeler.getModeling(), s = e.modeler.getElementById(t.elementId), a = (s.incoming ?? []).filter((p) => e.modeler.is(p, "bpmn:SequenceFlow")), l = (s.outgoing ?? []).filter((p) => e.modeler.is(p, "bpmn:SequenceFlow")), d = a.map((p) => p.source), m = l.map((p) => p.target);
|
|
543
|
+
if (i.removeElements([...a, ...l]), d.length === 1 && m.length === 1 && i.connect(d[0], m[0]), n) {
|
|
544
|
+
const p = e.modeler.getElementById(n);
|
|
545
|
+
i.connect(p, s);
|
|
546
|
+
}
|
|
547
|
+
if (o) {
|
|
548
|
+
const p = e.modeler.getElementById(o);
|
|
549
|
+
i.connect(s, p);
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
elementId: s.id,
|
|
553
|
+
newPosition: {
|
|
554
|
+
afterElementId: n ?? null,
|
|
555
|
+
beforeElementId: o ?? null
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
} catch (n) {
|
|
559
|
+
throw r("move_bpmn_element", n), new Error(`Failed to move BPMN element: ${n.message}`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}), V = (e) => ({
|
|
563
|
+
name: "add_sequence_flow",
|
|
564
|
+
description: "Creates a new sequence flow connection between two BPMN elements. Optionally sets a label and/or condition expression.",
|
|
565
|
+
parameters: {
|
|
566
|
+
type: "object",
|
|
567
|
+
properties: {
|
|
568
|
+
sourceId: {
|
|
569
|
+
type: "string",
|
|
570
|
+
description: "The ID of the source element (flow starts here)"
|
|
571
|
+
},
|
|
572
|
+
targetId: {
|
|
573
|
+
type: "string",
|
|
574
|
+
description: "The ID of the target element (flow ends here)"
|
|
575
|
+
},
|
|
576
|
+
label: {
|
|
577
|
+
type: "string",
|
|
578
|
+
description: "Optional label for the sequence flow"
|
|
579
|
+
},
|
|
580
|
+
conditionExpression: {
|
|
581
|
+
type: "string",
|
|
582
|
+
description: "Optional FEEL condition expression for conditional flows (e.g., after exclusive gateways)"
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
required: ["sourceId", "targetId"]
|
|
586
|
+
},
|
|
587
|
+
type: "frontend",
|
|
588
|
+
contentType: "BPMN",
|
|
589
|
+
category: "BPMN_MODIFICATION",
|
|
590
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
591
|
+
descriptionFormatter: () => "Connecting elements",
|
|
592
|
+
handler: async (t, r) => {
|
|
593
|
+
try {
|
|
594
|
+
const n = e.modeler.getModeling(), o = e.modeler.getModdle(), i = e.modeler.getElementById(t.sourceId), s = e.modeler.getElementById(t.targetId), a = n.connect(i, s);
|
|
595
|
+
if (t.label && n.updateProperties(a, { name: t.label }), t.conditionExpression) {
|
|
596
|
+
const l = o.create("bpmn:FormalExpression", {
|
|
597
|
+
body: t.conditionExpression
|
|
598
|
+
});
|
|
599
|
+
n.updateProperties(a, { conditionExpression: l });
|
|
600
|
+
}
|
|
601
|
+
return {
|
|
602
|
+
flowId: a.id,
|
|
603
|
+
sourceId: t.sourceId,
|
|
604
|
+
targetId: t.targetId
|
|
605
|
+
};
|
|
606
|
+
} catch (n) {
|
|
607
|
+
throw r("add_sequence_flow", n), new Error(`Failed to add sequence flow: ${n.message}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}), H = (e) => ({
|
|
611
|
+
name: "update_sequence_flow",
|
|
612
|
+
description: "Updates properties of an existing sequence flow (label and/or condition expression).",
|
|
613
|
+
parameters: {
|
|
614
|
+
type: "object",
|
|
615
|
+
properties: {
|
|
616
|
+
flowId: {
|
|
617
|
+
type: "string",
|
|
618
|
+
description: "The ID of the sequence flow to update"
|
|
619
|
+
},
|
|
620
|
+
label: {
|
|
621
|
+
type: "string",
|
|
622
|
+
description: "New label for the sequence flow"
|
|
623
|
+
},
|
|
624
|
+
conditionExpression: {
|
|
625
|
+
type: "string",
|
|
626
|
+
description: "New FEEL condition expression (set to empty string to remove condition)"
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
required: ["flowId"]
|
|
630
|
+
},
|
|
631
|
+
type: "frontend",
|
|
632
|
+
contentType: "BPMN",
|
|
633
|
+
category: "BPMN_MODIFICATION",
|
|
634
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
635
|
+
descriptionFormatter: (t) => {
|
|
636
|
+
if (t.conditionExpression) return "Setting flow condition";
|
|
637
|
+
const r = u(t.label);
|
|
638
|
+
return r ? `Labeling "${r}"` : "Updating connection";
|
|
639
|
+
},
|
|
640
|
+
handler: async (t, r) => {
|
|
641
|
+
try {
|
|
642
|
+
const n = e.modeler.getElementById(t.flowId);
|
|
643
|
+
if (!e.modeler.is(n, "bpmn:SequenceFlow"))
|
|
644
|
+
throw new Error(`Element ${t.flowId} is not a sequence flow`);
|
|
645
|
+
const o = e.modeler.getModeling(), i = e.modeler.getModdle(), s = {
|
|
646
|
+
...t.label !== void 0 ? { name: t.label } : {},
|
|
647
|
+
...t.conditionExpression !== void 0 ? {
|
|
648
|
+
conditionExpression: t.conditionExpression ? i.create("bpmn:FormalExpression", {
|
|
649
|
+
body: t.conditionExpression
|
|
650
|
+
}) : void 0
|
|
651
|
+
} : {}
|
|
652
|
+
};
|
|
653
|
+
return Object.keys(s).length > 0 && o.updateProperties(n, s), {
|
|
654
|
+
flowId: n.id,
|
|
655
|
+
updated: {
|
|
656
|
+
label: t.label,
|
|
657
|
+
conditionExpression: t.conditionExpression
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
} catch (n) {
|
|
661
|
+
throw r("update_sequence_flow", n), new Error(`Failed to update sequence flow: ${n.message}`);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}), W = (e) => ({
|
|
665
|
+
name: "delete_sequence_flow",
|
|
666
|
+
description: "Deletes a sequence flow connection from the diagram. Auto-layouts the diagram and returns validation errors.",
|
|
667
|
+
parameters: {
|
|
668
|
+
type: "object",
|
|
669
|
+
properties: {
|
|
670
|
+
flowId: {
|
|
671
|
+
type: "string",
|
|
672
|
+
description: "The ID of the sequence flow to delete"
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
required: ["flowId"]
|
|
676
|
+
},
|
|
677
|
+
type: "frontend",
|
|
678
|
+
contentType: "BPMN",
|
|
679
|
+
category: "BPMN_MODIFICATION",
|
|
680
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
681
|
+
descriptionFormatter: () => "Removing connection",
|
|
682
|
+
handler: async (t, r) => {
|
|
683
|
+
try {
|
|
684
|
+
const n = e.modeler.getModeling(), o = e.modeler.getElementById(t.flowId);
|
|
685
|
+
if (!e.modeler.is(o, "bpmn:SequenceFlow"))
|
|
686
|
+
throw new Error(`Element ${t.flowId} is not a sequence flow`);
|
|
687
|
+
const i = o.id;
|
|
688
|
+
return n.removeElements([o]), { flowId: i };
|
|
689
|
+
} catch (n) {
|
|
690
|
+
throw r("delete_sequence_flow", n), new Error(`Failed to delete sequence flow: ${n.message}`);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}), K = (e) => ({
|
|
694
|
+
name: "bind_form_to_task",
|
|
695
|
+
description: "Binds a Camunda form to a user task using the zeebe:formDefinition extension. Provide either formId (for linked Camunda forms) or formKey (for external/embedded forms). Auto-layouts the diagram and returns validation errors.",
|
|
696
|
+
parameters: {
|
|
697
|
+
type: "object",
|
|
698
|
+
properties: {
|
|
699
|
+
taskId: {
|
|
700
|
+
type: "string",
|
|
701
|
+
description: "The ID of the user task to bind the form to"
|
|
702
|
+
},
|
|
703
|
+
formId: {
|
|
704
|
+
type: "string",
|
|
705
|
+
description: "The Camunda form ID (for linked forms in the same project)"
|
|
706
|
+
},
|
|
707
|
+
formKey: {
|
|
708
|
+
type: "string",
|
|
709
|
+
description: "The external form key (for custom or embedded forms)"
|
|
710
|
+
},
|
|
711
|
+
bindingType: {
|
|
712
|
+
type: "string",
|
|
713
|
+
description: "The binding type: 'latest' (default), 'deployment', or 'versionTag'"
|
|
714
|
+
}
|
|
715
|
+
},
|
|
716
|
+
required: ["taskId"]
|
|
717
|
+
},
|
|
718
|
+
type: "frontend",
|
|
719
|
+
contentType: "BPMN",
|
|
720
|
+
category: "BPMN_MODIFICATION",
|
|
721
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
722
|
+
descriptionFormatter: () => "Binding a form",
|
|
723
|
+
handler: async (t, r) => {
|
|
724
|
+
try {
|
|
725
|
+
const n = e.modeler.getElementById(t.taskId);
|
|
726
|
+
if (!e.modeler.is(n, "bpmn:UserTask"))
|
|
727
|
+
throw new Error(`Element ${t.taskId} is not a user task`);
|
|
728
|
+
const o = {
|
|
729
|
+
...t.formId ? { formId: t.formId } : {},
|
|
730
|
+
...t.formKey ? { formKey: t.formKey } : {},
|
|
731
|
+
...t.bindingType ? { bindingType: t.bindingType } : {}
|
|
732
|
+
};
|
|
733
|
+
return E(
|
|
734
|
+
n,
|
|
735
|
+
"zeebe:FormDefinition",
|
|
736
|
+
o,
|
|
737
|
+
e.modeler.getModeler(),
|
|
738
|
+
e.modeler.getBusinessObject,
|
|
739
|
+
e.modeler.is
|
|
740
|
+
), {
|
|
741
|
+
taskId: n.id,
|
|
742
|
+
binding: {
|
|
743
|
+
formId: t.formId ?? null,
|
|
744
|
+
formKey: t.formKey ?? null,
|
|
745
|
+
bindingType: t.bindingType ?? "latest"
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
} catch (n) {
|
|
749
|
+
throw r("bind_form_to_task", n), new Error(`Failed to bind form to task: ${n.message}`);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}), J = (e) => ({
|
|
753
|
+
name: "set_element_properties",
|
|
754
|
+
description: "Sets Zeebe extension properties on a BPMN element: task definition (type/retries), I/O mappings (inputs/outputs), task headers, and custom Zeebe properties. Auto-layouts the diagram and returns validation errors.",
|
|
755
|
+
parameters: {
|
|
756
|
+
type: "object",
|
|
757
|
+
properties: {
|
|
758
|
+
elementId: {
|
|
759
|
+
type: "string",
|
|
760
|
+
description: "The ID of the BPMN element"
|
|
761
|
+
},
|
|
762
|
+
taskDefinition: {
|
|
763
|
+
type: "object",
|
|
764
|
+
description: "Task definition with 'type' (job type) and optional 'retries' (e.g., '3')",
|
|
765
|
+
properties: {
|
|
766
|
+
type: { type: "string", description: "The job type for the task worker" },
|
|
767
|
+
retries: { type: "string", description: "Number of retries (default: '3')" }
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
ioMappings: {
|
|
771
|
+
type: "object",
|
|
772
|
+
description: "Input/output variable mappings",
|
|
773
|
+
properties: {
|
|
774
|
+
inputs: {
|
|
775
|
+
type: "array",
|
|
776
|
+
description: "Input mappings: FEEL source expression → target variable name",
|
|
777
|
+
items: {
|
|
778
|
+
type: "object",
|
|
779
|
+
properties: {
|
|
780
|
+
source: { type: "string", description: "FEEL source expression" },
|
|
781
|
+
target: { type: "string", description: "Target variable name in the task" }
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
},
|
|
785
|
+
outputs: {
|
|
786
|
+
type: "array",
|
|
787
|
+
description: "Output mappings: FEEL source expression → target variable name",
|
|
788
|
+
items: {
|
|
789
|
+
type: "object",
|
|
790
|
+
properties: {
|
|
791
|
+
source: { type: "string", description: "FEEL source expression" },
|
|
792
|
+
target: { type: "string", description: "Target variable name in the process" }
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
},
|
|
798
|
+
taskHeaders: {
|
|
799
|
+
type: "object",
|
|
800
|
+
description: "Key-value map of task headers",
|
|
801
|
+
additionalProperties: { type: "string" }
|
|
802
|
+
},
|
|
803
|
+
zeebeProperties: {
|
|
804
|
+
type: "object",
|
|
805
|
+
description: "Key-value map of custom Zeebe properties",
|
|
806
|
+
additionalProperties: { type: "string" }
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
required: ["elementId"]
|
|
810
|
+
},
|
|
811
|
+
type: "frontend",
|
|
812
|
+
contentType: "BPMN",
|
|
813
|
+
category: "BPMN_MODIFICATION",
|
|
814
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
815
|
+
descriptionFormatter: (t) => t.taskDefinition ? "Setting job configuration" : t.ioMappings ? "Setting input/output mappings" : t.taskHeaders ? "Adding task headers" : "Configuring properties",
|
|
816
|
+
handler: async (t, r) => {
|
|
817
|
+
try {
|
|
818
|
+
const n = e.modeler.getModeler(), o = e.modeler.getModdle(), i = e.modeler.getElementById(t.elementId), s = (a, l) => E(
|
|
819
|
+
i,
|
|
820
|
+
a,
|
|
821
|
+
l,
|
|
822
|
+
n,
|
|
823
|
+
e.modeler.getBusinessObject,
|
|
824
|
+
e.modeler.is
|
|
825
|
+
);
|
|
826
|
+
if (t.taskDefinition && s("zeebe:TaskDefinition", t.taskDefinition), t.ioMappings) {
|
|
827
|
+
const a = t.ioMappings, l = {
|
|
828
|
+
...a.inputs ? {
|
|
829
|
+
inputParameters: a.inputs.map(
|
|
830
|
+
(d) => o.create("zeebe:Input", { source: d.source, target: d.target })
|
|
831
|
+
)
|
|
832
|
+
} : {},
|
|
833
|
+
...a.outputs ? {
|
|
834
|
+
outputParameters: a.outputs.map(
|
|
835
|
+
(d) => o.create("zeebe:Output", { source: d.source, target: d.target })
|
|
836
|
+
)
|
|
837
|
+
} : {}
|
|
838
|
+
};
|
|
839
|
+
s("zeebe:IoMapping", l);
|
|
840
|
+
}
|
|
841
|
+
if (t.taskHeaders) {
|
|
842
|
+
const a = Object.entries(t.taskHeaders).map(
|
|
843
|
+
([l, d]) => o.create("zeebe:Header", { key: l, value: d })
|
|
844
|
+
);
|
|
845
|
+
s("zeebe:TaskHeaders", { values: a });
|
|
846
|
+
}
|
|
847
|
+
if (t.zeebeProperties) {
|
|
848
|
+
const a = Object.entries(t.zeebeProperties).map(
|
|
849
|
+
([l, d]) => o.create("zeebe:Property", { name: l, value: d })
|
|
850
|
+
);
|
|
851
|
+
s("zeebe:Properties", { properties: a });
|
|
852
|
+
}
|
|
853
|
+
return { elementId: i.id };
|
|
854
|
+
} catch (n) {
|
|
855
|
+
throw r("set_element_properties", n), new Error(`Failed to set element properties: ${n.message}`);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}), Q = (e) => ({
|
|
859
|
+
name: "undo",
|
|
860
|
+
description: "Undoes the last BPMN modeling operation. Reverts the most recent change to the diagram.",
|
|
861
|
+
parameters: {},
|
|
862
|
+
type: "frontend",
|
|
863
|
+
contentType: "BPMN",
|
|
864
|
+
category: "BPMN_MODIFICATION",
|
|
865
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
866
|
+
descriptionFormatter: () => "Undoing last change",
|
|
867
|
+
handler: async (t, r) => {
|
|
868
|
+
try {
|
|
869
|
+
return e.modeler.getCommandStack().undo(), await e.diagram.saveContent(), { success: !0 };
|
|
870
|
+
} catch (n) {
|
|
871
|
+
throw r("undo", n), new Error(`Failed to undo: ${n.message}`);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}), Y = (e) => ({
|
|
875
|
+
name: "redo",
|
|
876
|
+
description: "Redoes the last undone BPMN modeling operation. Reapplies a previously undone change to the diagram.",
|
|
877
|
+
parameters: {},
|
|
878
|
+
type: "frontend",
|
|
879
|
+
contentType: "BPMN",
|
|
880
|
+
category: "BPMN_MODIFICATION",
|
|
881
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
882
|
+
descriptionFormatter: () => "Redoing last change",
|
|
883
|
+
handler: async (t, r) => {
|
|
884
|
+
try {
|
|
885
|
+
return e.modeler.getCommandStack().redo(), await e.diagram.saveContent(), { success: !0 };
|
|
886
|
+
} catch (n) {
|
|
887
|
+
throw r("redo", n), new Error(`Failed to redo: ${n.message}`);
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
}), Z = (e) => ({
|
|
891
|
+
name: "read_artifact",
|
|
892
|
+
description: "Reads the current artifact content. Returns form JSON if a form editor is active, BPMN XML if a BPMN diagram is open, or DMN XML if a DMN diagram is open.",
|
|
893
|
+
parameters: {},
|
|
894
|
+
type: "frontend",
|
|
895
|
+
contentType: "TEXT",
|
|
896
|
+
category: "FILE_OPERATION",
|
|
897
|
+
descriptionFormatter: () => "Reading diagram",
|
|
898
|
+
handler: async (t, r) => {
|
|
899
|
+
try {
|
|
900
|
+
if (e.form.isAvailable())
|
|
901
|
+
return { formJson: e.form.getContent() };
|
|
902
|
+
if (e.diagram.isBPMN())
|
|
903
|
+
return { bpmnXml: await e.diagram.exportXml() };
|
|
904
|
+
if (e.diagram.isDMN())
|
|
905
|
+
return { dmnXml: e.diagram.getContent() };
|
|
906
|
+
throw new Error("No artifact available to read. Open a BPMN, DMN, or Form file first.");
|
|
907
|
+
} catch (n) {
|
|
908
|
+
throw r("read_artifact", n), n;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}), ee = async (e, t) => {
|
|
912
|
+
const { error: r } = await e.diagram.importContent(t);
|
|
913
|
+
if (r)
|
|
914
|
+
throw new Error(`Failed to import BPMN: ${r instanceof Error ? r.message : String(r)}`);
|
|
915
|
+
return await e.diagram.saveContent(), { validationErrors: await e.diagram.getLintErrors() };
|
|
916
|
+
}, te = async (e, t) => {
|
|
917
|
+
const r = e.form.getParsedContent(t);
|
|
918
|
+
return e.form.importSchema(r), await e.form.update(), { validationErrors: await e.form.getLintErrors() };
|
|
919
|
+
}, ne = async (e, t) => {
|
|
920
|
+
const { error: r } = await e.diagram.importContent(t);
|
|
921
|
+
if (r)
|
|
922
|
+
throw new Error(`Failed to import DMN: ${r instanceof Error ? r.message : String(r)}`);
|
|
923
|
+
return await e.diagram.saveContent(), {};
|
|
924
|
+
}, re = (e) => ({
|
|
925
|
+
name: "write_artifact",
|
|
926
|
+
description: "Writes content to the current artifact. Accepts bpmnXml, formJson, or dmnXml. Validates the content after writing and returns any validation errors.",
|
|
927
|
+
parameters: {
|
|
928
|
+
type: "object",
|
|
929
|
+
properties: {
|
|
930
|
+
bpmnXml: { type: "string", description: "BPMN XML content to write" },
|
|
931
|
+
formJson: { type: "string", description: "Form JSON content to write" },
|
|
932
|
+
dmnXml: { type: "string", description: "DMN XML content to write" }
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
type: "frontend",
|
|
936
|
+
contentType: "TEXT",
|
|
937
|
+
category: "FILE_OPERATION",
|
|
938
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
939
|
+
descriptionFormatter: () => "Writing changes",
|
|
940
|
+
handler: async (t, r) => {
|
|
941
|
+
try {
|
|
942
|
+
if (!e.diagram.canEdit())
|
|
943
|
+
throw new Error("Cannot edit: the current diagram is read-only.");
|
|
944
|
+
if (t.bpmnXml)
|
|
945
|
+
return await ee(e, t.bpmnXml);
|
|
946
|
+
if (t.formJson)
|
|
947
|
+
return await te(e, t.formJson);
|
|
948
|
+
if (t.dmnXml)
|
|
949
|
+
return await ne(e, t.dmnXml);
|
|
950
|
+
throw new Error("No content provided. Pass bpmnXml, formJson, or dmnXml.");
|
|
951
|
+
} catch (n) {
|
|
952
|
+
throw r("write_artifact", n), n;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}), oe = (e) => ({
|
|
956
|
+
name: "sync_artifact_state_ui",
|
|
957
|
+
description: "Saves the current diagram state to persist any pending changes in the UI.",
|
|
958
|
+
parameters: {},
|
|
959
|
+
type: "frontend",
|
|
960
|
+
contentType: "TEXT",
|
|
961
|
+
category: "FILE_OPERATION",
|
|
962
|
+
displayName: "Saving changes",
|
|
963
|
+
descriptionFormatter: () => "Saving changes",
|
|
964
|
+
handler: async (t, r) => {
|
|
965
|
+
try {
|
|
966
|
+
return await e.diagram.saveContent(), { success: !0 };
|
|
967
|
+
} catch (n) {
|
|
968
|
+
throw r("sync_artifact_state_ui", n), n;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}), ie = (e) => ({
|
|
972
|
+
name: "create_file_in_project",
|
|
973
|
+
description: "Creates a new file in the current project. Supports BPMN, DMN, Form, and Connector Template file types.",
|
|
974
|
+
parameters: {
|
|
975
|
+
type: "object",
|
|
976
|
+
properties: {
|
|
977
|
+
name: { type: "string", description: "Name of the file to create" },
|
|
978
|
+
type: {
|
|
979
|
+
type: "string",
|
|
980
|
+
enum: ["BPMN", "DMN", "FORM", "CONNECTOR_TEMPLATE"],
|
|
981
|
+
description: "Type of the file to create"
|
|
982
|
+
},
|
|
983
|
+
content: { type: "string", description: "Content of the file" }
|
|
984
|
+
},
|
|
985
|
+
required: ["name", "type", "content"]
|
|
986
|
+
},
|
|
987
|
+
type: "frontend",
|
|
988
|
+
contentType: "TEXT",
|
|
989
|
+
category: "FILE_OPERATION",
|
|
990
|
+
requiredCapabilities: ["FILE_CREATION"],
|
|
991
|
+
descriptionFormatter: (t) => u(t.name) ? `Creating "${u(t.name)}"` : "Creating file",
|
|
992
|
+
handler: async (t, r) => {
|
|
993
|
+
try {
|
|
994
|
+
if (!e.diagram.canEdit())
|
|
995
|
+
throw new Error("Cannot create files: the current context is read-only.");
|
|
996
|
+
const { id: n, folderId: o } = e.project.resolve(), { id: i } = await e.files.create({
|
|
997
|
+
name: t.name,
|
|
998
|
+
type: t.type,
|
|
999
|
+
content: t.content,
|
|
1000
|
+
projectId: n,
|
|
1001
|
+
folderId: o
|
|
1002
|
+
});
|
|
1003
|
+
return {
|
|
1004
|
+
fileId: i,
|
|
1005
|
+
name: t.name,
|
|
1006
|
+
type: t.type
|
|
1007
|
+
};
|
|
1008
|
+
} catch (n) {
|
|
1009
|
+
throw r("create_file_in_project", n), n;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}), ae = (e) => ({
|
|
1013
|
+
name: "get_file_content_from_file_id",
|
|
1014
|
+
description: "Retrieves the content of a file by its ID from the project.",
|
|
1015
|
+
parameters: {
|
|
1016
|
+
type: "object",
|
|
1017
|
+
properties: {
|
|
1018
|
+
fileId: { type: "string", description: "The ID of the file to read" }
|
|
1019
|
+
},
|
|
1020
|
+
required: ["fileId"]
|
|
1021
|
+
},
|
|
1022
|
+
type: "frontend",
|
|
1023
|
+
contentType: "TEXT",
|
|
1024
|
+
category: "FILE_OPERATION",
|
|
1025
|
+
requiredCapabilities: ["FILE_OPERATIONS"],
|
|
1026
|
+
descriptionFormatter: () => "Reading file",
|
|
1027
|
+
handler: async (t, r) => {
|
|
1028
|
+
try {
|
|
1029
|
+
return { content: await e.files.getContent(t.fileId) };
|
|
1030
|
+
} catch (n) {
|
|
1031
|
+
throw r("get_file_content_from_file_id", n), n;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}), se = (e) => ({
|
|
1035
|
+
name: "list_files_in_project",
|
|
1036
|
+
description: "Lists all files in the current project.",
|
|
1037
|
+
parameters: {},
|
|
1038
|
+
type: "frontend",
|
|
1039
|
+
contentType: "TEXT",
|
|
1040
|
+
category: "FILE_OPERATION",
|
|
1041
|
+
requiredCapabilities: ["FILE_OPERATIONS"],
|
|
1042
|
+
descriptionFormatter: () => "Listing project files",
|
|
1043
|
+
handler: async (t, r) => {
|
|
1044
|
+
try {
|
|
1045
|
+
const { id: n } = e.project.resolve(), o = await e.files.list(n);
|
|
1046
|
+
return { files: o, totalCount: o.length };
|
|
1047
|
+
} catch (n) {
|
|
1048
|
+
throw r("list_files_in_project", n), n;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}), I = (e, t) => e.map((r) => ({ ...r, source: t })), de = (e) => Array.from(
|
|
1052
|
+
e.reduce((t, r) => {
|
|
1053
|
+
const n = t.get(r.id);
|
|
1054
|
+
return n && n.version >= r.version ? t : new Map([...t, [r.id, r]]);
|
|
1055
|
+
}, /* @__PURE__ */ new Map()).values()
|
|
1056
|
+
), le = (e, t) => {
|
|
1057
|
+
const r = t.toLowerCase(), n = (e.name ?? "").toLowerCase(), o = (e.description ?? "").toLowerCase();
|
|
1058
|
+
return n.includes(r) || o.includes(r);
|
|
1059
|
+
}, pe = (e, t) => !t || e.appliesTo.some((r) => r.toLowerCase().includes(t.toLowerCase())), ce = (e) => ({
|
|
1060
|
+
name: "search_element_templates",
|
|
1061
|
+
description: "Searches available element templates (connectors and custom templates) by name or description. Returns matching templates with their metadata. Use this to discover available integrations and connector types that can be applied to BPMN elements.",
|
|
1062
|
+
parameters: {
|
|
1063
|
+
type: "object",
|
|
1064
|
+
properties: {
|
|
1065
|
+
searchTerm: {
|
|
1066
|
+
type: "string",
|
|
1067
|
+
description: "The search term to filter templates by name or description"
|
|
1068
|
+
},
|
|
1069
|
+
elementType: {
|
|
1070
|
+
type: "string",
|
|
1071
|
+
description: "Optional BPMN element type to filter templates that apply to this type"
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
required: ["searchTerm"]
|
|
1075
|
+
},
|
|
1076
|
+
type: "frontend",
|
|
1077
|
+
contentType: "TEXT",
|
|
1078
|
+
category: "INTEGRATION",
|
|
1079
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
1080
|
+
descriptionFormatter: (t) => u(t.searchTerm) ? `Searching templates for "${u(t.searchTerm)}"` : "Browsing templates",
|
|
1081
|
+
handler: async (t, r) => {
|
|
1082
|
+
try {
|
|
1083
|
+
const n = I(e.templates.getOotbConnectors(), "ootb"), o = I(e.templates.getCustom(), "custom"), i = [...n, ...o], s = de(i).filter((a) => le(a, t.searchTerm)).filter((a) => pe(a, t.elementType)).map((a) => ({
|
|
1084
|
+
id: a.id,
|
|
1085
|
+
name: a.name,
|
|
1086
|
+
description: a.description ?? "",
|
|
1087
|
+
latestVersion: a.version,
|
|
1088
|
+
appliesTo: a.appliesTo,
|
|
1089
|
+
elementType: a.elementType ?? null,
|
|
1090
|
+
source: a.source
|
|
1091
|
+
}));
|
|
1092
|
+
return { templates: s, totalCount: s.length };
|
|
1093
|
+
} catch (n) {
|
|
1094
|
+
throw r("search_element_templates", n), new Error(`Failed to search element templates: ${n.message}`);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}), me = (e) => e.reduce(
|
|
1098
|
+
(t, r) => !t || r.version > t.version ? r : t,
|
|
1099
|
+
void 0
|
|
1100
|
+
), ue = (e, t) => e.find((r) => r.version === t), ge = (e) => ({
|
|
1101
|
+
name: "get_element_template_details",
|
|
1102
|
+
description: "Gets detailed information about a specific element template, including its properties, groups, and configuration. Use this after searching templates to understand what a template configures before applying it.",
|
|
1103
|
+
parameters: {
|
|
1104
|
+
type: "object",
|
|
1105
|
+
properties: {
|
|
1106
|
+
templateId: {
|
|
1107
|
+
type: "string",
|
|
1108
|
+
description: "The ID of the element template to get details for"
|
|
1109
|
+
},
|
|
1110
|
+
version: {
|
|
1111
|
+
type: "number",
|
|
1112
|
+
description: "Optional specific version to retrieve. If omitted, returns the latest version."
|
|
1113
|
+
}
|
|
1114
|
+
},
|
|
1115
|
+
required: ["templateId"]
|
|
1116
|
+
},
|
|
1117
|
+
type: "frontend",
|
|
1118
|
+
contentType: "TEXT",
|
|
1119
|
+
category: "INTEGRATION",
|
|
1120
|
+
requiredCapabilities: ["BPMN_VIEWING"],
|
|
1121
|
+
descriptionFormatter: () => "Loading template details",
|
|
1122
|
+
handler: async (t, r) => {
|
|
1123
|
+
try {
|
|
1124
|
+
const n = [...e.templates.getOotbConnectors(), ...e.templates.getCustom()].filter((i) => i.id === t.templateId);
|
|
1125
|
+
if (n.length === 0)
|
|
1126
|
+
throw new Error(`Template with ID "${t.templateId}" not found`);
|
|
1127
|
+
const o = t.version !== void 0 ? ue(n, t.version) : me(n);
|
|
1128
|
+
if (!o)
|
|
1129
|
+
throw new Error(`Template "${t.templateId}" version ${t.version} not found`);
|
|
1130
|
+
return {
|
|
1131
|
+
id: o.id,
|
|
1132
|
+
name: o.name,
|
|
1133
|
+
description: o.description ?? "",
|
|
1134
|
+
version: o.version,
|
|
1135
|
+
appliesTo: o.appliesTo,
|
|
1136
|
+
elementType: o.elementType ?? null,
|
|
1137
|
+
groups: o.groups ?? [],
|
|
1138
|
+
properties: o.properties ?? []
|
|
1139
|
+
};
|
|
1140
|
+
} catch (n) {
|
|
1141
|
+
throw r("get_element_template_details", n), new Error(`Failed to get template details: ${n.message}`);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}), ye = (e) => ({
|
|
1145
|
+
name: "apply_element_template",
|
|
1146
|
+
description: "Applies an element template (connector or custom template) to a BPMN element. The element must exist in the diagram and the template must be available. Use search_element_templates first to find the template ID.",
|
|
1147
|
+
parameters: {
|
|
1148
|
+
type: "object",
|
|
1149
|
+
properties: {
|
|
1150
|
+
elementId: {
|
|
1151
|
+
type: "string",
|
|
1152
|
+
description: "The ID of the BPMN element to apply the template to"
|
|
1153
|
+
},
|
|
1154
|
+
templateId: {
|
|
1155
|
+
type: "string",
|
|
1156
|
+
description: "The ID of the element template to apply"
|
|
1157
|
+
},
|
|
1158
|
+
version: {
|
|
1159
|
+
type: "number",
|
|
1160
|
+
description: "Optional specific template version. If omitted, applies the latest version."
|
|
1161
|
+
}
|
|
1162
|
+
},
|
|
1163
|
+
required: ["elementId", "templateId"]
|
|
1164
|
+
},
|
|
1165
|
+
type: "frontend",
|
|
1166
|
+
contentType: "TEXT",
|
|
1167
|
+
category: "INTEGRATION",
|
|
1168
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
1169
|
+
descriptionFormatter: () => "Applying connector template",
|
|
1170
|
+
handler: async (t, r) => {
|
|
1171
|
+
try {
|
|
1172
|
+
if (!e.diagram.canEdit())
|
|
1173
|
+
throw new Error("Diagram is not editable");
|
|
1174
|
+
return e.modeler.getElementById(t.elementId), e.templates.apply(t.elementId, t.templateId, t.version), await e.diagram.saveContent(), {
|
|
1175
|
+
elementId: t.elementId,
|
|
1176
|
+
templateId: t.templateId,
|
|
1177
|
+
success: !0
|
|
1178
|
+
};
|
|
1179
|
+
} catch (n) {
|
|
1180
|
+
throw r("apply_element_template", n), new Error(`Failed to apply element template: ${n.message}`);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}), fe = (e) => ({
|
|
1184
|
+
name: "get_diagram_errors",
|
|
1185
|
+
description: "Gets all validation errors for the current BPMN diagram, including lint errors and deployment errors. Use this to check if the diagram is valid and identify issues that need to be fixed.",
|
|
1186
|
+
parameters: {},
|
|
1187
|
+
type: "frontend",
|
|
1188
|
+
contentType: "TEXT",
|
|
1189
|
+
category: "BPMN_QUERY",
|
|
1190
|
+
requiredCapabilities: ["BPMN_VIEWING", "VALIDATION"],
|
|
1191
|
+
descriptionFormatter: () => "Checking diagram errors",
|
|
1192
|
+
handler: async (t, r) => {
|
|
1193
|
+
try {
|
|
1194
|
+
const n = await e.diagram.getLintErrors(), o = e.diagram.getDeploymentErrors();
|
|
1195
|
+
return {
|
|
1196
|
+
lintErrors: n,
|
|
1197
|
+
deploymentErrors: o,
|
|
1198
|
+
totalCount: n.length + o.length
|
|
1199
|
+
};
|
|
1200
|
+
} catch (n) {
|
|
1201
|
+
throw r("get_diagram_errors", n), new Error(`Failed to get diagram errors: ${n.message}`);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}), he = (e) => ({
|
|
1205
|
+
name: "get_form_errors",
|
|
1206
|
+
description: "Gets all validation errors for the current form. Returns lint errors that indicate issues with form field configuration. Only available when a form is open.",
|
|
1207
|
+
parameters: {},
|
|
1208
|
+
type: "frontend",
|
|
1209
|
+
contentType: "TEXT",
|
|
1210
|
+
category: "FORM_CORE",
|
|
1211
|
+
requiredCapabilities: ["FORM_VIEWING", "VALIDATION"],
|
|
1212
|
+
descriptionFormatter: () => "Checking form errors",
|
|
1213
|
+
handler: async (t, r) => {
|
|
1214
|
+
try {
|
|
1215
|
+
if (!e.form.isAvailable())
|
|
1216
|
+
throw new Error("Form is not available in the current context");
|
|
1217
|
+
const n = await e.form.getLintErrors();
|
|
1218
|
+
return {
|
|
1219
|
+
lintErrors: n,
|
|
1220
|
+
totalCount: n.length
|
|
1221
|
+
};
|
|
1222
|
+
} catch (n) {
|
|
1223
|
+
throw r("get_form_errors", n), new Error(`Failed to get form errors: ${n.message}`);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}), be = (e) => ({
|
|
1227
|
+
name: "layout_bpmn_xml",
|
|
1228
|
+
description: "Auto-layouts the current BPMN diagram to improve visual clarity and readability.",
|
|
1229
|
+
parameters: {},
|
|
1230
|
+
type: "frontend",
|
|
1231
|
+
contentType: "BPMN",
|
|
1232
|
+
category: "BPMN_CORE",
|
|
1233
|
+
requiredCapabilities: ["BPMN_EDITING"],
|
|
1234
|
+
displayName: "Laying out diagram",
|
|
1235
|
+
descriptionFormatter: () => "Laying out diagram",
|
|
1236
|
+
handler: async (t, r) => {
|
|
1237
|
+
try {
|
|
1238
|
+
if (!e.diagram.canEdit())
|
|
1239
|
+
throw new Error("Cannot layout: the current diagram is read-only.");
|
|
1240
|
+
const n = await e.diagram.exportXml(), o = await w(n), { error: i } = await e.diagram.importContent(o);
|
|
1241
|
+
if (i)
|
|
1242
|
+
throw new Error(`Auto-layout import failed: ${i instanceof Error ? i.message : String(i)}`);
|
|
1243
|
+
return e.diagram.ensureExecutionPlatform(), await e.diagram.saveContent(), { bpmnXml: o };
|
|
1244
|
+
} catch (n) {
|
|
1245
|
+
throw r("layout_bpmn_xml", n), n;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
}), Ie = (e) => [
|
|
1249
|
+
T(e),
|
|
1250
|
+
_(e),
|
|
1251
|
+
P(e),
|
|
1252
|
+
M(e),
|
|
1253
|
+
O(e),
|
|
1254
|
+
x(e),
|
|
1255
|
+
$(e),
|
|
1256
|
+
X(e),
|
|
1257
|
+
U(e),
|
|
1258
|
+
z(e),
|
|
1259
|
+
V(e),
|
|
1260
|
+
H(e),
|
|
1261
|
+
W(e),
|
|
1262
|
+
K(e),
|
|
1263
|
+
J(e),
|
|
1264
|
+
Q(e),
|
|
1265
|
+
Y(e),
|
|
1266
|
+
Z(e),
|
|
1267
|
+
re(e),
|
|
1268
|
+
oe(e),
|
|
1269
|
+
ie(e),
|
|
1270
|
+
ae(e),
|
|
1271
|
+
se(e),
|
|
1272
|
+
ce(e),
|
|
1273
|
+
ge(e),
|
|
1274
|
+
ye(e),
|
|
1275
|
+
fe(e),
|
|
1276
|
+
he(e),
|
|
1277
|
+
be(e)
|
|
1278
|
+
], Te = (e, t) => {
|
|
1279
|
+
for (const r of Ie(e))
|
|
1280
|
+
t.registerTool(r);
|
|
1281
|
+
}, ve = ({ getModeler: e, is: t, getBusinessObject: r }) => ({
|
|
1282
|
+
getModeler: e,
|
|
1283
|
+
getCanvas: () => e().get("canvas"),
|
|
1284
|
+
getElementRegistry: () => e().get("elementRegistry"),
|
|
1285
|
+
getModeling: () => e().get("modeling"),
|
|
1286
|
+
getCommandStack: () => e().get("commandStack"),
|
|
1287
|
+
getElementFactory: () => e().get("elementFactory"),
|
|
1288
|
+
getModdle: () => e().get("moddle"),
|
|
1289
|
+
getSelection: () => e().get("selection"),
|
|
1290
|
+
getElementById: (n) => {
|
|
1291
|
+
const o = e().get("elementRegistry").get(n);
|
|
1292
|
+
if (!o)
|
|
1293
|
+
throw new Error(`Element not found: ${n}`);
|
|
1294
|
+
return o;
|
|
1295
|
+
},
|
|
1296
|
+
is: t,
|
|
1297
|
+
getBusinessObject: r
|
|
1298
|
+
}), Ee = async (e, t, r) => {
|
|
1299
|
+
const { xml: n } = await e.saveXML({ format: !0 }), o = await r(n), { error: i } = await t.importContent(o);
|
|
1300
|
+
if (i)
|
|
1301
|
+
throw new Error(`Auto-layout failed: ${i instanceof Error ? i.message : String(i)}`);
|
|
1302
|
+
t.ensureExecutionPlatform();
|
|
1303
|
+
}, _e = (e, t) => async (r) => {
|
|
1304
|
+
const n = e.modeler.getModeler(), o = await r(n);
|
|
1305
|
+
await Ee(n, e.diagram, t), await e.diagram.saveContent();
|
|
1306
|
+
const i = await e.diagram.getLintErrors();
|
|
1307
|
+
return { ...o, validationErrors: i };
|
|
1308
|
+
};
|
|
1309
|
+
export {
|
|
1310
|
+
Ie as E,
|
|
1311
|
+
Te as T,
|
|
1312
|
+
_e as _,
|
|
1313
|
+
ve as v
|
|
1314
|
+
};
|