@camstack/types 1.2.237 → 1.2.238

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-Cqxm5OIN.js");
2
+ const require_sleep = require("./sleep-C0n7gucP.js");
3
3
  const require_event_category = require("./event-category-BVfsrBYA.js");
4
4
  const require_canonical_hash = require("./canonical-hash-CSE4ioRi.js");
5
5
  const require_enums = require("./enums.js");
@@ -27462,6 +27462,77 @@ var ClipPlaybackSchema = zod.z.object({
27462
27462
  * which days it asked for and got nothing — "no clips" would be a lie about a
27463
27463
  * card that is full of them.
27464
27464
  */
27465
+ /**
27466
+ * The operator's authorisation to WAKE a sleeping camera for one clip read.
27467
+ *
27468
+ * ONE value, absent by default, and it is a `force`-shaped operator signal in
27469
+ * exactly the sense `snapshot-wake-gate.ts` uses the word: *"`snapshot.getSnapshot`'s
27470
+ * `force` flag, and nothing else… a background caller must never set it…
27471
+ * Stale but honest beats woken"*. A scheduler, a retry, a reconcile and a
27472
+ * prefetch never set it; a surface sets it only behind the same confirm the
27473
+ * "Wake and refresh" gesture uses, and it is refused below 15 % battery
27474
+ * exactly as that gesture is.
27475
+ *
27476
+ * The gate is decided BEFORE `getApi()`, because on UDP the login IS the wake
27477
+ * (D549) — a read that opened a session and then checked would have woken the
27478
+ * camera to find out it was not allowed to.
27479
+ *
27480
+ * **One authorised yes is one wake.** `next-natural` — take the clip the next
27481
+ * time the camera is awake for its own reasons — is deliberately not a member:
27482
+ * it was proposed, it is free on the battery, and the operator declined it on
27483
+ * 2026-09-20 (*"Quando un export viene richiesto si sveglia la camera."*,
27484
+ * D558 "Considered and not taken").
27485
+ */
27486
+ var ClipWakeSchema = zod.z.enum(["authorised"]);
27487
+ /**
27488
+ * Hard ceiling on ONE {@link videoclipsCapability.methods.readClipBytes} — the
27489
+ * same 50 MiB `RECORDING_EXPORT_MAX_READ_BYTES` uses, and for the same second
27490
+ * reason: the envelope is unary, so a base64 payload is held whole (~1.33× its
27491
+ * size) in the provider AND in the caller, on a hub this repo has already
27492
+ * OOM'd once (D9/D18).
27493
+ *
27494
+ * Measured clips sit far below it — 92 KB–2.29 MB for a sub twin, 455 KB for a
27495
+ * 16 s main clip — so the bound bites rarely. "Rarely" is not "never": a long
27496
+ * 4K main twin can exceed it, and above the bound the provider REFUSES with
27497
+ * the size in the message, never truncates. Half a video is worse than an
27498
+ * honest refusal.
27499
+ *
27500
+ * The clean follow-on is a CHUNKED read so a `high` twin of a long clip stops
27501
+ * being refusable at all. That is a later slice, named here so the bound is
27502
+ * not mistaken for a design ceiling.
27503
+ */
27504
+ var VIDEOCLIPS_MAX_READ_BYTES = 50 * 1024 * 1024;
27505
+ /**
27506
+ * A clip's finished bytes, inline — the twin of `recordingExport.readExportBytes`.
27507
+ *
27508
+ * `bytes` is the DECODED length, so nobody infers it from the base64 length,
27509
+ * and `served` says which twin the caller actually got.
27510
+ */
27511
+ var ClipBytesSchema = zod.z.object({
27512
+ base64: zod.z.string(),
27513
+ contentType: zod.z.string(),
27514
+ /** Suggested filename, extension included. */
27515
+ name: zod.z.string(),
27516
+ bytes: zod.z.number().int().nonnegative(),
27517
+ /**
27518
+ * Which twin was actually served — the same contract
27519
+ * {@link ClipPlaybackSchema.served} carries, and REQUIRED here because the
27520
+ * export record persists it: a row read a week later must say the same thing
27521
+ * the panel said at the moment of the tap. A missing main twin is never
27522
+ * served silently as if it were the asked-for quality (D549 15).
27523
+ */
27524
+ served: require_sleep.CamProfileSchema,
27525
+ /**
27526
+ * The DECODED duration of the delivered file, when the fetch measured one.
27527
+ *
27528
+ * A clip fetch verifies its own completion against the catalog row and
27529
+ * retries a materially short pass (D568); this is that measurement, carried
27530
+ * so a consumer can say the same thing rather than re-deriving it. Absent
27531
+ * when the producer did not measure — never zero, which would say the file
27532
+ * is empty.
27533
+ */
27534
+ durationMs: zod.z.number().positive().optional()
27535
+ });
27465
27536
  var ClipSourceAvailabilitySchema = zod.z.object({
27466
27537
  state: zod.z.enum([
27467
27538
  "ok",
@@ -27633,6 +27704,68 @@ var videoclipsCapability = {
27633
27704
  }), ClipPlaybackSchema, {
27634
27705
  kind: "query",
27635
27706
  auth: "protected"
27707
+ }),
27708
+ /**
27709
+ * This clip's BYTES, base64, bounded — the by-handle read a clip EXPORT
27710
+ * pulls once (D558).
27711
+ *
27712
+ * `getClipPlayback` is the right answer for a player: it hands back a URL
27713
+ * on a plane the hub serves `access:'authenticated'`, which a browser and a
27714
+ * viewer session satisfy. It is the wrong answer for another ADDON. There
27715
+ * is no addon→addon byte transport in this framework — `AddonDataPlane`
27716
+ * only lets an addon SERVE, on `127.0.0.1` behind a per-listener secret
27717
+ * only the hub may present — so a recorder that wants a camera's clip
27718
+ * cannot fetch that URL. This method is the one seam that exists for it,
27719
+ * and it is deliberately the same shape (and the same bound) as
27720
+ * `recordingExport.readExportBytes`, which exists for the mirror-image
27721
+ * reason.
27722
+ *
27723
+ * Routing needs no `provider` pin: the id is source-prefixed and
27724
+ * self-contained, so `device-collection-dispatch.ts` rule 3 hands the call
27725
+ * to the source that claims it — and an id nobody claims is REFUSED rather
27726
+ * than answered by another source.
27727
+ *
27728
+ * The producer reuses the fetch path it already has, completion rules
27729
+ * included: a clip is taken by cmd 5 and finished on a short idle window
27730
+ * whose result is PROVED against the catalog row's own span, retried once
27731
+ * when it comes up materially short, and served-and-named when it is still
27732
+ * short (D568). A second fetch with different completion rules is exactly
27733
+ * the second authority D558 refuses to create.
27734
+ *
27735
+ * Every refusal THROWS with its reason and none of them is silent — the
27736
+ * sleep gate (decided before `getApi()`, liftable only by
27737
+ * {@link ClipWakeSchema}), a catalog row nobody claims, a clip with no
27738
+ * bytes behind it, a mux that failed, and the size bound. The caller turns
27739
+ * that reason into an operator-facing one; a truncated file is never an
27740
+ * answer.
27741
+ */
27742
+ readClipBytes: require_sleep.optionalMethod(zod.z.object({
27743
+ deviceId: zod.z.number(),
27744
+ clipId: zod.z.string().min(1),
27745
+ /**
27746
+ * Which twin to fetch, on the mapping D549 15 already fixed:
27747
+ * `low | mid` → the sub file, `high` → the main twin. `auto` is not
27748
+ * accepted here for the same reason it is not accepted by
27749
+ * `getClipPlayback` — a stored file has no broker session, so the
27750
+ * adaptive tier cannot be resolved for it.
27751
+ */
27752
+ profile: require_sleep.CamProfileSchema.optional(),
27753
+ /**
27754
+ * The CALLER's byte bound, so an over-size clip is refused before it is
27755
+ * read and encoded rather than after. Capped by
27756
+ * {@link VIDEOCLIPS_MAX_READ_BYTES} whatever is passed; absent means
27757
+ * that ceiling.
27758
+ */
27759
+ maxBytes: zod.z.number().int().positive().optional(),
27760
+ /**
27761
+ * The operator's authorisation to wake a sleeping camera for this
27762
+ * read. Absent — the default — means a sleeping standalone battery
27763
+ * camera is REFUSED by name, before any session is opened.
27764
+ */
27765
+ wake: ClipWakeSchema.optional()
27766
+ }), ClipBytesSchema, {
27767
+ kind: "query",
27768
+ auth: "protected"
27636
27769
  })
27637
27770
  }
27638
27771
  };
@@ -37153,13 +37286,135 @@ var ExportStateSchema = zod.z.enum([
37153
37286
  "expired",
37154
37287
  "deleted"
37155
37288
  ]);
37156
- /** One export job / history row. */
37289
+ /**
37290
+ * A stretch of footage THIS system recorded — the only thing `createExport`
37291
+ * could export before D558, and still the shape every legacy caller sends.
37292
+ */
37293
+ var ExportFootageSubjectSchema = zod.z.object({
37294
+ kind: zod.z.literal("footage"),
37295
+ deviceId: zod.z.number(),
37296
+ profiles: zod.z.array(zod.z.string()).min(1),
37297
+ fromMs: zod.z.number(),
37298
+ toMs: zod.z.number()
37299
+ });
37300
+ /**
37301
+ * A CLIP — a finished file with boundaries the camera chose, listed by one of
37302
+ * the device's `videoclips` sources.
37303
+ *
37304
+ * There is deliberately **no `fromMs`/`toMs` here**. The camera chose them,
37305
+ * no surface on this path asks for them (there is no drag and no
37306
+ * `datetime-local` pair — D558 § 5.4.3), and they reach the record only as the
37307
+ * projection. A range in the subject would be a second place the boundaries
37308
+ * live and the one a caller could get wrong.
37309
+ *
37310
+ * `provider` is the **addonId** of the source's serving addon — the `provider`
37311
+ * pin `videoclips.listClips` REQUIRES since D554 was amended on 2026-09-20.
37312
+ * There was never a default: a bare call fanned out and returned the union of
37313
+ * every source with `limit` meaning `limit × sources`. The catalog check that
37314
+ * validates this subject names it, so it asks exactly the source the operator
37315
+ * picked.
37316
+ *
37317
+ * `source` is that source's id (the namespace `clipId` is prefixed with), and
37318
+ * `sourceLabel` is its operator-facing name FROZEN at creation — a history row
37319
+ * still reads "SD card" after the source is unbound.
37320
+ *
37321
+ * `profile` is exactly ONE, and it is what was ASKED. What was SERVED lands on
37322
+ * the record's top-level `profile`, so a clip with no main twin renders the
37323
+ * divergence instead of hiding it (D549 15; measured on 592, 17 of 546 clips
37324
+ * had no main twin, so a silent fallback would be right 96.9 % of the time).
37325
+ * `auto` is not a member: a stored file has no broker session, so the adaptive
37326
+ * tier cannot be resolved for it.
37327
+ */
37328
+ var ExportClipSubjectSchema = zod.z.object({
37329
+ kind: zod.z.literal("clip"),
37330
+ deviceId: zod.z.number(),
37331
+ provider: zod.z.string().min(1),
37332
+ source: zod.z.string().min(1),
37333
+ sourceLabel: zod.z.string().min(1),
37334
+ clipId: zod.z.string().min(1),
37335
+ /**
37336
+ * WHERE IN THE CATALOG to confirm this clip — the day window the surface was
37337
+ * already listing when the operator picked the segment.
37338
+ *
37339
+ * It is **not** a time range control and it never becomes one: the record's
37340
+ * `fromMs`/`toMs` come from the catalog ROW and from nothing a caller
37341
+ * supplied (D558 § 5.4.3), and a window that does not contain the clip is a
37342
+ * `catalog-miss`, not a silently wider search. It exists because
37343
+ * `videoclips.listClips` takes `since`/`until` and has no by-handle twin:
37344
+ * the catalog check D558 asks for is literally that call, and a call needs a
37345
+ * window. The surface has one — `ClipsBrowser`'s `dayWindow`, one local
37346
+ * wall-clock day, which is also the only width measured to be cheap (one
37347
+ * day on 592 lists 171 clips in 712 ms, a busy day 546 in 2.0 s; twenty days
37348
+ * of one child's events took 3.6–5.4 s).
37349
+ */
37350
+ catalogWindow: zod.z.object({
37351
+ sinceMs: zod.z.number(),
37352
+ untilMs: zod.z.number()
37353
+ }),
37354
+ profile: zod.z.enum([
37355
+ "high",
37356
+ "mid",
37357
+ "low"
37358
+ ]),
37359
+ /**
37360
+ * The operator's authorisation to wake a sleeping camera for this export.
37361
+ * ONE definition, in the cap that owns the clip read ({@link ClipWakeSchema}),
37362
+ * because the gate that honours it is the clip provider's sleep gate — a
37363
+ * second enum here would be a second contract. Absent by default; never
37364
+ * settable by a scheduler or a retry.
37365
+ *
37366
+ * **One authorised yes is ONE wake.** A failed clip export is retried only by
37367
+ * an operator act that asks again; a queued job that outlived its wake fails
37368
+ * with a reason rather than waking on its turn; and this subject carries
37369
+ * exactly one profile precisely so one tap is never two fetches (D558 § 5.2).
37370
+ */
37371
+ wake: ClipWakeSchema.optional()
37372
+ });
37373
+ /**
37374
+ * WHAT an export is — the authority, as opposed to the four top-level fields
37375
+ * the Library sorts and labels on (D558 § 2.2).
37376
+ *
37377
+ * Read it through {@link exportSubjectOf}, never off the record directly: the
37378
+ * field is optional for the history rows written before it existed, and that
37379
+ * absence has exactly one interpreter.
37380
+ */
37381
+ var ExportSubjectSchema = zod.z.discriminatedUnion("kind", [ExportFootageSubjectSchema, ExportClipSubjectSchema]);
37382
+ /**
37383
+ * One export job / history row.
37384
+ *
37385
+ * **`subject` is the AUTHORITY on what was exported. `deviceId`, `profile`,
37386
+ * `fromMs` and `toMs` are its PROJECTION** — kept top-level because the whole
37387
+ * Library sorts and labels on them (`library-items.ts` orders an export by
37388
+ * `fromMs`; `export-format.ts` draws `rangeLabel` from the pair), and a row
37389
+ * that did not fill them would sort under the epoch and render a blank range.
37390
+ * Write to the subject and read from the projection and the two will disagree;
37391
+ * the projection is derived at creation and never edited afterwards.
37392
+ *
37393
+ * And they mean DIFFERENT FACTS for the two kinds, which is the part a reader
37394
+ * who knows only the recording export will get wrong:
37395
+ *
37396
+ * | field | `kind:'footage'` | `kind:'clip'` |
37397
+ * | --- | --- | --- |
37398
+ * | `fromMs`/`toMs` | the stretch the operator ASKED for | the camera's own boundaries, always `clip.timeRange`, never anything a caller supplied |
37399
+ * | `profile` | the stream rendered | the twin actually SERVED (`subject.profile` is the one asked for) |
37400
+ *
37401
+ * Same type, different fact — the shape this repo keeps getting wrong (D385's
37402
+ * two authorities, D224's second copy).
37403
+ */
37157
37404
  var ExportRecordSchema = zod.z.object({
37158
37405
  id: zod.z.string(),
37159
37406
  deviceId: zod.z.number(),
37160
37407
  profile: zod.z.string(),
37161
37408
  fromMs: zod.z.number(),
37162
37409
  toMs: zod.z.number(),
37410
+ /**
37411
+ * What this export IS. Optional ONLY for the rows written before D558: the
37412
+ * store parses every row through this schema on every read, so a required
37413
+ * field would make the export AUDIT — which is the whole reason rows survive
37414
+ * file deletion — unreadable in one release. Absence means `footage`, and
37415
+ * {@link exportSubjectOf} is the one place that says so.
37416
+ */
37417
+ subject: ExportSubjectSchema.optional(),
37163
37418
  options: ExportOptionsSchema,
37164
37419
  state: ExportStateSchema,
37165
37420
  /** 0–100 while rendering; null otherwise. */
@@ -37176,6 +37431,49 @@ var ExportRecordSchema = zod.z.object({
37176
37431
  /** Failure reason when state is 'failed'; null otherwise. */
37177
37432
  error: zod.z.string().nullable()
37178
37433
  });
37434
+ /**
37435
+ * Every way a clip export can fail, as a TOKEN — never prose.
37436
+ *
37437
+ * A branch that accepts work and produces nothing is the branch this repo
37438
+ * keeps losing work in (D391), and a clip export has five places to lose it
37439
+ * that a recording export does not have. The token is what a surface may key
37440
+ * a table on; the PROSE — the camera's own words, the source's verbatim
37441
+ * refusal — travels with it, in the same `ExportRecord.error` string, after a
37442
+ * `: `. Two separate things in one field because the field is one field:
37443
+ * `ClipStillRefusalCodeSchema` split them across two HTTP headers for the same
37444
+ * reason, and the surface that keyed on the whole header rendered every
37445
+ * refusal on this fleet as `Refused: <prose>`.
37446
+ *
37447
+ * Compose with {@link clipExportFailure}, read back with
37448
+ * {@link clipExportFailureOf}. Never hand-spell the separator.
37449
+ */
37450
+ var ClipExportFailureSchema = zod.z.enum([
37451
+ "catalog-miss",
37452
+ "catalog-unreachable",
37453
+ "no-file-for-window",
37454
+ "clip-in-progress",
37455
+ "unsupported-option",
37456
+ "sleeping",
37457
+ "camera-refused",
37458
+ "fetch-failed",
37459
+ "too-large-to-transfer",
37460
+ "wake-expired"
37461
+ ]);
37462
+ /** `<token>: <prose>` — the ONE composition of a clip export's failure string. */
37463
+ function clipExportFailure(code, detail) {
37464
+ return detail.length > 0 ? `${code}: ${detail}` : code;
37465
+ }
37466
+ /**
37467
+ * The token out of an {@link ExportRecord.error}, or null when the string did
37468
+ * not come from {@link clipExportFailure} (every footage failure, and every
37469
+ * error thrown by something that never heard of this vocabulary).
37470
+ */
37471
+ function clipExportFailureOf(error) {
37472
+ if (error === null) return null;
37473
+ const head = error.split(":", 1)[0] ?? "";
37474
+ const parsed = ClipExportFailureSchema.safeParse(head.trim());
37475
+ return parsed.success ? parsed.data : null;
37476
+ }
37179
37477
  /** Candidate download URLs (LAN first, then operator extra hosts). */
37180
37478
  var ExportDownloadSchema = zod.z.object({
37181
37479
  url: zod.z.string(),
@@ -37213,35 +37511,149 @@ var ExportBytesSchema = zod.z.object({
37213
37511
  name: zod.z.string(),
37214
37512
  bytes: zod.z.number().int().nonnegative()
37215
37513
  });
37514
+ /** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
37515
+ function resolveExportProfiles(input) {
37516
+ if (input.profiles !== void 0 && input.profiles.length > 0) return [...input.profiles];
37517
+ if (typeof input.profile === "string" && input.profile.length > 0) return [input.profile];
37518
+ return [];
37519
+ }
37216
37520
  /**
37217
- * `createExport` input. `profiles` is the canonical field (min 1). A legacy
37218
- * singular `profile` is still accepted so existing callers do not break.
37521
+ * `createExport` input — ONE object carrying an optional {@link ExportSubject},
37522
+ * never a union of two inputs.
37523
+ *
37524
+ * It has to be a ZodObject: generated routers call `.input.loose()` so the
37525
+ * out-of-band `nodeId` selector survives the wire parse, and `.loose()` is a
37526
+ * ZodObject method a `z.discriminatedUnion` does not have. That is why the
37527
+ * discriminant sits one level down, in `subject`, and why
37528
+ * {@link resolveCreateExportSubject} — not a `z.preprocess` wrapper, which
37529
+ * would have produced a schema with no `.loose()` — is the one reading of a
37530
+ * legacy flat input as a subject.
37219
37531
  *
37220
- * Must remain a ZodObject (`.loose()` for out-of-band `nodeId`).
37532
+ * **`deviceId` stays REQUIRED at the top level**, for both kinds, and a clip
37533
+ * subject naming a different one is REFUSED. Not symmetry: `METHOD_DEVICE_SELECTORS`
37534
+ * (generated) maps top-level fields and one-level object arrays, so per-device
37535
+ * scope enforcement in `scope-access.ts` reads THIS field and cannot see
37536
+ * `subject.deviceId`. A deviceId that lived only in the subject would let a
37537
+ * principal scoped to one camera create an export — and, on the clip path, a
37538
+ * WAKE — for another.
37539
+ *
37540
+ * **A clip carries no time range**, and one supplied alongside a clip subject
37541
+ * is refused rather than ignored: there is no drag on this path and nothing to
37542
+ * normalise (D558 § 5.4.3). The record's `fromMs`/`toMs` come from the clip's
37543
+ * own `timeRange` and from nowhere else.
37221
37544
  */
37222
37545
  var CreateExportInputSchema = zod.z.object({
37223
37546
  deviceId: zod.z.number(),
37224
37547
  /** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
37225
37548
  profile: zod.z.string().optional(),
37226
37549
  profiles: zod.z.array(zod.z.string()).min(1).optional(),
37227
- fromMs: zod.z.number(),
37228
- toMs: zod.z.number(),
37550
+ /** Footage only — a clip's boundaries are the camera's. */
37551
+ fromMs: zod.z.number().optional(),
37552
+ toMs: zod.z.number().optional(),
37553
+ /** What to export. Absent means the legacy flat footage request. */
37554
+ subject: ExportSubjectSchema.optional(),
37229
37555
  options: ExportOptionsSchema
37230
37556
  }).superRefine((v, ctx) => {
37231
- if ((v.profiles !== void 0 && v.profiles.length > 0 ? v.profiles : v.profile !== void 0 ? [v.profile] : []).length < 1) ctx.addIssue({
37557
+ if (v.subject?.kind === "clip") {
37558
+ if (v.subject.deviceId !== v.deviceId) ctx.addIssue({
37559
+ code: zod.z.ZodIssueCode.custom,
37560
+ message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId}) — the top-level field is what per-device scope enforcement reads`,
37561
+ path: ["subject", "deviceId"]
37562
+ });
37563
+ if (v.fromMs !== void 0 || v.toMs !== void 0) ctx.addIssue({
37564
+ code: zod.z.ZodIssueCode.custom,
37565
+ message: "a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row",
37566
+ path: ["fromMs"]
37567
+ });
37568
+ return;
37569
+ }
37570
+ if (v.subject?.kind === "footage" && v.subject.deviceId !== v.deviceId) ctx.addIssue({
37571
+ code: zod.z.ZodIssueCode.custom,
37572
+ message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId})`,
37573
+ path: ["subject", "deviceId"]
37574
+ });
37575
+ const fromMs = v.subject?.kind === "footage" ? v.subject.fromMs : v.fromMs;
37576
+ const toMs = v.subject?.kind === "footage" ? v.subject.toMs : v.toMs;
37577
+ if (typeof fromMs !== "number" || typeof toMs !== "number") ctx.addIssue({
37578
+ code: zod.z.ZodIssueCode.custom,
37579
+ message: "a footage export needs fromMs and toMs",
37580
+ path: ["fromMs"]
37581
+ });
37582
+ if ((v.subject?.kind === "footage" ? [...v.subject.profiles] : resolveExportProfiles(v)).length < 1) ctx.addIssue({
37232
37583
  code: zod.z.ZodIssueCode.custom,
37233
37584
  message: "pass profiles[] (min 1) or legacy profile",
37234
37585
  path: ["profiles"]
37235
37586
  });
37236
37587
  });
37588
+ /**
37589
+ * The ONE reading of a `createExport` input as a {@link ExportSubject}.
37590
+ *
37591
+ * Every consumer goes through this: a provider that branched on
37592
+ * `input.subject !== undefined` in one place and on `input.fromMs` in another
37593
+ * would be two authorities on what was asked for, which is how the flat fields
37594
+ * and the subject drift apart.
37595
+ *
37596
+ * Throws on a footage input with no range — an input that parsed cannot reach
37597
+ * that, and a caller that skipped the parse gets a named refusal rather than
37598
+ * `NaN` boundaries on a durable row.
37599
+ */
37600
+ function resolveCreateExportSubject(input) {
37601
+ if (input.subject !== void 0) return input.subject;
37602
+ const profiles = resolveExportProfiles(input);
37603
+ if (typeof input.fromMs !== "number" || typeof input.toMs !== "number") throw new Error("recording-export: a footage export needs fromMs and toMs");
37604
+ return {
37605
+ kind: "footage",
37606
+ deviceId: input.deviceId,
37607
+ profiles,
37608
+ fromMs: input.fromMs,
37609
+ toMs: input.toMs
37610
+ };
37611
+ }
37612
+ /**
37613
+ * The ONE interpreter of a stored row's subject.
37614
+ *
37615
+ * `ExportRecord.subject` is optional for exactly one reason — the history rows
37616
+ * written before D558 — and "absent means footage, built from the projection"
37617
+ * is a statement that must live in one place. Anything that reads
37618
+ * `rec.subject` directly and falls back inline is the second authority.
37619
+ */
37620
+ function exportSubjectOf(rec) {
37621
+ if (rec.subject !== void 0) return rec.subject;
37622
+ return {
37623
+ kind: "footage",
37624
+ deviceId: rec.deviceId,
37625
+ profiles: [rec.profile],
37626
+ fromMs: rec.fromMs,
37627
+ toMs: rec.toMs
37628
+ };
37629
+ }
37237
37630
  var recordingExportCapability = {
37238
37631
  name: "recording-export",
37239
37632
  scope: "system",
37240
37633
  mode: "singleton",
37241
37634
  methods: {
37242
- /** Queue a render of `[fromMs,toMs)` for `deviceId`/`profiles` (legacy
37243
- * singular `profile` still accepted). Fails fast when no footage covers
37244
- * the range. One job per profile; returns the first queued record. */
37635
+ /**
37636
+ * Queue an export of {@link ExportSubjectSchema}.
37637
+ *
37638
+ * `kind:'footage'` — a render of `[fromMs,toMs)` for `deviceId`/`profiles`
37639
+ * (legacy flat input, singular `profile` included, still accepted and
37640
+ * rewritten). Fails fast when no footage covers the range. One job per
37641
+ * profile; **returns the first queued record and the others are reachable
37642
+ * only through `listExports`** — a defect named in D558 § 6.3 and the
37643
+ * reason a clip subject carries exactly ONE profile.
37644
+ *
37645
+ * `kind:'clip'` — a finished file the camera holds, validated against the
37646
+ * device's clip CATALOG (`videoclips.listClips`, at the subject's
37647
+ * `provider`) instead of the recording index, and fetched once by handle
37648
+ * under a bound. Its `fromMs`/`toMs` come from the catalog row and from
37649
+ * nowhere else; a caller supplying a range is refused.
37650
+ *
37651
+ * A clip export reuses the six {@link ExportStateSchema} members and adds
37652
+ * none: the viewer maps an unknown state string to `failed`, so a seventh
37653
+ * member renders every live export — of both kinds — as FAILED on every
37654
+ * installed app (D558 § 6.1, pinned by `export-state-members.spec.ts`).
37655
+ * `subject.kind` is what tells a surface what `rendering` means.
37656
+ */
37245
37657
  createExport: require_sleep.method(CreateExportInputSchema, ExportRecordSchema, {
37246
37658
  kind: "mutation",
37247
37659
  auth: "protected"
@@ -51123,6 +51535,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
51123
51535
  addonId: null,
51124
51536
  access: "view"
51125
51537
  },
51538
+ "videoclips.readClipBytes": {
51539
+ capName: "videoclips",
51540
+ capScope: "device",
51541
+ addonId: null,
51542
+ access: "view"
51543
+ },
51126
51544
  "viewerUi.getStaticDir": {
51127
51545
  capName: "viewer-ui",
51128
51546
  capScope: "system",
@@ -53414,6 +53832,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
53414
53832
  form: "single",
53415
53833
  optional: false
53416
53834
  }],
53835
+ "videoclips.readClipBytes": [{
53836
+ name: "deviceId",
53837
+ form: "single",
53838
+ optional: false
53839
+ }],
53417
53840
  "waterHeater.setAway": [{
53418
53841
  name: "deviceId",
53419
53842
  form: "single",
@@ -59078,12 +59501,15 @@ exports.CarbonMonoxideStatusSchema = CarbonMonoxideStatusSchema;
59078
59501
  exports.ChargingStatus = require_sleep.ChargingStatus;
59079
59502
  exports.ClientNetworkStatsSchema = ClientNetworkStatsSchema;
59080
59503
  exports.ClimateControlStatusSchema = ClimateControlStatusSchema;
59504
+ exports.ClipBytesSchema = ClipBytesSchema;
59505
+ exports.ClipExportFailureSchema = ClipExportFailureSchema;
59081
59506
  exports.ClipPlaybackSchema = ClipPlaybackSchema;
59082
59507
  exports.ClipSchema = ClipSchema;
59083
59508
  exports.ClipSourceAvailabilitySchema = ClipSourceAvailabilitySchema;
59084
59509
  exports.ClipSourceSchema = ClipSourceSchema;
59085
59510
  exports.ClipStillDispositionSchema = ClipStillDispositionSchema;
59086
59511
  exports.ClipStillRefusalCodeSchema = ClipStillRefusalCodeSchema;
59512
+ exports.ClipWakeSchema = ClipWakeSchema;
59087
59513
  exports.ClusterAddonNodeDeploymentSchema = ClusterAddonNodeDeploymentSchema;
59088
59514
  exports.ClusterAddonStatusEntrySchema = ClusterAddonStatusEntrySchema;
59089
59515
  exports.CollectionColumnSchema = CollectionColumnSchema;
@@ -59243,15 +59669,18 @@ exports.EventMediaProductionSchema = EventMediaProductionSchema;
59243
59669
  exports.EventOwnerTypeSchema = EventOwnerTypeSchema;
59244
59670
  exports.EventSourceType = require_enums.EventSourceType$1;
59245
59671
  exports.ExportBytesSchema = ExportBytesSchema;
59672
+ exports.ExportClipSubjectSchema = ExportClipSubjectSchema;
59246
59673
  exports.ExportDenseRangeSchema = ExportDenseRangeSchema;
59247
59674
  exports.ExportDenseSchema = ExportDenseSchema;
59248
59675
  exports.ExportDownloadSchema = ExportDownloadSchema;
59676
+ exports.ExportFootageSubjectSchema = ExportFootageSubjectSchema;
59249
59677
  exports.ExportOptionsSchema = ExportOptionsSchema;
59250
59678
  exports.ExportRecordSchema = ExportRecordSchema;
59251
59679
  exports.ExportSetupFieldSchema = ExportSetupFieldSchema;
59252
59680
  exports.ExportSetupSchema = ExportSetupSchema;
59253
59681
  exports.ExportSpeedSchema = ExportSpeedSchema;
59254
59682
  exports.ExportStateSchema = ExportStateSchema;
59683
+ exports.ExportSubjectSchema = ExportSubjectSchema;
59255
59684
  exports.ExportTimelapseSchema = ExportTimelapseSchema;
59256
59685
  exports.ExposedDeviceSchema = ExposedDeviceSchema;
59257
59686
  exports.ExposureModeSchema = ExposureModeSchema;
@@ -59978,6 +60407,7 @@ exports.UpdateStatusSchema = UpdateStatusSchema;
59978
60407
  exports.UpdateUserInputSchema = UpdateUserInputSchema;
59979
60408
  exports.UserRecordSchema = UserRecordSchema;
59980
60409
  exports.UserSummarySchema = UserSummarySchema;
60410
+ exports.VIDEOCLIPS_MAX_READ_BYTES = VIDEOCLIPS_MAX_READ_BYTES;
59981
60411
  exports.VISIT_MERGE_GAP_MS = VISIT_MERGE_GAP_MS;
59982
60412
  exports.VacuumControlStatusSchema = VacuumControlStatusSchema;
59983
60413
  exports.VacuumStateSchema = VacuumStateSchema;
@@ -60098,6 +60528,8 @@ exports.classifyBearerPrincipal = classifyBearerPrincipal;
60098
60528
  exports.classifyStream = classifyStream;
60099
60529
  exports.classifyStreams = classifyStreams;
60100
60530
  exports.climateControlCapability = climateControlCapability;
60531
+ exports.clipExportFailure = clipExportFailure;
60532
+ exports.clipExportFailureOf = clipExportFailureOf;
60101
60533
  exports.clusterModelSettingKey = clusterModelSettingKey;
60102
60534
  exports.clusterStepSettingFieldsFor = clusterStepSettingFieldsFor;
60103
60535
  exports.clusterStepSettingKey = clusterStepSettingKey;
@@ -60197,6 +60629,7 @@ exports.evictionPolicyForMode = evictionPolicyForMode;
60197
60629
  exports.evictionPolicyOfLocation = evictionPolicyOfLocation;
60198
60630
  exports.expandAudioChunkToF32le = require_sleep.expandAudioChunkToF32le;
60199
60631
  exports.expandCapMethods = require_sleep.expandCapMethods;
60632
+ exports.exportSubjectOf = exportSubjectOf;
60200
60633
  exports.extractNestedAddonId = extractNestedAddonId;
60201
60634
  exports.extractSourceInfoFromMetadata = extractSourceInfoFromMetadata;
60202
60635
  exports.faceGalleryCapability = faceGalleryCapability;
@@ -60331,6 +60764,7 @@ exports.oauthIntegrationCapability = oauthIntegrationCapability;
60331
60764
  exports.objectInputDeclaresAddonId = objectInputDeclaresAddonId;
60332
60765
  exports.objectInputDeclaresRequiredDeviceId = objectInputDeclaresRequiredDeviceId;
60333
60766
  exports.occupancyScope = occupancyScope;
60767
+ exports.optionalMethod = require_sleep.optionalMethod;
60334
60768
  exports.osdCapability = osdCapability;
60335
60769
  exports.osdManagerCapability = osdManagerCapability;
60336
60770
  exports.overlayClusterStepSettings = overlayClusterStepSettings;
@@ -60398,10 +60832,12 @@ exports.resolveBucketMs = resolveBucketMs;
60398
60832
  exports.resolveCapMount = require_sleep.resolveCapMount;
60399
60833
  exports.resolveClusterStepModelId = resolveClusterStepModelId;
60400
60834
  exports.resolveContainerPrimaryChild = resolveContainerPrimaryChild;
60835
+ exports.resolveCreateExportSubject = resolveCreateExportSubject;
60401
60836
  exports.resolveDetectionRuntime = resolveDetectionRuntime;
60402
60837
  exports.resolveDeviceControlKind = resolveDeviceControlKind;
60403
60838
  exports.resolveDeviceProfile = resolveDeviceProfile;
60404
60839
  exports.resolveEgressDecodeHwAccel = resolveEgressDecodeHwAccel;
60840
+ exports.resolveExportProfiles = resolveExportProfiles;
60405
60841
  exports.resolveFormat = resolveFormat;
60406
60842
  exports.resolveHydratedFieldValue = require_sleep.resolveHydratedFieldValue;
60407
60843
  exports.resolveLocationIcon = resolveLocationIcon;