@camstack/addon-notifiers 1.2.7 → 1.2.9

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
@@ -2,8 +2,34 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
5
27
  let node_zlib = require("node:zlib");
6
- //#region ../types/dist/event-category-BLcNejAE.mjs
28
+ let node_fs = require("node:fs");
29
+ let node_path = require("node:path");
30
+ node_path = __toESM(node_path);
31
+ let node_url = require("node:url");
32
+ //#region ../types/dist/event-category-Bz24uP1U.mjs
7
33
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
8
34
  EventCategory["SystemBoot"] = "system.boot";
9
35
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -274,6 +300,19 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
274
300
  */
275
301
  EventCategory["DeviceStateChanged"] = "device.state-changed";
276
302
  /**
303
+ * Frame occupancy for a camera CHANGED — a tracked object was gained or
304
+ * lost. Carries `{ deviceId, totalObjects, byClass, zones }`.
305
+ *
306
+ * Emitted only on a change, so a steady scene is silent. It exists so a
307
+ * client can stop polling `zoneAnalytics.getCurrentSnapshot`: that was the
308
+ * one live badge with no push signal at all, and it cost a request every
309
+ * four seconds per visible camera.
310
+ *
311
+ * Like every event it is telemetry and may be dropped ([D8]) — a consumer
312
+ * keeps a slow reconcile rather than trusting it alone.
313
+ */
314
+ EventCategory["ZoneAnalyticsOccupancyChanged"] = "zone-analytics.occupancy-changed";
315
+ /**
277
316
  * Cap event fired by every device that registers the `battery`
278
317
  * capability. Mirrors the cap definition's `onStatusChanged`. Carries
279
318
  * `{ deviceId, status: BatteryStatus }`. Subscribers (alert center,
@@ -7304,35 +7343,22 @@ function buildCapturingReply(envelope) {
7304
7343
  */
7305
7344
  var RecordingWeekdaySchema = number().int().min(0).max(6);
7306
7345
  var HHMM = /^([01]\d|2[0-3]):[0-5]\d$/;
7307
- var RecordingScheduleSchema = discriminatedUnion("kind", [object({ kind: literal("always") }), object({
7308
- kind: literal("timeOfDay"),
7309
- start: string().regex(HHMM),
7310
- end: string().regex(HHMM),
7311
- /** Restrict to these weekdays; omit = every day. */
7312
- days: array(RecordingWeekdaySchema).optional()
7313
- })]);
7314
- var RecordingModeSchema = _enum([
7315
- "continuous",
7316
- "onMotion",
7317
- "onAudioThreshold"
7318
- ]);
7319
7346
  /**
7320
- * First-class, authoritative per-camera storage mode — the explicit choice the
7321
- * UI reads directly (never inferred from `rules`):
7322
- * - `off` — not recording.
7323
- * - `events` — record only around triggers (motion / audio threshold),
7324
- * with pre/post-buffer.
7325
- * - `continuous` — record 24/7 within the schedule.
7347
+ * DERIVED per-camera storage summary — the single field cheap consumers read
7348
+ * (the viewer's status dot, the camera list) instead of walking `bands`:
7349
+ * - `off` — no band covers the camera (or it is disabled).
7350
+ * - `events` — every band records around triggers only.
7351
+ * - `continuous` — at least one band records continuously.
7326
7352
  *
7327
- * `mode` compiles one-way to the internal `rules[]` consumed by the policy
7328
- * engine (see `compileRules`); `rules[]` is never authored directly anymore.
7353
+ * NEVER authored: the recorder stamps it from the authoritative `bands` on
7354
+ * every save (`activeModeForConfig`). Writing it has no effect.
7329
7355
  */
7330
7356
  var RecordingStorageModeSchema = _enum([
7331
7357
  "off",
7332
7358
  "events",
7333
7359
  "continuous"
7334
7360
  ]);
7335
- /** Which detectors trigger an `events`-mode recording. */
7361
+ /** Which detectors trigger an `events`-mode band. */
7336
7362
  var RecordingTriggersSchema = object({
7337
7363
  motion: boolean().optional(),
7338
7364
  audioThresholdDbfs: number().optional()
@@ -7368,18 +7394,6 @@ var RecordingBandSchema = object({
7368
7394
  preBufferSec: number().min(0).optional(),
7369
7395
  postBufferSec: number().min(0).optional()
7370
7396
  });
7371
- var RecordingRuleSchema = object({
7372
- schedule: RecordingScheduleSchema,
7373
- mode: RecordingModeSchema,
7374
- /** Seconds of footage to retain BEFORE a trigger (applied at keep/discard). */
7375
- preBufferSec: number().min(0).default(0),
7376
- /** Keep recording until this many seconds after the last trigger. */
7377
- postBufferSec: number().min(0).default(0),
7378
- /** Each new trigger restarts the post-buffer window. */
7379
- resetTimeoutOnNewEvent: boolean().default(true),
7380
- /** onAudioThreshold only — dBFS level that counts as a trigger. */
7381
- thresholdDbfs: number().optional()
7382
- });
7383
7397
  /**
7384
7398
  * Per-device retention overrides. Every field is optional; an unset or `0`
7385
7399
  * value inherits the node-wide recorder default. Only footage-lifetime limits
@@ -7413,40 +7427,28 @@ var ScrubThumbnailPresetSchema = _enum([
7413
7427
  /**
7414
7428
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7415
7429
  *
7416
- * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
7417
- * are its mode-specific parameters. `rules` is a DEPRECATED authoring input kept
7418
- * only for transition + migration (`migrateRulesToMode`); the policy engine
7419
- * consumes the compiled output of `compileRules(config)`, never `rules` directly.
7430
+ * `bands` is the ONLY authored recording intent: what to record, when, and on
7431
+ * which trigger. `mode` is a derived summary the recorder stamps on save; every
7432
+ * other field is a storage knob (profiles, segment length, retention, scrub).
7433
+ *
7434
+ * STRICT on purpose: the legacy authoring surface (`schedule`/`schedules`/
7435
+ * `triggers`/`preBufferSec`/`postBufferSec`/`rules`) was retired 2026-07-30.
7436
+ * A stale caller must fail loudly — silently stripping its legacy intent would
7437
+ * persist a band-less config, i.e. silently stop recording the camera.
7420
7438
  */
7421
7439
  var RecordingConfigSchema = object({
7422
7440
  enabled: boolean(),
7423
- /** Authoritative storage mode. Absent on legacy targets derived once via
7424
- * `migrateRulesToMode`, then persisted. */
7441
+ /** DERIVED summary of `bands`, stamped by the recorder on every save.
7442
+ * Authoring it has no effect — see {@link RecordingStorageModeSchema}. */
7425
7443
  mode: RecordingStorageModeSchema.optional(),
7426
7444
  profiles: array(CamProfileSchema).optional(),
7427
7445
  segmentSeconds: number().int().positive().optional(),
7428
- /** Shared recording time-bands for `events` & `continuous` — record only when
7429
- * the wall-clock falls inside one of these windows. Omit or empty = always.
7430
- * `continuous` compiles to one rule per band; `events` to band × trigger. */
7431
- schedules: array(RecordingScheduleSchema).optional(),
7432
- /** Legacy single-band predecessor of `schedules`. Read-compat only — it is
7433
- * normalized into `schedules` on read and never written going forward. (Not
7434
- * tagged `@deprecated`: the normalization paths must read it cast-free.) */
7435
- schedule: RecordingScheduleSchema.optional(),
7436
- /** `events`-mode only — which detectors trigger a recording. */
7437
- triggers: RecordingTriggersSchema.optional(),
7438
- /** `events`-mode only — seconds retained before / after a trigger. */
7439
- preBufferSec: number().min(0).optional(),
7440
- postBufferSec: number().min(0).optional(),
7441
- /** DEPRECATED authoring input; retained for migration/transition. */
7442
- rules: array(RecordingRuleSchema).optional(),
7443
7446
  /**
7444
- * AUTHORITATIVE mode-per-band recording model (recorder). When present it
7445
- * is the single source of truth; the legacy `mode`/`schedules`/`schedule`/
7446
- * `triggers`/`rules` fields above are kept for READ-COMPAT only and are
7447
- * derived into bands once via `migrateConfigToBands`.
7447
+ * AUTHORITATIVE mode-per-band recording model the single source of truth
7448
+ * the recorder's band engine consumes. An empty array = record nothing;
7449
+ * "off" is the absence of a covering band, never a band value.
7448
7450
  */
7449
- bands: array(RecordingBandSchema).optional(),
7451
+ bands: array(RecordingBandSchema).default([]),
7450
7452
  retention: RecordingRetentionSchema.optional(),
7451
7453
  /**
7452
7454
  * Per-camera scrub-thumbnail fidelity preset (resolution + JPEG quality for
@@ -7454,8 +7456,15 @@ var RecordingConfigSchema = object({
7454
7456
  * windows only — existing sheets are immutable, and each window's index
7455
7457
  * carries its own tile dims so mixed-preset history renders correctly.
7456
7458
  */
7457
- scrubThumbnails: ScrubThumbnailPresetSchema.optional()
7458
- });
7459
+ scrubThumbnails: ScrubThumbnailPresetSchema.optional(),
7460
+ /**
7461
+ * OPT-IN thumbnail-strip generation for this camera: every keyframe of the
7462
+ * low recording saved as a JPEG (the fast-drag scrub depth), a derived
7463
+ * cache that eviction reclaims with the footage. Absent/false = no strips
7464
+ * are written and scrub reads exact keyframes at every velocity.
7465
+ */
7466
+ stripsEnabled: boolean().optional()
7467
+ }).strict();
7459
7468
  /**
7460
7469
  * Ops-log — the durable, append-only operations audit shared by the
7461
7470
  * recordings and events management surfaces.
@@ -7474,7 +7483,8 @@ var OpsLogOpSchema = _enum([
7474
7483
  "prune",
7475
7484
  "manual-delete",
7476
7485
  "rescan",
7477
- "retention-run"
7486
+ "retention-run",
7487
+ "relocate"
7478
7488
  ]);
7479
7489
  /** Why the operation ran. */
7480
7490
  var OpsLogReasonSchema = _enum([
@@ -7513,6 +7523,55 @@ var OpsLogQueryInputSchema = object({
7513
7523
  limit: number().int().min(1).max(1e3).optional()
7514
7524
  });
7515
7525
  /**
7526
+ * Entity-relocation job state (storage entity-routing spec, Phase 4).
7527
+ *
7528
+ * One shape shared by the recorder's `relocateFootage` (segments + strips) and
7529
+ * pipeline-analytics' `relocateMedia` (event media blobs) so the admin Data
7530
+ * page renders both movers with one component. Jobs are in-RAM (a restart
7531
+ * forgets them — re-running is safe by construction: copy-if-absent, delete
7532
+ * after verify) and each completed/failed run also lands one durable ops-log
7533
+ * row on the owning addon's surface.
7534
+ */
7535
+ var RelocateJobStateSchema = _enum([
7536
+ "running",
7537
+ "done",
7538
+ "failed",
7539
+ "cancelled"
7540
+ ]);
7541
+ var RelocateJobSchema = object({
7542
+ jobId: string(),
7543
+ state: RelocateJobStateSchema,
7544
+ /** Source location — for media relocation this is informational ('*': rows
7545
+ * move from wherever they are to the target). */
7546
+ fromLocationId: string(),
7547
+ toLocationId: string(),
7548
+ /** Scoped device, or null = every device. */
7549
+ deviceId: number().nullable(),
7550
+ /** What the job moves (owner-addon specific: segments/strips or media). */
7551
+ entities: array(string()),
7552
+ filesMoved: number().int(),
7553
+ bytesMoved: number().int(),
7554
+ /** Total files discovered up front; null while (or when) unknown. */
7555
+ filesTotal: number().int().nullable(),
7556
+ startedAt: number(),
7557
+ finishedAt: number().nullable(),
7558
+ error: string().nullable()
7559
+ });
7560
+ var RelocateFootageInputSchema = object({
7561
+ deviceId: number().optional(),
7562
+ fromLocationId: string(),
7563
+ toLocationId: string(),
7564
+ entities: array(_enum(["segments", "strips"])).optional(),
7565
+ /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7566
+ * never allowed to starve live writers. */
7567
+ throttleMbps: number().min(1).max(1e3).optional()
7568
+ });
7569
+ var RelocateMediaInputSchema = object({
7570
+ deviceId: number().optional(),
7571
+ toLocationId: string(),
7572
+ throttleMbps: number().min(1).max(1e3).optional()
7573
+ });
7574
+ /**
7516
7575
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
7517
7576
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
7518
7577
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -7562,6 +7621,13 @@ var StorageLocationSchema = object({
7562
7621
  nodeId: string().optional(),
7563
7622
  isDefault: boolean().default(false),
7564
7623
  isSystem: boolean().default(false),
7624
+ /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7625
+ * for node-local locations it can reach) — never persisted, absent when the
7626
+ * volume is remote/unreachable. The single capacity truth every UI reads. */
7627
+ capacity: object({
7628
+ totalBytes: number(),
7629
+ availableBytes: number()
7630
+ }).nullable().optional(),
7565
7631
  createdAt: number(),
7566
7632
  updatedAt: number()
7567
7633
  });
@@ -8329,7 +8395,8 @@ var NcTaxonomyEntrySchema = object({
8329
8395
  /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8330
8396
  parentKind: string().nullable()
8331
8397
  });
8332
- object({
8398
+ /** The complete NC picker taxonomy — three grouped buckets. */
8399
+ var NcTaxonomySchema = object({
8333
8400
  videoClasses: array(NcTaxonomyEntrySchema),
8334
8401
  audioKinds: array(NcTaxonomyEntrySchema),
8335
8402
  labels: array(NcTaxonomyEntrySchema)
@@ -9052,9 +9119,20 @@ var DEGRADE_ORDER = {
9052
9119
  "markdown"
9053
9120
  ]
9054
9121
  };
9055
- /** Pick the best target format the kind supports for a given source format. */
9122
+ /**
9123
+ * Pick the best target format the kind supports for a given source format.
9124
+ *
9125
+ * TOLERANT of a source outside the union. `NotificationSchema.format` carries
9126
+ * `.default('text')`, but that default only runs where the schema is PARSED —
9127
+ * the tRPC router. A cap call arriving from another addon (`ctx.api`) skips
9128
+ * that parse, so `format` reaches here `undefined`, and the bare
9129
+ * `DEGRADE_ORDER[source]` threw `is not iterable`. That broke the one promise
9130
+ * the degrade path makes ("never throws — degradation is reported, never
9131
+ * surfaced as an error") and dead-lettered every Notification-Center delivery
9132
+ * for a day (2026-07-30). An unknown source degrades like `text`.
9133
+ */
9056
9134
  function resolveFormat(source, supported) {
9057
- for (const candidate of DEGRADE_ORDER[source]) if (supported.includes(candidate)) return candidate;
9135
+ for (const candidate of DEGRADE_ORDER[source] ?? DEGRADE_ORDER.text) if (supported.includes(candidate)) return candidate;
9058
9136
  return supported[0] ?? "text";
9059
9137
  }
9060
9138
  /** Transcode a body between formats. */
@@ -9099,7 +9177,7 @@ function resolveLevel(levels, n) {
9099
9177
  })[0]);
9100
9178
  }
9101
9179
  function splitBody(body, maxLen) {
9102
- if (maxLen <= 0 || body.length <= maxLen) return [body];
9180
+ if (!Number.isFinite(maxLen) || maxLen <= 0 || body.length <= maxLen) return [body];
9103
9181
  const parts = [];
9104
9182
  for (let i = 0; i < body.length; i += maxLen) parts.push(body.slice(i, i + maxLen));
9105
9183
  return parts;
@@ -9182,6 +9260,7 @@ function prepareNotification(caps, n) {
9182
9260
  renderedAs
9183
9261
  };
9184
9262
  }
9263
+ new Set(["devices", "classes"]);
9185
9264
  /**
9186
9265
  * Shared geometry vocabulary for on-frame shape caps — privacy-mask,
9187
9266
  * motion-zones, and the detection zones/lines editor all speak this one
@@ -9340,6 +9419,29 @@ var NcOccupancyConditionSchema = object({
9340
9419
  count: number().int().min(0).default(1),
9341
9420
  sustainSeconds: number().int().min(0).max(3600).default(15)
9342
9421
  });
9422
+ /**
9423
+ * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
9424
+ *
9425
+ * The values are not symmetric, and deliberately so — the absent value has to
9426
+ * mean exactly what every rule authored before this condition existed already
9427
+ * does:
9428
+ * - `enter` — entries and every NON-crossing record (movement state,
9429
+ * package, sensor). Exits are rejected. **This is the absent behaviour**:
9430
+ * an operator who never asked for exits must not start receiving them.
9431
+ * - `exit` — ONLY an exit crossing. A record that is not a crossing at all
9432
+ * fails closed, because "the car left the drive" is a question about a
9433
+ * boundary, not about a detection.
9434
+ * - `any` — no direction filter; entries, exits and non-crossings alike.
9435
+ *
9436
+ * A rule asking for a direction should normally also scope `zones`, which the
9437
+ * engine evaluates against the crossed zone as well as the current membership
9438
+ * (an exit's membership no longer contains the zone it just left).
9439
+ */
9440
+ var NcCrossingSchema = _enum([
9441
+ "enter",
9442
+ "exit",
9443
+ "any"
9444
+ ]);
9343
9445
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
9344
9446
  var NcZoneConditionSchema = object({
9345
9447
  ids: array(string().min(1)).min(1),
@@ -9364,6 +9466,13 @@ var NcConditionsSchema = object({
9364
9466
  /** Veto zones — any hit fails the rule. */
9365
9467
  zonesExclude: array(string().min(1)).optional(),
9366
9468
  /**
9469
+ * Zone-crossing direction. IMMEDIATE only — a crossing is a per-event fact
9470
+ * and a closed track carries none, so a `track-end` rule asking for one
9471
+ * fails closed (use `zones`, which tests `zonesVisited`). ABSENT = `enter`,
9472
+ * which is exactly today's behaviour. See {@link NcCrossingSchema}.
9473
+ */
9474
+ crossing: NcCrossingSchema.optional(),
9475
+ /**
9367
9476
  * Exact (case-insensitive) match on the record's collapsed `label`
9368
9477
  * (identity name / plate text / subclass).
9369
9478
  */
@@ -9498,17 +9607,85 @@ var NcRuleTargetSchema = object({
9498
9607
  * - `keyFrame` — the clean scene frame (no subject box).
9499
9608
  * - `none` — no attachment.
9500
9609
  */
9501
- var NcMediaPolicySchema = object({ attach: _enum([
9502
- "best",
9503
- "best-matching",
9504
- "keyFrame",
9505
- "none"
9506
- ]).default("best") });
9610
+ /**
9611
+ * WHAT THE PICTURE SHOWS — chosen explicitly, because the implicit ladders
9612
+ * conflate it with the selection strategy and betray the request: asking for
9613
+ * the clean scene frame on an object-event owner used to start at
9614
+ * `fullFrameBoxed`, i.e. the annotated frame (2026-07-30).
9615
+ * - `cropped` — the subject, tight. What "who is at the door" wants.
9616
+ * - `full` — the clean scene, no annotation. What "what is going on" wants.
9617
+ * - `boxed` — the scene WITH the detection boxes drawn, for verifying what
9618
+ * the pipeline actually saw.
9619
+ */
9620
+ var NcMediaFrameSchema = _enum([
9621
+ "cropped",
9622
+ "full",
9623
+ "boxed"
9624
+ ]);
9625
+ var NcMediaPolicySchema = object({
9626
+ attach: _enum([
9627
+ "best",
9628
+ "best-matching",
9629
+ "keyFrame",
9630
+ "none"
9631
+ ]).default("best"),
9632
+ /** What the still shows. Absent = `cropped` (the historical `best` shape). */
9633
+ frame: NcMediaFrameSchema.optional(),
9634
+ /** Crop the attached still to the rule's condition-zone bbox (padded) —
9635
+ * "show me the ZONE", not the whole scene or the subject crop. */
9636
+ zoneCrop: boolean().optional(),
9637
+ /**
9638
+ * Also attach a short GIF cut from the stream broker's clip ring around the
9639
+ * event — NOT from the recording, so the camera does not have to be
9640
+ * recording, and the window sits AROUND the moment instead of a segment
9641
+ * behind it. Fail-closed: a window the ring does not cover contributes no
9642
+ * gif, never a failed notification.
9643
+ */
9644
+ gif: boolean().optional(),
9645
+ /**
9646
+ * Also attach a short MP4 CLIP of the same cut. Same source and the same
9647
+ * fail-closed rule as `gif`. Prefer it where the backend takes video
9648
+ * (telegram, discord, zentik, webhook); backends that do not are handled by
9649
+ * the degrade engine, which drops the video and keeps the still.
9650
+ */
9651
+ clip: boolean().optional(),
9652
+ /** Seconds of footage BEFORE / AFTER the event instant. Defaults 3 / 7. */
9653
+ clipPreRollSec: number().int().min(0).max(30).optional(),
9654
+ clipPostRollSec: number().int().min(0).max(30).optional(),
9655
+ /**
9656
+ * Which stream profile the footage is cut from. Absent = the CHEAPEST
9657
+ * assigned profile: a notification is watched on a phone, so the 4K
9658
+ * rendition would burn CPU to produce a file the client downscales anyway.
9659
+ * A profile that is not assigned falls back to the cheapest, and the render
9660
+ * reports which one actually ran.
9661
+ */
9662
+ profile: CamProfileSchema.optional()
9663
+ });
9664
+ /**
9665
+ * Cooldown GRANULARITY over the subject's class — how much a fired
9666
+ * notification suppresses.
9667
+ * - `shared` (default, and the absent value) — one window for the whole
9668
+ * rule/scope: a cat silences the next dog for `cooldownSec`.
9669
+ * - `per-class` — an independent window per detected class, so cat→dog fires
9670
+ * at once and cat→cat still waits.
9671
+ *
9672
+ * AUDIO subjects are ALWAYS per-class regardless of this setting: a scream
9673
+ * must not be swallowed by a bark's window (the precedent this generalizes —
9674
+ * see `cooldownKey` in the rule engine).
9675
+ */
9676
+ var NcThrottleGranularitySchema = _enum(["shared", "per-class"]);
9507
9677
  /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
9508
9678
  var NcThrottleSchema = object({
9509
9679
  cooldownSec: number().int().min(0).max(86400).default(60),
9510
9680
  /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
9511
- scope: _enum(["rule", "rule-device"]).default("rule-device")
9681
+ scope: _enum(["rule", "rule-device"]).default("rule-device"),
9682
+ /**
9683
+ * Class granularity of the cooldown key. Optional rather than defaulted:
9684
+ * a Zod default does NOT run on the addon→addon cap path, so a persisted
9685
+ * rule authored before this field simply carries none — and the engine
9686
+ * reads absent as `shared`, the pre-existing behaviour.
9687
+ */
9688
+ granularity: NcThrottleGranularitySchema.optional()
9512
9689
  });
9513
9690
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
9514
9691
  var NcRuleInputSchema = object({
@@ -9517,7 +9694,19 @@ var NcRuleInputSchema = object({
9517
9694
  delivery: NcDeliverySchema,
9518
9695
  conditions: NcConditionsSchema.default({}),
9519
9696
  schedule: NcScheduleSchema.optional(),
9520
- targets: array(NcRuleTargetSchema).min(1),
9697
+ /** May be empty when `targetUsers` addresses at least one user — the
9698
+ * "at least one addressee" invariant is enforced by the provider, because
9699
+ * a cross-field refine here would break `NcRulePatchSchema.partial()`. */
9700
+ targets: array(NcRuleTargetSchema),
9701
+ /**
9702
+ * USERS this rule addresses in addition to `targets` (Phase 4). At fire
9703
+ * time each user fans out to the personal targets they own
9704
+ * (`config.ownerUserId`), filtered by that user's `allowedDevices` for the
9705
+ * firing camera — a user is never notified about a device they cannot open.
9706
+ * Per-user opt-outs (`disabledTargetIds`) still apply to the fanned-out
9707
+ * targets.
9708
+ */
9709
+ targetUsers: array(string()).optional(),
9521
9710
  media: NcMediaPolicySchema.default({ attach: "best" }),
9522
9711
  throttle: NcThrottleSchema.default({
9523
9712
  cooldownSec: 60,
@@ -9604,6 +9793,7 @@ var NcConditionDescriptorSchema = object({
9604
9793
  "schedule",
9605
9794
  "plateMatcher",
9606
9795
  "packagePhase",
9796
+ "crossingSelect",
9607
9797
  "polygonDraw",
9608
9798
  "occupancy"
9609
9799
  ]),
@@ -9730,7 +9920,10 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
9730
9920
  }), object({ results: array(NcTestResultSchema) }), {
9731
9921
  kind: "mutation",
9732
9922
  auth: "admin"
9733
- }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9923
+ }), method(object({}), object({
9924
+ catalog: array(NcConditionDescriptorSchema),
9925
+ taxonomy: NcTaxonomySchema.optional()
9926
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
9734
9927
  /**
9735
9928
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
9736
9929
  *
@@ -10467,6 +10660,28 @@ method(object({
10467
10660
  }), object({ success: literal(true) }), {
10468
10661
  kind: "mutation",
10469
10662
  auth: "admin"
10663
+ }), method(object({
10664
+ deviceId: number(),
10665
+ /** Absent = the LOWEST assigned profile — a notification attachment is
10666
+ * watched on a phone, and the cheap rendition is the right default. */
10667
+ profile: CamProfileSchema.optional(),
10668
+ aroundMs: number(),
10669
+ preRollSec: number().min(0).max(20).default(3),
10670
+ postRollSec: number().min(0).max(20).default(5),
10671
+ format: _enum(["gif", "mp4"]).default("gif"),
10672
+ maxWidth: number().int().min(120).max(1920).default(480),
10673
+ /** GIF only — MP4 keeps the source cadence. */
10674
+ fps: number().int().min(1).max(15).default(5)
10675
+ }), object({
10676
+ base64: string(),
10677
+ mime: string(),
10678
+ bytes: number().int(),
10679
+ /** The profile actually rendered (what the default resolved to). */
10680
+ profile: CamProfileSchema,
10681
+ durationMs: number()
10682
+ }), {
10683
+ kind: "mutation",
10684
+ auth: "admin"
10470
10685
  }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
10471
10686
  probed: boolean(),
10472
10687
  summary: string()
@@ -16102,7 +16317,10 @@ method(object({
16102
16317
  }), method(object({
16103
16318
  deviceId: number(),
16104
16319
  caps: array(string()).readonly().optional()
16105
- }), record(string(), unknown().nullable()));
16320
+ }), record(string(), unknown().nullable())), method(object({
16321
+ deviceIds: array(number()).readonly(),
16322
+ caps: array(string()).readonly().optional()
16323
+ }), record(string(), record(string(), unknown().nullable())));
16106
16324
  method(object({ deviceId: number() }), record(string(), record(string(), unknown()))), method(object({
16107
16325
  deviceId: number(),
16108
16326
  capName: string()
@@ -17033,6 +17251,36 @@ var TargetKindSchema = object({
17033
17251
  icon: string(),
17034
17252
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
17035
17253
  addonId: string(),
17254
+ /**
17255
+ * URL of the kind's bundled BRAND icon, served by the providing addon over
17256
+ * its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
17257
+ * when the addon bundles no icon for that kind — the client then falls back
17258
+ * to a neutral glyph rather than rendering the raw `icon` NAME as text.
17259
+ *
17260
+ * Root-relative on purpose: it resolves against whatever origin serves a web
17261
+ * client, and a native client joins it onto its own hub base.
17262
+ *
17263
+ * DECLARED here deliberately. It used to travel as an undeclared passthrough
17264
+ * field that survived only because the runtime cap-router forwards provider
17265
+ * output verbatim — so every consumer had to re-declare it by hand to stop
17266
+ * its own Zod parse from stripping it, and the whole arrangement would have
17267
+ * broken silently the moment output validation was tightened anywhere.
17268
+ */
17269
+ iconUrl: string().optional(),
17270
+ /**
17271
+ * Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
17272
+ *
17273
+ * The server knows this and therefore says it, because the client cannot
17274
+ * safely guess: a React-Native client renders SVG and raster through two
17275
+ * DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
17276
+ * not decode SVG on iOS/Android), so without this it silently fell back to a
17277
+ * placeholder glyph for every vector icon while the web build looked fine.
17278
+ *
17279
+ * Absent when {@link iconUrl} is absent, or for a legacy provider that has
17280
+ * not been updated — a client that cannot determine the type should prefer
17281
+ * its raster path, which is the safe default for an unknown image.
17282
+ */
17283
+ iconMediaType: string().optional(),
17036
17284
  configSchema: ConfigSchemaPassthrough,
17037
17285
  supportsDiscovery: boolean(),
17038
17286
  caps: TargetKindCapsSchema
@@ -17494,6 +17742,29 @@ var MotionEventSchema = object({
17494
17742
  * Absent on legacy rows ⇒ treat as `pipeline`.
17495
17743
  */
17496
17744
  var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17745
+ /**
17746
+ * The confirmed zone crossing that produced an object event. Present ONLY on
17747
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17748
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17749
+ * appearance event carry none, so a rule asking for a direction fails closed
17750
+ * on them.
17751
+ *
17752
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17753
+ * into its own event, so a frame in which a track enters A while leaving B
17754
+ * produces two events with two directions — never one ambiguous row.
17755
+ *
17756
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17757
+ * membership the box has NOW, and by definition it no longer contains the zone
17758
+ * that was just left. Without the id here, a zone-scoped rule could never match
17759
+ * the exit it asked for.
17760
+ */
17761
+ var ZoneCrossingSchema = object({
17762
+ direction: _enum(["enter", "exit"]),
17763
+ /** Admin zone id crossed. */
17764
+ zoneId: string(),
17765
+ /** Zone display name at crossing time (falls back to the id). */
17766
+ zoneName: string().optional()
17767
+ });
17497
17768
  var ObjectEventSchema = object({
17498
17769
  ...BaseEventFields,
17499
17770
  kind: literal("object"),
@@ -17520,6 +17791,12 @@ var ObjectEventSchema = object({
17520
17791
  zones: array(string()).readonly().optional(),
17521
17792
  /** Omitted in slim projection. */
17522
17793
  state: TrackStateSchema.optional(),
17794
+ /**
17795
+ * The zone crossing this event IS, when it is one. Absent on every other
17796
+ * event kind (movement state, appearance, package) — see
17797
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
17798
+ */
17799
+ zoneCrossing: ZoneCrossingSchema.optional(),
17523
17800
  /** Detection-frame dimensions in pixels — let consumers normalize the
17524
17801
  * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17525
17802
  frameWidth: number().optional(),
@@ -17778,6 +18055,15 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17778
18055
  }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
17779
18056
  kind: "mutation",
17780
18057
  auth: "admin"
18058
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18059
+ kind: "mutation",
18060
+ auth: "admin"
18061
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
18062
+ kind: "query",
18063
+ auth: "admin"
18064
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18065
+ kind: "mutation",
18066
+ auth: "admin"
17781
18067
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
17782
18068
  kind: "query",
17783
18069
  auth: "admin"
@@ -20257,6 +20543,17 @@ var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
20257
20543
  */
20258
20544
  priority: number()
20259
20545
  })).readonly() });
20546
+ /**
20547
+ * The chosen outbound endpoint for notification artifacts. `baseUrl: null` =
20548
+ * AUTO (resolved from the candidate ranking at send time); `resolved` reports
20549
+ * what AUTO currently picks, so the UI can show the effective value either way.
20550
+ */
20551
+ var NotificationEndpointSchema = object({
20552
+ /** The operator's explicit choice, or null for AUTO. */
20553
+ baseUrl: string().nullable(),
20554
+ /** What the ranking currently resolves to (null when nothing is reachable). */
20555
+ resolved: string().nullable()
20556
+ });
20260
20557
  var AllowedAddressesSchema = object({
20261
20558
  /**
20262
20559
  * Allowlist of interface addresses operators have explicitly opted
@@ -20279,7 +20576,7 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
20279
20576
  * to avoid mixed-content blocks in the browser. The public
20280
20577
  * tunnel always emits `https://` regardless. */
20281
20578
  scheme: _enum(["http", "https"]).optional()
20282
- }), GetConnectionEndpointsResultSchema), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" });
20579
+ }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" });
20283
20580
  /**
20284
20581
  * mesh-network — collection cap for mesh-VPN providers.
20285
20582
  *
@@ -21078,7 +21375,12 @@ var RecordingDeviceUsageSchema = object({
21078
21375
  var RecordingLocationUsageSchema = object({
21079
21376
  /** StorageLocation id; null for the legacy/degraded single-root fallback. */
21080
21377
  locationId: string().nullable(),
21081
- /** Bytes of recordings stored on this location. */
21378
+ /** Every location id sharing this row's PHYSICAL volume (aliases). One row
21379
+ * is emitted per physical disk (2026-07-29): two locations on one root
21380
+ * previously rendered as two identical "disks" with a nonsensical used
21381
+ * split — hydrate attribution across aliases is arbitrary by nature. */
21382
+ locationIds: array(string()).optional(),
21383
+ /** Bytes of recordings stored on this PHYSICAL volume (all aliases). */
21082
21384
  usedBytes: number(),
21083
21385
  /** Free bytes on the location's volume; null when capacity is unknown (remote). */
21084
21386
  availableBytes: number().nullable(),
@@ -21190,6 +21492,44 @@ method(object({
21190
21492
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
21191
21493
  kind: "query",
21192
21494
  auth: "admin"
21495
+ }), method(object({
21496
+ deviceId: number(),
21497
+ aroundMs: number(),
21498
+ preRollSec: number().min(0).max(30).default(2),
21499
+ postRollSec: number().min(0).max(30).default(5),
21500
+ maxWidth: number().int().min(120).max(1280).default(480),
21501
+ fps: number().int().min(1).max(15).default(5)
21502
+ }), object({
21503
+ gifBase64: string(),
21504
+ fromMs: number(),
21505
+ toMs: number()
21506
+ }), {
21507
+ kind: "mutation",
21508
+ auth: "admin"
21509
+ }), method(object({
21510
+ deviceId: number(),
21511
+ aroundMs: number(),
21512
+ preRollSec: number().min(0).max(30).default(3),
21513
+ postRollSec: number().min(0).max(30).default(7),
21514
+ maxWidth: number().int().min(160).max(1920).default(640)
21515
+ }), object({
21516
+ clipBase64: string(),
21517
+ mime: string(),
21518
+ fromMs: number(),
21519
+ toMs: number(),
21520
+ bytes: number().int()
21521
+ }), {
21522
+ kind: "mutation",
21523
+ auth: "admin"
21524
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
21525
+ kind: "mutation",
21526
+ auth: "admin"
21527
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
21528
+ kind: "query",
21529
+ auth: "admin"
21530
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21531
+ kind: "mutation",
21532
+ auth: "admin"
21193
21533
  });
21194
21534
  /**
21195
21535
  * `recordingExport` cap — render a footage time range into a single downloadable
@@ -22781,6 +23121,12 @@ Object.freeze({
22781
23121
  addonId: null,
22782
23122
  access: "view"
22783
23123
  },
23124
+ "deviceManager.getDeviceStatusAggregateBatch": {
23125
+ capName: "device-manager",
23126
+ capScope: "system",
23127
+ addonId: null,
23128
+ access: "view"
23129
+ },
22784
23130
  "deviceManager.getLinkedDevices": {
22785
23131
  capName: "device-manager",
22786
23132
  capScope: "system",
@@ -23675,6 +24021,12 @@ Object.freeze({
23675
24021
  addonId: null,
23676
24022
  access: "view"
23677
24023
  },
24024
+ "localNetwork.getNotificationEndpoint": {
24025
+ capName: "local-network",
24026
+ capScope: "system",
24027
+ addonId: null,
24028
+ access: "view"
24029
+ },
23678
24030
  "localNetwork.getPreferred": {
23679
24031
  capName: "local-network",
23680
24032
  capScope: "system",
@@ -23699,6 +24051,12 @@ Object.freeze({
23699
24051
  addonId: null,
23700
24052
  access: "create"
23701
24053
  },
24054
+ "localNetwork.setNotificationEndpoint": {
24055
+ capName: "local-network",
24056
+ capScope: "system",
24057
+ addonId: null,
24058
+ access: "create"
24059
+ },
23702
24060
  "lockControl.lock": {
23703
24061
  capName: "lock-control",
23704
24062
  capScope: "device",
@@ -24341,6 +24699,12 @@ Object.freeze({
24341
24699
  addonId: null,
24342
24700
  access: "create"
24343
24701
  },
24702
+ "pipelineAnalytics.cancelMediaRelocate": {
24703
+ capName: "pipeline-analytics",
24704
+ capScope: "device",
24705
+ addonId: null,
24706
+ access: "create"
24707
+ },
24344
24708
  "pipelineAnalytics.clearTracks": {
24345
24709
  capName: "pipeline-analytics",
24346
24710
  capScope: "device",
@@ -24395,6 +24759,12 @@ Object.freeze({
24395
24759
  addonId: null,
24396
24760
  access: "view"
24397
24761
  },
24762
+ "pipelineAnalytics.getMediaRelocateStatus": {
24763
+ capName: "pipeline-analytics",
24764
+ capScope: "device",
24765
+ addonId: null,
24766
+ access: "view"
24767
+ },
24398
24768
  "pipelineAnalytics.getMotionEvents": {
24399
24769
  capName: "pipeline-analytics",
24400
24770
  capScope: "device",
@@ -24467,6 +24837,12 @@ Object.freeze({
24467
24837
  addonId: null,
24468
24838
  access: "create"
24469
24839
  },
24840
+ "pipelineAnalytics.relocateMedia": {
24841
+ capName: "pipeline-analytics",
24842
+ capScope: "device",
24843
+ addonId: null,
24844
+ access: "create"
24845
+ },
24470
24846
  "pipelineAnalytics.searchObjectEvents": {
24471
24847
  capName: "pipeline-analytics",
24472
24848
  capScope: "device",
@@ -25229,6 +25605,12 @@ Object.freeze({
25229
25605
  addonId: null,
25230
25606
  access: "create"
25231
25607
  },
25608
+ "recording.cancelRelocate": {
25609
+ capName: "recording",
25610
+ capScope: "system",
25611
+ addonId: null,
25612
+ access: "create"
25613
+ },
25232
25614
  "recording.deleteFootprint": {
25233
25615
  capName: "recording",
25234
25616
  capScope: "system",
@@ -25259,6 +25641,12 @@ Object.freeze({
25259
25641
  addonId: null,
25260
25642
  access: "view"
25261
25643
  },
25644
+ "recording.getRelocateStatus": {
25645
+ capName: "recording",
25646
+ capScope: "system",
25647
+ addonId: null,
25648
+ access: "view"
25649
+ },
25262
25650
  "recording.getStorageUsage": {
25263
25651
  capName: "recording",
25264
25652
  capScope: "system",
@@ -25289,6 +25677,24 @@ Object.freeze({
25289
25677
  addonId: null,
25290
25678
  access: "view"
25291
25679
  },
25680
+ "recording.relocateFootage": {
25681
+ capName: "recording",
25682
+ capScope: "system",
25683
+ addonId: null,
25684
+ access: "create"
25685
+ },
25686
+ "recording.renderClip": {
25687
+ capName: "recording",
25688
+ capScope: "system",
25689
+ addonId: null,
25690
+ access: "create"
25691
+ },
25692
+ "recording.renderGif": {
25693
+ capName: "recording",
25694
+ capScope: "system",
25695
+ addonId: null,
25696
+ access: "create"
25697
+ },
25292
25698
  "recording.rescanStorage": {
25293
25699
  capName: "recording",
25294
25700
  capScope: "system",
@@ -25883,6 +26289,12 @@ Object.freeze({
25883
26289
  addonId: null,
25884
26290
  access: "create"
25885
26291
  },
26292
+ "streamBroker.renderPreBufferClip": {
26293
+ capName: "stream-broker",
26294
+ capScope: "system",
26295
+ addonId: null,
26296
+ access: "create"
26297
+ },
25886
26298
  "streamBroker.restartProfile": {
25887
26299
  capName: "stream-broker",
25888
26300
  capScope: "system",
@@ -26577,7 +26989,7 @@ var NOTIFIER_ICONS = {
26577
26989
  /** The addon id — also the `/addon/<id>/…` route prefix. Mirrors `NOTIFIERS_ADDON_ID`. */
26578
26990
  var NOTIFIERS_ROUTE_ID = "notifiers";
26579
26991
  /** One day; icons are immutable per addon version. */
26580
- var CACHE_CONTROL = "public, max-age=86400, immutable";
26992
+ var CACHE_CONTROL$1 = "public, max-age=86400, immutable";
26581
26993
  var ICON_KINDS = new Set(Object.keys(NOTIFIER_ICONS));
26582
26994
  /** `true` when a bundled brand icon exists for `kind`. */
26583
26995
  function hasIcon(kind) {
@@ -26591,6 +27003,15 @@ function hasIcon(kind) {
26591
27003
  function iconUrlFor(kind) {
26592
27004
  return hasIcon(kind) ? `/addon/${NOTIFIERS_ROUTE_ID}/icons/${kind}` : void 0;
26593
27005
  }
27006
+ /**
27007
+ * The media type `iconUrlFor(kind)` serves, or `undefined` when no icon is
27008
+ * bundled. The client needs it because SVG and raster render through different
27009
+ * components on React Native, and it cannot be guessed from the URL — the route
27010
+ * path deliberately carries no file extension.
27011
+ */
27012
+ function iconMediaTypeFor(kind) {
27013
+ return hasIcon(kind) ? NOTIFIER_ICONS[kind].contentType : void 0;
27014
+ }
26594
27015
  /** Pre-encode one bundled icon into every content coding. */
26595
27016
  function encodeIcon(icon) {
26596
27017
  const identity = typeof icon.body === "string" ? Buffer.from(icon.body, "utf8") : Buffer.from(icon.body);
@@ -26626,15 +27047,143 @@ function iconRoute(kind) {
26626
27047
  description: `Official brand icon (${encoded.contentType}) for the '${kind}' notifier kind.`,
26627
27048
  handler: async (request, reply) => {
26628
27049
  const coding = negotiateEncoding(String(request.headers["accept-encoding"] ?? ""));
26629
- reply.code(200).type(encoded.contentType).header("cache-control", CACHE_CONTROL).header("vary", "accept-encoding");
27050
+ reply.code(200).type(encoded.contentType).header("cache-control", CACHE_CONTROL$1).header("vary", "accept-encoding");
26630
27051
  if (coding !== null) reply.header("content-encoding", coding);
26631
27052
  reply.send(coding !== null ? encoded[coding] : encoded.identity);
26632
27053
  }
26633
27054
  };
26634
27055
  }
26635
- /** Build the `addon-routes` provider that serves the bundled icons. */
26636
- function createIconRouteProvider() {
26637
- return buildAddonRouteProvider(NOTIFIERS_ROUTE_ID, Object.keys(NOTIFIER_ICONS).map(iconRoute));
27056
+ /**
27057
+ * The icon routes, for composition into the addon's SINGLE `addon-routes`
27058
+ * provider. Not a provider of its own: a provider owns one route id and matches
27059
+ * paths within it, so the icons and the test samples must share one route set
27060
+ * (see `sample-routes.ts`).
27061
+ */
27062
+ function iconRoutes() {
27063
+ return Object.keys(NOTIFIER_ICONS).map(iconRoute);
27064
+ }
27065
+ //#endregion
27066
+ //#region src/sample-routes.ts
27067
+ /**
27068
+ * Serves the bundled test-notification sample media over the addon's own HTTP
27069
+ * surface via the `addon-routes` cap. One public GET route per sample:
27070
+ *
27071
+ * GET /addon/notifiers/samples/<name> → the bundled sample bytes
27072
+ *
27073
+ * WHY THIS EXISTS
27074
+ * ───────────────
27075
+ * The test panel used to attach `https://example.com/sample.jpg` — the IANA
27076
+ * reserved documentation domain, which serves no media. Every "does my target
27077
+ * deliver an image / gif / video" test was therefore broken by construction and
27078
+ * had never verified anything. The samples have to live somewhere the addon can
27079
+ * actually fetch, on an install with no internet, so they ship with the addon.
27080
+ *
27081
+ * The bytes are read from `assets/samples/` (not embedded in TS): a 128 KB mp4
27082
+ * as a base64 literal would inflate the bundle by ~170 KB of source. Path
27083
+ * resolution mirrors `addon-benchmark`'s `resolveFixturesDir` — `import.meta.url`
27084
+ * always points at the compiled bundle under `dist/`, so walking up one
27085
+ * directory lands on the package root whether the addon runs from source (tsx)
27086
+ * or from its built bundle.
27087
+ *
27088
+ * CONTENT-ENCODING IS OURS, DELIBERATELY
27089
+ * ──────────────────────────────────────
27090
+ * Same hazard `icon-routes.ts` documents: the hub pipes an addon route's reply
27091
+ * through its global `@fastify/compress`, and on the forked-addon UDS route
27092
+ * bridge that compressor emits an EMPTY brotli stream for a compressible body
27093
+ * over 1 KiB. The compressor skips a response that already declares a
27094
+ * non-identity `content-encoding`, so we negotiate and stamp it ourselves.
27095
+ *
27096
+ * Media types here are all ALREADY compressed (JPEG/GIF/MP4/MP3), so we serve
27097
+ * identity bytes and stamp `content-encoding: identity` — re-compressing them
27098
+ * wastes CPU for no gain, and the explicit header is what keeps the hub's
27099
+ * compressor off a body it would corrupt.
27100
+ */
27101
+ /** Samples are immutable per addon version. */
27102
+ var CACHE_CONTROL = "public, max-age=86400, immutable";
27103
+ /**
27104
+ * The bundled set. Keyed by the `AttachmentMediaType` each one exercises, so a
27105
+ * caps-driven test panel can ask for "the sample for this media type" without
27106
+ * knowing filenames. `icon` deliberately reuses the image sample — an icon slot
27107
+ * wants a small raster, and shipping a fifth file to say the same thing is
27108
+ * waste.
27109
+ */
27110
+ var SAMPLES = [
27111
+ {
27112
+ name: "image",
27113
+ file: "image.jpg",
27114
+ contentType: "image/jpeg"
27115
+ },
27116
+ {
27117
+ name: "gif",
27118
+ file: "animation.gif",
27119
+ contentType: "image/gif"
27120
+ },
27121
+ {
27122
+ name: "video",
27123
+ file: "clip.mp4",
27124
+ contentType: "video/mp4"
27125
+ },
27126
+ {
27127
+ name: "audio",
27128
+ file: "tone.mp3",
27129
+ contentType: "audio/mpeg"
27130
+ },
27131
+ {
27132
+ name: "icon",
27133
+ file: "image.jpg",
27134
+ contentType: "image/jpeg"
27135
+ }
27136
+ ];
27137
+ new Set(SAMPLES.map((s) => s.name));
27138
+ /** Resolve the addon's bundled samples directory (see the file header). */
27139
+ function resolveSamplesDir() {
27140
+ const here = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
27141
+ const pkgRoot = node_path.default.resolve(node_path.default.dirname(here), "..");
27142
+ return node_path.default.join(pkgRoot, "assets", "samples");
27143
+ }
27144
+ /**
27145
+ * Read every sample eagerly so a missing asset fails at BOOT with a clear
27146
+ * error, rather than on the first operator click with a 500 that reads as a
27147
+ * broken notifier.
27148
+ */
27149
+ function loadSamples() {
27150
+ const dir = resolveSamplesDir();
27151
+ const out = /* @__PURE__ */ new Map();
27152
+ for (const sample of SAMPLES) {
27153
+ const bytes = (0, node_fs.readFileSync)(node_path.default.join(dir, sample.file));
27154
+ out.set(sample.name, {
27155
+ contentType: sample.contentType,
27156
+ bytes
27157
+ });
27158
+ }
27159
+ return out;
27160
+ }
27161
+ /** One static GET route serving a single bundled sample. */
27162
+ function sampleRoute(sample, loaded) {
27163
+ return {
27164
+ method: "GET",
27165
+ path: `/samples/${sample.name}`,
27166
+ access: "public",
27167
+ description: `Bundled ${sample.contentType} test sample for the '${sample.name}' attachment slot.`,
27168
+ handler: async (_request, reply) => {
27169
+ reply.code(200).type(loaded.contentType).header("cache-control", CACHE_CONTROL).header("content-encoding", "identity").header("content-length", String(loaded.bytes.byteLength));
27170
+ reply.send(loaded.bytes);
27171
+ }
27172
+ };
27173
+ }
27174
+ /**
27175
+ * The sample routes, for composition into the addon's SINGLE `addon-routes`
27176
+ * provider. Deliberately not a provider of its own: a provider owns one route
27177
+ * id and matches paths within it, so two providers sharing `notifiers` would
27178
+ * collide — the icons and the samples must travel in one route set.
27179
+ */
27180
+ function sampleRoutes() {
27181
+ const loaded = loadSamples();
27182
+ return SAMPLES.map((sample) => {
27183
+ const bytes = loaded.get(sample.name);
27184
+ if (bytes === void 0) throw new Error(`notifiers: sample '${sample.name}' failed to load`);
27185
+ return sampleRoute(sample, bytes);
27186
+ });
26638
27187
  }
26639
27188
  //#endregion
26640
27189
  //#region src/nc-target-actions.ts
@@ -29223,6 +29772,7 @@ function createNotificationOutputProvider(deps) {
29223
29772
  };
29224
29773
  }
29225
29774
  const iconUrlFor = deps.iconUrlFor;
29775
+ const iconMediaTypeFor = deps.iconMediaTypeFor;
29226
29776
  return {
29227
29777
  listTargetKinds: async () => deps.adapters.map((a) => {
29228
29778
  const descriptor = {
@@ -29230,10 +29780,16 @@ function createNotificationOutputProvider(deps) {
29230
29780
  addonId
29231
29781
  };
29232
29782
  const iconUrl = iconUrlFor?.(a.descriptor.kind);
29233
- return iconUrl !== void 0 ? {
29783
+ if (iconUrl === void 0) return descriptor;
29784
+ const iconMediaType = iconMediaTypeFor?.(a.descriptor.kind);
29785
+ return iconMediaType !== void 0 ? {
29786
+ ...descriptor,
29787
+ iconUrl,
29788
+ iconMediaType
29789
+ } : {
29234
29790
  ...descriptor,
29235
29791
  iconUrl
29236
- } : descriptor;
29792
+ };
29237
29793
  }),
29238
29794
  listTargets: async () => {
29239
29795
  return (await store.list()).map((target) => {
@@ -29504,9 +30060,10 @@ var NotifiersAddon = class extends BaseAddon {
29504
30060
  store,
29505
30061
  adapters: ADAPTERS,
29506
30062
  logger: this.ctx.logger.child("notification-output"),
29507
- iconUrlFor
30063
+ iconUrlFor,
30064
+ iconMediaTypeFor
29508
30065
  });
29509
- const iconRouteProvider = createIconRouteProvider();
30066
+ const routeProvider = buildAddonRouteProvider(NOTIFIERS_ADDON_ID, [...iconRoutes(), ...sampleRoutes()]);
29510
30067
  const ncHandlers = makeNcTargetHandlers({
29511
30068
  provider,
29512
30069
  logger: this.ctx.logger.child("nc-target-actions")
@@ -29518,7 +30075,7 @@ var NotifiersAddon = class extends BaseAddon {
29518
30075
  provider
29519
30076
  }, {
29520
30077
  capability: addonRoutesCapability,
29521
- provider: iconRouteProvider
30078
+ provider: routeProvider
29522
30079
  }],
29523
30080
  customActions: ncTargetActions,
29524
30081
  actionHandlers: ncHandlers