@camstack/addon-provider-reolink 1.2.229 → 1.2.230
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/addon.js +539 -586
- package/dist/addon.mjs +539 -586
- package/package.json +2 -2
package/dist/addon.js
CHANGED
|
@@ -106677,7 +106677,7 @@ var ZodIssueCode = {
|
|
|
106677
106677
|
var ZodFirstPartyTypeKind;
|
|
106678
106678
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106679
106679
|
//#endregion
|
|
106680
|
-
//#region ../types/dist/sleep-
|
|
106680
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
106681
106681
|
/**
|
|
106682
106682
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106683
106683
|
* window to float samples (D455).
|
|
@@ -108306,6 +108306,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
108306
108306
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
108307
108307
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
108308
108308
|
/**
|
|
108309
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
108310
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
108311
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
108312
|
+
*/
|
|
108313
|
+
function migrationSet(catalogue, bindPorts) {
|
|
108314
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
108315
|
+
}
|
|
108316
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
108317
|
+
function refuseMixed(form, kept, dropped) {
|
|
108318
|
+
if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
|
|
108319
|
+
}
|
|
108320
|
+
function catalogueOf(list) {
|
|
108321
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
108322
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
108323
|
+
return kept;
|
|
108324
|
+
}
|
|
108325
|
+
function boundOf(list) {
|
|
108326
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
108327
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
108328
|
+
return kept;
|
|
108329
|
+
}
|
|
108330
|
+
/**
|
|
108309
108331
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
108310
108332
|
*
|
|
108311
108333
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -108472,23 +108494,21 @@ var BaseAddon = class {
|
|
|
108472
108494
|
await this.loadScopedSchemas();
|
|
108473
108495
|
return normalized;
|
|
108474
108496
|
}
|
|
108497
|
+
async runMigrations(first, second, third) {
|
|
108498
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
108499
|
+
return this.runBound(boundOf(first), second);
|
|
108500
|
+
}
|
|
108475
108501
|
/**
|
|
108476
|
-
*
|
|
108477
|
-
*
|
|
108478
|
-
*
|
|
108479
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
108480
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
108481
|
-
*
|
|
108482
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
108483
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
108484
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
108485
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
108486
|
-
*
|
|
108487
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
108488
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
108489
|
-
* omitted applied ids "newer").
|
|
108502
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
108503
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
108504
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
108490
108505
|
*/
|
|
108491
|
-
async
|
|
108506
|
+
async runMigrationSets(sets, options) {
|
|
108507
|
+
const api = this.ctx.migrationApi;
|
|
108508
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
108509
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
108510
|
+
}
|
|
108511
|
+
async runBound(migrations, options) {
|
|
108492
108512
|
const api = this.ctx.api.migrations;
|
|
108493
108513
|
const report = await runAddonMigrations({
|
|
108494
108514
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -114042,17 +114062,6 @@ var NodeColorIdSchema = _enum([
|
|
|
114042
114062
|
"node-g",
|
|
114043
114063
|
"node-h"
|
|
114044
114064
|
]);
|
|
114045
|
-
//#endregion
|
|
114046
|
-
//#region ../types/dist/index.mjs
|
|
114047
|
-
/**
|
|
114048
|
-
* The `smtp-inbound` broker kind (D999): a mailbox a device can send mail to.
|
|
114049
|
-
*
|
|
114050
|
-
* The `broker` cap carries these as `Record<string, unknown>` on the wire; the
|
|
114051
|
-
* provider and its consumers parse them with the schemas below at BOTH ends, so
|
|
114052
|
-
* the shape is declared once.
|
|
114053
|
-
*/
|
|
114054
|
-
/** The broker kind tag. */
|
|
114055
|
-
var SMTP_INBOUND_KIND = "smtp-inbound";
|
|
114056
114065
|
/** The id the first mailbox is minted under (adopt-id), so a consumer can find it again. */
|
|
114057
114066
|
var SMTP_INBOUND_DEFAULT_ID = "smtp-inbound-default";
|
|
114058
114067
|
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
@@ -114374,26 +114383,16 @@ var RecordIntegrationInstances = class {
|
|
|
114374
114383
|
...this.hooks.description,
|
|
114375
114384
|
mintsId: true
|
|
114376
114385
|
};
|
|
114377
|
-
|
|
114378
|
-
* The record an id names. A caller holding the `integrations` registry id (the Integrations
|
|
114379
|
-
* page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
|
|
114380
|
-
* record id answers as it is. An id that names nothing comes back unchanged.
|
|
114381
|
-
*/
|
|
114382
|
-
async resolveRecordId(id) {
|
|
114383
|
-
if (await this.handle.get(id) !== null) return id;
|
|
114384
|
-
const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
|
|
114385
|
-
return linked === void 0 ? id : linked.id;
|
|
114386
|
-
}
|
|
114387
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
|
|
114386
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
114388
114387
|
listInstances = async () => {
|
|
114389
114388
|
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
114390
114389
|
};
|
|
114391
114390
|
getInstance = async ({ id }) => {
|
|
114392
|
-
const record = await this.handle.get(
|
|
114391
|
+
const record = await this.handle.get(id);
|
|
114393
114392
|
return record === null ? null : this.viewOf(record);
|
|
114394
114393
|
};
|
|
114395
114394
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
114396
|
-
createInstance = async ({ id, name, kind }) => {
|
|
114395
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
114397
114396
|
const minted = id ?? this.hooks.mintId?.({
|
|
114398
114397
|
name,
|
|
114399
114398
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -114403,11 +114402,20 @@ var RecordIntegrationInstances = class {
|
|
|
114403
114402
|
id: minted,
|
|
114404
114403
|
data: this.hooks.initialBody(name, kind)
|
|
114405
114404
|
}, { ifRev: 0 });
|
|
114405
|
+
const patch = this.patchOf(values ?? {});
|
|
114406
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
114406
114407
|
await this.hooks.onChanged?.(minted, "created");
|
|
114407
114408
|
return { id: minted };
|
|
114408
114409
|
};
|
|
114409
|
-
updateInstance = async ({ id
|
|
114410
|
-
const
|
|
114410
|
+
updateInstance = async ({ id, name, values }) => {
|
|
114411
|
+
const patch = this.patchOf(values);
|
|
114412
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
114413
|
+
await this.handle.patch(id, patch);
|
|
114414
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
114415
|
+
return { ok: true };
|
|
114416
|
+
};
|
|
114417
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
114418
|
+
patchOf(values) {
|
|
114411
114419
|
const patch = {};
|
|
114412
114420
|
for (const [key, value] of Object.entries(values)) {
|
|
114413
114421
|
if (value === void 0) continue;
|
|
@@ -114418,11 +114426,8 @@ var RecordIntegrationInstances = class {
|
|
|
114418
114426
|
else if (isSecretClear(value)) patch[key] = null;
|
|
114419
114427
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
114420
114428
|
}
|
|
114421
|
-
|
|
114422
|
-
|
|
114423
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
114424
|
-
return { ok: true };
|
|
114425
|
-
};
|
|
114429
|
+
return patch;
|
|
114430
|
+
}
|
|
114426
114431
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
114427
114432
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
114428
114433
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -114442,10 +114447,7 @@ var RecordIntegrationInstances = class {
|
|
|
114442
114447
|
status: "unsupported",
|
|
114443
114448
|
error: "This integration declares no connection test"
|
|
114444
114449
|
};
|
|
114445
|
-
return this.hooks.test(input
|
|
114446
|
-
...input,
|
|
114447
|
-
id: await this.resolveRecordId(input.id)
|
|
114448
|
-
});
|
|
114450
|
+
return this.hooks.test(input);
|
|
114449
114451
|
};
|
|
114450
114452
|
/** The flat provider object to hand to `registerProvider`. */
|
|
114451
114453
|
toProvider() {
|
|
@@ -115758,13 +115760,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
115758
115760
|
};
|
|
115759
115761
|
if (orphans.some((d) => (d.parentDeviceId ?? null) === null) && fallback === null) throw new Error(`${orphans.length} device(s) of '${spec.addonId}' carry no integration and the addon has no integration to claim them to`);
|
|
115760
115762
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
115761
|
-
for (const id of unresolved) ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
115763
|
+
for (const id of unresolved) await ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
115762
115764
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
115763
115765
|
const wrong = [];
|
|
115764
115766
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
115765
115767
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
115766
115768
|
const claimed = plan.size;
|
|
115767
|
-
ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
115769
|
+
await ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
115768
115770
|
return {
|
|
115769
115771
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
115770
115772
|
summary: {
|
|
@@ -116980,6 +116982,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
116980
116982
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
116981
116983
|
total: number().int().nonnegative().nullable()
|
|
116982
116984
|
}).nullable();
|
|
116985
|
+
/**
|
|
116986
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
116987
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
116988
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
116989
|
+
* that was not asked about (a deleted or never-listed one).
|
|
116990
|
+
*
|
|
116991
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
116992
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
116993
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
116994
|
+
* it is a deleted location only when every location id was asked.
|
|
116995
|
+
* `null` is "could not be measured", never zero.
|
|
116996
|
+
*/
|
|
116997
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
116998
|
+
var MediaLocationCensusSchema = object({
|
|
116999
|
+
locations: array(object({
|
|
117000
|
+
locationId: string(),
|
|
117001
|
+
rows: number().int().nonnegative(),
|
|
117002
|
+
bytes: number().nonnegative()
|
|
117003
|
+
})).readonly(),
|
|
117004
|
+
unstamped: object({
|
|
117005
|
+
rows: number().int().nonnegative(),
|
|
117006
|
+
bytes: number().nonnegative()
|
|
117007
|
+
}),
|
|
117008
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
117009
|
+
unlisted: object({
|
|
117010
|
+
rows: number().int().nonnegative(),
|
|
117011
|
+
bytes: number().nonnegative()
|
|
117012
|
+
}),
|
|
117013
|
+
total: object({
|
|
117014
|
+
rows: number().int().nonnegative(),
|
|
117015
|
+
bytes: number().nonnegative()
|
|
117016
|
+
})
|
|
117017
|
+
});
|
|
116983
117018
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
116984
117019
|
/** The independently selectable logical storage classes — every class
|
|
116985
117020
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -148550,52 +148585,7 @@ onBrightnessChanged: { data: object({
|
|
|
148550
148585
|
minIntervalMs: 0
|
|
148551
148586
|
} } }
|
|
148552
148587
|
};
|
|
148553
|
-
|
|
148554
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
148555
|
-
*
|
|
148556
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
148557
|
-
* register and that other addons might consume. The first two kinds
|
|
148558
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
148559
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
148560
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
148561
|
-
* the same surface.
|
|
148562
|
-
*
|
|
148563
|
-
* Why one cap, not one cap per kind:
|
|
148564
|
-
* - The integrations page wants a single table of "every broker"
|
|
148565
|
-
* across kinds; a unified cap drives it without join logic.
|
|
148566
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
148567
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
148568
|
-
* - The `network-access` cap precedent: same interface, many
|
|
148569
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
148570
|
-
*
|
|
148571
|
-
* What stays kind-specific:
|
|
148572
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
148573
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
148574
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
148575
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
148576
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
148577
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
148578
|
-
* without rebreaking the cap signature.
|
|
148579
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
148580
|
-
* the kind-specific provider).
|
|
148581
|
-
*
|
|
148582
|
-
* Bidirectionality:
|
|
148583
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
148584
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
148585
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
148586
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
148587
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
148588
|
-
* provider re-subscribes upstream after a transport drop.
|
|
148589
|
-
*
|
|
148590
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
148591
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
148592
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
148593
|
-
* drop is recoverable via `getState({key})`).
|
|
148594
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
148595
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
148596
|
-
* per-broker wire-shaping needed.
|
|
148597
|
-
*/
|
|
148598
|
-
var BrokerStatusEnum = _enum([
|
|
148588
|
+
_enum([
|
|
148599
148589
|
"connected",
|
|
148600
148590
|
"disconnected",
|
|
148601
148591
|
"connecting",
|
|
@@ -148603,141 +148593,12 @@ var BrokerStatusEnum = _enum([
|
|
|
148603
148593
|
"unreachable",
|
|
148604
148594
|
"error"
|
|
148605
148595
|
]);
|
|
148606
|
-
var BrokerInfoSchema = object({
|
|
148607
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
148608
|
-
id: string(),
|
|
148609
|
-
/** Addon id of the provider that OWNS this broker.
|
|
148610
|
-
*
|
|
148611
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
148612
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
148613
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
148614
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
148615
|
-
* device belongs to one integration. The admin UI threads this id
|
|
148616
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
148617
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
148618
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
148619
|
-
* instead of defaulting to the first-registered one. */
|
|
148620
|
-
addonId: string(),
|
|
148621
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
148622
|
-
name: string(),
|
|
148623
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
148624
|
-
kind: string(),
|
|
148625
|
-
status: BrokerStatusEnum,
|
|
148626
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
148627
|
-
* flavour, latency, mTLS active, …). */
|
|
148628
|
-
info: record(string(), unknown()),
|
|
148629
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
148630
|
-
lastCheckedAt: number().nullable(),
|
|
148631
|
-
/** Last error message, when `status` indicates failure. */
|
|
148632
|
-
error: string().nullable()
|
|
148633
|
-
});
|
|
148634
148596
|
var RegistryStatusSchema = object({
|
|
148635
148597
|
brokerCount: number().int().nonnegative(),
|
|
148636
148598
|
connectedCount: number().int().nonnegative()
|
|
148637
148599
|
});
|
|
148638
|
-
/**
|
|
148639
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
148640
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
148641
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
148642
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
148643
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
148644
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
148645
|
-
* offers a kind whose creation form can't be rendered).
|
|
148646
|
-
*/
|
|
148647
|
-
var BrokerProviderInfoSchema = object({
|
|
148648
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
148649
|
-
addonId: string(),
|
|
148650
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
148651
|
-
kinds: array(object({
|
|
148652
|
-
kind: string(),
|
|
148653
|
-
label: string(),
|
|
148654
|
-
/**
|
|
148655
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
148656
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
148657
|
-
*/
|
|
148658
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
148659
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
148660
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
148661
|
-
/**
|
|
148662
|
-
* The kind signs in through a server-held interactive session instead of
|
|
148663
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
148664
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
148665
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
148666
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
148667
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
148668
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
148669
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
148670
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
148671
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
148672
|
-
* offers it as the default path; the fields the session fills are
|
|
148673
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
148674
|
-
*
|
|
148675
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
148676
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
148677
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
148678
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
148679
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
148680
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
148681
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
148682
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
148683
|
-
* `['proxy']`.
|
|
148684
|
-
*/
|
|
148685
|
-
signIn: object({
|
|
148686
|
-
basePath: string().min(1),
|
|
148687
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
148688
|
-
}).optional()
|
|
148689
|
-
}))
|
|
148690
|
-
});
|
|
148691
|
-
var ListInputSchema = object({
|
|
148692
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
148693
|
-
* only HA brokers. Omit to list every broker. */
|
|
148694
|
-
kind: string().optional() });
|
|
148695
148600
|
var GetInputSchema = object({ id: string() });
|
|
148696
|
-
var AddInputSchema = object({
|
|
148697
|
-
kind: string().min(1),
|
|
148698
|
-
name: string().min(1),
|
|
148699
|
-
/**
|
|
148700
|
-
* ADOPT an existing id instead of minting a new one.
|
|
148701
|
-
*
|
|
148702
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
148703
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
148704
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
148705
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
148706
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
148707
|
-
* password.
|
|
148708
|
-
*
|
|
148709
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
148710
|
-
* broker's id would silently take it over.
|
|
148711
|
-
*/
|
|
148712
|
-
id: string().min(1).optional(),
|
|
148713
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
148714
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
148715
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
148716
|
-
settings: record(string(), unknown())
|
|
148717
|
-
});
|
|
148718
|
-
var AddResultSchema = object({ id: string() });
|
|
148719
|
-
var RemoveInputSchema = object({ id: string() });
|
|
148720
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
148721
|
-
ok: literal(true),
|
|
148722
|
-
latencyMs: number().nonnegative()
|
|
148723
|
-
}), object({
|
|
148724
|
-
ok: literal(false),
|
|
148725
|
-
error: string()
|
|
148726
|
-
})]);
|
|
148727
148601
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
148728
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
148729
|
-
var TestSettingsInputSchema = object({
|
|
148730
|
-
kind: string(),
|
|
148731
|
-
settings: SettingsRecordSchema$1
|
|
148732
|
-
});
|
|
148733
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
148734
|
-
ok: literal(true),
|
|
148735
|
-
latencyMs: number().nonnegative().optional()
|
|
148736
|
-
}).strict(), object({
|
|
148737
|
-
ok: literal(false),
|
|
148738
|
-
error: string()
|
|
148739
|
-
})]);
|
|
148740
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
148741
148602
|
var PublishInputSchema = object({
|
|
148742
148603
|
brokerId: string(),
|
|
148743
148604
|
/** Kind-specific routing target.
|
|
@@ -148771,25 +148632,7 @@ var GetStateInputSchema = object({
|
|
|
148771
148632
|
* HA: entity_id (returns the cached entity state). */
|
|
148772
148633
|
key: string()
|
|
148773
148634
|
});
|
|
148774
|
-
method(
|
|
148775
|
-
kind: "mutation",
|
|
148776
|
-
auth: "admin"
|
|
148777
|
-
}), method(RemoveInputSchema, _void(), {
|
|
148778
|
-
kind: "mutation",
|
|
148779
|
-
auth: "admin"
|
|
148780
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
148781
|
-
kind: "mutation",
|
|
148782
|
-
auth: "admin"
|
|
148783
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
148784
|
-
id: string(),
|
|
148785
|
-
settings: SettingsRecordSchema$1
|
|
148786
|
-
}), _void(), {
|
|
148787
|
-
kind: "mutation",
|
|
148788
|
-
auth: "admin"
|
|
148789
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
148790
|
-
kind: "mutation",
|
|
148791
|
-
auth: "admin"
|
|
148792
|
-
}), method(PublishInputSchema, unknown(), {
|
|
148635
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
148793
148636
|
kind: "mutation",
|
|
148794
148637
|
auth: "admin"
|
|
148795
148638
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -157916,7 +157759,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
157916
157759
|
"inconclusive",
|
|
157917
157760
|
"unsupported"
|
|
157918
157761
|
]);
|
|
157919
|
-
var TestConnectionResultSchema
|
|
157762
|
+
var TestConnectionResultSchema = object({
|
|
157920
157763
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
157921
157764
|
success: boolean(),
|
|
157922
157765
|
error: string().optional(),
|
|
@@ -157961,7 +157804,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
157961
157804
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
157962
157805
|
addonId: string(),
|
|
157963
157806
|
settings: record(string(), unknown())
|
|
157964
|
-
}), TestConnectionResultSchema
|
|
157807
|
+
}), TestConnectionResultSchema, {
|
|
157965
157808
|
kind: "mutation",
|
|
157966
157809
|
auth: "admin"
|
|
157967
157810
|
});
|
|
@@ -157988,6 +157831,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
157988
157831
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
157989
157832
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
157990
157833
|
/**
|
|
157834
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
157835
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
157836
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
157837
|
+
* Integrations.
|
|
157838
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
157839
|
+
*/
|
|
157840
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
157841
|
+
/**
|
|
157991
157842
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
157992
157843
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
157993
157844
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -157998,6 +157849,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
157998
157849
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
157999
157850
|
id: string().min(1),
|
|
158000
157851
|
label: string().min(1),
|
|
157852
|
+
/**
|
|
157853
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
157854
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
157855
|
+
* provider with more than one section must name it on every kind.
|
|
157856
|
+
*/
|
|
157857
|
+
functionCap: string().min(1),
|
|
157858
|
+
/**
|
|
157859
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
157860
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
157861
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
157862
|
+
*/
|
|
157863
|
+
brokerKind: string().min(1).optional(),
|
|
157864
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
157865
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
157866
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
157867
|
+
canTest: boolean().optional(),
|
|
158001
157868
|
/** The kind signs in through a server-held interactive session. */
|
|
158002
157869
|
signIn: object({
|
|
158003
157870
|
basePath: string().min(1),
|
|
@@ -158010,11 +157877,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
158010
157877
|
});
|
|
158011
157878
|
var IntegrationInstanceDescriptionSchema = object({
|
|
158012
157879
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
158013
|
-
role:
|
|
158014
|
-
"devices",
|
|
158015
|
-
"services",
|
|
158016
|
-
"both"
|
|
158017
|
-
]),
|
|
157880
|
+
role: IntegrationInstanceRoleSchema,
|
|
158018
157881
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
158019
157882
|
discovery: object({
|
|
158020
157883
|
mode: _enum([
|
|
@@ -158089,7 +157952,11 @@ var integrationInstancesCapability = {
|
|
|
158089
157952
|
methods: {
|
|
158090
157953
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
158091
157954
|
/** The form; `id: null` is the create form. */
|
|
158092
|
-
instanceFormSchema: method(object({
|
|
157955
|
+
instanceFormSchema: method(object({
|
|
157956
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
157957
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
157958
|
+
kind: string().min(1).optional()
|
|
157959
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
158093
157960
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
158094
157961
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
158095
157962
|
/**
|
|
@@ -158099,7 +157966,9 @@ var integrationInstancesCapability = {
|
|
|
158099
157966
|
createInstance: method(object({
|
|
158100
157967
|
id: IntegrationInstanceIdSchema.optional(),
|
|
158101
157968
|
name: string().min(1),
|
|
158102
|
-
kind: string().min(1).optional()
|
|
157969
|
+
kind: string().min(1).optional(),
|
|
157970
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
157971
|
+
values: record(string(), unknown()).optional()
|
|
158103
157972
|
}), object({ id: string() }), {
|
|
158104
157973
|
kind: "mutation",
|
|
158105
157974
|
auth: "admin"
|
|
@@ -158126,8 +157995,10 @@ var integrationInstancesCapability = {
|
|
|
158126
157995
|
}),
|
|
158127
157996
|
testInstance: optionalMethod(object({
|
|
158128
157997
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
158129
|
-
values: record(string(), unknown())
|
|
158130
|
-
|
|
157998
|
+
values: record(string(), unknown()),
|
|
157999
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
158000
|
+
kind: string().min(1).optional()
|
|
158001
|
+
}), TestConnectionResultSchema, {
|
|
158131
158002
|
kind: "mutation",
|
|
158132
158003
|
auth: "admin"
|
|
158133
158004
|
})
|
|
@@ -160905,6 +160776,380 @@ var SystemMetricsSchema = object({
|
|
|
160905
160776
|
gpuMemoryPercent: number().optional()
|
|
160906
160777
|
});
|
|
160907
160778
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
|
|
160779
|
+
/**
|
|
160780
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
160781
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
160782
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
160783
|
+
*
|
|
160784
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
160785
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
160786
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
160787
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
160788
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
160789
|
+
* addons go through the owner's capability.
|
|
160790
|
+
*
|
|
160791
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
160792
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
160793
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
160794
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
160795
|
+
* row's own ref.
|
|
160796
|
+
*
|
|
160797
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
160798
|
+
*/
|
|
160799
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
160800
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
160801
|
+
var RecordBodySchema = record(string(), unknown());
|
|
160802
|
+
var RecordInputSchema = object({
|
|
160803
|
+
id: RecordIdSchema,
|
|
160804
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
160805
|
+
deviceId: number().int().optional(),
|
|
160806
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
160807
|
+
at: number().int().optional(),
|
|
160808
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
160809
|
+
expiresAt: number().int().optional(),
|
|
160810
|
+
data: RecordBodySchema
|
|
160811
|
+
});
|
|
160812
|
+
var RecordViewSchema = object({
|
|
160813
|
+
id: string(),
|
|
160814
|
+
deviceId: number().int().nullable(),
|
|
160815
|
+
at: number().nullable(),
|
|
160816
|
+
expiresAt: number().nullable(),
|
|
160817
|
+
rev: number().int(),
|
|
160818
|
+
updatedAt: number(),
|
|
160819
|
+
data: RecordBodySchema
|
|
160820
|
+
});
|
|
160821
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
160822
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
160823
|
+
string(),
|
|
160824
|
+
number(),
|
|
160825
|
+
boolean(),
|
|
160826
|
+
object({ in: array(union([
|
|
160827
|
+
string(),
|
|
160828
|
+
number(),
|
|
160829
|
+
boolean()
|
|
160830
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
160831
|
+
object({
|
|
160832
|
+
gt: union([string(), number()]).optional(),
|
|
160833
|
+
gte: union([string(), number()]).optional(),
|
|
160834
|
+
lt: union([string(), number()]).optional(),
|
|
160835
|
+
lte: union([string(), number()]).optional()
|
|
160836
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
160837
|
+
]));
|
|
160838
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
160839
|
+
var TimeWindowShape = {
|
|
160840
|
+
deviceId: number().int().optional(),
|
|
160841
|
+
atFrom: number().optional(),
|
|
160842
|
+
atTo: number().optional()
|
|
160843
|
+
};
|
|
160844
|
+
var RecordQueryInputSchema = object({
|
|
160845
|
+
...KindShape,
|
|
160846
|
+
...TimeWindowShape,
|
|
160847
|
+
where: RecordWhereSchema.optional(),
|
|
160848
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
160849
|
+
order: _enum(["at", "id"]).optional(),
|
|
160850
|
+
desc: boolean().optional(),
|
|
160851
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
160852
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
160853
|
+
cursor: string().min(1).optional()
|
|
160854
|
+
});
|
|
160855
|
+
var RecordQueryResultSchema = object({
|
|
160856
|
+
records: array(RecordViewSchema),
|
|
160857
|
+
nextCursor: string().nullable()
|
|
160858
|
+
});
|
|
160859
|
+
var RecordKindStateSchema = _enum([
|
|
160860
|
+
"created",
|
|
160861
|
+
"unchanged",
|
|
160862
|
+
"updated"
|
|
160863
|
+
]);
|
|
160864
|
+
var DeclareKindResultSchema = object({
|
|
160865
|
+
kindId: number().int(),
|
|
160866
|
+
state: RecordKindStateSchema,
|
|
160867
|
+
createdIndexes: array(string())
|
|
160868
|
+
});
|
|
160869
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
160870
|
+
var SecretRefsList = array(string());
|
|
160871
|
+
/**
|
|
160872
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
160873
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
160874
|
+
*/
|
|
160875
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
160876
|
+
object({
|
|
160877
|
+
op: literal("put"),
|
|
160878
|
+
kind: RecordKindNameSchema,
|
|
160879
|
+
record: RecordInputSchema,
|
|
160880
|
+
ifRev: number().int().min(0).optional()
|
|
160881
|
+
}),
|
|
160882
|
+
object({
|
|
160883
|
+
op: literal("patch"),
|
|
160884
|
+
kind: RecordKindNameSchema,
|
|
160885
|
+
id: RecordIdSchema,
|
|
160886
|
+
data: RecordBodySchema,
|
|
160887
|
+
at: number().int().nullable().optional(),
|
|
160888
|
+
expiresAt: number().int().nullable().optional(),
|
|
160889
|
+
ifRev: number().int().min(1).optional()
|
|
160890
|
+
}),
|
|
160891
|
+
object({
|
|
160892
|
+
op: literal("delete"),
|
|
160893
|
+
kind: RecordKindNameSchema,
|
|
160894
|
+
id: RecordIdSchema
|
|
160895
|
+
})
|
|
160896
|
+
]);
|
|
160897
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
160898
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
160899
|
+
kind: "mutation",
|
|
160900
|
+
auth: "admin"
|
|
160901
|
+
}), method(object({
|
|
160902
|
+
...KindShape,
|
|
160903
|
+
id: RecordIdSchema
|
|
160904
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
160905
|
+
...KindShape,
|
|
160906
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
160907
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
160908
|
+
...KindShape,
|
|
160909
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
160910
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
160911
|
+
...KindShape,
|
|
160912
|
+
record: RecordInputSchema,
|
|
160913
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
160914
|
+
ifRev: number().int().min(0).optional()
|
|
160915
|
+
}), object({
|
|
160916
|
+
rev: number().int(),
|
|
160917
|
+
releasedRefs: SecretRefsList
|
|
160918
|
+
}), {
|
|
160919
|
+
kind: "mutation",
|
|
160920
|
+
auth: "admin"
|
|
160921
|
+
}), method(object({
|
|
160922
|
+
...KindShape,
|
|
160923
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
160924
|
+
}), object({
|
|
160925
|
+
count: number().int(),
|
|
160926
|
+
releasedRefs: SecretRefsList
|
|
160927
|
+
}), {
|
|
160928
|
+
kind: "mutation",
|
|
160929
|
+
auth: "admin"
|
|
160930
|
+
}), method(object({
|
|
160931
|
+
...KindShape,
|
|
160932
|
+
id: RecordIdSchema,
|
|
160933
|
+
data: RecordBodySchema,
|
|
160934
|
+
at: number().int().nullable().optional(),
|
|
160935
|
+
expiresAt: number().int().nullable().optional(),
|
|
160936
|
+
ifRev: number().int().min(1).optional()
|
|
160937
|
+
}), object({
|
|
160938
|
+
rev: number().int(),
|
|
160939
|
+
releasedRefs: SecretRefsList
|
|
160940
|
+
}), {
|
|
160941
|
+
kind: "mutation",
|
|
160942
|
+
auth: "admin"
|
|
160943
|
+
}), method(object({
|
|
160944
|
+
...KindShape,
|
|
160945
|
+
id: RecordIdSchema
|
|
160946
|
+
}), object({
|
|
160947
|
+
deleted: boolean(),
|
|
160948
|
+
secretRefs: SecretRefsList
|
|
160949
|
+
}), {
|
|
160950
|
+
kind: "mutation",
|
|
160951
|
+
auth: "admin"
|
|
160952
|
+
}), method(object({
|
|
160953
|
+
...KindShape,
|
|
160954
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
160955
|
+
}), object({
|
|
160956
|
+
deleted: number().int(),
|
|
160957
|
+
secretRefs: SecretRefsList
|
|
160958
|
+
}), {
|
|
160959
|
+
kind: "mutation",
|
|
160960
|
+
auth: "admin"
|
|
160961
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
160962
|
+
...KindShape,
|
|
160963
|
+
...TimeWindowShape,
|
|
160964
|
+
where: RecordWhereSchema.optional()
|
|
160965
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
160966
|
+
...KindShape,
|
|
160967
|
+
deviceId: number().int().optional(),
|
|
160968
|
+
from: number(),
|
|
160969
|
+
to: number(),
|
|
160970
|
+
bucketMs: number().int().positive()
|
|
160971
|
+
}), object({ buckets: array(object({
|
|
160972
|
+
bucketStart: number(),
|
|
160973
|
+
count: number().int()
|
|
160974
|
+
})) }), { auth: "admin" }), method(object({
|
|
160975
|
+
...KindShape,
|
|
160976
|
+
op: _enum([
|
|
160977
|
+
"sum",
|
|
160978
|
+
"min",
|
|
160979
|
+
"max",
|
|
160980
|
+
"count"
|
|
160981
|
+
]),
|
|
160982
|
+
field: RecordFieldPathSchema.optional(),
|
|
160983
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
160984
|
+
where: RecordWhereSchema.optional()
|
|
160985
|
+
}), object({ rows: array(object({
|
|
160986
|
+
group: union([
|
|
160987
|
+
string(),
|
|
160988
|
+
number(),
|
|
160989
|
+
_null()
|
|
160990
|
+
]),
|
|
160991
|
+
value: number().nullable()
|
|
160992
|
+
})) }), { auth: "admin" }), method(object({
|
|
160993
|
+
...KindShape,
|
|
160994
|
+
deviceId: number().int().optional(),
|
|
160995
|
+
atBefore: number().optional(),
|
|
160996
|
+
where: RecordWhereSchema.optional()
|
|
160997
|
+
}), object({
|
|
160998
|
+
deleted: number().int(),
|
|
160999
|
+
secretRefs: SecretRefsList
|
|
161000
|
+
}), {
|
|
161001
|
+
kind: "mutation",
|
|
161002
|
+
auth: "admin"
|
|
161003
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
161004
|
+
results: array(object({
|
|
161005
|
+
rev: number().int().nullable(),
|
|
161006
|
+
deleted: boolean()
|
|
161007
|
+
})),
|
|
161008
|
+
releasedRefs: SecretRefsList,
|
|
161009
|
+
secretRefs: SecretRefsList
|
|
161010
|
+
}), {
|
|
161011
|
+
kind: "mutation",
|
|
161012
|
+
auth: "admin"
|
|
161013
|
+
}), method(object({
|
|
161014
|
+
deviceId: number().int(),
|
|
161015
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
161016
|
+
}), object({
|
|
161017
|
+
deleted: record(string(), number().int()),
|
|
161018
|
+
secretRefs: SecretRefsList
|
|
161019
|
+
}), {
|
|
161020
|
+
kind: "mutation",
|
|
161021
|
+
auth: "admin"
|
|
161022
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
161023
|
+
kind: "mutation",
|
|
161024
|
+
auth: "admin"
|
|
161025
|
+
});
|
|
161026
|
+
/**
|
|
161027
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
161028
|
+
*
|
|
161029
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
161030
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
161031
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
161032
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
161033
|
+
*
|
|
161034
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
161035
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
161036
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
161037
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
161038
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
161039
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
161040
|
+
*/
|
|
161041
|
+
var Rows = record(string(), unknown());
|
|
161042
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
161043
|
+
var RecordId = object({ id: string().min(1) });
|
|
161044
|
+
var RecordRowSchema = object({
|
|
161045
|
+
id: string(),
|
|
161046
|
+
deviceId: number().int().nullable(),
|
|
161047
|
+
at: number().nullable(),
|
|
161048
|
+
expiresAt: number().nullable(),
|
|
161049
|
+
rev: number().int(),
|
|
161050
|
+
updatedAt: number(),
|
|
161051
|
+
data: Rows
|
|
161052
|
+
});
|
|
161053
|
+
var RecordPutShape = {
|
|
161054
|
+
id: string().min(1),
|
|
161055
|
+
deviceId: number().int().optional(),
|
|
161056
|
+
at: number().int().optional(),
|
|
161057
|
+
expiresAt: number().int().optional(),
|
|
161058
|
+
data: Rows
|
|
161059
|
+
};
|
|
161060
|
+
var MigrationIntegrationSchema = object({
|
|
161061
|
+
id: string(),
|
|
161062
|
+
addonId: string(),
|
|
161063
|
+
name: string(),
|
|
161064
|
+
info: Rows,
|
|
161065
|
+
originStableId: string().optional()
|
|
161066
|
+
});
|
|
161067
|
+
var MigrationDeviceSchema = object({
|
|
161068
|
+
id: number().int(),
|
|
161069
|
+
integrationId: string().nullable().optional(),
|
|
161070
|
+
/** The owning device; null or absent for a root. */
|
|
161071
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
161072
|
+
type: string().optional(),
|
|
161073
|
+
name: string().optional(),
|
|
161074
|
+
stableId: string().optional()
|
|
161075
|
+
});
|
|
161076
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
161077
|
+
var MigrationApiInfoSchema = object({
|
|
161078
|
+
version: number().int(),
|
|
161079
|
+
methods: array(string())
|
|
161080
|
+
});
|
|
161081
|
+
object({
|
|
161082
|
+
message: string(),
|
|
161083
|
+
meta: Rows.optional(),
|
|
161084
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
161085
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
161086
|
+
});
|
|
161087
|
+
object({
|
|
161088
|
+
owner: string().min(1),
|
|
161089
|
+
metas: array(MigrationMetaSchema)
|
|
161090
|
+
}), object({
|
|
161091
|
+
bootId: string(),
|
|
161092
|
+
snapshot: _enum([
|
|
161093
|
+
"none",
|
|
161094
|
+
"written",
|
|
161095
|
+
"refused"
|
|
161096
|
+
]),
|
|
161097
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161098
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
161099
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
161100
|
+
}), object({ id: string().min(1) }), object({
|
|
161101
|
+
proceed: boolean(),
|
|
161102
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
161103
|
+
reason: string().nullable()
|
|
161104
|
+
}), object({
|
|
161105
|
+
id: string().min(1),
|
|
161106
|
+
result: MigrationOwnerResultSchema
|
|
161107
|
+
}), object({
|
|
161108
|
+
status: MigrationStatusSchema,
|
|
161109
|
+
error: string().nullable(),
|
|
161110
|
+
rowsChanged: number().int().nonnegative()
|
|
161111
|
+
}), object({
|
|
161112
|
+
rows: number().int().nonnegative(),
|
|
161113
|
+
secrets: number().int().nonnegative()
|
|
161114
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
161115
|
+
present: boolean(),
|
|
161116
|
+
removed: Rows
|
|
161117
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
161118
|
+
...RecordPutShape,
|
|
161119
|
+
ifRev: number().int().optional()
|
|
161120
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
161121
|
+
partial: Rows,
|
|
161122
|
+
ifRev: number().int().optional()
|
|
161123
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
161124
|
+
deviceId: number().int().optional(),
|
|
161125
|
+
atFrom: number().optional(),
|
|
161126
|
+
atTo: number().optional(),
|
|
161127
|
+
where: RecordWhereSchema.optional(),
|
|
161128
|
+
limit: number().int().min(1).optional(),
|
|
161129
|
+
cursor: string().min(1).optional(),
|
|
161130
|
+
resolveSecrets: boolean().optional()
|
|
161131
|
+
}), object({
|
|
161132
|
+
records: array(RecordRowSchema),
|
|
161133
|
+
nextCursor: string().nullable()
|
|
161134
|
+
}), object({
|
|
161135
|
+
deviceId: number().int().optional(),
|
|
161136
|
+
atBefore: number().optional(),
|
|
161137
|
+
where: RecordWhereSchema.optional()
|
|
161138
|
+
}), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
|
|
161139
|
+
ref: string().min(1),
|
|
161140
|
+
value: string()
|
|
161141
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
161142
|
+
addonId: string().min(1),
|
|
161143
|
+
integrationId: string().min(1).optional()
|
|
161144
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
161145
|
+
id: number().int(),
|
|
161146
|
+
integrationId: string().nullable(),
|
|
161147
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
161148
|
+
hasConfig: boolean()
|
|
161149
|
+
}).nullable(), object({
|
|
161150
|
+
deviceId: number().int(),
|
|
161151
|
+
integrationId: string().min(1)
|
|
161152
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
160908
161153
|
method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
|
|
160909
161154
|
id: string().min(1),
|
|
160910
161155
|
error: string().min(1)
|
|
@@ -160934,7 +161179,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
160934
161179
|
"written",
|
|
160935
161180
|
"refused"
|
|
160936
161181
|
]),
|
|
160937
|
-
steps: array(MigrationOwnerStepSchema)
|
|
161182
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161183
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
161184
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
160938
161185
|
}), {
|
|
160939
161186
|
kind: "mutation",
|
|
160940
161187
|
auth: "admin"
|
|
@@ -163601,7 +163848,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
163601
163848
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
163602
163849
|
kind: "mutation",
|
|
163603
163850
|
auth: "admin"
|
|
163604
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
163851
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
163852
|
+
kind: "query",
|
|
163853
|
+
auth: "admin"
|
|
163854
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
163605
163855
|
kind: "query",
|
|
163606
163856
|
auth: "admin"
|
|
163607
163857
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -166256,7 +166506,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
166256
166506
|
"unreachable",
|
|
166257
166507
|
"tls-error"
|
|
166258
166508
|
]);
|
|
166259
|
-
var BrokerInfoSchema
|
|
166509
|
+
var BrokerInfoSchema = object({
|
|
166260
166510
|
id: string(),
|
|
166261
166511
|
name: string(),
|
|
166262
166512
|
url: string(),
|
|
@@ -166319,7 +166569,7 @@ var StatusSchema = object({
|
|
|
166319
166569
|
brokerCount: number(),
|
|
166320
166570
|
embeddedRunning: boolean()
|
|
166321
166571
|
});
|
|
166322
|
-
method(_void(), array(BrokerInfoSchema
|
|
166572
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
166323
166573
|
kind: "mutation",
|
|
166324
166574
|
auth: "admin"
|
|
166325
166575
|
}), method(IdInputSchema, _void(), {
|
|
@@ -173705,253 +173955,6 @@ var rebootCapability = {
|
|
|
173705
173955
|
}) }
|
|
173706
173956
|
};
|
|
173707
173957
|
/**
|
|
173708
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
173709
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
173710
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
173711
|
-
*
|
|
173712
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
173713
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
173714
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
173715
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
173716
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
173717
|
-
* addons go through the owner's capability.
|
|
173718
|
-
*
|
|
173719
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
173720
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
173721
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
173722
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
173723
|
-
* row's own ref.
|
|
173724
|
-
*
|
|
173725
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
173726
|
-
*/
|
|
173727
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
173728
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
173729
|
-
var RecordBodySchema = record(string(), unknown());
|
|
173730
|
-
var RecordInputSchema = object({
|
|
173731
|
-
id: RecordIdSchema,
|
|
173732
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
173733
|
-
deviceId: number().int().optional(),
|
|
173734
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
173735
|
-
at: number().int().optional(),
|
|
173736
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
173737
|
-
expiresAt: number().int().optional(),
|
|
173738
|
-
data: RecordBodySchema
|
|
173739
|
-
});
|
|
173740
|
-
var RecordViewSchema = object({
|
|
173741
|
-
id: string(),
|
|
173742
|
-
deviceId: number().int().nullable(),
|
|
173743
|
-
at: number().nullable(),
|
|
173744
|
-
expiresAt: number().nullable(),
|
|
173745
|
-
rev: number().int(),
|
|
173746
|
-
updatedAt: number(),
|
|
173747
|
-
data: RecordBodySchema
|
|
173748
|
-
});
|
|
173749
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
173750
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
173751
|
-
string(),
|
|
173752
|
-
number(),
|
|
173753
|
-
boolean(),
|
|
173754
|
-
object({ in: array(union([
|
|
173755
|
-
string(),
|
|
173756
|
-
number(),
|
|
173757
|
-
boolean()
|
|
173758
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
173759
|
-
object({
|
|
173760
|
-
gt: union([string(), number()]).optional(),
|
|
173761
|
-
gte: union([string(), number()]).optional(),
|
|
173762
|
-
lt: union([string(), number()]).optional(),
|
|
173763
|
-
lte: union([string(), number()]).optional()
|
|
173764
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
173765
|
-
]));
|
|
173766
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
173767
|
-
var TimeWindowShape = {
|
|
173768
|
-
deviceId: number().int().optional(),
|
|
173769
|
-
atFrom: number().optional(),
|
|
173770
|
-
atTo: number().optional()
|
|
173771
|
-
};
|
|
173772
|
-
var RecordQueryInputSchema = object({
|
|
173773
|
-
...KindShape,
|
|
173774
|
-
...TimeWindowShape,
|
|
173775
|
-
where: RecordWhereSchema.optional(),
|
|
173776
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
173777
|
-
order: _enum(["at", "id"]).optional(),
|
|
173778
|
-
desc: boolean().optional(),
|
|
173779
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
173780
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
173781
|
-
cursor: string().min(1).optional()
|
|
173782
|
-
});
|
|
173783
|
-
var RecordQueryResultSchema = object({
|
|
173784
|
-
records: array(RecordViewSchema),
|
|
173785
|
-
nextCursor: string().nullable()
|
|
173786
|
-
});
|
|
173787
|
-
var RecordKindStateSchema = _enum([
|
|
173788
|
-
"created",
|
|
173789
|
-
"unchanged",
|
|
173790
|
-
"updated"
|
|
173791
|
-
]);
|
|
173792
|
-
var DeclareKindResultSchema = object({
|
|
173793
|
-
kindId: number().int(),
|
|
173794
|
-
state: RecordKindStateSchema,
|
|
173795
|
-
createdIndexes: array(string())
|
|
173796
|
-
});
|
|
173797
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
173798
|
-
var SecretRefsList = array(string());
|
|
173799
|
-
/**
|
|
173800
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
173801
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
173802
|
-
*/
|
|
173803
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
173804
|
-
object({
|
|
173805
|
-
op: literal("put"),
|
|
173806
|
-
kind: RecordKindNameSchema,
|
|
173807
|
-
record: RecordInputSchema,
|
|
173808
|
-
ifRev: number().int().min(0).optional()
|
|
173809
|
-
}),
|
|
173810
|
-
object({
|
|
173811
|
-
op: literal("patch"),
|
|
173812
|
-
kind: RecordKindNameSchema,
|
|
173813
|
-
id: RecordIdSchema,
|
|
173814
|
-
data: RecordBodySchema,
|
|
173815
|
-
at: number().int().nullable().optional(),
|
|
173816
|
-
expiresAt: number().int().nullable().optional(),
|
|
173817
|
-
ifRev: number().int().min(1).optional()
|
|
173818
|
-
}),
|
|
173819
|
-
object({
|
|
173820
|
-
op: literal("delete"),
|
|
173821
|
-
kind: RecordKindNameSchema,
|
|
173822
|
-
id: RecordIdSchema
|
|
173823
|
-
})
|
|
173824
|
-
]);
|
|
173825
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
173826
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
173827
|
-
kind: "mutation",
|
|
173828
|
-
auth: "admin"
|
|
173829
|
-
}), method(object({
|
|
173830
|
-
...KindShape,
|
|
173831
|
-
id: RecordIdSchema
|
|
173832
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
173833
|
-
...KindShape,
|
|
173834
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173835
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
173836
|
-
...KindShape,
|
|
173837
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173838
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
173839
|
-
...KindShape,
|
|
173840
|
-
record: RecordInputSchema,
|
|
173841
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
173842
|
-
ifRev: number().int().min(0).optional()
|
|
173843
|
-
}), object({
|
|
173844
|
-
rev: number().int(),
|
|
173845
|
-
releasedRefs: SecretRefsList
|
|
173846
|
-
}), {
|
|
173847
|
-
kind: "mutation",
|
|
173848
|
-
auth: "admin"
|
|
173849
|
-
}), method(object({
|
|
173850
|
-
...KindShape,
|
|
173851
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173852
|
-
}), object({
|
|
173853
|
-
count: number().int(),
|
|
173854
|
-
releasedRefs: SecretRefsList
|
|
173855
|
-
}), {
|
|
173856
|
-
kind: "mutation",
|
|
173857
|
-
auth: "admin"
|
|
173858
|
-
}), method(object({
|
|
173859
|
-
...KindShape,
|
|
173860
|
-
id: RecordIdSchema,
|
|
173861
|
-
data: RecordBodySchema,
|
|
173862
|
-
at: number().int().nullable().optional(),
|
|
173863
|
-
expiresAt: number().int().nullable().optional(),
|
|
173864
|
-
ifRev: number().int().min(1).optional()
|
|
173865
|
-
}), object({
|
|
173866
|
-
rev: number().int(),
|
|
173867
|
-
releasedRefs: SecretRefsList
|
|
173868
|
-
}), {
|
|
173869
|
-
kind: "mutation",
|
|
173870
|
-
auth: "admin"
|
|
173871
|
-
}), method(object({
|
|
173872
|
-
...KindShape,
|
|
173873
|
-
id: RecordIdSchema
|
|
173874
|
-
}), object({
|
|
173875
|
-
deleted: boolean(),
|
|
173876
|
-
secretRefs: SecretRefsList
|
|
173877
|
-
}), {
|
|
173878
|
-
kind: "mutation",
|
|
173879
|
-
auth: "admin"
|
|
173880
|
-
}), method(object({
|
|
173881
|
-
...KindShape,
|
|
173882
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173883
|
-
}), object({
|
|
173884
|
-
deleted: number().int(),
|
|
173885
|
-
secretRefs: SecretRefsList
|
|
173886
|
-
}), {
|
|
173887
|
-
kind: "mutation",
|
|
173888
|
-
auth: "admin"
|
|
173889
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
173890
|
-
...KindShape,
|
|
173891
|
-
...TimeWindowShape,
|
|
173892
|
-
where: RecordWhereSchema.optional()
|
|
173893
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
173894
|
-
...KindShape,
|
|
173895
|
-
deviceId: number().int().optional(),
|
|
173896
|
-
from: number(),
|
|
173897
|
-
to: number(),
|
|
173898
|
-
bucketMs: number().int().positive()
|
|
173899
|
-
}), object({ buckets: array(object({
|
|
173900
|
-
bucketStart: number(),
|
|
173901
|
-
count: number().int()
|
|
173902
|
-
})) }), { auth: "admin" }), method(object({
|
|
173903
|
-
...KindShape,
|
|
173904
|
-
op: _enum([
|
|
173905
|
-
"sum",
|
|
173906
|
-
"min",
|
|
173907
|
-
"max",
|
|
173908
|
-
"count"
|
|
173909
|
-
]),
|
|
173910
|
-
field: RecordFieldPathSchema.optional(),
|
|
173911
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
173912
|
-
where: RecordWhereSchema.optional()
|
|
173913
|
-
}), object({ rows: array(object({
|
|
173914
|
-
group: union([
|
|
173915
|
-
string(),
|
|
173916
|
-
number(),
|
|
173917
|
-
_null()
|
|
173918
|
-
]),
|
|
173919
|
-
value: number().nullable()
|
|
173920
|
-
})) }), { auth: "admin" }), method(object({
|
|
173921
|
-
...KindShape,
|
|
173922
|
-
deviceId: number().int().optional(),
|
|
173923
|
-
atBefore: number().optional(),
|
|
173924
|
-
where: RecordWhereSchema.optional()
|
|
173925
|
-
}), object({
|
|
173926
|
-
deleted: number().int(),
|
|
173927
|
-
secretRefs: SecretRefsList
|
|
173928
|
-
}), {
|
|
173929
|
-
kind: "mutation",
|
|
173930
|
-
auth: "admin"
|
|
173931
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
173932
|
-
results: array(object({
|
|
173933
|
-
rev: number().int().nullable(),
|
|
173934
|
-
deleted: boolean()
|
|
173935
|
-
})),
|
|
173936
|
-
releasedRefs: SecretRefsList,
|
|
173937
|
-
secretRefs: SecretRefsList
|
|
173938
|
-
}), {
|
|
173939
|
-
kind: "mutation",
|
|
173940
|
-
auth: "admin"
|
|
173941
|
-
}), method(object({
|
|
173942
|
-
deviceId: number().int(),
|
|
173943
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
173944
|
-
}), object({
|
|
173945
|
-
deleted: record(string(), number().int()),
|
|
173946
|
-
secretRefs: SecretRefsList
|
|
173947
|
-
}), {
|
|
173948
|
-
kind: "mutation",
|
|
173949
|
-
auth: "admin"
|
|
173950
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
173951
|
-
kind: "mutation",
|
|
173952
|
-
auth: "admin"
|
|
173953
|
-
});
|
|
173954
|
-
/**
|
|
173955
173958
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
173956
173959
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
173957
173960
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -186240,20 +186243,6 @@ Object.freeze({
|
|
|
186240
186243
|
access: "create",
|
|
186241
186244
|
role: "viewer"
|
|
186242
186245
|
},
|
|
186243
|
-
"broker.add": {
|
|
186244
|
-
capName: "broker",
|
|
186245
|
-
capScope: "system",
|
|
186246
|
-
addonId: null,
|
|
186247
|
-
access: "create",
|
|
186248
|
-
role: "admin"
|
|
186249
|
-
},
|
|
186250
|
-
"broker.get": {
|
|
186251
|
-
capName: "broker",
|
|
186252
|
-
capScope: "system",
|
|
186253
|
-
addonId: null,
|
|
186254
|
-
access: "view",
|
|
186255
|
-
role: "admin"
|
|
186256
|
-
},
|
|
186257
186246
|
"broker.getBrokerConfig": {
|
|
186258
186247
|
capName: "broker",
|
|
186259
186248
|
capScope: "system",
|
|
@@ -186261,20 +186250,6 @@ Object.freeze({
|
|
|
186261
186250
|
access: "view",
|
|
186262
186251
|
role: "admin"
|
|
186263
186252
|
},
|
|
186264
|
-
"broker.getSettings": {
|
|
186265
|
-
capName: "broker",
|
|
186266
|
-
capScope: "system",
|
|
186267
|
-
addonId: null,
|
|
186268
|
-
access: "view",
|
|
186269
|
-
role: "admin"
|
|
186270
|
-
},
|
|
186271
|
-
"broker.getSettingsSchema": {
|
|
186272
|
-
capName: "broker",
|
|
186273
|
-
capScope: "system",
|
|
186274
|
-
addonId: null,
|
|
186275
|
-
access: "view",
|
|
186276
|
-
role: "admin"
|
|
186277
|
-
},
|
|
186278
186253
|
"broker.getState": {
|
|
186279
186254
|
capName: "broker",
|
|
186280
186255
|
capScope: "system",
|
|
@@ -186289,20 +186264,6 @@ Object.freeze({
|
|
|
186289
186264
|
access: "view",
|
|
186290
186265
|
role: "admin"
|
|
186291
186266
|
},
|
|
186292
|
-
"broker.list": {
|
|
186293
|
-
capName: "broker",
|
|
186294
|
-
capScope: "system",
|
|
186295
|
-
addonId: null,
|
|
186296
|
-
access: "view",
|
|
186297
|
-
role: "admin"
|
|
186298
|
-
},
|
|
186299
|
-
"broker.listProviders": {
|
|
186300
|
-
capName: "broker",
|
|
186301
|
-
capScope: "system",
|
|
186302
|
-
addonId: null,
|
|
186303
|
-
access: "view",
|
|
186304
|
-
role: "admin"
|
|
186305
|
-
},
|
|
186306
186267
|
"broker.publish": {
|
|
186307
186268
|
capName: "broker",
|
|
186308
186269
|
capScope: "system",
|
|
@@ -186310,20 +186271,6 @@ Object.freeze({
|
|
|
186310
186271
|
access: "create",
|
|
186311
186272
|
role: "admin"
|
|
186312
186273
|
},
|
|
186313
|
-
"broker.remove": {
|
|
186314
|
-
capName: "broker",
|
|
186315
|
-
capScope: "system",
|
|
186316
|
-
addonId: null,
|
|
186317
|
-
access: "delete",
|
|
186318
|
-
role: "admin"
|
|
186319
|
-
},
|
|
186320
|
-
"broker.setSettings": {
|
|
186321
|
-
capName: "broker",
|
|
186322
|
-
capScope: "system",
|
|
186323
|
-
addonId: null,
|
|
186324
|
-
access: "create",
|
|
186325
|
-
role: "admin"
|
|
186326
|
-
},
|
|
186327
186274
|
"broker.subscribe": {
|
|
186328
186275
|
capName: "broker",
|
|
186329
186276
|
capScope: "system",
|
|
@@ -186331,20 +186278,6 @@ Object.freeze({
|
|
|
186331
186278
|
access: "create",
|
|
186332
186279
|
role: "admin"
|
|
186333
186280
|
},
|
|
186334
|
-
"broker.testConnection": {
|
|
186335
|
-
capName: "broker",
|
|
186336
|
-
capScope: "system",
|
|
186337
|
-
addonId: null,
|
|
186338
|
-
access: "create",
|
|
186339
|
-
role: "admin"
|
|
186340
|
-
},
|
|
186341
|
-
"broker.testSettings": {
|
|
186342
|
-
capName: "broker",
|
|
186343
|
-
capScope: "system",
|
|
186344
|
-
addonId: null,
|
|
186345
|
-
access: "create",
|
|
186346
|
-
role: "admin"
|
|
186347
|
-
},
|
|
186348
186281
|
"broker.unsubscribe": {
|
|
186349
186282
|
capName: "broker",
|
|
186350
186283
|
capScope: "system",
|
|
@@ -191308,6 +191241,13 @@ Object.freeze({
|
|
|
191308
191241
|
access: "view",
|
|
191309
191242
|
role: "viewer"
|
|
191310
191243
|
},
|
|
191244
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
191245
|
+
capName: "pipeline-analytics",
|
|
191246
|
+
capScope: "device",
|
|
191247
|
+
addonId: null,
|
|
191248
|
+
access: "view",
|
|
191249
|
+
role: "admin"
|
|
191250
|
+
},
|
|
191311
191251
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
191312
191252
|
capName: "pipeline-analytics",
|
|
191313
191253
|
capScope: "device",
|
|
@@ -200452,6 +200392,7 @@ object({
|
|
|
200452
200392
|
delay: number().nonnegative().optional(),
|
|
200453
200393
|
commands: record(string(), unknown())
|
|
200454
200394
|
});
|
|
200395
|
+
entryBody({ brokerId: string() });
|
|
200455
200396
|
//#endregion
|
|
200456
200397
|
//#region src/clips/clip-prefetch.ts
|
|
200457
200398
|
/** The longest a device may stay quiet after refusals, whatever its interval. */
|
|
@@ -220929,17 +220870,29 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
|
|
|
220929
220870
|
var REOLINK_SUBSCRIBER_ID = "provider-reolink";
|
|
220930
220871
|
var MAILBOX_NAME = "Camera mailbox";
|
|
220931
220872
|
var RECIPIENT_PREFIX = "cam-";
|
|
220932
|
-
/**
|
|
220873
|
+
/**
|
|
220874
|
+
* The real port: the mailboxes are `integration-instances` of the SMTP addon (the kind of its
|
|
220875
|
+
* `broker` section, found from its description, D1013); pub/sub goes through `ctx.api.broker`.
|
|
220876
|
+
* Every call is routed to the addon that owns the kind.
|
|
220877
|
+
*/
|
|
220933
220878
|
function createBrokerPort(api) {
|
|
220934
220879
|
const route = { addonId: SMTP_BROKER_ADDON_ID };
|
|
220880
|
+
const mailboxKind = async () => {
|
|
220881
|
+
const kind = (await api.integrationInstances.describe.query(route)).kinds?.find((k) => k.functionCap === "broker" && (k.brokerKind ?? k.id) === "smtp-inbound");
|
|
220882
|
+
if (kind === void 0) throw new Error("the SMTP addon declares no mailbox kind");
|
|
220883
|
+
return kind.id;
|
|
220884
|
+
};
|
|
220935
220885
|
return {
|
|
220936
|
-
list: async () =>
|
|
220937
|
-
|
|
220938
|
-
kind
|
|
220939
|
-
|
|
220886
|
+
list: async () => {
|
|
220887
|
+
const kind = await mailboxKind();
|
|
220888
|
+
return (await api.integrationInstances.listInstances.query(route)).filter((instance) => instance.kind === kind);
|
|
220889
|
+
},
|
|
220890
|
+
add: async ({ id, name, settings }) => api.integrationInstances.createInstance.mutate({
|
|
220891
|
+
...route,
|
|
220940
220892
|
id,
|
|
220941
|
-
|
|
220942
|
-
|
|
220893
|
+
name,
|
|
220894
|
+
kind: await mailboxKind(),
|
|
220895
|
+
values: { ...settings }
|
|
220943
220896
|
}),
|
|
220944
220897
|
getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
|
|
220945
220898
|
id,
|