@yarkivaev/scada 2.3.88 → 2.3.89
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
|
@@ -9,6 +9,30 @@ async function handleOperatorWrite(gate, parsed, write) {
|
|
|
9
9
|
await write(audit);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
function proposedRows(row, parsed) {
|
|
13
|
+
if (!Array.isArray(parsed.splits)) {
|
|
14
|
+
return [row];
|
|
15
|
+
}
|
|
16
|
+
return parsed.splits.map((piece) => {
|
|
17
|
+
const tags = piece.tag ? [piece.tag] : [];
|
|
18
|
+
return { ...row, start: piece.start, start_time: piece.start, tags };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function tagsAt(parsed, index) {
|
|
23
|
+
if (!Array.isArray(parsed.splits)) {
|
|
24
|
+
return parsed.tags;
|
|
25
|
+
}
|
|
26
|
+
const tag = parsed.splits[index] && parsed.splits[index].tag;
|
|
27
|
+
return tag ? [tag] : [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function blockedTag(standing, painted, parsed) {
|
|
31
|
+
return painted.some((gated, index) => {
|
|
32
|
+
return !allowedSegmentTags(gated.options, standing, tagsAt(parsed, index));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
12
36
|
async function rejectUnknownTags(timeline, parsed, machineId, res, decorate) {
|
|
13
37
|
if (typeof timeline.rowAt !== 'function') {
|
|
14
38
|
return false;
|
|
@@ -17,15 +41,8 @@ async function rejectUnknownTags(timeline, parsed, machineId, res, decorate) {
|
|
|
17
41
|
if (!row) {
|
|
18
42
|
return false;
|
|
19
43
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
? parsed.splits.map((piece) => {
|
|
23
|
-
return piece.tag;
|
|
24
|
-
}).filter((id) => {
|
|
25
|
-
return id;
|
|
26
|
-
})
|
|
27
|
-
: parsed.tags;
|
|
28
|
-
if (allowedSegmentTags(gated.options, gated.tags, wanted)) {
|
|
44
|
+
const painted = await decorate(machineId, proposedRows(row, parsed));
|
|
45
|
+
if (!blockedTag(row.tags, painted, parsed)) {
|
|
29
46
|
return false;
|
|
30
47
|
}
|
|
31
48
|
errorResponse('BAD_REQUEST', `Tag is not in segment options for ${machineId}`, 400).send(res);
|