bpmn-moddle 0.10.4 → 0.11.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-moddle",
3
- "version": "0.10.4",
3
+ "version": "0.11.0",
4
4
  "description": "A moddle wrapper for BPMN 2.0",
5
5
  "scripts": {
6
6
  "test": "grunt test"
@@ -35,14 +35,13 @@
35
35
  "grunt-contrib-watch": "^0.5.0",
36
36
  "grunt-mocha-test": "^0.11.0",
37
37
  "grunt-release": "^0.7.0",
38
- "ids": "^0.1.1",
39
38
  "jsondiffpatch": "^0.1.4",
40
39
  "load-grunt-tasks": "^0.3.0",
41
40
  "xsd-schema-validator": "^0.3.0"
42
41
  },
43
42
  "dependencies": {
44
43
  "lodash": "^3.0.0",
45
- "moddle": "^0.6.3",
46
- "moddle-xml": "^0.9.4"
44
+ "moddle": "^0.7.0",
45
+ "moddle-xml": "^0.10.0"
47
46
  }
48
47
  }
@@ -427,7 +427,8 @@
427
427
  {
428
428
  "name": "id",
429
429
  "isAttr": true,
430
- "type": "String"
430
+ "type": "String",
431
+ "isId": true
431
432
  },
432
433
  {
433
434
  "name": "documentation",
@@ -2718,6 +2719,9 @@
2718
2719
  "serialize": "xsi:type"
2719
2720
  }
2720
2721
  }
2722
+ ],
2723
+ "superClass": [
2724
+ "BaseElement"
2721
2725
  ]
2722
2726
  },
2723
2727
  {
@@ -6,6 +6,12 @@
6
6
  "name": "DiagramElement",
7
7
  "isAbstract": true,
8
8
  "properties": [
9
+ {
10
+ "name": "id",
11
+ "type": "String",
12
+ "isAttr": true,
13
+ "isId": true
14
+ },
9
15
  {
10
16
  "name": "extension",
11
17
  "type": "Extension"
@@ -90,6 +96,12 @@
90
96
  "name": "Diagram",
91
97
  "isAbstract": true,
92
98
  "properties": [
99
+ {
100
+ "name": "id",
101
+ "type": "String",
102
+ "isAttr": true,
103
+ "isId": true
104
+ },
93
105
  {
94
106
  "name": "rootElement",
95
107
  "type": "DiagramElement",
@@ -197,7 +209,15 @@
197
209
  },
198
210
  {
199
211
  "name": "Style",
200
- "isAbstract": true
212
+ "isAbstract": true,
213
+ "properties": [
214
+ {
215
+ "name": "id",
216
+ "type": "String",
217
+ "isAttr": true,
218
+ "isId": true
219
+ }
220
+ ]
201
221
  },
202
222
  {
203
223
  "name": "Extension",
@@ -29,6 +29,10 @@ describe('moddle BPMN 2.0 json', function() {
29
29
  typePrefix: 't'
30
30
  };
31
31
 
32
+ builder.alter('BaseElement#id', {
33
+ isId: true
34
+ });
35
+
32
36
  // perform a translation from
33
37
  //
34
38
  // BaseElement
@@ -149,6 +153,12 @@ describe('moddle BPMN 2.0 json', function() {
149
153
  delete desc.isAttr;
150
154
  });
151
155
 
156
+ // fix missing ResourceAssignmentExpression parent
157
+
158
+ builder.alter('ResourceAssignmentExpression', function(desc) {
159
+ desc.superClass = [ 'BaseElement' ];
160
+ });
161
+
152
162
 
153
163
  // fix positioning of elements
154
164
 
@@ -454,12 +464,12 @@ describe('moddle BPMN 2.0 json', function() {
454
464
  pkg.associations = [];
455
465
 
456
466
  pkg.types.push({
457
- 'name': 'Extension',
458
- 'properties': [
467
+ name: 'Extension',
468
+ properties: [
459
469
  {
460
- 'name': 'values',
461
- 'type': 'Element',
462
- 'isMany': true
470
+ name: 'values',
471
+ type: 'Element',
472
+ isMany: true
463
473
  }
464
474
  ]
465
475
  });
@@ -467,8 +477,34 @@ describe('moddle BPMN 2.0 json', function() {
467
477
  builder.alter('DiagramElement', function(data) {
468
478
 
469
479
  data.properties.unshift({
470
- 'name': 'extension',
471
- 'type': 'Extension'
480
+ name: 'extension',
481
+ type: 'Extension'
482
+ });
483
+
484
+ data.properties.unshift({
485
+ name: 'id',
486
+ type: 'String',
487
+ isAttr: true,
488
+ isId: true
489
+ });
490
+ });
491
+
492
+ builder.alter('Diagram', function(data) {
493
+ data.properties.unshift({
494
+ name: 'id',
495
+ type: 'String',
496
+ isAttr: true,
497
+ isId: true
498
+ });
499
+ });
500
+
501
+
502
+ builder.alter('Style', function(data) {
503
+ (data.properties = data.properties || []).unshift({
504
+ name: 'id',
505
+ type: 'String',
506
+ isAttr: true,
507
+ isId: true
472
508
  });
473
509
  });
474
510
 
@@ -40,6 +40,35 @@ describe('bpmn-moddle - roundtrip', function() {
40
40
  });
41
41
 
42
42
 
43
+ it('obscure ids model', function(done) {
44
+
45
+ var definitions = moddle.create('bpmn:Definitions', {
46
+ 'xmlns:foo': 'http://foo-ns',
47
+ targetNamespace: 'http://foo',
48
+ rootElements: [
49
+ moddle.create('bpmn:Message', { id: 'foo_bar' }),
50
+ moddle.create('bpmn:Message', { id: 'foo-bar' }),
51
+ moddle.create('bpmn:Message', { id: 'foo1bar' }),
52
+ moddle.create('bpmn:Message', { id: 'Foo1bar' }),
53
+ moddle.create('bpmn:Message', { id: '_foo_bar' }),
54
+ moddle.create('bpmn:Message', { id: '_foo-bar' }),
55
+ moddle.create('bpmn:Message', { id: '_11' })
56
+ // invalid
57
+ // moddle.create('bpmn:Message', { id: '-foo-bar' }),
58
+ // moddle.create('bpmn:Message', { id: 'foo:_foo_bar' }),
59
+ // moddle.create('bpmn:Message', { id: '1foo_bar' })
60
+ ]
61
+ });
62
+
63
+ // when
64
+ toXML(definitions, { format: true }, function(err, xml) {
65
+
66
+ // then
67
+ validate(err, xml, done);
68
+ });
69
+ });
70
+
71
+
43
72
  it('ioSpecification', function(done) {
44
73
 
45
74
  // given
@@ -414,13 +443,12 @@ describe('bpmn-moddle - roundtrip', function() {
414
443
 
415
444
  describe('vendor', function() {
416
445
 
417
-
418
446
  describe('signavio', function() {
419
447
 
420
448
  it('complex processElement', function(done) {
421
449
 
422
450
  // given
423
- fromFile('test/fixtures/bpmn/complex-no-extensions.bpmn', function(err, result) {
451
+ fromFile('test/fixtures/bpmn/vendor/signavio-complex-no-extensions.bpmn', function(err, result) {
424
452
 
425
453
  if (err) {
426
454
  return done(err);
@@ -441,7 +469,7 @@ describe('bpmn-moddle - roundtrip', function() {
441
469
  it('event definitions', function(done) {
442
470
 
443
471
  // given
444
- fromFile('test/fixtures/bpmn/event-definitions-yaoqiang.bpmn', function(err, result, context) {
472
+ fromFile('test/fixtures/bpmn/vendor/yaoqiang-event-definitions.bpmn', function(err, result, context) {
445
473
 
446
474
  if (err) {
447
475
  return done(err);
@@ -385,6 +385,43 @@ describe('bpmn-moddle - write', function() {
385
385
  });
386
386
 
387
387
 
388
+ it('ResourceAssignmentExpression', function(done) {
389
+
390
+ // given
391
+ var expression = moddle.create('bpmn:FormalExpression', { body: '${ foo < bar }' });
392
+
393
+ var assignmentExpression =
394
+ moddle.create('bpmn:ResourceAssignmentExpression', {
395
+ id: 'FOO BAR',
396
+ expression: expression
397
+ });
398
+
399
+ var expectedXML =
400
+ '<bpmn:resourceAssignmentExpression ' +
401
+ 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
402
+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
403
+ 'id="FOO BAR">' +
404
+ '<bpmn:expression xsi:type="bpmn:tFormalExpression">' +
405
+ '<![CDATA[${ foo < bar }]]>' +
406
+ '</bpmn:expression>' +
407
+ '</bpmn:resourceAssignmentExpression>';
408
+
409
+ // when
410
+ write(assignmentExpression, function(err, result, context) {
411
+
412
+ if (err) {
413
+ return done(err);
414
+ }
415
+
416
+ // then
417
+ expect(result).to.eql(expectedXML);
418
+
419
+ done(err);
420
+ });
421
+
422
+ });
423
+
424
+
388
425
  it('CallActivity#calledElement', function(done) {
389
426
 
390
427
  // given
@@ -811,6 +848,56 @@ describe('bpmn-moddle - write', function() {
811
848
  });
812
849
  });
813
850
 
851
+
852
+ it('nested elements via bpmn:extensionElements', function(done) {
853
+
854
+ var camundaNs = 'http://camunda.org/schema/1.0/bpmn';
855
+
856
+ // when
857
+
858
+ var inputParameter = moddle.createAny('camunda:inputParameter', camundaNs, {
859
+ name: 'assigneeEntity',
860
+ $body: 'user'
861
+ });
862
+
863
+ var inputOutput = moddle.createAny('camunda:inputOutput', camundaNs, {
864
+ $children: [
865
+ inputParameter
866
+ ]
867
+ });
868
+
869
+ var extensionElements = moddle.create('bpmn:ExtensionElements', {
870
+ values: [ inputOutput ]
871
+ });
872
+
873
+ var userTask = moddle.create('bpmn:UserTask', {
874
+ extensionElements: extensionElements
875
+ });
876
+
877
+ var expectedXML =
878
+ '<bpmn:userTask xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
879
+ 'xmlns:camunda="' + camundaNs + '">' +
880
+ '<bpmn:extensionElements>' +
881
+ '<camunda:inputOutput>' +
882
+ '<camunda:inputParameter name="assigneeEntity">user</camunda:inputParameter>' +
883
+ '</camunda:inputOutput>' +
884
+ '</bpmn:extensionElements>' +
885
+ '</bpmn:userTask>';
886
+
887
+ // when
888
+ write(userTask, function(err, result) {
889
+
890
+ if (err) {
891
+ return done(err);
892
+ }
893
+
894
+ // then
895
+ expect(result).to.eql(expectedXML);
896
+
897
+ done();
898
+ });
899
+ });
900
+
814
901
  });
815
902
 
816
903
  });
package/lib/id-support.js DELETED
@@ -1,55 +0,0 @@
1
- 'use strict';
2
-
3
- var ID_PATTERN = /^(.*:)?id$/;
4
-
5
- /**
6
- * Extends the bpmn instance with id support.
7
- *
8
- * @example
9
- *
10
- * var moddle, ids;
11
- *
12
- * require('id-support').extend(moddle, ids);
13
- *
14
- * moddle.ids.next(); // create a next id
15
- * moddle.ids; // ids instance
16
- *
17
- * // claims id as used
18
- * moddle.create('foo:Bar', { id: 'fooobar1' });
19
- *
20
- *
21
- * @param {Moddle} model
22
- * @param {Ids} ids
23
- *
24
- * @return {Moddle} the extended moddle instance
25
- */
26
- module.exports.extend = function(model, ids) {
27
-
28
- var set = model.properties.set;
29
-
30
- // do not reinitialize setter
31
- // unless it is already initialized
32
- if (!model.ids) {
33
-
34
- model.properties.set = function(target, property, value) {
35
-
36
- // ensure we log used ids once they are assigned
37
- // to model elements
38
- if (ID_PATTERN.test(property)) {
39
-
40
- var assigned = model.ids.assigned(value);
41
- if (assigned && assigned !== target) {
42
- throw new Error('id <' + value + '> already used');
43
- }
44
-
45
- model.ids.claim(value, target);
46
- }
47
-
48
- set.call(this, target, property, value);
49
- };
50
- }
51
-
52
- model.ids = ids;
53
-
54
- return model;
55
- };
@@ -1,97 +0,0 @@
1
- 'use strict';
2
-
3
- var Helper = require('../helper');
4
-
5
- var Ids = require('ids'),
6
- IdSupport = require('../../lib/id-support');
7
-
8
-
9
- describe('bpmn-moddle - id-support', function() {
10
-
11
- describe('.extend', function() {
12
-
13
- it('should extend bpmn-moddle with ids', function() {
14
-
15
- // given
16
- var moddle = Helper.createModdle();
17
- var ids = new Ids();
18
-
19
- // when
20
- IdSupport.extend(moddle, ids);
21
-
22
- // then
23
- expect(moddle.ids).to.equal(ids);
24
- });
25
-
26
- });
27
-
28
-
29
- describe('functionality', function() {
30
-
31
- it('should claim ids during object creation', function() {
32
-
33
- // given
34
- var moddle = Helper.createModdle();
35
- var ids = new Ids();
36
-
37
- IdSupport.extend(moddle, ids);
38
-
39
- // when
40
- var serviceTask = moddle.create('bpmn:ServiceTask', {
41
- id: 'ServiceTask_1'
42
- });
43
-
44
- // then
45
- expect(serviceTask.id).to.equal('ServiceTask_1');
46
- expect(moddle.ids.assigned(serviceTask.id)).to.equal(serviceTask);
47
- });
48
-
49
-
50
- it('should claim ids during object creation', function() {
51
-
52
- // given
53
- var moddle = Helper.createModdle();
54
- var ids = new Ids();
55
-
56
- IdSupport.extend(moddle, ids);
57
-
58
- // when
59
- moddle.create('bpmn:ServiceTask', {
60
- id: 'ServiceTask_1'
61
- });
62
-
63
- // then
64
- expect(function() {
65
-
66
- moddle.create('bpmn:ServiceTask', {
67
- id: 'ServiceTask_1'
68
- });
69
- }).to.throw('id <ServiceTask_1> already used');
70
- });
71
-
72
-
73
- it('should reset and allow reclaim of ids', function() {
74
-
75
- // given
76
- var moddle = Helper.createModdle();
77
- IdSupport.extend(moddle, new Ids());
78
-
79
- moddle.create('bpmn:ServiceTask', {
80
- id: 'ServiceTask_1'
81
- });
82
-
83
- // when
84
- IdSupport.extend(moddle, new Ids());
85
-
86
- // then
87
- // expect id to have been reset
88
- expect(function() {
89
-
90
- moddle.create('bpmn:ServiceTask', {
91
- id: 'ServiceTask_1'
92
- });
93
- }).not.to.throw();
94
- });
95
- });
96
-
97
- });