@yarkivaev/scada 2.3.88 → 2.3.90

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@yarkivaev/scada",
3
- "version": "2.3.88",
3
+ "version": "2.3.90",
4
4
  "description": "SCADA domain objects, state persistence, and plant monitoring",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "@clickhouse/client": "^1.0.0",
31
31
  "@modelcontextprotocol/sdk": "^1.24.3",
32
32
  "@yarkivaev/simple-server": "1.0.2",
33
- "@yarkivaev/source-to-sink": "1.3.7",
33
+ "@yarkivaev/source-to-sink": "1.3.8",
34
34
  "amqplib": "^0.10.9",
35
35
  "pg": "^8.0.0",
36
36
  "stompit": "^1.0.0",
@@ -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 [gated] = await decorate(machineId, [row]);
21
- const wanted = Array.isArray(parsed.splits)
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);