@camstack/server 1.2.926 → 1.2.928
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 +14 -0
- package/package.json +10 -17
- package/system/dist/addon-utils.mjs +1 -1
- 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 +4 -4
- 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 +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- 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 +5 -5
- 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 +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- 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 +4 -4
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -4
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +1 -1
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +1 -1
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +103 -55
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +103 -55
- package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +24 -11
- 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 +5 -5
- package/system/dist/builtins/local-network/local-network.addon.d.ts +13 -0
- package/system/dist/builtins/local-network/local-network.addon.js +47 -10
- package/system/dist/builtins/local-network/local-network.addon.mjs +47 -10
- 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 +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- 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/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 +20 -20
- 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 +115 -115
- 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-BEXh051r.js → capture-engine-BcuwOSXv.js} +1 -1
- package/system/dist/{capture-engine-CWfylyT8.mjs → capture-engine-Bz7eXFjT.mjs} +1 -1
- package/system/dist/{composition-sources-CcpMUxus.mjs → composition-sources-BI614LJx.mjs} +1 -1
- package/system/dist/{composition-sources-B3_FuKde.js → composition-sources-v_kkb8A9.js} +1 -1
- package/system/dist/{constants-fPesBGmF.mjs → constants-BcUTQd1M.mjs} +1 -1
- package/system/dist/{constants-B0tqNa2l.js → constants-D2etJ02O.js} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-Bh0GEstW.js → device-ca-CU8zh9Pi.js} +1 -1
- package/system/dist/{device-ca-B98SR8Xf.mjs → device-ca-ExMN3xW3.mjs} +1 -1
- package/system/dist/{device-row-store-CfWN8mLZ.js → device-row-store-BMIR-n3m.js} +1 -1
- package/system/dist/{device-row-store-BBByy029.mjs → device-row-store-CeW_GWh9.mjs} +1 -1
- package/system/dist/{dist-CH-iCceM.mjs → dist-BCHMSqzc.mjs} +325 -2
- package/system/dist/{dist-CVjsCA7D.js → dist-BZfvhfS1.js} +325 -2
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-DCqJbSVn.mjs → hub-identity-CYC1820R.mjs} +10 -10
- package/system/dist/{hub-identity-BU4XzogT.js → hub-identity-Csxx2Q8k.js} +1 -1
- package/system/dist/{hub-mdns-ciao-BNzmwsIH.js → hub-mdns-ciao-By5577HM.js} +2 -2
- package/system/dist/{hub-mdns-ciao-IOM82NRd.mjs → hub-mdns-ciao-CCDxM5qz.mjs} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +217 -217
- package/system/dist/{legacy-integration-rows-door-CRcvhOWb.js → legacy-integration-rows-door-CVwOo5aq.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-nQzjUyPU.mjs → legacy-integration-rows-door-D9tQOUzh.mjs} +1 -1
- package/system/dist/{rename-composition-block-oOfXrUWs.js → rename-composition-block-C9HuBrKS.js} +1 -1
- package/system/dist/{rename-composition-block-CJ-C9HoY.mjs → rename-composition-block-DtaYmYAR.mjs} +1 -1
- package/system/dist/{restore-archive-DaYf1tQb.mjs → restore-archive-BJfyu0sG.mjs} +94 -94
- package/system/dist/{restore-archive-BSdudYif.js → restore-archive-CIFvqOze.js} +1 -1
- package/system/dist/{wal-maintenance-CyOVe3E1.mjs → wal-maintenance-CTrCPzds.mjs} +0 -0
- package/system/dist/{wal-maintenance-BRc_MNtZ.js → wal-maintenance-dq7T3quB.js} +0 -0
- package/system/package.json +1 -1
|
@@ -3,14 +3,14 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
7
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
8
8
|
const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
|
|
9
|
-
const require_rename_composition_block = require("../../rename-composition-block-
|
|
9
|
+
const require_rename_composition_block = require("../../rename-composition-block-C9HuBrKS.js");
|
|
10
10
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
11
11
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
12
12
|
const require_retired_settings_keys = require("../../retired-settings-keys-C8nOOr5H.js");
|
|
13
|
-
const require_device_row_store = require("../../device-row-store-
|
|
13
|
+
const require_device_row_store = require("../../device-row-store-BMIR-n3m.js");
|
|
14
14
|
const require_template_protocol = require("../../template-protocol-D5ogm1rj.js");
|
|
15
15
|
const require_dns_wire = require("../../dns-wire-B1BvF9Ao.js");
|
|
16
16
|
let zod = require("zod");
|
|
@@ -13695,7 +13695,7 @@ var TransitionCorrelator = class {
|
|
|
13695
13695
|
deps;
|
|
13696
13696
|
pending = /* @__PURE__ */ new Map();
|
|
13697
13697
|
seq = 0;
|
|
13698
|
-
|
|
13698
|
+
held = /* @__PURE__ */ new Map();
|
|
13699
13699
|
constructor(deps) {
|
|
13700
13700
|
this.deps = deps;
|
|
13701
13701
|
}
|
|
@@ -13732,7 +13732,7 @@ var TransitionCorrelator = class {
|
|
|
13732
13732
|
const fields = require_dist.auditedFields(capName);
|
|
13733
13733
|
if (fields.size === 0) return;
|
|
13734
13734
|
const now = this.deps.now();
|
|
13735
|
-
|
|
13735
|
+
const changes = [];
|
|
13736
13736
|
for (const field of fields) {
|
|
13737
13737
|
const hadBefore = prior !== void 0 && Object.hasOwn(prior, field);
|
|
13738
13738
|
const has = Object.hasOwn(slice, field);
|
|
@@ -13740,13 +13740,96 @@ var TransitionCorrelator = class {
|
|
|
13740
13740
|
const before = hadBefore ? prior[field] : void 0;
|
|
13741
13741
|
const after = has ? slice[field] : void 0;
|
|
13742
13742
|
if (sameValue(before, after)) continue;
|
|
13743
|
-
|
|
13743
|
+
changes.push({
|
|
13744
|
+
field,
|
|
13745
|
+
before,
|
|
13746
|
+
after,
|
|
13747
|
+
neverHeld: !hadBefore
|
|
13748
|
+
});
|
|
13744
13749
|
}
|
|
13750
|
+
if (changes.length === 0) return;
|
|
13751
|
+
const key = this.keyOf(deviceId, capName);
|
|
13752
|
+
const burst = this.held.get(key) ?? {
|
|
13753
|
+
deviceId,
|
|
13754
|
+
capName,
|
|
13755
|
+
fields: /* @__PURE__ */ new Map(),
|
|
13756
|
+
firstAt: now,
|
|
13757
|
+
lastAt: now
|
|
13758
|
+
};
|
|
13759
|
+
burst.lastAt = now;
|
|
13760
|
+
const claimable = this.hasLiveCommand(deviceId, capName, now);
|
|
13761
|
+
for (const change of changes) {
|
|
13762
|
+
const earlier = burst.fields.get(change.field);
|
|
13763
|
+
if (change.neverHeld && earlier === void 0 && !claimable) continue;
|
|
13764
|
+
burst.fields.set(change.field, {
|
|
13765
|
+
before: earlier !== void 0 ? earlier.before : change.before,
|
|
13766
|
+
after: change.after,
|
|
13767
|
+
neverHeld: earlier !== void 0 ? earlier.neverHeld : change.neverHeld
|
|
13768
|
+
});
|
|
13769
|
+
}
|
|
13770
|
+
if (burst.fields.size === 0) return;
|
|
13771
|
+
this.held.set(key, burst);
|
|
13772
|
+
if (this.commandMatchedBy(deviceId, capName, changes, now) !== void 0) this.flushBurst(key, burst);
|
|
13773
|
+
}
|
|
13774
|
+
hasLiveCommand(deviceId, capName, now) {
|
|
13775
|
+
return (this.pending.get(this.keyOf(deviceId, capName)) ?? []).some((e) => !e.settled && e.expiresAt > now);
|
|
13776
|
+
}
|
|
13777
|
+
/** Write every held burst now (shutdown): a held change must not be lost (D49). */
|
|
13778
|
+
flush() {
|
|
13779
|
+
for (const [key, burst] of [...this.held]) this.flushBurst(key, burst);
|
|
13780
|
+
}
|
|
13781
|
+
/** The fields of a burst that ended somewhere other than where they started. */
|
|
13782
|
+
netChanges(burst) {
|
|
13783
|
+
return [...burst.fields].filter(([, f]) => !sameValue(f.before, f.after)).map(([field, f]) => ({
|
|
13784
|
+
field,
|
|
13785
|
+
...f
|
|
13786
|
+
}));
|
|
13787
|
+
}
|
|
13788
|
+
flushBurst(key, burst) {
|
|
13789
|
+
this.held.delete(key);
|
|
13790
|
+
const net = this.netChanges(burst);
|
|
13791
|
+
const { deviceId, capName } = burst;
|
|
13792
|
+
for (const field of burst.fields.keys()) {
|
|
13793
|
+
if (net.some((c) => c.field === field)) continue;
|
|
13794
|
+
this.deps.logger?.debug(`device-transitions: ${capName}.${field} went and came back inside one burst; no row`, { tags: { deviceId } });
|
|
13795
|
+
}
|
|
13796
|
+
const touched = [...burst.fields].map(([field, f]) => ({
|
|
13797
|
+
field,
|
|
13798
|
+
...f
|
|
13799
|
+
}));
|
|
13800
|
+
let claimed = this.commandMatchedBy(deviceId, capName, touched, burst.lastAt);
|
|
13801
|
+
for (const change of net) claimed = this.attribute(deviceId, capName, change.field, toTransitionValue(change.before), toTransitionValue(change.after), burst.lastAt, claimed, change.neverHeld);
|
|
13802
|
+
const effect = claimed?.effect;
|
|
13803
|
+
if (claimed !== void 0 && effect !== null && effect !== void 0) {
|
|
13804
|
+
if (!net.some((c) => c.field === effect.field)) {
|
|
13805
|
+
const before = burst.fields.get(effect.field)?.before;
|
|
13806
|
+
this.confirmWithoutNet(key, claimed, effect.field, toTransitionValue(before), toTransitionValue(effect.value), burst.lastAt);
|
|
13807
|
+
}
|
|
13808
|
+
}
|
|
13809
|
+
}
|
|
13810
|
+
confirmWithoutNet(key, entry, field, from, to, at) {
|
|
13811
|
+
entry.settled = true;
|
|
13812
|
+
this.emit(entry, "confirmed", field, from, to, at - entry.obs.at, void 0, at);
|
|
13813
|
+
this.pruneSettled(key);
|
|
13814
|
+
}
|
|
13815
|
+
pruneSettled(key) {
|
|
13816
|
+
const ring = this.pending.get(key);
|
|
13817
|
+
if (ring === void 0) return;
|
|
13818
|
+
const rest = ring.filter((e) => !e.settled);
|
|
13819
|
+
if (rest.length === 0) this.pending.delete(key);
|
|
13820
|
+
else this.pending.set(key, rest);
|
|
13821
|
+
}
|
|
13822
|
+
flushDue(now) {
|
|
13823
|
+
for (const [key, burst] of [...this.held]) if (now - burst.lastAt >= 5e3 || now - burst.firstAt >= 6e4) this.flushBurst(key, burst);
|
|
13824
|
+
}
|
|
13825
|
+
/** The newest live command whose effect one of `changes` fulfils, if any. */
|
|
13826
|
+
commandMatchedBy(deviceId, capName, changes, now) {
|
|
13827
|
+
return [...(this.pending.get(this.keyOf(deviceId, capName)) ?? []).filter((e) => !e.settled && e.expiresAt > now)].reverse().find((e) => e.effect !== null && changes.some((c) => e.effect !== null && e.effect.field === c.field && sameValue(e.effect.value, toTransitionValue(c.after))));
|
|
13745
13828
|
}
|
|
13746
13829
|
/** Expire every pending command past its window. Driven by the sender's tick. */
|
|
13747
13830
|
sweep() {
|
|
13748
13831
|
const now = this.deps.now();
|
|
13749
|
-
this.
|
|
13832
|
+
this.flushDue(now);
|
|
13750
13833
|
for (const [key, ring] of this.pending) {
|
|
13751
13834
|
const live = [];
|
|
13752
13835
|
for (const entry of ring) {
|
|
@@ -13767,26 +13850,25 @@ var TransitionCorrelator = class {
|
|
|
13767
13850
|
/** Forget a removed device's pending commands. */
|
|
13768
13851
|
forgetDevice(deviceId) {
|
|
13769
13852
|
const prefix = `${deviceId}|`;
|
|
13770
|
-
for (const key of [...this.
|
|
13853
|
+
for (const key of [...this.held.keys()]) {
|
|
13854
|
+
if (!key.startsWith(prefix)) continue;
|
|
13855
|
+
this.deps.logger?.debug(`device-transitions: device removed with a held ${key.slice(prefix.length)} burst; dropped`, { tags: { deviceId } });
|
|
13856
|
+
this.held.delete(key);
|
|
13857
|
+
}
|
|
13771
13858
|
for (const key of [...this.pending.keys()]) if (key.startsWith(prefix)) this.pending.delete(key);
|
|
13772
13859
|
}
|
|
13773
13860
|
attribute(deviceId, capName, field, from, to, now, claimedByThisWrite, neverHeld) {
|
|
13774
13861
|
const key = this.keyOf(deviceId, capName);
|
|
13775
|
-
const
|
|
13776
|
-
const live = (ring ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13862
|
+
const live = (this.pending.get(key) ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13777
13863
|
const matched = [...live].reverse().find((e) => e.effect !== null && e.effect.field === field && sameValue(e.effect.value, to)) ?? claimedByThisWrite ?? [...live].reverse().find((e) => e.effect === null);
|
|
13778
13864
|
if (matched === void 0) {
|
|
13779
13865
|
if (neverHeld) return void 0;
|
|
13780
|
-
this.
|
|
13866
|
+
this.writeDevice(deviceId, capName, field, from, to, now);
|
|
13781
13867
|
return;
|
|
13782
13868
|
}
|
|
13783
13869
|
matched.settled = true;
|
|
13784
|
-
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at);
|
|
13785
|
-
|
|
13786
|
-
const rest = ring.filter((e) => !e.settled);
|
|
13787
|
-
if (rest.length === 0) this.pending.delete(key);
|
|
13788
|
-
else this.pending.set(key, rest);
|
|
13789
|
-
}
|
|
13870
|
+
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at, void 0, now);
|
|
13871
|
+
this.pruneSettled(key);
|
|
13790
13872
|
return matched;
|
|
13791
13873
|
}
|
|
13792
13874
|
expire(entry) {
|
|
@@ -13802,9 +13884,8 @@ var TransitionCorrelator = class {
|
|
|
13802
13884
|
const field = entry.effect?.field ?? "*";
|
|
13803
13885
|
this.emit(entry, "failed", field, entry.fromAtCommand, entry.fromAtCommand, null, message);
|
|
13804
13886
|
}
|
|
13805
|
-
emit(entry, outcome, field, from, to, matchedAfterMs, error) {
|
|
13887
|
+
emit(entry, outcome, field, from, to, matchedAfterMs, error, at = this.deps.now()) {
|
|
13806
13888
|
const { obs } = entry;
|
|
13807
|
-
const at = this.deps.now();
|
|
13808
13889
|
this.deps.emit({
|
|
13809
13890
|
id: this.nextId(obs.deviceId, at),
|
|
13810
13891
|
deviceId: obs.deviceId,
|
|
@@ -13825,27 +13906,7 @@ var TransitionCorrelator = class {
|
|
|
13825
13906
|
}
|
|
13826
13907
|
});
|
|
13827
13908
|
}
|
|
13828
|
-
/** A change nobody asked for
|
|
13829
|
-
emitDevice(deviceId, capName, field, from, to, at) {
|
|
13830
|
-
const key = `${deviceId}|${capName}|${field}`;
|
|
13831
|
-
const window = this.deviceRows.get(key);
|
|
13832
|
-
if (window === void 0 || at - window.lastEmitAt >= 1e4) {
|
|
13833
|
-
if (window?.held !== void 0 && !sameValue(window.held.from, window.held.to)) this.writeDevice(deviceId, capName, field, window.held.from, window.held.to, window.held.at);
|
|
13834
|
-
this.writeDevice(deviceId, capName, field, from, to, at);
|
|
13835
|
-
this.deviceRows.set(key, {
|
|
13836
|
-
deviceId,
|
|
13837
|
-
capName,
|
|
13838
|
-
field,
|
|
13839
|
-
lastEmitAt: at
|
|
13840
|
-
});
|
|
13841
|
-
return;
|
|
13842
|
-
}
|
|
13843
|
-
window.held = {
|
|
13844
|
-
from: window.held?.from ?? from,
|
|
13845
|
-
to,
|
|
13846
|
-
at
|
|
13847
|
-
};
|
|
13848
|
-
}
|
|
13909
|
+
/** A change nobody asked for. */
|
|
13849
13910
|
writeDevice(deviceId, capName, field, from, to, at) {
|
|
13850
13911
|
this.deps.emit({
|
|
13851
13912
|
id: this.nextId(deviceId, at),
|
|
@@ -13859,21 +13920,6 @@ var TransitionCorrelator = class {
|
|
|
13859
13920
|
actor: { kind: "device" }
|
|
13860
13921
|
});
|
|
13861
13922
|
}
|
|
13862
|
-
/** Release coalesced device rows whose window has closed; forget windows nothing is held in. */
|
|
13863
|
-
releaseDeviceRows(now) {
|
|
13864
|
-
for (const [key, window] of this.deviceRows) {
|
|
13865
|
-
if (now - window.lastEmitAt < 1e4) continue;
|
|
13866
|
-
const held = window.held;
|
|
13867
|
-
this.deviceRows.delete(key);
|
|
13868
|
-
if (held === void 0 || sameValue(held.from, held.to)) continue;
|
|
13869
|
-
this.writeDevice(window.deviceId, window.capName, window.field, held.from, held.to, held.at);
|
|
13870
|
-
this.deviceRows.set(key, {
|
|
13871
|
-
...window,
|
|
13872
|
-
held: void 0,
|
|
13873
|
-
lastEmitAt: now
|
|
13874
|
-
});
|
|
13875
|
-
}
|
|
13876
|
-
}
|
|
13877
13923
|
keyOf(deviceId, capName) {
|
|
13878
13924
|
return `${deviceId}|${capName}`;
|
|
13879
13925
|
}
|
|
@@ -13989,6 +14035,7 @@ function startDeviceTransitions(deps) {
|
|
|
13989
14035
|
};
|
|
13990
14036
|
const correlator = new TransitionCorrelator({
|
|
13991
14037
|
now,
|
|
14038
|
+
logger: deps.logger,
|
|
13992
14039
|
currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
|
|
13993
14040
|
emit: (row) => {
|
|
13994
14041
|
sender.enqueue(row);
|
|
@@ -14021,6 +14068,7 @@ function startDeviceTransitions(deps) {
|
|
|
14021
14068
|
unsubscribe();
|
|
14022
14069
|
deps.mirror.setTransitionTap(null);
|
|
14023
14070
|
stopTicker();
|
|
14071
|
+
correlator.flush();
|
|
14024
14072
|
await sender.flush();
|
|
14025
14073
|
sender.abandon();
|
|
14026
14074
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $ as DEVICE_TEMPLATE_VALUES_CAP, $l as isDeviceConfigCap, $o as sameIdentifiers, Br as createDeviceExtensionProvider, Bu as DeviceRole, El as auditedFields, Eu as secretTreeFromPaths, Fu as vocabActionIdFor, Ga as normalizeTags, Gl as expandCapMethods$1, Hi as identityLinkId, Hu as errMsg$1, Io as resolveCommandHold, Jo as resolveTemplateRef, Ka as normalizeUnit, Lc as BaseAddon, Ln as WORKLOAD_TRANSITION_CATEGORY, Ml as commandEffect, Mu as toSecretFieldView, Na as mergeIdentifiers, Nu as transformSecretWrite, Pi as generateDeviceAlias, Pu as userError, Qo as runtimeStatePolicyFor, Rn as WorkloadStateSchema, S as CAP_NAMES_WITH_STATUS, Su as resolveSecretMarkers, Ui as identityLinkSidesRefusal, Vi as identifierStrength, Vt as MINUTES_PER_DAY, Vu as DeviceType$1, W as DEVICE_IDENTIFIER_KEYS, Wu as EventCategory$1, X as DEVICE_TEMPLATE_MAX_LENGTH, Xs as workloadTransition, Y as DEVICE_TEMPLATE_FILTERS, Yr as defineExtensionSlotProvider, Ys as workloadCapability, Z as DEVICE_TEMPLATE_MAX_OUTPUT, Zl as isCommand$1, Zo as runtimeFieldUnit, aa as isKernelDerivedFeature, b as CAMERA_SWITCH_ORDER, bo as reconcileReportedFeatures, bt as FieldClaimModeSchema, ci as deviceStateCapability, cr as buildStreamParamsConfigSchema, di as effectiveRefreshIntervalMs, ei as deviceExtensionCapability, fi as enumerateItemArrayFields, fr as canonicalIconKey, ft as ExportNameRefusedError, gr as checkDeviceAlias, ii as deviceOffersActions, it as DeviceIdentifiersSchema, iu as isSecretClear, j as ConditionMirror, ji as formatMinutes, jl as collectZodSecretPaths$1, ku as sleep$2, li as deviceStatusCapability, ma as legacyAutoLinkIds, ms as siteZoneKey, nu as isKeychainStoredField, ot as DeviceStatusSchema, ou as isSecretMarker, pi as enumerateSchemaFields, pl as SECRET_CLEAR, ra as isEmptyIdentifiers, ri as deviceManagerCapability, rs as searchRank, s as ALL_CAPABILITY_DEFINITIONS, ss as settleDeviceFeatures, su as isSecretMarkerLike, tn as PUSH_CONFIRM_WINDOW_MS, to as parseStreamParamsFormPatch, ua as isWorkloadSettled, uc as capAppliesToDeviceKind, vi as expandContainer, vn as STREAM_PROFILE_META, wc as implementedMethodsOf$1, wr as commandBurstOffsets, xa as locationIconKey, xi as extractSourceInfoFromMetadata, xt as FieldClaimSchema, yl as WELL_KNOWN_TAB_MAP, z as DAY_NAMES, zu as DeviceFeature } from "../../dist-
|
|
1
|
+
import { $ as DEVICE_TEMPLATE_VALUES_CAP, $l as isDeviceConfigCap, $o as sameIdentifiers, Br as createDeviceExtensionProvider, Bu as DeviceRole, El as auditedFields, Eu as secretTreeFromPaths, Fu as vocabActionIdFor, Ga as normalizeTags, Gl as expandCapMethods$1, Hi as identityLinkId, Hu as errMsg$1, Io as resolveCommandHold, Jo as resolveTemplateRef, Ka as normalizeUnit, Lc as BaseAddon, Ln as WORKLOAD_TRANSITION_CATEGORY, Ml as commandEffect, Mu as toSecretFieldView, Na as mergeIdentifiers, Nu as transformSecretWrite, Pi as generateDeviceAlias, Pu as userError, Qo as runtimeStatePolicyFor, Rn as WorkloadStateSchema, S as CAP_NAMES_WITH_STATUS, Su as resolveSecretMarkers, Ui as identityLinkSidesRefusal, Vi as identifierStrength, Vt as MINUTES_PER_DAY, Vu as DeviceType$1, W as DEVICE_IDENTIFIER_KEYS, Wu as EventCategory$1, X as DEVICE_TEMPLATE_MAX_LENGTH, Xs as workloadTransition, Y as DEVICE_TEMPLATE_FILTERS, Yr as defineExtensionSlotProvider, Ys as workloadCapability, Z as DEVICE_TEMPLATE_MAX_OUTPUT, Zl as isCommand$1, Zo as runtimeFieldUnit, aa as isKernelDerivedFeature, b as CAMERA_SWITCH_ORDER, bo as reconcileReportedFeatures, bt as FieldClaimModeSchema, ci as deviceStateCapability, cr as buildStreamParamsConfigSchema, di as effectiveRefreshIntervalMs, ei as deviceExtensionCapability, fi as enumerateItemArrayFields, fr as canonicalIconKey, ft as ExportNameRefusedError, gr as checkDeviceAlias, ii as deviceOffersActions, it as DeviceIdentifiersSchema, iu as isSecretClear, j as ConditionMirror, ji as formatMinutes, jl as collectZodSecretPaths$1, ku as sleep$2, li as deviceStatusCapability, ma as legacyAutoLinkIds, ms as siteZoneKey, nu as isKeychainStoredField, ot as DeviceStatusSchema, ou as isSecretMarker, pi as enumerateSchemaFields, pl as SECRET_CLEAR, ra as isEmptyIdentifiers, ri as deviceManagerCapability, rs as searchRank, s as ALL_CAPABILITY_DEFINITIONS, ss as settleDeviceFeatures, su as isSecretMarkerLike, tn as PUSH_CONFIRM_WINDOW_MS, to as parseStreamParamsFormPatch, ua as isWorkloadSettled, uc as capAppliesToDeviceKind, vi as expandContainer, vn as STREAM_PROFILE_META, wc as implementedMethodsOf$1, wr as commandBurstOffsets, xa as locationIconKey, xi as extractSourceInfoFromMetadata, xt as FieldClaimSchema, yl as WELL_KNOWN_TAB_MAP, z as DAY_NAMES, zu as DeviceFeature } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { a as redactLogText, i as redactLogMeta, n as isSecretArgumentKey } from "../../log-redactor-XLDrPzOi.mjs";
|
|
4
|
-
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-
|
|
4
|
+
import { n as renameCompositionBlock, t as composedBlockIdOf } from "../../rename-composition-block-DtaYmYAR.mjs";
|
|
5
5
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
6
6
|
import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
7
7
|
import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-u6xQA6r7.mjs";
|
|
8
|
-
import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-
|
|
8
|
+
import { a as MigrationRefusedError, i as deviceManagerRecordKinds, n as DeviceRowStore, r as deviceRowBackendOf } from "../../device-row-store-CeW_GWh9.mjs";
|
|
9
9
|
import { n as isRenderResponse, r as analyzeTemplate } from "../../template-protocol-SgPDx3Hw.mjs";
|
|
10
10
|
import { s as normalizeServiceType } from "../../dns-wire-Dm3H_7ST.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
@@ -13689,7 +13689,7 @@ var TransitionCorrelator = class {
|
|
|
13689
13689
|
deps;
|
|
13690
13690
|
pending = /* @__PURE__ */ new Map();
|
|
13691
13691
|
seq = 0;
|
|
13692
|
-
|
|
13692
|
+
held = /* @__PURE__ */ new Map();
|
|
13693
13693
|
constructor(deps) {
|
|
13694
13694
|
this.deps = deps;
|
|
13695
13695
|
}
|
|
@@ -13726,7 +13726,7 @@ var TransitionCorrelator = class {
|
|
|
13726
13726
|
const fields = auditedFields(capName);
|
|
13727
13727
|
if (fields.size === 0) return;
|
|
13728
13728
|
const now = this.deps.now();
|
|
13729
|
-
|
|
13729
|
+
const changes = [];
|
|
13730
13730
|
for (const field of fields) {
|
|
13731
13731
|
const hadBefore = prior !== void 0 && Object.hasOwn(prior, field);
|
|
13732
13732
|
const has = Object.hasOwn(slice, field);
|
|
@@ -13734,13 +13734,96 @@ var TransitionCorrelator = class {
|
|
|
13734
13734
|
const before = hadBefore ? prior[field] : void 0;
|
|
13735
13735
|
const after = has ? slice[field] : void 0;
|
|
13736
13736
|
if (sameValue(before, after)) continue;
|
|
13737
|
-
|
|
13737
|
+
changes.push({
|
|
13738
|
+
field,
|
|
13739
|
+
before,
|
|
13740
|
+
after,
|
|
13741
|
+
neverHeld: !hadBefore
|
|
13742
|
+
});
|
|
13738
13743
|
}
|
|
13744
|
+
if (changes.length === 0) return;
|
|
13745
|
+
const key = this.keyOf(deviceId, capName);
|
|
13746
|
+
const burst = this.held.get(key) ?? {
|
|
13747
|
+
deviceId,
|
|
13748
|
+
capName,
|
|
13749
|
+
fields: /* @__PURE__ */ new Map(),
|
|
13750
|
+
firstAt: now,
|
|
13751
|
+
lastAt: now
|
|
13752
|
+
};
|
|
13753
|
+
burst.lastAt = now;
|
|
13754
|
+
const claimable = this.hasLiveCommand(deviceId, capName, now);
|
|
13755
|
+
for (const change of changes) {
|
|
13756
|
+
const earlier = burst.fields.get(change.field);
|
|
13757
|
+
if (change.neverHeld && earlier === void 0 && !claimable) continue;
|
|
13758
|
+
burst.fields.set(change.field, {
|
|
13759
|
+
before: earlier !== void 0 ? earlier.before : change.before,
|
|
13760
|
+
after: change.after,
|
|
13761
|
+
neverHeld: earlier !== void 0 ? earlier.neverHeld : change.neverHeld
|
|
13762
|
+
});
|
|
13763
|
+
}
|
|
13764
|
+
if (burst.fields.size === 0) return;
|
|
13765
|
+
this.held.set(key, burst);
|
|
13766
|
+
if (this.commandMatchedBy(deviceId, capName, changes, now) !== void 0) this.flushBurst(key, burst);
|
|
13767
|
+
}
|
|
13768
|
+
hasLiveCommand(deviceId, capName, now) {
|
|
13769
|
+
return (this.pending.get(this.keyOf(deviceId, capName)) ?? []).some((e) => !e.settled && e.expiresAt > now);
|
|
13770
|
+
}
|
|
13771
|
+
/** Write every held burst now (shutdown): a held change must not be lost (D49). */
|
|
13772
|
+
flush() {
|
|
13773
|
+
for (const [key, burst] of [...this.held]) this.flushBurst(key, burst);
|
|
13774
|
+
}
|
|
13775
|
+
/** The fields of a burst that ended somewhere other than where they started. */
|
|
13776
|
+
netChanges(burst) {
|
|
13777
|
+
return [...burst.fields].filter(([, f]) => !sameValue(f.before, f.after)).map(([field, f]) => ({
|
|
13778
|
+
field,
|
|
13779
|
+
...f
|
|
13780
|
+
}));
|
|
13781
|
+
}
|
|
13782
|
+
flushBurst(key, burst) {
|
|
13783
|
+
this.held.delete(key);
|
|
13784
|
+
const net = this.netChanges(burst);
|
|
13785
|
+
const { deviceId, capName } = burst;
|
|
13786
|
+
for (const field of burst.fields.keys()) {
|
|
13787
|
+
if (net.some((c) => c.field === field)) continue;
|
|
13788
|
+
this.deps.logger?.debug(`device-transitions: ${capName}.${field} went and came back inside one burst; no row`, { tags: { deviceId } });
|
|
13789
|
+
}
|
|
13790
|
+
const touched = [...burst.fields].map(([field, f]) => ({
|
|
13791
|
+
field,
|
|
13792
|
+
...f
|
|
13793
|
+
}));
|
|
13794
|
+
let claimed = this.commandMatchedBy(deviceId, capName, touched, burst.lastAt);
|
|
13795
|
+
for (const change of net) claimed = this.attribute(deviceId, capName, change.field, toTransitionValue(change.before), toTransitionValue(change.after), burst.lastAt, claimed, change.neverHeld);
|
|
13796
|
+
const effect = claimed?.effect;
|
|
13797
|
+
if (claimed !== void 0 && effect !== null && effect !== void 0) {
|
|
13798
|
+
if (!net.some((c) => c.field === effect.field)) {
|
|
13799
|
+
const before = burst.fields.get(effect.field)?.before;
|
|
13800
|
+
this.confirmWithoutNet(key, claimed, effect.field, toTransitionValue(before), toTransitionValue(effect.value), burst.lastAt);
|
|
13801
|
+
}
|
|
13802
|
+
}
|
|
13803
|
+
}
|
|
13804
|
+
confirmWithoutNet(key, entry, field, from, to, at) {
|
|
13805
|
+
entry.settled = true;
|
|
13806
|
+
this.emit(entry, "confirmed", field, from, to, at - entry.obs.at, void 0, at);
|
|
13807
|
+
this.pruneSettled(key);
|
|
13808
|
+
}
|
|
13809
|
+
pruneSettled(key) {
|
|
13810
|
+
const ring = this.pending.get(key);
|
|
13811
|
+
if (ring === void 0) return;
|
|
13812
|
+
const rest = ring.filter((e) => !e.settled);
|
|
13813
|
+
if (rest.length === 0) this.pending.delete(key);
|
|
13814
|
+
else this.pending.set(key, rest);
|
|
13815
|
+
}
|
|
13816
|
+
flushDue(now) {
|
|
13817
|
+
for (const [key, burst] of [...this.held]) if (now - burst.lastAt >= 5e3 || now - burst.firstAt >= 6e4) this.flushBurst(key, burst);
|
|
13818
|
+
}
|
|
13819
|
+
/** The newest live command whose effect one of `changes` fulfils, if any. */
|
|
13820
|
+
commandMatchedBy(deviceId, capName, changes, now) {
|
|
13821
|
+
return [...(this.pending.get(this.keyOf(deviceId, capName)) ?? []).filter((e) => !e.settled && e.expiresAt > now)].reverse().find((e) => e.effect !== null && changes.some((c) => e.effect !== null && e.effect.field === c.field && sameValue(e.effect.value, toTransitionValue(c.after))));
|
|
13739
13822
|
}
|
|
13740
13823
|
/** Expire every pending command past its window. Driven by the sender's tick. */
|
|
13741
13824
|
sweep() {
|
|
13742
13825
|
const now = this.deps.now();
|
|
13743
|
-
this.
|
|
13826
|
+
this.flushDue(now);
|
|
13744
13827
|
for (const [key, ring] of this.pending) {
|
|
13745
13828
|
const live = [];
|
|
13746
13829
|
for (const entry of ring) {
|
|
@@ -13761,26 +13844,25 @@ var TransitionCorrelator = class {
|
|
|
13761
13844
|
/** Forget a removed device's pending commands. */
|
|
13762
13845
|
forgetDevice(deviceId) {
|
|
13763
13846
|
const prefix = `${deviceId}|`;
|
|
13764
|
-
for (const key of [...this.
|
|
13847
|
+
for (const key of [...this.held.keys()]) {
|
|
13848
|
+
if (!key.startsWith(prefix)) continue;
|
|
13849
|
+
this.deps.logger?.debug(`device-transitions: device removed with a held ${key.slice(prefix.length)} burst; dropped`, { tags: { deviceId } });
|
|
13850
|
+
this.held.delete(key);
|
|
13851
|
+
}
|
|
13765
13852
|
for (const key of [...this.pending.keys()]) if (key.startsWith(prefix)) this.pending.delete(key);
|
|
13766
13853
|
}
|
|
13767
13854
|
attribute(deviceId, capName, field, from, to, now, claimedByThisWrite, neverHeld) {
|
|
13768
13855
|
const key = this.keyOf(deviceId, capName);
|
|
13769
|
-
const
|
|
13770
|
-
const live = (ring ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13856
|
+
const live = (this.pending.get(key) ?? []).filter((e) => !e.settled && e.expiresAt > now);
|
|
13771
13857
|
const matched = [...live].reverse().find((e) => e.effect !== null && e.effect.field === field && sameValue(e.effect.value, to)) ?? claimedByThisWrite ?? [...live].reverse().find((e) => e.effect === null);
|
|
13772
13858
|
if (matched === void 0) {
|
|
13773
13859
|
if (neverHeld) return void 0;
|
|
13774
|
-
this.
|
|
13860
|
+
this.writeDevice(deviceId, capName, field, from, to, now);
|
|
13775
13861
|
return;
|
|
13776
13862
|
}
|
|
13777
13863
|
matched.settled = true;
|
|
13778
|
-
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at);
|
|
13779
|
-
|
|
13780
|
-
const rest = ring.filter((e) => !e.settled);
|
|
13781
|
-
if (rest.length === 0) this.pending.delete(key);
|
|
13782
|
-
else this.pending.set(key, rest);
|
|
13783
|
-
}
|
|
13864
|
+
this.emit(matched, "confirmed", field, from, to, now - matched.obs.at, void 0, now);
|
|
13865
|
+
this.pruneSettled(key);
|
|
13784
13866
|
return matched;
|
|
13785
13867
|
}
|
|
13786
13868
|
expire(entry) {
|
|
@@ -13796,9 +13878,8 @@ var TransitionCorrelator = class {
|
|
|
13796
13878
|
const field = entry.effect?.field ?? "*";
|
|
13797
13879
|
this.emit(entry, "failed", field, entry.fromAtCommand, entry.fromAtCommand, null, message);
|
|
13798
13880
|
}
|
|
13799
|
-
emit(entry, outcome, field, from, to, matchedAfterMs, error) {
|
|
13881
|
+
emit(entry, outcome, field, from, to, matchedAfterMs, error, at = this.deps.now()) {
|
|
13800
13882
|
const { obs } = entry;
|
|
13801
|
-
const at = this.deps.now();
|
|
13802
13883
|
this.deps.emit({
|
|
13803
13884
|
id: this.nextId(obs.deviceId, at),
|
|
13804
13885
|
deviceId: obs.deviceId,
|
|
@@ -13819,27 +13900,7 @@ var TransitionCorrelator = class {
|
|
|
13819
13900
|
}
|
|
13820
13901
|
});
|
|
13821
13902
|
}
|
|
13822
|
-
/** A change nobody asked for
|
|
13823
|
-
emitDevice(deviceId, capName, field, from, to, at) {
|
|
13824
|
-
const key = `${deviceId}|${capName}|${field}`;
|
|
13825
|
-
const window = this.deviceRows.get(key);
|
|
13826
|
-
if (window === void 0 || at - window.lastEmitAt >= 1e4) {
|
|
13827
|
-
if (window?.held !== void 0 && !sameValue(window.held.from, window.held.to)) this.writeDevice(deviceId, capName, field, window.held.from, window.held.to, window.held.at);
|
|
13828
|
-
this.writeDevice(deviceId, capName, field, from, to, at);
|
|
13829
|
-
this.deviceRows.set(key, {
|
|
13830
|
-
deviceId,
|
|
13831
|
-
capName,
|
|
13832
|
-
field,
|
|
13833
|
-
lastEmitAt: at
|
|
13834
|
-
});
|
|
13835
|
-
return;
|
|
13836
|
-
}
|
|
13837
|
-
window.held = {
|
|
13838
|
-
from: window.held?.from ?? from,
|
|
13839
|
-
to,
|
|
13840
|
-
at
|
|
13841
|
-
};
|
|
13842
|
-
}
|
|
13903
|
+
/** A change nobody asked for. */
|
|
13843
13904
|
writeDevice(deviceId, capName, field, from, to, at) {
|
|
13844
13905
|
this.deps.emit({
|
|
13845
13906
|
id: this.nextId(deviceId, at),
|
|
@@ -13853,21 +13914,6 @@ var TransitionCorrelator = class {
|
|
|
13853
13914
|
actor: { kind: "device" }
|
|
13854
13915
|
});
|
|
13855
13916
|
}
|
|
13856
|
-
/** Release coalesced device rows whose window has closed; forget windows nothing is held in. */
|
|
13857
|
-
releaseDeviceRows(now) {
|
|
13858
|
-
for (const [key, window] of this.deviceRows) {
|
|
13859
|
-
if (now - window.lastEmitAt < 1e4) continue;
|
|
13860
|
-
const held = window.held;
|
|
13861
|
-
this.deviceRows.delete(key);
|
|
13862
|
-
if (held === void 0 || sameValue(held.from, held.to)) continue;
|
|
13863
|
-
this.writeDevice(window.deviceId, window.capName, window.field, held.from, held.to, held.at);
|
|
13864
|
-
this.deviceRows.set(key, {
|
|
13865
|
-
...window,
|
|
13866
|
-
held: void 0,
|
|
13867
|
-
lastEmitAt: now
|
|
13868
|
-
});
|
|
13869
|
-
}
|
|
13870
|
-
}
|
|
13871
13917
|
keyOf(deviceId, capName) {
|
|
13872
13918
|
return `${deviceId}|${capName}`;
|
|
13873
13919
|
}
|
|
@@ -13983,6 +14029,7 @@ function startDeviceTransitions(deps) {
|
|
|
13983
14029
|
};
|
|
13984
14030
|
const correlator = new TransitionCorrelator({
|
|
13985
14031
|
now,
|
|
14032
|
+
logger: deps.logger,
|
|
13986
14033
|
currentSlice: (deviceId, capName) => deps.mirror.currentSlice(deviceId, capName),
|
|
13987
14034
|
emit: (row) => {
|
|
13988
14035
|
sender.enqueue(row);
|
|
@@ -14015,6 +14062,7 @@ function startDeviceTransitions(deps) {
|
|
|
14015
14062
|
unsubscribe();
|
|
14016
14063
|
deps.mirror.setTransitionTap(null);
|
|
14017
14064
|
stopTicker();
|
|
14065
|
+
correlator.flush();
|
|
14018
14066
|
await sender.flush();
|
|
14019
14067
|
sender.abandon();
|
|
14020
14068
|
}
|
|
@@ -13,22 +13,27 @@
|
|
|
13
13
|
* mirror's current slice. Nothing here does I/O, so a state write never waits on
|
|
14
14
|
* the audit; what it produces is handed to `emit`, whose queue is bounded.
|
|
15
15
|
*/
|
|
16
|
-
import { type DeviceCommandObservation, type DeviceTransition, type TransitionValue } from "@camstack/types";
|
|
16
|
+
import { type DeviceCommandObservation, type DeviceTransition, type IScopedLogger, type TransitionValue } from "@camstack/types";
|
|
17
17
|
/** How long a command waits for the change it should cause. */
|
|
18
18
|
export declare const COMMAND_MATCH_WINDOW_MS = 3e4;
|
|
19
19
|
/** Pending commands kept per (device, cap); the oldest is expired when a ninth arrives. */
|
|
20
20
|
export declare const PENDING_RING_MAX = 8;
|
|
21
21
|
/**
|
|
22
|
-
* A
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* A cap's audited fields are SETTLED before they are written: changes are held as one burst per
|
|
23
|
+
* (device, cap) and written, one row per field, when the burst ends. It ends when a pending
|
|
24
|
+
* command is matched by its effect (written at once, credited to the command), or when the cap
|
|
25
|
+
* has been quiet for this long. A cover that reports `open`, `position 6`, `opening`, then `open`
|
|
26
|
+
* and `position 100` is one change per field (`closed -> open`, `0 -> 100`), not five.
|
|
26
27
|
*/
|
|
27
|
-
export declare const
|
|
28
|
+
export declare const SETTLE_QUIET_MS = 5e3;
|
|
29
|
+
/** A burst that never goes quiet (a flapping sensor) is written anyway after this long. */
|
|
30
|
+
export declare const SETTLE_MAX_HOLD_MS = 6e4;
|
|
28
31
|
/** The field of a row whose command named none (a toggle that changed nothing we saw). */
|
|
29
32
|
export declare const NO_FIELD = "*";
|
|
30
33
|
export type CurrentSlice = (deviceId: number, capName: string) => Readonly<Record<string, unknown>> | undefined;
|
|
31
34
|
export interface CorrelatorDeps {
|
|
35
|
+
/** Optional: names the branches that write nothing (a there-and-back field, a dropped burst). */
|
|
36
|
+
readonly logger?: IScopedLogger;
|
|
32
37
|
readonly now: () => number;
|
|
33
38
|
readonly currentSlice: CurrentSlice;
|
|
34
39
|
readonly emit: (transition: DeviceTransition) => void;
|
|
@@ -41,12 +46,23 @@ export declare class TransitionCorrelator {
|
|
|
41
46
|
private readonly deps;
|
|
42
47
|
private readonly pending;
|
|
43
48
|
private seq;
|
|
44
|
-
private readonly
|
|
49
|
+
private readonly held;
|
|
45
50
|
constructor(deps: CorrelatorDeps);
|
|
46
51
|
/** A command left its caller. */
|
|
47
52
|
recordCommand(obs: DeviceCommandObservation): void;
|
|
48
53
|
/** The mirror stored a new native slice for `capName` (the previous one, if any, is `prior`). */
|
|
49
54
|
onSliceChange(deviceId: number, capName: string, prior: Readonly<Record<string, unknown>> | undefined, slice: Readonly<Record<string, unknown>>): void;
|
|
55
|
+
private hasLiveCommand;
|
|
56
|
+
/** Write every held burst now (shutdown): a held change must not be lost (D49). */
|
|
57
|
+
flush(): void;
|
|
58
|
+
/** The fields of a burst that ended somewhere other than where they started. */
|
|
59
|
+
private netChanges;
|
|
60
|
+
private flushBurst;
|
|
61
|
+
private confirmWithoutNet;
|
|
62
|
+
private pruneSettled;
|
|
63
|
+
private flushDue;
|
|
64
|
+
/** The newest live command whose effect one of `changes` fulfils, if any. */
|
|
65
|
+
private commandMatchedBy;
|
|
50
66
|
/** Expire every pending command past its window. Driven by the sender's tick. */
|
|
51
67
|
sweep(): void;
|
|
52
68
|
/** Commands still waiting, for a status read. */
|
|
@@ -57,11 +73,8 @@ export declare class TransitionCorrelator {
|
|
|
57
73
|
private expire;
|
|
58
74
|
private fail;
|
|
59
75
|
private emit;
|
|
60
|
-
/** A change nobody asked for
|
|
61
|
-
private emitDevice;
|
|
76
|
+
/** A change nobody asked for. */
|
|
62
77
|
private writeDevice;
|
|
63
|
-
/** Release coalesced device rows whose window has closed; forget windows nothing is held in. */
|
|
64
|
-
private releaseDeviceRows;
|
|
65
78
|
private keyOf;
|
|
66
79
|
private nextId;
|
|
67
80
|
private nextCommandId;
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
9
9
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lc as BaseAddon, wa as logDestinationCapability } from "../../dist-
|
|
1
|
+
import { Lc as BaseAddon, wa as logDestinationCapability } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
|
|
4
4
|
var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
|
|
@@ -3,11 +3,11 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
7
|
-
const require_device_ca = require("../../device-ca-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
|
+
const require_device_ca = require("../../device-ca-CU8zh9Pi.js");
|
|
8
8
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
9
|
-
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-
|
|
10
|
-
const require_constants = require("../../constants-
|
|
9
|
+
const require_legacy_integration_rows_door = require("../../legacy-integration-rows-door-CVwOo5aq.js");
|
|
10
|
+
const require_constants = require("../../constants-D2etJ02O.js");
|
|
11
11
|
const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
|
|
12
12
|
let node_crypto = require("node:crypto");
|
|
13
13
|
let _camstack_types_node = require("@camstack/types/node");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ft as KeychainAuditEntrySchema, It as KeychainResetRecordSchema, Kl as formatSecretScope, Lc as BaseAddon, Pt as KEYCHAIN_RESET_TRIGGER_ACTOR, Wu as EventCategory, fa as keychainAdminCapability, mu as normalizeSecretOwner, pa as keychainCapability, vu as parseSecretRef, zl as defineRecordKinds } from "../../dist-
|
|
2
|
-
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-
|
|
1
|
+
import { Ft as KeychainAuditEntrySchema, It as KeychainResetRecordSchema, Kl as formatSecretScope, Lc as BaseAddon, Pt as KEYCHAIN_RESET_TRIGGER_ACTOR, Wu as EventCategory, fa as keychainAdminCapability, mu as normalizeSecretOwner, pa as keychainCapability, vu as parseSecretRef, zl as defineRecordKinds } from "../../dist-BCHMSqzc.mjs";
|
|
2
|
+
import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-ExMN3xW3.mjs";
|
|
3
3
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
4
|
-
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-
|
|
5
|
-
import { a as MESH_CA_KEY_REF } from "../../constants-
|
|
4
|
+
import { t as LEGACY_INTEGRATION_ROWS_TABLE } from "../../legacy-integration-rows-door-D9tQOUzh.mjs";
|
|
5
|
+
import { a as MESH_CA_KEY_REF } from "../../constants-BcUTQd1M.mjs";
|
|
6
6
|
import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
|
|
7
7
|
import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
8
8
|
import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Hu as errMsg, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, fn as RecordingStatusSchema, ka as mayWriteToLocation, ln as RECORDING_SOURCE_CAMSTACK_ADDON } from "../../dist-
|
|
1
|
+
import { Hu as errMsg, Lc as BaseAddon, Pl as createEvent, Wu as EventCategory, fn as RecordingStatusSchema, ka as mayWriteToLocation, ln as RECORDING_SOURCE_CAMSTACK_ADDON } from "../../dist-BCHMSqzc.mjs";
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as fsp from "node:fs/promises";
|
|
@@ -3,10 +3,10 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-BZfvhfS1.js");
|
|
7
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
8
8
|
const require_ms$1 = require("../../ms-LB3giGoU.js");
|
|
9
|
-
const require_device_ca = require("../../device-ca-
|
|
9
|
+
const require_device_ca = require("../../device-ca-CU8zh9Pi.js");
|
|
10
10
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
11
11
|
let zod = require("zod");
|
|
12
12
|
let node_crypto = require("node:crypto");
|