@bpmnkit/plugins 0.0.8

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 (140) hide show
  1. package/README.md +153 -0
  2. package/dist/ai-bridge/css.d.ts +2 -0
  3. package/dist/ai-bridge/css.js +366 -0
  4. package/dist/ai-bridge/index.d.ts +44 -0
  5. package/dist/ai-bridge/index.js +132 -0
  6. package/dist/ai-bridge/panel.d.ts +27 -0
  7. package/dist/ai-bridge/panel.js +715 -0
  8. package/dist/ascii-view/css.d.ts +4 -0
  9. package/dist/ascii-view/css.js +83 -0
  10. package/dist/ascii-view/index.d.ts +25 -0
  11. package/dist/ascii-view/index.js +92 -0
  12. package/dist/command-palette/css.d.ts +4 -0
  13. package/dist/command-palette/css.js +157 -0
  14. package/dist/command-palette/index.d.ts +53 -0
  15. package/dist/command-palette/index.js +378 -0
  16. package/dist/command-palette-editor/index.d.ts +35 -0
  17. package/dist/command-palette-editor/index.js +60 -0
  18. package/dist/config-panel/css.d.ts +4 -0
  19. package/dist/config-panel/css.js +719 -0
  20. package/dist/config-panel/index.d.ts +36 -0
  21. package/dist/config-panel/index.js +73 -0
  22. package/dist/config-panel/renderer.d.ts +127 -0
  23. package/dist/config-panel/renderer.js +1162 -0
  24. package/dist/config-panel/types.d.ts +118 -0
  25. package/dist/config-panel/types.js +2 -0
  26. package/dist/config-panel-bpmn/index.d.ts +58 -0
  27. package/dist/config-panel-bpmn/index.js +1320 -0
  28. package/dist/config-panel-bpmn/template-engine.d.ts +17 -0
  29. package/dist/config-panel-bpmn/template-engine.js +307 -0
  30. package/dist/config-panel-bpmn/template-to-service-task.d.ts +30 -0
  31. package/dist/config-panel-bpmn/template-to-service-task.js +92 -0
  32. package/dist/config-panel-bpmn/template-types.d.ts +126 -0
  33. package/dist/config-panel-bpmn/template-types.js +6 -0
  34. package/dist/config-panel-bpmn/templates/generated.d.ts +3 -0
  35. package/dist/config-panel-bpmn/templates/generated.js +57865 -0
  36. package/dist/config-panel-bpmn/util.d.ts +46 -0
  37. package/dist/config-panel-bpmn/util.js +195 -0
  38. package/dist/dmn-editor/css.d.ts +3 -0
  39. package/dist/dmn-editor/css.js +667 -0
  40. package/dist/dmn-editor/dmn-editor.d.ts +34 -0
  41. package/dist/dmn-editor/dmn-editor.js +646 -0
  42. package/dist/dmn-editor/drd-canvas.d.ts +85 -0
  43. package/dist/dmn-editor/drd-canvas.js +1087 -0
  44. package/dist/dmn-editor/index.d.ts +3 -0
  45. package/dist/dmn-editor/index.js +2 -0
  46. package/dist/dmn-viewer/css.d.ts +3 -0
  47. package/dist/dmn-viewer/css.js +151 -0
  48. package/dist/dmn-viewer/dmn-viewer.d.ts +30 -0
  49. package/dist/dmn-viewer/dmn-viewer.js +160 -0
  50. package/dist/dmn-viewer/feel.d.ts +3 -0
  51. package/dist/dmn-viewer/feel.js +2 -0
  52. package/dist/dmn-viewer/index.d.ts +14 -0
  53. package/dist/dmn-viewer/index.js +12 -0
  54. package/dist/element-docs/content.d.ts +20 -0
  55. package/dist/element-docs/content.js +1032 -0
  56. package/dist/element-docs/index.d.ts +7 -0
  57. package/dist/element-docs/index.js +643 -0
  58. package/dist/feel-playground/css.d.ts +4 -0
  59. package/dist/feel-playground/css.js +292 -0
  60. package/dist/feel-playground/index.d.ts +4 -0
  61. package/dist/feel-playground/index.js +3 -0
  62. package/dist/feel-playground/playground-plugin.d.ts +14 -0
  63. package/dist/feel-playground/playground-plugin.js +292 -0
  64. package/dist/form-editor/css.d.ts +3 -0
  65. package/dist/form-editor/css.js +703 -0
  66. package/dist/form-editor/form-editor.d.ts +48 -0
  67. package/dist/form-editor/form-editor.js +1039 -0
  68. package/dist/form-editor/index.d.ts +3 -0
  69. package/dist/form-editor/index.js +2 -0
  70. package/dist/form-viewer/css.d.ts +3 -0
  71. package/dist/form-viewer/css.js +303 -0
  72. package/dist/form-viewer/form-viewer.d.ts +29 -0
  73. package/dist/form-viewer/form-viewer.js +376 -0
  74. package/dist/form-viewer/index.d.ts +12 -0
  75. package/dist/form-viewer/index.js +11 -0
  76. package/dist/history/checkpoint.d.ts +10 -0
  77. package/dist/history/checkpoint.js +92 -0
  78. package/dist/history/css.d.ts +2 -0
  79. package/dist/history/css.js +130 -0
  80. package/dist/history/history-panel.d.ts +12 -0
  81. package/dist/history/history-panel.js +142 -0
  82. package/dist/history/index.d.ts +5 -0
  83. package/dist/history/index.js +3 -0
  84. package/dist/main-menu/css.d.ts +4 -0
  85. package/dist/main-menu/css.js +272 -0
  86. package/dist/main-menu/index.d.ts +59 -0
  87. package/dist/main-menu/index.js +285 -0
  88. package/dist/minimap/css.d.ts +10 -0
  89. package/dist/minimap/css.js +54 -0
  90. package/dist/minimap/index.d.ts +38 -0
  91. package/dist/minimap/index.js +69 -0
  92. package/dist/minimap/minimap.d.ts +35 -0
  93. package/dist/minimap/minimap.js +166 -0
  94. package/dist/optimize/index.d.ts +21 -0
  95. package/dist/optimize/index.js +304 -0
  96. package/dist/process-runner/css.d.ts +2 -0
  97. package/dist/process-runner/css.js +467 -0
  98. package/dist/process-runner/index.d.ts +56 -0
  99. package/dist/process-runner/index.js +549 -0
  100. package/dist/storage/auto-save.d.ts +11 -0
  101. package/dist/storage/auto-save.js +44 -0
  102. package/dist/storage/css.d.ts +2 -0
  103. package/dist/storage/css.js +2 -0
  104. package/dist/storage/db.d.ts +99 -0
  105. package/dist/storage/db.js +116 -0
  106. package/dist/storage/dialog.d.ts +15 -0
  107. package/dist/storage/dialog.js +201 -0
  108. package/dist/storage/export.d.ts +3 -0
  109. package/dist/storage/export.js +137 -0
  110. package/dist/storage/index.d.ts +44 -0
  111. package/dist/storage/index.js +201 -0
  112. package/dist/storage/sidebar.d.ts +2 -0
  113. package/dist/storage/sidebar.js +2 -0
  114. package/dist/storage/storage-api.d.ts +76 -0
  115. package/dist/storage/storage-api.js +342 -0
  116. package/dist/storage/types.d.ts +44 -0
  117. package/dist/storage/types.js +2 -0
  118. package/dist/storage-tabs-bridge/index.d.ts +96 -0
  119. package/dist/storage-tabs-bridge/index.js +502 -0
  120. package/dist/tabs/css.d.ts +3 -0
  121. package/dist/tabs/css.js +642 -0
  122. package/dist/tabs/file-resolver.d.ts +71 -0
  123. package/dist/tabs/file-resolver.js +46 -0
  124. package/dist/tabs/index.d.ts +15 -0
  125. package/dist/tabs/index.js +13 -0
  126. package/dist/tabs/tabs-plugin.d.ts +250 -0
  127. package/dist/tabs/tabs-plugin.js +1119 -0
  128. package/dist/token-highlight/css.d.ts +2 -0
  129. package/dist/token-highlight/css.js +81 -0
  130. package/dist/token-highlight/index.d.ts +44 -0
  131. package/dist/token-highlight/index.js +164 -0
  132. package/dist/watermark/css.d.ts +10 -0
  133. package/dist/watermark/css.js +54 -0
  134. package/dist/watermark/index.d.ts +48 -0
  135. package/dist/watermark/index.js +64 -0
  136. package/dist/zoom-controls/css.d.ts +4 -0
  137. package/dist/zoom-controls/css.js +48 -0
  138. package/dist/zoom-controls/index.d.ts +36 -0
  139. package/dist/zoom-controls/index.js +111 -0
  140. package/package.json +121 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a Camunda element template into the PanelSchema + PanelAdapter pair
3
+ * used by the config-panel plugin renderer.
4
+ */
5
+ import type { PanelAdapter, PanelSchema } from "../config-panel/index.js";
6
+ import type { ElementTemplate } from "./template-types.js";
7
+ export interface TemplateRegistration {
8
+ schema: PanelSchema;
9
+ adapter: PanelAdapter;
10
+ }
11
+ /**
12
+ * Builds a PanelSchema + PanelAdapter pair from an element template descriptor.
13
+ * The result is cached by the caller (per template id) so reference-equality
14
+ * comparisons in the renderer work correctly.
15
+ */
16
+ export declare function buildRegistrationFromTemplate(template: ElementTemplate): TemplateRegistration;
17
+ //# sourceMappingURL=template-engine.d.ts.map
@@ -0,0 +1,307 @@
1
+ import { zeebeExtensionsToXmlElements } from "@bpmnkit/core";
2
+ import { findFlowElement, getAdHocAttr, getIoInput, getTaskHeader, parseZeebeExtensions, updateFlowElement, xmlLocalName, } from "./util.js";
3
+ // ── Condition conversion ──────────────────────────────────────────────────────
4
+ function buildConditionFn(cond) {
5
+ if ("allMatch" in cond) {
6
+ const fns = cond.allMatch.map((c) => buildConditionFn(c));
7
+ return (values) => fns.every((fn) => fn(values));
8
+ }
9
+ if ("equals" in cond) {
10
+ return (values) => values[cond.property] === cond.equals;
11
+ }
12
+ if ("oneOf" in cond) {
13
+ const set = new Set(cond.oneOf);
14
+ return (values) => set.has(values[cond.property]);
15
+ }
16
+ if ("isActive" in cond) {
17
+ const expected = cond.isActive;
18
+ return (values) => Boolean(values[cond.property]) === expected;
19
+ }
20
+ return () => true;
21
+ }
22
+ // ── Property key derivation ───────────────────────────────────────────────────
23
+ /**
24
+ * Derive the panel field key for a template property.
25
+ *
26
+ * The key is used as:
27
+ * - The field key in PanelSchema (for rendering + condition references)
28
+ * - The value-map key in the adapter (for read/write)
29
+ *
30
+ * Priority: property.id > binding-derived name
31
+ */
32
+ function getPropertyKey(prop) {
33
+ if (prop.id)
34
+ return prop.id;
35
+ const b = prop.binding;
36
+ if (b.type === "zeebe:input")
37
+ return b.name;
38
+ if (b.type === "zeebe:output")
39
+ return b.source;
40
+ if (b.type === "zeebe:taskHeader")
41
+ return b.key;
42
+ if (b.type === "zeebe:taskDefinition")
43
+ return `taskDef.${b.property}`;
44
+ if (b.type === "zeebe:taskDefinition:type")
45
+ return "taskDef.type";
46
+ if (b.type === "property")
47
+ return b.name;
48
+ if (b.type === "zeebe:property")
49
+ return b.name;
50
+ if (b.type === "zeebe:adHoc")
51
+ return `adHoc.${b.property}`;
52
+ return "";
53
+ }
54
+ // ── Property → FieldSchema ────────────────────────────────────────────────────
55
+ function propToFieldSchema(prop) {
56
+ const key = getPropertyKey(prop);
57
+ const condition = prop.condition ? buildConditionFn(prop.condition) : undefined;
58
+ const base = {
59
+ key,
60
+ label: prop.label ?? key,
61
+ type: "text",
62
+ placeholder: prop.placeholder,
63
+ hint: prop.description,
64
+ tooltip: prop.tooltip,
65
+ condition,
66
+ ...(prop.constraints?.notEmpty === true ? { required: true } : {}),
67
+ };
68
+ // FEEL mode: "optional" → toggle, "required" → fixed (always FEEL, no toggle)
69
+ const feelOptional = prop.feel === "optional";
70
+ const feelRequired = prop.feel === "required";
71
+ const hasFeel = feelOptional || feelRequired;
72
+ switch (prop.type) {
73
+ case "Text":
74
+ if (hasFeel) {
75
+ return { ...base, type: "feel-expression", ...(feelRequired ? { feelFixed: true } : {}) };
76
+ }
77
+ return { ...base, type: "textarea" };
78
+ case "Dropdown":
79
+ return {
80
+ ...base,
81
+ type: "select",
82
+ options: (prop.choices ?? []).map((c) => ({ value: c.value, label: c.name })),
83
+ };
84
+ case "Boolean":
85
+ return { ...base, type: "toggle" };
86
+ case "Number":
87
+ return {
88
+ ...base,
89
+ type: "text",
90
+ placeholder: prop.placeholder ?? String(prop.value ?? ""),
91
+ };
92
+ default:
93
+ // String
94
+ if (hasFeel) {
95
+ return { ...base, type: "feel-expression", ...(feelRequired ? { feelFixed: true } : {}) };
96
+ }
97
+ return base;
98
+ }
99
+ }
100
+ // ── Adapter read/write helpers ────────────────────────────────────────────────
101
+ function readPropertyValue(ext, el, prop) {
102
+ const b = prop.binding;
103
+ if (b.type === "zeebe:input")
104
+ return getIoInput(ext, b.name);
105
+ if (b.type === "zeebe:taskHeader")
106
+ return getTaskHeader(ext, b.key);
107
+ if (b.type === "zeebe:taskDefinition" && b.property === "type")
108
+ return ext.taskDefinition?.type;
109
+ if (b.type === "zeebe:taskDefinition" && b.property === "retries")
110
+ return ext.taskDefinition?.retries;
111
+ if (b.type === "zeebe:taskDefinition:type")
112
+ return ext.taskDefinition?.type;
113
+ if (b.type === "property" && b.name === "name")
114
+ return el.name;
115
+ if (b.type === "zeebe:adHoc")
116
+ return getAdHocAttr(el.extensionElements, b.property);
117
+ return undefined;
118
+ }
119
+ function applyBinding(binding, value, inputs, headers, taskDef, adHocProps) {
120
+ if (binding.type === "zeebe:input") {
121
+ inputs.push({ source: value, target: binding.name });
122
+ }
123
+ else if (binding.type === "zeebe:taskHeader") {
124
+ headers.push({ key: binding.key, value });
125
+ }
126
+ else if (binding.type === "zeebe:taskDefinition" && binding.property === "type") {
127
+ taskDef.type = value;
128
+ }
129
+ else if (binding.type === "zeebe:taskDefinition" && binding.property === "retries") {
130
+ taskDef.retries = value;
131
+ }
132
+ else if (binding.type === "zeebe:taskDefinition:type") {
133
+ taskDef.type = value;
134
+ }
135
+ else if (binding.type === "zeebe:adHoc") {
136
+ if (binding.property === "outputCollection")
137
+ adHocProps.outputCollection = value;
138
+ else if (binding.property === "outputElement")
139
+ adHocProps.outputElement = value;
140
+ else if (binding.property === "activeElementsCollection")
141
+ adHocProps.activeElementsCollection = value;
142
+ }
143
+ }
144
+ /**
145
+ * Builds a PanelSchema + PanelAdapter pair from an element template descriptor.
146
+ * The result is cached by the caller (per template id) so reference-equality
147
+ * comparisons in the renderer work correctly.
148
+ */
149
+ export function buildRegistrationFromTemplate(template) {
150
+ // Collect visible (non-hidden) properties and their keys
151
+ const visibleProps = template.properties.filter((p) => p.type !== "Hidden");
152
+ const propsByKey = new Map();
153
+ for (const prop of visibleProps) {
154
+ const key = getPropertyKey(prop);
155
+ if (key)
156
+ propsByKey.set(key, prop);
157
+ }
158
+ // Collect hidden properties (written at save time with their fixed default values)
159
+ const hiddenProps = template.properties.filter((p) => p.type === "Hidden");
160
+ // Group visible properties by their group id
161
+ const byGroup = new Map();
162
+ const ungrouped = [];
163
+ for (const prop of visibleProps) {
164
+ if (prop.group) {
165
+ const arr = byGroup.get(prop.group);
166
+ if (arr)
167
+ arr.push(prop);
168
+ else
169
+ byGroup.set(prop.group, [prop]);
170
+ }
171
+ else {
172
+ ungrouped.push(prop);
173
+ }
174
+ }
175
+ // Build schema groups
176
+ // "General" group always comes first: name + any ungrouped properties
177
+ const nameField = {
178
+ key: "name",
179
+ label: "Name",
180
+ type: "text",
181
+ placeholder: "Task name",
182
+ };
183
+ /**
184
+ * Action button that strips the zeebe:modelerTemplate stamp so the renderer
185
+ * falls back to the generic connector selector on the next diagram:change.
186
+ * The sentinel value "__change_connector" is intercepted by write() below.
187
+ */
188
+ const changeConnectorField = {
189
+ key: "__change_connector",
190
+ label: "Change connector",
191
+ type: "action",
192
+ hint: "Switch to a different connector or custom task type.",
193
+ onClick: (_values, setValue) => {
194
+ setValue("__change_connector", "remove");
195
+ },
196
+ };
197
+ const generalFields = [
198
+ nameField,
199
+ changeConnectorField,
200
+ ...ungrouped.map((p) => propToFieldSchema(p)),
201
+ ];
202
+ const schemaGroups = [{ id: "general", label: "General", fields: generalFields }];
203
+ for (const tg of template.groups ?? []) {
204
+ const props = byGroup.get(tg.id);
205
+ if (!props || props.length === 0)
206
+ continue;
207
+ schemaGroups.push({
208
+ id: tg.id,
209
+ label: tg.label,
210
+ fields: props.map((p) => propToFieldSchema(p)),
211
+ });
212
+ }
213
+ const schema = {
214
+ compact: [nameField],
215
+ groups: schemaGroups,
216
+ ...(template.documentationRef ? { docsUrl: template.documentationRef } : {}),
217
+ templateName: template.name,
218
+ };
219
+ // Build adapter
220
+ const adapter = {
221
+ read(defs, id) {
222
+ const el = findFlowElement(defs, id);
223
+ if (!el)
224
+ return {};
225
+ const ext = parseZeebeExtensions(el.extensionElements);
226
+ const values = { name: el.name ?? "" };
227
+ for (const [key, prop] of propsByKey) {
228
+ const raw = readPropertyValue(ext, el, prop);
229
+ // Fall back to template default when not yet written to XML
230
+ values[key] = raw ?? String(prop.value ?? "");
231
+ }
232
+ return values;
233
+ },
234
+ write(defs, id, values) {
235
+ // "Change connector" button — strip the template stamp so the renderer
236
+ // falls back to the generic connector selector on the next render.
237
+ if (values.__change_connector === "remove") {
238
+ return updateFlowElement(defs, id, (el) => {
239
+ const { "zeebe:modelerTemplate": _tm, "zeebe:modelerTemplateVersion": _tmv, "zeebe:modelerTemplateIcon": _tmi, ...rest } = el.unknownAttributes;
240
+ return { ...el, unknownAttributes: rest };
241
+ });
242
+ }
243
+ return updateFlowElement(defs, id, (el) => {
244
+ const name = typeof values.name === "string" ? values.name || undefined : el.name;
245
+ const inputs = [];
246
+ const headers = [];
247
+ const taskDef = {};
248
+ const adHocProps = {};
249
+ // 1. Apply hidden properties first (fixed default values)
250
+ for (const prop of hiddenProps) {
251
+ const val = String(prop.value ?? "");
252
+ if (val)
253
+ applyBinding(prop.binding, val, inputs, headers, taskDef, adHocProps);
254
+ }
255
+ // 2. Apply user-entered values for visible properties
256
+ for (const [key, prop] of propsByKey) {
257
+ const raw = values[key];
258
+ const val = typeof raw === "boolean" ? String(raw) : typeof raw === "string" ? raw : "";
259
+ const isBlank = val === "" || val === undefined;
260
+ // Skip optional blank values — don't write to XML
261
+ if (isBlank && prop.optional)
262
+ continue;
263
+ // Skip truly blank fields with no default
264
+ if (isBlank && prop.value === undefined)
265
+ continue;
266
+ const effectiveVal = val !== "" ? val : String(prop.value ?? "");
267
+ if (!effectiveVal)
268
+ continue;
269
+ applyBinding(prop.binding, effectiveVal, inputs, headers, taskDef, adHocProps);
270
+ }
271
+ // Preserve non-Zeebe extension elements
272
+ const ZEEBE_LOCAL = new Set(["taskDefinition", "ioMapping", "taskHeaders", "adHoc"]);
273
+ const otherExts = el.extensionElements.filter((x) => !ZEEBE_LOCAL.has(xmlLocalName(x.name)));
274
+ const newZeebeExts = zeebeExtensionsToXmlElements({
275
+ taskDefinition: taskDef.type
276
+ ? { type: taskDef.type, retries: taskDef.retries || undefined }
277
+ : undefined,
278
+ ioMapping: inputs.length > 0 ? { inputs, outputs: [] } : undefined,
279
+ taskHeaders: headers.length > 0 ? { headers } : undefined,
280
+ adHoc: (adHocProps.outputCollection ??
281
+ adHocProps.outputElement ??
282
+ adHocProps.activeElementsCollection)
283
+ ? adHocProps
284
+ : undefined,
285
+ });
286
+ return {
287
+ ...el,
288
+ name,
289
+ extensionElements: [...otherExts, ...newZeebeExts],
290
+ // Stamp the modelerTemplate attribute so the editor recognizes it
291
+ unknownAttributes: {
292
+ ...el.unknownAttributes,
293
+ "zeebe:modelerTemplate": template.id,
294
+ ...(template.version !== undefined
295
+ ? { "zeebe:modelerTemplateVersion": String(template.version) }
296
+ : {}),
297
+ ...(template.icon?.contents
298
+ ? { "zeebe:modelerTemplateIcon": template.icon.contents }
299
+ : {}),
300
+ },
301
+ };
302
+ });
303
+ },
304
+ };
305
+ return { schema, adapter };
306
+ }
307
+ //# sourceMappingURL=template-engine.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Convert an element template + user-provided values into ServiceTaskOptions
3
+ * for use with the core `Bpmn` builder.
4
+ */
5
+ import type { ServiceTaskOptions } from "@bpmnkit/core";
6
+ import type { ElementTemplate } from "./template-types.js";
7
+ /**
8
+ * Convert a Camunda element template into `ServiceTaskOptions` for the core
9
+ * `Bpmn` builder, applying `values` for user-configurable properties and
10
+ * fixed template defaults for Hidden properties.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { Bpmn } from "@bpmnkit/core";
15
+ * import { CAMUNDA_CONNECTOR_TEMPLATES, templateToServiceTaskOptions } from "@bpmnkit/canvas-plugin-config-panel-bpmn";
16
+ *
17
+ * const kafka = CAMUNDA_CONNECTOR_TEMPLATES.find(t => t.id === "io.camunda.connectors.KAFKA.v1")!;
18
+ * const defs = Bpmn.createProcess("proc")
19
+ * .startEvent("start")
20
+ * .serviceTask("publish", templateToServiceTaskOptions(kafka, {
21
+ * "topic.bootstrapServers": "localhost:9092",
22
+ * "topic.topicName": "orders",
23
+ * "message.value": "= order",
24
+ * }))
25
+ * .endEvent("end")
26
+ * .build();
27
+ * ```
28
+ */
29
+ export declare function templateToServiceTaskOptions(template: ElementTemplate, values?: Record<string, string>): ServiceTaskOptions;
30
+ //# sourceMappingURL=template-to-service-task.d.ts.map
@@ -0,0 +1,92 @@
1
+ /** Derive the lookup key for a template property (same logic as the template engine). */
2
+ function propertyKey(prop) {
3
+ if (prop.id)
4
+ return prop.id;
5
+ const b = prop.binding;
6
+ if (b.type === "zeebe:input")
7
+ return b.name;
8
+ if (b.type === "zeebe:output")
9
+ return b.source;
10
+ if (b.type === "zeebe:taskHeader")
11
+ return b.key;
12
+ if (b.type === "zeebe:taskDefinition")
13
+ return `taskDef.${b.property}`;
14
+ if (b.type === "zeebe:taskDefinition:type")
15
+ return "taskDef.type";
16
+ if (b.type === "property")
17
+ return b.name;
18
+ if (b.type === "zeebe:property")
19
+ return b.name;
20
+ return "";
21
+ }
22
+ function applyBinding(binding, value, inputs, taskHeaders, out) {
23
+ if (binding.type === "zeebe:input") {
24
+ inputs.push({ source: value, target: binding.name });
25
+ }
26
+ else if (binding.type === "zeebe:taskHeader") {
27
+ taskHeaders[binding.key] = value;
28
+ }
29
+ else if (binding.type === "zeebe:taskDefinition" && binding.property === "type") {
30
+ out.taskType = value;
31
+ }
32
+ else if (binding.type === "zeebe:taskDefinition" && binding.property === "retries") {
33
+ out.retries = value;
34
+ }
35
+ else if (binding.type === "zeebe:taskDefinition:type") {
36
+ out.taskType = value;
37
+ }
38
+ }
39
+ /**
40
+ * Convert a Camunda element template into `ServiceTaskOptions` for the core
41
+ * `Bpmn` builder, applying `values` for user-configurable properties and
42
+ * fixed template defaults for Hidden properties.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import { Bpmn } from "@bpmnkit/core";
47
+ * import { CAMUNDA_CONNECTOR_TEMPLATES, templateToServiceTaskOptions } from "@bpmnkit/canvas-plugin-config-panel-bpmn";
48
+ *
49
+ * const kafka = CAMUNDA_CONNECTOR_TEMPLATES.find(t => t.id === "io.camunda.connectors.KAFKA.v1")!;
50
+ * const defs = Bpmn.createProcess("proc")
51
+ * .startEvent("start")
52
+ * .serviceTask("publish", templateToServiceTaskOptions(kafka, {
53
+ * "topic.bootstrapServers": "localhost:9092",
54
+ * "topic.topicName": "orders",
55
+ * "message.value": "= order",
56
+ * }))
57
+ * .endEvent("end")
58
+ * .build();
59
+ * ```
60
+ */
61
+ export function templateToServiceTaskOptions(template, values = {}) {
62
+ const inputs = [];
63
+ const taskHeaders = {};
64
+ const out = {
65
+ taskType: "",
66
+ retries: undefined,
67
+ };
68
+ for (const prop of template.properties) {
69
+ if (prop.type === "Hidden") {
70
+ if (typeof prop.value === "string" && prop.value) {
71
+ applyBinding(prop.binding, prop.value, inputs, taskHeaders, out);
72
+ }
73
+ continue;
74
+ }
75
+ const key = propertyKey(prop);
76
+ const val = values[key] ?? (typeof prop.value === "string" ? prop.value : undefined);
77
+ if (!val)
78
+ continue;
79
+ applyBinding(prop.binding, val, inputs, taskHeaders, out);
80
+ }
81
+ return {
82
+ name: values.name ?? template.name,
83
+ taskType: out.taskType,
84
+ retries: out.retries,
85
+ modelerTemplate: template.id,
86
+ modelerTemplateVersion: template.version !== undefined ? String(template.version) : undefined,
87
+ modelerTemplateIcon: template.icon?.contents,
88
+ ioMapping: inputs.length > 0 ? { inputs } : undefined,
89
+ taskHeaders: Object.keys(taskHeaders).length > 0 ? taskHeaders : undefined,
90
+ };
91
+ }
92
+ //# sourceMappingURL=template-to-service-task.js.map
@@ -0,0 +1,126 @@
1
+ /**
2
+ * TypeScript types matching the Camunda element template JSON schema.
3
+ * https://github.com/camunda/element-templates-json-schema
4
+ */
5
+ export interface ElementTemplate {
6
+ /** Unique template identifier (reverse-domain, e.g. "io.camunda.connectors.HttpJson.v2"). */
7
+ id: string;
8
+ /** Display name shown in the template catalog. */
9
+ name: string;
10
+ /** Short description. */
11
+ description?: string;
12
+ /** Integer version; templates with the same id + different version are distinct. */
13
+ version?: number;
14
+ /** BPMN element types this template applies to (e.g. "bpmn:ServiceTask", "bpmn:Task"). */
15
+ appliesTo: string[];
16
+ /** Forces the element to be converted to this type on apply. */
17
+ elementType?: {
18
+ value: string;
19
+ };
20
+ /** UI section definitions (collapsible groups). */
21
+ groups?: TemplateGroup[];
22
+ /** All property definitions. */
23
+ properties: TemplateProperty[];
24
+ /** Link to external documentation. */
25
+ documentationRef?: string;
26
+ /** Custom icon: { contents: "data:image/svg+xml;base64,..." } */
27
+ icon?: {
28
+ contents: string;
29
+ };
30
+ }
31
+ export interface TemplateGroup {
32
+ id: string;
33
+ label: string;
34
+ tooltip?: string;
35
+ openByDefault?: boolean;
36
+ }
37
+ export interface TemplateProperty {
38
+ /** Unique key used in condition references. Falls back to binding name if absent. */
39
+ id?: string;
40
+ /** Label shown above the input. Hidden properties have no label. */
41
+ label?: string;
42
+ /** Hint text shown below the input. */
43
+ description?: string;
44
+ /** UI control type. */
45
+ type: "String" | "Text" | "Hidden" | "Dropdown" | "Boolean" | "Number";
46
+ /** Default value applied when the template is first used. */
47
+ value?: string | number | boolean;
48
+ /** Placeholder text. */
49
+ placeholder?: string;
50
+ /** If true, empty values are not written to the BPMN XML. */
51
+ optional?: boolean;
52
+ /** FEEL expression mode (only relevant for String/Text). */
53
+ feel?: "optional" | "required" | "static";
54
+ /** Which template group this property belongs to. */
55
+ group?: string;
56
+ /** Tooltip text. */
57
+ tooltip?: string;
58
+ /** How this property maps to the BPMN XML. */
59
+ binding: TemplateBinding;
60
+ /** Conditional visibility. */
61
+ condition?: TemplateCondition;
62
+ /** Required for Dropdown type. */
63
+ choices?: Array<{
64
+ name: string;
65
+ value: string;
66
+ }>;
67
+ /** Validation constraints. */
68
+ constraints?: {
69
+ notEmpty?: boolean;
70
+ minLength?: number;
71
+ maxLength?: number;
72
+ pattern?: string | {
73
+ value: string;
74
+ message: string;
75
+ };
76
+ };
77
+ }
78
+ /** All supported binding types. */
79
+ export type TemplateBinding = {
80
+ type: "property";
81
+ name: string;
82
+ }
83
+ /** @deprecated Use zeebe:taskDefinition with property field instead. */
84
+ | {
85
+ type: "zeebe:taskDefinition:type";
86
+ } | {
87
+ type: "zeebe:taskDefinition";
88
+ property: "type" | "retries";
89
+ } | {
90
+ type: "zeebe:input";
91
+ name: string;
92
+ } | {
93
+ type: "zeebe:output";
94
+ source: string;
95
+ } | {
96
+ type: "zeebe:taskHeader";
97
+ key: string;
98
+ } | {
99
+ type: "zeebe:property";
100
+ name: string;
101
+ } | {
102
+ type: "zeebe:adHoc";
103
+ property: "outputCollection" | "outputElement" | "activeElementsCollection";
104
+ };
105
+ /** Condition controlling whether a property is shown in the UI. */
106
+ export type TemplateCondition = {
107
+ property: string;
108
+ equals: string;
109
+ type?: string;
110
+ } | {
111
+ property: string;
112
+ oneOf: string[];
113
+ type?: string;
114
+ } | {
115
+ property: string;
116
+ isActive: boolean;
117
+ type?: string;
118
+ } | {
119
+ allMatch: Array<{
120
+ property: string;
121
+ equals?: string;
122
+ oneOf?: string[];
123
+ isActive?: boolean;
124
+ }>;
125
+ };
126
+ //# sourceMappingURL=template-types.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * TypeScript types matching the Camunda element template JSON schema.
3
+ * https://github.com/camunda/element-templates-json-schema
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=template-types.js.map
@@ -0,0 +1,3 @@
1
+ import type { ElementTemplate } from "../template-types.js";
2
+ export declare const CAMUNDA_CONNECTOR_TEMPLATES: ElementTemplate[];
3
+ //# sourceMappingURL=generated.d.ts.map