@camstack/server 1.2.899 → 1.2.901
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/dist/api/trpc/generated-cap-routers.js +50 -0
- package/package.json +11 -10
- 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 +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/composition-api.d.ts +37 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +14 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +516 -7
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +516 -7
- package/system/dist/builtins/core-blocks/link-contributions.d.ts +85 -0
- package/system/dist/builtins/core-blocks/power-source-service.d.ts +25 -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-identifiers-action.d.ts +8 -0
- package/system/dist/builtins/device-manager/device-identity-index.d.ts +56 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +625 -62
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +624 -61
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +9 -1
- package/system/dist/builtins/device-manager/device-provider-context.d.ts +3 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +4 -2
- package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +66 -0
- package/system/dist/builtins/device-manager/identity-links-store.d.ts +22 -0
- package/system/dist/builtins/device-manager/record-kinds.d.ts +2 -1
- 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/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 +284 -284
- 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-LHKTf-nM.js → capture-engine-B3csK2sW.js} +1 -1
- package/system/dist/{capture-engine-BcD6iCZM.mjs → capture-engine-CCAzcezv.mjs} +1 -1
- package/system/dist/{composition-sources-C3ARJk2g.mjs → composition-sources-BX7u-Hdf.mjs} +1 -1
- package/system/dist/{composition-sources-DNUDbuXy.js → composition-sources-Bkbk5Oh5.js} +1 -1
- package/system/dist/{constants-dL8fl9aI.js → constants-BqxCksdV.js} +1 -1
- package/system/dist/{constants-er38mZOb.mjs → constants-_bOm_ae5.mjs} +1 -1
- package/system/dist/{device-ca-Ccz5olgH.mjs → device-ca-DRqN1P5Y.mjs} +1 -1
- package/system/dist/{device-ca-KWa6uJRU.js → device-ca-KNx_DazP.js} +1 -1
- package/system/dist/{dist-DEAjZE_-.js → dist-BNrIzdrJ.js} +351 -7
- package/system/dist/{dist-DBanWvHF.mjs → dist-S-zGcCEr.mjs} +310 -8
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-CVv79TVO.mjs → hub-identity-DSdbZxeR.mjs} +1 -1
- package/system/dist/{hub-identity-Dy8ZSUuq.js → hub-identity-pN0LtUhx.js} +1 -1
- package/system/dist/{hub-mdns-ciao-C_XjO7YI.js → hub-mdns-ciao-GafEbDm8.js} +2 -2
- package/system/dist/{hub-mdns-ciao-DtmIyWDL.mjs → hub-mdns-ciao-wAcv5VBY.mjs} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-BL8T4lya.mjs → legacy-integration-rows-door--186Wij_.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-DPInWtE6.js → legacy-integration-rows-door-B1swGb0r.js} +1 -1
- package/system/dist/{rename-composition-block-Dgo-9-Ts.mjs → rename-composition-block-Cf5syiM4.mjs} +1 -1
- package/system/dist/{rename-composition-block-BxzETYOf.js → rename-composition-block-gJ_4GdHr.js} +1 -1
- package/system/dist/{restore-archive-BUtuNTe1.mjs → restore-archive-DScscuGI.mjs} +82 -82
- package/system/dist/{restore-archive-Zvx9sHZP.js → restore-archive-DXi9iBay.js} +1 -1
- package/system/dist/{wal-maintenance-DS2IKwtK.js → wal-maintenance-BA9XNPvt.js} +0 -0
- package/system/dist/{wal-maintenance-cASt_sYy.mjs → wal-maintenance-s3KdED98.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Customize features an identity link contributes (D1063).
|
|
3
|
+
*
|
|
4
|
+
* A `linked` link whose evidence holds adds, on its host device, each default
|
|
5
|
+
* contribution its kind declares (`IDENTITY_LINK_KINDS[kind].contributions`) — a PoE port's link adds
|
|
6
|
+
* `power-source` to the camera it feeds, sourced from the port's `switch.on`.
|
|
7
|
+
* The feature is an ordinary D663 customization feature stamped
|
|
8
|
+
* `contributedBy: { linkId }`; its `enabled` toggle is the operator's (D62) and
|
|
9
|
+
* survives every pass. A link that is no longer `linked` takes back only the
|
|
10
|
+
* features it stamped — and so does a `linked` operator link flagged
|
|
11
|
+
* `evidenceGone`, until its evidence returns.
|
|
12
|
+
*
|
|
13
|
+
* Skipped, with a line in the host's log:
|
|
14
|
+
* - the host serves the cap natively (D944) — the link never replaces it;
|
|
15
|
+
* - the operator already set that target with no stamp — the operator wins;
|
|
16
|
+
* - another link already stamped that cap on the host.
|
|
17
|
+
*
|
|
18
|
+
* When a pass runs: on `identity-link.created` / `.lost`; once at boot (and on
|
|
19
|
+
* each device registration until a pass has read the links); after any write of
|
|
20
|
+
* a customization by someone other than this reconciler (`compositionWritten`);
|
|
21
|
+
* and when `power-source` refuses to act through a stamp whose link is gone
|
|
22
|
+
* (`link-lost`). Events are telemetry and may be dropped (D11): every pass reads
|
|
23
|
+
* the links itself over RPC, and the dangerous case — cutting power through a
|
|
24
|
+
* port that now feeds another device — is closed at the point of use, where
|
|
25
|
+
* `power-source` re-reads the link before it acts. Coalesced and serialized; no
|
|
26
|
+
* timer. Links that are `not-loaded` change nothing (D315).
|
|
27
|
+
*
|
|
28
|
+
* A write refused because the block changed since it was read
|
|
29
|
+
* (`CompositionChangedError`) is retried against a fresh read, at most
|
|
30
|
+
* {@link MAX_HOST_ATTEMPTS} times per host per pass, then logged.
|
|
31
|
+
*
|
|
32
|
+
* The operator's off-switch for a contribution is `enabled: false` only; the
|
|
33
|
+
* composition API refuses to remove a stamped feature, so a feature absent here
|
|
34
|
+
* is one this reconciler never wrote and adding it is correct.
|
|
35
|
+
*/
|
|
36
|
+
import { type Composition, type CompositionFeature, type CompositionFieldsFeature, type CompositionSourceRef, type CoreBlock, type IdentityLink, type IdentityLinkContribution, type IdentityLinksRead, type IScopedLogger } from "@camstack/types";
|
|
37
|
+
/** Attempts per host per pass when the block keeps changing under the write. */
|
|
38
|
+
export declare const MAX_HOST_ATTEMPTS = 3;
|
|
39
|
+
/** What the reconciler reads and writes; the addon wires these to `ctx.api` and the composition API. */
|
|
40
|
+
export interface LinkContributionPorts {
|
|
41
|
+
readonly listLinks: () => Promise<IdentityLinksRead>;
|
|
42
|
+
/** The device id of a host no link names any more; null when it cannot be found. */
|
|
43
|
+
readonly deviceIdOf: (ref: CompositionSourceRef) => Promise<number | null>;
|
|
44
|
+
/** The caps bound on a device right now (`getBindings`). */
|
|
45
|
+
readonly boundCaps: (deviceId: number) => Promise<readonly string[]>;
|
|
46
|
+
/** Every stored block; `null` until the table was read. */
|
|
47
|
+
readonly blocks: () => readonly CoreBlock[] | null;
|
|
48
|
+
readonly create: (host: CompositionSourceRef, features: readonly CompositionFeature[]) => Promise<void>;
|
|
49
|
+
readonly update: (block: CoreBlock, composition: Composition) => Promise<void>;
|
|
50
|
+
readonly logger: IScopedLogger;
|
|
51
|
+
}
|
|
52
|
+
/** One contribution a linked link owes its host. */
|
|
53
|
+
interface Owed {
|
|
54
|
+
readonly link: IdentityLink;
|
|
55
|
+
readonly contribution: IdentityLinkContribution;
|
|
56
|
+
readonly hostDeviceId: number;
|
|
57
|
+
readonly source: CompositionSourceRef;
|
|
58
|
+
}
|
|
59
|
+
/** Compile one contribution as the Customize editor would, then stamp it. */
|
|
60
|
+
export declare function compileContribution(owed: Owed, host: CompositionSourceRef): CompositionFieldsFeature | null;
|
|
61
|
+
export declare class LinkContributionReconciler {
|
|
62
|
+
private readonly ports;
|
|
63
|
+
private tail;
|
|
64
|
+
private passQueued;
|
|
65
|
+
private answered;
|
|
66
|
+
constructor(ports: LinkContributionPorts);
|
|
67
|
+
/** True once a pass has read the links — until then a device registration asks again. */
|
|
68
|
+
hasAnswered(): boolean;
|
|
69
|
+
requestPass(): void;
|
|
70
|
+
settled(): Promise<void>;
|
|
71
|
+
pass(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* The id of a host whose stamps go: from a link that still names it (a
|
|
74
|
+
* dismissed one), else from the device listing.
|
|
75
|
+
*/
|
|
76
|
+
private hostIdOf;
|
|
77
|
+
private reconcileWithRetry;
|
|
78
|
+
private reconcileHost;
|
|
79
|
+
/** The target a stamped feature carries: the kind table names it. */
|
|
80
|
+
private targetIdOfStamp;
|
|
81
|
+
private skip;
|
|
82
|
+
private log;
|
|
83
|
+
private serialized;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -16,9 +16,18 @@
|
|
|
16
16
|
* switched on or off: power on / off are refused as `not-settable`, and `getStatus`
|
|
17
17
|
* says so (`switchSettable`) for the surfaces that withdraw them.
|
|
18
18
|
*
|
|
19
|
+
* A power source an identity link contributed (`contributedBy`, D1063) is
|
|
20
|
+
* checked against that link at the point of use: the link is read over RPC
|
|
21
|
+
* before every action, and one that is no longer `linked`, or now names another
|
|
22
|
+
* port, refuses as `link-lost` and asks core-blocks to reconcile the
|
|
23
|
+
* contributions. A read that fails, or links not loaded yet, refuse as
|
|
24
|
+
* `link-unknown` — cutting power is destructive work (D49). A stamp alone is
|
|
25
|
+
* never proof the port still feeds this device: the event that withdraws it
|
|
26
|
+
* may have been dropped (D11).
|
|
27
|
+
*
|
|
19
28
|
* Every refusal is a typed result with its reason, logged with the device tag.
|
|
20
29
|
*/
|
|
21
|
-
import { type CompositionSourceRef, type CoreBlock, type IPowerSourceProvider, type IScopedLogger, type PowerSourceActionResult, type PowerSourceInfo, type SwitchOptions } from "@camstack/types";
|
|
30
|
+
import { type IdentityLinksRead, type CompositionSourceRef, type CoreBlock, type IPowerSourceProvider, type IScopedLogger, type PowerSourceActionResult, type PowerSourceInfo, type SwitchOptions } from "@camstack/types";
|
|
22
31
|
/** What the service needs to know about a device it names. */
|
|
23
32
|
export interface PowerSourceDevice {
|
|
24
33
|
readonly id: number;
|
|
@@ -59,9 +68,17 @@ export interface PowerSourceScheduler {
|
|
|
59
68
|
readonly schedule: (delayMs: number, fire: () => void) => PowerSourceTimer;
|
|
60
69
|
}
|
|
61
70
|
export declare const timeoutScheduler: PowerSourceScheduler;
|
|
71
|
+
/** The identity links a contributed power source is checked against (D1063). */
|
|
72
|
+
export interface PowerSourceIdentityLinks {
|
|
73
|
+
/** `device-manager.listIdentityLinks`, read on every action through a contributed link. */
|
|
74
|
+
readonly read: () => Promise<IdentityLinksRead>;
|
|
75
|
+
/** The contributed link is lost: reconcile the link contributions (the host `deviceId`). */
|
|
76
|
+
readonly lost: (deviceId: number) => void;
|
|
77
|
+
}
|
|
62
78
|
export interface PowerSourceServiceDeps {
|
|
63
79
|
readonly blocks: () => readonly Pick<CoreBlock, "id" | "source">[];
|
|
64
80
|
readonly devices: PowerSourceDevices;
|
|
81
|
+
readonly links: PowerSourceIdentityLinks;
|
|
65
82
|
readonly scheduler: PowerSourceScheduler;
|
|
66
83
|
readonly logger: IScopedLogger;
|
|
67
84
|
}
|
|
@@ -101,6 +118,13 @@ export declare class PowerSourceService implements IPowerSourceProvider {
|
|
|
101
118
|
private settableOf;
|
|
102
119
|
/** The link and the switch, or the reason there is nothing to act on. Reads the switch state: unknown is refused. */
|
|
103
120
|
private lookup;
|
|
121
|
+
/**
|
|
122
|
+
* The identity link that contributed this power source, read now: null when it is
|
|
123
|
+
* still `linked`, its evidence still holds, and its source side is the switch the
|
|
124
|
+
* feature reads. An operator-confirmed link whose evidence is gone (`evidenceGone`)
|
|
125
|
+
* is refused as `link-lost`: the port may now feed another device (D1063).
|
|
126
|
+
*/
|
|
127
|
+
private checkContributingLink;
|
|
104
128
|
/** The stored link of the device `deviceId`, read from the customizations now. */
|
|
105
129
|
private linkOf;
|
|
106
130
|
/** The stored link, and whether it names one of the device's own actuators (#462). */
|
|
@@ -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-BNrIzdrJ.js");
|
|
7
|
+
const require_capture_engine = require("../../capture-engine-B3csK2sW.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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ct as
|
|
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-
|
|
1
|
+
import { Ct as HISTORY_CATALOG, Dl as defineRecordKinds, Du as EventCategory, Fl as historyUnitFor, Ic as InvalidRecordError, Kn as armRemovalReconcile, Kr as deviceHistoryCapability, Mc as DeviceTransitionSchema, Qc as RecordTooLargeError, Tc as BaseAddon, U as DEVICE_HISTORY_ENERGY_KEY, Ul as isReadingQuantity, Xr as deviceRunsCapability, Yr as deviceRemovalHookCapability, at as DeviceRunSchema, ei as deviceTransitionsCapability, kl as emitReadiness, wc as wattMillisecondsToKwh, wt as HISTORY_ITEM_CATALOG, wu as DeviceType } from "../../dist-S-zGcCEr.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-CCAzcezv.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
|
|
@@ -6,4 +6,12 @@ export declare class SetIdentifiersRefusedError extends Error {
|
|
|
6
6
|
readonly reason: SetIdentifiersRefusal;
|
|
7
7
|
constructor(reason: SetIdentifiersRefusal, message: string);
|
|
8
8
|
}
|
|
9
|
+
/** The two declared-identity columns: the device's own, and its link's far end (D1063). */
|
|
10
|
+
export type DeclaredIdentityColumn = "identifiers" | "attachedIdentifiers";
|
|
9
11
|
export declare function setIdentifiers(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setIdentifiers"]>[0]): ReturnType<IDeviceManagerProvider["setIdentifiers"]>;
|
|
12
|
+
/**
|
|
13
|
+
* `device-manager.setAttachedIdentifiers` (D1063): the identity of the device at
|
|
14
|
+
* the far end of this device's physical link. Same owner check, normalisation
|
|
15
|
+
* and merge as {@link setIdentifiers}, its own column.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setAttachedIdentifiers(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setAttachedIdentifiers"]>[0]): ReturnType<IDeviceManagerProvider["setAttachedIdentifiers"]>;
|
|
@@ -18,9 +18,15 @@
|
|
|
18
18
|
* write that lands while the snapshot is in flight is buffered and replayed over
|
|
19
19
|
* it, so the seed can never roll a newer write back.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* It finds candidates and links nothing itself: the `IdentityLinkReconciler`
|
|
22
|
+
* (D1063) turns {@link linkCandidates} into link records, and is told of every
|
|
23
|
+
* change that can move a candidate through {@link onIdentityChanged}.
|
|
24
|
+
*
|
|
25
|
+
* Beside the same-device pairs it pairs a device's `attachedIdentifiers` — the
|
|
26
|
+
* far end of its physical link, a PoE port's wired client — with another
|
|
27
|
+
* device's `identifiers`, graded by the same {@link classifyIdentityMatch}.
|
|
22
28
|
*/
|
|
23
|
-
import { type IdentityCandidates, type IdentityConfidence, type IdentityMatchedKey } from "@camstack/types";
|
|
29
|
+
import { type IdentityCandidates, type IdentityConfidence, type IdentityLinkKind, type IdentityLinkSide, type IdentityMatchedKey } from "@camstack/types";
|
|
24
30
|
import type { PersistedDeviceMeta } from "./device-meta-types.js";
|
|
25
31
|
import type { DeviceRegistrationRow, DeviceRow, DeviceRowPatch } from "./device-row-store.js";
|
|
26
32
|
/** What the row store tells its observer, after each statement succeeded. */
|
|
@@ -34,6 +40,28 @@ export interface DeviceRowObserver {
|
|
|
34
40
|
/** The row was deleted (`remove`). */
|
|
35
41
|
rowRemoved(deviceId: number): void;
|
|
36
42
|
}
|
|
43
|
+
/** One pair a link could be made of (D1063). For `poe-power`, `a` is the attaching side. */
|
|
44
|
+
export interface IdentityLinkCandidate {
|
|
45
|
+
readonly kind: IdentityLinkKind;
|
|
46
|
+
readonly a: IdentityLinkSide;
|
|
47
|
+
readonly b: IdentityLinkSide;
|
|
48
|
+
/** The role of `a`, which a kind may require (`poe-power` → `poe-port`). */
|
|
49
|
+
readonly aRole: string | null;
|
|
50
|
+
readonly keys: readonly IdentityMatchedKey[];
|
|
51
|
+
readonly confidence: IdentityConfidence;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* What the reconciler reads: every candidate, plus the device each ref names
|
|
55
|
+
* right now. `unknown` until the index has loaded (D315).
|
|
56
|
+
*/
|
|
57
|
+
export type IdentityLinkCandidates = {
|
|
58
|
+
readonly status: "unknown";
|
|
59
|
+
} | {
|
|
60
|
+
readonly status: "answered";
|
|
61
|
+
readonly candidates: readonly IdentityLinkCandidate[];
|
|
62
|
+
/** The numeric id a device ref names now; null when no row carries it. */
|
|
63
|
+
readonly deviceIdOf: (addonId: string, stableId: string) => number | null;
|
|
64
|
+
};
|
|
37
65
|
/**
|
|
38
66
|
* Grade the keys two devices share. `null` when they are no candidate at all
|
|
39
67
|
* (no strong key matched).
|
|
@@ -52,15 +80,41 @@ export declare function classifyIdentityMatch(keys: readonly IdentityMatchedKey[
|
|
|
52
80
|
export declare class DeviceIdentityIndex implements DeviceRowObserver {
|
|
53
81
|
private readonly devices;
|
|
54
82
|
private readonly byKey;
|
|
83
|
+
private readonly listeners;
|
|
84
|
+
/** True while {@link seed} replays rows: one notification follows, not one per row. */
|
|
85
|
+
private seeding;
|
|
55
86
|
/** `null` once seeded; until then, the writes to replay over the snapshot. */
|
|
56
87
|
private pending;
|
|
57
88
|
/** Load from a fleet snapshot, then replay every write that landed meanwhile. */
|
|
58
89
|
seed(rows: readonly DeviceRow[]): void;
|
|
90
|
+
/**
|
|
91
|
+
* Called after every change that can move a candidate (identifiers, attached
|
|
92
|
+
* identifiers, role, integration, a row written or removed) and after the
|
|
93
|
+
* seed. Synchronous: the listener schedules its own work.
|
|
94
|
+
*/
|
|
95
|
+
onIdentityChanged(listener: () => void): () => void;
|
|
59
96
|
rowWritten(meta: PersistedDeviceMeta): void;
|
|
60
97
|
registrationWritten(row: DeviceRegistrationRow): void;
|
|
61
98
|
rowPatched(deviceId: number, patch: DeviceRowPatch): void;
|
|
62
99
|
rowRemoved(deviceId: number): void;
|
|
63
100
|
/**
|
|
101
|
+
* Every pair a link could be made of (D1063): the same-device pairs of
|
|
102
|
+
* {@link candidates}, plus each device's attached identifiers paired with
|
|
103
|
+
* another integration's device identifiers (`poe-power`).
|
|
104
|
+
*
|
|
105
|
+
* One link per port: when a port's attached keys reach several devices, or a
|
|
106
|
+
* device is reached by several ports, every one of those attached pairs is
|
|
107
|
+
* graded a `proposal` at most — the operator picks.
|
|
108
|
+
*
|
|
109
|
+
* Freshness first: a pair whose shared keys the port only RETAINS (declared
|
|
110
|
+
* unread — no client now, D49) is no candidate when another port FRESHLY
|
|
111
|
+
* reports the same device. A camera moved from port 7 to port 9 is port 9's;
|
|
112
|
+
* port 7's auto link loses its evidence. Two fresh reports stay proposals.
|
|
113
|
+
*/
|
|
114
|
+
linkCandidates(): IdentityLinkCandidates;
|
|
115
|
+
private attachedPairs;
|
|
116
|
+
private changed;
|
|
117
|
+
/**
|
|
64
118
|
* Every cross-integration candidate pair, graded by `classifyIdentityMatch`,
|
|
65
119
|
* plus the devices whose identity is unknown (nothing declared).
|
|
66
120
|
*/
|