@camstack/addon-mqtt-broker 1.2.97 → 1.2.98

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.
@@ -7332,6 +7332,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7332
7332
  action: string().min(1),
7333
7333
  input: unknown()
7334
7334
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7335
+ new Set([
7336
+ "track",
7337
+ "summary",
7338
+ "face",
7339
+ "identity",
7340
+ "plate",
7341
+ "vehicle",
7342
+ "scene",
7343
+ "motion",
7344
+ "object",
7345
+ "audio"
7346
+ ]);
7347
+ new Set([
7348
+ "motion",
7349
+ "object",
7350
+ "audio"
7351
+ ]);
7335
7352
  var EncodeProfileSchema = object({
7336
7353
  video: object({
7337
7354
  codec: _enum([
@@ -12479,8 +12496,17 @@ method(object({
12479
12496
  }), array(SettingsRecordSchema).readonly()), method(object({
12480
12497
  namespace: string().optional(),
12481
12498
  collection: string(),
12482
- record: SettingsRecordSchema
12483
- }), _void(), { kind: "mutation" }), method(object({
12499
+ record: object({
12500
+ id: string().optional(),
12501
+ data: record(string(), unknown())
12502
+ })
12503
+ }), object({
12504
+ /**
12505
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12506
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12507
+ * primary key — which is the only place an auto key is knowable.
12508
+ */
12509
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12484
12510
  namespace: string().optional(),
12485
12511
  collection: string(),
12486
12512
  records: array(BulkRecordSchema).readonly()
@@ -12589,8 +12615,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12589
12615
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12590
12616
  namespace: string().optional(),
12591
12617
  collection: string(),
12592
- record: SettingsRecordSchema
12593
- }), _void(), {
12618
+ record: object({
12619
+ id: string().optional(),
12620
+ data: record(string(), unknown())
12621
+ })
12622
+ }), object({
12623
+ /**
12624
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12625
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12626
+ * primary key — which is the only place an auto key is knowable.
12627
+ */
12628
+ id: union([string(), number()]) }), {
12594
12629
  kind: "mutation",
12595
12630
  auth: "admin"
12596
12631
  }), method(object({
@@ -19251,7 +19286,20 @@ var TrackSchema = object({
19251
19286
  ...TrackRetrainFields
19252
19287
  });
19253
19288
  var BaseEventFields = {
19254
- id: string(),
19289
+ /**
19290
+ * A SQLite ROWID, assigned by the database (D474).
19291
+ *
19292
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19293
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19294
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19295
+ * the rowid: the table itself is that B-tree, so the index stops existing
19296
+ * rather than getting smaller. No shorter string does that.
19297
+ *
19298
+ * Defined once here for all three event kinds, which is why they move
19299
+ * together: a per-table migration would have forked this and
19300
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19301
+ */
19302
+ id: number().int(),
19255
19303
  deviceId: number(),
19256
19304
  timestamp: number()
19257
19305
  };
@@ -19270,7 +19318,34 @@ var MotionEventSchema = object({
19270
19318
  /** Omitted in slim projection. */
19271
19319
  frameHeight: number().optional(),
19272
19320
  /** Populated by B5 (recording playback URL for this event). */
19273
- mediaUrl: string().optional()
19321
+ mediaUrl: string().optional(),
19322
+ /**
19323
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19324
+ * episode is still open — a further rising edge extends it in place rather
19325
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19326
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19327
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19328
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19329
+ * motion for an instantaneous trigger).
19330
+ *
19331
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19332
+ * "closed the old way, before this column existed", never "still open".
19333
+ * Nothing in this codebase may read an absent `durationMs` as an open
19334
+ * episode; only `null` means open.
19335
+ */
19336
+ durationMs: number().nullable().optional(),
19337
+ /**
19338
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19339
+ * first entry is always `0`) of every genuine off→on transition the
19340
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19341
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19342
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19343
+ * explicit `false` mid-episode and then resumes before the quiet window
19344
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19345
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19346
+ * which must never be read as "no episode happened here".
19347
+ */
19348
+ edges: array(number()).readonly().optional()
19274
19349
  });
19275
19350
  /**
19276
19351
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19325,6 +19400,23 @@ var ObjectEventSchema = object({
19325
19400
  * includes it (it is light). Absent on rows written before this field.
19326
19401
  */
19327
19402
  frameId: string().optional(),
19403
+ /**
19404
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19405
+ * (D474).
19406
+ *
19407
+ * Only the package detector writes it, and it exists because the event id
19408
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19409
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19410
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19411
+ * assigned by SQLite, so that key had to move off the primary key rather
19412
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19413
+ * every parcel on every boot.
19414
+ *
19415
+ * Absent on every other object event, and on every row written before this
19416
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19417
+ * not per row, and nothing addresses a row by it.
19418
+ */
19419
+ idempotencyKey: string().optional(),
19328
19420
  /** Omitted in slim projection. */
19329
19421
  trackId: string().optional(),
19330
19422
  className: string(),
@@ -26391,9 +26483,54 @@ object({
26391
26483
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26392
26484
  lastDetectedAt: number().nullable(),
26393
26485
  /**
26394
- * Ms after which `detected` auto-reverts to false if no fresh push
26395
- * arrives. Null means the provider leaves detected state until a
26396
- * native "clear" event.
26486
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26487
+ * `null` while false and on every `Sensor` device (D475) — see that
26488
+ * constant's doc for the one-authority rule.
26489
+ *
26490
+ * ## Reading this field still arms nothing
26491
+ *
26492
+ * It reads like an instruction to the consumer ("revert after N ms if
26493
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26494
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26495
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26496
+ * imported constant, not as a read of `device.state.motion.value`, so this
26497
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26498
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26499
+ * field would add a second falling-edge authority beside whichever one
26500
+ * already owns the device, and two that can disagree are worse than one.
26501
+ * Consumers that need a falling edge SHAPED differently — held open across
26502
+ * a flapping source — debounce on their own side and say so, as
26503
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26504
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26505
+ *
26506
+ * ## Who writes it
26507
+ *
26508
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26509
+ * `cooldown_expired`, which then writes this slice with
26510
+ * `detected: false` (`handlePhaseChanged` in
26511
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26512
+ * matters most for the sources that only ever push a rising one:
26513
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26514
+ * a false.
26515
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26516
+ * provider pushes the false itself, from the upstream system's own
26517
+ * state change. No phase machine is involved.
26518
+ *
26519
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26520
+ *
26521
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26522
+ * phase machine is the sole writer for a camera. It is not.
26523
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26524
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26525
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26526
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26527
+ * two authorities can disagree about one slice, which this repo
26528
+ * forbids, and the doc said otherwise — which is worse than saying
26529
+ * nothing, because it reads as verification.
26530
+ *
26531
+ * This predates D475 and is not fixed there: the fix touches every
26532
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26533
+ * "sole writer" wording without also removing the other writers.
26397
26534
  */
26398
26535
  autoClearAfterMs: number().nullable()
26399
26536
  });
@@ -7327,6 +7327,23 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7327
7327
  action: string().min(1),
7328
7328
  input: unknown()
7329
7329
  }), unknown(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7330
+ new Set([
7331
+ "track",
7332
+ "summary",
7333
+ "face",
7334
+ "identity",
7335
+ "plate",
7336
+ "vehicle",
7337
+ "scene",
7338
+ "motion",
7339
+ "object",
7340
+ "audio"
7341
+ ]);
7342
+ new Set([
7343
+ "motion",
7344
+ "object",
7345
+ "audio"
7346
+ ]);
7330
7347
  var EncodeProfileSchema = object({
7331
7348
  video: object({
7332
7349
  codec: _enum([
@@ -12474,8 +12491,17 @@ method(object({
12474
12491
  }), array(SettingsRecordSchema).readonly()), method(object({
12475
12492
  namespace: string().optional(),
12476
12493
  collection: string(),
12477
- record: SettingsRecordSchema
12478
- }), _void(), { kind: "mutation" }), method(object({
12494
+ record: object({
12495
+ id: string().optional(),
12496
+ data: record(string(), unknown())
12497
+ })
12498
+ }), object({
12499
+ /**
12500
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12501
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12502
+ * primary key — which is the only place an auto key is knowable.
12503
+ */
12504
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12479
12505
  namespace: string().optional(),
12480
12506
  collection: string(),
12481
12507
  records: array(BulkRecordSchema).readonly()
@@ -12584,8 +12610,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12584
12610
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12585
12611
  namespace: string().optional(),
12586
12612
  collection: string(),
12587
- record: SettingsRecordSchema
12588
- }), _void(), {
12613
+ record: object({
12614
+ id: string().optional(),
12615
+ data: record(string(), unknown())
12616
+ })
12617
+ }), object({
12618
+ /**
12619
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12620
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12621
+ * primary key — which is the only place an auto key is knowable.
12622
+ */
12623
+ id: union([string(), number()]) }), {
12589
12624
  kind: "mutation",
12590
12625
  auth: "admin"
12591
12626
  }), method(object({
@@ -19246,7 +19281,20 @@ var TrackSchema = object({
19246
19281
  ...TrackRetrainFields
19247
19282
  });
19248
19283
  var BaseEventFields = {
19249
- id: string(),
19284
+ /**
19285
+ * A SQLite ROWID, assigned by the database (D474).
19286
+ *
19287
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19288
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19289
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19290
+ * the rowid: the table itself is that B-tree, so the index stops existing
19291
+ * rather than getting smaller. No shorter string does that.
19292
+ *
19293
+ * Defined once here for all three event kinds, which is why they move
19294
+ * together: a per-table migration would have forked this and
19295
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19296
+ */
19297
+ id: number().int(),
19250
19298
  deviceId: number(),
19251
19299
  timestamp: number()
19252
19300
  };
@@ -19265,7 +19313,34 @@ var MotionEventSchema = object({
19265
19313
  /** Omitted in slim projection. */
19266
19314
  frameHeight: number().optional(),
19267
19315
  /** Populated by B5 (recording playback URL for this event). */
19268
- mediaUrl: string().optional()
19316
+ mediaUrl: string().optional(),
19317
+ /**
19318
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19319
+ * episode is still open — a further rising edge extends it in place rather
19320
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19321
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19322
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19323
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19324
+ * motion for an instantaneous trigger).
19325
+ *
19326
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19327
+ * "closed the old way, before this column existed", never "still open".
19328
+ * Nothing in this codebase may read an absent `durationMs` as an open
19329
+ * episode; only `null` means open.
19330
+ */
19331
+ durationMs: number().nullable().optional(),
19332
+ /**
19333
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19334
+ * first entry is always `0`) of every genuine off→on transition the
19335
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19336
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19337
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19338
+ * explicit `false` mid-episode and then resumes before the quiet window
19339
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19340
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19341
+ * which must never be read as "no episode happened here".
19342
+ */
19343
+ edges: array(number()).readonly().optional()
19269
19344
  });
19270
19345
  /**
19271
19346
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19320,6 +19395,23 @@ var ObjectEventSchema = object({
19320
19395
  * includes it (it is light). Absent on rows written before this field.
19321
19396
  */
19322
19397
  frameId: string().optional(),
19398
+ /**
19399
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19400
+ * (D474).
19401
+ *
19402
+ * Only the package detector writes it, and it exists because the event id
19403
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19404
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19405
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19406
+ * assigned by SQLite, so that key had to move off the primary key rather
19407
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19408
+ * every parcel on every boot.
19409
+ *
19410
+ * Absent on every other object event, and on every row written before this
19411
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19412
+ * not per row, and nothing addresses a row by it.
19413
+ */
19414
+ idempotencyKey: string().optional(),
19323
19415
  /** Omitted in slim projection. */
19324
19416
  trackId: string().optional(),
19325
19417
  className: string(),
@@ -26386,9 +26478,54 @@ object({
26386
26478
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26387
26479
  lastDetectedAt: number().nullable(),
26388
26480
  /**
26389
- * Ms after which `detected` auto-reverts to false if no fresh push
26390
- * arrives. Null means the provider leaves detected state until a
26391
- * native "clear" event.
26481
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26482
+ * `null` while false and on every `Sensor` device (D475) — see that
26483
+ * constant's doc for the one-authority rule.
26484
+ *
26485
+ * ## Reading this field still arms nothing
26486
+ *
26487
+ * It reads like an instruction to the consumer ("revert after N ms if
26488
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26489
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26490
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26491
+ * imported constant, not as a read of `device.state.motion.value`, so this
26492
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26493
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26494
+ * field would add a second falling-edge authority beside whichever one
26495
+ * already owns the device, and two that can disagree are worse than one.
26496
+ * Consumers that need a falling edge SHAPED differently — held open across
26497
+ * a flapping source — debounce on their own side and say so, as
26498
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26499
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26500
+ *
26501
+ * ## Who writes it
26502
+ *
26503
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26504
+ * `cooldown_expired`, which then writes this slice with
26505
+ * `detected: false` (`handlePhaseChanged` in
26506
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26507
+ * matters most for the sources that only ever push a rising one:
26508
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26509
+ * a false.
26510
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26511
+ * provider pushes the false itself, from the upstream system's own
26512
+ * state change. No phase machine is involved.
26513
+ *
26514
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26515
+ *
26516
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26517
+ * phase machine is the sole writer for a camera. It is not.
26518
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26519
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26520
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26521
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26522
+ * two authorities can disagree about one slice, which this repo
26523
+ * forbids, and the doc said otherwise — which is worse than saying
26524
+ * nothing, because it reads as verification.
26525
+ *
26526
+ * This predates D475 and is not fixed there: the fix touches every
26527
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26528
+ * "sole writer" wording without also removing the other writers.
26392
26529
  */
26393
26530
  autoClearAfterMs: number().nullable()
26394
26531
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-mqtt-broker",
3
- "version": "1.2.97",
3
+ "version": "1.2.98",
4
4
  "description": "MQTT broker registry addon for CamStack — manages external broker entries + an optional embedded aedes broker. Consumers spin up their own `mqtt.js` clients via the `mqtt-broker` cap.",
5
5
  "keywords": [
6
6
  "camstack",