@camstack/addon-export-alexa 1.2.179 → 1.2.180
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 +7 -0
- package/dist/export-alexa.addon.js +2098 -300
- package/dist/export-alexa.addon.mjs +2098 -300
- package/package.json +5 -2
|
@@ -791,7 +791,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
791
791
|
return EventCategory;
|
|
792
792
|
}({});
|
|
793
793
|
//#endregion
|
|
794
|
-
//#region ../types/dist/device-type-
|
|
794
|
+
//#region ../types/dist/device-type-D1fH5kaC.mjs
|
|
795
795
|
/**
|
|
796
796
|
import { errMsg } from '@camstack/types'
|
|
797
797
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1022,6 +1022,12 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
1022
1022
|
DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
|
|
1023
1023
|
/** Media player exposes stop distinct from pause. */
|
|
1024
1024
|
DeviceFeature["MediaPlayerStop"] = "media-player-stop";
|
|
1025
|
+
/** Media player exposes volume up / down in steps (an infrared TV has no level). */
|
|
1026
|
+
DeviceFeature["MediaPlayerVolumeStep"] = "media-player-volume-step";
|
|
1027
|
+
/** Media player exposes channel up / down in steps. */
|
|
1028
|
+
DeviceFeature["MediaPlayerChannelStep"] = "media-player-channel-step";
|
|
1029
|
+
/** Media player exposes power on / off. */
|
|
1030
|
+
DeviceFeature["MediaPlayerPower"] = "media-player-power";
|
|
1025
1031
|
/** Alarm panel requires a PIN code on arm/disarm. */
|
|
1026
1032
|
DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
|
|
1027
1033
|
/** Presence device carries GPS coordinates (lat/lng/accuracy) in
|
|
@@ -4558,6 +4564,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4558
4564
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4559
4565
|
json.type = "boolean";
|
|
4560
4566
|
};
|
|
4567
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4568
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4569
|
+
};
|
|
4570
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4571
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4572
|
+
};
|
|
4561
4573
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4562
4574
|
if (ctx.target === "openapi-3.0") {
|
|
4563
4575
|
json.type = "string";
|
|
@@ -4565,12 +4577,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4565
4577
|
json.enum = [null];
|
|
4566
4578
|
} else json.type = "null";
|
|
4567
4579
|
};
|
|
4580
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4581
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4582
|
+
};
|
|
4568
4583
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4569
4584
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4570
4585
|
};
|
|
4571
4586
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4572
4587
|
json.not = {};
|
|
4573
4588
|
};
|
|
4589
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4590
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4574
4591
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4575
4592
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4576
4593
|
};
|
|
@@ -4602,12 +4619,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4602
4619
|
json.enum = vals;
|
|
4603
4620
|
}
|
|
4604
4621
|
};
|
|
4622
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4623
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4624
|
+
};
|
|
4625
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4626
|
+
const _json = json;
|
|
4627
|
+
const pattern = schema._zod.pattern;
|
|
4628
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4629
|
+
_json.type = "string";
|
|
4630
|
+
_json.pattern = pattern.source;
|
|
4631
|
+
};
|
|
4632
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4633
|
+
const _json = json;
|
|
4634
|
+
const file = {
|
|
4635
|
+
type: "string",
|
|
4636
|
+
format: "binary",
|
|
4637
|
+
contentEncoding: "binary"
|
|
4638
|
+
};
|
|
4639
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4640
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4641
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4642
|
+
if (mime) if (mime.length === 1) {
|
|
4643
|
+
file.contentMediaType = mime[0];
|
|
4644
|
+
Object.assign(_json, file);
|
|
4645
|
+
} else {
|
|
4646
|
+
Object.assign(_json, file);
|
|
4647
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4648
|
+
}
|
|
4649
|
+
else Object.assign(_json, file);
|
|
4650
|
+
};
|
|
4651
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4652
|
+
json.type = "boolean";
|
|
4653
|
+
};
|
|
4605
4654
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4606
4655
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4607
4656
|
};
|
|
4657
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4658
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4659
|
+
};
|
|
4608
4660
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4609
4661
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4610
4662
|
};
|
|
4663
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4664
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4665
|
+
};
|
|
4666
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4667
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4668
|
+
};
|
|
4611
4669
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4612
4670
|
const json = _json;
|
|
4613
4671
|
const def = schema._zod.def;
|
|
@@ -4812,6 +4870,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4812
4870
|
seen.ref = def.innerType;
|
|
4813
4871
|
json.readOnly = true;
|
|
4814
4872
|
};
|
|
4873
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4874
|
+
const def = schema._zod.def;
|
|
4875
|
+
process$1(def.innerType, ctx, params);
|
|
4876
|
+
const seen = ctx.seen.get(schema);
|
|
4877
|
+
seen.ref = def.innerType;
|
|
4878
|
+
};
|
|
4815
4879
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4816
4880
|
const def = schema._zod.def;
|
|
4817
4881
|
process$1(def.innerType, ctx, params);
|
|
@@ -4824,6 +4888,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4824
4888
|
const seen = ctx.seen.get(schema);
|
|
4825
4889
|
seen.ref = innerType;
|
|
4826
4890
|
};
|
|
4891
|
+
var allProcessors = {
|
|
4892
|
+
string: stringProcessor,
|
|
4893
|
+
number: numberProcessor,
|
|
4894
|
+
boolean: booleanProcessor,
|
|
4895
|
+
bigint: bigintProcessor,
|
|
4896
|
+
symbol: symbolProcessor,
|
|
4897
|
+
null: nullProcessor,
|
|
4898
|
+
undefined: undefinedProcessor,
|
|
4899
|
+
void: voidProcessor,
|
|
4900
|
+
never: neverProcessor,
|
|
4901
|
+
any: anyProcessor,
|
|
4902
|
+
unknown: unknownProcessor,
|
|
4903
|
+
date: dateProcessor,
|
|
4904
|
+
enum: enumProcessor,
|
|
4905
|
+
literal: literalProcessor,
|
|
4906
|
+
nan: nanProcessor,
|
|
4907
|
+
template_literal: templateLiteralProcessor,
|
|
4908
|
+
file: fileProcessor,
|
|
4909
|
+
success: successProcessor,
|
|
4910
|
+
custom: customProcessor,
|
|
4911
|
+
function: functionProcessor,
|
|
4912
|
+
transform: transformProcessor,
|
|
4913
|
+
map: mapProcessor,
|
|
4914
|
+
set: setProcessor,
|
|
4915
|
+
array: arrayProcessor,
|
|
4916
|
+
object: objectProcessor,
|
|
4917
|
+
union: unionProcessor,
|
|
4918
|
+
intersection: intersectionProcessor,
|
|
4919
|
+
tuple: tupleProcessor,
|
|
4920
|
+
record: recordProcessor,
|
|
4921
|
+
nullable: nullableProcessor,
|
|
4922
|
+
nonoptional: nonoptionalProcessor,
|
|
4923
|
+
default: defaultProcessor,
|
|
4924
|
+
prefault: prefaultProcessor,
|
|
4925
|
+
catch: catchProcessor,
|
|
4926
|
+
pipe: pipeProcessor,
|
|
4927
|
+
readonly: readonlyProcessor,
|
|
4928
|
+
promise: promiseProcessor,
|
|
4929
|
+
optional: optionalProcessor,
|
|
4930
|
+
lazy: lazyProcessor
|
|
4931
|
+
};
|
|
4932
|
+
function toJSONSchema(input, params) {
|
|
4933
|
+
if ("_idmap" in input) {
|
|
4934
|
+
const registry = input;
|
|
4935
|
+
const ctx = initializeContext({
|
|
4936
|
+
...params,
|
|
4937
|
+
processors: allProcessors
|
|
4938
|
+
});
|
|
4939
|
+
const defs = {};
|
|
4940
|
+
for (const entry of registry._idmap.entries()) {
|
|
4941
|
+
const [_, schema] = entry;
|
|
4942
|
+
process$1(schema, ctx);
|
|
4943
|
+
}
|
|
4944
|
+
const schemas = {};
|
|
4945
|
+
ctx.external = {
|
|
4946
|
+
registry,
|
|
4947
|
+
uri: params?.uri,
|
|
4948
|
+
defs
|
|
4949
|
+
};
|
|
4950
|
+
for (const entry of registry._idmap.entries()) {
|
|
4951
|
+
const [key, schema] = entry;
|
|
4952
|
+
extractDefs(ctx, schema);
|
|
4953
|
+
schemas[key] = finalize(ctx, schema);
|
|
4954
|
+
}
|
|
4955
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4956
|
+
return { schemas };
|
|
4957
|
+
}
|
|
4958
|
+
const ctx = initializeContext({
|
|
4959
|
+
...params,
|
|
4960
|
+
processors: allProcessors
|
|
4961
|
+
});
|
|
4962
|
+
process$1(input, ctx);
|
|
4963
|
+
extractDefs(ctx, input);
|
|
4964
|
+
return finalize(ctx, input);
|
|
4965
|
+
}
|
|
4827
4966
|
//#endregion
|
|
4828
4967
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4829
4968
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5848,7 +5987,7 @@ var ZodIssueCode = {
|
|
|
5848
5987
|
var ZodFirstPartyTypeKind;
|
|
5849
5988
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5850
5989
|
//#endregion
|
|
5851
|
-
//#region ../types/dist/sleep-
|
|
5990
|
+
//#region ../types/dist/sleep-BKClVk0K.mjs
|
|
5852
5991
|
/**
|
|
5853
5992
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5854
5993
|
* window to float samples (D455).
|
|
@@ -5927,6 +6066,22 @@ function buildAlawTable() {
|
|
|
5927
6066
|
}
|
|
5928
6067
|
buildUlawTable();
|
|
5929
6068
|
buildAlawTable();
|
|
6069
|
+
/**
|
|
6070
|
+
* An addon whose own migrations did not apply refuses to initialise (D987). The error is typed
|
|
6071
|
+
* so a runner hosting several addons can tell "this addon is blocked" from a crash and keep its
|
|
6072
|
+
* co-located siblings running. Recognised by NAME and shape, never `instanceof`: a forked addon
|
|
6073
|
+
* bundles its own copy of this module, so the class the runner sees is not the one that threw.
|
|
6074
|
+
*/
|
|
6075
|
+
var MIGRATIONS_BLOCKED_ERROR_NAME = "AddonMigrationsBlockedError";
|
|
6076
|
+
var AddonMigrationsBlockedError = class extends Error {
|
|
6077
|
+
/** The ledger ids that did not apply and block the owner. */
|
|
6078
|
+
migrationIds;
|
|
6079
|
+
constructor(migrationIds) {
|
|
6080
|
+
super(`migration(s) ${migrationIds.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
|
|
6081
|
+
this.name = MIGRATIONS_BLOCKED_ERROR_NAME;
|
|
6082
|
+
this.migrationIds = migrationIds;
|
|
6083
|
+
}
|
|
6084
|
+
};
|
|
5930
6085
|
/** Is this field's stored value a credential? */
|
|
5931
6086
|
function isSecretConfigField(field) {
|
|
5932
6087
|
if (field.type === "password") return true;
|
|
@@ -5980,9 +6135,16 @@ function isSecretMarker(value) {
|
|
|
5980
6135
|
const ref = value["$secret"];
|
|
5981
6136
|
return typeof ref === "string" && ref.length > 0;
|
|
5982
6137
|
}
|
|
6138
|
+
/** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
|
|
6139
|
+
function isSecretMarkerLike(value) {
|
|
6140
|
+
return isRecord$7(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
|
|
6141
|
+
}
|
|
5983
6142
|
function isSecretClear(value) {
|
|
5984
6143
|
return isRecord$7(value) && value["$secretClear"] === true;
|
|
5985
6144
|
}
|
|
6145
|
+
function isSecretFieldView(value) {
|
|
6146
|
+
return isRecord$7(value) && value["set"] === true && isSecretMarkerLike(value);
|
|
6147
|
+
}
|
|
5986
6148
|
/**
|
|
5987
6149
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5988
6150
|
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
@@ -6632,11 +6794,36 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6632
6794
|
}
|
|
6633
6795
|
return out;
|
|
6634
6796
|
}
|
|
6797
|
+
/**
|
|
6798
|
+
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6799
|
+
*
|
|
6800
|
+
* A ref is DETERMINISTIC from where the value lives — the owner addon, the
|
|
6801
|
+
* scope (global, one node, one device, one integration, one row of a business
|
|
6802
|
+
* collection) and the field path inside that scope — so saving the same field
|
|
6803
|
+
* twice updates the same ref, and the ref itself says which settings blob
|
|
6804
|
+
* points at it. It is also the AAD of the value's ciphertext: a ciphertext
|
|
6805
|
+
* copied onto another ref does not decrypt.
|
|
6806
|
+
*
|
|
6807
|
+
* Array items are addressed by ITEM ID, never by index
|
|
6808
|
+
* (`providers[authentik].clientSecret`), so reordering a list keeps every ref.
|
|
6809
|
+
*
|
|
6810
|
+
* Pure and browser-safe: no node builtins, no I/O.
|
|
6811
|
+
*/
|
|
6812
|
+
/** The URI scheme of every keychain ref. */
|
|
6813
|
+
var SECRET_REF_SCHEME = "secret://";
|
|
6635
6814
|
var GLOBAL_SCOPE = { kind: "global" };
|
|
6636
6815
|
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6637
6816
|
function globalSecretScope() {
|
|
6638
6817
|
return GLOBAL_SCOPE;
|
|
6639
6818
|
}
|
|
6819
|
+
/**
|
|
6820
|
+
* An addon id as a ref owner. A hub in-process builtin's context id is
|
|
6821
|
+
* `addon:<id>`; the owner of its secrets is `<id>`, exactly as for the same
|
|
6822
|
+
* addon running forked.
|
|
6823
|
+
*/
|
|
6824
|
+
function normalizeSecretOwner(addonId) {
|
|
6825
|
+
return addonId.startsWith("addon:") ? addonId.slice(6) : addonId;
|
|
6826
|
+
}
|
|
6640
6827
|
function encodeSegment(value) {
|
|
6641
6828
|
return encodeURIComponent(value);
|
|
6642
6829
|
}
|
|
@@ -6647,6 +6834,16 @@ function decodeSegment(value) {
|
|
|
6647
6834
|
return null;
|
|
6648
6835
|
}
|
|
6649
6836
|
}
|
|
6837
|
+
/** The scope as it appears inside a ref (`global`, `node/<id>`, …). */
|
|
6838
|
+
function formatSecretScope(scope) {
|
|
6839
|
+
switch (scope.kind) {
|
|
6840
|
+
case "global": return "global";
|
|
6841
|
+
case "node": return `node/${encodeSegment(scope.nodeId)}`;
|
|
6842
|
+
case "device": return `device/${scope.deviceId}`;
|
|
6843
|
+
case "integration": return `integration/${encodeSegment(scope.integrationId)}`;
|
|
6844
|
+
case "row": return `row/${encodeSegment(scope.collection)}/${encodeSegment(scope.rowId)}`;
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6650
6847
|
/**
|
|
6651
6848
|
* The field path of a value inside an array item, addressed by the item's id:
|
|
6652
6849
|
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
@@ -6655,6 +6852,13 @@ function decodeSegment(value) {
|
|
|
6655
6852
|
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6656
6853
|
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6657
6854
|
}
|
|
6855
|
+
/** Build a ref. Throws on an empty owner or field path — both are bugs. */
|
|
6856
|
+
function buildSecretRef(parts) {
|
|
6857
|
+
const owner = normalizeSecretOwner(parts.owner);
|
|
6858
|
+
if (owner.length === 0) throw new Error("buildSecretRef: owner is empty");
|
|
6859
|
+
if (parts.fieldPath.length === 0) throw new Error("buildSecretRef: fieldPath is empty");
|
|
6860
|
+
return `${SECRET_REF_SCHEME}${encodeSegment(owner)}/${formatSecretScope(parts.scope)}/${parts.fieldPath}`;
|
|
6861
|
+
}
|
|
6658
6862
|
function parseScope(segments) {
|
|
6659
6863
|
switch (segments[0]) {
|
|
6660
6864
|
case "global": return {
|
|
@@ -6795,7 +6999,7 @@ async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
|
6795
6999
|
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6796
7000
|
return out;
|
|
6797
7001
|
}
|
|
6798
|
-
function rowId(row, idKey) {
|
|
7002
|
+
function rowId$1(row, idKey) {
|
|
6799
7003
|
const raw = row[idKey];
|
|
6800
7004
|
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6801
7005
|
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
@@ -6812,7 +7016,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6812
7016
|
}
|
|
6813
7017
|
const storedById = /* @__PURE__ */ new Map();
|
|
6814
7018
|
for (const row of storedRows) {
|
|
6815
|
-
const id = rowId(row, node.idKey);
|
|
7019
|
+
const id = rowId$1(row, node.idKey);
|
|
6816
7020
|
if (id !== null) storedById.set(id, row);
|
|
6817
7021
|
}
|
|
6818
7022
|
const kept = /* @__PURE__ */ new Set();
|
|
@@ -6822,13 +7026,13 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6822
7026
|
rows.push(row);
|
|
6823
7027
|
continue;
|
|
6824
7028
|
}
|
|
6825
|
-
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
7029
|
+
const id = rowId$1(row, node.idKey) ?? ctx.mintId();
|
|
6826
7030
|
kept.add(id);
|
|
6827
7031
|
const withId = {
|
|
6828
7032
|
...row,
|
|
6829
7033
|
[node.idKey]: row[node.idKey] ?? id
|
|
6830
7034
|
};
|
|
6831
|
-
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
7035
|
+
if (rowId$1(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6832
7036
|
const storedRow = storedById.get(id) ?? {};
|
|
6833
7037
|
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6834
7038
|
}
|
|
@@ -7580,7 +7784,7 @@ var BaseAddon = class {
|
|
|
7580
7784
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7581
7785
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7582
7786
|
}, migrations, this.ctx.logger);
|
|
7583
|
-
if (report.blockOwner.length > 0) throw new
|
|
7787
|
+
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7584
7788
|
return report;
|
|
7585
7789
|
}
|
|
7586
7790
|
/**
|
|
@@ -8559,6 +8763,45 @@ function normalizeAddonInitResult(result) {
|
|
|
8559
8763
|
if (Array.isArray(result)) return { providers: result };
|
|
8560
8764
|
return result;
|
|
8561
8765
|
}
|
|
8766
|
+
var PREFIX$1 = "records/";
|
|
8767
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8768
|
+
var RecordsError = class extends Error {
|
|
8769
|
+
code;
|
|
8770
|
+
detail;
|
|
8771
|
+
constructor(code, detail) {
|
|
8772
|
+
super(`${PREFIX$1}${code}: ${detail}`);
|
|
8773
|
+
this.name = "RecordsError";
|
|
8774
|
+
this.code = code;
|
|
8775
|
+
this.detail = detail;
|
|
8776
|
+
}
|
|
8777
|
+
};
|
|
8778
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8779
|
+
var RevConflictError = class extends RecordsError {
|
|
8780
|
+
constructor(detail) {
|
|
8781
|
+
super("rev-conflict", detail);
|
|
8782
|
+
this.name = "RevConflictError";
|
|
8783
|
+
}
|
|
8784
|
+
};
|
|
8785
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8786
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8787
|
+
constructor(detail) {
|
|
8788
|
+
super("secret-unavailable", detail);
|
|
8789
|
+
this.name = "RecordSecretUnavailableError";
|
|
8790
|
+
}
|
|
8791
|
+
};
|
|
8792
|
+
var InvalidRecordError = class extends RecordsError {
|
|
8793
|
+
constructor(detail) {
|
|
8794
|
+
super("invalid-record", detail);
|
|
8795
|
+
this.name = "InvalidRecordError";
|
|
8796
|
+
}
|
|
8797
|
+
};
|
|
8798
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8799
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
8800
|
+
constructor(detail) {
|
|
8801
|
+
super("declaration-refused", detail);
|
|
8802
|
+
this.name = "DeclarationRefusedError";
|
|
8803
|
+
}
|
|
8804
|
+
};
|
|
8562
8805
|
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8563
8806
|
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8564
8807
|
var RECORD_DATABASES = ["settings", "events"];
|
|
@@ -8574,6 +8817,152 @@ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
|
8574
8817
|
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8575
8818
|
var RECORD_BATCH_MAX = 1e3;
|
|
8576
8819
|
var RECORD_QUERY_MAX = 1e3;
|
|
8820
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8821
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8822
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8823
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8824
|
+
/**
|
|
8825
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8826
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8827
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8828
|
+
*
|
|
8829
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8830
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8831
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8832
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8833
|
+
*
|
|
8834
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8835
|
+
*/
|
|
8836
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8837
|
+
function parseSecretPath(path) {
|
|
8838
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8839
|
+
return path.split(".").map((raw) => {
|
|
8840
|
+
const each = raw.endsWith("[]");
|
|
8841
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8842
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8843
|
+
return {
|
|
8844
|
+
key,
|
|
8845
|
+
each
|
|
8846
|
+
};
|
|
8847
|
+
});
|
|
8848
|
+
}
|
|
8849
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8850
|
+
function secretArrayPrefixes(path) {
|
|
8851
|
+
const segments = parseSecretPath(path);
|
|
8852
|
+
const prefixes = [];
|
|
8853
|
+
const walked = [];
|
|
8854
|
+
for (const segment of segments) {
|
|
8855
|
+
walked.push(segment.key);
|
|
8856
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8857
|
+
}
|
|
8858
|
+
return prefixes;
|
|
8859
|
+
}
|
|
8860
|
+
function isRecord$4(value) {
|
|
8861
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8862
|
+
}
|
|
8863
|
+
function elementId(element, idKey, declared, prefix) {
|
|
8864
|
+
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
8865
|
+
if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
|
|
8866
|
+
return id;
|
|
8867
|
+
}
|
|
8868
|
+
/**
|
|
8869
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
8870
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
8871
|
+
* result is a new body, `data` is untouched.
|
|
8872
|
+
*/
|
|
8873
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
8874
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
8875
|
+
if (!isRecord$4(node)) return node;
|
|
8876
|
+
const segment = segments[index];
|
|
8877
|
+
if (segment === void 0) return node;
|
|
8878
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
8879
|
+
const child = node[segment.key];
|
|
8880
|
+
const keys = [...walkedKeys, segment.key];
|
|
8881
|
+
const last = index === segments.length - 1;
|
|
8882
|
+
if (segment.each) {
|
|
8883
|
+
if (!Array.isArray(child)) return node;
|
|
8884
|
+
const prefix = keys.join(".");
|
|
8885
|
+
const idKey = arrayKeys[prefix];
|
|
8886
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
8887
|
+
const mapped = child.map((element) => {
|
|
8888
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
8889
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
8890
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
8891
|
+
});
|
|
8892
|
+
return {
|
|
8893
|
+
...node,
|
|
8894
|
+
[segment.key]: mapped
|
|
8895
|
+
};
|
|
8896
|
+
}
|
|
8897
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8898
|
+
if (last) {
|
|
8899
|
+
const replacement = visit({
|
|
8900
|
+
declared,
|
|
8901
|
+
concrete,
|
|
8902
|
+
value: child
|
|
8903
|
+
});
|
|
8904
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
8905
|
+
return {
|
|
8906
|
+
...node,
|
|
8907
|
+
[segment.key]: replacement
|
|
8908
|
+
};
|
|
8909
|
+
}
|
|
8910
|
+
return {
|
|
8911
|
+
...node,
|
|
8912
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
8913
|
+
};
|
|
8914
|
+
}
|
|
8915
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
8916
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
8917
|
+
let current = data;
|
|
8918
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
8919
|
+
return current;
|
|
8920
|
+
}
|
|
8921
|
+
/**
|
|
8922
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
8923
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
8924
|
+
* already holds during an adoption.
|
|
8925
|
+
*/
|
|
8926
|
+
function recordSecretCollection(kind) {
|
|
8927
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
8928
|
+
}
|
|
8929
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
8930
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
8931
|
+
return buildSecretRef({
|
|
8932
|
+
owner,
|
|
8933
|
+
scope: {
|
|
8934
|
+
kind: "row",
|
|
8935
|
+
collection: recordSecretCollection(kind),
|
|
8936
|
+
rowId
|
|
8937
|
+
},
|
|
8938
|
+
fieldPath: concretePath
|
|
8939
|
+
});
|
|
8940
|
+
}
|
|
8941
|
+
/**
|
|
8942
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
8943
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
8944
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
8945
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
8946
|
+
* stored secret (the records door reads a view as KEEP).
|
|
8947
|
+
*
|
|
8948
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
8949
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
8950
|
+
*/
|
|
8951
|
+
function isRecord$3(value) {
|
|
8952
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8953
|
+
}
|
|
8954
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
8955
|
+
if (decl.secretPaths.length === 0) return data;
|
|
8956
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
8957
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
8958
|
+
return {
|
|
8959
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
8960
|
+
v: 1,
|
|
8961
|
+
set: true
|
|
8962
|
+
};
|
|
8963
|
+
});
|
|
8964
|
+
return isRecord$3(shown) ? shown : data;
|
|
8965
|
+
}
|
|
8577
8966
|
/**
|
|
8578
8967
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
8579
8968
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -8598,6 +8987,73 @@ var PeerBytesTicketSchema = object({
|
|
|
8598
8987
|
*/
|
|
8599
8988
|
declaredBytes: number().int().nonnegative().nullable()
|
|
8600
8989
|
});
|
|
8990
|
+
function defOf(schema) {
|
|
8991
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8992
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8993
|
+
const def = Reflect.get(zodBag, "def");
|
|
8994
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8995
|
+
return def;
|
|
8996
|
+
}
|
|
8997
|
+
function declaredHere(schema) {
|
|
8998
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8999
|
+
}
|
|
9000
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
9001
|
+
var WRAPPERS = new Set([
|
|
9002
|
+
"optional",
|
|
9003
|
+
"nullable",
|
|
9004
|
+
"default",
|
|
9005
|
+
"prefault",
|
|
9006
|
+
"catch",
|
|
9007
|
+
"readonly",
|
|
9008
|
+
"nonoptional"
|
|
9009
|
+
]);
|
|
9010
|
+
/**
|
|
9011
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
9012
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
9013
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
9014
|
+
* `.transform` on `in`).
|
|
9015
|
+
*/
|
|
9016
|
+
function layersOf(schema) {
|
|
9017
|
+
const out = [];
|
|
9018
|
+
const queue = [schema];
|
|
9019
|
+
while (queue.length > 0) {
|
|
9020
|
+
const s = queue.shift();
|
|
9021
|
+
if (!s || out.includes(s)) continue;
|
|
9022
|
+
out.push(s);
|
|
9023
|
+
const def = defOf(s);
|
|
9024
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
9025
|
+
if (def.type === "pipe") {
|
|
9026
|
+
if (def.in) queue.push(def.in);
|
|
9027
|
+
if (def.out) queue.push(def.out);
|
|
9028
|
+
}
|
|
9029
|
+
}
|
|
9030
|
+
return out;
|
|
9031
|
+
}
|
|
9032
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
9033
|
+
function isZodSecret(schema) {
|
|
9034
|
+
return layersOf(schema).some(declaredHere);
|
|
9035
|
+
}
|
|
9036
|
+
/**
|
|
9037
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
9038
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
9039
|
+
* object or array is reported as one path and not descended into — everything
|
|
9040
|
+
* under it is secret.
|
|
9041
|
+
*/
|
|
9042
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
9043
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
9044
|
+
const paths = [];
|
|
9045
|
+
for (const layer of layersOf(schema)) {
|
|
9046
|
+
const def = defOf(layer);
|
|
9047
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
9048
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
9049
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
9050
|
+
else if (def.type === "intersection") {
|
|
9051
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
9052
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
9053
|
+
}
|
|
9054
|
+
}
|
|
9055
|
+
return [...new Set(paths)];
|
|
9056
|
+
}
|
|
8601
9057
|
/**
|
|
8602
9058
|
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8603
9059
|
* Zod row schema that describes it, and the helper that turns the two into the
|
|
@@ -8664,6 +9120,110 @@ var RecordKindDeclarationSchema = object({
|
|
|
8664
9120
|
}).strict();
|
|
8665
9121
|
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8666
9122
|
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
9123
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
9124
|
+
function assertValidDeclaration(name, decl) {
|
|
9125
|
+
const refuse = (why) => {
|
|
9126
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
9127
|
+
};
|
|
9128
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
9129
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9130
|
+
for (const index of decl.indexes) {
|
|
9131
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
9132
|
+
seen.add(index.name);
|
|
9133
|
+
}
|
|
9134
|
+
const { retention } = decl;
|
|
9135
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
9136
|
+
if ("ttlMs" in retention) {
|
|
9137
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
9138
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
9139
|
+
}
|
|
9140
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
9141
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
9142
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
9143
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
9144
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
9145
|
+
if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
|
|
9146
|
+
}
|
|
9147
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
9148
|
+
for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
|
|
9149
|
+
}
|
|
9150
|
+
function bodyFieldsOf(schema) {
|
|
9151
|
+
return { ...toJSONSchema(schema, {
|
|
9152
|
+
unrepresentable: "any",
|
|
9153
|
+
io: "input"
|
|
9154
|
+
}) };
|
|
9155
|
+
}
|
|
9156
|
+
function isRecordLike(value) {
|
|
9157
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9158
|
+
}
|
|
9159
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
9160
|
+
function hasNameField(json, field) {
|
|
9161
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
9162
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
9163
|
+
const properties = json["properties"];
|
|
9164
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
9165
|
+
}
|
|
9166
|
+
/**
|
|
9167
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
9168
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
9169
|
+
* types its handle from.
|
|
9170
|
+
*/
|
|
9171
|
+
function defineRecordKinds(specs) {
|
|
9172
|
+
const out = {};
|
|
9173
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
9174
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
9175
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
9176
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
9177
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
9178
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
9179
|
+
database: spec.database,
|
|
9180
|
+
class: spec.class,
|
|
9181
|
+
writeTrigger: spec.writeTrigger,
|
|
9182
|
+
device: spec.device,
|
|
9183
|
+
at: spec.at,
|
|
9184
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
9185
|
+
retention: spec.retention,
|
|
9186
|
+
deviceRemoval: spec.deviceRemoval,
|
|
9187
|
+
maxDataBytes: spec.maxDataBytes,
|
|
9188
|
+
secretPaths: [...secretPaths],
|
|
9189
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
9190
|
+
transactFamily: spec.transactFamily,
|
|
9191
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
9192
|
+
title: spec.entry.title,
|
|
9193
|
+
nameField,
|
|
9194
|
+
fields
|
|
9195
|
+
}
|
|
9196
|
+
});
|
|
9197
|
+
assertValidDeclaration(name, parsed);
|
|
9198
|
+
out[name] = {
|
|
9199
|
+
name,
|
|
9200
|
+
schema: spec.schema,
|
|
9201
|
+
declaration: parsed
|
|
9202
|
+
};
|
|
9203
|
+
}
|
|
9204
|
+
return out;
|
|
9205
|
+
}
|
|
9206
|
+
/**
|
|
9207
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
9208
|
+
* engine, never aged, belonging to no device.
|
|
9209
|
+
*/
|
|
9210
|
+
function defineEntryKind(name, spec) {
|
|
9211
|
+
const defined = defineRecordKinds({ [name]: {
|
|
9212
|
+
schema: spec.schema,
|
|
9213
|
+
class: "config",
|
|
9214
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9215
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9216
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9217
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9218
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
9219
|
+
entry: {
|
|
9220
|
+
title: spec.title,
|
|
9221
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
9222
|
+
}
|
|
9223
|
+
} })[name];
|
|
9224
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
9225
|
+
return defined;
|
|
9226
|
+
}
|
|
8667
9227
|
object({
|
|
8668
9228
|
field: string().min(1),
|
|
8669
9229
|
on: literal("advance")
|
|
@@ -11339,7 +11899,7 @@ object({
|
|
|
11339
11899
|
params: record(string(), union([string(), number()])).optional()
|
|
11340
11900
|
});
|
|
11341
11901
|
//#endregion
|
|
11342
|
-
//#region ../types/dist/composition-
|
|
11902
|
+
//#region ../types/dist/composition-BodkvOV0.mjs
|
|
11343
11903
|
/**
|
|
11344
11904
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11345
11905
|
*
|
|
@@ -12476,7 +13036,14 @@ var CompositionForwardCommandSchema = object({
|
|
|
12476
13036
|
method: string().min(1),
|
|
12477
13037
|
args: record(string().min(1), CompositionForwardArgSchema).optional()
|
|
12478
13038
|
});
|
|
12479
|
-
var CompositionCommandTargetSchema = discriminatedUnion("kind", [
|
|
13039
|
+
var CompositionCommandTargetSchema = discriminatedUnion("kind", [
|
|
13040
|
+
CompositionForwardCommandSchema,
|
|
13041
|
+
CompositionCodeSourceSchema,
|
|
13042
|
+
object({
|
|
13043
|
+
kind: literal("extension"),
|
|
13044
|
+
target: literal("remote")
|
|
13045
|
+
})
|
|
13046
|
+
]);
|
|
12480
13047
|
/** An item key inside an item-array cap (`consumables.items[<key>]`). */
|
|
12481
13048
|
var COMPOSITION_ITEM_KEY_RE = /^[a-z0-9][a-z0-9-]{0,47}$/;
|
|
12482
13049
|
/**
|
|
@@ -12856,6 +13423,144 @@ function buildCapturingReply(envelope) {
|
|
|
12856
13423
|
};
|
|
12857
13424
|
return wrapper;
|
|
12858
13425
|
}
|
|
13426
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13427
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
13428
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13429
|
+
function topLevelSecretKeys(paths) {
|
|
13430
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[")));
|
|
13431
|
+
}
|
|
13432
|
+
var RecordIntegrationInstances = class {
|
|
13433
|
+
records;
|
|
13434
|
+
kind;
|
|
13435
|
+
hooks;
|
|
13436
|
+
handle;
|
|
13437
|
+
secretKeys;
|
|
13438
|
+
nameField;
|
|
13439
|
+
constructor(records, kind, hooks) {
|
|
13440
|
+
this.records = records;
|
|
13441
|
+
this.kind = kind;
|
|
13442
|
+
this.hooks = hooks;
|
|
13443
|
+
this.handle = records.kind(kind);
|
|
13444
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13445
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13446
|
+
}
|
|
13447
|
+
/**
|
|
13448
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13449
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13450
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13451
|
+
*/
|
|
13452
|
+
async readResolved(id) {
|
|
13453
|
+
try {
|
|
13454
|
+
const record = await this.handle.getResolved(id);
|
|
13455
|
+
return record === null ? null : {
|
|
13456
|
+
id,
|
|
13457
|
+
body: record.data,
|
|
13458
|
+
enabled: record.data.enabled !== false,
|
|
13459
|
+
secrets: "resolved"
|
|
13460
|
+
};
|
|
13461
|
+
} catch (err) {
|
|
13462
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13463
|
+
const stored = await this.handle.get(id);
|
|
13464
|
+
if (stored === null) return null;
|
|
13465
|
+
return {
|
|
13466
|
+
id,
|
|
13467
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13468
|
+
enabled: stored.data.enabled !== false,
|
|
13469
|
+
secrets: "unavailable"
|
|
13470
|
+
};
|
|
13471
|
+
}
|
|
13472
|
+
}
|
|
13473
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13474
|
+
async getResolved(id) {
|
|
13475
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
13476
|
+
}
|
|
13477
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13478
|
+
async listResolved() {
|
|
13479
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13480
|
+
const out = [];
|
|
13481
|
+
for (const record of page.records) {
|
|
13482
|
+
const read = await this.readResolved(record.id);
|
|
13483
|
+
if (read !== null) out.push(read);
|
|
13484
|
+
}
|
|
13485
|
+
return out;
|
|
13486
|
+
}
|
|
13487
|
+
viewOf(record) {
|
|
13488
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13489
|
+
const rawName = record.data[this.nameField];
|
|
13490
|
+
return {
|
|
13491
|
+
id: record.id,
|
|
13492
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
13493
|
+
configured: this.hooks.configured(record.data),
|
|
13494
|
+
enabled: record.data.enabled !== false,
|
|
13495
|
+
formValues: shown
|
|
13496
|
+
};
|
|
13497
|
+
}
|
|
13498
|
+
describe = async () => this.hooks.description;
|
|
13499
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13500
|
+
listInstances = async () => {
|
|
13501
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13502
|
+
};
|
|
13503
|
+
getInstance = async ({ id }) => {
|
|
13504
|
+
const record = await this.handle.get(id);
|
|
13505
|
+
return record === null ? null : this.viewOf(record);
|
|
13506
|
+
};
|
|
13507
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13508
|
+
createInstance = async ({ id, name }) => {
|
|
13509
|
+
await this.handle.put({
|
|
13510
|
+
id,
|
|
13511
|
+
data: this.hooks.initialBody(name)
|
|
13512
|
+
}, { ifRev: 0 });
|
|
13513
|
+
await this.hooks.onChanged?.(id);
|
|
13514
|
+
return { id };
|
|
13515
|
+
};
|
|
13516
|
+
updateInstance = async ({ id, name, values }) => {
|
|
13517
|
+
const patch = {};
|
|
13518
|
+
for (const [key, value] of Object.entries(values)) {
|
|
13519
|
+
if (value === void 0) continue;
|
|
13520
|
+
if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13521
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
13522
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13523
|
+
}
|
|
13524
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13525
|
+
await this.handle.patch(id, patch);
|
|
13526
|
+
await this.hooks.onChanged?.(id);
|
|
13527
|
+
return { ok: true };
|
|
13528
|
+
};
|
|
13529
|
+
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13530
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13531
|
+
await this.handle.patch(id, { enabled });
|
|
13532
|
+
await this.hooks.onChanged?.(id);
|
|
13533
|
+
return { ok: true };
|
|
13534
|
+
};
|
|
13535
|
+
/** The row and its keychain refs go together (the records door). */
|
|
13536
|
+
deleteInstance = async ({ id }) => {
|
|
13537
|
+
await this.handle.delete(id);
|
|
13538
|
+
await this.hooks.onChanged?.(id);
|
|
13539
|
+
return { ok: true };
|
|
13540
|
+
};
|
|
13541
|
+
testInstance = async (input) => {
|
|
13542
|
+
if (this.hooks.test === void 0) return {
|
|
13543
|
+
success: false,
|
|
13544
|
+
status: "unsupported",
|
|
13545
|
+
error: "This integration declares no connection test"
|
|
13546
|
+
};
|
|
13547
|
+
return this.hooks.test(input);
|
|
13548
|
+
};
|
|
13549
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
13550
|
+
toProvider() {
|
|
13551
|
+
return {
|
|
13552
|
+
describe: this.describe,
|
|
13553
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
13554
|
+
listInstances: this.listInstances,
|
|
13555
|
+
getInstance: this.getInstance,
|
|
13556
|
+
createInstance: this.createInstance,
|
|
13557
|
+
updateInstance: this.updateInstance,
|
|
13558
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
13559
|
+
deleteInstance: this.deleteInstance,
|
|
13560
|
+
testInstance: this.testInstance
|
|
13561
|
+
};
|
|
13562
|
+
}
|
|
13563
|
+
};
|
|
12859
13564
|
var EncodeProfileSchema = object({
|
|
12860
13565
|
video: object({
|
|
12861
13566
|
codec: _enum([
|
|
@@ -19280,6 +19985,48 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19280
19985
|
scope: "device",
|
|
19281
19986
|
noun: t("Media player", "Lettore multimediale"),
|
|
19282
19987
|
actions: [
|
|
19988
|
+
{
|
|
19989
|
+
id: "media.turnOn",
|
|
19990
|
+
method: "turnOn",
|
|
19991
|
+
label: t("Turn on", "Accendi"),
|
|
19992
|
+
phrase: t("Turn on {device}", "Accendi {device}"),
|
|
19993
|
+
icon: "power"
|
|
19994
|
+
},
|
|
19995
|
+
{
|
|
19996
|
+
id: "media.turnOff",
|
|
19997
|
+
method: "turnOff",
|
|
19998
|
+
label: t("Turn off", "Spegni"),
|
|
19999
|
+
phrase: t("Turn off {device}", "Spegni {device}"),
|
|
20000
|
+
icon: "power"
|
|
20001
|
+
},
|
|
20002
|
+
{
|
|
20003
|
+
id: "media.volumeUp",
|
|
20004
|
+
method: "volumeUp",
|
|
20005
|
+
label: t("Volume up", "Alza il volume"),
|
|
20006
|
+
phrase: t("Raise the volume of {device}", "Alza il volume di {device}"),
|
|
20007
|
+
icon: "volume-2"
|
|
20008
|
+
},
|
|
20009
|
+
{
|
|
20010
|
+
id: "media.volumeDown",
|
|
20011
|
+
method: "volumeDown",
|
|
20012
|
+
label: t("Volume down", "Abbassa il volume"),
|
|
20013
|
+
phrase: t("Lower the volume of {device}", "Abbassa il volume di {device}"),
|
|
20014
|
+
icon: "volume-2"
|
|
20015
|
+
},
|
|
20016
|
+
{
|
|
20017
|
+
id: "media.channelUp",
|
|
20018
|
+
method: "channelUp",
|
|
20019
|
+
label: t("Channel up", "Canale successivo"),
|
|
20020
|
+
phrase: t("Go to the next channel on {device}", "Passa al canale successivo su {device}"),
|
|
20021
|
+
icon: "skip-forward"
|
|
20022
|
+
},
|
|
20023
|
+
{
|
|
20024
|
+
id: "media.channelDown",
|
|
20025
|
+
method: "channelDown",
|
|
20026
|
+
label: t("Channel down", "Canale precedente"),
|
|
20027
|
+
phrase: t("Go to the previous channel on {device}", "Torna al canale precedente su {device}"),
|
|
20028
|
+
icon: "skip-back"
|
|
20029
|
+
},
|
|
19283
20030
|
{
|
|
19284
20031
|
id: "media.play",
|
|
19285
20032
|
method: "play",
|
|
@@ -47856,6 +48603,188 @@ DeviceType.Control, method(object({
|
|
|
47856
48603
|
kind: "mutation",
|
|
47857
48604
|
auth: "protected"
|
|
47858
48605
|
});
|
|
48606
|
+
/**
|
|
48607
|
+
* Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
|
|
48608
|
+
* Apple TV, Spotify, Roku, generic OTT receivers, …) on
|
|
48609
|
+
* `DeviceType.MediaPlayer`. Disjoint from the camera streaming
|
|
48610
|
+
* surface — those use `DeviceType.Camera` + the broker pipeline.
|
|
48611
|
+
*
|
|
48612
|
+
* The cap declares a wide method surface; not every backend supports
|
|
48613
|
+
* every method. Drivers signal sub-capability via the
|
|
48614
|
+
* `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
|
|
48615
|
+
* corresponding method) so the UI gates buttons without a slice
|
|
48616
|
+
* fetch — same pattern as `PanTiltZoom` for cameras.
|
|
48617
|
+
*/
|
|
48618
|
+
var MediaPlayerStateSchema = _enum([
|
|
48619
|
+
"off",
|
|
48620
|
+
"on",
|
|
48621
|
+
"idle",
|
|
48622
|
+
"playing",
|
|
48623
|
+
"paused",
|
|
48624
|
+
"buffering",
|
|
48625
|
+
"standby"
|
|
48626
|
+
]);
|
|
48627
|
+
var MediaPlayerRepeatSchema = _enum([
|
|
48628
|
+
"off",
|
|
48629
|
+
"all",
|
|
48630
|
+
"one"
|
|
48631
|
+
]);
|
|
48632
|
+
var MediaInfoSchema = object({
|
|
48633
|
+
/** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
|
|
48634
|
+
* `podcast`, …). */
|
|
48635
|
+
type: string(),
|
|
48636
|
+
/** Human-readable title. */
|
|
48637
|
+
title: string(),
|
|
48638
|
+
/** Optional artist / channel / station label. */
|
|
48639
|
+
artist: string().optional(),
|
|
48640
|
+
/** Optional album / season / show name. */
|
|
48641
|
+
album: string().optional(),
|
|
48642
|
+
/** Optional cover-art / thumbnail URL. */
|
|
48643
|
+
imageUrl: string().optional()
|
|
48644
|
+
});
|
|
48645
|
+
/**
|
|
48646
|
+
* Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
|
|
48647
|
+
* the device said so. `assumed`: the driver has no feedback (infrared) and
|
|
48648
|
+
* tracks what it last SENT; it moves only after a send was accepted, and a
|
|
48649
|
+
* human at the real remote makes it wrong. A UI shows an assumed value as a
|
|
48650
|
+
* guess, never as a reading.
|
|
48651
|
+
*/
|
|
48652
|
+
var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
|
|
48653
|
+
/** The fields of a media-player status a driver can only guess. */
|
|
48654
|
+
var MediaPlayerAssumedFieldSchema = _enum([
|
|
48655
|
+
"state",
|
|
48656
|
+
"volumeLevel",
|
|
48657
|
+
"isMuted",
|
|
48658
|
+
"source"
|
|
48659
|
+
]);
|
|
48660
|
+
var MediaPlayerStatusSchema = object({
|
|
48661
|
+
/** Playback lifecycle state. */
|
|
48662
|
+
state: MediaPlayerStateSchema,
|
|
48663
|
+
/**
|
|
48664
|
+
* Whether the state fields are readings or the driver's own bookkeeping.
|
|
48665
|
+
* A slice written before this field existed parses as `reported`.
|
|
48666
|
+
*/
|
|
48667
|
+
stateSource: MediaPlayerStateSourceSchema.default("reported"),
|
|
48668
|
+
/**
|
|
48669
|
+
* Which fields are the driver's own guess. `stateSource` is `assumed` when
|
|
48670
|
+
* this is not empty; a field not listed here is a reading even then (power
|
|
48671
|
+
* from a running-state source, mute guessed from the last send).
|
|
48672
|
+
*/
|
|
48673
|
+
assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
|
|
48674
|
+
/** Volume as 0..100 inclusive. Null when the device has no volume
|
|
48675
|
+
* surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
|
|
48676
|
+
volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
|
|
48677
|
+
/** Mute toggle distinct from volume=0. Null when no mute surface.
|
|
48678
|
+
* Pair with `DeviceFeature.MediaPlayerMute`. */
|
|
48679
|
+
isMuted: boolean().nullable(),
|
|
48680
|
+
/** Active source / input. Empty when no source surface. */
|
|
48681
|
+
source: string(),
|
|
48682
|
+
/** Selectable sources. Empty when no source surface.
|
|
48683
|
+
* Pair with `DeviceFeature.MediaPlayerSelectSource`. */
|
|
48684
|
+
availableSources: array(string()),
|
|
48685
|
+
/** Currently-playing media info. Null when nothing is playing. */
|
|
48686
|
+
currentMedia: MediaInfoSchema.nullable(),
|
|
48687
|
+
/** Current playback position in ms. Null when not seekable or
|
|
48688
|
+
* nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
|
|
48689
|
+
position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
|
|
48690
|
+
/** Total duration of the current media in ms. Null when unknown
|
|
48691
|
+
* (live stream) or nothing is playing. */
|
|
48692
|
+
duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
|
|
48693
|
+
/** Shuffle toggle. Null when no shuffle surface.
|
|
48694
|
+
* Pair with `DeviceFeature.MediaPlayerShuffle`. */
|
|
48695
|
+
shuffle: boolean().nullable(),
|
|
48696
|
+
/** Repeat mode. Null when no repeat surface.
|
|
48697
|
+
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
48698
|
+
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
48699
|
+
/** Ms epoch when the slice was last updated. */
|
|
48700
|
+
lastChangedAt: number()
|
|
48701
|
+
});
|
|
48702
|
+
var stepInput = object({
|
|
48703
|
+
deviceId: number().int().nonnegative(),
|
|
48704
|
+
/** How many presses: the caller's count (Alexa `volumeSteps`, `channelCount`). */
|
|
48705
|
+
steps: number().int().min(1).max(50).default(1)
|
|
48706
|
+
});
|
|
48707
|
+
var deviceOnly = object({ deviceId: number().int().nonnegative() });
|
|
48708
|
+
DeviceType.MediaPlayer, method(deviceOnly, _void(), {
|
|
48709
|
+
kind: "mutation",
|
|
48710
|
+
auth: "protected"
|
|
48711
|
+
}), method(deviceOnly, _void(), {
|
|
48712
|
+
kind: "mutation",
|
|
48713
|
+
auth: "protected"
|
|
48714
|
+
}), method(stepInput, _void(), {
|
|
48715
|
+
kind: "mutation",
|
|
48716
|
+
auth: "protected"
|
|
48717
|
+
}), method(stepInput, _void(), {
|
|
48718
|
+
kind: "mutation",
|
|
48719
|
+
auth: "protected"
|
|
48720
|
+
}), method(stepInput, _void(), {
|
|
48721
|
+
kind: "mutation",
|
|
48722
|
+
auth: "protected"
|
|
48723
|
+
}), method(stepInput, _void(), {
|
|
48724
|
+
kind: "mutation",
|
|
48725
|
+
auth: "protected"
|
|
48726
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
48727
|
+
kind: "mutation",
|
|
48728
|
+
auth: "protected"
|
|
48729
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
48730
|
+
kind: "mutation",
|
|
48731
|
+
auth: "protected"
|
|
48732
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
48733
|
+
kind: "mutation",
|
|
48734
|
+
auth: "protected"
|
|
48735
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
48736
|
+
kind: "mutation",
|
|
48737
|
+
auth: "protected"
|
|
48738
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
48739
|
+
kind: "mutation",
|
|
48740
|
+
auth: "protected"
|
|
48741
|
+
}), method(object({
|
|
48742
|
+
deviceId: number().int().nonnegative(),
|
|
48743
|
+
position: number().int().nonnegative()
|
|
48744
|
+
}), _void(), {
|
|
48745
|
+
kind: "mutation",
|
|
48746
|
+
auth: "protected"
|
|
48747
|
+
}), method(object({
|
|
48748
|
+
deviceId: number().int().nonnegative(),
|
|
48749
|
+
volumeLevel: number().min(0).max(100)
|
|
48750
|
+
}), _void(), {
|
|
48751
|
+
kind: "mutation",
|
|
48752
|
+
auth: "protected"
|
|
48753
|
+
}), method(object({
|
|
48754
|
+
deviceId: number().int().nonnegative(),
|
|
48755
|
+
muted: boolean()
|
|
48756
|
+
}), _void(), {
|
|
48757
|
+
kind: "mutation",
|
|
48758
|
+
auth: "protected"
|
|
48759
|
+
}), method(object({
|
|
48760
|
+
deviceId: number().int().nonnegative(),
|
|
48761
|
+
shuffle: boolean()
|
|
48762
|
+
}), _void(), {
|
|
48763
|
+
kind: "mutation",
|
|
48764
|
+
auth: "protected"
|
|
48765
|
+
}), method(object({
|
|
48766
|
+
deviceId: number().int().nonnegative(),
|
|
48767
|
+
repeat: MediaPlayerRepeatSchema
|
|
48768
|
+
}), _void(), {
|
|
48769
|
+
kind: "mutation",
|
|
48770
|
+
auth: "protected"
|
|
48771
|
+
}), method(object({
|
|
48772
|
+
deviceId: number().int().nonnegative(),
|
|
48773
|
+
source: string().min(1)
|
|
48774
|
+
}), _void(), {
|
|
48775
|
+
kind: "mutation",
|
|
48776
|
+
auth: "protected"
|
|
48777
|
+
}), method(object({
|
|
48778
|
+
deviceId: number().int().nonnegative(),
|
|
48779
|
+
/** Media identifier / URL. */
|
|
48780
|
+
mediaId: string().min(1),
|
|
48781
|
+
/** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
|
|
48782
|
+
* passes it through to the upstream service. */
|
|
48783
|
+
mediaType: string().min(1)
|
|
48784
|
+
}), _void(), {
|
|
48785
|
+
kind: "mutation",
|
|
48786
|
+
auth: "protected"
|
|
48787
|
+
});
|
|
47859
48788
|
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, 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, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder, DeviceType.Heater;
|
|
47860
48789
|
var NUMBER = {
|
|
47861
48790
|
kind: "fixed",
|
|
@@ -53368,31 +54297,53 @@ var IntegrationInstancePatchSchema = object({
|
|
|
53368
54297
|
/** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
|
|
53369
54298
|
values: record(string(), unknown())
|
|
53370
54299
|
});
|
|
53371
|
-
|
|
53372
|
-
|
|
53373
|
-
|
|
53374
|
-
|
|
53375
|
-
|
|
53376
|
-
|
|
53377
|
-
|
|
53378
|
-
|
|
53379
|
-
|
|
53380
|
-
|
|
53381
|
-
|
|
53382
|
-
|
|
53383
|
-
|
|
53384
|
-
|
|
53385
|
-
|
|
53386
|
-
|
|
53387
|
-
|
|
53388
|
-
|
|
53389
|
-
|
|
53390
|
-
|
|
53391
|
-
|
|
53392
|
-
}),
|
|
53393
|
-
|
|
53394
|
-
|
|
53395
|
-
|
|
54300
|
+
var integrationInstancesCapability = {
|
|
54301
|
+
name: "integration-instances",
|
|
54302
|
+
scope: "system",
|
|
54303
|
+
mode: "collection",
|
|
54304
|
+
methods: {
|
|
54305
|
+
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
54306
|
+
/** The form; `id: null` is the create form. */
|
|
54307
|
+
instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54308
|
+
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54309
|
+
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54310
|
+
/** Insert the typed record under the given id (a duplicate id is refused). */
|
|
54311
|
+
createInstance: method(object({
|
|
54312
|
+
id: IntegrationInstanceIdSchema,
|
|
54313
|
+
name: string().min(1)
|
|
54314
|
+
}), object({ id: string() }), {
|
|
54315
|
+
kind: "mutation",
|
|
54316
|
+
auth: "admin"
|
|
54317
|
+
}),
|
|
54318
|
+
updateInstance: method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
|
|
54319
|
+
kind: "mutation",
|
|
54320
|
+
auth: "admin"
|
|
54321
|
+
}),
|
|
54322
|
+
/**
|
|
54323
|
+
* Switch ONE instance on or off. A row control, not a form field: `updateInstance.values` is the
|
|
54324
|
+
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
54325
|
+
*/
|
|
54326
|
+
setInstanceEnabled: method(object({
|
|
54327
|
+
id: IntegrationInstanceIdSchema,
|
|
54328
|
+
enabled: boolean()
|
|
54329
|
+
}), object({ ok: literal(true) }), {
|
|
54330
|
+
kind: "mutation",
|
|
54331
|
+
auth: "admin"
|
|
54332
|
+
}),
|
|
54333
|
+
/** Delete the record and its keychain refs together. */
|
|
54334
|
+
deleteInstance: method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
|
|
54335
|
+
kind: "mutation",
|
|
54336
|
+
auth: "admin"
|
|
54337
|
+
}),
|
|
54338
|
+
testInstance: optionalMethod(object({
|
|
54339
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
54340
|
+
values: record(string(), unknown())
|
|
54341
|
+
}), TestConnectionResultSchema$1, {
|
|
54342
|
+
kind: "mutation",
|
|
54343
|
+
auth: "admin"
|
|
54344
|
+
})
|
|
54345
|
+
}
|
|
54346
|
+
};
|
|
53396
54347
|
/**
|
|
53397
54348
|
* Two-way audio / talk-back cap. Clients open a WebRTC audio-only
|
|
53398
54349
|
* session (server-initiated offer pattern, identical to the main
|
|
@@ -55375,164 +56326,6 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
|
|
|
55375
56326
|
]);
|
|
55376
56327
|
method(_void(), array(LoginMethodContributionSchema).readonly());
|
|
55377
56328
|
/**
|
|
55378
|
-
* Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
|
|
55379
|
-
* Apple TV, Spotify, Roku, generic OTT receivers, …) on
|
|
55380
|
-
* `DeviceType.MediaPlayer`. Disjoint from the camera streaming
|
|
55381
|
-
* surface — those use `DeviceType.Camera` + the broker pipeline.
|
|
55382
|
-
*
|
|
55383
|
-
* The cap declares a wide method surface; not every backend supports
|
|
55384
|
-
* every method. Drivers signal sub-capability via the
|
|
55385
|
-
* `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
|
|
55386
|
-
* corresponding method) so the UI gates buttons without a slice
|
|
55387
|
-
* fetch — same pattern as `PanTiltZoom` for cameras.
|
|
55388
|
-
*/
|
|
55389
|
-
var MediaPlayerStateSchema = _enum([
|
|
55390
|
-
"off",
|
|
55391
|
-
"on",
|
|
55392
|
-
"idle",
|
|
55393
|
-
"playing",
|
|
55394
|
-
"paused",
|
|
55395
|
-
"buffering",
|
|
55396
|
-
"standby"
|
|
55397
|
-
]);
|
|
55398
|
-
var MediaPlayerRepeatSchema = _enum([
|
|
55399
|
-
"off",
|
|
55400
|
-
"all",
|
|
55401
|
-
"one"
|
|
55402
|
-
]);
|
|
55403
|
-
var MediaInfoSchema = object({
|
|
55404
|
-
/** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
|
|
55405
|
-
* `podcast`, …). */
|
|
55406
|
-
type: string(),
|
|
55407
|
-
/** Human-readable title. */
|
|
55408
|
-
title: string(),
|
|
55409
|
-
/** Optional artist / channel / station label. */
|
|
55410
|
-
artist: string().optional(),
|
|
55411
|
-
/** Optional album / season / show name. */
|
|
55412
|
-
album: string().optional(),
|
|
55413
|
-
/** Optional cover-art / thumbnail URL. */
|
|
55414
|
-
imageUrl: string().optional()
|
|
55415
|
-
});
|
|
55416
|
-
/**
|
|
55417
|
-
* Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
|
|
55418
|
-
* the device said so. `assumed`: the driver has no feedback (infrared) and
|
|
55419
|
-
* tracks what it last SENT; it moves only after a send was accepted, and a
|
|
55420
|
-
* human at the real remote makes it wrong. A UI shows an assumed value as a
|
|
55421
|
-
* guess, never as a reading.
|
|
55422
|
-
*/
|
|
55423
|
-
var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
|
|
55424
|
-
/** The fields of a media-player status a driver can only guess. */
|
|
55425
|
-
var MediaPlayerAssumedFieldSchema = _enum([
|
|
55426
|
-
"state",
|
|
55427
|
-
"volumeLevel",
|
|
55428
|
-
"isMuted",
|
|
55429
|
-
"source"
|
|
55430
|
-
]);
|
|
55431
|
-
object({
|
|
55432
|
-
/** Playback lifecycle state. */
|
|
55433
|
-
state: MediaPlayerStateSchema,
|
|
55434
|
-
/**
|
|
55435
|
-
* Whether the state fields are readings or the driver's own bookkeeping.
|
|
55436
|
-
* A slice written before this field existed parses as `reported`.
|
|
55437
|
-
*/
|
|
55438
|
-
stateSource: MediaPlayerStateSourceSchema.default("reported"),
|
|
55439
|
-
/**
|
|
55440
|
-
* Which fields are the driver's own guess. `stateSource` is `assumed` when
|
|
55441
|
-
* this is not empty; a field not listed here is a reading even then (power
|
|
55442
|
-
* from a running-state source, mute guessed from the last send).
|
|
55443
|
-
*/
|
|
55444
|
-
assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
|
|
55445
|
-
/** Volume as 0..100 inclusive. Null when the device has no volume
|
|
55446
|
-
* surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
|
|
55447
|
-
volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
|
|
55448
|
-
/** Mute toggle distinct from volume=0. Null when no mute surface.
|
|
55449
|
-
* Pair with `DeviceFeature.MediaPlayerMute`. */
|
|
55450
|
-
isMuted: boolean().nullable(),
|
|
55451
|
-
/** Active source / input. Empty when no source surface. */
|
|
55452
|
-
source: string(),
|
|
55453
|
-
/** Selectable sources. Empty when no source surface.
|
|
55454
|
-
* Pair with `DeviceFeature.MediaPlayerSelectSource`. */
|
|
55455
|
-
availableSources: array(string()),
|
|
55456
|
-
/** Currently-playing media info. Null when nothing is playing. */
|
|
55457
|
-
currentMedia: MediaInfoSchema.nullable(),
|
|
55458
|
-
/** Current playback position in ms. Null when not seekable or
|
|
55459
|
-
* nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
|
|
55460
|
-
position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
|
|
55461
|
-
/** Total duration of the current media in ms. Null when unknown
|
|
55462
|
-
* (live stream) or nothing is playing. */
|
|
55463
|
-
duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
|
|
55464
|
-
/** Shuffle toggle. Null when no shuffle surface.
|
|
55465
|
-
* Pair with `DeviceFeature.MediaPlayerShuffle`. */
|
|
55466
|
-
shuffle: boolean().nullable(),
|
|
55467
|
-
/** Repeat mode. Null when no repeat surface.
|
|
55468
|
-
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
55469
|
-
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
55470
|
-
/** Ms epoch when the slice was last updated. */
|
|
55471
|
-
lastChangedAt: number()
|
|
55472
|
-
});
|
|
55473
|
-
DeviceType.MediaPlayer, method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55474
|
-
kind: "mutation",
|
|
55475
|
-
auth: "protected"
|
|
55476
|
-
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55477
|
-
kind: "mutation",
|
|
55478
|
-
auth: "protected"
|
|
55479
|
-
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55480
|
-
kind: "mutation",
|
|
55481
|
-
auth: "protected"
|
|
55482
|
-
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55483
|
-
kind: "mutation",
|
|
55484
|
-
auth: "protected"
|
|
55485
|
-
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55486
|
-
kind: "mutation",
|
|
55487
|
-
auth: "protected"
|
|
55488
|
-
}), method(object({
|
|
55489
|
-
deviceId: number().int().nonnegative(),
|
|
55490
|
-
position: number().int().nonnegative()
|
|
55491
|
-
}), _void(), {
|
|
55492
|
-
kind: "mutation",
|
|
55493
|
-
auth: "protected"
|
|
55494
|
-
}), method(object({
|
|
55495
|
-
deviceId: number().int().nonnegative(),
|
|
55496
|
-
volumeLevel: number().min(0).max(100)
|
|
55497
|
-
}), _void(), {
|
|
55498
|
-
kind: "mutation",
|
|
55499
|
-
auth: "protected"
|
|
55500
|
-
}), method(object({
|
|
55501
|
-
deviceId: number().int().nonnegative(),
|
|
55502
|
-
muted: boolean()
|
|
55503
|
-
}), _void(), {
|
|
55504
|
-
kind: "mutation",
|
|
55505
|
-
auth: "protected"
|
|
55506
|
-
}), method(object({
|
|
55507
|
-
deviceId: number().int().nonnegative(),
|
|
55508
|
-
shuffle: boolean()
|
|
55509
|
-
}), _void(), {
|
|
55510
|
-
kind: "mutation",
|
|
55511
|
-
auth: "protected"
|
|
55512
|
-
}), method(object({
|
|
55513
|
-
deviceId: number().int().nonnegative(),
|
|
55514
|
-
repeat: MediaPlayerRepeatSchema
|
|
55515
|
-
}), _void(), {
|
|
55516
|
-
kind: "mutation",
|
|
55517
|
-
auth: "protected"
|
|
55518
|
-
}), method(object({
|
|
55519
|
-
deviceId: number().int().nonnegative(),
|
|
55520
|
-
source: string().min(1)
|
|
55521
|
-
}), _void(), {
|
|
55522
|
-
kind: "mutation",
|
|
55523
|
-
auth: "protected"
|
|
55524
|
-
}), method(object({
|
|
55525
|
-
deviceId: number().int().nonnegative(),
|
|
55526
|
-
/** Media identifier / URL. */
|
|
55527
|
-
mediaId: string().min(1),
|
|
55528
|
-
/** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
|
|
55529
|
-
* passes it through to the upstream service. */
|
|
55530
|
-
mediaType: string().min(1)
|
|
55531
|
-
}), _void(), {
|
|
55532
|
-
kind: "mutation",
|
|
55533
|
-
auth: "protected"
|
|
55534
|
-
});
|
|
55535
|
-
/**
|
|
55536
56329
|
* mesh-network — collection cap for mesh-VPN providers.
|
|
55537
56330
|
*
|
|
55538
56331
|
* Different shape from `network-access` (public tunnels):
|
|
@@ -63825,6 +64618,21 @@ var NcTemplateVarKindSchema = _enum([
|
|
|
63825
64618
|
"sound",
|
|
63826
64619
|
"system"
|
|
63827
64620
|
]);
|
|
64621
|
+
/**
|
|
64622
|
+
* The default title/body a rule of one SITUATION is delivered with when the
|
|
64623
|
+
* operator wrote no template — served so an editor can pre-fill it (and the
|
|
64624
|
+
* operator can rebuild it from placeholders) instead of starting from a blank
|
|
64625
|
+
* box that, once saved, silently replaces it. `id` names the situation inside
|
|
64626
|
+
* a rule `kind`: `appliance-cycle` is a `sensor` rule whose device is an
|
|
64627
|
+
* appliance finishing a cycle. Texts are raw templates (`{{var}}` intact), in
|
|
64628
|
+
* the hub's current language and with its overrides applied.
|
|
64629
|
+
*/
|
|
64630
|
+
var NcTemplateDefaultSchema = object({
|
|
64631
|
+
id: _enum(["appliance-cycle"]),
|
|
64632
|
+
kind: NcRuleKindSchema,
|
|
64633
|
+
title: string(),
|
|
64634
|
+
body: string()
|
|
64635
|
+
});
|
|
63828
64636
|
/** Which producer renders a template: an ordinary rule, a timelapse, a digest. */
|
|
63829
64637
|
var NcTemplateFamilySchema = _enum([
|
|
63830
64638
|
"rule",
|
|
@@ -64680,7 +65488,11 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
64680
65488
|
}), method(object({}), object({
|
|
64681
65489
|
catalog: array(NcConditionDescriptorSchema),
|
|
64682
65490
|
taxonomy: NcTaxonomySchema.optional()
|
|
64683
|
-
})), method(object({}), object({
|
|
65491
|
+
})), method(object({}), object({
|
|
65492
|
+
vars: array(NcTemplateVarDescriptorSchema),
|
|
65493
|
+
/** Per-situation default texts; absent on a hub that predates them. */
|
|
65494
|
+
defaults: array(NcTemplateDefaultSchema)
|
|
65495
|
+
})), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
|
|
64684
65496
|
kind: "mutation",
|
|
64685
65497
|
access: "view"
|
|
64686
65498
|
}), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), NcRuleLastRunsSchema, { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
|
|
@@ -70168,7 +70980,13 @@ var RemoteMediaCommandSchema = _enum([
|
|
|
70168
70980
|
"next",
|
|
70169
70981
|
"previous",
|
|
70170
70982
|
"setMute",
|
|
70171
|
-
"selectSource"
|
|
70983
|
+
"selectSource",
|
|
70984
|
+
"turnOn",
|
|
70985
|
+
"turnOff",
|
|
70986
|
+
"volumeUp",
|
|
70987
|
+
"volumeDown",
|
|
70988
|
+
"channelUp",
|
|
70989
|
+
"channelDown"
|
|
70172
70990
|
]);
|
|
70173
70991
|
/** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
|
|
70174
70992
|
var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
|
|
@@ -70189,7 +71007,7 @@ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.e
|
|
|
70189
71007
|
}), RemoteSendResultSchema, {
|
|
70190
71008
|
kind: "mutation",
|
|
70191
71009
|
auth: "protected"
|
|
70192
|
-
}), method(deviceInput.extend({
|
|
71010
|
+
}), method(deviceInput, MediaPlayerStatusSchema.nullable(), { auth: "protected" }), method(deviceInput.extend({
|
|
70193
71011
|
command: RemoteMediaCommandSchema,
|
|
70194
71012
|
muted: boolean().optional(),
|
|
70195
71013
|
source: string().optional(),
|
|
@@ -72024,7 +72842,11 @@ Object.values(DeviceType), method(_void(), array(StreamSignalSchema).readonly())
|
|
|
72024
72842
|
* `getSettingsUISchema()` surface.
|
|
72025
72843
|
*/
|
|
72026
72844
|
var SwitchStatusSchema = object({
|
|
72027
|
-
|
|
72845
|
+
/**
|
|
72846
|
+
* `null` = the device has never reported its state (a measurement that
|
|
72847
|
+
* has not happened is unknown, never `false`).
|
|
72848
|
+
*/
|
|
72849
|
+
on: boolean().nullable().meta({ label: "On" }),
|
|
72028
72850
|
/** Ms epoch of the last state change. Useful for UI "X minutes ago". */
|
|
72029
72851
|
lastChangedAt: number()
|
|
72030
72852
|
});
|
|
@@ -72036,7 +72858,7 @@ DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceTyp
|
|
|
72036
72858
|
auth: "protected"
|
|
72037
72859
|
}), object({
|
|
72038
72860
|
deviceId: number(),
|
|
72039
|
-
on: boolean(),
|
|
72861
|
+
on: boolean().nullable(),
|
|
72040
72862
|
lastChangedAt: number()
|
|
72041
72863
|
});
|
|
72042
72864
|
/** C0 controls, DEL and the C1 range: none of them belongs in a name. */
|
|
@@ -75060,6 +75882,7 @@ function buildDescriptor(capName, kind) {
|
|
|
75060
75882
|
* contributes one entry per bound cap present in this map.
|
|
75061
75883
|
*/
|
|
75062
75884
|
var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
|
|
75885
|
+
DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
|
|
75063
75886
|
var btn = (idSuffix, row, col, init) => ({
|
|
75064
75887
|
idSuffix,
|
|
75065
75888
|
row,
|
|
@@ -79674,6 +80497,20 @@ Object.freeze({
|
|
|
79674
80497
|
access: "view",
|
|
79675
80498
|
role: "admin"
|
|
79676
80499
|
},
|
|
80500
|
+
"mediaPlayer.channelDown": {
|
|
80501
|
+
capName: "media-player",
|
|
80502
|
+
capScope: "device",
|
|
80503
|
+
addonId: null,
|
|
80504
|
+
access: "create",
|
|
80505
|
+
role: "viewer"
|
|
80506
|
+
},
|
|
80507
|
+
"mediaPlayer.channelUp": {
|
|
80508
|
+
capName: "media-player",
|
|
80509
|
+
capScope: "device",
|
|
80510
|
+
addonId: null,
|
|
80511
|
+
access: "create",
|
|
80512
|
+
role: "viewer"
|
|
80513
|
+
},
|
|
79677
80514
|
"mediaPlayer.getStatus": {
|
|
79678
80515
|
capName: "media-player",
|
|
79679
80516
|
capScope: "device",
|
|
@@ -79765,6 +80602,34 @@ Object.freeze({
|
|
|
79765
80602
|
access: "create",
|
|
79766
80603
|
role: "viewer"
|
|
79767
80604
|
},
|
|
80605
|
+
"mediaPlayer.turnOff": {
|
|
80606
|
+
capName: "media-player",
|
|
80607
|
+
capScope: "device",
|
|
80608
|
+
addonId: null,
|
|
80609
|
+
access: "create",
|
|
80610
|
+
role: "viewer"
|
|
80611
|
+
},
|
|
80612
|
+
"mediaPlayer.turnOn": {
|
|
80613
|
+
capName: "media-player",
|
|
80614
|
+
capScope: "device",
|
|
80615
|
+
addonId: null,
|
|
80616
|
+
access: "create",
|
|
80617
|
+
role: "viewer"
|
|
80618
|
+
},
|
|
80619
|
+
"mediaPlayer.volumeDown": {
|
|
80620
|
+
capName: "media-player",
|
|
80621
|
+
capScope: "device",
|
|
80622
|
+
addonId: null,
|
|
80623
|
+
access: "create",
|
|
80624
|
+
role: "viewer"
|
|
80625
|
+
},
|
|
80626
|
+
"mediaPlayer.volumeUp": {
|
|
80627
|
+
capName: "media-player",
|
|
80628
|
+
capScope: "device",
|
|
80629
|
+
addonId: null,
|
|
80630
|
+
access: "create",
|
|
80631
|
+
role: "viewer"
|
|
80632
|
+
},
|
|
79768
80633
|
"meshNetwork.getStatus": {
|
|
79769
80634
|
capName: "mesh-network",
|
|
79770
80635
|
capScope: "system",
|
|
@@ -83321,6 +84186,13 @@ Object.freeze({
|
|
|
83321
84186
|
access: "create",
|
|
83322
84187
|
role: "admin"
|
|
83323
84188
|
},
|
|
84189
|
+
"remote.getAssumedStatus": {
|
|
84190
|
+
capName: "remote",
|
|
84191
|
+
capScope: "system",
|
|
84192
|
+
addonId: null,
|
|
84193
|
+
access: "view",
|
|
84194
|
+
role: "admin"
|
|
84195
|
+
},
|
|
83324
84196
|
"remote.getConfig": {
|
|
83325
84197
|
capName: "remote",
|
|
83326
84198
|
capScope: "system",
|
|
@@ -87012,6 +87884,16 @@ Object.freeze({
|
|
|
87012
87884
|
form: "single",
|
|
87013
87885
|
optional: true
|
|
87014
87886
|
}],
|
|
87887
|
+
"mediaPlayer.channelDown": [{
|
|
87888
|
+
name: "deviceId",
|
|
87889
|
+
form: "single",
|
|
87890
|
+
optional: false
|
|
87891
|
+
}],
|
|
87892
|
+
"mediaPlayer.channelUp": [{
|
|
87893
|
+
name: "deviceId",
|
|
87894
|
+
form: "single",
|
|
87895
|
+
optional: false
|
|
87896
|
+
}],
|
|
87015
87897
|
"mediaPlayer.getStatus": [{
|
|
87016
87898
|
name: "deviceId",
|
|
87017
87899
|
form: "single",
|
|
@@ -87077,6 +87959,26 @@ Object.freeze({
|
|
|
87077
87959
|
form: "single",
|
|
87078
87960
|
optional: false
|
|
87079
87961
|
}],
|
|
87962
|
+
"mediaPlayer.turnOff": [{
|
|
87963
|
+
name: "deviceId",
|
|
87964
|
+
form: "single",
|
|
87965
|
+
optional: false
|
|
87966
|
+
}],
|
|
87967
|
+
"mediaPlayer.turnOn": [{
|
|
87968
|
+
name: "deviceId",
|
|
87969
|
+
form: "single",
|
|
87970
|
+
optional: false
|
|
87971
|
+
}],
|
|
87972
|
+
"mediaPlayer.volumeDown": [{
|
|
87973
|
+
name: "deviceId",
|
|
87974
|
+
form: "single",
|
|
87975
|
+
optional: false
|
|
87976
|
+
}],
|
|
87977
|
+
"mediaPlayer.volumeUp": [{
|
|
87978
|
+
name: "deviceId",
|
|
87979
|
+
form: "single",
|
|
87980
|
+
optional: false
|
|
87981
|
+
}],
|
|
87080
87982
|
"meter.getStatus": [{
|
|
87081
87983
|
name: "deviceId",
|
|
87082
87984
|
form: "single",
|
|
@@ -88242,6 +89144,11 @@ Object.freeze({
|
|
|
88242
89144
|
form: "single",
|
|
88243
89145
|
optional: true
|
|
88244
89146
|
}],
|
|
89147
|
+
"remote.getAssumedStatus": [{
|
|
89148
|
+
name: "deviceId",
|
|
89149
|
+
form: "single",
|
|
89150
|
+
optional: false
|
|
89151
|
+
}],
|
|
88245
89152
|
"remote.getConfig": [{
|
|
88246
89153
|
name: "deviceId",
|
|
88247
89154
|
form: "single",
|
|
@@ -89497,6 +90404,7 @@ var STATE_SUMMARY_VARS = [
|
|
|
89497
90404
|
[...RULE_TEXT],
|
|
89498
90405
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
89499
90406
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
90407
|
+
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
89500
90408
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
89501
90409
|
([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
|
|
89502
90410
|
([...RULE_TEXT], [...CONSUMABLE]),
|
|
@@ -91706,8 +92614,8 @@ function climateProperties(slice) {
|
|
|
91706
92614
|
//#endregion
|
|
91707
92615
|
//#region src/handlers/climate-controller.ts
|
|
91708
92616
|
var CAP_CLIMATE = "climate-control";
|
|
91709
|
-
var CAP_SWITCH$
|
|
91710
|
-
var UNCERTAINTY_MS$
|
|
92617
|
+
var CAP_SWITCH$2 = "switch";
|
|
92618
|
+
var UNCERTAINTY_MS$2 = 500;
|
|
91711
92619
|
var PRESET_NONE = "none";
|
|
91712
92620
|
var ScaleSchema = _enum([
|
|
91713
92621
|
"CELSIUS",
|
|
@@ -92004,7 +92912,7 @@ function successResponse$2(c, properties) {
|
|
|
92004
92912
|
context: { properties: properties.map((p) => ({
|
|
92005
92913
|
...p,
|
|
92006
92914
|
timeOfSample: now,
|
|
92007
|
-
uncertaintyInMilliseconds: UNCERTAINTY_MS$
|
|
92915
|
+
uncertaintyInMilliseconds: UNCERTAINTY_MS$2
|
|
92008
92916
|
})) }
|
|
92009
92917
|
};
|
|
92010
92918
|
}
|
|
@@ -92046,7 +92954,7 @@ async function handlesPower(c) {
|
|
|
92046
92954
|
lastPowerClaim.set(deps, known);
|
|
92047
92955
|
try {
|
|
92048
92956
|
const caps = (await deps.ctx.api.deviceManager.getBindings.query({ deviceId: c.deviceId })).entries.map((e) => e.capName);
|
|
92049
|
-
const claim = caps.includes(CAP_CLIMATE) && !caps.includes(CAP_SWITCH$
|
|
92957
|
+
const claim = caps.includes(CAP_CLIMATE) && !caps.includes(CAP_SWITCH$2);
|
|
92050
92958
|
known.set(c.deviceId, claim);
|
|
92051
92959
|
return claim;
|
|
92052
92960
|
} catch (err) {
|
|
@@ -93106,7 +94014,7 @@ function fanProperties(slice) {
|
|
|
93106
94014
|
//#endregion
|
|
93107
94015
|
//#region src/handlers/fan-controller.ts
|
|
93108
94016
|
var CAP_FAN = "fan-control";
|
|
93109
|
-
var UNCERTAINTY_MS = 500;
|
|
94017
|
+
var UNCERTAINTY_MS$1 = 500;
|
|
93110
94018
|
/** What AdjustRangeValue moves by when the device states no step of its own. */
|
|
93111
94019
|
var DEFAULT_ADJUST = 10;
|
|
93112
94020
|
var SetRangePayload = object({ rangeValue: number() });
|
|
@@ -93118,7 +94026,7 @@ var SetModePayload = object({ mode: string() });
|
|
|
93118
94026
|
function clamp(value) {
|
|
93119
94027
|
return Math.max(0, Math.min(100, Math.round(value)));
|
|
93120
94028
|
}
|
|
93121
|
-
function message(err) {
|
|
94029
|
+
function message$1(err) {
|
|
93122
94030
|
return err instanceof Error ? err.message : String(err);
|
|
93123
94031
|
}
|
|
93124
94032
|
async function readSlice(c, deps) {
|
|
@@ -93130,7 +94038,7 @@ async function readSlice(c, deps) {
|
|
|
93130
94038
|
} catch (err) {
|
|
93131
94039
|
deps.logger.warn("alexa fan-controller: the fan state could not be read", {
|
|
93132
94040
|
tags: { deviceId: c.deviceId },
|
|
93133
|
-
meta: { error: message(err) }
|
|
94041
|
+
meta: { error: message$1(err) }
|
|
93134
94042
|
});
|
|
93135
94043
|
return null;
|
|
93136
94044
|
}
|
|
@@ -93152,7 +94060,7 @@ function successResponse$1(c, properties) {
|
|
|
93152
94060
|
context: { properties: properties.map((p) => ({
|
|
93153
94061
|
...p,
|
|
93154
94062
|
timeOfSample: now,
|
|
93155
|
-
uncertaintyInMilliseconds: UNCERTAINTY_MS
|
|
94063
|
+
uncertaintyInMilliseconds: UNCERTAINTY_MS$1
|
|
93156
94064
|
})) }
|
|
93157
94065
|
};
|
|
93158
94066
|
}
|
|
@@ -93170,7 +94078,7 @@ async function setSpeed(c, deps, slice, speed) {
|
|
|
93170
94078
|
tags: { deviceId: c.deviceId },
|
|
93171
94079
|
meta: {
|
|
93172
94080
|
speed,
|
|
93173
|
-
error: message(err)
|
|
94081
|
+
error: message$1(err)
|
|
93174
94082
|
}
|
|
93175
94083
|
});
|
|
93176
94084
|
return unreachable(c, "the fan did not accept the speed");
|
|
@@ -93213,7 +94121,7 @@ async function handleToggle(c, deps) {
|
|
|
93213
94121
|
tags: { deviceId: c.deviceId },
|
|
93214
94122
|
meta: {
|
|
93215
94123
|
oscillating,
|
|
93216
|
-
error: message(err)
|
|
94124
|
+
error: message$1(err)
|
|
93217
94125
|
}
|
|
93218
94126
|
});
|
|
93219
94127
|
return unreachable(c, "the fan did not accept the command");
|
|
@@ -93233,7 +94141,7 @@ async function customNames(c, deps) {
|
|
|
93233
94141
|
} catch (err) {
|
|
93234
94142
|
deps.logger.warn("alexa fan-controller: the custom presets could not be read", {
|
|
93235
94143
|
tags: { deviceId: c.deviceId },
|
|
93236
|
-
meta: { error: message(err) }
|
|
94144
|
+
meta: { error: message$1(err) }
|
|
93237
94145
|
});
|
|
93238
94146
|
return [];
|
|
93239
94147
|
}
|
|
@@ -93256,7 +94164,7 @@ async function handleMode(c, deps) {
|
|
|
93256
94164
|
tags: { deviceId: c.deviceId },
|
|
93257
94165
|
meta: {
|
|
93258
94166
|
preset: mode.name,
|
|
93259
|
-
error: message(err)
|
|
94167
|
+
error: message$1(err)
|
|
93260
94168
|
}
|
|
93261
94169
|
});
|
|
93262
94170
|
return unreachable(c, "the fan did not accept the preset");
|
|
@@ -93308,7 +94216,7 @@ async function applyCustom(c, deps, name) {
|
|
|
93308
94216
|
tags: { deviceId: c.deviceId },
|
|
93309
94217
|
meta: {
|
|
93310
94218
|
preset: name,
|
|
93311
|
-
error: message(err)
|
|
94219
|
+
error: message$1(err)
|
|
93312
94220
|
}
|
|
93313
94221
|
});
|
|
93314
94222
|
return unreachable(c, "the preset could not be applied");
|
|
@@ -93504,6 +94412,397 @@ var lockAdapter = {
|
|
|
93504
94412
|
shaping: unshaped
|
|
93505
94413
|
};
|
|
93506
94414
|
//#endregion
|
|
94415
|
+
//#region src/endpoints/adapters/media-player-model.ts
|
|
94416
|
+
/**
|
|
94417
|
+
* A media player exported as a TV (planning#398). What Alexa is told depends on
|
|
94418
|
+
* what the player can DO (its features) and what it REPORTS (its slice):
|
|
94419
|
+
*
|
|
94420
|
+
* power → `Alexa.PowerController` (feature `media-player-power`)
|
|
94421
|
+
* volume ±N → `Alexa.StepSpeaker` (feature `media-player-volume-step`)
|
|
94422
|
+
* mute → `Alexa.Speaker` (`muted` only) (feature `media-player-mute`)
|
|
94423
|
+
* channel ±N → `Alexa.ChannelController` (feature `media-player-channel-step`)
|
|
94424
|
+
* transport → `Alexa.PlaybackController` (stop / next / previous by feature; play and
|
|
94425
|
+
* pause only when the player REPORTS its state,
|
|
94426
|
+
* since an assumed one cannot tell)
|
|
94427
|
+
* inputs → `Alexa.InputController` (the reported sources Amazon names)
|
|
94428
|
+
*
|
|
94429
|
+
* A property is reported only for a known value: an assumed `standby`, a null
|
|
94430
|
+
* mute and an unlisted volume or input produce no property at all (D393).
|
|
94431
|
+
*/
|
|
94432
|
+
var CAP_MEDIA_PLAYER = "media-player";
|
|
94433
|
+
/** The input names Amazon accepts for `Alexa.InputController` (alexa-inputcontroller). */
|
|
94434
|
+
var AMAZON_INPUTS = [
|
|
94435
|
+
...Array.from({ length: 7 }, (_, i) => `AUX ${i + 1}`),
|
|
94436
|
+
"BLURAY",
|
|
94437
|
+
"CABLE",
|
|
94438
|
+
"CD",
|
|
94439
|
+
"COAX 1",
|
|
94440
|
+
"COAX 2",
|
|
94441
|
+
"COMPOSITE 1",
|
|
94442
|
+
"DVD",
|
|
94443
|
+
"GAME",
|
|
94444
|
+
"HD RADIO",
|
|
94445
|
+
...Array.from({ length: 10 }, (_, i) => `HDMI ${i + 1}`),
|
|
94446
|
+
"HDMI ARC",
|
|
94447
|
+
...Array.from({ length: 10 }, (_, i) => `INPUT ${i + 1}`),
|
|
94448
|
+
"IPOD",
|
|
94449
|
+
...Array.from({ length: 7 }, (_, i) => `LINE ${i + 1}`),
|
|
94450
|
+
"MEDIA PLAYER",
|
|
94451
|
+
"OPTICAL 1",
|
|
94452
|
+
"OPTICAL 2",
|
|
94453
|
+
"PHONO",
|
|
94454
|
+
"PLAYSTATION",
|
|
94455
|
+
"PLAYSTATION 3",
|
|
94456
|
+
"PLAYSTATION 4",
|
|
94457
|
+
"SATELLITE",
|
|
94458
|
+
"SMARTCAST",
|
|
94459
|
+
"TUNER",
|
|
94460
|
+
"TV",
|
|
94461
|
+
"USB",
|
|
94462
|
+
"USB DAC",
|
|
94463
|
+
"VIDEO 1",
|
|
94464
|
+
"VIDEO 2",
|
|
94465
|
+
"VIDEO 3",
|
|
94466
|
+
"XBOX"
|
|
94467
|
+
];
|
|
94468
|
+
function squash(name) {
|
|
94469
|
+
return name.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
94470
|
+
}
|
|
94471
|
+
/** The Amazon input a source name stands for ("hdmi1" → "HDMI 1"), or null. */
|
|
94472
|
+
function amazonInputOf(source) {
|
|
94473
|
+
const wanted = squash(source);
|
|
94474
|
+
return AMAZON_INPUTS.find((name) => squash(name) === wanted) ?? null;
|
|
94475
|
+
}
|
|
94476
|
+
/** The sources of a slice that Amazon has a name for, paired with the player's own name. */
|
|
94477
|
+
function inputPairs(status) {
|
|
94478
|
+
const seen = /* @__PURE__ */ new Set();
|
|
94479
|
+
const pairs = [];
|
|
94480
|
+
for (const source of status.availableSources) {
|
|
94481
|
+
const amazon = amazonInputOf(source);
|
|
94482
|
+
if (amazon === null || seen.has(amazon)) continue;
|
|
94483
|
+
seen.add(amazon);
|
|
94484
|
+
pairs.push({
|
|
94485
|
+
amazon,
|
|
94486
|
+
source
|
|
94487
|
+
});
|
|
94488
|
+
}
|
|
94489
|
+
return pairs;
|
|
94490
|
+
}
|
|
94491
|
+
function readMediaPlayerSlice(slice) {
|
|
94492
|
+
const parsed = MediaPlayerStatusSchema.safeParse(slice);
|
|
94493
|
+
return parsed.success ? parsed.data : null;
|
|
94494
|
+
}
|
|
94495
|
+
var PLAYBACK_BY_FEATURE = [
|
|
94496
|
+
[DeviceFeature.MediaPlayerStop, "Stop"],
|
|
94497
|
+
[DeviceFeature.MediaPlayerNext, "Next"],
|
|
94498
|
+
[DeviceFeature.MediaPlayerPrevious, "Previous"]
|
|
94499
|
+
];
|
|
94500
|
+
function playbackOperations(device, status) {
|
|
94501
|
+
return [...status !== null && status.stateSource === "reported" ? ["Play", "Pause"] : [], ...PLAYBACK_BY_FEATURE.filter(([feature]) => device.features.includes(feature)).map(([, operation]) => operation)];
|
|
94502
|
+
}
|
|
94503
|
+
function describeMediaPlayerCapabilities(device) {
|
|
94504
|
+
const has = (feature) => device.features.includes(feature);
|
|
94505
|
+
const status = readMediaPlayerSlice(device.slices[CAP_MEDIA_PLAYER]);
|
|
94506
|
+
const capabilities = [];
|
|
94507
|
+
if (has(DeviceFeature.MediaPlayerPower)) capabilities.push(iface("Alexa.PowerController", "powerState"));
|
|
94508
|
+
if (has(DeviceFeature.MediaPlayerVolumeStep)) capabilities.push({
|
|
94509
|
+
type: "AlexaInterface",
|
|
94510
|
+
interface: "Alexa.StepSpeaker",
|
|
94511
|
+
version: "3"
|
|
94512
|
+
});
|
|
94513
|
+
if (has(DeviceFeature.MediaPlayerMute)) capabilities.push(iface("Alexa.Speaker", "muted"));
|
|
94514
|
+
if (has(DeviceFeature.MediaPlayerChannelStep)) capabilities.push({
|
|
94515
|
+
type: "AlexaInterface",
|
|
94516
|
+
interface: "Alexa.ChannelController",
|
|
94517
|
+
version: "3"
|
|
94518
|
+
});
|
|
94519
|
+
const operations = playbackOperations(device, status);
|
|
94520
|
+
if (operations.length > 0) capabilities.push({
|
|
94521
|
+
type: "AlexaInterface",
|
|
94522
|
+
interface: "Alexa.PlaybackController",
|
|
94523
|
+
version: "3",
|
|
94524
|
+
supportedOperations: operations
|
|
94525
|
+
});
|
|
94526
|
+
const inputs = status === null ? [] : inputPairs(status);
|
|
94527
|
+
if (has(DeviceFeature.MediaPlayerSelectSource) && inputs.length > 0) capabilities.push({
|
|
94528
|
+
...iface("Alexa.InputController", "input"),
|
|
94529
|
+
inputs: inputs.map((i) => ({ name: i.amazon }))
|
|
94530
|
+
});
|
|
94531
|
+
return capabilities;
|
|
94532
|
+
}
|
|
94533
|
+
/** The Alexa properties of a slice: only what is known. */
|
|
94534
|
+
function mediaPlayerProperties(slice) {
|
|
94535
|
+
const status = readMediaPlayerSlice(slice);
|
|
94536
|
+
if (status === null) return [];
|
|
94537
|
+
const out = [];
|
|
94538
|
+
if (status.state === "off") out.push({
|
|
94539
|
+
namespace: "Alexa.PowerController",
|
|
94540
|
+
name: "powerState",
|
|
94541
|
+
value: "OFF"
|
|
94542
|
+
});
|
|
94543
|
+
else if (status.state !== "standby") out.push({
|
|
94544
|
+
namespace: "Alexa.PowerController",
|
|
94545
|
+
name: "powerState",
|
|
94546
|
+
value: "ON"
|
|
94547
|
+
});
|
|
94548
|
+
if (status.isMuted !== null) out.push({
|
|
94549
|
+
namespace: "Alexa.Speaker",
|
|
94550
|
+
name: "muted",
|
|
94551
|
+
value: status.isMuted
|
|
94552
|
+
});
|
|
94553
|
+
const input = inputPairs(status).find((i) => i.source === status.source);
|
|
94554
|
+
if (input !== void 0) out.push({
|
|
94555
|
+
namespace: "Alexa.InputController",
|
|
94556
|
+
name: "input",
|
|
94557
|
+
value: input.amazon
|
|
94558
|
+
});
|
|
94559
|
+
return out;
|
|
94560
|
+
}
|
|
94561
|
+
//#endregion
|
|
94562
|
+
//#region src/handlers/media-player-controller.ts
|
|
94563
|
+
var UNCERTAINTY_MS = 1e3;
|
|
94564
|
+
var CAP_SWITCH$1 = "switch";
|
|
94565
|
+
var StepsPayload = object({ volumeSteps: number().int() });
|
|
94566
|
+
var ChannelPayload = object({ channelCount: number().int() });
|
|
94567
|
+
var MutePayload = object({ mute: boolean() });
|
|
94568
|
+
var InputPayload = object({ input: string() });
|
|
94569
|
+
function message(err) {
|
|
94570
|
+
return err instanceof Error ? err.message : String(err);
|
|
94571
|
+
}
|
|
94572
|
+
function success(c, properties) {
|
|
94573
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
94574
|
+
return {
|
|
94575
|
+
event: {
|
|
94576
|
+
header: {
|
|
94577
|
+
namespace: "Alexa",
|
|
94578
|
+
name: "Response",
|
|
94579
|
+
messageId: c.header.messageId,
|
|
94580
|
+
...c.header.correlationToken !== void 0 ? { correlationToken: c.header.correlationToken } : {},
|
|
94581
|
+
payloadVersion: "3"
|
|
94582
|
+
},
|
|
94583
|
+
endpoint: { endpointId: c.endpoint.endpointId },
|
|
94584
|
+
payload: {}
|
|
94585
|
+
},
|
|
94586
|
+
context: { properties: properties.map((p) => ({
|
|
94587
|
+
...p,
|
|
94588
|
+
timeOfSample: now,
|
|
94589
|
+
uncertaintyInMilliseconds: UNCERTAINTY_MS
|
|
94590
|
+
})) }
|
|
94591
|
+
};
|
|
94592
|
+
}
|
|
94593
|
+
/** PowerController on a media player, not on a switch: decided by the bound caps. */
|
|
94594
|
+
async function claimsMediaPlayerPower(c) {
|
|
94595
|
+
const deps = c.deps.mediaPlayerController;
|
|
94596
|
+
try {
|
|
94597
|
+
const caps = (await deps.ctx.api.deviceManager.getBindings.query({ deviceId: c.deviceId })).entries.map((e) => e.capName);
|
|
94598
|
+
return caps.includes("media-player") && !caps.includes(CAP_SWITCH$1);
|
|
94599
|
+
} catch (err) {
|
|
94600
|
+
deps.logger.warn("alexa media-player-controller: the bound caps could not be read", {
|
|
94601
|
+
tags: { deviceId: c.deviceId },
|
|
94602
|
+
meta: {
|
|
94603
|
+
error: message(err),
|
|
94604
|
+
decidedFrom: "no previous answer: not claimed"
|
|
94605
|
+
}
|
|
94606
|
+
});
|
|
94607
|
+
return false;
|
|
94608
|
+
}
|
|
94609
|
+
}
|
|
94610
|
+
/** How long a step command may run before Alexa is answered anyway (its own budget is ~8 s). */
|
|
94611
|
+
var STEP_ANSWER_BUDGET_MS = 3e3;
|
|
94612
|
+
/** The properties a command may assert: only those the player READS back, never an assumption (D393). */
|
|
94613
|
+
async function reportedProperties(c, namespace) {
|
|
94614
|
+
const deps = c.deps.mediaPlayerController;
|
|
94615
|
+
try {
|
|
94616
|
+
const slice = await deps.ctx.api.deviceState.getCapSlice.query({
|
|
94617
|
+
deviceId: c.deviceId,
|
|
94618
|
+
capName: CAP_MEDIA_PLAYER
|
|
94619
|
+
});
|
|
94620
|
+
const status = readMediaPlayerSlice(slice);
|
|
94621
|
+
if (status === null || status.stateSource !== "reported") return [];
|
|
94622
|
+
return mediaPlayerProperties(slice).filter((p) => p.namespace === namespace);
|
|
94623
|
+
} catch (err) {
|
|
94624
|
+
deps.logger.warn("alexa media-player-controller: the state could not be re-read", {
|
|
94625
|
+
tags: { deviceId: c.deviceId },
|
|
94626
|
+
meta: { error: message(err) }
|
|
94627
|
+
});
|
|
94628
|
+
return [];
|
|
94629
|
+
}
|
|
94630
|
+
}
|
|
94631
|
+
async function attempt(c, what, run, options = {}) {
|
|
94632
|
+
const deps = c.deps.mediaPlayerController;
|
|
94633
|
+
const settled = run().then(() => ({ ok: true }), (error) => ({
|
|
94634
|
+
ok: false,
|
|
94635
|
+
error
|
|
94636
|
+
}));
|
|
94637
|
+
let timer;
|
|
94638
|
+
const outcome = options.slow === true ? await Promise.race([settled, new Promise((resolve) => {
|
|
94639
|
+
timer = setTimeout(() => resolve(null), STEP_ANSWER_BUDGET_MS);
|
|
94640
|
+
})]) : await settled;
|
|
94641
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
94642
|
+
if (outcome === null) {
|
|
94643
|
+
deps.logger.info(`alexa media-player-controller: ${what} still sending, answered`, { tags: { deviceId: c.deviceId } });
|
|
94644
|
+
settled.then((late) => {
|
|
94645
|
+
if (!late.ok) deps.logger.warn(`alexa media-player-controller: ${what} failed after the answer`, {
|
|
94646
|
+
tags: { deviceId: c.deviceId },
|
|
94647
|
+
meta: { error: message(late.error) }
|
|
94648
|
+
});
|
|
94649
|
+
});
|
|
94650
|
+
return success(c, []);
|
|
94651
|
+
}
|
|
94652
|
+
if (!outcome.ok) {
|
|
94653
|
+
deps.logger.warn(`alexa media-player-controller: ${what} failed`, {
|
|
94654
|
+
tags: { deviceId: c.deviceId },
|
|
94655
|
+
meta: { error: message(outcome.error) }
|
|
94656
|
+
});
|
|
94657
|
+
return errorEnvelope(c.header, "ENDPOINT_UNREACHABLE", `the player did not accept ${what}`);
|
|
94658
|
+
}
|
|
94659
|
+
deps.logger.info(`alexa media-player-controller: ${what}`, { tags: { deviceId: c.deviceId } });
|
|
94660
|
+
return success(c, options.namespace === void 0 ? [] : await reportedProperties(c, options.namespace));
|
|
94661
|
+
}
|
|
94662
|
+
async function volume(c) {
|
|
94663
|
+
const payload = StepsPayload.safeParse(c.payload);
|
|
94664
|
+
if (!payload.success || payload.data.volumeSteps === 0) return errorEnvelope(c.header, "INVALID_DIRECTIVE", "volumeSteps is required");
|
|
94665
|
+
const steps = Math.min(Math.abs(payload.data.volumeSteps), 50);
|
|
94666
|
+
const api = c.deps.mediaPlayerController.ctx.api.mediaPlayer;
|
|
94667
|
+
const up = payload.data.volumeSteps > 0;
|
|
94668
|
+
return attempt(c, `volume ${up ? "up" : "down"} ${steps}`, () => up ? api.volumeUp.mutate({
|
|
94669
|
+
deviceId: c.deviceId,
|
|
94670
|
+
steps
|
|
94671
|
+
}) : api.volumeDown.mutate({
|
|
94672
|
+
deviceId: c.deviceId,
|
|
94673
|
+
steps
|
|
94674
|
+
}), { slow: true });
|
|
94675
|
+
}
|
|
94676
|
+
async function channel(c) {
|
|
94677
|
+
const payload = ChannelPayload.safeParse(c.payload);
|
|
94678
|
+
if (!payload.success || payload.data.channelCount === 0) return errorEnvelope(c.header, "INVALID_DIRECTIVE", "channelCount is required");
|
|
94679
|
+
const steps = Math.min(Math.abs(payload.data.channelCount), 50);
|
|
94680
|
+
const api = c.deps.mediaPlayerController.ctx.api.mediaPlayer;
|
|
94681
|
+
const up = payload.data.channelCount > 0;
|
|
94682
|
+
return attempt(c, `channel ${up ? "up" : "down"} ${steps}`, () => up ? api.channelUp.mutate({
|
|
94683
|
+
deviceId: c.deviceId,
|
|
94684
|
+
steps
|
|
94685
|
+
}) : api.channelDown.mutate({
|
|
94686
|
+
deviceId: c.deviceId,
|
|
94687
|
+
steps
|
|
94688
|
+
}), { slow: true });
|
|
94689
|
+
}
|
|
94690
|
+
async function mute(c) {
|
|
94691
|
+
const payload = MutePayload.safeParse(c.payload);
|
|
94692
|
+
if (!payload.success) return errorEnvelope(c.header, "INVALID_DIRECTIVE", "mute is required");
|
|
94693
|
+
const muted = payload.data.mute;
|
|
94694
|
+
const api = c.deps.mediaPlayerController.ctx.api.mediaPlayer;
|
|
94695
|
+
return attempt(c, `mute ${String(muted)}`, () => api.setMute.mutate({
|
|
94696
|
+
deviceId: c.deviceId,
|
|
94697
|
+
muted
|
|
94698
|
+
}), { namespace: "Alexa.Speaker" });
|
|
94699
|
+
}
|
|
94700
|
+
async function power$1(c) {
|
|
94701
|
+
const on = c.header.name === "TurnOn";
|
|
94702
|
+
const api = c.deps.mediaPlayerController.ctx.api.mediaPlayer;
|
|
94703
|
+
return attempt(c, on ? "turn on" : "turn off", () => on ? api.turnOn.mutate({ deviceId: c.deviceId }) : api.turnOff.mutate({ deviceId: c.deviceId }), { namespace: "Alexa.PowerController" });
|
|
94704
|
+
}
|
|
94705
|
+
async function playback(c) {
|
|
94706
|
+
const api = c.deps.mediaPlayerController.ctx.api.mediaPlayer;
|
|
94707
|
+
const input = { deviceId: c.deviceId };
|
|
94708
|
+
switch (c.header.name) {
|
|
94709
|
+
case "Play": return attempt(c, "play", () => api.play.mutate(input));
|
|
94710
|
+
case "Pause": return attempt(c, "pause", () => api.pause.mutate(input));
|
|
94711
|
+
case "Stop": return attempt(c, "stop", () => api.stop.mutate(input));
|
|
94712
|
+
case "Next": return attempt(c, "next", () => api.next.mutate(input));
|
|
94713
|
+
case "Previous": return attempt(c, "previous", () => api.previous.mutate(input));
|
|
94714
|
+
default: return errorEnvelope(c.header, "INVALID_DIRECTIVE", `unsupported ${c.header.name}`);
|
|
94715
|
+
}
|
|
94716
|
+
}
|
|
94717
|
+
async function selectInput(c) {
|
|
94718
|
+
const payload = InputPayload.safeParse(c.payload);
|
|
94719
|
+
if (!payload.success) return errorEnvelope(c.header, "INVALID_DIRECTIVE", "input is required");
|
|
94720
|
+
const deps = c.deps.mediaPlayerController;
|
|
94721
|
+
let source;
|
|
94722
|
+
try {
|
|
94723
|
+
const status = readMediaPlayerSlice(await deps.ctx.api.deviceState.getCapSlice.query({
|
|
94724
|
+
deviceId: c.deviceId,
|
|
94725
|
+
capName: CAP_MEDIA_PLAYER
|
|
94726
|
+
}));
|
|
94727
|
+
source = status === null ? void 0 : inputPairs(status).find((i) => i.amazon === payload.data.input)?.source;
|
|
94728
|
+
} catch (err) {
|
|
94729
|
+
deps.logger.warn("alexa media-player-controller: the sources could not be read", {
|
|
94730
|
+
tags: { deviceId: c.deviceId },
|
|
94731
|
+
meta: { error: message(err) }
|
|
94732
|
+
});
|
|
94733
|
+
return errorEnvelope(c.header, "ENDPOINT_UNREACHABLE", "the player sources could not be read");
|
|
94734
|
+
}
|
|
94735
|
+
if (source === void 0) return errorEnvelope(c.header, "INVALID_VALUE", `the player has no input ${payload.data.input}`);
|
|
94736
|
+
const chosen = source;
|
|
94737
|
+
return attempt(c, `select input ${chosen}`, () => deps.ctx.api.mediaPlayer.selectSource.mutate({
|
|
94738
|
+
deviceId: c.deviceId,
|
|
94739
|
+
source: chosen
|
|
94740
|
+
}), { namespace: "Alexa.InputController" });
|
|
94741
|
+
}
|
|
94742
|
+
/** The one handler behind every media-player directive. */
|
|
94743
|
+
async function handleMediaPlayerDirective(c) {
|
|
94744
|
+
switch (`${c.header.namespace}/${c.header.name}`) {
|
|
94745
|
+
case "Alexa.PowerController/TurnOn":
|
|
94746
|
+
case "Alexa.PowerController/TurnOff": return power$1(c);
|
|
94747
|
+
case "Alexa.StepSpeaker/AdjustVolume": return volume(c);
|
|
94748
|
+
case "Alexa.StepSpeaker/SetMute":
|
|
94749
|
+
case "Alexa.Speaker/SetMute": return mute(c);
|
|
94750
|
+
case "Alexa.ChannelController/SkipChannels": return channel(c);
|
|
94751
|
+
case "Alexa.InputController/SelectInput": return selectInput(c);
|
|
94752
|
+
default: return c.header.namespace === "Alexa.PlaybackController" ? playback(c) : errorEnvelope(c.header, "INVALID_DIRECTIVE", `unsupported ${c.header.name}`);
|
|
94753
|
+
}
|
|
94754
|
+
}
|
|
94755
|
+
//#endregion
|
|
94756
|
+
//#region src/endpoints/adapters/media-player.ts
|
|
94757
|
+
function directive(key, claims) {
|
|
94758
|
+
return {
|
|
94759
|
+
key,
|
|
94760
|
+
needsReachableDevice: true,
|
|
94761
|
+
handle: handleMediaPlayerDirective,
|
|
94762
|
+
...claims === void 0 ? {} : { claims }
|
|
94763
|
+
};
|
|
94764
|
+
}
|
|
94765
|
+
var DIRECTIVES = [
|
|
94766
|
+
directive("Alexa.PowerController/TurnOn", claimsMediaPlayerPower),
|
|
94767
|
+
directive("Alexa.PowerController/TurnOff", claimsMediaPlayerPower),
|
|
94768
|
+
directive("Alexa.StepSpeaker/AdjustVolume"),
|
|
94769
|
+
directive("Alexa.StepSpeaker/SetMute"),
|
|
94770
|
+
directive("Alexa.Speaker/SetMute"),
|
|
94771
|
+
directive("Alexa.ChannelController/SkipChannels"),
|
|
94772
|
+
directive("Alexa.PlaybackController/Play"),
|
|
94773
|
+
directive("Alexa.PlaybackController/Pause"),
|
|
94774
|
+
directive("Alexa.PlaybackController/Stop"),
|
|
94775
|
+
directive("Alexa.PlaybackController/Next"),
|
|
94776
|
+
directive("Alexa.PlaybackController/Previous"),
|
|
94777
|
+
directive("Alexa.InputController/SelectInput")
|
|
94778
|
+
];
|
|
94779
|
+
/**
|
|
94780
|
+
* `media-player` → a TV: power, step volume, mute, channel steps, transport and
|
|
94781
|
+
* inputs, each only when the player says it can (features) and, for the ones
|
|
94782
|
+
* that need a reading, only when it reports one. Registered before `switch`: a
|
|
94783
|
+
* TV is a TV, not a SWITCH.
|
|
94784
|
+
*/
|
|
94785
|
+
var mediaPlayerAdapter = {
|
|
94786
|
+
cap: CAP_MEDIA_PLAYER,
|
|
94787
|
+
stateCaps: [CAP_MEDIA_PLAYER],
|
|
94788
|
+
discoveryReads: [CAP_MEDIA_PLAYER],
|
|
94789
|
+
describe: (device) => {
|
|
94790
|
+
const capabilities = describeMediaPlayerCapabilities(device);
|
|
94791
|
+
if (capabilities.length === 0) return {
|
|
94792
|
+
kind: "skip",
|
|
94793
|
+
reason: "the media player offers nothing Alexa can drive"
|
|
94794
|
+
};
|
|
94795
|
+
return {
|
|
94796
|
+
kind: "publish",
|
|
94797
|
+
capabilities,
|
|
94798
|
+
category: "TV"
|
|
94799
|
+
};
|
|
94800
|
+
},
|
|
94801
|
+
properties: (_cap, slice) => mediaPlayerProperties(slice),
|
|
94802
|
+
directives: DIRECTIVES,
|
|
94803
|
+
shaping: () => null
|
|
94804
|
+
};
|
|
94805
|
+
//#endregion
|
|
93507
94806
|
//#region src/endpoints/adapters/motion.ts
|
|
93508
94807
|
/** `motion` → `Alexa.MotionSensor` (MOTION_SENSOR). */
|
|
93509
94808
|
var motionAdapter = {
|
|
@@ -93711,6 +95010,7 @@ var GENERIC_ADAPTERS = [
|
|
|
93711
95010
|
temperatureAdapter,
|
|
93712
95011
|
humidityAdapter,
|
|
93713
95012
|
fanAdapter,
|
|
95013
|
+
mediaPlayerAdapter,
|
|
93714
95014
|
{
|
|
93715
95015
|
cap: "switch",
|
|
93716
95016
|
stateCaps: ["switch", "brightness"],
|
|
@@ -93846,6 +95146,7 @@ var GENERIC_DEVICE_TYPES = [
|
|
|
93846
95146
|
"climate",
|
|
93847
95147
|
"cover",
|
|
93848
95148
|
"fan",
|
|
95149
|
+
"media-player",
|
|
93849
95150
|
"generic"
|
|
93850
95151
|
];
|
|
93851
95152
|
function toEndpoint(input, plan) {
|
|
@@ -95447,7 +96748,12 @@ var ALLOWED_INTERFACE_VERSIONS = {
|
|
|
95447
96748
|
"Alexa.SmartVision.SnapshotProvider": "1.1",
|
|
95448
96749
|
"Alexa.SmartVision.ObjectDetectionSensor": "1.0",
|
|
95449
96750
|
"Alexa.DataController": "1.0",
|
|
95450
|
-
"Alexa.SceneController": "3"
|
|
96751
|
+
"Alexa.SceneController": "3",
|
|
96752
|
+
"Alexa.StepSpeaker": "3",
|
|
96753
|
+
"Alexa.Speaker": "3",
|
|
96754
|
+
"Alexa.ChannelController": "3",
|
|
96755
|
+
"Alexa.PlaybackController": "3",
|
|
96756
|
+
"Alexa.InputController": "3"
|
|
95451
96757
|
};
|
|
95452
96758
|
/** `imageNetClass` values Amazon accepts (alexa-smartvision-objectdetectionsensor). */
|
|
95453
96759
|
var SMART_VISION_CLASSES = new Set(["person", "package"]);
|
|
@@ -95487,6 +96793,7 @@ var DISPLAY_CATEGORIES = new Set([
|
|
|
95487
96793
|
"THERMOSTAT",
|
|
95488
96794
|
"AIR_CONDITIONER",
|
|
95489
96795
|
"FAN",
|
|
96796
|
+
"TV",
|
|
95490
96797
|
"DOOR",
|
|
95491
96798
|
"GATE",
|
|
95492
96799
|
"GARAGE_DOOR",
|
|
@@ -99637,12 +100944,30 @@ function troubleshootingSection() {
|
|
|
99637
100944
|
]
|
|
99638
100945
|
};
|
|
99639
100946
|
}
|
|
99640
|
-
/**
|
|
99641
|
-
|
|
99642
|
-
function customSkillSecuritySection(input) {
|
|
100947
|
+
/** The enforcement switch of the custom skill's ingress token: part of the skill instance. */
|
|
100948
|
+
function instanceSecuritySection(input) {
|
|
99643
100949
|
return {
|
|
99644
100950
|
id: "export-alexa-custom-security",
|
|
99645
100951
|
title: "Custom-skill security",
|
|
100952
|
+
columns: 1,
|
|
100953
|
+
fields: [{
|
|
100954
|
+
type: "boolean",
|
|
100955
|
+
key: "enforceIngressToken",
|
|
100956
|
+
label: "Require ingress token",
|
|
100957
|
+
description: "When on, this hub refuses skill calls without the matching token. Turn it on only after HUB_INGRESS_TOKEN is set in your Lambda. The token itself is shown on the addon page.",
|
|
100958
|
+
default: input.defaults.enforceIngressToken,
|
|
100959
|
+
showWhen: CUSTOM_SKILL_ONLY
|
|
100960
|
+
}]
|
|
100961
|
+
};
|
|
100962
|
+
}
|
|
100963
|
+
/** Custom skill only: the public skill's shared Lambda sends one ingress token
|
|
100964
|
+
* for every hub (`HUB_INGRESS_TOKEN`), so a per-hub token cannot apply to it. The rows are
|
|
100965
|
+
* built only for a custom skill: the mode is not a field of this page. */
|
|
100966
|
+
function customSkillSecuritySection(input) {
|
|
100967
|
+
if (input.skillMode !== "custom") return null;
|
|
100968
|
+
return {
|
|
100969
|
+
id: "export-alexa-custom-security-token",
|
|
100970
|
+
title: "Custom-skill ingress token",
|
|
99646
100971
|
style: "accordion",
|
|
99647
100972
|
defaultCollapsed: true,
|
|
99648
100973
|
columns: 1,
|
|
@@ -99652,8 +100977,7 @@ function customSkillSecuritySection(input) {
|
|
|
99652
100977
|
key: "__ingress-token-info",
|
|
99653
100978
|
label: "Ingress token",
|
|
99654
100979
|
variant: "info",
|
|
99655
|
-
|
|
99656
|
-
content: "An optional shared secret your skill Lambda sends on every call to this hub. Show it, put it in the Lambda's HUB_INGRESS_TOKEN environment variable, then turn on \"Require ingress token\". After a rotation, update the Lambda."
|
|
100980
|
+
content: "An optional shared secret your skill Lambda sends on every call to this hub. Show it, put it in the Lambda's HUB_INGRESS_TOKEN environment variable, then turn on \"Require ingress token\" on the skill. After a rotation, update the Lambda."
|
|
99657
100981
|
},
|
|
99658
100982
|
{
|
|
99659
100983
|
type: "addon-action-button",
|
|
@@ -99664,8 +100988,7 @@ function customSkillSecuritySection(input) {
|
|
|
99664
100988
|
buttonLabel: "Show ingress token",
|
|
99665
100989
|
action: "revealIngressToken",
|
|
99666
100990
|
variant: "default",
|
|
99667
|
-
successMessage: "Ingress token: {ingressToken}"
|
|
99668
|
-
showWhen: CUSTOM_SKILL_ONLY
|
|
100991
|
+
successMessage: "Ingress token: {ingressToken}"
|
|
99669
100992
|
},
|
|
99670
100993
|
{
|
|
99671
100994
|
type: "addon-action-button",
|
|
@@ -99677,27 +101000,25 @@ function customSkillSecuritySection(input) {
|
|
|
99677
101000
|
action: "regenerateIngressToken",
|
|
99678
101001
|
variant: "default",
|
|
99679
101002
|
successMessage: "New ingress token: {ingressToken} — put it in HUB_INGRESS_TOKEN now.",
|
|
99680
|
-
confirmMessage: "Rotate the ingress token? With \"Require ingress token\" on, the Lambda is refused until you update HUB_INGRESS_TOKEN."
|
|
99681
|
-
showWhen: CUSTOM_SKILL_ONLY
|
|
99682
|
-
},
|
|
99683
|
-
{
|
|
99684
|
-
type: "boolean",
|
|
99685
|
-
key: "enforceIngressToken",
|
|
99686
|
-
label: "Require ingress token",
|
|
99687
|
-
description: "When on, this hub refuses skill calls without the matching token. Turn it on only after HUB_INGRESS_TOKEN is set in your Lambda.",
|
|
99688
|
-
default: input.defaults.enforceIngressToken,
|
|
99689
|
-
showWhen: CUSTOM_SKILL_ONLY
|
|
101003
|
+
confirmMessage: "Rotate the ingress token? With \"Require ingress token\" on, the Lambda is refused until you update HUB_INGRESS_TOKEN."
|
|
99690
101004
|
}
|
|
99691
101005
|
]
|
|
99692
101006
|
};
|
|
99693
101007
|
}
|
|
99694
|
-
|
|
101008
|
+
/** The skill instance's form (`skills` record). */
|
|
101009
|
+
function buildAlexaInstanceSections(input) {
|
|
99695
101010
|
return [
|
|
99696
101011
|
connectionSection(input),
|
|
99697
101012
|
featuresSection(input),
|
|
101013
|
+
instanceSecuritySection(input)
|
|
101014
|
+
];
|
|
101015
|
+
}
|
|
101016
|
+
function buildAlexaSettingsSections(input) {
|
|
101017
|
+
const security = customSkillSecuritySection(input);
|
|
101018
|
+
return [
|
|
99698
101019
|
accountLinkSection(input),
|
|
99699
101020
|
troubleshootingSection(),
|
|
99700
|
-
|
|
101021
|
+
...security === null ? [] : [security]
|
|
99701
101022
|
];
|
|
99702
101023
|
}
|
|
99703
101024
|
//#endregion
|
|
@@ -100432,7 +101753,7 @@ var ALEXA_ADDON_ID = "export-alexa";
|
|
|
100432
101753
|
* key, id `<addonId>.<key>`, data `{ addonId, key, value }` (never a per-addon scoped table,
|
|
100433
101754
|
* which exists only when something lazily declared it).
|
|
100434
101755
|
*/
|
|
100435
|
-
var ADDON_SETTINGS_TABLE = "addon-settings";
|
|
101756
|
+
var ADDON_SETTINGS_TABLE$1 = "addon-settings";
|
|
100436
101757
|
var RETIRED_PUBLIC_URL_KEYS = ["publicHubUrl"];
|
|
100437
101758
|
async function planDropPublicHubUrl(ports) {
|
|
100438
101759
|
const stored = await ports.readStored();
|
|
@@ -100441,7 +101762,7 @@ async function planDropPublicHubUrl(ports) {
|
|
|
100441
101762
|
const rowId = (key) => `${ALEXA_ADDON_ID}.${key}`;
|
|
100442
101763
|
return { edits: [{
|
|
100443
101764
|
op: "deleteKeys",
|
|
100444
|
-
scope: ADDON_SETTINGS_TABLE,
|
|
101765
|
+
scope: ADDON_SETTINGS_TABLE$1,
|
|
100445
101766
|
keys: present.map(rowId),
|
|
100446
101767
|
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId(key), {
|
|
100447
101768
|
addonId: ALEXA_ADDON_ID,
|
|
@@ -100451,24 +101772,314 @@ async function planDropPublicHubUrl(ports) {
|
|
|
100451
101772
|
}] };
|
|
100452
101773
|
}
|
|
100453
101774
|
//#endregion
|
|
101775
|
+
//#region src/skill-records.ts
|
|
101776
|
+
/**
|
|
101777
|
+
* The Alexa export as an integration instance (D985, D996): ONE `skills` record, owned by
|
|
101778
|
+
* `export-alexa` and named after it, holds how the skill reaches this hub and what each exposed
|
|
101779
|
+
* camera carries. The two ledgers of the link (`linkedAccounts`, `tokens`) are a second record,
|
|
101780
|
+
* `skill-links`, under the SAME id: the instance they belong to. The tokens' credentials are
|
|
101781
|
+
* keychain markers bound to that row, matched by user id so a reorder keeps every ref.
|
|
101782
|
+
*/
|
|
101783
|
+
/** A single-instance addon keeps its records under its own addon id. */
|
|
101784
|
+
var ALEXA_INSTANCE_ID = "export-alexa";
|
|
101785
|
+
var alexaSkillsKind = defineEntryKind("skills", {
|
|
101786
|
+
title: "Alexa skill",
|
|
101787
|
+
nameField: "name",
|
|
101788
|
+
schema: object({
|
|
101789
|
+
name: string().min(1),
|
|
101790
|
+
skillMode: _enum(["public", "custom"]),
|
|
101791
|
+
region: _enum([
|
|
101792
|
+
"NA",
|
|
101793
|
+
"EU",
|
|
101794
|
+
"FE"
|
|
101795
|
+
]),
|
|
101796
|
+
expectedAudience: string(),
|
|
101797
|
+
detectionSensors: boolean(),
|
|
101798
|
+
objectDetection: boolean(),
|
|
101799
|
+
snapshots: boolean(),
|
|
101800
|
+
enforceIngressToken: boolean(),
|
|
101801
|
+
enabled: boolean().optional()
|
|
101802
|
+
})
|
|
101803
|
+
});
|
|
101804
|
+
/** What a skill starts as: the defaults the addon's constructor used to carry. */
|
|
101805
|
+
var ALEXA_SKILL_DEFAULT_BODY = {
|
|
101806
|
+
skillMode: "public",
|
|
101807
|
+
region: "NA",
|
|
101808
|
+
expectedAudience: "",
|
|
101809
|
+
detectionSensors: true,
|
|
101810
|
+
objectDetection: true,
|
|
101811
|
+
snapshots: true,
|
|
101812
|
+
enforceIngressToken: false
|
|
101813
|
+
};
|
|
101814
|
+
/** The settings keys that moved into the `skills` record; the migrations name them. */
|
|
101815
|
+
var MOVED_SKILL_KEYS = [
|
|
101816
|
+
"skillMode",
|
|
101817
|
+
"region",
|
|
101818
|
+
"expectedAudience",
|
|
101819
|
+
"detectionSensors",
|
|
101820
|
+
"objectDetection",
|
|
101821
|
+
"snapshots",
|
|
101822
|
+
"enforceIngressToken"
|
|
101823
|
+
];
|
|
101824
|
+
/** The ledger keys that moved into the `skill-links` record. */
|
|
101825
|
+
var MOVED_LEDGER_KEYS = ["linkedAccounts", "tokens"];
|
|
101826
|
+
var LinkedAccountSchema = object({
|
|
101827
|
+
userId: string(),
|
|
101828
|
+
username: string(),
|
|
101829
|
+
linkedAt: number()
|
|
101830
|
+
});
|
|
101831
|
+
var LwaTokenEntrySchema = object({
|
|
101832
|
+
userId: string(),
|
|
101833
|
+
accessToken: string().meta({ secret: true }),
|
|
101834
|
+
expiresAt: number(),
|
|
101835
|
+
receivedAt: number(),
|
|
101836
|
+
refreshToken: string().optional().meta({ secret: true }),
|
|
101837
|
+
brokerUrl: string().optional(),
|
|
101838
|
+
brokerCredential: string().optional().meta({ secret: true })
|
|
101839
|
+
});
|
|
101840
|
+
var alexaSkillLinksKind = defineEntryKind("skill-links", {
|
|
101841
|
+
title: "Alexa account links",
|
|
101842
|
+
nameField: "name",
|
|
101843
|
+
schema: object({
|
|
101844
|
+
name: string().min(1),
|
|
101845
|
+
linkedAccounts: array(LinkedAccountSchema),
|
|
101846
|
+
tokens: array(LwaTokenEntrySchema)
|
|
101847
|
+
}),
|
|
101848
|
+
secretArrayKeys: { tokens: "userId" }
|
|
101849
|
+
});
|
|
101850
|
+
//#endregion
|
|
101851
|
+
//#region src/migrations/settings-to-records.ts
|
|
101852
|
+
/**
|
|
101853
|
+
* The Alexa export's settings move into records (D985, D996). Three migrations of the catalogue
|
|
101854
|
+
* after the retired-URL one, each idempotent, in this order:
|
|
101855
|
+
*
|
|
101856
|
+
* 2. `moveSettingsToSkill` (procedure): the seven skill settings become the `skills` record.
|
|
101857
|
+
* An existing record is never overwritten.
|
|
101858
|
+
* 3. `moveLedgersToLinks` (procedure): `linkedAccounts` and `tokens` become the `skill-links`
|
|
101859
|
+
* record. The record is read BACK (credentials resolved) and must equal what the old
|
|
101860
|
+
* settings carried, byte for byte, BEFORE the old token credentials are cleared; any
|
|
101861
|
+
* difference throws and clears nothing. An existing record is never overwritten.
|
|
101862
|
+
* 4. `planDropMovedSettings` (plan): the moved keys are deleted from the canonical
|
|
101863
|
+
* `addon-settings` rows, and only while the records are confirmed to hold what they carried.
|
|
101864
|
+
*
|
|
101865
|
+
* All three are `tolerate`: the addon keeps reading the legacy keys until a record exists.
|
|
101866
|
+
*/
|
|
101867
|
+
/** The canonical `addon-settings` table: one row per key, id `<addonId>.<key>`. */
|
|
101868
|
+
var ADDON_SETTINGS_TABLE = "addon-settings";
|
|
101869
|
+
var SKILL_NAME = "Alexa skill";
|
|
101870
|
+
var LINKS_NAME = "Alexa account links";
|
|
101871
|
+
function text(stored, key) {
|
|
101872
|
+
const value = stored[key];
|
|
101873
|
+
return typeof value === "string" ? value.trim() : "";
|
|
101874
|
+
}
|
|
101875
|
+
function flag(stored, key, fallback) {
|
|
101876
|
+
const value = stored[key];
|
|
101877
|
+
return typeof value === "boolean" ? value : fallback;
|
|
101878
|
+
}
|
|
101879
|
+
/** The record body the legacy settings describe; a missing or mistyped key takes the default. */
|
|
101880
|
+
function skillBodyFrom(stored) {
|
|
101881
|
+
const d = ALEXA_SKILL_DEFAULT_BODY;
|
|
101882
|
+
const region = stored["region"];
|
|
101883
|
+
return {
|
|
101884
|
+
name: SKILL_NAME,
|
|
101885
|
+
skillMode: stored["skillMode"] === "custom" ? "custom" : "public",
|
|
101886
|
+
region: region === "EU" || region === "FE" ? region : "NA",
|
|
101887
|
+
expectedAudience: text(stored, "expectedAudience"),
|
|
101888
|
+
detectionSensors: flag(stored, "detectionSensors", d.detectionSensors),
|
|
101889
|
+
objectDetection: flag(stored, "objectDetection", d.objectDetection),
|
|
101890
|
+
snapshots: flag(stored, "snapshots", d.snapshots),
|
|
101891
|
+
enforceIngressToken: flag(stored, "enforceIngressToken", d.enforceIngressToken)
|
|
101892
|
+
};
|
|
101893
|
+
}
|
|
101894
|
+
async function moveSettingsToSkill(ports) {
|
|
101895
|
+
const stored = await ports.readStored();
|
|
101896
|
+
if (!MOVED_SKILL_KEYS.some((key) => key in stored)) return {
|
|
101897
|
+
outcome: "already-done",
|
|
101898
|
+
summary: { moved: false }
|
|
101899
|
+
};
|
|
101900
|
+
return await ports.putSkill(skillBodyFrom(stored)) === "created" ? {
|
|
101901
|
+
outcome: "done",
|
|
101902
|
+
summary: { moved: true }
|
|
101903
|
+
} : {
|
|
101904
|
+
outcome: "already-done",
|
|
101905
|
+
summary: { moved: false }
|
|
101906
|
+
};
|
|
101907
|
+
}
|
|
101908
|
+
function accountsOf(value) {
|
|
101909
|
+
return Array.isArray(value) ? value.filter(isLinkedAccount) : [];
|
|
101910
|
+
}
|
|
101911
|
+
function tokensOf(value) {
|
|
101912
|
+
return Array.isArray(value) ? value.filter(isTokenEntry) : [];
|
|
101913
|
+
}
|
|
101914
|
+
function isLinkedAccount(value) {
|
|
101915
|
+
return typeof value === "object" && value !== null && "userId" in value && typeof value.userId === "string" && "username" in value && typeof value.username === "string" && "linkedAt" in value && typeof value.linkedAt === "number";
|
|
101916
|
+
}
|
|
101917
|
+
function isTokenEntry(value) {
|
|
101918
|
+
return typeof value === "object" && value !== null && "userId" in value && typeof value.userId === "string" && "accessToken" in value && typeof value.accessToken === "string" && "expiresAt" in value && typeof value.expiresAt === "number" && "receivedAt" in value && typeof value.receivedAt === "number";
|
|
101919
|
+
}
|
|
101920
|
+
/** Key-order-independent JSON, so "byte-identical" does not depend on how a store orders keys. */
|
|
101921
|
+
function canonical(value) {
|
|
101922
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
101923
|
+
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(v)}`).join(",")}}`;
|
|
101924
|
+
return JSON.stringify(value) ?? "null";
|
|
101925
|
+
}
|
|
101926
|
+
async function moveLedgersToLinks(ports) {
|
|
101927
|
+
const stored = await ports.readStored();
|
|
101928
|
+
if (!MOVED_LEDGER_KEYS.some((key) => key in stored)) return {
|
|
101929
|
+
outcome: "already-done",
|
|
101930
|
+
summary: { moved: false }
|
|
101931
|
+
};
|
|
101932
|
+
const linkedAccounts = accountsOf(stored["linkedAccounts"]);
|
|
101933
|
+
const tokens = tokensOf(stored["tokens"]);
|
|
101934
|
+
const put = await ports.putLinks({
|
|
101935
|
+
name: LINKS_NAME,
|
|
101936
|
+
linkedAccounts,
|
|
101937
|
+
tokens
|
|
101938
|
+
});
|
|
101939
|
+
const held = await ports.readLinks();
|
|
101940
|
+
if (!(held !== null && canonical(held.linkedAccounts) === canonical(linkedAccounts) && canonical(held.tokens) === canonical(tokens))) {
|
|
101941
|
+
ports.warn("Alexa migration: the skill-links record does not hold what the settings carried; the legacy ledgers are kept");
|
|
101942
|
+
if (put === "created") throw new Error("the Alexa link record does not match the legacy settings; nothing was cleared");
|
|
101943
|
+
return {
|
|
101944
|
+
outcome: "already-done",
|
|
101945
|
+
summary: { moved: false }
|
|
101946
|
+
};
|
|
101947
|
+
}
|
|
101948
|
+
if (tokens.length > 0) await ports.clearOldTokenSecrets();
|
|
101949
|
+
return put === "created" ? {
|
|
101950
|
+
outcome: "done",
|
|
101951
|
+
summary: {
|
|
101952
|
+
moved: true,
|
|
101953
|
+
accounts: linkedAccounts.length
|
|
101954
|
+
}
|
|
101955
|
+
} : {
|
|
101956
|
+
outcome: "already-done",
|
|
101957
|
+
summary: { moved: false }
|
|
101958
|
+
};
|
|
101959
|
+
}
|
|
101960
|
+
/** Whether a stored token entry still carries a credential: text, or a keychain marker. */
|
|
101961
|
+
function carriesCredential(entry) {
|
|
101962
|
+
if (typeof entry !== "object" || entry === null) return false;
|
|
101963
|
+
return [
|
|
101964
|
+
"accessToken",
|
|
101965
|
+
"refreshToken",
|
|
101966
|
+
"brokerCredential"
|
|
101967
|
+
].some((key) => {
|
|
101968
|
+
const value = Reflect.get(entry, key);
|
|
101969
|
+
if (typeof value === "string") return value.length > 0;
|
|
101970
|
+
return typeof value === "object" && value !== null;
|
|
101971
|
+
});
|
|
101972
|
+
}
|
|
101973
|
+
var rowId = (key) => `${ALEXA_INSTANCE_ID}.${key}`;
|
|
101974
|
+
async function planDropMovedSettings(ports) {
|
|
101975
|
+
const stored = await ports.readRawStored();
|
|
101976
|
+
const skillKeys = MOVED_SKILL_KEYS.filter((key) => key in stored);
|
|
101977
|
+
const ledgerKeys = MOVED_LEDGER_KEYS.filter((key) => key in stored);
|
|
101978
|
+
if (skillKeys.length === 0 && ledgerKeys.length === 0) return { edits: [] };
|
|
101979
|
+
const refuse = (reason) => {
|
|
101980
|
+
ports.warn(`Alexa migration: the legacy keys are kept: ${reason}`);
|
|
101981
|
+
throw new Error(`the legacy Alexa keys are not deleted: ${reason}`);
|
|
101982
|
+
};
|
|
101983
|
+
if (skillKeys.length > 0 && !await ports.hasSkill()) return refuse("no Alexa skill record exists");
|
|
101984
|
+
if (ledgerKeys.length > 0) {
|
|
101985
|
+
const links = await ports.readLinks();
|
|
101986
|
+
if (links === null) return refuse("no Alexa link record exists");
|
|
101987
|
+
const held = new Set(links.linkedAccounts.map((a) => a.userId));
|
|
101988
|
+
const heldTokens = new Set(links.tokens.map((t) => t.userId));
|
|
101989
|
+
const legacyTokens = stored["tokens"];
|
|
101990
|
+
if (Array.isArray(legacyTokens) && legacyTokens.some(carriesCredential)) return refuse("the old settings still carry Amazon push credentials");
|
|
101991
|
+
for (const account of accountsOf(stored["linkedAccounts"])) if (!held.has(account.userId)) return refuse(`the record lacks the account ${account.userId}`);
|
|
101992
|
+
for (const token of tokensOf(stored["tokens"])) if (!heldTokens.has(token.userId)) return refuse(`the record lacks the grant ${token.userId}`);
|
|
101993
|
+
}
|
|
101994
|
+
const present = [...skillKeys, ...ledgerKeys];
|
|
101995
|
+
return { edits: [{
|
|
101996
|
+
op: "deleteKeys",
|
|
101997
|
+
scope: ADDON_SETTINGS_TABLE,
|
|
101998
|
+
keys: present.map(rowId),
|
|
101999
|
+
precondition: preconditionOf(Object.fromEntries(present.map((key) => [rowId(key), {
|
|
102000
|
+
addonId: ALEXA_INSTANCE_ID,
|
|
102001
|
+
key,
|
|
102002
|
+
value: stored[key]
|
|
102003
|
+
}])))
|
|
102004
|
+
}] };
|
|
102005
|
+
}
|
|
102006
|
+
//#endregion
|
|
100454
102007
|
//#region src/migrations/index.ts
|
|
100455
|
-
|
|
100456
|
-
var
|
|
100457
|
-
|
|
100458
|
-
|
|
100459
|
-
|
|
100460
|
-
|
|
100461
|
-
|
|
100462
|
-
|
|
100463
|
-
|
|
100464
|
-
|
|
100465
|
-
|
|
100466
|
-
|
|
100467
|
-
|
|
100468
|
-
|
|
100469
|
-
|
|
100470
|
-
|
|
100471
|
-
|
|
102008
|
+
var DROP_PUBLIC_HUB_URL_ID = "export-alexa/2026-11-02-drop-public-hub-url";
|
|
102009
|
+
var SETTINGS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-settings-to-integration";
|
|
102010
|
+
var LEDGERS_TO_INTEGRATION_ID = "export-alexa/2026-11-03-ledgers-to-integration";
|
|
102011
|
+
var DROP_MOVED_SETTINGS_ID = "export-alexa/2026-11-03-drop-moved-settings";
|
|
102012
|
+
var FIXTURE_MARK = "the exposed device list the migration does not know";
|
|
102013
|
+
/**
|
|
102014
|
+
* The `export-alexa` catalogue (D987): offered to the engine when the addon initialises. Every
|
|
102015
|
+
* entry is `tolerate`; until a record exists the addon keeps reading the legacy keys.
|
|
102016
|
+
*/
|
|
102017
|
+
var ADDON_MIGRATIONS = [
|
|
102018
|
+
{
|
|
102019
|
+
meta: {
|
|
102020
|
+
id: DROP_PUBLIC_HUB_URL_ID,
|
|
102021
|
+
owner: "export-alexa",
|
|
102022
|
+
level: "addon-state",
|
|
102023
|
+
seq: 1,
|
|
102024
|
+
dependsOn: [],
|
|
102025
|
+
store: "settings",
|
|
102026
|
+
scope: "cluster",
|
|
102027
|
+
onFailure: "tolerate",
|
|
102028
|
+
bodyKind: "plan",
|
|
102029
|
+
description: "Delete the retired publicHubUrl setting; the public URL is the publicEndpoint role",
|
|
102030
|
+
fixtureMark: FIXTURE_MARK
|
|
102031
|
+
},
|
|
102032
|
+
plan: planDropPublicHubUrl
|
|
102033
|
+
},
|
|
102034
|
+
{
|
|
102035
|
+
meta: {
|
|
102036
|
+
id: SETTINGS_TO_INTEGRATION_ID,
|
|
102037
|
+
owner: "export-alexa",
|
|
102038
|
+
level: "addon-state",
|
|
102039
|
+
seq: 2,
|
|
102040
|
+
dependsOn: [],
|
|
102041
|
+
store: "settings",
|
|
102042
|
+
scope: "cluster",
|
|
102043
|
+
onFailure: "tolerate",
|
|
102044
|
+
bodyKind: "procedure",
|
|
102045
|
+
description: "Move the Alexa skill settings (mode, region, audience, feature switches) into the skills record",
|
|
102046
|
+
fixtureMark: FIXTURE_MARK
|
|
102047
|
+
},
|
|
102048
|
+
procedure: moveSettingsToSkill
|
|
102049
|
+
},
|
|
102050
|
+
{
|
|
102051
|
+
meta: {
|
|
102052
|
+
id: LEDGERS_TO_INTEGRATION_ID,
|
|
102053
|
+
owner: "export-alexa",
|
|
102054
|
+
level: "addon-state",
|
|
102055
|
+
seq: 3,
|
|
102056
|
+
dependsOn: [SETTINGS_TO_INTEGRATION_ID],
|
|
102057
|
+
store: "settings",
|
|
102058
|
+
scope: "cluster",
|
|
102059
|
+
onFailure: "tolerate",
|
|
102060
|
+
bodyKind: "procedure",
|
|
102061
|
+
description: "Move the linked accounts and Amazon push grants into the skill-links record; the old credentials are cleared only after the record reads back identical",
|
|
102062
|
+
fixtureMark: FIXTURE_MARK
|
|
102063
|
+
},
|
|
102064
|
+
procedure: moveLedgersToLinks
|
|
102065
|
+
},
|
|
102066
|
+
{
|
|
102067
|
+
meta: {
|
|
102068
|
+
id: DROP_MOVED_SETTINGS_ID,
|
|
102069
|
+
owner: "export-alexa",
|
|
102070
|
+
level: "addon-state",
|
|
102071
|
+
seq: 4,
|
|
102072
|
+
dependsOn: [SETTINGS_TO_INTEGRATION_ID, LEDGERS_TO_INTEGRATION_ID],
|
|
102073
|
+
store: "settings",
|
|
102074
|
+
scope: "cluster",
|
|
102075
|
+
onFailure: "tolerate",
|
|
102076
|
+
bodyKind: "plan",
|
|
102077
|
+
description: "Delete the Alexa settings and ledger keys that moved into the records",
|
|
102078
|
+
fixtureMark: FIXTURE_MARK
|
|
102079
|
+
},
|
|
102080
|
+
plan: planDropMovedSettings
|
|
102081
|
+
}
|
|
102082
|
+
];
|
|
100472
102083
|
//#endregion
|
|
100473
102084
|
//#region src/oauth-integration.ts
|
|
100474
102085
|
/**
|
|
@@ -101811,6 +103422,11 @@ var SUPPORTED_KINDS = [
|
|
|
101811
103422
|
DeviceType.Cover,
|
|
101812
103423
|
DeviceType.Generic
|
|
101813
103424
|
];
|
|
103425
|
+
/** Whether a stored token entry still carries a keychain marker instead of a resolved credential. */
|
|
103426
|
+
function hasUnresolvedCredential(entry) {
|
|
103427
|
+
if (typeof entry !== "object" || entry === null) return false;
|
|
103428
|
+
return "accessToken" in entry && isSecretMarker(entry.accessToken) || "refreshToken" in entry && isSecretMarker(entry.refreshToken) || "brokerCredential" in entry && isSecretMarker(entry.brokerCredential);
|
|
103429
|
+
}
|
|
101814
103430
|
var ExportAlexaAddon = class extends BaseAddon {
|
|
101815
103431
|
/** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
|
|
101816
103432
|
secretStatePaths = [
|
|
@@ -101846,13 +103462,69 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101846
103462
|
constructor() {
|
|
101847
103463
|
super({ ...DEFAULT_CONFIG });
|
|
101848
103464
|
}
|
|
103465
|
+
instances = null;
|
|
103466
|
+
/** The `skills` record, once it exists; until then the legacy settings keys answer. */
|
|
103467
|
+
skillRow = null;
|
|
103468
|
+
/** The `skill-links` record, once it exists; until then the legacy ledger keys answer. */
|
|
103469
|
+
linksRow = null;
|
|
103470
|
+
/** The keychain refused the link credentials: the ledger is read-only until it answers (D49). */
|
|
103471
|
+
linksLocked = false;
|
|
103472
|
+
/**
|
|
103473
|
+
* The settings as the addon reads them: the records where they exist, the legacy keys until
|
|
103474
|
+
* the migrations have moved them.
|
|
103475
|
+
*/
|
|
103476
|
+
get view() {
|
|
103477
|
+
const skill = this.skillRow;
|
|
103478
|
+
const links = this.linksRow;
|
|
103479
|
+
if (skill === null && links === null) return this.config;
|
|
103480
|
+
return {
|
|
103481
|
+
...this.config,
|
|
103482
|
+
...skill === null ? {} : {
|
|
103483
|
+
skillMode: skill.skillMode,
|
|
103484
|
+
region: skill.region,
|
|
103485
|
+
expectedAudience: skill.expectedAudience,
|
|
103486
|
+
detectionSensors: skill.detectionSensors,
|
|
103487
|
+
objectDetection: skill.objectDetection,
|
|
103488
|
+
snapshots: skill.snapshots,
|
|
103489
|
+
enforceIngressToken: skill.enforceIngressToken
|
|
103490
|
+
},
|
|
103491
|
+
...links === null ? {} : {
|
|
103492
|
+
linkedAccounts: links.linkedAccounts,
|
|
103493
|
+
tokens: links.tokens
|
|
103494
|
+
}
|
|
103495
|
+
};
|
|
103496
|
+
}
|
|
101849
103497
|
/**
|
|
101850
103498
|
* The hub's public origin: the `publicEndpoint` role of `local-network`, read on every use
|
|
101851
103499
|
* through `ctx.api` (planning#378). No setting holds it and nothing ranks the palette here.
|
|
101852
103500
|
*/
|
|
101853
103501
|
publicEndpoint = createPublicEndpointReader(() => this.ctx.api.localNetwork.getAddresses.query());
|
|
101854
103502
|
async onInitialize() {
|
|
101855
|
-
|
|
103503
|
+
const records = this.ctx.records;
|
|
103504
|
+
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
103505
|
+
await records.declare({
|
|
103506
|
+
skills: alexaSkillsKind,
|
|
103507
|
+
"skill-links": alexaSkillLinksKind
|
|
103508
|
+
});
|
|
103509
|
+
this.instances = new RecordIntegrationInstances(records, alexaSkillsKind, {
|
|
103510
|
+
description: {
|
|
103511
|
+
instanceMode: "single",
|
|
103512
|
+
kind: "skills",
|
|
103513
|
+
canTest: false
|
|
103514
|
+
},
|
|
103515
|
+
formSchema: () => this.skillForm(),
|
|
103516
|
+
initialBody: (name) => ({
|
|
103517
|
+
...ALEXA_SKILL_DEFAULT_BODY,
|
|
103518
|
+
name
|
|
103519
|
+
}),
|
|
103520
|
+
configured: () => true,
|
|
103521
|
+
onChanged: async () => {
|
|
103522
|
+
await this.refreshRecords();
|
|
103523
|
+
await this.onConfigChanged();
|
|
103524
|
+
}
|
|
103525
|
+
});
|
|
103526
|
+
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
103527
|
+
await this.refreshRecords();
|
|
101856
103528
|
if (!this.config.ingressToken) await this.updateGlobalSettings({ ingressToken: generateIngressToken() });
|
|
101857
103529
|
if (!this.config.snapshotSigningKey) await this.updateGlobalSettings({ snapshotSigningKey: generateIngressToken() });
|
|
101858
103530
|
if (!this.config.visionNamespace) await this.updateGlobalSettings({ visionNamespace: randomUUID() });
|
|
@@ -101870,7 +103542,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101870
103542
|
});
|
|
101871
103543
|
this.visibilityRef = new AccountVisibilityMirror({
|
|
101872
103544
|
gate: this.accessGateRef,
|
|
101873
|
-
listLinkedUserIds: () => this.
|
|
103545
|
+
listLinkedUserIds: () => this.view.linkedAccounts.map((a) => a.userId),
|
|
101874
103546
|
listExposedDeviceIds: () => this.config.exposed.map((e) => e.deviceId),
|
|
101875
103547
|
getStored: () => this.config.accountVisibility,
|
|
101876
103548
|
setStored: (next) => this.updateGlobalSettings({ accountVisibility: next }),
|
|
@@ -101879,8 +103551,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101879
103551
|
this.visionRef = new AlexaVisionRuntime({
|
|
101880
103552
|
ctx: this.ctx,
|
|
101881
103553
|
logger: this.ctx.logger,
|
|
101882
|
-
integrationOn: () => this.
|
|
101883
|
-
snapshotsOn: () => this.
|
|
103554
|
+
integrationOn: () => this.view.objectDetection,
|
|
103555
|
+
snapshotsOn: () => this.view.snapshots,
|
|
101884
103556
|
isExposed: (deviceId) => this.config.exposed.some((e) => e.deviceId === deviceId),
|
|
101885
103557
|
knownClasses: (deviceId) => this.config.detectionClasses[deviceId]?.classes ?? [],
|
|
101886
103558
|
namespace: () => this.config.visionNamespace,
|
|
@@ -101891,12 +103563,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101891
103563
|
this.actionScenes = new ActionSceneExports({
|
|
101892
103564
|
api: this.ctx.api,
|
|
101893
103565
|
logger: this.ctx.logger,
|
|
101894
|
-
linkedUserIds: () => this.
|
|
103566
|
+
linkedUserIds: () => this.view.linkedAccounts.map((a) => a.userId),
|
|
101895
103567
|
isAdminUser: async (userId) => {
|
|
101896
103568
|
const lookup = await this.accessGate.principal(userId);
|
|
101897
103569
|
return lookup.kind === "found" && lookup.principal.kind === "admin";
|
|
101898
103570
|
},
|
|
101899
|
-
canPush: () => this.
|
|
103571
|
+
canPush: () => this.view.tokens.length > 0,
|
|
101900
103572
|
postAddOrUpdate: (userId, endpoints) => this.requireGateway().postReport(userId, (accessToken) => buildAddOrUpdateReportPayload(userId, endpoints, accessToken), `action scenes add/update (${endpoints.length})`),
|
|
101901
103573
|
postDelete: (userId, ids) => this.requireGateway().postReport(userId, (accessToken) => buildDeleteReportPayload(userId, ids, accessToken), `action scenes delete (${ids.length})`),
|
|
101902
103574
|
persist: (entries) => this.updateGlobalSettings({ exposedActions: [...entries] })
|
|
@@ -101907,7 +103579,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101907
103579
|
});
|
|
101908
103580
|
const deviceExportProvider = {
|
|
101909
103581
|
getStatus: async () => ({
|
|
101910
|
-
linkState: this.
|
|
103582
|
+
linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
|
|
101911
103583
|
exposedDeviceCount: this.config.exposed.length,
|
|
101912
103584
|
setup: await this.buildSetupBlock()
|
|
101913
103585
|
}),
|
|
@@ -101995,6 +103667,10 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
101995
103667
|
ctx: this.ctx,
|
|
101996
103668
|
logger: this.ctx.logger
|
|
101997
103669
|
},
|
|
103670
|
+
mediaPlayerController: {
|
|
103671
|
+
ctx: this.ctx,
|
|
103672
|
+
logger: this.ctx.logger
|
|
103673
|
+
},
|
|
101998
103674
|
coverController: {
|
|
101999
103675
|
ctx: this.ctx,
|
|
102000
103676
|
logger: this.ctx.logger,
|
|
@@ -102004,7 +103680,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102004
103680
|
ctx: this.ctx,
|
|
102005
103681
|
logger: this.ctx.logger,
|
|
102006
103682
|
store: this.snapshotStore,
|
|
102007
|
-
enabled: () => this.
|
|
103683
|
+
enabled: () => this.view.snapshots,
|
|
102008
103684
|
publicEndpoint: this.publicEndpoint
|
|
102009
103685
|
},
|
|
102010
103686
|
vision: this.vision.context(),
|
|
@@ -102026,7 +103702,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102026
103702
|
onBrokerAdvertised: (raw) => this.rememberAdvertisedBroker(raw),
|
|
102027
103703
|
snapshotRoute: {
|
|
102028
103704
|
store: this.snapshotStore,
|
|
102029
|
-
enabled: () => this.
|
|
103705
|
+
enabled: () => this.view.snapshots,
|
|
102030
103706
|
verifyToken: (token) => this.verifyAccountLinkToken(token),
|
|
102031
103707
|
mayView: async (userId, deviceId) => {
|
|
102032
103708
|
const lookup = await this.accessGate.principal(userId);
|
|
@@ -102054,13 +103730,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102054
103730
|
onExposedDoorbellPress: (deviceId) => {
|
|
102055
103731
|
this.egressPrewarm?.onPress(deviceId);
|
|
102056
103732
|
},
|
|
102057
|
-
listLinkedAccounts: () => this.
|
|
102058
|
-
listTokens: () => this.
|
|
103733
|
+
listLinkedAccounts: () => this.view.linkedAccounts,
|
|
103734
|
+
listTokens: () => this.view.tokens,
|
|
102059
103735
|
upsertToken: (input) => this.upsertToken(input),
|
|
102060
103736
|
removeLinkedAccount: (userId) => this.removeLinkedAccount(userId),
|
|
102061
103737
|
getAdvertisedBrokerUrl: () => this.config.advertisedBrokerUrl || null,
|
|
102062
103738
|
getPublicEndpoint: this.publicEndpoint,
|
|
102063
|
-
getRegion: () => this.
|
|
103739
|
+
getRegion: () => this.view.region,
|
|
102064
103740
|
getExportedSignature: (deviceId) => this.config.exportedSignatures[deviceId] ?? null,
|
|
102065
103741
|
accountMaySee: (userId, deviceId) => this.visibility.allows(userId, deviceId)
|
|
102066
103742
|
});
|
|
@@ -102068,7 +103744,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102068
103744
|
const gatewayForFeed = this.lwaGateway;
|
|
102069
103745
|
this.detectionFeed = new DetectionSensorFeed({
|
|
102070
103746
|
eventBus: this.ctx.eventBus,
|
|
102071
|
-
enabled: () => this.
|
|
103747
|
+
enabled: () => this.view.detectionSensors,
|
|
102072
103748
|
isExposed: (deviceId) => this.config.exposed.some((e) => e.deviceId === deviceId),
|
|
102073
103749
|
readActiveTracks: async (deviceId) => {
|
|
102074
103750
|
return (await this.ctx.api.pipelineAnalytics.getActiveTracks.query({ deviceId })).map((t) => ({
|
|
@@ -102114,8 +103790,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102114
103790
|
this.syncEngine = new SyncEngine({
|
|
102115
103791
|
logger: this.ctx.logger,
|
|
102116
103792
|
listExposed: () => this.config.exposed,
|
|
102117
|
-
listLinkedAccounts: () => this.
|
|
102118
|
-
hasProactiveCredentials: () => this.
|
|
103793
|
+
listLinkedAccounts: () => this.view.linkedAccounts,
|
|
103794
|
+
hasProactiveCredentials: () => this.view.tokens.length > 0,
|
|
102119
103795
|
buildEndpoints: (deviceId) => this.buildEndpointsForOneDevice(deviceId),
|
|
102120
103796
|
filterForAccount: (userId, endpoints) => this.filterForAccount(userId, endpoints),
|
|
102121
103797
|
afterPush: (userId, endpoints) => this.requireGateway().scheduleInitialConnectivity(userId, endpoints),
|
|
@@ -102145,10 +103821,10 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102145
103821
|
this.ctx.addDisposer(async () => clearInterval(reaper));
|
|
102146
103822
|
this.ctx.logger.info("export-alexa: initialized", { meta: {
|
|
102147
103823
|
exposedCount: this.config.exposed.length,
|
|
102148
|
-
skillMode: this.
|
|
103824
|
+
skillMode: this.view.skillMode,
|
|
102149
103825
|
skillIdSet: this.effectiveSettings().expectedAudience.length > 0,
|
|
102150
|
-
pushGrants: this.
|
|
102151
|
-
brokerGrants: this.
|
|
103826
|
+
pushGrants: this.view.tokens.length,
|
|
103827
|
+
brokerGrants: this.view.tokens.filter(isBrokerGrant).length
|
|
102152
103828
|
} });
|
|
102153
103829
|
return {
|
|
102154
103830
|
providers: [
|
|
@@ -102156,6 +103832,10 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102156
103832
|
capability: deviceExportCapability,
|
|
102157
103833
|
provider: deviceExportProvider
|
|
102158
103834
|
},
|
|
103835
|
+
{
|
|
103836
|
+
capability: integrationInstancesCapability,
|
|
103837
|
+
provider: this.requireInstances().toProvider()
|
|
103838
|
+
},
|
|
102159
103839
|
{
|
|
102160
103840
|
capability: addonRoutesCapability,
|
|
102161
103841
|
provider: routeProvider
|
|
@@ -102263,18 +103943,18 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102263
103943
|
return buildEndpointsForExposedDevice(deviceId, {
|
|
102264
103944
|
ctx: this.ctx,
|
|
102265
103945
|
logger: this.ctx.logger,
|
|
102266
|
-
snapshots: this.
|
|
102267
|
-
...this.
|
|
103946
|
+
snapshots: this.view.snapshots,
|
|
103947
|
+
...this.view.detectionSensors ? { detectionClasses: async (id) => effectiveSensorClasses(await classesOf(id), parseSensorSelection(await vision.readPrefs(id))) } : {},
|
|
102268
103948
|
alexaName: async (id) => readAlexaName(await vision.readPrefs(id)),
|
|
102269
|
-
...this.
|
|
103949
|
+
...this.view.objectDetection ? { objectDetection: async (id) => vision.buildClasses(id, await classesOf(id)) } : {}
|
|
102270
103950
|
});
|
|
102271
103951
|
}
|
|
102272
103952
|
/** The settings that change every exposed endpoint's shape, as one key. */
|
|
102273
103953
|
shapeSwitches() {
|
|
102274
103954
|
return JSON.stringify({
|
|
102275
|
-
detectionSensors: this.
|
|
102276
|
-
snapshots: this.
|
|
102277
|
-
objectDetection: this.
|
|
103955
|
+
detectionSensors: this.view.detectionSensors,
|
|
103956
|
+
snapshots: this.view.snapshots,
|
|
103957
|
+
objectDetection: this.view.objectDetection
|
|
102278
103958
|
});
|
|
102279
103959
|
}
|
|
102280
103960
|
/**
|
|
@@ -102286,7 +103966,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102286
103966
|
const now = this.shapeSwitches();
|
|
102287
103967
|
if (this.appliedShapeSwitches === null || now === this.appliedShapeSwitches) return;
|
|
102288
103968
|
this.appliedShapeSwitches = now;
|
|
102289
|
-
if (!this.
|
|
103969
|
+
if (!this.view.snapshots) this.snapshotStore.clear();
|
|
102290
103970
|
this.ctx.logger.info("export-alexa: an endpoint-shape switch changed — re-syncing every device", { meta: { switches: now } });
|
|
102291
103971
|
const engine = this.syncEngine;
|
|
102292
103972
|
if (engine === null) return;
|
|
@@ -102296,7 +103976,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102296
103976
|
}
|
|
102297
103977
|
scheduleDetectionClassRefresh() {
|
|
102298
103978
|
const timer = setInterval(() => {
|
|
102299
|
-
if (!this.
|
|
103979
|
+
if (!this.view.detectionSensors && !this.view.objectDetection) return;
|
|
102300
103980
|
this.requireSyncEngine().reconcileAllExposed().catch((err) => {
|
|
102301
103981
|
this.ctx.logger.warn("export-alexa: detection-class refresh failed", { meta: { error: errMsg$1(err) } });
|
|
102302
103982
|
});
|
|
@@ -102438,8 +104118,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102438
104118
|
* Throws when nothing can be sent, so the button says why.
|
|
102439
104119
|
*/
|
|
102440
104120
|
async resyncDiscovery() {
|
|
102441
|
-
if (this.
|
|
102442
|
-
if (this.
|
|
104121
|
+
if (this.view.linkedAccounts.length === 0) throw new Error("No linked Amazon account. Link the skill from the Alexa app first.");
|
|
104122
|
+
if (this.view.tokens.length === 0) throw new Error("No Amazon push grant is stored for the linked account, so nothing can be sent. Re-link the skill from the Alexa app.");
|
|
102443
104123
|
const r = await this.requireSyncEngine().resync();
|
|
102444
104124
|
this.ctx.logger.info("export-alexa: manual discovery re-sync", { meta: { ...r } });
|
|
102445
104125
|
return r;
|
|
@@ -102488,11 +104168,13 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102488
104168
|
}
|
|
102489
104169
|
this.ctx.logger.warn("export-alexa: revokeOauthSession reported failure — the session may already be gone", { meta: { sessionId: id } });
|
|
102490
104170
|
}
|
|
102491
|
-
await this.revokeAtBroker(this.
|
|
102492
|
-
const removedAccounts = this.
|
|
102493
|
-
await this.
|
|
104171
|
+
await this.revokeAtBroker(this.view.tokens);
|
|
104172
|
+
const removedAccounts = this.view.linkedAccounts.length;
|
|
104173
|
+
await this.writeLedger({
|
|
102494
104174
|
linkedAccounts: [],
|
|
102495
|
-
tokens: []
|
|
104175
|
+
tokens: []
|
|
104176
|
+
});
|
|
104177
|
+
await this.updateGlobalSettings({
|
|
102496
104178
|
exportedEndpoints: {},
|
|
102497
104179
|
exportedSignatures: {},
|
|
102498
104180
|
accountVisibility: {}
|
|
@@ -102517,25 +104199,25 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102517
104199
|
...input.brokerUrl ? { brokerUrl: input.brokerUrl } : {},
|
|
102518
104200
|
...input.brokerCredential ? { brokerCredential: input.brokerCredential } : {}
|
|
102519
104201
|
};
|
|
102520
|
-
const next = this.
|
|
104202
|
+
const next = this.view.tokens.filter((t) => t.userId !== input.userId);
|
|
102521
104203
|
next.push(entry);
|
|
102522
|
-
await this.
|
|
104204
|
+
await this.writeLedger({ tokens: next });
|
|
102523
104205
|
}
|
|
102524
104206
|
async removeLinkedAccount(userId) {
|
|
102525
|
-
await this.
|
|
102526
|
-
tokens: this.
|
|
102527
|
-
linkedAccounts: this.
|
|
104207
|
+
await this.writeLedger({
|
|
104208
|
+
tokens: this.view.tokens.filter((t) => t.userId !== userId),
|
|
104209
|
+
linkedAccounts: this.view.linkedAccounts.filter((a) => a.userId !== userId)
|
|
102528
104210
|
});
|
|
102529
104211
|
this.ctx.logger.warn("export-alexa: unlinked revoked account", { meta: { userId } });
|
|
102530
104212
|
}
|
|
102531
104213
|
async recordLinkedAccount(input) {
|
|
102532
|
-
if (this.
|
|
102533
|
-
const next = [...this.
|
|
104214
|
+
if (this.view.linkedAccounts.some((a) => a.userId === input.userId)) return;
|
|
104215
|
+
const next = [...this.view.linkedAccounts, {
|
|
102534
104216
|
userId: input.userId,
|
|
102535
104217
|
username: input.username,
|
|
102536
104218
|
linkedAt: Date.now()
|
|
102537
104219
|
}];
|
|
102538
|
-
await this.
|
|
104220
|
+
await this.writeLedger({ linkedAccounts: next });
|
|
102539
104221
|
const engine = this.syncEngine;
|
|
102540
104222
|
if (!engine) return;
|
|
102541
104223
|
engine.pushAllToAccount(input.userId).then((r) => {
|
|
@@ -102554,8 +104236,8 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102554
104236
|
* token carries none). Idempotent via recordLinkedAccount.
|
|
102555
104237
|
*/
|
|
102556
104238
|
async backfillLinkedAccounts() {
|
|
102557
|
-
const linked = new Set(this.
|
|
102558
|
-
const missing = this.
|
|
104239
|
+
const linked = new Set(this.view.linkedAccounts.map((a) => a.userId));
|
|
104240
|
+
const missing = this.view.tokens.filter((t) => !linked.has(t.userId));
|
|
102559
104241
|
for (const t of missing) await this.recordLinkedAccount({
|
|
102560
104242
|
userId: t.userId,
|
|
102561
104243
|
username: t.userId
|
|
@@ -102597,10 +104279,10 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102597
104279
|
* broker no longer recognises is reported, not retried — re-link instead.
|
|
102598
104280
|
*/
|
|
102599
104281
|
async rotateBrokerCredentials() {
|
|
102600
|
-
if (!this.
|
|
104282
|
+
if (!this.view.tokens.some(isBrokerGrant)) throw new Error("No link is held at the skill's token broker, so there is no credential to rotate. Link the skill from the Alexa app first.");
|
|
102601
104283
|
let rotated = 0;
|
|
102602
104284
|
let failed = 0;
|
|
102603
|
-
for (const t of this.
|
|
104285
|
+
for (const t of this.view.tokens) {
|
|
102604
104286
|
if (!isBrokerGrant(t)) continue;
|
|
102605
104287
|
try {
|
|
102606
104288
|
const next = await rotateBrokerCredential(fetch, t.brokerUrl, t.brokerCredential);
|
|
@@ -102652,17 +104334,133 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102652
104334
|
return buildAlexaSetupBlock({
|
|
102653
104335
|
publicEndpoint: await this.publicEndpoint(),
|
|
102654
104336
|
ingressToken: this.config.ingressToken,
|
|
102655
|
-
skillMode: this.
|
|
104337
|
+
skillMode: this.view.skillMode
|
|
104338
|
+
});
|
|
104339
|
+
}
|
|
104340
|
+
requireInstances() {
|
|
104341
|
+
if (this.instances === null) throw new Error("export-alexa: the instances are not open");
|
|
104342
|
+
return this.instances;
|
|
104343
|
+
}
|
|
104344
|
+
skillHandle() {
|
|
104345
|
+
const records = this.ctx.records;
|
|
104346
|
+
if (records === void 0) throw new Error("records are not available");
|
|
104347
|
+
return records.kind(alexaSkillsKind);
|
|
104348
|
+
}
|
|
104349
|
+
linksHandle() {
|
|
104350
|
+
const records = this.ctx.records;
|
|
104351
|
+
if (records === void 0) throw new Error("records are not available");
|
|
104352
|
+
return records.kind(alexaSkillLinksKind);
|
|
104353
|
+
}
|
|
104354
|
+
/** Re-read both records. A failed read changes nothing: the addon keeps what it has. */
|
|
104355
|
+
async refreshRecords() {
|
|
104356
|
+
try {
|
|
104357
|
+
this.skillRow = (await this.skillHandle().getResolved("export-alexa"))?.data ?? null;
|
|
104358
|
+
} catch (err) {
|
|
104359
|
+
this.ctx.logger.warn("export-alexa: the skill record could not be read", {
|
|
104360
|
+
meta: { error: errMsg$1(err) },
|
|
104361
|
+
tags: {
|
|
104362
|
+
topic: "export-alexa",
|
|
104363
|
+
phase: "records-read-failed"
|
|
104364
|
+
}
|
|
104365
|
+
});
|
|
104366
|
+
}
|
|
104367
|
+
try {
|
|
104368
|
+
this.linksRow = (await this.linksHandle().getResolved("export-alexa"))?.data ?? null;
|
|
104369
|
+
this.linksLocked = false;
|
|
104370
|
+
} catch (err) {
|
|
104371
|
+
if (!(err instanceof RecordSecretUnavailableError)) {
|
|
104372
|
+
this.ctx.logger.warn("export-alexa: the link record could not be read", {
|
|
104373
|
+
meta: { error: errMsg$1(err) },
|
|
104374
|
+
tags: {
|
|
104375
|
+
topic: "export-alexa",
|
|
104376
|
+
phase: "records-read-failed"
|
|
104377
|
+
}
|
|
104378
|
+
});
|
|
104379
|
+
return;
|
|
104380
|
+
}
|
|
104381
|
+
this.linksLocked = true;
|
|
104382
|
+
this.ctx.logger.warn("export-alexa: the keychain is locked; the link ledger is read-only", { tags: {
|
|
104383
|
+
topic: "export-alexa",
|
|
104384
|
+
phase: "keychain-locked"
|
|
104385
|
+
} });
|
|
104386
|
+
}
|
|
104387
|
+
}
|
|
104388
|
+
/**
|
|
104389
|
+
* Write the account-link ledgers: to the `skill-links` record once it exists, to the legacy
|
|
104390
|
+
* settings keys until then (the migration moves them).
|
|
104391
|
+
*/
|
|
104392
|
+
async writeLedger(patch) {
|
|
104393
|
+
if (this.linksRow === null) {
|
|
104394
|
+
await this.updateGlobalSettings({
|
|
104395
|
+
...patch.linkedAccounts === void 0 ? {} : { linkedAccounts: patch.linkedAccounts },
|
|
104396
|
+
...patch.tokens === void 0 ? {} : { tokens: patch.tokens }
|
|
104397
|
+
});
|
|
104398
|
+
return;
|
|
104399
|
+
}
|
|
104400
|
+
if (this.linksLocked) throw new Error("the keychain is locked: the Amazon link ledger cannot be changed right now");
|
|
104401
|
+
const next = {
|
|
104402
|
+
name: this.linksRow.name,
|
|
104403
|
+
linkedAccounts: patch.linkedAccounts ?? this.linksRow.linkedAccounts,
|
|
104404
|
+
tokens: patch.tokens ?? this.linksRow.tokens
|
|
104405
|
+
};
|
|
104406
|
+
await this.linksHandle().put({
|
|
104407
|
+
id: ALEXA_INSTANCE_ID,
|
|
104408
|
+
data: next
|
|
102656
104409
|
});
|
|
104410
|
+
this.linksRow = next;
|
|
104411
|
+
}
|
|
104412
|
+
/** The ports of the settings migrations: the old settings in, the records out. */
|
|
104413
|
+
migrationPorts() {
|
|
104414
|
+
const skills = this.skillHandle();
|
|
104415
|
+
const links = this.linksHandle();
|
|
104416
|
+
const putOnce = async (handle, body) => {
|
|
104417
|
+
if (await handle.get("export-alexa") !== null) return "exists";
|
|
104418
|
+
try {
|
|
104419
|
+
await handle.put({
|
|
104420
|
+
id: ALEXA_INSTANCE_ID,
|
|
104421
|
+
data: body
|
|
104422
|
+
}, { ifRev: 0 });
|
|
104423
|
+
} catch (err) {
|
|
104424
|
+
if (err instanceof RevConflictError) return "exists";
|
|
104425
|
+
throw err;
|
|
104426
|
+
}
|
|
104427
|
+
return "created";
|
|
104428
|
+
};
|
|
104429
|
+
return {
|
|
104430
|
+
readStored: async () => {
|
|
104431
|
+
const stored = await this.resolveGlobalStore();
|
|
104432
|
+
const tokens = stored["tokens"];
|
|
104433
|
+
if (Array.isArray(tokens) && tokens.some(hasUnresolvedCredential)) throw new Error("the old Amazon push grants could not be resolved");
|
|
104434
|
+
return stored;
|
|
104435
|
+
},
|
|
104436
|
+
readRawStored: async () => await this.ctx.settings?.readAddonStore() ?? {},
|
|
104437
|
+
warn: (message) => {
|
|
104438
|
+
this.ctx.logger.warn(message, { tags: {
|
|
104439
|
+
topic: "export-alexa",
|
|
104440
|
+
phase: "migration"
|
|
104441
|
+
} });
|
|
104442
|
+
},
|
|
104443
|
+
putSkill: (body) => putOnce(skills, body),
|
|
104444
|
+
putLinks: (body) => putOnce(links, body),
|
|
104445
|
+
readLinks: async () => (await links.getResolved("export-alexa"))?.data ?? null,
|
|
104446
|
+
hasSkill: async () => await skills.get(ALEXA_INSTANCE_ID) !== null,
|
|
104447
|
+
clearOldTokenSecrets: async () => {
|
|
104448
|
+
await this.clearSecrets(["tokens"]);
|
|
104449
|
+
}
|
|
104450
|
+
};
|
|
104451
|
+
}
|
|
104452
|
+
/** The instance form: how the skill reaches this hub and what each camera carries. */
|
|
104453
|
+
skillForm() {
|
|
104454
|
+
return { sections: buildAlexaInstanceSections({ defaults: ALEXA_SKILL_DEFAULT_BODY }) };
|
|
102657
104455
|
}
|
|
102658
104456
|
/** The settings page: see `settings-schema.ts` for its layout. The account-
|
|
102659
104457
|
* linking rows live in the `device-export` setup block instead. */
|
|
102660
104458
|
globalSettingsSchema() {
|
|
102661
104459
|
return { sections: buildAlexaSettingsSections({
|
|
102662
|
-
linkedAccounts: this.
|
|
102663
|
-
tokens: this.
|
|
104460
|
+
linkedAccounts: this.view.linkedAccounts,
|
|
104461
|
+
tokens: this.view.tokens,
|
|
102664
104462
|
now: Date.now(),
|
|
102665
|
-
|
|
104463
|
+
skillMode: this.view.skillMode
|
|
102666
104464
|
}) };
|
|
102667
104465
|
}
|
|
102668
104466
|
/**
|
|
@@ -102703,7 +104501,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102703
104501
|
const settings = entry?.settings ?? DEFAULT_DEVICE_SETTINGS;
|
|
102704
104502
|
const enabled = entry !== null;
|
|
102705
104503
|
const enabledKey = `alexa:${deviceId}:enabled`;
|
|
102706
|
-
const linkedCount = this.
|
|
104504
|
+
const linkedCount = this.view.linkedAccounts.length;
|
|
102707
104505
|
const statusLabel = enabled ? `Exposed${linkedCount > 0 ? `, ${linkedCount} linked Alexa account(s)` : " (no linked Alexa account yet)"}` : linkedCount > 0 ? `${linkedCount} linked Alexa account(s) — device not exposed` : "Not exposed";
|
|
102708
104506
|
return {
|
|
102709
104507
|
tabs: [{
|
|
@@ -102770,12 +104568,12 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
102770
104568
|
available: this.detectionClassSource === null ? [] : await this.detectionClassSource.classesFor(deviceId).catch(() => []),
|
|
102771
104569
|
saved: parseSensorSelection(store),
|
|
102772
104570
|
enabledKey,
|
|
102773
|
-
masterOn: this.
|
|
104571
|
+
masterOn: this.view.detectionSensors
|
|
102774
104572
|
}), objectDetectionField({
|
|
102775
104573
|
deviceId,
|
|
102776
104574
|
store,
|
|
102777
104575
|
enabledKey,
|
|
102778
|
-
integrationOn: this.
|
|
104576
|
+
integrationOn: this.view.objectDetection
|
|
102779
104577
|
})];
|
|
102780
104578
|
}
|
|
102781
104579
|
/**
|