@ejfdelgado/ejflab-common 1.8.5 → 1.9.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 +1 -1
- package/src/flowchart/FlowChartExec.js +17 -8
- package/src/flowchart/steps/CommandMinio.js +6 -1
- package/src/flowchart/steps/CommandSet.js +1 -1
- package/src/flowchart/steps/StepBasic.js +33 -5
- package/src/flowchart/steps/StepMultiple.js +1 -1
- package/src/flowchart/steps/StepMultipleDone.js +1 -1
package/package.json
CHANGED
|
@@ -85,19 +85,28 @@ class FlowChartExec {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
saveBufferData(sourceId, pathId, buffer) {
|
|
88
|
-
|
|
89
|
-
if (!
|
|
90
|
-
|
|
88
|
+
let pathId2 = pathId;
|
|
89
|
+
if (!pathId2.startsWith(".")) {
|
|
90
|
+
pathId2 = "." + pathId2;
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
const compoundKey = `${sourceId}${pathId2}`;
|
|
93
|
+
const parts = /^(.*)\.([^.]+)$/.exec(compoundKey);
|
|
94
|
+
if (!parts) {
|
|
95
|
+
console.log("ERROR! Key must contain at least two parts separated with a dot");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const baseKey = parts[1];
|
|
99
|
+
const endKey = parts[2];
|
|
100
|
+
SimpleObj.recreate(this.bufferData, compoundKey, true);
|
|
101
|
+
const baseObject = SimpleObj.getValue(this.bufferData, baseKey, {});
|
|
102
|
+
baseObject[endKey] = buffer;
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
readBufferData(sourceId, pathId) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.bufferData[sourceId] = {};
|
|
106
|
+
if (!pathId.startsWith(".")) {
|
|
107
|
+
pathId = "." + pathId;
|
|
99
108
|
}
|
|
100
|
-
return this.bufferData
|
|
109
|
+
return SimpleObj.getValue(this.bufferData, `${sourceId}${pathId}`, null);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
registerPendingCall(id, val = true) {
|
|
@@ -8,12 +8,17 @@ class CommandMinio extends CommandBasic {
|
|
|
8
8
|
const minioSrv = this.context.getSuperContext().getMinioClient();
|
|
9
9
|
|
|
10
10
|
if (action == "write") {
|
|
11
|
-
|
|
11
|
+
let objectPath = this.args[2];
|
|
12
12
|
const sourcePath = this.args[3];
|
|
13
13
|
const metadata = this.args[4];
|
|
14
|
+
let extra = this.resolveArgument(objectPath);
|
|
15
|
+
if (typeof extra == "string") {
|
|
16
|
+
objectPath = extra;
|
|
17
|
+
}
|
|
14
18
|
//console.log(`CommandMinio.write bucket ${bucketName} objectPath ${objectPath} from ${sourcePath}`);
|
|
15
19
|
//console.log(metadata);
|
|
16
20
|
const bytes = this.resolveArgument(sourcePath);
|
|
21
|
+
//console.log(bytes);
|
|
17
22
|
// Armar el payload para minio
|
|
18
23
|
const payload = {
|
|
19
24
|
objectPath, bytes, metadata
|
|
@@ -204,7 +204,7 @@ class StepBasic {
|
|
|
204
204
|
// It reads from buffer
|
|
205
205
|
buffer = this.context.readBufferData(sourceId, pathId);
|
|
206
206
|
if (!buffer) {
|
|
207
|
-
console.log(`No buffer in ${sourceId}
|
|
207
|
+
console.log(`No buffer in ${sourceId}${pathId}`);
|
|
208
208
|
return undefined;
|
|
209
209
|
}
|
|
210
210
|
} else {
|
|
@@ -214,15 +214,43 @@ class StepBasic {
|
|
|
214
214
|
return buffer;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
const partsSource = /^(b\.([^.]+)
|
|
217
|
+
breakPath(val) {
|
|
218
|
+
const partsSource = /^(b\.([^.]+)([^\s]+)|d.(.+))$/i.exec(val);
|
|
219
219
|
if (partsSource == null) {
|
|
220
|
-
console.log(`${val} doesn't match ^(b\.([^.]+)
|
|
220
|
+
//console.log(`${val} doesn't match ^(b\.([^.]+)([^\s]+)|d.(.+))$`);
|
|
221
221
|
return undefined;
|
|
222
222
|
}
|
|
223
|
-
|
|
223
|
+
return {
|
|
224
|
+
isBuffer: !partsSource[4],
|
|
225
|
+
sourceId: partsSource[2],
|
|
226
|
+
pathId: partsSource[3],
|
|
227
|
+
completePath: partsSource[4]
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
resolveArgument(val) {
|
|
232
|
+
const breaked = this.breakPath(val);
|
|
233
|
+
let buffer = null;
|
|
234
|
+
if (breaked) {
|
|
235
|
+
buffer = this.readInputFrom(breaked.isBuffer, breaked.sourceId, breaked.pathId, breaked.completePath);
|
|
236
|
+
} else {
|
|
237
|
+
buffer = SimpleObj.getValue(this.context.data, val, null);
|
|
238
|
+
}
|
|
224
239
|
return buffer;
|
|
225
240
|
}
|
|
241
|
+
|
|
242
|
+
writeArgument(path, val) {
|
|
243
|
+
const braked = this.breakPath(path);
|
|
244
|
+
if (braked) {
|
|
245
|
+
if (braked.isBuffer) {
|
|
246
|
+
this.context.saveBufferData(braked.sourceId, braked.pathId, val);
|
|
247
|
+
} else {
|
|
248
|
+
SimpleObj.recreate(this.context.data, braked.completePath, val);
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
SimpleObj.recreate(this.context.data, path, val);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
226
254
|
}
|
|
227
255
|
|
|
228
256
|
module.exports = {
|
|
@@ -23,7 +23,7 @@ class StepMultiple extends StepBasic {
|
|
|
23
23
|
// console.log(`StepMultiple ${JSON.stringify(this.args)}`);
|
|
24
24
|
// Reads the list to iterate
|
|
25
25
|
const room = this.context.getRoom();
|
|
26
|
-
this.list =
|
|
26
|
+
this.list = this.resolveArgument(this.args[1]);
|
|
27
27
|
const WORKSPACE = SimpleObj.getValue(this.context.data, "env.WORKSPACE", ".");
|
|
28
28
|
const flowChartTemplateName = this.args[0];
|
|
29
29
|
const indexPath = this.args[2];
|
|
@@ -10,7 +10,7 @@ class StepMultipleDone extends StepBasic {
|
|
|
10
10
|
async execFirst() { }
|
|
11
11
|
|
|
12
12
|
async canContinue() {
|
|
13
|
-
this.list =
|
|
13
|
+
this.list = this.resolveArgument(this.args[0]);
|
|
14
14
|
if (!(this.list instanceof Array)) {
|
|
15
15
|
console.log(`In StepMultipleDone, warning ${this.args[0]} is not a list!`);
|
|
16
16
|
return true;
|