@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/addon.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_err_msg = require("./err-msg-COpsHMw2.js");
5
5
  //#region src/generated/cap-input-defaults.ts
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as DeviceType, At as emitReadiness, Ct as DATAPLANE_SECRET_HEADER, Dt as normalizeAddonInitResult, Et as BaseAddon, G as ReadinessRegistry, H as nodePin, I as expandCapMethods, K as ReadinessTimeoutError, S as DEVICE_CHILDREN_BATCH_MAX, T as describeCustomActions, Tt as DisposerChain, U as readNodePin, Y as scopeKey, a as asJsonObject, b as deviceOpsCapability, d as BOOT_RECOVERY_BACKOFF_MS, f as DEVICE_SCOPED_CAPS, h as createEventBusSliceSource, j as adminUiCapability, m as createDeviceProxy, p as isDeviceScopedCap, s as asString, t as sleep, u as parseJsonUnknown, x as viewerUiCapability } from "./sleep-CaB_hL5g.mjs";
1
+ import { A as DeviceType, Dt as BaseAddon, Et as DisposerChain, I as expandCapMethods, K as ReadinessRegistry, Ot as normalizeAddonInitResult, S as DEVICE_CHILDREN_BATCH_MAX, T as describeCustomActions, U as nodePin, W as readNodePin, X as scopeKey, a as asJsonObject, b as deviceOpsCapability, d as BOOT_RECOVERY_BACKOFF_MS, f as DEVICE_SCOPED_CAPS, h as createEventBusSliceSource, j as adminUiCapability, jt as emitReadiness, m as createDeviceProxy, p as isDeviceScopedCap, q as ReadinessTimeoutError, s as asString, t as sleep, u as parseJsonUnknown, wt as DATAPLANE_SECRET_HEADER, x as viewerUiCapability } from "./sleep-BVhJDJka.mjs";
2
2
  import { t as EventCategory } from "./event-category-BVDXG4tB.mjs";
3
3
  import { t as errMsg } from "./err-msg-IQTHeDzc.mjs";
4
4
  //#region src/generated/cap-input-defaults.ts
@@ -107,6 +107,29 @@ export interface CapabilityMethodSchema<TInput extends z.ZodType = z.ZodType, TO
107
107
  * rationale as the status-Partial on native providers.
108
108
  */
109
109
  readonly systemOnly?: boolean;
110
+ /**
111
+ * When true the method is OPTIONAL on `InferProvider` — a source of a
112
+ * COLLECTION cap may legitimately not serve it.
113
+ *
114
+ * Not the same thing as {@link systemOnly}, which is about the native/system
115
+ * split of ONE addon. This is about peers: a `mode:'collection'` cap's
116
+ * providers are sources listed beside each other, none privileged, and they
117
+ * do genuinely different things. `videoclips.readClipBytes` is the case —
118
+ * the recorder's `analytics` source is a time WINDOW over footage with no
119
+ * file behind it at all, so demanding the method of it buys a throwing stub,
120
+ * and a throwing stub reads exactly like a method somebody forgot.
121
+ *
122
+ * The RUNTIME already treated absence as a named case: `callSource`
123
+ * (`device-collection-dispatch.ts`) answers a missing method with
124
+ * `NOT_IMPLEMENTED` naming the cap, the source and the method, and
125
+ * `isCollectionArrayMethod` lets a missing ARRAY method contribute `[]`
126
+ * rather than emptying the fan-out. This flag stops the TYPE from demanding
127
+ * what the framework never needed.
128
+ *
129
+ * Use it only where a source's ABSENCE of the method is a fact about that
130
+ * source, never to soften a method somebody has not got round to writing.
131
+ */
132
+ readonly providerOptional?: boolean;
110
133
  /**
111
134
  * Opt-in caller-identity injection (D-1). When `'required'`, the hub
112
135
  * cap-router injects a server-derived {@link CapCaller} into the input
@@ -804,8 +827,16 @@ type ProviderMethodInput<M, TIn extends z.ZodType> = M extends {
804
827
  } ? z.infer<TIn> & {
805
828
  readonly caller: CapCaller;
806
829
  } : z.infer<TIn>;
830
+ /** One provider method's callable shape, subscription arm included. */
831
+ type ProviderMethodFn<M> = M extends CapabilityMethodSchema<infer TIn, infer TOut> ? M['kind'] extends 'subscription' ? (input: z.infer<TIn>, push: (value: z.infer<TOut>) => void) => (() => void) | void : (input: ProviderMethodInput<M, TIn>) => Promise<z.infer<TOut>> : never;
807
832
  export type InferProvider<T extends CapabilityDefinition> = {
808
- readonly [K in keyof T['methods']]: T['methods'][K] extends CapabilityMethodSchema<infer TIn, infer TOut> ? T['methods'][K]['kind'] extends 'subscription' ? (input: z.infer<TIn>, push: (value: z.infer<TOut>) => void) => (() => void) | void : (input: ProviderMethodInput<T['methods'][K], TIn>) => Promise<z.infer<TOut>> : never;
833
+ readonly [K in keyof T['methods'] as T['methods'][K] extends {
834
+ providerOptional: true;
835
+ } ? never : K]: ProviderMethodFn<T['methods'][K]>;
836
+ } & {
837
+ readonly [K in keyof T['methods'] as T['methods'][K] extends {
838
+ providerOptional: true;
839
+ } ? K : never]?: ProviderMethodFn<T['methods'][K]>;
809
840
  } & (T['exposesDeviceSettings'] extends true ? DeviceSettingsContribution : Record<never, never>) & (T extends {
810
841
  status: CapabilityStatusSchema;
811
842
  } ? DeviceStatusContribution<InferStatus<T>> : Record<never, never>);
@@ -935,6 +966,15 @@ export declare function method<TIn extends z.ZodType, TOut extends z.ZodType, TK
935
966
  export declare function systemMethod<TIn extends z.ZodType, TOut extends z.ZodType, TKind extends CapabilityMethodKind = 'query'>(input: TIn, output: TOut, options?: CapabilityMethodOptions<TKind>): CapabilityMethodSchema<TIn, TOut, TKind> & {
936
967
  readonly systemOnly: true;
937
968
  };
969
+ /**
970
+ * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
971
+ * on `InferProvider`. The `providerOptional: true` literal is what
972
+ * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
973
+ * for when this is the honest answer and when it is a soft stub.
974
+ */
975
+ export declare function optionalMethod<TIn extends z.ZodType, TOut extends z.ZodType, TKind extends CapabilityMethodKind = 'query'>(input: TIn, output: TOut, options?: CapabilityMethodOptions<TKind>): CapabilityMethodSchema<TIn, TOut, TKind> & {
976
+ readonly providerOptional: true;
977
+ };
938
978
  /** Shorthand to define an event schema */
939
979
  export declare function event<TData extends z.ZodType>(data: TData): CapabilityEventSchema<TData>;
940
980
  /** Type guard: does this cap declare the D14 device-config archetype? */
@@ -38,7 +38,7 @@ export { streamSignalsCapability, type IStreamSignalsProvider, type StreamSignal
38
38
  export { cameraStreamsCapability, type ICameraStreamsProvider, type PickedCamStream, PickedCamStreamSchema, type PickStreamPreferences, PickStreamPreferencesSchema, type PickStreamRequirements, PickStreamRequirementsSchema, type StreamCodec, StreamCodecSchema, } from './camera-streams.cap.js';
39
39
  export { emitsCollectionSelector, extractNestedAddonId, isArrayOutputSchema, isCollectionArrayMethod, isObjectInput, isVoidInput, kebabToCamel, looseSchema, objectInputDeclaresAddonId, objectInputDeclaresRequiredDeviceId, procedureAuthKey, resolveMethodAuth, } from './cap-router-predicates.js';
40
40
  export type { CapabilityDefinition, CapabilityEventSchema, CapabilityMethodAuth, CapabilityMethodCaller, CapabilityMethodKind, CapabilityMethodOptions, CapabilityMethodSchema, CapabilityMountHint, CapabilityMountKind, CapabilityStatusItemArray, CapabilityStatusKind, CapabilityStatusSchema, CapCaller, DeviceConfigDerivedFormUi, DeviceConfigSpec, DeviceConfigUiSpec, DeviceConfigWidgetUi, DeviceSettingsContribution, InferDeviceProxyCap, InferEvents, InferName, InferNativeProvider, InferProvider, InferRuntimeState, ProviderKind, RuntimeStateDurability, UiContribution, UiContributionKind, UiContributionRemote, } from './capability-definition.js';
41
- export { DEFAULT_RUNTIME_STATE_DURABILITY, DEVICE_SETTINGS_CONTRIBUTION_METHODS, DEVICE_STATUS_METHOD, event, expandCapMethods, isDeviceConfigCap, method, resolveCapMount, } from './capability-definition.js';
41
+ export { DEFAULT_RUNTIME_STATE_DURABILITY, DEVICE_SETTINGS_CONTRIBUTION_METHODS, DEVICE_STATUS_METHOD, event, expandCapMethods, isDeviceConfigCap, method, optionalMethod, resolveCapMount, } from './capability-definition.js';
42
42
  export { CORE_BLOCK_ADDON_PREFIX, CORE_BLOCKS_ADDON_ID, type CoreBlock, type CoreBlockCompileResult, CoreBlockCompileResultSchema, type CoreBlockInput, CoreBlockInputSchema, type CoreBlockPlacement, CoreBlockPlacementSchema, CoreBlockSchema, type CoreBlockStatus, CoreBlockStatusSchema, coreBlockAddonId, coreBlockIdFromAddonId, coreBlocksCapability, type ICoreBlocksProvider, } from './core-blocks.cap.js';
43
43
  export * from './custom-actions.js';
44
44
  export type { CustomModelDescriptor, ICustomModelRegistryProvider, } from './custom-model-registry.cap.js';
@@ -116,8 +116,8 @@ export type { IUserPasskeysProvider, PasskeySummary } from './user-passkeys.cap.
116
116
  export { PasskeySummarySchema, userPasskeysCapability } from './user-passkeys.cap.js';
117
117
  export type { IVectorStoreProvider } from './vector-store.cap.js';
118
118
  export { VectorDeclareIndexInputSchema, VectorDeleteByFilterInputSchema, VectorDeleteInputSchema, VectorDeleteResultSchema, type VectorFilter, VectorFilterSchema, VectorGetInputSchema, VectorGetResultSchema, type VectorItem, VectorItemSchema, type VectorMatch, VectorMatchSchema, type VectorMetadata, VectorMetadataSchema, type VectorMetric, VectorMetricSchema, VectorQueryInputSchema, VectorQueryResultSchema, VectorStatsInputSchema, VectorStatsResultSchema, VectorUpsertInputSchema, VectorUpsertResultSchema, vectorStoreCapability, } from './vector-store.cap.js';
119
- export type { Clip, ClipPlayback, ClipSource, ClipSourceAvailability, ClipStillDisposition, ClipStillRefusalCode, IVideoclipsProvider, } from './videoclips.cap.js';
120
- export { CLIP_STILL_DISPOSITION_HEADER, CLIP_STILL_REASON_CODE_HEADER, CLIP_STILL_REASON_HEADER, ClipPlaybackSchema, ClipSchema, ClipSourceAvailabilitySchema, ClipSourceSchema, ClipStillDispositionSchema, ClipStillRefusalCodeSchema, MAX_CLIP_EVENT_IDS, MAX_CLIP_LABELS, videoclipsCapability, } from './videoclips.cap.js';
119
+ export type { Clip, ClipBytes, ClipPlayback, ClipSource, ClipSourceAvailability, ClipStillDisposition, ClipStillRefusalCode, ClipWake, IVideoclipsProvider, } from './videoclips.cap.js';
120
+ export { CLIP_STILL_DISPOSITION_HEADER, CLIP_STILL_REASON_CODE_HEADER, CLIP_STILL_REASON_HEADER, ClipBytesSchema, ClipPlaybackSchema, ClipSchema, ClipSourceAvailabilitySchema, ClipSourceSchema, ClipStillDispositionSchema, ClipStillRefusalCodeSchema, ClipWakeSchema, MAX_CLIP_EVENT_IDS, MAX_CLIP_LABELS, VIDEOCLIPS_MAX_READ_BYTES, videoclipsCapability, } from './videoclips.cap.js';
121
121
  export type { IViewerUiProvider } from './viewer-ui.cap.js';
122
122
  export { viewerUiCapability } from './viewer-ui.cap.js';
123
123
  export { type IWebrtcSessionProvider, type WebrtcClientHints, type WebrtcLadderDecision, WebrtcLadderDecisionSchema, type WebrtcSessionDebug, WebrtcSessionDebugSchema, type WebrtcStreamChoice, WebrtcStreamChoiceSchema, type WebrtcStreamTarget, WebrtcStreamTargetSchema, type WebrtcTierFailure, WebrtcTierFailureSchema, webrtcClientHintsSchema, webrtcSessionCapability, } from './webrtc-session.cap.js';
@@ -191,7 +191,7 @@ export { type IPtzProvider, type PtzHomePreset, PtzHomePresetSchema, type PtzHom
191
191
  export { type IPtzAutotrackProvider, type PtzAutotrackRuntimeState, PtzAutotrackRuntimeStateSchema, type PtzAutotrackSettings, PtzAutotrackSettingsSchema, type PtzAutotrackStatus, PtzAutotrackStatusSchema, type PtzAutotrackTargetOption, PtzAutotrackTargetOptionSchema, ptzAutotrackCapability, } from './ptz-autotrack.cap.js';
192
192
  export { type IRebootProvider, rebootCapability } from './reboot.cap.js';
193
193
  export { type IRecordingProvider, type LocateSegmentResult, LocateSegmentResultSchema, RECORDING_TIMELINE_BATCH_MAX, type ReadGopBytesResult, ReadGopBytesResultSchema, type ReadSegmentBytesResult, ReadSegmentBytesResultSchema, type ReadWindowBytesResult, ReadWindowBytesResultSchema, type RecordingAvailability, type RecordingAvailabilityForDevice, RecordingAvailabilityForDeviceSchema, RecordingAvailabilitySchema, type RecordingDays, type RecordingDaysForDevice, RecordingDaysForDeviceSchema, RecordingDaysSchema, type RecordingDeviceUsage, RecordingDeviceUsageSchema, type RecordingLocationUsage, RecordingLocationUsageSchema, type RecordingManifest, RecordingManifestSchema, RecordingRangeSchema, type RecordingRebalanceInput, RecordingRebalanceInputSchema, type RecordingRebalanceMove, RecordingRebalanceMoveSchema, type RecordingRebalancePlan, RecordingRebalancePlanSchema, type RecordingRebalanceSkip, type RecordingRebalanceSkipReason, RecordingRebalanceSkipReasonSchema, RecordingRebalanceSkipSchema, type RecordingStatus, RecordingStatusSchema, type RecordingStorageUsage, RecordingStorageUsageSchema, recordingCapability, } from './recording.cap.js';
194
- export { EXPORT_DENSE_MAX_RANGES, type ExportBytes, ExportBytesSchema, type ExportDense, type ExportDenseRange, ExportDenseRangeSchema, ExportDenseSchema, type ExportDownload, ExportDownloadSchema, type ExportOptions, ExportOptionsSchema, type ExportRecord, ExportRecordSchema, ExportSpeedSchema, type ExportState, ExportStateSchema, ExportTimelapseSchema, type IRecordingExportProvider, RECORDING_EXPORT_MAX_READ_BYTES, recordingExportCapability, } from './recording-export.cap.js';
194
+ export { clipExportFailure, type ClipExportFailure, ClipExportFailureSchema, clipExportFailureOf, EXPORT_DENSE_MAX_RANGES, type ExportBytes, ExportBytesSchema, type ExportClipSubject, ExportClipSubjectSchema, type ExportDense, type ExportDenseRange, ExportDenseRangeSchema, ExportDenseSchema, type ExportDownload, ExportDownloadSchema, type ExportFootageSubject, ExportFootageSubjectSchema, type ExportOptions, ExportOptionsSchema, type ExportRecord, ExportRecordSchema, ExportSpeedSchema, type ExportState, ExportStateSchema, type ExportSubject, ExportSubjectSchema, exportSubjectOf, ExportTimelapseSchema, type IRecordingExportProvider, RECORDING_EXPORT_MAX_READ_BYTES, recordingExportCapability, resolveCreateExportSubject, resolveExportProfiles, } from './recording-export.cap.js';
195
195
  export { type IRecordingSignalProvider, type RecordingSignalRuntimeState, RecordingSignalRuntimeStateSchema, type RecordingSignalStatus, RecordingSignalStatusSchema, recordingSignalCapability, } from './recording-signal.cap.js';
196
196
  export { type ISceneMonitorProvider, SCENE_CONDITIONS, SCENE_CONFIRM_DEFAULT_MAX_IMAGE_PX, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS, SCENE_DEFAULT_ANCHOR_THRESHOLD, SCENE_DEFAULT_CHECK_INTERVAL_SEC, SCENE_DEFAULT_OBSERVATION_SPACING_SEC, SCENE_DEFAULT_QUIET_SECONDS, SCENE_DEFAULT_UNCOVERED_POLICY, SCENE_DIVERGED, SCENE_RESET_RECAPTURES, type SceneCheck, SceneCheckSchema, type SceneCondition, SceneConditionSchema, type SceneConfirm, SceneConfirmSchema, type SceneMonitor, SceneMonitorSchema, type SceneMonitorState, SceneMonitorStateSchema, type SceneMonitorStatus, type SceneMonitorStatusForDevice, SceneMonitorStatusForDeviceSchema, SceneMonitorStatusSchema, type SceneReference, SceneReferenceSchema, type SceneUnavailable, SceneUnavailableSchema, type SceneUncoveredPolicy, SceneUncoveredPolicySchema, type SceneVerdict, SceneVerdictSchema, sceneMonitorCapability, } from './scene-monitor.cap.js';
197
197
  export { type ZoneRule, type ZoneRuleMode, ZoneRuleModeEnum, ZoneRuleSchema, type ZoneRules, ZoneRulesArraySchema, } from './schemas/zone-rule.js';
@@ -113,13 +113,156 @@ export declare const ExportStateSchema: z.ZodEnum<{
113
113
  expired: "expired";
114
114
  }>;
115
115
  export type ExportState = z.infer<typeof ExportStateSchema>;
116
- /** One export job / history row. */
116
+ /**
117
+ * A stretch of footage THIS system recorded — the only thing `createExport`
118
+ * could export before D558, and still the shape every legacy caller sends.
119
+ */
120
+ export declare const ExportFootageSubjectSchema: z.ZodObject<{
121
+ kind: z.ZodLiteral<"footage">;
122
+ deviceId: z.ZodNumber;
123
+ profiles: z.ZodArray<z.ZodString>;
124
+ fromMs: z.ZodNumber;
125
+ toMs: z.ZodNumber;
126
+ }, z.core.$strip>;
127
+ export type ExportFootageSubject = z.infer<typeof ExportFootageSubjectSchema>;
128
+ /**
129
+ * A CLIP — a finished file with boundaries the camera chose, listed by one of
130
+ * the device's `videoclips` sources.
131
+ *
132
+ * There is deliberately **no `fromMs`/`toMs` here**. The camera chose them,
133
+ * no surface on this path asks for them (there is no drag and no
134
+ * `datetime-local` pair — D558 § 5.4.3), and they reach the record only as the
135
+ * projection. A range in the subject would be a second place the boundaries
136
+ * live and the one a caller could get wrong.
137
+ *
138
+ * `provider` is the **addonId** of the source's serving addon — the `provider`
139
+ * pin `videoclips.listClips` REQUIRES since D554 was amended on 2026-09-20.
140
+ * There was never a default: a bare call fanned out and returned the union of
141
+ * every source with `limit` meaning `limit × sources`. The catalog check that
142
+ * validates this subject names it, so it asks exactly the source the operator
143
+ * picked.
144
+ *
145
+ * `source` is that source's id (the namespace `clipId` is prefixed with), and
146
+ * `sourceLabel` is its operator-facing name FROZEN at creation — a history row
147
+ * still reads "SD card" after the source is unbound.
148
+ *
149
+ * `profile` is exactly ONE, and it is what was ASKED. What was SERVED lands on
150
+ * the record's top-level `profile`, so a clip with no main twin renders the
151
+ * divergence instead of hiding it (D549 15; measured on 592, 17 of 546 clips
152
+ * had no main twin, so a silent fallback would be right 96.9 % of the time).
153
+ * `auto` is not a member: a stored file has no broker session, so the adaptive
154
+ * tier cannot be resolved for it.
155
+ */
156
+ export declare const ExportClipSubjectSchema: z.ZodObject<{
157
+ kind: z.ZodLiteral<"clip">;
158
+ deviceId: z.ZodNumber;
159
+ provider: z.ZodString;
160
+ source: z.ZodString;
161
+ sourceLabel: z.ZodString;
162
+ clipId: z.ZodString;
163
+ catalogWindow: z.ZodObject<{
164
+ sinceMs: z.ZodNumber;
165
+ untilMs: z.ZodNumber;
166
+ }, z.core.$strip>;
167
+ profile: z.ZodEnum<{
168
+ high: "high";
169
+ mid: "mid";
170
+ low: "low";
171
+ }>;
172
+ wake: z.ZodOptional<z.ZodEnum<{
173
+ authorised: "authorised";
174
+ }>>;
175
+ }, z.core.$strip>;
176
+ export type ExportClipSubject = z.infer<typeof ExportClipSubjectSchema>;
177
+ /**
178
+ * WHAT an export is — the authority, as opposed to the four top-level fields
179
+ * the Library sorts and labels on (D558 § 2.2).
180
+ *
181
+ * Read it through {@link exportSubjectOf}, never off the record directly: the
182
+ * field is optional for the history rows written before it existed, and that
183
+ * absence has exactly one interpreter.
184
+ */
185
+ export declare const ExportSubjectSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
186
+ kind: z.ZodLiteral<"footage">;
187
+ deviceId: z.ZodNumber;
188
+ profiles: z.ZodArray<z.ZodString>;
189
+ fromMs: z.ZodNumber;
190
+ toMs: z.ZodNumber;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ kind: z.ZodLiteral<"clip">;
193
+ deviceId: z.ZodNumber;
194
+ provider: z.ZodString;
195
+ source: z.ZodString;
196
+ sourceLabel: z.ZodString;
197
+ clipId: z.ZodString;
198
+ catalogWindow: z.ZodObject<{
199
+ sinceMs: z.ZodNumber;
200
+ untilMs: z.ZodNumber;
201
+ }, z.core.$strip>;
202
+ profile: z.ZodEnum<{
203
+ high: "high";
204
+ mid: "mid";
205
+ low: "low";
206
+ }>;
207
+ wake: z.ZodOptional<z.ZodEnum<{
208
+ authorised: "authorised";
209
+ }>>;
210
+ }, z.core.$strip>], "kind">;
211
+ export type ExportSubject = z.infer<typeof ExportSubjectSchema>;
212
+ /**
213
+ * One export job / history row.
214
+ *
215
+ * **`subject` is the AUTHORITY on what was exported. `deviceId`, `profile`,
216
+ * `fromMs` and `toMs` are its PROJECTION** — kept top-level because the whole
217
+ * Library sorts and labels on them (`library-items.ts` orders an export by
218
+ * `fromMs`; `export-format.ts` draws `rangeLabel` from the pair), and a row
219
+ * that did not fill them would sort under the epoch and render a blank range.
220
+ * Write to the subject and read from the projection and the two will disagree;
221
+ * the projection is derived at creation and never edited afterwards.
222
+ *
223
+ * And they mean DIFFERENT FACTS for the two kinds, which is the part a reader
224
+ * who knows only the recording export will get wrong:
225
+ *
226
+ * | field | `kind:'footage'` | `kind:'clip'` |
227
+ * | --- | --- | --- |
228
+ * | `fromMs`/`toMs` | the stretch the operator ASKED for | the camera's own boundaries, always `clip.timeRange`, never anything a caller supplied |
229
+ * | `profile` | the stream rendered | the twin actually SERVED (`subject.profile` is the one asked for) |
230
+ *
231
+ * Same type, different fact — the shape this repo keeps getting wrong (D385's
232
+ * two authorities, D224's second copy).
233
+ */
117
234
  export declare const ExportRecordSchema: z.ZodObject<{
118
235
  id: z.ZodString;
119
236
  deviceId: z.ZodNumber;
120
237
  profile: z.ZodString;
121
238
  fromMs: z.ZodNumber;
122
239
  toMs: z.ZodNumber;
240
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
241
+ kind: z.ZodLiteral<"footage">;
242
+ deviceId: z.ZodNumber;
243
+ profiles: z.ZodArray<z.ZodString>;
244
+ fromMs: z.ZodNumber;
245
+ toMs: z.ZodNumber;
246
+ }, z.core.$strip>, z.ZodObject<{
247
+ kind: z.ZodLiteral<"clip">;
248
+ deviceId: z.ZodNumber;
249
+ provider: z.ZodString;
250
+ source: z.ZodString;
251
+ sourceLabel: z.ZodString;
252
+ clipId: z.ZodString;
253
+ catalogWindow: z.ZodObject<{
254
+ sinceMs: z.ZodNumber;
255
+ untilMs: z.ZodNumber;
256
+ }, z.core.$strip>;
257
+ profile: z.ZodEnum<{
258
+ high: "high";
259
+ mid: "mid";
260
+ low: "low";
261
+ }>;
262
+ wake: z.ZodOptional<z.ZodEnum<{
263
+ authorised: "authorised";
264
+ }>>;
265
+ }, z.core.$strip>], "kind">>;
123
266
  options: z.ZodObject<{
124
267
  speed: z.ZodOptional<z.ZodNumber>;
125
268
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -157,6 +300,43 @@ export declare const ExportRecordSchema: z.ZodObject<{
157
300
  error: z.ZodNullable<z.ZodString>;
158
301
  }, z.core.$strip>;
159
302
  export type ExportRecord = z.infer<typeof ExportRecordSchema>;
303
+ /**
304
+ * Every way a clip export can fail, as a TOKEN — never prose.
305
+ *
306
+ * A branch that accepts work and produces nothing is the branch this repo
307
+ * keeps losing work in (D391), and a clip export has five places to lose it
308
+ * that a recording export does not have. The token is what a surface may key
309
+ * a table on; the PROSE — the camera's own words, the source's verbatim
310
+ * refusal — travels with it, in the same `ExportRecord.error` string, after a
311
+ * `: `. Two separate things in one field because the field is one field:
312
+ * `ClipStillRefusalCodeSchema` split them across two HTTP headers for the same
313
+ * reason, and the surface that keyed on the whole header rendered every
314
+ * refusal on this fleet as `Refused: <prose>`.
315
+ *
316
+ * Compose with {@link clipExportFailure}, read back with
317
+ * {@link clipExportFailureOf}. Never hand-spell the separator.
318
+ */
319
+ export declare const ClipExportFailureSchema: z.ZodEnum<{
320
+ sleeping: "sleeping";
321
+ "camera-refused": "camera-refused";
322
+ "catalog-miss": "catalog-miss";
323
+ "catalog-unreachable": "catalog-unreachable";
324
+ "no-file-for-window": "no-file-for-window";
325
+ "clip-in-progress": "clip-in-progress";
326
+ "unsupported-option": "unsupported-option";
327
+ "fetch-failed": "fetch-failed";
328
+ "too-large-to-transfer": "too-large-to-transfer";
329
+ "wake-expired": "wake-expired";
330
+ }>;
331
+ export type ClipExportFailure = z.infer<typeof ClipExportFailureSchema>;
332
+ /** `<token>: <prose>` — the ONE composition of a clip export's failure string. */
333
+ export declare function clipExportFailure(code: ClipExportFailure, detail: string): string;
334
+ /**
335
+ * The token out of an {@link ExportRecord.error}, or null when the string did
336
+ * not come from {@link clipExportFailure} (every footage failure, and every
337
+ * error thrown by something that never heard of this vocabulary).
338
+ */
339
+ export declare function clipExportFailureOf(error: string | null): ClipExportFailure | null;
160
340
  /** Candidate download URLs (LAN first, then operator extra hosts). */
161
341
  export declare const ExportDownloadSchema: z.ZodObject<{
162
342
  url: z.ZodString;
@@ -195,28 +375,68 @@ export declare const ExportBytesSchema: z.ZodObject<{
195
375
  bytes: z.ZodNumber;
196
376
  }, z.core.$strip>;
197
377
  export type ExportBytes = z.infer<typeof ExportBytesSchema>;
378
+ /** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
379
+ export declare function resolveExportProfiles(input: {
380
+ readonly profile?: string;
381
+ readonly profiles?: readonly string[];
382
+ }): string[];
198
383
  /**
199
- * Rewrite a legacy `{ profile }` into `{ profiles: [profile] }` so one parse
200
- * path serves both the multi-stream picker and the timelapse scheduler.
384
+ * `createExport` input — ONE object carrying an optional {@link ExportSubject},
385
+ * never a union of two inputs.
201
386
  *
202
- * Kept as a named function (not `z.preprocess` wrapping the method input)
203
- * because generated routers call `.input.loose()` — a ZodObject method that a
204
- * preprocess/pipe schema does not have. The object schema still *accepts* the
205
- * singular field; this helper is the explicit rewrite the tests pin.
206
- */
207
- export declare function preprocessCreateExportInput(raw: unknown): unknown;
208
- /**
209
- * `createExport` input. `profiles` is the canonical field (min 1). A legacy
210
- * singular `profile` is still accepted so existing callers do not break.
387
+ * It has to be a ZodObject: generated routers call `.input.loose()` so the
388
+ * out-of-band `nodeId` selector survives the wire parse, and `.loose()` is a
389
+ * ZodObject method a `z.discriminatedUnion` does not have. That is why the
390
+ * discriminant sits one level down, in `subject`, and why
391
+ * {@link resolveCreateExportSubject} — not a `z.preprocess` wrapper, which
392
+ * would have produced a schema with no `.loose()` — is the one reading of a
393
+ * legacy flat input as a subject.
211
394
  *
212
- * Must remain a ZodObject (`.loose()` for out-of-band `nodeId`).
395
+ * **`deviceId` stays REQUIRED at the top level**, for both kinds, and a clip
396
+ * subject naming a different one is REFUSED. Not symmetry: `METHOD_DEVICE_SELECTORS`
397
+ * (generated) maps top-level fields and one-level object arrays, so per-device
398
+ * scope enforcement in `scope-access.ts` reads THIS field and cannot see
399
+ * `subject.deviceId`. A deviceId that lived only in the subject would let a
400
+ * principal scoped to one camera create an export — and, on the clip path, a
401
+ * WAKE — for another.
402
+ *
403
+ * **A clip carries no time range**, and one supplied alongside a clip subject
404
+ * is refused rather than ignored: there is no drag on this path and nothing to
405
+ * normalise (D558 § 5.4.3). The record's `fromMs`/`toMs` come from the clip's
406
+ * own `timeRange` and from nowhere else.
213
407
  */
214
408
  export declare const CreateExportInputSchema: z.ZodObject<{
215
409
  deviceId: z.ZodNumber;
216
410
  profile: z.ZodOptional<z.ZodString>;
217
411
  profiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
218
- fromMs: z.ZodNumber;
219
- toMs: z.ZodNumber;
412
+ fromMs: z.ZodOptional<z.ZodNumber>;
413
+ toMs: z.ZodOptional<z.ZodNumber>;
414
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
415
+ kind: z.ZodLiteral<"footage">;
416
+ deviceId: z.ZodNumber;
417
+ profiles: z.ZodArray<z.ZodString>;
418
+ fromMs: z.ZodNumber;
419
+ toMs: z.ZodNumber;
420
+ }, z.core.$strip>, z.ZodObject<{
421
+ kind: z.ZodLiteral<"clip">;
422
+ deviceId: z.ZodNumber;
423
+ provider: z.ZodString;
424
+ source: z.ZodString;
425
+ sourceLabel: z.ZodString;
426
+ clipId: z.ZodString;
427
+ catalogWindow: z.ZodObject<{
428
+ sinceMs: z.ZodNumber;
429
+ untilMs: z.ZodNumber;
430
+ }, z.core.$strip>;
431
+ profile: z.ZodEnum<{
432
+ high: "high";
433
+ mid: "mid";
434
+ low: "low";
435
+ }>;
436
+ wake: z.ZodOptional<z.ZodEnum<{
437
+ authorised: "authorised";
438
+ }>>;
439
+ }, z.core.$strip>], "kind">>;
220
440
  options: z.ZodObject<{
221
441
  speed: z.ZodOptional<z.ZodNumber>;
222
442
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -238,20 +458,87 @@ export declare const CreateExportInputSchema: z.ZodObject<{
238
458
  }, z.core.$strip>;
239
459
  }, z.core.$strip>;
240
460
  export type CreateExportInput = z.infer<typeof CreateExportInputSchema>;
461
+ /**
462
+ * The ONE reading of a `createExport` input as a {@link ExportSubject}.
463
+ *
464
+ * Every consumer goes through this: a provider that branched on
465
+ * `input.subject !== undefined` in one place and on `input.fromMs` in another
466
+ * would be two authorities on what was asked for, which is how the flat fields
467
+ * and the subject drift apart.
468
+ *
469
+ * Throws on a footage input with no range — an input that parsed cannot reach
470
+ * that, and a caller that skipped the parse gets a named refusal rather than
471
+ * `NaN` boundaries on a durable row.
472
+ */
473
+ export declare function resolveCreateExportSubject(input: CreateExportInput): ExportSubject;
474
+ /**
475
+ * The ONE interpreter of a stored row's subject.
476
+ *
477
+ * `ExportRecord.subject` is optional for exactly one reason — the history rows
478
+ * written before D558 — and "absent means footage, built from the projection"
479
+ * is a statement that must live in one place. Anything that reads
480
+ * `rec.subject` directly and falls back inline is the second authority.
481
+ */
482
+ export declare function exportSubjectOf(rec: ExportRecord): ExportSubject;
241
483
  export declare const recordingExportCapability: {
242
484
  readonly name: "recording-export";
243
485
  readonly scope: "system";
244
486
  readonly mode: "singleton";
245
487
  readonly methods: {
246
- /** Queue a render of `[fromMs,toMs)` for `deviceId`/`profiles` (legacy
247
- * singular `profile` still accepted). Fails fast when no footage covers
248
- * the range. One job per profile; returns the first queued record. */
488
+ /**
489
+ * Queue an export of {@link ExportSubjectSchema}.
490
+ *
491
+ * `kind:'footage'` — a render of `[fromMs,toMs)` for `deviceId`/`profiles`
492
+ * (legacy flat input, singular `profile` included, still accepted and
493
+ * rewritten). Fails fast when no footage covers the range. One job per
494
+ * profile; **returns the first queued record and the others are reachable
495
+ * only through `listExports`** — a defect named in D558 § 6.3 and the
496
+ * reason a clip subject carries exactly ONE profile.
497
+ *
498
+ * `kind:'clip'` — a finished file the camera holds, validated against the
499
+ * device's clip CATALOG (`videoclips.listClips`, at the subject's
500
+ * `provider`) instead of the recording index, and fetched once by handle
501
+ * under a bound. Its `fromMs`/`toMs` come from the catalog row and from
502
+ * nowhere else; a caller supplying a range is refused.
503
+ *
504
+ * A clip export reuses the six {@link ExportStateSchema} members and adds
505
+ * none: the viewer maps an unknown state string to `failed`, so a seventh
506
+ * member renders every live export — of both kinds — as FAILED on every
507
+ * installed app (D558 § 6.1, pinned by `export-state-members.spec.ts`).
508
+ * `subject.kind` is what tells a surface what `rendering` means.
509
+ */
249
510
  readonly createExport: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
250
511
  deviceId: z.ZodNumber;
251
512
  profile: z.ZodOptional<z.ZodString>;
252
513
  profiles: z.ZodOptional<z.ZodArray<z.ZodString>>;
253
- fromMs: z.ZodNumber;
254
- toMs: z.ZodNumber;
514
+ fromMs: z.ZodOptional<z.ZodNumber>;
515
+ toMs: z.ZodOptional<z.ZodNumber>;
516
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
517
+ kind: z.ZodLiteral<"footage">;
518
+ deviceId: z.ZodNumber;
519
+ profiles: z.ZodArray<z.ZodString>;
520
+ fromMs: z.ZodNumber;
521
+ toMs: z.ZodNumber;
522
+ }, z.core.$strip>, z.ZodObject<{
523
+ kind: z.ZodLiteral<"clip">;
524
+ deviceId: z.ZodNumber;
525
+ provider: z.ZodString;
526
+ source: z.ZodString;
527
+ sourceLabel: z.ZodString;
528
+ clipId: z.ZodString;
529
+ catalogWindow: z.ZodObject<{
530
+ sinceMs: z.ZodNumber;
531
+ untilMs: z.ZodNumber;
532
+ }, z.core.$strip>;
533
+ profile: z.ZodEnum<{
534
+ high: "high";
535
+ mid: "mid";
536
+ low: "low";
537
+ }>;
538
+ wake: z.ZodOptional<z.ZodEnum<{
539
+ authorised: "authorised";
540
+ }>>;
541
+ }, z.core.$strip>], "kind">>;
255
542
  options: z.ZodObject<{
256
543
  speed: z.ZodOptional<z.ZodNumber>;
257
544
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -277,6 +564,32 @@ export declare const recordingExportCapability: {
277
564
  profile: z.ZodString;
278
565
  fromMs: z.ZodNumber;
279
566
  toMs: z.ZodNumber;
567
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
568
+ kind: z.ZodLiteral<"footage">;
569
+ deviceId: z.ZodNumber;
570
+ profiles: z.ZodArray<z.ZodString>;
571
+ fromMs: z.ZodNumber;
572
+ toMs: z.ZodNumber;
573
+ }, z.core.$strip>, z.ZodObject<{
574
+ kind: z.ZodLiteral<"clip">;
575
+ deviceId: z.ZodNumber;
576
+ provider: z.ZodString;
577
+ source: z.ZodString;
578
+ sourceLabel: z.ZodString;
579
+ clipId: z.ZodString;
580
+ catalogWindow: z.ZodObject<{
581
+ sinceMs: z.ZodNumber;
582
+ untilMs: z.ZodNumber;
583
+ }, z.core.$strip>;
584
+ profile: z.ZodEnum<{
585
+ high: "high";
586
+ mid: "mid";
587
+ low: "low";
588
+ }>;
589
+ wake: z.ZodOptional<z.ZodEnum<{
590
+ authorised: "authorised";
591
+ }>>;
592
+ }, z.core.$strip>], "kind">>;
280
593
  options: z.ZodObject<{
281
594
  speed: z.ZodOptional<z.ZodNumber>;
282
595
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -322,6 +635,32 @@ export declare const recordingExportCapability: {
322
635
  profile: z.ZodString;
323
636
  fromMs: z.ZodNumber;
324
637
  toMs: z.ZodNumber;
638
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
639
+ kind: z.ZodLiteral<"footage">;
640
+ deviceId: z.ZodNumber;
641
+ profiles: z.ZodArray<z.ZodString>;
642
+ fromMs: z.ZodNumber;
643
+ toMs: z.ZodNumber;
644
+ }, z.core.$strip>, z.ZodObject<{
645
+ kind: z.ZodLiteral<"clip">;
646
+ deviceId: z.ZodNumber;
647
+ provider: z.ZodString;
648
+ source: z.ZodString;
649
+ sourceLabel: z.ZodString;
650
+ clipId: z.ZodString;
651
+ catalogWindow: z.ZodObject<{
652
+ sinceMs: z.ZodNumber;
653
+ untilMs: z.ZodNumber;
654
+ }, z.core.$strip>;
655
+ profile: z.ZodEnum<{
656
+ high: "high";
657
+ mid: "mid";
658
+ low: "low";
659
+ }>;
660
+ wake: z.ZodOptional<z.ZodEnum<{
661
+ authorised: "authorised";
662
+ }>>;
663
+ }, z.core.$strip>], "kind">>;
325
664
  options: z.ZodObject<{
326
665
  speed: z.ZodOptional<z.ZodNumber>;
327
666
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -366,6 +705,32 @@ export declare const recordingExportCapability: {
366
705
  profile: z.ZodString;
367
706
  fromMs: z.ZodNumber;
368
707
  toMs: z.ZodNumber;
708
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
709
+ kind: z.ZodLiteral<"footage">;
710
+ deviceId: z.ZodNumber;
711
+ profiles: z.ZodArray<z.ZodString>;
712
+ fromMs: z.ZodNumber;
713
+ toMs: z.ZodNumber;
714
+ }, z.core.$strip>, z.ZodObject<{
715
+ kind: z.ZodLiteral<"clip">;
716
+ deviceId: z.ZodNumber;
717
+ provider: z.ZodString;
718
+ source: z.ZodString;
719
+ sourceLabel: z.ZodString;
720
+ clipId: z.ZodString;
721
+ catalogWindow: z.ZodObject<{
722
+ sinceMs: z.ZodNumber;
723
+ untilMs: z.ZodNumber;
724
+ }, z.core.$strip>;
725
+ profile: z.ZodEnum<{
726
+ high: "high";
727
+ mid: "mid";
728
+ low: "low";
729
+ }>;
730
+ wake: z.ZodOptional<z.ZodEnum<{
731
+ authorised: "authorised";
732
+ }>>;
733
+ }, z.core.$strip>], "kind">>;
369
734
  options: z.ZodObject<{
370
735
  speed: z.ZodOptional<z.ZodNumber>;
371
736
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -411,6 +776,32 @@ export declare const recordingExportCapability: {
411
776
  profile: z.ZodString;
412
777
  fromMs: z.ZodNumber;
413
778
  toMs: z.ZodNumber;
779
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
780
+ kind: z.ZodLiteral<"footage">;
781
+ deviceId: z.ZodNumber;
782
+ profiles: z.ZodArray<z.ZodString>;
783
+ fromMs: z.ZodNumber;
784
+ toMs: z.ZodNumber;
785
+ }, z.core.$strip>, z.ZodObject<{
786
+ kind: z.ZodLiteral<"clip">;
787
+ deviceId: z.ZodNumber;
788
+ provider: z.ZodString;
789
+ source: z.ZodString;
790
+ sourceLabel: z.ZodString;
791
+ clipId: z.ZodString;
792
+ catalogWindow: z.ZodObject<{
793
+ sinceMs: z.ZodNumber;
794
+ untilMs: z.ZodNumber;
795
+ }, z.core.$strip>;
796
+ profile: z.ZodEnum<{
797
+ high: "high";
798
+ mid: "mid";
799
+ low: "low";
800
+ }>;
801
+ wake: z.ZodOptional<z.ZodEnum<{
802
+ authorised: "authorised";
803
+ }>>;
804
+ }, z.core.$strip>], "kind">>;
414
805
  options: z.ZodObject<{
415
806
  speed: z.ZodOptional<z.ZodNumber>;
416
807
  timelapse: z.ZodOptional<z.ZodObject<{
@@ -456,6 +847,32 @@ export declare const recordingExportCapability: {
456
847
  profile: z.ZodString;
457
848
  fromMs: z.ZodNumber;
458
849
  toMs: z.ZodNumber;
850
+ subject: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
851
+ kind: z.ZodLiteral<"footage">;
852
+ deviceId: z.ZodNumber;
853
+ profiles: z.ZodArray<z.ZodString>;
854
+ fromMs: z.ZodNumber;
855
+ toMs: z.ZodNumber;
856
+ }, z.core.$strip>, z.ZodObject<{
857
+ kind: z.ZodLiteral<"clip">;
858
+ deviceId: z.ZodNumber;
859
+ provider: z.ZodString;
860
+ source: z.ZodString;
861
+ sourceLabel: z.ZodString;
862
+ clipId: z.ZodString;
863
+ catalogWindow: z.ZodObject<{
864
+ sinceMs: z.ZodNumber;
865
+ untilMs: z.ZodNumber;
866
+ }, z.core.$strip>;
867
+ profile: z.ZodEnum<{
868
+ high: "high";
869
+ mid: "mid";
870
+ low: "low";
871
+ }>;
872
+ wake: z.ZodOptional<z.ZodEnum<{
873
+ authorised: "authorised";
874
+ }>>;
875
+ }, z.core.$strip>], "kind">>;
459
876
  options: z.ZodObject<{
460
877
  speed: z.ZodOptional<z.ZodNumber>;
461
878
  timelapse: z.ZodOptional<z.ZodObject<{