@ejfdelgado/ejflab-common 1.5.4 → 1.6.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.5.4",
4
+ "version": "1.6.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
@@ -10,7 +10,6 @@
10
10
  "scripts": {
11
11
  "mylogin": "npm login",
12
12
  "mypublish": "npm publish --access=public",
13
- "diff": "unset GTK_PATH && git difftool",
14
13
  "clean": "rm -rf node_modules && npm cache clean --force && rm package-lock.json && npm install"
15
14
  },
16
15
  "engines": {
@@ -26,6 +26,7 @@ const { SimpleObj } = require("../SimpleObj");
26
26
  const { CommandPrint } = require('./steps/CommandPrint');
27
27
  const { CommandMongo } = require('./steps/CommandMongo');
28
28
  const { CommandMinio } = require('./steps/CommandMinio');
29
+ const { CommandPostgres } = require('./steps/CommandPostgres.js');
29
30
 
30
31
  class FlowChartExec {
31
32
  executionPromise = null;
@@ -68,6 +69,7 @@ class FlowChartExec {
68
69
  this.registry["mongo"] = CommandMongo;
69
70
  this.registry["print"] = CommandPrint;
70
71
  this.registry["minio"] = CommandMinio;
72
+ this.registry["postgres"] = CommandPostgres;
71
73
  }
72
74
 
73
75
  registerTimeline(id, timeline) {
@@ -0,0 +1,31 @@
1
+ const { SimpleObj } = require("../../SimpleObj");
2
+ const { CommandBasic } = require("./CommandBasic");
3
+
4
+ class CommandPostgres extends CommandBasic {
5
+ async computation() {
6
+ const action = this.args[0];
7
+ const dbIdPath = this.args[1];
8
+ const bodyPath = this.args[2];
9
+ //srv/wideSight/sql/writes/object.sql
10
+ const script = this.args[3];
11
+ const postgresSrv = this.context.getSuperContext().getPostgresClient();
12
+ if (action == "execute") {
13
+ const dbIdData = SimpleObj.getValue(this.context.data, dbIdPath, null);
14
+ let bodyData = SimpleObj.getValue(this.context.data, bodyPath, null);
15
+ bodyData = JSON.parse(JSON.stringify(bodyData));
16
+ if (!(bodyData instanceof Array)) {
17
+ bodyData = [bodyData]
18
+ }
19
+ for (let i = 0; i < bodyData.length; i++) {
20
+ const payload = JSON.parse(JSON.stringify(dbIdData));
21
+ payload.object = bodyData[i];
22
+ console.log(`script=${script}`);
23
+ console.log(JSON.stringify(payload, null, 4));
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ module.exports = {
30
+ CommandPostgres
31
+ };