@aranzatech/diagrams-bpmn 0.2.6 → 0.2.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.
package/dist/index.cjs CHANGED
@@ -2505,7 +2505,17 @@ var ARANZA_DESCRIPTOR = {
2505
2505
  properties: [
2506
2506
  { name: "priority", isAttr: true, type: "String" },
2507
2507
  { name: "owner", isAttr: true, type: "String" },
2508
- { name: "sla", isAttr: true, type: "String" }
2508
+ { name: "sla", isAttr: true, type: "String" },
2509
+ // Aranza connector execution config (resolved at runtime by the Flowable delegate)
2510
+ { name: "connector", isAttr: true, type: "String" },
2511
+ { name: "action", isAttr: true, type: "String" },
2512
+ // Flowable implementation hints stored for round-trip fidelity
2513
+ { name: "flowableType", isAttr: true, type: "String" },
2514
+ { name: "flowableDelegateExpression", isAttr: true, type: "String" },
2515
+ // BusinessRuleTask: reference to a DMN decision table id
2516
+ { name: "decisionRef", isAttr: true, type: "String" },
2517
+ // UserTask: form key resolved to a FormDefinition name at runtime
2518
+ { name: "formKey", isAttr: true, type: "String" }
2509
2519
  ]
2510
2520
  }
2511
2521
  ],
@@ -2780,11 +2790,20 @@ function extractSubProcessVariant(el) {
2780
2790
  return "embedded";
2781
2791
  }
2782
2792
  function extractAranzaExtensions(el) {
2793
+ const result = {};
2794
+ const elAttrs = el.$attrs;
2795
+ if (elAttrs) {
2796
+ const ft = asString(elAttrs["flowable:type"]);
2797
+ if (ft) result.flowableType = ft;
2798
+ const fde = asString(elAttrs["flowable:delegateExpression"]);
2799
+ if (fde) result.flowableDelegateExpression = fde;
2800
+ const fk = asString(elAttrs["flowable:formKey"]);
2801
+ if (fk) result.formKey = fk;
2802
+ }
2783
2803
  const ext = el.extensionElements;
2784
- if (!ext) return {};
2804
+ if (!ext) return result;
2785
2805
  const taskConfig = asElements(ext.values).find((v) => v.$type === "aranza:TaskConfig");
2786
- if (!taskConfig) return {};
2787
- const result = {};
2806
+ if (!taskConfig) return result;
2788
2807
  const priority = asString(taskConfig.priority);
2789
2808
  if (priority === "critical" || priority === "high" || priority === "medium" || priority === "low") {
2790
2809
  result.priority = priority;
@@ -2793,8 +2812,26 @@ function extractAranzaExtensions(el) {
2793
2812
  if (owner) result.owner = owner;
2794
2813
  const sla = asString(taskConfig.sla);
2795
2814
  if (sla) result.sla = sla;
2815
+ const connector = asString(taskConfig.connector);
2816
+ if (connector) result.connector = connector;
2817
+ const action = asString(taskConfig.action);
2818
+ if (action) result.action = action;
2819
+ const flowableType = asString(taskConfig.flowableType);
2820
+ if (flowableType) result.flowableType = flowableType;
2821
+ const flowableDelegateExpression = asString(taskConfig.flowableDelegateExpression);
2822
+ if (flowableDelegateExpression) result.flowableDelegateExpression = flowableDelegateExpression;
2823
+ const decisionRef = asString(taskConfig.decisionRef);
2824
+ if (decisionRef) result.decisionRef = decisionRef;
2825
+ const formKey = asString(taskConfig.formKey);
2826
+ if (formKey) result.formKey = formKey;
2796
2827
  return result;
2797
2828
  }
2829
+ function extractCompletionCondition(el) {
2830
+ const cc = el.completionCondition;
2831
+ if (!cc) return void 0;
2832
+ if (typeof cc === "string") return cc.trim() || void 0;
2833
+ return asString(cc.body);
2834
+ }
2798
2835
  function walkFlowElements(elements, parentId, ctx, nodes, edges) {
2799
2836
  for (const el of elements) {
2800
2837
  const { $type, id } = el;
@@ -2833,6 +2870,9 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
2833
2870
  const attachedToRef = el.attachedToRef?.id;
2834
2871
  const calledElement = elementType === "CallActivity" ? asString(el.calledElement) : void 0;
2835
2872
  const aranzaExt = extractAranzaExtensions(el);
2873
+ const scriptFormat = elementType === "ScriptTask" ? asString(el.scriptFormat) : void 0;
2874
+ const script = elementType === "ScriptTask" ? asString(el.script) : void 0;
2875
+ const completionCondition = elementType === "AdHocSubProcess" ? extractCompletionCondition(el) : void 0;
2836
2876
  const data = {
2837
2877
  elementType,
2838
2878
  ...label ? { label } : {},
@@ -2850,6 +2890,9 @@ function buildNode(el, elementType, parentId, ctx, nodes) {
2850
2890
  ...eventDefinition?.conditionExpression ? { conditionExpression: eventDefinition.conditionExpression } : {},
2851
2891
  ...eventDefinition?.linkName ? { linkName: eventDefinition.linkName } : {},
2852
2892
  ...calledElement ? { calledElement } : {},
2893
+ ...scriptFormat ? { scriptFormat } : {},
2894
+ ...script ? { script } : {},
2895
+ ...completionCondition ? { completionCondition } : {},
2853
2896
  ...aranzaExt
2854
2897
  };
2855
2898
  if (elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess") {
@@ -3144,11 +3187,25 @@ function buildEventDefinitions(moddle, node, eventDefinition) {
3144
3187
  }
3145
3188
  function buildAranzaExtensionElements(moddle, node) {
3146
3189
  const { priority, owner, sla } = node.data;
3147
- if (!priority && !owner && !sla) return null;
3190
+ const connector = typeof node.data.connector === "string" ? node.data.connector : void 0;
3191
+ const action = typeof node.data.action === "string" ? node.data.action : void 0;
3192
+ const flowableType = typeof node.data.flowableType === "string" ? node.data.flowableType : void 0;
3193
+ const flowableDelegateExpression = typeof node.data.flowableDelegateExpression === "string" ? node.data.flowableDelegateExpression : void 0;
3194
+ const decisionRef = typeof node.data.decisionRef === "string" ? node.data.decisionRef : void 0;
3195
+ const formKey = typeof node.data.formKey === "string" ? node.data.formKey : void 0;
3196
+ if (!priority && !owner && !sla && !connector && !action && !flowableType && !flowableDelegateExpression && !decisionRef && !formKey) {
3197
+ return null;
3198
+ }
3148
3199
  const configAttrs = {};
3149
3200
  if (priority) configAttrs.priority = priority;
3150
3201
  if (owner) configAttrs.owner = owner;
3151
3202
  if (sla) configAttrs.sla = sla;
3203
+ if (connector) configAttrs.connector = connector;
3204
+ if (action) configAttrs.action = action;
3205
+ if (flowableType) configAttrs.flowableType = flowableType;
3206
+ if (flowableDelegateExpression) configAttrs.flowableDelegateExpression = flowableDelegateExpression;
3207
+ if (decisionRef) configAttrs.decisionRef = decisionRef;
3208
+ if (formKey) configAttrs.formKey = formKey;
3152
3209
  const taskConfig = moddle.create("aranza:TaskConfig", configAttrs);
3153
3210
  return moddle.create("bpmn:ExtensionElements", { values: [taskConfig] });
3154
3211
  }
@@ -3324,6 +3381,28 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
3324
3381
  if (elementType === "CallActivity" && node.data.calledElement) {
3325
3382
  attrs.calledElement = node.data.calledElement;
3326
3383
  }
3384
+ if (elementType === "ScriptTask") {
3385
+ const scriptFormat = typeof node.data.scriptFormat === "string" ? node.data.scriptFormat : void 0;
3386
+ const script = typeof node.data.script === "string" ? node.data.script : void 0;
3387
+ if (scriptFormat) attrs.scriptFormat = scriptFormat;
3388
+ if (script) attrs.script = script;
3389
+ }
3390
+ if (elementType === "UserTask") {
3391
+ const fk = typeof node.data.formKey === "string" ? node.data.formKey : void 0;
3392
+ if (fk) attrs.$attrs = { "flowable:formKey": fk };
3393
+ }
3394
+ if (elementType === "ServiceTask") {
3395
+ const flowableAttrs = {};
3396
+ const flowableType = typeof node.data.flowableType === "string" ? node.data.flowableType : void 0;
3397
+ const flowableDelegateExpression = typeof node.data.flowableDelegateExpression === "string" ? node.data.flowableDelegateExpression : void 0;
3398
+ const connector = typeof node.data.connector === "string" ? node.data.connector : void 0;
3399
+ if (connector) flowableAttrs["flowable:type"] = "http";
3400
+ if (flowableType) flowableAttrs["flowable:type"] = flowableType;
3401
+ if (flowableDelegateExpression) {
3402
+ flowableAttrs["flowable:delegateExpression"] = flowableDelegateExpression;
3403
+ }
3404
+ if (Object.keys(flowableAttrs).length > 0) attrs.$attrs = flowableAttrs;
3405
+ }
3327
3406
  const aranzaConfig = buildAranzaExtensionElements(moddle, node);
3328
3407
  if (aranzaConfig) attrs.extensionElements = aranzaConfig;
3329
3408
  const isSubProcess2 = elementType === "SubProcess" || elementType === "Transaction" || elementType === "EventSubProcess" || elementType === "AdHocSubProcess";
@@ -3332,6 +3411,11 @@ function buildFlowElement(moddle, node, allNodes, allEdges) {
3332
3411
  if (elementType === "EventSubProcess" || node.data.subProcessVariant === "event") {
3333
3412
  attrs.triggeredByEvent = true;
3334
3413
  }
3414
+ if (elementType === "AdHocSubProcess" && typeof node.data.completionCondition === "string" && node.data.completionCondition.trim()) {
3415
+ attrs.completionCondition = moddle.create("bpmn:FormalExpression", {
3416
+ body: node.data.completionCondition.trim()
3417
+ });
3418
+ }
3335
3419
  }
3336
3420
  const element = moddle.create(moddleType, attrs);
3337
3421
  return element;