@camstack/addon-provider-reolink 1.2.229 → 1.2.230

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.mjs CHANGED
@@ -106669,7 +106669,7 @@ var ZodIssueCode = {
106669
106669
  var ZodFirstPartyTypeKind;
106670
106670
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106671
106671
  //#endregion
106672
- //#region ../types/dist/sleep-DEZaLbiu.mjs
106672
+ //#region ../types/dist/sleep-BX_MqzUe.mjs
106673
106673
  /**
106674
106674
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106675
106675
  * window to float samples (D455).
@@ -108298,6 +108298,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
108298
108298
  /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
108299
108299
  var SECRET_CHANGE_DEBOUNCE_MS = 250;
108300
108300
  /**
108301
+ * Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
108302
+ * place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
108303
+ * through `api` (guard `check-migration-ports-surface`).
108304
+ */
108305
+ function migrationSet(catalogue, bindPorts) {
108306
+ return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
108307
+ }
108308
+ /** A mixed array is a mistake: the other kind would be dropped without a word. */
108309
+ function refuseMixed(form, kept, dropped) {
108310
+ if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
108311
+ }
108312
+ function catalogueOf(list) {
108313
+ const kept = list.filter((entry) => !("execute" in entry));
108314
+ refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
108315
+ return kept;
108316
+ }
108317
+ function boundOf(list) {
108318
+ const kept = list.filter((entry) => "execute" in entry);
108319
+ refuseMixed("bound migrations", kept.length, list.length - kept.length);
108320
+ return kept;
108321
+ }
108322
+ /**
108301
108323
  * Base class for CamStack addons. Eliminates settings boilerplate:
108302
108324
  *
108303
108325
  * - Typed `config` property with automatic resolution from store + defaults
@@ -108464,23 +108486,21 @@ var BaseAddon = class {
108464
108486
  await this.loadScopedSchemas();
108465
108487
  return normalized;
108466
108488
  }
108489
+ async runMigrations(first, second, third) {
108490
+ if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
108491
+ return this.runBound(boundOf(first), second);
108492
+ }
108467
108493
  /**
108468
- * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
108469
- * engine. Call it at the point of the boot where the data must already have the new
108470
- * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
108471
- * restored devices — with the catalogue bound to the addon's ports
108472
- * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
108473
- *
108474
- * An engine that cannot be reached or refuses the catalogue is logged and runs
108475
- * nothing; the boot continues. A migration that FAILED (or was blocked by one)
108476
- * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
108477
- * serve data whose shape it cannot trust; `tolerate` migrations never do.
108478
- *
108479
- * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
108480
- * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
108481
- * omitted applied ids "newer").
108494
+ * Several catalogues of ONE owner in one declaration (the engine replaces an owner's
108495
+ * catalogue on every declare, so two calls would each judge the other's ids "newer").
108496
+ * Build each entry with `migrationSet(catalogue, (api) => ports)`.
108482
108497
  */
108483
- async runMigrations(migrations, options) {
108498
+ async runMigrationSets(sets, options) {
108499
+ const api = this.ctx.migrationApi;
108500
+ if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
108501
+ return this.runBound(sets.flatMap((set) => set.bind(api)), options);
108502
+ }
108503
+ async runBound(migrations, options) {
108484
108504
  const api = this.ctx.api.migrations;
108485
108505
  const report = await runAddonMigrations({
108486
108506
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -114034,17 +114054,6 @@ var NodeColorIdSchema = _enum([
114034
114054
  "node-g",
114035
114055
  "node-h"
114036
114056
  ]);
114037
- //#endregion
114038
- //#region ../types/dist/index.mjs
114039
- /**
114040
- * The `smtp-inbound` broker kind (D999): a mailbox a device can send mail to.
114041
- *
114042
- * The `broker` cap carries these as `Record<string, unknown>` on the wire; the
114043
- * provider and its consumers parse them with the schemas below at BOTH ends, so
114044
- * the shape is declared once.
114045
- */
114046
- /** The broker kind tag. */
114047
- var SMTP_INBOUND_KIND = "smtp-inbound";
114048
114057
  /** The id the first mailbox is minted under (adopt-id), so a consumer can find it again. */
114049
114058
  var SMTP_INBOUND_DEFAULT_ID = "smtp-inbound-default";
114050
114059
  var SMTP_INBOUND_DEFAULT_PORT = 2525;
@@ -114366,26 +114375,16 @@ var RecordIntegrationInstances = class {
114366
114375
  ...this.hooks.description,
114367
114376
  mintsId: true
114368
114377
  };
114369
- /**
114370
- * The record an id names. A caller holding the `integrations` registry id (the Integrations
114371
- * page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
114372
- * record id answers as it is. An id that names nothing comes back unchanged.
114373
- */
114374
- async resolveRecordId(id) {
114375
- if (await this.handle.get(id) !== null) return id;
114376
- const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
114377
- return linked === void 0 ? id : linked.id;
114378
- }
114379
- instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
114378
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
114380
114379
  listInstances = async () => {
114381
114380
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
114382
114381
  };
114383
114382
  getInstance = async ({ id }) => {
114384
- const record = await this.handle.get(await this.resolveRecordId(id));
114383
+ const record = await this.handle.get(id);
114385
114384
  return record === null ? null : this.viewOf(record);
114386
114385
  };
114387
114386
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
114388
- createInstance = async ({ id, name, kind }) => {
114387
+ createInstance = async ({ id, name, kind, values }) => {
114389
114388
  const minted = id ?? this.hooks.mintId?.({
114390
114389
  name,
114391
114390
  ...kind !== void 0 ? { kind } : {}
@@ -114395,11 +114394,20 @@ var RecordIntegrationInstances = class {
114395
114394
  id: minted,
114396
114395
  data: this.hooks.initialBody(name, kind)
114397
114396
  }, { ifRev: 0 });
114397
+ const patch = this.patchOf(values ?? {});
114398
+ if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
114398
114399
  await this.hooks.onChanged?.(minted, "created");
114399
114400
  return { id: minted };
114400
114401
  };
114401
- updateInstance = async ({ id: askedId, name, values }) => {
114402
- const id = await this.resolveRecordId(askedId);
114402
+ updateInstance = async ({ id, name, values }) => {
114403
+ const patch = this.patchOf(values);
114404
+ if (name !== void 0) patch[this.nameField] = name;
114405
+ await this.handle.patch(id, patch);
114406
+ await this.hooks.onChanged?.(id, "updated");
114407
+ return { ok: true };
114408
+ };
114409
+ /** The record patch a form `values` object means: secrets kept, cleared or replaced. */
114410
+ patchOf(values) {
114403
114411
  const patch = {};
114404
114412
  for (const [key, value] of Object.entries(values)) {
114405
114413
  if (value === void 0) continue;
@@ -114410,11 +114418,8 @@ var RecordIntegrationInstances = class {
114410
114418
  else if (isSecretClear(value)) patch[key] = null;
114411
114419
  else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
114412
114420
  }
114413
- if (name !== void 0) patch[this.nameField] = name;
114414
- await this.handle.patch(id, patch);
114415
- await this.hooks.onChanged?.(id, "updated");
114416
- return { ok: true };
114417
- };
114421
+ return patch;
114422
+ }
114418
114423
  /** The switch lives in the record body; the addon is told so it applies it (D996). */
114419
114424
  setInstanceEnabled = async ({ id, enabled }) => {
114420
114425
  if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
@@ -114434,10 +114439,7 @@ var RecordIntegrationInstances = class {
114434
114439
  status: "unsupported",
114435
114440
  error: "This integration declares no connection test"
114436
114441
  };
114437
- return this.hooks.test(input.id === null ? input : {
114438
- ...input,
114439
- id: await this.resolveRecordId(input.id)
114440
- });
114442
+ return this.hooks.test(input);
114441
114443
  };
114442
114444
  /** The flat provider object to hand to `registerProvider`. */
114443
114445
  toProvider() {
@@ -115750,13 +115752,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
115750
115752
  };
115751
115753
  if (orphans.some((d) => (d.parentDeviceId ?? null) === null) && fallback === null) throw new Error(`${orphans.length} device(s) of '${spec.addonId}' carry no integration and the addon has no integration to claim them to`);
115752
115754
  for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
115753
- for (const id of unresolved) ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
115755
+ for (const id of unresolved) await ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
115754
115756
  for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
115755
115757
  const wrong = [];
115756
115758
  for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
115757
115759
  if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
115758
115760
  const claimed = plan.size;
115759
- ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
115761
+ await ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
115760
115762
  return {
115761
115763
  outcome: claimed > 0 ? "done" : "already-done",
115762
115764
  summary: {
@@ -116972,6 +116974,39 @@ var UnstampedEventMediaCountSchema = object({
116972
116974
  /** Sum across both, or `null` when either lane could not be counted. */
116973
116975
  total: number().int().nonnegative().nullable()
116974
116976
  }).nullable();
116977
+ /**
116978
+ * Where the stored event media sits, per storage location: how many media rows
116979
+ * and how many bytes carry each location id, how many carry none (legacy,
116980
+ * resolved to the default `eventMedia` location), and how many name a location
116981
+ * that was not asked about (a deleted or never-listed one).
116982
+ *
116983
+ * One covering-index aggregate per asked location plus the NULL one, and one
116984
+ * unfiltered total that scans the covering index: O(rows), not a walk of the
116985
+ * rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
116986
+ * it is a deleted location only when every location id was asked.
116987
+ * `null` is "could not be measured", never zero.
116988
+ */
116989
+ var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
116990
+ var MediaLocationCensusSchema = object({
116991
+ locations: array(object({
116992
+ locationId: string(),
116993
+ rows: number().int().nonnegative(),
116994
+ bytes: number().nonnegative()
116995
+ })).readonly(),
116996
+ unstamped: object({
116997
+ rows: number().int().nonnegative(),
116998
+ bytes: number().nonnegative()
116999
+ }),
117000
+ /** Rows stamped with a location id that was not in the asked list. */
117001
+ unlisted: object({
117002
+ rows: number().int().nonnegative(),
117003
+ bytes: number().nonnegative()
117004
+ }),
117005
+ total: object({
117006
+ rows: number().int().nonnegative(),
117007
+ bytes: number().nonnegative()
117008
+ })
117009
+ });
116975
117010
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
116976
117011
  /** The independently selectable logical storage classes — every class
116977
117012
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -148542,52 +148577,7 @@ onBrightnessChanged: { data: object({
148542
148577
  minIntervalMs: 0
148543
148578
  } } }
148544
148579
  };
148545
- /**
148546
- * `broker` — unified pub/sub broker registry, system-scoped collection.
148547
- *
148548
- * The cap models any kind-tagged message broker the user wants to
148549
- * register and that other addons might consume. The first two kinds
148550
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
148551
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
148552
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
148553
- * the same surface.
148554
- *
148555
- * Why one cap, not one cap per kind:
148556
- * - The integrations page wants a single table of "every broker"
148557
- * across kinds; a unified cap drives it without join logic.
148558
- * - Generic admin operations (add / remove / test / status) are
148559
- * identical across kinds — duplicating them per cap was busywork.
148560
- * - The `network-access` cap precedent: same interface, many
148561
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
148562
- *
148563
- * What stays kind-specific:
148564
- * - `getBrokerConfig` payload (kind decides whether it returns
148565
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
148566
- * `Record<string, unknown>` at the wire; consumers narrow.
148567
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
148568
- * key) — also typed as `Record<string, unknown>` so each kind can
148569
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
148570
- * without rebreaking the cap signature.
148571
- * - `add` `settings` payload (different fields per kind, validated by
148572
- * the kind-specific provider).
148573
- *
148574
- * Bidirectionality:
148575
- * - `publish` is RPC — synchronous result (provider-defined).
148576
- * - `subscribe` returns a subscription handle; the actual message
148577
- * stream flows over the typed event-bus as `broker.message` events
148578
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
148579
- * event handler. Subscriptions persist across reconnects — the
148580
- * provider re-subscribes upstream after a transport drop.
148581
- *
148582
- * Why event-bus push (not a subscription RPC stream):
148583
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
148584
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
148585
- * drop is recoverable via `getState({key})`).
148586
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
148587
- * - Cross-process: events already route through `$event-bus`; no
148588
- * per-broker wire-shaping needed.
148589
- */
148590
- var BrokerStatusEnum = _enum([
148580
+ _enum([
148591
148581
  "connected",
148592
148582
  "disconnected",
148593
148583
  "connecting",
@@ -148595,141 +148585,12 @@ var BrokerStatusEnum = _enum([
148595
148585
  "unreachable",
148596
148586
  "error"
148597
148587
  ]);
148598
- var BrokerInfoSchema = object({
148599
- /** Stable broker id. Persisted; survives addon restarts. */
148600
- id: string(),
148601
- /** Addon id of the provider that OWNS this broker.
148602
- *
148603
- * The `broker` cap is a system-scoped collection: several addons
148604
- * register a `broker` provider, each owning a DISJOINT set of
148605
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
148606
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
148607
- * device belongs to one integration. The admin UI threads this id
148608
- * back as the `{ addonId }` system-collection selector on every
148609
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
148610
- * `testConnection`), so the call routes to the OWNING provider
148611
- * instead of defaulting to the first-registered one. */
148612
- addonId: string(),
148613
- /** Human-readable name (operator-chosen at add-time). */
148614
- name: string(),
148615
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
148616
- kind: string(),
148617
- status: BrokerStatusEnum,
148618
- /** Free-form provider-specific info (HA version, MQTT broker
148619
- * flavour, latency, mTLS active, …). */
148620
- info: record(string(), unknown()),
148621
- /** Ms epoch of the last connection probe / status update. */
148622
- lastCheckedAt: number().nullable(),
148623
- /** Last error message, when `status` indicates failure. */
148624
- error: string().nullable()
148625
- });
148626
148588
  var RegistryStatusSchema = object({
148627
148589
  brokerCount: number().int().nonnegative(),
148628
148590
  connectedCount: number().int().nonnegative()
148629
148591
  });
148630
- /**
148631
- * One entry per `broker` provider — which addon provides which broker
148632
- * kind(s). The unified create picker reads this to know, for each
148633
- * (addonId, kind) pair the operator can pick, where to route the
148634
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
148635
- * `{ addonId }` selector). A provider only advertises a kind here when
148636
- * it implements `getSettingsSchema` for that kind (so the picker never
148637
- * offers a kind whose creation form can't be rendered).
148638
- */
148639
- var BrokerProviderInfoSchema = object({
148640
- /** Addon id of the `broker` provider this entry describes. */
148641
- addonId: string(),
148642
- /** Broker kinds this provider can create, with a display label. */
148643
- kinds: array(object({
148644
- kind: string(),
148645
- label: string(),
148646
- /**
148647
- * Relative hub path to start an interactive account link (OAuth popup).
148648
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
148649
- */
148650
- interactiveConnectPath: string().min(1).optional(),
148651
- /** Relative hub path to disconnect the linked account (same popup pattern). */
148652
- interactiveDisconnectPath: string().min(1).optional(),
148653
- /**
148654
- * The kind signs in through a server-held interactive session instead of
148655
- * (or before) typed credentials. `basePath` is a hub-relative route set
148656
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
148657
- * contract: `POST {basePath}/start` (body: the form's settings) answers
148658
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
148659
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
148660
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
148661
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
148662
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
148663
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
148664
- * offers it as the default path; the fields the session fills are
148665
- * marked `filledBySignIn` in the kind's settings schema.
148666
- *
148667
- * `methods` lists the ways the session can sign in, recommended first:
148668
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
148669
- * settings) answering `{ sessionId, userCode, verificationUrl,
148670
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
148671
- * any device, and the same `status` / `commit` / `cancel` routes follow
148672
- * (status then carries `method`, `userCode`, `verificationUrl`,
148673
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
148674
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
148675
- * `['proxy']`.
148676
- */
148677
- signIn: object({
148678
- basePath: string().min(1),
148679
- methods: array(_enum(["device-code", "proxy"])).optional()
148680
- }).optional()
148681
- }))
148682
- });
148683
- var ListInputSchema = object({
148684
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
148685
- * only HA brokers. Omit to list every broker. */
148686
- kind: string().optional() });
148687
148592
  var GetInputSchema = object({ id: string() });
148688
- var AddInputSchema = object({
148689
- kind: string().min(1),
148690
- name: string().min(1),
148691
- /**
148692
- * ADOPT an existing id instead of minting a new one.
148693
- *
148694
- * Written the day this cost an outage. A broker's id is not a detail: HA
148695
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
148696
- * lost from config and re-added as `ha_001` leaves every one of its devices
148697
- * bound to a broker that no longer exists. Re-entering the password under the
148698
- * ORIGINAL id turns a multi-step device migration back into re-entering a
148699
- * password.
148700
- *
148701
- * A provider MUST refuse an id that is already in use — adopting a live
148702
- * broker's id would silently take it over.
148703
- */
148704
- id: string().min(1).optional(),
148705
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
148706
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
148707
- * branch on receipt — invalid shape rejects the add. */
148708
- settings: record(string(), unknown())
148709
- });
148710
- var AddResultSchema = object({ id: string() });
148711
- var RemoveInputSchema = object({ id: string() });
148712
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
148713
- ok: literal(true),
148714
- latencyMs: number().nonnegative()
148715
- }), object({
148716
- ok: literal(false),
148717
- error: string()
148718
- })]);
148719
148593
  var SettingsRecordSchema$1 = record(string(), unknown());
148720
- var SettingsSchemaInputSchema = object({ kind: string() });
148721
- var TestSettingsInputSchema = object({
148722
- kind: string(),
148723
- settings: SettingsRecordSchema$1
148724
- });
148725
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
148726
- ok: literal(true),
148727
- latencyMs: number().nonnegative().optional()
148728
- }).strict(), object({
148729
- ok: literal(false),
148730
- error: string()
148731
- })]);
148732
- var SettingsSchemaResultSchema = unknown().nullable();
148733
148594
  var PublishInputSchema = object({
148734
148595
  brokerId: string(),
148735
148596
  /** Kind-specific routing target.
@@ -148763,25 +148624,7 @@ var GetStateInputSchema = object({
148763
148624
  * HA: entity_id (returns the cached entity state). */
148764
148625
  key: string()
148765
148626
  });
148766
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
148767
- kind: "mutation",
148768
- auth: "admin"
148769
- }), method(RemoveInputSchema, _void(), {
148770
- kind: "mutation",
148771
- auth: "admin"
148772
- }), method(GetInputSchema, TestConnectionResultSchema, {
148773
- kind: "mutation",
148774
- auth: "admin"
148775
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
148776
- id: string(),
148777
- settings: SettingsRecordSchema$1
148778
- }), _void(), {
148779
- kind: "mutation",
148780
- auth: "admin"
148781
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
148782
- kind: "mutation",
148783
- auth: "admin"
148784
- }), method(PublishInputSchema, unknown(), {
148627
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
148785
148628
  kind: "mutation",
148786
148629
  auth: "admin"
148787
148630
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -157908,7 +157751,7 @@ var TestConnectionStatusEnum = _enum([
157908
157751
  "inconclusive",
157909
157752
  "unsupported"
157910
157753
  ]);
157911
- var TestConnectionResultSchema$1 = object({
157754
+ var TestConnectionResultSchema = object({
157912
157755
  /** True ONLY for `validated`. Never true for a test that did not run. */
157913
157756
  success: boolean(),
157914
157757
  error: string().optional(),
@@ -157953,7 +157796,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
157953
157796
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
157954
157797
  addonId: string(),
157955
157798
  settings: record(string(), unknown())
157956
- }), TestConnectionResultSchema$1, {
157799
+ }), TestConnectionResultSchema, {
157957
157800
  kind: "mutation",
157958
157801
  auth: "admin"
157959
157802
  });
@@ -157980,6 +157823,14 @@ var ConfigSchemaPassthrough$3 = custom();
157980
157823
  var IntegrationInstanceIdSchema = string().min(1);
157981
157824
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
157982
157825
  /**
157826
+ * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
157827
+ * instance is an integration that brings devices (the registry owns its on/off switch);
157828
+ * `services`: a connection configured from the addon's own function page, never listed on
157829
+ * Integrations.
157830
+ * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
157831
+ */
157832
+ var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
157833
+ /**
157983
157834
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
157984
157835
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
157985
157836
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -157990,6 +157841,22 @@ var IntegrationInstanceKindSchema = object({
157990
157841
  /** Stable id of the kind, sent back as `createInstance.kind`. */
157991
157842
  id: string().min(1),
157992
157843
  label: string().min(1),
157844
+ /**
157845
+ * The function capability this kind is configured for (`broker`, `smtp-provider`,
157846
+ * `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
157847
+ * provider with more than one section must name it on every kind.
157848
+ */
157849
+ functionCap: string().min(1),
157850
+ /**
157851
+ * For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
157852
+ * (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
157853
+ * finds the instances whose kind names it; absent takes the kind `id`.
157854
+ */
157855
+ brokerKind: string().min(1).optional(),
157856
+ /** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
157857
+ role: IntegrationInstanceRoleSchema.optional(),
157858
+ /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
157859
+ canTest: boolean().optional(),
157993
157860
  /** The kind signs in through a server-held interactive session. */
157994
157861
  signIn: object({
157995
157862
  basePath: string().min(1),
@@ -158002,11 +157869,7 @@ var IntegrationInstanceKindSchema = object({
158002
157869
  });
158003
157870
  var IntegrationInstanceDescriptionSchema = object({
158004
157871
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
158005
- role: _enum([
158006
- "devices",
158007
- "services",
158008
- "both"
158009
- ]),
157872
+ role: IntegrationInstanceRoleSchema,
158010
157873
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
158011
157874
  discovery: object({
158012
157875
  mode: _enum([
@@ -158081,7 +157944,11 @@ var integrationInstancesCapability = {
158081
157944
  methods: {
158082
157945
  describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
158083
157946
  /** The form; `id: null` is the create form. */
158084
- instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
157947
+ instanceFormSchema: method(object({
157948
+ id: IntegrationInstanceIdSchema.nullable(),
157949
+ /** The kind of the create form (`id: null`) of a provider with several. */
157950
+ kind: string().min(1).optional()
157951
+ }), ConfigSchemaPassthrough$3, { auth: "admin" }),
158085
157952
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
158086
157953
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
158087
157954
  /**
@@ -158091,7 +157958,9 @@ var integrationInstancesCapability = {
158091
157958
  createInstance: method(object({
158092
157959
  id: IntegrationInstanceIdSchema.optional(),
158093
157960
  name: string().min(1),
158094
- kind: string().min(1).optional()
157961
+ kind: string().min(1).optional(),
157962
+ /** Form values written with the record (a link picked in the create dialog). */
157963
+ values: record(string(), unknown()).optional()
158095
157964
  }), object({ id: string() }), {
158096
157965
  kind: "mutation",
158097
157966
  auth: "admin"
@@ -158118,8 +157987,10 @@ var integrationInstancesCapability = {
158118
157987
  }),
158119
157988
  testInstance: optionalMethod(object({
158120
157989
  id: IntegrationInstanceIdSchema.nullable(),
158121
- values: record(string(), unknown())
158122
- }), TestConnectionResultSchema$1, {
157990
+ values: record(string(), unknown()),
157991
+ /** The kind to test when `id` is null and the provider has several. */
157992
+ kind: string().min(1).optional()
157993
+ }), TestConnectionResultSchema, {
158123
157994
  kind: "mutation",
158124
157995
  auth: "admin"
158125
157996
  })
@@ -160897,6 +160768,380 @@ var SystemMetricsSchema = object({
160897
160768
  gpuMemoryPercent: number().optional()
160898
160769
  });
160899
160770
  method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
160771
+ /**
160772
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
160773
+ * config documents, mirrors. The third storage API next to `ctx.settings`
160774
+ * (operator intent, D870) and device-history (numbers over time, D850).
160775
+ *
160776
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
160777
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
160778
+ * that with the addon id closed over). It is deliberately NOT in any input
160779
+ * schema, so a session can never supply it, and a call with no stamp is refused
160780
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
160781
+ * addons go through the owner's capability.
160782
+ *
160783
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
160784
+ * never `[]`. Secret fields are never on the wire: a read shows the
160785
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
160786
+ * resolves itself, and a write may carry only a keychain marker bound to the
160787
+ * row's own ref.
160788
+ *
160789
+ * Internal: addons reach it through `ctx.records`, never directly.
160790
+ */
160791
+ var RecordIdSchema = string().min(1).max(256);
160792
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
160793
+ var RecordBodySchema = record(string(), unknown());
160794
+ var RecordInputSchema = object({
160795
+ id: RecordIdSchema,
160796
+ /** The device this row belongs to (D865 removal, per-device reads). */
160797
+ deviceId: number().int().optional(),
160798
+ /** The domain clock, ms: observed / created / opened. */
160799
+ at: number().int().optional(),
160800
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
160801
+ expiresAt: number().int().optional(),
160802
+ data: RecordBodySchema
160803
+ });
160804
+ var RecordViewSchema = object({
160805
+ id: string(),
160806
+ deviceId: number().int().nullable(),
160807
+ at: number().nullable(),
160808
+ expiresAt: number().nullable(),
160809
+ rev: number().int(),
160810
+ updatedAt: number(),
160811
+ data: RecordBodySchema
160812
+ });
160813
+ /** Declared index fields only. Anything else does not compile, by design. */
160814
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
160815
+ string(),
160816
+ number(),
160817
+ boolean(),
160818
+ object({ in: array(union([
160819
+ string(),
160820
+ number(),
160821
+ boolean()
160822
+ ])).min(1).max(RECORD_BATCH_MAX) }),
160823
+ object({
160824
+ gt: union([string(), number()]).optional(),
160825
+ gte: union([string(), number()]).optional(),
160826
+ lt: union([string(), number()]).optional(),
160827
+ lte: union([string(), number()]).optional()
160828
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
160829
+ ]));
160830
+ var KindShape = { kind: RecordKindNameSchema };
160831
+ var TimeWindowShape = {
160832
+ deviceId: number().int().optional(),
160833
+ atFrom: number().optional(),
160834
+ atTo: number().optional()
160835
+ };
160836
+ var RecordQueryInputSchema = object({
160837
+ ...KindShape,
160838
+ ...TimeWindowShape,
160839
+ where: RecordWhereSchema.optional(),
160840
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
160841
+ order: _enum(["at", "id"]).optional(),
160842
+ desc: boolean().optional(),
160843
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
160844
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
160845
+ cursor: string().min(1).optional()
160846
+ });
160847
+ var RecordQueryResultSchema = object({
160848
+ records: array(RecordViewSchema),
160849
+ nextCursor: string().nullable()
160850
+ });
160851
+ var RecordKindStateSchema = _enum([
160852
+ "created",
160853
+ "unchanged",
160854
+ "updated"
160855
+ ]);
160856
+ var DeclareKindResultSchema = object({
160857
+ kindId: number().int(),
160858
+ state: RecordKindStateSchema,
160859
+ createdIndexes: array(string())
160860
+ });
160861
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
160862
+ var SecretRefsList = array(string());
160863
+ /**
160864
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
160865
+ * All ops of one call share ONE database file and ONE `transactFamily`.
160866
+ */
160867
+ var RecordTransactOpSchema = discriminatedUnion("op", [
160868
+ object({
160869
+ op: literal("put"),
160870
+ kind: RecordKindNameSchema,
160871
+ record: RecordInputSchema,
160872
+ ifRev: number().int().min(0).optional()
160873
+ }),
160874
+ object({
160875
+ op: literal("patch"),
160876
+ kind: RecordKindNameSchema,
160877
+ id: RecordIdSchema,
160878
+ data: RecordBodySchema,
160879
+ at: number().int().nullable().optional(),
160880
+ expiresAt: number().int().nullable().optional(),
160881
+ ifRev: number().int().min(1).optional()
160882
+ }),
160883
+ object({
160884
+ op: literal("delete"),
160885
+ kind: RecordKindNameSchema,
160886
+ id: RecordIdSchema
160887
+ })
160888
+ ]);
160889
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
160890
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
160891
+ kind: "mutation",
160892
+ auth: "admin"
160893
+ }), method(object({
160894
+ ...KindShape,
160895
+ id: RecordIdSchema
160896
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
160897
+ ...KindShape,
160898
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160899
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
160900
+ ...KindShape,
160901
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160902
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
160903
+ ...KindShape,
160904
+ record: RecordInputSchema,
160905
+ /** Compare-and-set. `0` means "the row must not exist". */
160906
+ ifRev: number().int().min(0).optional()
160907
+ }), object({
160908
+ rev: number().int(),
160909
+ releasedRefs: SecretRefsList
160910
+ }), {
160911
+ kind: "mutation",
160912
+ auth: "admin"
160913
+ }), method(object({
160914
+ ...KindShape,
160915
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
160916
+ }), object({
160917
+ count: number().int(),
160918
+ releasedRefs: SecretRefsList
160919
+ }), {
160920
+ kind: "mutation",
160921
+ auth: "admin"
160922
+ }), method(object({
160923
+ ...KindShape,
160924
+ id: RecordIdSchema,
160925
+ data: RecordBodySchema,
160926
+ at: number().int().nullable().optional(),
160927
+ expiresAt: number().int().nullable().optional(),
160928
+ ifRev: number().int().min(1).optional()
160929
+ }), object({
160930
+ rev: number().int(),
160931
+ releasedRefs: SecretRefsList
160932
+ }), {
160933
+ kind: "mutation",
160934
+ auth: "admin"
160935
+ }), method(object({
160936
+ ...KindShape,
160937
+ id: RecordIdSchema
160938
+ }), object({
160939
+ deleted: boolean(),
160940
+ secretRefs: SecretRefsList
160941
+ }), {
160942
+ kind: "mutation",
160943
+ auth: "admin"
160944
+ }), method(object({
160945
+ ...KindShape,
160946
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160947
+ }), object({
160948
+ deleted: number().int(),
160949
+ secretRefs: SecretRefsList
160950
+ }), {
160951
+ kind: "mutation",
160952
+ auth: "admin"
160953
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
160954
+ ...KindShape,
160955
+ ...TimeWindowShape,
160956
+ where: RecordWhereSchema.optional()
160957
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
160958
+ ...KindShape,
160959
+ deviceId: number().int().optional(),
160960
+ from: number(),
160961
+ to: number(),
160962
+ bucketMs: number().int().positive()
160963
+ }), object({ buckets: array(object({
160964
+ bucketStart: number(),
160965
+ count: number().int()
160966
+ })) }), { auth: "admin" }), method(object({
160967
+ ...KindShape,
160968
+ op: _enum([
160969
+ "sum",
160970
+ "min",
160971
+ "max",
160972
+ "count"
160973
+ ]),
160974
+ field: RecordFieldPathSchema.optional(),
160975
+ groupBy: RecordFieldPathSchema.optional(),
160976
+ where: RecordWhereSchema.optional()
160977
+ }), object({ rows: array(object({
160978
+ group: union([
160979
+ string(),
160980
+ number(),
160981
+ _null()
160982
+ ]),
160983
+ value: number().nullable()
160984
+ })) }), { auth: "admin" }), method(object({
160985
+ ...KindShape,
160986
+ deviceId: number().int().optional(),
160987
+ atBefore: number().optional(),
160988
+ where: RecordWhereSchema.optional()
160989
+ }), object({
160990
+ deleted: number().int(),
160991
+ secretRefs: SecretRefsList
160992
+ }), {
160993
+ kind: "mutation",
160994
+ auth: "admin"
160995
+ }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
160996
+ results: array(object({
160997
+ rev: number().int().nullable(),
160998
+ deleted: boolean()
160999
+ })),
161000
+ releasedRefs: SecretRefsList,
161001
+ secretRefs: SecretRefsList
161002
+ }), {
161003
+ kind: "mutation",
161004
+ auth: "admin"
161005
+ }), method(object({
161006
+ deviceId: number().int(),
161007
+ kinds: array(RecordKindNameSchema).optional()
161008
+ }), object({
161009
+ deleted: record(string(), number().int()),
161010
+ secretRefs: SecretRefsList
161011
+ }), {
161012
+ kind: "mutation",
161013
+ auth: "admin"
161014
+ }), method(object(KindShape), object({ id: number().int() }), {
161015
+ kind: "mutation",
161016
+ auth: "admin"
161017
+ });
161018
+ /**
161019
+ * The wire shapes of the migration API, version 1 (planning#447).
161020
+ *
161021
+ * A migration is code that outlives the server it was written against: an addon at
161022
+ * version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
161023
+ * the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
161024
+ * is the contract of every method of it, one Zod pair per method.
161025
+ *
161026
+ * APPEND-ONLY. A released method is never removed and never changes meaning: an input
161027
+ * field is never removed or made required, an enum never narrows, an output field is
161028
+ * never removed. A change that cannot be expressed that way is `migration-api.v2`, next
161029
+ * to this file. `scripts/check-migration-api-append-only.ts` holds the line against
161030
+ * `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
161031
+ * `it('<id>'` in `migration-api.contract.spec.ts`.
161032
+ */
161033
+ var Rows = record(string(), unknown());
161034
+ var IntegrationId = object({ integrationId: string().min(1) });
161035
+ var RecordId = object({ id: string().min(1) });
161036
+ var RecordRowSchema = object({
161037
+ id: string(),
161038
+ deviceId: number().int().nullable(),
161039
+ at: number().nullable(),
161040
+ expiresAt: number().nullable(),
161041
+ rev: number().int(),
161042
+ updatedAt: number(),
161043
+ data: Rows
161044
+ });
161045
+ var RecordPutShape = {
161046
+ id: string().min(1),
161047
+ deviceId: number().int().optional(),
161048
+ at: number().int().optional(),
161049
+ expiresAt: number().int().optional(),
161050
+ data: Rows
161051
+ };
161052
+ var MigrationIntegrationSchema = object({
161053
+ id: string(),
161054
+ addonId: string(),
161055
+ name: string(),
161056
+ info: Rows,
161057
+ originStableId: string().optional()
161058
+ });
161059
+ var MigrationDeviceSchema = object({
161060
+ id: number().int(),
161061
+ integrationId: string().nullable().optional(),
161062
+ /** The owning device; null or absent for a root. */
161063
+ parentDeviceId: number().int().nullable().optional(),
161064
+ type: string().optional(),
161065
+ name: string().optional(),
161066
+ stableId: string().optional()
161067
+ });
161068
+ /** What the engine says about the migration API it serves: lets an addon notice an older server. */
161069
+ var MigrationApiInfoSchema = object({
161070
+ version: number().int(),
161071
+ methods: array(string())
161072
+ });
161073
+ object({
161074
+ message: string(),
161075
+ meta: Rows.optional(),
161076
+ /** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
161077
+ tags: object({ deviceId: number().int().optional() }).optional()
161078
+ });
161079
+ object({
161080
+ owner: string().min(1),
161081
+ metas: array(MigrationMetaSchema)
161082
+ }), object({
161083
+ bootId: string(),
161084
+ snapshot: _enum([
161085
+ "none",
161086
+ "written",
161087
+ "refused"
161088
+ ]),
161089
+ steps: array(MigrationOwnerStepSchema),
161090
+ /** The migration API the engine serves; absent from a server that predates it. */
161091
+ migrationApi: MigrationApiInfoSchema.optional()
161092
+ }), object({ id: string().min(1) }), object({
161093
+ proceed: boolean(),
161094
+ state: union([literal("pending"), MigrationStatusSchema]),
161095
+ reason: string().nullable()
161096
+ }), object({
161097
+ id: string().min(1),
161098
+ result: MigrationOwnerResultSchema
161099
+ }), object({
161100
+ status: MigrationStatusSchema,
161101
+ error: string().nullable(),
161102
+ rowsChanged: number().int().nonnegative()
161103
+ }), object({
161104
+ rows: number().int().nonnegative(),
161105
+ secrets: number().int().nonnegative()
161106
+ }), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
161107
+ present: boolean(),
161108
+ removed: Rows
161109
+ }), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
161110
+ ...RecordPutShape,
161111
+ ifRev: number().int().optional()
161112
+ }), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
161113
+ partial: Rows,
161114
+ ifRev: number().int().optional()
161115
+ }), object({ rev: number().int() }), object({ deleted: boolean() }), object({
161116
+ deviceId: number().int().optional(),
161117
+ atFrom: number().optional(),
161118
+ atTo: number().optional(),
161119
+ where: RecordWhereSchema.optional(),
161120
+ limit: number().int().min(1).optional(),
161121
+ cursor: string().min(1).optional(),
161122
+ resolveSecrets: boolean().optional()
161123
+ }), object({
161124
+ records: array(RecordRowSchema),
161125
+ nextCursor: string().nullable()
161126
+ }), object({
161127
+ deviceId: number().int().optional(),
161128
+ atBefore: number().optional(),
161129
+ where: RecordWhereSchema.optional()
161130
+ }), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
161131
+ ref: string().min(1),
161132
+ value: string()
161133
+ }), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
161134
+ addonId: string().min(1),
161135
+ integrationId: string().min(1).optional()
161136
+ }), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
161137
+ id: number().int(),
161138
+ integrationId: string().nullable(),
161139
+ /** Whether the device carries any stored config; its content is not offered. */
161140
+ hasConfig: boolean()
161141
+ }).nullable(), object({
161142
+ deviceId: number().int(),
161143
+ integrationId: string().min(1)
161144
+ }), object({}), object({}), object({ nodeId: string() }), object({}), object({});
160900
161145
  method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
160901
161146
  id: string().min(1),
160902
161147
  error: string().min(1)
@@ -160926,7 +161171,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
160926
161171
  "written",
160927
161172
  "refused"
160928
161173
  ]),
160929
- steps: array(MigrationOwnerStepSchema)
161174
+ steps: array(MigrationOwnerStepSchema),
161175
+ /** The migration API this engine serves (additive: a server that predates it omits it). */
161176
+ migrationApi: MigrationApiInfoSchema.optional()
160930
161177
  }), {
160931
161178
  kind: "mutation",
160932
161179
  auth: "admin"
@@ -163593,7 +163840,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
163593
163840
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
163594
163841
  kind: "mutation",
163595
163842
  auth: "admin"
163596
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
163843
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
163844
+ kind: "query",
163845
+ auth: "admin"
163846
+ }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
163597
163847
  kind: "query",
163598
163848
  auth: "admin"
163599
163849
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -166248,7 +166498,7 @@ var BrokerStatusSchema$1 = _enum([
166248
166498
  "unreachable",
166249
166499
  "tls-error"
166250
166500
  ]);
166251
- var BrokerInfoSchema$1 = object({
166501
+ var BrokerInfoSchema = object({
166252
166502
  id: string(),
166253
166503
  name: string(),
166254
166504
  url: string(),
@@ -166311,7 +166561,7 @@ var StatusSchema = object({
166311
166561
  brokerCount: number(),
166312
166562
  embeddedRunning: boolean()
166313
166563
  });
166314
- method(_void(), array(BrokerInfoSchema$1)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
166564
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
166315
166565
  kind: "mutation",
166316
166566
  auth: "admin"
166317
166567
  }), method(IdInputSchema, _void(), {
@@ -173697,253 +173947,6 @@ var rebootCapability = {
173697
173947
  }) }
173698
173948
  };
173699
173949
  /**
173700
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
173701
- * config documents, mirrors. The third storage API next to `ctx.settings`
173702
- * (operator intent, D870) and device-history (numbers over time, D850).
173703
- *
173704
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
173705
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
173706
- * that with the addon id closed over). It is deliberately NOT in any input
173707
- * schema, so a session can never supply it, and a call with no stamp is refused
173708
- * `records/no-caller`. A kind is readable and writable only by its owner; other
173709
- * addons go through the owner's capability.
173710
- *
173711
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
173712
- * never `[]`. Secret fields are never on the wire: a read shows the
173713
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
173714
- * resolves itself, and a write may carry only a keychain marker bound to the
173715
- * row's own ref.
173716
- *
173717
- * Internal: addons reach it through `ctx.records`, never directly.
173718
- */
173719
- var RecordIdSchema = string().min(1).max(256);
173720
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
173721
- var RecordBodySchema = record(string(), unknown());
173722
- var RecordInputSchema = object({
173723
- id: RecordIdSchema,
173724
- /** The device this row belongs to (D865 removal, per-device reads). */
173725
- deviceId: number().int().optional(),
173726
- /** The domain clock, ms: observed / created / opened. */
173727
- at: number().int().optional(),
173728
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
173729
- expiresAt: number().int().optional(),
173730
- data: RecordBodySchema
173731
- });
173732
- var RecordViewSchema = object({
173733
- id: string(),
173734
- deviceId: number().int().nullable(),
173735
- at: number().nullable(),
173736
- expiresAt: number().nullable(),
173737
- rev: number().int(),
173738
- updatedAt: number(),
173739
- data: RecordBodySchema
173740
- });
173741
- /** Declared index fields only. Anything else does not compile, by design. */
173742
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
173743
- string(),
173744
- number(),
173745
- boolean(),
173746
- object({ in: array(union([
173747
- string(),
173748
- number(),
173749
- boolean()
173750
- ])).min(1).max(RECORD_BATCH_MAX) }),
173751
- object({
173752
- gt: union([string(), number()]).optional(),
173753
- gte: union([string(), number()]).optional(),
173754
- lt: union([string(), number()]).optional(),
173755
- lte: union([string(), number()]).optional()
173756
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
173757
- ]));
173758
- var KindShape = { kind: RecordKindNameSchema };
173759
- var TimeWindowShape = {
173760
- deviceId: number().int().optional(),
173761
- atFrom: number().optional(),
173762
- atTo: number().optional()
173763
- };
173764
- var RecordQueryInputSchema = object({
173765
- ...KindShape,
173766
- ...TimeWindowShape,
173767
- where: RecordWhereSchema.optional(),
173768
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
173769
- order: _enum(["at", "id"]).optional(),
173770
- desc: boolean().optional(),
173771
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
173772
- /** Opaque keyset cursor from a previous answer. There is no offset. */
173773
- cursor: string().min(1).optional()
173774
- });
173775
- var RecordQueryResultSchema = object({
173776
- records: array(RecordViewSchema),
173777
- nextCursor: string().nullable()
173778
- });
173779
- var RecordKindStateSchema = _enum([
173780
- "created",
173781
- "unchanged",
173782
- "updated"
173783
- ]);
173784
- var DeclareKindResultSchema = object({
173785
- kindId: number().int(),
173786
- state: RecordKindStateSchema,
173787
- createdIndexes: array(string())
173788
- });
173789
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
173790
- var SecretRefsList = array(string());
173791
- /**
173792
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
173793
- * All ops of one call share ONE database file and ONE `transactFamily`.
173794
- */
173795
- var RecordTransactOpSchema = discriminatedUnion("op", [
173796
- object({
173797
- op: literal("put"),
173798
- kind: RecordKindNameSchema,
173799
- record: RecordInputSchema,
173800
- ifRev: number().int().min(0).optional()
173801
- }),
173802
- object({
173803
- op: literal("patch"),
173804
- kind: RecordKindNameSchema,
173805
- id: RecordIdSchema,
173806
- data: RecordBodySchema,
173807
- at: number().int().nullable().optional(),
173808
- expiresAt: number().int().nullable().optional(),
173809
- ifRev: number().int().min(1).optional()
173810
- }),
173811
- object({
173812
- op: literal("delete"),
173813
- kind: RecordKindNameSchema,
173814
- id: RecordIdSchema
173815
- })
173816
- ]);
173817
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
173818
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
173819
- kind: "mutation",
173820
- auth: "admin"
173821
- }), method(object({
173822
- ...KindShape,
173823
- id: RecordIdSchema
173824
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
173825
- ...KindShape,
173826
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173827
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
173828
- ...KindShape,
173829
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173830
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
173831
- ...KindShape,
173832
- record: RecordInputSchema,
173833
- /** Compare-and-set. `0` means "the row must not exist". */
173834
- ifRev: number().int().min(0).optional()
173835
- }), object({
173836
- rev: number().int(),
173837
- releasedRefs: SecretRefsList
173838
- }), {
173839
- kind: "mutation",
173840
- auth: "admin"
173841
- }), method(object({
173842
- ...KindShape,
173843
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
173844
- }), object({
173845
- count: number().int(),
173846
- releasedRefs: SecretRefsList
173847
- }), {
173848
- kind: "mutation",
173849
- auth: "admin"
173850
- }), method(object({
173851
- ...KindShape,
173852
- id: RecordIdSchema,
173853
- data: RecordBodySchema,
173854
- at: number().int().nullable().optional(),
173855
- expiresAt: number().int().nullable().optional(),
173856
- ifRev: number().int().min(1).optional()
173857
- }), object({
173858
- rev: number().int(),
173859
- releasedRefs: SecretRefsList
173860
- }), {
173861
- kind: "mutation",
173862
- auth: "admin"
173863
- }), method(object({
173864
- ...KindShape,
173865
- id: RecordIdSchema
173866
- }), object({
173867
- deleted: boolean(),
173868
- secretRefs: SecretRefsList
173869
- }), {
173870
- kind: "mutation",
173871
- auth: "admin"
173872
- }), method(object({
173873
- ...KindShape,
173874
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173875
- }), object({
173876
- deleted: number().int(),
173877
- secretRefs: SecretRefsList
173878
- }), {
173879
- kind: "mutation",
173880
- auth: "admin"
173881
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
173882
- ...KindShape,
173883
- ...TimeWindowShape,
173884
- where: RecordWhereSchema.optional()
173885
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
173886
- ...KindShape,
173887
- deviceId: number().int().optional(),
173888
- from: number(),
173889
- to: number(),
173890
- bucketMs: number().int().positive()
173891
- }), object({ buckets: array(object({
173892
- bucketStart: number(),
173893
- count: number().int()
173894
- })) }), { auth: "admin" }), method(object({
173895
- ...KindShape,
173896
- op: _enum([
173897
- "sum",
173898
- "min",
173899
- "max",
173900
- "count"
173901
- ]),
173902
- field: RecordFieldPathSchema.optional(),
173903
- groupBy: RecordFieldPathSchema.optional(),
173904
- where: RecordWhereSchema.optional()
173905
- }), object({ rows: array(object({
173906
- group: union([
173907
- string(),
173908
- number(),
173909
- _null()
173910
- ]),
173911
- value: number().nullable()
173912
- })) }), { auth: "admin" }), method(object({
173913
- ...KindShape,
173914
- deviceId: number().int().optional(),
173915
- atBefore: number().optional(),
173916
- where: RecordWhereSchema.optional()
173917
- }), object({
173918
- deleted: number().int(),
173919
- secretRefs: SecretRefsList
173920
- }), {
173921
- kind: "mutation",
173922
- auth: "admin"
173923
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
173924
- results: array(object({
173925
- rev: number().int().nullable(),
173926
- deleted: boolean()
173927
- })),
173928
- releasedRefs: SecretRefsList,
173929
- secretRefs: SecretRefsList
173930
- }), {
173931
- kind: "mutation",
173932
- auth: "admin"
173933
- }), method(object({
173934
- deviceId: number().int(),
173935
- kinds: array(RecordKindNameSchema).optional()
173936
- }), object({
173937
- deleted: record(string(), number().int()),
173938
- secretRefs: SecretRefsList
173939
- }), {
173940
- kind: "mutation",
173941
- auth: "admin"
173942
- }), method(object(KindShape), object({ id: number().int() }), {
173943
- kind: "mutation",
173944
- auth: "admin"
173945
- });
173946
- /**
173947
173950
  * record-entries - the ONE admin surface for every list of user-created entries
173948
173951
  * (D881): notification targets, brokers, LLM profiles, anything an addon
173949
173952
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -186232,20 +186235,6 @@ Object.freeze({
186232
186235
  access: "create",
186233
186236
  role: "viewer"
186234
186237
  },
186235
- "broker.add": {
186236
- capName: "broker",
186237
- capScope: "system",
186238
- addonId: null,
186239
- access: "create",
186240
- role: "admin"
186241
- },
186242
- "broker.get": {
186243
- capName: "broker",
186244
- capScope: "system",
186245
- addonId: null,
186246
- access: "view",
186247
- role: "admin"
186248
- },
186249
186238
  "broker.getBrokerConfig": {
186250
186239
  capName: "broker",
186251
186240
  capScope: "system",
@@ -186253,20 +186242,6 @@ Object.freeze({
186253
186242
  access: "view",
186254
186243
  role: "admin"
186255
186244
  },
186256
- "broker.getSettings": {
186257
- capName: "broker",
186258
- capScope: "system",
186259
- addonId: null,
186260
- access: "view",
186261
- role: "admin"
186262
- },
186263
- "broker.getSettingsSchema": {
186264
- capName: "broker",
186265
- capScope: "system",
186266
- addonId: null,
186267
- access: "view",
186268
- role: "admin"
186269
- },
186270
186245
  "broker.getState": {
186271
186246
  capName: "broker",
186272
186247
  capScope: "system",
@@ -186281,20 +186256,6 @@ Object.freeze({
186281
186256
  access: "view",
186282
186257
  role: "admin"
186283
186258
  },
186284
- "broker.list": {
186285
- capName: "broker",
186286
- capScope: "system",
186287
- addonId: null,
186288
- access: "view",
186289
- role: "admin"
186290
- },
186291
- "broker.listProviders": {
186292
- capName: "broker",
186293
- capScope: "system",
186294
- addonId: null,
186295
- access: "view",
186296
- role: "admin"
186297
- },
186298
186259
  "broker.publish": {
186299
186260
  capName: "broker",
186300
186261
  capScope: "system",
@@ -186302,20 +186263,6 @@ Object.freeze({
186302
186263
  access: "create",
186303
186264
  role: "admin"
186304
186265
  },
186305
- "broker.remove": {
186306
- capName: "broker",
186307
- capScope: "system",
186308
- addonId: null,
186309
- access: "delete",
186310
- role: "admin"
186311
- },
186312
- "broker.setSettings": {
186313
- capName: "broker",
186314
- capScope: "system",
186315
- addonId: null,
186316
- access: "create",
186317
- role: "admin"
186318
- },
186319
186266
  "broker.subscribe": {
186320
186267
  capName: "broker",
186321
186268
  capScope: "system",
@@ -186323,20 +186270,6 @@ Object.freeze({
186323
186270
  access: "create",
186324
186271
  role: "admin"
186325
186272
  },
186326
- "broker.testConnection": {
186327
- capName: "broker",
186328
- capScope: "system",
186329
- addonId: null,
186330
- access: "create",
186331
- role: "admin"
186332
- },
186333
- "broker.testSettings": {
186334
- capName: "broker",
186335
- capScope: "system",
186336
- addonId: null,
186337
- access: "create",
186338
- role: "admin"
186339
- },
186340
186273
  "broker.unsubscribe": {
186341
186274
  capName: "broker",
186342
186275
  capScope: "system",
@@ -191300,6 +191233,13 @@ Object.freeze({
191300
191233
  access: "view",
191301
191234
  role: "viewer"
191302
191235
  },
191236
+ "pipelineAnalytics.getMediaLocationCensus": {
191237
+ capName: "pipeline-analytics",
191238
+ capScope: "device",
191239
+ addonId: null,
191240
+ access: "view",
191241
+ role: "admin"
191242
+ },
191303
191243
  "pipelineAnalytics.getMediaReclaimStatus": {
191304
191244
  capName: "pipeline-analytics",
191305
191245
  capScope: "device",
@@ -200444,6 +200384,7 @@ object({
200444
200384
  delay: number().nonnegative().optional(),
200445
200385
  commands: record(string(), unknown())
200446
200386
  });
200387
+ entryBody({ brokerId: string() });
200447
200388
  //#endregion
200448
200389
  //#region src/clips/clip-prefetch.ts
200449
200390
  /** The longest a device may stay quiet after refusals, whatever its interval. */
@@ -220921,17 +220862,29 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
220921
220862
  var REOLINK_SUBSCRIBER_ID = "provider-reolink";
220922
220863
  var MAILBOX_NAME = "Camera mailbox";
220923
220864
  var RECIPIENT_PREFIX = "cam-";
220924
- /** The real port: `ctx.api.broker`, every call routed to the addon that owns the kind. */
220865
+ /**
220866
+ * The real port: the mailboxes are `integration-instances` of the SMTP addon (the kind of its
220867
+ * `broker` section, found from its description, D1013); pub/sub goes through `ctx.api.broker`.
220868
+ * Every call is routed to the addon that owns the kind.
220869
+ */
220925
220870
  function createBrokerPort(api) {
220926
220871
  const route = { addonId: SMTP_BROKER_ADDON_ID };
220872
+ const mailboxKind = async () => {
220873
+ const kind = (await api.integrationInstances.describe.query(route)).kinds?.find((k) => k.functionCap === "broker" && (k.brokerKind ?? k.id) === "smtp-inbound");
220874
+ if (kind === void 0) throw new Error("the SMTP addon declares no mailbox kind");
220875
+ return kind.id;
220876
+ };
220927
220877
  return {
220928
- list: async () => api.broker.list.query({ kind: SMTP_INBOUND_KIND }),
220929
- add: async ({ id, name, settings }) => api.broker.add.mutate({
220930
- kind: SMTP_INBOUND_KIND,
220931
- name,
220878
+ list: async () => {
220879
+ const kind = await mailboxKind();
220880
+ return (await api.integrationInstances.listInstances.query(route)).filter((instance) => instance.kind === kind);
220881
+ },
220882
+ add: async ({ id, name, settings }) => api.integrationInstances.createInstance.mutate({
220883
+ ...route,
220932
220884
  id,
220933
- settings: { ...settings },
220934
- ...route
220885
+ name,
220886
+ kind: await mailboxKind(),
220887
+ values: { ...settings }
220935
220888
  }),
220936
220889
  getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
220937
220890
  id,