unifi-protect 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/client/client.d.ts +11 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +18 -14
- package/dist/client/client.js.map +1 -1
- package/dist/client/connection.d.ts +2 -2
- package/dist/client/connection.d.ts.map +1 -1
- package/dist/client/connection.js +11 -14
- package/dist/client/connection.js.map +1 -1
- package/dist/client/livestream-pool.d.ts +11 -9
- package/dist/client/livestream-pool.d.ts.map +1 -1
- package/dist/client/livestream-pool.js +26 -19
- package/dist/client/livestream-pool.js.map +1 -1
- package/dist/devices/chime.d.ts +3 -3
- package/dist/devices/context.d.ts +1 -1
- package/dist/devices/device.d.ts +5 -6
- package/dist/devices/device.d.ts.map +1 -1
- package/dist/devices/device.js +5 -6
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/fob.d.ts +2 -2
- package/dist/devices/fob.js +2 -2
- package/dist/devices/light.d.ts +2 -2
- package/dist/devices/light.js +2 -2
- package/dist/devices/relay.d.ts +2 -2
- package/dist/devices/relay.js +2 -2
- package/dist/diagnostics.d.ts +92 -36
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +55 -32
- package/dist/diagnostics.js.map +1 -1
- package/dist/errors.d.ts +25 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +24 -19
- package/dist/errors.js.map +1 -1
- package/dist/event-bus.d.ts +3 -3
- package/dist/event-bus.d.ts.map +1 -1
- package/dist/event-bus.js +5 -4
- package/dist/event-bus.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/protocol/events.d.ts +30 -16
- package/dist/protocol/events.d.ts.map +1 -1
- package/dist/protocol/events.js +51 -27
- package/dist/protocol/events.js.map +1 -1
- package/dist/protocol/packet.d.ts +3 -0
- package/dist/protocol/packet.d.ts.map +1 -1
- package/dist/protocol/packet.js +3 -0
- package/dist/protocol/packet.js.map +1 -1
- package/dist/protocol/reducer.d.ts +26 -3
- package/dist/protocol/reducer.d.ts.map +1 -1
- package/dist/protocol/reducer.js +19 -7
- package/dist/protocol/reducer.js.map +1 -1
- package/dist/schema-manifest.json +1 -0
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -0
- package/dist/settings.js.map +1 -1
- package/dist/state/selectors.d.ts +3 -3
- package/dist/state/selectors.d.ts.map +1 -1
- package/dist/state/selectors.js +10 -6
- package/dist/state/selectors.js.map +1 -1
- package/dist/state/store.d.ts +7 -5
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/store.js +29 -5
- package/dist/state/store.js.map +1 -1
- package/dist/transport/auth.d.ts +12 -8
- package/dist/transport/auth.d.ts.map +1 -1
- package/dist/transport/auth.js +69 -16
- package/dist/transport/auth.js.map +1 -1
- package/dist/transport/events-stream.d.ts +5 -2
- package/dist/transport/events-stream.d.ts.map +1 -1
- package/dist/transport/events-stream.js +17 -15
- package/dist/transport/events-stream.js.map +1 -1
- package/dist/transport/http.d.ts +14 -8
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +25 -15
- package/dist/transport/http.js.map +1 -1
- package/dist/transport/livestream-session.d.ts +19 -10
- package/dist/transport/livestream-session.d.ts.map +1 -1
- package/dist/transport/livestream-session.js +19 -13
- package/dist/transport/livestream-session.js.map +1 -1
- package/dist/transport/talkback-session.d.ts +12 -7
- package/dist/transport/talkback-session.d.ts.map +1 -1
- package/dist/transport/talkback-session.js +16 -10
- package/dist/transport/talkback-session.js.map +1 -1
- package/dist/transport/ws.d.ts +6 -6
- package/dist/transport/ws.js +1 -1
- package/dist/util/cli/client.d.ts +23 -2
- package/dist/util/cli/client.d.ts.map +1 -1
- package/dist/util/cli/client.js +35 -5
- package/dist/util/cli/client.js.map +1 -1
- package/dist/util/cli/commands/camera.d.ts.map +1 -1
- package/dist/util/cli/commands/camera.js +5 -4
- package/dist/util/cli/commands/camera.js.map +1 -1
- package/dist/util/cli/commands/capture.d.ts +27 -0
- package/dist/util/cli/commands/capture.d.ts.map +1 -0
- package/dist/util/cli/commands/capture.js +397 -0
- package/dist/util/cli/commands/capture.js.map +1 -0
- package/dist/util/cli/commands/doctor.d.ts.map +1 -1
- package/dist/util/cli/commands/doctor.js +96 -96
- package/dist/util/cli/commands/doctor.js.map +1 -1
- package/dist/util/cli/commands/watch-events.d.ts +5 -0
- package/dist/util/cli/commands/watch-events.d.ts.map +1 -1
- package/dist/util/cli/commands/watch-events.js +8 -4
- package/dist/util/cli/commands/watch-events.js.map +1 -1
- package/dist/util/cli/commands/watch-state.d.ts.map +1 -1
- package/dist/util/cli/commands/watch-state.js +1 -0
- package/dist/util/cli/commands/watch-state.js.map +1 -1
- package/dist/util/cli/credentials.d.ts +30 -2
- package/dist/util/cli/credentials.d.ts.map +1 -1
- package/dist/util/cli/credentials.js +146 -4
- package/dist/util/cli/credentials.js.map +1 -1
- package/dist/util/cli/diagnostics-feed.d.ts +2 -2
- package/dist/util/cli/diagnostics-feed.d.ts.map +1 -1
- package/dist/util/cli/diagnostics-feed.js +8 -10
- package/dist/util/cli/diagnostics-feed.js.map +1 -1
- package/dist/util/cli/index.js +5 -13
- package/dist/util/cli/index.js.map +1 -1
- package/dist/util/cli/manifest.d.ts +253 -0
- package/dist/util/cli/manifest.d.ts.map +1 -0
- package/dist/util/cli/manifest.js +405 -0
- package/dist/util/cli/manifest.js.map +1 -0
- package/dist/util/cli/output/format.d.ts +29 -0
- package/dist/util/cli/output/format.d.ts.map +1 -1
- package/dist/util/cli/output/format.js +34 -2
- package/dist/util/cli/output/format.js.map +1 -1
- package/dist/util/cli/scrub.d.ts +54 -0
- package/dist/util/cli/scrub.d.ts.map +1 -0
- package/dist/util/cli/scrub.js +218 -0
- package/dist/util/cli/scrub.js.map +1 -0
- package/dist/util/cli/shared.d.ts +57 -10
- package/dist/util/cli/shared.d.ts.map +1 -1
- package/dist/util/cli/shared.js +53 -9
- package/dist/util/cli/shared.js.map +1 -1
- package/package.json +8 -8
- package/src/client/client.ts +29 -18
- package/src/client/connection.ts +15 -18
- package/src/client/livestream-pool.ts +36 -27
- package/src/devices/chime.ts +3 -3
- package/src/devices/context.ts +1 -1
- package/src/devices/device.ts +5 -6
- package/src/devices/fob.ts +2 -2
- package/src/devices/light.ts +2 -2
- package/src/devices/relay.ts +2 -2
- package/src/diagnostics.ts +118 -35
- package/src/errors.ts +28 -22
- package/src/event-bus.ts +5 -4
- package/src/index.ts +16 -12
- package/src/protocol/events.ts +58 -32
- package/src/protocol/packet.ts +3 -0
- package/src/protocol/reducer.ts +31 -14
- package/src/settings.ts +5 -0
- package/src/state/selectors.ts +10 -6
- package/src/state/store.ts +37 -8
- package/src/transport/auth.ts +85 -17
- package/src/transport/events-stream.ts +22 -17
- package/src/transport/http.ts +37 -21
- package/src/transport/livestream-session.ts +38 -23
- package/src/transport/talkback-session.ts +21 -12
- package/src/transport/ws.ts +7 -7
- package/src/util/cli/client.ts +42 -5
- package/src/util/cli/commands/camera.ts +5 -4
- package/src/util/cli/commands/capture.ts +490 -0
- package/src/util/cli/commands/doctor.ts +16 -33
- package/src/util/cli/commands/watch-events.ts +8 -4
- package/src/util/cli/commands/watch-state.ts +3 -2
- package/src/util/cli/credentials.ts +253 -5
- package/src/util/cli/diagnostics-feed.ts +10 -15
- package/src/util/cli/index.ts +5 -17
- package/src/util/cli/manifest.ts +764 -0
- package/src/util/cli/output/format.ts +39 -2
- package/src/util/cli/scrub.ts +352 -0
- package/src/util/cli/shared.ts +70 -17
package/dist/errors.js
CHANGED
|
@@ -183,13 +183,15 @@ export class ProtectProtocolError extends FatalError {
|
|
|
183
183
|
*
|
|
184
184
|
* @returns Never returns - always throws.
|
|
185
185
|
*
|
|
186
|
-
* @throws {@link ProtectProtocolError} always, naming the unhandled variant's
|
|
186
|
+
* @throws {@link ProtectProtocolError} always, naming the unhandled variant's `kind` when the variant is an object that carries one, or the variant's coerced
|
|
187
|
+
* string form otherwise.
|
|
187
188
|
*
|
|
188
189
|
* @category Errors
|
|
189
190
|
*/
|
|
190
191
|
export function assertNever(value) {
|
|
191
|
-
// `value` is statically `never`, so we read its runtime shape defensively: an object variant
|
|
192
|
-
// modelKey)
|
|
192
|
+
// `value` is statically `never`, so we read its runtime shape defensively: an object variant carrying a `kind` property surfaces that tag, and anything else -
|
|
193
|
+
// a bare string such as a modelKey, or an object variant tagged some other way (a `type`-tagged union, for instance) - falls back to its coerced string form,
|
|
194
|
+
// which for a plain object without a `kind` property is the generic "[object Object]" rather than a name that distinguishes the variant.
|
|
193
195
|
const variant = value;
|
|
194
196
|
const detail = ((typeof variant === "object") && (variant !== null) && ("kind" in variant)) ? String(variant.kind) : String(variant);
|
|
195
197
|
throw new ProtectProtocolError("Encountered an unhandled variant in an exhaustive switch: " + detail + ".");
|
|
@@ -211,9 +213,10 @@ export class ProtectBootstrapError extends FatalError {
|
|
|
211
213
|
}
|
|
212
214
|
/**
|
|
213
215
|
* A pooled livestream reconnected and the controller negotiated a different codec than the one in flight (H.264 to HEVC, or a channel reconfigured mid-stream). Fatal
|
|
214
|
-
* because no fixed-codec consumer can adapt in place: an FFmpeg pipe cannot re-initialize, and HKSV tolerates no second init segment. The pool surfaces this as
|
|
215
|
-
* terminal a recovering stream can raise
|
|
216
|
-
* codec strings the two init segments carried, so a consumer
|
|
216
|
+
* because no fixed-codec consumer can adapt in place: an FFmpeg pipe cannot re-initialize, and HKSV tolerates no second init segment. The pool surfaces this as a
|
|
217
|
+
* terminal a recovering stream can raise - alongside {@link ProtectLivestreamUnavailableError} when the recovery policy gives up instead - after which the consumer
|
|
218
|
+
* re-subscribes for a fresh stream against the new codec. The `from` / `to` descriptors are the RFC 6381 codec strings the two init segments carried, so a consumer
|
|
219
|
+
* can log precisely what changed.
|
|
217
220
|
*
|
|
218
221
|
* @category Errors
|
|
219
222
|
*/
|
|
@@ -229,7 +232,7 @@ export class ProtectCodecChangeError extends FatalError {
|
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
/**
|
|
232
|
-
* A pooled livestream's recovery policy gave up. The `phase` names which
|
|
235
|
+
* A pooled livestream's recovery policy gave up. The `phase` names which regime the pool gave up in: `establishing` means the first segment never arrived within
|
|
233
236
|
* the bounded establishment deadline (the stream that never produced media), and `recovering` means a previously-live stream could not be re-established and the policy
|
|
234
237
|
* elected to stop. Fatal because the policy - the single authority over whether to keep trying - has declared the stream unrecoverable; the consumer re-subscribes if it
|
|
235
238
|
* still wants the stream. `attempts` carries how many consecutive reconnect attempts the episode made before the policy returned `giveUp`.
|
|
@@ -264,24 +267,25 @@ export class ProtectUnsupportedError extends FatalError {
|
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
269
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
+
* A `util.inspect` options bag for diagnostic formatting - logs, debug dumps, and CLI output: stable colors, unlimited depth, and sorted object keys. A call site
|
|
271
|
+
* that imports this constant instead of writing its own options literal gets a formatting change (disabling colors when stdout isn't a TTY, bounding `depth`,
|
|
272
|
+
* adding `breakLength` for tight log lines) for free the next time this bag is updated.
|
|
270
273
|
*
|
|
271
274
|
* @category Utilities
|
|
272
275
|
*/
|
|
273
276
|
export const INSPECT_OPTIONS = { colors: true, depth: null, sorted: true };
|
|
274
277
|
/**
|
|
275
|
-
* Predicate for the WebSocket-error-handler suppression rule shared by the realtime events WS
|
|
278
|
+
* Predicate for the WebSocket-error-handler suppression rule shared by every WebSocket subsystem in the library - the realtime events WS, the livestream WS, and
|
|
279
|
+
* the talkback WS.
|
|
276
280
|
*
|
|
277
|
-
*
|
|
281
|
+
* Each subsystem classifies an undici teardown `TypeError` and an `ETIMEDOUT` errno as expected disconnects rather than user-actionable errors:
|
|
278
282
|
*
|
|
279
283
|
* 1. A `TypeError` from undici's internal WebSocket teardown - the error class undici raises when the socket closes mid-frame during a disconnect.
|
|
280
|
-
* 2. An `ETIMEDOUT` errno on the cause chain - the slow-controller path.
|
|
281
|
-
* `PROTECT_EVENTS_WATCHDOG_TIMEOUT`, a livestream session against its heartbeat timeout) that reports prolonged silence separately; this predicate instead
|
|
282
|
-
* the socket-level errno, so the two are complementary and logging this disconnect-during-reboot symptom at the error level would be duplicate noise.
|
|
284
|
+
* 2. An `ETIMEDOUT` errno on the cause chain - the slow-controller path. The events and livestream subsystems each run their own silence watchdog (the events WS
|
|
285
|
+
* against `PROTECT_EVENTS_WATCHDOG_TIMEOUT`, a livestream session against its heartbeat timeout) that reports prolonged silence separately; this predicate instead
|
|
286
|
+
* classifies the socket-level errno, so the two are complementary and logging this disconnect-during-reboot symptom at the error level would be duplicate noise.
|
|
283
287
|
*
|
|
284
|
-
* Centralizing the predicate means a future addition (`EPIPE`, `ECONNRESET`, etc.) lands in one place and
|
|
288
|
+
* Centralizing the predicate means a future addition (`EPIPE`, `ECONNRESET`, etc.) lands in one place and every WebSocket subsystem picks it up identically.
|
|
285
289
|
*
|
|
286
290
|
* @param error - The error value to classify. Typed `unknown` because WebSocket `ErrorEvent.error` is untyped at the contract level.
|
|
287
291
|
*
|
|
@@ -295,7 +299,7 @@ export function isExpectedWsDisconnect(error) {
|
|
|
295
299
|
/**
|
|
296
300
|
* Safely resolve an unknown error to a Node `ErrnoException` shape.
|
|
297
301
|
*
|
|
298
|
-
*
|
|
302
|
+
* The following error shapes are recognized:
|
|
299
303
|
*
|
|
300
304
|
* 1. An `Error` whose `cause` chain wraps a Node `ErrnoException`. Undici raises this shape from upstream connection errors (DNS, TCP, TLS), where the surface
|
|
301
305
|
* error is the generic `TypeError("fetch failed")` and the actual errno data lives one hop down the cause chain.
|
|
@@ -304,8 +308,9 @@ export function isExpectedWsDisconnect(error) {
|
|
|
304
308
|
* Both shapes are validated to require `code` as a string before returning, guarding against the (rare but legal) case where an Error has a `code` property of a
|
|
305
309
|
* non-string type. A non-string `code` would otherwise satisfy a downstream `code === "ECONNREFUSED"` comparison only by accident of `===` semantics.
|
|
306
310
|
*
|
|
307
|
-
* Anything outside these
|
|
308
|
-
* that
|
|
311
|
+
* Anything outside these shapes (locally thrown TypeErrors with no cause, custom errors without `code`, non-Error throws) returns `undefined`. Internal callers
|
|
312
|
+
* such as `ProtectNetworkError`'s constructor and `isExpectedWsDisconnect` treat that as no matching code and continue past it via optional chaining, rather than
|
|
313
|
+
* treating the absence as an error condition in its own right.
|
|
309
314
|
*
|
|
310
315
|
* @param error - The error value to inspect. Typed `unknown` because catch bindings and event handlers receive untyped values.
|
|
311
316
|
*
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,YAAa,SAAQ,KAAK;IAE9C,iKAAiK;IACjK,+JAA+J;IAC/J,+CAA+C;IAC/C,YAAsB,OAAe,EAAE,OAA6B;QAElE,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAE1C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAgB,gBAAiB,SAAQ,YAAY;CAAG;AAE9D;;;;GAIG;AACH,MAAM,OAAgB,UAAW,SAAQ,YAAY;CAAG;AAExD;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,gBAAgB;IAEzD,8FAA8F;IACrF,UAAU,CAAS;IAE5B,YAAY,OAAe,EAAE,OAAgD;QAE3E,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAEzC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACvC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO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K,YAAY,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAE9C,gKAAgK;IAChK,IAAG,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAQ,KAAK,CAAC,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAE9J,OAAO,KAAK,CAAC,KAA8B,CAAC;IAC9C,CAAC;IAED,6FAA6F;IAC7F,IAAG,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,OAAQ,KAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAEhH,OAAO,KAA8B,CAAC;IACxC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/event-bus.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface StreamOptions {
|
|
|
8
8
|
signal?: AbortSignal;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A typed facade over `node:events.EventEmitter` that exposes
|
|
11
|
+
* A typed facade over `node:events.EventEmitter` that exposes a fixed set of subscription shapes - the canonical contract every event-producing subsystem in this
|
|
12
12
|
* library presents (`Transport`, `EventStream`, `ConnectionMonitor`, `LivestreamSession`, `ProtectClient`).
|
|
13
13
|
*
|
|
14
14
|
* We *compose* `EventEmitter` rather than *extend* it, for several concrete reasons:
|
|
@@ -19,8 +19,8 @@ export interface StreamOptions {
|
|
|
19
19
|
* host class. Consumers see only the three rails.
|
|
20
20
|
* 3. It aligns subscriptions with the library's `await using` resource-lifetime discipline: a subscription is a resource, and a `Disposable` subscription completes
|
|
21
21
|
* that alignment.
|
|
22
|
-
* 4. It preserves Node's battle-tested emit machinery - listener-during-emit reentrancy, sync-throw handling, listener self-removal - which has
|
|
23
|
-
* bug-fixing behind it, without inheriting the surface bloat.
|
|
22
|
+
* 4. It preserves Node's battle-tested emit machinery - listener-during-emit reentrancy, sync-throw handling, listener self-removal - which has years of
|
|
23
|
+
* production bug-fixing behind it, without inheriting the surface bloat.
|
|
24
24
|
*
|
|
25
25
|
* The same internal emitter drives all three rails, so a single {@link emit} notifies every active {@link on} callback, resolves every pending {@link once} promise,
|
|
26
26
|
* and pushes to every open {@link stream} iterator. That is the single-source-of-truth guarantee: there is exactly one fan-out path per event.
|
package/dist/event-bus.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAE5B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,qBAAa,QAAQ,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;;;IAa/E;;;;;;;;;;OAUG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,UAAU;IAYpG;;;;;;;;OAQG;IACG,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../src/event-bus.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAE5B,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AASD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,qBAAa,QAAQ,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;;;IAa/E;;;;;;;;;;OAUG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,UAAU;IAYpG;;;;;;;;OAQG;IACG,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAUlH;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,GAAE,aAAkB,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAOzG;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO;CAIjF"}
|
package/dist/event-bus.js
CHANGED
|
@@ -10,7 +10,7 @@ import { EventEmitter, once as nextEmission, on as subscribeIterator } from "nod
|
|
|
10
10
|
// it never throws on a missing listener and never cross-rejects a sibling stream. The prefix is internal and never observable; consumers always use the bare name.
|
|
11
11
|
const EVENT_NAME_PREFIX = "ufp:event:";
|
|
12
12
|
/**
|
|
13
|
-
* A typed facade over `node:events.EventEmitter` that exposes
|
|
13
|
+
* A typed facade over `node:events.EventEmitter` that exposes a fixed set of subscription shapes - the canonical contract every event-producing subsystem in this
|
|
14
14
|
* library presents (`Transport`, `EventStream`, `ConnectionMonitor`, `LivestreamSession`, `ProtectClient`).
|
|
15
15
|
*
|
|
16
16
|
* We *compose* `EventEmitter` rather than *extend* it, for several concrete reasons:
|
|
@@ -21,8 +21,8 @@ const EVENT_NAME_PREFIX = "ufp:event:";
|
|
|
21
21
|
* host class. Consumers see only the three rails.
|
|
22
22
|
* 3. It aligns subscriptions with the library's `await using` resource-lifetime discipline: a subscription is a resource, and a `Disposable` subscription completes
|
|
23
23
|
* that alignment.
|
|
24
|
-
* 4. It preserves Node's battle-tested emit machinery - listener-during-emit reentrancy, sync-throw handling, listener self-removal - which has
|
|
25
|
-
* bug-fixing behind it, without inheriting the surface bloat.
|
|
24
|
+
* 4. It preserves Node's battle-tested emit machinery - listener-during-emit reentrancy, sync-throw handling, listener self-removal - which has years of
|
|
25
|
+
* production bug-fixing behind it, without inheriting the surface bloat.
|
|
26
26
|
*
|
|
27
27
|
* The same internal emitter drives all three rails, so a single {@link emit} notifies every active {@link on} callback, resolves every pending {@link once} promise,
|
|
28
28
|
* and pushes to every open {@link stream} iterator. That is the single-source-of-truth guarantee: there is exactly one fan-out path per event.
|
|
@@ -75,7 +75,8 @@ export class EventBus {
|
|
|
75
75
|
*/
|
|
76
76
|
async once(event, opts = {}) {
|
|
77
77
|
// node:events' `once` already implements the signal-cancellable, single-shot semantics we want; resolving to the argument array is exactly our tuple shape. We
|
|
78
|
-
// forward the options object only when a signal is present
|
|
78
|
+
// forward the options object only when a signal is present, mirroring node:events' own default of omitting the options object entirely rather than allocating
|
|
79
|
+
// one that carries no signal.
|
|
79
80
|
const args = await nextEmission(this.#emitter, EVENT_NAME_PREFIX + event, opts.signal ? { signal: opts.signal } : undefined);
|
|
80
81
|
return args;
|
|
81
82
|
}
|
package/dist/event-bus.js.map
CHANGED
|
@@ -1 +1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,GAAG,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE7H,OAAO,IAA8B,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAoC,KAAQ,EAAE,OAAsB,EAAE;QAE1E,gKAAgK;QAChK,4EAA4E;QAC5E,OAAO,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAA+B,CAAC;IACtJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,IAAI,CAAoC,KAAQ,EAAE,GAAG,IAAiB;QAEpE,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -28,11 +28,11 @@ export type { Sensor } from "./devices/sensor.ts";
|
|
|
28
28
|
export type { Viewer } from "./devices/viewer.ts";
|
|
29
29
|
export { ProtectClient } from "./client/client.ts";
|
|
30
30
|
export type { ConnectOptions, ProtectClientEvents } from "./client/client.ts";
|
|
31
|
-
export type { ConnectionEvents, ConnectionMonitor, ConnectionState, ConnectionTransition } from "./client/connection.ts";
|
|
31
|
+
export type { ConnectionEvents, ConnectionMonitor, ConnectionState, ConnectionTransition, ThrottleSource } from "./client/connection.ts";
|
|
32
32
|
export { defaultLivestreamRecoveryPolicy } from "./client/livestream-pool.ts";
|
|
33
33
|
export type { LivestreamSubscribeOptions, LivestreamSubscription, LivestreamSubscriptionState, LivestreamSubscriptionStats, RecoveryContext, RecoveryDecision, RecoveryPolicy } from "./client/livestream-pool.ts";
|
|
34
|
-
export { channels } from "./diagnostics.ts";
|
|
35
|
-
export type { AdoptionContradictionPayload, AuthReloginPayload, ConnectionRebootDetectedPayload, ConnectionTransitionPayload, EventsClosedPayload, EventsPacketPayload, EventsReconnectingPayload, HttpRequestEndPayload, HttpRequestStartPayload, HttpThrottleEnteredPayload, LivestreamCodecChangedPayload, LivestreamRecoveryExhaustedPayload, LivestreamRecoveryRecoveredPayload, LivestreamRecoveryStartedPayload, LivestreamSessionClosedPayload, LivestreamSessionOpenedPayload, LivestreamStallDetectedPayload, LivestreamSubscriptionCreatedPayload, LivestreamSubscriptionDisposedPayload, SchemaUnknownModelKeyPayload, SchemaUnmodeledCollectionPayload, TalkbackSessionClosedPayload, TalkbackSessionOpenedPayload } from "./diagnostics.ts";
|
|
34
|
+
export { channels, subscribeToChannel } from "./diagnostics.ts";
|
|
35
|
+
export type { AdoptionContradictionPayload, AnyProtectDiagnosticsChannel, AuthReloginPayload, ConnectionRebootDetectedPayload, ConnectionTransitionPayload, EventsClosedPayload, EventsPacketPayload, EventsReconnectingPayload, HttpRequestEndPayload, HttpRequestStartPayload, HttpThrottleEnteredPayload, LivestreamCodecChangedPayload, LivestreamRecoveryExhaustedPayload, LivestreamRecoveryRecoveredPayload, LivestreamRecoveryStartedPayload, LivestreamSessionClosedPayload, LivestreamSessionOpenedPayload, LivestreamStallDetectedPayload, LivestreamSubscriptionCreatedPayload, LivestreamSubscriptionDisposedPayload, ProtectDiagnosticsChannel, SchemaUnknownModelKeyPayload, SchemaUnmodeledCollectionPayload, TalkbackSessionClosedPayload, TalkbackSessionOpenedPayload } from "./diagnostics.ts";
|
|
36
36
|
export { PROTECT_API_ERROR_LIMIT, PROTECT_API_RETRY_INTERVAL, PROTECT_API_TIMEOUT, PROTECT_BOOTSTRAP_REFRESH_INTERVAL, PROTECT_EVENTS_WATCHDOG_TIMEOUT, PROTECT_LIVESTREAM_AWAIT_MARGIN_MS, PROTECT_LIVESTREAM_AWAIT_MAX_MS, PROTECT_LIVESTREAM_AWAIT_MIN_MS, PROTECT_LIVESTREAM_DEFAULT_TOLERANCE_MS, PROTECT_LIVESTREAM_ESTABLISH_BACKOFF_MS, PROTECT_LIVESTREAM_ESTABLISH_DEADLINE_MS, PROTECT_LIVESTREAM_HEARTBEAT_TIMEOUT, PROTECT_LIVESTREAM_RECOVERY_BACKOFF_MS, PROTECT_REBOOT_ANTICIPATION_WINDOW_MS, PROTECT_REBOOT_DETECTION_THRESHOLD, PROTECT_RECOVERY_BACKOFF_KNOWN_MS, PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS, PROTECT_RECOVERY_STEADY_INTERVAL_MS } from "./settings.ts";
|
|
37
37
|
export type { DeepPartial, Nullable, ProtectAirQualityMetric, ProtectAirQualityMetricInterface, ProtectAirQualityThresholdSettings, ProtectAirQualityThresholdSettingsInterface, ProtectBridgeCandidate, ProtectCameraChannelConfig, ProtectCameraChannelConfigInterface, ProtectCameraConfig, ProtectCameraConfigInterface, ProtectCameraLcdMessageConfig, ProtectCameraLcdMessageConfigInterface, ProtectCameraRecordingPathSettings, ProtectCameraRecordingPathSettingsInterface, ProtectCameraTalkbackConfig, ProtectCameraTalkbackConfigInterface, ProtectChimeConfig, ProtectChimeConfigInterface, ProtectDeviceBase, ProtectDeviceBaseInterface, ProtectEventAdd, ProtectEventAddInterface, ProtectEventMetadata, ProtectEventMetadataDetectedThumbnail, ProtectEventMetadataDetectedThumbnailInterface, ProtectEventMetadataInterface, ProtectFobConfig, ProtectFobConfigInterface, ProtectKnownDevice, ProtectKnownJsonValue, ProtectLightConfig, ProtectLightConfigInterface, ProtectNvrAgreement, ProtectNvrAgreementInterface, ProtectNvrAiFeatureToggle, ProtectNvrAiFeatureToggleInterface, ProtectNvrBootstrap, ProtectNvrBootstrapInterface, ProtectNvrConfig, ProtectNvrConfigInterface, ProtectNvrLiveviewConfig, ProtectNvrLiveviewConfigInterface, ProtectNvrSystemEvent, ProtectNvrSystemEventController, ProtectNvrSystemEventControllerInterface, ProtectNvrSystemEventInterface, ProtectNvrSystemInfo, ProtectNvrSystemInfoInterface, ProtectNvrUserConfig, ProtectNvrUserConfigInterface, ProtectPtzAxisRange, ProtectPtzAxisRangeInterface, ProtectRelayConfig, ProtectRelayConfigInterface, ProtectRelayInputConfigInterface, ProtectRelayOutputConfigInterface, ProtectRingtoneConfig, ProtectRingtoneConfigInterface, ProtectSensorAirQuality, ProtectSensorAirQualityInterface, ProtectSensorAirQualitySettings, ProtectSensorAirQualitySettingsInterface, ProtectSensorConfig, ProtectSensorConfigInterface, ProtectSensorSensitivitySettings, ProtectSensorSensitivitySettingsInterface, ProtectSensorSmokeStatus, ProtectSensorSmokeStatusInterface, ProtectSmartZone, ProtectSmartZoneInterface, ProtectStateRecord, ProtectThresholdSettings, ProtectThresholdSettingsInterface, ProtectViewerConfig, ProtectViewerConfigInterface, ProtectWifiConnectionState, ProtectWifiConnectionStateInterface, ProtectWiredConnectionState, ProtectWiredConnectionStateInterface, ProtectWirelessConnectionSettings, ProtectWirelessConnectionSettingsInterface, ProtectWirelessConnectionState, ProtectWirelessConnectionStateInterface } from "./types/index.ts";
|
|
38
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,YAAY,EACjJ,iCAAiC,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAChK,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE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C,EAAE,iCAAiC,EAAE,qBAAqB,EAAE,8BAA8B,EAAE,uBAAuB,EACnJ,gCAAgC,EAAE,+BAA+B,EAAE,wCAAwC,EAAE,mBAAmB,EAAE,4BAA4B,EAC9J,gCAAgC,EAAE,yCAAyC,EAAE,wBAAwB,EAAE,iCAAiC,EAAE,gBAAgB,EAC1J,yBAAyB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,iCAAiC,EAC1G,mBAAmB,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,mCAAmC,EAAE,2BAA2B,EAC/I,oCAAoC,EAAE,iCAAiC,EAAE,0CAA0C,EAAE,8BAA8B,EACnJ,uCAAuC,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// This file is the consumer contract, and the contract is Layer 3. The surface is curated by one rule, expressed in the type system so it cannot drift:
|
|
6
6
|
//
|
|
7
|
-
// - `export` a value only for what a consumer constructs, calls as a free function,
|
|
8
|
-
// hierarchy, the selectors, the diagnostics channels, the default logger/clock,
|
|
7
|
+
// - `export` a value only for what a consumer constructs, calls as a free function, tests `instanceof` against, or iterates as a vocabulary array: ProtectClient
|
|
8
|
+
// (its static connect()), the error hierarchy, the selectors, the diagnostics channels, the default logger/clock, the timing constants, and the device-collection
|
|
9
|
+
// key vocabulary.
|
|
9
10
|
// - `export type` only for what a consumer receives but never builds: the device projections, the getter-return classes (StateStore / ConnectionMonitor / Transport /
|
|
10
11
|
// ProtectResponse / LivestreamSubscription), and every event, state, option, and domain type reachable from a public signature. Exporting these as types makes a
|
|
11
12
|
// second composition path unrepresentable - there is exactly one way to build a client, ProtectClient.connect() - so the single-source-of-truth rule is enforced by
|
|
12
13
|
// the compiler rather than by documentation. The one blessed exception is `createStateStore`, a value export that constructs the real store standalone for test
|
|
13
14
|
// harnesses; it widens only the store's own construction, never the client's, which stays the single `connect()` path.
|
|
14
15
|
// - Export nothing that is pure composition internals: AuthSession, EventStream, EventBus, LivestreamSession, LivestreamPool, DeviceRegistry, the free codec/reducer
|
|
15
|
-
// functions, and the internal
|
|
16
|
+
// functions, and the internal interfaces and helpers. They are reachable in source for the reader, never on the published surface.
|
|
16
17
|
//
|
|
17
18
|
// The test the next contributor applies to any new symbol: does a consumer construct or call it (value), receive it (type), or neither (internal)? That keeps this file
|
|
18
19
|
// a deliberate, reviewable contract rather than whatever each module happens to export.
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
export { FatalError, ProtectAbortedError, ProtectAuthError, ProtectAuthorizationError, ProtectBootstrapError, ProtectCodecChangeError, ProtectError, ProtectLivestreamUnavailableError, ProtectNetworkError, ProtectProtocolError, ProtectRequestError, ProtectStallError, ProtectThrottledError, ProtectTimeoutError, ProtectUnsupportedError, RecoverableError } from "./errors.js";
|
|
21
22
|
// Logging - the consumer-injectable logger interface and the silent default a consumer may pass to suppress output.
|
|
22
23
|
export { noopLog } from "./logging.js";
|
|
23
|
-
// Clock - the time abstraction (
|
|
24
|
+
// Clock - the time abstraction (injected through ConnectOptions) and its production implementation a consumer may reuse.
|
|
24
25
|
export { wallClock } from "./clock.js";
|
|
25
26
|
// The id-keyed device-collection vocabulary - the category key set the selector catalog and every per-category consumer iterate over. A value export (a consumer iterates
|
|
26
27
|
// the runtime array to reach a category's selectors) plus its type; `DeviceModelKey` stays internal, since the collection vocabulary is the consumer-facing surface.
|
|
@@ -38,8 +39,9 @@ export { ProtectClient } from "./client/client.js";
|
|
|
38
39
|
// Livestream pool - the subscription handle a consumer receives (a type), the recovery-policy contract a consumer's injected `recoveryPolicy` is written against (types),
|
|
39
40
|
// and the library's default policy a consumer may delegate to when composing its own (a value).
|
|
40
41
|
export { defaultLivestreamRecoveryPolicy } from "./client/livestream-pool.js";
|
|
41
|
-
// Diagnostics - the named observability channels (subscribed by a consumer)
|
|
42
|
-
|
|
42
|
+
// Diagnostics - the named observability channels (subscribed by a consumer through `subscribeToChannel`), the typed channel shape they are declared with, and their
|
|
43
|
+
// payload types. Part of the public contract.
|
|
44
|
+
export { channels, subscribeToChannel } from "./diagnostics.js";
|
|
43
45
|
// Settings - the externally observable timing and retry constants behind the ConnectOptions defaults, exposed as documented reference values.
|
|
44
46
|
export { PROTECT_API_ERROR_LIMIT, PROTECT_API_RETRY_INTERVAL, PROTECT_API_TIMEOUT, PROTECT_BOOTSTRAP_REFRESH_INTERVAL, PROTECT_EVENTS_WATCHDOG_TIMEOUT, PROTECT_LIVESTREAM_AWAIT_MARGIN_MS, PROTECT_LIVESTREAM_AWAIT_MAX_MS, PROTECT_LIVESTREAM_AWAIT_MIN_MS, PROTECT_LIVESTREAM_DEFAULT_TOLERANCE_MS, PROTECT_LIVESTREAM_ESTABLISH_BACKOFF_MS, PROTECT_LIVESTREAM_ESTABLISH_DEADLINE_MS, PROTECT_LIVESTREAM_HEARTBEAT_TIMEOUT, PROTECT_LIVESTREAM_RECOVERY_BACKOFF_MS, PROTECT_REBOOT_ANTICIPATION_WINDOW_MS, PROTECT_REBOOT_DETECTION_THRESHOLD, PROTECT_RECOVERY_BACKOFF_KNOWN_MS, PROTECT_RECOVERY_BACKOFF_UNKNOWN_MS, PROTECT_RECOVERY_STEADY_INTERVAL_MS } from "./settings.js";
|
|
45
47
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wJAAwJ;AACxJ,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wJAAwJ;AACxJ,EAAE;AACF,mKAAmK;AACnK,sKAAsK;AACtK,sBAAsB;AACtB,wKAAwK;AACxK,qKAAqK;AACrK,wKAAwK;AACxK,oKAAoK;AACpK,2HAA2H;AAC3H,uKAAuK;AACvK,uIAAuI;AACvI,EAAE;AACF,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AA+B,EAAE,uCAAuC,EAC7I,uCAAuC,EAAE,wCAAwC,EAAE,oCAAoC,EAAE,sCAAsC,EAC/J,qCAAqC,EACrC,kCAAkC,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,mCAAmC,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The typed-event taxonomy for the UniFi Protect realtime stream, the pure {@link classifyPacket} that lifts a {@link RawPacket} into it, and the bootstrap-dimension
|
|
3
3
|
* {@link findUnmodeledDeviceCollections} that lifts an applied bootstrap into the device collections the reducer does not model.
|
|
4
4
|
*
|
|
5
|
-
* This module is Layer 1: it depends only on the codec's output shape and the domain types, performs no I/O, holds no state
|
|
5
|
+
* This module is Layer 1: it depends only on the codec's output shape and the domain types, performs no I/O, and holds no state. It is the second half
|
|
6
6
|
* of the protocol contract - {@link ../protocol/packet | packet.ts} turns bytes into a `RawPacket`; this turns a `RawPacket` into a {@link TypedEvent}. Because it owns
|
|
7
7
|
* the modelKey vocabulary ({@link DEVICE_MODEL_KEYS} / {@link KNOWN_MODEL_KEYS}), it also hosts the bootstrap-dimension classifier: where `classifyPacket` catches
|
|
8
8
|
* an unmodeled class that *emits a realtime packet*, `findUnmodeledDeviceCollections` catches one that merely *lives in the bootstrap* - the standing twin the realtime
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
import type { DeepPartial, ProtectNvrBootstrap, ProtectStateRecord } from "../types/index.ts";
|
|
14
14
|
import type { RawPacket } from "./packet.ts";
|
|
15
15
|
export declare const DEVICE_COLLECTION_KEYS: readonly ["camera", "chime", "fob", "light", "relay", "sensor", "viewer"];
|
|
16
|
-
declare const DEVICE_MODEL_KEYS: readonly ["camera", "chime", "fob", "light", "relay", "sensor", "viewer", "nvr"];
|
|
17
16
|
/** @internal */
|
|
18
|
-
declare const
|
|
19
|
-
|
|
17
|
+
export declare const DEVICE_MODEL_KEYS: readonly ["camera", "chime", "fob", "light", "relay", "sensor", "viewer", "nvr"];
|
|
18
|
+
/** @internal */
|
|
19
|
+
export declare const STATE_MODEL_KEYS: readonly ["camera", "chime", "fob", "light", "relay", "sensor", "viewer", "nvr", "liveview", "user"];
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare const KNOWN_MODEL_KEYS: readonly ["camera", "chime", "fob", "light", "relay", "sensor", "viewer", "nvr", "liveview", "user", "activeSessionStat", "aiport", "aiprocessor", "bridge", "event", "group", "linkstation", "smartDetectObject"];
|
|
20
22
|
/**
|
|
21
23
|
* The id-keyed device collections - every `DeviceModelKey` except the NVR singleton. The vocabulary the device selectors, the projections, and every per-category
|
|
22
24
|
* consumer iterate over; the innermost tier of the modelKey taxonomy.
|
|
@@ -79,7 +81,7 @@ export type AuthMethod = "fingerprint" | "nfc";
|
|
|
79
81
|
* unlike motion's `lastMotion` - so the occurrence is its single source of truth. It is a sibling of `motionDetected`, not a `smartDetect` variant: tamper is not a
|
|
80
82
|
* smart object class and carries no `objectTypes`.
|
|
81
83
|
* - `authDetected` - a doorbell reported an authentication scan: a fingerprint match (`fingerprintIdentified`) or an NFC card tap (`nfcCardScanned`). Camera-attributed
|
|
82
|
-
* (the doorbell that performed the scan
|
|
84
|
+
* (the doorbell that performed the scan) and, like `tamperDetected`, a one-way occurrence with no paired state field, so the
|
|
83
85
|
* occurrence is its single source of truth. It is decided by its explicit auth `type` *ahead* of the generic `accessEvent` fallback as defensive precedence - live
|
|
84
86
|
* captures of both methods confirm auth metadata (`fingerprint`/`nfc`) and the `accessEventId` access marker are disjoint, so a scan is never absorbed as a bare access
|
|
85
87
|
* occurrence even were a future firmware to co-stamp it. The `method` the classifier resolved (`"fingerprint"` / `"nfc"`) is lifted onto the event - the consumer reads
|
|
@@ -87,9 +89,10 @@ export type AuthMethod = "fingerprint" | "nfc";
|
|
|
87
89
|
* identity matched stay metadata reads (an unrecognized scan still classifies, carrying e.g. `metadata.fingerprint.ulpId: null`).
|
|
88
90
|
* - `doorbellRing` - a doorbell was pressed.
|
|
89
91
|
* - `accessEvent` - a UniFi Access occurrence (door, reader, lock), distinguished within the `event` channel by its access metadata.
|
|
90
|
-
* - `buttonPressed` - a security-action button was pressed on a fob (or a sensor with a button). Device-attributed (the pressing device, from the
|
|
91
|
-
*
|
|
92
|
-
* the device family rides in `metadata.deviceModelKey` since the wire event type is shared
|
|
92
|
+
* - `buttonPressed` - a security-action button was pressed on a fob (or a sensor with a button). Device-attributed (the pressing device, from the payload's
|
|
93
|
+
* `device` field, or the metadata's `sensorId` text when the payload carries no device), so it routes by `deviceId` like `accessEvent`; the classifier lifts
|
|
94
|
+
* `button` (which button) and `pressType` (how it was pressed), and the device family rides in `metadata.deviceModelKey` since the wire event type is shared
|
|
95
|
+
* across button-bearing devices.
|
|
93
96
|
*
|
|
94
97
|
* @category Events
|
|
95
98
|
*/
|
|
@@ -157,6 +160,18 @@ export type TypedEvent = {
|
|
|
157
160
|
pressType: string;
|
|
158
161
|
metadata?: Record<string, unknown>;
|
|
159
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* Every `type` value the library recognizes on an `event`-modelKey payload, assembled from the individual constants above so each of those stays the single source of
|
|
165
|
+
* its own value. Recognition is broader than modeling: `access` is recognized here while the classifier declines to lift it into an occurrence, because a type the
|
|
166
|
+
* library knows about is not wire drift even when it produces no event.
|
|
167
|
+
*
|
|
168
|
+
* The realtime classifier does not consult this array - it branches on the individual constants, which is what lets each occurrence carry its own resolution logic.
|
|
169
|
+
* This exists for a consumer asking the different question "is this a wire type the library has seen before?", which is what separates protocol evolution from
|
|
170
|
+
* ordinary traffic.
|
|
171
|
+
*
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
export declare const KNOWN_EVENT_TYPES: readonly string[];
|
|
160
175
|
/**
|
|
161
176
|
* Classify a decoded {@link RawPacket} into a {@link TypedEvent}, or `null` if the packet is valid but describes something the library does not model.
|
|
162
177
|
*
|
|
@@ -216,10 +231,10 @@ export interface UnmodeledCollection {
|
|
|
216
231
|
* The bootstrap-dimension twin of {@link classifyPacket}: scan an applied bootstrap for device-shaped collections the reducer does not model. Pure, total, and
|
|
217
232
|
* side-effect-free - it reads only the bootstrap and the modelKey vocabulary beside it. A collection qualifies when its value is a non-empty array whose first element
|
|
218
233
|
* is a record carrying both a string `modelKey` and a string `mac` - the device shape, present on relay/aiport/aiprocessor/linkstation/bridge and absent on the
|
|
219
|
-
* user/liveview/ringtone rosters (no `mac`) and the group collections (no `
|
|
220
|
-
* models. For each survivor it reports the bootstrap array key (`collection`), the record's self-declared `modelKey`, the array length (`count`), the first
|
|
221
|
-
* (`exampleId`), and whether the `modelKey` is otherwise recognized (`known`, via {@link isKnownModelKey}) - `true` for a recognized-but-unreduced class,
|
|
222
|
-
* genuine drift.
|
|
234
|
+
* user/liveview/ringtone rosters (no `mac`) and the group collections (a `modelKey` but no `mac`) - and whose `modelKey` is not already a {@link DeviceModelKey} the
|
|
235
|
+
* library models. For each survivor it reports the bootstrap array key (`collection`), the record's self-declared `modelKey`, the array length (`count`), the first
|
|
236
|
+
* record's id (`exampleId`), and whether the `modelKey` is otherwise recognized (`known`, via {@link isKnownModelKey}) - `true` for a recognized-but-unreduced class,
|
|
237
|
+
* `false` for genuine drift.
|
|
223
238
|
*
|
|
224
239
|
* Where {@link classifyPacket} catches an unmodeled class that emits a realtime packet, this catches a quiescent one that merely lives in the bootstrap. Both read the
|
|
225
240
|
* same vocabulary, so a class the library already models is automatically excluded from both, with no separate edit needed here.
|
|
@@ -246,9 +261,9 @@ export declare function findUnmodeledDeviceCollections(bootstrap: ProtectNvrBoot
|
|
|
246
261
|
*/
|
|
247
262
|
export declare function isKnownModelKey(value: string): value is ModelKey;
|
|
248
263
|
/**
|
|
249
|
-
* Whether the given wire model key is one the library models as a device - a {@link DeviceModelKey} with a REST endpoint and a Layer-3 projection. The innermost of
|
|
250
|
-
*
|
|
251
|
-
* already models, so a class promoted into {@link DEVICE_MODEL_KEYS} (as `relay` was) leaves the unmodeled report automatically, with no second edit.
|
|
264
|
+
* Whether the given wire model key is one the library models as a device - a {@link DeviceModelKey} with a REST endpoint and a Layer-3 projection. The innermost of
|
|
265
|
+
* this file's nested vocabulary guards ({@link isKnownModelKey} is the outermost). {@link findUnmodeledDeviceCollections} uses it to drop a bootstrap collection the
|
|
266
|
+
* library already models, so a class promoted into {@link DEVICE_MODEL_KEYS} (as `relay` was) leaves the unmodeled report automatically, with no second edit.
|
|
252
267
|
*
|
|
253
268
|
* @param value - The wire model-key string.
|
|
254
269
|
*
|
|
@@ -257,5 +272,4 @@ export declare function isKnownModelKey(value: string): value is ModelKey;
|
|
|
257
272
|
* @category Events
|
|
258
273
|
*/
|
|
259
274
|
export declare function isDeviceModelKey(value: string): value is DeviceModelKey;
|
|
260
|
-
export {};
|
|
261
275
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/protocol/events.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAU7C,eAAO,MAAM,sBAAsB,2EAA8E,CAAC;AAGlH,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/protocol/events.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAU7C,eAAO,MAAM,sBAAsB,2EAA8E,CAAC;AAGlH,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,kFAAgD,CAAC;AAM/E,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,sGAAwD,CAAC;AAQtF,gBAAgB;AAChB,eAAO,MAAM,gBA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,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAmBlJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EACsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,GAAG,UAAU,GAAG,IAAI,CAkBhE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,MAAM,EAAE,CAiClE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAElC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,mBAAmB,GAAG,SAAS,mBAAmB,EAAE,CAuC7G;AA6ID;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAGhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,cAAc,CAGvE"}
|
package/dist/protocol/events.js
CHANGED
|
@@ -3,39 +3,60 @@
|
|
|
3
3
|
* events.ts: The typed-event taxonomy and the pure classifier that lifts a RawPacket into it.
|
|
4
4
|
*/
|
|
5
5
|
import { assertNever } from "../errors.js";
|
|
6
|
-
// The modelKey taxonomy
|
|
7
|
-
// its type and its runtime membership test. The controller emits realtime `update` packets for more than the projectable devices, so the tiers separate
|
|
8
|
-
// questions: "is this an id-keyed device collection?", "is this device-addressable?", "do we reduce it into state?", and "is this a modelKey we
|
|
9
|
-
// all?".
|
|
6
|
+
// The modelKey taxonomy nests DeviceCollectionKey inside DeviceModelKey inside StateModelKey inside ModelKey, each declared once as the single source of truth
|
|
7
|
+
// for both its type and its runtime membership test. The controller emits realtime `update` packets for more than the projectable devices, so the tiers separate
|
|
8
|
+
// the distinct questions: "is this an id-keyed device collection?", "is this device-addressable?", "do we reduce it into state?", and "is this a modelKey we
|
|
9
|
+
// recognize on the wire at all?".
|
|
10
10
|
// Tier 0 - the id-keyed device collections: every DeviceModelKey except the NVR singleton. The vocabulary a consumer iterates to reach a device category's selectors and
|
|
11
11
|
// projections, and the innermost tier of the taxonomy.
|
|
12
12
|
export const DEVICE_COLLECTION_KEYS = ["camera", "chime", "fob", "light", "relay", "sensor", "viewer"];
|
|
13
13
|
// Tier 1 - addressable via a REST endpoint and surfaced as a Layer-3 projection identity: the device collections plus the NVR singleton.
|
|
14
|
-
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const DEVICE_MODEL_KEYS = [...DEVICE_COLLECTION_KEYS, "nvr"];
|
|
15
16
|
// Tier 2 - the model keys the reducer folds into ProtectState from the realtime stream: every device, the user roster, and the liveview collection. `user` and `liveview`
|
|
16
17
|
// are reduced (their realtime updates carry permission/role and liveview changes we want reflected immediately) but are not device-addressed, so each is a StateModelKey
|
|
17
18
|
// without being a DeviceModelKey. Note this is the *realtime-reduced* set: `ringtones` is also reduced into ProtectState but bootstrap-only (the controller emits no
|
|
18
19
|
// `ringtone` packet), so it is deliberately not here and not in KNOWN_MODEL_KEYS - leaving schema:unknownModelKey armed as a tripwire if that ever changes.
|
|
19
20
|
/** @internal */
|
|
20
|
-
const STATE_MODEL_KEYS = [...DEVICE_MODEL_KEYS, "liveview", "user"];
|
|
21
|
+
export const STATE_MODEL_KEYS = [...DEVICE_MODEL_KEYS, "liveview", "user"];
|
|
21
22
|
// Tier 3 - every model key the controller is observed to emit on the realtime stream: the reduced set, the `event` activity channel, and the recognized-but-unmodeled
|
|
22
23
|
// keys the controller broadcasts but the library does not fold into state - the `group`/`bridge` collections, the newer device classes (`aiport`, `aiprocessor`,
|
|
23
24
|
// `linkstation`), and detection/session telemetry (`smartDetectObject`, `activeSessionStat`). A device-shaped key here can become a reduced StateModelKey when a
|
|
24
|
-
// consumer needs it - `relay`
|
|
25
|
+
// consumer needs it - `relay` is one such promoted key, modeled as a DeviceModelKey. Membership in this set is what makes the schema:unknownModelKey diagnostic
|
|
25
26
|
// honest - a key in this set is known even when we do not reduce it, so the diagnostic fires only for a key outside it (genuine wire drift). This set beyond the
|
|
26
27
|
// collections was confirmed by a schema-drift sweep against a real controller; `doorlock` and `ringtone` remain deliberately absent, as neither is observed in practice.
|
|
27
|
-
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const KNOWN_MODEL_KEYS = [...STATE_MODEL_KEYS, "activeSessionStat", "aiport", "aiprocessor", "bridge", "event", "group", "linkstation",
|
|
30
|
+
"smartDetectObject"];
|
|
28
31
|
// The distinguishing `type` values on an `event`-modelKey payload, grouped by the activity signal each maps to. Naming them as constants keeps the wire vocabulary in
|
|
29
32
|
// one place and makes it cheap to extend as live-controller captures confirm additional values.
|
|
30
33
|
// The auth wire types map to their resolved `AuthMethod` rather than a bare membership list: under `noUncheckedIndexedAccess` a lookup returns `AuthMethod | undefined`,
|
|
31
34
|
// so this map is both the "is this an auth type?" test and the method resolution - no parallel list-and-switch to keep in sync, and a new auth type is a single entry
|
|
32
35
|
// whose value the `AuthMethod` union must admit (a closed-by-construction extension point, not an open passthrough).
|
|
36
|
+
// The controller's user login/session audit record, which it emits on every authentication (this library's own `connect()` included). The classifier deliberately does
|
|
37
|
+
// not model it - the wire makes a login and a software unlock indistinguishable, as the note in `classifyActivity` explains - but it is a type the library recognizes,
|
|
38
|
+
// so it is named here and carried into KNOWN_EVENT_TYPES below. Without it, every login would read as an unrecognized wire type to a consumer checking against that
|
|
39
|
+
// vocabulary.
|
|
40
|
+
const ACCESS_EVENT_TYPE = "access";
|
|
33
41
|
const AUTH_EVENT_METHODS = { fingerprintIdentified: "fingerprint", nfcCardScanned: "nfc" };
|
|
34
42
|
const MOTION_EVENT_TYPE = "motion";
|
|
35
43
|
const RING_EVENT_TYPE = "ring";
|
|
36
44
|
const SENSOR_BUTTON_EVENT_TYPE = "sensorButtonPressed";
|
|
37
45
|
const SMART_EVENT_TYPES = ["smartAudioDetect", "smartDetectLine", "smartDetectZone"];
|
|
38
46
|
const TAMPER_EVENT_TYPE = "smartDetectTamper";
|
|
47
|
+
/**
|
|
48
|
+
* Every `type` value the library recognizes on an `event`-modelKey payload, assembled from the individual constants above so each of those stays the single source of
|
|
49
|
+
* its own value. Recognition is broader than modeling: `access` is recognized here while the classifier declines to lift it into an occurrence, because a type the
|
|
50
|
+
* library knows about is not wire drift even when it produces no event.
|
|
51
|
+
*
|
|
52
|
+
* The realtime classifier does not consult this array - it branches on the individual constants, which is what lets each occurrence carry its own resolution logic.
|
|
53
|
+
* This exists for a consumer asking the different question "is this a wire type the library has seen before?", which is what separates protocol evolution from
|
|
54
|
+
* ordinary traffic.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export const KNOWN_EVENT_TYPES = [ACCESS_EVENT_TYPE, ...Object.keys(AUTH_EVENT_METHODS), MOTION_EVENT_TYPE, RING_EVENT_TYPE,
|
|
59
|
+
SENSOR_BUTTON_EVENT_TYPE, ...SMART_EVENT_TYPES, TAMPER_EVENT_TYPE];
|
|
39
60
|
/**
|
|
40
61
|
* Classify a decoded {@link RawPacket} into a {@link TypedEvent}, or `null` if the packet is valid but describes something the library does not model.
|
|
41
62
|
*
|
|
@@ -115,10 +136,10 @@ export function eventSubjects(event) {
|
|
|
115
136
|
* The bootstrap-dimension twin of {@link classifyPacket}: scan an applied bootstrap for device-shaped collections the reducer does not model. Pure, total, and
|
|
116
137
|
* side-effect-free - it reads only the bootstrap and the modelKey vocabulary beside it. A collection qualifies when its value is a non-empty array whose first element
|
|
117
138
|
* is a record carrying both a string `modelKey` and a string `mac` - the device shape, present on relay/aiport/aiprocessor/linkstation/bridge and absent on the
|
|
118
|
-
* user/liveview/ringtone rosters (no `mac`) and the group collections (no `
|
|
119
|
-
* models. For each survivor it reports the bootstrap array key (`collection`), the record's self-declared `modelKey`, the array length (`count`), the first
|
|
120
|
-
* (`exampleId`), and whether the `modelKey` is otherwise recognized (`known`, via {@link isKnownModelKey}) - `true` for a recognized-but-unreduced class,
|
|
121
|
-
* genuine drift.
|
|
139
|
+
* user/liveview/ringtone rosters (no `mac`) and the group collections (a `modelKey` but no `mac`) - and whose `modelKey` is not already a {@link DeviceModelKey} the
|
|
140
|
+
* library models. For each survivor it reports the bootstrap array key (`collection`), the record's self-declared `modelKey`, the array length (`count`), the first
|
|
141
|
+
* record's id (`exampleId`), and whether the `modelKey` is otherwise recognized (`known`, via {@link isKnownModelKey}) - `true` for a recognized-but-unreduced class,
|
|
142
|
+
* `false` for genuine drift.
|
|
122
143
|
*
|
|
123
144
|
* Where {@link classifyPacket} catches an unmodeled class that emits a realtime packet, this catches a quiescent one that merely lives in the bootstrap. Both read the
|
|
124
145
|
* same vocabulary, so a class the library already models is automatically excluded from both, with no separate edit needed here.
|
|
@@ -133,7 +154,7 @@ export function findUnmodeledDeviceCollections(bootstrap) {
|
|
|
133
154
|
const collections = [];
|
|
134
155
|
for (const [collection, value] of Object.entries(bootstrap)) {
|
|
135
156
|
// The device-shaped predicate: a non-empty array whose first element is a record with both a string `modelKey` and a string `mac`. The `mac` is what separates a
|
|
136
|
-
// device collection from the user/liveview/ringtone rosters (no `mac`) and the group collections (no `
|
|
157
|
+
// device collection from the user/liveview/ringtone rosters (no `mac`) and the group collections (a `modelKey` but no `mac`).
|
|
137
158
|
if (!Array.isArray(value) || (value.length === 0)) {
|
|
138
159
|
continue;
|
|
139
160
|
}
|
|
@@ -181,13 +202,14 @@ function classifyActivity(eventId, payload) {
|
|
|
181
202
|
const cameraId = stringField(payload, "cameraId") ?? stringField(payload, "camera");
|
|
182
203
|
const metadata = recordField(payload, "metadata");
|
|
183
204
|
const type = stringField(payload, "type");
|
|
184
|
-
// A doorbell authentication scan - a fingerprint match or an NFC card tap - is camera-attributed (the doorbell that performed it), resolved
|
|
185
|
-
// `camera`
|
|
186
|
-
// disjoint, so the two branches do not collide on observed traffic; we nonetheless resolve
|
|
187
|
-
// *before* the accessEvent branch below - the same "an explicit type wins over the
|
|
188
|
-
// smart-detection branch - as defensive precedence, so a future firmware that
|
|
189
|
-
// absorbed as a bare `accessEvent`. The resolved method is lifted onto the event
|
|
190
|
-
// from metadata shape), exactly as `smartDetect` lifts `objectTypes`. Because this
|
|
205
|
+
// A doorbell authentication scan - a fingerprint match or an NFC card tap - is camera-attributed (the doorbell that performed it), resolved through the
|
|
206
|
+
// shared `cameraId`-then-`camera` fallback every camera-attributed signal uses. Live captures of both methods confirm its metadata (`fingerprint`/`nfc`)
|
|
207
|
+
// and a generic access occurrence's `accessEventId` marker are disjoint, so the two branches do not collide on observed traffic; we nonetheless resolve
|
|
208
|
+
// the `method` from the wire `type` and decide the occurrence by it *before* the accessEvent branch below - the same "an explicit type wins over the
|
|
209
|
+
// metadata fallback" discipline `tamperDetected` uses against the smart-detection branch - as defensive precedence, so a future firmware that
|
|
210
|
+
// co-stamped a scan with `accessEventId` could still never have it absorbed as a bare `accessEvent`. The resolved method is lifted onto the event
|
|
211
|
+
// (the classifier's own answer, so the consumer never re-derives it from metadata shape), exactly as `smartDetect` lifts `objectTypes`. Because this
|
|
212
|
+
// test precedes the shared camera-id guard further down, it carries
|
|
191
213
|
// its own: without a camera id the signal is unroutable, so we decline. Whether the scan succeeded and which identity matched stay metadata reads at
|
|
192
214
|
// delivery - data, not classification (an unrecognized scan still classifies, carrying `metadata.fingerprint.ulpId: null`).
|
|
193
215
|
const method = (type !== undefined) ? AUTH_EVENT_METHODS[type] : undefined;
|
|
@@ -204,9 +226,10 @@ function classifyActivity(eventId, payload) {
|
|
|
204
226
|
}
|
|
205
227
|
return { action: stringField(metadata, "action") ?? type ?? "", at, deviceId, eventId, kind: "accessEvent", metadata };
|
|
206
228
|
}
|
|
207
|
-
// A button press on a fob (or a sensor with a button) is a device-attributed occurrence: the wire carries the pressing device on `device` (with `camera` null),
|
|
208
|
-
//
|
|
209
|
-
//
|
|
229
|
+
// A button press on a fob (or a sensor with a button) is a device-attributed occurrence: the wire carries the pressing device on `device` (with `camera` null),
|
|
230
|
+
// or falls back to the metadata's `sensorId` text when the payload carries no device, so it routes by `deviceId` like an access occurrence rather than
|
|
231
|
+
// through the camera-id guard below. The lifted `button` and `pressType` are the occurrence's identity - which button, and how it was pressed - while the
|
|
232
|
+
// device family rides in `metadata.deviceModelKey`, since the event type is shared across button-bearing devices.
|
|
210
233
|
if (type === SENSOR_BUTTON_EVENT_TYPE) {
|
|
211
234
|
const deviceId = stringField(payload, "device") ?? readNestedText(metadata?.["sensorId"]);
|
|
212
235
|
if (deviceId === undefined) {
|
|
@@ -267,9 +290,9 @@ export function isKnownModelKey(value) {
|
|
|
267
290
|
return KNOWN_MODEL_KEYS.includes(value);
|
|
268
291
|
}
|
|
269
292
|
/**
|
|
270
|
-
* Whether the given wire model key is one the library models as a device - a {@link DeviceModelKey} with a REST endpoint and a Layer-3 projection. The innermost of
|
|
271
|
-
*
|
|
272
|
-
* already models, so a class promoted into {@link DEVICE_MODEL_KEYS} (as `relay` was) leaves the unmodeled report automatically, with no second edit.
|
|
293
|
+
* Whether the given wire model key is one the library models as a device - a {@link DeviceModelKey} with a REST endpoint and a Layer-3 projection. The innermost of
|
|
294
|
+
* this file's nested vocabulary guards ({@link isKnownModelKey} is the outermost). {@link findUnmodeledDeviceCollections} uses it to drop a bootstrap collection the
|
|
295
|
+
* library already models, so a class promoted into {@link DEVICE_MODEL_KEYS} (as `relay` was) leaves the unmodeled report automatically, with no second edit.
|
|
273
296
|
*
|
|
274
297
|
* @param value - The wire model-key string.
|
|
275
298
|
*
|
|
@@ -304,7 +327,8 @@ function stringArrayField(record, key) {
|
|
|
304
327
|
const value = record[key];
|
|
305
328
|
return Array.isArray(value) ? value.filter((element) => typeof element === "string") : [];
|
|
306
329
|
}
|
|
307
|
-
// Read the `.text` of a `{ text: string }`-shaped property
|
|
330
|
+
// Read the `.text` of a `{ text: string }`-shaped property - the shape the access metadata's `deviceId` field and the button-press metadata's `sensorId`, `button`,
|
|
331
|
+
// and `buttonPressType` fields share - or undefined if it does not match.
|
|
308
332
|
function readNestedText(value) {
|
|
309
333
|
return isRecord(value) ? stringField(value, "text") : undefined;
|
|
310
334
|
}
|