@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.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;
@@ -114375,7 +114384,7 @@ var RecordIntegrationInstances = class {
114375
114384
  return record === null ? null : this.viewOf(record);
114376
114385
  };
114377
114386
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
114378
- createInstance = async ({ id, name, kind }) => {
114387
+ createInstance = async ({ id, name, kind, values }) => {
114379
114388
  const minted = id ?? this.hooks.mintId?.({
114380
114389
  name,
114381
114390
  ...kind !== void 0 ? { kind } : {}
@@ -114385,10 +114394,20 @@ var RecordIntegrationInstances = class {
114385
114394
  id: minted,
114386
114395
  data: this.hooks.initialBody(name, kind)
114387
114396
  }, { ifRev: 0 });
114397
+ const patch = this.patchOf(values ?? {});
114398
+ if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
114388
114399
  await this.hooks.onChanged?.(minted, "created");
114389
114400
  return { id: minted };
114390
114401
  };
114391
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) {
114392
114411
  const patch = {};
114393
114412
  for (const [key, value] of Object.entries(values)) {
114394
114413
  if (value === void 0) continue;
@@ -114399,11 +114418,8 @@ var RecordIntegrationInstances = class {
114399
114418
  else if (isSecretClear(value)) patch[key] = null;
114400
114419
  else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
114401
114420
  }
114402
- if (name !== void 0) patch[this.nameField] = name;
114403
- await this.handle.patch(id, patch);
114404
- await this.hooks.onChanged?.(id, "updated");
114405
- return { ok: true };
114406
- };
114421
+ return patch;
114422
+ }
114407
114423
  /** The switch lives in the record body; the addon is told so it applies it (D996). */
114408
114424
  setInstanceEnabled = async ({ id, enabled }) => {
114409
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`);
@@ -115736,13 +115752,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
115736
115752
  };
115737
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`);
115738
115754
  for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
115739
- 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);
115740
115756
  for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
115741
115757
  const wrong = [];
115742
115758
  for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
115743
115759
  if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
115744
115760
  const claimed = plan.size;
115745
- 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`);
115746
115762
  return {
115747
115763
  outcome: claimed > 0 ? "done" : "already-done",
115748
115764
  summary: {
@@ -116958,6 +116974,39 @@ var UnstampedEventMediaCountSchema = object({
116958
116974
  /** Sum across both, or `null` when either lane could not be counted. */
116959
116975
  total: number().int().nonnegative().nullable()
116960
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
+ });
116961
117010
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
116962
117011
  /** The independently selectable logical storage classes — every class
116963
117012
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -148528,52 +148577,7 @@ onBrightnessChanged: { data: object({
148528
148577
  minIntervalMs: 0
148529
148578
  } } }
148530
148579
  };
148531
- /**
148532
- * `broker` — unified pub/sub broker registry, system-scoped collection.
148533
- *
148534
- * The cap models any kind-tagged message broker the user wants to
148535
- * register and that other addons might consume. The first two kinds
148536
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
148537
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
148538
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
148539
- * the same surface.
148540
- *
148541
- * Why one cap, not one cap per kind:
148542
- * - The integrations page wants a single table of "every broker"
148543
- * across kinds; a unified cap drives it without join logic.
148544
- * - Generic admin operations (add / remove / test / status) are
148545
- * identical across kinds — duplicating them per cap was busywork.
148546
- * - The `network-access` cap precedent: same interface, many
148547
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
148548
- *
148549
- * What stays kind-specific:
148550
- * - `getBrokerConfig` payload (kind decides whether it returns
148551
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
148552
- * `Record<string, unknown>` at the wire; consumers narrow.
148553
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
148554
- * key) — also typed as `Record<string, unknown>` so each kind can
148555
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
148556
- * without rebreaking the cap signature.
148557
- * - `add` `settings` payload (different fields per kind, validated by
148558
- * the kind-specific provider).
148559
- *
148560
- * Bidirectionality:
148561
- * - `publish` is RPC — synchronous result (provider-defined).
148562
- * - `subscribe` returns a subscription handle; the actual message
148563
- * stream flows over the typed event-bus as `broker.message` events
148564
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
148565
- * event handler. Subscriptions persist across reconnects — the
148566
- * provider re-subscribes upstream after a transport drop.
148567
- *
148568
- * Why event-bus push (not a subscription RPC stream):
148569
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
148570
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
148571
- * drop is recoverable via `getState({key})`).
148572
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
148573
- * - Cross-process: events already route through `$event-bus`; no
148574
- * per-broker wire-shaping needed.
148575
- */
148576
- var BrokerStatusEnum = _enum([
148580
+ _enum([
148577
148581
  "connected",
148578
148582
  "disconnected",
148579
148583
  "connecting",
@@ -148581,141 +148585,12 @@ var BrokerStatusEnum = _enum([
148581
148585
  "unreachable",
148582
148586
  "error"
148583
148587
  ]);
148584
- var BrokerInfoSchema = object({
148585
- /** Stable broker id. Persisted; survives addon restarts. */
148586
- id: string(),
148587
- /** Addon id of the provider that OWNS this broker.
148588
- *
148589
- * The `broker` cap is a system-scoped collection: several addons
148590
- * register a `broker` provider, each owning a DISJOINT set of
148591
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
148592
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
148593
- * device belongs to one integration. The admin UI threads this id
148594
- * back as the `{ addonId }` system-collection selector on every
148595
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
148596
- * `testConnection`), so the call routes to the OWNING provider
148597
- * instead of defaulting to the first-registered one. */
148598
- addonId: string(),
148599
- /** Human-readable name (operator-chosen at add-time). */
148600
- name: string(),
148601
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
148602
- kind: string(),
148603
- status: BrokerStatusEnum,
148604
- /** Free-form provider-specific info (HA version, MQTT broker
148605
- * flavour, latency, mTLS active, …). */
148606
- info: record(string(), unknown()),
148607
- /** Ms epoch of the last connection probe / status update. */
148608
- lastCheckedAt: number().nullable(),
148609
- /** Last error message, when `status` indicates failure. */
148610
- error: string().nullable()
148611
- });
148612
148588
  var RegistryStatusSchema = object({
148613
148589
  brokerCount: number().int().nonnegative(),
148614
148590
  connectedCount: number().int().nonnegative()
148615
148591
  });
148616
- /**
148617
- * One entry per `broker` provider — which addon provides which broker
148618
- * kind(s). The unified create picker reads this to know, for each
148619
- * (addonId, kind) pair the operator can pick, where to route the
148620
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
148621
- * `{ addonId }` selector). A provider only advertises a kind here when
148622
- * it implements `getSettingsSchema` for that kind (so the picker never
148623
- * offers a kind whose creation form can't be rendered).
148624
- */
148625
- var BrokerProviderInfoSchema = object({
148626
- /** Addon id of the `broker` provider this entry describes. */
148627
- addonId: string(),
148628
- /** Broker kinds this provider can create, with a display label. */
148629
- kinds: array(object({
148630
- kind: string(),
148631
- label: string(),
148632
- /**
148633
- * Relative hub path to start an interactive account link (OAuth popup).
148634
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
148635
- */
148636
- interactiveConnectPath: string().min(1).optional(),
148637
- /** Relative hub path to disconnect the linked account (same popup pattern). */
148638
- interactiveDisconnectPath: string().min(1).optional(),
148639
- /**
148640
- * The kind signs in through a server-held interactive session instead of
148641
- * (or before) typed credentials. `basePath` is a hub-relative route set
148642
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
148643
- * contract: `POST {basePath}/start` (body: the form's settings) answers
148644
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
148645
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
148646
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
148647
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
148648
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
148649
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
148650
- * offers it as the default path; the fields the session fills are
148651
- * marked `filledBySignIn` in the kind's settings schema.
148652
- *
148653
- * `methods` lists the ways the session can sign in, recommended first:
148654
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
148655
- * settings) answering `{ sessionId, userCode, verificationUrl,
148656
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
148657
- * any device, and the same `status` / `commit` / `cancel` routes follow
148658
- * (status then carries `method`, `userCode`, `verificationUrl`,
148659
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
148660
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
148661
- * `['proxy']`.
148662
- */
148663
- signIn: object({
148664
- basePath: string().min(1),
148665
- methods: array(_enum(["device-code", "proxy"])).optional()
148666
- }).optional()
148667
- }))
148668
- });
148669
- var ListInputSchema = object({
148670
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
148671
- * only HA brokers. Omit to list every broker. */
148672
- kind: string().optional() });
148673
148592
  var GetInputSchema = object({ id: string() });
148674
- var AddInputSchema = object({
148675
- kind: string().min(1),
148676
- name: string().min(1),
148677
- /**
148678
- * ADOPT an existing id instead of minting a new one.
148679
- *
148680
- * Written the day this cost an outage. A broker's id is not a detail: HA
148681
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
148682
- * lost from config and re-added as `ha_001` leaves every one of its devices
148683
- * bound to a broker that no longer exists. Re-entering the password under the
148684
- * ORIGINAL id turns a multi-step device migration back into re-entering a
148685
- * password.
148686
- *
148687
- * A provider MUST refuse an id that is already in use — adopting a live
148688
- * broker's id would silently take it over.
148689
- */
148690
- id: string().min(1).optional(),
148691
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
148692
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
148693
- * branch on receipt — invalid shape rejects the add. */
148694
- settings: record(string(), unknown())
148695
- });
148696
- var AddResultSchema = object({ id: string() });
148697
- var RemoveInputSchema = object({ id: string() });
148698
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
148699
- ok: literal(true),
148700
- latencyMs: number().nonnegative()
148701
- }), object({
148702
- ok: literal(false),
148703
- error: string()
148704
- })]);
148705
148593
  var SettingsRecordSchema$1 = record(string(), unknown());
148706
- var SettingsSchemaInputSchema = object({ kind: string() });
148707
- var TestSettingsInputSchema = object({
148708
- kind: string(),
148709
- settings: SettingsRecordSchema$1
148710
- });
148711
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
148712
- ok: literal(true),
148713
- latencyMs: number().nonnegative().optional()
148714
- }).strict(), object({
148715
- ok: literal(false),
148716
- error: string()
148717
- })]);
148718
- var SettingsSchemaResultSchema = unknown().nullable();
148719
148594
  var PublishInputSchema = object({
148720
148595
  brokerId: string(),
148721
148596
  /** Kind-specific routing target.
@@ -148749,25 +148624,7 @@ var GetStateInputSchema = object({
148749
148624
  * HA: entity_id (returns the cached entity state). */
148750
148625
  key: string()
148751
148626
  });
148752
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
148753
- kind: "mutation",
148754
- auth: "admin"
148755
- }), method(RemoveInputSchema, _void(), {
148756
- kind: "mutation",
148757
- auth: "admin"
148758
- }), method(GetInputSchema, TestConnectionResultSchema, {
148759
- kind: "mutation",
148760
- auth: "admin"
148761
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
148762
- id: string(),
148763
- settings: SettingsRecordSchema$1
148764
- }), _void(), {
148765
- kind: "mutation",
148766
- auth: "admin"
148767
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
148768
- kind: "mutation",
148769
- auth: "admin"
148770
- }), method(PublishInputSchema, unknown(), {
148627
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
148771
148628
  kind: "mutation",
148772
148629
  auth: "admin"
148773
148630
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -153605,7 +153462,14 @@ var DiscoveryCandidateSchema = object({
153605
153462
  /** `stableId` of the gateway candidate this device was found BEHIND. */
153606
153463
  parentStableId: string().optional(),
153607
153464
  /** `false` = shown for context but not pickable. Default true. */
153608
- selectable: boolean().optional()
153465
+ selectable: boolean().optional(),
153466
+ /**
153467
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
153468
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
153469
+ * admin asks for exactly these, on the creation form prefilled with
153470
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
153471
+ */
153472
+ needsParams: array(string()).optional()
153609
153473
  });
153610
153474
  /**
153611
153475
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -153732,8 +153596,14 @@ var deviceProviderCapability = {
153732
153596
  * provider does not support manual creation. Lets the Add-Device dialog
153733
153597
  * pick the right type instead of assuming Camera.
153734
153598
  */
153735
- getManualCreationType: method(object({}), object({ deviceType: _enum(DeviceType).nullable() })),
153736
- adoptDiscoveredDevice: method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
153599
+ getManualCreationType: method(object({
153600
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153601
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
153602
+ adoptDiscoveredDevice: method(object({
153603
+ candidate: DiscoveryCandidateSchema,
153604
+ /** The integration the operator adopts into; a provider with several instances needs it. */
153605
+ integrationId: string().optional()
153606
+ }), DeviceSummarySchema, {
153737
153607
  kind: "mutation",
153738
153608
  auth: "admin"
153739
153609
  }),
@@ -153744,10 +153614,16 @@ var deviceProviderCapability = {
153744
153614
  * devices of that type. The output is a `ConfigUISchema` — the
153745
153615
  * router type-asserts it at the boundary.
153746
153616
  */
153747
- getChildCreationSchema: method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema),
153617
+ getChildCreationSchema: method(object({
153618
+ type: _enum(DeviceType),
153619
+ /** The integration asked about; a provider whose integrations differ answers per one. */
153620
+ integrationId: string().optional()
153621
+ }), CreationSchemaOutputSchema),
153748
153622
  createDevice: method(object({
153749
153623
  type: _enum(DeviceType),
153750
- config: record(string(), unknown())
153624
+ config: record(string(), unknown()),
153625
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
153626
+ integrationId: string().optional()
153751
153627
  }), DeviceSummarySchema, {
153752
153628
  kind: "mutation",
153753
153629
  auth: "admin"
@@ -154472,7 +154348,10 @@ method(object({
154472
154348
  auth: "admin"
154473
154349
  }), method(object({
154474
154350
  addonId: string(),
154475
- type: _enum(DeviceType)
154351
+ type: _enum(DeviceType),
154352
+ /** The integration the form is for; a provider whose integrations differ (a hub
154353
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
154354
+ integrationId: string().optional()
154476
154355
  }), unknown().nullable()), method(object({
154477
154356
  addonId: string(),
154478
154357
  type: _enum(DeviceType),
@@ -154556,7 +154435,11 @@ method(object({
154556
154435
  kind: "mutation",
154557
154436
  auth: "admin",
154558
154437
  timeoutMs: 12e4
154559
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154438
+ }), method(object({
154439
+ addonId: string(),
154440
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
154441
+ integrationId: string().optional()
154442
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
154560
154443
  deviceId: number(),
154561
154444
  key: string(),
154562
154445
  value: unknown()
@@ -157868,7 +157751,7 @@ var TestConnectionStatusEnum = _enum([
157868
157751
  "inconclusive",
157869
157752
  "unsupported"
157870
157753
  ]);
157871
- var TestConnectionResultSchema$1 = object({
157754
+ var TestConnectionResultSchema = object({
157872
157755
  /** True ONLY for `validated`. Never true for a test that did not run. */
157873
157756
  success: boolean(),
157874
157757
  error: string().optional(),
@@ -157913,7 +157796,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
157913
157796
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
157914
157797
  addonId: string(),
157915
157798
  settings: record(string(), unknown())
157916
- }), TestConnectionResultSchema$1, {
157799
+ }), TestConnectionResultSchema, {
157917
157800
  kind: "mutation",
157918
157801
  auth: "admin"
157919
157802
  });
@@ -157940,6 +157823,14 @@ var ConfigSchemaPassthrough$3 = custom();
157940
157823
  var IntegrationInstanceIdSchema = string().min(1);
157941
157824
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
157942
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
+ /**
157943
157834
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
157944
157835
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
157945
157836
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -157950,6 +157841,22 @@ var IntegrationInstanceKindSchema = object({
157950
157841
  /** Stable id of the kind, sent back as `createInstance.kind`. */
157951
157842
  id: string().min(1),
157952
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(),
157953
157860
  /** The kind signs in through a server-held interactive session. */
157954
157861
  signIn: object({
157955
157862
  basePath: string().min(1),
@@ -157962,11 +157869,7 @@ var IntegrationInstanceKindSchema = object({
157962
157869
  });
157963
157870
  var IntegrationInstanceDescriptionSchema = object({
157964
157871
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
157965
- role: _enum([
157966
- "devices",
157967
- "services",
157968
- "both"
157969
- ]),
157872
+ role: IntegrationInstanceRoleSchema,
157970
157873
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
157971
157874
  discovery: object({
157972
157875
  mode: _enum([
@@ -158041,7 +157944,11 @@ var integrationInstancesCapability = {
158041
157944
  methods: {
158042
157945
  describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
158043
157946
  /** The form; `id: null` is the create form. */
158044
- 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" }),
158045
157952
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
158046
157953
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
158047
157954
  /**
@@ -158051,7 +157958,9 @@ var integrationInstancesCapability = {
158051
157958
  createInstance: method(object({
158052
157959
  id: IntegrationInstanceIdSchema.optional(),
158053
157960
  name: string().min(1),
158054
- 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()
158055
157964
  }), object({ id: string() }), {
158056
157965
  kind: "mutation",
158057
157966
  auth: "admin"
@@ -158078,8 +157987,10 @@ var integrationInstancesCapability = {
158078
157987
  }),
158079
157988
  testInstance: optionalMethod(object({
158080
157989
  id: IntegrationInstanceIdSchema.nullable(),
158081
- values: record(string(), unknown())
158082
- }), 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, {
158083
157994
  kind: "mutation",
158084
157995
  auth: "admin"
158085
157996
  })
@@ -160857,6 +160768,380 @@ var SystemMetricsSchema = object({
160857
160768
  gpuMemoryPercent: number().optional()
160858
160769
  });
160859
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({});
160860
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({
160861
161146
  id: string().min(1),
160862
161147
  error: string().min(1)
@@ -160886,7 +161171,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
160886
161171
  "written",
160887
161172
  "refused"
160888
161173
  ]),
160889
- 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()
160890
161177
  }), {
160891
161178
  kind: "mutation",
160892
161179
  auth: "admin"
@@ -163553,7 +163840,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
163553
163840
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
163554
163841
  kind: "mutation",
163555
163842
  auth: "admin"
163556
- }), 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, {
163557
163847
  kind: "query",
163558
163848
  auth: "admin"
163559
163849
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -166208,7 +166498,7 @@ var BrokerStatusSchema$1 = _enum([
166208
166498
  "unreachable",
166209
166499
  "tls-error"
166210
166500
  ]);
166211
- var BrokerInfoSchema$1 = object({
166501
+ var BrokerInfoSchema = object({
166212
166502
  id: string(),
166213
166503
  name: string(),
166214
166504
  url: string(),
@@ -166271,7 +166561,7 @@ var StatusSchema = object({
166271
166561
  brokerCount: number(),
166272
166562
  embeddedRunning: boolean()
166273
166563
  });
166274
- 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, {
166275
166565
  kind: "mutation",
166276
166566
  auth: "admin"
166277
166567
  }), method(IdInputSchema, _void(), {
@@ -173657,253 +173947,6 @@ var rebootCapability = {
173657
173947
  }) }
173658
173948
  };
173659
173949
  /**
173660
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
173661
- * config documents, mirrors. The third storage API next to `ctx.settings`
173662
- * (operator intent, D870) and device-history (numbers over time, D850).
173663
- *
173664
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
173665
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
173666
- * that with the addon id closed over). It is deliberately NOT in any input
173667
- * schema, so a session can never supply it, and a call with no stamp is refused
173668
- * `records/no-caller`. A kind is readable and writable only by its owner; other
173669
- * addons go through the owner's capability.
173670
- *
173671
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
173672
- * never `[]`. Secret fields are never on the wire: a read shows the
173673
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
173674
- * resolves itself, and a write may carry only a keychain marker bound to the
173675
- * row's own ref.
173676
- *
173677
- * Internal: addons reach it through `ctx.records`, never directly.
173678
- */
173679
- var RecordIdSchema = string().min(1).max(256);
173680
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
173681
- var RecordBodySchema = record(string(), unknown());
173682
- var RecordInputSchema = object({
173683
- id: RecordIdSchema,
173684
- /** The device this row belongs to (D865 removal, per-device reads). */
173685
- deviceId: number().int().optional(),
173686
- /** The domain clock, ms: observed / created / opened. */
173687
- at: number().int().optional(),
173688
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
173689
- expiresAt: number().int().optional(),
173690
- data: RecordBodySchema
173691
- });
173692
- var RecordViewSchema = object({
173693
- id: string(),
173694
- deviceId: number().int().nullable(),
173695
- at: number().nullable(),
173696
- expiresAt: number().nullable(),
173697
- rev: number().int(),
173698
- updatedAt: number(),
173699
- data: RecordBodySchema
173700
- });
173701
- /** Declared index fields only. Anything else does not compile, by design. */
173702
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
173703
- string(),
173704
- number(),
173705
- boolean(),
173706
- object({ in: array(union([
173707
- string(),
173708
- number(),
173709
- boolean()
173710
- ])).min(1).max(RECORD_BATCH_MAX) }),
173711
- object({
173712
- gt: union([string(), number()]).optional(),
173713
- gte: union([string(), number()]).optional(),
173714
- lt: union([string(), number()]).optional(),
173715
- lte: union([string(), number()]).optional()
173716
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
173717
- ]));
173718
- var KindShape = { kind: RecordKindNameSchema };
173719
- var TimeWindowShape = {
173720
- deviceId: number().int().optional(),
173721
- atFrom: number().optional(),
173722
- atTo: number().optional()
173723
- };
173724
- var RecordQueryInputSchema = object({
173725
- ...KindShape,
173726
- ...TimeWindowShape,
173727
- where: RecordWhereSchema.optional(),
173728
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
173729
- order: _enum(["at", "id"]).optional(),
173730
- desc: boolean().optional(),
173731
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
173732
- /** Opaque keyset cursor from a previous answer. There is no offset. */
173733
- cursor: string().min(1).optional()
173734
- });
173735
- var RecordQueryResultSchema = object({
173736
- records: array(RecordViewSchema),
173737
- nextCursor: string().nullable()
173738
- });
173739
- var RecordKindStateSchema = _enum([
173740
- "created",
173741
- "unchanged",
173742
- "updated"
173743
- ]);
173744
- var DeclareKindResultSchema = object({
173745
- kindId: number().int(),
173746
- state: RecordKindStateSchema,
173747
- createdIndexes: array(string())
173748
- });
173749
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
173750
- var SecretRefsList = array(string());
173751
- /**
173752
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
173753
- * All ops of one call share ONE database file and ONE `transactFamily`.
173754
- */
173755
- var RecordTransactOpSchema = discriminatedUnion("op", [
173756
- object({
173757
- op: literal("put"),
173758
- kind: RecordKindNameSchema,
173759
- record: RecordInputSchema,
173760
- ifRev: number().int().min(0).optional()
173761
- }),
173762
- object({
173763
- op: literal("patch"),
173764
- kind: RecordKindNameSchema,
173765
- id: RecordIdSchema,
173766
- data: RecordBodySchema,
173767
- at: number().int().nullable().optional(),
173768
- expiresAt: number().int().nullable().optional(),
173769
- ifRev: number().int().min(1).optional()
173770
- }),
173771
- object({
173772
- op: literal("delete"),
173773
- kind: RecordKindNameSchema,
173774
- id: RecordIdSchema
173775
- })
173776
- ]);
173777
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
173778
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
173779
- kind: "mutation",
173780
- auth: "admin"
173781
- }), method(object({
173782
- ...KindShape,
173783
- id: RecordIdSchema
173784
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
173785
- ...KindShape,
173786
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173787
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
173788
- ...KindShape,
173789
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173790
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
173791
- ...KindShape,
173792
- record: RecordInputSchema,
173793
- /** Compare-and-set. `0` means "the row must not exist". */
173794
- ifRev: number().int().min(0).optional()
173795
- }), object({
173796
- rev: number().int(),
173797
- releasedRefs: SecretRefsList
173798
- }), {
173799
- kind: "mutation",
173800
- auth: "admin"
173801
- }), method(object({
173802
- ...KindShape,
173803
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
173804
- }), object({
173805
- count: number().int(),
173806
- releasedRefs: SecretRefsList
173807
- }), {
173808
- kind: "mutation",
173809
- auth: "admin"
173810
- }), method(object({
173811
- ...KindShape,
173812
- id: RecordIdSchema,
173813
- data: RecordBodySchema,
173814
- at: number().int().nullable().optional(),
173815
- expiresAt: number().int().nullable().optional(),
173816
- ifRev: number().int().min(1).optional()
173817
- }), object({
173818
- rev: number().int(),
173819
- releasedRefs: SecretRefsList
173820
- }), {
173821
- kind: "mutation",
173822
- auth: "admin"
173823
- }), method(object({
173824
- ...KindShape,
173825
- id: RecordIdSchema
173826
- }), object({
173827
- deleted: boolean(),
173828
- secretRefs: SecretRefsList
173829
- }), {
173830
- kind: "mutation",
173831
- auth: "admin"
173832
- }), method(object({
173833
- ...KindShape,
173834
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
173835
- }), object({
173836
- deleted: number().int(),
173837
- secretRefs: SecretRefsList
173838
- }), {
173839
- kind: "mutation",
173840
- auth: "admin"
173841
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
173842
- ...KindShape,
173843
- ...TimeWindowShape,
173844
- where: RecordWhereSchema.optional()
173845
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
173846
- ...KindShape,
173847
- deviceId: number().int().optional(),
173848
- from: number(),
173849
- to: number(),
173850
- bucketMs: number().int().positive()
173851
- }), object({ buckets: array(object({
173852
- bucketStart: number(),
173853
- count: number().int()
173854
- })) }), { auth: "admin" }), method(object({
173855
- ...KindShape,
173856
- op: _enum([
173857
- "sum",
173858
- "min",
173859
- "max",
173860
- "count"
173861
- ]),
173862
- field: RecordFieldPathSchema.optional(),
173863
- groupBy: RecordFieldPathSchema.optional(),
173864
- where: RecordWhereSchema.optional()
173865
- }), object({ rows: array(object({
173866
- group: union([
173867
- string(),
173868
- number(),
173869
- _null()
173870
- ]),
173871
- value: number().nullable()
173872
- })) }), { auth: "admin" }), method(object({
173873
- ...KindShape,
173874
- deviceId: number().int().optional(),
173875
- atBefore: number().optional(),
173876
- where: RecordWhereSchema.optional()
173877
- }), object({
173878
- deleted: number().int(),
173879
- secretRefs: SecretRefsList
173880
- }), {
173881
- kind: "mutation",
173882
- auth: "admin"
173883
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
173884
- results: array(object({
173885
- rev: number().int().nullable(),
173886
- deleted: boolean()
173887
- })),
173888
- releasedRefs: SecretRefsList,
173889
- secretRefs: SecretRefsList
173890
- }), {
173891
- kind: "mutation",
173892
- auth: "admin"
173893
- }), method(object({
173894
- deviceId: number().int(),
173895
- kinds: array(RecordKindNameSchema).optional()
173896
- }), object({
173897
- deleted: record(string(), number().int()),
173898
- secretRefs: SecretRefsList
173899
- }), {
173900
- kind: "mutation",
173901
- auth: "admin"
173902
- }), method(object(KindShape), object({ id: number().int() }), {
173903
- kind: "mutation",
173904
- auth: "admin"
173905
- });
173906
- /**
173907
173950
  * record-entries - the ONE admin surface for every list of user-created entries
173908
173951
  * (D881): notification targets, brokers, LLM profiles, anything an addon
173909
173952
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -184760,7 +184803,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184760
184803
  * `deviceClasses` map (first registered type). `null` when manual creation is
184761
184804
  * unsupported. Lets the Add-Device dialog pick the right type per provider.
184762
184805
  */
184763
- async getManualCreationType() {
184806
+ async getManualCreationType(_input) {
184764
184807
  if (!await this.supportsManualCreation()) return { deviceType: null };
184765
184808
  return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
184766
184809
  }
@@ -184771,7 +184814,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184771
184814
  return true;
184772
184815
  }
184773
184816
  async getChildCreationSchema(input) {
184774
- return this.onGetCreationSchema(input.type);
184817
+ return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
184775
184818
  }
184776
184819
  /**
184777
184820
  * Default kernel-orchestrated `createDevice` implementation. The
@@ -184783,7 +184826,7 @@ var BaseDeviceProvider = class extends BaseAddon {
184783
184826
  * `deviceClasses` instead.
184784
184827
  */
184785
184828
  async createDevice(input) {
184786
- const spec = await this.onCreateDevice(input.type, input.config);
184829
+ const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
184787
184830
  const Class = this.deviceClasses[spec.meta.type];
184788
184831
  if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
184789
184832
  const stableId = this.generateStableId(spec.meta.type, spec.config);
@@ -186192,20 +186235,6 @@ Object.freeze({
186192
186235
  access: "create",
186193
186236
  role: "viewer"
186194
186237
  },
186195
- "broker.add": {
186196
- capName: "broker",
186197
- capScope: "system",
186198
- addonId: null,
186199
- access: "create",
186200
- role: "admin"
186201
- },
186202
- "broker.get": {
186203
- capName: "broker",
186204
- capScope: "system",
186205
- addonId: null,
186206
- access: "view",
186207
- role: "admin"
186208
- },
186209
186238
  "broker.getBrokerConfig": {
186210
186239
  capName: "broker",
186211
186240
  capScope: "system",
@@ -186213,20 +186242,6 @@ Object.freeze({
186213
186242
  access: "view",
186214
186243
  role: "admin"
186215
186244
  },
186216
- "broker.getSettings": {
186217
- capName: "broker",
186218
- capScope: "system",
186219
- addonId: null,
186220
- access: "view",
186221
- role: "admin"
186222
- },
186223
- "broker.getSettingsSchema": {
186224
- capName: "broker",
186225
- capScope: "system",
186226
- addonId: null,
186227
- access: "view",
186228
- role: "admin"
186229
- },
186230
186245
  "broker.getState": {
186231
186246
  capName: "broker",
186232
186247
  capScope: "system",
@@ -186241,20 +186256,6 @@ Object.freeze({
186241
186256
  access: "view",
186242
186257
  role: "admin"
186243
186258
  },
186244
- "broker.list": {
186245
- capName: "broker",
186246
- capScope: "system",
186247
- addonId: null,
186248
- access: "view",
186249
- role: "admin"
186250
- },
186251
- "broker.listProviders": {
186252
- capName: "broker",
186253
- capScope: "system",
186254
- addonId: null,
186255
- access: "view",
186256
- role: "admin"
186257
- },
186258
186259
  "broker.publish": {
186259
186260
  capName: "broker",
186260
186261
  capScope: "system",
@@ -186262,20 +186263,6 @@ Object.freeze({
186262
186263
  access: "create",
186263
186264
  role: "admin"
186264
186265
  },
186265
- "broker.remove": {
186266
- capName: "broker",
186267
- capScope: "system",
186268
- addonId: null,
186269
- access: "delete",
186270
- role: "admin"
186271
- },
186272
- "broker.setSettings": {
186273
- capName: "broker",
186274
- capScope: "system",
186275
- addonId: null,
186276
- access: "create",
186277
- role: "admin"
186278
- },
186279
186266
  "broker.subscribe": {
186280
186267
  capName: "broker",
186281
186268
  capScope: "system",
@@ -186283,20 +186270,6 @@ Object.freeze({
186283
186270
  access: "create",
186284
186271
  role: "admin"
186285
186272
  },
186286
- "broker.testConnection": {
186287
- capName: "broker",
186288
- capScope: "system",
186289
- addonId: null,
186290
- access: "create",
186291
- role: "admin"
186292
- },
186293
- "broker.testSettings": {
186294
- capName: "broker",
186295
- capScope: "system",
186296
- addonId: null,
186297
- access: "create",
186298
- role: "admin"
186299
- },
186300
186273
  "broker.unsubscribe": {
186301
186274
  capName: "broker",
186302
186275
  capScope: "system",
@@ -191260,6 +191233,13 @@ Object.freeze({
191260
191233
  access: "view",
191261
191234
  role: "viewer"
191262
191235
  },
191236
+ "pipelineAnalytics.getMediaLocationCensus": {
191237
+ capName: "pipeline-analytics",
191238
+ capScope: "device",
191239
+ addonId: null,
191240
+ access: "view",
191241
+ role: "admin"
191242
+ },
191263
191243
  "pipelineAnalytics.getMediaReclaimStatus": {
191264
191244
  capName: "pipeline-analytics",
191265
191245
  capScope: "device",
@@ -200404,6 +200384,7 @@ object({
200404
200384
  delay: number().nonnegative().optional(),
200405
200385
  commands: record(string(), unknown())
200406
200386
  });
200387
+ entryBody({ brokerId: string() });
200407
200388
  //#endregion
200408
200389
  //#region src/clips/clip-prefetch.ts
200409
200390
  /** The longest a device may stay quiet after refusals, whatever its interval. */
@@ -220881,17 +220862,29 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
220881
220862
  var REOLINK_SUBSCRIBER_ID = "provider-reolink";
220882
220863
  var MAILBOX_NAME = "Camera mailbox";
220883
220864
  var RECIPIENT_PREFIX = "cam-";
220884
- /** 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
+ */
220885
220870
  function createBrokerPort(api) {
220886
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
+ };
220887
220877
  return {
220888
- list: async () => api.broker.list.query({ kind: SMTP_INBOUND_KIND }),
220889
- add: async ({ id, name, settings }) => api.broker.add.mutate({
220890
- kind: SMTP_INBOUND_KIND,
220891
- 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,
220892
220884
  id,
220893
- settings: { ...settings },
220894
- ...route
220885
+ name,
220886
+ kind: await mailboxKind(),
220887
+ values: { ...settings }
220895
220888
  }),
220896
220889
  getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
220897
220890
  id,
@@ -221695,6 +221688,19 @@ function reolinkInstancesProvider(instances, deps) {
221695
221688
  }
221696
221689
  };
221697
221690
  }
221691
+ /**
221692
+ * Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
221693
+ * manual add by IP). An integration the registry cannot name is not a hub for this question.
221694
+ */
221695
+ async function integrationIsHub(instances, deps, id) {
221696
+ const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
221697
+ if (evidence === null) return false;
221698
+ return isHubIntegration({
221699
+ originStableId: evidence.originStableId,
221700
+ info: evidence.info,
221701
+ settings: body === null ? {} : hubSettingsOf(body)
221702
+ });
221703
+ }
221698
221704
  //#endregion
221699
221705
  //#region src/migrations/integration-rows-to-record.ts
221700
221706
  /**
@@ -222473,6 +222479,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222473
222479
  autodetectCache = new AutodetectCache();
222474
222480
  hubManager = null;
222475
222481
  instances = null;
222482
+ hubIntegrationProbe = null;
222476
222483
  /**
222477
222484
  * The camera mailbox bridge (`email-push-bridge.ts`, D999): battery cameras mail motion to a
222478
222485
  * mailbox of the `smtp-inbound` broker, the bridge turns each message into the camera's
@@ -222983,6 +222990,7 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
222983
222990
  registryEvidenceOf
222984
222991
  });
222985
222992
  this.instances = instances;
222993
+ this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
222986
222994
  await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
222987
222995
  this.wireEmailBridge();
222988
222996
  const wireSleepPushResolvers = (event, via) => {
@@ -223316,10 +223324,22 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
223316
223324
  config: input.candidate.prefilledConfig
223317
223325
  });
223318
223326
  }
223319
- async onGetCreationSchema(type) {
223327
+ async onGetCreationSchema(type, context) {
223320
223328
  if (type !== DeviceType.Camera) return null;
223329
+ if (await this.isHubIntegrationId(context?.integrationId)) return null;
223321
223330
  return buildCreationFormSchema();
223322
223331
  }
223332
+ /** A hub integration's devices come from the hub: no manual add by IP for it. */
223333
+ async getManualCreationType(input) {
223334
+ if (await this.isHubIntegrationId(input?.integrationId)) return { deviceType: null };
223335
+ return super.getManualCreationType(input);
223336
+ }
223337
+ /** `false` for no integration, or one the registry cannot name (the addon's own default). */
223338
+ async isHubIntegrationId(id) {
223339
+ const probe = this.hubIntegrationProbe;
223340
+ if (id === void 0 || probe === null) return false;
223341
+ return probe(id);
223342
+ }
223323
223343
  async onCreateDevice(type, config) {
223324
223344
  if (type !== DeviceType.Camera) throw new Error(`Reolink provider does not support device type: ${type}`);
223325
223345
  const name = getString(config, "name").trim();