Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit extension namespaces #45

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Explicit extension namespaces #45

wants to merge 6 commits into from

Conversation

nikku
Copy link
Member

@nikku nikku commented Dec 17, 2022

Context

This PR fixes a long standing issue that prevents general usability of moddle for advanced use-cases, i.e. UML parsing: We handle extension provided properties in a magic fashion, and polute the local namespace with them. All under the assuption that names declared across packages do not ever overlap (which can only hold true accidentally). In case of overlap we blow up (#36).

UML specifically defines two packages UML and UMLDI, and both declare a property ownedElement:

image

(Image from #36).

The Solution

This PR makes extension namespaces explicit, offering a more predicatable moddle behavior, and enabling use-cases such as #36 in the first place:

  • Remove magic access to non-namespaced names for extension properties:

    // before, now disallowed
    const element = moddle.create('bpmn:ServiceTask', {
      topic: 'FOOBAR'
    });
    
    element.topic; // 'FOOBAR'
    
    // correct usage
    const element = moddle.create('bpmn:ServiceTask', {
      'camunda:topic': 'FOOBAR'
    });
    
    element['camunda:topic']; // 'FOOBAR'
  • As a result you may define properties with name clashes in a safe manner:

    const diagramElement = moddle.create('umldi:DiagramElement', {
      ownedElement: [ ... ],
      'uml:ownedElement': [ ... ]
    });

Regarding the UML Case

For ease of use in moddle users must clearly separate local from extension properties. Inheritance must still be conflict free, meaning that the stock UML case ⬆️ is still not suppported out of the box. However you could argue that introducing such conflicts in the first place is bad language design. We have no urge to support such.

Given this PR you can however solve the situation through a virtual glue package (8a65475). That glue package does what UML should have done in the first place, clearly defining ownership (core domain - UMLDI) and extension (UML):

image


As indicated earlier this is a major breaking change: Where extension properties have been mapped via their local names in the past, they now must be mapped explicitly.

When considering the core bpmn.io domain this results in minor adjustments (f058e3a, bpmn-io/moddle-xml#68, bpmn-io/bpmn-moddle#97). When we considering the extension domain, this results in major changes (camunda/camunda-bpmn-moddle#122, camunda/zeebe-bpmn-moddle#40).


Migration

To aid migration migration to this new major version (and guide our users through stricter usage requirements) I suggest a strict mode and explicit logging of miss-use (#48).

@bpmn-io-tasks bpmn-io-tasks bot added the needs review Review pending label Dec 17, 2022
@nikku nikku mentioned this pull request Dec 17, 2022
@nikku nikku changed the base branch from master to fix-inherits December 17, 2022 20:49
@nikku nikku marked this pull request as draft December 18, 2022 11:55
@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed needs review Review pending labels Dec 18, 2022
Base automatically changed from fix-inherits to master December 19, 2022 10:20
@nikku nikku changed the base branch from master to strict-mode December 20, 2022 13:59
Base automatically changed from strict-mode to master December 20, 2022 16:03
@nikku nikku added the backlog Queued in backlog label Dec 21, 2022 — with bpmn-io-tasks
@nikku nikku removed the in progress Currently worked on label Dec 21, 2022
@nikku nikku changed the base branch from master to improve-test-coverage December 21, 2022 21:27
Base automatically changed from improve-test-coverage to master December 21, 2022 21:38
@nikku nikku removed their assignment Feb 13, 2023
This resolves name conflicts by making extensions only available through 
their namespace names.

Related to #36


BREAKING CHANGES: 

* Extensions are not registered with their local names anymore, 
  but only via their namespace prefixed names such as 
  `someProperty` -> `e:someProperty`
@marstamm
Copy link
Contributor

This issue is also preventing us to create a generic bpmn-linter that support both camunda: and zeebe: diagrams without configuration. Cf. camunda/camunda-modeler#3853 (comment) .

I verified this is the same issue with a test-case on https://github.com/bpmn-io/moddle/tree/test-allow-overlapping-types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Queued in backlog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants