### Install Project Dependencies Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/README.md Run this command to install all necessary dependencies for the project. ```sh npm install ``` -------------------------------- ### Example: Checking Timer Expression Support Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Illustrates how to check if 'timeCycle', 'timeDuration', or 'timeDate' expressions are valid for a start event, considering its configuration. ```javascript const startEvent = elementRegistry.get('StartEvent_1'); const supportsCycle = isTimerExpressionTypeSupported('timeCycle', startEvent); // May be true or false depending on interrupting property const supportsDuration = isTimerExpressionTypeSupported('timeDuration', startEvent); // True if parent is event sub-process, false otherwise const supportsDate = isTimerExpressionTypeSupported('timeDate', startEvent); // True for start events ``` -------------------------------- ### Basic Setup for Camunda Cloud (Zeebe) Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Initialize a BpmnModeler with Camunda Cloud behaviors and Zeebe moddle. This setup is required for Zeebe-specific features. ```javascript import BpmnModeler from 'bpmn-js/lib/Modeler'; import camundaCloudBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-cloud'; import zeebeModdle from 'zeebe-bpmn-moddle'; const bpmnModeler = new BpmnModeler({ container: document.getElementById('canvas'), additionalModules: [ camundaCloudBehaviors, zeebeModdle // Required for zeebe: namespace support ] }); // Load a diagram const xmlString = await fetch('process.bpmn').then(r => r.text()); await bpmnModeler.importXML(xmlString); ``` -------------------------------- ### Basic Setup with Camunda Cloud Behaviors Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Initialize a bpmn-js modeler with Camunda Cloud behaviors and Zeebe moddle. This setup is required before importing any XML. ```javascript import BpmnModeler from 'bpmn-js/lib/Modeler'; import camundaCloudBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-cloud'; import zeebeModdle from 'zeebe-bpmn-moddle'; const modeler = new BpmnModeler({ container: '#canvas', additionalModules: [ camundaCloudBehaviors, zeebeModdle ] }); await modeler.importXML(xmlString); ``` -------------------------------- ### Example: Using getInputOutput Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Demonstrates how to retrieve the InputOutput element and then access its input and output parameters using helper functions. ```javascript const businessObject = getBusinessObject(serviceTask); const inputOutput = getInputOutput(businessObject); if (inputOutput) { const inputs = getInputParameters(inputOutput); const outputs = getOutputParameters(inputOutput); } ``` -------------------------------- ### Install camunda-bpmn-js-behaviors Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Install the library using npm. Ensure you also install the appropriate bpmn-js and moddle dependencies for your Camunda version. ```bash npm install camunda-bpmn-js-behaviors ``` ```bash # For Camunda Cloud (Zeebe) npm install bpmn-js zeebe-bpmn-moddle # For Camunda Platform 7 npm install bpmn-js camunda-bpmn-moddle ``` -------------------------------- ### Install camunda-bpmn-js-behaviors Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Install the necessary packages for camunda-bpmn-js-behaviors, bpmn-js, and zeebe-bpmn-moddle using npm. ```bash npm install camunda-bpmn-js-behaviors bpmn-js zeebe-bpmn-moddle ``` -------------------------------- ### Basic Setup for Camunda Platform 7 Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Initialize a BpmnModeler with Camunda Platform 7 behaviors and moddle. This setup is required for Camunda 7-specific features. ```javascript import BpmnModeler from 'bpmn-js/lib/Modeler'; import camundaPlatformBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-platform'; import camundaModdle from 'camunda-bpmn-moddle'; const bpmnModeler = new BpmnModeler({ container: document.getElementById('canvas'), additionalModules: [ camundaPlatformBehaviors, camundaModdle // Required for camunda: namespace support ] }); await bpmnModeler.importXML(xmlString); ``` -------------------------------- ### Dependency Injection Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Demonstrates how to use dependency injection with CommandInterceptor in JavaScript. Ensure dependencies are correctly listed in the $inject property. ```javascript class MyBehavior extends CommandInterceptor { constructor(eventBus, modeling, bpmnFactory) { ... } } MyBehavior.$inject = ['eventBus', 'modeling', 'bpmnFactory']; ``` -------------------------------- ### User Task Extension Elements Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md An example of BPMN extension elements for a User Task, including form definition, assignment, and task listeners. The library automatically manages these elements. ```xml ``` -------------------------------- ### Example: Accessing Timer Event Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Demonstrates retrieving a timer event definition and accessing its timeCycle, timeDate, or timeDuration properties. ```javascript const boundaryEvent = elementRegistry.get('BoundaryEvent_Timer'); const timerDef = getTimerEventDefinition(boundaryEvent); if (timerDef) { const timeCycle = timerDef.get('timeCycle'); const timeDate = timerDef.get('timeDate'); const timeDuration = timerDef.get('timeDuration'); } ``` -------------------------------- ### Get Form Definition Usage Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Example of how to import and use the getFormDefinition function to retrieve form details from a user task. ```javascript import { getFormDefinition } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/FormsUtil'; const formDef = getFormDefinition(userTask); // formDef.get('formId') // formDef.get('formKey') // formDef.get('externalReference') ``` -------------------------------- ### Example Usage for CleanUpBusinessRuleTaskBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Illustrates switching a business rule task from a decision invocation to a task definition by updating its moddle properties. ```javascript const brtask = elementRegistry.get('BusinessRuleTask_1'); const extensionElements = getBusinessObject(brtask).get('extensionElements'); // Switching from decision to task definition modeling.updateModdleProperties(brtask, extensionElements, { values: values.filter(v => !is(v, 'zeebe:CalledDecision')).concat(taskDefinitionElement) }); ``` -------------------------------- ### Example: Removing Empty InputOutput Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Shows how to check if an InputOutput element is empty using `isInputOutputEmpty` and then remove it if it is, preventing unnecessary elements in the model. ```javascript const inputOutput = getInputOutput(businessObject); if (isInputOutputEmpty(inputOutput)) { // Safe to remove empty InputOutput extension element removeExtensionElements(element, businessObject, inputOutput, commandStack); } ``` -------------------------------- ### User Task Form Key Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Demonstrates setting a form key for a user task, which automatically removes any existing form reference properties. ```javascript const userTask = elementRegistry.get('UserTask_1'); const businessObject = getBusinessObject(userTask); // Setting form key removes form ref properties modeling.updateModdleProperties(userTask, businessObject, { 'camunda:formKey': 'embedded:app:forms/myForm.html' }); // Result: camunda:formRef, camunda:formRefBinding, and camunda:formRefVersion are removed ``` -------------------------------- ### Create Zeebe User Task Behavior Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Demonstrates how to create a User Task using the modeling service. The `camundaCloudBehaviors` module automatically adds the `zeebe:UserTask` extension element. ```javascript const bpmnModeler = new BpmnModeler({ additionalModules: [camundaCloudBehaviors] }); const canvas = bpmnModeler.get('canvas'); const modeling = bpmnModeler.get('modeling'); const userTask = modeling.createShape( { type: 'bpmn:UserTask' }, { x: 200, y: 100 }, canvas.getRootElement() ); // zeebe:UserTask is automatically created with extension elements ``` -------------------------------- ### Example Usage for CleanUpAdHocSubProcessBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Demonstrates how adding a TaskDefinition to an ad-hoc subprocess automatically removes ad-hoc specific properties like completionCondition. ```javascript const adHocSubProcess = elementRegistry.get('AdHocSubProcess_1'); const extensionElements = getBusinessObject(adHocSubProcess).get('extensionElements'); // Adding TaskDefinition automatically removes ad-hoc specific properties modeling.updateModdleProperties(adHocSubProcess, extensionElements, { values: [...values, taskDefinitionElement] }); ``` -------------------------------- ### Example: Accessing Called Element Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Demonstrates how to retrieve a called element from a call activity and access its process ID and variable propagation settings. ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const calledElement = getCalledElement(callActivity); if (calledElement) { const processId = calledElement.get('processId'); const propagate = calledElement.get('propagateAllChildVariables'); } ``` -------------------------------- ### Command Stack Operations Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md Illustrates basic command stack operations for undoing and redoing actions. Behaviors are integrated into the command execution lifecycle to maintain data consistency. ```javascript commandStack.execute('shape.delete', { shape }); commandStack.undo(); commandStack.redo(); ``` -------------------------------- ### User Task Form Ref Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Demonstrates setting a form reference for a user task, which automatically removes the form key property. ```javascript const userTask = elementRegistry.get('UserTask_1'); const businessObject = getBusinessObject(userTask); // Setting form ref removes form key modeling.updateModdleProperties(userTask, businessObject, { 'camunda:formRef': 'myForm', 'camunda:formRefBinding': 'latest' }); // Result: camunda:formKey is removed ``` -------------------------------- ### Example: Checking Variable Propagation Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Shows how to determine if a call activity is configured to propagate all child variables. The result reflects explicit settings or the default behavior. ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const shouldPropagate = isPropagateAllChildVariables(callActivity); // Default: true if call activity has no output parameters defined // If explicitly set, returns the set value ``` -------------------------------- ### Called Element Utility Usage Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Demonstrates importing and using functions to get called element information and check variable propagation settings. ```javascript import { getCalledElement, isPropagateAllChildVariables } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/CalledElementUtil'; const called = getCalledElement(callActivity); const shouldPropagate = isPropagateAllChildVariables(callActivity); ``` -------------------------------- ### Manage Input/Output Parameters (Camunda Cloud) Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Use this snippet to get, create, or modify input and output parameters for Call Activities in Camunda Cloud. It handles creating the IoMapping if it doesn't exist and adding new input parameters. ```javascript import { getIoMapping, getInputParameters, getOutputParameters, createIoMapping } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/InputOutputUtil'; const callActivity = elementRegistry.get('CallActivity_1'); let ioMapping = getIoMapping(callActivity); // Create IoMapping if it doesn't exist if (!ioMapping) { const extElements = getExtensionElementsList(callActivity)[0] || createElement('bpmn:ExtensionElements', { values: [] }, getBusinessObject(callActivity), bpmnFactory); ioMapping = createIoMapping(extElements, bpmnFactory, { 'zeebe:inputParameters': [], 'zeebe:outputParameters': [] }); modeling.updateModdleProperties(callActivity, extElements, { values: [...extElements.get('values'), ioMapping] }); } // Add input parameter const inputParam = bpmnFactory.create('zeebe:InputParameter', { name: 'variable1', value: '${myVar}' }); const inputs = getInputParameters(callActivity); modeling.updateModdleProperties(callActivity, ioMapping, { 'zeebe:inputParameters': [...inputs, inputParam] }); // Handle variable propagation import { isPropagateAllChildVariables } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/CalledElementUtil'; const shouldPropagate = isPropagateAllChildVariables(callActivity); if (!shouldPropagate) { // Has explicit output mappings - modify them const outputs = getOutputParameters(callActivity); // ... } else { // All child variables propagated - no output mappings needed } ``` -------------------------------- ### Get Output Parameters from IoMapping Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves all output parameters from an element's IoMapping. Use this to access and process defined outputs. ```javascript function getOutputParameters(element) ``` ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const outputs = getOutputParameters(callActivity); outputs.forEach(output => { console.log('Output target:', output.get('target')); console.log('Output expression:', output.get('source')); }); ``` -------------------------------- ### Moddle Element Access Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md Shows how to access and update moddle elements using the bpmn-moddle library. Behaviors interact with both diagram elements and moddle elements. ```javascript const businessObject = getBusinessObject(element); const extElements = businessObject.get('extensionElements'); modeling.updateModdleProperties(element, bo, { prop: value }); ``` -------------------------------- ### Get Input Parameters from IoMapping Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves all input parameters from an element's IoMapping. Useful for iterating through and processing all defined inputs. ```javascript function getInputParameters(element) ``` ```javascript const serviceTask = elementRegistry.get('ServiceTask_1'); const inputs = getInputParameters(serviceTask); inputs.forEach(input => { console.log('Input name:', input.get('name')); console.log('Input value:', input.get('value')); }); ``` -------------------------------- ### Canvas Service Methods Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Provides access to the diagram's viewport and the root element. Use `getContainer` to get the HTML element hosting the canvas. ```javascript getRootElement(): Shape ``` ```javascript setRootElement(element: Shape) ``` ```javascript getContainer(): HTMLElement ``` -------------------------------- ### Update Input/Output Parameters Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Example of how to update input and output parameters for a service task using the modeling service. This involves retrieving the business object and modifying its inputParameters and outputParameters properties. ```javascript const serviceTask = elementRegistry.get('ServiceTask_1'); const businessObject = getBusinessObject(serviceTask); // Updating input/output parameters const inputOutput = getInputOutput(businessObject); modeling.updateModdleProperties(serviceTask, inputOutput, { inputParameters: [ { name: 'variable1', value: '${execution.getVariable("var1")}' } ], outputParameters: [] }); ``` -------------------------------- ### Get IoMapping from Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the zeebe:IoMapping extension element from a given BPMN element. Use this to access input and output parameters associated with an element. ```javascript function getIoMapping(element) ``` ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const ioMapping = getIoMapping(callActivity); if (ioMapping) { const inputs = ioMapping.get('zeebe:inputParameters'); const outputs = ioMapping.get('zeebe:outputParameters'); } ``` -------------------------------- ### Manage Extension Elements Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Use these functions to get, check, create, and remove extension elements from BPMN elements. Ensure you have the necessary factory and command stack instances. ```javascript // Get and check const taskDef = getExtensionElementsList(element, 'zeebe:TaskDefinition')[0]; if (!taskDef) { // Create it const ext = getExtensionElementsList(element, 'bpmn:ExtensionElements')[0]; const newTaskDef = createElement('zeebe:TaskDefinition', {}, ext, factory); } // Remove it if (taskDef) { removeExtensionElements(element, businessObject, taskDef, commandStack); } ``` -------------------------------- ### bpmn:Event Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Base type for various BPMN events (start, end, intermediate, boundary). Includes standard event properties and async configurations. ```javascript { id: string, name: string, eventDefinitions: Array, asyncBefore: boolean, asyncAfter: boolean, extensionElements: bpmn:ExtensionElements } ``` -------------------------------- ### Example: Cleanup Error Event Definition Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Demonstrates how camunda:errorCodeVariable and camunda:errorMessageVariable are removed when an error event definition is updated to an empty array. ```javascript const endEvent = elementRegistry.get('EndEvent_Error'); const businessObject = getBusinessObject(endEvent); // When removing error event definition, camunda properties are cleaned up modeling.updateModdleProperties(endEvent, businessObject, { eventDefinitions: [] }); // Result: camunda:errorCodeVariable and camunda:errorMessageVariable are removed ``` -------------------------------- ### Get Form Definition from Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the zeebe:FormDefinition extension element from a given BPMN element. Use this to access form details associated with user tasks or start events. ```javascript function getFormDefinition(element) ``` ```javascript const userTask = elementRegistry.get('UserTask_1'); const formDef = getFormDefinition(userTask); if (formDef) { const formId = formDef.get('formId'); const formKey = formDef.get('formKey'); const externalRef = formDef.get('externalReference'); } ``` -------------------------------- ### Import Camunda Cloud Behaviors Module Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Import the behaviors module for Camunda Cloud (Zeebe) environments. ```javascript // For Camunda Cloud (Zeebe) import behaviors from 'camunda-bpmn-js-behaviors/lib/camunda-cloud'; ``` -------------------------------- ### Input/Output Parameter Utility Usage Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Shows how to import and use utility functions to retrieve input and output parameters for a call activity. ```javascript import { getInputParameters, getOutputParameters } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/InputOutputUtil'; const inputs = getInputParameters(callActivity); const outputs = getOutputParameters(callActivity); ``` -------------------------------- ### getFormDefinition Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the zeebe:FormDefinition extension element from a given diagram element, typically a user task or start event. ```APIDOC ## getFormDefinition ### Description Retrieves the zeebe:FormDefinition extension element from a diagram element. ### Method ```javascript function getFormDefinition(element) ``` ### Parameters #### Path Parameters - **element** (djs.model.Base) - Required - User task or start event element ### Response #### Success Response - **ModdleElement | undefined** - The FormDefinition element or undefined ### Request Example ```javascript const userTask = elementRegistry.get('UserTask_1'); const formDef = getFormDefinition(userTask); if (formDef) { const formId = formDef.get('formId'); const formKey = formDef.get('formKey'); const externalRef = formDef.get('externalReference'); } ``` ``` -------------------------------- ### Get Timer Event Definition Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the bpmn:TimerEventDefinition from a timer event element. Returns the definition or null if not found. ```javascript function getTimerEventDefinition(element) ``` -------------------------------- ### createIoMapping Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Creates a new zeebe:IoMapping extension element. This function is used to programmatically add input and output mapping configurations to elements. ```APIDOC ## createIoMapping ### Description Creates a new zeebe:IoMapping extension element. ### Signature ```javascript function createIoMapping(parent, bpmnFactory, properties) ``` ### Parameters #### Path Parameters - **parent** (ModdleElement) - Required - Parent element (typically extensionElements) - **bpmnFactory** (BpmnFactory) - Required - BPMN factory for creating elements - **properties** (object) - Required - Initial properties (typically { 'zeebe:inputParameters': [], 'zeebe:outputParameters': [] }) ### Returns - **ModdleElement** - The newly created IoMapping element ### Example ```javascript const extensionElements = getExtensionElementsList(task)[0]; const ioMapping = createIoMapping(extensionElements, bpmnFactory, { 'zeebe:inputParameters': [], 'zeebe:outputParameters': [] }); ``` ``` -------------------------------- ### CreateZeebeUserTaskBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes user task elements with default Zeebe configurations, automatically adding a `zeebe:UserTask` extension element. ```APIDOC ## CreateZeebeUserTaskBehavior ### Description Initializes user task elements with default Zeebe configurations. ### Constructor `new CreateZeebeUserTaskBehavior(bpmnFactory, eventBus, modeling)` ### Behavior - Automatically adds `zeebe:UserTask` extension element when a user task is created - Creates extension elements container if needed - Can be disabled via `createElementsBehavior: false` hint ### Example Usage ```javascript const bpmnModeler = new BpmnModeler({ additionalModules: [camundaCloudBehaviors] }); const canvas = bpmnModeler.get('canvas'); const modeling = bpmnModeler.get('modeling'); const userTask = modeling.createShape( { type: 'bpmn:UserTask' }, { x: 200, y: 100 }, canvas.getRootElement() ); // zeebe:UserTask is automatically created with extension elements ``` ``` -------------------------------- ### Import Camunda Cloud or Camunda Platform Behaviors Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md Import only one of these modules to include the respective behaviors. Do not import both simultaneously. ```javascript // Use ONLY ONE of these, never both together import camundaCloudBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-cloud'; import camundaPlatformBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-platform'; ``` -------------------------------- ### Constructor for CleanUpSubscriptionBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes the behavior with event bus and modeling services for managing subscription cleanup. ```javascript new CleanUpSubscriptionBehavior(eventBus, modeling) ``` -------------------------------- ### CreateZeebeScriptTaskBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes script task elements with default Zeebe configurations, automatically adding a `zeebe:TaskDefinition` extension element. ```APIDOC ## CreateZeebeScriptTaskBehavior ### Description Initializes script task elements with default Zeebe configurations. ### Constructor `new CreateZeebeScriptTaskBehavior(bpmnFactory, eventBus, modeling)` ### Behavior - Automatically adds `zeebe:TaskDefinition` extension element when a script task is created ``` -------------------------------- ### ElementRegistry Get Method Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Retrieves a diagram element by its unique ID. Use this service to access specific elements within the diagram. ```javascript get(id: string): djs.model.Base | undefined ``` ```javascript const elementRegistry = bpmnModeler.get('elementRegistry'); const userTask = elementRegistry.get('UserTask_1'); ``` -------------------------------- ### Run Lint and Tests Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/README.md Execute this command to perform linting and run tests once. ```sh npm run all ``` -------------------------------- ### Implementing a Custom Behavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Extend the library by creating and registering your own custom behaviors. This allows for custom logic to be integrated into the modeling process. ```javascript import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor'; class MyCustomBehavior extends CommandInterceptor { constructor(eventBus) { super(eventBus); this.postExecute('element.updateModdleProperties', (context) => { // Your custom logic }, true); } } MyCustomBehavior.$inject = ['eventBus']; const modeler = new BpmnModeler({ additionalModules: [ camundaCloudBehaviors, { myCustomBehavior: ['type', MyCustomBehavior] } ] }); ``` -------------------------------- ### Set Call Activity Variables Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md This code demonstrates how to set input and output parameters for a Call Activity. It includes logic to create the IoMapping element if it does not already exist. ```javascript import { getIoMapping, getOutputParameters, createIoMapping } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/InputOutputUtil'; const callActivity = elementRegistry.get('CallActivity_1'); let ioMapping = getIoMapping(callActivity); // Create IoMapping if missing if (!ioMapping) { const extElements = getExtensionElementsList(callActivity)[0]; ioMapping = createIoMapping(extElements, bpmnFactory, { 'zeebe:inputParameters': [], 'zeebe:outputParameters': [] }); modeling.updateModdleProperties(callActivity, extElements, { values: [...extElements.get('values'), ioMapping] }); } // Add output mapping const outputs = getOutputParameters(callActivity); const newOutput = bpmnFactory.create('zeebe:OutputParameter', { target: 'result', source: '= subprocessOutput' }); modeling.updateModdleProperties(callActivity, ioMapping, { 'zeebe:outputParameters': [...outputs, newOutput] }); ``` -------------------------------- ### CreateZeebeCallActivityBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes call activity elements with default Zeebe configurations, automatically adding a `zeebe:CalledElement` extension element. ```APIDOC ## CreateZeebeCallActivityBehavior ### Description Initializes call activity elements with default Zeebe configurations. ### Constructor `new CreateZeebeCallActivityBehavior(bpmnFactory, eventBus, modeling)` ### Behavior - Automatically adds `zeebe:CalledElement` extension element when a call activity is created ``` -------------------------------- ### Get Output Parameters Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves an array of output parameter elements from a given camunda:InputOutput element. Ensure the InputOutput element is valid before calling. ```javascript function getOutputParameters(inputOutput) ``` -------------------------------- ### Import Camunda Cloud Behaviors Module Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Import the `camundaCloudBehaviors` module and include it in the `additionalModules` when initializing a BpmnModeler instance. ```javascript import camundaCloudBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-cloud'; const bpmnModeler = new BpmnModeler({ container: '#container', additionalModules: [ camundaCloudBehaviors ] }); ``` -------------------------------- ### Get Input Parameters Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves an array of input parameter elements from a given camunda:InputOutput element. Ensure the InputOutput element is valid before calling. ```javascript function getInputParameters(inputOutput) ``` -------------------------------- ### Get Specific Output Parameter Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves a single output parameter from an element's IoMapping by its 0-based index. Returns undefined if the index is out of bounds. ```javascript function getOutputParameter(element, index) ``` -------------------------------- ### Constructor for CleanUpJobPriorityDefinitionBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes the behavior with necessary services like eventBus and modeling. ```javascript new CleanUpJobPriorityDefinitionBehavior(eventBus, modeling) ``` -------------------------------- ### Get Specific Input Parameter Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves a single input parameter from an element's IoMapping by its 0-based index. Returns undefined if the index is out of bounds. ```javascript function getInputParameter(element, index) ``` -------------------------------- ### CreateZeebeBusinessRuleTaskBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes business rule task elements with default Zeebe configurations, automatically adding a `zeebe:CalledDecision` extension element. ```APIDOC ## CreateZeebeBusinessRuleTaskBehavior ### Description Initializes business rule task elements with default Zeebe configurations. ### Constructor `new CreateZeebeBusinessRuleTaskBehavior(bpmnFactory, eventBus, modeling)` ### Behavior - Automatically adds `zeebe:CalledDecision` extension element when a business rule task is created - Creates extension elements container if needed - Can be disabled via `createElementsBehavior: false` hint on context ``` -------------------------------- ### Import Camunda Platform Behaviors Module Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Import the behaviors module for Camunda Platform 7 environments. Do not import both Camunda Cloud and Camunda Platform behaviors simultaneously. ```javascript // For Camunda Platform 7 import behaviors from 'camunda-bpmn-js-behaviors/lib/camunda-platform'; ``` -------------------------------- ### Delete Last Participant Behavior Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Illustrates how deleting the last participant in a collaboration preserves the `isExecutable` flag by transferring it to the new root process element. ```javascript const collaboration = canvas.getRootElement(); // bpmn:Collaboration const participant = elementRegistry.get('Participant_1'); // Deleting the last participant converts to process and preserves isExecutable modeling.removeShape(participant); // Result: new root process has isExecutable = true/false based on participant's process ``` -------------------------------- ### Create IoMapping Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Creates a new zeebe:IoMapping extension element. This function requires the parent element, a BPMN factory, and initial properties for inputs and outputs. ```javascript function createIoMapping(parent, bpmnFactory, properties) ``` ```javascript const extensionElements = getExtensionElementsList(task)[0]; const ioMapping = createIoMapping(extensionElements, bpmnFactory, { 'zeebe:inputParameters': [], 'zeebe:outputParameters': [] }); ``` -------------------------------- ### Create User Task with Auto-Configuration (Zeebe) Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Create a user task element. Camunda Cloud behaviors automatically configure the zeebe:UserTask extension element and its associated form infrastructure. ```javascript const modeling = bpmnModeler.get('modeling'); const canvas = bpmnModeler.get('canvas'); // Create a user task (Zeebe only) const userTaskShape = modeling.createShape( { type: 'bpmn:UserTask', label: 'My User Task' }, { x: 200, y: 100 }, canvas.getRootElement() ); // Zeebe behaviors automatically: // - Create zeebe:UserTask extension element // - Create bpmn:ExtensionElements container if needed // - Set up form infrastructure ``` -------------------------------- ### Get All Called Elements Extension Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves all zeebe:CalledElement extension elements from a call activity. This is useful when a call activity might invoke multiple processes. ```javascript function getCalledElements(element) ``` -------------------------------- ### Get Called Element Extension Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the zeebe:CalledElement extension element from a call activity. Use this to access properties like processId or propagation settings. ```javascript function getCalledElement(element) ``` -------------------------------- ### zeebe:IoMapping Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Defines the structure for input and output parameter mappings in Zeebe. ```javascript { 'zeebe:inputParameters': Array, 'zeebe:outputParameters': Array } ``` -------------------------------- ### Create Call Activity with Auto-Configuration (Zeebe) Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Create a call activity element. Camunda Cloud behaviors automatically configure the zeebe:CalledElement extension element. ```javascript const modeling = bpmnModeler.get('modeling'); const canvas = bpmnModeler.get('canvas'); // Create a call activity (Zeebe) const callActivityShape = modeling.createShape( { type: 'bpmn:CallActivity', label: 'Call Subprocess' }, { x: 400, y: 100 }, canvas.getRootElement() ); // Zeebe behaviors automatically: // - Create zeebe:CalledElement extension element ``` -------------------------------- ### Get Event Definition by Type Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves a specific event definition from an event element. Use this to access properties of timer, conditional, or message event definitions. ```javascript function getEventDefinition(element, type) ``` ```javascript // Check for timer event definition const timerEvent = getEventDefinition(boundaryEvent, 'bpmn:TimerEventDefinition'); if (timerEvent) { const timeCycle = timerEvent.get('timeCycle'); } // Check for conditional event const conditionalEvent = getEventDefinition(catchEvent, 'bpmn:ConditionalEventDefinition'); // Check for message event const messageEvent = getEventDefinition(startEvent, 'bpmn:MessageEventDefinition'); ``` -------------------------------- ### RemoveInitiatorBehaviour Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Manages the cleanup of initiator variables when element types change. It ensures that the 'camunda:initiator' variable is correctly handled, particularly for start events and user tasks. ```APIDOC ## RemoveInitiatorBehaviour ### Description Manages cleanup of initiator variables when element types change. It removes `camunda:initiator` when a start event is replaced with a non-start-event type and ensures it's only present on user task start events. ### Constructor `new RemoveInitiatorBehaviour(eventBus, modeling)` #### Parameters * **eventBus** (EventBus) - Required - Event bus for command lifecycle hooks * **modeling** (Modeling) - Required - Modeling service for updating properties ``` -------------------------------- ### getIoMapping Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the zeebe:IoMapping extension element from a given diagram element. This function is useful for accessing the input and output parameter configurations associated with an element. ```APIDOC ## getIoMapping ### Description Retrieves the zeebe:IoMapping extension element from an element. ### Signature ```javascript function getIoMapping(element) ``` ### Parameters #### Path Parameters - **element** (djs.model.Base | ModdleElement) - Required - The diagram element ### Returns - **ModdleElement | undefined** - The IoMapping element or undefined ### Example ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const ioMapping = getIoMapping(callActivity); if (ioMapping) { const inputs = ioMapping.get('zeebe:inputParameters'); const outputs = ioMapping.get('zeebe:outputParameters'); } ``` ``` -------------------------------- ### Get camunda:InputOutput Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves the camunda:InputOutput extension element from a process element's business object. Use this to access input and output parameters. ```javascript function getInputOutput(businessObject) ``` -------------------------------- ### Manage Input/Output Parameters (Camunda Platform 7) Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md This snippet demonstrates how to access and modify input and output parameters for Service Tasks in Camunda Platform 7. It shows how to retrieve existing parameters and add new ones. ```javascript import { getInputOutput, getInputParameters, getOutputParameters } from 'camunda-bpmn-js-behaviors/lib/camunda-platform/util/InputOutputUtil'; const serviceTask = elementRegistry.get('ServiceTask_1'); const businessObject = getBusinessObject(serviceTask); let inputOutput = getInputOutput(businessObject); if (inputOutput) { const inputs = getInputParameters(inputOutput); const outputs = getOutputParameters(inputOutput); // Modify parameters const newInput = bpmnFactory.create('camunda:InputParameter', { name: 'variable1' }); modeling.updateModdleProperties(serviceTask, inputOutput, { inputParameters: [...inputs, newInput] }); } ``` -------------------------------- ### Get User Task Form Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves a zeebe:UserTaskForm element referenced by a form definition. Optionally search for a specific form key or root element. ```javascript function getUserTaskForm(element, options = {}) ``` ```javascript const userTask = elementRegistry.get('UserTask_1'); const userTaskForm = getUserTaskForm(userTask); if (userTaskForm) { const formBody = userTaskForm.get('body'); const formId = userTaskForm.get('id'); } // Search with specific form key const customForm = getUserTaskForm(userTask, { formKey: 'camunda-forms:bpmn:UserTaskForm_1' }); ``` -------------------------------- ### CommandInterceptor Pattern Flow Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Illustrates the lifecycle of a command within the CommandInterceptor pattern, showing the sequence of hooks and UI updates. ```text User Action ↓ Command created (e.g., shape.create) ↓ preExecute hooks (validate/modify) ↓ Command executes (model changes) ↓ postExecute hooks (immediate cleanup) ↓ Command recorded (undo/redo stack) ↓ postExecuted hooks (final sync) ↓ UI updates ``` -------------------------------- ### Create and Update User Task Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Demonstrates creating a user task and updating its form definition. Conflicting properties are automatically handled, and elements are cleaned up on removal. ```javascript // Create a user task (zeebe:UserTask automatically added) const shape = modeling.createShape( { type: 'bpmn:UserTask', label: 'My Task' }, { x: 100, y: 100 }, canvas.getRootElement() ); // Set form (conflicting properties automatically removed) const businessObject = getBusinessObject(shape); const formDef = getExtensionElementsList(shape, 'zeebe:FormDefinition')[0]; modeling.updateModdleProperties(shape, formDef, { formId: 'myForm', bindingType: 'latest' }); // Result: formKey and externalReference are automatically cleared // Delete element (form and properties automatically cleaned up) modeling.removeShape(shape); // Result: orphaned zeebe:UserTaskForm removed, extension elements cleaned up ``` -------------------------------- ### Get Extension Elements List Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves extension elements from a BPMN element, optionally filtered by type. Returns an array of matching elements or an empty array if none are found. ```javascript function getExtensionElementsList(element, type = undefined) ``` ```javascript // Get all extension elements const allExtensions = getExtensionElementsList(userTask); // Get specific extension element type const taskDefinitions = getExtensionElementsList(userTask, 'zeebe:TaskDefinition'); const formDefinitions = getExtensionElementsList(userTask, 'zeebe:FormDefinition'); // Access the first of a type const formDef = getExtensionElementsList(userTask, 'zeebe:FormDefinition')[0]; ``` -------------------------------- ### Import Camunda Platform Specific Utility Functions Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Import utility functions specific to Camunda Platform for handling input and output. ```javascript // Platform-specific utilities import { getInputOutput, isInputOutputEmpty } from 'camunda-bpmn-js-behaviors/lib/camunda-platform/util/InputOutputUtil'; ``` -------------------------------- ### camunda:ExecutionListener Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Defines a listener for process execution events. Specify the event type ('start' or 'end') and the execution logic via expression, delegate expression, class, or script. ```javascript { event: string, // 'start' | 'end' expression: string, delegateExpression: string, class: string, script: camunda:Script } ``` -------------------------------- ### Import Camunda Platform Behaviors Module Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Import the camundaPlatformBehaviors module and include it in the bpmnModeler's additionalModules. ```javascript import camundaPlatformBehaviors from 'camunda-bpmn-js-behaviors/lib/camunda-platform'; const bpmnModeler = new BpmnModeler({ container: '#container', additionalModules: [ camundaPlatformBehaviors ] }); ``` -------------------------------- ### Get Root Element of BPMN Element Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Traverses up the element hierarchy from any BPMN element to find and return the root bpmn:Process element. This is useful for accessing process-level properties or elements. ```javascript function getRootElement(element) ``` ```javascript const userTask = elementRegistry.get('UserTask_1'); const root = getRootElement(userTask); // Returns the bpmn:Process that contains userTask // Get all forms defined at process root const allForms = getExtensionElementsList(root, 'zeebe:UserTaskForm'); ``` -------------------------------- ### CallActivityVariablesPropagationBehavior Example Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Demonstrates how setting `propagateAllChildVariables` to `true` on a call activity's `zeebe:CalledElement` automatically removes all `zeebe:Output` elements. This enforces mutual exclusivity between variable propagation strategies. ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const calledElement = getExtensionElementsList(callActivity, 'zeebe:CalledElement')[0]; // Setting propagateAllChildVariables to true removes output parameters modeling.updateModdleProperties(callActivity, calledElement, { propagateAllChildVariables: true }); // Result: all zeebe:Output elements are removed from zeebe:IoMapping ``` -------------------------------- ### CommandStack Service Methods Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Manages the undo and redo functionality for diagram operations. Use `execute` to perform actions and `canUndo`/`canRedo` to check availability. ```javascript execute(command, context) ``` ```javascript undo() ``` ```javascript redo() ``` ```javascript canUndo(): boolean ``` ```javascript canRedo(): boolean ``` -------------------------------- ### FormsBehavior Example Usage Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md The FormsBehavior automatically manages Zeebe form definitions during modeler operations like importing XML, creating user tasks, or updating form properties. It ensures correct creation, referencing, and cleanup of forms. ```javascript const modeler = new BpmnModeler({ additionalModules: [camundaCloudBehaviors] }); // FormsBehavior automatically manages forms during these operations: await modeler.importXML(xmlString); modeling.createShape({ type: 'bpmn:UserTask' }, { x: 100, y: 100 }); modeling.updateModdleProperties(userTask, formDefinition, { formId: 'form_123', bindingType: 'latest' }); ``` -------------------------------- ### Import Shared Utility Functions Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Import shared utility functions for managing extension elements, creating elements, and handling event definitions. ```javascript // Shared utilities import { getExtensionElementsList, removeExtensionElements } from 'camunda-bpmn-js-behaviors/lib/util/ExtensionElementsUtil'; import { createElement } from 'camunda-bpmn-js-behaviors/lib/util/ElementUtil'; import { getEventDefinition } from 'camunda-bpmn-js-behaviors/lib/util/EventDefinition'; import { getPrefixedId } from 'camunda-bpmn-js-behaviors/lib/util/IdsUtil'; ``` -------------------------------- ### Constructor for CleanUpBusinessRuleTaskBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes the behavior with the command stack and event bus. This behavior enforces mutual exclusivity between decision invocation and task definition modes. ```javascript new CleanUpBusinessRuleTaskBehavior(commandStack, eventBus) ``` -------------------------------- ### Create User Task Command Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md Illustrates the command used to create a new user task shape in the diagram. Behaviors hook into the 'shape.create' command to add Zeebe-specific extensions and initialize form infrastructure. ```javascript modeling.createShape({ type: 'bpmn:UserTask' }, position, parent) ``` -------------------------------- ### Import Camunda Cloud Specific Utility Functions Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/README.md Import utility functions specific to Camunda Cloud for handling forms, input/output, called elements, and timers. ```javascript // Cloud-specific utilities import { getFormDefinition, getUserTaskForm, getRootElement, isUserTaskFormKey, createUserTaskFormId } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/FormsUtil'; import { getIoMapping, getInputParameters, getOutputParameters, createIoMapping } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/InputOutputUtil'; import { getCalledElement, isPropagateAllChildVariables } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/CalledElementUtil'; import { isTimerExpressionTypeSupported, getTimerEventDefinition, TIMER_PROPERTIES } from 'camunda-bpmn-js-behaviors/lib/camunda-cloud/util/TimerUtil'; ``` -------------------------------- ### Constructor for CleanUpTimerExpressionBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes the behavior with event bus and modeling services for managing timer expressions. ```javascript new CleanUpTimerExpressionBehavior(eventBus, modeling) ``` -------------------------------- ### zeebe:TimerDefinition Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Placeholder for Zeebe-specific timer configuration properties. ```javascript { // Zeebe-specific timer properties } ``` -------------------------------- ### VersionTagBehavior Constructor Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md The VersionTagBehavior is initialized with the event bus and modeling services. These are essential for handling command lifecycle events and updating process definition properties. ```javascript new VersionTagBehavior(eventBus, modeling) ``` -------------------------------- ### bpmn:ExtensionElements Properties Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/types.md Container for platform-specific extension elements, such as zeebe:* or camunda:* properties. ```javascript { values: Array } ``` -------------------------------- ### Dependency Injection with CommandInterceptor Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/architecture-overview.md Behaviors extend CommandInterceptor and use Diji's $inject for dependency injection. Dependencies are automatically resolved when the module is registered. ```javascript class FormsBehavior extends CommandInterceptor { constructor(bpmnFactory, elementRegistry, eventBus, modeling) { ... } } FormsBehavior.$inject = ['bpmnFactory', 'elementRegistry', 'eventBus', 'modeling']; ``` -------------------------------- ### Validating Support Before Modification Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Use utility functions to check if a specific modification is supported before attempting it. This prevents errors and ensures compatibility. ```javascript if (isTimerExpressionTypeSupported('timeCycle', element)) { // Safe to set timeCycle } ``` -------------------------------- ### Handle Async Operations in BPMN Modeling Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/usage-guide.md Manage asynchronous operations in BPMN modeling by either using promise-based command execution for immediate results or by listening to `commandStack.changed` events for confirmation. ```javascript const modeling = bpmnModeler.get('modeling'); const eventBus = bpmnModeler.get('eventBus'); // Method 1: Use promise-based command execution const result = await modeling.updateModdleProperties(element, bo, props); // Method 2: Listen to command completion eventBus.once('commandStack.changed', () => { // Element and model are now in consistent state console.log('Model updated successfully'); }); modeling.updateModdleProperties(element, bo, props); ``` -------------------------------- ### OrderExtensionElementsBehavior Constructor Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-platform-behaviors.md Instantiate OrderExtensionElementsBehavior with an EventBus instance. This behavior ensures consistent ordering of extension elements. ```javascript new OrderExtensionElementsBehavior(eventBus) ``` -------------------------------- ### Constructor for CleanUpMessageRefBehavior Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/camunda-cloud-behaviors.md Initializes the behavior with event bus and modeling services for managing message references. ```javascript new CleanUpMessageRefBehavior(eventBus, modeling) ``` -------------------------------- ### getOutputParameters Source: https://github.com/camunda/camunda-bpmn-js-behaviors/blob/main/_autodocs/api-reference/utility-functions.md Retrieves all output parameters from an element's IoMapping. This function returns an array of output parameter elements, which can be empty if no outputs are defined. ```APIDOC ## getOutputParameters ### Description Retrieves all output parameters from an element's IoMapping. ### Signature ```javascript function getOutputParameters(element) ``` ### Parameters #### Path Parameters - **element** (djs.model.Base | ModdleElement) - Required - The diagram element ### Returns - **Array** - Array of output parameter elements (empty array if none) ### Example ```javascript const callActivity = elementRegistry.get('CallActivity_1'); const outputs = getOutputParameters(callActivity); outputs.forEach(output => { console.log('Output target:', output.get('target')); console.log('Output expression:', output.get('source')); }); ``` ```