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