@camstack/addon-import-alexa 0.2.126 → 0.2.128
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/dist/addon.js +1747 -136
- package/dist/addon.mjs +1747 -136
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
38
38
|
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
39
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
40
40
|
//#endregion
|
|
41
|
-
//#region ../types/dist/event-category-
|
|
41
|
+
//#region ../types/dist/event-category-BvOFi6PY.mjs
|
|
42
42
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
43
43
|
EventCategory["SystemBoot"] = "system.boot";
|
|
44
44
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -102,6 +102,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
102
102
|
* consumes this category and maps it to the `addon-crash-loop` kind.
|
|
103
103
|
*/
|
|
104
104
|
EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
|
|
105
|
+
/**
|
|
106
|
+
* A runner whose addon refused to start with a typed reason (D877) - parked
|
|
107
|
+
* in `refused`, never counted by the crash breaker, retried on operator
|
|
108
|
+
* action. One event per refusal.
|
|
109
|
+
*/
|
|
110
|
+
EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
|
|
111
|
+
/**
|
|
112
|
+
* A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
|
|
113
|
+
* `refused`. In-process telemetry for the boot check (re-evaluate while any
|
|
114
|
+
* runner is still pending) and the alert centre (close a recovered runner).
|
|
115
|
+
*/
|
|
116
|
+
EventCategory["ProcessStateChanged"] = "process.state-changed";
|
|
117
|
+
/**
|
|
118
|
+
* The node's one-shot runner boot check (D877): planned runners against the
|
|
119
|
+
* process service, `degraded` when any is failed, refused or missing. The
|
|
120
|
+
* alert centre turns it into one alert and a direct critical push.
|
|
121
|
+
*/
|
|
122
|
+
EventCategory["SystemRunnerCheck"] = "system.runner-check";
|
|
105
123
|
EventCategory["AddonError"] = "addon.error";
|
|
106
124
|
EventCategory["AddonPageReady"] = "addon.page-ready";
|
|
107
125
|
EventCategory["AddonWidgetReady"] = "addon.widget-ready";
|
|
@@ -4144,6 +4162,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4144
4162
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4145
4163
|
json.type = "boolean";
|
|
4146
4164
|
};
|
|
4165
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4166
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4167
|
+
};
|
|
4168
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4169
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4170
|
+
};
|
|
4147
4171
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4148
4172
|
if (ctx.target === "openapi-3.0") {
|
|
4149
4173
|
json.type = "string";
|
|
@@ -4151,12 +4175,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4151
4175
|
json.enum = [null];
|
|
4152
4176
|
} else json.type = "null";
|
|
4153
4177
|
};
|
|
4178
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4179
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4180
|
+
};
|
|
4154
4181
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4155
4182
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4156
4183
|
};
|
|
4157
4184
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4158
4185
|
json.not = {};
|
|
4159
4186
|
};
|
|
4187
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4188
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4160
4189
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4161
4190
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4162
4191
|
};
|
|
@@ -4188,12 +4217,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4188
4217
|
json.enum = vals;
|
|
4189
4218
|
}
|
|
4190
4219
|
};
|
|
4220
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4221
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4222
|
+
};
|
|
4223
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4224
|
+
const _json = json;
|
|
4225
|
+
const pattern = schema._zod.pattern;
|
|
4226
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4227
|
+
_json.type = "string";
|
|
4228
|
+
_json.pattern = pattern.source;
|
|
4229
|
+
};
|
|
4230
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4231
|
+
const _json = json;
|
|
4232
|
+
const file = {
|
|
4233
|
+
type: "string",
|
|
4234
|
+
format: "binary",
|
|
4235
|
+
contentEncoding: "binary"
|
|
4236
|
+
};
|
|
4237
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4238
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4239
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4240
|
+
if (mime) if (mime.length === 1) {
|
|
4241
|
+
file.contentMediaType = mime[0];
|
|
4242
|
+
Object.assign(_json, file);
|
|
4243
|
+
} else {
|
|
4244
|
+
Object.assign(_json, file);
|
|
4245
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4246
|
+
}
|
|
4247
|
+
else Object.assign(_json, file);
|
|
4248
|
+
};
|
|
4249
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4250
|
+
json.type = "boolean";
|
|
4251
|
+
};
|
|
4191
4252
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4192
4253
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4193
4254
|
};
|
|
4255
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4256
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4257
|
+
};
|
|
4194
4258
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4195
4259
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4196
4260
|
};
|
|
4261
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4262
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4263
|
+
};
|
|
4264
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4265
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4266
|
+
};
|
|
4197
4267
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4198
4268
|
const json = _json;
|
|
4199
4269
|
const def = schema._zod.def;
|
|
@@ -4398,6 +4468,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4398
4468
|
seen.ref = def.innerType;
|
|
4399
4469
|
json.readOnly = true;
|
|
4400
4470
|
};
|
|
4471
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4472
|
+
const def = schema._zod.def;
|
|
4473
|
+
process$1(def.innerType, ctx, params);
|
|
4474
|
+
const seen = ctx.seen.get(schema);
|
|
4475
|
+
seen.ref = def.innerType;
|
|
4476
|
+
};
|
|
4401
4477
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4402
4478
|
const def = schema._zod.def;
|
|
4403
4479
|
process$1(def.innerType, ctx, params);
|
|
@@ -4410,6 +4486,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4410
4486
|
const seen = ctx.seen.get(schema);
|
|
4411
4487
|
seen.ref = innerType;
|
|
4412
4488
|
};
|
|
4489
|
+
var allProcessors = {
|
|
4490
|
+
string: stringProcessor,
|
|
4491
|
+
number: numberProcessor,
|
|
4492
|
+
boolean: booleanProcessor,
|
|
4493
|
+
bigint: bigintProcessor,
|
|
4494
|
+
symbol: symbolProcessor,
|
|
4495
|
+
null: nullProcessor,
|
|
4496
|
+
undefined: undefinedProcessor,
|
|
4497
|
+
void: voidProcessor,
|
|
4498
|
+
never: neverProcessor,
|
|
4499
|
+
any: anyProcessor,
|
|
4500
|
+
unknown: unknownProcessor,
|
|
4501
|
+
date: dateProcessor,
|
|
4502
|
+
enum: enumProcessor,
|
|
4503
|
+
literal: literalProcessor,
|
|
4504
|
+
nan: nanProcessor,
|
|
4505
|
+
template_literal: templateLiteralProcessor,
|
|
4506
|
+
file: fileProcessor,
|
|
4507
|
+
success: successProcessor,
|
|
4508
|
+
custom: customProcessor,
|
|
4509
|
+
function: functionProcessor,
|
|
4510
|
+
transform: transformProcessor,
|
|
4511
|
+
map: mapProcessor,
|
|
4512
|
+
set: setProcessor,
|
|
4513
|
+
array: arrayProcessor,
|
|
4514
|
+
object: objectProcessor,
|
|
4515
|
+
union: unionProcessor,
|
|
4516
|
+
intersection: intersectionProcessor,
|
|
4517
|
+
tuple: tupleProcessor,
|
|
4518
|
+
record: recordProcessor,
|
|
4519
|
+
nullable: nullableProcessor,
|
|
4520
|
+
nonoptional: nonoptionalProcessor,
|
|
4521
|
+
default: defaultProcessor,
|
|
4522
|
+
prefault: prefaultProcessor,
|
|
4523
|
+
catch: catchProcessor,
|
|
4524
|
+
pipe: pipeProcessor,
|
|
4525
|
+
readonly: readonlyProcessor,
|
|
4526
|
+
promise: promiseProcessor,
|
|
4527
|
+
optional: optionalProcessor,
|
|
4528
|
+
lazy: lazyProcessor
|
|
4529
|
+
};
|
|
4530
|
+
function toJSONSchema(input, params) {
|
|
4531
|
+
if ("_idmap" in input) {
|
|
4532
|
+
const registry = input;
|
|
4533
|
+
const ctx = initializeContext({
|
|
4534
|
+
...params,
|
|
4535
|
+
processors: allProcessors
|
|
4536
|
+
});
|
|
4537
|
+
const defs = {};
|
|
4538
|
+
for (const entry of registry._idmap.entries()) {
|
|
4539
|
+
const [_, schema] = entry;
|
|
4540
|
+
process$1(schema, ctx);
|
|
4541
|
+
}
|
|
4542
|
+
const schemas = {};
|
|
4543
|
+
ctx.external = {
|
|
4544
|
+
registry,
|
|
4545
|
+
uri: params?.uri,
|
|
4546
|
+
defs
|
|
4547
|
+
};
|
|
4548
|
+
for (const entry of registry._idmap.entries()) {
|
|
4549
|
+
const [key, schema] = entry;
|
|
4550
|
+
extractDefs(ctx, schema);
|
|
4551
|
+
schemas[key] = finalize(ctx, schema);
|
|
4552
|
+
}
|
|
4553
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4554
|
+
return { schemas };
|
|
4555
|
+
}
|
|
4556
|
+
const ctx = initializeContext({
|
|
4557
|
+
...params,
|
|
4558
|
+
processors: allProcessors
|
|
4559
|
+
});
|
|
4560
|
+
process$1(input, ctx);
|
|
4561
|
+
extractDefs(ctx, input);
|
|
4562
|
+
return finalize(ctx, input);
|
|
4563
|
+
}
|
|
4413
4564
|
//#endregion
|
|
4414
4565
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4415
4566
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5426,7 +5577,7 @@ var ZodIssueCode = {
|
|
|
5426
5577
|
var ZodFirstPartyTypeKind;
|
|
5427
5578
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5428
5579
|
//#endregion
|
|
5429
|
-
//#region ../types/dist/sleep-
|
|
5580
|
+
//#region ../types/dist/sleep-BOjuyoPC.mjs
|
|
5430
5581
|
/**
|
|
5431
5582
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5432
5583
|
* window to float samples (D455).
|
|
@@ -5543,7 +5694,7 @@ function isKeychainStoredField(field) {
|
|
|
5543
5694
|
var SECRET_CLEAR = { $secretClear: true };
|
|
5544
5695
|
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5545
5696
|
var LEGACY_DEVICE_REDACTION = "***";
|
|
5546
|
-
function isRecord$
|
|
5697
|
+
function isRecord$5(value) {
|
|
5547
5698
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5548
5699
|
}
|
|
5549
5700
|
function makeSecretMarker(ref) {
|
|
@@ -5554,12 +5705,12 @@ function makeSecretMarker(ref) {
|
|
|
5554
5705
|
}
|
|
5555
5706
|
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5556
5707
|
function isSecretMarker(value) {
|
|
5557
|
-
if (!isRecord$
|
|
5708
|
+
if (!isRecord$5(value)) return false;
|
|
5558
5709
|
const ref = value["$secret"];
|
|
5559
5710
|
return typeof ref === "string" && ref.length > 0;
|
|
5560
5711
|
}
|
|
5561
5712
|
function isSecretClear(value) {
|
|
5562
|
-
return isRecord$
|
|
5713
|
+
return isRecord$5(value) && value["$secretClear"] === true;
|
|
5563
5714
|
}
|
|
5564
5715
|
/**
|
|
5565
5716
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
@@ -6169,7 +6320,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6169
6320
|
}
|
|
6170
6321
|
};
|
|
6171
6322
|
var KEEP = { kind: "keep" };
|
|
6172
|
-
function isRecord$
|
|
6323
|
+
function isRecord$4(value) {
|
|
6173
6324
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6174
6325
|
}
|
|
6175
6326
|
function defaultMintId() {
|
|
@@ -6182,7 +6333,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6182
6333
|
return out;
|
|
6183
6334
|
}
|
|
6184
6335
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6185
|
-
else if (isRecord$
|
|
6336
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6186
6337
|
return out;
|
|
6187
6338
|
}
|
|
6188
6339
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -6237,7 +6388,7 @@ function rowId(row, idKey) {
|
|
|
6237
6388
|
return null;
|
|
6238
6389
|
}
|
|
6239
6390
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6240
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
6391
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
6241
6392
|
if (!Array.isArray(incoming)) {
|
|
6242
6393
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6243
6394
|
return {
|
|
@@ -6253,7 +6404,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6253
6404
|
const kept = /* @__PURE__ */ new Set();
|
|
6254
6405
|
const rows = [];
|
|
6255
6406
|
for (const row of incoming) {
|
|
6256
|
-
if (!isRecord$
|
|
6407
|
+
if (!isRecord$4(row)) {
|
|
6257
6408
|
rows.push(row);
|
|
6258
6409
|
continue;
|
|
6259
6410
|
}
|
|
@@ -6278,7 +6429,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6278
6429
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6279
6430
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6280
6431
|
case "object": {
|
|
6281
|
-
if (!isRecord$
|
|
6432
|
+
if (!isRecord$4(incoming)) {
|
|
6282
6433
|
if (incoming === void 0) return KEEP;
|
|
6283
6434
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6284
6435
|
return {
|
|
@@ -6286,7 +6437,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6286
6437
|
value: incoming
|
|
6287
6438
|
};
|
|
6288
6439
|
}
|
|
6289
|
-
const storedObj = isRecord$
|
|
6440
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
6290
6441
|
return {
|
|
6291
6442
|
kind: "value",
|
|
6292
6443
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -6409,7 +6560,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
6409
6560
|
value: items
|
|
6410
6561
|
};
|
|
6411
6562
|
}
|
|
6412
|
-
if (isRecord$
|
|
6563
|
+
if (isRecord$4(v)) {
|
|
6413
6564
|
const out = {};
|
|
6414
6565
|
for (const [k, child] of Object.entries(v)) {
|
|
6415
6566
|
const s = substitute(child);
|
|
@@ -6677,7 +6828,6 @@ function createHandle(raw, opts) {
|
|
|
6677
6828
|
const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
|
|
6678
6829
|
const readAddonStoreResult = raw.readAddonStoreResult;
|
|
6679
6830
|
const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
|
|
6680
|
-
const readDeviceStoreBatch = raw.readDeviceStoreBatch;
|
|
6681
6831
|
const overrides = {
|
|
6682
6832
|
readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
|
|
6683
6833
|
...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
|
|
@@ -6701,12 +6851,12 @@ function createHandle(raw, opts) {
|
|
|
6701
6851
|
};
|
|
6702
6852
|
} } : {},
|
|
6703
6853
|
readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
|
|
6704
|
-
|
|
6705
|
-
const rows = await readDeviceStoreBatch
|
|
6854
|
+
readDeviceStoreBatch: async (deviceIds) => {
|
|
6855
|
+
const rows = await raw.readDeviceStoreBatch(deviceIds);
|
|
6706
6856
|
const out = /* @__PURE__ */ new Map();
|
|
6707
6857
|
for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
|
|
6708
6858
|
return out;
|
|
6709
|
-
}
|
|
6859
|
+
},
|
|
6710
6860
|
writeAddonStore: async (patch) => {
|
|
6711
6861
|
await writeAddon(patch);
|
|
6712
6862
|
},
|
|
@@ -7333,7 +7483,7 @@ var BaseAddon = class {
|
|
|
7333
7483
|
if (!ctx) return;
|
|
7334
7484
|
const addonId = ctx.id;
|
|
7335
7485
|
setImmediate(() => {
|
|
7336
|
-
ctx.api.addons
|
|
7486
|
+
ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
|
|
7337
7487
|
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7338
7488
|
}).catch((err) => {
|
|
7339
7489
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -7533,7 +7683,7 @@ var BaseAddon = class {
|
|
|
7533
7683
|
return this._addonSecretTree;
|
|
7534
7684
|
}
|
|
7535
7685
|
deviceSecretTree() {
|
|
7536
|
-
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7686
|
+
this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
|
|
7537
7687
|
return this._deviceSecretTree;
|
|
7538
7688
|
}
|
|
7539
7689
|
/**
|
|
@@ -7609,42 +7759,135 @@ var BaseAddon = class {
|
|
|
7609
7759
|
this[timerOf] = timer;
|
|
7610
7760
|
}
|
|
7611
7761
|
/**
|
|
7612
|
-
* Wrap `ctx.settings.readAddonStore()` with a
|
|
7613
|
-
*
|
|
7614
|
-
* swap, or any race where the SqliteSettingsBackend is between shutdown and
|
|
7615
|
-
* re-initialize) doesn't propagate up into `initialize()` and leave the
|
|
7762
|
+
* Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
|
|
7763
|
+
* settings-store outage doesn't propagate up into `initialize()` and leave the
|
|
7616
7764
|
* addon permanently broken.
|
|
7617
7765
|
*
|
|
7618
|
-
*
|
|
7619
|
-
*
|
|
7620
|
-
* `
|
|
7766
|
+
* Two kinds of outage, two budgets:
|
|
7767
|
+
* - the store's own restart fingerprints (`SqliteSettingsBackend not
|
|
7768
|
+
* initialized`, `provider not available`): a short budget, then the addon
|
|
7769
|
+
* falls back to `{}` (defaults) - its first successful patch rehydrates;
|
|
7770
|
+
* - a TRANSPORT failure (the hub is restarting while this runner boots:
|
|
7771
|
+
* `discovery deadline exceeded`, `parent could not route`, a refused or
|
|
7772
|
+
* timed-out connection). Since D870 a runner's settings read THROWS instead
|
|
7773
|
+
* of answering `{}`, so without a budget a hub restart ends in a respawn
|
|
7774
|
+
* loop. A long, bounded budget; only after it the error propagates - the
|
|
7775
|
+
* addon never runs on defaults for a store it could not ask.
|
|
7776
|
+
* Anything else propagates immediately so real bugs surface.
|
|
7621
7777
|
*/
|
|
7622
7778
|
async readAddonStoreWithRetry() {
|
|
7623
7779
|
const settings = this.rawSettings();
|
|
7624
7780
|
if (!settings) return {};
|
|
7625
|
-
const delaysMs = [
|
|
7626
|
-
150,
|
|
7627
|
-
350,
|
|
7628
|
-
600,
|
|
7629
|
-
900
|
|
7630
|
-
];
|
|
7631
7781
|
let lastErr;
|
|
7632
|
-
for (let attempt = 0
|
|
7782
|
+
for (let attempt = 0;; attempt++) try {
|
|
7633
7783
|
const stored = await settings.readAddonStore() ?? {};
|
|
7634
7784
|
this.settingsStoreReady = true;
|
|
7635
7785
|
return stored;
|
|
7636
7786
|
} catch (err) {
|
|
7637
7787
|
lastErr = err;
|
|
7638
|
-
const
|
|
7639
|
-
if (
|
|
7640
|
-
|
|
7641
|
-
|
|
7788
|
+
const kind = classifyStoreError(err);
|
|
7789
|
+
if (kind === "permanent") throw err;
|
|
7790
|
+
const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
|
|
7791
|
+
if (delay === void 0) {
|
|
7792
|
+
if (kind === "transport") throw err;
|
|
7793
|
+
break;
|
|
7794
|
+
}
|
|
7795
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
7642
7796
|
}
|
|
7643
7797
|
this.settingsStoreReady = false;
|
|
7644
7798
|
this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
|
|
7645
7799
|
return {};
|
|
7646
7800
|
}
|
|
7647
7801
|
};
|
|
7802
|
+
/** The settings store's own restart fingerprints. */
|
|
7803
|
+
var RESTART_RETRY_DELAYS_MS = [
|
|
7804
|
+
150,
|
|
7805
|
+
350,
|
|
7806
|
+
600,
|
|
7807
|
+
900
|
|
7808
|
+
];
|
|
7809
|
+
/** A hub restarting under a booting runner: ~100 s in total. */
|
|
7810
|
+
var TRANSPORT_RETRY_DELAYS_MS = [
|
|
7811
|
+
150,
|
|
7812
|
+
350,
|
|
7813
|
+
600,
|
|
7814
|
+
900,
|
|
7815
|
+
2e3,
|
|
7816
|
+
5e3,
|
|
7817
|
+
1e4,
|
|
7818
|
+
2e4,
|
|
7819
|
+
3e4,
|
|
7820
|
+
3e4
|
|
7821
|
+
];
|
|
7822
|
+
var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
|
|
7823
|
+
/** Node / socket error codes of a connection that did not happen or broke. */
|
|
7824
|
+
var TRANSPORT_CODES = new Set([
|
|
7825
|
+
"ECONNREFUSED",
|
|
7826
|
+
"ECONNRESET",
|
|
7827
|
+
"ETIMEDOUT",
|
|
7828
|
+
"EPIPE",
|
|
7829
|
+
"EHOSTUNREACH",
|
|
7830
|
+
"ENETUNREACH"
|
|
7831
|
+
]);
|
|
7832
|
+
/** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
|
|
7833
|
+
var UNAVAILABLE_TRPC_CODES = new Set([
|
|
7834
|
+
"TIMEOUT",
|
|
7835
|
+
"SERVICE_UNAVAILABLE",
|
|
7836
|
+
"BAD_GATEWAY",
|
|
7837
|
+
"GATEWAY_TIMEOUT"
|
|
7838
|
+
]);
|
|
7839
|
+
/** The exact phrases OUR transport raises when it cannot reach the hub. */
|
|
7840
|
+
var TRANSPORT_PHRASES = [
|
|
7841
|
+
"discovery deadline exceeded",
|
|
7842
|
+
"parent could not route child unowned cap call",
|
|
7843
|
+
"UDS request timed out after",
|
|
7844
|
+
"channel closed"
|
|
7845
|
+
];
|
|
7846
|
+
/** Moleculer error `type`s of a call that could not be served right now. */
|
|
7847
|
+
var MOLECULER_TRANSIENT_TYPES = new Set([
|
|
7848
|
+
"REQUEST_TIMEOUT",
|
|
7849
|
+
"SERVICE_NOT_FOUND",
|
|
7850
|
+
"SERVICE_NOT_AVAILABLE",
|
|
7851
|
+
"REQUEST_REJECTED",
|
|
7852
|
+
"BROKER_DISCONNECTED"
|
|
7853
|
+
]);
|
|
7854
|
+
function stringProp(value, key) {
|
|
7855
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
7856
|
+
const found = Reflect.get(value, key);
|
|
7857
|
+
return typeof found === "string" ? found : void 0;
|
|
7858
|
+
}
|
|
7859
|
+
/** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
|
|
7860
|
+
function errorCode(err) {
|
|
7861
|
+
const out = {};
|
|
7862
|
+
const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
|
|
7863
|
+
const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
|
|
7864
|
+
const node = stringProp(err, "code") ?? stringProp(cause, "code");
|
|
7865
|
+
if (node !== void 0) out.node = node;
|
|
7866
|
+
const trpc = stringProp(data, "code");
|
|
7867
|
+
if (trpc !== void 0) out.trpc = trpc;
|
|
7868
|
+
return out;
|
|
7869
|
+
}
|
|
7870
|
+
/**
|
|
7871
|
+
* Is a settings read failure worth retrying, and with which budget? Only
|
|
7872
|
+
* EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
|
|
7873
|
+
* one of the exact phrases our own transport raises. A message that merely
|
|
7874
|
+
* contains "timed out" or "unreachable" is not evidence of anything, and
|
|
7875
|
+
* `settings store not wired` is a wiring bug that retrying cannot fix.
|
|
7876
|
+
*/
|
|
7877
|
+
function classifyStoreError(err) {
|
|
7878
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7879
|
+
if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
|
|
7880
|
+
const code = errorCode(err);
|
|
7881
|
+
if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
|
|
7882
|
+
if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
|
|
7883
|
+
if (typeof err === "object" && err !== null) {
|
|
7884
|
+
if (Reflect.get(err, "retryable") === true) return "transport";
|
|
7885
|
+
const type = stringProp(err, "type");
|
|
7886
|
+
if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
|
|
7887
|
+
}
|
|
7888
|
+
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
7889
|
+
return "permanent";
|
|
7890
|
+
}
|
|
7648
7891
|
/**
|
|
7649
7892
|
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
7650
7893
|
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
@@ -7734,6 +7977,356 @@ var PeerBytesTicketSchema = object({
|
|
|
7734
7977
|
*/
|
|
7735
7978
|
declaredBytes: number().int().nonnegative().nullable()
|
|
7736
7979
|
});
|
|
7980
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7981
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7982
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7983
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7984
|
+
var RECORD_CLASSES = [
|
|
7985
|
+
"config",
|
|
7986
|
+
"ledger",
|
|
7987
|
+
"audit",
|
|
7988
|
+
"mirror",
|
|
7989
|
+
"ephemeral"
|
|
7990
|
+
];
|
|
7991
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
7992
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
7993
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
7994
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
7995
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
7996
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7997
|
+
var PREFIX = "records/";
|
|
7998
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
7999
|
+
var RecordsError = class extends Error {
|
|
8000
|
+
code;
|
|
8001
|
+
detail;
|
|
8002
|
+
constructor(code, detail) {
|
|
8003
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
8004
|
+
this.name = "RecordsError";
|
|
8005
|
+
this.code = code;
|
|
8006
|
+
this.detail = detail;
|
|
8007
|
+
}
|
|
8008
|
+
};
|
|
8009
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8010
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8011
|
+
constructor(detail) {
|
|
8012
|
+
super("secret-unavailable", detail);
|
|
8013
|
+
this.name = "RecordSecretUnavailableError";
|
|
8014
|
+
}
|
|
8015
|
+
};
|
|
8016
|
+
var InvalidRecordError = class extends RecordsError {
|
|
8017
|
+
constructor(detail) {
|
|
8018
|
+
super("invalid-record", detail);
|
|
8019
|
+
this.name = "InvalidRecordError";
|
|
8020
|
+
}
|
|
8021
|
+
};
|
|
8022
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8023
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
8024
|
+
constructor(detail) {
|
|
8025
|
+
super("declaration-refused", detail);
|
|
8026
|
+
this.name = "DeclarationRefusedError";
|
|
8027
|
+
}
|
|
8028
|
+
};
|
|
8029
|
+
function defOf(schema) {
|
|
8030
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8031
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8032
|
+
const def = Reflect.get(zodBag, "def");
|
|
8033
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8034
|
+
return def;
|
|
8035
|
+
}
|
|
8036
|
+
function declaredHere(schema) {
|
|
8037
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8038
|
+
}
|
|
8039
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8040
|
+
var WRAPPERS = new Set([
|
|
8041
|
+
"optional",
|
|
8042
|
+
"nullable",
|
|
8043
|
+
"default",
|
|
8044
|
+
"prefault",
|
|
8045
|
+
"catch",
|
|
8046
|
+
"readonly",
|
|
8047
|
+
"nonoptional"
|
|
8048
|
+
]);
|
|
8049
|
+
/**
|
|
8050
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8051
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8052
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8053
|
+
* `.transform` on `in`).
|
|
8054
|
+
*/
|
|
8055
|
+
function layersOf(schema) {
|
|
8056
|
+
const out = [];
|
|
8057
|
+
const queue = [schema];
|
|
8058
|
+
while (queue.length > 0) {
|
|
8059
|
+
const s = queue.shift();
|
|
8060
|
+
if (!s || out.includes(s)) continue;
|
|
8061
|
+
out.push(s);
|
|
8062
|
+
const def = defOf(s);
|
|
8063
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8064
|
+
if (def.type === "pipe") {
|
|
8065
|
+
if (def.in) queue.push(def.in);
|
|
8066
|
+
if (def.out) queue.push(def.out);
|
|
8067
|
+
}
|
|
8068
|
+
}
|
|
8069
|
+
return out;
|
|
8070
|
+
}
|
|
8071
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8072
|
+
function isZodSecret(schema) {
|
|
8073
|
+
return layersOf(schema).some(declaredHere);
|
|
8074
|
+
}
|
|
8075
|
+
/**
|
|
8076
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8077
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8078
|
+
* object or array is reported as one path and not descended into — everything
|
|
8079
|
+
* under it is secret.
|
|
8080
|
+
*/
|
|
8081
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8082
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8083
|
+
const paths = [];
|
|
8084
|
+
for (const layer of layersOf(schema)) {
|
|
8085
|
+
const def = defOf(layer);
|
|
8086
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8087
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8088
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8089
|
+
else if (def.type === "intersection") {
|
|
8090
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8091
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8092
|
+
}
|
|
8093
|
+
}
|
|
8094
|
+
return [...new Set(paths)];
|
|
8095
|
+
}
|
|
8096
|
+
/**
|
|
8097
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8098
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8099
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8100
|
+
*
|
|
8101
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8102
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8103
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8104
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8105
|
+
*
|
|
8106
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8107
|
+
*/
|
|
8108
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8109
|
+
function parseSecretPath(path) {
|
|
8110
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8111
|
+
return path.split(".").map((raw) => {
|
|
8112
|
+
const each = raw.endsWith("[]");
|
|
8113
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8114
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8115
|
+
return {
|
|
8116
|
+
key,
|
|
8117
|
+
each
|
|
8118
|
+
};
|
|
8119
|
+
});
|
|
8120
|
+
}
|
|
8121
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8122
|
+
function secretArrayPrefixes(path) {
|
|
8123
|
+
const segments = parseSecretPath(path);
|
|
8124
|
+
const prefixes = [];
|
|
8125
|
+
const walked = [];
|
|
8126
|
+
for (const segment of segments) {
|
|
8127
|
+
walked.push(segment.key);
|
|
8128
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8129
|
+
}
|
|
8130
|
+
return prefixes;
|
|
8131
|
+
}
|
|
8132
|
+
/**
|
|
8133
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8134
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8135
|
+
* JSON the engine stores.
|
|
8136
|
+
*
|
|
8137
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
8138
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
8139
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
8140
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
8141
|
+
* never a field name (D879).
|
|
8142
|
+
*/
|
|
8143
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
8144
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
8145
|
+
var RecordIndexSchema = object({
|
|
8146
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
8147
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
8148
|
+
unique: boolean().optional()
|
|
8149
|
+
}).strict();
|
|
8150
|
+
var RecordRetentionSchema = union([
|
|
8151
|
+
object({
|
|
8152
|
+
ttlMs: number().int().positive(),
|
|
8153
|
+
from: _enum(["at", "write"])
|
|
8154
|
+
}).strict(),
|
|
8155
|
+
object({
|
|
8156
|
+
maxRows: number().int().positive().optional(),
|
|
8157
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
8158
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
8159
|
+
object({
|
|
8160
|
+
owner: string().min(1),
|
|
8161
|
+
reason: string().min(1)
|
|
8162
|
+
}).strict(),
|
|
8163
|
+
object({ none: string().min(1) }).strict()
|
|
8164
|
+
]);
|
|
8165
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
8166
|
+
var EntryDescriptorSchema = object({
|
|
8167
|
+
title: string().min(1),
|
|
8168
|
+
/** The record body field shown as the entry's name. */
|
|
8169
|
+
nameField: string().min(1),
|
|
8170
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
8171
|
+
fields: record(string(), unknown())
|
|
8172
|
+
}).strict();
|
|
8173
|
+
/** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
|
|
8174
|
+
var RecordKindDeclarationSchema = object({
|
|
8175
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
8176
|
+
class: _enum(RECORD_CLASSES),
|
|
8177
|
+
writeTrigger: string().min(1),
|
|
8178
|
+
device: _enum([
|
|
8179
|
+
"required",
|
|
8180
|
+
"optional",
|
|
8181
|
+
"none"
|
|
8182
|
+
]).default("none"),
|
|
8183
|
+
at: _enum(["required", "none"]).default("none"),
|
|
8184
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
8185
|
+
retention: RecordRetentionSchema,
|
|
8186
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
8187
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
8188
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
8189
|
+
secretPaths: array(string().min(1)).default([]),
|
|
8190
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
8191
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
8192
|
+
/** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
|
|
8193
|
+
adoptsFrom: string().min(1).optional(),
|
|
8194
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
8195
|
+
transactFamily: string().min(1).optional(),
|
|
8196
|
+
entry: EntryDescriptorSchema.optional()
|
|
8197
|
+
}).strict();
|
|
8198
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8199
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
8200
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
8201
|
+
function assertValidDeclaration(name, decl) {
|
|
8202
|
+
const refuse = (why) => {
|
|
8203
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
8204
|
+
};
|
|
8205
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
8206
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8207
|
+
for (const index of decl.indexes) {
|
|
8208
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
8209
|
+
seen.add(index.name);
|
|
8210
|
+
}
|
|
8211
|
+
const { retention } = decl;
|
|
8212
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
8213
|
+
if ("ttlMs" in retention) {
|
|
8214
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
8215
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
8216
|
+
}
|
|
8217
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
8218
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
8219
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
8220
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
8221
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
8222
|
+
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)`);
|
|
8223
|
+
}
|
|
8224
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
8225
|
+
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`);
|
|
8226
|
+
}
|
|
8227
|
+
function bodyFieldsOf(schema) {
|
|
8228
|
+
return { ...toJSONSchema(schema, {
|
|
8229
|
+
unrepresentable: "any",
|
|
8230
|
+
io: "input"
|
|
8231
|
+
}) };
|
|
8232
|
+
}
|
|
8233
|
+
function isRecordLike(value) {
|
|
8234
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8235
|
+
}
|
|
8236
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
8237
|
+
function hasNameField(json, field) {
|
|
8238
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
8239
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
8240
|
+
const properties = json["properties"];
|
|
8241
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
8242
|
+
}
|
|
8243
|
+
/**
|
|
8244
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
8245
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
8246
|
+
* types its handle from.
|
|
8247
|
+
*/
|
|
8248
|
+
function defineRecordKinds(specs) {
|
|
8249
|
+
const out = {};
|
|
8250
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
8251
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
8252
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
8253
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
8254
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
8255
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
8256
|
+
database: spec.database,
|
|
8257
|
+
class: spec.class,
|
|
8258
|
+
writeTrigger: spec.writeTrigger,
|
|
8259
|
+
device: spec.device,
|
|
8260
|
+
at: spec.at,
|
|
8261
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
8262
|
+
retention: spec.retention,
|
|
8263
|
+
deviceRemoval: spec.deviceRemoval,
|
|
8264
|
+
maxDataBytes: spec.maxDataBytes,
|
|
8265
|
+
secretPaths: [...secretPaths],
|
|
8266
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
8267
|
+
adoptsFrom: spec.adoptsFrom,
|
|
8268
|
+
transactFamily: spec.transactFamily,
|
|
8269
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
8270
|
+
title: spec.entry.title,
|
|
8271
|
+
nameField,
|
|
8272
|
+
fields
|
|
8273
|
+
}
|
|
8274
|
+
});
|
|
8275
|
+
assertValidDeclaration(name, parsed);
|
|
8276
|
+
out[name] = {
|
|
8277
|
+
name,
|
|
8278
|
+
schema: spec.schema,
|
|
8279
|
+
declaration: parsed
|
|
8280
|
+
};
|
|
8281
|
+
}
|
|
8282
|
+
return out;
|
|
8283
|
+
}
|
|
8284
|
+
/**
|
|
8285
|
+
* Entry kinds (D881): every list of user-created entries (notification
|
|
8286
|
+
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
8287
|
+
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
8288
|
+
* through the `record-entries` capability with password fields derived from
|
|
8289
|
+
* the schema (`.meta({ secret: true })`).
|
|
8290
|
+
*/
|
|
8291
|
+
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
8292
|
+
function entryBody(shape) {
|
|
8293
|
+
return object({
|
|
8294
|
+
name: string().min(1),
|
|
8295
|
+
...shape
|
|
8296
|
+
});
|
|
8297
|
+
}
|
|
8298
|
+
/**
|
|
8299
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
8300
|
+
* engine, never aged, belonging to no device.
|
|
8301
|
+
*/
|
|
8302
|
+
function defineEntryKind(name, spec) {
|
|
8303
|
+
const defined = defineRecordKinds({ [name]: {
|
|
8304
|
+
schema: spec.schema,
|
|
8305
|
+
class: "config",
|
|
8306
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
8307
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
8308
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
8309
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
8310
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
8311
|
+
...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
|
|
8312
|
+
entry: {
|
|
8313
|
+
title: spec.title,
|
|
8314
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
8315
|
+
}
|
|
8316
|
+
} })[name];
|
|
8317
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
8318
|
+
return defined;
|
|
8319
|
+
}
|
|
8320
|
+
/**
|
|
8321
|
+
* Legacy source for broker entry adoption (B2): brokers live in addon-settings
|
|
8322
|
+
* as one row `<addonId>.brokers` whose value is an array until records-adopt
|
|
8323
|
+
* copies them into the entry kind.
|
|
8324
|
+
*/
|
|
8325
|
+
var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
|
|
8326
|
+
/** The `adoptsFrom` value for an addon's broker entry kind. */
|
|
8327
|
+
function settingsBrokersAdoptsFrom(addonId) {
|
|
8328
|
+
return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
|
|
8329
|
+
}
|
|
7737
8330
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
7738
8331
|
var CamProfileSchema = _enum([
|
|
7739
8332
|
"high",
|
|
@@ -8198,75 +8791,12 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
8198
8791
|
kind: "mutation",
|
|
8199
8792
|
auth: "admin"
|
|
8200
8793
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
8201
|
-
function defOf(schema) {
|
|
8202
|
-
return schema._zod?.def ?? {};
|
|
8203
|
-
}
|
|
8204
|
-
function declaredHere(schema) {
|
|
8205
|
-
return globalRegistry.get(schema)?.secret === true;
|
|
8206
|
-
}
|
|
8207
|
-
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8208
|
-
var WRAPPERS = new Set([
|
|
8209
|
-
"optional",
|
|
8210
|
-
"nullable",
|
|
8211
|
-
"default",
|
|
8212
|
-
"prefault",
|
|
8213
|
-
"catch",
|
|
8214
|
-
"readonly",
|
|
8215
|
-
"nonoptional"
|
|
8216
|
-
]);
|
|
8217
|
-
/**
|
|
8218
|
-
* The schema layers that make up ONE field: the schema itself and every
|
|
8219
|
-
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8220
|
-
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8221
|
-
* `.transform` on `in`).
|
|
8222
|
-
*/
|
|
8223
|
-
function layersOf(schema) {
|
|
8224
|
-
const out = [];
|
|
8225
|
-
const queue = [schema];
|
|
8226
|
-
while (queue.length > 0) {
|
|
8227
|
-
const s = queue.shift();
|
|
8228
|
-
if (!s || out.includes(s)) continue;
|
|
8229
|
-
out.push(s);
|
|
8230
|
-
const def = defOf(s);
|
|
8231
|
-
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8232
|
-
if (def.type === "pipe") {
|
|
8233
|
-
if (def.in) queue.push(def.in);
|
|
8234
|
-
if (def.out) queue.push(def.out);
|
|
8235
|
-
}
|
|
8236
|
-
}
|
|
8237
|
-
return out;
|
|
8238
|
-
}
|
|
8239
|
-
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8240
|
-
function isZodSecret(schema) {
|
|
8241
|
-
return layersOf(schema).some(declaredHere);
|
|
8242
|
-
}
|
|
8243
|
-
/**
|
|
8244
|
-
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8245
|
-
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8246
|
-
* object or array is reported as one path and not descended into — everything
|
|
8247
|
-
* under it is secret.
|
|
8248
|
-
*/
|
|
8249
|
-
function collectZodSecretPaths(schema, prefix = "") {
|
|
8250
|
-
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8251
|
-
const paths = [];
|
|
8252
|
-
for (const layer of layersOf(schema)) {
|
|
8253
|
-
const def = defOf(layer);
|
|
8254
|
-
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8255
|
-
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8256
|
-
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8257
|
-
else if (def.type === "intersection") {
|
|
8258
|
-
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8259
|
-
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8260
|
-
}
|
|
8261
|
-
}
|
|
8262
|
-
return [...new Set(paths)];
|
|
8263
|
-
}
|
|
8264
8794
|
object({
|
|
8265
8795
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
8266
8796
|
params: record(string(), union([string(), number()])).optional()
|
|
8267
8797
|
});
|
|
8268
8798
|
//#endregion
|
|
8269
|
-
//#region ../types/dist/err-msg-
|
|
8799
|
+
//#region ../types/dist/err-msg-BXKzRBwg.mjs
|
|
8270
8800
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
8271
8801
|
DeviceType["Camera"] = "camera";
|
|
8272
8802
|
DeviceType["Hub"] = "hub";
|
|
@@ -8358,6 +8888,10 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
8358
8888
|
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
8359
8889
|
* integrations sharing the same food/desiccant/hopper surface. */
|
|
8360
8890
|
DeviceType["PetFeeder"] = "pet-feeder";
|
|
8891
|
+
/** Built-in dishwasher — program lifecycle, door / remote-start gates,
|
|
8892
|
+
* salt and rinse-aid levels. Installed with the `dishwasher` cap.
|
|
8893
|
+
* Sources: native Bosch Home Connect, reusable by similar integrations. */
|
|
8894
|
+
DeviceType["Dishwasher"] = "dishwasher";
|
|
8361
8895
|
return DeviceType;
|
|
8362
8896
|
}({});
|
|
8363
8897
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -8535,6 +9069,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8535
9069
|
/** Virtual HA toggle (input_boolean.*) — distinguishable from a
|
|
8536
9070
|
* real Switch device for UI rendering / export adapters. */
|
|
8537
9071
|
DeviceRole["BinaryHelper"] = "binary-helper";
|
|
9072
|
+
/** A smart plug: a `switch` whose source says it is an outlet (HA
|
|
9073
|
+
* `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
|
|
9074
|
+
DeviceRole["Outlet"] = "outlet";
|
|
8538
9075
|
/** Generic motion / occupancy / moving event source. Distinct from
|
|
8539
9076
|
* the camera accessory PirSensor role: that one is a camera child;
|
|
8540
9077
|
* this is a standalone HA / 3rd-party motion sensor. */
|
|
@@ -8612,7 +9149,7 @@ function errMsg(err) {
|
|
|
8612
9149
|
return String(err);
|
|
8613
9150
|
}
|
|
8614
9151
|
//#endregion
|
|
8615
|
-
//#region ../types/dist/composition-
|
|
9152
|
+
//#region ../types/dist/composition-CB6PMT9p.mjs
|
|
8616
9153
|
/**
|
|
8617
9154
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
8618
9155
|
*
|
|
@@ -11933,11 +12470,10 @@ var ClipModelMetaSchema = object({
|
|
|
11933
12470
|
/**
|
|
11934
12471
|
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
11935
12472
|
* per index: two models share an index only when their vectors are ranked
|
|
11936
|
-
* against each other, which for CLIP means never across families.
|
|
11937
|
-
*
|
|
11938
|
-
* `modelId`); any other model gets its own.
|
|
12473
|
+
* against each other, which for CLIP means never across families. Every
|
|
12474
|
+
* model gets its own.
|
|
11939
12475
|
*/
|
|
11940
|
-
vectorIndex: string().regex(/^object-clip
|
|
12476
|
+
vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
11941
12477
|
/**
|
|
11942
12478
|
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
11943
12479
|
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
@@ -13135,8 +13671,13 @@ var AlertSeveritySchema = _enum([
|
|
|
13135
13671
|
"info",
|
|
13136
13672
|
"success",
|
|
13137
13673
|
"warning",
|
|
13138
|
-
"error"
|
|
13674
|
+
"error",
|
|
13675
|
+
"critical"
|
|
13139
13676
|
]);
|
|
13677
|
+
var AlertActionSchema = object({
|
|
13678
|
+
label: string(),
|
|
13679
|
+
href: string().optional()
|
|
13680
|
+
});
|
|
13140
13681
|
var AlertStatusSchema = _enum([
|
|
13141
13682
|
"active",
|
|
13142
13683
|
"in-progress",
|
|
@@ -13154,6 +13695,7 @@ var AlertSchema = object({
|
|
|
13154
13695
|
severity: AlertSeveritySchema,
|
|
13155
13696
|
title: string(),
|
|
13156
13697
|
message: string(),
|
|
13698
|
+
action: AlertActionSchema.optional(),
|
|
13157
13699
|
status: AlertStatusSchema,
|
|
13158
13700
|
progress: number().optional(),
|
|
13159
13701
|
read: boolean(),
|
|
@@ -15738,6 +16280,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
15738
16280
|
keyField: string()
|
|
15739
16281
|
}).optional()
|
|
15740
16282
|
})) });
|
|
16283
|
+
/**
|
|
16284
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
16285
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
16286
|
+
*
|
|
16287
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
16288
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
16289
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
16290
|
+
*/
|
|
16291
|
+
var RawSecretMigrationInputSchema = object({
|
|
16292
|
+
/** `false` (the default of the script) = report only. */
|
|
16293
|
+
apply: boolean() });
|
|
16294
|
+
var RawSecretMigrationReportSchema = object({
|
|
16295
|
+
apply: boolean(),
|
|
16296
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
16297
|
+
rows: number().int(),
|
|
16298
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
16299
|
+
raw: number().int(),
|
|
16300
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
16301
|
+
markers: number().int(),
|
|
16302
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
16303
|
+
migrated: number().int(),
|
|
16304
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
16305
|
+
failed: number().int(),
|
|
16306
|
+
/** After the run: rows still holding plaintext. */
|
|
16307
|
+
remainingRaw: number().int(),
|
|
16308
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
16309
|
+
unresolvedMarkers: number().int(),
|
|
16310
|
+
/**
|
|
16311
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
16312
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
16313
|
+
*/
|
|
16314
|
+
redundantCopies: number().int().optional(),
|
|
16315
|
+
/** True when nothing is raw and every marker resolves. */
|
|
16316
|
+
verified: boolean()
|
|
16317
|
+
});
|
|
15741
16318
|
/** Where a block runs. The operator chooses — a block driving a device on an
|
|
15742
16319
|
* agent is the reason placement is not fixed to the hub. */
|
|
15743
16320
|
var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
|
|
@@ -15964,6 +16541,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
15964
16541
|
}), SettingsUpdateResultSchema, {
|
|
15965
16542
|
kind: "mutation",
|
|
15966
16543
|
auth: "admin"
|
|
16544
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
16545
|
+
kind: "mutation",
|
|
16546
|
+
auth: "admin"
|
|
15967
16547
|
}), method(object({}), object({ libs: array(object({
|
|
15968
16548
|
filePath: string(),
|
|
15969
16549
|
content: string()
|
|
@@ -16227,6 +16807,347 @@ id: union([string(), number()]) }), {
|
|
|
16227
16807
|
auth: "admin"
|
|
16228
16808
|
});
|
|
16229
16809
|
/**
|
|
16810
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
16811
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
16812
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
16813
|
+
*
|
|
16814
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
16815
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
16816
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
16817
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
16818
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
16819
|
+
* addons go through the owner's capability.
|
|
16820
|
+
*
|
|
16821
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
16822
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
16823
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
16824
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
16825
|
+
* row's own ref.
|
|
16826
|
+
*
|
|
16827
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
16828
|
+
*/
|
|
16829
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
16830
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
16831
|
+
var RecordBodySchema = record(string(), unknown());
|
|
16832
|
+
var RecordInputSchema = object({
|
|
16833
|
+
id: RecordIdSchema,
|
|
16834
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
16835
|
+
deviceId: number().int().optional(),
|
|
16836
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
16837
|
+
at: number().int().optional(),
|
|
16838
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
16839
|
+
expiresAt: number().int().optional(),
|
|
16840
|
+
data: RecordBodySchema
|
|
16841
|
+
});
|
|
16842
|
+
var RecordViewSchema = object({
|
|
16843
|
+
id: string(),
|
|
16844
|
+
deviceId: number().int().nullable(),
|
|
16845
|
+
at: number().nullable(),
|
|
16846
|
+
expiresAt: number().nullable(),
|
|
16847
|
+
rev: number().int(),
|
|
16848
|
+
updatedAt: number(),
|
|
16849
|
+
data: RecordBodySchema
|
|
16850
|
+
});
|
|
16851
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
16852
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
16853
|
+
string(),
|
|
16854
|
+
number(),
|
|
16855
|
+
boolean(),
|
|
16856
|
+
object({ in: array(union([
|
|
16857
|
+
string(),
|
|
16858
|
+
number(),
|
|
16859
|
+
boolean()
|
|
16860
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
16861
|
+
object({
|
|
16862
|
+
gt: union([string(), number()]).optional(),
|
|
16863
|
+
gte: union([string(), number()]).optional(),
|
|
16864
|
+
lt: union([string(), number()]).optional(),
|
|
16865
|
+
lte: union([string(), number()]).optional()
|
|
16866
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
16867
|
+
]));
|
|
16868
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
16869
|
+
var TimeWindowShape = {
|
|
16870
|
+
deviceId: number().int().optional(),
|
|
16871
|
+
atFrom: number().optional(),
|
|
16872
|
+
atTo: number().optional()
|
|
16873
|
+
};
|
|
16874
|
+
var RecordQueryInputSchema = object({
|
|
16875
|
+
...KindShape,
|
|
16876
|
+
...TimeWindowShape,
|
|
16877
|
+
where: RecordWhereSchema.optional(),
|
|
16878
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
16879
|
+
order: _enum(["at", "id"]).optional(),
|
|
16880
|
+
desc: boolean().optional(),
|
|
16881
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
16882
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
16883
|
+
cursor: string().min(1).optional()
|
|
16884
|
+
});
|
|
16885
|
+
var RecordQueryResultSchema = object({
|
|
16886
|
+
records: array(RecordViewSchema),
|
|
16887
|
+
nextCursor: string().nullable()
|
|
16888
|
+
});
|
|
16889
|
+
var RecordKindStateSchema = _enum([
|
|
16890
|
+
"created",
|
|
16891
|
+
"unchanged",
|
|
16892
|
+
"updated"
|
|
16893
|
+
]);
|
|
16894
|
+
var DeclareKindResultSchema = object({
|
|
16895
|
+
kindId: number().int(),
|
|
16896
|
+
state: RecordKindStateSchema,
|
|
16897
|
+
createdIndexes: array(string()),
|
|
16898
|
+
/** The boot guard: the kind is empty while its legacy table still holds rows. */
|
|
16899
|
+
adoptionPending: object({
|
|
16900
|
+
legacyTable: string(),
|
|
16901
|
+
legacyRows: number().int()
|
|
16902
|
+
}).nullable()
|
|
16903
|
+
});
|
|
16904
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
16905
|
+
var SecretRefsList = array(string());
|
|
16906
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
16907
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
16908
|
+
kind: "mutation",
|
|
16909
|
+
auth: "admin"
|
|
16910
|
+
}), method(object({
|
|
16911
|
+
...KindShape,
|
|
16912
|
+
id: RecordIdSchema
|
|
16913
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
16914
|
+
...KindShape,
|
|
16915
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16916
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
16917
|
+
...KindShape,
|
|
16918
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16919
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
16920
|
+
...KindShape,
|
|
16921
|
+
record: RecordInputSchema,
|
|
16922
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
16923
|
+
ifRev: number().int().min(0).optional()
|
|
16924
|
+
}), object({
|
|
16925
|
+
rev: number().int(),
|
|
16926
|
+
releasedRefs: SecretRefsList
|
|
16927
|
+
}), {
|
|
16928
|
+
kind: "mutation",
|
|
16929
|
+
auth: "admin"
|
|
16930
|
+
}), method(object({
|
|
16931
|
+
...KindShape,
|
|
16932
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16933
|
+
}), object({
|
|
16934
|
+
count: number().int(),
|
|
16935
|
+
releasedRefs: SecretRefsList
|
|
16936
|
+
}), {
|
|
16937
|
+
kind: "mutation",
|
|
16938
|
+
auth: "admin"
|
|
16939
|
+
}), method(object({
|
|
16940
|
+
...KindShape,
|
|
16941
|
+
id: RecordIdSchema,
|
|
16942
|
+
data: RecordBodySchema,
|
|
16943
|
+
at: number().int().nullable().optional(),
|
|
16944
|
+
expiresAt: number().int().nullable().optional(),
|
|
16945
|
+
ifRev: number().int().min(1).optional()
|
|
16946
|
+
}), object({
|
|
16947
|
+
rev: number().int(),
|
|
16948
|
+
releasedRefs: SecretRefsList
|
|
16949
|
+
}), {
|
|
16950
|
+
kind: "mutation",
|
|
16951
|
+
auth: "admin"
|
|
16952
|
+
}), method(object({
|
|
16953
|
+
...KindShape,
|
|
16954
|
+
id: RecordIdSchema
|
|
16955
|
+
}), object({
|
|
16956
|
+
deleted: boolean(),
|
|
16957
|
+
secretRefs: SecretRefsList
|
|
16958
|
+
}), {
|
|
16959
|
+
kind: "mutation",
|
|
16960
|
+
auth: "admin"
|
|
16961
|
+
}), method(object({
|
|
16962
|
+
...KindShape,
|
|
16963
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16964
|
+
}), object({
|
|
16965
|
+
deleted: number().int(),
|
|
16966
|
+
secretRefs: SecretRefsList
|
|
16967
|
+
}), {
|
|
16968
|
+
kind: "mutation",
|
|
16969
|
+
auth: "admin"
|
|
16970
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16971
|
+
...KindShape,
|
|
16972
|
+
...TimeWindowShape,
|
|
16973
|
+
where: RecordWhereSchema.optional()
|
|
16974
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
16975
|
+
...KindShape,
|
|
16976
|
+
deviceId: number().int().optional(),
|
|
16977
|
+
from: number(),
|
|
16978
|
+
to: number(),
|
|
16979
|
+
bucketMs: number().int().positive()
|
|
16980
|
+
}), object({ buckets: array(object({
|
|
16981
|
+
bucketStart: number(),
|
|
16982
|
+
count: number().int()
|
|
16983
|
+
})) }), { auth: "admin" }), method(object({
|
|
16984
|
+
...KindShape,
|
|
16985
|
+
op: _enum([
|
|
16986
|
+
"sum",
|
|
16987
|
+
"min",
|
|
16988
|
+
"max",
|
|
16989
|
+
"count"
|
|
16990
|
+
]),
|
|
16991
|
+
field: RecordFieldPathSchema.optional(),
|
|
16992
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
16993
|
+
where: RecordWhereSchema.optional()
|
|
16994
|
+
}), object({ rows: array(object({
|
|
16995
|
+
group: union([
|
|
16996
|
+
string(),
|
|
16997
|
+
number(),
|
|
16998
|
+
_null()
|
|
16999
|
+
]),
|
|
17000
|
+
value: number().nullable()
|
|
17001
|
+
})) }), { auth: "admin" }), method(object({
|
|
17002
|
+
...KindShape,
|
|
17003
|
+
deviceId: number().int().optional(),
|
|
17004
|
+
atBefore: number().optional(),
|
|
17005
|
+
where: RecordWhereSchema.optional()
|
|
17006
|
+
}), object({
|
|
17007
|
+
deleted: number().int(),
|
|
17008
|
+
secretRefs: SecretRefsList
|
|
17009
|
+
}), {
|
|
17010
|
+
kind: "mutation",
|
|
17011
|
+
auth: "admin"
|
|
17012
|
+
}), method(object({
|
|
17013
|
+
deviceId: number().int(),
|
|
17014
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
17015
|
+
}), object({
|
|
17016
|
+
deleted: record(string(), number().int()),
|
|
17017
|
+
secretRefs: SecretRefsList
|
|
17018
|
+
}), {
|
|
17019
|
+
kind: "mutation",
|
|
17020
|
+
auth: "admin"
|
|
17021
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
17022
|
+
kind: "mutation",
|
|
17023
|
+
auth: "admin"
|
|
17024
|
+
});
|
|
17025
|
+
/** One table of the settings database. */
|
|
17026
|
+
var StorageTableSchema = object({
|
|
17027
|
+
/** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
|
|
17028
|
+
name: string(),
|
|
17029
|
+
/** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
|
|
17030
|
+
owner: string().nullable(),
|
|
17031
|
+
rows: number().int().nonnegative(),
|
|
17032
|
+
/** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
|
|
17033
|
+
bytes: number().int().nonnegative().nullable(),
|
|
17034
|
+
/** Declared by an addon since this engine process started (a running addon claims it). */
|
|
17035
|
+
declaredThisBoot: boolean()
|
|
17036
|
+
});
|
|
17037
|
+
/** One declared record kind (D881) as System -> Data shows it. */
|
|
17038
|
+
var StorageKindSchema = object({
|
|
17039
|
+
owner: string(),
|
|
17040
|
+
kind: string(),
|
|
17041
|
+
database: _enum(["settings", "events"]),
|
|
17042
|
+
class: string(),
|
|
17043
|
+
state: _enum([
|
|
17044
|
+
"declared",
|
|
17045
|
+
"orphaned",
|
|
17046
|
+
"dropped"
|
|
17047
|
+
]),
|
|
17048
|
+
/** `null` when the caller asked for no counts (`counts: false`). */
|
|
17049
|
+
rows: number().int().nonnegative().nullable(),
|
|
17050
|
+
/** Rows x the average size of a sample; null for an empty kind. */
|
|
17051
|
+
bytesEstimate: number().int().nonnegative().nullable(),
|
|
17052
|
+
writeTrigger: string(),
|
|
17053
|
+
retention: RecordRetentionSchema,
|
|
17054
|
+
/** `true` when the kind is an entry kind (the generic entries UI lists it). */
|
|
17055
|
+
entry: boolean(),
|
|
17056
|
+
/** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
|
|
17057
|
+
declaration: RecordKindDeclarationSchema
|
|
17058
|
+
});
|
|
17059
|
+
method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
|
|
17060
|
+
collection: string().min(1),
|
|
17061
|
+
expectRows: number().int().nonnegative()
|
|
17062
|
+
}), object({
|
|
17063
|
+
dropped: literal(true),
|
|
17064
|
+
rows: number().int().nonnegative()
|
|
17065
|
+
}), {
|
|
17066
|
+
kind: "mutation",
|
|
17067
|
+
auth: "admin"
|
|
17068
|
+
}), method(object({
|
|
17069
|
+
owner: string().min(1).optional(),
|
|
17070
|
+
/** `false` skips the per-kind row count (a catalog read only). Default true. */
|
|
17071
|
+
counts: boolean().optional()
|
|
17072
|
+
}), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
|
|
17073
|
+
owner: string().min(1),
|
|
17074
|
+
kind: RecordKindNameSchema
|
|
17075
|
+
}), RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
17076
|
+
owner: string().min(1),
|
|
17077
|
+
kind: RecordKindNameSchema,
|
|
17078
|
+
records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
17079
|
+
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
17080
|
+
complete: boolean().optional()
|
|
17081
|
+
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
|
|
17082
|
+
kind: "mutation",
|
|
17083
|
+
auth: "admin"
|
|
17084
|
+
}), method(object({
|
|
17085
|
+
collection: string().min(1),
|
|
17086
|
+
cursor: string().optional(),
|
|
17087
|
+
limit: number().int().min(1).max(1e3).optional()
|
|
17088
|
+
}), object({
|
|
17089
|
+
rows: array(object({
|
|
17090
|
+
id: string(),
|
|
17091
|
+
data: record(string(), unknown())
|
|
17092
|
+
})),
|
|
17093
|
+
nextCursor: string().nullable()
|
|
17094
|
+
}), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
|
|
17095
|
+
/**
|
|
17096
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
17097
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
17098
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
17099
|
+
*
|
|
17100
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
17101
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
17102
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
17103
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
17104
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
17105
|
+
* a secret value, and a locked keychain refuses the write with
|
|
17106
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
17107
|
+
*
|
|
17108
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
17109
|
+
*/
|
|
17110
|
+
var EntryKindInfoSchema = object({
|
|
17111
|
+
owner: string(),
|
|
17112
|
+
kind: RecordKindNameSchema,
|
|
17113
|
+
title: string(),
|
|
17114
|
+
nameField: string(),
|
|
17115
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
17116
|
+
fields: record(string(), unknown()),
|
|
17117
|
+
secretPaths: array(string()),
|
|
17118
|
+
rows: number().int().nonnegative()
|
|
17119
|
+
});
|
|
17120
|
+
var EntryViewSchema = object({
|
|
17121
|
+
id: RecordIdSchema,
|
|
17122
|
+
name: string(),
|
|
17123
|
+
rev: number().int(),
|
|
17124
|
+
updatedAt: number(),
|
|
17125
|
+
/** Secret fields hold the redaction token. */
|
|
17126
|
+
data: RecordBodySchema
|
|
17127
|
+
});
|
|
17128
|
+
var EntryAddress = {
|
|
17129
|
+
owner: string().min(1),
|
|
17130
|
+
kind: RecordKindNameSchema
|
|
17131
|
+
};
|
|
17132
|
+
method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
|
|
17133
|
+
...EntryAddress,
|
|
17134
|
+
id: RecordIdSchema.optional(),
|
|
17135
|
+
data: RecordBodySchema,
|
|
17136
|
+
ifRev: number().int().min(1).optional()
|
|
17137
|
+
}), object({
|
|
17138
|
+
id: string(),
|
|
17139
|
+
rev: number().int()
|
|
17140
|
+
}), {
|
|
17141
|
+
kind: "mutation",
|
|
17142
|
+
auth: "admin"
|
|
17143
|
+
}), method(object({
|
|
17144
|
+
...EntryAddress,
|
|
17145
|
+
id: RecordIdSchema
|
|
17146
|
+
}), object({ deleted: boolean() }), {
|
|
17147
|
+
kind: "mutation",
|
|
17148
|
+
auth: "admin"
|
|
17149
|
+
});
|
|
17150
|
+
/**
|
|
16230
17151
|
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
16231
17152
|
*
|
|
16232
17153
|
* Settings blobs never hold a secret: they hold a marker
|
|
@@ -16767,6 +17688,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
|
|
|
16767
17688
|
kind: "mutation",
|
|
16768
17689
|
auth: "admin",
|
|
16769
17690
|
caller: "required"
|
|
17691
|
+
}), method(object({
|
|
17692
|
+
ref: string().min(1),
|
|
17693
|
+
value: string().min(1)
|
|
17694
|
+
}), object({
|
|
17695
|
+
ref: string(),
|
|
17696
|
+
version: number().int()
|
|
17697
|
+
}), {
|
|
17698
|
+
kind: "mutation",
|
|
17699
|
+
auth: "admin",
|
|
17700
|
+
caller: "required"
|
|
16770
17701
|
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
16771
17702
|
deleted: array(string()).readonly(),
|
|
16772
17703
|
kept: array(object({
|
|
@@ -39445,6 +40376,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
|
|
|
39445
40376
|
}), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
|
|
39446
40377
|
kind: "mutation",
|
|
39447
40378
|
auth: "admin"
|
|
40379
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
40380
|
+
kind: "mutation",
|
|
40381
|
+
auth: "admin"
|
|
39448
40382
|
}), method(ProfileRefInputSchema, _void(), {
|
|
39449
40383
|
kind: "mutation",
|
|
39450
40384
|
auth: "admin"
|
|
@@ -49954,6 +50888,41 @@ var ServerRollbackInfoSchema = object({
|
|
|
49954
50888
|
atMs: number(),
|
|
49955
50889
|
reason: string()
|
|
49956
50890
|
});
|
|
50891
|
+
/**
|
|
50892
|
+
* The runner boot check (D877): the runners this node PLANNED (hub: one per
|
|
50893
|
+
* `resolveRunnerId` over its forked addons; agent: the runners its process
|
|
50894
|
+
* service holds, because only the hub plans) against the states the process
|
|
50895
|
+
* service reports. Kept in memory, recomputed by the same one-shot check after
|
|
50896
|
+
* every boot, served on `getServerPackageStatus`.
|
|
50897
|
+
*
|
|
50898
|
+
* `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
|
|
50899
|
+
* refusal (an addon that said "I will not start, and here is why"), `missing` a
|
|
50900
|
+
* planned runner the process service has no entry for.
|
|
50901
|
+
*/
|
|
50902
|
+
var RunnerRefusalSchema = object({
|
|
50903
|
+
runnerId: string(),
|
|
50904
|
+
addonIds: array(string()),
|
|
50905
|
+
reason: string()
|
|
50906
|
+
});
|
|
50907
|
+
var RunnerBootCheckSchema = object({
|
|
50908
|
+
checkedAtMs: number(),
|
|
50909
|
+
/** Runners planned for this node. */
|
|
50910
|
+
expected: number(),
|
|
50911
|
+
/** Planned runners whose process is `running`. */
|
|
50912
|
+
running: number(),
|
|
50913
|
+
failed: array(string()),
|
|
50914
|
+
refused: array(RunnerRefusalSchema),
|
|
50915
|
+
missing: array(string()),
|
|
50916
|
+
/**
|
|
50917
|
+
* Runners still on their way: `starting`, or `crashed` waiting on a backoff
|
|
50918
|
+
* respawn. The check is FINAL only when this is empty; until then nothing is
|
|
50919
|
+
* pushed and the verdict is re-evaluated on the next runner state change.
|
|
50920
|
+
* Optional for version skew (absent = settled).
|
|
50921
|
+
*/
|
|
50922
|
+
pending: array(string()).optional(),
|
|
50923
|
+
/** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
|
|
50924
|
+
planKnown: boolean()
|
|
50925
|
+
});
|
|
49957
50926
|
var ServerPackageStatusSchema = object({
|
|
49958
50927
|
/** Root package name (`@camstack/server` on the hub). */
|
|
49959
50928
|
packageName: string(),
|
|
@@ -50016,7 +50985,14 @@ var ServerPackageStatusSchema = object({
|
|
|
50016
50985
|
* for version skew: an older provider's payload simply omits it, and an
|
|
50017
50986
|
* absent wrapper is unknown — never `native`.
|
|
50018
50987
|
*/
|
|
50019
|
-
wrapper: WrapperIdentitySchema.optional()
|
|
50988
|
+
wrapper: WrapperIdentitySchema.optional(),
|
|
50989
|
+
/**
|
|
50990
|
+
* What this node PLANNED to run against what its process service reports
|
|
50991
|
+
* (D877). Absent until the one-shot boot check has run (~60 s after boot) and
|
|
50992
|
+
* on a provider that predates it. Absent is "not checked yet", never "all
|
|
50993
|
+
* well": a consumer that needs the answer treats it as pending.
|
|
50994
|
+
*/
|
|
50995
|
+
runners: RunnerBootCheckSchema.optional()
|
|
50020
50996
|
});
|
|
50021
50997
|
var ServerUpdateCheckResultSchema = object({
|
|
50022
50998
|
packageName: string(),
|
|
@@ -50067,6 +51043,13 @@ var ServerUpdateOutcomeSchema = _enum([
|
|
|
50067
51043
|
"refused",
|
|
50068
51044
|
"failed"
|
|
50069
51045
|
]);
|
|
51046
|
+
/** One addon the pre-flight found the target version would refuse (D877). */
|
|
51047
|
+
var UpdateBlockerSchema = object({
|
|
51048
|
+
addonId: string(),
|
|
51049
|
+
reason: string(),
|
|
51050
|
+
/** What the operator does about it. */
|
|
51051
|
+
remedy: string()
|
|
51052
|
+
});
|
|
50070
51053
|
var ServerUpdateActionResultSchema = object({
|
|
50071
51054
|
accepted: boolean(),
|
|
50072
51055
|
targetVersion: string().nullable(),
|
|
@@ -50084,14 +51067,27 @@ var ServerUpdateActionResultSchema = object({
|
|
|
50084
51067
|
* The failure itself, verbatim enough to act on (the npm output for a
|
|
50085
51068
|
* staging install). Non-null only for `failed`.
|
|
50086
51069
|
*/
|
|
50087
|
-
error: string().nullable().optional()
|
|
51070
|
+
error: string().nullable().optional(),
|
|
51071
|
+
/**
|
|
51072
|
+
* The addons the target version would refuse to start on this node's live
|
|
51073
|
+
* store (D877), present when the pre-flight refused the update
|
|
51074
|
+
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
51075
|
+
*/
|
|
51076
|
+
blockers: array(UpdateBlockerSchema).optional()
|
|
50088
51077
|
});
|
|
50089
51078
|
method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
|
|
50090
51079
|
kind: "mutation",
|
|
50091
51080
|
auth: "admin"
|
|
50092
|
-
}), method(object({
|
|
50093
|
-
/** Explicit target version; omitted = latest from the registry. */
|
|
50094
|
-
version: string().optional()
|
|
51081
|
+
}), method(object({
|
|
51082
|
+
/** Explicit target version; omitted = latest from the registry. */
|
|
51083
|
+
version: string().optional(),
|
|
51084
|
+
/**
|
|
51085
|
+
* Apply even though the pre-flight (D877) found addons the target would
|
|
51086
|
+
* refuse to start. Off by default: those addons stay down until the
|
|
51087
|
+
* remedy is run, which is the incident this gate exists to prevent.
|
|
51088
|
+
*/
|
|
51089
|
+
acknowledgeRefusals: boolean().optional()
|
|
51090
|
+
}), ServerUpdateActionResultSchema, {
|
|
50095
51091
|
kind: "mutation",
|
|
50096
51092
|
auth: "admin",
|
|
50097
51093
|
timeoutMs: 16 * 6e4
|
|
@@ -52537,7 +53533,9 @@ var ManifestShapeSchema = object({
|
|
|
52537
53533
|
var AddonProcessSchema = object({
|
|
52538
53534
|
pid: number().optional(),
|
|
52539
53535
|
mode: string(),
|
|
52540
|
-
state: string()
|
|
53536
|
+
state: string(),
|
|
53537
|
+
/** Why the runner is `refused` (an addon's own words), when it is (D877). */
|
|
53538
|
+
reason: string().optional()
|
|
52541
53539
|
});
|
|
52542
53540
|
/**
|
|
52543
53541
|
* Per-addon health snapshot from the kernel's AddonHealthMonitor.
|
|
@@ -53305,7 +54303,8 @@ var batteryCapability = {
|
|
|
53305
54303
|
DeviceType.Button,
|
|
53306
54304
|
DeviceType.Switch,
|
|
53307
54305
|
DeviceType.PetFeeder,
|
|
53308
|
-
DeviceType.Container
|
|
54306
|
+
DeviceType.Container,
|
|
54307
|
+
DeviceType.Thermostat
|
|
53309
54308
|
],
|
|
53310
54309
|
methods: {
|
|
53311
54310
|
/**
|
|
@@ -53943,6 +54942,12 @@ var ClimateControlStatusSchema = object({
|
|
|
53943
54942
|
/** Horizontal louver swing on/off. Null when the device has no
|
|
53944
54943
|
* horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
|
|
53945
54944
|
swingHorizontal: boolean().nullable(),
|
|
54945
|
+
/** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54946
|
+
minTemp: number().nullable().optional(),
|
|
54947
|
+
/** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54948
|
+
maxTemp: number().nullable().optional(),
|
|
54949
|
+
/** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
|
|
54950
|
+
tempStep: number().positive().nullable().optional(),
|
|
53946
54951
|
/** Ms epoch when the slice was last updated (push or command). */
|
|
53947
54952
|
lastFetchedAt: number()
|
|
53948
54953
|
});
|
|
@@ -54789,6 +55794,125 @@ onStatusChanged: { data: object({
|
|
|
54789
55794
|
* whether persisting is worth a SQLite commit. */
|
|
54790
55795
|
volatileStateFields: ["lastChangedAt"]
|
|
54791
55796
|
};
|
|
55797
|
+
/**
|
|
55798
|
+
* Smart-dishwasher cap — program lifecycle, door / remote-start gates,
|
|
55799
|
+
* consumable levels (salt, rinse aid) and common program options.
|
|
55800
|
+
*
|
|
55801
|
+
* Sources: native Bosch Home Connect (`dishwasher` device type). Reusable
|
|
55802
|
+
* by any integration that exposes the same program / option surface.
|
|
55803
|
+
*
|
|
55804
|
+
* `kind: 'poll'` — cloud REST APIs typically have no push channel; the
|
|
55805
|
+
* provider refreshes the slice on an interval and eagerly after commands.
|
|
55806
|
+
*/
|
|
55807
|
+
var DishwasherStateSchema = _enum([
|
|
55808
|
+
"idle",
|
|
55809
|
+
"running",
|
|
55810
|
+
"paused",
|
|
55811
|
+
"finished",
|
|
55812
|
+
"error",
|
|
55813
|
+
"unavailable"
|
|
55814
|
+
]);
|
|
55815
|
+
var DishwasherConsumableLevelSchema = _enum([
|
|
55816
|
+
"ok",
|
|
55817
|
+
"low",
|
|
55818
|
+
"empty"
|
|
55819
|
+
]);
|
|
55820
|
+
var DishwasherStatusSchema = object({
|
|
55821
|
+
state: DishwasherStateSchema,
|
|
55822
|
+
/** Active program id/name, or null when none selected / unknown. */
|
|
55823
|
+
program: string().nullable(),
|
|
55824
|
+
/** Program tokens the hardware accepts — drives the UI selector. */
|
|
55825
|
+
availablePrograms: array(string()),
|
|
55826
|
+
/** Minutes remaining on the active cycle, or null when not running. */
|
|
55827
|
+
remainingMinutes: number().int().nonnegative().nullable(),
|
|
55828
|
+
/** Cycle completion 0..100, or null when not applicable. */
|
|
55829
|
+
progressPercent: number().min(0).max(100).nullable(),
|
|
55830
|
+
/** True when the door is reported open. */
|
|
55831
|
+
doorOpen: boolean(),
|
|
55832
|
+
/** True when remote start is allowed (door closed, power on, etc.). */
|
|
55833
|
+
remoteStartAllowed: boolean(),
|
|
55834
|
+
/** Main power / switched-on state. */
|
|
55835
|
+
powerOn: boolean(),
|
|
55836
|
+
saltLevel: DishwasherConsumableLevelSchema.nullable(),
|
|
55837
|
+
rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
|
|
55838
|
+
halfLoad: boolean(),
|
|
55839
|
+
hygienePlus: boolean(),
|
|
55840
|
+
errorCode: number().nullable(),
|
|
55841
|
+
errorLabel: string().nullable(),
|
|
55842
|
+
lastFetchedAt: number()
|
|
55843
|
+
});
|
|
55844
|
+
var dishwasherCapability = {
|
|
55845
|
+
name: "dishwasher",
|
|
55846
|
+
scope: "device",
|
|
55847
|
+
deviceNative: true,
|
|
55848
|
+
mode: "singleton",
|
|
55849
|
+
deviceTypes: [DeviceType.Dishwasher],
|
|
55850
|
+
methods: {
|
|
55851
|
+
start: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55852
|
+
kind: "mutation",
|
|
55853
|
+
auth: "protected"
|
|
55854
|
+
}),
|
|
55855
|
+
pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55856
|
+
kind: "mutation",
|
|
55857
|
+
auth: "protected"
|
|
55858
|
+
}),
|
|
55859
|
+
stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
55860
|
+
kind: "mutation",
|
|
55861
|
+
auth: "protected"
|
|
55862
|
+
}),
|
|
55863
|
+
setProgram: method(object({
|
|
55864
|
+
deviceId: number().int().nonnegative(),
|
|
55865
|
+
program: string().min(1)
|
|
55866
|
+
}), _void(), {
|
|
55867
|
+
kind: "mutation",
|
|
55868
|
+
auth: "protected"
|
|
55869
|
+
}),
|
|
55870
|
+
setPower: method(object({
|
|
55871
|
+
deviceId: number().int().nonnegative(),
|
|
55872
|
+
on: boolean()
|
|
55873
|
+
}), _void(), {
|
|
55874
|
+
kind: "mutation",
|
|
55875
|
+
auth: "protected"
|
|
55876
|
+
}),
|
|
55877
|
+
setHalfLoad: method(object({
|
|
55878
|
+
deviceId: number().int().nonnegative(),
|
|
55879
|
+
on: boolean()
|
|
55880
|
+
}), _void(), {
|
|
55881
|
+
kind: "mutation",
|
|
55882
|
+
auth: "protected"
|
|
55883
|
+
}),
|
|
55884
|
+
setHygienePlus: method(object({
|
|
55885
|
+
deviceId: number().int().nonnegative(),
|
|
55886
|
+
on: boolean()
|
|
55887
|
+
}), _void(), {
|
|
55888
|
+
kind: "mutation",
|
|
55889
|
+
auth: "protected"
|
|
55890
|
+
}),
|
|
55891
|
+
setOption: method(object({
|
|
55892
|
+
deviceId: number().int().nonnegative(),
|
|
55893
|
+
key: string().min(1),
|
|
55894
|
+
value: union([
|
|
55895
|
+
boolean(),
|
|
55896
|
+
string(),
|
|
55897
|
+
number()
|
|
55898
|
+
])
|
|
55899
|
+
}), _void(), {
|
|
55900
|
+
kind: "mutation",
|
|
55901
|
+
auth: "protected"
|
|
55902
|
+
})
|
|
55903
|
+
},
|
|
55904
|
+
status: {
|
|
55905
|
+
schema: DishwasherStatusSchema,
|
|
55906
|
+
kind: "poll"
|
|
55907
|
+
},
|
|
55908
|
+
runtimeState: DishwasherStatusSchema,
|
|
55909
|
+
durability: "session",
|
|
55910
|
+
history: { fields: { progressPercent: {
|
|
55911
|
+
kind: "gauge",
|
|
55912
|
+
unit: "%",
|
|
55913
|
+
deadband: 2
|
|
55914
|
+
} } }
|
|
55915
|
+
};
|
|
54792
55916
|
var DoorbellStatusSchema = object({
|
|
54793
55917
|
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
54794
55918
|
lastPressedAt: number().nullable(),
|
|
@@ -55591,6 +56715,32 @@ var gasCapability = {
|
|
|
55591
56715
|
* whether persisting is worth a SQLite commit. */
|
|
55592
56716
|
volatileStateFields: ["lastChangedAt"]
|
|
55593
56717
|
};
|
|
56718
|
+
var HeatingValveStatusSchema = object({
|
|
56719
|
+
/** Radiator valve opening 0 (closed) .. 100 (open). Null = not yet known. */
|
|
56720
|
+
position: number().min(0).max(100).nullable(),
|
|
56721
|
+
/** Ms epoch when the slice was last updated (push or poll). */
|
|
56722
|
+
lastFetchedAt: number()
|
|
56723
|
+
});
|
|
56724
|
+
var heatingValveCapability = {
|
|
56725
|
+
name: "heating-valve",
|
|
56726
|
+
scope: "device",
|
|
56727
|
+
deviceNative: true,
|
|
56728
|
+
mode: "singleton",
|
|
56729
|
+
deviceTypes: [DeviceType.Thermostat],
|
|
56730
|
+
methods: {},
|
|
56731
|
+
status: {
|
|
56732
|
+
schema: HeatingValveStatusSchema,
|
|
56733
|
+
kind: "push"
|
|
56734
|
+
},
|
|
56735
|
+
runtimeState: HeatingValveStatusSchema,
|
|
56736
|
+
durability: "session",
|
|
56737
|
+
history: { fields: { position: {
|
|
56738
|
+
kind: "gauge",
|
|
56739
|
+
unit: "%",
|
|
56740
|
+
deadband: 1
|
|
56741
|
+
} } },
|
|
56742
|
+
volatileStateFields: ["lastFetchedAt"]
|
|
56743
|
+
};
|
|
55594
56744
|
/**
|
|
55595
56745
|
* Humidifier / dehumidifier cap. Models HA `humidifier.*` entities —
|
|
55596
56746
|
* an on/off actuator with an optional target-humidity setpoint and an
|
|
@@ -56723,7 +57873,19 @@ var TlsStatusSchema = object({
|
|
|
56723
57873
|
sans: array(string()),
|
|
56724
57874
|
caCertPem: string().nullable(),
|
|
56725
57875
|
reissueError: string().nullable(),
|
|
56726
|
-
restartRequired: boolean()
|
|
57876
|
+
restartRequired: boolean(),
|
|
57877
|
+
/** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
|
|
57878
|
+
caMissing: boolean(),
|
|
57879
|
+
/** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
|
|
57880
|
+
localCaConstrained: boolean().nullable(),
|
|
57881
|
+
/** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
|
|
57882
|
+
caReplacedAt: string().nullable(),
|
|
57883
|
+
/** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
|
|
57884
|
+
storedUpload: object({
|
|
57885
|
+
leafFingerprintSha256: string(),
|
|
57886
|
+
validTo: string(),
|
|
57887
|
+
hasCa: boolean()
|
|
57888
|
+
}).nullable()
|
|
56727
57889
|
});
|
|
56728
57890
|
method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
|
|
56729
57891
|
/**
|
|
@@ -56779,6 +57941,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
|
|
|
56779
57941
|
}), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
|
|
56780
57942
|
kind: "mutation",
|
|
56781
57943
|
auth: "admin"
|
|
57944
|
+
}), method(_void(), TlsStatusSchema, {
|
|
57945
|
+
kind: "mutation",
|
|
57946
|
+
auth: "admin"
|
|
56782
57947
|
});
|
|
56783
57948
|
var LockControlStatusSchema = object({
|
|
56784
57949
|
/** Lifecycle state of the lock. `jammed` means the motor reported
|
|
@@ -63272,7 +64437,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
63272
64437
|
kind: "mutation",
|
|
63273
64438
|
auth: "admin",
|
|
63274
64439
|
access: "delete"
|
|
63275
|
-
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(
|
|
64440
|
+
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
64441
|
+
kind: "mutation",
|
|
64442
|
+
auth: "admin",
|
|
64443
|
+
access: "create"
|
|
64444
|
+
}), method(object({
|
|
63276
64445
|
userId: string(),
|
|
63277
64446
|
code: string()
|
|
63278
64447
|
}), object({ valid: boolean() }), {
|
|
@@ -64992,6 +66161,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
64992
66161
|
dayNight: dayNightCapability,
|
|
64993
66162
|
deviceDiscovery: deviceDiscoveryCapability,
|
|
64994
66163
|
deviceStatus: deviceStatusCapability,
|
|
66164
|
+
dishwasher: dishwasherCapability,
|
|
64995
66165
|
doorbell: doorbellCapability,
|
|
64996
66166
|
enumSensor: enumSensorCapability,
|
|
64997
66167
|
eventEmitter: eventEmitterCapability,
|
|
@@ -64999,6 +66169,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
|
|
|
64999
66169
|
featureProbe: featureProbeCapability,
|
|
65000
66170
|
flood: floodCapability,
|
|
65001
66171
|
gas: gasCapability,
|
|
66172
|
+
heatingValve: heatingValveCapability,
|
|
65002
66173
|
humidifier: humidifierCapability,
|
|
65003
66174
|
humiditySensor: humiditySensorCapability,
|
|
65004
66175
|
image: imageCapability,
|
|
@@ -65084,13 +66255,14 @@ var BaseDevice = class {
|
|
|
65084
66255
|
get state() {
|
|
65085
66256
|
if (!this._stateProxyCache) {
|
|
65086
66257
|
const cache = {};
|
|
65087
|
-
const handler = { get: (
|
|
66258
|
+
const handler = { get: (target, key) => {
|
|
65088
66259
|
const k = key;
|
|
65089
|
-
|
|
66260
|
+
const existing = Reflect.get(target, k);
|
|
66261
|
+
if (existing !== void 0) return existing;
|
|
65090
66262
|
const cap = DEVICE_LOCAL_STATE_CAPS[k];
|
|
65091
66263
|
if (!cap) return void 0;
|
|
65092
66264
|
const proxy = this.sliceProxy(cap);
|
|
65093
|
-
|
|
66265
|
+
Reflect.set(target, k, proxy);
|
|
65094
66266
|
return proxy;
|
|
65095
66267
|
} };
|
|
65096
66268
|
this._stateProxyCache = new Proxy(cache, handler);
|
|
@@ -65289,7 +66461,7 @@ var BaseDevice = class {
|
|
|
65289
66461
|
async updateSourceInfo(patch) {
|
|
65290
66462
|
const next = mergeSourceInfo(this.sourceInfo, patch);
|
|
65291
66463
|
this._sourceInfoCache = Object.freeze({ ...next });
|
|
65292
|
-
const action = this.ctx.api
|
|
66464
|
+
const action = this.ctx.api.deviceManager?.setMetadata;
|
|
65293
66465
|
if (action) try {
|
|
65294
66466
|
await action.mutate({
|
|
65295
66467
|
deviceId: this.id,
|
|
@@ -65324,7 +66496,7 @@ var BaseDevice = class {
|
|
|
65324
66496
|
* device boot on a meta refresh.
|
|
65325
66497
|
*/
|
|
65326
66498
|
async refreshFeatures() {
|
|
65327
|
-
const action = this.ctx.api
|
|
66499
|
+
const action = this.ctx.api.deviceManager?.registerDevice;
|
|
65328
66500
|
if (!action) return;
|
|
65329
66501
|
try {
|
|
65330
66502
|
await action.mutate({
|
|
@@ -65723,6 +66895,12 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
65723
66895
|
provider: this
|
|
65724
66896
|
}];
|
|
65725
66897
|
}
|
|
66898
|
+
/** Flatten `super.onInitialize()` whether it returned an array or an envelope. */
|
|
66899
|
+
providerRegistrationsFromSuper(result) {
|
|
66900
|
+
if (Array.isArray(result)) return result;
|
|
66901
|
+
if (result !== void 0 && result.providers !== void 0) return [...result.providers];
|
|
66902
|
+
return [];
|
|
66903
|
+
}
|
|
65726
66904
|
async onShutdown() {
|
|
65727
66905
|
this._restoreShuttingDown = true;
|
|
65728
66906
|
this.cancelRestoreRetries();
|
|
@@ -66249,7 +67427,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
66249
67427
|
return toDeviceSummary(device, this.addonId);
|
|
66250
67428
|
}
|
|
66251
67429
|
};
|
|
66252
|
-
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
|
|
67430
|
+
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
|
|
66253
67431
|
new Set(Object.values(DeviceType));
|
|
66254
67432
|
Object.freeze({
|
|
66255
67433
|
"accessories.getStatus": {
|
|
@@ -67398,6 +68576,12 @@ Object.freeze({
|
|
|
67398
68576
|
addonId: null,
|
|
67399
68577
|
access: "view"
|
|
67400
68578
|
},
|
|
68579
|
+
"coreBlocks.migrateRawSecrets": {
|
|
68580
|
+
capName: "core-blocks",
|
|
68581
|
+
capScope: "system",
|
|
68582
|
+
addonId: null,
|
|
68583
|
+
access: "create"
|
|
68584
|
+
},
|
|
67401
68585
|
"coreBlocks.restart": {
|
|
67402
68586
|
capName: "core-blocks",
|
|
67403
68587
|
capScope: "system",
|
|
@@ -68664,6 +69848,60 @@ Object.freeze({
|
|
|
68664
69848
|
addonId: null,
|
|
68665
69849
|
access: "view"
|
|
68666
69850
|
},
|
|
69851
|
+
"dishwasher.getStatus": {
|
|
69852
|
+
capName: "dishwasher",
|
|
69853
|
+
capScope: "device",
|
|
69854
|
+
addonId: null,
|
|
69855
|
+
access: "view"
|
|
69856
|
+
},
|
|
69857
|
+
"dishwasher.pause": {
|
|
69858
|
+
capName: "dishwasher",
|
|
69859
|
+
capScope: "device",
|
|
69860
|
+
addonId: null,
|
|
69861
|
+
access: "create"
|
|
69862
|
+
},
|
|
69863
|
+
"dishwasher.setHalfLoad": {
|
|
69864
|
+
capName: "dishwasher",
|
|
69865
|
+
capScope: "device",
|
|
69866
|
+
addonId: null,
|
|
69867
|
+
access: "create"
|
|
69868
|
+
},
|
|
69869
|
+
"dishwasher.setHygienePlus": {
|
|
69870
|
+
capName: "dishwasher",
|
|
69871
|
+
capScope: "device",
|
|
69872
|
+
addonId: null,
|
|
69873
|
+
access: "create"
|
|
69874
|
+
},
|
|
69875
|
+
"dishwasher.setOption": {
|
|
69876
|
+
capName: "dishwasher",
|
|
69877
|
+
capScope: "device",
|
|
69878
|
+
addonId: null,
|
|
69879
|
+
access: "create"
|
|
69880
|
+
},
|
|
69881
|
+
"dishwasher.setPower": {
|
|
69882
|
+
capName: "dishwasher",
|
|
69883
|
+
capScope: "device",
|
|
69884
|
+
addonId: null,
|
|
69885
|
+
access: "create"
|
|
69886
|
+
},
|
|
69887
|
+
"dishwasher.setProgram": {
|
|
69888
|
+
capName: "dishwasher",
|
|
69889
|
+
capScope: "device",
|
|
69890
|
+
addonId: null,
|
|
69891
|
+
access: "create"
|
|
69892
|
+
},
|
|
69893
|
+
"dishwasher.start": {
|
|
69894
|
+
capName: "dishwasher",
|
|
69895
|
+
capScope: "device",
|
|
69896
|
+
addonId: null,
|
|
69897
|
+
access: "create"
|
|
69898
|
+
},
|
|
69899
|
+
"dishwasher.stop": {
|
|
69900
|
+
capName: "dishwasher",
|
|
69901
|
+
capScope: "device",
|
|
69902
|
+
addonId: null,
|
|
69903
|
+
access: "create"
|
|
69904
|
+
},
|
|
68667
69905
|
"doorbell.getStatus": {
|
|
68668
69906
|
capName: "doorbell",
|
|
68669
69907
|
capScope: "device",
|
|
@@ -68874,6 +70112,12 @@ Object.freeze({
|
|
|
68874
70112
|
addonId: null,
|
|
68875
70113
|
access: "view"
|
|
68876
70114
|
},
|
|
70115
|
+
"heatingValve.getStatus": {
|
|
70116
|
+
capName: "heating-valve",
|
|
70117
|
+
capScope: "device",
|
|
70118
|
+
addonId: null,
|
|
70119
|
+
access: "view"
|
|
70120
|
+
},
|
|
68877
70121
|
"humidifier.getStatus": {
|
|
68878
70122
|
capName: "humidifier",
|
|
68879
70123
|
capScope: "device",
|
|
@@ -69084,6 +70328,12 @@ Object.freeze({
|
|
|
69084
70328
|
addonId: null,
|
|
69085
70329
|
access: "create"
|
|
69086
70330
|
},
|
|
70331
|
+
"keychainAdmin.importSecret": {
|
|
70332
|
+
capName: "keychain-admin",
|
|
70333
|
+
capScope: "system",
|
|
70334
|
+
addonId: null,
|
|
70335
|
+
access: "create"
|
|
70336
|
+
},
|
|
69087
70337
|
"keychainAdmin.listAudit": {
|
|
69088
70338
|
capName: "keychain-admin",
|
|
69089
70339
|
capScope: "system",
|
|
@@ -69252,6 +70502,12 @@ Object.freeze({
|
|
|
69252
70502
|
addonId: null,
|
|
69253
70503
|
access: "view"
|
|
69254
70504
|
},
|
|
70505
|
+
"llm.migrateRawSecrets": {
|
|
70506
|
+
capName: "llm",
|
|
70507
|
+
capScope: "system",
|
|
70508
|
+
addonId: null,
|
|
70509
|
+
access: "create"
|
|
70510
|
+
},
|
|
69255
70511
|
"llm.resolveModelRef": {
|
|
69256
70512
|
capName: "llm",
|
|
69257
70513
|
capScope: "system",
|
|
@@ -69480,6 +70736,12 @@ Object.freeze({
|
|
|
69480
70736
|
addonId: null,
|
|
69481
70737
|
access: "create"
|
|
69482
70738
|
},
|
|
70739
|
+
"localNetwork.useStoredUploadedCertificate": {
|
|
70740
|
+
capName: "local-network",
|
|
70741
|
+
capScope: "system",
|
|
70742
|
+
addonId: null,
|
|
70743
|
+
access: "create"
|
|
70744
|
+
},
|
|
69483
70745
|
"lockControl.getStatus": {
|
|
69484
70746
|
capName: "lock-control",
|
|
69485
70747
|
capScope: "device",
|
|
@@ -72132,6 +73394,30 @@ Object.freeze({
|
|
|
72132
73394
|
addonId: null,
|
|
72133
73395
|
access: "create"
|
|
72134
73396
|
},
|
|
73397
|
+
"recordEntries.deleteEntry": {
|
|
73398
|
+
capName: "record-entries",
|
|
73399
|
+
capScope: "system",
|
|
73400
|
+
addonId: null,
|
|
73401
|
+
access: "delete"
|
|
73402
|
+
},
|
|
73403
|
+
"recordEntries.listEntries": {
|
|
73404
|
+
capName: "record-entries",
|
|
73405
|
+
capScope: "system",
|
|
73406
|
+
addonId: null,
|
|
73407
|
+
access: "view"
|
|
73408
|
+
},
|
|
73409
|
+
"recordEntries.listEntryKinds": {
|
|
73410
|
+
capName: "record-entries",
|
|
73411
|
+
capScope: "system",
|
|
73412
|
+
addonId: null,
|
|
73413
|
+
access: "view"
|
|
73414
|
+
},
|
|
73415
|
+
"recordEntries.putEntry": {
|
|
73416
|
+
capName: "record-entries",
|
|
73417
|
+
capScope: "system",
|
|
73418
|
+
addonId: null,
|
|
73419
|
+
access: "create"
|
|
73420
|
+
},
|
|
72135
73421
|
"recording.getAvailability": {
|
|
72136
73422
|
capName: "recording",
|
|
72137
73423
|
capScope: "device",
|
|
@@ -72432,6 +73718,102 @@ Object.freeze({
|
|
|
72432
73718
|
addonId: null,
|
|
72433
73719
|
access: "view"
|
|
72434
73720
|
},
|
|
73721
|
+
"records.aggregate": {
|
|
73722
|
+
capName: "records",
|
|
73723
|
+
capScope: "system",
|
|
73724
|
+
addonId: null,
|
|
73725
|
+
access: "view"
|
|
73726
|
+
},
|
|
73727
|
+
"records.allocateId": {
|
|
73728
|
+
capName: "records",
|
|
73729
|
+
capScope: "system",
|
|
73730
|
+
addonId: null,
|
|
73731
|
+
access: "create"
|
|
73732
|
+
},
|
|
73733
|
+
"records.count": {
|
|
73734
|
+
capName: "records",
|
|
73735
|
+
capScope: "system",
|
|
73736
|
+
addonId: null,
|
|
73737
|
+
access: "view"
|
|
73738
|
+
},
|
|
73739
|
+
"records.declareKinds": {
|
|
73740
|
+
capName: "records",
|
|
73741
|
+
capScope: "system",
|
|
73742
|
+
addonId: null,
|
|
73743
|
+
access: "create"
|
|
73744
|
+
},
|
|
73745
|
+
"records.delete": {
|
|
73746
|
+
capName: "records",
|
|
73747
|
+
capScope: "system",
|
|
73748
|
+
addonId: null,
|
|
73749
|
+
access: "delete"
|
|
73750
|
+
},
|
|
73751
|
+
"records.deleteDevice": {
|
|
73752
|
+
capName: "records",
|
|
73753
|
+
capScope: "system",
|
|
73754
|
+
addonId: null,
|
|
73755
|
+
access: "delete"
|
|
73756
|
+
},
|
|
73757
|
+
"records.deleteMany": {
|
|
73758
|
+
capName: "records",
|
|
73759
|
+
capScope: "system",
|
|
73760
|
+
addonId: null,
|
|
73761
|
+
access: "delete"
|
|
73762
|
+
},
|
|
73763
|
+
"records.deleteWhere": {
|
|
73764
|
+
capName: "records",
|
|
73765
|
+
capScope: "system",
|
|
73766
|
+
addonId: null,
|
|
73767
|
+
access: "delete"
|
|
73768
|
+
},
|
|
73769
|
+
"records.get": {
|
|
73770
|
+
capName: "records",
|
|
73771
|
+
capScope: "system",
|
|
73772
|
+
addonId: null,
|
|
73773
|
+
access: "view"
|
|
73774
|
+
},
|
|
73775
|
+
"records.getMany": {
|
|
73776
|
+
capName: "records",
|
|
73777
|
+
capScope: "system",
|
|
73778
|
+
addonId: null,
|
|
73779
|
+
access: "view"
|
|
73780
|
+
},
|
|
73781
|
+
"records.histogram": {
|
|
73782
|
+
capName: "records",
|
|
73783
|
+
capScope: "system",
|
|
73784
|
+
addonId: null,
|
|
73785
|
+
access: "view"
|
|
73786
|
+
},
|
|
73787
|
+
"records.patch": {
|
|
73788
|
+
capName: "records",
|
|
73789
|
+
capScope: "system",
|
|
73790
|
+
addonId: null,
|
|
73791
|
+
access: "create"
|
|
73792
|
+
},
|
|
73793
|
+
"records.put": {
|
|
73794
|
+
capName: "records",
|
|
73795
|
+
capScope: "system",
|
|
73796
|
+
addonId: null,
|
|
73797
|
+
access: "create"
|
|
73798
|
+
},
|
|
73799
|
+
"records.putMany": {
|
|
73800
|
+
capName: "records",
|
|
73801
|
+
capScope: "system",
|
|
73802
|
+
addonId: null,
|
|
73803
|
+
access: "create"
|
|
73804
|
+
},
|
|
73805
|
+
"records.query": {
|
|
73806
|
+
capName: "records",
|
|
73807
|
+
capScope: "system",
|
|
73808
|
+
addonId: null,
|
|
73809
|
+
access: "view"
|
|
73810
|
+
},
|
|
73811
|
+
"records.secretRefs": {
|
|
73812
|
+
capName: "records",
|
|
73813
|
+
capScope: "system",
|
|
73814
|
+
addonId: null,
|
|
73815
|
+
access: "view"
|
|
73816
|
+
},
|
|
72435
73817
|
"sceneMonitor.captureReference": {
|
|
72436
73818
|
capName: "scene-monitor",
|
|
72437
73819
|
capScope: "device",
|
|
@@ -72864,6 +74246,48 @@ Object.freeze({
|
|
|
72864
74246
|
addonId: null,
|
|
72865
74247
|
access: "create"
|
|
72866
74248
|
},
|
|
74249
|
+
"storageAdmin.adoptRecords": {
|
|
74250
|
+
capName: "storage-admin",
|
|
74251
|
+
capScope: "system",
|
|
74252
|
+
addonId: null,
|
|
74253
|
+
access: "create"
|
|
74254
|
+
},
|
|
74255
|
+
"storageAdmin.dropCollection": {
|
|
74256
|
+
capName: "storage-admin",
|
|
74257
|
+
capScope: "system",
|
|
74258
|
+
addonId: null,
|
|
74259
|
+
access: "delete"
|
|
74260
|
+
},
|
|
74261
|
+
"storageAdmin.isAdoptedLegacyTable": {
|
|
74262
|
+
capName: "storage-admin",
|
|
74263
|
+
capScope: "system",
|
|
74264
|
+
addonId: null,
|
|
74265
|
+
access: "view"
|
|
74266
|
+
},
|
|
74267
|
+
"storageAdmin.listKinds": {
|
|
74268
|
+
capName: "storage-admin",
|
|
74269
|
+
capScope: "system",
|
|
74270
|
+
addonId: null,
|
|
74271
|
+
access: "view"
|
|
74272
|
+
},
|
|
74273
|
+
"storageAdmin.listTables": {
|
|
74274
|
+
capName: "storage-admin",
|
|
74275
|
+
capScope: "system",
|
|
74276
|
+
addonId: null,
|
|
74277
|
+
access: "view"
|
|
74278
|
+
},
|
|
74279
|
+
"storageAdmin.readLegacyCollection": {
|
|
74280
|
+
capName: "storage-admin",
|
|
74281
|
+
capScope: "system",
|
|
74282
|
+
addonId: null,
|
|
74283
|
+
access: "view"
|
|
74284
|
+
},
|
|
74285
|
+
"storageAdmin.readRecords": {
|
|
74286
|
+
capName: "storage-admin",
|
|
74287
|
+
capScope: "system",
|
|
74288
|
+
addonId: null,
|
|
74289
|
+
access: "view"
|
|
74290
|
+
},
|
|
72867
74291
|
"storageEvictable.evict": {
|
|
72868
74292
|
capName: "storage-evictable",
|
|
72869
74293
|
capScope: "system",
|
|
@@ -73776,6 +75200,12 @@ Object.freeze({
|
|
|
73776
75200
|
addonId: null,
|
|
73777
75201
|
access: "view"
|
|
73778
75202
|
},
|
|
75203
|
+
"userManagement.migrateRawSecrets": {
|
|
75204
|
+
capName: "user-management",
|
|
75205
|
+
capScope: "system",
|
|
75206
|
+
addonId: null,
|
|
75207
|
+
access: "create"
|
|
75208
|
+
},
|
|
73779
75209
|
"userManagement.oauthExchangeCode": {
|
|
73780
75210
|
capName: "user-management",
|
|
73781
75211
|
capScope: "system",
|
|
@@ -74275,7 +75705,7 @@ Object.freeze({
|
|
|
74275
75705
|
access: "create"
|
|
74276
75706
|
}
|
|
74277
75707
|
});
|
|
74278
|
-
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;
|
|
75708
|
+
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.Dishwasher;
|
|
74279
75709
|
DeviceFeature.BatteryOperated;
|
|
74280
75710
|
Object.freeze({
|
|
74281
75711
|
"accessories.getStatus": [{
|
|
@@ -75099,6 +76529,51 @@ Object.freeze({
|
|
|
75099
76529
|
form: "single",
|
|
75100
76530
|
optional: false
|
|
75101
76531
|
}],
|
|
76532
|
+
"dishwasher.getStatus": [{
|
|
76533
|
+
name: "deviceId",
|
|
76534
|
+
form: "single",
|
|
76535
|
+
optional: false
|
|
76536
|
+
}],
|
|
76537
|
+
"dishwasher.pause": [{
|
|
76538
|
+
name: "deviceId",
|
|
76539
|
+
form: "single",
|
|
76540
|
+
optional: false
|
|
76541
|
+
}],
|
|
76542
|
+
"dishwasher.setHalfLoad": [{
|
|
76543
|
+
name: "deviceId",
|
|
76544
|
+
form: "single",
|
|
76545
|
+
optional: false
|
|
76546
|
+
}],
|
|
76547
|
+
"dishwasher.setHygienePlus": [{
|
|
76548
|
+
name: "deviceId",
|
|
76549
|
+
form: "single",
|
|
76550
|
+
optional: false
|
|
76551
|
+
}],
|
|
76552
|
+
"dishwasher.setOption": [{
|
|
76553
|
+
name: "deviceId",
|
|
76554
|
+
form: "single",
|
|
76555
|
+
optional: false
|
|
76556
|
+
}],
|
|
76557
|
+
"dishwasher.setPower": [{
|
|
76558
|
+
name: "deviceId",
|
|
76559
|
+
form: "single",
|
|
76560
|
+
optional: false
|
|
76561
|
+
}],
|
|
76562
|
+
"dishwasher.setProgram": [{
|
|
76563
|
+
name: "deviceId",
|
|
76564
|
+
form: "single",
|
|
76565
|
+
optional: false
|
|
76566
|
+
}],
|
|
76567
|
+
"dishwasher.start": [{
|
|
76568
|
+
name: "deviceId",
|
|
76569
|
+
form: "single",
|
|
76570
|
+
optional: false
|
|
76571
|
+
}],
|
|
76572
|
+
"dishwasher.stop": [{
|
|
76573
|
+
name: "deviceId",
|
|
76574
|
+
form: "single",
|
|
76575
|
+
optional: false
|
|
76576
|
+
}],
|
|
75102
76577
|
"doorbell.getStatus": [{
|
|
75103
76578
|
name: "deviceId",
|
|
75104
76579
|
form: "single",
|
|
@@ -75168,6 +76643,11 @@ Object.freeze({
|
|
|
75168
76643
|
form: "single",
|
|
75169
76644
|
optional: false
|
|
75170
76645
|
}],
|
|
76646
|
+
"heatingValve.getStatus": [{
|
|
76647
|
+
name: "deviceId",
|
|
76648
|
+
form: "single",
|
|
76649
|
+
optional: false
|
|
76650
|
+
}],
|
|
75171
76651
|
"humidifier.getStatus": [{
|
|
75172
76652
|
name: "deviceId",
|
|
75173
76653
|
form: "single",
|
|
@@ -76452,6 +77932,37 @@ Object.freeze({
|
|
|
76452
77932
|
form: "single",
|
|
76453
77933
|
optional: false
|
|
76454
77934
|
}],
|
|
77935
|
+
"records.count": [{
|
|
77936
|
+
name: "deviceId",
|
|
77937
|
+
form: "single",
|
|
77938
|
+
optional: true
|
|
77939
|
+
}],
|
|
77940
|
+
"records.deleteDevice": [{
|
|
77941
|
+
name: "deviceId",
|
|
77942
|
+
form: "single",
|
|
77943
|
+
optional: false
|
|
77944
|
+
}],
|
|
77945
|
+
"records.deleteWhere": [{
|
|
77946
|
+
name: "deviceId",
|
|
77947
|
+
form: "single",
|
|
77948
|
+
optional: true
|
|
77949
|
+
}],
|
|
77950
|
+
"records.histogram": [{
|
|
77951
|
+
name: "deviceId",
|
|
77952
|
+
form: "single",
|
|
77953
|
+
optional: true
|
|
77954
|
+
}],
|
|
77955
|
+
"records.putMany": [{
|
|
77956
|
+
name: "records",
|
|
77957
|
+
form: "object-array",
|
|
77958
|
+
optional: false,
|
|
77959
|
+
itemField: "deviceId"
|
|
77960
|
+
}],
|
|
77961
|
+
"records.query": [{
|
|
77962
|
+
name: "deviceId",
|
|
77963
|
+
form: "single",
|
|
77964
|
+
optional: true
|
|
77965
|
+
}],
|
|
76455
77966
|
"sceneMonitor.captureReference": [{
|
|
76456
77967
|
name: "deviceId",
|
|
76457
77968
|
form: "single",
|
|
@@ -76568,6 +78079,17 @@ Object.freeze({
|
|
|
76568
78079
|
form: "single",
|
|
76569
78080
|
optional: false
|
|
76570
78081
|
}],
|
|
78082
|
+
"storageAdmin.adoptRecords": [{
|
|
78083
|
+
name: "records",
|
|
78084
|
+
form: "object-array",
|
|
78085
|
+
optional: false,
|
|
78086
|
+
itemField: "deviceId"
|
|
78087
|
+
}],
|
|
78088
|
+
"storageAdmin.readRecords": [{
|
|
78089
|
+
name: "deviceId",
|
|
78090
|
+
form: "single",
|
|
78091
|
+
optional: true
|
|
78092
|
+
}],
|
|
76571
78093
|
"streamBroker.acquireEgressTranscode": [{
|
|
76572
78094
|
name: "deviceId",
|
|
76573
78095
|
form: "single",
|
|
@@ -121507,6 +123029,70 @@ var AlexaDevice = class extends BaseDevice {
|
|
|
121507
123029
|
function isKnownCap(cap) {
|
|
121508
123030
|
return KNOWN_CAPS.has(cap);
|
|
121509
123031
|
}
|
|
123032
|
+
var alexaBrokersEntryKind = defineEntryKind("brokers", {
|
|
123033
|
+
title: "Alexa import brokers",
|
|
123034
|
+
schema: entryBody({
|
|
123035
|
+
connection: AlexaBrokerEntrySchema.shape.connection,
|
|
123036
|
+
integrationId: string().optional()
|
|
123037
|
+
}),
|
|
123038
|
+
writeTrigger: "an operator links or removes an Alexa account broker",
|
|
123039
|
+
adoptsFrom: settingsBrokersAdoptsFrom("import-alexa")
|
|
123040
|
+
});
|
|
123041
|
+
//#endregion
|
|
123042
|
+
//#region src/alexa-broker-store.ts
|
|
123043
|
+
function rowToEntry(id, data) {
|
|
123044
|
+
const parsed = AlexaBrokerEntrySchema.safeParse({
|
|
123045
|
+
id,
|
|
123046
|
+
name: data.name,
|
|
123047
|
+
connection: data.connection,
|
|
123048
|
+
integrationId: data.integrationId
|
|
123049
|
+
});
|
|
123050
|
+
return parsed.success ? parsed.data : null;
|
|
123051
|
+
}
|
|
123052
|
+
var AlexaBrokerStore = class AlexaBrokerStore {
|
|
123053
|
+
kind;
|
|
123054
|
+
constructor(kind) {
|
|
123055
|
+
this.kind = kind;
|
|
123056
|
+
}
|
|
123057
|
+
static of(records) {
|
|
123058
|
+
return new AlexaBrokerStore(records.kind(alexaBrokersEntryKind));
|
|
123059
|
+
}
|
|
123060
|
+
async listResolved() {
|
|
123061
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
123062
|
+
const out = [];
|
|
123063
|
+
for (const record of page.records) {
|
|
123064
|
+
let data = record.data;
|
|
123065
|
+
try {
|
|
123066
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
123067
|
+
if (resolved !== null) data = resolved.data;
|
|
123068
|
+
} catch (err) {
|
|
123069
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
123070
|
+
}
|
|
123071
|
+
const entry = rowToEntry(record.id, data);
|
|
123072
|
+
if (entry !== null) out.push(entry);
|
|
123073
|
+
}
|
|
123074
|
+
return out;
|
|
123075
|
+
}
|
|
123076
|
+
async replaceAll(entries) {
|
|
123077
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
123078
|
+
const nextIds = new Set(entries.map((e) => e.id));
|
|
123079
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
123080
|
+
for (const entry of entries) {
|
|
123081
|
+
const { id, name, connection, integrationId } = entry;
|
|
123082
|
+
const body = {
|
|
123083
|
+
name,
|
|
123084
|
+
connection,
|
|
123085
|
+
...integrationId === void 0 ? {} : { integrationId }
|
|
123086
|
+
};
|
|
123087
|
+
const parsed = alexaBrokersEntryKind.schema.safeParse(body);
|
|
123088
|
+
if (!parsed.success) throw new Error(`invalid Alexa broker '${id}': ${parsed.error.message}`);
|
|
123089
|
+
await this.kind.put({
|
|
123090
|
+
id,
|
|
123091
|
+
data: parsed.data
|
|
123092
|
+
});
|
|
123093
|
+
}
|
|
123094
|
+
}
|
|
123095
|
+
};
|
|
121510
123096
|
//#endregion
|
|
121511
123097
|
//#region src/addon.ts
|
|
121512
123098
|
/** Default config — a fresh install starts with no accounts. */
|
|
@@ -121554,11 +123140,18 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121554
123140
|
deviceClasses = Object.fromEntries(ALEXA_DEVICE_TYPES.map((t) => [t, AlexaDevice]));
|
|
121555
123141
|
registry = null;
|
|
121556
123142
|
proxyLogin = null;
|
|
123143
|
+
brokerStore = null;
|
|
123144
|
+
activeBrokers = [];
|
|
121557
123145
|
constructor() {
|
|
121558
123146
|
super({ ...DEFAULTS });
|
|
121559
123147
|
}
|
|
121560
123148
|
async onInitialize() {
|
|
121561
|
-
const regs = await super.onInitialize();
|
|
123149
|
+
const regs = this.providerRegistrationsFromSuper(await super.onInitialize());
|
|
123150
|
+
const records = this.ctx.records;
|
|
123151
|
+
if (records === void 0) throw new Error("import-alexa: ctx.records is required (hub-only addon)");
|
|
123152
|
+
await records.declare({ brokers: alexaBrokersEntryKind });
|
|
123153
|
+
this.brokerStore = AlexaBrokerStore.of(records);
|
|
123154
|
+
this.activeBrokers = await this.loadPersistedBrokers();
|
|
121562
123155
|
this.registry = new AlexaBrokerRegistry(this.ctx.logger, {
|
|
121563
123156
|
dataDir: this.ctx.dataDir,
|
|
121564
123157
|
onBrokerConnected: (brokerId) => {
|
|
@@ -121583,7 +123176,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121583
123176
|
}
|
|
121584
123177
|
});
|
|
121585
123178
|
alexaCommands.setDispatcher((brokerId, command) => this.requireRegistry().sendCommand(brokerId, command));
|
|
121586
|
-
await this.registry.restore(this.
|
|
123179
|
+
await this.registry.restore(this.activeBrokers);
|
|
121587
123180
|
this.proxyLogin = new AlexaProxyLoginManager({
|
|
121588
123181
|
logger: this.ctx.logger,
|
|
121589
123182
|
getProxyConfig: () => {
|
|
@@ -121594,7 +123187,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121594
123187
|
};
|
|
121595
123188
|
}
|
|
121596
123189
|
});
|
|
121597
|
-
this.ctx.logger.info("Alexa: import addon initialised", { meta: { brokerCount: this.
|
|
123190
|
+
this.ctx.logger.info("Alexa: import addon initialised", { meta: { brokerCount: this.activeBrokers.length } });
|
|
121598
123191
|
await this.reconcileIntegrationsToBrokers();
|
|
121599
123192
|
this.subscribeIntegrationLifecycle();
|
|
121600
123193
|
const loginRoutes = buildAlexaLoginRoutes({
|
|
@@ -121618,10 +123211,28 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121618
123211
|
}
|
|
121619
123212
|
];
|
|
121620
123213
|
}
|
|
123214
|
+
async loadPersistedBrokers() {
|
|
123215
|
+
const store = this.brokerStore;
|
|
123216
|
+
if (store !== null) {
|
|
123217
|
+
const fromRecords = await store.listResolved();
|
|
123218
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
123219
|
+
}
|
|
123220
|
+
return this.config.brokers;
|
|
123221
|
+
}
|
|
123222
|
+
async persistBrokerEntries(entries) {
|
|
123223
|
+
this.activeBrokers = [...entries];
|
|
123224
|
+
const store = this.brokerStore;
|
|
123225
|
+
if (store !== null) {
|
|
123226
|
+
await store.replaceAll(entries);
|
|
123227
|
+
return;
|
|
123228
|
+
}
|
|
123229
|
+
await this.updateGlobalSettings({ brokers: [...entries] });
|
|
123230
|
+
}
|
|
121621
123231
|
async onConfigChanged() {
|
|
121622
123232
|
const reg = this.registry;
|
|
121623
123233
|
if (!reg) return;
|
|
121624
|
-
|
|
123234
|
+
this.activeBrokers = await this.loadPersistedBrokers();
|
|
123235
|
+
const persisted = this.activeBrokers;
|
|
121625
123236
|
const liveIds = new Set(reg.list().map((b) => b.id));
|
|
121626
123237
|
const persistedIds = new Set(persisted.map((e) => e.id));
|
|
121627
123238
|
for (const liveId of liveIds) if (!persistedIds.has(liveId)) try {
|
|
@@ -121652,7 +123263,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121652
123263
|
...b,
|
|
121653
123264
|
id: created.id
|
|
121654
123265
|
} : b);
|
|
121655
|
-
await this.
|
|
123266
|
+
await this.persistBrokerEntries(next);
|
|
121656
123267
|
}
|
|
121657
123268
|
} catch (err) {
|
|
121658
123269
|
this.ctx.logger.warn("Alexa onConfigChanged: failed to start new broker", { meta: {
|
|
@@ -121740,8 +123351,8 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121740
123351
|
return buildAlexaBrokerProvider({
|
|
121741
123352
|
ownerAddonId: this.ctx.id,
|
|
121742
123353
|
registry: this.requireRegistry(),
|
|
121743
|
-
getBrokers: () => this.
|
|
121744
|
-
persistBrokers: (brokers) => this.
|
|
123354
|
+
getBrokers: () => this.activeBrokers,
|
|
123355
|
+
persistBrokers: (brokers) => this.persistBrokerEntries(brokers),
|
|
121745
123356
|
cascadeRemoveDevices: (brokerId) => this.cascadeRemoveDevicesForBroker(brokerId),
|
|
121746
123357
|
logger: this.ctx.logger
|
|
121747
123358
|
});
|
|
@@ -121756,7 +123367,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121756
123367
|
async commitCapturedCookie(input) {
|
|
121757
123368
|
const reg = this.requireRegistry();
|
|
121758
123369
|
if (input.brokerId !== void 0) {
|
|
121759
|
-
const existing = this.
|
|
123370
|
+
const existing = this.activeBrokers.find((b) => b.id === input.brokerId);
|
|
121760
123371
|
if (existing === void 0) throw new Error(`commitCookie: unknown broker "${input.brokerId}"`);
|
|
121761
123372
|
const connection = {
|
|
121762
123373
|
...existing.connection,
|
|
@@ -121764,7 +123375,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121764
123375
|
cookie: input.cookie
|
|
121765
123376
|
};
|
|
121766
123377
|
const updated = await reg.updateEntry(input.brokerId, connection);
|
|
121767
|
-
await this.
|
|
123378
|
+
await this.persistBrokerEntries(this.activeBrokers.map((b) => b.id === input.brokerId ? updated : b));
|
|
121768
123379
|
this.ctx.logger.info("Alexa: proxy-login cookie committed to existing broker", { meta: { brokerId: input.brokerId } });
|
|
121769
123380
|
return { brokerId: input.brokerId };
|
|
121770
123381
|
}
|
|
@@ -121773,7 +123384,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121773
123384
|
cookie: input.cookie
|
|
121774
123385
|
});
|
|
121775
123386
|
const entry = await reg.createEntry(input.name, connection);
|
|
121776
|
-
await this.
|
|
123387
|
+
await this.persistBrokerEntries([...this.activeBrokers, entry]);
|
|
121777
123388
|
this.ctx.logger.info("Alexa: proxy-login cookie committed to new broker", { meta: {
|
|
121778
123389
|
brokerId: entry.id,
|
|
121779
123390
|
name: input.name
|
|
@@ -121800,7 +123411,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121800
123411
|
const settings = await this.ctx.api.integrations.getSettings.query({ id: integration.id });
|
|
121801
123412
|
const brokerId = typeof settings["brokerId"] === "string" ? settings["brokerId"] : void 0;
|
|
121802
123413
|
if (brokerId === void 0) continue;
|
|
121803
|
-
if (!this.
|
|
123414
|
+
if (!this.activeBrokers.some((b) => b.id === brokerId)) {
|
|
121804
123415
|
this.ctx.logger.warn("Alexa integration→broker: linked broker not found", { meta: {
|
|
121805
123416
|
integrationId: integration.id,
|
|
121806
123417
|
brokerId
|
|
@@ -121809,7 +123420,7 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121809
123420
|
}
|
|
121810
123421
|
this.requireRegistry().linkIntegration(integration.id, brokerId);
|
|
121811
123422
|
}
|
|
121812
|
-
const toRemove = this.
|
|
123423
|
+
const toRemove = this.activeBrokers.filter((b) => b.integrationId !== void 0 && !surviving.has(b.integrationId)).map((b) => b.id);
|
|
121813
123424
|
if (toRemove.length === 0) return;
|
|
121814
123425
|
for (const id of toRemove) try {
|
|
121815
123426
|
await this.requireRegistry().removeEntry(id);
|
|
@@ -121820,8 +123431,8 @@ var AlexaImportAddon = class extends BaseDeviceProvider {
|
|
|
121820
123431
|
error: errMsg(err)
|
|
121821
123432
|
} });
|
|
121822
123433
|
}
|
|
121823
|
-
const nextBrokers = this.
|
|
121824
|
-
await this.
|
|
123434
|
+
const nextBrokers = this.activeBrokers.filter((b) => !toRemove.includes(b.id));
|
|
123435
|
+
await this.persistBrokerEntries(nextBrokers);
|
|
121825
123436
|
} catch (err) {
|
|
121826
123437
|
this.ctx.logger.warn("Alexa integration→broker reconcile failed", { meta: { error: errMsg(err) } });
|
|
121827
123438
|
}
|