@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
|
@@ -6016,7 +6016,7 @@ var ZodIssueCode = {
|
|
|
6016
6016
|
var ZodFirstPartyTypeKind;
|
|
6017
6017
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6018
6018
|
//#endregion
|
|
6019
|
-
//#region ../types/dist/sleep-
|
|
6019
|
+
//#region ../types/dist/sleep-BaWhXZFm.mjs
|
|
6020
6020
|
/**
|
|
6021
6021
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6022
6022
|
* window to float samples (D455).
|
|
@@ -7028,7 +7028,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
|
7028
7028
|
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
7029
7029
|
return out;
|
|
7030
7030
|
}
|
|
7031
|
-
function rowId$
|
|
7031
|
+
function rowId$2(row, idKey) {
|
|
7032
7032
|
const raw = row[idKey];
|
|
7033
7033
|
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
7034
7034
|
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
@@ -7045,7 +7045,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7045
7045
|
}
|
|
7046
7046
|
const storedById = /* @__PURE__ */ new Map();
|
|
7047
7047
|
for (const row of storedRows) {
|
|
7048
|
-
const id = rowId$
|
|
7048
|
+
const id = rowId$2(row, node.idKey);
|
|
7049
7049
|
if (id !== null) storedById.set(id, row);
|
|
7050
7050
|
}
|
|
7051
7051
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -7055,13 +7055,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7055
7055
|
rows.push(row);
|
|
7056
7056
|
continue;
|
|
7057
7057
|
}
|
|
7058
|
-
const id = rowId$
|
|
7058
|
+
const id = rowId$2(row, node.idKey) ?? ctx.mintId();
|
|
7059
7059
|
kept.add(id);
|
|
7060
7060
|
const withId = {
|
|
7061
7061
|
...row,
|
|
7062
7062
|
[node.idKey]: row[node.idKey] ?? id
|
|
7063
7063
|
};
|
|
7064
|
-
if (rowId$
|
|
7064
|
+
if (rowId$2(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7065
7065
|
const storedRow = storedById.get(id) ?? {};
|
|
7066
7066
|
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
7067
7067
|
}
|
|
@@ -8859,6 +8859,10 @@ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
|
8859
8859
|
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8860
8860
|
* (`auth.accessToken`, `headers[].value`).
|
|
8861
8861
|
*
|
|
8862
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8863
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8864
|
+
* key releases exactly that key's secret.
|
|
8865
|
+
*
|
|
8862
8866
|
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8863
8867
|
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8864
8868
|
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
@@ -8871,11 +8875,13 @@ function parseSecretPath(path) {
|
|
|
8871
8875
|
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8872
8876
|
return path.split(".").map((raw) => {
|
|
8873
8877
|
const each = raw.endsWith("[]");
|
|
8874
|
-
const
|
|
8878
|
+
const map = raw.endsWith("{}");
|
|
8879
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8875
8880
|
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8876
8881
|
return {
|
|
8877
8882
|
key,
|
|
8878
|
-
each
|
|
8883
|
+
each,
|
|
8884
|
+
map
|
|
8879
8885
|
};
|
|
8880
8886
|
});
|
|
8881
8887
|
}
|
|
@@ -8927,6 +8933,22 @@ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arra
|
|
|
8927
8933
|
[segment.key]: mapped
|
|
8928
8934
|
};
|
|
8929
8935
|
}
|
|
8936
|
+
if (segment.map) {
|
|
8937
|
+
if (!isRecord$4(child)) return node;
|
|
8938
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
8939
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
8940
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
8941
|
+
return [mapKey, visit({
|
|
8942
|
+
declared,
|
|
8943
|
+
concrete,
|
|
8944
|
+
value
|
|
8945
|
+
})];
|
|
8946
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
8947
|
+
return {
|
|
8948
|
+
...node,
|
|
8949
|
+
[segment.key]: Object.fromEntries(kept)
|
|
8950
|
+
};
|
|
8951
|
+
}
|
|
8930
8952
|
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8931
8953
|
if (last) {
|
|
8932
8954
|
const replacement = visit({
|
|
@@ -9068,7 +9090,8 @@ function isZodSecret(schema) {
|
|
|
9068
9090
|
}
|
|
9069
9091
|
/**
|
|
9070
9092
|
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9071
|
-
* element of this array" (`connection.password`, `rows[].token`)
|
|
9093
|
+
* element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
|
|
9094
|
+
* map" (`applianceSecrets{}`). A declared
|
|
9072
9095
|
* object or array is reported as one path and not descended into — everything
|
|
9073
9096
|
* under it is secret.
|
|
9074
9097
|
*/
|
|
@@ -9079,6 +9102,7 @@ function collectZodSecretPaths(schema, prefix = "") {
|
|
|
9079
9102
|
const def = defOf(layer);
|
|
9080
9103
|
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9081
9104
|
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9105
|
+
else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
|
|
9082
9106
|
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9083
9107
|
else if (def.type === "intersection") {
|
|
9084
9108
|
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
@@ -9218,7 +9242,7 @@ function defineRecordKinds(specs) {
|
|
|
9218
9242
|
retention: spec.retention,
|
|
9219
9243
|
deviceRemoval: spec.deviceRemoval,
|
|
9220
9244
|
maxDataBytes: spec.maxDataBytes,
|
|
9221
|
-
secretPaths: [...secretPaths],
|
|
9245
|
+
secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
|
|
9222
9246
|
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
9223
9247
|
transactFamily: spec.transactFamily,
|
|
9224
9248
|
entry: spec.entry === void 0 ? void 0 : {
|
|
@@ -9249,6 +9273,7 @@ function defineEntryKind(name, spec) {
|
|
|
9249
9273
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9250
9274
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9251
9275
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
9276
|
+
...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
|
|
9252
9277
|
entry: {
|
|
9253
9278
|
title: spec.title,
|
|
9254
9279
|
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
@@ -11932,7 +11957,7 @@ object({
|
|
|
11932
11957
|
params: record(string(), union([string(), number()])).optional()
|
|
11933
11958
|
});
|
|
11934
11959
|
//#endregion
|
|
11935
|
-
//#region ../types/dist/composition-
|
|
11960
|
+
//#region ../types/dist/composition-CRNwcFYY.mjs
|
|
11936
11961
|
/**
|
|
11937
11962
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11938
11963
|
*
|
|
@@ -12695,38 +12720,6 @@ function validateExpressionSource(src) {
|
|
|
12695
12720
|
return null;
|
|
12696
12721
|
}
|
|
12697
12722
|
/**
|
|
12698
|
-
* One power reading becomes a washer, dryer or dishwasher (D944 helper).
|
|
12699
|
-
*
|
|
12700
|
-
* Standby of the control board is under 5 W; a motor or a heater is far
|
|
12701
|
-
* above that, so 5 W is the line. A door lock or a short pump spike is not
|
|
12702
|
-
* a cycle, so running starts only after 30 s above the line.
|
|
12703
|
-
*
|
|
12704
|
-
* A wash, dry or dishwasher pause (soak, heat-wait, heater off between
|
|
12705
|
-
* bursts) lasts several minutes. Ending the cycle on the first dip would
|
|
12706
|
-
* report "finished" in the middle of the program, so the stop dwell is
|
|
12707
|
-
* 10 minutes on every type. The number is stored per type so one machine
|
|
12708
|
-
* can move later without moving the others.
|
|
12709
|
-
*/
|
|
12710
|
-
var APPLIANCE_TEMPLATE_ID = "appliance";
|
|
12711
|
-
var APPLIANCE_KINDS = [
|
|
12712
|
-
"washer",
|
|
12713
|
-
"dryer",
|
|
12714
|
-
"dishwasher"
|
|
12715
|
-
];
|
|
12716
|
-
DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
|
|
12717
|
-
/**
|
|
12718
|
-
* A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
|
|
12719
|
-
*
|
|
12720
|
-
* The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
|
|
12721
|
-
* (D967), so the heater switches exactly as the plug does. Running is the
|
|
12722
|
-
* plug being on; when a power reading is also named, running is the draw
|
|
12723
|
-
* staying above the line instead (a plug left on with the stove's own
|
|
12724
|
-
* thermostat open is not heating). 50 W is far above any standby and below
|
|
12725
|
-
* the smallest radiator.
|
|
12726
|
-
*/
|
|
12727
|
-
var HEATER_TEMPLATE_ID = "heater";
|
|
12728
|
-
DeviceType.Heater;
|
|
12729
|
-
/**
|
|
12730
12723
|
* Statistics and integrals over a history read (D944).
|
|
12731
12724
|
*
|
|
12732
12725
|
* Pure: the same points always give the same answer, so a restart recomputes
|
|
@@ -12870,34 +12863,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
|
|
|
12870
12863
|
/** Actuator groups only. Readings leave this unset. */
|
|
12871
12864
|
active: ActiveCriterionSchema.optional()
|
|
12872
12865
|
}),
|
|
12873
|
-
object({
|
|
12874
|
-
kind: literal("appliance"),
|
|
12875
|
-
templateId: literal(APPLIANCE_TEMPLATE_ID),
|
|
12876
|
-
appliance: _enum(APPLIANCE_KINDS),
|
|
12877
|
-
thresholdWatts: number().positive(),
|
|
12878
|
-
startDwellMs: number().int().nonnegative(),
|
|
12879
|
-
stopDwellMs: number().int().nonnegative(),
|
|
12880
|
-
member: HelperMemberSchema,
|
|
12881
|
-
/**
|
|
12882
|
-
* The plug that powers the appliance (`switch.on`). Optional: when set, the
|
|
12883
|
-
* composition carries a `power-source` feature, so the hub can cut and restore
|
|
12884
|
-
* that plug (power-source link of a NEW-target composition).
|
|
12885
|
-
*/
|
|
12886
|
-
powerSwitch: HelperMemberSchema.optional(),
|
|
12887
|
-
/** How long a forced restart keeps the plug off; the cap's default when unset. */
|
|
12888
|
-
offSeconds: number().optional()
|
|
12889
|
-
}),
|
|
12890
|
-
object({
|
|
12891
|
-
kind: literal("heater"),
|
|
12892
|
-
templateId: literal(HEATER_TEMPLATE_ID),
|
|
12893
|
-
/** The plug, read and commanded at `switch.on`. */
|
|
12894
|
-
plug: HelperMemberSchema,
|
|
12895
|
-
/** The plug's power reading, when it has one: running is then the draw, not the switch. */
|
|
12896
|
-
meter: HelperMemberSchema.optional(),
|
|
12897
|
-
thresholdWatts: number().positive(),
|
|
12898
|
-
startDwellMs: number().int().nonnegative(),
|
|
12899
|
-
stopDwellMs: number().int().nonnegative()
|
|
12900
|
-
}),
|
|
12901
12866
|
object({
|
|
12902
12867
|
kind: literal("statistic"),
|
|
12903
12868
|
stat: _enum(STATISTIC_STATS),
|
|
@@ -13121,7 +13086,7 @@ var CompositionSchema = object({
|
|
|
13121
13086
|
kind: literal("existing"),
|
|
13122
13087
|
device: CompositionSourceRefSchema
|
|
13123
13088
|
})]),
|
|
13124
|
-
features: array(CompositionFeatureSchema).min(
|
|
13089
|
+
features: array(CompositionFeatureSchema).min(0).max(16),
|
|
13125
13090
|
/**
|
|
13126
13091
|
* Present when the block is a helper template. Absent on a free
|
|
13127
13092
|
* composition (the room example, device 4603). The editor reads this,
|
|
@@ -13456,11 +13421,49 @@ function buildCapturingReply(envelope) {
|
|
|
13456
13421
|
};
|
|
13457
13422
|
return wrapper;
|
|
13458
13423
|
}
|
|
13424
|
+
/**
|
|
13425
|
+
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13426
|
+
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13427
|
+
*
|
|
13428
|
+
* Every instance is one record of the addon's own kind, keyed by the
|
|
13429
|
+
* `integrations` registry id. The records door does the secret work: a field the
|
|
13430
|
+
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13431
|
+
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13432
|
+
*
|
|
13433
|
+
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13434
|
+
* token or the view the form was given KEEP the stored secret;
|
|
13435
|
+
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13436
|
+
*/
|
|
13459
13437
|
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13460
13438
|
var INSTANCES_LIST_MAX = 1e3;
|
|
13461
13439
|
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13462
13440
|
function topLevelSecretKeys(paths) {
|
|
13463
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[")));
|
|
13441
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13442
|
+
}
|
|
13443
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13444
|
+
function secretMapKeys(paths) {
|
|
13445
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13446
|
+
}
|
|
13447
|
+
/**
|
|
13448
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13449
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13450
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13451
|
+
*/
|
|
13452
|
+
function secretMapPatch(value) {
|
|
13453
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13454
|
+
const out = {};
|
|
13455
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13456
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13457
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
13458
|
+
}
|
|
13459
|
+
/** Does the kind's body schema carry an `enabled` field? */
|
|
13460
|
+
function declaresEnabled(kind) {
|
|
13461
|
+
const json = toJSONSchema(kind.schema, {
|
|
13462
|
+
unrepresentable: "any",
|
|
13463
|
+
io: "input"
|
|
13464
|
+
});
|
|
13465
|
+
const properties = Reflect.get(json, "properties");
|
|
13466
|
+
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13464
13467
|
}
|
|
13465
13468
|
var RecordIntegrationInstances = class {
|
|
13466
13469
|
records;
|
|
@@ -13468,14 +13471,20 @@ var RecordIntegrationInstances = class {
|
|
|
13468
13471
|
hooks;
|
|
13469
13472
|
handle;
|
|
13470
13473
|
secretKeys;
|
|
13474
|
+
secretMaps;
|
|
13471
13475
|
nameField;
|
|
13476
|
+
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13477
|
+
registryOwnsEnabled;
|
|
13472
13478
|
constructor(records, kind, hooks) {
|
|
13473
13479
|
this.records = records;
|
|
13474
13480
|
this.kind = kind;
|
|
13475
13481
|
this.hooks = hooks;
|
|
13476
13482
|
this.handle = records.kind(kind);
|
|
13477
13483
|
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13484
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13478
13485
|
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13486
|
+
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13487
|
+
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"`);
|
|
13479
13488
|
}
|
|
13480
13489
|
/**
|
|
13481
13490
|
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
@@ -13520,15 +13529,23 @@ var RecordIntegrationInstances = class {
|
|
|
13520
13529
|
viewOf(record) {
|
|
13521
13530
|
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13522
13531
|
const rawName = record.data[this.nameField];
|
|
13532
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
13533
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
13523
13534
|
return {
|
|
13524
13535
|
id: record.id,
|
|
13525
13536
|
name: typeof rawName === "string" ? rawName : record.id,
|
|
13526
13537
|
configured: this.hooks.configured(record.data),
|
|
13527
|
-
enabled: record.data.enabled !== false,
|
|
13528
|
-
formValues: shown
|
|
13538
|
+
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13539
|
+
formValues: shown,
|
|
13540
|
+
...kind !== void 0 ? { kind } : {},
|
|
13541
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13542
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13529
13543
|
};
|
|
13530
13544
|
}
|
|
13531
|
-
describe = async () => this.hooks.description
|
|
13545
|
+
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13546
|
+
...this.hooks.description,
|
|
13547
|
+
mintsId: true
|
|
13548
|
+
};
|
|
13532
13549
|
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13533
13550
|
listInstances = async () => {
|
|
13534
13551
|
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
@@ -13538,37 +13555,46 @@ var RecordIntegrationInstances = class {
|
|
|
13538
13555
|
return record === null ? null : this.viewOf(record);
|
|
13539
13556
|
};
|
|
13540
13557
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13541
|
-
createInstance = async ({ id, name }) => {
|
|
13558
|
+
createInstance = async ({ id, name, kind }) => {
|
|
13559
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
13560
|
+
name,
|
|
13561
|
+
...kind !== void 0 ? { kind } : {}
|
|
13562
|
+
});
|
|
13563
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13542
13564
|
await this.handle.put({
|
|
13543
|
-
id,
|
|
13544
|
-
data: this.hooks.initialBody(name)
|
|
13565
|
+
id: minted,
|
|
13566
|
+
data: this.hooks.initialBody(name, kind)
|
|
13545
13567
|
}, { ifRev: 0 });
|
|
13546
|
-
await this.hooks.onChanged?.(
|
|
13547
|
-
return { id };
|
|
13568
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
13569
|
+
return { id: minted };
|
|
13548
13570
|
};
|
|
13549
13571
|
updateInstance = async ({ id, name, values }) => {
|
|
13550
13572
|
const patch = {};
|
|
13551
13573
|
for (const [key, value] of Object.entries(values)) {
|
|
13552
13574
|
if (value === void 0) continue;
|
|
13553
|
-
if (
|
|
13575
|
+
if (this.secretMaps.has(key)) {
|
|
13576
|
+
const entries = secretMapPatch(value);
|
|
13577
|
+
if (entries !== null) patch[key] = entries;
|
|
13578
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13554
13579
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13555
13580
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13556
13581
|
}
|
|
13557
13582
|
if (name !== void 0) patch[this.nameField] = name;
|
|
13558
13583
|
await this.handle.patch(id, patch);
|
|
13559
|
-
await this.hooks.onChanged?.(id);
|
|
13584
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13560
13585
|
return { ok: true };
|
|
13561
13586
|
};
|
|
13562
13587
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13563
13588
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13589
|
+
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13564
13590
|
await this.handle.patch(id, { enabled });
|
|
13565
|
-
await this.hooks.onChanged?.(id);
|
|
13591
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
13566
13592
|
return { ok: true };
|
|
13567
13593
|
};
|
|
13568
13594
|
/** The row and its keychain refs go together (the records door). */
|
|
13569
13595
|
deleteInstance = async ({ id }) => {
|
|
13570
13596
|
await this.handle.delete(id);
|
|
13571
|
-
await this.hooks.onChanged?.(id);
|
|
13597
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
13572
13598
|
return { ok: true };
|
|
13573
13599
|
};
|
|
13574
13600
|
testInstance = async (input) => {
|
|
@@ -49265,49 +49291,6 @@ function actuator(input) {
|
|
|
49265
49291
|
};
|
|
49266
49292
|
}
|
|
49267
49293
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
49268
|
-
var PowerSourceRefusalReasonSchema = _enum([
|
|
49269
|
-
"no-power-source",
|
|
49270
|
-
"switch-missing",
|
|
49271
|
-
"switch-offline",
|
|
49272
|
-
"switch-unknown",
|
|
49273
|
-
"restart-in-progress",
|
|
49274
|
-
"switch-call-failed"
|
|
49275
|
-
]);
|
|
49276
|
-
var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
|
|
49277
|
-
accepted: literal(false),
|
|
49278
|
-
reason: PowerSourceRefusalReasonSchema,
|
|
49279
|
-
/** One line for the operator, naming the switch. */
|
|
49280
|
-
message: string()
|
|
49281
|
-
})]);
|
|
49282
|
-
var PowerSourceInfoSchema = object({
|
|
49283
|
-
/** False when the device has no power source linked; the rest is then empty. */
|
|
49284
|
-
linked: boolean(),
|
|
49285
|
-
switchDeviceId: number().nullable(),
|
|
49286
|
-
switchName: string().nullable(),
|
|
49287
|
-
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
49288
|
-
switchOn: boolean().nullable(),
|
|
49289
|
-
switchOnline: boolean().nullable(),
|
|
49290
|
-
restartInProgress: boolean(),
|
|
49291
|
-
offSeconds: number().int()
|
|
49292
|
-
});
|
|
49293
|
-
object({
|
|
49294
|
-
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
49295
|
-
switchOn: boolean().nullable(),
|
|
49296
|
-
offSeconds: number().int(),
|
|
49297
|
-
lastFetchedAt: number()
|
|
49298
|
-
});
|
|
49299
|
-
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;
|
|
49300
|
-
var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
|
|
49301
|
-
systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49302
|
-
kind: "mutation",
|
|
49303
|
-
auth: "admin"
|
|
49304
|
-
}), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49305
|
-
kind: "mutation",
|
|
49306
|
-
auth: "admin"
|
|
49307
|
-
}), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
|
|
49308
|
-
kind: "mutation",
|
|
49309
|
-
auth: "admin"
|
|
49310
|
-
});
|
|
49311
49294
|
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
49312
49295
|
DeviceType.Camera;
|
|
49313
49296
|
`${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
|
|
@@ -49335,6 +49318,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
49335
49318
|
}).optional()
|
|
49336
49319
|
})) });
|
|
49337
49320
|
/**
|
|
49321
|
+
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
49322
|
+
* `z.infer`, they do not restate the shape.
|
|
49323
|
+
*/
|
|
49324
|
+
var OverrideSourceSchema = object({
|
|
49325
|
+
addonId: string().min(1),
|
|
49326
|
+
stableId: string().min(1),
|
|
49327
|
+
cap: string().min(1),
|
|
49328
|
+
fieldPath: string().min(1)
|
|
49329
|
+
});
|
|
49330
|
+
var IdentityTransformDraftSchema = object({ kind: literal("identity") });
|
|
49331
|
+
var InvertTransformDraftSchema = object({ kind: literal("invert") });
|
|
49332
|
+
var ThresholdTransformDraftSchema = object({
|
|
49333
|
+
kind: literal("threshold"),
|
|
49334
|
+
comparison: _enum(["gte", "lte"]),
|
|
49335
|
+
threshold: number(),
|
|
49336
|
+
startDwellMs: number().nonnegative(),
|
|
49337
|
+
stopDwellMs: number().nonnegative()
|
|
49338
|
+
});
|
|
49339
|
+
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49340
|
+
IdentityTransformDraftSchema,
|
|
49341
|
+
InvertTransformDraftSchema,
|
|
49342
|
+
ThresholdTransformDraftSchema,
|
|
49343
|
+
object({
|
|
49344
|
+
kind: literal("linear"),
|
|
49345
|
+
scale: number(),
|
|
49346
|
+
offset: number(),
|
|
49347
|
+
clampMin: number().optional(),
|
|
49348
|
+
clampMax: number().optional()
|
|
49349
|
+
}),
|
|
49350
|
+
object({
|
|
49351
|
+
kind: literal("enum-map"),
|
|
49352
|
+
mapping: record(string(), string().nullable())
|
|
49353
|
+
}),
|
|
49354
|
+
object({ kind: literal("number") })
|
|
49355
|
+
]);
|
|
49356
|
+
var ScalarOverrideDraftSchema = object({
|
|
49357
|
+
kind: literal("scalar"),
|
|
49358
|
+
cap: string().min(1),
|
|
49359
|
+
targetId: string().min(1),
|
|
49360
|
+
source: OverrideSourceSchema,
|
|
49361
|
+
transform: CustomizeTransformDraftSchema
|
|
49362
|
+
});
|
|
49363
|
+
var KeyedArrayOverrideDraftSchema = object({
|
|
49364
|
+
kind: literal("keyedArray"),
|
|
49365
|
+
cap: string().min(1),
|
|
49366
|
+
targetId: string().min(1),
|
|
49367
|
+
key: string().min(1),
|
|
49368
|
+
label: string().min(1),
|
|
49369
|
+
fieldPath: string().min(1),
|
|
49370
|
+
source: OverrideSourceSchema,
|
|
49371
|
+
transform: CustomizeTransformDraftSchema
|
|
49372
|
+
});
|
|
49373
|
+
var PulseOverrideDraftSchema = object({
|
|
49374
|
+
kind: literal("pulse"),
|
|
49375
|
+
cap: string().min(1),
|
|
49376
|
+
targetId: string().min(1),
|
|
49377
|
+
enabled: boolean(),
|
|
49378
|
+
debounceMs: number().nonnegative(),
|
|
49379
|
+
edges: array(_enum([
|
|
49380
|
+
"rising",
|
|
49381
|
+
"button",
|
|
49382
|
+
"native-event"
|
|
49383
|
+
])).min(1).optional(),
|
|
49384
|
+
sources: array(OverrideSourceSchema).min(1)
|
|
49385
|
+
});
|
|
49386
|
+
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
|
|
49387
|
+
"in-addition",
|
|
49388
|
+
"confirm",
|
|
49389
|
+
"replace"
|
|
49390
|
+
]).optional() });
|
|
49391
|
+
discriminatedUnion("kind", [
|
|
49392
|
+
ScalarOverrideDraftSchema,
|
|
49393
|
+
KeyedArrayOverrideDraftSchema,
|
|
49394
|
+
PulseOverrideDraftSchema,
|
|
49395
|
+
object({
|
|
49396
|
+
kind: literal("span"),
|
|
49397
|
+
cap: string().min(1),
|
|
49398
|
+
targetId: string().min(1),
|
|
49399
|
+
timeoutMs: number().nonnegative(),
|
|
49400
|
+
cooldownMs: number().nonnegative().optional(),
|
|
49401
|
+
sources: array(SpanSourceDraftSchema)
|
|
49402
|
+
})
|
|
49403
|
+
]);
|
|
49404
|
+
object({
|
|
49405
|
+
targetId: string().min(1),
|
|
49406
|
+
configured: boolean(),
|
|
49407
|
+
source: _enum(["native", "assigned"]),
|
|
49408
|
+
state: _enum([
|
|
49409
|
+
"active",
|
|
49410
|
+
"stale",
|
|
49411
|
+
"released",
|
|
49412
|
+
"unavailable"
|
|
49413
|
+
]),
|
|
49414
|
+
reason: string().nullable()
|
|
49415
|
+
});
|
|
49416
|
+
/**
|
|
49417
|
+
* What a running-threshold proposal says (planning#405). The schema is the
|
|
49418
|
+
* type: the algorithm, the capability method and the UI all read `z.infer`.
|
|
49419
|
+
*
|
|
49420
|
+
* A proposal is read-only advice: it carries the numbers it was derived from
|
|
49421
|
+
* (`evidence`) so the operator can judge it, and an `insufficient` answer names
|
|
49422
|
+
* WHY with a typed reason and the catalog defaults, never an invented number.
|
|
49423
|
+
*/
|
|
49424
|
+
var RunningProposalTierSchema = _enum(["raw", "5m"]);
|
|
49425
|
+
var RunningProposalConfidenceSchema = _enum([
|
|
49426
|
+
"high",
|
|
49427
|
+
"medium",
|
|
49428
|
+
"low"
|
|
49429
|
+
]);
|
|
49430
|
+
var RunningProposalInsufficientReasonSchema = _enum([
|
|
49431
|
+
"no-history",
|
|
49432
|
+
"span-too-short",
|
|
49433
|
+
"truncated",
|
|
49434
|
+
"no-idle-floor",
|
|
49435
|
+
"no-runs",
|
|
49436
|
+
"no-separation"
|
|
49437
|
+
]);
|
|
49438
|
+
var RunningProposalReplaySchema = object({
|
|
49439
|
+
/** Intervals the real dwell expression held true over the window. */
|
|
49440
|
+
intervals: number().int().nonnegative(),
|
|
49441
|
+
/** Intervals outside every run, or a second interval inside one. */
|
|
49442
|
+
extra: number().int().nonnegative(),
|
|
49443
|
+
/** Runs without an interval of their own (none, or merged into a neighbour). */
|
|
49444
|
+
missed: number().int().nonnegative()
|
|
49445
|
+
});
|
|
49446
|
+
var RunningProposalEvidenceSchema = object({
|
|
49447
|
+
tier: RunningProposalTierSchema,
|
|
49448
|
+
spanMs: number().nonnegative(),
|
|
49449
|
+
from: number(),
|
|
49450
|
+
to: number(),
|
|
49451
|
+
points: number().int().nonnegative(),
|
|
49452
|
+
runsFound: number().int().nonnegative(),
|
|
49453
|
+
pausesFound: number().int().nonnegative(),
|
|
49454
|
+
longestPauseMs: number().nonnegative(),
|
|
49455
|
+
idleFloorW: number(),
|
|
49456
|
+
noiseCeilingW: number(),
|
|
49457
|
+
plateauW: number(),
|
|
49458
|
+
replay: RunningProposalReplaySchema
|
|
49459
|
+
});
|
|
49460
|
+
var RunningProposalInsufficientEvidenceSchema = object({
|
|
49461
|
+
spanMs: number().nonnegative(),
|
|
49462
|
+
points: number().int().nonnegative(),
|
|
49463
|
+
runsFound: number().int().nonnegative()
|
|
49464
|
+
});
|
|
49465
|
+
var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
|
|
49466
|
+
state: literal("proposal"),
|
|
49467
|
+
transform: ThresholdTransformDraftSchema,
|
|
49468
|
+
evidence: RunningProposalEvidenceSchema,
|
|
49469
|
+
confidence: RunningProposalConfidenceSchema,
|
|
49470
|
+
/** Why the confidence is not higher; empty when nothing held it back. */
|
|
49471
|
+
notes: array(string())
|
|
49472
|
+
}), object({
|
|
49473
|
+
state: literal("insufficient"),
|
|
49474
|
+
reason: RunningProposalInsufficientReasonSchema,
|
|
49475
|
+
evidence: RunningProposalInsufficientEvidenceSchema,
|
|
49476
|
+
/** The catalog defaults, offered as what stands when nothing better is known. */
|
|
49477
|
+
fallback: ThresholdTransformDraftSchema
|
|
49478
|
+
})]);
|
|
49479
|
+
/**
|
|
49338
49480
|
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
49339
49481
|
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
49340
49482
|
*
|
|
@@ -49624,6 +49766,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
49624
49766
|
kind: "mutation",
|
|
49625
49767
|
auth: "admin",
|
|
49626
49768
|
access: "view"
|
|
49769
|
+
}), method(object({
|
|
49770
|
+
deviceId: number().int(),
|
|
49771
|
+
cap: string().min(1),
|
|
49772
|
+
fieldPath: string().min(1),
|
|
49773
|
+
deviceType: _enum(DeviceType).optional()
|
|
49774
|
+
}), RunningThresholdProposalSchema, {
|
|
49775
|
+
auth: "admin",
|
|
49776
|
+
access: "view"
|
|
49627
49777
|
}), method(object({
|
|
49628
49778
|
blockId: string().min(1),
|
|
49629
49779
|
trace: AutomationRunTraceSchema.optional(),
|
|
@@ -50432,7 +50582,53 @@ method(object({
|
|
|
50432
50582
|
* exposes only the COMMON surface: link state, supported device
|
|
50433
50583
|
* kinds (so the UI can filter the device picker), and per-device
|
|
50434
50584
|
* expose/unexpose.
|
|
50585
|
+
*
|
|
50586
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
50587
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
50588
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
50589
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
50590
|
+
* default instance's); present = that instance; an id the provider does not
|
|
50591
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
50592
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
50593
|
+
* change always names the target it changes. A single-instance provider
|
|
50594
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
50595
|
+
*/
|
|
50596
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
50597
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
50598
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
50599
|
+
/** One independent export target of an addon. */
|
|
50600
|
+
var ExportInstanceSchema = object({
|
|
50601
|
+
instanceId: InstanceIdSchema$1,
|
|
50602
|
+
name: string(),
|
|
50603
|
+
enabled: boolean(),
|
|
50604
|
+
kind: string().optional()
|
|
50605
|
+
});
|
|
50606
|
+
var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
|
|
50607
|
+
/** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
|
|
50608
|
+
var ExportInstanceUnknownError = class extends Error {
|
|
50609
|
+
code = EXPORT_INSTANCE_UNKNOWN;
|
|
50610
|
+
instanceId;
|
|
50611
|
+
constructor(addon, instanceId) {
|
|
50612
|
+
super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
|
|
50613
|
+
this.name = "ExportInstanceUnknownError";
|
|
50614
|
+
this.instanceId = instanceId;
|
|
50615
|
+
}
|
|
50616
|
+
};
|
|
50617
|
+
/**
|
|
50618
|
+
* The instance a `getStatus` call names. The cap's `status` block injects a per-device
|
|
50619
|
+
* `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
|
|
50620
|
+
* both shapes; only the second names an instance (a per-device status read is addon-wide).
|
|
50435
50621
|
*/
|
|
50622
|
+
function statusInstanceOf(input) {
|
|
50623
|
+
return "instanceId" in input ? input.instanceId : void 0;
|
|
50624
|
+
}
|
|
50625
|
+
/**
|
|
50626
|
+
* A single-instance provider's check: an absent id or its own passes, any other throws
|
|
50627
|
+
* `ExportInstanceUnknownError`.
|
|
50628
|
+
*/
|
|
50629
|
+
function assertOwnExportInstance(addon, own, instanceId) {
|
|
50630
|
+
if (instanceId !== void 0 && instanceId !== own) throw new ExportInstanceUnknownError(addon, instanceId);
|
|
50631
|
+
}
|
|
50436
50632
|
var LinkStateSchema = _enum([
|
|
50437
50633
|
"unlinked",
|
|
50438
50634
|
"linked",
|
|
@@ -50483,10 +50679,14 @@ var ExposedDeviceSchema = object({
|
|
|
50483
50679
|
capabilities: array(string()).optional()
|
|
50484
50680
|
});
|
|
50485
50681
|
var ExposeInputSchema = object({
|
|
50682
|
+
instanceId: InstanceIdSchema$1,
|
|
50486
50683
|
deviceId: string(),
|
|
50487
50684
|
capabilities: array(string()).optional()
|
|
50488
50685
|
});
|
|
50489
|
-
var UnexposeInputSchema = object({
|
|
50686
|
+
var UnexposeInputSchema = object({
|
|
50687
|
+
instanceId: InstanceIdSchema$1,
|
|
50688
|
+
deviceId: string()
|
|
50689
|
+
});
|
|
50490
50690
|
/**
|
|
50491
50691
|
* What an exporter may expose besides devices (D968). An action and a
|
|
50492
50692
|
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
@@ -50515,8 +50715,14 @@ var ExposedEntitySchema = object({
|
|
|
50515
50715
|
entity: ExportEntityRefSchema,
|
|
50516
50716
|
exposedAs: string().optional()
|
|
50517
50717
|
});
|
|
50518
|
-
var ExposeEntityInputSchema = object({
|
|
50519
|
-
|
|
50718
|
+
var ExposeEntityInputSchema = object({
|
|
50719
|
+
instanceId: InstanceIdSchema$1,
|
|
50720
|
+
entity: ExportEntityRefSchema
|
|
50721
|
+
});
|
|
50722
|
+
var UnexposeEntityInputSchema = object({
|
|
50723
|
+
instanceId: InstanceIdSchema$1,
|
|
50724
|
+
entity: ExportEntityRefSchema
|
|
50725
|
+
});
|
|
50520
50726
|
var deviceExportCapability = {
|
|
50521
50727
|
name: "device-export",
|
|
50522
50728
|
scope: "system",
|
|
@@ -50536,9 +50742,10 @@ var deviceExportCapability = {
|
|
|
50536
50742
|
*/
|
|
50537
50743
|
exposesDeviceSettings: true,
|
|
50538
50744
|
methods: {
|
|
50539
|
-
getStatus: method(
|
|
50540
|
-
|
|
50541
|
-
|
|
50745
|
+
getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
|
|
50746
|
+
listInstances: method(_void(), array(ExportInstanceSchema)),
|
|
50747
|
+
listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
|
|
50748
|
+
listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
|
|
50542
50749
|
exposeDevice: method(ExposeInputSchema, _void(), {
|
|
50543
50750
|
kind: "mutation",
|
|
50544
50751
|
auth: "admin"
|
|
@@ -50548,7 +50755,7 @@ var deviceExportCapability = {
|
|
|
50548
50755
|
auth: "admin"
|
|
50549
50756
|
}),
|
|
50550
50757
|
listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
|
|
50551
|
-
listExposedEntities: optionalMethod(
|
|
50758
|
+
listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
|
|
50552
50759
|
exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
50553
50760
|
kind: "mutation",
|
|
50554
50761
|
auth: "admin"
|
|
@@ -53753,15 +53960,15 @@ var FanPresetCaptureResultSchema = object({
|
|
|
53753
53960
|
items: array(FanCaptureItemSchema),
|
|
53754
53961
|
omitted: array(FanCaptureOmissionSchema)
|
|
53755
53962
|
});
|
|
53756
|
-
var deviceInput$
|
|
53963
|
+
var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
|
|
53757
53964
|
DeviceType.Fan;
|
|
53758
|
-
method(deviceInput$
|
|
53965
|
+
method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
|
|
53759
53966
|
kind: "mutation",
|
|
53760
53967
|
auth: "admin"
|
|
53761
|
-
}), method(deviceInput$
|
|
53968
|
+
}), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
|
|
53762
53969
|
kind: "mutation",
|
|
53763
53970
|
auth: "protected"
|
|
53764
|
-
}), method(deviceInput$
|
|
53971
|
+
}), method(deviceInput$2.extend({
|
|
53765
53972
|
fields: array(FanCaptureFieldSchema).optional(),
|
|
53766
53973
|
steps: array(ActionStepSchema).max(20).default([])
|
|
53767
53974
|
}), FanPresetCaptureResultSchema, { auth: "protected" });
|
|
@@ -54293,13 +54500,65 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54293
54500
|
*/
|
|
54294
54501
|
var ConfigSchemaPassthrough$3 = custom();
|
|
54295
54502
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54503
|
+
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54504
|
+
/**
|
|
54505
|
+
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54506
|
+
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54507
|
+
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
54508
|
+
* interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
|
|
54509
|
+
* instance id.
|
|
54510
|
+
*/
|
|
54511
|
+
var IntegrationInstanceKindSchema = object({
|
|
54512
|
+
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54513
|
+
id: string().min(1),
|
|
54514
|
+
label: string().min(1),
|
|
54515
|
+
/** The kind signs in through a server-held interactive session. */
|
|
54516
|
+
signIn: object({
|
|
54517
|
+
basePath: string().min(1),
|
|
54518
|
+
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
54519
|
+
}).optional(),
|
|
54520
|
+
/** Relative hub path to start an interactive account link of an instance of this kind. */
|
|
54521
|
+
connectPath: string().min(1).optional(),
|
|
54522
|
+
/** Relative hub path to disconnect that account. */
|
|
54523
|
+
disconnectPath: string().min(1).optional()
|
|
54524
|
+
});
|
|
54296
54525
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54526
|
+
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54527
|
+
role: _enum([
|
|
54528
|
+
"devices",
|
|
54529
|
+
"services",
|
|
54530
|
+
"both"
|
|
54531
|
+
]),
|
|
54532
|
+
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54533
|
+
discovery: object({
|
|
54534
|
+
mode: _enum([
|
|
54535
|
+
"none",
|
|
54536
|
+
"lan",
|
|
54537
|
+
"account"
|
|
54538
|
+
]),
|
|
54539
|
+
scopedToInstance: boolean()
|
|
54540
|
+
}).optional(),
|
|
54297
54541
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54298
|
-
instanceMode:
|
|
54542
|
+
instanceMode: IntegrationInstanceModeSchema,
|
|
54299
54543
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
54300
54544
|
kind: string(),
|
|
54301
54545
|
/** True when `testInstance` really probes the remote. */
|
|
54302
|
-
canTest: boolean()
|
|
54546
|
+
canTest: boolean(),
|
|
54547
|
+
/**
|
|
54548
|
+
* The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
|
|
54549
|
+
* Add flow asks which first and sends it as `createInstance.kind`.
|
|
54550
|
+
*/
|
|
54551
|
+
kinds: array(IntegrationInstanceKindSchema).optional(),
|
|
54552
|
+
/**
|
|
54553
|
+
* The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
|
|
54554
|
+
* devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
|
|
54555
|
+
*/
|
|
54556
|
+
allowRestoreId: boolean().optional(),
|
|
54557
|
+
/**
|
|
54558
|
+
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54559
|
+
* send an id (the UI then mints an opaque one).
|
|
54560
|
+
*/
|
|
54561
|
+
mintsId: boolean().optional()
|
|
54303
54562
|
});
|
|
54304
54563
|
var IntegrationInstanceStatusSchema = object({
|
|
54305
54564
|
state: _enum([
|
|
@@ -54308,7 +54567,9 @@ var IntegrationInstanceStatusSchema = object({
|
|
|
54308
54567
|
"error",
|
|
54309
54568
|
"unknown"
|
|
54310
54569
|
]),
|
|
54311
|
-
detail: string().optional()
|
|
54570
|
+
detail: string().optional(),
|
|
54571
|
+
/** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
|
|
54572
|
+
label: string().optional()
|
|
54312
54573
|
});
|
|
54313
54574
|
var IntegrationInstanceSchema = object({
|
|
54314
54575
|
id: IntegrationInstanceIdSchema,
|
|
@@ -54316,13 +54577,18 @@ var IntegrationInstanceSchema = object({
|
|
|
54316
54577
|
/** The addon's own rule (an URL is present, a client id is present...). */
|
|
54317
54578
|
configured: boolean(),
|
|
54318
54579
|
/**
|
|
54319
|
-
* The instance's own on/off switch (D996)
|
|
54320
|
-
*
|
|
54580
|
+
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54581
|
+
* so a row written before the field existed is on). Absent when the `integrations` registry
|
|
54582
|
+
* owns the switch (`describe().role` is `devices`): read it from the registry row.
|
|
54321
54583
|
*/
|
|
54322
|
-
enabled: boolean(),
|
|
54584
|
+
enabled: boolean().optional(),
|
|
54585
|
+
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
54586
|
+
kind: string().optional(),
|
|
54323
54587
|
/** Values for the instance form; a secret is a `SecretFieldView`, never text. */
|
|
54324
54588
|
formValues: record(string(), unknown()),
|
|
54325
|
-
status: IntegrationInstanceStatusSchema.optional()
|
|
54589
|
+
status: IntegrationInstanceStatusSchema.optional(),
|
|
54590
|
+
/** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
|
|
54591
|
+
lastCheckedAt: number().optional()
|
|
54326
54592
|
});
|
|
54327
54593
|
var IntegrationInstancePatchSchema = object({
|
|
54328
54594
|
id: IntegrationInstanceIdSchema,
|
|
@@ -54340,10 +54606,14 @@ var integrationInstancesCapability = {
|
|
|
54340
54606
|
instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54341
54607
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54342
54608
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54343
|
-
/**
|
|
54609
|
+
/**
|
|
54610
|
+
* Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
|
|
54611
|
+
* without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
|
|
54612
|
+
*/
|
|
54344
54613
|
createInstance: method(object({
|
|
54345
|
-
id: IntegrationInstanceIdSchema,
|
|
54346
|
-
name: string().min(1)
|
|
54614
|
+
id: IntegrationInstanceIdSchema.optional(),
|
|
54615
|
+
name: string().min(1),
|
|
54616
|
+
kind: string().min(1).optional()
|
|
54347
54617
|
}), object({ id: string() }), {
|
|
54348
54618
|
kind: "mutation",
|
|
54349
54619
|
auth: "admin"
|
|
@@ -56175,6 +56445,11 @@ var LogEntrySchema = object({
|
|
|
56175
56445
|
* flight, and not asking for the next slice ends the scan.
|
|
56176
56446
|
*/
|
|
56177
56447
|
var LogReadQuerySchema = object({
|
|
56448
|
+
/**
|
|
56449
|
+
* Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
|
|
56450
|
+
* the provider's first readable one, so a caller written before instances existed is unchanged.
|
|
56451
|
+
*/
|
|
56452
|
+
instanceId: string().min(1).max(200).optional(),
|
|
56178
56453
|
/** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
|
|
56179
56454
|
requestId: string().min(1).max(64).optional(),
|
|
56180
56455
|
/** The device the line is about (`tags.deviceId`, numeric). */
|
|
@@ -56237,6 +56512,8 @@ var LogReadResultSchema = object({
|
|
|
56237
56512
|
/** True when `cancelRead` ended this slice early. */
|
|
56238
56513
|
cancelled: boolean().optional()
|
|
56239
56514
|
});
|
|
56515
|
+
/** Names one destination instance; absent ⇒ the provider's first readable one. */
|
|
56516
|
+
var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
|
|
56240
56517
|
var LogReadCapabilitiesSchema = object({
|
|
56241
56518
|
/** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
|
|
56242
56519
|
readable: boolean(),
|
|
@@ -56255,7 +56532,7 @@ var LogReadCapabilitiesSchema = object({
|
|
|
56255
56532
|
/** How far back the store reaches, when the provider knows (days). */
|
|
56256
56533
|
retentionDays: number().nullable()
|
|
56257
56534
|
});
|
|
56258
|
-
method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(
|
|
56535
|
+
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() }), {
|
|
56259
56536
|
kind: "mutation",
|
|
56260
56537
|
auth: "admin"
|
|
56261
56538
|
});
|
|
@@ -67843,6 +68120,49 @@ object({
|
|
|
67843
68120
|
DeviceType.PetFeeder,
|
|
67844
68121
|
DeviceType.Heater
|
|
67845
68122
|
].filter((type) => type !== DeviceType.Sensor);
|
|
68123
|
+
var PowerSourceRefusalReasonSchema = _enum([
|
|
68124
|
+
"no-power-source",
|
|
68125
|
+
"switch-missing",
|
|
68126
|
+
"switch-offline",
|
|
68127
|
+
"switch-unknown",
|
|
68128
|
+
"restart-in-progress",
|
|
68129
|
+
"switch-call-failed"
|
|
68130
|
+
]);
|
|
68131
|
+
var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
|
|
68132
|
+
accepted: literal(false),
|
|
68133
|
+
reason: PowerSourceRefusalReasonSchema,
|
|
68134
|
+
/** One line for the operator, naming the switch. */
|
|
68135
|
+
message: string()
|
|
68136
|
+
})]);
|
|
68137
|
+
var PowerSourceInfoSchema = object({
|
|
68138
|
+
/** False when the device has no power source linked; the rest is then empty. */
|
|
68139
|
+
linked: boolean(),
|
|
68140
|
+
switchDeviceId: number().nullable(),
|
|
68141
|
+
switchName: string().nullable(),
|
|
68142
|
+
/** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
|
|
68143
|
+
switchOn: boolean().nullable(),
|
|
68144
|
+
switchOnline: boolean().nullable(),
|
|
68145
|
+
restartInProgress: boolean(),
|
|
68146
|
+
offSeconds: number().int()
|
|
68147
|
+
});
|
|
68148
|
+
object({
|
|
68149
|
+
/** Null while the switch has not reported: unknown is never `false` (D393). */
|
|
68150
|
+
switchOn: boolean().nullable(),
|
|
68151
|
+
offSeconds: number().int(),
|
|
68152
|
+
lastFetchedAt: number()
|
|
68153
|
+
});
|
|
68154
|
+
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;
|
|
68155
|
+
var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
|
|
68156
|
+
systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68157
|
+
kind: "mutation",
|
|
68158
|
+
auth: "admin"
|
|
68159
|
+
}), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68160
|
+
kind: "mutation",
|
|
68161
|
+
auth: "admin"
|
|
68162
|
+
}), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
|
|
68163
|
+
kind: "mutation",
|
|
68164
|
+
auth: "admin"
|
|
68165
|
+
});
|
|
67846
68166
|
/**
|
|
67847
68167
|
* Presence cap. Models HA `person.*` and `device_tracker.*` entities
|
|
67848
68168
|
* on `DeviceType.Presence`. Read-only — no setters: presence is
|
|
@@ -75915,6 +76235,25 @@ function buildDescriptor(capName, kind) {
|
|
|
75915
76235
|
* contributes one entry per bound cap present in this map.
|
|
75916
76236
|
*/
|
|
75917
76237
|
var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
|
|
76238
|
+
/**
|
|
76239
|
+
* What a remote key is CALLED and what it LOOKS like, for every role (D963),
|
|
76240
|
+
* shared by the admin UI and the viewer. A role is data on the wire; each
|
|
76241
|
+
* client resolves its name from `label` (English and Italian side by side) and
|
|
76242
|
+
* its glyph from `icon`, a lucide id from the shared icon catalogue — the
|
|
76243
|
+
* server sends an id, a client maps it to its own icon set.
|
|
76244
|
+
*
|
|
76245
|
+
* `legend` is text printed on the key INSTEAD of a glyph (a digit has no
|
|
76246
|
+
* pictogram): a client that can draw text shows it, one that cannot falls back
|
|
76247
|
+
* to `icon`.
|
|
76248
|
+
*/
|
|
76249
|
+
function digit(n) {
|
|
76250
|
+
return {
|
|
76251
|
+
label: t(n, n),
|
|
76252
|
+
icon: "hash",
|
|
76253
|
+
legend: n
|
|
76254
|
+
};
|
|
76255
|
+
}
|
|
76256
|
+
digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
|
|
75918
76257
|
DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
|
|
75919
76258
|
var btn = (idSuffix, row, col, init) => ({
|
|
75920
76259
|
idSuffix,
|
|
@@ -76042,6 +76381,34 @@ discriminatedUnion("kind", [object({
|
|
|
76042
76381
|
kind: literal("pronto"),
|
|
76043
76382
|
code: string()
|
|
76044
76383
|
})]);
|
|
76384
|
+
/**
|
|
76385
|
+
* Propose a running threshold from a device's own power history (planning#405).
|
|
76386
|
+
*
|
|
76387
|
+
* Pure and deterministic: the same series gives the same answer. The series is
|
|
76388
|
+
* a HELD-VALUE step series — a point's value stands until the next point — which
|
|
76389
|
+
* is how device-history stores a gauge, so "time at a level" is exact, not a
|
|
76390
|
+
* count of samples.
|
|
76391
|
+
*
|
|
76392
|
+
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
76393
|
+
* near F. A device that is not near one level most of the time has no floor.
|
|
76394
|
+
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
76395
|
+
* 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
|
|
76396
|
+
* the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
|
|
76397
|
+
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
76398
|
+
* grid a person would type; stop dwell covers the longest pause; start dwell
|
|
76399
|
+
* covers the longest standby blip above T.
|
|
76400
|
+
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
76401
|
+
* run must hold exactly one true interval and nothing may flap outside.
|
|
76402
|
+
*/
|
|
76403
|
+
var SECOND_MS = 1e3;
|
|
76404
|
+
var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
76405
|
+
24 * (60 * MINUTE_MS$1);
|
|
76406
|
+
10 * MINUTE_MS$1;
|
|
76407
|
+
30 * SECOND_MS;
|
|
76408
|
+
60 * SECOND_MS;
|
|
76409
|
+
20 * MINUTE_MS$1;
|
|
76410
|
+
10 * SECOND_MS;
|
|
76411
|
+
10 * SECOND_MS;
|
|
76045
76412
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
76046
76413
|
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
76047
76414
|
String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
|
|
@@ -77583,6 +77950,13 @@ Object.freeze({
|
|
|
77583
77950
|
access: "create",
|
|
77584
77951
|
role: "admin"
|
|
77585
77952
|
},
|
|
77953
|
+
"coreBlocks.proposeRunningThreshold": {
|
|
77954
|
+
capName: "core-blocks",
|
|
77955
|
+
capScope: "system",
|
|
77956
|
+
addonId: null,
|
|
77957
|
+
access: "view",
|
|
77958
|
+
role: "admin"
|
|
77959
|
+
},
|
|
77586
77960
|
"coreBlocks.reportAutomationRun": {
|
|
77587
77961
|
capName: "core-blocks",
|
|
77588
77962
|
capScope: "system",
|
|
@@ -78094,6 +78468,13 @@ Object.freeze({
|
|
|
78094
78468
|
access: "view",
|
|
78095
78469
|
role: "admin"
|
|
78096
78470
|
},
|
|
78471
|
+
"deviceExport.listInstances": {
|
|
78472
|
+
capName: "device-export",
|
|
78473
|
+
capScope: "system",
|
|
78474
|
+
addonId: null,
|
|
78475
|
+
access: "view",
|
|
78476
|
+
role: "admin"
|
|
78477
|
+
},
|
|
78097
78478
|
"deviceExport.listSupportedDeviceKinds": {
|
|
78098
78479
|
capName: "device-export",
|
|
78099
78480
|
capScope: "system",
|
|
@@ -87066,6 +87447,11 @@ Object.freeze({
|
|
|
87066
87447
|
form: "single",
|
|
87067
87448
|
optional: false
|
|
87068
87449
|
}],
|
|
87450
|
+
"coreBlocks.proposeRunningThreshold": [{
|
|
87451
|
+
name: "deviceId",
|
|
87452
|
+
form: "single",
|
|
87453
|
+
optional: false
|
|
87454
|
+
}],
|
|
87069
87455
|
"cover.close": [{
|
|
87070
87456
|
name: "deviceId",
|
|
87071
87457
|
form: "single",
|
|
@@ -89729,99 +90115,6 @@ Object.freeze({
|
|
|
89729
90115
|
"network-access": "ingress",
|
|
89730
90116
|
"smtp-provider": "email"
|
|
89731
90117
|
});
|
|
89732
|
-
/**
|
|
89733
|
-
* A saved Customize assignment (D936). The schema is the type: callers use
|
|
89734
|
-
* `z.infer`, they do not restate the shape.
|
|
89735
|
-
*/
|
|
89736
|
-
var OverrideSourceSchema = object({
|
|
89737
|
-
addonId: string().min(1),
|
|
89738
|
-
stableId: string().min(1),
|
|
89739
|
-
cap: string().min(1),
|
|
89740
|
-
fieldPath: string().min(1)
|
|
89741
|
-
});
|
|
89742
|
-
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
89743
|
-
object({ kind: literal("identity") }),
|
|
89744
|
-
object({ kind: literal("invert") }),
|
|
89745
|
-
object({
|
|
89746
|
-
kind: literal("threshold"),
|
|
89747
|
-
comparison: _enum(["gte", "lte"]),
|
|
89748
|
-
threshold: number(),
|
|
89749
|
-
startDwellMs: number().nonnegative(),
|
|
89750
|
-
stopDwellMs: number().nonnegative()
|
|
89751
|
-
}),
|
|
89752
|
-
object({
|
|
89753
|
-
kind: literal("linear"),
|
|
89754
|
-
scale: number(),
|
|
89755
|
-
offset: number(),
|
|
89756
|
-
clampMin: number().optional(),
|
|
89757
|
-
clampMax: number().optional()
|
|
89758
|
-
}),
|
|
89759
|
-
object({
|
|
89760
|
-
kind: literal("enum-map"),
|
|
89761
|
-
mapping: record(string(), string().nullable())
|
|
89762
|
-
}),
|
|
89763
|
-
object({ kind: literal("number") })
|
|
89764
|
-
]);
|
|
89765
|
-
var ScalarOverrideDraftSchema = object({
|
|
89766
|
-
kind: literal("scalar"),
|
|
89767
|
-
cap: string().min(1),
|
|
89768
|
-
targetId: string().min(1),
|
|
89769
|
-
source: OverrideSourceSchema,
|
|
89770
|
-
transform: CustomizeTransformDraftSchema
|
|
89771
|
-
});
|
|
89772
|
-
var KeyedArrayOverrideDraftSchema = object({
|
|
89773
|
-
kind: literal("keyedArray"),
|
|
89774
|
-
cap: string().min(1),
|
|
89775
|
-
targetId: string().min(1),
|
|
89776
|
-
key: string().min(1),
|
|
89777
|
-
label: string().min(1),
|
|
89778
|
-
fieldPath: string().min(1),
|
|
89779
|
-
source: OverrideSourceSchema,
|
|
89780
|
-
transform: CustomizeTransformDraftSchema
|
|
89781
|
-
});
|
|
89782
|
-
var PulseOverrideDraftSchema = object({
|
|
89783
|
-
kind: literal("pulse"),
|
|
89784
|
-
cap: string().min(1),
|
|
89785
|
-
targetId: string().min(1),
|
|
89786
|
-
enabled: boolean(),
|
|
89787
|
-
debounceMs: number().nonnegative(),
|
|
89788
|
-
edges: array(_enum([
|
|
89789
|
-
"rising",
|
|
89790
|
-
"button",
|
|
89791
|
-
"native-event"
|
|
89792
|
-
])).min(1).optional(),
|
|
89793
|
-
sources: array(OverrideSourceSchema).min(1)
|
|
89794
|
-
});
|
|
89795
|
-
var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
|
|
89796
|
-
"in-addition",
|
|
89797
|
-
"confirm",
|
|
89798
|
-
"replace"
|
|
89799
|
-
]).optional() });
|
|
89800
|
-
discriminatedUnion("kind", [
|
|
89801
|
-
ScalarOverrideDraftSchema,
|
|
89802
|
-
KeyedArrayOverrideDraftSchema,
|
|
89803
|
-
PulseOverrideDraftSchema,
|
|
89804
|
-
object({
|
|
89805
|
-
kind: literal("span"),
|
|
89806
|
-
cap: string().min(1),
|
|
89807
|
-
targetId: string().min(1),
|
|
89808
|
-
timeoutMs: number().nonnegative(),
|
|
89809
|
-
cooldownMs: number().nonnegative().optional(),
|
|
89810
|
-
sources: array(SpanSourceDraftSchema)
|
|
89811
|
-
})
|
|
89812
|
-
]);
|
|
89813
|
-
object({
|
|
89814
|
-
targetId: string().min(1),
|
|
89815
|
-
configured: boolean(),
|
|
89816
|
-
source: _enum(["native", "assigned"]),
|
|
89817
|
-
state: _enum([
|
|
89818
|
-
"active",
|
|
89819
|
-
"stale",
|
|
89820
|
-
"released",
|
|
89821
|
-
"unavailable"
|
|
89822
|
-
]),
|
|
89823
|
-
reason: string().nullable()
|
|
89824
|
-
});
|
|
89825
90118
|
var G711_SCALE_CORRECTION_DB = {
|
|
89826
90119
|
PCMU: 20 * Math.log10(4),
|
|
89827
90120
|
PCMA: 20 * Math.log10(8)
|
|
@@ -101786,7 +102079,7 @@ var ALEXA_ADDON_ID = "export-alexa";
|
|
|
101786
102079
|
* key, id `<addonId>.<key>`, data `{ addonId, key, value }` (never a per-addon scoped table,
|
|
101787
102080
|
* which exists only when something lazily declared it).
|
|
101788
102081
|
*/
|
|
101789
|
-
var ADDON_SETTINGS_TABLE$
|
|
102082
|
+
var ADDON_SETTINGS_TABLE$2 = "addon-settings";
|
|
101790
102083
|
var RETIRED_PUBLIC_URL_KEYS = ["publicHubUrl"];
|
|
101791
102084
|
async function planDropPublicHubUrl(ports) {
|
|
101792
102085
|
const stored = await ports.readStored();
|
|
@@ -101795,7 +102088,7 @@ async function planDropPublicHubUrl(ports) {
|
|
|
101795
102088
|
const rowId = (key) => `${ALEXA_ADDON_ID}.${key}`;
|
|
101796
102089
|
return { edits: [{
|
|
101797
102090
|
op: "deleteKeys",
|
|
101798
|
-
scope: ADDON_SETTINGS_TABLE$
|
|
102091
|
+
scope: ADDON_SETTINGS_TABLE$2,
|
|
101799
102092
|
keys: present.map(rowId),
|
|
101800
102093
|
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId(key), {
|
|
101801
102094
|
addonId: ALEXA_ADDON_ID,
|
|
@@ -101880,6 +102173,130 @@ var alexaSkillLinksKind = defineEntryKind("skill-links", {
|
|
|
101880
102173
|
}),
|
|
101881
102174
|
secretArrayKeys: { tokens: "userId" }
|
|
101882
102175
|
});
|
|
102176
|
+
/** The exposure keys that moved into the `skill-exports` record; the migrations name them. */
|
|
102177
|
+
var MOVED_EXPOSURE_KEYS = ["exposed", "exposedActions"];
|
|
102178
|
+
var ExportDeviceSettingsSchema = object({
|
|
102179
|
+
streamPreference: string(),
|
|
102180
|
+
sourceProfile: CamProfileSchema.optional(),
|
|
102181
|
+
allowTranscode: boolean().optional()
|
|
102182
|
+
});
|
|
102183
|
+
var ExposedDeviceEntrySchema = object({
|
|
102184
|
+
deviceId: number(),
|
|
102185
|
+
exposedAt: number(),
|
|
102186
|
+
settings: ExportDeviceSettingsSchema.optional()
|
|
102187
|
+
});
|
|
102188
|
+
var ActionSceneEntrySchema = object({
|
|
102189
|
+
actionId: string(),
|
|
102190
|
+
displayName: string(),
|
|
102191
|
+
addedAt: number()
|
|
102192
|
+
});
|
|
102193
|
+
var SkillExportsBodySchema = object({
|
|
102194
|
+
name: string().min(1),
|
|
102195
|
+
devices: array(ExposedDeviceEntrySchema),
|
|
102196
|
+
actions: array(ActionSceneEntrySchema)
|
|
102197
|
+
});
|
|
102198
|
+
var SKILL_EXPORTS_KIND_NAME = "skill-exports";
|
|
102199
|
+
var SKILL_EXPORTS_NAME = "Alexa exposure";
|
|
102200
|
+
var alexaSkillExportsKind = defineEntryKind(SKILL_EXPORTS_KIND_NAME, {
|
|
102201
|
+
title: "Alexa exposure",
|
|
102202
|
+
nameField: "name",
|
|
102203
|
+
schema: SkillExportsBodySchema
|
|
102204
|
+
});
|
|
102205
|
+
var EMPTY_SKILL_EXPORTS = {
|
|
102206
|
+
name: SKILL_EXPORTS_NAME,
|
|
102207
|
+
devices: [],
|
|
102208
|
+
actions: []
|
|
102209
|
+
};
|
|
102210
|
+
//#endregion
|
|
102211
|
+
//#region src/migrations/exposure-to-record.ts
|
|
102212
|
+
/**
|
|
102213
|
+
* The Alexa exposure lists move into the `skill-exports` record (planning#408 P4). Two
|
|
102214
|
+
* migrations, both `block-owner`: the addon must not serve a membership it cannot trust, and
|
|
102215
|
+
* after them nothing reads the old keys.
|
|
102216
|
+
*
|
|
102217
|
+
* 1. `moveExposureToRecord` (procedure): `exposed` and `exposedActions` become the record under
|
|
102218
|
+
* the instance id. An existing record is never overwritten. A record this pass just wrote is
|
|
102219
|
+
* read BACK and must equal what the settings carried, or the pass throws.
|
|
102220
|
+
* 2. `planDropMovedExposure` (plan): the two keys are deleted only while the record holds every
|
|
102221
|
+
* device and action the settings carried; a record that cannot be read leaves them in place.
|
|
102222
|
+
*/
|
|
102223
|
+
var ADDON_SETTINGS_TABLE$1 = "addon-settings";
|
|
102224
|
+
function devicesOf(value) {
|
|
102225
|
+
if (!Array.isArray(value)) return [];
|
|
102226
|
+
return value.flatMap((entry) => {
|
|
102227
|
+
const parsed = ExposedDeviceEntrySchema.safeParse(entry);
|
|
102228
|
+
return parsed.success ? [parsed.data] : [];
|
|
102229
|
+
});
|
|
102230
|
+
}
|
|
102231
|
+
function actionsOf(value) {
|
|
102232
|
+
if (!Array.isArray(value)) return [];
|
|
102233
|
+
return value.flatMap((entry) => {
|
|
102234
|
+
const parsed = ActionSceneEntrySchema.safeParse(entry);
|
|
102235
|
+
return parsed.success ? [parsed.data] : [];
|
|
102236
|
+
});
|
|
102237
|
+
}
|
|
102238
|
+
/** Key-order-independent JSON, so "identical" does not depend on how a store orders keys. */
|
|
102239
|
+
function canonical$1(value) {
|
|
102240
|
+
if (Array.isArray(value)) return `[${value.map(canonical$1).join(",")}]`;
|
|
102241
|
+
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(",")}}`;
|
|
102242
|
+
return JSON.stringify(value) ?? "null";
|
|
102243
|
+
}
|
|
102244
|
+
async function moveExposureToRecord(ports) {
|
|
102245
|
+
const stored = await ports.readRawStored();
|
|
102246
|
+
if (!MOVED_EXPOSURE_KEYS.some((key) => key in stored)) return {
|
|
102247
|
+
outcome: "already-done",
|
|
102248
|
+
summary: { moved: false }
|
|
102249
|
+
};
|
|
102250
|
+
const devices = devicesOf(stored["exposed"]);
|
|
102251
|
+
const actions = actionsOf(stored["exposedActions"]);
|
|
102252
|
+
const dropped = (Array.isArray(stored["exposed"]) ? stored["exposed"].length : 0) - devices.length + ((Array.isArray(stored["exposedActions"]) ? stored["exposedActions"].length : 0) - actions.length);
|
|
102253
|
+
if (dropped > 0) ports.warn(`Alexa migration: ${dropped} exposure entr(ies) were not understood and are left out`);
|
|
102254
|
+
const body = {
|
|
102255
|
+
name: SKILL_EXPORTS_NAME,
|
|
102256
|
+
devices,
|
|
102257
|
+
actions
|
|
102258
|
+
};
|
|
102259
|
+
if (await ports.putExports(body) === "exists") return {
|
|
102260
|
+
outcome: "already-done",
|
|
102261
|
+
summary: { moved: false }
|
|
102262
|
+
};
|
|
102263
|
+
const held = await ports.readExports();
|
|
102264
|
+
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");
|
|
102265
|
+
return {
|
|
102266
|
+
outcome: "done",
|
|
102267
|
+
summary: {
|
|
102268
|
+
moved: true,
|
|
102269
|
+
devices: devices.length,
|
|
102270
|
+
actions: actions.length
|
|
102271
|
+
}
|
|
102272
|
+
};
|
|
102273
|
+
}
|
|
102274
|
+
var rowId$1 = (key) => `${ALEXA_INSTANCE_ID}.${key}`;
|
|
102275
|
+
async function planDropMovedExposure(ports) {
|
|
102276
|
+
const stored = await ports.readRawStored();
|
|
102277
|
+
const present = MOVED_EXPOSURE_KEYS.filter((key) => key in stored);
|
|
102278
|
+
if (present.length === 0) return { edits: [] };
|
|
102279
|
+
const refuse = (reason) => {
|
|
102280
|
+
ports.warn(`Alexa migration: the legacy exposure keys are kept: ${reason}`);
|
|
102281
|
+
throw new Error(`the legacy Alexa exposure keys are not deleted: ${reason}`);
|
|
102282
|
+
};
|
|
102283
|
+
const held = await ports.readExports();
|
|
102284
|
+
if (held === null) return refuse("no exposure record exists");
|
|
102285
|
+
const heldDevices = new Set(held.devices.map((d) => d.deviceId));
|
|
102286
|
+
for (const device of devicesOf(stored["exposed"])) if (!heldDevices.has(device.deviceId)) return refuse(`the record lacks the device ${device.deviceId}`);
|
|
102287
|
+
const heldActions = new Set(held.actions.map((a) => a.actionId));
|
|
102288
|
+
for (const action of actionsOf(stored["exposedActions"])) if (!heldActions.has(action.actionId)) return refuse(`the record lacks the action ${action.actionId}`);
|
|
102289
|
+
return { edits: [{
|
|
102290
|
+
op: "deleteKeys",
|
|
102291
|
+
scope: ADDON_SETTINGS_TABLE$1,
|
|
102292
|
+
keys: present.map(rowId$1),
|
|
102293
|
+
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId$1(key), {
|
|
102294
|
+
addonId: ALEXA_INSTANCE_ID,
|
|
102295
|
+
key,
|
|
102296
|
+
value: stored[key]
|
|
102297
|
+
}])))
|
|
102298
|
+
}] };
|
|
102299
|
+
}
|
|
101883
102300
|
//#endregion
|
|
101884
102301
|
//#region src/migrations/settings-to-records.ts
|
|
101885
102302
|
/**
|
|
@@ -102079,7 +102496,9 @@ var DROP_PUBLIC_HUB_URL_ID = "export-alexa/2026-11-02-drop-public-hub-url";
|
|
|
102079
102496
|
var SETTINGS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-settings-to-integration";
|
|
102080
102497
|
var LEDGERS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-ledgers-to-integration";
|
|
102081
102498
|
var DROP_MOVED_SETTINGS_ID = "export-alexa/2026-11-03-drop-moved-settings";
|
|
102082
|
-
var
|
|
102499
|
+
var EXPOSURE_TO_RECORD_ID = "export-alexa/2026-11-04-exposure-to-record";
|
|
102500
|
+
var DROP_MOVED_EXPOSURE_ID = "export-alexa/2026-11-04-drop-moved-exposure";
|
|
102501
|
+
var FIXTURE_MARK = "the endpoint sync state the migration does not know";
|
|
102083
102502
|
/**
|
|
102084
102503
|
* The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
|
|
102085
102504
|
* entry is `tolerate`; until a record exists the addon keeps reading the legacy keys.
|
|
@@ -102148,6 +102567,38 @@ var ADDON_MIGRATIONS = [
|
|
|
102148
102567
|
fixtureMark: FIXTURE_MARK
|
|
102149
102568
|
},
|
|
102150
102569
|
plan: planDropMovedSettings
|
|
102570
|
+
},
|
|
102571
|
+
{
|
|
102572
|
+
meta: {
|
|
102573
|
+
id: EXPOSURE_TO_RECORD_ID,
|
|
102574
|
+
owner: "export-alexa",
|
|
102575
|
+
level: "addon-state",
|
|
102576
|
+
seq: 5,
|
|
102577
|
+
dependsOn: [],
|
|
102578
|
+
store: "settings",
|
|
102579
|
+
scope: "cluster",
|
|
102580
|
+
onFailure: "block-owner",
|
|
102581
|
+
bodyKind: "procedure",
|
|
102582
|
+
description: "Move the exposed devices and actions into the skill-exports record; the record is read back before anything is deleted",
|
|
102583
|
+
fixtureMark: FIXTURE_MARK
|
|
102584
|
+
},
|
|
102585
|
+
procedure: moveExposureToRecord
|
|
102586
|
+
},
|
|
102587
|
+
{
|
|
102588
|
+
meta: {
|
|
102589
|
+
id: DROP_MOVED_EXPOSURE_ID,
|
|
102590
|
+
owner: "export-alexa",
|
|
102591
|
+
level: "addon-state",
|
|
102592
|
+
seq: 6,
|
|
102593
|
+
dependsOn: [EXPOSURE_TO_RECORD_ID],
|
|
102594
|
+
store: "settings",
|
|
102595
|
+
scope: "cluster",
|
|
102596
|
+
onFailure: "block-owner",
|
|
102597
|
+
bodyKind: "plan",
|
|
102598
|
+
description: "Delete the exposed and exposedActions settings keys once the record holds what they carried",
|
|
102599
|
+
fixtureMark: FIXTURE_MARK
|
|
102600
|
+
},
|
|
102601
|
+
plan: planDropMovedExposure
|
|
102151
102602
|
}
|
|
102152
102603
|
];
|
|
102153
102604
|
//#endregion
|
|
@@ -103381,11 +103832,10 @@ var SyncEngine = class {
|
|
|
103381
103832
|
* linkable OAuth client of the hub's core `/oauth2/*` server.
|
|
103382
103833
|
*
|
|
103383
103834
|
* Persistence:
|
|
103384
|
-
*
|
|
103385
|
-
*
|
|
103386
|
-
* `
|
|
103387
|
-
*
|
|
103388
|
-
* of truth.
|
|
103835
|
+
* The skill, its account links and what it exposes are records
|
|
103836
|
+
* (`skills`, `skill-links`, `skill-exports`); the remaining hidden state
|
|
103837
|
+
* lives on `this.config` and writes through `updateGlobalSettings`. There
|
|
103838
|
+
* is NO `<dataDir>/alexa/*.json` sidecar anymore.
|
|
103389
103839
|
*
|
|
103390
103840
|
* Out of scope for this dispatch:
|
|
103391
103841
|
* - AWS Lambda template (CloudFormation + signing image) — the
|
|
@@ -103440,8 +103890,6 @@ var DEFAULT_CONFIG = {
|
|
|
103440
103890
|
lwaClientSecret: "",
|
|
103441
103891
|
advertisedBrokerUrl: "",
|
|
103442
103892
|
region: "NA",
|
|
103443
|
-
exposed: [],
|
|
103444
|
-
exposedActions: [],
|
|
103445
103893
|
linkedAccounts: [],
|
|
103446
103894
|
tokens: [],
|
|
103447
103895
|
exportedEndpoints: {},
|
|
@@ -103497,6 +103945,8 @@ function hasUnresolvedCredential(entry) {
|
|
|
103497
103945
|
if (typeof entry !== "object" || entry === null) return false;
|
|
103498
103946
|
return "accessToken" in entry && isSecretMarker(entry.accessToken) || "refreshToken" in entry && isSecretMarker(entry.refreshToken) || "brokerCredential" in entry && isSecretMarker(entry.brokerCredential);
|
|
103499
103947
|
}
|
|
103948
|
+
/** The one export instance this addon serves. */
|
|
103949
|
+
var EXPORT_ALEXA_ADDON_ID = "export-alexa";
|
|
103500
103950
|
var ExportAlexaAddon = class extends BaseAddon {
|
|
103501
103951
|
/** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
|
|
103502
103952
|
secretStatePaths = [
|
|
@@ -103537,8 +103987,30 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103537
103987
|
skillRow = null;
|
|
103538
103988
|
/** The `skill-links` record, once it exists; until then the legacy ledger keys answer. */
|
|
103539
103989
|
linksRow = null;
|
|
103990
|
+
/**
|
|
103991
|
+
* The `skill-exports` record: what the skill exposes (devices Alexa discovers, actions it sees
|
|
103992
|
+
* as scenes). Loaded once at boot after the migrations; this addon is its only writer, so the
|
|
103993
|
+
* in-memory copy is the synchronous read the event path needs. No settings key backs it.
|
|
103994
|
+
*/
|
|
103995
|
+
exportsRow = EMPTY_SKILL_EXPORTS;
|
|
103540
103996
|
/** The keychain refused the link credentials: the ledger is read-only until it answers (D49). */
|
|
103541
103997
|
linksLocked = false;
|
|
103998
|
+
get exposedDevices() {
|
|
103999
|
+
return this.exportsRow.devices;
|
|
104000
|
+
}
|
|
104001
|
+
/** Persist a change of the exposure: the record first, the in-memory copy after it landed. */
|
|
104002
|
+
async writeExports(patch) {
|
|
104003
|
+
const next = {
|
|
104004
|
+
name: this.exportsRow.name,
|
|
104005
|
+
devices: patch.devices ?? this.exportsRow.devices,
|
|
104006
|
+
actions: patch.actions ?? this.exportsRow.actions
|
|
104007
|
+
};
|
|
104008
|
+
await this.exportsHandle().put({
|
|
104009
|
+
id: ALEXA_INSTANCE_ID,
|
|
104010
|
+
data: next
|
|
104011
|
+
});
|
|
104012
|
+
this.exportsRow = next;
|
|
104013
|
+
}
|
|
103542
104014
|
/**
|
|
103543
104015
|
* The legacy ledger keys as lists. A store written by an older build may hold something that
|
|
103544
104016
|
* is not a list there (a clear instruction stored as the value); the page and the gateway read
|
|
@@ -103590,10 +104062,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103590
104062
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
103591
104063
|
await records.declare({
|
|
103592
104064
|
skills: alexaSkillsKind,
|
|
103593
|
-
"skill-links": alexaSkillLinksKind
|
|
104065
|
+
"skill-links": alexaSkillLinksKind,
|
|
104066
|
+
"skill-exports": alexaSkillExportsKind
|
|
103594
104067
|
});
|
|
103595
104068
|
this.instances = new RecordIntegrationInstances(records, alexaSkillsKind, {
|
|
103596
104069
|
description: {
|
|
104070
|
+
role: "services",
|
|
103597
104071
|
instanceMode: "single",
|
|
103598
104072
|
kind: "skills",
|
|
103599
104073
|
canTest: false
|
|
@@ -103611,6 +104085,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103611
104085
|
});
|
|
103612
104086
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
103613
104087
|
await this.refreshRecords();
|
|
104088
|
+
this.exportsRow = (await this.exportsHandle().get("export-alexa"))?.data ?? EMPTY_SKILL_EXPORTS;
|
|
103614
104089
|
if (!this.config.ingressToken) await this.updateGlobalSettings({ ingressToken: generateIngressToken() });
|
|
103615
104090
|
if (!this.config.snapshotSigningKey) await this.updateGlobalSettings({ snapshotSigningKey: generateIngressToken() });
|
|
103616
104091
|
if (!this.config.visionNamespace) await this.updateGlobalSettings({ visionNamespace: (0, node_crypto.randomUUID)() });
|
|
@@ -103629,7 +104104,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103629
104104
|
this.visibilityRef = new AccountVisibilityMirror({
|
|
103630
104105
|
gate: this.accessGateRef,
|
|
103631
104106
|
listLinkedUserIds: () => this.view.linkedAccounts.map((a) => a.userId),
|
|
103632
|
-
listExposedDeviceIds: () => this.
|
|
104107
|
+
listExposedDeviceIds: () => this.exposedDevices.map((e) => e.deviceId),
|
|
103633
104108
|
getStored: () => this.config.accountVisibility,
|
|
103634
104109
|
setStored: (next) => this.updateGlobalSettings({ accountVisibility: next }),
|
|
103635
104110
|
logger: this.ctx.logger
|
|
@@ -103639,7 +104114,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103639
104114
|
logger: this.ctx.logger,
|
|
103640
104115
|
integrationOn: () => this.view.objectDetection,
|
|
103641
104116
|
snapshotsOn: () => this.view.snapshots,
|
|
103642
|
-
isExposed: (deviceId) => this.
|
|
104117
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId),
|
|
103643
104118
|
knownClasses: (deviceId) => this.config.detectionClasses[deviceId]?.classes ?? [],
|
|
103644
104119
|
namespace: () => this.config.visionNamespace,
|
|
103645
104120
|
publicEndpoint: this.publicEndpoint,
|
|
@@ -103657,36 +104132,61 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103657
104132
|
canPush: () => this.view.tokens.length > 0,
|
|
103658
104133
|
postAddOrUpdate: (userId, endpoints) => this.requireGateway().postReport(userId, (accessToken) => buildAddOrUpdateReportPayload(userId, endpoints, accessToken), `action scenes add/update (${endpoints.length})`),
|
|
103659
104134
|
postDelete: (userId, ids) => this.requireGateway().postReport(userId, (accessToken) => buildDeleteReportPayload(userId, ids, accessToken), `action scenes delete (${ids.length})`),
|
|
103660
|
-
persist: (entries) => this.
|
|
103661
|
-
}, this.
|
|
104135
|
+
persist: (entries) => this.writeExports({ actions: [...entries] })
|
|
104136
|
+
}, this.exportsRow.actions);
|
|
103662
104137
|
const actionScenes = this.actionScenes;
|
|
103663
104138
|
actionScenes.reconcile().catch((err) => {
|
|
103664
104139
|
this.ctx.logger.warn("export-alexa: action scene reconcile at boot failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
103665
104140
|
});
|
|
104141
|
+
const ownInstance = (instanceId) => assertOwnExportInstance("export-alexa", EXPORT_ALEXA_ADDON_ID, instanceId);
|
|
103666
104142
|
const deviceExportProvider = {
|
|
103667
|
-
getStatus: async () =>
|
|
103668
|
-
|
|
103669
|
-
|
|
103670
|
-
|
|
103671
|
-
|
|
103672
|
-
|
|
103673
|
-
|
|
103674
|
-
|
|
103675
|
-
|
|
104143
|
+
getStatus: async (input) => {
|
|
104144
|
+
ownInstance(statusInstanceOf(input));
|
|
104145
|
+
return {
|
|
104146
|
+
linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
|
|
104147
|
+
exposedDeviceCount: this.exposedDevices.length,
|
|
104148
|
+
setup: await this.buildSetupBlock()
|
|
104149
|
+
};
|
|
104150
|
+
},
|
|
104151
|
+
listInstances: async () => [{
|
|
104152
|
+
instanceId: EXPORT_ALEXA_ADDON_ID,
|
|
104153
|
+
name: "Alexa",
|
|
104154
|
+
enabled: true,
|
|
104155
|
+
kind: "alexa-skill"
|
|
104156
|
+
}],
|
|
104157
|
+
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
104158
|
+
ownInstance(instanceId);
|
|
104159
|
+
return [...SUPPORTED_KINDS];
|
|
104160
|
+
},
|
|
104161
|
+
listExposedDevices: async ({ instanceId }) => {
|
|
104162
|
+
ownInstance(instanceId);
|
|
104163
|
+
return this.exposedDevices.map((e) => ({ deviceId: String(e.deviceId) }));
|
|
104164
|
+
},
|
|
104165
|
+
exposeDevice: async ({ instanceId, deviceId }) => {
|
|
104166
|
+
ownInstance(instanceId);
|
|
104167
|
+
return this.exposeDevice(deviceId);
|
|
104168
|
+
},
|
|
104169
|
+
unexposeDevice: async ({ instanceId, deviceId }) => {
|
|
104170
|
+
ownInstance(instanceId);
|
|
104171
|
+
return this.unexposeDevice(deviceId);
|
|
104172
|
+
},
|
|
103676
104173
|
listSupportedEntityKinds: async () => ["device", "action"],
|
|
103677
|
-
listExposedEntities: async () => {
|
|
104174
|
+
listExposedEntities: async ({ instanceId }) => {
|
|
104175
|
+
ownInstance(instanceId);
|
|
103678
104176
|
await actionScenes.reconcile();
|
|
103679
|
-
return [...this.
|
|
104177
|
+
return [...this.exposedDevices.map((e) => ({ entity: {
|
|
103680
104178
|
kind: "device",
|
|
103681
104179
|
deviceId: String(e.deviceId)
|
|
103682
104180
|
} })), ...actionScenes.list()];
|
|
103683
104181
|
},
|
|
103684
|
-
exposeEntity: async ({ entity }) => {
|
|
104182
|
+
exposeEntity: async ({ instanceId, entity }) => {
|
|
104183
|
+
ownInstance(instanceId);
|
|
103685
104184
|
if (entity.kind === "device") return this.exposeDevice(entity.deviceId);
|
|
103686
104185
|
if (entity.kind === "action") return actionScenes.expose(entity.actionId);
|
|
103687
104186
|
throw new Error("export-alexa: a notification target cannot be exported to Alexa");
|
|
103688
104187
|
},
|
|
103689
|
-
unexposeEntity: async ({ entity }) => {
|
|
104188
|
+
unexposeEntity: async ({ instanceId, entity }) => {
|
|
104189
|
+
ownInstance(instanceId);
|
|
103690
104190
|
if (entity.kind === "device") return this.unexposeDevice(entity.deviceId);
|
|
103691
104191
|
if (entity.kind === "action") return actionScenes.unexpose(entity.actionId);
|
|
103692
104192
|
throw new Error("export-alexa: a notification target cannot be exported to Alexa");
|
|
@@ -103703,18 +104203,18 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103703
104203
|
discovery: {
|
|
103704
104204
|
ctx: this.ctx,
|
|
103705
104205
|
logger: this.ctx.logger,
|
|
103706
|
-
listExposed: async () => this.
|
|
104206
|
+
listExposed: async () => this.exposedDevices,
|
|
103707
104207
|
buildEndpoints: (deviceId) => this.buildEndpointsForOneDevice(deviceId)
|
|
103708
104208
|
},
|
|
103709
104209
|
cameraStream: {
|
|
103710
104210
|
ctx: this.ctx,
|
|
103711
104211
|
logger: this.ctx.logger,
|
|
103712
|
-
listExposed: () => this.
|
|
104212
|
+
listExposed: () => this.exposedDevices
|
|
103713
104213
|
},
|
|
103714
104214
|
rtcSession: {
|
|
103715
104215
|
ctx: this.ctx,
|
|
103716
104216
|
logger: this.ctx.logger,
|
|
103717
|
-
listExposed: () => this.
|
|
104217
|
+
listExposed: () => this.exposedDevices
|
|
103718
104218
|
},
|
|
103719
104219
|
ptzPreset: {
|
|
103720
104220
|
ctx: this.ctx,
|
|
@@ -103806,13 +104306,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103806
104306
|
this.egressPrewarm = new AlexaEgressPrewarm({
|
|
103807
104307
|
api: this.ctx.api,
|
|
103808
104308
|
logger: this.ctx.logger,
|
|
103809
|
-
listExposed: () => this.
|
|
104309
|
+
listExposed: () => this.exposedDevices,
|
|
103810
104310
|
hasLiveSession: (deviceId) => heldEgressHandles().some((h) => h.deviceId === deviceId)
|
|
103811
104311
|
});
|
|
103812
104312
|
this.lwaGateway = new LwaEventGateway({
|
|
103813
104313
|
ctx: this.ctx,
|
|
103814
104314
|
logger: this.ctx.logger,
|
|
103815
|
-
listExposed: () => this.
|
|
104315
|
+
listExposed: () => this.exposedDevices,
|
|
103816
104316
|
onExposedDoorbellPress: (deviceId) => {
|
|
103817
104317
|
this.egressPrewarm?.onPress(deviceId);
|
|
103818
104318
|
},
|
|
@@ -103831,7 +104331,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103831
104331
|
this.detectionFeed = new DetectionSensorFeed({
|
|
103832
104332
|
eventBus: this.ctx.eventBus,
|
|
103833
104333
|
enabled: () => this.view.detectionSensors,
|
|
103834
|
-
isExposed: (deviceId) => this.
|
|
104334
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId),
|
|
103835
104335
|
readActiveTracks: async (deviceId) => {
|
|
103836
104336
|
return (await this.ctx.api.pipelineAnalytics.getActiveTracks.query({ deviceId })).map((t) => ({
|
|
103837
104337
|
trackId: t.trackId,
|
|
@@ -103875,7 +104375,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103875
104375
|
this.stateReconciler.start();
|
|
103876
104376
|
this.syncEngine = new SyncEngine({
|
|
103877
104377
|
logger: this.ctx.logger,
|
|
103878
|
-
listExposed: () => this.
|
|
104378
|
+
listExposed: () => this.exposedDevices,
|
|
103879
104379
|
listLinkedAccounts: () => this.view.linkedAccounts,
|
|
103880
104380
|
hasProactiveCredentials: () => this.view.tokens.length > 0,
|
|
103881
104381
|
buildEndpoints: (deviceId) => this.buildEndpointsForOneDevice(deviceId),
|
|
@@ -103896,7 +104396,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103896
104396
|
const offRemoved = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceUnregistered }, (event) => {
|
|
103897
104397
|
const id = event.data?.deviceId;
|
|
103898
104398
|
if (typeof id !== "number") return;
|
|
103899
|
-
if (!this.
|
|
104399
|
+
if (!this.exposedDevices.some((e) => e.deviceId === id)) return;
|
|
103900
104400
|
this.unexposeDevice(String(id));
|
|
103901
104401
|
});
|
|
103902
104402
|
this.ctx.addDisposer(async () => offRemoved());
|
|
@@ -103906,7 +104406,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103906
104406
|
reaper.unref?.();
|
|
103907
104407
|
this.ctx.addDisposer(async () => clearInterval(reaper));
|
|
103908
104408
|
this.ctx.logger.info("export-alexa: initialized", { meta: {
|
|
103909
|
-
exposedCount: this.
|
|
104409
|
+
exposedCount: this.exposedDevices.length,
|
|
103910
104410
|
skillMode: this.view.skillMode,
|
|
103911
104411
|
skillIdSet: this.effectiveSettings().expectedAudience.length > 0,
|
|
103912
104412
|
pushGrants: this.view.tokens.length,
|
|
@@ -103981,13 +104481,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
103981
104481
|
if (!await this.ctx.api.deviceManager.getDevice.query({ deviceId }).catch((err) => {
|
|
103982
104482
|
throw new Error(`export-alexa: deviceManager.getDevice failed: ${errMsg$1(err)}`);
|
|
103983
104483
|
})) throw new Error(`export-alexa: device ${deviceId} not found`);
|
|
103984
|
-
const next = this.
|
|
104484
|
+
const next = this.exposedDevices.filter((e) => e.deviceId !== deviceId);
|
|
103985
104485
|
next.push({
|
|
103986
104486
|
deviceId,
|
|
103987
104487
|
exposedAt: Date.now(),
|
|
103988
104488
|
settings: DEFAULT_DEVICE_SETTINGS
|
|
103989
104489
|
});
|
|
103990
|
-
await this.
|
|
104490
|
+
await this.writeExports({ devices: next });
|
|
103991
104491
|
this.ctx.logger.info("export-alexa: exposed device", { meta: { deviceId } });
|
|
103992
104492
|
this.requireSyncEngine().pushDevice(deviceId).then((r) => {
|
|
103993
104493
|
this.ctx.logger.info("export-alexa: synced exposed device", { meta: { ...r } });
|
|
@@ -104002,9 +104502,9 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104002
104502
|
async unexposeDevice(deviceIdRaw) {
|
|
104003
104503
|
const deviceId = Number.parseInt(deviceIdRaw, 10);
|
|
104004
104504
|
if (!Number.isFinite(deviceId)) return;
|
|
104005
|
-
const next = this.
|
|
104006
|
-
if (next.length === this.
|
|
104007
|
-
await this.
|
|
104505
|
+
const next = this.exposedDevices.filter((e) => e.deviceId !== deviceId);
|
|
104506
|
+
if (next.length === this.exposedDevices.length) return;
|
|
104507
|
+
await this.writeExports({ devices: next });
|
|
104008
104508
|
this.ctx.logger.info("export-alexa: unexposed device", { meta: { deviceId } });
|
|
104009
104509
|
this.requireSyncEngine().removeDevice(deviceId).catch((err) => {
|
|
104010
104510
|
this.ctx.logger.warn("export-alexa: unexpose delete failed", { meta: {
|
|
@@ -104119,7 +104619,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104119
104619
|
get endpointAccess() {
|
|
104120
104620
|
return {
|
|
104121
104621
|
gate: this.accessGate,
|
|
104122
|
-
isExposed: (deviceId) => this.
|
|
104622
|
+
isExposed: (deviceId) => this.exposedDevices.some((e) => e.deviceId === deviceId)
|
|
104123
104623
|
};
|
|
104124
104624
|
}
|
|
104125
104625
|
/** Narrow the nullable `lwaGateway` for the SyncEngine post closures. It is
|
|
@@ -104149,7 +104649,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104149
104649
|
const off = this.ctx.eventBus.subscribe({ category: EventCategory.DeviceBindingsChanged }, (event) => {
|
|
104150
104650
|
const deviceId = event.data?.deviceId;
|
|
104151
104651
|
if (typeof deviceId !== "number") return;
|
|
104152
|
-
if (!this.
|
|
104652
|
+
if (!this.exposedDevices.some((e) => e.deviceId === deviceId)) return;
|
|
104153
104653
|
const pending = this.pendingReconcileTimers.get(deviceId);
|
|
104154
104654
|
if (pending) clearTimeout(pending);
|
|
104155
104655
|
const timer = setTimeout(() => {
|
|
@@ -104437,6 +104937,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104437
104937
|
if (records === void 0) throw new Error("records are not available");
|
|
104438
104938
|
return records.kind(alexaSkillLinksKind);
|
|
104439
104939
|
}
|
|
104940
|
+
exportsHandle() {
|
|
104941
|
+
const records = this.ctx.records;
|
|
104942
|
+
if (records === void 0) throw new Error("records are not available");
|
|
104943
|
+
return records.kind(alexaSkillExportsKind);
|
|
104944
|
+
}
|
|
104440
104945
|
/** Re-read both records. A failed read changes nothing: the addon keeps what it has. */
|
|
104441
104946
|
async refreshRecords() {
|
|
104442
104947
|
try {
|
|
@@ -104499,6 +105004,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104499
105004
|
migrationPorts() {
|
|
104500
105005
|
const skills = this.skillHandle();
|
|
104501
105006
|
const links = this.linksHandle();
|
|
105007
|
+
const exportsHandle = this.exportsHandle();
|
|
104502
105008
|
const putOnce = async (handle, body) => {
|
|
104503
105009
|
if (await handle.get("export-alexa") !== null) return "exists";
|
|
104504
105010
|
try {
|
|
@@ -104528,6 +105034,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104528
105034
|
},
|
|
104529
105035
|
putSkill: (body) => putOnce(skills, body),
|
|
104530
105036
|
putLinks: (body) => putOnce(links, body),
|
|
105037
|
+
putExports: (body) => putOnce(exportsHandle, body),
|
|
105038
|
+
readExports: async () => (await exportsHandle.get("export-alexa"))?.data ?? null,
|
|
104531
105039
|
replaceLinks: async (body) => {
|
|
104532
105040
|
await links.put({
|
|
104533
105041
|
id: ALEXA_INSTANCE_ID,
|
|
@@ -104833,14 +105341,14 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
104833
105341
|
}
|
|
104834
105342
|
}
|
|
104835
105343
|
findEntry(deviceId) {
|
|
104836
|
-
return this.
|
|
105344
|
+
return this.exposedDevices.find((e) => e.deviceId === deviceId) ?? null;
|
|
104837
105345
|
}
|
|
104838
105346
|
async patchEntrySettings(deviceId, settings) {
|
|
104839
|
-
const next = this.
|
|
105347
|
+
const next = this.exposedDevices.map((e) => e.deviceId === deviceId ? {
|
|
104840
105348
|
...e,
|
|
104841
105349
|
settings
|
|
104842
105350
|
} : e);
|
|
104843
|
-
await this.
|
|
105351
|
+
await this.writeExports({ devices: next });
|
|
104844
105352
|
}
|
|
104845
105353
|
};
|
|
104846
105354
|
//#endregion
|