ERROR Error: unknown type <camunda:Connector>

Hi folks,

We’re developing a custom properties panel for the Bpmn.io modeler and have an issue creating the elements in the ‘camunda’ namespace.

Quite stuck at the moment so any help is greatly appreciated.

Ours is a Angular 9 project.

The related libraries we import:

    "bpmn-js": "^7.2.0",
    "bpmn-js-properties-panel": "^0.35.0",
    "camunda-bpmn-moddle": "^4.4.0",

The way we create the modeler:

import camundaModdleExtension from 'camunda-bpmn-moddle/lib';
import * as camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';
import * as camundaPropertiesProvider from 'bpmn-js-properties-panel/lib/provider/camunda';
import * as BpmnJS from 'bpmn-js/dist/bpmn-modeler.production.min.js';
// Omitted for brevity
        this.modeler = new BpmnJS({
          container: '#canvas',
          keyboard: {
            bindTo: document
          },
          additionalModules: [
            camundaModdleExtension,
            camundaPropertiesProvider,
            // Also tried the below
            // { ['camundaPropertiesProvider']: ['type', camundaPropertiesProvider.propertiesProvider[1]] },
            // { ['camundaExtensionModule']: ['type', camundaModdleExtension] },
          ],
          moddleExtensions: {
            camunda: camundaModdle
          }
        });

The way we get the moddle and try to create a ‘camunda’ element:

    let modeling = modeler.get('modeling');
    let moddle = modeling._elementFactory._moddle;

    let connector = moddle.create('camunda:Connector', {
    });

The last statement in the code above causes the ERROR Error: unknown type camunda:Connector error.
The ‘bpmn’ elements are created with no issues.

One thing we noticed that may be related - if we print out the moddle we see packages in the registry:

   "registry": {
      "packageMap": {
        "bpmn": {
          "name": "BPMN20",
...
        "bpmndi": {
          "name": "BPMNDI",
...
        "undefined": {
          "default": {
            "name": "Camunda",

Looks like the camunda package is not registered right - however we have not been able to figure out the cause.

Any ideas please?

Thanks,
Andrey.

Can you try out to import the default export?

import camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';

Hi Niklas,

Thanks so much for the prompt reply.

The suggested change solves this particular issues, however it breaks the code that updates certain other BPMN elements.
I am looking into it, will update here when I understand the problem better.

Thanks,
Andrey.

Hi,

@Niklas_Kiefer, thanks again for the advice.
It does seem to solve the original problem - the camunda package is registered properly in the moddle and

moddle.create('camunda:Connector', {

    });

now creates the element.

However with this change the attributes in the camunda: namespace don’t seem to load anymore.

The way we do the imports and create the modeler:

import camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';
import * as camundaPropertiesProvider from 'bpmn-js-properties-panel/lib/provider/camunda';
// Also tried
// import propertiesProvider from 'bpmn-js-properties-panel/lib/provider/camunda';

        this.modeler = new BpmnJS({
          container: '#canvas',
          keyboard: {
            bindTo: document
          },
          additionalModules: [
            camundaModdleExtension,
            camundaPropertiesProvider,
            // also tried propertiesProvider for the alternative import above
          ],
          moddleExtensions: {
            camunda: camundaModdle
          }
        });

Now we have a user task with the camunda.asyncBefore being true:

      <bpmn:userTask id="TestTask" name="User task with WC" camunda:asyncBefore="true">

However when we try to get the attributes we get nothing:

      LogUtil.consoleLogPretty('BpmnTaskElementBase element.businessObject.$attrs', element.businessObject.$attrs);

we get this output:

BpmnTaskElementBase element.businessObject.$attrs {}

While with the old import

import * as camundaModdle from 'camunda-bpmn-moddle/resources/camunda.json';

the output of the same logging is

BpmnTaskElementBase element.businessObject.$attrs {
  "camunda:asyncBefore": "true"
}

Any help is greatly appreciated.

Sorry, nevermind my previous message.
The ‘camunda’ namespace properties are now available not as the items in the $attrs collection but as the regular properties of the business object and we can work with that.

Thanks,
Andrey.