@camstack/server 1.2.896 → 1.2.898
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/CHANGELOG.md +12 -0
- package/package.json +17 -23
- package/system/dist/addon-runner.js +103 -12
- package/system/dist/addon-runner.mjs +103 -12
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +14 -11
- package/system/dist/builtins/composer/composer.addon.mjs +11 -8
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +170 -14
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +169 -13
- package/system/dist/builtins/core-blocks/migrations/automation-confirmed-view.d.ts +23 -0
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
- package/system/dist/builtins/core-blocks/migrations/pump-cycle-split.d.ts +1 -0
- package/system/dist/builtins/device-history/device-history.addon.js +10 -9
- package/system/dist/builtins/device-history/device-history.addon.mjs +10 -9
- package/system/dist/builtins/device-manager/command-holds-wiring.d.ts +22 -0
- package/system/dist/builtins/device-manager/command-holds.d.ts +75 -0
- package/system/dist/builtins/device-manager/device-manager.addon.d.ts +2 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +383 -27
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +380 -28
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +35 -9
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/shared/device-state-changed.d.ts +8 -0
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-BgIjQWh6.js → capture-engine-BWS0KTbm.js} +48 -1
- package/system/dist/{capture-engine-DPn6JaPc.mjs → capture-engine-DBQDaDxJ.mjs} +37 -2
- package/system/dist/{composition-sources-Bec_hQMM.js → composition-sources-CDOW1dnY.js} +1 -32
- package/system/dist/{composition-sources-B0rdPm85.mjs → composition-sources-CGUWmf-T.mjs} +2 -21
- package/system/dist/{constants-DsQsO8PD.mjs → constants-BmrLkwZs.mjs} +1 -1
- package/system/dist/{constants-CsYMak6g.js → constants-BwrRoq-j.js} +1 -1
- package/system/dist/{device-ca-BuDqRFZd.mjs → device-ca-BGgZXEto.mjs} +1 -1
- package/system/dist/{device-ca-BeK8EI_7.js → device-ca-DiuwWyZY.js} +1 -1
- package/system/dist/{dist-CHC8tlB1.js → dist-CCd8IeIU.js} +705 -54
- package/system/dist/{dist-DiknL6UU.mjs → dist-D7t8wLTF.mjs} +694 -55
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-Dt-mbtkY.mjs → hub-identity-BohJeqdO.mjs} +1 -1
- package/system/dist/{hub-identity-BM26oLpK.js → hub-identity-G_ZdyPpc.js} +1 -1
- package/system/dist/{hub-mdns-ciao-BDgSHCPM.js → hub-mdns-ciao-CKD4EgkG.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CHq7b1FX.mjs → hub-mdns-ciao-D5RxSMrH.mjs} +2 -2
- package/system/dist/index.js +45 -13
- package/system/dist/index.mjs +46 -14
- package/system/dist/kernel/command-hold-overrides.d.ts +42 -0
- package/system/dist/kernel/moleculer/child-cap-descriptors.d.ts +3 -0
- package/system/dist/kernel/moleculer/device-cap-proxy.d.ts +2 -1
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +6 -1
- package/system/dist/{legacy-integration-rows-door-BYJa0xPI.js → legacy-integration-rows-door-BgCl68ek.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-1WauJNCy.mjs → legacy-integration-rows-door-Rm9JmIsl.mjs} +1 -1
- package/system/dist/{rename-composition-block-fMaUic9d.js → rename-composition-block-2Z2ED7Og.js} +1 -1
- package/system/dist/{rename-composition-block-BOoAElGp.mjs → rename-composition-block-DNO3mNEO.mjs} +1 -1
- package/system/dist/{restore-archive-DNLe1z5A.mjs → restore-archive-2L5TymvF.mjs} +1 -1
- package/system/dist/{restore-archive-CeZV08vh.js → restore-archive-CZkQO8t3.js} +1 -1
- package/system/dist/{wal-maintenance-CekT_qH6.mjs → wal-maintenance-BMYe_n18.mjs} +0 -0
- package/system/dist/{wal-maintenance-CmCCUKZO.js → wal-maintenance-YjDJ73Qd.js} +0 -0
- package/system/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored generated automations move to the CONFIRMED view (D1061).
|
|
3
|
+
*
|
|
4
|
+
* An automation generated before D1061 read a device's slice in the effective
|
|
5
|
+
* view: a command the hub still holds read as already done, so a condition on
|
|
6
|
+
* it could pass before the device acted. The generator now asks for the
|
|
7
|
+
* device's word. This regenerates each stored automation from the recipe its
|
|
8
|
+
* code embeds (`AUTOMATION_RECIPE`), exactly as saving it in the editor would.
|
|
9
|
+
*
|
|
10
|
+
* Only code that is still what the generator writes is regenerated: its body
|
|
11
|
+
* (the recipe literal blanked, as `instanceCodeHash` reads it) must equal what
|
|
12
|
+
* the generator wrote before D1061 for that same recipe. Code edited by hand,
|
|
13
|
+
* or written by a generator older than the one before D1061, is left exactly
|
|
14
|
+
* as it is and logged per automation: regenerating it would lose what it does
|
|
15
|
+
* differently. A hand-written script (no recipe) is not an automation here.
|
|
16
|
+
* A rerun finds every regenerated automation already current and edits nothing.
|
|
17
|
+
*/
|
|
18
|
+
import { type MigrationProcedureResult } from "@camstack/types";
|
|
19
|
+
import type { CoreBlocksMigrationPorts } from "./pump-cycle-split.js";
|
|
20
|
+
export declare const AUTOMATION_CONFIRMED_VIEW_ID = "core-blocks/2026-11-17-automation-confirmed-view";
|
|
21
|
+
/** The code the generator wrote for the same recipe before D1061. */
|
|
22
|
+
export declare function beforeConfirmedView(current: string): string;
|
|
23
|
+
export declare function regenerateAutomationsConfirmedView(ports: CoreBlocksMigrationPorts): Promise<MigrationProcedureResult>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AddonMigration } from "@camstack/types";
|
|
2
2
|
import { type CoreBlocksMigrationPorts } from "./pump-cycle-split.js";
|
|
3
3
|
import { type RemoteMigrationPorts } from "./remote-config-migrations.js";
|
|
4
|
+
export { AUTOMATION_CONFIRMED_VIEW_ID } from "./automation-confirmed-view.js";
|
|
4
5
|
export { FOUNTAIN_DRINK_DROP_ID } from "./fountain-drink-drop.js";
|
|
5
6
|
export { REMOTE_COLOUR_ROLES_ID, REMOTE_POWER_DROP_ID, remoteMigrationPortsOver, type RemoteMigrationPorts } from "./remote-config-migrations.js";
|
|
6
7
|
/** Everything the core-blocks catalogue touches: the block rows, and the stored remotes and templates. */
|
|
@@ -36,6 +36,7 @@ export interface CoreBlocksMigrationPorts {
|
|
|
36
36
|
/** Replace a row's body, refused when the row changed since it was read. */
|
|
37
37
|
replaceBlockRow(id: string, data: CoreBlockRowBody, ifRev: number): Promise<void>;
|
|
38
38
|
now(): number;
|
|
39
|
+
info(message: string, meta: Readonly<Record<string, unknown>>): void;
|
|
39
40
|
warn(message: string, meta: Readonly<Record<string, unknown>>): void;
|
|
40
41
|
}
|
|
41
42
|
/** The ports over the real `core_blocks` kind. */
|
|
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
7
|
-
const require_capture_engine = require("../../capture-engine-
|
|
6
|
+
const require_dist = require("../../dist-CCd8IeIU.js");
|
|
7
|
+
const require_capture_engine = require("../../capture-engine-BWS0KTbm.js");
|
|
8
8
|
const require_retention = require("../../retention-BcOSL6b9.js");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
10
10
|
//#region src/builtins/device-history/capture/point-writer.ts
|
|
@@ -3987,10 +3987,11 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
|
|
|
3987
3987
|
};
|
|
3988
3988
|
}
|
|
3989
3989
|
},
|
|
3990
|
-
readSnapshots: async () => api.deviceState.getAllSnapshots.query({}),
|
|
3990
|
+
readSnapshots: async () => api.deviceState.getAllSnapshots.query({ confirmed: true }),
|
|
3991
3991
|
readCapSlice: (deviceId, capName) => api.deviceState.getCapSlice.query({
|
|
3992
3992
|
deviceId,
|
|
3993
|
-
capName
|
|
3993
|
+
capName,
|
|
3994
|
+
confirmed: true
|
|
3994
3995
|
}),
|
|
3995
3996
|
readDeviceQuantity: async (deviceId) => {
|
|
3996
3997
|
const quantity = (await api.deviceManager.getDevice.query({ deviceId }))?.sourceInfo?.quantity;
|
|
@@ -4010,10 +4011,9 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
|
|
|
4010
4011
|
this.transitions = transitions;
|
|
4011
4012
|
runtime.retentionJob.attachTransitions(transitions);
|
|
4012
4013
|
this.unsubscribe = this.ctx.eventBus.subscribe({ category: require_dist.EventCategory.DeviceStateChanged }, (event) => {
|
|
4013
|
-
const data = event.data;
|
|
4014
|
-
if (
|
|
4014
|
+
const data = require_capture_engine.parseConfirmedStateChanged(event.data);
|
|
4015
|
+
if (data === null) return;
|
|
4015
4016
|
const { deviceId, capName, slice } = data;
|
|
4016
|
-
if (typeof deviceId !== "number" || typeof capName !== "string" || !isRecord(slice)) return;
|
|
4017
4017
|
const at = event.timestamp instanceof Date ? event.timestamp.getTime() : Date.now();
|
|
4018
4018
|
runtime.capture.handleState(deviceId, capName, slice, at);
|
|
4019
4019
|
runs.handleState(deviceId, capName, slice, at);
|
|
@@ -4041,10 +4041,11 @@ var DeviceHistoryAddon = class extends require_dist.BaseAddon {
|
|
|
4041
4041
|
if (records === void 0) throw new Error("device-history needs ctx.records on the hub for the run ledger");
|
|
4042
4042
|
return new DeviceRunsService({
|
|
4043
4043
|
records,
|
|
4044
|
-
readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({}),
|
|
4044
|
+
readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({ confirmed: true }),
|
|
4045
4045
|
readCapSlice: (deviceId, capName) => ctx.api.deviceState.getCapSlice.query({
|
|
4046
4046
|
deviceId,
|
|
4047
|
-
capName
|
|
4047
|
+
capName,
|
|
4048
|
+
confirmed: true
|
|
4048
4049
|
}),
|
|
4049
4050
|
deviceTypeOf: (deviceId) => runtime.directory.ensure(deviceId),
|
|
4050
4051
|
energyFromHistory: (deviceId, from, to) => energyKwhFromHistory((query) => runtime.query.query(query), deviceId, from, to),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-
|
|
1
|
+
import { Ec as InvalidRecordError, Gr as deviceRunsCapability, H as DEVICE_HISTORY_ENERGY_KEY, Hc as RecordTooLargeError, Nl as isReadingQuantity, Sc as DeviceTransitionSchema, St as HISTORY_ITEM_CATALOG, Tl as historyUnitFor, Vn as armRemovalReconcile, Vr as deviceHistoryCapability, Wr as deviceRemovalHookCapability, Yr as deviceTransitionsCapability, _l as defineRecordKinds, _u as EventCategory, hc as BaseAddon, mc as wattMillisecondsToKwh, mu as DeviceType, rt as DeviceRunSchema, xt as HISTORY_CATALOG, yl as emitReadiness } from "../../dist-D7t8wLTF.mjs";
|
|
2
|
+
import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, m as parseConfirmedStateChanged, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-DBQDaDxJ.mjs";
|
|
3
3
|
import { a as FIVE_MINUTES_MS, c as bucketEndOf, i as DAY_MS, l as bucketStartOf, n as RetentionJob, o as HOUR_MS, r as DepartureTracker, s as ROLLUP_GRACE_MS, t as DEFAULT_RETENTION, u as floorTo } from "../../retention-CUOVI1p7.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
//#region src/builtins/device-history/capture/point-writer.ts
|
|
@@ -3982,10 +3982,11 @@ var DeviceHistoryAddon = class extends BaseAddon {
|
|
|
3982
3982
|
};
|
|
3983
3983
|
}
|
|
3984
3984
|
},
|
|
3985
|
-
readSnapshots: async () => api.deviceState.getAllSnapshots.query({}),
|
|
3985
|
+
readSnapshots: async () => api.deviceState.getAllSnapshots.query({ confirmed: true }),
|
|
3986
3986
|
readCapSlice: (deviceId, capName) => api.deviceState.getCapSlice.query({
|
|
3987
3987
|
deviceId,
|
|
3988
|
-
capName
|
|
3988
|
+
capName,
|
|
3989
|
+
confirmed: true
|
|
3989
3990
|
}),
|
|
3990
3991
|
readDeviceQuantity: async (deviceId) => {
|
|
3991
3992
|
const quantity = (await api.deviceManager.getDevice.query({ deviceId }))?.sourceInfo?.quantity;
|
|
@@ -4005,10 +4006,9 @@ var DeviceHistoryAddon = class extends BaseAddon {
|
|
|
4005
4006
|
this.transitions = transitions;
|
|
4006
4007
|
runtime.retentionJob.attachTransitions(transitions);
|
|
4007
4008
|
this.unsubscribe = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
|
|
4008
|
-
const data = event.data;
|
|
4009
|
-
if (
|
|
4009
|
+
const data = parseConfirmedStateChanged(event.data);
|
|
4010
|
+
if (data === null) return;
|
|
4010
4011
|
const { deviceId, capName, slice } = data;
|
|
4011
|
-
if (typeof deviceId !== "number" || typeof capName !== "string" || !isRecord(slice)) return;
|
|
4012
4012
|
const at = event.timestamp instanceof Date ? event.timestamp.getTime() : Date.now();
|
|
4013
4013
|
runtime.capture.handleState(deviceId, capName, slice, at);
|
|
4014
4014
|
runs.handleState(deviceId, capName, slice, at);
|
|
@@ -4036,10 +4036,11 @@ var DeviceHistoryAddon = class extends BaseAddon {
|
|
|
4036
4036
|
if (records === void 0) throw new Error("device-history needs ctx.records on the hub for the run ledger");
|
|
4037
4037
|
return new DeviceRunsService({
|
|
4038
4038
|
records,
|
|
4039
|
-
readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({}),
|
|
4039
|
+
readSnapshots: async () => ctx.api.deviceState.getAllSnapshots.query({ confirmed: true }),
|
|
4040
4040
|
readCapSlice: (deviceId, capName) => ctx.api.deviceState.getCapSlice.query({
|
|
4041
4041
|
deviceId,
|
|
4042
|
-
capName
|
|
4042
|
+
capName,
|
|
4043
|
+
confirmed: true
|
|
4043
4044
|
}),
|
|
4044
4045
|
deviceTypeOf: (deviceId) => runtime.directory.ensure(deviceId),
|
|
4045
4046
|
energyFromHistory: (deviceId, from, to) => energyKwhFromHistory((query) => runtime.query.query(query), deviceId, from, to),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arms the command hold (D1061) from the D1022 command seams.
|
|
3
|
+
*
|
|
4
|
+
* Every device command the hub sees — its tRPC mount, the UDS parent for a
|
|
5
|
+
* forked addon's `ctx.api`, an in-process addon's `ctx.api` — reaches the
|
|
6
|
+
* process-wide observer registry BEFORE the call runs. Here each one resolves
|
|
7
|
+
* what it leads to (the vocabulary's effects under the provider's option) on
|
|
8
|
+
* the slice the device last reported, and the mirror holds it; a refused call
|
|
9
|
+
* rolls the hold back at once.
|
|
10
|
+
*
|
|
11
|
+
* Telemetry in, never a gate (D8): a throw here costs the hold, never the call.
|
|
12
|
+
*/
|
|
13
|
+
import { type CommandHoldOptions, type IScopedLogger } from "@camstack/types";
|
|
14
|
+
import type { DeviceStateMirror } from "./device-state-mirror.js";
|
|
15
|
+
export interface CommandHoldsWiringDeps {
|
|
16
|
+
readonly mirror: DeviceStateMirror;
|
|
17
|
+
readonly logger: IScopedLogger;
|
|
18
|
+
/** The provider's options for a device cap; defaults to the process-wide registry. */
|
|
19
|
+
readonly optionsFor?: (deviceId: number, capName: string) => CommandHoldOptions | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** Subscribe the hold to the command observations; returns the unsubscribe. */
|
|
22
|
+
export declare function startCommandHolds(deps: CommandHoldsWiringDeps): () => void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command hold (D1061): what a device was just told to do, shown at once.
|
|
3
|
+
*
|
|
4
|
+
* A command arms a hold on each field its effects name; the mirror reads the
|
|
5
|
+
* device's slice through it (the EFFECTIVE slice) while the slice it stores,
|
|
6
|
+
* persists and records stays what the device reported. Each held field
|
|
7
|
+
* remembers what the device reported for it when the command arrived. A
|
|
8
|
+
* reading of a held field is
|
|
9
|
+
* - STALE when it equals that pre-command value (or a value an older,
|
|
10
|
+
* replaced command held): the device has not acted yet — keep holding;
|
|
11
|
+
* - the CONFIRMATION when it equals the held value, a number within the
|
|
12
|
+
* effect's tolerance (the step of the arg it came from) — release;
|
|
13
|
+
* - the DEVICE'S OWN ANSWER otherwise (locking, jammed, arming, a value
|
|
14
|
+
* rounded beyond the step) — release at once and serve it (logged at
|
|
15
|
+
* debug, `device-answered`).
|
|
16
|
+
* A held field also ends when the call is refused (rolled back at once), when
|
|
17
|
+
* the limit elapses with the device still stale (reverted, warned), or when a
|
|
18
|
+
* newer command names the same field (latest wins).
|
|
19
|
+
*
|
|
20
|
+
* Memory only: a restart drops every hold. Nothing here does I/O; the timers
|
|
21
|
+
* are unref'd so a hold never keeps a process alive.
|
|
22
|
+
*/
|
|
23
|
+
import type { CommandEffect, IScopedLogger } from "@camstack/types";
|
|
24
|
+
type Slice = Readonly<Record<string, unknown>>;
|
|
25
|
+
/** Why a hold ended other than by confirmation. */
|
|
26
|
+
export type HoldRelease = "refused" | "unconfirmed";
|
|
27
|
+
export interface CommandHoldsDeps {
|
|
28
|
+
readonly logger: IScopedLogger;
|
|
29
|
+
/** The slice the hold sits on (native, or a claim's merge), `null` when the cap has none. */
|
|
30
|
+
readonly baseSlice: (deviceId: number, capName: string) => Slice | null;
|
|
31
|
+
/** Re-emit the cap: the held set changed while the slice under it did not. */
|
|
32
|
+
readonly reemit: (deviceId: number, capName: string) => void;
|
|
33
|
+
}
|
|
34
|
+
/** What one command armed. */
|
|
35
|
+
export interface ArmRequest {
|
|
36
|
+
readonly deviceId: number;
|
|
37
|
+
readonly capName: string;
|
|
38
|
+
readonly method: string;
|
|
39
|
+
readonly effects: readonly CommandEffect[];
|
|
40
|
+
readonly holdMs: number;
|
|
41
|
+
}
|
|
42
|
+
export declare class CommandHolds {
|
|
43
|
+
private readonly deps;
|
|
44
|
+
/** device → cap → field → held value. */
|
|
45
|
+
private readonly held;
|
|
46
|
+
private readonly armings;
|
|
47
|
+
private seq;
|
|
48
|
+
constructor(deps: CommandHoldsDeps);
|
|
49
|
+
/**
|
|
50
|
+
* Hold what a command leads to. A field the slice already holds is not held
|
|
51
|
+
* (and a standing hold on it is dropped: the newer command wins). Returns the
|
|
52
|
+
* token that `release` takes, or `null` when nothing is held.
|
|
53
|
+
*/
|
|
54
|
+
arm(request: ArmRequest): number | null;
|
|
55
|
+
/** End what `token` still holds — refused at once, or unconfirmed at the limit. */
|
|
56
|
+
release(token: number, reason: HoldRelease): void;
|
|
57
|
+
/**
|
|
58
|
+
* The slice under the hold moved: keep each held field it still reports
|
|
59
|
+
* stale, drop the ones it confirms or answers otherwise.
|
|
60
|
+
*/
|
|
61
|
+
settle(deviceId: number, capName: string, base: Slice): void;
|
|
62
|
+
/** `base` with the held values over it; `base` itself when nothing is held. */
|
|
63
|
+
overlay(deviceId: number, capName: string, base: Slice): Slice;
|
|
64
|
+
/** Is any field of the cap held? */
|
|
65
|
+
isHolding(deviceId: number, capName: string): boolean;
|
|
66
|
+
/** Forget a removed device's holds. */
|
|
67
|
+
clearDevice(deviceId: number): void;
|
|
68
|
+
/** Stop every timer (shutdown). */
|
|
69
|
+
dispose(): void;
|
|
70
|
+
private fieldsOf;
|
|
71
|
+
private dropEmpty;
|
|
72
|
+
/** An arming whose fields were all confirmed or replaced holds nothing: stop its timer. */
|
|
73
|
+
private forgetStaleArmings;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -35,6 +35,8 @@ export declare class DeviceManagerAddon extends BaseAddon {
|
|
|
35
35
|
private stateMirrorImpl;
|
|
36
36
|
/** The transition audit (D1022): command + mirror correlation, shipped to device-history. */
|
|
37
37
|
private transitions;
|
|
38
|
+
/** Unsubscribes the command hold (D1061). */
|
|
39
|
+
private stopCommandHolds;
|
|
38
40
|
/**
|
|
39
41
|
* Removes the claimed-status overlay this addon installed on the capability
|
|
40
42
|
* registry (D663, S3): `getStatus` of a claimed cap answers the mirror for
|