@camstack/addon-provider-reolink 1.2.228 → 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.js CHANGED
@@ -106677,7 +106677,7 @@ var ZodIssueCode = {
106677
106677
  var ZodFirstPartyTypeKind;
106678
106678
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
106679
106679
  //#endregion
106680
- //#region ../types/dist/sleep-DEZaLbiu.mjs
106680
+ //#region ../types/dist/sleep-BX_MqzUe.mjs
106681
106681
  /**
106682
106682
  * The audio chunk plane's byte format, and the ONE expansion from a coded
106683
106683
  * window to float samples (D455).
@@ -108306,6 +108306,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
108306
108306
  /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
108307
108307
  var SECRET_CHANGE_DEBOUNCE_MS = 250;
108308
108308
  /**
108309
+ * Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
108310
+ * place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
108311
+ * through `api` (guard `check-migration-ports-surface`).
108312
+ */
108313
+ function migrationSet(catalogue, bindPorts) {
108314
+ return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
108315
+ }
108316
+ /** A mixed array is a mistake: the other kind would be dropped without a word. */
108317
+ function refuseMixed(form, kept, dropped) {
108318
+ 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`);
108319
+ }
108320
+ function catalogueOf(list) {
108321
+ const kept = list.filter((entry) => !("execute" in entry));
108322
+ refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
108323
+ return kept;
108324
+ }
108325
+ function boundOf(list) {
108326
+ const kept = list.filter((entry) => "execute" in entry);
108327
+ refuseMixed("bound migrations", kept.length, list.length - kept.length);
108328
+ return kept;
108329
+ }
108330
+ /**
108309
108331
  * Base class for CamStack addons. Eliminates settings boilerplate:
108310
108332
  *
108311
108333
  * - Typed `config` property with automatic resolution from store + defaults
@@ -108472,23 +108494,21 @@ var BaseAddon = class {
108472
108494
  await this.loadScopedSchemas();
108473
108495
  return normalized;
108474
108496
  }
108497
+ async runMigrations(first, second, third) {
108498
+ if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
108499
+ return this.runBound(boundOf(first), second);
108500
+ }
108475
108501
  /**
108476
- * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
108477
- * engine. Call it at the point of the boot where the data must already have the new
108478
- * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
108479
- * restored devices — with the catalogue bound to the addon's ports
108480
- * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
108481
- *
108482
- * An engine that cannot be reached or refuses the catalogue is logged and runs
108483
- * nothing; the boot continues. A migration that FAILED (or was blocked by one)
108484
- * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
108485
- * serve data whose shape it cannot trust; `tolerate` migrations never do.
108486
- *
108487
- * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
108488
- * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
108489
- * omitted applied ids "newer").
108502
+ * Several catalogues of ONE owner in one declaration (the engine replaces an owner's
108503
+ * catalogue on every declare, so two calls would each judge the other's ids "newer").
108504
+ * Build each entry with `migrationSet(catalogue, (api) => ports)`.
108490
108505
  */
108491
- async runMigrations(migrations, options) {
108506
+ async runMigrationSets(sets, options) {
108507
+ const api = this.ctx.migrationApi;
108508
+ if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
108509
+ return this.runBound(sets.flatMap((set) => set.bind(api)), options);
108510
+ }
108511
+ async runBound(migrations, options) {
108492
108512
  const api = this.ctx.api.migrations;
108493
108513
  const report = await runAddonMigrations({
108494
108514
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -114042,17 +114062,6 @@ var NodeColorIdSchema = _enum([
114042
114062
  "node-g",
114043
114063
  "node-h"
114044
114064
  ]);
114045
- //#endregion
114046
- //#region ../types/dist/index.mjs
114047
- /**
114048
- * The `smtp-inbound` broker kind (D999): a mailbox a device can send mail to.
114049
- *
114050
- * The `broker` cap carries these as `Record<string, unknown>` on the wire; the
114051
- * provider and its consumers parse them with the schemas below at BOTH ends, so
114052
- * the shape is declared once.
114053
- */
114054
- /** The broker kind tag. */
114055
- var SMTP_INBOUND_KIND = "smtp-inbound";
114056
114065
  /** The id the first mailbox is minted under (adopt-id), so a consumer can find it again. */
114057
114066
  var SMTP_INBOUND_DEFAULT_ID = "smtp-inbound-default";
114058
114067
  var SMTP_INBOUND_DEFAULT_PORT = 2525;
@@ -114383,7 +114392,7 @@ var RecordIntegrationInstances = class {
114383
114392
  return record === null ? null : this.viewOf(record);
114384
114393
  };
114385
114394
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
114386
- createInstance = async ({ id, name, kind }) => {
114395
+ createInstance = async ({ id, name, kind, values }) => {
114387
114396
  const minted = id ?? this.hooks.mintId?.({
114388
114397
  name,
114389
114398
  ...kind !== void 0 ? { kind } : {}
@@ -114393,10 +114402,20 @@ var RecordIntegrationInstances = class {
114393
114402
  id: minted,
114394
114403
  data: this.hooks.initialBody(name, kind)
114395
114404
  }, { ifRev: 0 });
114405
+ const patch = this.patchOf(values ?? {});
114406
+ if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
114396
114407
  await this.hooks.onChanged?.(minted, "created");
114397
114408
  return { id: minted };
114398
114409
  };
114399
114410
  updateInstance = async ({ id, name, values }) => {
114411
+ const patch = this.patchOf(values);
114412
+ if (name !== void 0) patch[this.nameField] = name;
114413
+ await this.handle.patch(id, patch);
114414
+ await this.hooks.onChanged?.(id, "updated");
114415
+ return { ok: true };
114416
+ };
114417
+ /** The record patch a form `values` object means: secrets kept, cleared or replaced. */
114418
+ patchOf(values) {
114400
114419
  const patch = {};
114401
114420
  for (const [key, value] of Object.entries(values)) {
114402
114421
  if (value === void 0) continue;
@@ -114407,11 +114426,8 @@ var RecordIntegrationInstances = class {
114407
114426
  else if (isSecretClear(value)) patch[key] = null;
114408
114427
  else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
114409
114428
  }
114410
- if (name !== void 0) patch[this.nameField] = name;
114411
- await this.handle.patch(id, patch);
114412
- await this.hooks.onChanged?.(id, "updated");
114413
- return { ok: true };
114414
- };
114429
+ return patch;
114430
+ }
114415
114431
  /** The switch lives in the record body; the addon is told so it applies it (D996). */
114416
114432
  setInstanceEnabled = async ({ id, enabled }) => {
114417
114433
  if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
@@ -115744,13 +115760,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
115744
115760
  };
115745
115761
  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`);
115746
115762
  for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
115747
- 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);
115763
+ 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);
115748
115764
  for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
115749
115765
  const wrong = [];
115750
115766
  for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
115751
115767
  if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
115752
115768
  const claimed = plan.size;
115753
- 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`);
115769
+ 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`);
115754
115770
  return {
115755
115771
  outcome: claimed > 0 ? "done" : "already-done",
115756
115772
  summary: {
@@ -116966,6 +116982,39 @@ var UnstampedEventMediaCountSchema = object({
116966
116982
  /** Sum across both, or `null` when either lane could not be counted. */
116967
116983
  total: number().int().nonnegative().nullable()
116968
116984
  }).nullable();
116985
+ /**
116986
+ * Where the stored event media sits, per storage location: how many media rows
116987
+ * and how many bytes carry each location id, how many carry none (legacy,
116988
+ * resolved to the default `eventMedia` location), and how many name a location
116989
+ * that was not asked about (a deleted or never-listed one).
116990
+ *
116991
+ * One covering-index aggregate per asked location plus the NULL one, and one
116992
+ * unfiltered total that scans the covering index: O(rows), not a walk of the
116993
+ * rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
116994
+ * it is a deleted location only when every location id was asked.
116995
+ * `null` is "could not be measured", never zero.
116996
+ */
116997
+ var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
116998
+ var MediaLocationCensusSchema = object({
116999
+ locations: array(object({
117000
+ locationId: string(),
117001
+ rows: number().int().nonnegative(),
117002
+ bytes: number().nonnegative()
117003
+ })).readonly(),
117004
+ unstamped: object({
117005
+ rows: number().int().nonnegative(),
117006
+ bytes: number().nonnegative()
117007
+ }),
117008
+ /** Rows stamped with a location id that was not in the asked list. */
117009
+ unlisted: object({
117010
+ rows: number().int().nonnegative(),
117011
+ bytes: number().nonnegative()
117012
+ }),
117013
+ total: object({
117014
+ rows: number().int().nonnegative(),
117015
+ bytes: number().nonnegative()
117016
+ })
117017
+ });
116969
117018
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
116970
117019
  /** The independently selectable logical storage classes — every class
116971
117020
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -148536,52 +148585,7 @@ onBrightnessChanged: { data: object({
148536
148585
  minIntervalMs: 0
148537
148586
  } } }
148538
148587
  };
148539
- /**
148540
- * `broker` — unified pub/sub broker registry, system-scoped collection.
148541
- *
148542
- * The cap models any kind-tagged message broker the user wants to
148543
- * register and that other addons might consume. The first two kinds
148544
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
148545
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
148546
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
148547
- * the same surface.
148548
- *
148549
- * Why one cap, not one cap per kind:
148550
- * - The integrations page wants a single table of "every broker"
148551
- * across kinds; a unified cap drives it without join logic.
148552
- * - Generic admin operations (add / remove / test / status) are
148553
- * identical across kinds — duplicating them per cap was busywork.
148554
- * - The `network-access` cap precedent: same interface, many
148555
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
148556
- *
148557
- * What stays kind-specific:
148558
- * - `getBrokerConfig` payload (kind decides whether it returns
148559
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
148560
- * `Record<string, unknown>` at the wire; consumers narrow.
148561
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
148562
- * key) — also typed as `Record<string, unknown>` so each kind can
148563
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
148564
- * without rebreaking the cap signature.
148565
- * - `add` `settings` payload (different fields per kind, validated by
148566
- * the kind-specific provider).
148567
- *
148568
- * Bidirectionality:
148569
- * - `publish` is RPC — synchronous result (provider-defined).
148570
- * - `subscribe` returns a subscription handle; the actual message
148571
- * stream flows over the typed event-bus as `broker.message` events
148572
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
148573
- * event handler. Subscriptions persist across reconnects — the
148574
- * provider re-subscribes upstream after a transport drop.
148575
- *
148576
- * Why event-bus push (not a subscription RPC stream):
148577
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
148578
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
148579
- * drop is recoverable via `getState({key})`).
148580
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
148581
- * - Cross-process: events already route through `$event-bus`; no
148582
- * per-broker wire-shaping needed.
148583
- */
148584
- var BrokerStatusEnum = _enum([
148588
+ _enum([
148585
148589
  "connected",
148586
148590
  "disconnected",
148587
148591
  "connecting",
@@ -148589,141 +148593,12 @@ var BrokerStatusEnum = _enum([
148589
148593
  "unreachable",
148590
148594
  "error"
148591
148595
  ]);
148592
- var BrokerInfoSchema = object({
148593
- /** Stable broker id. Persisted; survives addon restarts. */
148594
- id: string(),
148595
- /** Addon id of the provider that OWNS this broker.
148596
- *
148597
- * The `broker` cap is a system-scoped collection: several addons
148598
- * register a `broker` provider, each owning a DISJOINT set of
148599
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
148600
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
148601
- * device belongs to one integration. The admin UI threads this id
148602
- * back as the `{ addonId }` system-collection selector on every
148603
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
148604
- * `testConnection`), so the call routes to the OWNING provider
148605
- * instead of defaulting to the first-registered one. */
148606
- addonId: string(),
148607
- /** Human-readable name (operator-chosen at add-time). */
148608
- name: string(),
148609
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
148610
- kind: string(),
148611
- status: BrokerStatusEnum,
148612
- /** Free-form provider-specific info (HA version, MQTT broker
148613
- * flavour, latency, mTLS active, …). */
148614
- info: record(string(), unknown()),
148615
- /** Ms epoch of the last connection probe / status update. */
148616
- lastCheckedAt: number().nullable(),
148617
- /** Last error message, when `status` indicates failure. */
148618
- error: string().nullable()
148619
- });
148620
148596
  var RegistryStatusSchema = object({
148621
148597
  brokerCount: number().int().nonnegative(),
148622
148598
  connectedCount: number().int().nonnegative()
148623
148599
  });
148624
- /**
148625
- * One entry per `broker` provider — which addon provides which broker
148626
- * kind(s). The unified create picker reads this to know, for each
148627
- * (addonId, kind) pair the operator can pick, where to route the
148628
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
148629
- * `{ addonId }` selector). A provider only advertises a kind here when
148630
- * it implements `getSettingsSchema` for that kind (so the picker never
148631
- * offers a kind whose creation form can't be rendered).
148632
- */
148633
- var BrokerProviderInfoSchema = object({
148634
- /** Addon id of the `broker` provider this entry describes. */
148635
- addonId: string(),
148636
- /** Broker kinds this provider can create, with a display label. */
148637
- kinds: array(object({
148638
- kind: string(),
148639
- label: string(),
148640
- /**
148641
- * Relative hub path to start an interactive account link (OAuth popup).
148642
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
148643
- */
148644
- interactiveConnectPath: string().min(1).optional(),
148645
- /** Relative hub path to disconnect the linked account (same popup pattern). */
148646
- interactiveDisconnectPath: string().min(1).optional(),
148647
- /**
148648
- * The kind signs in through a server-held interactive session instead of
148649
- * (or before) typed credentials. `basePath` is a hub-relative route set
148650
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
148651
- * contract: `POST {basePath}/start` (body: the form's settings) answers
148652
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
148653
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
148654
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
148655
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
148656
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
148657
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
148658
- * offers it as the default path; the fields the session fills are
148659
- * marked `filledBySignIn` in the kind's settings schema.
148660
- *
148661
- * `methods` lists the ways the session can sign in, recommended first:
148662
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
148663
- * settings) answering `{ sessionId, userCode, verificationUrl,
148664
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
148665
- * any device, and the same `status` / `commit` / `cancel` routes follow
148666
- * (status then carries `method`, `userCode`, `verificationUrl`,
148667
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
148668
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
148669
- * `['proxy']`.
148670
- */
148671
- signIn: object({
148672
- basePath: string().min(1),
148673
- methods: array(_enum(["device-code", "proxy"])).optional()
148674
- }).optional()
148675
- }))
148676
- });
148677
- var ListInputSchema = object({
148678
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
148679
- * only HA brokers. Omit to list every broker. */
148680
- kind: string().optional() });
148681
148600
  var GetInputSchema = object({ id: string() });
148682
- var AddInputSchema = object({
148683
- kind: string().min(1),
148684
- name: string().min(1),
148685
- /**
148686
- * ADOPT an existing id instead of minting a new one.
148687
- *
148688
- * Written the day this cost an outage. A broker's id is not a detail: HA
148689
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
148690
- * lost from config and re-added as `ha_001` leaves every one of its devices
148691
- * bound to a broker that no longer exists. Re-entering the password under the
148692
- * ORIGINAL id turns a multi-step device migration back into re-entering a
148693
- * password.
148694
- *
148695
- * A provider MUST refuse an id that is already in use — adopting a live
148696
- * broker's id would silently take it over.
148697
- */
148698
- id: string().min(1).optional(),
148699
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
148700
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
148701
- * branch on receipt — invalid shape rejects the add. */
148702
- settings: record(string(), unknown())
148703
- });
148704
- var AddResultSchema = object({ id: string() });
148705
- var RemoveInputSchema = object({ id: string() });
148706
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
148707
- ok: literal(true),
148708
- latencyMs: number().nonnegative()
148709
- }), object({
148710
- ok: literal(false),
148711
- error: string()
148712
- })]);
148713
148601
  var SettingsRecordSchema$1 = record(string(), unknown());
148714
- var SettingsSchemaInputSchema = object({ kind: string() });
148715
- var TestSettingsInputSchema = object({
148716
- kind: string(),
148717
- settings: SettingsRecordSchema$1
148718
- });
148719
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
148720
- ok: literal(true),
148721
- latencyMs: number().nonnegative().optional()
148722
- }).strict(), object({
148723
- ok: literal(false),
148724
- error: string()
148725
- })]);
148726
- var SettingsSchemaResultSchema = unknown().nullable();
148727
148602
  var PublishInputSchema = object({
148728
148603
  brokerId: string(),
148729
148604
  /** Kind-specific routing target.
@@ -148757,25 +148632,7 @@ var GetStateInputSchema = object({
148757
148632
  * HA: entity_id (returns the cached entity state). */
148758
148633
  key: string()
148759
148634
  });
148760
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
148761
- kind: "mutation",
148762
- auth: "admin"
148763
- }), method(RemoveInputSchema, _void(), {
148764
- kind: "mutation",
148765
- auth: "admin"
148766
- }), method(GetInputSchema, TestConnectionResultSchema, {
148767
- kind: "mutation",
148768
- auth: "admin"
148769
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
148770
- id: string(),
148771
- settings: SettingsRecordSchema$1
148772
- }), _void(), {
148773
- kind: "mutation",
148774
- auth: "admin"
148775
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
148776
- kind: "mutation",
148777
- auth: "admin"
148778
- }), method(PublishInputSchema, unknown(), {
148635
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
148779
148636
  kind: "mutation",
148780
148637
  auth: "admin"
148781
148638
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -153613,7 +153470,14 @@ var DiscoveryCandidateSchema = object({
153613
153470
  /** `stableId` of the gateway candidate this device was found BEHIND. */
153614
153471
  parentStableId: string().optional(),
153615
153472
  /** `false` = shown for context but not pickable. Default true. */
153616
- selectable: boolean().optional()
153473
+ selectable: boolean().optional(),
153474
+ /**
153475
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
153476
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
153477
+ * admin asks for exactly these, on the creation form prefilled with
153478
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
153479
+ */
153480
+ needsParams: array(string()).optional()
153617
153481
  });
153618
153482
  /**
153619
153483
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -153740,8 +153604,14 @@ var deviceProviderCapability = {
153740
153604
  * provider does not support manual creation. Lets the Add-Device dialog
153741
153605
  * pick the right type instead of assuming Camera.
153742
153606
  */
153743
- getManualCreationType: method(object({}), object({ deviceType: _enum(DeviceType).nullable() })),
153744
- adoptDiscoveredDevice: method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
153607
+ getManualCreationType: method(object({
153608
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153609
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
153610
+ adoptDiscoveredDevice: method(object({
153611
+ candidate: DiscoveryCandidateSchema,
153612
+ /** The integration the operator adopts into; a provider with several instances needs it. */
153613
+ integrationId: string().optional()
153614
+ }), DeviceSummarySchema, {
153745
153615
  kind: "mutation",
153746
153616
  auth: "admin"
153747
153617
  }),
@@ -153752,10 +153622,16 @@ var deviceProviderCapability = {
153752
153622
  * devices of that type. The output is a `ConfigUISchema` — the
153753
153623
  * router type-asserts it at the boundary.
153754
153624
  */
153755
- getChildCreationSchema: method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema),
153625
+ getChildCreationSchema: method(object({
153626
+ type: _enum(DeviceType),
153627
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153628
+ integrationId: string().optional()
153629
+ }), CreationSchemaOutputSchema),
153756
153630
  createDevice: method(object({
153757
153631
  type: _enum(DeviceType),
153758
- config: record(string(), unknown())
153632
+ config: record(string(), unknown()),
153633
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
153634
+ integrationId: string().optional()
153759
153635
  }), DeviceSummarySchema, {
153760
153636
  kind: "mutation",
153761
153637
  auth: "admin"
@@ -154480,7 +154356,10 @@ method(object({
154480
154356
  auth: "admin"
154481
154357
  }), method(object({
154482
154358
  addonId: string(),
154483
- type: _enum(DeviceType)
154359
+ type: _enum(DeviceType),
154360
+ /** The integration the form is for; a provider whose integrations differ (a hub
154361
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
154362
+ integrationId: string().optional()
154484
154363
  }), unknown().nullable()), method(object({
154485
154364
  addonId: string(),
154486
154365
  type: _enum(DeviceType),
@@ -154564,7 +154443,11 @@ method(object({
154564
154443
  kind: "mutation",
154565
154444
  auth: "admin",
154566
154445
  timeoutMs: 12e4
154567
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154446
+ }), method(object({
154447
+ addonId: string(),
154448
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
154449
+ integrationId: string().optional()
154450
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154568
154451
  deviceId: number(),
154569
154452
  key: string(),
154570
154453
  value: unknown()
@@ -157876,7 +157759,7 @@ var TestConnectionStatusEnum = _enum([
157876
157759
  "inconclusive",
157877
157760
  "unsupported"
157878
157761
  ]);
157879
- var TestConnectionResultSchema$1 = object({
157762
+ var TestConnectionResultSchema = object({
157880
157763
  /** True ONLY for `validated`. Never true for a test that did not run. */
157881
157764
  success: boolean(),
157882
157765
  error: string().optional(),
@@ -157921,7 +157804,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
157921
157804
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
157922
157805
  addonId: string(),
157923
157806
  settings: record(string(), unknown())
157924
- }), TestConnectionResultSchema$1, {
157807
+ }), TestConnectionResultSchema, {
157925
157808
  kind: "mutation",
157926
157809
  auth: "admin"
157927
157810
  });
@@ -157948,6 +157831,14 @@ var ConfigSchemaPassthrough$3 = custom();
157948
157831
  var IntegrationInstanceIdSchema = string().min(1);
157949
157832
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
157950
157833
  /**
157834
+ * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
157835
+ * instance is an integration that brings devices (the registry owns its on/off switch);
157836
+ * `services`: a connection configured from the addon's own function page, never listed on
157837
+ * Integrations.
157838
+ * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
157839
+ */
157840
+ var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
157841
+ /**
157951
157842
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
157952
157843
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
157953
157844
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -157958,6 +157849,22 @@ var IntegrationInstanceKindSchema = object({
157958
157849
  /** Stable id of the kind, sent back as `createInstance.kind`. */
157959
157850
  id: string().min(1),
157960
157851
  label: string().min(1),
157852
+ /**
157853
+ * The function capability this kind is configured for (`broker`, `smtp-provider`,
157854
+ * `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
157855
+ * provider with more than one section must name it on every kind.
157856
+ */
157857
+ functionCap: string().min(1),
157858
+ /**
157859
+ * For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
157860
+ * (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
157861
+ * finds the instances whose kind names it; absent takes the kind `id`.
157862
+ */
157863
+ brokerKind: string().min(1).optional(),
157864
+ /** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
157865
+ role: IntegrationInstanceRoleSchema.optional(),
157866
+ /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
157867
+ canTest: boolean().optional(),
157961
157868
  /** The kind signs in through a server-held interactive session. */
157962
157869
  signIn: object({
157963
157870
  basePath: string().min(1),
@@ -157970,11 +157877,7 @@ var IntegrationInstanceKindSchema = object({
157970
157877
  });
157971
157878
  var IntegrationInstanceDescriptionSchema = object({
157972
157879
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
157973
- role: _enum([
157974
- "devices",
157975
- "services",
157976
- "both"
157977
- ]),
157880
+ role: IntegrationInstanceRoleSchema,
157978
157881
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
157979
157882
  discovery: object({
157980
157883
  mode: _enum([
@@ -158049,7 +157952,11 @@ var integrationInstancesCapability = {
158049
157952
  methods: {
158050
157953
  describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
158051
157954
  /** The form; `id: null` is the create form. */
158052
- instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
157955
+ instanceFormSchema: method(object({
157956
+ id: IntegrationInstanceIdSchema.nullable(),
157957
+ /** The kind of the create form (`id: null`) of a provider with several. */
157958
+ kind: string().min(1).optional()
157959
+ }), ConfigSchemaPassthrough$3, { auth: "admin" }),
158053
157960
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
158054
157961
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
158055
157962
  /**
@@ -158059,7 +157966,9 @@ var integrationInstancesCapability = {
158059
157966
  createInstance: method(object({
158060
157967
  id: IntegrationInstanceIdSchema.optional(),
158061
157968
  name: string().min(1),
158062
- kind: string().min(1).optional()
157969
+ kind: string().min(1).optional(),
157970
+ /** Form values written with the record (a link picked in the create dialog). */
157971
+ values: record(string(), unknown()).optional()
158063
157972
  }), object({ id: string() }), {
158064
157973
  kind: "mutation",
158065
157974
  auth: "admin"
@@ -158086,8 +157995,10 @@ var integrationInstancesCapability = {
158086
157995
  }),
158087
157996
  testInstance: optionalMethod(object({
158088
157997
  id: IntegrationInstanceIdSchema.nullable(),
158089
- values: record(string(), unknown())
158090
- }), TestConnectionResultSchema$1, {
157998
+ values: record(string(), unknown()),
157999
+ /** The kind to test when `id` is null and the provider has several. */
158000
+ kind: string().min(1).optional()
158001
+ }), TestConnectionResultSchema, {
158091
158002
  kind: "mutation",
158092
158003
  auth: "admin"
158093
158004
  })
@@ -160865,6 +160776,380 @@ var SystemMetricsSchema = object({
160865
160776
  gpuMemoryPercent: number().optional()
160866
160777
  });
160867
160778
  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);
160779
+ /**
160780
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
160781
+ * config documents, mirrors. The third storage API next to `ctx.settings`
160782
+ * (operator intent, D870) and device-history (numbers over time, D850).
160783
+ *
160784
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
160785
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
160786
+ * that with the addon id closed over). It is deliberately NOT in any input
160787
+ * schema, so a session can never supply it, and a call with no stamp is refused
160788
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
160789
+ * addons go through the owner's capability.
160790
+ *
160791
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
160792
+ * never `[]`. Secret fields are never on the wire: a read shows the
160793
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
160794
+ * resolves itself, and a write may carry only a keychain marker bound to the
160795
+ * row's own ref.
160796
+ *
160797
+ * Internal: addons reach it through `ctx.records`, never directly.
160798
+ */
160799
+ var RecordIdSchema = string().min(1).max(256);
160800
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
160801
+ var RecordBodySchema = record(string(), unknown());
160802
+ var RecordInputSchema = object({
160803
+ id: RecordIdSchema,
160804
+ /** The device this row belongs to (D865 removal, per-device reads). */
160805
+ deviceId: number().int().optional(),
160806
+ /** The domain clock, ms: observed / created / opened. */
160807
+ at: number().int().optional(),
160808
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
160809
+ expiresAt: number().int().optional(),
160810
+ data: RecordBodySchema
160811
+ });
160812
+ var RecordViewSchema = object({
160813
+ id: string(),
160814
+ deviceId: number().int().nullable(),
160815
+ at: number().nullable(),
160816
+ expiresAt: number().nullable(),
160817
+ rev: number().int(),
160818
+ updatedAt: number(),
160819
+ data: RecordBodySchema
160820
+ });
160821
+ /** Declared index fields only. Anything else does not compile, by design. */
160822
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
160823
+ string(),
160824
+ number(),
160825
+ boolean(),
160826
+ object({ in: array(union([
160827
+ string(),
160828
+ number(),
160829
+ boolean()
160830
+ ])).min(1).max(RECORD_BATCH_MAX) }),
160831
+ object({
160832
+ gt: union([string(), number()]).optional(),
160833
+ gte: union([string(), number()]).optional(),
160834
+ lt: union([string(), number()]).optional(),
160835
+ lte: union([string(), number()]).optional()
160836
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
160837
+ ]));
160838
+ var KindShape = { kind: RecordKindNameSchema };
160839
+ var TimeWindowShape = {
160840
+ deviceId: number().int().optional(),
160841
+ atFrom: number().optional(),
160842
+ atTo: number().optional()
160843
+ };
160844
+ var RecordQueryInputSchema = object({
160845
+ ...KindShape,
160846
+ ...TimeWindowShape,
160847
+ where: RecordWhereSchema.optional(),
160848
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
160849
+ order: _enum(["at", "id"]).optional(),
160850
+ desc: boolean().optional(),
160851
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
160852
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
160853
+ cursor: string().min(1).optional()
160854
+ });
160855
+ var RecordQueryResultSchema = object({
160856
+ records: array(RecordViewSchema),
160857
+ nextCursor: string().nullable()
160858
+ });
160859
+ var RecordKindStateSchema = _enum([
160860
+ "created",
160861
+ "unchanged",
160862
+ "updated"
160863
+ ]);
160864
+ var DeclareKindResultSchema = object({
160865
+ kindId: number().int(),
160866
+ state: RecordKindStateSchema,
160867
+ createdIndexes: array(string())
160868
+ });
160869
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
160870
+ var SecretRefsList = array(string());
160871
+ /**
160872
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
160873
+ * All ops of one call share ONE database file and ONE `transactFamily`.
160874
+ */
160875
+ var RecordTransactOpSchema = discriminatedUnion("op", [
160876
+ object({
160877
+ op: literal("put"),
160878
+ kind: RecordKindNameSchema,
160879
+ record: RecordInputSchema,
160880
+ ifRev: number().int().min(0).optional()
160881
+ }),
160882
+ object({
160883
+ op: literal("patch"),
160884
+ kind: RecordKindNameSchema,
160885
+ id: RecordIdSchema,
160886
+ data: RecordBodySchema,
160887
+ at: number().int().nullable().optional(),
160888
+ expiresAt: number().int().nullable().optional(),
160889
+ ifRev: number().int().min(1).optional()
160890
+ }),
160891
+ object({
160892
+ op: literal("delete"),
160893
+ kind: RecordKindNameSchema,
160894
+ id: RecordIdSchema
160895
+ })
160896
+ ]);
160897
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
160898
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
160899
+ kind: "mutation",
160900
+ auth: "admin"
160901
+ }), method(object({
160902
+ ...KindShape,
160903
+ id: RecordIdSchema
160904
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
160905
+ ...KindShape,
160906
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160907
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
160908
+ ...KindShape,
160909
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160910
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
160911
+ ...KindShape,
160912
+ record: RecordInputSchema,
160913
+ /** Compare-and-set. `0` means "the row must not exist". */
160914
+ ifRev: number().int().min(0).optional()
160915
+ }), object({
160916
+ rev: number().int(),
160917
+ releasedRefs: SecretRefsList
160918
+ }), {
160919
+ kind: "mutation",
160920
+ auth: "admin"
160921
+ }), method(object({
160922
+ ...KindShape,
160923
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
160924
+ }), object({
160925
+ count: number().int(),
160926
+ releasedRefs: SecretRefsList
160927
+ }), {
160928
+ kind: "mutation",
160929
+ auth: "admin"
160930
+ }), method(object({
160931
+ ...KindShape,
160932
+ id: RecordIdSchema,
160933
+ data: RecordBodySchema,
160934
+ at: number().int().nullable().optional(),
160935
+ expiresAt: number().int().nullable().optional(),
160936
+ ifRev: number().int().min(1).optional()
160937
+ }), object({
160938
+ rev: number().int(),
160939
+ releasedRefs: SecretRefsList
160940
+ }), {
160941
+ kind: "mutation",
160942
+ auth: "admin"
160943
+ }), method(object({
160944
+ ...KindShape,
160945
+ id: RecordIdSchema
160946
+ }), object({
160947
+ deleted: boolean(),
160948
+ secretRefs: SecretRefsList
160949
+ }), {
160950
+ kind: "mutation",
160951
+ auth: "admin"
160952
+ }), method(object({
160953
+ ...KindShape,
160954
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
160955
+ }), object({
160956
+ deleted: number().int(),
160957
+ secretRefs: SecretRefsList
160958
+ }), {
160959
+ kind: "mutation",
160960
+ auth: "admin"
160961
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
160962
+ ...KindShape,
160963
+ ...TimeWindowShape,
160964
+ where: RecordWhereSchema.optional()
160965
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
160966
+ ...KindShape,
160967
+ deviceId: number().int().optional(),
160968
+ from: number(),
160969
+ to: number(),
160970
+ bucketMs: number().int().positive()
160971
+ }), object({ buckets: array(object({
160972
+ bucketStart: number(),
160973
+ count: number().int()
160974
+ })) }), { auth: "admin" }), method(object({
160975
+ ...KindShape,
160976
+ op: _enum([
160977
+ "sum",
160978
+ "min",
160979
+ "max",
160980
+ "count"
160981
+ ]),
160982
+ field: RecordFieldPathSchema.optional(),
160983
+ groupBy: RecordFieldPathSchema.optional(),
160984
+ where: RecordWhereSchema.optional()
160985
+ }), object({ rows: array(object({
160986
+ group: union([
160987
+ string(),
160988
+ number(),
160989
+ _null()
160990
+ ]),
160991
+ value: number().nullable()
160992
+ })) }), { auth: "admin" }), method(object({
160993
+ ...KindShape,
160994
+ deviceId: number().int().optional(),
160995
+ atBefore: number().optional(),
160996
+ where: RecordWhereSchema.optional()
160997
+ }), object({
160998
+ deleted: number().int(),
160999
+ secretRefs: SecretRefsList
161000
+ }), {
161001
+ kind: "mutation",
161002
+ auth: "admin"
161003
+ }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
161004
+ results: array(object({
161005
+ rev: number().int().nullable(),
161006
+ deleted: boolean()
161007
+ })),
161008
+ releasedRefs: SecretRefsList,
161009
+ secretRefs: SecretRefsList
161010
+ }), {
161011
+ kind: "mutation",
161012
+ auth: "admin"
161013
+ }), method(object({
161014
+ deviceId: number().int(),
161015
+ kinds: array(RecordKindNameSchema).optional()
161016
+ }), object({
161017
+ deleted: record(string(), number().int()),
161018
+ secretRefs: SecretRefsList
161019
+ }), {
161020
+ kind: "mutation",
161021
+ auth: "admin"
161022
+ }), method(object(KindShape), object({ id: number().int() }), {
161023
+ kind: "mutation",
161024
+ auth: "admin"
161025
+ });
161026
+ /**
161027
+ * The wire shapes of the migration API, version 1 (planning#447).
161028
+ *
161029
+ * A migration is code that outlives the server it was written against: an addon at
161030
+ * version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
161031
+ * the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
161032
+ * is the contract of every method of it, one Zod pair per method.
161033
+ *
161034
+ * APPEND-ONLY. A released method is never removed and never changes meaning: an input
161035
+ * field is never removed or made required, an enum never narrows, an output field is
161036
+ * never removed. A change that cannot be expressed that way is `migration-api.v2`, next
161037
+ * to this file. `scripts/check-migration-api-append-only.ts` holds the line against
161038
+ * `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
161039
+ * `it('<id>'` in `migration-api.contract.spec.ts`.
161040
+ */
161041
+ var Rows = record(string(), unknown());
161042
+ var IntegrationId = object({ integrationId: string().min(1) });
161043
+ var RecordId = object({ id: string().min(1) });
161044
+ var RecordRowSchema = object({
161045
+ id: string(),
161046
+ deviceId: number().int().nullable(),
161047
+ at: number().nullable(),
161048
+ expiresAt: number().nullable(),
161049
+ rev: number().int(),
161050
+ updatedAt: number(),
161051
+ data: Rows
161052
+ });
161053
+ var RecordPutShape = {
161054
+ id: string().min(1),
161055
+ deviceId: number().int().optional(),
161056
+ at: number().int().optional(),
161057
+ expiresAt: number().int().optional(),
161058
+ data: Rows
161059
+ };
161060
+ var MigrationIntegrationSchema = object({
161061
+ id: string(),
161062
+ addonId: string(),
161063
+ name: string(),
161064
+ info: Rows,
161065
+ originStableId: string().optional()
161066
+ });
161067
+ var MigrationDeviceSchema = object({
161068
+ id: number().int(),
161069
+ integrationId: string().nullable().optional(),
161070
+ /** The owning device; null or absent for a root. */
161071
+ parentDeviceId: number().int().nullable().optional(),
161072
+ type: string().optional(),
161073
+ name: string().optional(),
161074
+ stableId: string().optional()
161075
+ });
161076
+ /** What the engine says about the migration API it serves: lets an addon notice an older server. */
161077
+ var MigrationApiInfoSchema = object({
161078
+ version: number().int(),
161079
+ methods: array(string())
161080
+ });
161081
+ object({
161082
+ message: string(),
161083
+ meta: Rows.optional(),
161084
+ /** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
161085
+ tags: object({ deviceId: number().int().optional() }).optional()
161086
+ });
161087
+ object({
161088
+ owner: string().min(1),
161089
+ metas: array(MigrationMetaSchema)
161090
+ }), object({
161091
+ bootId: string(),
161092
+ snapshot: _enum([
161093
+ "none",
161094
+ "written",
161095
+ "refused"
161096
+ ]),
161097
+ steps: array(MigrationOwnerStepSchema),
161098
+ /** The migration API the engine serves; absent from a server that predates it. */
161099
+ migrationApi: MigrationApiInfoSchema.optional()
161100
+ }), object({ id: string().min(1) }), object({
161101
+ proceed: boolean(),
161102
+ state: union([literal("pending"), MigrationStatusSchema]),
161103
+ reason: string().nullable()
161104
+ }), object({
161105
+ id: string().min(1),
161106
+ result: MigrationOwnerResultSchema
161107
+ }), object({
161108
+ status: MigrationStatusSchema,
161109
+ error: string().nullable(),
161110
+ rowsChanged: number().int().nonnegative()
161111
+ }), object({
161112
+ rows: number().int().nonnegative(),
161113
+ secrets: number().int().nonnegative()
161114
+ }), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
161115
+ present: boolean(),
161116
+ removed: Rows
161117
+ }), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
161118
+ ...RecordPutShape,
161119
+ ifRev: number().int().optional()
161120
+ }), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
161121
+ partial: Rows,
161122
+ ifRev: number().int().optional()
161123
+ }), object({ rev: number().int() }), object({ deleted: boolean() }), object({
161124
+ deviceId: number().int().optional(),
161125
+ atFrom: number().optional(),
161126
+ atTo: number().optional(),
161127
+ where: RecordWhereSchema.optional(),
161128
+ limit: number().int().min(1).optional(),
161129
+ cursor: string().min(1).optional(),
161130
+ resolveSecrets: boolean().optional()
161131
+ }), object({
161132
+ records: array(RecordRowSchema),
161133
+ nextCursor: string().nullable()
161134
+ }), object({
161135
+ deviceId: number().int().optional(),
161136
+ atBefore: number().optional(),
161137
+ where: RecordWhereSchema.optional()
161138
+ }), 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({
161139
+ ref: string().min(1),
161140
+ value: string()
161141
+ }), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
161142
+ addonId: string().min(1),
161143
+ integrationId: string().min(1).optional()
161144
+ }), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
161145
+ id: number().int(),
161146
+ integrationId: string().nullable(),
161147
+ /** Whether the device carries any stored config; its content is not offered. */
161148
+ hasConfig: boolean()
161149
+ }).nullable(), object({
161150
+ deviceId: number().int(),
161151
+ integrationId: string().min(1)
161152
+ }), object({}), object({}), object({ nodeId: string() }), object({}), object({});
160868
161153
  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({
160869
161154
  id: string().min(1),
160870
161155
  error: string().min(1)
@@ -160894,7 +161179,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
160894
161179
  "written",
160895
161180
  "refused"
160896
161181
  ]),
160897
- steps: array(MigrationOwnerStepSchema)
161182
+ steps: array(MigrationOwnerStepSchema),
161183
+ /** The migration API this engine serves (additive: a server that predates it omits it). */
161184
+ migrationApi: MigrationApiInfoSchema.optional()
160898
161185
  }), {
160899
161186
  kind: "mutation",
160900
161187
  auth: "admin"
@@ -163561,7 +163848,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
163561
163848
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
163562
163849
  kind: "mutation",
163563
163850
  auth: "admin"
163564
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
163851
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
163852
+ kind: "query",
163853
+ auth: "admin"
163854
+ }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
163565
163855
  kind: "query",
163566
163856
  auth: "admin"
163567
163857
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -166216,7 +166506,7 @@ var BrokerStatusSchema$1 = _enum([
166216
166506
  "unreachable",
166217
166507
  "tls-error"
166218
166508
  ]);
166219
- var BrokerInfoSchema$1 = object({
166509
+ var BrokerInfoSchema = object({
166220
166510
  id: string(),
166221
166511
  name: string(),
166222
166512
  url: string(),
@@ -166279,7 +166569,7 @@ var StatusSchema = object({
166279
166569
  brokerCount: number(),
166280
166570
  embeddedRunning: boolean()
166281
166571
  });
166282
- method(_void(), array(BrokerInfoSchema$1)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
166572
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
166283
166573
  kind: "mutation",
166284
166574
  auth: "admin"
166285
166575
  }), method(IdInputSchema, _void(), {
@@ -173665,253 +173955,6 @@ var rebootCapability = {
173665
173955
  }) }
173666
173956
  };
173667
173957
  /**
173668
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
173669
- * config documents, mirrors. The third storage API next to `ctx.settings`
173670
- * (operator intent, D870) and device-history (numbers over time, D850).
173671
- *
173672
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
173673
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
173674
- * that with the addon id closed over). It is deliberately NOT in any input
173675
- * schema, so a session can never supply it, and a call with no stamp is refused
173676
- * `records/no-caller`. A kind is readable and writable only by its owner; other
173677
- * addons go through the owner's capability.
173678
- *
173679
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
173680
- * never `[]`. Secret fields are never on the wire: a read shows the
173681
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
173682
- * resolves itself, and a write may carry only a keychain marker bound to the
173683
- * row's own ref.
173684
- *
173685
- * Internal: addons reach it through `ctx.records`, never directly.
173686
- */
173687
- var RecordIdSchema = string().min(1).max(256);
173688
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
173689
- var RecordBodySchema = record(string(), unknown());
173690
- var RecordInputSchema = object({
173691
- id: RecordIdSchema,
173692
- /** The device this row belongs to (D865 removal, per-device reads). */
173693
- deviceId: number().int().optional(),
173694
- /** The domain clock, ms: observed / created / opened. */
173695
- at: number().int().optional(),
173696
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
173697
- expiresAt: number().int().optional(),
173698
- data: RecordBodySchema
173699
- });
173700
- var RecordViewSchema = object({
173701
- id: string(),
173702
- deviceId: number().int().nullable(),
173703
- at: number().nullable(),
173704
- expiresAt: number().nullable(),
173705
- rev: number().int(),
173706
- updatedAt: number(),
173707
- data: RecordBodySchema
173708
- });
173709
- /** Declared index fields only. Anything else does not compile, by design. */
173710
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
173711
- string(),
173712
- number(),
173713
- boolean(),
173714
- object({ in: array(union([
173715
- string(),
173716
- number(),
173717
- boolean()
173718
- ])).min(1).max(RECORD_BATCH_MAX) }),
173719
- object({
173720
- gt: union([string(), number()]).optional(),
173721
- gte: union([string(), number()]).optional(),
173722
- lt: union([string(), number()]).optional(),
173723
- lte: union([string(), number()]).optional()
173724
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
173725
- ]));
173726
- var KindShape = { kind: RecordKindNameSchema };
173727
- var TimeWindowShape = {
173728
- deviceId: number().int().optional(),
173729
- atFrom: number().optional(),
173730
- atTo: number().optional()
173731
- };
173732
- var RecordQueryInputSchema = object({
173733
- ...KindShape,
173734
- ...TimeWindowShape,
173735
- where: RecordWhereSchema.optional(),
173736
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
173737
- order: _enum(["at", "id"]).optional(),
173738
- desc: boolean().optional(),
173739
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
173740
- /** Opaque keyset cursor from a previous answer. There is no offset. */
173741
- cursor: string().min(1).optional()
173742
- });
173743
- var RecordQueryResultSchema = object({
173744
- records: array(RecordViewSchema),
173745
- nextCursor: string().nullable()
173746
- });
173747
- var RecordKindStateSchema = _enum([
173748
- "created",
173749
- "unchanged",
173750
- "updated"
173751
- ]);
173752
- var DeclareKindResultSchema = object({
173753
- kindId: number().int(),
173754
- state: RecordKindStateSchema,
173755
- createdIndexes: array(string())
173756
- });
173757
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
173758
- var SecretRefsList = array(string());
173759
- /**
173760
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
173761
- * All ops of one call share ONE database file and ONE `transactFamily`.
173762
- */
173763
- var RecordTransactOpSchema = discriminatedUnion("op", [
173764
- object({
173765
- op: literal("put"),
173766
- kind: RecordKindNameSchema,
173767
- record: RecordInputSchema,
173768
- ifRev: number().int().min(0).optional()
173769
- }),
173770
- object({
173771
- op: literal("patch"),
173772
- kind: RecordKindNameSchema,
173773
- id: RecordIdSchema,
173774
- data: RecordBodySchema,
173775
- at: number().int().nullable().optional(),
173776
- expiresAt: number().int().nullable().optional(),
173777
- ifRev: number().int().min(1).optional()
173778
- }),
173779
- object({
173780
- op: literal("delete"),
173781
- kind: RecordKindNameSchema,
173782
- id: RecordIdSchema
173783
- })
173784
- ]);
173785
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
173786
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
173787
- kind: "mutation",
173788
- auth: "admin"
173789
- }), method(object({
173790
- ...KindShape,
173791
- id: RecordIdSchema
173792
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
173793
- ...KindShape,
173794
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173795
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
173796
- ...KindShape,
173797
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173798
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
173799
- ...KindShape,
173800
- record: RecordInputSchema,
173801
- /** Compare-and-set. `0` means "the row must not exist". */
173802
- ifRev: number().int().min(0).optional()
173803
- }), object({
173804
- rev: number().int(),
173805
- releasedRefs: SecretRefsList
173806
- }), {
173807
- kind: "mutation",
173808
- auth: "admin"
173809
- }), method(object({
173810
- ...KindShape,
173811
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
173812
- }), object({
173813
- count: number().int(),
173814
- releasedRefs: SecretRefsList
173815
- }), {
173816
- kind: "mutation",
173817
- auth: "admin"
173818
- }), method(object({
173819
- ...KindShape,
173820
- id: RecordIdSchema,
173821
- data: RecordBodySchema,
173822
- at: number().int().nullable().optional(),
173823
- expiresAt: number().int().nullable().optional(),
173824
- ifRev: number().int().min(1).optional()
173825
- }), object({
173826
- rev: number().int(),
173827
- releasedRefs: SecretRefsList
173828
- }), {
173829
- kind: "mutation",
173830
- auth: "admin"
173831
- }), method(object({
173832
- ...KindShape,
173833
- id: RecordIdSchema
173834
- }), object({
173835
- deleted: boolean(),
173836
- secretRefs: SecretRefsList
173837
- }), {
173838
- kind: "mutation",
173839
- auth: "admin"
173840
- }), method(object({
173841
- ...KindShape,
173842
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173843
- }), object({
173844
- deleted: number().int(),
173845
- secretRefs: SecretRefsList
173846
- }), {
173847
- kind: "mutation",
173848
- auth: "admin"
173849
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
173850
- ...KindShape,
173851
- ...TimeWindowShape,
173852
- where: RecordWhereSchema.optional()
173853
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
173854
- ...KindShape,
173855
- deviceId: number().int().optional(),
173856
- from: number(),
173857
- to: number(),
173858
- bucketMs: number().int().positive()
173859
- }), object({ buckets: array(object({
173860
- bucketStart: number(),
173861
- count: number().int()
173862
- })) }), { auth: "admin" }), method(object({
173863
- ...KindShape,
173864
- op: _enum([
173865
- "sum",
173866
- "min",
173867
- "max",
173868
- "count"
173869
- ]),
173870
- field: RecordFieldPathSchema.optional(),
173871
- groupBy: RecordFieldPathSchema.optional(),
173872
- where: RecordWhereSchema.optional()
173873
- }), object({ rows: array(object({
173874
- group: union([
173875
- string(),
173876
- number(),
173877
- _null()
173878
- ]),
173879
- value: number().nullable()
173880
- })) }), { auth: "admin" }), method(object({
173881
- ...KindShape,
173882
- deviceId: number().int().optional(),
173883
- atBefore: number().optional(),
173884
- where: RecordWhereSchema.optional()
173885
- }), object({
173886
- deleted: number().int(),
173887
- secretRefs: SecretRefsList
173888
- }), {
173889
- kind: "mutation",
173890
- auth: "admin"
173891
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
173892
- results: array(object({
173893
- rev: number().int().nullable(),
173894
- deleted: boolean()
173895
- })),
173896
- releasedRefs: SecretRefsList,
173897
- secretRefs: SecretRefsList
173898
- }), {
173899
- kind: "mutation",
173900
- auth: "admin"
173901
- }), method(object({
173902
- deviceId: number().int(),
173903
- kinds: array(RecordKindNameSchema).optional()
173904
- }), object({
173905
- deleted: record(string(), number().int()),
173906
- secretRefs: SecretRefsList
173907
- }), {
173908
- kind: "mutation",
173909
- auth: "admin"
173910
- }), method(object(KindShape), object({ id: number().int() }), {
173911
- kind: "mutation",
173912
- auth: "admin"
173913
- });
173914
- /**
173915
173958
  * record-entries - the ONE admin surface for every list of user-created entries
173916
173959
  * (D881): notification targets, brokers, LLM profiles, anything an addon
173917
173960
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -184768,7 +184811,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184768
184811
  * `deviceClasses` map (first registered type). `null` when manual creation is
184769
184812
  * unsupported. Lets the Add-Device dialog pick the right type per provider.
184770
184813
  */
184771
- async getManualCreationType() {
184814
+ async getManualCreationType(_input) {
184772
184815
  if (!await this.supportsManualCreation()) return { deviceType: null };
184773
184816
  return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
184774
184817
  }
@@ -184779,7 +184822,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184779
184822
  return true;
184780
184823
  }
184781
184824
  async getChildCreationSchema(input) {
184782
- return this.onGetCreationSchema(input.type);
184825
+ return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
184783
184826
  }
184784
184827
  /**
184785
184828
  * Default kernel-orchestrated `createDevice` implementation. The
@@ -184791,7 +184834,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184791
184834
  * `deviceClasses` instead.
184792
184835
  */
184793
184836
  async createDevice(input) {
184794
- const spec = await this.onCreateDevice(input.type, input.config);
184837
+ const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
184795
184838
  const Class = this.deviceClasses[spec.meta.type];
184796
184839
  if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
184797
184840
  const stableId = this.generateStableId(spec.meta.type, spec.config);
@@ -186200,20 +186243,6 @@ Object.freeze({
186200
186243
  access: "create",
186201
186244
  role: "viewer"
186202
186245
  },
186203
- "broker.add": {
186204
- capName: "broker",
186205
- capScope: "system",
186206
- addonId: null,
186207
- access: "create",
186208
- role: "admin"
186209
- },
186210
- "broker.get": {
186211
- capName: "broker",
186212
- capScope: "system",
186213
- addonId: null,
186214
- access: "view",
186215
- role: "admin"
186216
- },
186217
186246
  "broker.getBrokerConfig": {
186218
186247
  capName: "broker",
186219
186248
  capScope: "system",
@@ -186221,20 +186250,6 @@ Object.freeze({
186221
186250
  access: "view",
186222
186251
  role: "admin"
186223
186252
  },
186224
- "broker.getSettings": {
186225
- capName: "broker",
186226
- capScope: "system",
186227
- addonId: null,
186228
- access: "view",
186229
- role: "admin"
186230
- },
186231
- "broker.getSettingsSchema": {
186232
- capName: "broker",
186233
- capScope: "system",
186234
- addonId: null,
186235
- access: "view",
186236
- role: "admin"
186237
- },
186238
186253
  "broker.getState": {
186239
186254
  capName: "broker",
186240
186255
  capScope: "system",
@@ -186249,20 +186264,6 @@ Object.freeze({
186249
186264
  access: "view",
186250
186265
  role: "admin"
186251
186266
  },
186252
- "broker.list": {
186253
- capName: "broker",
186254
- capScope: "system",
186255
- addonId: null,
186256
- access: "view",
186257
- role: "admin"
186258
- },
186259
- "broker.listProviders": {
186260
- capName: "broker",
186261
- capScope: "system",
186262
- addonId: null,
186263
- access: "view",
186264
- role: "admin"
186265
- },
186266
186267
  "broker.publish": {
186267
186268
  capName: "broker",
186268
186269
  capScope: "system",
@@ -186270,20 +186271,6 @@ Object.freeze({
186270
186271
  access: "create",
186271
186272
  role: "admin"
186272
186273
  },
186273
- "broker.remove": {
186274
- capName: "broker",
186275
- capScope: "system",
186276
- addonId: null,
186277
- access: "delete",
186278
- role: "admin"
186279
- },
186280
- "broker.setSettings": {
186281
- capName: "broker",
186282
- capScope: "system",
186283
- addonId: null,
186284
- access: "create",
186285
- role: "admin"
186286
- },
186287
186274
  "broker.subscribe": {
186288
186275
  capName: "broker",
186289
186276
  capScope: "system",
@@ -186291,20 +186278,6 @@ Object.freeze({
186291
186278
  access: "create",
186292
186279
  role: "admin"
186293
186280
  },
186294
- "broker.testConnection": {
186295
- capName: "broker",
186296
- capScope: "system",
186297
- addonId: null,
186298
- access: "create",
186299
- role: "admin"
186300
- },
186301
- "broker.testSettings": {
186302
- capName: "broker",
186303
- capScope: "system",
186304
- addonId: null,
186305
- access: "create",
186306
- role: "admin"
186307
- },
186308
186281
  "broker.unsubscribe": {
186309
186282
  capName: "broker",
186310
186283
  capScope: "system",
@@ -191268,6 +191241,13 @@ Object.freeze({
191268
191241
  access: "view",
191269
191242
  role: "viewer"
191270
191243
  },
191244
+ "pipelineAnalytics.getMediaLocationCensus": {
191245
+ capName: "pipeline-analytics",
191246
+ capScope: "device",
191247
+ addonId: null,
191248
+ access: "view",
191249
+ role: "admin"
191250
+ },
191271
191251
  "pipelineAnalytics.getMediaReclaimStatus": {
191272
191252
  capName: "pipeline-analytics",
191273
191253
  capScope: "device",
@@ -200412,6 +200392,7 @@ object({
200412
200392
  delay: number().nonnegative().optional(),
200413
200393
  commands: record(string(), unknown())
200414
200394
  });
200395
+ entryBody({ brokerId: string() });
200415
200396
  //#endregion
200416
200397
  //#region src/clips/clip-prefetch.ts
200417
200398
  /** The longest a device may stay quiet after refusals, whatever its interval. */
@@ -220889,17 +220870,29 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
220889
220870
  var REOLINK_SUBSCRIBER_ID = "provider-reolink";
220890
220871
  var MAILBOX_NAME = "Camera mailbox";
220891
220872
  var RECIPIENT_PREFIX = "cam-";
220892
- /** The real port: `ctx.api.broker`, every call routed to the addon that owns the kind. */
220873
+ /**
220874
+ * The real port: the mailboxes are `integration-instances` of the SMTP addon (the kind of its
220875
+ * `broker` section, found from its description, D1013); pub/sub goes through `ctx.api.broker`.
220876
+ * Every call is routed to the addon that owns the kind.
220877
+ */
220893
220878
  function createBrokerPort(api) {
220894
220879
  const route = { addonId: SMTP_BROKER_ADDON_ID };
220880
+ const mailboxKind = async () => {
220881
+ const kind = (await api.integrationInstances.describe.query(route)).kinds?.find((k) => k.functionCap === "broker" && (k.brokerKind ?? k.id) === "smtp-inbound");
220882
+ if (kind === void 0) throw new Error("the SMTP addon declares no mailbox kind");
220883
+ return kind.id;
220884
+ };
220895
220885
  return {
220896
- list: async () => api.broker.list.query({ kind: SMTP_INBOUND_KIND }),
220897
- add: async ({ id, name, settings }) => api.broker.add.mutate({
220898
- kind: SMTP_INBOUND_KIND,
220899
- name,
220886
+ list: async () => {
220887
+ const kind = await mailboxKind();
220888
+ return (await api.integrationInstances.listInstances.query(route)).filter((instance) => instance.kind === kind);
220889
+ },
220890
+ add: async ({ id, name, settings }) => api.integrationInstances.createInstance.mutate({
220891
+ ...route,
220900
220892
  id,
220901
- settings: { ...settings },
220902
- ...route
220893
+ name,
220894
+ kind: await mailboxKind(),
220895
+ values: { ...settings }
220903
220896
  }),
220904
220897
  getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
220905
220898
  id,
@@ -221703,6 +221696,19 @@ function reolinkInstancesProvider(instances, deps) {
221703
221696
  }
221704
221697
  };
221705
221698
  }
221699
+ /**
221700
+ * Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
221701
+ * manual add by IP). An integration the registry cannot name is not a hub for this question.
221702
+ */
221703
+ async function integrationIsHub(instances, deps, id) {
221704
+ const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
221705
+ if (evidence === null) return false;
221706
+ return isHubIntegration({
221707
+ originStableId: evidence.originStableId,
221708
+ info: evidence.info,
221709
+ settings: body === null ? {} : hubSettingsOf(body)
221710
+ });
221711
+ }
221706
221712
  //#endregion
221707
221713
  //#region src/migrations/integration-rows-to-record.ts
221708
221714
  /**
@@ -222481,6 +222487,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222481
222487
  autodetectCache = new AutodetectCache();
222482
222488
  hubManager = null;
222483
222489
  instances = null;
222490
+ hubIntegrationProbe = null;
222484
222491
  /**
222485
222492
  * The camera mailbox bridge (`email-push-bridge.ts`, D999): battery cameras mail motion to a
222486
222493
  * mailbox of the `smtp-inbound` broker, the bridge turns each message into the camera's
@@ -222991,6 +222998,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222991
222998
  registryEvidenceOf
222992
222999
  });
222993
223000
  this.instances = instances;
223001
+ this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
222994
223002
  await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
222995
223003
  this.wireEmailBridge();
222996
223004
  const wireSleepPushResolvers = (event, via) => {
@@ -223324,10 +223332,22 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223324
223332
  config: input.candidate.prefilledConfig
223325
223333
  });
223326
223334
  }
223327
- async onGetCreationSchema(type) {
223335
+ async onGetCreationSchema(type, context) {
223328
223336
  if (type !== DeviceType.Camera) return null;
223337
+ if (await this.isHubIntegrationId(context?.integrationId)) return null;
223329
223338
  return buildCreationFormSchema();
223330
223339
  }
223340
+ /** A hub integration's devices come from the hub: no manual add by IP for it. */
223341
+ async getManualCreationType(input) {
223342
+ if (await this.isHubIntegrationId(input?.integrationId)) return { deviceType: null };
223343
+ return super.getManualCreationType(input);
223344
+ }
223345
+ /** `false` for no integration, or one the registry cannot name (the addon's own default). */
223346
+ async isHubIntegrationId(id) {
223347
+ const probe = this.hubIntegrationProbe;
223348
+ if (id === void 0 || probe === null) return false;
223349
+ return probe(id);
223350
+ }
223331
223351
  async onCreateDevice(type, config) {
223332
223352
  if (type !== DeviceType.Camera) throw new Error(`Reolink provider does not support device type: ${type}`);
223333
223353
  const name = getString(config, "name").trim();