@yarkivaev/scada 2.12.2 → 2.14.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/README.md +1 -1
- package/db/migrations/E0013__history_staged_corrections.sql +1 -1
- package/db/migrations/E0017__history_live_covering.sql +1 -1
- package/db/migrations/E0025__history_processor_properties.sql +76 -0
- package/db/migrations/E0026__history_processor_properties_grants.sql +1 -0
- package/index.js +43 -2
- package/package.json +3 -2
- package/src/application/control/controlClient.js +1 -1
- package/src/application/control/createOnlyJSON.js +50 -0
- package/src/application/control/index.js +2 -0
- package/src/application/control/jsonAssignments.js +30 -0
- package/src/application/foldedMetricsSink.js +1 -1
- package/src/application/mcp/loadMetricSeries.js +69 -0
- package/src/application/mcp/locateMachineMetric.js +25 -0
- package/src/application/mcp/metricQueryPorts.js +78 -0
- package/src/application/mcp/parseBearerTokens.js +43 -0
- package/src/application/runtime/assignment.js +4 -1
- package/src/application/runtime/collectorStartup.js +23 -0
- package/src/application/runtime/index.js +2 -0
- package/src/application/runtime/runCollector.js +46 -9
- package/src/application/runtime/runtimeServices.js +20 -2
- package/src/application/runtime/spoolHistory.js +12 -12
- package/src/application/runtime/spoolSurface.js +2 -2
- package/src/application/runtime/spooledOutput.js +27 -0
- package/src/application/siteServer.js +2 -2
- package/src/application/supervisorSink.js +5 -6
- package/src/application/sync/publishingOperations.js +52 -0
- package/src/application/sync/siteSync.js +1 -1
- package/src/application/sync/siteSyncRows.js +1 -1
- package/src/application/sync/siteSyncSites.js +1 -1
- package/src/application/telemetry/telemetryBackfill.js +127 -0
- package/src/application/timelineOperatorFromEnv.js +1 -1
- package/src/domain/ingest/telemetryTimestamp.js +7 -0
- package/src/domain/segment/dispatch.js +19 -17
- package/src/domain/segment/historyFold.js +2 -1
- package/src/domain/segment/intervalFold.js +1 -1
- package/src/domain/segment/segmentContinue.js +1 -1
- package/src/infrastructure/catalog/tagCatalog.js +7 -11
- package/src/infrastructure/deploy/applyWhenChanged.js +15 -0
- package/src/infrastructure/deploy/deploymentKube.js +35 -0
- package/src/infrastructure/deploy/executeKubeSeed.js +24 -0
- package/src/infrastructure/deploy/executeRelease.js +8 -11
- package/src/infrastructure/deploy/operatePostgresMaintenance.js +85 -0
- package/src/infrastructure/deploy/postgresMaintenancePlan.js +54 -0
- package/src/infrastructure/deploy/postgresRestoreObjects.js +73 -0
- package/src/infrastructure/deploy/preflightKubeStorage.js +76 -0
- package/src/infrastructure/deploy/prepareKubePrerequisites.js +95 -0
- package/src/infrastructure/deploy/verifyCollectorCoverage.js +43 -0
- package/src/infrastructure/deploy/verifyPeerBrokerPerimeter.js +24 -0
- package/src/infrastructure/http/plant/json/decisionJson.js +1 -1
- package/src/infrastructure/http/plant/routes/timelineRoute.js +1 -1
- package/src/infrastructure/http/plant/timelineOperator.js +2 -2
- package/src/infrastructure/ingest/db/migrationProfile.js +2 -1
- package/src/infrastructure/ingest/mysql40/byteReader.js +51 -0
- package/src/infrastructure/ingest/mysql40/mysql40.js +116 -0
- package/src/infrastructure/ingest/mysql40/packets.js +72 -0
- package/src/infrastructure/ingest/mysql40/resultRows.js +92 -0
- package/src/infrastructure/ingest/mysql40/scramble.js +89 -0
- package/src/infrastructure/ingest/pipelines/segmentPipeline.js +38 -14
- package/src/infrastructure/ingest/sinks/contiguousPhases.js +1 -1
- package/src/infrastructure/ingest/sinks/continuedSegments.js +9 -8
- package/src/infrastructure/ingest/sinks/decisionSegment.js +1 -1
- package/src/infrastructure/ingest/sinks/foldingSegments.js +16 -10
- package/src/infrastructure/ingest/sinks/{foldCastingPhases.js → repairPhaseOverlaps.js} +17 -29
- package/src/infrastructure/ingest/sinks/retagSink.js +1 -1
- package/src/infrastructure/ingest/sinks/userDecisionSink.js +1 -1
- package/src/infrastructure/ingest/telemetry/edgeTelemetryRuntime.js +83 -0
- package/src/infrastructure/ingest/telemetry/historyTelemetryMetrics.js +15 -0
- package/src/infrastructure/ingest/telemetry/opcuaLocate.js +2 -2
- package/src/infrastructure/ingest/telemetry/replayStoredTelemetry.js +125 -0
- package/src/infrastructure/ingest/telemetry/telemetryIngest.js +52 -0
- package/src/infrastructure/ingest/telemetry/telemetryReplay.js +15 -0
- package/src/infrastructure/management/kubeServiceAccount.js +43 -0
- package/src/infrastructure/management/kubectlPortForward.js +27 -0
- package/src/infrastructure/mdmesh/hmiApplication.js +64 -0
- package/src/infrastructure/mdmesh/hmiControl.js +85 -0
- package/src/infrastructure/mdmesh/hmiFile.js +69 -0
- package/src/infrastructure/mdmesh/hmiMonitor.js +53 -0
- package/src/infrastructure/mdmesh/hmiReconcile.js +170 -0
- package/src/infrastructure/mdmesh/hmiRuntime.js +33 -0
- package/src/infrastructure/mdmesh/index.js +7 -0
- package/src/infrastructure/mdmesh/mdmeshClient.js +72 -0
- package/src/infrastructure/messaging/ownership/edgeSitesFromEnv.js +137 -0
- package/src/infrastructure/messaging/rabbitmq/reconcile.js +71 -12
- package/src/infrastructure/messaging/stomp/retagBody.js +1 -1
- package/src/infrastructure/messaging/stomp/segmentRetags.js +1 -1
- package/src/infrastructure/opcua/health.js +91 -0
- package/src/infrastructure/opcua/index.js +1 -0
- package/src/infrastructure/persistence/clickhouse/historyObservations.js +149 -0
- package/src/infrastructure/persistence/clickhouse/historyRetention.js +94 -0
- package/src/infrastructure/persistence/clickhouse/historySourceIdentity.js +34 -0
- package/src/infrastructure/persistence/clickhouse/insertMetricRows.js +19 -0
- package/src/infrastructure/persistence/clickhouse/jsonMetrics.js +26 -0
- package/src/infrastructure/persistence/clickhouse/localHistory.js +51 -0
- package/src/infrastructure/persistence/clickhouse/metricsState.js +92 -0
- package/src/infrastructure/persistence/clickhouse/rowBinary.js +38 -0
- package/src/infrastructure/persistence/clickhouse/telemetryTarget.js +41 -0
- package/src/infrastructure/persistence/pg/checkpoints.js +35 -9
- package/src/infrastructure/persistence/pg/history.js +74 -56
- package/src/infrastructure/persistence/pg/historyContext.js +34 -17
- package/src/infrastructure/persistence/pg/historyCorrection.js +5 -2
- package/src/infrastructure/persistence/pg/historyFence.js +1 -1
- package/src/infrastructure/persistence/pg/historyNativeBounds.js +31 -0
- package/src/infrastructure/persistence/pg/historyPurge.js +26 -0
- package/src/infrastructure/persistence/pg/historySeed.js +3 -3
- package/src/infrastructure/persistence/pg/historySession.js +15 -0
- package/src/infrastructure/persistence/pg/intervalFoldPg.js +1 -1
- package/src/infrastructure/persistence/pg/prepareRuntimeRole.js +67 -0
- package/src/infrastructure/persistence/pg/telemetrySource.js +64 -0
- package/src/infrastructure/persistence/postgresPool.js +6 -1
- package/src/infrastructure/persistence/runtime/taskStateSqlite.js +37 -0
- package/src/infrastructure/persistence/stateDataFromPool.js +16 -2
- package/src/infrastructure/replication/canonicalJSON.js +15 -0
- package/src/infrastructure/replication/postgresSnapshotReplica.js +129 -0
- package/src/infrastructure/replication/postgresSnapshotRuntime.js +40 -0
- package/src/infrastructure/replication/snapshotSync.js +61 -0
- package/src/infrastructure/replication/tableSnapshotFormat.js +50 -0
- package/src/infrastructure/streams/modbusSource.js +1 -1
- package/src/infrastructure/streams/stompSend.js +1 -1
- package/src/infrastructure/sync/operationAmqp.js +26 -0
- package/src/infrastructure/sync/operationEvent.js +10 -0
- package/src/infrastructure/tls/mirrorTLSSecret.js +37 -0
- package/src/infrastructure/tls/mutualJSON.js +79 -0
- package/src/infrastructure/tls/tlsMaterial.js +57 -0
- package/stream-processing/src/main/scala/scada/processing/infra/state/AtomicStateFile.scala +7 -0
- package/stream-processing/src/main/scala/scada/processing/infra/state/StateJournal.scala +22 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/HistoryClient.scala +10 -1
- package/stream-processing/src/main/scala/scada/processing/runtime/LiveWorker.scala +70 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/LocalHistory.scala +2 -8
- package/stream-processing/src/main/scala/scada/processing/runtime/StatefulHistory.scala +108 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/TimelinePublication.scala +43 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/WorkerStores.scala +43 -0
- package/src/infrastructure/catalog/tag-catalog.json +0 -27
|
@@ -13,9 +13,14 @@ function uniqueStarts(records) {
|
|
|
13
13
|
return [...kept.values()];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
async function foldMachine(runner, machine, batch) {
|
|
16
|
+
async function foldMachine(runner, machine, batch, { preserveCoverage, isAuthoritative }) {
|
|
17
|
+
const inferred = batch.filter((row) => { return !isAuthoritative(row); });
|
|
18
|
+
if (!inferred.length || (preserveCoverage && inferred.every((row) => { return row.duration === 0; }))) {
|
|
19
|
+
return uniqueStarts(batch);
|
|
20
|
+
}
|
|
17
21
|
await runner.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [`history:${machine}`]);
|
|
18
|
-
|
|
22
|
+
const folded = await historyAbsorb(runner, machine, uniqueStarts(historyFold([], inferred)));
|
|
23
|
+
return folded.concat(batch.filter(isAuthoritative));
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
function grouped(records) {
|
|
@@ -28,10 +33,10 @@ function grouped(records) {
|
|
|
28
33
|
return groups;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
function foldAll(runner, groups) {
|
|
36
|
+
function foldAll(runner, groups, policy) {
|
|
32
37
|
return [...groups].reduce(async (prior, [machine, batch]) => {
|
|
33
38
|
const acc = await prior;
|
|
34
|
-
acc.push(...await foldMachine(runner, machine, batch));
|
|
39
|
+
acc.push(...await foldMachine(runner, machine, batch, policy));
|
|
35
40
|
return acc;
|
|
36
41
|
}, Promise.resolve([]));
|
|
37
42
|
}
|
|
@@ -43,15 +48,15 @@ function stamped(records) {
|
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
async function writeOwned(pool, inner, records) {
|
|
51
|
+
async function writeOwned(pool, inner, records, policy) {
|
|
47
52
|
if (typeof pool.connect !== 'function') {
|
|
48
|
-
const next = stamped(uniqueStarts(await foldAll(pool, grouped(records))));
|
|
53
|
+
const next = stamped(uniqueStarts(await foldAll(pool, grouped(records), policy)));
|
|
49
54
|
return inner.write(next, pool);
|
|
50
55
|
}
|
|
51
56
|
const client = await pool.connect();
|
|
52
57
|
try {
|
|
53
58
|
await client.query('BEGIN');
|
|
54
|
-
const next = stamped(uniqueStarts(await foldAll(client, grouped(records))));
|
|
59
|
+
const next = stamped(uniqueStarts(await foldAll(client, grouped(records), policy)));
|
|
55
60
|
const result = await inner.write(next, client);
|
|
56
61
|
await client.query('COMMIT');
|
|
57
62
|
return result;
|
|
@@ -74,13 +79,14 @@ async function writeOwned(pool, inner, records) {
|
|
|
74
79
|
* const sink = foldingSegments(segmentSink, pool);
|
|
75
80
|
* await sink.write([record], client);
|
|
76
81
|
*/
|
|
77
|
-
export default function foldingSegments(inner, pool) {
|
|
82
|
+
export default function foldingSegments(inner, pool, { preserveCoverage = false, isAuthoritative = () => { return false; } } = {}) {
|
|
83
|
+
const policy = { preserveCoverage, isAuthoritative };
|
|
78
84
|
return {
|
|
79
85
|
async write(records, client) {
|
|
80
86
|
if (client && typeof client.query === 'function') {
|
|
81
|
-
return inner.write(stamped(uniqueStarts(await foldAll(client, grouped(records)))), client);
|
|
87
|
+
return inner.write(stamped(uniqueStarts(await foldAll(client, grouped(records), policy))), client);
|
|
82
88
|
}
|
|
83
|
-
return writeOwned(pool, inner, records);
|
|
89
|
+
return writeOwned(pool, inner, records, policy);
|
|
84
90
|
}
|
|
85
91
|
};
|
|
86
92
|
}
|
|
@@ -5,7 +5,7 @@ function startOf(row) {
|
|
|
5
5
|
return new Date(row.start_time).getTime();
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
function pinLive(rows) {
|
|
8
|
+
function pinLive(rows, preserveCoverage) {
|
|
9
9
|
if (!rows.length) {
|
|
10
10
|
return rows;
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ function pinLive(rows) {
|
|
|
15
15
|
return ordered.map((row, i, all) => {
|
|
16
16
|
const copy = { ...row };
|
|
17
17
|
if (i === all.length - 1) {
|
|
18
|
-
if (copy.duration === 0) {
|
|
18
|
+
if (!preserveCoverage && copy.duration === 0) {
|
|
19
19
|
copy.end_time = copy.start_time;
|
|
20
20
|
}
|
|
21
21
|
return copy;
|
|
@@ -74,10 +74,10 @@ function foldRows(rows) {
|
|
|
74
74
|
}, Promise.resolve([]));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async function foldMachine(runner, machine) {
|
|
77
|
+
async function foldMachine(runner, machine, preserveCoverage) {
|
|
78
78
|
await runner.query('SELECT pg_advisory_xact_lock(hashtextextended($1, 0))', [`history:${machine}`]);
|
|
79
79
|
const stored = await loadPhases(runner, machine);
|
|
80
|
-
const folded = pinLive(await foldRows(stored));
|
|
80
|
+
const folded = pinLive(await foldRows(stored), preserveCoverage);
|
|
81
81
|
const kept = new Set(folded.map(startOf));
|
|
82
82
|
await dropStarts(runner, machine, stored.filter((row) => {
|
|
83
83
|
return !kept.has(startOf(row));
|
|
@@ -88,15 +88,15 @@ async function foldMachine(runner, machine) {
|
|
|
88
88
|
}, Promise.resolve());
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
async function foldOwned(pool, machine) {
|
|
91
|
+
async function foldOwned(pool, machine, preserveCoverage) {
|
|
92
92
|
if (typeof pool.connect !== 'function') {
|
|
93
|
-
await foldMachine(pool, machine);
|
|
93
|
+
await foldMachine(pool, machine, preserveCoverage);
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const client = await pool.connect();
|
|
97
97
|
try {
|
|
98
98
|
await client.query('BEGIN');
|
|
99
|
-
await foldMachine(client, machine);
|
|
99
|
+
await foldMachine(client, machine, preserveCoverage);
|
|
100
100
|
await client.query('COMMIT');
|
|
101
101
|
} catch (error) {
|
|
102
102
|
await client.query('ROLLBACK');
|
|
@@ -106,9 +106,9 @@ async function foldOwned(pool, machine) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
async function foldOwnedRetry(pool, machine, attempt) {
|
|
109
|
+
async function foldOwnedRetry(pool, machine, attempt, preserveCoverage) {
|
|
110
110
|
try {
|
|
111
|
-
await foldOwned(pool, machine);
|
|
111
|
+
await foldOwned(pool, machine, preserveCoverage);
|
|
112
112
|
} catch (error) {
|
|
113
113
|
if (error?.code !== '40P01' || attempt >= 7) {
|
|
114
114
|
throw error;
|
|
@@ -116,32 +116,20 @@ async function foldOwnedRetry(pool, machine, attempt) {
|
|
|
116
116
|
await new Promise((resolve) => {
|
|
117
117
|
setTimeout(resolve, 40 * (attempt + 1));
|
|
118
118
|
});
|
|
119
|
-
await foldOwnedRetry(pool, machine, attempt + 1);
|
|
119
|
+
await foldOwnedRetry(pool, machine, attempt + 1, preserveCoverage);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
* @param {string[]} protectedTracks - driver machines with authoritative phases
|
|
128
|
-
* @returns {Promise<void>}
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* await foldCastingPhases(pool);
|
|
132
|
-
*/
|
|
133
|
-
export default async function foldCastingPhases(pool, protectedTracks = []) {
|
|
134
|
-
const found = await pool.query(
|
|
135
|
-
`SELECT DISTINCT machine FROM segments WHERE machine LIKE 'cm%' AND kind='phase' AND NOT (machine = ANY($1::text[]))`,
|
|
136
|
-
[protectedTracks]
|
|
137
|
-
);
|
|
138
|
-
await found.rows.reduce(async (prior, row) => {
|
|
123
|
+
/** Repairs overlapping phases on application-selected machines outside authoritative tracks. */
|
|
124
|
+
export default async function repairPhaseOverlaps(pool, machines = [], protectedTracks = [], { preserveCoverage = false } = {}) {
|
|
125
|
+
const selected = [...new Set(machines)].filter((machine) => { return !protectedTracks.includes(machine); });
|
|
126
|
+
await selected.reduce(async (prior, machine) => {
|
|
139
127
|
await prior;
|
|
140
128
|
try {
|
|
141
|
-
await foldOwnedRetry(pool,
|
|
142
|
-
process.stderr.write(`[supervisor-sink] folded
|
|
129
|
+
await foldOwnedRetry(pool, machine, 0, preserveCoverage);
|
|
130
|
+
process.stderr.write(`[supervisor-sink] folded overlapping phases for ${machine}\n`);
|
|
143
131
|
} catch (error) {
|
|
144
|
-
processingErrorLog('
|
|
132
|
+
processingErrorLog('repair_phase_overlaps', error, { machine });
|
|
145
133
|
}
|
|
146
134
|
}, Promise.resolve());
|
|
147
135
|
}
|
|
@@ -11,7 +11,7 @@ import processingErrorLog from '../processingErrorLog.js';
|
|
|
11
11
|
* const pool = new pg.Pool({ connectionString: url });
|
|
12
12
|
* const sink = retagSink(pool);
|
|
13
13
|
* sink.accept({ machine: 'm2', start_time: '2024-01-01T00:00:00.000Z',
|
|
14
|
-
* tags: '["
|
|
14
|
+
* tags: '["needs_review"]', properties: '{}' });
|
|
15
15
|
*
|
|
16
16
|
* @param {object} pool - pg Pool (or compatible) with query() method
|
|
17
17
|
* @returns {object} Sink with accept() method
|
|
@@ -12,7 +12,7 @@ import { applyDecision } from './decisionSegment.js';
|
|
|
12
12
|
* sink.accept({ machine: 'm2', startTime: '2024-01-01T00:00:00.000Z',
|
|
13
13
|
* username: 'Ivan Petrov', operatorId: 2,
|
|
14
14
|
* decidedAt: '2024-01-01T00:01:00.000Z',
|
|
15
|
-
* payload: '{"tags":["
|
|
15
|
+
* payload: '{"tags":["needs_review"]}' });
|
|
16
16
|
*
|
|
17
17
|
* @param {object} pool - pg Pool (or compatible) with query() method
|
|
18
18
|
* @returns {object} Sink with accept() method
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { createClient } from '@clickhouse/client';
|
|
3
|
+
import { openPostgresPool as openPool } from '../../persistence/postgresPool.js';
|
|
4
|
+
import metricsState from '../../persistence/clickhouse/metricsState.js';
|
|
5
|
+
import historyMetrics from './historyTelemetryMetrics.js';
|
|
6
|
+
|
|
7
|
+
function responseFor(inputs, path, response) {
|
|
8
|
+
if (!['/live', '/ready', '/status'].includes(path)) {
|
|
9
|
+
response.writeHead(404).end();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const queues = inputs.map((input) => { return input.status(); });
|
|
13
|
+
const ready = queues.every((state) => { return state.ready; });
|
|
14
|
+
const live = queues.every((state) => { return state.live; });
|
|
15
|
+
const status = { ...queues[0], ready, live, queues };
|
|
16
|
+
const unhealthy = (path === '/ready' && !ready) || (path === '/live' && !live);
|
|
17
|
+
response.writeHead(unhealthy ? 503 : 200, { 'content-type': 'application/json' }).end(JSON.stringify(status));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function schemaReady(client) {
|
|
21
|
+
const result = await client.query({
|
|
22
|
+
query: "SELECT count() AS n FROM system.tables WHERE database='scada' AND name='metrics'",
|
|
23
|
+
format: 'JSONEachRow'
|
|
24
|
+
});
|
|
25
|
+
if (Number((await result.json())[0]?.n) !== 1) {
|
|
26
|
+
throw new Error('ClickHouse telemetry schema is not initialized');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function serve(inputs, resources, { port, host }) {
|
|
31
|
+
const server = createServer((req, res) => { responseFor(inputs, req.url, res); });
|
|
32
|
+
let stopping;
|
|
33
|
+
function stop() {
|
|
34
|
+
stopping ??= Promise.allSettled(inputs.map((input) => { return input.stop(); })).then(async (settled) => {
|
|
35
|
+
const closed = await Promise.allSettled(resources.map((close) => { return close(); }));
|
|
36
|
+
server.close();
|
|
37
|
+
const failure = [...settled, ...closed].find((result) => { return result.status === 'rejected'; });
|
|
38
|
+
if (failure) { throw failure.reason; }
|
|
39
|
+
});
|
|
40
|
+
return stopping;
|
|
41
|
+
}
|
|
42
|
+
function onSignal() {
|
|
43
|
+
void stop().catch((error) => {
|
|
44
|
+
process.stderr.write(`${error.message}\n`);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const signals = ['SIGINT', 'SIGTERM'];
|
|
49
|
+
signals.forEach((signal) => { process.once(signal, onSignal); });
|
|
50
|
+
server.once('close', () => { signals.forEach((signal) => { process.off(signal, onSignal); }); });
|
|
51
|
+
server.listen(port, host);
|
|
52
|
+
return stop;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function sinks(client, spec) {
|
|
56
|
+
const base = metricsState(client);
|
|
57
|
+
const pool = spec.history ? openPool(spec.postgres) : undefined;
|
|
58
|
+
const history = spec.history?.(client, pool);
|
|
59
|
+
return { pool, history, metrics: history ? historyMetrics(base, history) : base };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Opens the local ClickHouse ingest queues and their shared readiness endpoint. */
|
|
63
|
+
export default async function edgeTelemetryRuntime(spec) {
|
|
64
|
+
const { clickhouse, queues, broker, createInput, inputOptions, port = 9093, host = '0.0.0.0' } = spec;
|
|
65
|
+
if (!queues.length || queues.some((queue) => { return typeof queue !== 'string' || !queue; }) ||
|
|
66
|
+
new Set(queues).size !== queues.length) {
|
|
67
|
+
throw new Error('Distinct telemetry queue names required');
|
|
68
|
+
}
|
|
69
|
+
const client = createClient({ 'request_timeout': 40000, 'max_open_connections': 2,
|
|
70
|
+
'clickhouse_settings': { 'async_insert': 0, 'insert_deduplicate': 1 }, ...clickhouse });
|
|
71
|
+
const { pool, history, metrics } = sinks(client, spec);
|
|
72
|
+
const inputs = queues.map((queue) => { return createInput(broker, queue, metrics, inputOptions); });
|
|
73
|
+
const stop = serve(inputs, [() => { return client.close(); }, () => { return pool?.end(); }], { port, host });
|
|
74
|
+
try {
|
|
75
|
+
await schemaReady(client);
|
|
76
|
+
await history?.ready();
|
|
77
|
+
await Promise.all(inputs.map((input) => { return input.start(); }));
|
|
78
|
+
} catch (error) {
|
|
79
|
+
await stop().catch(() => { return undefined; });
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
return { stop };
|
|
83
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Finish durable history work before acknowledging a telemetry write. */
|
|
2
|
+
export default function historyTelemetryMetrics(metrics, history) {
|
|
3
|
+
return {
|
|
4
|
+
...metrics,
|
|
5
|
+
requireTimestamp: true,
|
|
6
|
+
async insertRows(records, context = {}) {
|
|
7
|
+
context.signal?.throwIfAborted();
|
|
8
|
+
await history.prepare(records);
|
|
9
|
+
context.signal?.throwIfAborted();
|
|
10
|
+
await metrics.insertRows(records, context);
|
|
11
|
+
context.signal?.throwIfAborted();
|
|
12
|
+
await history.complete(records);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @returns {function(object): object|null} locator
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* const locate = opcuaLocate({ 'tlc-
|
|
9
|
-
* locate({ topic: 'OPCUA/tlc-
|
|
8
|
+
* const locate = opcuaLocate({ 'tlc-line-8': 'line-8' });
|
|
9
|
+
* locate({ topic: 'OPCUA/tlc-line-8/GET/axis_moving/VALUE', value: 1, ts: 1 });
|
|
10
10
|
*/
|
|
11
11
|
export default function opcuaLocate(devices) {
|
|
12
12
|
const map = devices || {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
import amqp from 'amqplib';
|
|
3
|
+
import {createClient} from '@clickhouse/client';
|
|
4
|
+
import replay from './telemetryReplay.js';
|
|
5
|
+
|
|
6
|
+
function required(env, name) {
|
|
7
|
+
const value = env[name];
|
|
8
|
+
if (!value) { throw new Error(`${name} is required`); }
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function bound(env, name, fallback) {
|
|
12
|
+
return env[name] || fallback;
|
|
13
|
+
}
|
|
14
|
+
async function* pages(pool, from, to, size) {
|
|
15
|
+
const client = await pool.connect();
|
|
16
|
+
let committed = false;
|
|
17
|
+
try {
|
|
18
|
+
await client.query('BEGIN READ ONLY');
|
|
19
|
+
await client.query(
|
|
20
|
+
"DECLARE telemetry_replay NO SCROLL CURSOR FOR SELECT topic,to_char(ts AT TIME ZONE 'UTC','YYYY-MM-DD HH24:MI:SS.US') AS ts,value FROM metrics WHERE ts >= $1::timestamptz AND ts < $2::timestamptz ORDER BY topic,ts,float8send(value)",
|
|
21
|
+
[from, to]
|
|
22
|
+
);
|
|
23
|
+
let batch;
|
|
24
|
+
do {
|
|
25
|
+
// eslint-disable-next-line no-await-in-loop
|
|
26
|
+
batch = await client.query(`FETCH FORWARD ${size} FROM telemetry_replay`);
|
|
27
|
+
if (batch.rows.length > 0) {
|
|
28
|
+
yield batch.rows;
|
|
29
|
+
}
|
|
30
|
+
} while (batch.rows.length !== 0);
|
|
31
|
+
await client.query('COMMIT');
|
|
32
|
+
committed = true;
|
|
33
|
+
} finally {
|
|
34
|
+
const error = committed ? undefined : await client.query('ROLLBACK').then(() => {return undefined}, (failure) => {return failure});
|
|
35
|
+
client.release(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function pull(client, from, to, size, offset) {
|
|
39
|
+
const result = await client.query({
|
|
40
|
+
query: `SELECT stored.topic,formatDateTime(stored.ts,'%F %T.%f','UTC') AS ts,stored.value
|
|
41
|
+
FROM scada.metrics AS stored
|
|
42
|
+
WHERE stored.ts >= parseDateTime64BestEffort({from:String},6,'UTC')
|
|
43
|
+
AND stored.ts < parseDateTime64BestEffort({to:String},6,'UTC')
|
|
44
|
+
ORDER BY stored.topic,stored.ts,stored.value LIMIT {size:UInt32} OFFSET {offset:UInt32}`,
|
|
45
|
+
'query_params': {from, to, size, offset},
|
|
46
|
+
format: 'JSONEachRow'
|
|
47
|
+
});
|
|
48
|
+
return result.json();
|
|
49
|
+
}
|
|
50
|
+
async function* clickhousePages(env, from, to, size) {
|
|
51
|
+
const client = createClient({
|
|
52
|
+
url: env.CLICKHOUSE_URL,
|
|
53
|
+
username: bound(env, 'CLICKHOUSE_USER', 'default'),
|
|
54
|
+
password: env.CLICKHOUSE_PASSWORD || '',
|
|
55
|
+
'request_timeout': 120000
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
let offset = 0;
|
|
59
|
+
let rows;
|
|
60
|
+
do {
|
|
61
|
+
// eslint-disable-next-line no-await-in-loop
|
|
62
|
+
rows = await pull(client, from, to, size, offset);
|
|
63
|
+
if (rows.length > 0) {
|
|
64
|
+
yield rows;
|
|
65
|
+
}
|
|
66
|
+
offset += rows.length;
|
|
67
|
+
} while (rows.length !== 0);
|
|
68
|
+
} finally {
|
|
69
|
+
await client.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function publish(channel, row) {
|
|
73
|
+
const message = replay(row);
|
|
74
|
+
await new Promise((resolve, reject) => {
|
|
75
|
+
channel.publish(message.exchange, message.routingKey, Buffer.from(message.payload), {
|
|
76
|
+
persistent: true,
|
|
77
|
+
contentType: 'application/json'
|
|
78
|
+
}, (error) => { if (error) { reject(error); } else { resolve(); } });
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async function* load(env, from, to, size) {
|
|
82
|
+
if (env.CLICKHOUSE_URL) {
|
|
83
|
+
yield* clickhousePages(env, from, to, size);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const pool = new pg.Pool({connectionString: required(env, 'POSTGRES_URL'), max: 1});
|
|
87
|
+
try {
|
|
88
|
+
yield* pages(pool, from, to, size);
|
|
89
|
+
} finally {
|
|
90
|
+
await pool.end();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function replayWindow(env) {
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
const from = env.SOURCE_FROM || new Date(now - Number(bound(env, 'LOOKBACK_MS', '28800000'))).toISOString();
|
|
96
|
+
const to = env.SOURCE_TO || new Date(now).toISOString();
|
|
97
|
+
const size = Number(bound(env, 'SOURCE_PAGE_SIZE', '2000'));
|
|
98
|
+
if (!Number.isSafeInteger(size) || size < 1 || size > 100000) {
|
|
99
|
+
throw new RangeError('Invalid telemetry replay page size');
|
|
100
|
+
}
|
|
101
|
+
return { from, to, size };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Republishes stored metrics onto the local telemetry exchange in bounded batches. */
|
|
105
|
+
export default async function replayStoredTelemetry(env) {
|
|
106
|
+
const { from, to, size } = replayWindow(env);
|
|
107
|
+
const connection = await amqp.connect(required(env, 'AMQP_URL'));
|
|
108
|
+
let channel;
|
|
109
|
+
let records = 0;
|
|
110
|
+
try {
|
|
111
|
+
channel = await connection.createConfirmChannel();
|
|
112
|
+
for await (const page of load(env, from, to, size)) {
|
|
113
|
+
// Wait for publisher confirms before reading another page.
|
|
114
|
+
await Promise.all(page.map((row) => {return publish(channel, row)}));
|
|
115
|
+
records += page.length;
|
|
116
|
+
}
|
|
117
|
+
} finally {
|
|
118
|
+
try {
|
|
119
|
+
await channel?.close();
|
|
120
|
+
} finally {
|
|
121
|
+
await connection.close();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { from, to, records };
|
|
125
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import amqpMetricsIngest from './amqpMetricsIngest.js';
|
|
2
|
+
|
|
3
|
+
function batchConfig(options) {
|
|
4
|
+
const config = { size: 256, prefetch: 512, maxWaitMs: 1000, writeTimeoutMs: 45000, ...options };
|
|
5
|
+
for (const key of ['size', 'prefetch', 'maxWaitMs', 'writeTimeoutMs']) {
|
|
6
|
+
if (!Number.isSafeInteger(config[key]) || config[key] <= 0) { throw new Error(`Invalid telemetry ${key}`); }
|
|
7
|
+
}
|
|
8
|
+
if (config.size > config.prefetch) { throw new Error('Telemetry batch exceeds the broker acknowledgement window'); }
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function metricBatches(metrics, state, clock, failure, halt) {
|
|
13
|
+
return {
|
|
14
|
+
requireTimestamp: metrics.requireTimestamp === true,
|
|
15
|
+
async write(records, context) {
|
|
16
|
+
try {
|
|
17
|
+
await metrics.insertRows(records, context);
|
|
18
|
+
state.records += records.length;
|
|
19
|
+
state.batches += 1;
|
|
20
|
+
Object.assign(state, { lastWrite: new Date(clock()).toISOString(), error: '', failedAt: undefined });
|
|
21
|
+
} catch (error) {
|
|
22
|
+
failure(error);
|
|
23
|
+
if (error.code === 'WRITE_TIMEOUT') { halt?.(error); }
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Consume acknowledged telemetry and measure ingest health at the storage boundary. */
|
|
31
|
+
export default function telemetryIngest(url, queue, metrics, settings = {}) {
|
|
32
|
+
const { clock = Date.now, halt, connect = amqpMetricsIngest, report, ...options } = settings;
|
|
33
|
+
const config = batchConfig(options);
|
|
34
|
+
const state = { started: false, records: 0, batches: 0, lastWrite: undefined, error: '', failedAt: undefined };
|
|
35
|
+
function failure(error) {
|
|
36
|
+
state.failedAt ??= clock();
|
|
37
|
+
if (state.error !== error.message) { report?.(error); }
|
|
38
|
+
state.error = error.message;
|
|
39
|
+
}
|
|
40
|
+
const sink = metricBatches(metrics, state, clock, failure, halt);
|
|
41
|
+
const input = connect(url, queue, sink, { ...config,
|
|
42
|
+
exclusive: true, stopTimeoutMs: 50000, maxMessageBytes: 65536, maxPendingBytes: 8388608,
|
|
43
|
+
maxBytes: 1048576, maxRecords: 1024, onError: failure
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
async start() { await input.start(); Object.assign(state, { started: true }); },
|
|
47
|
+
async stop() { state.started = false; await input.stop(); },
|
|
48
|
+
status() {
|
|
49
|
+
return { ...state, ready: state.started && !state.error, live: state.failedAt === undefined || clock() - state.failedAt < 60000 };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import telemetryTimestamp from '../../../domain/ingest/telemetryTimestamp.js';
|
|
2
|
+
|
|
3
|
+
/** Encode a stored point as a persistent AMQP publish with its original millisecond timestamp. */
|
|
4
|
+
export default function telemetryReplay(row, exchange = 'scada.telemetry') {
|
|
5
|
+
const instant = Math.trunc(telemetryTimestamp(row.ts));
|
|
6
|
+
if (!Number.isSafeInteger(instant) || !Number.isFinite(row.value)) {
|
|
7
|
+
throw new Error(`Replay requires original integer timestamp and finite value topic=${row.topic} ts=${row.ts}`);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
exchange,
|
|
11
|
+
routingKey: String(row.topic).replaceAll('/', '.'),
|
|
12
|
+
payload: JSON.stringify({ ts: instant, value: row.value }),
|
|
13
|
+
persistent: true
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { request } from 'node:https';
|
|
3
|
+
|
|
4
|
+
const identity = '/var/run/secrets/kubernetes.io/serviceaccount';
|
|
5
|
+
|
|
6
|
+
function collect(response, limit, resolve, reject) {
|
|
7
|
+
const chunks = [];
|
|
8
|
+
let size = 0;
|
|
9
|
+
response.on('data', (chunk) => {
|
|
10
|
+
size += chunk.length;
|
|
11
|
+
if (size > limit) {
|
|
12
|
+
response.destroy(new Error('Kubernetes API response is too large'));
|
|
13
|
+
} else {
|
|
14
|
+
chunks.push(chunk);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
response.on('error', reject);
|
|
18
|
+
response.on('end', () => {
|
|
19
|
+
resolve({ status: response.statusCode, body: Buffer.concat(chunks).toString('utf8') });
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Authenticated JSON request to the cluster API using the mounted service account. */
|
|
24
|
+
export default function kubeServiceAccount(address, { limit = 1048576, timeoutMs = 8000 } = {}) {
|
|
25
|
+
const base = new URL(address);
|
|
26
|
+
if (base.protocol !== 'https:') { throw new TypeError('Kubernetes API requires HTTPS'); }
|
|
27
|
+
return function exchange(method, path, body, contentType = 'application/json') {
|
|
28
|
+
const target = new URL(path, base);
|
|
29
|
+
if (target.origin !== base.origin) { throw new TypeError('Invalid Kubernetes API path'); }
|
|
30
|
+
const token = readFileSync(`${identity}/token`, 'utf8').trim();
|
|
31
|
+
const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json', 'Content-Type': contentType };
|
|
32
|
+
const ca = readFileSync(`${identity}/ca.crt`);
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
const connection = request(target, { method, headers, ca, rejectUnauthorized: true }, (response) => {
|
|
35
|
+
collect(response, limit, resolve, reject);
|
|
36
|
+
});
|
|
37
|
+
const timer = setTimeout(() => { connection.destroy(new Error('Kubernetes API request timed out')); }, timeoutMs);
|
|
38
|
+
connection.on('error', reject);
|
|
39
|
+
connection.on('close', () => { clearTimeout(timer); });
|
|
40
|
+
connection.end(body === undefined ? undefined : JSON.stringify(body));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
function forwardedPort(child, timeout) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const timer = setTimeout(() => { reject(new Error('Port forward timeout')); }, timeout);
|
|
6
|
+
let output = '';
|
|
7
|
+
function failed() { clearTimeout(timer); reject(new Error('Port forward stopped')); }
|
|
8
|
+
child.once('error', failed);
|
|
9
|
+
child.once('exit', failed);
|
|
10
|
+
child.stdout.on('data', (chunk) => {
|
|
11
|
+
output = (output + chunk.toString()).slice(-4096);
|
|
12
|
+
const match = /Forwarding from 127[.]0[.]0[.]1:(?<port>\d+)/u.exec(output);
|
|
13
|
+
if (match) { clearTimeout(timer); resolve(Number(match.groups.port)); }
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Invoke an operation over a temporary, loopback-only port owned by this process. */
|
|
19
|
+
export async function kubectlPortForward({ context, namespace, target, port, timeout = 15000 }, use) {
|
|
20
|
+
const child = spawn('kubectl', ['--context', context, '--namespace', namespace, 'port-forward',
|
|
21
|
+
target, `:${port}`, '--address=127.0.0.1'], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
22
|
+
child.stderr.resume();
|
|
23
|
+
try {
|
|
24
|
+
const forwarded = await forwardedPort(child, timeout);
|
|
25
|
+
return await use(`http://127.0.0.1:${forwarded}`);
|
|
26
|
+
} finally { child.kill('SIGTERM'); }
|
|
27
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function native(device, kiosk) {
|
|
2
|
+
const { apk } = device.application;
|
|
3
|
+
return { name: kiosk.applicationName, pkg: apk.package, version: apk.version, versionCode: apk.versionCode,
|
|
4
|
+
url: apk.url, sha256: apk.sha256, type: 'app', showIcon: true, runAfterInstall: true };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
async function existing(client, desired) {
|
|
8
|
+
const rows = await client.request('/private/configurations/applications');
|
|
9
|
+
if (!Array.isArray(rows)) { throw new Error('MDMesh application inventory is invalid'); }
|
|
10
|
+
const found = rows.filter(row => { return row.pkg === desired.pkg; });
|
|
11
|
+
if (found.length > 1 || found.some(row => { return row.name !== desired.name; })) { throw new Error('HMI application package is ambiguous or unmanaged'); }
|
|
12
|
+
if (!found[0]) { return undefined; }
|
|
13
|
+
const current = await client.request(`/private/applications/${found[0].id}`);
|
|
14
|
+
const versions = await client.request(`/private/applications/${found[0].id}/versions`);
|
|
15
|
+
const version = versions.find(row => {return row.id === current.latestVersion});
|
|
16
|
+
return { ...current, sha256: version?.apkHash ? Buffer.from(version.apkHash, 'base64url').toString('hex') : '' };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function matches(current, desired) {
|
|
20
|
+
return current && ['pkg', 'version', 'versionCode', 'url', 'sha256'].every(key => { return current[key] === desired[key]; });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function store(client, current, desired) {
|
|
24
|
+
if (current) {
|
|
25
|
+
await client.request('/private/applications/versions', 'PUT', { applicationId: current.id,
|
|
26
|
+
version: desired.version, versionCode: desired.versionCode, url: desired.url,
|
|
27
|
+
apkHash: Buffer.from(desired.sha256, 'hex').toString('base64url'), split: false });
|
|
28
|
+
} else { await client.request('/private/applications/android', 'PUT', desired); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function removal(row) {
|
|
32
|
+
if (!Number.isSafeInteger(row.id) || row.id <= 0) { throw new Error('HMI retired package has invalid identity'); }
|
|
33
|
+
return { id: row.id, usedVersionId: row.latestVersion || row.usedVersionId || row.id, action: 1, showIcon: false, remove: true };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function retired(device, client) {
|
|
37
|
+
const names = device.application.apk.retire || [];
|
|
38
|
+
if (!names.length) { return []; }
|
|
39
|
+
const rows = await client.request('/private/configurations/applications');
|
|
40
|
+
if (!Array.isArray(rows)) { throw new Error('MDMesh application inventory is invalid'); }
|
|
41
|
+
return names.flatMap((pkg) => {
|
|
42
|
+
const found = rows.filter((row) => { return row.pkg === pkg; });
|
|
43
|
+
if (found.length > 1) { throw new Error('HMI retired package is ambiguous'); }
|
|
44
|
+
return found[0] ? [removal(found[0])] : [];
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Reconcile a signed, immutable HMI APK before using its VERSION identity in a kiosk configuration. */
|
|
49
|
+
export default async function hmiApplication(device, client, apply, kiosk) {
|
|
50
|
+
const desired = native(device, kiosk);
|
|
51
|
+
let current = await existing(client, desired);
|
|
52
|
+
if (current && !matches(current, desired) && (current.version === desired.version || desired.versionCode <= current.versionCode)) {
|
|
53
|
+
throw new Error('HMI APK identity is immutable; publish a new version with an increased versionCode');
|
|
54
|
+
}
|
|
55
|
+
if (apply && !matches(current, desired)) {
|
|
56
|
+
await store(client, current, desired);
|
|
57
|
+
current = await existing(client, desired);
|
|
58
|
+
if (!matches(current, desired)) { throw new Error('MDMesh HMI application readback did not match its immutable APK'); }
|
|
59
|
+
}
|
|
60
|
+
if (!current || !matches(current, desired)) { return { ready: false, settings: {} }; }
|
|
61
|
+
if (!Number.isSafeInteger(current.latestVersion) || current.latestVersion <= 0) { throw new Error('MDMesh HMI application has no version identity'); }
|
|
62
|
+
const applications = [{ id: current.id, usedVersionId: current.latestVersion, action: 1, showIcon: true, remove: false }, ...await retired(device, client)];
|
|
63
|
+
return { ready: true, settings: { mainAppId: current.latestVersion, autostartForeground: true, applications } };
|
|
64
|
+
}
|