@yarkivaev/scada 2.5.3 → 2.5.4

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.5.3",
3
+ "version": "2.5.4",
4
4
  "description": "SCADA domain objects, state persistence, and plant monitoring",
5
5
  "repository": {
6
6
  "type": "git",
@@ -120,7 +120,7 @@ function siteExtraRoutes(catalog, extraRoutes, syncRoutes) {
120
120
  */
121
121
  export default async function siteServer(config) {
122
122
  const env = collectionEnvironment(config);
123
- const sink = supervisorSink(env);
123
+ const sink = supervisorSink(env, { stateData: config.stateData });
124
124
  const ops = bindSiteOperations(sink, config.kindSources || config.operationSources);
125
125
  const http = edgeApi(sink.dataAccess, {
126
126
  port: sink.apiPort,
@@ -97,7 +97,8 @@ export default function supervisorSink(env = process.env, options = {}) {
97
97
  if (cfg.pipeline.transactions.enabled) { cfg.pipeline.onBatch = segmentBatchStats(cfg.pipeline.transactions.statsIntervalMs); }
98
98
  const pool = holdClient(new pg.Pool({ connectionString: cfg.postgres, max: cfg.dbPoolMax }));
99
99
  const metricsEnabled = cfg.sinkDbProfile === 'edge';
100
- const dataAccess = stateDataFromPool(pool, { metricsEnabled });
100
+ const data = stateDataFromPool(pool, { metricsEnabled });
101
+ const dataAccess = options.stateData ? options.stateData(data, pool) : data;
101
102
  return {
102
103
  health: () => {return health.status()},
103
104
  apiPort: cfg.apiPort,
@@ -35,7 +35,7 @@ function overlay(items, rows) {
35
35
  }));
36
36
  rows.forEach((row) => {
37
37
  const item = byKey.get(row.kind);
38
- if (!item) {
38
+ if (!item || (item.found && Date.parse(item.timestamp) > row.end_time.getTime())) {
39
39
  return;
40
40
  }
41
41
  item.found = true;