Skip to content

Commit 43062cb

Browse files
committed
major upgrade smqp@10
adjust lint rules
1 parent 5389277 commit 43062cb

8 files changed

Lines changed: 82 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## [17.2.0] - 2025-07-22
6+
7+
- major upgrade of [smqp@10.0.0](https://github.com/paed01/smqp/blob/default/CHANGELOG.md)
8+
59
## [17.1.0] - 2025-04-30
610

711
- add support for ad-hoc subprocess. The behavior is the same as for an ordinary subprocess

dist/process/Process.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
314314
const {
315315
output,
316316
...rest
317-
} = content; // eslint-disable-line no-unused-vars
317+
} = content;
318318
this._publishEvent('leave', rest);
319319
return;
320320
}

eslint.config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ const rules = {
4242
'no-undef-init': 2,
4343
'no-undef': 2,
4444
'no-underscore-dangle': 0,
45-
'no-unused-vars': 2,
4645
'no-unused-expressions': 2,
47-
'no-use-before-define': 0,
46+
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
47+
'no-use-before-define': [
48+
'error',
49+
{
50+
functions: false,
51+
classes: true,
52+
variables: true,
53+
allowNamedExports: false,
54+
},
55+
],
4856
'no-var': 2,
4957
'no-with': 2,
5058
'prefer-const': ['error', { destructuring: 'all' }],

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bpmn-elements",
3-
"version": "17.1.0",
3+
"version": "17.2.0",
44
"description": "Executable workflow elements based on BPMN 2.0",
55
"type": "module",
66
"main": "./dist/index.js",
@@ -104,6 +104,6 @@
104104
},
105105
"dependencies": {
106106
"@0dep/piso": "^2.4.0",
107-
"smqp": "^9.0.6"
107+
"smqp": "^10.0.0"
108108
}
109109
}

src/process/Process.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ Process.prototype._onRunMessage = function onRunMessage(routingKey, message) {
306306
this[kStatus] = undefined;
307307
message.ack();
308308
this._deactivateRunConsumers();
309-
const { output, ...rest } = content; // eslint-disable-line no-unused-vars
309+
const { output, ...rest } = content;
310310
this._publishEvent('leave', rest);
311311
return;
312312
}

test/feature/compensation-feature.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,10 @@ Feature('Compensation', () => {
797797
});
798798
});
799799

800+
let end;
800801
When('definition is ran', () => {
802+
end = definition.waitFor('end');
803+
801804
definition.run();
802805
});
803806

@@ -874,7 +877,6 @@ Feature('Compensation', () => {
874877
return stopped;
875878
});
876879

877-
let end;
878880
When('definition is recovered and resumed', () => {
879881
definition = new Definition(context.clone(), {
880882
services: {

test/feature/issues/issue-39-feature.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ const source = `
2121
</process>
2222
</definitions>`;
2323

24+
class FlorianSequenceFlow extends SequenceFlow {
25+
getCondition() {
26+
const condition = super.getCondition();
27+
if (condition?.type !== 'expression') return condition;
28+
29+
const execute = condition.execute;
30+
condition.execute = asyncExecute.bind(condition);
31+
32+
return condition;
33+
34+
function asyncExecute(message, callback) {
35+
execute.call(condition, message, (executeErr, result) => {
36+
if (executeErr) return callback(executeErr);
37+
return Promise.resolve(result)
38+
.then((r) => (callback ? callback(null, r) : result))
39+
.catch((err) => (callback ? callback(err) : err));
40+
});
41+
}
42+
}
43+
}
44+
2445
Feature('Issue 39 - resolve SequenceFlow expression promise', () => {
2546
Scenario('expression function returns promise', () => {
2647
let context, definition, end;
@@ -58,24 +79,3 @@ Feature('Issue 39 - resolve SequenceFlow expression promise', () => {
5879
});
5980
});
6081
});
61-
62-
class FlorianSequenceFlow extends SequenceFlow {
63-
getCondition() {
64-
const condition = super.getCondition();
65-
if (condition?.type !== 'expression') return condition;
66-
67-
const execute = condition.execute;
68-
condition.execute = asyncExecute.bind(condition);
69-
70-
return condition;
71-
72-
function asyncExecute(message, callback) {
73-
execute.call(condition, message, (executeErr, result) => {
74-
if (executeErr) return callback(executeErr);
75-
return Promise.resolve(result)
76-
.then((r) => (callback ? callback(null, r) : result))
77-
.catch((err) => (callback ? callback(err) : err));
78-
});
79-
}
80-
}
81-
}

test/flows/SequenceFlow-test.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,46 @@ const extensions = {
1212

1313
const multipleInboundSource = factory.resource('multiple-multiple-inbound.bpmn').toString();
1414

15+
class TestScripts {
16+
constructor() {
17+
this.javaScripts = new Scripts();
18+
this.scripts = new Map();
19+
}
20+
register({ id, type, behaviour }) {
21+
if (!behaviour.conditionExpression) return;
22+
23+
const scriptBody = behaviour.conditionExpression.body;
24+
const sync = !/next\(/.test(scriptBody);
25+
26+
const registered = this.javaScripts.register({
27+
id,
28+
type,
29+
behaviour: {
30+
conditionExpression: {
31+
...behaviour.conditionExpression,
32+
language: 'javascript',
33+
},
34+
},
35+
});
36+
37+
this.scripts.set(id, { sync, registered });
38+
}
39+
getScript(language, { id }) {
40+
const { sync, registered } = this.scripts.get(id);
41+
return {
42+
execute,
43+
};
44+
45+
function execute(executionContext, callback) {
46+
if (sync) {
47+
const result = registered.script.runInNewContext(executionContext);
48+
return callback(null, result);
49+
}
50+
return registered.script.runInNewContext({ ...executionContext, next: callback });
51+
}
52+
}
53+
}
54+
1555
describe('SequenceFlow', () => {
1656
describe('properties', () => {
1757
let context;
@@ -616,43 +656,3 @@ describe('SequenceFlow', () => {
616656
});
617657
});
618658
});
619-
620-
class TestScripts {
621-
constructor() {
622-
this.javaScripts = new Scripts();
623-
this.scripts = new Map();
624-
}
625-
register({ id, type, behaviour }) {
626-
if (!behaviour.conditionExpression) return;
627-
628-
const scriptBody = behaviour.conditionExpression.body;
629-
const sync = !/next\(/.test(scriptBody);
630-
631-
const registered = this.javaScripts.register({
632-
id,
633-
type,
634-
behaviour: {
635-
conditionExpression: {
636-
...behaviour.conditionExpression,
637-
language: 'javascript',
638-
},
639-
},
640-
});
641-
642-
this.scripts.set(id, { sync, registered });
643-
}
644-
getScript(language, { id }) {
645-
const { sync, registered } = this.scripts.get(id);
646-
return {
647-
execute,
648-
};
649-
650-
function execute(executionContext, callback) {
651-
if (sync) {
652-
const result = registered.script.runInNewContext(executionContext);
653-
return callback(null, result);
654-
}
655-
return registered.script.runInNewContext({ ...executionContext, next: callback });
656-
}
657-
}
658-
}

0 commit comments

Comments
 (0)