@5minds/node-red-contrib-processcube 0.8.0 → 0.10.0-develop-748f9b-ly4wvjse

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,22 @@
23
23
  "info": "",
24
24
  "env": []
25
25
  },
26
+ {
27
+ "id": "5d27ab4d14b947e9",
28
+ "type": "tab",
29
+ "label": "Process Instances",
30
+ "disabled": false,
31
+ "info": "",
32
+ "env": []
33
+ },
34
+ {
35
+ "id": "f28ae6aa3a05069e",
36
+ "type": "tab",
37
+ "label": "Process Definitions",
38
+ "disabled": false,
39
+ "info": "",
40
+ "env": []
41
+ },
26
42
  {
27
43
  "id": "09cdc14cfb8ad687",
28
44
  "type": "group",
@@ -204,6 +220,54 @@
204
220
  "w": 852,
205
221
  "h": 182
206
222
  },
223
+ {
224
+ "id": "4c59118134081e05",
225
+ "type": "group",
226
+ "z": "f28ae6aa3a05069e",
227
+ "style": {
228
+ "stroke": "#999999",
229
+ "stroke-opacity": "1",
230
+ "fill": "none",
231
+ "fill-opacity": "1",
232
+ "label": true,
233
+ "label-position": "nw",
234
+ "color": "#a4a4a4"
235
+ },
236
+ "nodes": [
237
+ "d97caca0ec54a633",
238
+ "f74139117c9dab27",
239
+ "5539a5c4c0f9cbe2",
240
+ "a8e2b5a6ca25c924"
241
+ ],
242
+ "x": 14,
243
+ "y": 39,
244
+ "w": 592,
245
+ "h": 142
246
+ },
247
+ {
248
+ "id": "f1d4eaed7570324e",
249
+ "type": "group",
250
+ "z": "f28ae6aa3a05069e",
251
+ "style": {
252
+ "stroke": "#999999",
253
+ "stroke-opacity": "1",
254
+ "fill": "none",
255
+ "fill-opacity": "1",
256
+ "label": true,
257
+ "label-position": "nw",
258
+ "color": "#a4a4a4"
259
+ },
260
+ "nodes": [
261
+ "bcc97a73cff5a086",
262
+ "b418463be836efbb",
263
+ "0633b709dd9c166f",
264
+ "fbb37831549d41ff"
265
+ ],
266
+ "x": 14,
267
+ "y": 219,
268
+ "w": 572,
269
+ "h": 142
270
+ },
207
271
  {
208
272
  "id": "d042a4c68f51d6ab",
209
273
  "type": "processcube-engine-config",
@@ -2489,5 +2553,218 @@
2489
2553
  "x": 1420,
2490
2554
  "y": 1020,
2491
2555
  "wires": []
2556
+ },
2557
+ {
2558
+ "id": "baa5d814f2e1f1d8",
2559
+ "type": "processinstance-query",
2560
+ "z": "5d27ab4d14b947e9",
2561
+ "name": "",
2562
+ "engine": "d042a4c68f51d6ab",
2563
+ "query": "{\"includeXml\":false}",
2564
+ "query_type": "json",
2565
+ "x": 360,
2566
+ "y": 120,
2567
+ "wires": [
2568
+ [
2569
+ "2af2c5031c617e3d"
2570
+ ]
2571
+ ]
2572
+ },
2573
+ {
2574
+ "id": "2af2c5031c617e3d",
2575
+ "type": "debug",
2576
+ "z": "5d27ab4d14b947e9",
2577
+ "name": "debug 25",
2578
+ "active": true,
2579
+ "tosidebar": true,
2580
+ "console": false,
2581
+ "tostatus": false,
2582
+ "complete": "false",
2583
+ "statusVal": "",
2584
+ "statusType": "auto",
2585
+ "x": 600,
2586
+ "y": 120,
2587
+ "wires": []
2588
+ },
2589
+ {
2590
+ "id": "81af643792f131f0",
2591
+ "type": "inject",
2592
+ "z": "5d27ab4d14b947e9",
2593
+ "name": "",
2594
+ "props": [
2595
+ {
2596
+ "p": "payload"
2597
+ },
2598
+ {
2599
+ "p": "topic",
2600
+ "vt": "str"
2601
+ }
2602
+ ],
2603
+ "repeat": "",
2604
+ "crontab": "",
2605
+ "once": false,
2606
+ "onceDelay": 0.1,
2607
+ "topic": "",
2608
+ "payload": "",
2609
+ "payloadType": "date",
2610
+ "x": 100,
2611
+ "y": 120,
2612
+ "wires": [
2613
+ [
2614
+ "baa5d814f2e1f1d8"
2615
+ ]
2616
+ ]
2617
+ },
2618
+ {
2619
+ "id": "d97caca0ec54a633",
2620
+ "type": "processdefinition-query",
2621
+ "z": "f28ae6aa3a05069e",
2622
+ "g": "4c59118134081e05",
2623
+ "name": "Query definitions",
2624
+ "engine": "d042a4c68f51d6ab",
2625
+ "query": "{\"includeXml\":false}",
2626
+ "query_type": "json",
2627
+ "models_only": false,
2628
+ "x": 310,
2629
+ "y": 140,
2630
+ "wires": [
2631
+ [
2632
+ "5539a5c4c0f9cbe2"
2633
+ ]
2634
+ ]
2635
+ },
2636
+ {
2637
+ "id": "f74139117c9dab27",
2638
+ "type": "inject",
2639
+ "z": "f28ae6aa3a05069e",
2640
+ "g": "4c59118134081e05",
2641
+ "name": "",
2642
+ "props": [
2643
+ {
2644
+ "p": "payload"
2645
+ },
2646
+ {
2647
+ "p": "topic",
2648
+ "vt": "str"
2649
+ }
2650
+ ],
2651
+ "repeat": "",
2652
+ "crontab": "",
2653
+ "once": false,
2654
+ "onceDelay": 0.1,
2655
+ "topic": "",
2656
+ "payload": "",
2657
+ "payloadType": "date",
2658
+ "x": 120,
2659
+ "y": 140,
2660
+ "wires": [
2661
+ [
2662
+ "d97caca0ec54a633"
2663
+ ]
2664
+ ]
2665
+ },
2666
+ {
2667
+ "id": "5539a5c4c0f9cbe2",
2668
+ "type": "debug",
2669
+ "z": "f28ae6aa3a05069e",
2670
+ "g": "4c59118134081e05",
2671
+ "name": "debug 26",
2672
+ "active": true,
2673
+ "tosidebar": true,
2674
+ "console": false,
2675
+ "tostatus": false,
2676
+ "complete": "false",
2677
+ "statusVal": "",
2678
+ "statusType": "auto",
2679
+ "x": 500,
2680
+ "y": 140,
2681
+ "wires": []
2682
+ },
2683
+ {
2684
+ "id": "bcc97a73cff5a086",
2685
+ "type": "processdefinition-query",
2686
+ "z": "f28ae6aa3a05069e",
2687
+ "g": "f1d4eaed7570324e",
2688
+ "name": "Query models",
2689
+ "engine": "d042a4c68f51d6ab",
2690
+ "query": "{\"includeXml\":false}",
2691
+ "query_type": "json",
2692
+ "models_only": true,
2693
+ "x": 300,
2694
+ "y": 320,
2695
+ "wires": [
2696
+ [
2697
+ "0633b709dd9c166f"
2698
+ ]
2699
+ ]
2700
+ },
2701
+ {
2702
+ "id": "b418463be836efbb",
2703
+ "type": "inject",
2704
+ "z": "f28ae6aa3a05069e",
2705
+ "g": "f1d4eaed7570324e",
2706
+ "name": "",
2707
+ "props": [
2708
+ {
2709
+ "p": "payload"
2710
+ },
2711
+ {
2712
+ "p": "topic",
2713
+ "vt": "str"
2714
+ }
2715
+ ],
2716
+ "repeat": "",
2717
+ "crontab": "",
2718
+ "once": false,
2719
+ "onceDelay": 0.1,
2720
+ "topic": "",
2721
+ "payload": "",
2722
+ "payloadType": "date",
2723
+ "x": 120,
2724
+ "y": 320,
2725
+ "wires": [
2726
+ [
2727
+ "bcc97a73cff5a086"
2728
+ ]
2729
+ ]
2730
+ },
2731
+ {
2732
+ "id": "0633b709dd9c166f",
2733
+ "type": "debug",
2734
+ "z": "f28ae6aa3a05069e",
2735
+ "g": "f1d4eaed7570324e",
2736
+ "name": "debug 27",
2737
+ "active": true,
2738
+ "tosidebar": true,
2739
+ "console": false,
2740
+ "tostatus": false,
2741
+ "complete": "false",
2742
+ "statusVal": "",
2743
+ "statusType": "auto",
2744
+ "x": 480,
2745
+ "y": 320,
2746
+ "wires": []
2747
+ },
2748
+ {
2749
+ "id": "a8e2b5a6ca25c924",
2750
+ "type": "comment",
2751
+ "z": "f28ae6aa3a05069e",
2752
+ "g": "4c59118134081e05",
2753
+ "name": "Definitions",
2754
+ "info": "",
2755
+ "x": 100,
2756
+ "y": 80,
2757
+ "wires": []
2758
+ },
2759
+ {
2760
+ "id": "fbb37831549d41ff",
2761
+ "type": "comment",
2762
+ "z": "f28ae6aa3a05069e",
2763
+ "g": "f1d4eaed7570324e",
2764
+ "name": "Models",
2765
+ "info": "",
2766
+ "x": 90,
2767
+ "y": 260,
2768
+ "wires": []
2492
2769
  }
2493
2770
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "0.8.0",
3
+ "version": "0.10.0-develop-748f9b-ly4wvjse",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "authors": [
@@ -37,6 +37,8 @@
37
37
  "externaltaskError": "externaltask-error.js",
38
38
  "processStart": "process-start.js",
39
39
  "processcubeEngineConfig": "processcube-engine-config.js",
40
+ "ProcessinstanceQuery": "processinstance-query.js",
41
+ "ProcessdefinitionQuery": "processdefinition-query.js",
40
42
  "messageEventTrigger": "message-event-trigger.js",
41
43
  "signalEventTrigger": "signal-event-trigger.js",
42
44
  "UserTaskNewListener": "usertask-new-listener.js",
@@ -0,0 +1,59 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('processdefinition-query', {
3
+ category: 'ProcessCube',
4
+ color: '#00aed7',
5
+ defaults: {
6
+ name: {value: ""},
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ query: {value: "payload"},
9
+ query_type: {value: "msg"},
10
+ models_only: {value: false},
11
+ },
12
+ inputs: 1,
13
+ outputs: 1,
14
+ icon: "font-awesome/fa-envelope-open",
15
+ label: function() {
16
+ return this.name || "processdefinition-query";
17
+ },
18
+ oneditprepare: function() {
19
+ $("#node-input-query").typedInput({
20
+ default: 'msg',
21
+ types: ['msg', 'json']
22
+ });
23
+
24
+ $("#node-input-query").typedInput('value', this.query);
25
+ $("#node-input-query").typedInput('type', this.query_type);
26
+ },
27
+ oneditsave: function() {
28
+ this.query = $("#node-input-query").typedInput('value'),
29
+ this.query_type = $("#node-input-query").typedInput('type')
30
+
31
+ }
32
+ });
33
+ </script>
34
+
35
+ <script type="text/html" data-template-name="processdefinition-query">
36
+ <div class="form-row">
37
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
38
+ <input type="text" id="node-input-name" placeholder="Name">
39
+ </div>
40
+ <div class="form-row">
41
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
42
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000">
43
+ </div>
44
+ <div class="form-row">
45
+ <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
46
+ <input type="text" id="node-input-query">
47
+ </div>
48
+ <div class="form-row" style="display:flex; margin-bottom: 3px;">
49
+ <label for="node-input-models_only" style="vertical-align:top"><i class="fa fa-list-alt"></i> Models Only</label>
50
+ <div>
51
+ <input type="checkbox" checked id="node-input-models_only" style="display: inline-block; width: auto; margin: 0px 0px 0px 4px;">
52
+ <label style="width:auto" for="node-input-models_only">Only send models as result.</label>
53
+ </div>
54
+ </div>
55
+ </script>
56
+
57
+ <script type="text/html" data-help-name="processdefinition-query">
58
+ <p>A node which queries to Process Definitions of https://processcube.io</p>
59
+ </script>
@@ -0,0 +1,66 @@
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
5
+
6
+ module.exports = function(RED) {
7
+ function ProcessdefinitionQuery(config) {
8
+ RED.nodes.createNode(this,config);
9
+ var node = this;
10
+ var flowContext = node.context().flow;
11
+ var nodeContext = node.context();
12
+
13
+ this.engine = this.server = RED.nodes.getNode(config.engine);
14
+
15
+ const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
16
+
17
+ var client = nodeContext.get('client');
18
+
19
+ if (!client) {
20
+ nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
+ client = nodeContext.get('client');
22
+ }
23
+
24
+ var eventEmitter = flowContext.get('emitter');
25
+
26
+ if (!eventEmitter) {
27
+ flowContext.set('emitter', new EventEmitter());
28
+ eventEmitter = flowContext.get('emitter');
29
+ }
30
+
31
+ node.on("close", async () => {
32
+ client.dispose();
33
+ client = null;
34
+ });
35
+
36
+ node.on('input', function(msg) {
37
+ const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
38
+
39
+ client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
40
+
41
+
42
+ if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
43
+ let models = [];
44
+
45
+ matchingProcessDefinitions.processDefinitions.forEach(processDefinition => {
46
+ processDefinition.processModels.forEach(model => {
47
+ models.push(model);
48
+ });
49
+ });
50
+
51
+ msg.payload = {
52
+ models: models,
53
+ totalCount: models.length
54
+ };
55
+
56
+ } else {
57
+ msg.payload = matchingProcessDefinitions;
58
+ }
59
+
60
+
61
+ node.send(msg);
62
+ });
63
+ });
64
+ }
65
+ RED.nodes.registerType("processdefinition-query", ProcessdefinitionQuery);
66
+ }
@@ -0,0 +1,51 @@
1
+ <script type="text/javascript">
2
+ RED.nodes.registerType('processinstance-query', {
3
+ category: 'ProcessCube',
4
+ color: '#00aed7',
5
+ defaults: {
6
+ name: {value: ""},
7
+ engine: {value: "", type: "processcube-engine-config"},
8
+ query: {value: "payload"},
9
+ query_type: {value: "msg"}
10
+ },
11
+ inputs: 1,
12
+ outputs: 1,
13
+ icon: "font-awesome/fa-envelope-open",
14
+ label: function() {
15
+ return this.name || "processinstance-query";
16
+ },
17
+ oneditprepare: function() {
18
+ $("#node-input-query").typedInput({
19
+ default: 'msg',
20
+ types: ['msg', 'json']
21
+ });
22
+
23
+ $("#node-input-query").typedInput('value', this.query);
24
+ $("#node-input-query").typedInput('type', this.query_type);
25
+ },
26
+ oneditsave: function() {
27
+ this.query = $("#node-input-query").typedInput('value'),
28
+ this.query_type = $("#node-input-query").typedInput('type')
29
+
30
+ }
31
+ });
32
+ </script>
33
+
34
+ <script type="text/html" data-template-name="processinstance-query">
35
+ <div class="form-row">
36
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
37
+ <input type="text" id="node-input-name" placeholder="Name">
38
+ </div>
39
+ <div class="form-row">
40
+ <label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
41
+ <input type="text" id="node-input-engine" placeholder="http://engine:8000">
42
+ </div>
43
+ <div class="form-row">
44
+ <label for="node-input-query"><i class="fa fa-tag"></i> Query</label>
45
+ <input type="text" id="node-input-query">
46
+ </div>
47
+ </script>
48
+
49
+ <script type="text/html" data-help-name="processinstance-query">
50
+ <p>A node which queries to Process Instances of https://processcube.io</p>
51
+ </script>
@@ -0,0 +1,48 @@
1
+ const process = require('process');
2
+ const EventEmitter = require('node:events');
3
+
4
+ const engine_client = require('@5minds/processcube_engine_client');
5
+
6
+ module.exports = function(RED) {
7
+ function ProcessinstanceQuery(config) {
8
+ RED.nodes.createNode(this,config);
9
+ var node = this;
10
+ var flowContext = node.context().flow;
11
+ var nodeContext = node.context();
12
+
13
+ this.engine = this.server = RED.nodes.getNode(config.engine);
14
+
15
+ const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';
16
+
17
+ var client = nodeContext.get('client');
18
+
19
+ if (!client) {
20
+ nodeContext.set('client', new engine_client.EngineClient(engineUrl));
21
+ client = nodeContext.get('client');
22
+ }
23
+
24
+ var eventEmitter = flowContext.get('emitter');
25
+
26
+ if (!eventEmitter) {
27
+ flowContext.set('emitter', new EventEmitter());
28
+ eventEmitter = flowContext.get('emitter');
29
+ }
30
+
31
+ node.on("close", async () => {
32
+ client.dispose();
33
+ client = null;
34
+ });
35
+
36
+ node.on('input', function(msg) {
37
+ const query = RED.util.evaluateNodeProperty(config.query, config.query_type, node, msg)
38
+
39
+ client.processInstances.query(query).then((matchingInstances) => {
40
+
41
+ msg.payload = matchingInstances;
42
+
43
+ node.send(msg);
44
+ });
45
+ });
46
+ }
47
+ RED.nodes.registerType("processinstance-query", ProcessinstanceQuery);
48
+ }