@ejfdelgado/ejflab-back 1.1.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.
Files changed (64) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +2 -0
  3. package/package.json +57 -0
  4. package/srv/AudIASrv.mjs +218 -0
  5. package/srv/AuthorizationSrv.mjs +213 -0
  6. package/srv/ComputeEngineSrv.mjs +289 -0
  7. package/srv/EmailHandler.mjs +54 -0
  8. package/srv/Image2MeshSrv.mjs +101 -0
  9. package/srv/ImagiationSrv.mjs +408 -0
  10. package/srv/KeysSrv.mjs +104 -0
  11. package/srv/MainHandler.mjs +140 -0
  12. package/srv/MainReplacer.mjs +77 -0
  13. package/srv/MfaSrv.mjs +266 -0
  14. package/srv/MilvusSrv.mjs +152 -0
  15. package/srv/MinioSrv.mjs +154 -0
  16. package/srv/MongoSrv.mjs +320 -0
  17. package/srv/MyError.mjs +48 -0
  18. package/srv/MyFileService.mjs +392 -0
  19. package/srv/MyFileServiceLocal.mjs +177 -0
  20. package/srv/MyPdf.mjs +37 -0
  21. package/srv/MyShell.mjs +205 -0
  22. package/srv/MySqlSrv.mjs +43 -0
  23. package/srv/Network.mjs +111 -0
  24. package/srv/OpenCVSrv.mjs +27 -0
  25. package/srv/PageSrv.mjs +234 -0
  26. package/srv/PayUSrv.mjs +186 -0
  27. package/srv/PayUSrvConstants.mjs +46 -0
  28. package/srv/PostgresSrv.mjs +109 -0
  29. package/srv/SecretsSrv.mjs +126 -0
  30. package/srv/SocketIOCall.mjs +494 -0
  31. package/srv/TupleSrv.mjs +141 -0
  32. package/srv/UtilesSrv.mjs +8 -0
  33. package/srv/callprocessors/AskIceServersProcessor.mjs +14 -0
  34. package/srv/callprocessors/AskRoomProcessor.mjs +15 -0
  35. package/srv/callprocessors/CallUserProcessor.mjs +17 -0
  36. package/srv/callprocessors/ChatSetSawProcessor.mjs +42 -0
  37. package/srv/callprocessors/CheckSrcResponseProcessor.mjs +28 -0
  38. package/srv/callprocessors/ClientChangeProcessor.mjs +19 -0
  39. package/srv/callprocessors/CloseVideoChatProcessor.mjs +16 -0
  40. package/srv/callprocessors/DestroyModelProcessor.mjs +16 -0
  41. package/srv/callprocessors/DisconnectProcessor.mjs +53 -0
  42. package/srv/callprocessors/GenericProcessor.mjs +7 -0
  43. package/srv/callprocessors/GetModelProcessor.mjs +11 -0
  44. package/srv/callprocessors/IncludeOtherPeersProcessor.mjs +12 -0
  45. package/srv/callprocessors/LoadFlowChartProcessor.mjs +103 -0
  46. package/srv/callprocessors/MakeAnswerProcessor.mjs +17 -0
  47. package/srv/callprocessors/OnIceCandidateProcessor.mjs +13 -0
  48. package/srv/callprocessors/OpenVideoChatProcessor.mjs +17 -0
  49. package/srv/callprocessors/PauseFlowChartProcessor.mjs +16 -0
  50. package/srv/callprocessors/ProcessResponseProcessor.mjs +123 -0
  51. package/srv/callprocessors/ReadSrcResponseProcessor.mjs +30 -0
  52. package/srv/callprocessors/RegisterProcessorProcessor.mjs +23 -0
  53. package/srv/callprocessors/RegisterSourceProcessor.mjs +22 -0
  54. package/srv/callprocessors/SendChatProcessor.mjs +71 -0
  55. package/srv/callprocessors/StartFlowChartProcessor.mjs +48 -0
  56. package/srv/callprocessors/StopFlowChartProcessor.mjs +16 -0
  57. package/srv/callprocessors/SubscribemeProcessor.mjs +13 -0
  58. package/srv/callprocessors/UpdateMyInformationProcessor.mjs +30 -0
  59. package/srv/common/FirebasConfig.mjs +160 -0
  60. package/srv/common/General.mjs +69 -0
  61. package/srv/common/MimeTypeMap.mjs +142 -0
  62. package/srv/common/MyStore.mjs +169 -0
  63. package/srv/common/Usuario.mjs +101 -0
  64. package/srv/common/Utilidades.mjs +43 -0
@@ -0,0 +1,17 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class CallUserProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ console.log(`CallUserProcessor... to ${args.to}`);
10
+ //console.log(JSON.stringify(args, null, 4));
11
+ // Redirects to other:
12
+ this.io.to(args.to).emit("callMade", {
13
+ offer: args.offer,
14
+ socket: this.socket.id,
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,42 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class ChatSetSawProcessor extends GenericProcessor {
5
+ MAX_COUNT_TIMESTAMS = 6;
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+ execute(args) {
10
+ const now = new Date().getTime();
11
+ const { author } = args;
12
+ const room = this.context.getRoomFromSocket(this.socket);
13
+ // Also notify last message time
14
+ const roomPublicData = this.context.getRoomLiveTupleModel("public");
15
+ if (roomPublicData.model.data) {
16
+ let lastmsg = roomPublicData.model.data.lastmsg;
17
+ if (!lastmsg) {
18
+ lastmsg = {};
19
+ roomPublicData.model.data.lastmsg = lastmsg;
20
+ lastmsg[room] = {}
21
+ }
22
+ let tiempos = lastmsg[room][author];
23
+ if (!tiempos) {
24
+ tiempos = {
25
+ last: now,
26
+ };
27
+ lastmsg[room][author] = tiempos;
28
+ } else {
29
+ tiempos.last = now;
30
+ }
31
+ const changePaths = [
32
+ "data",
33
+ "data.lastmsg",
34
+ `data.lastmsg.${room}`,
35
+ `data.lastmsg.${room}.${author}`,
36
+ `data.lastmsg.${room}.${author}.last`
37
+ ];
38
+ let changes2 = roomPublicData.builder.trackDifferences(roomPublicData.model, [], null, changePaths);
39
+ roomPublicData.model = roomPublicData.builder.affect(changes2);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,28 @@
1
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
2
+ import { GenericProcessor } from "./GenericProcessor.mjs";
3
+
4
+
5
+ export class CheckSrcResponseProcessor extends GenericProcessor {
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+ async execute(args) {
10
+ const { uid, metadata } = args;
11
+ const room = this.context.getRoomFromSocket(this.socket);
12
+ const instance = await this.context.getFlowChartExec(room);
13
+ if (!instance) {
14
+ return;
15
+ }
16
+ const roomData = this.context.getRoomLiveTupleModel(room);
17
+ roomData.model.data = instance.getData();
18
+ const configuration = SimpleObj.getValue(roomData.model, `data.state.sources.${uid}.data`, null);
19
+ if (configuration) {
20
+ for (let key in metadata) {
21
+ const oldData = configuration[key];
22
+ oldData.metadata = metadata[key];
23
+ }
24
+ let changes = roomData.builder.trackDifferences(roomData.model, [], null, ["data", "data.state", "data.state.sources", `data.state.sources.${uid}`]);
25
+ roomData.model = roomData.builder.affect(changes);
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,19 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class ClientChangeProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ const { changes } = args;
10
+ const socketId = this.socket.id;
11
+ const room = this.context.socketToRoom[socketId];
12
+ // Apply to local model
13
+ const roomData = this.context.getRoomLiveTupleModel(room);
14
+ roomData.model = roomData.builder.affect(changes);
15
+ //Share to others the change
16
+ //console.log(`emit to ${room} clientChange ${JSON.stringify(changes)}`);
17
+ this.io.to(room).emit("clientChange", changes);
18
+ }
19
+ }
@@ -0,0 +1,16 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class CloseVideoChatProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ console.log(`CloseVideoChatProcessor... to ${args.room}`);
10
+ //console.log(JSON.stringify(args, null, 4));
11
+ // Redirects to other:
12
+ this.io.to(args.room).emit("closeVideoChat", {
13
+ room: args.room,
14
+ });
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class DestroyModelProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ const socketId = this.socket.id;
10
+ const room = this.context.getRoomFromSocket(this.socket);
11
+ this.context.getRoomLiveTupleModel(room, true);
12
+ // Emmit to client do the same!
13
+ this.io.to(room).emit("setModel", { model: {} });
14
+ this.io.to(room).emit("flowchartUnloaded", {});
15
+ }
16
+ }
@@ -0,0 +1,53 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
3
+
4
+
5
+ export class DisconnectProcessor extends GenericProcessor {
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+
10
+ clearClientSocket(sources, socketId) {
11
+ for (let sourceKey in sources) {
12
+ const source = sources[sourceKey];
13
+ if (source.socket == socketId) {
14
+ source.socket = null;
15
+ break;
16
+ }
17
+ }
18
+ }
19
+
20
+ clearPersonFromPeople(people, socketId) {
21
+ for (let personId in people) {
22
+ const onePerson = people[personId];
23
+ if (onePerson.socket == socketId) {
24
+ delete people[personId]
25
+ break;
26
+ }
27
+ }
28
+ }
29
+
30
+ async execute(args) {
31
+ const socketId = this.socket.id;
32
+ // Busco los sources
33
+ const room = this.context.getRoomFromSocket(this.socket);
34
+ const instance = await this.context.getFlowChartExec(room);
35
+ const roomData = this.context.getRoomLiveTupleModel(room);
36
+ if (instance) {
37
+ roomData.model.data = instance.getData();
38
+ }
39
+ const sources = SimpleObj.getValue(roomData.model, "data.state.sources", {});
40
+ const processors = SimpleObj.getValue(roomData.model, "data.state.processors", {});
41
+ this.clearClientSocket(sources, socketId);
42
+ this.clearClientSocket(processors, socketId);
43
+ //
44
+ const people = SimpleObj.getValue(roomData.model, "data.people", null);
45
+ if (people) {
46
+ this.clearPersonFromPeople(people, socketId);
47
+ }
48
+
49
+ const observe = ["data", "data.state", "data.state.sources", "data.state.processors", "data.people"];
50
+ let changes = roomData.builder.trackDifferences(roomData.model, [], null, observe);
51
+ roomData.model = roomData.builder.affect(changes);
52
+ }
53
+ }
@@ -0,0 +1,7 @@
1
+ export class GenericProcessor {
2
+ constructor(context, io, socket) {
3
+ this.context = context;
4
+ this.io = io;
5
+ this.socket = socket;
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class GetModelProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ this.context.sendCurrentModel(this.socket);
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class IncludeOtherPeersProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ console.log(`IncludeOtherPeersProcessor... to ${args.to}`);
10
+ this.io.to(args.to).emit("includeOtherPeers", {});
11
+ }
12
+ }
@@ -0,0 +1,103 @@
1
+ import { FlowChartExec } from "@ejfdelgado/ejflab-common/src/flowchart/FlowChartExec.js";
2
+ import { GenericProcessor } from "./GenericProcessor.mjs";
3
+ import fs from "fs";
4
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
5
+ import { Buffer } from 'buffer';
6
+
7
+ const WORKSPACE = process.env.WORKSPACE;
8
+
9
+ export class LoadFlowChartProcessor extends GenericProcessor {
10
+ constructor(context, io, socket) {
11
+ super(context, io, socket);
12
+ }
13
+
14
+ completePaths(objeto) {
15
+ if (!objeto) {
16
+ return;
17
+ }
18
+ for (let llave in objeto) {
19
+ let valor = objeto[llave];
20
+ if (typeof valor == "string") {
21
+ valor = valor.replaceAll("${WORKSPACE}", WORKSPACE);
22
+ objeto[llave] = valor;
23
+ }
24
+ }
25
+ }
26
+
27
+ async execute(args) {
28
+ let { names, conf, dataPath, dataVal, room, skipValidation } = args;
29
+ console.log(`LoadFlowChartProcessor at room ${room}...`);
30
+ this.completePaths(names);
31
+ this.completePaths(dataPath);
32
+ if (!room) {
33
+ if (this.socket) {
34
+ room = this.context.getRoomFromSocket(this.socket);
35
+ } else {
36
+ room = "public";
37
+ }
38
+ }
39
+ console.log(`Creating flowchart into ${room}`);
40
+ let instance = null;
41
+ if (skipValidation === false) {
42
+ instance = await this.context.getFlowChartExec(room);
43
+ if (instance && instance.isRunning()) {
44
+ console.log("It is already running, must stop or pause first.");
45
+ return;
46
+ }
47
+ }
48
+
49
+ let data = {};
50
+ if (dataPath) {
51
+ const keysData = Object.keys(dataPath);
52
+ for (let i = 0; i < keysData.length; i++) {
53
+ const keyData = keysData[i];
54
+ const dataObject = JSON.parse(fs.readFileSync(dataPath[keyData], 'utf8'));
55
+ if (keyData.length == 0) {
56
+ Object.assign(data, dataObject);
57
+ } else {
58
+ SimpleObj.recreate(data, keyData, dataObject);
59
+ }
60
+ }
61
+ }
62
+
63
+ if (dataVal) {
64
+ const keysDataVal = Object.keys(dataVal);
65
+ for (let i = 0; i < keysDataVal.length; i++) {
66
+ const keyData = keysDataVal[i];
67
+ const dataObject = dataVal[keyData];
68
+ SimpleObj.recreate(data, keyData, dataObject);
69
+ }
70
+ }
71
+
72
+ data['scope'] = { room, progress: 0 };
73
+
74
+ // Leer el archivo y su data
75
+ instance = new FlowChartExec();
76
+ instance.setSocketIO(this.io, room);
77
+ instance.setConf(conf);
78
+ instance.setData(data);
79
+ this.context.setFlowChartExec(room, instance);
80
+ const flowchart = instance.loadFlowChart(names);
81
+ // Asignarlo al modelo
82
+ const roomData = this.context.getRoomLiveTupleModel(room);
83
+
84
+ roomData.model.currentNodes = [];
85
+ roomData.model.history = [];
86
+ roomData.model.flowchart = flowchart;
87
+ roomData.model.data = data;
88
+ roomData.model.version = 0;
89
+ // So it will be capable to reload from this point
90
+ roomData.model.request = Buffer.from(JSON.stringify(args), "utf8").toString("base64");
91
+ const changes = roomData.builder.trackDifferences(roomData.model);
92
+ roomData.model = roomData.builder.affect(changes);
93
+
94
+ // Notify
95
+ const statusFun = (status) => {
96
+ if (status === false) {
97
+ this.io.to(room).emit("flowchartLoaded", {});
98
+ roomData.statusEmitter.off("status", statusFun);
99
+ }
100
+ };
101
+ roomData.statusEmitter.on("status", statusFun);
102
+ }
103
+ }
@@ -0,0 +1,17 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class MakeAnswerProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ console.log(`MakeAnswerProcessor... to ${args.to}`);
10
+ //console.log(JSON.stringify(args, null, 4));
11
+ // Redirects to other:
12
+ this.io.to(args.to).emit("answerMade", {
13
+ socket: this.socket.id,
14
+ answer: args.answer
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class OnIceCandidateProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ // Just redirects to room
10
+ args.from = this.socket.id;
11
+ this.io.to(args.to).emit("onicecandidate", args);
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+
4
+ export class OpenVideoChatProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ execute(args) {
9
+ console.log(`OpenVideoChatProcessor... to ${args.uuid}`);
10
+ // Redirects to other:
11
+ // Translate args.uuid to socketId of args.room
12
+ const socketId = this.context.getSocketIdFromRoomAndUUID("public", args.uuid);
13
+ this.io.to(socketId).emit("openVideoChat", {
14
+ room: args.room,
15
+ });
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+
3
+ export class PauseFlowChartProcessor extends GenericProcessor {
4
+ constructor(context, io, socket) {
5
+ super(context, io, socket);
6
+ }
7
+ async execute(args) {
8
+ const room = this.context.getRoomFromSocket(this.socket);
9
+ const instance = await this.context.getFlowChartExec(room);
10
+ if (!instance) {
11
+ console.log(`No instance to stop`);
12
+ return;
13
+ }
14
+ instance.pause();
15
+ }
16
+ }
@@ -0,0 +1,123 @@
1
+ import { GenericProcessor } from "./GenericProcessor.mjs";
2
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
3
+
4
+ export class ProcessResponseProcessor extends GenericProcessor {
5
+ constructor(context, io, socket) {
6
+ super(context, io, socket);
7
+ }
8
+ async execute(args) {
9
+ const { processorId, id, data } = args;
10
+ let room = "";
11
+ if (args.room) {
12
+ room = args.room;
13
+ } else if (this.socket) {
14
+ room = this.context.getRoomFromSocket(this.socket);
15
+ }
16
+
17
+ if (!room) {
18
+ console.log(`No room provided`);
19
+ return;
20
+ }
21
+
22
+ const instance = await this.context.getFlowChartExec(room);
23
+ if (!instance) {
24
+ console.log(`No instance found for room ${room}`);
25
+ return;
26
+ }
27
+
28
+ // Check for ignore timedout messages
29
+ if (!instance.existsPendingCall(id)) {
30
+ console.log(`WARNING: Ignoring message id ${id}`);
31
+ return;
32
+ }
33
+
34
+ // Handling errors
35
+ if (data["error"]) {
36
+ console.log(`Processors name ${processorId} returns an error ${JSON.stringify(data["error"])}`);
37
+ // Halt everything
38
+ if (!instance.canRetry(id, new Error(data["error"]))) {
39
+ instance.stop();
40
+ return;
41
+ }
42
+ }
43
+
44
+ // Reads output description
45
+ const roomData = this.context.getRoomLiveTupleModel(room);
46
+
47
+ const partsName = /^([^\.\d]+)(\d*)\.?([^'.]*)$/.exec(processorId);
48
+ if (!partsName) {
49
+ console.log(`The processor name ${processorId} does not match ^([^\.\d]+)(\d*)\.?([^'.]*)$`);
50
+ return;
51
+ }
52
+ let method = "main";
53
+ const processorMethod = partsName[0];
54
+ const processorName = partsName[1];
55
+ const instanceNumber = partsName[2];
56
+ let processorInstance = partsName[1];
57
+ if (typeof partsName[2] == "string") {
58
+ processorInstance += instanceNumber;
59
+ }
60
+ if (typeof partsName[3] == "string" && partsName[3].trim().length > 0) {
61
+ method = partsName[3];
62
+ }
63
+
64
+ const outputConnectionsConf = SimpleObj.getValue(roomData.model, `flowchart.flux.${processorInstance}.${method}.out`, null);
65
+ if (!outputConnectionsConf) {
66
+ console.log(`WARN: No output connection flux configuration for ${processorInstance}.${method}`);
67
+ //return;
68
+ }
69
+
70
+ roomData.model.data = instance.getData();
71
+ let countLocalChanges = 0;
72
+ if (!!outputConnectionsConf) {
73
+ outputConnectionsConf.forEach((outputConnectionsConfOne) => {
74
+ const { key, val } = outputConnectionsConfOne;
75
+ const output = val;
76
+ const dataLocal = data[key];
77
+ if (dataLocal != undefined) {
78
+ // Sends dataResponse to val
79
+ const outputParts = /^(b\.([^.]+)\.([^.]+)|d\.(.+))$/i.exec(output);
80
+ if (!outputParts) {
81
+ console.log(`${output} does not match ^(b\.([^.]+)\.([^.]+)|d\.(.+))$`);
82
+ return;
83
+ }
84
+ if (!outputParts[4]) {
85
+ const processorIdLocal = outputParts[2];
86
+ const sourcePath = outputParts[3];
87
+ instance.saveBufferData(processorIdLocal, sourcePath, dataLocal);
88
+ // Publish to others
89
+ const destiny = `${room}.${output}`;
90
+ //console.log(`Publishing to ${destiny} ok?`);
91
+ this.io.to(destiny).emit("processResponse", {
92
+ processorId,
93
+ sourcePath,
94
+ data: dataLocal
95
+ });
96
+ } else {
97
+ // Affect the model in the given point
98
+ const path = outputParts[4];
99
+ SimpleObj.recreate(roomData.model.data, path, dataLocal);
100
+ countLocalChanges++;
101
+ // Publish to others
102
+ const destiny = `${room}.d.${path}`;
103
+ //console.log(`Publishing to ${destiny} ok?`);
104
+ this.io.to(destiny).emit("processResponse", {
105
+ processorId,
106
+ sourcePath: path,
107
+ data: dataLocal
108
+ });
109
+ }
110
+ } else {
111
+ console.log(`Skip output connection ${val} with no value`);
112
+ }
113
+ });
114
+ }
115
+
116
+ if (countLocalChanges > 0) {
117
+ const changes = roomData.builder.trackDifferences(roomData.model, [], null, ["data"]);
118
+ roomData.model = roomData.builder.affect(changes);
119
+ }
120
+
121
+ instance.clearPendingCall(id);
122
+ }
123
+ }
@@ -0,0 +1,30 @@
1
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
2
+ import { GenericProcessor } from "./GenericProcessor.mjs";
3
+
4
+
5
+ export class ReadSrcResponseProcessor extends GenericProcessor {
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+ async execute(args) {
10
+ const { response, sourcePair, id } = args;
11
+ const room = this.context.getRoomFromSocket(this.socket);
12
+ const instance = await this.context.getFlowChartExec(room);
13
+ if (!instance) {
14
+ return;
15
+ }
16
+ const sourceId = sourcePair.split(".")[0];
17
+ for (let sourcePath in response) {
18
+ const buffer = response[sourcePath];
19
+ instance.saveBufferData(sourceId, sourcePath, buffer);
20
+ // Publish to others
21
+ this.io.to(`${room}.${sourceId}.${sourcePath}`).emit("readSrcResponse", {
22
+ sourceId,
23
+ sourcePath,
24
+ buffer
25
+ });
26
+ }
27
+ instance.clearPendingCall(id);
28
+
29
+ }
30
+ }
@@ -0,0 +1,23 @@
1
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
2
+ import { GenericProcessor } from "./GenericProcessor.mjs";
3
+
4
+
5
+ export class RegisterProcessorProcessor extends GenericProcessor {
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+ async execute(args) {
10
+ const { uid } = args;
11
+ const room = this.context.getRoomFromSocket(this.socket);
12
+ const instance = await this.context.getFlowChartExec(room);
13
+ if (!instance) {
14
+ console.log(`No flowchart for room ${room}`);
15
+ return;
16
+ }
17
+ const roomData = this.context.getRoomLiveTupleModel(room);
18
+ roomData.model.data = instance.getData();
19
+ SimpleObj.recreate(roomData.model, `data.state.processors.${uid}.socket`, this.socket.id);
20
+ let changes = roomData.builder.trackDifferences(roomData.model, [], null, ["data", "data.state", "data.state.processors"]);
21
+ roomData.model = roomData.builder.affect(changes);
22
+ }
23
+ }
@@ -0,0 +1,22 @@
1
+ import { SimpleObj } from "@ejfdelgado/ejflab-common/src/SimpleObj.js";
2
+ import { GenericProcessor } from "./GenericProcessor.mjs";
3
+
4
+
5
+ export class RegisterSourceProcessor extends GenericProcessor {
6
+ constructor(context, io, socket) {
7
+ super(context, io, socket);
8
+ }
9
+ async execute(args) {
10
+ const { uid } = args;
11
+ const room = this.context.getRoomFromSocket(this.socket);
12
+ const instance = await this.context.getFlowChartExec(room);
13
+ if (!instance) {
14
+ return;
15
+ }
16
+ const roomData = this.context.getRoomLiveTupleModel(room);
17
+ roomData.model.data = instance.getData();
18
+ SimpleObj.recreate(roomData.model, `data.state.sources.${uid}.socket`, this.socket.id);
19
+ let changes = roomData.builder.trackDifferences(roomData.model, [], null, ["data", "data.state", "data.state.sources"]);
20
+ roomData.model = roomData.builder.affect(changes);
21
+ }
22
+ }