@camstack/addon-export-alexa 1.2.181 → 1.2.183
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 +12 -0
- package/dist/export-alexa.addon.js +797 -289
- package/dist/export-alexa.addon.mjs +797 -289
- package/package.json +2 -2
|
@@ -5987,7 +5987,7 @@ var ZodIssueCode = {
|
|
|
5987
5987
|
var ZodFirstPartyTypeKind;
|
|
5988
5988
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5989
5989
|
//#endregion
|
|
5990
|
-
//#region ../types/dist/sleep-
|
|
5990
|
+
//#region ../types/dist/sleep-BaWhXZFm.mjs
|
|
5991
5991
|
/**
|
|
5992
5992
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5993
5993
|
* window to float samples (D455).
|
|
@@ -6999,7 +6999,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
|
6999
6999
|
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
7000
7000
|
return out;
|
|
7001
7001
|
}
|
|
7002
|
-
function rowId$
|
|
7002
|
+
function rowId$2(row, idKey) {
|
|
7003
7003
|
const raw = row[idKey];
|
|
7004
7004
|
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
7005
7005
|
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
@@ -7016,7 +7016,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7016
7016
|
}
|
|
7017
7017
|
const storedById = /* @__PURE__ */ new Map();
|
|
7018
7018
|
for (const row of storedRows) {
|
|
7019
|
-
const id = rowId$
|
|
7019
|
+
const id = rowId$2(row, node.idKey);
|
|
7020
7020
|
if (id !== null) storedById.set(id, row);
|
|
7021
7021
|
}
|
|
7022
7022
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -7026,13 +7026,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7026
7026
|
rows.push(row);
|
|
7027
7027
|
continue;
|
|
7028
7028
|
}
|
|
7029
|
-
const id = rowId$
|
|
7029
|
+
const id = rowId$2(row, node.idKey) ?? ctx.mintId();
|
|
7030
7030
|
kept.add(id);
|
|
7031
7031
|
const withId = {
|
|
7032
7032
|
...row,
|
|
7033
7033
|
[node.idKey]: row[node.idKey] ?? id
|
|
7034
7034
|
};
|
|
7035
|
-
if (rowId$
|
|
7035
|
+
if (rowId$2(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7036
7036
|
const storedRow = storedById.get(id) ?? {};
|
|
7037
7037
|
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
7038
7038
|
}
|
|
@@ -8830,6 +8830,10 @@ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
|
8830
8830
|
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8831
8831
|
* (`auth.accessToken`, `headers[].value`).
|
|
8832
8832
|
*
|
|
8833
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8834
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8835
|
+
* key releases exactly that key's secret.
|
|
8836
|
+
*
|
|
8833
8837
|
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8834
8838
|
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8835
8839
|
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
@@ -8842,11 +8846,13 @@ function parseSecretPath(path) {
|
|
|
8842
8846
|
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8843
8847
|
return path.split(".").map((raw) => {
|
|
8844
8848
|
const each = raw.endsWith("[]");
|
|
8845
|
-
const
|
|
8849
|
+
const map = raw.endsWith("{}");
|
|
8850
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8846
8851
|
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8847
8852
|
return {
|
|
8848
8853
|
key,
|
|
8849
|
-
each
|
|
8854
|
+
each,
|
|
8855
|
+
map
|
|
8850
8856
|
};
|
|
8851
8857
|
});
|
|
8852
8858
|
}
|
|
@@ -8898,6 +8904,22 @@ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arra
|
|
|
8898
8904
|
[segment.key]: mapped
|
|
8899
8905
|
};
|
|
8900
8906
|
}
|
|
8907
|
+
if (segment.map) {
|
|
8908
|
+
if (!isRecord$4(child)) return node;
|
|
8909
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
8910
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
8911
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
8912
|
+
return [mapKey, visit({
|
|
8913
|
+
declared,
|
|
8914
|
+
concrete,
|
|
8915
|
+
value
|
|
8916
|
+
})];
|
|
8917
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
8918
|
+
return {
|
|
8919
|
+
...node,
|
|
8920
|
+
[segment.key]: Object.fromEntries(kept)
|
|
8921
|
+
};
|
|
8922
|
+
}
|
|
8901
8923
|
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8902
8924
|
if (last) {
|
|
8903
8925
|
const replacement = visit({
|
|
@@ -9039,7 +9061,8 @@ function isZodSecret(schema) {
|
|
|
9039
9061
|
}
|
|
9040
9062
|
/**
|
|
9041
9063
|
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9042
|
-
* element of this array" (`connection.password`, `rows[].token`)
|
|
9064
|
+
* element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
|
|
9065
|
+
* map" (`applianceSecrets{}`). A declared
|
|
9043
9066
|
* object or array is reported as one path and not descended into — everything
|
|
9044
9067
|
* under it is secret.
|
|
9045
9068
|
*/
|
|
@@ -9050,6 +9073,7 @@ function collectZodSecretPaths(schema, prefix = "") {
|
|
|
9050
9073
|
const def = defOf(layer);
|
|
9051
9074
|
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9052
9075
|
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9076
|
+
else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
|
|
9053
9077
|
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9054
9078
|
else if (def.type === "intersection") {
|
|
9055
9079
|
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
@@ -9189,7 +9213,7 @@ function defineRecordKinds(specs) {
|
|
|
9189
9213
|
retention: spec.retention,
|
|
9190
9214
|
deviceRemoval: spec.deviceRemoval,
|
|
9191
9215
|
maxDataBytes: spec.maxDataBytes,
|
|
9192
|
-
secretPaths: [...secretPaths],
|
|
9216
|
+
secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
|
|
9193
9217
|
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
9194
9218
|
transactFamily: spec.transactFamily,
|
|
9195
9219
|
entry: spec.entry === void 0 ? void 0 : {
|
|
@@ -9220,6 +9244,7 @@ function defineEntryKind(name, spec) {
|
|
|
9220
9244
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9221
9245
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9222
9246
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
9247
|
+
...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
|
|
9223
9248
|
entry: {
|
|
9224
9249
|
title: spec.title,
|
|
9225
9250
|
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
@@ -11903,7 +11928,7 @@ object({
|
|
|
11903
11928
|
params: record(string(), union([string(), number()])).optional()
|
|
11904
11929
|
});
|
|
11905
11930
|
//#endregion
|
|
11906
|
-
//#region ../types/dist/composition-
|
|
11931
|
+
//#region ../types/dist/composition-CRNwcFYY.mjs
|
|
11907
11932
|
/**
|
|
11908
11933
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11909
11934
|
*
|
|
@@ -12666,38 +12691,6 @@ function validateExpressionSource(src) {
|
|
|
12666
12691
|
return null;
|
|
12667
12692
|
}
|
|
12668
12693
|
/**
|
|
12669
|
-
* One power reading becomes a washer, dryer or dishwasher (D944 helper).
|
|
12670
|
-
*
|
|
12671
|
-
* Standby of the control board is under 5 W; a motor or a heater is far
|
|
12672
|
-
* above that, so 5 W is the line. A door lock or a short pump spike is not
|
|
12673
|
-
* a cycle, so running starts only after 30 s above the line.
|
|
12674
|
-
*
|
|
12675
|
-
* A wash, dry or dishwasher pause (soak, heat-wait, heater off between
|
|
12676
|
-
* bursts) lasts several minutes. Ending the cycle on the first dip would
|
|
12677
|
-
* report "finished" in the middle of the program, so the stop dwell is
|
|
12678
|
-
* 10 minutes on every type. The number is stored per type so one machine
|
|
12679
|
-
* can move later without moving the others.
|
|
12680
|
-
*/
|
|
12681
|
-
var APPLIANCE_TEMPLATE_ID = "appliance";
|
|
12682
|
-
var APPLIANCE_KINDS = [
|
|
12683
|
-
"washer",
|
|
12684
|
-
"dryer",
|
|
12685
|
-
"dishwasher"
|
|
12686
|
-
];
|
|
12687
|
-
DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
|
|
12688
|
-
/**
|
|
12689
|
-
* A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
|
|
12690
|
-
*
|
|
12691
|
-
* The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
|
|
12692
|
-
* (D967), so the heater switches exactly as the plug does. Running is the
|
|
12693
|
-
* plug being on; when a power reading is also named, running is the draw
|
|
12694
|
-
* staying above the line instead (a plug left on with the stove's own
|
|
12695
|
-
* thermostat open is not heating). 50 W is far above any standby and below
|
|
12696
|
-
* the smallest radiator.
|
|
12697
|
-
*/
|
|
12698
|
-
var HEATER_TEMPLATE_ID = "heater";
|
|
12699
|
-
DeviceType.Heater;
|
|
12700
|
-
/**
|
|
12701
12694
|
* Statistics and integrals over a history read (D944).
|
|
12702
12695
|
*
|
|
12703
12696
|
* Pure: the same points always give the same answer, so a restart recomputes
|
|
@@ -12841,34 +12834,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
|
|
|
12841
12834
|
/** Actuator groups only. Readings leave this unset. */
|
|
12842
12835
|
active: ActiveCriterionSchema.optional()
|
|
12843
12836
|
}),
|
|
12844
|
-
object({
|
|
12845
|
-
kind: literal("appliance"),
|
|
12846
|
-
templateId: literal(APPLIANCE_TEMPLATE_ID),
|
|
12847
|
-
appliance: _enum(APPLIANCE_KINDS),
|
|
12848
|
-
thresholdWatts: number().positive(),
|
|
12849
|
-
startDwellMs: number().int().nonnegative(),
|
|
12850
|
-
stopDwellMs: number().int().nonnegative(),
|
|
12851
|
-
member: HelperMemberSchema,
|
|
12852
|
-
/**
|
|
12853
|
-
* The plug that powers the appliance (`switch.on`). Optional: when set, the
|
|
12854
|
-
* composition carries a `power-source` feature, so the hub can cut and restore
|
|
12855
|
-
* that plug (power-source link of a NEW-target composition).
|
|
12856
|
-
*/
|
|
12857
|
-
powerSwitch: HelperMemberSchema.optional(),
|
|
12858
|
-
/** How long a forced restart keeps the plug off; the cap's default when unset. */
|
|
12859
|
-
offSeconds: number().optional()
|
|
12860
|
-
}),
|
|
12861
|
-
object({
|
|
12862
|
-
kind: literal("heater"),
|
|
12863
|
-
templateId: literal(HEATER_TEMPLATE_ID),
|
|
12864
|
-
/** The plug, read and commanded at `switch.on`. */
|
|
12865
|
-
plug: HelperMemberSchema,
|
|
12866
|
-
/** The plug's power reading, when it has one: running is then the draw, not the switch. */
|
|
12867
|
-
meter: HelperMemberSchema.optional(),
|
|
12868
|
-
thresholdWatts: number().positive(),
|
|
12869
|
-
startDwellMs: number().int().nonnegative(),
|
|
12870
|
-
stopDwellMs: number().int().nonnegative()
|
|
12871
|
-
}),
|
|
12872
12837
|
object({
|
|
12873
12838
|
kind: literal("statistic"),
|
|
12874
12839
|
stat: _enum(STATISTIC_STATS),
|
|
@@ -13092,7 +13057,7 @@ var CompositionSchema = object({
|
|
|
13092
13057
|
kind: literal("existing"),
|
|
13093
13058
|
device: CompositionSourceRefSchema
|
|
13094
13059
|
})]),
|
|
13095
|
-
features: array(CompositionFeatureSchema).min(
|
|
13060
|
+
features: array(CompositionFeatureSchema).min(0).max(16),
|
|
13096
13061
|
/**
|
|
13097
13062
|
* Present when the block is a helper template. Absent on a free
|
|
13098
13063
|
* composition (the room example, device 4603). The editor reads this,
|
|
@@ -13427,11 +13392,49 @@ function buildCapturingReply(envelope) {
|
|
|
13427
13392
|
};
|
|
13428
13393
|
return wrapper;
|
|
13429
13394
|
}
|
|
13395
|
+
/**
|
|
13396
|
+
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13397
|
+
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13398
|
+
*
|
|
13399
|
+
* Every instance is one record of the addon's own kind, keyed by the
|
|
13400
|
+
* `integrations` registry id. The records door does the secret work: a field the
|
|
13401
|
+
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13402
|
+
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13403
|
+
*
|
|
13404
|
+
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13405
|
+
* token or the view the form was given KEEP the stored secret;
|
|
13406
|
+
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13407
|
+
*/
|
|
13430
13408
|
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13431
13409
|
var INSTANCES_LIST_MAX = 1e3;
|
|
13432
13410
|
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13433
13411
|
function topLevelSecretKeys(paths) {
|
|
13434
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[")));
|
|
13412
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13413
|
+
}
|
|
13414
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13415
|
+
function secretMapKeys(paths) {
|
|
13416
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13417
|
+
}
|
|
13418
|
+
/**
|
|
13419
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13420
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13421
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13422
|
+
*/
|
|
13423
|
+
function secretMapPatch(value) {
|
|
13424
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13425
|
+
const out = {};
|
|
13426
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13427
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13428
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
13429
|
+
}
|
|
13430
|
+
/** Does the kind's body schema carry an `enabled` field? */
|
|
13431
|
+
function declaresEnabled(kind) {
|
|
13432
|
+
const json = toJSONSchema(kind.schema, {
|
|
13433
|
+
unrepresentable: "any",
|
|
13434
|
+
io: "input"
|
|
13435
|
+
});
|
|
13436
|
+
const properties = Reflect.get(json, "properties");
|
|
13437
|
+
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13435
13438
|
}
|
|
13436
13439
|
var RecordIntegrationInstances = class {
|
|
13437
13440
|
records;
|
|
@@ -13439,14 +13442,20 @@ var RecordIntegrationInstances = class {
|
|
|
13439
13442
|
hooks;
|
|
13440
13443
|
handle;
|
|
13441
13444
|
secretKeys;
|
|
13445
|
+
secretMaps;
|
|
13442
13446
|
nameField;
|
|
13447
|
+
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13448
|
+
registryOwnsEnabled;
|
|
13443
13449
|
constructor(records, kind, hooks) {
|
|
13444
13450
|
this.records = records;
|
|
13445
13451
|
this.kind = kind;
|
|
13446
13452
|
this.hooks = hooks;
|
|
13447
13453
|
this.handle = records.kind(kind);
|
|
13448
13454
|
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13455
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13449
13456
|
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13457
|
+
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13458
|
+
if (this.registryOwnsEnabled && declaresEnabled(kind)) throw new Error(`kind "${kind.name}": the integrations registry owns the on/off switch of a role "devices" addon, so the body must not declare "enabled"`);
|
|
13450
13459
|
}
|
|
13451
13460
|
/**
|
|
13452
13461
|
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
@@ -13491,15 +13500,23 @@ var RecordIntegrationInstances = class {
|
|
|
13491
13500
|
viewOf(record) {
|
|
13492
13501
|
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13493
13502
|
const rawName = record.data[this.nameField];
|
|
13503
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
13504
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
13494
13505
|
return {
|
|
13495
13506
|
id: record.id,
|
|
13496
13507
|
name: typeof rawName === "string" ? rawName : record.id,
|
|
13497
13508
|
configured: this.hooks.configured(record.data),
|
|
13498
|
-
enabled: record.data.enabled !== false,
|
|
13499
|
-
formValues: shown
|
|
13509
|
+
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13510
|
+
formValues: shown,
|
|
13511
|
+
...kind !== void 0 ? { kind } : {},
|
|
13512
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13513
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13500
13514
|
};
|
|
13501
13515
|
}
|
|
13502
|
-
describe = async () => this.hooks.description
|
|
13516
|
+
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13517
|
+
...this.hooks.description,
|
|
13518
|
+
mintsId: true
|
|
13519
|
+
};
|
|
13503
13520
|
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13504
13521
|
listInstances = async () => {
|
|
13505
13522
|
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
@@ -13509,37 +13526,46 @@ var RecordIntegrationInstances = class {
|
|
|
13509
13526
|
return record === null ? null : this.viewOf(record);
|
|
13510
13527
|
};
|
|
13511
13528
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13512
|
-
createInstance = async ({ id, name }) => {
|
|
13529
|
+
createInstance = async ({ id, name, kind }) => {
|
|
13530
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
13531
|
+
name,
|
|
13532
|
+
...kind !== void 0 ? { kind } : {}
|
|
13533
|
+
});
|
|
13534
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13513
13535
|
await this.handle.put({
|
|
13514
|
-
id,
|
|
13515
|
-
data: this.hooks.initialBody(name)
|
|
13536
|
+
id: minted,
|
|
13537
|
+
data: this.hooks.initialBody(name, kind)
|
|
13516
13538
|
}, { ifRev: 0 });
|
|
13517
|
-
await this.hooks.onChanged?.(
|
|
13518
|
-
return { id };
|
|
13539
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
13540
|
+
return { id: minted };
|
|
13519
13541
|
};
|
|
13520
13542
|
updateInstance = async ({ id, name, values }) => {
|
|
13521
13543
|
const patch = {};
|
|
13522
13544
|
for (const [key, value] of Object.entries(values)) {
|
|
13523
13545
|
if (value === void 0) continue;
|
|
13524
|
-
if (
|
|
13546
|
+
if (this.secretMaps.has(key)) {
|
|
13547
|
+
const entries = secretMapPatch(value);
|
|
13548
|
+
if (entries !== null) patch[key] = entries;
|
|
13549
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13525
13550
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13526
13551
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13527
13552
|
}
|
|
13528
13553
|
if (name !== void 0) patch[this.nameField] = name;
|
|
13529
13554
|
await this.handle.patch(id, patch);
|
|
13530
|
-
await this.hooks.onChanged?.(id);
|
|
13555
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13531
13556
|
return { ok: true };
|
|
13532
13557
|
};
|
|
13533
13558
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13534
13559
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13560
|
+
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13535
13561
|
await this.handle.patch(id, { enabled });
|
|
13536
|
-
await this.hooks.onChanged?.(id);
|
|
13562
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
13537
13563
|
return { ok: true };
|
|
13538
13564
|
};
|
|
13539
13565
|
/** The row and its keychain refs go together (the records door). */
|
|
13540
13566
|
deleteInstance = async ({ id }) => {
|
|
13541
13567
|
await this.handle.delete(id);
|
|
13542
|
-
await this.hooks.onChanged?.(id);
|
|
13568
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
13543
13569
|
return { ok: true };
|
|
13544
13570
|
};
|
|
13545
13571
|
testInstance = async (input) => {
|
|
@@ -49236,49 +49262,6 @@ function actuator(input) {
|
|
|
49236
49262
|
};
|
|
49237
49263
|
}
|
|
49238
49264
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
49239
|
-
var PowerSourceRefusalReasonSchema = _enum([
|
|
49240
|
-
"no-power-source",
|
|
49241
|
-
"switch-missing",
|
|
49242
|
-
"switch-offline",
|
|
49243
|
-
"switch-unknown",
|
|
49244
|
-
"restart-in-progress",
|
|
49245
|
-
"switch-call-failed"
|
|
49246
|
-
]);
|
|
49247
|
-
var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
|
|
49248
|
-
accepted: literal(false),
|
|
49249
|
-
reason: PowerSourceRefusalReasonSchema,
|
|
49250
|
-
/** One line for the operator, naming the switch. */
|
|
49251
|
-
message: string()
|
|
49252
|
-
})]);
|
|
49253
|
-
var PowerSourceInfoSchema = object({
|
|
49254
|
-
/** False when the device has no power source linked; the rest is then empty. */
|
|
49255
|
-
linked: boolean(),
|
|
49256
|
-
switchDeviceId: number().nullable(),
|
|
49257
|
-
switchName: string().nullable(),
|
|
49258
|
-
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
49259
|
-
switchOn: boolean().nullable(),
|
|
49260
|
-
switchOnline: boolean().nullable(),
|
|
49261
|
-
restartInProgress: boolean(),
|
|
49262
|
-
offSeconds: number().int()
|
|
49263
|
-
});
|
|
49264
|
-
object({
|
|
49265
|
-
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
49266
|
-
switchOn: boolean().nullable(),
|
|
49267
|
-
offSeconds: number().int(),
|
|
49268
|
-
lastFetchedAt: number()
|
|
49269
|
-
});
|
|
49270
|
-
DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater;
|
|
49271
|
-
var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
|
|
49272
|
-
systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49273
|
-
kind: "mutation",
|
|
49274
|
-
auth: "admin"
|
|
49275
|
-
}), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49276
|
-
kind: "mutation",
|
|
49277
|
-
auth: "admin"
|
|
49278
|
-
}), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49279
|
-
kind: "mutation",
|
|
49280
|
-
auth: "admin"
|
|
49281
|
-
});
|
|
49282
49265
|
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
49283
49266
|
DeviceType.Camera;
|
|
49284
49267
|
`${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
|
|
@@ -49306,6 +49289,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
49306
49289
|
}).optional()
|
|
49307
49290
|
})) });
|
|
49308
49291
|
/**
|
|
49292
|
+
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
49293
|
+
* `z.infer`, they do not restate the shape.
|
|
49294
|
+
*/
|
|
49295
|
+
var OverrideSourceSchema = object({
|
|
49296
|
+
addonId: string().min(1),
|
|
49297
|
+
stableId: string().min(1),
|
|
49298
|
+
cap: string().min(1),
|
|
49299
|
+
fieldPath: string().min(1)
|
|
49300
|
+
});
|
|
49301
|
+
var IdentityTransformDraftSchema = object({ kind: literal("identity") });
|
|
49302
|
+
var InvertTransformDraftSchema = object({ kind: literal("invert") });
|
|
49303
|
+
var ThresholdTransformDraftSchema = object({
|
|
49304
|
+
kind: literal("threshold"),
|
|
49305
|
+
comparison: _enum(["gte", "lte"]),
|
|
49306
|
+
threshold: number(),
|
|
49307
|
+
startDwellMs: number().nonnegative(),
|
|
49308
|
+
stopDwellMs: number().nonnegative()
|
|
49309
|
+
});
|
|
49310
|
+
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49311
|
+
IdentityTransformDraftSchema,
|
|
49312
|
+
InvertTransformDraftSchema,
|
|
49313
|
+
ThresholdTransformDraftSchema,
|
|
49314
|
+
object({
|
|
49315
|
+
kind: literal("linear"),
|
|
49316
|
+
scale: number(),
|
|
49317
|
+
offset: number(),
|
|
49318
|
+
clampMin: number().optional(),
|
|
49319
|
+
clampMax: number().optional()
|
|
49320
|
+
}),
|
|
49321
|
+
object({
|
|
49322
|
+
kind: literal("enum-map"),
|
|
49323
|
+
mapping: record(string(), string().nullable())
|
|
49324
|
+
}),
|
|
49325
|
+
object({ kind: literal("number") })
|
|
49326
|
+
]);
|
|
49327
|
+
var ScalarOverrideDraftSchema = object({
|
|
49328
|
+
kind: literal("scalar"),
|
|
49329
|
+
cap: string().min(1),
|
|
49330
|
+
targetId: string().min(1),
|
|
49331
|
+
source: OverrideSourceSchema,
|
|
49332
|
+
transform: CustomizeTransformDraftSchema
|
|
49333
|
+
});
|
|
49334
|
+
var KeyedArrayOverrideDraftSchema = object({
|
|
49335
|
+
kind: literal("keyedArray"),
|
|
49336
|
+
cap: string().min(1),
|
|
49337
|
+
targetId: string().min(1),
|
|
49338
|
+
key: string().min(1),
|
|
49339
|
+
label: string().min(1),
|
|
49340
|
+
fieldPath: string().min(1),
|
|
49341
|
+
source: OverrideSourceSchema,
|
|
49342
|
+
transform: CustomizeTransformDraftSchema
|
|
49343
|
+
});
|
|
49344
|
+
var PulseOverrideDraftSchema = object({
|
|
49345
|
+
kind: literal("pulse"),
|
|
49346
|
+
cap: string().min(1),
|
|
49347
|
+
targetId: string().min(1),
|
|
49348
|
+
enabled: boolean(),
|
|
49349
|
+
debounceMs: number().nonnegative(),
|
|
49350
|
+
edges: array(_enum([
|
|
49351
|
+
"rising",
|
|
49352
|
+
"button",
|
|
49353
|
+
"native-event"
|
|
49354
|
+
])).min(1).optional(),
|
|
49355
|
+
sources: array(OverrideSourceSchema).min(1)
|
|
49356
|
+
});
|
|
49357
|
+
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
|
|
49358
|
+
"in-addition",
|
|
49359
|
+
"confirm",
|
|
49360
|
+
"replace"
|
|
49361
|
+
]).optional() });
|
|
49362
|
+
discriminatedUnion("kind", [
|
|
49363
|
+
ScalarOverrideDraftSchema,
|
|
49364
|
+
KeyedArrayOverrideDraftSchema,
|
|
49365
|
+
PulseOverrideDraftSchema,
|
|
49366
|
+
object({
|
|
49367
|
+
kind: literal("span"),
|
|
49368
|
+
cap: string().min(1),
|
|
49369
|
+
targetId: string().min(1),
|
|
49370
|
+
timeoutMs: number().nonnegative(),
|
|
49371
|
+
cooldownMs: number().nonnegative().optional(),
|
|
49372
|
+
sources: array(SpanSourceDraftSchema)
|
|
49373
|
+
})
|
|
49374
|
+
]);
|
|
49375
|
+
object({
|
|
49376
|
+
targetId: string().min(1),
|
|
49377
|
+
configured: boolean(),
|
|
49378
|
+
source: _enum(["native", "assigned"]),
|
|
49379
|
+
state: _enum([
|
|
49380
|
+
"active",
|
|
49381
|
+
"stale",
|
|
49382
|
+
"released",
|
|
49383
|
+
"unavailable"
|
|
49384
|
+
]),
|
|
49385
|
+
reason: string().nullable()
|
|
49386
|
+
});
|
|
49387
|
+
/**
|
|
49388
|
+
* What a running-threshold proposal says (planning#405). The schema is the
|
|
49389
|
+
* type: the algorithm, the capability method and the UI all read `z.infer`.
|
|
49390
|
+
*
|
|
49391
|
+
* A proposal is read-only advice: it carries the numbers it was derived from
|
|
49392
|
+
* (`evidence`) so the operator can judge it, and an `insufficient` answer names
|
|
49393
|
+
* WHY with a typed reason and the catalog defaults, never an invented number.
|
|
49394
|
+
*/
|
|
49395
|
+
var RunningProposalTierSchema = _enum(["raw", "5m"]);
|
|
49396
|
+
var RunningProposalConfidenceSchema = _enum([
|
|
49397
|
+
"high",
|
|
49398
|
+
"medium",
|
|
49399
|
+
"low"
|
|
49400
|
+
]);
|
|
49401
|
+
var RunningProposalInsufficientReasonSchema = _enum([
|
|
49402
|
+
"no-history",
|
|
49403
|
+
"span-too-short",
|
|
49404
|
+
"truncated",
|
|
49405
|
+
"no-idle-floor",
|
|
49406
|
+
"no-runs",
|
|
49407
|
+
"no-separation"
|
|
49408
|
+
]);
|
|
49409
|
+
var RunningProposalReplaySchema = object({
|
|
49410
|
+
/** Intervals the real dwell expression held true over the window. */
|
|
49411
|
+
intervals: number().int().nonnegative(),
|
|
49412
|
+
/** Intervals outside every run, or a second interval inside one. */
|
|
49413
|
+
extra: number().int().nonnegative(),
|
|
49414
|
+
/** Runs without an interval of their own (none, or merged into a neighbour). */
|
|
49415
|
+
missed: number().int().nonnegative()
|
|
49416
|
+
});
|
|
49417
|
+
var RunningProposalEvidenceSchema = object({
|
|
49418
|
+
tier: RunningProposalTierSchema,
|
|
49419
|
+
spanMs: number().nonnegative(),
|
|
49420
|
+
from: number(),
|
|
49421
|
+
to: number(),
|
|
49422
|
+
points: number().int().nonnegative(),
|
|
49423
|
+
runsFound: number().int().nonnegative(),
|
|
49424
|
+
pausesFound: number().int().nonnegative(),
|
|
49425
|
+
longestPauseMs: number().nonnegative(),
|
|
49426
|
+
idleFloorW: number(),
|
|
49427
|
+
noiseCeilingW: number(),
|
|
49428
|
+
plateauW: number(),
|
|
49429
|
+
replay: RunningProposalReplaySchema
|
|
49430
|
+
});
|
|
49431
|
+
var RunningProposalInsufficientEvidenceSchema = object({
|
|
49432
|
+
spanMs: number().nonnegative(),
|
|
49433
|
+
points: number().int().nonnegative(),
|
|
49434
|
+
runsFound: number().int().nonnegative()
|
|
49435
|
+
});
|
|
49436
|
+
var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
|
|
49437
|
+
state: literal("proposal"),
|
|
49438
|
+
transform: ThresholdTransformDraftSchema,
|
|
49439
|
+
evidence: RunningProposalEvidenceSchema,
|
|
49440
|
+
confidence: RunningProposalConfidenceSchema,
|
|
49441
|
+
/** Why the confidence is not higher; empty when nothing held it back. */
|
|
49442
|
+
notes: array(string())
|
|
49443
|
+
}), object({
|
|
49444
|
+
state: literal("insufficient"),
|
|
49445
|
+
reason: RunningProposalInsufficientReasonSchema,
|
|
49446
|
+
evidence: RunningProposalInsufficientEvidenceSchema,
|
|
49447
|
+
/** The catalog defaults, offered as what stands when nothing better is known. */
|
|
49448
|
+
fallback: ThresholdTransformDraftSchema
|
|
49449
|
+
})]);
|
|
49450
|
+
/**
|
|
49309
49451
|
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
49310
49452
|
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
49311
49453
|
*
|
|
@@ -49595,6 +49737,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
49595
49737
|
kind: "mutation",
|
|
49596
49738
|
auth: "admin",
|
|
49597
49739
|
access: "view"
|
|
49740
|
+
}), method(object({
|
|
49741
|
+
deviceId: number().int(),
|
|
49742
|
+
cap: string().min(1),
|
|
49743
|
+
fieldPath: string().min(1),
|
|
49744
|
+
deviceType: _enum(DeviceType).optional()
|
|
49745
|
+
}), RunningThresholdProposalSchema, {
|
|
49746
|
+
auth: "admin",
|
|
49747
|
+
access: "view"
|
|
49598
49748
|
}), method(object({
|
|
49599
49749
|
blockId: string().min(1),
|
|
49600
49750
|
trace: AutomationRunTraceSchema.optional(),
|
|
@@ -50403,7 +50553,53 @@ method(object({
|
|
|
50403
50553
|
* exposes only the COMMON surface: link state, supported device
|
|
50404
50554
|
* kinds (so the UI can filter the device picker), and per-device
|
|
50405
50555
|
* expose/unexpose.
|
|
50556
|
+
*
|
|
50557
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
50558
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
50559
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
50560
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
50561
|
+
* default instance's); present = that instance; an id the provider does not
|
|
50562
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
50563
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
50564
|
+
* change always names the target it changes. A single-instance provider
|
|
50565
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
50566
|
+
*/
|
|
50567
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
50568
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
50569
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
50570
|
+
/** One independent export target of an addon. */
|
|
50571
|
+
var ExportInstanceSchema = object({
|
|
50572
|
+
instanceId: InstanceIdSchema$1,
|
|
50573
|
+
name: string(),
|
|
50574
|
+
enabled: boolean(),
|
|
50575
|
+
kind: string().optional()
|
|
50576
|
+
});
|
|
50577
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
50578
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
50579
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
50580
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
50581
|
+
instanceId;
|
|
50582
|
+
constructor(addon, instanceId) {
|
|
50583
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
50584
|
+
this.name = "ExportInstanceUnknownError";
|
|
50585
|
+
this.instanceId = instanceId;
|
|
50586
|
+
}
|
|
50587
|
+
};
|
|
50588
|
+
/**
|
|
50589
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
50590
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
50591
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
50406
50592
|
*/
|
|
50593
|
+
function statusInstanceOf(input) {
|
|
50594
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
50595
|
+
}
|
|
50596
|
+
/**
|
|
50597
|
+
* A single-instance provider's check: an absent id or its own passes, any other throws
|
|
50598
|
+
* `ExportInstanceUnknownError`.
|
|
50599
|
+
*/
|
|
50600
|
+
function assertOwnExportInstance(addon, own, instanceId) {
|
|
50601
|
+
if (instanceId !== void 0 && instanceId !== own) throw new ExportInstanceUnknownError(addon, instanceId);
|
|
50602
|
+
}
|
|
50407
50603
|
var LinkStateSchema = _enum([
|
|
50408
50604
|
"unlinked",
|
|
50409
50605
|
"linked",
|
|
@@ -50454,10 +50650,14 @@ var ExposedDeviceSchema = object({
|
|
|
50454
50650
|
capabilities: array(string()).optional()
|
|
50455
50651
|
});
|
|
50456
50652
|
var ExposeInputSchema = object({
|
|
50653
|
+
instanceId: InstanceIdSchema$1,
|
|
50457
50654
|
deviceId: string(),
|
|
50458
50655
|
capabilities: array(string()).optional()
|
|
50459
50656
|
});
|
|
50460
|
-
var UnexposeInputSchema = object({
|
|
50657
|
+
var UnexposeInputSchema = object({
|
|
50658
|
+
instanceId: InstanceIdSchema$1,
|
|
50659
|
+
deviceId: string()
|
|
50660
|
+
});
|
|
50461
50661
|
/**
|
|
50462
50662
|
* What an exporter may expose besides devices (D968). An action and a
|
|
50463
50663
|
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
@@ -50486,8 +50686,14 @@ var ExposedEntitySchema = object({
|
|
|
50486
50686
|
entity: ExportEntityRefSchema,
|
|
50487
50687
|
exposedAs: string().optional()
|
|
50488
50688
|
});
|
|
50489
|
-
var ExposeEntityInputSchema = object({
|
|
50490
|
-
|
|
50689
|
+
var ExposeEntityInputSchema = object({
|
|
50690
|
+
instanceId: InstanceIdSchema$1,
|
|
50691
|
+
entity: ExportEntityRefSchema
|
|
50692
|
+
});
|
|
50693
|
+
var UnexposeEntityInputSchema = object({
|
|
50694
|
+
instanceId: InstanceIdSchema$1,
|
|
50695
|
+
entity: ExportEntityRefSchema
|
|
50696
|
+
});
|
|
50491
50697
|
var deviceExportCapability = {
|
|
50492
50698
|
name: "device-export",
|
|
50493
50699
|
scope: "system",
|
|
@@ -50507,9 +50713,10 @@ var deviceExportCapability = {
|
|
|
50507
50713
|
*/
|
|
50508
50714
|
exposesDeviceSettings: true,
|
|
50509
50715
|
methods: {
|
|
50510
|
-
getStatus: method(
|
|
50511
|
-
|
|
50512
|
-
|
|
50716
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
50717
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
50718
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
50719
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
50513
50720
|
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
50514
50721
|
kind: "mutation",
|
|
50515
50722
|
auth: "admin"
|
|
@@ -50519,7 +50726,7 @@ var deviceExportCapability = {
|
|
|
50519
50726
|
auth: "admin"
|
|
50520
50727
|
}),
|
|
50521
50728
|
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
50522
|
-
listExposedEntities: optionalMethod(
|
|
50729
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
50523
50730
|
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
50524
50731
|
kind: "mutation",
|
|
50525
50732
|
auth: "admin"
|
|
@@ -53724,15 +53931,15 @@ var FanPresetCaptureResultSchema = object({
|
|
|
53724
53931
|
items: array(FanCaptureItemSchema),
|
|
53725
53932
|
omitted: array(FanCaptureOmissionSchema)
|
|
53726
53933
|
});
|
|
53727
|
-
var deviceInput$
|
|
53934
|
+
var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
|
|
53728
53935
|
DeviceType.Fan;
|
|
53729
|
-
method(deviceInput$
|
|
53936
|
+
method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
|
|
53730
53937
|
kind: "mutation",
|
|
53731
53938
|
auth: "admin"
|
|
53732
|
-
}), method(deviceInput$
|
|
53939
|
+
}), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
|
|
53733
53940
|
kind: "mutation",
|
|
53734
53941
|
auth: "protected"
|
|
53735
|
-
}), method(deviceInput$
|
|
53942
|
+
}), method(deviceInput$2.extend({
|
|
53736
53943
|
fields: array(FanCaptureFieldSchema).optional(),
|
|
53737
53944
|
steps: array(ActionStepSchema).max(20).default([])
|
|
53738
53945
|
}), FanPresetCaptureResultSchema, { auth: "protected" });
|
|
@@ -54264,13 +54471,65 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54264
54471
|
*/
|
|
54265
54472
|
var ConfigSchemaPassthrough$3 = custom();
|
|
54266
54473
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54474
|
+
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54475
|
+
/**
|
|
54476
|
+
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54477
|
+
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54478
|
+
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
54479
|
+
* interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
|
|
54480
|
+
* instance id.
|
|
54481
|
+
*/
|
|
54482
|
+
var IntegrationInstanceKindSchema = object({
|
|
54483
|
+
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54484
|
+
id: string().min(1),
|
|
54485
|
+
label: string().min(1),
|
|
54486
|
+
/** The kind signs in through a server-held interactive session. */
|
|
54487
|
+
signIn: object({
|
|
54488
|
+
basePath: string().min(1),
|
|
54489
|
+
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
54490
|
+
}).optional(),
|
|
54491
|
+
/** Relative hub path to start an interactive account link of an instance of this kind. */
|
|
54492
|
+
connectPath: string().min(1).optional(),
|
|
54493
|
+
/** Relative hub path to disconnect that account. */
|
|
54494
|
+
disconnectPath: string().min(1).optional()
|
|
54495
|
+
});
|
|
54267
54496
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54497
|
+
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54498
|
+
role: _enum([
|
|
54499
|
+
"devices",
|
|
54500
|
+
"services",
|
|
54501
|
+
"both"
|
|
54502
|
+
]),
|
|
54503
|
+
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54504
|
+
discovery: object({
|
|
54505
|
+
mode: _enum([
|
|
54506
|
+
"none",
|
|
54507
|
+
"lan",
|
|
54508
|
+
"account"
|
|
54509
|
+
]),
|
|
54510
|
+
scopedToInstance: boolean()
|
|
54511
|
+
}).optional(),
|
|
54268
54512
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54269
|
-
instanceMode:
|
|
54513
|
+
instanceMode: IntegrationInstanceModeSchema,
|
|
54270
54514
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
54271
54515
|
kind: string(),
|
|
54272
54516
|
/** True when `testInstance` really probes the remote. */
|
|
54273
|
-
canTest: boolean()
|
|
54517
|
+
canTest: boolean(),
|
|
54518
|
+
/**
|
|
54519
|
+
* The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
|
|
54520
|
+
* Add flow asks which first and sends it as `createInstance.kind`.
|
|
54521
|
+
*/
|
|
54522
|
+
kinds: array(IntegrationInstanceKindSchema).optional(),
|
|
54523
|
+
/**
|
|
54524
|
+
* The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
|
|
54525
|
+
* devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
|
|
54526
|
+
*/
|
|
54527
|
+
allowRestoreId: boolean().optional(),
|
|
54528
|
+
/**
|
|
54529
|
+
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54530
|
+
* send an id (the UI then mints an opaque one).
|
|
54531
|
+
*/
|
|
54532
|
+
mintsId: boolean().optional()
|
|
54274
54533
|
});
|
|
54275
54534
|
var IntegrationInstanceStatusSchema = object({
|
|
54276
54535
|
state: _enum([
|
|
@@ -54279,7 +54538,9 @@ var IntegrationInstanceStatusSchema = object({
|
|
|
54279
54538
|
"error",
|
|
54280
54539
|
"unknown"
|
|
54281
54540
|
]),
|
|
54282
|
-
detail: string().optional()
|
|
54541
|
+
detail: string().optional(),
|
|
54542
|
+
/** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
|
|
54543
|
+
label: string().optional()
|
|
54283
54544
|
});
|
|
54284
54545
|
var IntegrationInstanceSchema = object({
|
|
54285
54546
|
id: IntegrationInstanceIdSchema,
|
|
@@ -54287,13 +54548,18 @@ var IntegrationInstanceSchema = object({
|
|
|
54287
54548
|
/** The addon's own rule (an URL is present, a client id is present...). */
|
|
54288
54549
|
configured: boolean(),
|
|
54289
54550
|
/**
|
|
54290
|
-
* The instance's own on/off switch (D996)
|
|
54291
|
-
*
|
|
54551
|
+
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54552
|
+
* so a row written before the field existed is on). Absent when the `integrations` registry
|
|
54553
|
+
* owns the switch (`describe().role` is `devices`): read it from the registry row.
|
|
54292
54554
|
*/
|
|
54293
|
-
enabled: boolean(),
|
|
54555
|
+
enabled: boolean().optional(),
|
|
54556
|
+
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
54557
|
+
kind: string().optional(),
|
|
54294
54558
|
/** Values for the instance form; a secret is a `SecretFieldView`, never text. */
|
|
54295
54559
|
formValues: record(string(), unknown()),
|
|
54296
|
-
status: IntegrationInstanceStatusSchema.optional()
|
|
54560
|
+
status: IntegrationInstanceStatusSchema.optional(),
|
|
54561
|
+
/** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
|
|
54562
|
+
lastCheckedAt: number().optional()
|
|
54297
54563
|
});
|
|
54298
54564
|
var IntegrationInstancePatchSchema = object({
|
|
54299
54565
|
id: IntegrationInstanceIdSchema,
|
|
@@ -54311,10 +54577,14 @@ var integrationInstancesCapability = {
|
|
|
54311
54577
|
instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54312
54578
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54313
54579
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54314
|
-
/**
|
|
54580
|
+
/**
|
|
54581
|
+
* Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
|
|
54582
|
+
* without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
|
|
54583
|
+
*/
|
|
54315
54584
|
createInstance: method(object({
|
|
54316
|
-
id: IntegrationInstanceIdSchema,
|
|
54317
|
-
name: string().min(1)
|
|
54585
|
+
id: IntegrationInstanceIdSchema.optional(),
|
|
54586
|
+
name: string().min(1),
|
|
54587
|
+
kind: string().min(1).optional()
|
|
54318
54588
|
}), object({ id: string() }), {
|
|
54319
54589
|
kind: "mutation",
|
|
54320
54590
|
auth: "admin"
|
|
@@ -56146,6 +56416,11 @@ var LogEntrySchema = object({
|
|
|
56146
56416
|
* flight, and not asking for the next slice ends the scan.
|
|
56147
56417
|
*/
|
|
56148
56418
|
var LogReadQuerySchema = object({
|
|
56419
|
+
/**
|
|
56420
|
+
* Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
|
|
56421
|
+
* the provider's first readable one, so a caller written before instances existed is unchanged.
|
|
56422
|
+
*/
|
|
56423
|
+
instanceId: string().min(1).max(200).optional(),
|
|
56149
56424
|
/** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
|
|
56150
56425
|
requestId: string().min(1).max(64).optional(),
|
|
56151
56426
|
/** The device the line is about (`tags.deviceId`, numeric). */
|
|
@@ -56208,6 +56483,8 @@ var LogReadResultSchema = object({
|
|
|
56208
56483
|
/** True when `cancelRead` ended this slice early. */
|
|
56209
56484
|
cancelled: boolean().optional()
|
|
56210
56485
|
});
|
|
56486
|
+
/** Names one destination instance; absent ⇒ the provider's first readable one. */
|
|
56487
|
+
var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
|
|
56211
56488
|
var LogReadCapabilitiesSchema = object({
|
|
56212
56489
|
/** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
|
|
56213
56490
|
readable: boolean(),
|
|
@@ -56226,7 +56503,7 @@ var LogReadCapabilitiesSchema = object({
|
|
|
56226
56503
|
/** How far back the store reaches, when the provider knows (days). */
|
|
56227
56504
|
retentionDays: number().nullable()
|
|
56228
56505
|
});
|
|
56229
|
-
method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(
|
|
56506
|
+
method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(LogInstanceSelectorSchema, LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
|
|
56230
56507
|
kind: "mutation",
|
|
56231
56508
|
auth: "admin"
|
|
56232
56509
|
});
|
|
@@ -67814,6 +68091,49 @@ object({
|
|
|
67814
68091
|
DeviceType.PetFeeder,
|
|
67815
68092
|
DeviceType.Heater
|
|
67816
68093
|
].filter((type) => type !== DeviceType.Sensor);
|
|
68094
|
+
var PowerSourceRefusalReasonSchema = _enum([
|
|
68095
|
+
"no-power-source",
|
|
68096
|
+
"switch-missing",
|
|
68097
|
+
"switch-offline",
|
|
68098
|
+
"switch-unknown",
|
|
68099
|
+
"restart-in-progress",
|
|
68100
|
+
"switch-call-failed"
|
|
68101
|
+
]);
|
|
68102
|
+
var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
|
|
68103
|
+
accepted: literal(false),
|
|
68104
|
+
reason: PowerSourceRefusalReasonSchema,
|
|
68105
|
+
/** One line for the operator, naming the switch. */
|
|
68106
|
+
message: string()
|
|
68107
|
+
})]);
|
|
68108
|
+
var PowerSourceInfoSchema = object({
|
|
68109
|
+
/** False when the device has no power source linked; the rest is then empty. */
|
|
68110
|
+
linked: boolean(),
|
|
68111
|
+
switchDeviceId: number().nullable(),
|
|
68112
|
+
switchName: string().nullable(),
|
|
68113
|
+
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
68114
|
+
switchOn: boolean().nullable(),
|
|
68115
|
+
switchOnline: boolean().nullable(),
|
|
68116
|
+
restartInProgress: boolean(),
|
|
68117
|
+
offSeconds: number().int()
|
|
68118
|
+
});
|
|
68119
|
+
object({
|
|
68120
|
+
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
68121
|
+
switchOn: boolean().nullable(),
|
|
68122
|
+
offSeconds: number().int(),
|
|
68123
|
+
lastFetchedAt: number()
|
|
68124
|
+
});
|
|
68125
|
+
DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater;
|
|
68126
|
+
var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
|
|
68127
|
+
systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68128
|
+
kind: "mutation",
|
|
68129
|
+
auth: "admin"
|
|
68130
|
+
}), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68131
|
+
kind: "mutation",
|
|
68132
|
+
auth: "admin"
|
|
68133
|
+
}), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68134
|
+
kind: "mutation",
|
|
68135
|
+
auth: "admin"
|
|
68136
|
+
});
|
|
67817
68137
|
/**
|
|
67818
68138
|
* Presence cap. Models HA `person.*` and `device_tracker.*` entities
|
|
67819
68139
|
* on `DeviceType.Presence`. Read-only — no setters: presence is
|
|
@@ -75886,6 +76206,25 @@ function buildDescriptor(capName, kind) {
|
|
|
75886
76206
|
* contributes one entry per bound cap present in this map.
|
|
75887
76207
|
*/
|
|
75888
76208
|
var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
|
|
76209
|
+
/**
|
|
76210
|
+
* What a remote key is CALLED and what it LOOKS like, for every role (D963),
|
|
76211
|
+
* shared by the admin UI and the viewer. A role is data on the wire; each
|
|
76212
|
+
* client resolves its name from `label` (English and Italian side by side) and
|
|
76213
|
+
* its glyph from `icon`, a lucide id from the shared icon catalogue — the
|
|
76214
|
+
* server sends an id, a client maps it to its own icon set.
|
|
76215
|
+
*
|
|
76216
|
+
* `legend` is text printed on the key INSTEAD of a glyph (a digit has no
|
|
76217
|
+
* pictogram): a client that can draw text shows it, one that cannot falls back
|
|
76218
|
+
* to `icon`.
|
|
76219
|
+
*/
|
|
76220
|
+
function digit(n) {
|
|
76221
|
+
return {
|
|
76222
|
+
label: t(n, n),
|
|
76223
|
+
icon: "hash",
|
|
76224
|
+
legend: n
|
|
76225
|
+
};
|
|
76226
|
+
}
|
|
76227
|
+
digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
|
|
75889
76228
|
DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
|
|
75890
76229
|
var btn = (idSuffix, row, col, init) => ({
|
|
75891
76230
|
idSuffix,
|
|
@@ -76013,6 +76352,34 @@ discriminatedUnion("kind", [object({
|
|
|
76013
76352
|
kind: literal("pronto"),
|
|
76014
76353
|
code: string()
|
|
76015
76354
|
})]);
|
|
76355
|
+
/**
|
|
76356
|
+
* Propose a running threshold from a device's own power history (planning#405).
|
|
76357
|
+
*
|
|
76358
|
+
* Pure and deterministic: the same series gives the same answer. The series is
|
|
76359
|
+
* a HELD-VALUE step series — a point's value stands until the next point — which
|
|
76360
|
+
* is how device-history stores a gauge, so "time at a level" is exact, not a
|
|
76361
|
+
* count of samples.
|
|
76362
|
+
*
|
|
76363
|
+
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
76364
|
+
* near F. A device that is not near one level most of the time has no floor.
|
|
76365
|
+
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
76366
|
+
* 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
|
|
76367
|
+
* the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
|
|
76368
|
+
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
76369
|
+
* grid a person would type; stop dwell covers the longest pause; start dwell
|
|
76370
|
+
* covers the longest standby blip above T.
|
|
76371
|
+
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
76372
|
+
* run must hold exactly one true interval and nothing may flap outside.
|
|
76373
|
+
*/
|
|
76374
|
+
var SECOND_MS = 1e3;
|
|
76375
|
+
var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
76376
|
+
24 * (60 * MINUTE_MS$1);
|
|
76377
|
+
10 * MINUTE_MS$1;
|
|
76378
|
+
30 * SECOND_MS;
|
|
76379
|
+
60 * SECOND_MS;
|
|
76380
|
+
20 * MINUTE_MS$1;
|
|
76381
|
+
10 * SECOND_MS;
|
|
76382
|
+
10 * SECOND_MS;
|
|
76016
76383
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
76017
76384
|
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
76018
76385
|
String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
|
|
@@ -77554,6 +77921,13 @@ Object.freeze({
|
|
|
77554
77921
|
access: "create",
|
|
77555
77922
|
role: "admin"
|
|
77556
77923
|
},
|
|
77924
|
+
"coreBlocks.proposeRunningThreshold": {
|
|
77925
|
+
capName: "core-blocks",
|
|
77926
|
+
capScope: "system",
|
|
77927
|
+
addonId: null,
|
|
77928
|
+
access: "view",
|
|
77929
|
+
role: "admin"
|
|
77930
|
+
},
|
|
77557
77931
|
"coreBlocks.reportAutomationRun": {
|
|
77558
77932
|
capName: "core-blocks",
|
|
77559
77933
|
capScope: "system",
|
|
@@ -78065,6 +78439,13 @@ Object.freeze({
|
|
|
78065
78439
|
access: "view",
|
|
78066
78440
|
role: "admin"
|
|
78067
78441
|
},
|
|
78442
|
+
"deviceExport.listInstances": {
|
|
78443
|
+
capName: "device-export",
|
|
78444
|
+
capScope: "system",
|
|
78445
|
+
addonId: null,
|
|
78446
|
+
access: "view",
|
|
78447
|
+
role: "admin"
|
|
78448
|
+
},
|
|
78068
78449
|
"deviceExport.listSupportedDeviceKinds": {
|
|
78069
78450
|
capName: "device-export",
|
|
78070
78451
|
capScope: "system",
|
|
@@ -87037,6 +87418,11 @@ Object.freeze({
|
|
|
87037
87418
|
form: "single",
|
|
87038
87419
|
optional: false
|
|
87039
87420
|
}],
|
|
87421
|
+
"coreBlocks.proposeRunningThreshold": [{
|
|
87422
|
+
name: "deviceId",
|
|
87423
|
+
form: "single",
|
|
87424
|
+
optional: false
|
|
87425
|
+
}],
|
|
87040
87426
|
"cover.close": [{
|
|
87041
87427
|
name: "deviceId",
|
|
87042
87428
|
form: "single",
|
|
@@ -89700,99 +90086,6 @@ Object.freeze({
|
|
|
89700
90086
|
"network-access": "ingress",
|
|
89701
90087
|
"smtp-provider": "email"
|
|
89702
90088
|
});
|
|
89703
|
-
/**
|
|
89704
|
-
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
89705
|
-
* `z.infer`, they do not restate the shape.
|
|
89706
|
-
*/
|
|
89707
|
-
var OverrideSourceSchema = object({
|
|
89708
|
-
addonId: string().min(1),
|
|
89709
|
-
stableId: string().min(1),
|
|
89710
|
-
cap: string().min(1),
|
|
89711
|
-
fieldPath: string().min(1)
|
|
89712
|
-
});
|
|
89713
|
-
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
89714
|
-
object({ kind: literal("identity") }),
|
|
89715
|
-
object({ kind: literal("invert") }),
|
|
89716
|
-
object({
|
|
89717
|
-
kind: literal("threshold"),
|
|
89718
|
-
comparison: _enum(["gte", "lte"]),
|
|
89719
|
-
threshold: number(),
|
|
89720
|
-
startDwellMs: number().nonnegative(),
|
|
89721
|
-
stopDwellMs: number().nonnegative()
|
|
89722
|
-
}),
|
|
89723
|
-
object({
|
|
89724
|
-
kind: literal("linear"),
|
|
89725
|
-
scale: number(),
|
|
89726
|
-
offset: number(),
|
|
89727
|
-
clampMin: number().optional(),
|
|
89728
|
-
clampMax: number().optional()
|
|
89729
|
-
}),
|
|
89730
|
-
object({
|
|
89731
|
-
kind: literal("enum-map"),
|
|
89732
|
-
mapping: record(string(), string().nullable())
|
|
89733
|
-
}),
|
|
89734
|
-
object({ kind: literal("number") })
|
|
89735
|
-
]);
|
|
89736
|
-
var ScalarOverrideDraftSchema = object({
|
|
89737
|
-
kind: literal("scalar"),
|
|
89738
|
-
cap: string().min(1),
|
|
89739
|
-
targetId: string().min(1),
|
|
89740
|
-
source: OverrideSourceSchema,
|
|
89741
|
-
transform: CustomizeTransformDraftSchema
|
|
89742
|
-
});
|
|
89743
|
-
var KeyedArrayOverrideDraftSchema = object({
|
|
89744
|
-
kind: literal("keyedArray"),
|
|
89745
|
-
cap: string().min(1),
|
|
89746
|
-
targetId: string().min(1),
|
|
89747
|
-
key: string().min(1),
|
|
89748
|
-
label: string().min(1),
|
|
89749
|
-
fieldPath: string().min(1),
|
|
89750
|
-
source: OverrideSourceSchema,
|
|
89751
|
-
transform: CustomizeTransformDraftSchema
|
|
89752
|
-
});
|
|
89753
|
-
var PulseOverrideDraftSchema = object({
|
|
89754
|
-
kind: literal("pulse"),
|
|
89755
|
-
cap: string().min(1),
|
|
89756
|
-
targetId: string().min(1),
|
|
89757
|
-
enabled: boolean(),
|
|
89758
|
-
debounceMs: number().nonnegative(),
|
|
89759
|
-
edges: array(_enum([
|
|
89760
|
-
"rising",
|
|
89761
|
-
"button",
|
|
89762
|
-
"native-event"
|
|
89763
|
-
])).min(1).optional(),
|
|
89764
|
-
sources: array(OverrideSourceSchema).min(1)
|
|
89765
|
-
});
|
|
89766
|
-
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
|
|
89767
|
-
"in-addition",
|
|
89768
|
-
"confirm",
|
|
89769
|
-
"replace"
|
|
89770
|
-
]).optional() });
|
|
89771
|
-
discriminatedUnion("kind", [
|
|
89772
|
-
ScalarOverrideDraftSchema,
|
|
89773
|
-
KeyedArrayOverrideDraftSchema,
|
|
89774
|
-
PulseOverrideDraftSchema,
|
|
89775
|
-
object({
|
|
89776
|
-
kind: literal("span"),
|
|
89777
|
-
cap: string().min(1),
|
|
89778
|
-
targetId: string().min(1),
|
|
89779
|
-
timeoutMs: number().nonnegative(),
|
|
89780
|
-
cooldownMs: number().nonnegative().optional(),
|
|
89781
|
-
sources: array(SpanSourceDraftSchema)
|
|
89782
|
-
})
|
|
89783
|
-
]);
|
|
89784
|
-
object({
|
|
89785
|
-
targetId: string().min(1),
|
|
89786
|
-
configured: boolean(),
|
|
89787
|
-
source: _enum(["native", "assigned"]),
|
|
89788
|
-
state: _enum([
|
|
89789
|
-
"active",
|
|
89790
|
-
"stale",
|
|
89791
|
-
"released",
|
|
89792
|
-
"unavailable"
|
|
89793
|
-
]),
|
|
89794
|
-
reason: string().nullable()
|
|
89795
|
-
});
|
|
89796
90089
|
var G711_SCALE_CORRECTION_DB = {
|
|
89797
90090
|
PCMU: 20 * Math.log10(4),
|
|
89798
90091
|
PCMA: 20 * Math.log10(8)
|
|
@@ -101757,7 +102050,7 @@ var ALEXA_ADDON_ID = "export-alexa";
|
|
|
101757
102050
|
* key, id `<addonId>.<key>`, data `{ addonId, key, value }` (never a per-addon scoped table,
|
|
101758
102051
|
* which exists only when something lazily declared it).
|
|
101759
102052
|
*/
|
|
101760
|
-
var ADDON_SETTINGS_TABLE$
|
|
102053
|
+
var ADDON_SETTINGS_TABLE$2 = "addon-settings";
|
|
101761
102054
|
var RETIRED_PUBLIC_URL_KEYS = ["publicHubUrl"];
|
|
101762
102055
|
async function planDropPublicHubUrl(ports) {
|
|
101763
102056
|
const stored = await ports.readStored();
|
|
@@ -101766,7 +102059,7 @@ async function planDropPublicHubUrl(ports) {
|
|
|
101766
102059
|
const rowId = (key) => `${ALEXA_ADDON_ID}.${key}`;
|
|
101767
102060
|
return { edits: [{
|
|
101768
102061
|
op: "deleteKeys",
|
|
101769
|
-
scope: ADDON_SETTINGS_TABLE$
|
|
102062
|
+
scope: ADDON_SETTINGS_TABLE$2,
|
|
101770
102063
|
keys: present.map(rowId),
|
|
101771
102064
|
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId(key), {
|
|
101772
102065
|
addonId: ALEXA_ADDON_ID,
|
|
@@ -101851,6 +102144,130 @@ var alexaSkillLinksKind = defineEntryKind("skill-links", {
|
|
|
101851
102144
|
}),
|
|
101852
102145
|
secretArrayKeys: { tokens: "userId" }
|
|
101853
102146
|
});
|
|
102147
|
+
/** The exposure keys that moved into the `skill-exports` record; the migrations name them. */
|
|
102148
|
+
var MOVED_EXPOSURE_KEYS = ["exposed", "exposedActions"];
|
|
102149
|
+
var ExportDeviceSettingsSchema = object({
|
|
102150
|
+
streamPreference: string(),
|
|
102151
|
+
sourceProfile: CamProfileSchema.optional(),
|
|
102152
|
+
allowTranscode: boolean().optional()
|
|
102153
|
+
});
|
|
102154
|
+
var ExposedDeviceEntrySchema = object({
|
|
102155
|
+
deviceId: number(),
|
|
102156
|
+
exposedAt: number(),
|
|
102157
|
+
settings: ExportDeviceSettingsSchema.optional()
|
|
102158
|
+
});
|
|
102159
|
+
var ActionSceneEntrySchema = object({
|
|
102160
|
+
actionId: string(),
|
|
102161
|
+
displayName: string(),
|
|
102162
|
+
addedAt: number()
|
|
102163
|
+
});
|
|
102164
|
+
var SkillExportsBodySchema = object({
|
|
102165
|
+
name: string().min(1),
|
|
102166
|
+
devices: array(ExposedDeviceEntrySchema),
|
|
102167
|
+
actions: array(ActionSceneEntrySchema)
|
|
102168
|
+
});
|
|
102169
|
+
var SKILL_EXPORTS_KIND_NAME = "skill-exports";
|
|
102170
|
+
var SKILL_EXPORTS_NAME = "Alexa exposure";
|
|
102171
|
+
var alexaSkillExportsKind = defineEntryKind(SKILL_EXPORTS_KIND_NAME, {
|
|
102172
|
+
title: "Alexa exposure",
|
|
102173
|
+
nameField: "name",
|
|
102174
|
+
schema: SkillExportsBodySchema
|
|
102175
|
+
});
|
|
102176
|
+
var EMPTY_SKILL_EXPORTS = {
|
|
102177
|
+
name: SKILL_EXPORTS_NAME,
|
|
102178
|
+
devices: [],
|
|
102179
|
+
actions: []
|
|
102180
|
+
};
|
|
102181
|
+
//#endregion
|
|
102182
|
+
//#region src/migrations/exposure-to-record.ts
|
|
102183
|
+
/**
|
|
102184
|
+
* The Alexa exposure lists move into the `skill-exports` record (planning#408 P4). Two
|
|
102185
|
+
* migrations, both `block-owner`: the addon must not serve a membership it cannot trust, and
|
|
102186
|
+
* after them nothing reads the old keys.
|
|
102187
|
+
*
|
|
102188
|
+
* 1. `moveExposureToRecord` (procedure): `exposed` and `exposedActions` become the record under
|
|
102189
|
+
* the instance id. An existing record is never overwritten. A record this pass just wrote is
|
|
102190
|
+
* read BACK and must equal what the settings carried, or the pass throws.
|
|
102191
|
+
* 2. `planDropMovedExposure` (plan): the two keys are deleted only while the record holds every
|
|
102192
|
+
* device and action the settings carried; a record that cannot be read leaves them in place.
|
|
102193
|
+
*/
|
|
102194
|
+
var ADDON_SETTINGS_TABLE$1 = "addon-settings";
|
|
102195
|
+
function devicesOf(value) {
|
|
102196
|
+
if (!Array.isArray(value)) return [];
|
|
102197
|
+
return value.flatMap((entry) => {
|
|
102198
|
+
const parsed = ExposedDeviceEntrySchema.safeParse(entry);
|
|
102199
|
+
return parsed.success ? [parsed.data] : [];
|
|
102200
|
+
});
|
|
102201
|
+
}
|
|
102202
|
+
function actionsOf(value) {
|
|
102203
|
+
if (!Array.isArray(value)) return [];
|
|
102204
|
+
return value.flatMap((entry) => {
|
|
102205
|
+
const parsed = ActionSceneEntrySchema.safeParse(entry);
|
|
102206
|
+
return parsed.success ? [parsed.data] : [];
|
|
102207
|
+
});
|
|
102208
|
+
}
|
|
102209
|
+
/** Key-order-independent JSON, so "identical" does not depend on how a store orders keys. */
|
|
102210
|
+
function canonical$1(value) {
|
|
102211
|
+
if (Array.isArray(value)) return `[${value.map(canonical$1).join(",")}]`;
|
|
102212
|
+
if (typeof value === "object" && value !== null) return `{${Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${JSON.stringify(k)}:${canonical$1(v)}`).join(",")}}`;
|
|
102213
|
+
return JSON.stringify(value) ?? "null";
|
|
102214
|
+
}
|
|
102215
|
+
async function moveExposureToRecord(ports) {
|
|
102216
|
+
const stored = await ports.readRawStored();
|
|
102217
|
+
if (!MOVED_EXPOSURE_KEYS.some((key) => key in stored)) return {
|
|
102218
|
+
outcome: "already-done",
|
|
102219
|
+
summary: { moved: false }
|
|
102220
|
+
};
|
|
102221
|
+
const devices = devicesOf(stored["exposed"]);
|
|
102222
|
+
const actions = actionsOf(stored["exposedActions"]);
|
|
102223
|
+
const dropped = (Array.isArray(stored["exposed"]) ? stored["exposed"].length : 0) - devices.length + ((Array.isArray(stored["exposedActions"]) ? stored["exposedActions"].length : 0) - actions.length);
|
|
102224
|
+
if (dropped > 0) ports.warn(`Alexa migration: ${dropped} exposure entr(ies) were not understood and are left out`);
|
|
102225
|
+
const body = {
|
|
102226
|
+
name: SKILL_EXPORTS_NAME,
|
|
102227
|
+
devices,
|
|
102228
|
+
actions
|
|
102229
|
+
};
|
|
102230
|
+
if (await ports.putExports(body) === "exists") return {
|
|
102231
|
+
outcome: "already-done",
|
|
102232
|
+
summary: { moved: false }
|
|
102233
|
+
};
|
|
102234
|
+
const held = await ports.readExports();
|
|
102235
|
+
if (held === null || canonical$1(held.devices) !== canonical$1(devices) || canonical$1(held.actions) !== canonical$1(actions)) throw new Error("the Alexa exposure record does not match the legacy settings; nothing was cleared");
|
|
102236
|
+
return {
|
|
102237
|
+
outcome: "done",
|
|
102238
|
+
summary: {
|
|
102239
|
+
moved: true,
|
|
102240
|
+
devices: devices.length,
|
|
102241
|
+
actions: actions.length
|
|
102242
|
+
}
|
|
102243
|
+
};
|
|
102244
|
+
}
|
|
102245
|
+
var rowId$1 = (key) => `${ALEXA_INSTANCE_ID}.${key}`;
|
|
102246
|
+
async function planDropMovedExposure(ports) {
|
|
102247
|
+
const stored = await ports.readRawStored();
|
|
102248
|
+
const present = MOVED_EXPOSURE_KEYS.filter((key) => key in stored);
|
|
102249
|
+
if (present.length === 0) return { edits: [] };
|
|
102250
|
+
const refuse = (reason) => {
|
|
102251
|
+
ports.warn(`Alexa migration: the legacy exposure keys are kept: ${reason}`);
|
|
102252
|
+
throw new Error(`the legacy Alexa exposure keys are not deleted: ${reason}`);
|
|
102253
|
+
};
|
|
102254
|
+
const held = await ports.readExports();
|
|
102255
|
+
if (held === null) return refuse("no exposure record exists");
|
|
102256
|
+
const heldDevices = new Set(held.devices.map((d) => d.deviceId));
|
|
102257
|
+
for (const device of devicesOf(stored["exposed"])) if (!heldDevices.has(device.deviceId)) return refuse(`the record lacks the device ${device.deviceId}`);
|
|
102258
|
+
const heldActions = new Set(held.actions.map((a) => a.actionId));
|
|
102259
|
+
for (const action of actionsOf(stored["exposedActions"])) if (!heldActions.has(action.actionId)) return refuse(`the record lacks the action ${action.actionId}`);
|
|
102260
|
+
return { edits: [{
|
|
102261
|
+
op: "deleteKeys",
|
|
102262
|
+
scope: ADDON_SETTINGS_TABLE$1,
|
|
102263
|
+
keys: present.map(rowId$1),
|
|
102264
|
+
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId$1(key), {
|
|
102265
|
+
addonId: ALEXA_INSTANCE_ID,
|
|
102266
|
+
key,
|
|
102267
|
+
value: stored[key]
|
|
102268
|
+
}])))
|
|
102269
|
+
}] };
|
|
102270
|
+
}
|
|
101854
102271
|
//#endregion
|
|
101855
102272
|
//#region src/migrations/settings-to-records.ts
|
|
101856
102273
|
/**
|
|
@@ -102050,7 +102467,9 @@ var DROP_PUBLIC_HUB_URL_ID = "export-alexa/2026-11-02-drop-public-hub-url";
|
|
|
102050
102467
|
var SETTINGS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-settings-to-integration";
|
|
102051
102468
|
var LEDGERS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-ledgers-to-integration";
|
|
102052
102469
|
var DROP_MOVED_SETTINGS_ID = "export-alexa/2026-11-03-drop-moved-settings";
|
|
102053
|
-
var
|
|
102470
|
+
var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
|
|
102471
|
+
var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
|
|
102472
|
+
var FIXTURE_MARK = "the endpoint sync state the migration does not know";
|
|
102054
102473
|
/**
|
|
102055
102474
|
* The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
|
|
102056
102475
|
* entry is `tolerate`; until a record exists the addon keeps reading the legacy keys.
|
|
@@ -102119,6 +102538,38 @@ var ADDON_MIGRATIONS = [
|
|
|
102119
102538
|
fixtureMark: FIXTURE_MARK
|
|
102120
102539
|
},
|
|
102121
102540
|
plan: planDropMovedSettings
|
|
102541
|
+
},
|
|
102542
|
+
{
|
|
102543
|
+
meta: {
|
|
102544
|
+
id: EXPOSURE_TO_RECORD_ID,
|
|
102545
|
+
owner: "export-alexa",
|
|
102546
|
+
level: "addon-state",
|
|
102547
|
+
seq: 5,
|
|
102548
|
+
dependsOn: [],
|
|
102549
|
+
store: "settings",
|
|
102550
|
+
scope: "cluster",
|
|
102551
|
+
onFailure: "block-owner",
|
|
102552
|
+
bodyKind: "procedure",
|
|
102553
|
+
description: "Move the exposed devices and actions into the skill-exports record; the record is read back before anything is deleted",
|
|
102554
|
+
fixtureMark: FIXTURE_MARK
|
|
102555
|
+
},
|
|
102556
|
+
procedure: moveExposureToRecord
|
|
102557
|
+
},
|
|
102558
|
+
{
|
|
102559
|
+
meta: {
|
|
102560
|
+
id: DROP_MOVED_EXPOSURE_ID,
|
|
102561
|
+
owner: "export-alexa",
|
|
102562
|
+
level: "addon-state",
|
|
102563
|
+
seq: 6,
|
|
102564
|
+
dependsOn: [EXPOSURE_TO_RECORD_ID],
|
|
102565
|
+
store: "settings",
|
|
102566
|
+
scope: "cluster",
|
|
102567
|
+
onFailure: "block-owner",
|
|
102568
|
+
bodyKind: "plan",
|
|
102569
|
+
description: "Delete the exposed and exposedActions settings keys once the record holds what they carried",
|
|
102570
|
+
fixtureMark: FIXTURE_MARK
|
|
102571
|
+
},
|
|
102572
|
+
plan: planDropMovedExposure
|
|
102122
102573
|
}
|
|
102123
102574
|
];
|
|
102124
102575
|
//#endregion
|
|
@@ -103352,11 +103803,10 @@ var SyncEngine = class {
|
|
|
103352
103803
|
* linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
103353
103804
|
*
|
|
103354
103805
|
* Persistence:
|
|
103355
|
-
*
|
|
103356
|
-
*
|
|
103357
|
-
* `
|
|
103358
|
-
*
|
|
103359
|
-
* of truth.
|
|
103806
|
+
* The skill, its account links and what it exposes are records
|
|
103807
|
+
* (`skills`, `skill-links`, `skill-exports`); the remaining hidden state
|
|
103808
|
+
* lives on `this.config` and writes through `updateGlobalSettings`. There
|
|
103809
|
+
* is NO `<dataDir>/alexa/*.json` sidecar anymore.
|
|
103360
103810
|
*
|
|
103361
103811
|
* Out of scope for this dispatch:
|
|
103362
103812
|
* - AWS Lambda template (CloudFormation + signing image) — the
|
|
@@ -103411,8 +103861,6 @@ var DEFAULT_CONFIG = {
|
|
|
103411
103861
|
lwaClientSecret: "",
|
|
103412
103862
|
advertisedBrokerUrl: "",
|
|
103413
103863
|
region: "NA",
|
|
103414
|
-
exposed: [],
|
|
103415
|
-
exposedActions: [],
|
|
103416
103864
|
linkedAccounts: [],
|
|
103417
103865
|
tokens: [],
|
|
103418
103866
|
exportedEndpoints: {},
|
|
@@ -103468,6 +103916,8 @@ function hasUnresolvedCredential(entry) {
|
|
|
103468
103916
|
if (typeof entry !== "object" || entry === null) return false;
|
|
103469
103917
|
return "accessToken" in entry && isSecretMarker(entry.accessToken) || "refreshToken" in entry && isSecretMarker(entry.refreshToken) || "brokerCredential" in entry && isSecretMarker(entry.brokerCredential);
|
|
103470
103918
|
}
|
|
103919
|
+
/** The one export instance this addon serves. */
|
|
103920
|
+
var EXPORT_ALEXA_ADDON_ID = "export-alexa";
|
|
103471
103921
|
var ExportAlexaAddon = class extends BaseAddon {
|
|
103472
103922
|
/** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
|
|
103473
103923
|
secretStatePaths = [
|
|
@@ -103508,8 +103958,30 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103508
103958
|
skillRow = null;
|
|
103509
103959
|
/** The `skill-links` record, once it exists; until then the legacy ledger keys answer. */
|
|
103510
103960
|
linksRow = null;
|
|
103961
|
+
/**
|
|
103962
|
+
* The `skill-exports` record: what the skill exposes (devices Alexa discovers, actions it sees
|
|
103963
|
+
* as scenes). Loaded once at boot after the migrations; this addon is its only writer, so the
|
|
103964
|
+
* in-memory copy is the synchronous read the event path needs. No settings key backs it.
|
|
103965
|
+
*/
|
|
103966
|
+
exportsRow = EMPTY_SKILL_EXPORTS;
|
|
103511
103967
|
/** The keychain refused the link credentials: the ledger is read-only until it answers (D49). */
|
|
103512
103968
|
linksLocked = false;
|
|
103969
|
+
get exposedDevices() {
|
|
103970
|
+
return this.exportsRow.devices;
|
|
103971
|
+
}
|
|
103972
|
+
/** Persist a change of the exposure: the record first, the in-memory copy after it landed. */
|
|
103973
|
+
async writeExports(patch) {
|
|
103974
|
+
const next = {
|
|
103975
|
+
name: this.exportsRow.name,
|
|
103976
|
+
devices: patch.devices ?? this.exportsRow.devices,
|
|
103977
|
+
actions: patch.actions ?? this.exportsRow.actions
|
|
103978
|
+
};
|
|
103979
|
+
await this.exportsHandle().put({
|
|
103980
|
+
id: ALEXA_INSTANCE_ID,
|
|
103981
|
+
data: next
|
|
103982
|
+
});
|
|
103983
|
+
this.exportsRow = next;
|
|
103984
|
+
}
|
|
103513
103985
|
/**
|
|
103514
103986
|
* The legacy ledger keys as lists. A store written by an older build may hold something that
|
|
103515
103987
|
* is not a list there (a clear instruction stored as the value); the page and the gateway read
|
|
@@ -103561,10 +104033,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103561
104033
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
103562
104034
|
await records.declare({
|
|
103563
104035
|
skills: alexaSkillsKind,
|
|
103564
|
-
"skill-links": alexaSkillLinksKind
|
|
104036
|
+
"skill-links": alexaSkillLinksKind,
|
|
104037
|
+
"skill-exports": alexaSkillExportsKind
|
|
103565
104038
|
});
|
|
103566
104039
|
this.instances = new RecordIntegrationInstances(records, alexaSkillsKind, {
|
|
103567
104040
|
description: {
|
|
104041
|
+
role: "services",
|
|
103568
104042
|
instanceMode: "single",
|
|
103569
104043
|
kind: "skills",
|
|
103570
104044
|
canTest: false
|
|
@@ -103582,6 +104056,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103582
104056
|
});
|
|
103583
104057
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
103584
104058
|
await this.refreshRecords();
|
|
104059
|
+
this.exportsRow = (await this.exportsHandle().get("export-alexa"))?.data ?? EMPTY_SKILL_EXPORTS;
|
|
103585
104060
|
if (!this.config.ingressToken) await this.updateGlobalSettings({ ingressToken: generateIngressToken() });
|
|
103586
104061
|
if (!this.config.snapshotSigningKey) await this.updateGlobalSettings({ snapshotSigningKey: generateIngressToken() });
|
|
103587
104062
|
if (!this.config.visionNamespace) await this.updateGlobalSettings({ visionNamespace: randomUUID() });
|
|
@@ -103600,7 +104075,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103600
104075
|
this.visibilityRef = new AccountVisibilityMirror({
|
|
103601
104076
|
gate: this.accessGateRef,
|
|
103602
104077
|
listLinkedUserIds: () => this.view.linkedAccounts.map((a) => a.userId),
|
|
103603
|
-
listExposedDeviceIds: () => this.
|
|
104078
|
+
listExposedDeviceIds: () => this.exposedDevices.map((e) => e.deviceId),
|
|
103604
104079
|
getStored: () => this.config.accountVisibility,
|
|
103605
104080
|
setStored: (next) => this.updateGlobalSettings({ accountVisibility: next }),
|
|
103606
104081
|
logger: this.ctx.logger
|
|
@@ -103610,7 +104085,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103610
104085
|
logger: this.ctx.logger,
|
|
103611
104086
|
integrationOn: () => this.view.objectDetection,
|
|
103612
104087
|
snapshotsOn: () => this.view.snapshots,
|
|
103613
|
-
isExposed: (deviceId) => this.
|
|
104088
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId),
|
|
103614
104089
|
knownClasses: (deviceId) => this.config.detectionClasses[deviceId]?.classes ?? [],
|
|
103615
104090
|
namespace: () => this.config.visionNamespace,
|
|
103616
104091
|
publicEndpoint: this.publicEndpoint,
|
|
@@ -103628,36 +104103,61 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103628
104103
|
canPush: () => this.view.tokens.length > 0,
|
|
103629
104104
|
postAddOrUpdate: (userId, endpoints) => this.requireGateway().postReport(userId, (accessToken) => buildAddOrUpdateReportPayload(userId, endpoints, accessToken), `action scenes add/update (${endpoints.length})`),
|
|
103630
104105
|
postDelete: (userId, ids) => this.requireGateway().postReport(userId, (accessToken) => buildDeleteReportPayload(userId, ids, accessToken), `action scenes delete (${ids.length})`),
|
|
103631
|
-
persist: (entries) => this.
|
|
103632
|
-
}, this.
|
|
104106
|
+
persist: (entries) => this.writeExports({ actions: [...entries] })
|
|
104107
|
+
}, this.exportsRow.actions);
|
|
103633
104108
|
const actionScenes = this.actionScenes;
|
|
103634
104109
|
actionScenes.reconcile().catch((err) => {
|
|
103635
104110
|
this.ctx.logger.warn("export-alexa: action scene reconcile at boot failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
103636
104111
|
});
|
|
104112
|
+
const ownInstance = (instanceId) => assertOwnExportInstance("export-alexa", EXPORT_ALEXA_ADDON_ID, instanceId);
|
|
103637
104113
|
const deviceExportProvider = {
|
|
103638
|
-
getStatus: async () =>
|
|
103639
|
-
|
|
103640
|
-
|
|
103641
|
-
|
|
103642
|
-
|
|
103643
|
-
|
|
103644
|
-
|
|
103645
|
-
|
|
103646
|
-
|
|
104114
|
+
getStatus: async (input) => {
|
|
104115
|
+
ownInstance(statusInstanceOf(input));
|
|
104116
|
+
return {
|
|
104117
|
+
linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
|
|
104118
|
+
exposedDeviceCount: this.exposedDevices.length,
|
|
104119
|
+
setup: await this.buildSetupBlock()
|
|
104120
|
+
};
|
|
104121
|
+
},
|
|
104122
|
+
listInstances: async () => [{
|
|
104123
|
+
instanceId: EXPORT_ALEXA_ADDON_ID,
|
|
104124
|
+
name: "Alexa",
|
|
104125
|
+
enabled: true,
|
|
104126
|
+
kind: "alexa-skill"
|
|
104127
|
+
}],
|
|
104128
|
+
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
104129
|
+
ownInstance(instanceId);
|
|
104130
|
+
return [...SUPPORTED_KINDS];
|
|
104131
|
+
},
|
|
104132
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
104133
|
+
ownInstance(instanceId);
|
|
104134
|
+
return this.exposedDevices.map((e) => ({ deviceId: String(e.deviceId) }));
|
|
104135
|
+
},
|
|
104136
|
+
exposeDevice: async ({ instanceId, deviceId }) => {
|
|
104137
|
+
ownInstance(instanceId);
|
|
104138
|
+
return this.exposeDevice(deviceId);
|
|
104139
|
+
},
|
|
104140
|
+
unexposeDevice: async ({ instanceId, deviceId }) => {
|
|
104141
|
+
ownInstance(instanceId);
|
|
104142
|
+
return this.unexposeDevice(deviceId);
|
|
104143
|
+
},
|
|
103647
104144
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
103648
|
-
listExposedEntities: async () => {
|
|
104145
|
+
listExposedEntities: async ({ instanceId }) => {
|
|
104146
|
+
ownInstance(instanceId);
|
|
103649
104147
|
await actionScenes.reconcile();
|
|
103650
|
-
return [...this.
|
|
104148
|
+
return [...this.exposedDevices.map((e) => ({ entity: {
|
|
103651
104149
|
kind: "device",
|
|
103652
104150
|
deviceId: String(e.deviceId)
|
|
103653
104151
|
} })), ...actionScenes.list()];
|
|
103654
104152
|
},
|
|
103655
|
-
exposeEntity: async ({ entity }) => {
|
|
104153
|
+
exposeEntity: async ({ instanceId, entity }) => {
|
|
104154
|
+
ownInstance(instanceId);
|
|
103656
104155
|
if (entity.kind === "device") return this.exposeDevice(entity.deviceId);
|
|
103657
104156
|
if (entity.kind === "action") return actionScenes.expose(entity.actionId);
|
|
103658
104157
|
throw new Error("export-alexa: a notification target cannot be exported to Alexa");
|
|
103659
104158
|
},
|
|
103660
|
-
unexposeEntity: async ({ entity }) => {
|
|
104159
|
+
unexposeEntity: async ({ instanceId, entity }) => {
|
|
104160
|
+
ownInstance(instanceId);
|
|
103661
104161
|
if (entity.kind === "device") return this.unexposeDevice(entity.deviceId);
|
|
103662
104162
|
if (entity.kind === "action") return actionScenes.unexpose(entity.actionId);
|
|
103663
104163
|
throw new Error("export-alexa: a notification target cannot be exported to Alexa");
|
|
@@ -103674,18 +104174,18 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103674
104174
|
discovery: {
|
|
103675
104175
|
ctx: this.ctx,
|
|
103676
104176
|
logger: this.ctx.logger,
|
|
103677
|
-
listExposed: async () => this.
|
|
104177
|
+
listExposed: async () => this.exposedDevices,
|
|
103678
104178
|
buildEndpoints: (deviceId) => this.buildEndpointsForOneDevice(deviceId)
|
|
103679
104179
|
},
|
|
103680
104180
|
cameraStream: {
|
|
103681
104181
|
ctx: this.ctx,
|
|
103682
104182
|
logger: this.ctx.logger,
|
|
103683
|
-
listExposed: () => this.
|
|
104183
|
+
listExposed: () => this.exposedDevices
|
|
103684
104184
|
},
|
|
103685
104185
|
rtcSession: {
|
|
103686
104186
|
ctx: this.ctx,
|
|
103687
104187
|
logger: this.ctx.logger,
|
|
103688
|
-
listExposed: () => this.
|
|
104188
|
+
listExposed: () => this.exposedDevices
|
|
103689
104189
|
},
|
|
103690
104190
|
ptzPreset: {
|
|
103691
104191
|
ctx: this.ctx,
|
|
@@ -103777,13 +104277,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103777
104277
|
this.egressPrewarm = new AlexaEgressPrewarm({
|
|
103778
104278
|
api: this.ctx.api,
|
|
103779
104279
|
logger: this.ctx.logger,
|
|
103780
|
-
listExposed: () => this.
|
|
104280
|
+
listExposed: () => this.exposedDevices,
|
|
103781
104281
|
hasLiveSession: (deviceId) => heldEgressHandles().some((h) => h.deviceId === deviceId)
|
|
103782
104282
|
});
|
|
103783
104283
|
this.lwaGateway = new LwaEventGateway({
|
|
103784
104284
|
ctx: this.ctx,
|
|
103785
104285
|
logger: this.ctx.logger,
|
|
103786
|
-
listExposed: () => this.
|
|
104286
|
+
listExposed: () => this.exposedDevices,
|
|
103787
104287
|
onExposedDoorbellPress: (deviceId) => {
|
|
103788
104288
|
this.egressPrewarm?.onPress(deviceId);
|
|
103789
104289
|
},
|
|
@@ -103802,7 +104302,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103802
104302
|
this.detectionFeed = new DetectionSensorFeed({
|
|
103803
104303
|
eventBus: this.ctx.eventBus,
|
|
103804
104304
|
enabled: () => this.view.detectionSensors,
|
|
103805
|
-
isExposed: (deviceId) => this.
|
|
104305
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId),
|
|
103806
104306
|
readActiveTracks: async (deviceId) => {
|
|
103807
104307
|
return (await this.ctx.api.pipelineAnalytics.getActiveTracks.query({ deviceId })).map((t) => ({
|
|
103808
104308
|
trackId: t.trackId,
|
|
@@ -103846,7 +104346,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103846
104346
|
this.stateReconciler.start();
|
|
103847
104347
|
this.syncEngine = new SyncEngine({
|
|
103848
104348
|
logger: this.ctx.logger,
|
|
103849
|
-
listExposed: () => this.
|
|
104349
|
+
listExposed: () => this.exposedDevices,
|
|
103850
104350
|
listLinkedAccounts: () => this.view.linkedAccounts,
|
|
103851
104351
|
hasProactiveCredentials: () => this.view.tokens.length > 0,
|
|
103852
104352
|
buildEndpoints: (deviceId) => this.buildEndpointsForOneDevice(deviceId),
|
|
@@ -103867,7 +104367,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103867
104367
|
const offRemoved = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceUnregistered }, (event) => {
|
|
103868
104368
|
const id = event.data?.deviceId;
|
|
103869
104369
|
if (typeof id !== "number") return;
|
|
103870
|
-
if (!this.
|
|
104370
|
+
if (!this.exposedDevices.some((e) => e.deviceId === id)) return;
|
|
103871
104371
|
this.unexposeDevice(String(id));
|
|
103872
104372
|
});
|
|
103873
104373
|
this.ctx.addDisposer(async () => offRemoved());
|
|
@@ -103877,7 +104377,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103877
104377
|
reaper.unref?.();
|
|
103878
104378
|
this.ctx.addDisposer(async () => clearInterval(reaper));
|
|
103879
104379
|
this.ctx.logger.info("export-alexa: initialized", { meta: {
|
|
103880
|
-
exposedCount: this.
|
|
104380
|
+
exposedCount: this.exposedDevices.length,
|
|
103881
104381
|
skillMode: this.view.skillMode,
|
|
103882
104382
|
skillIdSet: this.effectiveSettings().expectedAudience.length > 0,
|
|
103883
104383
|
pushGrants: this.view.tokens.length,
|
|
@@ -103952,13 +104452,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103952
104452
|
if (!await this.ctx.api.deviceManager.getDevice.query({ deviceId }).catch((err) => {
|
|
103953
104453
|
throw new Error(`export-alexa: deviceManager.getDevice failed: ${errMsg$1(err)}`);
|
|
103954
104454
|
})) throw new Error(`export-alexa: device ${deviceId} not found`);
|
|
103955
|
-
const next = this.
|
|
104455
|
+
const next = this.exposedDevices.filter((e) => e.deviceId !== deviceId);
|
|
103956
104456
|
next.push({
|
|
103957
104457
|
deviceId,
|
|
103958
104458
|
exposedAt: Date.now(),
|
|
103959
104459
|
settings: DEFAULT_DEVICE_SETTINGS
|
|
103960
104460
|
});
|
|
103961
|
-
await this.
|
|
104461
|
+
await this.writeExports({ devices: next });
|
|
103962
104462
|
this.ctx.logger.info("export-alexa: exposed device", { meta: { deviceId } });
|
|
103963
104463
|
this.requireSyncEngine().pushDevice(deviceId).then((r) => {
|
|
103964
104464
|
this.ctx.logger.info("export-alexa: synced exposed device", { meta: { ...r } });
|
|
@@ -103973,9 +104473,9 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103973
104473
|
async unexposeDevice(deviceIdRaw) {
|
|
103974
104474
|
const deviceId = Number.parseInt(deviceIdRaw, 10);
|
|
103975
104475
|
if (!Number.isFinite(deviceId)) return;
|
|
103976
|
-
const next = this.
|
|
103977
|
-
if (next.length === this.
|
|
103978
|
-
await this.
|
|
104476
|
+
const next = this.exposedDevices.filter((e) => e.deviceId !== deviceId);
|
|
104477
|
+
if (next.length === this.exposedDevices.length) return;
|
|
104478
|
+
await this.writeExports({ devices: next });
|
|
103979
104479
|
this.ctx.logger.info("export-alexa: unexposed device", { meta: { deviceId } });
|
|
103980
104480
|
this.requireSyncEngine().removeDevice(deviceId).catch((err) => {
|
|
103981
104481
|
this.ctx.logger.warn("export-alexa: unexpose delete failed", { meta: {
|
|
@@ -104090,7 +104590,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104090
104590
|
get endpointAccess() {
|
|
104091
104591
|
return {
|
|
104092
104592
|
gate: this.accessGate,
|
|
104093
|
-
isExposed: (deviceId) => this.
|
|
104593
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId)
|
|
104094
104594
|
};
|
|
104095
104595
|
}
|
|
104096
104596
|
/** Narrow the nullable `lwaGateway` for the SyncEngine post closures. It is
|
|
@@ -104120,7 +104620,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104120
104620
|
const off = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceBindingsChanged }, (event) => {
|
|
104121
104621
|
const deviceId = event.data?.deviceId;
|
|
104122
104622
|
if (typeof deviceId !== "number") return;
|
|
104123
|
-
if (!this.
|
|
104623
|
+
if (!this.exposedDevices.some((e) => e.deviceId === deviceId)) return;
|
|
104124
104624
|
const pending = this.pendingReconcileTimers.get(deviceId);
|
|
104125
104625
|
if (pending) clearTimeout(pending);
|
|
104126
104626
|
const timer = setTimeout(() => {
|
|
@@ -104408,6 +104908,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104408
104908
|
if (records === void 0) throw new Error("records are not available");
|
|
104409
104909
|
return records.kind(alexaSkillLinksKind);
|
|
104410
104910
|
}
|
|
104911
|
+
exportsHandle() {
|
|
104912
|
+
const records = this.ctx.records;
|
|
104913
|
+
if (records === void 0) throw new Error("records are not available");
|
|
104914
|
+
return records.kind(alexaSkillExportsKind);
|
|
104915
|
+
}
|
|
104411
104916
|
/** Re-read both records. A failed read changes nothing: the addon keeps what it has. */
|
|
104412
104917
|
async refreshRecords() {
|
|
104413
104918
|
try {
|
|
@@ -104470,6 +104975,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104470
104975
|
migrationPorts() {
|
|
104471
104976
|
const skills = this.skillHandle();
|
|
104472
104977
|
const links = this.linksHandle();
|
|
104978
|
+
const exportsHandle = this.exportsHandle();
|
|
104473
104979
|
const putOnce = async (handle, body) => {
|
|
104474
104980
|
if (await handle.get("export-alexa") !== null) return "exists";
|
|
104475
104981
|
try {
|
|
@@ -104499,6 +105005,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104499
105005
|
},
|
|
104500
105006
|
putSkill: (body) => putOnce(skills, body),
|
|
104501
105007
|
putLinks: (body) => putOnce(links, body),
|
|
105008
|
+
putExports: (body) => putOnce(exportsHandle, body),
|
|
105009
|
+
readExports: async () => (await exportsHandle.get("export-alexa"))?.data ?? null,
|
|
104502
105010
|
replaceLinks: async (body) => {
|
|
104503
105011
|
await links.put({
|
|
104504
105012
|
id: ALEXA_INSTANCE_ID,
|
|
@@ -104804,14 +105312,14 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104804
105312
|
}
|
|
104805
105313
|
}
|
|
104806
105314
|
findEntry(deviceId) {
|
|
104807
|
-
return this.
|
|
105315
|
+
return this.exposedDevices.find((e) => e.deviceId === deviceId) ?? null;
|
|
104808
105316
|
}
|
|
104809
105317
|
async patchEntrySettings(deviceId, settings) {
|
|
104810
|
-
const next = this.
|
|
105318
|
+
const next = this.exposedDevices.map((e) => e.deviceId === deviceId ? {
|
|
104811
105319
|
...e,
|
|
104812
105320
|
settings
|
|
104813
105321
|
} : e);
|
|
104814
|
-
await this.
|
|
105322
|
+
await this.writeExports({ devices: next });
|
|
104815
105323
|
}
|
|
104816
105324
|
};
|
|
104817
105325
|
//#endregion
|