@yarkivaev/scada 2.3.48 → 2.3.49
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 +9 -5
- package/package.json +1 -1
- package/src/domain/operation/operations.js +2 -2
- package/src/infrastructure/client/machineClient.js +1 -1
- package/src/infrastructure/client/machineOperationsClient.js +1 -1
- package/src/infrastructure/http/plant/json/operationJson.js +1 -1
- package/src/infrastructure/messaging/ownership/httpOperations.js +1 -1
- package/src/infrastructure/persistence/pg/operations.js +2 -2
- package/src/infrastructure/persistence/pg/userDecisions.js +1 -1
- package/src/infrastructure/sync/operationCodec.js +2 -2
- package/src/infrastructure/sync/operationSyncSink.js +2 -2
package/README.md
CHANGED
|
@@ -200,14 +200,18 @@ import stateDataFake from '@yarkivaev/scada/stateDataFake';
|
|
|
200
200
|
|
|
201
201
|
## Package boundary
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
**Hard rule:** this package is factory-agnostic. It must not contain Sokol melting/bath domain, chem-analysis UI, HMI copy (e.g. Болото), `weight_after` fold semantics, or plant-specific sensors/routes. Those belong in `sokol-scada` (or another plant package).
|
|
204
|
+
|
|
205
|
+
Opaque operation `kind` strings and generic ports (`latestForMachine`, list/upsert/stream) are allowed; never treat a kind as a first-class domain type here.
|
|
206
|
+
|
|
207
|
+
| This package (`@yarkivaev/scada`) | Downstream plant package (`sokol-scada`, …) |
|
|
204
208
|
|------------------------|--------------------------|
|
|
205
|
-
| Generic plant, timeline, alerts,
|
|
209
|
+
| Generic plant, shop, machine, timeline, alerts, operations ports | Melting bath, chem, cycles HMI, site sensors |
|
|
206
210
|
| Empty/injectable alert `translations` | Localized rule messages |
|
|
207
|
-
| Opaque operation `kind` strings | Site
|
|
208
|
-
| `plantApi`, `siteServer`, `supervisorSink` | Site bins
|
|
211
|
+
| Opaque operation `kind` strings | Site kinds (`bath`, `chem`, …) and fold/prefix logic |
|
|
212
|
+
| `plantApi`, `siteServer`, `supervisorSink` | Site bins, routes, `bathSensor`, reports |
|
|
209
213
|
| Export ports `Query` / `Stream` / `Sink` / `Job` | Export jobs + destination adapters |
|
|
210
|
-
| ClickHouse + PG adapters | Plant wiring (`
|
|
214
|
+
| ClickHouse + PG adapters | Plant wiring (`sokolPlant` / `edgePlant`) |
|
|
211
215
|
|
|
212
216
|
Depend on a pinned version (`"@yarkivaev/scada": "…#v2.3.46"`), not a local path, in downstream packages.
|
|
213
217
|
|
package/package.json
CHANGED
|
@@ -41,8 +41,8 @@ function resolveKinds(kinds, sources) {
|
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* const ops = operations(store, bus, { temp: temperaturePort });
|
|
44
|
-
* await ops.listForMachine('m1', ['
|
|
45
|
-
* await ops.latestForMachine('m1', '
|
|
44
|
+
* await ops.listForMachine('m1', ['sample', 'temp'], { from: new Date() });
|
|
45
|
+
* await ops.latestForMachine('m1', 'sample', { to: new Date() });
|
|
46
46
|
* await ops.remove('m1', 'nb-1');
|
|
47
47
|
*/
|
|
48
48
|
export default function operations(persistence, bus, kindSources) {
|
|
@@ -48,7 +48,7 @@ function rangeQuery(options) {
|
|
|
48
48
|
* @example
|
|
49
49
|
* const machine = machineClient(baseUrl, 'm1', fetch, EventSource, logger);
|
|
50
50
|
* const info = await machine.info();
|
|
51
|
-
* await machine.createOperation({ kind: '
|
|
51
|
+
* await machine.createOperation({ kind: 'load', payload: { action: 'add' } });
|
|
52
52
|
* await machine.updateOperation(key, { payload: { action: 'load' } });
|
|
53
53
|
* await machine.deleteOperation(key);
|
|
54
54
|
*/
|
|
@@ -121,7 +121,7 @@ function deleteRequest(request, key, fields) {
|
|
|
121
121
|
*
|
|
122
122
|
* @example
|
|
123
123
|
* const ops = machineOperationsClient(baseUrl, request, EventSource, logger);
|
|
124
|
-
* await ops.createOperation({ kind: '
|
|
124
|
+
* await ops.createOperation({ kind: 'load', payload: {}, operatorId: 2 });
|
|
125
125
|
* await ops.operationDecisions(key);
|
|
126
126
|
*/
|
|
127
127
|
export default function machineOperationsClient(baseUrl, request, eventSource, logger) {
|
|
@@ -12,7 +12,7 @@ function iso(value) {
|
|
|
12
12
|
* @returns {object} API item with external_key and source_updated_at
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
-
* operationJson({ key: 'nb-1', occurred_at: new Date(), kind: '
|
|
15
|
+
* operationJson({ key: 'nb-1', occurred_at: new Date(), kind: 'sample', payload: {}, machine: 'm1' });
|
|
16
16
|
*/
|
|
17
17
|
export default function operationJson(row) {
|
|
18
18
|
const occurred = iso(row.occurred_at);
|
|
@@ -45,7 +45,7 @@ async function readJson(res) {
|
|
|
45
45
|
*
|
|
46
46
|
* @example
|
|
47
47
|
* const port = httpOperations({ baseUrl: 'http://edge/api/v1' }, 'm2');
|
|
48
|
-
* await port.create({ kind: '
|
|
48
|
+
* await port.create({ kind: 'load', payload: {}, operatorId: 2 });
|
|
49
49
|
*/
|
|
50
50
|
export default function httpOperations(site, machineId) {
|
|
51
51
|
const base = trimBase(site.baseUrl);
|
|
@@ -101,8 +101,8 @@ async function removeOperation(pool, machineId, key) {
|
|
|
101
101
|
*
|
|
102
102
|
* @example
|
|
103
103
|
* const store = operationStatePg(pool);
|
|
104
|
-
* await store.upsert({ machine: 'm1', key: 'nb-1', kind: '
|
|
105
|
-
* await store.latestForMachine('m1', '
|
|
104
|
+
* await store.upsert({ machine: 'm1', key: 'nb-1', kind: 'sample', ... });
|
|
105
|
+
* await store.latestForMachine('m1', 'sample', { to: new Date() });
|
|
106
106
|
* await store.remove('m1', 'nb-1');
|
|
107
107
|
*/
|
|
108
108
|
export default function operationStatePg(pool) {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* const catalog = userDecisionsFromPg(pool);
|
|
13
13
|
* await catalog.insert({
|
|
14
14
|
* machine: 'm1', startTime: new Date(), username: 'Ivan',
|
|
15
|
-
* decidedAt: new Date(), payload: { kind: 'operation_op', verb: 'create', key: '
|
|
15
|
+
* decidedAt: new Date(), payload: { kind: 'operation_op', verb: 'create', key: 'op:m1:1' }
|
|
16
16
|
* });
|
|
17
17
|
*/
|
|
18
18
|
function mapRow(row) {
|
|
@@ -55,8 +55,8 @@ async function decode(parsed, collector) {
|
|
|
55
55
|
*
|
|
56
56
|
* @example
|
|
57
57
|
* const codec = operationCodec(collector);
|
|
58
|
-
* await codec.accept(Buffer.from('{"machine":"m1","occurred_at":"2024-06-01T10:00:00.000Z","kind":"
|
|
59
|
-
* await codec.accept(Buffer.from('{"type":"deleted","machine":"m1","occurred_at":"2024-06-01T10:00:00.000Z","kind":"
|
|
58
|
+
* await codec.accept(Buffer.from('{"machine":"m1","occurred_at":"2024-06-01T10:00:00.000Z","kind":"sample","external_key":"nb-1","payload":{}}'));
|
|
59
|
+
* await codec.accept(Buffer.from('{"type":"deleted","machine":"m1","occurred_at":"2024-06-01T10:00:00.000Z","kind":"load","external_key":"k"}'));
|
|
60
60
|
*/
|
|
61
61
|
export default function operationCodec(collector) {
|
|
62
62
|
if (!collector || typeof collector.accept !== 'function') {
|
|
@@ -8,8 +8,8 @@ import processingErrorLog from '../ingest/processingErrorLog.js';
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* const sink = operationSyncSink(dataAccess.operations);
|
|
11
|
-
* await sink.accept({ machine: 'm1', occurred_at: new Date(), kind: '
|
|
12
|
-
* await sink.remove({ machine: 'm1', kind: '
|
|
11
|
+
* await sink.accept({ machine: 'm1', occurred_at: new Date(), kind: 'sample', key: 'nb-1', payload: {} });
|
|
12
|
+
* await sink.remove({ machine: 'm1', kind: 'sample', key: 'nb-1', occurred_at: new Date() });
|
|
13
13
|
*/
|
|
14
14
|
export default function operationSyncSink(operations) {
|
|
15
15
|
return {
|