@ejfdelgado/ejflab-common 1.7.1 → 1.7.3

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.7.1",
4
+ "version": "1.7.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
@@ -8,6 +8,7 @@ class CommandPostgres extends CommandBasic {
8
8
  const bodyPath = this.args[2];
9
9
  //srv/wideSight/sql/writes/object.sql
10
10
  const script = this.args[3];
11
+ const destination = this.args[4];
11
12
  const postgresSrv = this.context.getSuperContext().getPostgresClient();
12
13
  if (action == "execute") {
13
14
  //console.log("Starting execute...");
@@ -40,7 +41,35 @@ class CommandPostgres extends CommandBasic {
40
41
  client.release();
41
42
  }
42
43
  //console.log("Finishing execute...");
43
- //console.log(JSON.stringify(response));
44
+ if (typeof destination == "string" && destination.trim().length > 0) {
45
+ let generalResponse = null;
46
+ if (response.length == 1) {
47
+ const rows = response[0].rows;
48
+ if (rows) {
49
+ const noList = !!this.args[5];
50
+ if (rows.length == 1 && noList) {
51
+ generalResponse = rows[0];
52
+ } else {
53
+ const first = response[0];
54
+ generalResponse = {
55
+ command: first.command,
56
+ rowCount: first.rowCount,
57
+ rows: first.rows,
58
+ };
59
+ }
60
+ }
61
+ SimpleObj.recreate(this.context.data, destination, generalResponse);
62
+ } else if (response.length > 1) {
63
+ generalResponse = response.map((elem) => {
64
+ return {
65
+ command: elem.command,
66
+ rowCount: elem.rowCount,
67
+ rows: elem.rows,
68
+ }
69
+ });
70
+ SimpleObj.recreate(this.context.data, destination, generalResponse);
71
+ }
72
+ }
44
73
  }
45
74
  }
46
75
  }
@@ -21,6 +21,7 @@ class StepMultiple extends StepBasic {
21
21
  }
22
22
  async execFirst() {
23
23
  // Reads the list to iterate
24
+ const room = this.context.getRoom();
24
25
  this.list = SimpleObj.getValue(this.context.data, this.args[1], []);
25
26
  const WORKSPACE = SimpleObj.getValue(this.context.data, "env.WORKSPACE", "./");
26
27
  //console.log(`WORKSPACE=${WORKSPACE}`);
@@ -31,7 +32,13 @@ class StepMultiple extends StepBasic {
31
32
  Print: '${WORKSPACE}/flowcharts/multiple/flow01N.drawio',
32
33
  };
33
34
  this.completePaths(extraConfiguration, WORKSPACE);
34
- this.context.complementFlowChart(extraConfiguration);
35
+ // Force update the model
36
+ const superContext = this.context.getSuperContext();
37
+ const roomData = superContext.getRoomLiveTupleModel(room);
38
+ roomData.model.flowchart = this.context.complementFlowChart(extraConfiguration);
39
+ let changes = roomData.builder.trackDifferences(roomData.model, [], null, ["flowchart"]);
40
+ roomData.model = roomData.builder.affect(changes);
41
+ superContext.emitToRoom(room, "flowChartModified");
35
42
  }
36
43
 
37
44
  async canContinue() {