@camstack/addon-provider-enpal 0.1.10 → 0.1.11

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
@@ -5980,7 +5980,7 @@ var ZodIssueCode = {
5980
5980
  var ZodFirstPartyTypeKind;
5981
5981
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5982
5982
  //#endregion
5983
- //#region ../types/dist/sleep-DEZaLbiu.mjs
5983
+ //#region ../types/dist/sleep-BX_MqzUe.mjs
5984
5984
  /**
5985
5985
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5986
5986
  * window to float samples (D455).
@@ -7609,6 +7609,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7609
7609
  /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7610
7610
  var SECRET_CHANGE_DEBOUNCE_MS = 250;
7611
7611
  /**
7612
+ * Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
7613
+ * place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
7614
+ * through `api` (guard `check-migration-ports-surface`).
7615
+ */
7616
+ function migrationSet(catalogue, bindPorts) {
7617
+ return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
7618
+ }
7619
+ /** A mixed array is a mistake: the other kind would be dropped without a word. */
7620
+ function refuseMixed(form, kept, dropped) {
7621
+ 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`);
7622
+ }
7623
+ function catalogueOf(list) {
7624
+ const kept = list.filter((entry) => !("execute" in entry));
7625
+ refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
7626
+ return kept;
7627
+ }
7628
+ function boundOf(list) {
7629
+ const kept = list.filter((entry) => "execute" in entry);
7630
+ refuseMixed("bound migrations", kept.length, list.length - kept.length);
7631
+ return kept;
7632
+ }
7633
+ /**
7612
7634
  * Base class for CamStack addons. Eliminates settings boilerplate:
7613
7635
  *
7614
7636
  * - Typed `config` property with automatic resolution from store + defaults
@@ -7775,23 +7797,21 @@ var BaseAddon = class {
7775
7797
  await this.loadScopedSchemas();
7776
7798
  return normalized;
7777
7799
  }
7800
+ async runMigrations(first, second, third) {
7801
+ if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
7802
+ return this.runBound(boundOf(first), second);
7803
+ }
7778
7804
  /**
7779
- * Run this addon's migration catalogue (D987 M3) through the hub's `migrations`
7780
- * engine. Call it at the point of the boot where the data must already have the new
7781
- * shape — `onInitialize`, or `onRestoreDevices` for a migration that needs the
7782
- * restored devices — with the catalogue bound to the addon's ports
7783
- * (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
7784
- *
7785
- * An engine that cannot be reached or refuses the catalogue is logged and runs
7786
- * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7787
- * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7788
- * serve data whose shape it cannot trust; `tolerate` migrations never do.
7789
- *
7790
- * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
7791
- * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
7792
- * omitted applied ids "newer").
7805
+ * Several catalogues of ONE owner in one declaration (the engine replaces an owner's
7806
+ * catalogue on every declare, so two calls would each judge the other's ids "newer").
7807
+ * Build each entry with `migrationSet(catalogue, (api) => ports)`.
7793
7808
  */
7794
- async runMigrations(migrations, options) {
7809
+ async runMigrationSets(sets, options) {
7810
+ const api = this.ctx.migrationApi;
7811
+ if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
7812
+ return this.runBound(sets.flatMap((set) => set.bind(api)), options);
7813
+ }
7814
+ async runBound(migrations, options) {
7795
7815
  const api = this.ctx.api.migrations;
7796
7816
  const report = await runAddonMigrations({
7797
7817
  declareOwner: (input) => api.declareOwner.mutate(input),
@@ -13509,26 +13529,16 @@ var RecordIntegrationInstances = class {
13509
13529
  ...this.hooks.description,
13510
13530
  mintsId: true
13511
13531
  };
13512
- /**
13513
- * The record an id names. A caller holding the `integrations` registry id (the Integrations
13514
- * page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
13515
- * record id answers as it is. An id that names nothing comes back unchanged.
13516
- */
13517
- async resolveRecordId(id) {
13518
- if (await this.handle.get(id) !== null) return id;
13519
- const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
13520
- return linked === void 0 ? id : linked.id;
13521
- }
13522
- instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
13532
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13523
13533
  listInstances = async () => {
13524
13534
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
13525
13535
  };
13526
13536
  getInstance = async ({ id }) => {
13527
- const record = await this.handle.get(await this.resolveRecordId(id));
13537
+ const record = await this.handle.get(id);
13528
13538
  return record === null ? null : this.viewOf(record);
13529
13539
  };
13530
13540
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13531
- createInstance = async ({ id, name, kind }) => {
13541
+ createInstance = async ({ id, name, kind, values }) => {
13532
13542
  const minted = id ?? this.hooks.mintId?.({
13533
13543
  name,
13534
13544
  ...kind !== void 0 ? { kind } : {}
@@ -13538,11 +13548,20 @@ var RecordIntegrationInstances = class {
13538
13548
  id: minted,
13539
13549
  data: this.hooks.initialBody(name, kind)
13540
13550
  }, { ifRev: 0 });
13551
+ const patch = this.patchOf(values ?? {});
13552
+ if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
13541
13553
  await this.hooks.onChanged?.(minted, "created");
13542
13554
  return { id: minted };
13543
13555
  };
13544
- updateInstance = async ({ id: askedId, name, values }) => {
13545
- const id = await this.resolveRecordId(askedId);
13556
+ updateInstance = async ({ id, name, values }) => {
13557
+ const patch = this.patchOf(values);
13558
+ if (name !== void 0) patch[this.nameField] = name;
13559
+ await this.handle.patch(id, patch);
13560
+ await this.hooks.onChanged?.(id, "updated");
13561
+ return { ok: true };
13562
+ };
13563
+ /** The record patch a form `values` object means: secrets kept, cleared or replaced. */
13564
+ patchOf(values) {
13546
13565
  const patch = {};
13547
13566
  for (const [key, value] of Object.entries(values)) {
13548
13567
  if (value === void 0) continue;
@@ -13553,11 +13572,8 @@ var RecordIntegrationInstances = class {
13553
13572
  else if (isSecretClear(value)) patch[key] = null;
13554
13573
  else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
13555
13574
  }
13556
- if (name !== void 0) patch[this.nameField] = name;
13557
- await this.handle.patch(id, patch);
13558
- await this.hooks.onChanged?.(id, "updated");
13559
- return { ok: true };
13560
- };
13575
+ return patch;
13576
+ }
13561
13577
  /** The switch lives in the record body; the addon is told so it applies it (D996). */
13562
13578
  setInstanceEnabled = async ({ id, enabled }) => {
13563
13579
  if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
@@ -13577,10 +13593,7 @@ var RecordIntegrationInstances = class {
13577
13593
  status: "unsupported",
13578
13594
  error: "This integration declares no connection test"
13579
13595
  };
13580
- return this.hooks.test(input.id === null ? input : {
13581
- ...input,
13582
- id: await this.resolveRecordId(input.id)
13583
- });
13596
+ return this.hooks.test(input);
13584
13597
  };
13585
13598
  /** The flat provider object to hand to `registerProvider`. */
13586
13599
  toProvider() {
@@ -14878,25 +14891,6 @@ function integrationRowsPortsOver(deps) {
14878
14891
  log: { warn: deps.warn }
14879
14892
  });
14880
14893
  }
14881
- function defaultIntegrationApiOver(api) {
14882
- return {
14883
- list: () => api.integrations.list.query(),
14884
- readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
14885
- clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
14886
- listDevices: (addonId) => api.deviceManager.listAll.query({
14887
- addonId,
14888
- projection: "slim"
14889
- }),
14890
- setDeviceIntegrationId: async (deviceId, integrationId) => {
14891
- await api.deviceManager.setIntegrationId.mutate({
14892
- deviceId,
14893
- integrationId
14894
- });
14895
- },
14896
- readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
14897
- readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
14898
- };
14899
- }
14900
14894
  /**
14901
14895
  * The trainer contract — what the hub hands the cloud trainer and what it
14902
14896
  * gets back (cloud training, D805+).
@@ -15985,6 +15979,39 @@ var UnstampedEventMediaCountSchema = object({
15985
15979
  /** Sum across both, or `null` when either lane could not be counted. */
15986
15980
  total: number().int().nonnegative().nullable()
15987
15981
  }).nullable();
15982
+ /**
15983
+ * Where the stored event media sits, per storage location: how many media rows
15984
+ * and how many bytes carry each location id, how many carry none (legacy,
15985
+ * resolved to the default `eventMedia` location), and how many name a location
15986
+ * that was not asked about (a deleted or never-listed one).
15987
+ *
15988
+ * One covering-index aggregate per asked location plus the NULL one, and one
15989
+ * unfiltered total that scans the covering index: O(rows), not a walk of the
15990
+ * rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
15991
+ * it is a deleted location only when every location id was asked.
15992
+ * `null` is "could not be measured", never zero.
15993
+ */
15994
+ var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
15995
+ var MediaLocationCensusSchema = object({
15996
+ locations: array(object({
15997
+ locationId: string(),
15998
+ rows: number().int().nonnegative(),
15999
+ bytes: number().nonnegative()
16000
+ })).readonly(),
16001
+ unstamped: object({
16002
+ rows: number().int().nonnegative(),
16003
+ bytes: number().nonnegative()
16004
+ }),
16005
+ /** Rows stamped with a location id that was not in the asked list. */
16006
+ unlisted: object({
16007
+ rows: number().int().nonnegative(),
16008
+ bytes: number().nonnegative()
16009
+ }),
16010
+ total: object({
16011
+ rows: number().int().nonnegative(),
16012
+ bytes: number().nonnegative()
16013
+ })
16014
+ });
15988
16015
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
15989
16016
  /** The independently selectable logical storage classes — every class
15990
16017
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -47100,52 +47127,7 @@ onBrightnessChanged: { data: object({
47100
47127
  minIntervalMs: 0
47101
47128
  } } }
47102
47129
  };
47103
- /**
47104
- * `broker` — unified pub/sub broker registry, system-scoped collection.
47105
- *
47106
- * The cap models any kind-tagged message broker the user wants to
47107
- * register and that other addons might consume. The first two kinds
47108
- * are MQTT (mosquitto / aedes embedded / cloud bridge) and
47109
- * Home Assistant (HA WebSocket — subscribe_entities + call_service).
47110
- * Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
47111
- * the same surface.
47112
- *
47113
- * Why one cap, not one cap per kind:
47114
- * - The integrations page wants a single table of "every broker"
47115
- * across kinds; a unified cap drives it without join logic.
47116
- * - Generic admin operations (add / remove / test / status) are
47117
- * identical across kinds — duplicating them per cap was busywork.
47118
- * - The `network-access` cap precedent: same interface, many
47119
- * `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
47120
- *
47121
- * What stays kind-specific:
47122
- * - `getBrokerConfig` payload (kind decides whether it returns
47123
- * mqtt URL+creds, HA baseUrl+token, …) — typed as
47124
- * `Record<string, unknown>` at the wire; consumers narrow.
47125
- * - `publish` / `subscribe` / `getState` arguments (target / filter /
47126
- * key) — also typed as `Record<string, unknown>` so each kind can
47127
- * evolve its surface (MQTT topic+qos vs HA entity_id+domain)
47128
- * without rebreaking the cap signature.
47129
- * - `add` `settings` payload (different fields per kind, validated by
47130
- * the kind-specific provider).
47131
- *
47132
- * Bidirectionality:
47133
- * - `publish` is RPC — synchronous result (provider-defined).
47134
- * - `subscribe` returns a subscription handle; the actual message
47135
- * stream flows over the typed event-bus as `broker.message` events
47136
- * keyed by `(brokerId, subscriptionId)`. Consumers filter in their
47137
- * event handler. Subscriptions persist across reconnects — the
47138
- * provider re-subscribes upstream after a transport drop.
47139
- *
47140
- * Why event-bus push (not a subscription RPC stream):
47141
- * - Matches the rest of CamStack's D8 contract — events for telemetry,
47142
- * RPC for loss-is-a-bug. Broker messages are telemetry (a single
47143
- * drop is recoverable via `getState({key})`).
47144
- * - Frees `broker.subscribe` from holding a long-lived RPC channel.
47145
- * - Cross-process: events already route through `$event-bus`; no
47146
- * per-broker wire-shaping needed.
47147
- */
47148
- var BrokerStatusEnum = _enum([
47130
+ _enum([
47149
47131
  "connected",
47150
47132
  "disconnected",
47151
47133
  "connecting",
@@ -47153,141 +47135,12 @@ var BrokerStatusEnum = _enum([
47153
47135
  "unreachable",
47154
47136
  "error"
47155
47137
  ]);
47156
- var BrokerInfoSchema = object({
47157
- /** Stable broker id. Persisted; survives addon restarts. */
47158
- id: string(),
47159
- /** Addon id of the provider that OWNS this broker.
47160
- *
47161
- * The `broker` cap is a system-scoped collection: several addons
47162
- * register a `broker` provider, each owning a DISJOINT set of
47163
- * brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
47164
- * `ha_*`). A broker therefore belongs to exactly one addon — like a
47165
- * device belongs to one integration. The admin UI threads this id
47166
- * back as the `{ addonId }` system-collection selector on every
47167
- * id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
47168
- * `testConnection`), so the call routes to the OWNING provider
47169
- * instead of defaulting to the first-registered one. */
47170
- addonId: string(),
47171
- /** Human-readable name (operator-chosen at add-time). */
47172
- name: string(),
47173
- /** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
47174
- kind: string(),
47175
- status: BrokerStatusEnum,
47176
- /** Free-form provider-specific info (HA version, MQTT broker
47177
- * flavour, latency, mTLS active, …). */
47178
- info: record(string(), unknown()),
47179
- /** Ms epoch of the last connection probe / status update. */
47180
- lastCheckedAt: number().nullable(),
47181
- /** Last error message, when `status` indicates failure. */
47182
- error: string().nullable()
47183
- });
47184
47138
  var RegistryStatusSchema = object({
47185
47139
  brokerCount: number().int().nonnegative(),
47186
47140
  connectedCount: number().int().nonnegative()
47187
47141
  });
47188
- /**
47189
- * One entry per `broker` provider — which addon provides which broker
47190
- * kind(s). The unified create picker reads this to know, for each
47191
- * (addonId, kind) pair the operator can pick, where to route the
47192
- * follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
47193
- * `{ addonId }` selector). A provider only advertises a kind here when
47194
- * it implements `getSettingsSchema` for that kind (so the picker never
47195
- * offers a kind whose creation form can't be rendered).
47196
- */
47197
- var BrokerProviderInfoSchema = object({
47198
- /** Addon id of the `broker` provider this entry describes. */
47199
- addonId: string(),
47200
- /** Broker kinds this provider can create, with a display label. */
47201
- kinds: array(object({
47202
- kind: string(),
47203
- label: string(),
47204
- /**
47205
- * Relative hub path to start an interactive account link (OAuth popup).
47206
- * May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
47207
- */
47208
- interactiveConnectPath: string().min(1).optional(),
47209
- /** Relative hub path to disconnect the linked account (same popup pattern). */
47210
- interactiveDisconnectPath: string().min(1).optional(),
47211
- /**
47212
- * The kind signs in through a server-held interactive session instead of
47213
- * (or before) typed credentials. `basePath` is a hub-relative route set
47214
- * served by the owning addon (`/addon/<id>/...`) speaking the sign-in
47215
- * contract: `POST {basePath}/start` (body: the form's settings) answers
47216
- * `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
47217
- * `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
47218
- * 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
47219
- * (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
47220
- * existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
47221
- * (`{ sessionId }`) drops the session. The dialog that edits a broker
47222
- * offers it as the default path; the fields the session fills are
47223
- * marked `filledBySignIn` in the kind's settings schema.
47224
- *
47225
- * `methods` lists the ways the session can sign in, recommended first:
47226
- * `'device-code'` adds `POST {basePath}/code/start` (body: the form's
47227
- * settings) answering `{ sessionId, userCode, verificationUrl,
47228
- * expiresAt }` — the operator types `userCode` at `verificationUrl` on
47229
- * any device, and the same `status` / `commit` / `cancel` routes follow
47230
- * (status then carries `method`, `userCode`, `verificationUrl`,
47231
- * `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
47232
- * `'proxy'` is the `{basePath}/start` flow above. Absent means
47233
- * `['proxy']`.
47234
- */
47235
- signIn: object({
47236
- basePath: string().min(1),
47237
- methods: array(_enum(["device-code", "proxy"])).optional()
47238
- }).optional()
47239
- }))
47240
- });
47241
- var ListInputSchema = object({
47242
- /** Optional kind filter — `list({kind:'home-assistant'})` returns
47243
- * only HA brokers. Omit to list every broker. */
47244
- kind: string().optional() });
47245
47142
  var GetInputSchema = object({ id: string() });
47246
- var AddInputSchema = object({
47247
- kind: string().min(1),
47248
- name: string().min(1),
47249
- /**
47250
- * ADOPT an existing id instead of minting a new one.
47251
- *
47252
- * Written the day this cost an outage. A broker's id is not a detail: HA
47253
- * devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
47254
- * lost from config and re-added as `ha_001` leaves every one of its devices
47255
- * bound to a broker that no longer exists. Re-entering the password under the
47256
- * ORIGINAL id turns a multi-step device migration back into re-entering a
47257
- * password.
47258
- *
47259
- * A provider MUST refuse an id that is already in use — adopting a live
47260
- * broker's id would silently take it over.
47261
- */
47262
- id: string().min(1).optional(),
47263
- /** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
47264
- * `{baseUrl,accessToken}`). Validated by the kind-specific provider
47265
- * branch on receipt — invalid shape rejects the add. */
47266
- settings: record(string(), unknown())
47267
- });
47268
- var AddResultSchema = object({ id: string() });
47269
- var RemoveInputSchema = object({ id: string() });
47270
- var TestConnectionResultSchema = discriminatedUnion("ok", [object({
47271
- ok: literal(true),
47272
- latencyMs: number().nonnegative()
47273
- }), object({
47274
- ok: literal(false),
47275
- error: string()
47276
- })]);
47277
47143
  var SettingsRecordSchema$1 = record(string(), unknown());
47278
- var SettingsSchemaInputSchema = object({ kind: string() });
47279
- var TestSettingsInputSchema = object({
47280
- kind: string(),
47281
- settings: SettingsRecordSchema$1
47282
- });
47283
- var TestSettingsResultSchema = discriminatedUnion("ok", [object({
47284
- ok: literal(true),
47285
- latencyMs: number().nonnegative().optional()
47286
- }).strict(), object({
47287
- ok: literal(false),
47288
- error: string()
47289
- })]);
47290
- var SettingsSchemaResultSchema = unknown().nullable();
47291
47144
  var PublishInputSchema = object({
47292
47145
  brokerId: string(),
47293
47146
  /** Kind-specific routing target.
@@ -47321,25 +47174,7 @@ var GetStateInputSchema = object({
47321
47174
  * HA: entity_id (returns the cached entity state). */
47322
47175
  key: string()
47323
47176
  });
47324
- method(ListInputSchema, array(BrokerInfoSchema)), method(GetInputSchema, BrokerInfoSchema.nullable()), method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }), method(AddInputSchema, AddResultSchema, {
47325
- kind: "mutation",
47326
- auth: "admin"
47327
- }), method(RemoveInputSchema, _void(), {
47328
- kind: "mutation",
47329
- auth: "admin"
47330
- }), method(GetInputSchema, TestConnectionResultSchema, {
47331
- kind: "mutation",
47332
- auth: "admin"
47333
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
47334
- id: string(),
47335
- settings: SettingsRecordSchema$1
47336
- }), _void(), {
47337
- kind: "mutation",
47338
- auth: "admin"
47339
- }), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
47340
- kind: "mutation",
47341
- auth: "admin"
47342
- }), method(PublishInputSchema, unknown(), {
47177
+ method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
47343
47178
  kind: "mutation",
47344
47179
  auth: "admin"
47345
47180
  }), method(SubscribeInputSchema, SubscribeResultSchema, {
@@ -52177,7 +52012,14 @@ var DiscoveryCandidateSchema = object({
52177
52012
  /** `stableId` of the gateway candidate this device was found BEHIND. */
52178
52013
  parentStableId: string().optional(),
52179
52014
  /** `false` = shown for context but not pickable. Default true. */
52180
- selectable: boolean().optional()
52015
+ selectable: boolean().optional(),
52016
+ /**
52017
+ * Keys of the provider's creation form (`getChildCreationSchema`) this candidate
52018
+ * cannot be adopted without — a key for an encrypted board, a pairing code. The
52019
+ * admin asks for exactly these, on the creation form prefilled with
52020
+ * `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
52021
+ */
52022
+ needsParams: array(string()).optional()
52181
52023
  });
52182
52024
  /**
52183
52025
  * Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
@@ -52304,8 +52146,14 @@ var deviceProviderCapability = {
52304
52146
  * provider does not support manual creation. Lets the Add-Device dialog
52305
52147
  * pick the right type instead of assuming Camera.
52306
52148
  */
52307
- getManualCreationType: method(object({}), object({ deviceType: _enum(DeviceType).nullable() })),
52308
- adoptDiscoveredDevice: method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
52149
+ getManualCreationType: method(object({
52150
+ /** The integration asked about; a provider whose integrations differ answers per one. */
52151
+ integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
52152
+ adoptDiscoveredDevice: method(object({
52153
+ candidate: DiscoveryCandidateSchema,
52154
+ /** The integration the operator adopts into; a provider with several instances needs it. */
52155
+ integrationId: string().optional()
52156
+ }), DeviceSummarySchema, {
52309
52157
  kind: "mutation",
52310
52158
  auth: "admin"
52311
52159
  }),
@@ -52316,10 +52164,16 @@ var deviceProviderCapability = {
52316
52164
  * devices of that type. The output is a `ConfigUISchema` — the
52317
52165
  * router type-asserts it at the boundary.
52318
52166
  */
52319
- getChildCreationSchema: method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema),
52167
+ getChildCreationSchema: method(object({
52168
+ type: _enum(DeviceType),
52169
+ /** The integration asked about; a provider whose integrations differ answers per one. */
52170
+ integrationId: string().optional()
52171
+ }), CreationSchemaOutputSchema),
52320
52172
  createDevice: method(object({
52321
52173
  type: _enum(DeviceType),
52322
- config: record(string(), unknown())
52174
+ config: record(string(), unknown()),
52175
+ /** The integration the operator adds the device to; a provider with several instances needs it. */
52176
+ integrationId: string().optional()
52323
52177
  }), DeviceSummarySchema, {
52324
52178
  kind: "mutation",
52325
52179
  auth: "admin"
@@ -53044,7 +52898,10 @@ method(object({
53044
52898
  auth: "admin"
53045
52899
  }), method(object({
53046
52900
  addonId: string(),
53047
- type: _enum(DeviceType)
52901
+ type: _enum(DeviceType),
52902
+ /** The integration the form is for; a provider whose integrations differ (a hub
52903
+ * integration takes no manual add) answers per integration. Absent = the addon's own. */
52904
+ integrationId: string().optional()
53048
52905
  }), unknown().nullable()), method(object({
53049
52906
  addonId: string(),
53050
52907
  type: _enum(DeviceType),
@@ -53128,7 +52985,11 @@ method(object({
53128
52985
  kind: "mutation",
53129
52986
  auth: "admin",
53130
52987
  timeoutMs: 12e4
53131
- }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
52988
+ }), method(object({
52989
+ addonId: string(),
52990
+ /** The integration the Add-Device dialog is open on; absent = the addon's own. */
52991
+ integrationId: string().optional()
52992
+ }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
53132
52993
  deviceId: number(),
53133
52994
  key: string(),
53134
52995
  value: unknown()
@@ -56408,7 +56269,7 @@ var TestConnectionStatusEnum = _enum([
56408
56269
  "inconclusive",
56409
56270
  "unsupported"
56410
56271
  ]);
56411
- var TestConnectionResultSchema$1 = object({
56272
+ var TestConnectionResultSchema = object({
56412
56273
  /** True ONLY for `validated`. Never true for a test that did not run. */
56413
56274
  success: boolean(),
56414
56275
  error: string().optional(),
@@ -56453,7 +56314,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
56453
56314
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
56454
56315
  addonId: string(),
56455
56316
  settings: record(string(), unknown())
56456
- }), TestConnectionResultSchema$1, {
56317
+ }), TestConnectionResultSchema, {
56457
56318
  kind: "mutation",
56458
56319
  auth: "admin"
56459
56320
  });
@@ -56480,6 +56341,14 @@ var ConfigSchemaPassthrough$3 = custom();
56480
56341
  var IntegrationInstanceIdSchema = string().min(1);
56481
56342
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56482
56343
  /**
56344
+ * What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
56345
+ * instance is an integration that brings devices (the registry owns its on/off switch);
56346
+ * `services`: a connection configured from the addon's own function page, never listed on
56347
+ * Integrations.
56348
+ * It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
56349
+ */
56350
+ var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
56351
+ /**
56483
56352
  * One kind of instance a provider can create (an adapter, an account type). The sign-in and
56484
56353
  * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
56485
56354
  * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
@@ -56490,6 +56359,22 @@ var IntegrationInstanceKindSchema = object({
56490
56359
  /** Stable id of the kind, sent back as `createInstance.kind`. */
56491
56360
  id: string().min(1),
56492
56361
  label: string().min(1),
56362
+ /**
56363
+ * The function capability this kind is configured for (`broker`, `smtp-provider`,
56364
+ * `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
56365
+ * provider with more than one section must name it on every kind.
56366
+ */
56367
+ functionCap: string().min(1),
56368
+ /**
56369
+ * For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
56370
+ * (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
56371
+ * finds the instances whose kind names it; absent takes the kind `id`.
56372
+ */
56373
+ brokerKind: string().min(1).optional(),
56374
+ /** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
56375
+ role: IntegrationInstanceRoleSchema.optional(),
56376
+ /** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
56377
+ canTest: boolean().optional(),
56493
56378
  /** The kind signs in through a server-held interactive session. */
56494
56379
  signIn: object({
56495
56380
  basePath: string().min(1),
@@ -56502,11 +56387,7 @@ var IntegrationInstanceKindSchema = object({
56502
56387
  });
56503
56388
  var IntegrationInstanceDescriptionSchema = object({
56504
56389
  /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
56505
- role: _enum([
56506
- "devices",
56507
- "services",
56508
- "both"
56509
- ]),
56390
+ role: IntegrationInstanceRoleSchema,
56510
56391
  /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
56511
56392
  discovery: object({
56512
56393
  mode: _enum([
@@ -56581,7 +56462,11 @@ var integrationInstancesCapability = {
56581
56462
  methods: {
56582
56463
  describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
56583
56464
  /** The form; `id: null` is the create form. */
56584
- instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56465
+ instanceFormSchema: method(object({
56466
+ id: IntegrationInstanceIdSchema.nullable(),
56467
+ /** The kind of the create form (`id: null`) of a provider with several. */
56468
+ kind: string().min(1).optional()
56469
+ }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56585
56470
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56586
56471
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56587
56472
  /**
@@ -56591,7 +56476,9 @@ var integrationInstancesCapability = {
56591
56476
  createInstance: method(object({
56592
56477
  id: IntegrationInstanceIdSchema.optional(),
56593
56478
  name: string().min(1),
56594
- kind: string().min(1).optional()
56479
+ kind: string().min(1).optional(),
56480
+ /** Form values written with the record (a link picked in the create dialog). */
56481
+ values: record(string(), unknown()).optional()
56595
56482
  }), object({ id: string() }), {
56596
56483
  kind: "mutation",
56597
56484
  auth: "admin"
@@ -56618,8 +56505,10 @@ var integrationInstancesCapability = {
56618
56505
  }),
56619
56506
  testInstance: optionalMethod(object({
56620
56507
  id: IntegrationInstanceIdSchema.nullable(),
56621
- values: record(string(), unknown())
56622
- }), TestConnectionResultSchema$1, {
56508
+ values: record(string(), unknown()),
56509
+ /** The kind to test when `id` is null and the provider has several. */
56510
+ kind: string().min(1).optional()
56511
+ }), TestConnectionResultSchema, {
56623
56512
  kind: "mutation",
56624
56513
  auth: "admin"
56625
56514
  })
@@ -59376,6 +59265,380 @@ var SystemMetricsSchema = object({
59376
59265
  gpuMemoryPercent: number().optional()
59377
59266
  });
59378
59267
  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);
59268
+ /**
59269
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
59270
+ * config documents, mirrors. The third storage API next to `ctx.settings`
59271
+ * (operator intent, D870) and device-history (numbers over time, D850).
59272
+ *
59273
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
59274
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
59275
+ * that with the addon id closed over). It is deliberately NOT in any input
59276
+ * schema, so a session can never supply it, and a call with no stamp is refused
59277
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
59278
+ * addons go through the owner's capability.
59279
+ *
59280
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
59281
+ * never `[]`. Secret fields are never on the wire: a read shows the
59282
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
59283
+ * resolves itself, and a write may carry only a keychain marker bound to the
59284
+ * row's own ref.
59285
+ *
59286
+ * Internal: addons reach it through `ctx.records`, never directly.
59287
+ */
59288
+ var RecordIdSchema = string().min(1).max(256);
59289
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
59290
+ var RecordBodySchema = record(string(), unknown());
59291
+ var RecordInputSchema = object({
59292
+ id: RecordIdSchema,
59293
+ /** The device this row belongs to (D865 removal, per-device reads). */
59294
+ deviceId: number().int().optional(),
59295
+ /** The domain clock, ms: observed / created / opened. */
59296
+ at: number().int().optional(),
59297
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
59298
+ expiresAt: number().int().optional(),
59299
+ data: RecordBodySchema
59300
+ });
59301
+ var RecordViewSchema = object({
59302
+ id: string(),
59303
+ deviceId: number().int().nullable(),
59304
+ at: number().nullable(),
59305
+ expiresAt: number().nullable(),
59306
+ rev: number().int(),
59307
+ updatedAt: number(),
59308
+ data: RecordBodySchema
59309
+ });
59310
+ /** Declared index fields only. Anything else does not compile, by design. */
59311
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
59312
+ string(),
59313
+ number(),
59314
+ boolean(),
59315
+ object({ in: array(union([
59316
+ string(),
59317
+ number(),
59318
+ boolean()
59319
+ ])).min(1).max(RECORD_BATCH_MAX) }),
59320
+ object({
59321
+ gt: union([string(), number()]).optional(),
59322
+ gte: union([string(), number()]).optional(),
59323
+ lt: union([string(), number()]).optional(),
59324
+ lte: union([string(), number()]).optional()
59325
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
59326
+ ]));
59327
+ var KindShape = { kind: RecordKindNameSchema };
59328
+ var TimeWindowShape = {
59329
+ deviceId: number().int().optional(),
59330
+ atFrom: number().optional(),
59331
+ atTo: number().optional()
59332
+ };
59333
+ var RecordQueryInputSchema = object({
59334
+ ...KindShape,
59335
+ ...TimeWindowShape,
59336
+ where: RecordWhereSchema.optional(),
59337
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
59338
+ order: _enum(["at", "id"]).optional(),
59339
+ desc: boolean().optional(),
59340
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
59341
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
59342
+ cursor: string().min(1).optional()
59343
+ });
59344
+ var RecordQueryResultSchema = object({
59345
+ records: array(RecordViewSchema),
59346
+ nextCursor: string().nullable()
59347
+ });
59348
+ var RecordKindStateSchema = _enum([
59349
+ "created",
59350
+ "unchanged",
59351
+ "updated"
59352
+ ]);
59353
+ var DeclareKindResultSchema = object({
59354
+ kindId: number().int(),
59355
+ state: RecordKindStateSchema,
59356
+ createdIndexes: array(string())
59357
+ });
59358
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
59359
+ var SecretRefsList = array(string());
59360
+ /**
59361
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
59362
+ * All ops of one call share ONE database file and ONE `transactFamily`.
59363
+ */
59364
+ var RecordTransactOpSchema = discriminatedUnion("op", [
59365
+ object({
59366
+ op: literal("put"),
59367
+ kind: RecordKindNameSchema,
59368
+ record: RecordInputSchema,
59369
+ ifRev: number().int().min(0).optional()
59370
+ }),
59371
+ object({
59372
+ op: literal("patch"),
59373
+ kind: RecordKindNameSchema,
59374
+ id: RecordIdSchema,
59375
+ data: RecordBodySchema,
59376
+ at: number().int().nullable().optional(),
59377
+ expiresAt: number().int().nullable().optional(),
59378
+ ifRev: number().int().min(1).optional()
59379
+ }),
59380
+ object({
59381
+ op: literal("delete"),
59382
+ kind: RecordKindNameSchema,
59383
+ id: RecordIdSchema
59384
+ })
59385
+ ]);
59386
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
59387
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
59388
+ kind: "mutation",
59389
+ auth: "admin"
59390
+ }), method(object({
59391
+ ...KindShape,
59392
+ id: RecordIdSchema
59393
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
59394
+ ...KindShape,
59395
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
59396
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
59397
+ ...KindShape,
59398
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
59399
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
59400
+ ...KindShape,
59401
+ record: RecordInputSchema,
59402
+ /** Compare-and-set. `0` means "the row must not exist". */
59403
+ ifRev: number().int().min(0).optional()
59404
+ }), object({
59405
+ rev: number().int(),
59406
+ releasedRefs: SecretRefsList
59407
+ }), {
59408
+ kind: "mutation",
59409
+ auth: "admin"
59410
+ }), method(object({
59411
+ ...KindShape,
59412
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
59413
+ }), object({
59414
+ count: number().int(),
59415
+ releasedRefs: SecretRefsList
59416
+ }), {
59417
+ kind: "mutation",
59418
+ auth: "admin"
59419
+ }), method(object({
59420
+ ...KindShape,
59421
+ id: RecordIdSchema,
59422
+ data: RecordBodySchema,
59423
+ at: number().int().nullable().optional(),
59424
+ expiresAt: number().int().nullable().optional(),
59425
+ ifRev: number().int().min(1).optional()
59426
+ }), object({
59427
+ rev: number().int(),
59428
+ releasedRefs: SecretRefsList
59429
+ }), {
59430
+ kind: "mutation",
59431
+ auth: "admin"
59432
+ }), method(object({
59433
+ ...KindShape,
59434
+ id: RecordIdSchema
59435
+ }), object({
59436
+ deleted: boolean(),
59437
+ secretRefs: SecretRefsList
59438
+ }), {
59439
+ kind: "mutation",
59440
+ auth: "admin"
59441
+ }), method(object({
59442
+ ...KindShape,
59443
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
59444
+ }), object({
59445
+ deleted: number().int(),
59446
+ secretRefs: SecretRefsList
59447
+ }), {
59448
+ kind: "mutation",
59449
+ auth: "admin"
59450
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
59451
+ ...KindShape,
59452
+ ...TimeWindowShape,
59453
+ where: RecordWhereSchema.optional()
59454
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
59455
+ ...KindShape,
59456
+ deviceId: number().int().optional(),
59457
+ from: number(),
59458
+ to: number(),
59459
+ bucketMs: number().int().positive()
59460
+ }), object({ buckets: array(object({
59461
+ bucketStart: number(),
59462
+ count: number().int()
59463
+ })) }), { auth: "admin" }), method(object({
59464
+ ...KindShape,
59465
+ op: _enum([
59466
+ "sum",
59467
+ "min",
59468
+ "max",
59469
+ "count"
59470
+ ]),
59471
+ field: RecordFieldPathSchema.optional(),
59472
+ groupBy: RecordFieldPathSchema.optional(),
59473
+ where: RecordWhereSchema.optional()
59474
+ }), object({ rows: array(object({
59475
+ group: union([
59476
+ string(),
59477
+ number(),
59478
+ _null()
59479
+ ]),
59480
+ value: number().nullable()
59481
+ })) }), { auth: "admin" }), method(object({
59482
+ ...KindShape,
59483
+ deviceId: number().int().optional(),
59484
+ atBefore: number().optional(),
59485
+ where: RecordWhereSchema.optional()
59486
+ }), object({
59487
+ deleted: number().int(),
59488
+ secretRefs: SecretRefsList
59489
+ }), {
59490
+ kind: "mutation",
59491
+ auth: "admin"
59492
+ }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
59493
+ results: array(object({
59494
+ rev: number().int().nullable(),
59495
+ deleted: boolean()
59496
+ })),
59497
+ releasedRefs: SecretRefsList,
59498
+ secretRefs: SecretRefsList
59499
+ }), {
59500
+ kind: "mutation",
59501
+ auth: "admin"
59502
+ }), method(object({
59503
+ deviceId: number().int(),
59504
+ kinds: array(RecordKindNameSchema).optional()
59505
+ }), object({
59506
+ deleted: record(string(), number().int()),
59507
+ secretRefs: SecretRefsList
59508
+ }), {
59509
+ kind: "mutation",
59510
+ auth: "admin"
59511
+ }), method(object(KindShape), object({ id: number().int() }), {
59512
+ kind: "mutation",
59513
+ auth: "admin"
59514
+ });
59515
+ /**
59516
+ * The wire shapes of the migration API, version 1 (planning#447).
59517
+ *
59518
+ * A migration is code that outlives the server it was written against: an addon at
59519
+ * version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
59520
+ * the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
59521
+ * is the contract of every method of it, one Zod pair per method.
59522
+ *
59523
+ * APPEND-ONLY. A released method is never removed and never changes meaning: an input
59524
+ * field is never removed or made required, an enum never narrows, an output field is
59525
+ * never removed. A change that cannot be expressed that way is `migration-api.v2`, next
59526
+ * to this file. `scripts/check-migration-api-append-only.ts` holds the line against
59527
+ * `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
59528
+ * `it('<id>'` in `migration-api.contract.spec.ts`.
59529
+ */
59530
+ var Rows = record(string(), unknown());
59531
+ var IntegrationId = object({ integrationId: string().min(1) });
59532
+ var RecordId = object({ id: string().min(1) });
59533
+ var RecordRowSchema = object({
59534
+ id: string(),
59535
+ deviceId: number().int().nullable(),
59536
+ at: number().nullable(),
59537
+ expiresAt: number().nullable(),
59538
+ rev: number().int(),
59539
+ updatedAt: number(),
59540
+ data: Rows
59541
+ });
59542
+ var RecordPutShape = {
59543
+ id: string().min(1),
59544
+ deviceId: number().int().optional(),
59545
+ at: number().int().optional(),
59546
+ expiresAt: number().int().optional(),
59547
+ data: Rows
59548
+ };
59549
+ var MigrationIntegrationSchema = object({
59550
+ id: string(),
59551
+ addonId: string(),
59552
+ name: string(),
59553
+ info: Rows,
59554
+ originStableId: string().optional()
59555
+ });
59556
+ var MigrationDeviceSchema = object({
59557
+ id: number().int(),
59558
+ integrationId: string().nullable().optional(),
59559
+ /** The owning device; null or absent for a root. */
59560
+ parentDeviceId: number().int().nullable().optional(),
59561
+ type: string().optional(),
59562
+ name: string().optional(),
59563
+ stableId: string().optional()
59564
+ });
59565
+ /** What the engine says about the migration API it serves: lets an addon notice an older server. */
59566
+ var MigrationApiInfoSchema = object({
59567
+ version: number().int(),
59568
+ methods: array(string())
59569
+ });
59570
+ object({
59571
+ message: string(),
59572
+ meta: Rows.optional(),
59573
+ /** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
59574
+ tags: object({ deviceId: number().int().optional() }).optional()
59575
+ });
59576
+ object({
59577
+ owner: string().min(1),
59578
+ metas: array(MigrationMetaSchema)
59579
+ }), object({
59580
+ bootId: string(),
59581
+ snapshot: _enum([
59582
+ "none",
59583
+ "written",
59584
+ "refused"
59585
+ ]),
59586
+ steps: array(MigrationOwnerStepSchema),
59587
+ /** The migration API the engine serves; absent from a server that predates it. */
59588
+ migrationApi: MigrationApiInfoSchema.optional()
59589
+ }), object({ id: string().min(1) }), object({
59590
+ proceed: boolean(),
59591
+ state: union([literal("pending"), MigrationStatusSchema]),
59592
+ reason: string().nullable()
59593
+ }), object({
59594
+ id: string().min(1),
59595
+ result: MigrationOwnerResultSchema
59596
+ }), object({
59597
+ status: MigrationStatusSchema,
59598
+ error: string().nullable(),
59599
+ rowsChanged: number().int().nonnegative()
59600
+ }), object({
59601
+ rows: number().int().nonnegative(),
59602
+ secrets: number().int().nonnegative()
59603
+ }), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
59604
+ present: boolean(),
59605
+ removed: Rows
59606
+ }), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
59607
+ ...RecordPutShape,
59608
+ ifRev: number().int().optional()
59609
+ }), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
59610
+ partial: Rows,
59611
+ ifRev: number().int().optional()
59612
+ }), object({ rev: number().int() }), object({ deleted: boolean() }), object({
59613
+ deviceId: number().int().optional(),
59614
+ atFrom: number().optional(),
59615
+ atTo: number().optional(),
59616
+ where: RecordWhereSchema.optional(),
59617
+ limit: number().int().min(1).optional(),
59618
+ cursor: string().min(1).optional(),
59619
+ resolveSecrets: boolean().optional()
59620
+ }), object({
59621
+ records: array(RecordRowSchema),
59622
+ nextCursor: string().nullable()
59623
+ }), object({
59624
+ deviceId: number().int().optional(),
59625
+ atBefore: number().optional(),
59626
+ where: RecordWhereSchema.optional()
59627
+ }), 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({
59628
+ ref: string().min(1),
59629
+ value: string()
59630
+ }), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
59631
+ addonId: string().min(1),
59632
+ integrationId: string().min(1).optional()
59633
+ }), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
59634
+ id: number().int(),
59635
+ integrationId: string().nullable(),
59636
+ /** Whether the device carries any stored config; its content is not offered. */
59637
+ hasConfig: boolean()
59638
+ }).nullable(), object({
59639
+ deviceId: number().int(),
59640
+ integrationId: string().min(1)
59641
+ }), object({}), object({}), object({ nodeId: string() }), object({}), object({});
59379
59642
  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({
59380
59643
  id: string().min(1),
59381
59644
  error: string().min(1)
@@ -59405,7 +59668,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
59405
59668
  "written",
59406
59669
  "refused"
59407
59670
  ]),
59408
- steps: array(MigrationOwnerStepSchema)
59671
+ steps: array(MigrationOwnerStepSchema),
59672
+ /** The migration API this engine serves (additive: a server that predates it omits it). */
59673
+ migrationApi: MigrationApiInfoSchema.optional()
59409
59674
  }), {
59410
59675
  kind: "mutation",
59411
59676
  auth: "admin"
@@ -62072,7 +62337,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
62072
62337
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
62073
62338
  kind: "mutation",
62074
62339
  auth: "admin"
62075
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
62340
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
62341
+ kind: "query",
62342
+ auth: "admin"
62343
+ }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
62076
62344
  kind: "query",
62077
62345
  auth: "admin"
62078
62346
  }), method(object({}), array(RelocateJobSchema).readonly(), {
@@ -64727,7 +64995,7 @@ var BrokerStatusSchema$1 = _enum([
64727
64995
  "unreachable",
64728
64996
  "tls-error"
64729
64997
  ]);
64730
- var BrokerInfoSchema$1 = object({
64998
+ var BrokerInfoSchema = object({
64731
64999
  id: string(),
64732
65000
  name: string(),
64733
65001
  url: string(),
@@ -64790,7 +65058,7 @@ var StatusSchema = object({
64790
65058
  brokerCount: number(),
64791
65059
  embeddedRunning: boolean()
64792
65060
  });
64793
- method(_void(), array(BrokerInfoSchema$1)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
65061
+ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
64794
65062
  kind: "mutation",
64795
65063
  auth: "admin"
64796
65064
  }), method(IdInputSchema, _void(), {
@@ -71972,253 +72240,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
71972
72240
  auth: "admin"
71973
72241
  });
71974
72242
  /**
71975
- * records - an addon's own facts and documents (D881): ledgers, audit rows,
71976
- * config documents, mirrors. The third storage API next to `ctx.settings`
71977
- * (operator intent, D870) and device-history (numbers over time, D850).
71978
- *
71979
- * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
71980
- * crossed a process and stated by a hub in-process caller (`ctx.records` does
71981
- * that with the addon id closed over). It is deliberately NOT in any input
71982
- * schema, so a session can never supply it, and a call with no stamp is refused
71983
- * `records/no-caller`. A kind is readable and writable only by its owner; other
71984
- * addons go through the owner's capability.
71985
- *
71986
- * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
71987
- * never `[]`. Secret fields are never on the wire: a read shows the
71988
- * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
71989
- * resolves itself, and a write may carry only a keychain marker bound to the
71990
- * row's own ref.
71991
- *
71992
- * Internal: addons reach it through `ctx.records`, never directly.
71993
- */
71994
- var RecordIdSchema = string().min(1).max(256);
71995
- /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
71996
- var RecordBodySchema = record(string(), unknown());
71997
- var RecordInputSchema = object({
71998
- id: RecordIdSchema,
71999
- /** The device this row belongs to (D865 removal, per-device reads). */
72000
- deviceId: number().int().optional(),
72001
- /** The domain clock, ms: observed / created / opened. */
72002
- at: number().int().optional(),
72003
- /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
72004
- expiresAt: number().int().optional(),
72005
- data: RecordBodySchema
72006
- });
72007
- var RecordViewSchema = object({
72008
- id: string(),
72009
- deviceId: number().int().nullable(),
72010
- at: number().nullable(),
72011
- expiresAt: number().nullable(),
72012
- rev: number().int(),
72013
- updatedAt: number(),
72014
- data: RecordBodySchema
72015
- });
72016
- /** Declared index fields only. Anything else does not compile, by design. */
72017
- var RecordWhereSchema = record(RecordFieldPathSchema, union([
72018
- string(),
72019
- number(),
72020
- boolean(),
72021
- object({ in: array(union([
72022
- string(),
72023
- number(),
72024
- boolean()
72025
- ])).min(1).max(RECORD_BATCH_MAX) }),
72026
- object({
72027
- gt: union([string(), number()]).optional(),
72028
- gte: union([string(), number()]).optional(),
72029
- lt: union([string(), number()]).optional(),
72030
- lte: union([string(), number()]).optional()
72031
- }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
72032
- ]));
72033
- var KindShape = { kind: RecordKindNameSchema };
72034
- var TimeWindowShape = {
72035
- deviceId: number().int().optional(),
72036
- atFrom: number().optional(),
72037
- atTo: number().optional()
72038
- };
72039
- var RecordQueryInputSchema = object({
72040
- ...KindShape,
72041
- ...TimeWindowShape,
72042
- where: RecordWhereSchema.optional(),
72043
- /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
72044
- order: _enum(["at", "id"]).optional(),
72045
- desc: boolean().optional(),
72046
- limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
72047
- /** Opaque keyset cursor from a previous answer. There is no offset. */
72048
- cursor: string().min(1).optional()
72049
- });
72050
- var RecordQueryResultSchema = object({
72051
- records: array(RecordViewSchema),
72052
- nextCursor: string().nullable()
72053
- });
72054
- var RecordKindStateSchema = _enum([
72055
- "created",
72056
- "unchanged",
72057
- "updated"
72058
- ]);
72059
- var DeclareKindResultSchema = object({
72060
- kindId: number().int(),
72061
- state: RecordKindStateSchema,
72062
- createdIndexes: array(string())
72063
- });
72064
- /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
72065
- var SecretRefsList = array(string());
72066
- /**
72067
- * One op of a `transact`: the single-row writes, each on a kind of the caller.
72068
- * All ops of one call share ONE database file and ONE `transactFamily`.
72069
- */
72070
- var RecordTransactOpSchema = discriminatedUnion("op", [
72071
- object({
72072
- op: literal("put"),
72073
- kind: RecordKindNameSchema,
72074
- record: RecordInputSchema,
72075
- ifRev: number().int().min(0).optional()
72076
- }),
72077
- object({
72078
- op: literal("patch"),
72079
- kind: RecordKindNameSchema,
72080
- id: RecordIdSchema,
72081
- data: RecordBodySchema,
72082
- at: number().int().nullable().optional(),
72083
- expiresAt: number().int().nullable().optional(),
72084
- ifRev: number().int().min(1).optional()
72085
- }),
72086
- object({
72087
- op: literal("delete"),
72088
- kind: RecordKindNameSchema,
72089
- id: RecordIdSchema
72090
- })
72091
- ]);
72092
- var RecordSecretRefsSchema = record(string(), record(string(), string()));
72093
- method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
72094
- kind: "mutation",
72095
- auth: "admin"
72096
- }), method(object({
72097
- ...KindShape,
72098
- id: RecordIdSchema
72099
- }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
72100
- ...KindShape,
72101
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
72102
- }), array(RecordViewSchema), { auth: "admin" }), method(object({
72103
- ...KindShape,
72104
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
72105
- }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
72106
- ...KindShape,
72107
- record: RecordInputSchema,
72108
- /** Compare-and-set. `0` means "the row must not exist". */
72109
- ifRev: number().int().min(0).optional()
72110
- }), object({
72111
- rev: number().int(),
72112
- releasedRefs: SecretRefsList
72113
- }), {
72114
- kind: "mutation",
72115
- auth: "admin"
72116
- }), method(object({
72117
- ...KindShape,
72118
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
72119
- }), object({
72120
- count: number().int(),
72121
- releasedRefs: SecretRefsList
72122
- }), {
72123
- kind: "mutation",
72124
- auth: "admin"
72125
- }), method(object({
72126
- ...KindShape,
72127
- id: RecordIdSchema,
72128
- data: RecordBodySchema,
72129
- at: number().int().nullable().optional(),
72130
- expiresAt: number().int().nullable().optional(),
72131
- ifRev: number().int().min(1).optional()
72132
- }), object({
72133
- rev: number().int(),
72134
- releasedRefs: SecretRefsList
72135
- }), {
72136
- kind: "mutation",
72137
- auth: "admin"
72138
- }), method(object({
72139
- ...KindShape,
72140
- id: RecordIdSchema
72141
- }), object({
72142
- deleted: boolean(),
72143
- secretRefs: SecretRefsList
72144
- }), {
72145
- kind: "mutation",
72146
- auth: "admin"
72147
- }), method(object({
72148
- ...KindShape,
72149
- ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
72150
- }), object({
72151
- deleted: number().int(),
72152
- secretRefs: SecretRefsList
72153
- }), {
72154
- kind: "mutation",
72155
- auth: "admin"
72156
- }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
72157
- ...KindShape,
72158
- ...TimeWindowShape,
72159
- where: RecordWhereSchema.optional()
72160
- }), object({ count: number().int() }), { auth: "admin" }), method(object({
72161
- ...KindShape,
72162
- deviceId: number().int().optional(),
72163
- from: number(),
72164
- to: number(),
72165
- bucketMs: number().int().positive()
72166
- }), object({ buckets: array(object({
72167
- bucketStart: number(),
72168
- count: number().int()
72169
- })) }), { auth: "admin" }), method(object({
72170
- ...KindShape,
72171
- op: _enum([
72172
- "sum",
72173
- "min",
72174
- "max",
72175
- "count"
72176
- ]),
72177
- field: RecordFieldPathSchema.optional(),
72178
- groupBy: RecordFieldPathSchema.optional(),
72179
- where: RecordWhereSchema.optional()
72180
- }), object({ rows: array(object({
72181
- group: union([
72182
- string(),
72183
- number(),
72184
- _null()
72185
- ]),
72186
- value: number().nullable()
72187
- })) }), { auth: "admin" }), method(object({
72188
- ...KindShape,
72189
- deviceId: number().int().optional(),
72190
- atBefore: number().optional(),
72191
- where: RecordWhereSchema.optional()
72192
- }), object({
72193
- deleted: number().int(),
72194
- secretRefs: SecretRefsList
72195
- }), {
72196
- kind: "mutation",
72197
- auth: "admin"
72198
- }), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
72199
- results: array(object({
72200
- rev: number().int().nullable(),
72201
- deleted: boolean()
72202
- })),
72203
- releasedRefs: SecretRefsList,
72204
- secretRefs: SecretRefsList
72205
- }), {
72206
- kind: "mutation",
72207
- auth: "admin"
72208
- }), method(object({
72209
- deviceId: number().int(),
72210
- kinds: array(RecordKindNameSchema).optional()
72211
- }), object({
72212
- deleted: record(string(), number().int()),
72213
- secretRefs: SecretRefsList
72214
- }), {
72215
- kind: "mutation",
72216
- auth: "admin"
72217
- }), method(object(KindShape), object({ id: number().int() }), {
72218
- kind: "mutation",
72219
- auth: "admin"
72220
- });
72221
- /**
72222
72243
  * record-entries - the ONE admin surface for every list of user-created entries
72223
72244
  * (D881): notification targets, brokers, LLM profiles, anything an addon
72224
72245
  * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
@@ -82038,7 +82059,7 @@ var BaseDeviceProvider = class extends BaseAddon {
82038
82059
  * `deviceClasses` map (first registered type). `null` when manual creation is
82039
82060
  * unsupported. Lets the Add-Device dialog pick the right type per provider.
82040
82061
  */
82041
- async getManualCreationType() {
82062
+ async getManualCreationType(_input) {
82042
82063
  if (!await this.supportsManualCreation()) return { deviceType: null };
82043
82064
  return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
82044
82065
  }
@@ -82049,7 +82070,7 @@ var BaseDeviceProvider = class extends BaseAddon {
82049
82070
  return true;
82050
82071
  }
82051
82072
  async getChildCreationSchema(input) {
82052
- return this.onGetCreationSchema(input.type);
82073
+ return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
82053
82074
  }
82054
82075
  /**
82055
82076
  * Default kernel-orchestrated `createDevice` implementation. The
@@ -82061,7 +82082,7 @@ var BaseDeviceProvider = class extends BaseAddon {
82061
82082
  * `deviceClasses` instead.
82062
82083
  */
82063
82084
  async createDevice(input) {
82064
- const spec = await this.onCreateDevice(input.type, input.config);
82085
+ const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
82065
82086
  const Class = this.deviceClasses[spec.meta.type];
82066
82087
  if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
82067
82088
  const stableId = this.generateStableId(spec.meta.type, spec.config);
@@ -83470,20 +83491,6 @@ Object.freeze({
83470
83491
  access: "create",
83471
83492
  role: "viewer"
83472
83493
  },
83473
- "broker.add": {
83474
- capName: "broker",
83475
- capScope: "system",
83476
- addonId: null,
83477
- access: "create",
83478
- role: "admin"
83479
- },
83480
- "broker.get": {
83481
- capName: "broker",
83482
- capScope: "system",
83483
- addonId: null,
83484
- access: "view",
83485
- role: "admin"
83486
- },
83487
83494
  "broker.getBrokerConfig": {
83488
83495
  capName: "broker",
83489
83496
  capScope: "system",
@@ -83491,20 +83498,6 @@ Object.freeze({
83491
83498
  access: "view",
83492
83499
  role: "admin"
83493
83500
  },
83494
- "broker.getSettings": {
83495
- capName: "broker",
83496
- capScope: "system",
83497
- addonId: null,
83498
- access: "view",
83499
- role: "admin"
83500
- },
83501
- "broker.getSettingsSchema": {
83502
- capName: "broker",
83503
- capScope: "system",
83504
- addonId: null,
83505
- access: "view",
83506
- role: "admin"
83507
- },
83508
83501
  "broker.getState": {
83509
83502
  capName: "broker",
83510
83503
  capScope: "system",
@@ -83519,20 +83512,6 @@ Object.freeze({
83519
83512
  access: "view",
83520
83513
  role: "admin"
83521
83514
  },
83522
- "broker.list": {
83523
- capName: "broker",
83524
- capScope: "system",
83525
- addonId: null,
83526
- access: "view",
83527
- role: "admin"
83528
- },
83529
- "broker.listProviders": {
83530
- capName: "broker",
83531
- capScope: "system",
83532
- addonId: null,
83533
- access: "view",
83534
- role: "admin"
83535
- },
83536
83515
  "broker.publish": {
83537
83516
  capName: "broker",
83538
83517
  capScope: "system",
@@ -83540,20 +83519,6 @@ Object.freeze({
83540
83519
  access: "create",
83541
83520
  role: "admin"
83542
83521
  },
83543
- "broker.remove": {
83544
- capName: "broker",
83545
- capScope: "system",
83546
- addonId: null,
83547
- access: "delete",
83548
- role: "admin"
83549
- },
83550
- "broker.setSettings": {
83551
- capName: "broker",
83552
- capScope: "system",
83553
- addonId: null,
83554
- access: "create",
83555
- role: "admin"
83556
- },
83557
83522
  "broker.subscribe": {
83558
83523
  capName: "broker",
83559
83524
  capScope: "system",
@@ -83561,20 +83526,6 @@ Object.freeze({
83561
83526
  access: "create",
83562
83527
  role: "admin"
83563
83528
  },
83564
- "broker.testConnection": {
83565
- capName: "broker",
83566
- capScope: "system",
83567
- addonId: null,
83568
- access: "create",
83569
- role: "admin"
83570
- },
83571
- "broker.testSettings": {
83572
- capName: "broker",
83573
- capScope: "system",
83574
- addonId: null,
83575
- access: "create",
83576
- role: "admin"
83577
- },
83578
83529
  "broker.unsubscribe": {
83579
83530
  capName: "broker",
83580
83531
  capScope: "system",
@@ -88538,6 +88489,13 @@ Object.freeze({
88538
88489
  access: "view",
88539
88490
  role: "viewer"
88540
88491
  },
88492
+ "pipelineAnalytics.getMediaLocationCensus": {
88493
+ capName: "pipeline-analytics",
88494
+ capScope: "device",
88495
+ addonId: null,
88496
+ access: "view",
88497
+ role: "admin"
88498
+ },
88541
88499
  "pipelineAnalytics.getMediaReclaimStatus": {
88542
88500
  capName: "pipeline-analytics",
88543
88501
  capScope: "device",
@@ -97604,6 +97562,74 @@ object({
97604
97562
  delay: number().nonnegative().optional(),
97605
97563
  commands: record(string(), unknown())
97606
97564
  });
97565
+ entryBody({ brokerId: string() });
97566
+ function secretsOverMigrationApi(api) {
97567
+ return {
97568
+ resolve: async (refs) => {
97569
+ const { values } = await api.secrets.resolve({ refs: [...refs] });
97570
+ const out = {};
97571
+ for (const ref of refs) {
97572
+ const value = values[ref];
97573
+ out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
97574
+ kind: "value",
97575
+ value,
97576
+ version: 0
97577
+ };
97578
+ }
97579
+ return out;
97580
+ },
97581
+ delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
97582
+ };
97583
+ }
97584
+ /** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
97585
+ function recordsOverMigrationApi(api) {
97586
+ return { kind: (definition) => {
97587
+ const handle = api.records.kind(definition);
97588
+ return {
97589
+ get: (id) => handle.get({ id }),
97590
+ getResolved: (id) => handle.getResolved({ id }),
97591
+ put: (input, opts) => handle.put({
97592
+ ...input,
97593
+ ...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
97594
+ }),
97595
+ delete: (id) => handle.delete({ id })
97596
+ };
97597
+ } };
97598
+ }
97599
+ function integrationRowsApiOver(api) {
97600
+ return {
97601
+ list: async () => (await api.integrations.list({})).integrations,
97602
+ readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
97603
+ clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
97604
+ };
97605
+ }
97606
+ /**
97607
+ * One serial lane per migration API: a log line is delivered after the line before it, so the
97608
+ * order the steps wrote them in is the order the hub reads them in. A delivery that fails
97609
+ * is reported once through the same door; if that fails too nothing is left to tell, and the
97610
+ * line is dropped rather than thrown into a migration step or left as an unhandled rejection.
97611
+ */
97612
+ var lanes = /* @__PURE__ */ new WeakMap();
97613
+ function deliver(api, send) {
97614
+ const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
97615
+ const reason = error instanceof Error ? error.message : String(error);
97616
+ await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
97617
+ });
97618
+ lanes.set(api, next);
97619
+ return next;
97620
+ }
97621
+ function warnOver(api) {
97622
+ return (message) => deliver(api, () => api.log.warn({ message }));
97623
+ }
97624
+ /** What the rows-to-records move needs, over the migration API. */
97625
+ function rowsDepsOver(api) {
97626
+ return {
97627
+ api: integrationRowsApiOver(api),
97628
+ records: recordsOverMigrationApi(api),
97629
+ secrets: secretsOverMigrationApi(api),
97630
+ warn: warnOver(api)
97631
+ };
97632
+ }
97607
97633
  //#endregion
97608
97634
  //#region src/config.ts
97609
97635
  /**
@@ -99372,18 +99398,15 @@ var EnpalProviderAddon = class extends BaseDeviceProvider {
99372
99398
  const records = this.ctx.records;
99373
99399
  if (records === void 0) throw new Error("provider-enpal: ctx.records is required (hub-only addon)");
99374
99400
  await records.declare(enpalRecordKinds);
99375
- await this.runMigrations(defineAddonMigrations([integrationRowsMigration({
99401
+ await this.runMigrations([integrationRowsMigration({
99376
99402
  addonId: this.addonId,
99377
99403
  date: ENPAL_MIGRATIONS_DATE,
99378
99404
  kind: enpalConnectionsEntryKind,
99379
99405
  fixtureMark: "host"
99380
- })], integrationRowsPortsOver({
99381
- api: defaultIntegrationApiOver(this.ctx.api),
99382
- secrets: this.ctx.secrets ?? null,
99383
- records,
99384
- kind: enpalConnectionsEntryKind,
99385
- warn: (message) => this.ctx.logger.warn(message)
99386
- })));
99406
+ })], (api) => integrationRowsPortsOver({
99407
+ ...rowsDepsOver(api),
99408
+ kind: enpalConnectionsEntryKind
99409
+ }));
99387
99410
  this.instances = buildEnpalInstances(records, { onChanged: () => this.reconcileIntegrations() });
99388
99411
  this.clients = new EnpalClientRegistry(this.ctx.logger, {
99389
99412
  onConnected: (integrationId) => this.setIntegrationDevicesOnline(integrationId, true),