@camstack/addon-export-google 0.1.61 → 0.1.63

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.
@@ -7377,8 +7377,23 @@ function errMsg(err) {
7377
7377
  if (typeof err === "string") return err;
7378
7378
  return String(err);
7379
7379
  }
7380
- //#endregion
7381
- //#region ../types/dist/index.mjs
7380
+ new Set([
7381
+ "track",
7382
+ "summary",
7383
+ "face",
7384
+ "identity",
7385
+ "plate",
7386
+ "vehicle",
7387
+ "scene",
7388
+ "motion",
7389
+ "object",
7390
+ "audio"
7391
+ ]);
7392
+ new Set([
7393
+ "motion",
7394
+ "object",
7395
+ "audio"
7396
+ ]);
7382
7397
  /**
7383
7398
  * Build an `IAddonRouteProvider` from a list of routes. Implements
7384
7399
  * both the operator-facing `getRoutes` (returning route descriptors
@@ -12642,8 +12657,17 @@ method(object({
12642
12657
  }), array(SettingsRecordSchema).readonly()), method(object({
12643
12658
  namespace: string().optional(),
12644
12659
  collection: string(),
12645
- record: SettingsRecordSchema
12646
- }), _void(), { kind: "mutation" }), method(object({
12660
+ record: object({
12661
+ id: string().optional(),
12662
+ data: record(string(), unknown())
12663
+ })
12664
+ }), object({
12665
+ /**
12666
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12667
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12668
+ * primary key — which is the only place an auto key is knowable.
12669
+ */
12670
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12647
12671
  namespace: string().optional(),
12648
12672
  collection: string(),
12649
12673
  records: array(BulkRecordSchema).readonly()
@@ -12752,8 +12776,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12752
12776
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12753
12777
  namespace: string().optional(),
12754
12778
  collection: string(),
12755
- record: SettingsRecordSchema
12756
- }), _void(), {
12779
+ record: object({
12780
+ id: string().optional(),
12781
+ data: record(string(), unknown())
12782
+ })
12783
+ }), object({
12784
+ /**
12785
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12786
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12787
+ * primary key — which is the only place an auto key is knowable.
12788
+ */
12789
+ id: union([string(), number()]) }), {
12757
12790
  kind: "mutation",
12758
12791
  auth: "admin"
12759
12792
  }), method(object({
@@ -19436,7 +19469,20 @@ var TrackSchema = object({
19436
19469
  ...TrackRetrainFields
19437
19470
  });
19438
19471
  var BaseEventFields = {
19439
- id: string(),
19472
+ /**
19473
+ * A SQLite ROWID, assigned by the database (D474).
19474
+ *
19475
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19476
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19477
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19478
+ * the rowid: the table itself is that B-tree, so the index stops existing
19479
+ * rather than getting smaller. No shorter string does that.
19480
+ *
19481
+ * Defined once here for all three event kinds, which is why they move
19482
+ * together: a per-table migration would have forked this and
19483
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19484
+ */
19485
+ id: number().int(),
19440
19486
  deviceId: number(),
19441
19487
  timestamp: number()
19442
19488
  };
@@ -19455,7 +19501,34 @@ var MotionEventSchema = object({
19455
19501
  /** Omitted in slim projection. */
19456
19502
  frameHeight: number().optional(),
19457
19503
  /** Populated by B5 (recording playback URL for this event). */
19458
- mediaUrl: string().optional()
19504
+ mediaUrl: string().optional(),
19505
+ /**
19506
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19507
+ * episode is still open — a further rising edge extends it in place rather
19508
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19509
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19510
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19511
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19512
+ * motion for an instantaneous trigger).
19513
+ *
19514
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19515
+ * "closed the old way, before this column existed", never "still open".
19516
+ * Nothing in this codebase may read an absent `durationMs` as an open
19517
+ * episode; only `null` means open.
19518
+ */
19519
+ durationMs: number().nullable().optional(),
19520
+ /**
19521
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19522
+ * first entry is always `0`) of every genuine off→on transition the
19523
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19524
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19525
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19526
+ * explicit `false` mid-episode and then resumes before the quiet window
19527
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19528
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19529
+ * which must never be read as "no episode happened here".
19530
+ */
19531
+ edges: array(number()).readonly().optional()
19459
19532
  });
19460
19533
  /**
19461
19534
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19510,6 +19583,23 @@ var ObjectEventSchema = object({
19510
19583
  * includes it (it is light). Absent on rows written before this field.
19511
19584
  */
19512
19585
  frameId: string().optional(),
19586
+ /**
19587
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19588
+ * (D474).
19589
+ *
19590
+ * Only the package detector writes it, and it exists because the event id
19591
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19592
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19593
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19594
+ * assigned by SQLite, so that key had to move off the primary key rather
19595
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19596
+ * every parcel on every boot.
19597
+ *
19598
+ * Absent on every other object event, and on every row written before this
19599
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19600
+ * not per row, and nothing addresses a row by it.
19601
+ */
19602
+ idempotencyKey: string().optional(),
19513
19603
  /** Omitted in slim projection. */
19514
19604
  trackId: string().optional(),
19515
19605
  className: string(),
@@ -26588,9 +26678,54 @@ object({
26588
26678
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26589
26679
  lastDetectedAt: number().nullable(),
26590
26680
  /**
26591
- * Ms after which `detected` auto-reverts to false if no fresh push
26592
- * arrives. Null means the provider leaves detected state until a
26593
- * native "clear" event.
26681
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26682
+ * `null` while false and on every `Sensor` device (D475) — see that
26683
+ * constant's doc for the one-authority rule.
26684
+ *
26685
+ * ## Reading this field still arms nothing
26686
+ *
26687
+ * It reads like an instruction to the consumer ("revert after N ms if
26688
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26689
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26690
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26691
+ * imported constant, not as a read of `device.state.motion.value`, so this
26692
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26693
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26694
+ * field would add a second falling-edge authority beside whichever one
26695
+ * already owns the device, and two that can disagree are worse than one.
26696
+ * Consumers that need a falling edge SHAPED differently — held open across
26697
+ * a flapping source — debounce on their own side and say so, as
26698
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26699
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26700
+ *
26701
+ * ## Who writes it
26702
+ *
26703
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26704
+ * `cooldown_expired`, which then writes this slice with
26705
+ * `detected: false` (`handlePhaseChanged` in
26706
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26707
+ * matters most for the sources that only ever push a rising one:
26708
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26709
+ * a false.
26710
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26711
+ * provider pushes the false itself, from the upstream system's own
26712
+ * state change. No phase machine is involved.
26713
+ *
26714
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26715
+ *
26716
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26717
+ * phase machine is the sole writer for a camera. It is not.
26718
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26719
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26720
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26721
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26722
+ * two authorities can disagree about one slice, which this repo
26723
+ * forbids, and the doc said otherwise — which is worse than saying
26724
+ * nothing, because it reads as verification.
26725
+ *
26726
+ * This predates D475 and is not fixed there: the fix touches every
26727
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26728
+ * "sole writer" wording without also removing the other writers.
26594
26729
  */
26595
26730
  autoClearAfterMs: number().nullable()
26596
26731
  });
@@ -7373,8 +7373,23 @@ function errMsg(err) {
7373
7373
  if (typeof err === "string") return err;
7374
7374
  return String(err);
7375
7375
  }
7376
- //#endregion
7377
- //#region ../types/dist/index.mjs
7376
+ new Set([
7377
+ "track",
7378
+ "summary",
7379
+ "face",
7380
+ "identity",
7381
+ "plate",
7382
+ "vehicle",
7383
+ "scene",
7384
+ "motion",
7385
+ "object",
7386
+ "audio"
7387
+ ]);
7388
+ new Set([
7389
+ "motion",
7390
+ "object",
7391
+ "audio"
7392
+ ]);
7378
7393
  /**
7379
7394
  * Build an `IAddonRouteProvider` from a list of routes. Implements
7380
7395
  * both the operator-facing `getRoutes` (returning route descriptors
@@ -12638,8 +12653,17 @@ method(object({
12638
12653
  }), array(SettingsRecordSchema).readonly()), method(object({
12639
12654
  namespace: string().optional(),
12640
12655
  collection: string(),
12641
- record: SettingsRecordSchema
12642
- }), _void(), { kind: "mutation" }), method(object({
12656
+ record: object({
12657
+ id: string().optional(),
12658
+ data: record(string(), unknown())
12659
+ })
12660
+ }), object({
12661
+ /**
12662
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12663
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12664
+ * primary key — which is the only place an auto key is knowable.
12665
+ */
12666
+ id: union([string(), number()]) }), { kind: "mutation" }), method(object({
12643
12667
  namespace: string().optional(),
12644
12668
  collection: string(),
12645
12669
  records: array(BulkRecordSchema).readonly()
@@ -12748,8 +12772,17 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12748
12772
  }), array(SettingsRecordSchema).readonly(), { auth: "admin" }), method(object({
12749
12773
  namespace: string().optional(),
12750
12774
  collection: string(),
12751
- record: SettingsRecordSchema
12752
- }), _void(), {
12775
+ record: object({
12776
+ id: string().optional(),
12777
+ data: record(string(), unknown())
12778
+ })
12779
+ }), object({
12780
+ /**
12781
+ * The id the row ACTUALLY got (D473): the one supplied, the UUID minted
12782
+ * for an absent one, or the ROWID SQLite assigned on an `INTEGER`
12783
+ * primary key — which is the only place an auto key is knowable.
12784
+ */
12785
+ id: union([string(), number()]) }), {
12753
12786
  kind: "mutation",
12754
12787
  auth: "admin"
12755
12788
  }), method(object({
@@ -19432,7 +19465,20 @@ var TrackSchema = object({
19432
19465
  ...TrackRetrainFields
19433
19466
  });
19434
19467
  var BaseEventFields = {
19435
- id: string(),
19468
+ /**
19469
+ * A SQLite ROWID, assigned by the database (D474).
19470
+ *
19471
+ * Was a 36-character UUID and cost 263 MB of a 1 117 MB database — paid
19472
+ * TWICE per row, in the row and in the primary-key index, across 2.1 million
19473
+ * motion, audio and object events. An `INTEGER PRIMARY KEY` in SQLite **is**
19474
+ * the rowid: the table itself is that B-tree, so the index stops existing
19475
+ * rather than getting smaller. No shorter string does that.
19476
+ *
19477
+ * Defined once here for all three event kinds, which is why they move
19478
+ * together: a per-table migration would have forked this and
19479
+ * `COMMON_BASE_COLUMNS` and reunited them two stages later.
19480
+ */
19481
+ id: number().int(),
19436
19482
  deviceId: number(),
19437
19483
  timestamp: number()
19438
19484
  };
@@ -19451,7 +19497,34 @@ var MotionEventSchema = object({
19451
19497
  /** Omitted in slim projection. */
19452
19498
  frameHeight: number().optional(),
19453
19499
  /** Populated by B5 (recording playback URL for this event). */
19454
- mediaUrl: string().optional()
19500
+ mediaUrl: string().optional(),
19501
+ /**
19502
+ * One row per motion EPISODE, not one per push (D475). `null` while the
19503
+ * episode is still open — a further rising edge extends it in place rather
19504
+ * than inserting a new row. Set once, at close, to `lastOnAt - startedAt`
19505
+ * (the span from the first rising edge to the LAST one, deliberately NOT
19506
+ * `closedAt - startedAt` — the close delay is a quiet CONFIRMATION, not
19507
+ * movement, and folding it in would report `MOTION_CLOSE_AFTER_MS` of
19508
+ * motion for an instantaneous trigger).
19509
+ *
19510
+ * **Absent** (not merely `null`) on a row written before D475 — that means
19511
+ * "closed the old way, before this column existed", never "still open".
19512
+ * Nothing in this codebase may read an absent `durationMs` as an open
19513
+ * episode; only `null` means open.
19514
+ */
19515
+ durationMs: number().nullable().optional(),
19516
+ /**
19517
+ * Ms offsets from `timestamp` (the episode's own first rising edge, so the
19518
+ * first entry is always `0`) of every genuine off→on transition the
19519
+ * episode saw — "ogni evento on si deve salvare" (D475). NOT one entry per
19520
+ * push: a firmware source that keepalives at ~1 Hz for the whole burst
19521
+ * (Reolink, Hikvision) produces exactly one edge; a source that reports an
19522
+ * explicit `false` mid-episode and then resumes before the quiet window
19523
+ * elapses produces another. Stored compactly — see `motion-edge-codec.ts`
19524
+ * — and decoded back to this shape on read. Absent/empty on a legacy row,
19525
+ * which must never be read as "no episode happened here".
19526
+ */
19527
+ edges: array(number()).readonly().optional()
19455
19528
  });
19456
19529
  /**
19457
19530
  * Which detection SOURCE produced an object event. `pipeline` = the ML
@@ -19506,6 +19579,23 @@ var ObjectEventSchema = object({
19506
19579
  * includes it (it is light). Absent on rows written before this field.
19507
19580
  */
19508
19581
  frameId: string().optional(),
19582
+ /**
19583
+ * A PRODUCER-chosen key that makes a synthetic event's emission idempotent
19584
+ * (D474).
19585
+ *
19586
+ * Only the package detector writes it, and it exists because the event id
19587
+ * stopped being choosable: the delivery and pick-up rows used to BE their
19588
+ * dedupe key (`pa-pkg-<entryId>-delivered`), which is how "never emit a
19589
+ * second delivery for this entry" survived a restart. An `INTEGER` rowid is
19590
+ * assigned by SQLite, so that key had to move off the primary key rather
19591
+ * than be dropped — a detector that cannot recognise its own row re-delivers
19592
+ * every parcel on every boot.
19593
+ *
19594
+ * Absent on every other object event, and on every row written before this
19595
+ * field. Never a substitute for `id`: it is unique per (producer, occasion),
19596
+ * not per row, and nothing addresses a row by it.
19597
+ */
19598
+ idempotencyKey: string().optional(),
19509
19599
  /** Omitted in slim projection. */
19510
19600
  trackId: string().optional(),
19511
19601
  className: string(),
@@ -26584,9 +26674,54 @@ object({
26584
26674
  /** Ms epoch of the last detected-true observation. Null if never detected. */
26585
26675
  lastDetectedAt: number().nullable(),
26586
26676
  /**
26587
- * Ms after which `detected` auto-reverts to false if no fresh push
26588
- * arrives. Null means the provider leaves detected state until a
26589
- * native "clear" event.
26677
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
26678
+ * `null` while false and on every `Sensor` device (D475) — see that
26679
+ * constant's doc for the one-authority rule.
26680
+ *
26681
+ * ## Reading this field still arms nothing
26682
+ *
26683
+ * It reads like an instruction to the consumer ("revert after N ms if
26684
+ * no fresh push arrives") and it is not one: nothing in this repo reads
26685
+ * the LIVE cap value to drive a timer. `pipeline-analytics`'s motion-episode
26686
+ * close DOES now use the same number — `MOTION_CLOSE_AFTER_MS` — but as an
26687
+ * imported constant, not as a read of `device.state.motion.value`, so this
26688
+ * field stays what it always was: DESCRIPTIVE output, mirroring an answer
26689
+ * computed elsewhere. Building a self-clear timer out of a READ of this
26690
+ * field would add a second falling-edge authority beside whichever one
26691
+ * already owns the device, and two that can disagree are worse than one.
26692
+ * Consumers that need a falling edge SHAPED differently — held open across
26693
+ * a flapping source — debounce on their own side and say so, as
26694
+ * `addon-export-alexa/src/motion-clear-hold.ts` and
26695
+ * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
26696
+ *
26697
+ * ## Who writes it
26698
+ *
26699
+ * - **Cameras** — the runner's phase machine, `active → watching` on
26700
+ * `cooldown_expired`, which then writes this slice with
26701
+ * `detected: false` (`handlePhaseChanged` in
26702
+ * `pipeline-runner/index.ts`). It produces the FALLING edge, which
26703
+ * matters most for the sources that only ever push a rising one:
26704
+ * Reolink emits `MotionOnMotionChanged { detected: true }` and never
26705
+ * a false.
26706
+ * - **Sensors** (Home Assistant binary sensors, Homematic) — the
26707
+ * provider pushes the false itself, from the upstream system's own
26708
+ * state change. No phase machine is involved.
26709
+ *
26710
+ * ### The phase machine is CANONICAL, not sole — and that is a defect
26711
+ *
26712
+ * An earlier revision of this docblock (mine, 2026-09-12) claimed the
26713
+ * phase machine is the sole writer for a camera. It is not.
26714
+ * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
26715
+ * `setCapSlice(motionCapability, …)` on their own rising edge, and
26716
+ * Hikvision's comment says why: it read THIS docblock, agreed the
26717
+ * runner is canonical, and wrote anyway to avoid per-tick churn. So
26718
+ * two authorities can disagree about one slice, which this repo
26719
+ * forbids, and the doc said otherwise — which is worse than saying
26720
+ * nothing, because it reads as verification.
26721
+ *
26722
+ * This predates D475 and is not fixed there: the fix touches every
26723
+ * camera provider. Recorded in D475's Consequences. Do not restore the
26724
+ * "sole writer" wording without also removing the other writers.
26590
26725
  */
26591
26726
  autoClearAfterMs: number().nullable()
26592
26727
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-google",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "description": "Google Home export — hub-side smart-home fulfillment (SYNC / QUERY / EXECUTE / DISCONNECT) for the non-camera fleet, served over the hub's own OAuth account link. No Google credential is stored, sent or required.",
5
5
  "keywords": [
6
6
  "camstack",