@ejfdelgado/ejflab-common 1.5.3 → 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.
|
|
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": {
|
package/src/changePath.js
CHANGED
|
@@ -21,15 +21,19 @@ const HTML_PATHS = [
|
|
|
21
21
|
];
|
|
22
22
|
|
|
23
23
|
// Search bundle reference
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (fs.existsSync(DIST_DIR)) {
|
|
25
|
+
const fileList = fs.readdirSync(DIST_DIR).filter((fileName) => {
|
|
26
|
+
return /^main\./.exec(fileName) != null;
|
|
27
|
+
});
|
|
28
|
+
if (fileList.length > 0) {
|
|
29
|
+
FILE_PATHS.push(`${DIST_DIR}/${fileList[0]}`);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.log(`Warning: folder ${DIST_DIR} does not exists!`);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
function changeSimpleFile(filePath) {
|
|
32
|
-
console.log(`
|
|
36
|
+
console.log(`Trying ${filePath}...`);
|
|
33
37
|
// Read content
|
|
34
38
|
if (fs.existsSync(filePath)) {
|
|
35
39
|
let myConstantsContent = fs.readFileSync(filePath, { encoding: "utf8" });
|
|
@@ -39,7 +43,7 @@ function changeSimpleFile(filePath) {
|
|
|
39
43
|
fs.writeFileSync(filePath, myConstantsContent, { encoding: "utf8" });
|
|
40
44
|
//console.log(myConstantsContent);
|
|
41
45
|
} else {
|
|
42
|
-
console.log(`
|
|
46
|
+
console.log(`Warning: ${filePath} dont exists! continue...`);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -49,7 +53,7 @@ for (let i = 0; i < FILE_PATHS.length; i++) {
|
|
|
49
53
|
|
|
50
54
|
// Change also the html
|
|
51
55
|
function changeHtmlTag(filePath) {
|
|
52
|
-
console.log(`
|
|
56
|
+
console.log(`Trying ${filePath}...`);
|
|
53
57
|
// Read content
|
|
54
58
|
if (fs.existsSync(filePath)) {
|
|
55
59
|
let myConstantsContent = fs.readFileSync(filePath, { encoding: "utf8" });
|
|
@@ -59,7 +63,7 @@ function changeHtmlTag(filePath) {
|
|
|
59
63
|
fs.writeFileSync(filePath, myConstantsContent, { encoding: "utf8" });
|
|
60
64
|
//console.log(myConstantsContent);
|
|
61
65
|
} else {
|
|
62
|
-
console.log(`
|
|
66
|
+
console.log(`Warning: ${filePath} dont exists! continue...`);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -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
|
+
};
|