@camstack/addon-provider-onvif 1.2.96 → 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.
package/dist/addon.js CHANGED
@@ -7302,6 +7302,23 @@ function errMsg(err) {
7302
7302
  if (typeof err === "string") return err;
7303
7303
  return String(err);
7304
7304
  }
7305
+ new Set([
7306
+ "track",
7307
+ "summary",
7308
+ "face",
7309
+ "identity",
7310
+ "plate",
7311
+ "vehicle",
7312
+ "scene",
7313
+ "motion",
7314
+ "object",
7315
+ "audio"
7316
+ ]);
7317
+ new Set([
7318
+ "motion",
7319
+ "object",
7320
+ "audio"
7321
+ ]);
7305
7322
  var EncodeProfileSchema = object({
7306
7323
  video: object({
7307
7324
  codec: _enum([
@@ -12400,8 +12417,17 @@ method(object({
12400
12417
  }), array(SettingsRecordSchema).readonly()), method(object({
12401
12418
  namespace: string().optional(),
12402
12419
  collection: string(),
12403
- record: SettingsRecordSchema
12404
- }), _void(), { kind: "mutation" }), method(object({
12420
+ record: object({
12421
+ id: string().optional(),
12422
+ data: record(string(), unknown())
12423
+ })
12424
+ }), object({
12425
+ /**
12426
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12427
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12428
+ * primary key — which is the only place an auto key is knowable.
12429
+ */
12430
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12405
12431
  namespace: string().optional(),
12406
12432
  collection: string(),
12407
12433
  records: array(BulkRecordSchema).readonly()
@@ -12510,8 +12536,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12510
12536
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12511
12537
  namespace: string().optional(),
12512
12538
  collection: string(),
12513
- record: SettingsRecordSchema
12514
- }), _void(), {
12539
+ record: object({
12540
+ id: string().optional(),
12541
+ data: record(string(), unknown())
12542
+ })
12543
+ }), object({
12544
+ /**
12545
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12546
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12547
+ * primary key — which is the only place an auto key is knowable.
12548
+ */
12549
+ id: union([string(), number()]) }), {
12515
12550
  kind: "mutation",
12516
12551
  auth: "admin"
12517
12552
  }), method(object({
@@ -19234,7 +19269,20 @@ var TrackSchema = object({
19234
19269
  ...TrackRetrainFields
19235
19270
  });
19236
19271
  var BaseEventFields = {
19237
- id: string(),
19272
+ /**
19273
+ * A SQLite ROWID, assigned by the database (D474).
19274
+ *
19275
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19276
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19277
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19278
+ * the rowid: the table itself is that B-tree, so the index stops existing
19279
+ * rather than getting smaller. No shorter string does that.
19280
+ *
19281
+ * Defined once here for all three event kinds, which is why they move
19282
+ * together: a per-table migration would have forked this and
19283
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19284
+ */
19285
+ id: number().int(),
19238
19286
  deviceId: number(),
19239
19287
  timestamp: number()
19240
19288
  };
@@ -19253,7 +19301,34 @@ var MotionEventSchema = object({
19253
19301
  /** Omitted in slim projection. */
19254
19302
  frameHeight: number().optional(),
19255
19303
  /** Populated by B5 (recording playback URL for this event). */
19256
- mediaUrl: string().optional()
19304
+ mediaUrl: string().optional(),
19305
+ /**
19306
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19307
+ * episode is still open — a further rising edge extends it in place rather
19308
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19309
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19310
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19311
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19312
+ * motion for an instantaneous trigger).
19313
+ *
19314
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19315
+ * "closed the old way, before this column existed", never "still open".
19316
+ * Nothing in this codebase may read an absent `durationMs` as an open
19317
+ * episode; only `null` means open.
19318
+ */
19319
+ durationMs: number().nullable().optional(),
19320
+ /**
19321
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19322
+ * first entry is always `0`) of every genuine off→on transition the
19323
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19324
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19325
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19326
+ * explicit `false` mid-episode and then resumes before the quiet window
19327
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19328
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19329
+ * which must never be read as "no episode happened here".
19330
+ */
19331
+ edges: array(number()).readonly().optional()
19257
19332
  });
19258
19333
  /**
19259
19334
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19308,6 +19383,23 @@ var ObjectEventSchema = object({
19308
19383
  * includes it (it is light). Absent on rows written before this field.
19309
19384
  */
19310
19385
  frameId: string().optional(),
19386
+ /**
19387
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19388
+ * (D474).
19389
+ *
19390
+ * Only the package detector writes it, and it exists because the event id
19391
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19392
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19393
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19394
+ * assigned by SQLite, so that key had to move off the primary key rather
19395
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19396
+ * every parcel on every boot.
19397
+ *
19398
+ * Absent on every other object event, and on every row written before this
19399
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19400
+ * not per row, and nothing addresses a row by it.
19401
+ */
19402
+ idempotencyKey: string().optional(),
19311
19403
  /** Omitted in slim projection. */
19312
19404
  trackId: string().optional(),
19313
19405
  className: string(),
@@ -26478,9 +26570,54 @@ object({
26478
26570
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26479
26571
  lastDetectedAt: number().nullable(),
26480
26572
  /**
26481
- * Ms after which `detected` auto-reverts to false if no fresh push
26482
- * arrives. Null means the provider leaves detected state until a
26483
- * native "clear" event.
26573
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26574
+ * `null` while false and on every `Sensor` device (D475) — see that
26575
+ * constant's doc for the one-authority rule.
26576
+ *
26577
+ * ## Reading this field still arms nothing
26578
+ *
26579
+ * It reads like an instruction to the consumer ("revert after N ms if
26580
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26581
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26582
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26583
+ * imported constant, not as a read of `device.state.motion.value`, so this
26584
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26585
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26586
+ * field would add a second falling-edge authority beside whichever one
26587
+ * already owns the device, and two that can disagree are worse than one.
26588
+ * Consumers that need a falling edge SHAPED differently — held open across
26589
+ * a flapping source — debounce on their own side and say so, as
26590
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26591
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26592
+ *
26593
+ * ## Who writes it
26594
+ *
26595
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26596
+ * `cooldown_expired`, which then writes this slice with
26597
+ * `detected: false` (`handlePhaseChanged` in
26598
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26599
+ * matters most for the sources that only ever push a rising one:
26600
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26601
+ * a false.
26602
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26603
+ * provider pushes the false itself, from the upstream system's own
26604
+ * state change. No phase machine is involved.
26605
+ *
26606
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26607
+ *
26608
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26609
+ * phase machine is the sole writer for a camera. It is not.
26610
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26611
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26612
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26613
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26614
+ * two authorities can disagree about one slice, which this repo
26615
+ * forbids, and the doc said otherwise — which is worse than saying
26616
+ * nothing, because it reads as verification.
26617
+ *
26618
+ * This predates D475 and is not fixed there: the fix touches every
26619
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26620
+ * "sole writer" wording without also removing the other writers.
26484
26621
  */
26485
26622
  autoClearAfterMs: number().nullable()
26486
26623
  });
package/dist/addon.mjs CHANGED
@@ -7303,6 +7303,23 @@ function errMsg(err) {
7303
7303
  if (typeof err === "string") return err;
7304
7304
  return String(err);
7305
7305
  }
7306
+ new Set([
7307
+ "track",
7308
+ "summary",
7309
+ "face",
7310
+ "identity",
7311
+ "plate",
7312
+ "vehicle",
7313
+ "scene",
7314
+ "motion",
7315
+ "object",
7316
+ "audio"
7317
+ ]);
7318
+ new Set([
7319
+ "motion",
7320
+ "object",
7321
+ "audio"
7322
+ ]);
7306
7323
  var EncodeProfileSchema = object({
7307
7324
  video: object({
7308
7325
  codec: _enum([
@@ -12401,8 +12418,17 @@ method(object({
12401
12418
  }), array(SettingsRecordSchema).readonly()), method(object({
12402
12419
  namespace: string().optional(),
12403
12420
  collection: string(),
12404
- record: SettingsRecordSchema
12405
- }), _void(), { kind: "mutation" }), method(object({
12421
+ record: object({
12422
+ id: string().optional(),
12423
+ data: record(string(), unknown())
12424
+ })
12425
+ }), object({
12426
+ /**
12427
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12428
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12429
+ * primary key — which is the only place an auto key is knowable.
12430
+ */
12431
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12406
12432
  namespace: string().optional(),
12407
12433
  collection: string(),
12408
12434
  records: array(BulkRecordSchema).readonly()
@@ -12511,8 +12537,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12511
12537
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12512
12538
  namespace: string().optional(),
12513
12539
  collection: string(),
12514
- record: SettingsRecordSchema
12515
- }), _void(), {
12540
+ record: object({
12541
+ id: string().optional(),
12542
+ data: record(string(), unknown())
12543
+ })
12544
+ }), object({
12545
+ /**
12546
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12547
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12548
+ * primary key — which is the only place an auto key is knowable.
12549
+ */
12550
+ id: union([string(), number()]) }), {
12516
12551
  kind: "mutation",
12517
12552
  auth: "admin"
12518
12553
  }), method(object({
@@ -19235,7 +19270,20 @@ var TrackSchema = object({
19235
19270
  ...TrackRetrainFields
19236
19271
  });
19237
19272
  var BaseEventFields = {
19238
- id: string(),
19273
+ /**
19274
+ * A SQLite ROWID, assigned by the database (D474).
19275
+ *
19276
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19277
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19278
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19279
+ * the rowid: the table itself is that B-tree, so the index stops existing
19280
+ * rather than getting smaller. No shorter string does that.
19281
+ *
19282
+ * Defined once here for all three event kinds, which is why they move
19283
+ * together: a per-table migration would have forked this and
19284
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19285
+ */
19286
+ id: number().int(),
19239
19287
  deviceId: number(),
19240
19288
  timestamp: number()
19241
19289
  };
@@ -19254,7 +19302,34 @@ var MotionEventSchema = object({
19254
19302
  /** Omitted in slim projection. */
19255
19303
  frameHeight: number().optional(),
19256
19304
  /** Populated by B5 (recording playback URL for this event). */
19257
- mediaUrl: string().optional()
19305
+ mediaUrl: string().optional(),
19306
+ /**
19307
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19308
+ * episode is still open — a further rising edge extends it in place rather
19309
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19310
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19311
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19312
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19313
+ * motion for an instantaneous trigger).
19314
+ *
19315
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19316
+ * "closed the old way, before this column existed", never "still open".
19317
+ * Nothing in this codebase may read an absent `durationMs` as an open
19318
+ * episode; only `null` means open.
19319
+ */
19320
+ durationMs: number().nullable().optional(),
19321
+ /**
19322
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19323
+ * first entry is always `0`) of every genuine off→on transition the
19324
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19325
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19326
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19327
+ * explicit `false` mid-episode and then resumes before the quiet window
19328
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19329
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19330
+ * which must never be read as "no episode happened here".
19331
+ */
19332
+ edges: array(number()).readonly().optional()
19258
19333
  });
19259
19334
  /**
19260
19335
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19309,6 +19384,23 @@ var ObjectEventSchema = object({
19309
19384
  * includes it (it is light). Absent on rows written before this field.
19310
19385
  */
19311
19386
  frameId: string().optional(),
19387
+ /**
19388
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19389
+ * (D474).
19390
+ *
19391
+ * Only the package detector writes it, and it exists because the event id
19392
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19393
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19394
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19395
+ * assigned by SQLite, so that key had to move off the primary key rather
19396
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19397
+ * every parcel on every boot.
19398
+ *
19399
+ * Absent on every other object event, and on every row written before this
19400
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19401
+ * not per row, and nothing addresses a row by it.
19402
+ */
19403
+ idempotencyKey: string().optional(),
19312
19404
  /** Omitted in slim projection. */
19313
19405
  trackId: string().optional(),
19314
19406
  className: string(),
@@ -26479,9 +26571,54 @@ object({
26479
26571
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26480
26572
  lastDetectedAt: number().nullable(),
26481
26573
  /**
26482
- * Ms after which `detected` auto-reverts to false if no fresh push
26483
- * arrives. Null means the provider leaves detected state until a
26484
- * native "clear" event.
26574
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26575
+ * `null` while false and on every `Sensor` device (D475) — see that
26576
+ * constant's doc for the one-authority rule.
26577
+ *
26578
+ * ## Reading this field still arms nothing
26579
+ *
26580
+ * It reads like an instruction to the consumer ("revert after N ms if
26581
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26582
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26583
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26584
+ * imported constant, not as a read of `device.state.motion.value`, so this
26585
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26586
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26587
+ * field would add a second falling-edge authority beside whichever one
26588
+ * already owns the device, and two that can disagree are worse than one.
26589
+ * Consumers that need a falling edge SHAPED differently — held open across
26590
+ * a flapping source — debounce on their own side and say so, as
26591
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26592
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26593
+ *
26594
+ * ## Who writes it
26595
+ *
26596
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26597
+ * `cooldown_expired`, which then writes this slice with
26598
+ * `detected: false` (`handlePhaseChanged` in
26599
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26600
+ * matters most for the sources that only ever push a rising one:
26601
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26602
+ * a false.
26603
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26604
+ * provider pushes the false itself, from the upstream system's own
26605
+ * state change. No phase machine is involved.
26606
+ *
26607
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26608
+ *
26609
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26610
+ * phase machine is the sole writer for a camera. It is not.
26611
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26612
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26613
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26614
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26615
+ * two authorities can disagree about one slice, which this repo
26616
+ * forbids, and the doc said otherwise — which is worse than saying
26617
+ * nothing, because it reads as verification.
26618
+ *
26619
+ * This predates D475 and is not fixed there: the fix touches every
26620
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26621
+ * "sole writer" wording without also removing the other writers.
26485
26622
  */
26486
26623
  autoClearAfterMs: number().nullable()
26487
26624
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-onvif",
3
- "version": "1.2.96",
3
+ "version": "1.2.98",
4
4
  "description": "ONVIF camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",