@camstack/addon-provider-homematic 1.2.135 → 1.2.136
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 +1480 -136
- package/dist/addon.mjs +1480 -136
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from "path";
|
|
|
9
9
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
10
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
11
11
|
//#endregion
|
|
12
|
-
//#region ../types/dist/event-category-
|
|
12
|
+
//#region ../types/dist/event-category-BvOFi6PY.mjs
|
|
13
13
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
14
14
|
EventCategory["SystemBoot"] = "system.boot";
|
|
15
15
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -73,6 +73,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
73
73
|
* consumes this category and maps it to the `addon-crash-loop` kind.
|
|
74
74
|
*/
|
|
75
75
|
EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
|
|
76
|
+
/**
|
|
77
|
+
* A runner whose addon refused to start with a typed reason (D877) - parked
|
|
78
|
+
* in `refused`, never counted by the crash breaker, retried on operator
|
|
79
|
+
* action. One event per refusal.
|
|
80
|
+
*/
|
|
81
|
+
EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
|
|
82
|
+
/**
|
|
83
|
+
* A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
|
|
84
|
+
* `refused`. In-process telemetry for the boot check (re-evaluate while any
|
|
85
|
+
* runner is still pending) and the alert centre (close a recovered runner).
|
|
86
|
+
*/
|
|
87
|
+
EventCategory["ProcessStateChanged"] = "process.state-changed";
|
|
88
|
+
/**
|
|
89
|
+
* The node's one-shot runner boot check (D877): planned runners against the
|
|
90
|
+
* process service, `degraded` when any is failed, refused or missing. The
|
|
91
|
+
* alert centre turns it into one alert and a direct critical push.
|
|
92
|
+
*/
|
|
93
|
+
EventCategory["SystemRunnerCheck"] = "system.runner-check";
|
|
76
94
|
EventCategory["AddonError"] = "addon.error";
|
|
77
95
|
EventCategory["AddonPageReady"] = "addon.page-ready";
|
|
78
96
|
EventCategory["AddonWidgetReady"] = "addon.widget-ready";
|
|
@@ -4115,6 +4133,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4115
4133
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4116
4134
|
json.type = "boolean";
|
|
4117
4135
|
};
|
|
4136
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4137
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4138
|
+
};
|
|
4139
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4140
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4141
|
+
};
|
|
4118
4142
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4119
4143
|
if (ctx.target === "openapi-3.0") {
|
|
4120
4144
|
json.type = "string";
|
|
@@ -4122,12 +4146,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4122
4146
|
json.enum = [null];
|
|
4123
4147
|
} else json.type = "null";
|
|
4124
4148
|
};
|
|
4149
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4150
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4151
|
+
};
|
|
4125
4152
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4126
4153
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4127
4154
|
};
|
|
4128
4155
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4129
4156
|
json.not = {};
|
|
4130
4157
|
};
|
|
4158
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4159
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4131
4160
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4132
4161
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4133
4162
|
};
|
|
@@ -4159,12 +4188,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4159
4188
|
json.enum = vals;
|
|
4160
4189
|
}
|
|
4161
4190
|
};
|
|
4191
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4192
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4193
|
+
};
|
|
4194
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4195
|
+
const _json = json;
|
|
4196
|
+
const pattern = schema._zod.pattern;
|
|
4197
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4198
|
+
_json.type = "string";
|
|
4199
|
+
_json.pattern = pattern.source;
|
|
4200
|
+
};
|
|
4201
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4202
|
+
const _json = json;
|
|
4203
|
+
const file = {
|
|
4204
|
+
type: "string",
|
|
4205
|
+
format: "binary",
|
|
4206
|
+
contentEncoding: "binary"
|
|
4207
|
+
};
|
|
4208
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4209
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4210
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4211
|
+
if (mime) if (mime.length === 1) {
|
|
4212
|
+
file.contentMediaType = mime[0];
|
|
4213
|
+
Object.assign(_json, file);
|
|
4214
|
+
} else {
|
|
4215
|
+
Object.assign(_json, file);
|
|
4216
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4217
|
+
}
|
|
4218
|
+
else Object.assign(_json, file);
|
|
4219
|
+
};
|
|
4220
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4221
|
+
json.type = "boolean";
|
|
4222
|
+
};
|
|
4162
4223
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4163
4224
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4164
4225
|
};
|
|
4226
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4227
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4228
|
+
};
|
|
4165
4229
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4166
4230
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4167
4231
|
};
|
|
4232
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4233
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4234
|
+
};
|
|
4235
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4236
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4237
|
+
};
|
|
4168
4238
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4169
4239
|
const json = _json;
|
|
4170
4240
|
const def = schema._zod.def;
|
|
@@ -4369,6 +4439,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4369
4439
|
seen.ref = def.innerType;
|
|
4370
4440
|
json.readOnly = true;
|
|
4371
4441
|
};
|
|
4442
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4443
|
+
const def = schema._zod.def;
|
|
4444
|
+
process$1(def.innerType, ctx, params);
|
|
4445
|
+
const seen = ctx.seen.get(schema);
|
|
4446
|
+
seen.ref = def.innerType;
|
|
4447
|
+
};
|
|
4372
4448
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4373
4449
|
const def = schema._zod.def;
|
|
4374
4450
|
process$1(def.innerType, ctx, params);
|
|
@@ -4381,6 +4457,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4381
4457
|
const seen = ctx.seen.get(schema);
|
|
4382
4458
|
seen.ref = innerType;
|
|
4383
4459
|
};
|
|
4460
|
+
var allProcessors = {
|
|
4461
|
+
string: stringProcessor,
|
|
4462
|
+
number: numberProcessor,
|
|
4463
|
+
boolean: booleanProcessor,
|
|
4464
|
+
bigint: bigintProcessor,
|
|
4465
|
+
symbol: symbolProcessor,
|
|
4466
|
+
null: nullProcessor,
|
|
4467
|
+
undefined: undefinedProcessor,
|
|
4468
|
+
void: voidProcessor,
|
|
4469
|
+
never: neverProcessor,
|
|
4470
|
+
any: anyProcessor,
|
|
4471
|
+
unknown: unknownProcessor,
|
|
4472
|
+
date: dateProcessor,
|
|
4473
|
+
enum: enumProcessor,
|
|
4474
|
+
literal: literalProcessor,
|
|
4475
|
+
nan: nanProcessor,
|
|
4476
|
+
template_literal: templateLiteralProcessor,
|
|
4477
|
+
file: fileProcessor,
|
|
4478
|
+
success: successProcessor,
|
|
4479
|
+
custom: customProcessor,
|
|
4480
|
+
function: functionProcessor,
|
|
4481
|
+
transform: transformProcessor,
|
|
4482
|
+
map: mapProcessor,
|
|
4483
|
+
set: setProcessor,
|
|
4484
|
+
array: arrayProcessor,
|
|
4485
|
+
object: objectProcessor,
|
|
4486
|
+
union: unionProcessor,
|
|
4487
|
+
intersection: intersectionProcessor,
|
|
4488
|
+
tuple: tupleProcessor,
|
|
4489
|
+
record: recordProcessor,
|
|
4490
|
+
nullable: nullableProcessor,
|
|
4491
|
+
nonoptional: nonoptionalProcessor,
|
|
4492
|
+
default: defaultProcessor,
|
|
4493
|
+
prefault: prefaultProcessor,
|
|
4494
|
+
catch: catchProcessor,
|
|
4495
|
+
pipe: pipeProcessor,
|
|
4496
|
+
readonly: readonlyProcessor,
|
|
4497
|
+
promise: promiseProcessor,
|
|
4498
|
+
optional: optionalProcessor,
|
|
4499
|
+
lazy: lazyProcessor
|
|
4500
|
+
};
|
|
4501
|
+
function toJSONSchema(input, params) {
|
|
4502
|
+
if ("_idmap" in input) {
|
|
4503
|
+
const registry = input;
|
|
4504
|
+
const ctx = initializeContext({
|
|
4505
|
+
...params,
|
|
4506
|
+
processors: allProcessors
|
|
4507
|
+
});
|
|
4508
|
+
const defs = {};
|
|
4509
|
+
for (const entry of registry._idmap.entries()) {
|
|
4510
|
+
const [_, schema] = entry;
|
|
4511
|
+
process$1(schema, ctx);
|
|
4512
|
+
}
|
|
4513
|
+
const schemas = {};
|
|
4514
|
+
ctx.external = {
|
|
4515
|
+
registry,
|
|
4516
|
+
uri: params?.uri,
|
|
4517
|
+
defs
|
|
4518
|
+
};
|
|
4519
|
+
for (const entry of registry._idmap.entries()) {
|
|
4520
|
+
const [key, schema] = entry;
|
|
4521
|
+
extractDefs(ctx, schema);
|
|
4522
|
+
schemas[key] = finalize(ctx, schema);
|
|
4523
|
+
}
|
|
4524
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4525
|
+
return { schemas };
|
|
4526
|
+
}
|
|
4527
|
+
const ctx = initializeContext({
|
|
4528
|
+
...params,
|
|
4529
|
+
processors: allProcessors
|
|
4530
|
+
});
|
|
4531
|
+
process$1(input, ctx);
|
|
4532
|
+
extractDefs(ctx, input);
|
|
4533
|
+
return finalize(ctx, input);
|
|
4534
|
+
}
|
|
4384
4535
|
//#endregion
|
|
4385
4536
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4386
4537
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5397,7 +5548,7 @@ var ZodIssueCode = {
|
|
|
5397
5548
|
var ZodFirstPartyTypeKind;
|
|
5398
5549
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5399
5550
|
//#endregion
|
|
5400
|
-
//#region ../types/dist/sleep-
|
|
5551
|
+
//#region ../types/dist/sleep-bZIhUvjd.mjs
|
|
5401
5552
|
/**
|
|
5402
5553
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5403
5554
|
* window to float samples (D455).
|
|
@@ -5514,7 +5665,7 @@ function isKeychainStoredField(field) {
|
|
|
5514
5665
|
var SECRET_CLEAR = { $secretClear: true };
|
|
5515
5666
|
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5516
5667
|
var LEGACY_DEVICE_REDACTION = "***";
|
|
5517
|
-
function isRecord$
|
|
5668
|
+
function isRecord$5(value) {
|
|
5518
5669
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5519
5670
|
}
|
|
5520
5671
|
function makeSecretMarker(ref) {
|
|
@@ -5525,12 +5676,12 @@ function makeSecretMarker(ref) {
|
|
|
5525
5676
|
}
|
|
5526
5677
|
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5527
5678
|
function isSecretMarker(value) {
|
|
5528
|
-
if (!isRecord$
|
|
5679
|
+
if (!isRecord$5(value)) return false;
|
|
5529
5680
|
const ref = value["$secret"];
|
|
5530
5681
|
return typeof ref === "string" && ref.length > 0;
|
|
5531
5682
|
}
|
|
5532
5683
|
function isSecretClear(value) {
|
|
5533
|
-
return isRecord$
|
|
5684
|
+
return isRecord$5(value) && value["$secretClear"] === true;
|
|
5534
5685
|
}
|
|
5535
5686
|
/**
|
|
5536
5687
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
@@ -6140,7 +6291,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6140
6291
|
}
|
|
6141
6292
|
};
|
|
6142
6293
|
var KEEP = { kind: "keep" };
|
|
6143
|
-
function isRecord$
|
|
6294
|
+
function isRecord$4(value) {
|
|
6144
6295
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6145
6296
|
}
|
|
6146
6297
|
function defaultMintId() {
|
|
@@ -6153,7 +6304,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6153
6304
|
return out;
|
|
6154
6305
|
}
|
|
6155
6306
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6156
|
-
else if (isRecord$
|
|
6307
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6157
6308
|
return out;
|
|
6158
6309
|
}
|
|
6159
6310
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -6208,7 +6359,7 @@ function rowId(row, idKey) {
|
|
|
6208
6359
|
return null;
|
|
6209
6360
|
}
|
|
6210
6361
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6211
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
6362
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
6212
6363
|
if (!Array.isArray(incoming)) {
|
|
6213
6364
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6214
6365
|
return {
|
|
@@ -6224,7 +6375,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6224
6375
|
const kept = /* @__PURE__ */ new Set();
|
|
6225
6376
|
const rows = [];
|
|
6226
6377
|
for (const row of incoming) {
|
|
6227
|
-
if (!isRecord$
|
|
6378
|
+
if (!isRecord$4(row)) {
|
|
6228
6379
|
rows.push(row);
|
|
6229
6380
|
continue;
|
|
6230
6381
|
}
|
|
@@ -6249,7 +6400,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6249
6400
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6250
6401
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6251
6402
|
case "object": {
|
|
6252
|
-
if (!isRecord$
|
|
6403
|
+
if (!isRecord$4(incoming)) {
|
|
6253
6404
|
if (incoming === void 0) return KEEP;
|
|
6254
6405
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6255
6406
|
return {
|
|
@@ -6257,7 +6408,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6257
6408
|
value: incoming
|
|
6258
6409
|
};
|
|
6259
6410
|
}
|
|
6260
|
-
const storedObj = isRecord$
|
|
6411
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
6261
6412
|
return {
|
|
6262
6413
|
kind: "value",
|
|
6263
6414
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -6380,7 +6531,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
6380
6531
|
value: items
|
|
6381
6532
|
};
|
|
6382
6533
|
}
|
|
6383
|
-
if (isRecord$
|
|
6534
|
+
if (isRecord$4(v)) {
|
|
6384
6535
|
const out = {};
|
|
6385
6536
|
for (const [k, child] of Object.entries(v)) {
|
|
6386
6537
|
const s = substitute(child);
|
|
@@ -6648,7 +6799,6 @@ function createHandle(raw, opts) {
|
|
|
6648
6799
|
const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
|
|
6649
6800
|
const readAddonStoreResult = raw.readAddonStoreResult;
|
|
6650
6801
|
const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
|
|
6651
|
-
const readDeviceStoreBatch = raw.readDeviceStoreBatch;
|
|
6652
6802
|
const overrides = {
|
|
6653
6803
|
readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
|
|
6654
6804
|
...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
|
|
@@ -6672,12 +6822,12 @@ function createHandle(raw, opts) {
|
|
|
6672
6822
|
};
|
|
6673
6823
|
} } : {},
|
|
6674
6824
|
readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
|
|
6675
|
-
|
|
6676
|
-
const rows = await readDeviceStoreBatch
|
|
6825
|
+
readDeviceStoreBatch: async (deviceIds) => {
|
|
6826
|
+
const rows = await raw.readDeviceStoreBatch(deviceIds);
|
|
6677
6827
|
const out = /* @__PURE__ */ new Map();
|
|
6678
6828
|
for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
|
|
6679
6829
|
return out;
|
|
6680
|
-
}
|
|
6830
|
+
},
|
|
6681
6831
|
writeAddonStore: async (patch) => {
|
|
6682
6832
|
await writeAddon(patch);
|
|
6683
6833
|
},
|
|
@@ -7304,7 +7454,7 @@ var BaseAddon = class {
|
|
|
7304
7454
|
if (!ctx) return;
|
|
7305
7455
|
const addonId = ctx.id;
|
|
7306
7456
|
setImmediate(() => {
|
|
7307
|
-
ctx.api.addons
|
|
7457
|
+
ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
|
|
7308
7458
|
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7309
7459
|
}).catch((err) => {
|
|
7310
7460
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -7504,7 +7654,7 @@ var BaseAddon = class {
|
|
|
7504
7654
|
return this._addonSecretTree;
|
|
7505
7655
|
}
|
|
7506
7656
|
deviceSecretTree() {
|
|
7507
|
-
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7657
|
+
this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
|
|
7508
7658
|
return this._deviceSecretTree;
|
|
7509
7659
|
}
|
|
7510
7660
|
/**
|
|
@@ -7580,42 +7730,135 @@ var BaseAddon = class {
|
|
|
7580
7730
|
this[timerOf] = timer;
|
|
7581
7731
|
}
|
|
7582
7732
|
/**
|
|
7583
|
-
* Wrap `ctx.settings.readAddonStore()` with a
|
|
7584
|
-
*
|
|
7585
|
-
* swap, or any race where the SqliteSettingsBackend is between shutdown and
|
|
7586
|
-
* re-initialize) doesn't propagate up into `initialize()` and leave the
|
|
7733
|
+
* Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
|
|
7734
|
+
* settings-store outage doesn't propagate up into `initialize()` and leave the
|
|
7587
7735
|
* addon permanently broken.
|
|
7588
7736
|
*
|
|
7589
|
-
*
|
|
7590
|
-
*
|
|
7591
|
-
* `
|
|
7737
|
+
* Two kinds of outage, two budgets:
|
|
7738
|
+
* - the store's own restart fingerprints (`SqliteSettingsBackend not
|
|
7739
|
+
* initialized`, `provider not available`): a short budget, then the addon
|
|
7740
|
+
* falls back to `{}` (defaults) - its first successful patch rehydrates;
|
|
7741
|
+
* - a TRANSPORT failure (the hub is restarting while this runner boots:
|
|
7742
|
+
* `discovery deadline exceeded`, `parent could not route`, a refused or
|
|
7743
|
+
* timed-out connection). Since D870 a runner's settings read THROWS instead
|
|
7744
|
+
* of answering `{}`, so without a budget a hub restart ends in a respawn
|
|
7745
|
+
* loop. A long, bounded budget; only after it the error propagates - the
|
|
7746
|
+
* addon never runs on defaults for a store it could not ask.
|
|
7747
|
+
* Anything else propagates immediately so real bugs surface.
|
|
7592
7748
|
*/
|
|
7593
7749
|
async readAddonStoreWithRetry() {
|
|
7594
7750
|
const settings = this.rawSettings();
|
|
7595
7751
|
if (!settings) return {};
|
|
7596
|
-
const delaysMs = [
|
|
7597
|
-
150,
|
|
7598
|
-
350,
|
|
7599
|
-
600,
|
|
7600
|
-
900
|
|
7601
|
-
];
|
|
7602
7752
|
let lastErr;
|
|
7603
|
-
for (let attempt = 0
|
|
7753
|
+
for (let attempt = 0;; attempt++) try {
|
|
7604
7754
|
const stored = await settings.readAddonStore() ?? {};
|
|
7605
7755
|
this.settingsStoreReady = true;
|
|
7606
7756
|
return stored;
|
|
7607
7757
|
} catch (err) {
|
|
7608
7758
|
lastErr = err;
|
|
7609
|
-
const
|
|
7610
|
-
if (
|
|
7611
|
-
|
|
7612
|
-
|
|
7759
|
+
const kind = classifyStoreError(err);
|
|
7760
|
+
if (kind === "permanent") throw err;
|
|
7761
|
+
const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
|
|
7762
|
+
if (delay === void 0) {
|
|
7763
|
+
if (kind === "transport") throw err;
|
|
7764
|
+
break;
|
|
7765
|
+
}
|
|
7766
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
7613
7767
|
}
|
|
7614
7768
|
this.settingsStoreReady = false;
|
|
7615
7769
|
this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
|
|
7616
7770
|
return {};
|
|
7617
7771
|
}
|
|
7618
7772
|
};
|
|
7773
|
+
/** The settings store's own restart fingerprints. */
|
|
7774
|
+
var RESTART_RETRY_DELAYS_MS = [
|
|
7775
|
+
150,
|
|
7776
|
+
350,
|
|
7777
|
+
600,
|
|
7778
|
+
900
|
|
7779
|
+
];
|
|
7780
|
+
/** A hub restarting under a booting runner: ~100 s in total. */
|
|
7781
|
+
var TRANSPORT_RETRY_DELAYS_MS = [
|
|
7782
|
+
150,
|
|
7783
|
+
350,
|
|
7784
|
+
600,
|
|
7785
|
+
900,
|
|
7786
|
+
2e3,
|
|
7787
|
+
5e3,
|
|
7788
|
+
1e4,
|
|
7789
|
+
2e4,
|
|
7790
|
+
3e4,
|
|
7791
|
+
3e4
|
|
7792
|
+
];
|
|
7793
|
+
var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
|
|
7794
|
+
/** Node / socket error codes of a connection that did not happen or broke. */
|
|
7795
|
+
var TRANSPORT_CODES = new Set([
|
|
7796
|
+
"ECONNREFUSED",
|
|
7797
|
+
"ECONNRESET",
|
|
7798
|
+
"ETIMEDOUT",
|
|
7799
|
+
"EPIPE",
|
|
7800
|
+
"EHOSTUNREACH",
|
|
7801
|
+
"ENETUNREACH"
|
|
7802
|
+
]);
|
|
7803
|
+
/** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
|
|
7804
|
+
var UNAVAILABLE_TRPC_CODES = new Set([
|
|
7805
|
+
"TIMEOUT",
|
|
7806
|
+
"SERVICE_UNAVAILABLE",
|
|
7807
|
+
"BAD_GATEWAY",
|
|
7808
|
+
"GATEWAY_TIMEOUT"
|
|
7809
|
+
]);
|
|
7810
|
+
/** The exact phrases OUR transport raises when it cannot reach the hub. */
|
|
7811
|
+
var TRANSPORT_PHRASES = [
|
|
7812
|
+
"discovery deadline exceeded",
|
|
7813
|
+
"parent could not route child unowned cap call",
|
|
7814
|
+
"UDS request timed out after",
|
|
7815
|
+
"channel closed"
|
|
7816
|
+
];
|
|
7817
|
+
/** Moleculer error `type`s of a call that could not be served right now. */
|
|
7818
|
+
var MOLECULER_TRANSIENT_TYPES = new Set([
|
|
7819
|
+
"REQUEST_TIMEOUT",
|
|
7820
|
+
"SERVICE_NOT_FOUND",
|
|
7821
|
+
"SERVICE_NOT_AVAILABLE",
|
|
7822
|
+
"REQUEST_REJECTED",
|
|
7823
|
+
"BROKER_DISCONNECTED"
|
|
7824
|
+
]);
|
|
7825
|
+
function stringProp(value, key) {
|
|
7826
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
7827
|
+
const found = Reflect.get(value, key);
|
|
7828
|
+
return typeof found === "string" ? found : void 0;
|
|
7829
|
+
}
|
|
7830
|
+
/** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
|
|
7831
|
+
function errorCode(err) {
|
|
7832
|
+
const out = {};
|
|
7833
|
+
const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
|
|
7834
|
+
const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
|
|
7835
|
+
const node = stringProp(err, "code") ?? stringProp(cause, "code");
|
|
7836
|
+
if (node !== void 0) out.node = node;
|
|
7837
|
+
const trpc = stringProp(data, "code");
|
|
7838
|
+
if (trpc !== void 0) out.trpc = trpc;
|
|
7839
|
+
return out;
|
|
7840
|
+
}
|
|
7841
|
+
/**
|
|
7842
|
+
* Is a settings read failure worth retrying, and with which budget? Only
|
|
7843
|
+
* EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
|
|
7844
|
+
* one of the exact phrases our own transport raises. A message that merely
|
|
7845
|
+
* contains "timed out" or "unreachable" is not evidence of anything, and
|
|
7846
|
+
* `settings store not wired` is a wiring bug that retrying cannot fix.
|
|
7847
|
+
*/
|
|
7848
|
+
function classifyStoreError(err) {
|
|
7849
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7850
|
+
if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
|
|
7851
|
+
const code = errorCode(err);
|
|
7852
|
+
if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
|
|
7853
|
+
if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
|
|
7854
|
+
if (typeof err === "object" && err !== null) {
|
|
7855
|
+
if (Reflect.get(err, "retryable") === true) return "transport";
|
|
7856
|
+
const type = stringProp(err, "type");
|
|
7857
|
+
if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
|
|
7858
|
+
}
|
|
7859
|
+
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
7860
|
+
return "permanent";
|
|
7861
|
+
}
|
|
7619
7862
|
/**
|
|
7620
7863
|
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
7621
7864
|
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
@@ -7705,6 +7948,356 @@ var PeerBytesTicketSchema = object({
|
|
|
7705
7948
|
*/
|
|
7706
7949
|
declaredBytes: number().int().nonnegative().nullable()
|
|
7707
7950
|
});
|
|
7951
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7952
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7953
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7954
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7955
|
+
var RECORD_CLASSES = [
|
|
7956
|
+
"config",
|
|
7957
|
+
"ledger",
|
|
7958
|
+
"audit",
|
|
7959
|
+
"mirror",
|
|
7960
|
+
"ephemeral"
|
|
7961
|
+
];
|
|
7962
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
7963
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
7964
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
7965
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
7966
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
7967
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7968
|
+
var PREFIX = "records/";
|
|
7969
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
7970
|
+
var RecordsError = class extends Error {
|
|
7971
|
+
code;
|
|
7972
|
+
detail;
|
|
7973
|
+
constructor(code, detail) {
|
|
7974
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
7975
|
+
this.name = "RecordsError";
|
|
7976
|
+
this.code = code;
|
|
7977
|
+
this.detail = detail;
|
|
7978
|
+
}
|
|
7979
|
+
};
|
|
7980
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
7981
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
7982
|
+
constructor(detail) {
|
|
7983
|
+
super("secret-unavailable", detail);
|
|
7984
|
+
this.name = "RecordSecretUnavailableError";
|
|
7985
|
+
}
|
|
7986
|
+
};
|
|
7987
|
+
var InvalidRecordError = class extends RecordsError {
|
|
7988
|
+
constructor(detail) {
|
|
7989
|
+
super("invalid-record", detail);
|
|
7990
|
+
this.name = "InvalidRecordError";
|
|
7991
|
+
}
|
|
7992
|
+
};
|
|
7993
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
7994
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
7995
|
+
constructor(detail) {
|
|
7996
|
+
super("declaration-refused", detail);
|
|
7997
|
+
this.name = "DeclarationRefusedError";
|
|
7998
|
+
}
|
|
7999
|
+
};
|
|
8000
|
+
function defOf(schema) {
|
|
8001
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8002
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8003
|
+
const def = Reflect.get(zodBag, "def");
|
|
8004
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8005
|
+
return def;
|
|
8006
|
+
}
|
|
8007
|
+
function declaredHere(schema) {
|
|
8008
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8009
|
+
}
|
|
8010
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8011
|
+
var WRAPPERS = new Set([
|
|
8012
|
+
"optional",
|
|
8013
|
+
"nullable",
|
|
8014
|
+
"default",
|
|
8015
|
+
"prefault",
|
|
8016
|
+
"catch",
|
|
8017
|
+
"readonly",
|
|
8018
|
+
"nonoptional"
|
|
8019
|
+
]);
|
|
8020
|
+
/**
|
|
8021
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8022
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8023
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8024
|
+
* `.transform` on `in`).
|
|
8025
|
+
*/
|
|
8026
|
+
function layersOf(schema) {
|
|
8027
|
+
const out = [];
|
|
8028
|
+
const queue = [schema];
|
|
8029
|
+
while (queue.length > 0) {
|
|
8030
|
+
const s = queue.shift();
|
|
8031
|
+
if (!s || out.includes(s)) continue;
|
|
8032
|
+
out.push(s);
|
|
8033
|
+
const def = defOf(s);
|
|
8034
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8035
|
+
if (def.type === "pipe") {
|
|
8036
|
+
if (def.in) queue.push(def.in);
|
|
8037
|
+
if (def.out) queue.push(def.out);
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
return out;
|
|
8041
|
+
}
|
|
8042
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8043
|
+
function isZodSecret(schema) {
|
|
8044
|
+
return layersOf(schema).some(declaredHere);
|
|
8045
|
+
}
|
|
8046
|
+
/**
|
|
8047
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8048
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8049
|
+
* object or array is reported as one path and not descended into — everything
|
|
8050
|
+
* under it is secret.
|
|
8051
|
+
*/
|
|
8052
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8053
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8054
|
+
const paths = [];
|
|
8055
|
+
for (const layer of layersOf(schema)) {
|
|
8056
|
+
const def = defOf(layer);
|
|
8057
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8058
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8059
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8060
|
+
else if (def.type === "intersection") {
|
|
8061
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8062
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8063
|
+
}
|
|
8064
|
+
}
|
|
8065
|
+
return [...new Set(paths)];
|
|
8066
|
+
}
|
|
8067
|
+
/**
|
|
8068
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8069
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8070
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8071
|
+
*
|
|
8072
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8073
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8074
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8075
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8076
|
+
*
|
|
8077
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8078
|
+
*/
|
|
8079
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8080
|
+
function parseSecretPath(path) {
|
|
8081
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8082
|
+
return path.split(".").map((raw) => {
|
|
8083
|
+
const each = raw.endsWith("[]");
|
|
8084
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8085
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8086
|
+
return {
|
|
8087
|
+
key,
|
|
8088
|
+
each
|
|
8089
|
+
};
|
|
8090
|
+
});
|
|
8091
|
+
}
|
|
8092
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8093
|
+
function secretArrayPrefixes(path) {
|
|
8094
|
+
const segments = parseSecretPath(path);
|
|
8095
|
+
const prefixes = [];
|
|
8096
|
+
const walked = [];
|
|
8097
|
+
for (const segment of segments) {
|
|
8098
|
+
walked.push(segment.key);
|
|
8099
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8100
|
+
}
|
|
8101
|
+
return prefixes;
|
|
8102
|
+
}
|
|
8103
|
+
/**
|
|
8104
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8105
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8106
|
+
* JSON the engine stores.
|
|
8107
|
+
*
|
|
8108
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
8109
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
8110
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
8111
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
8112
|
+
* never a field name (D879).
|
|
8113
|
+
*/
|
|
8114
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
8115
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
8116
|
+
var RecordIndexSchema = object({
|
|
8117
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
8118
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
8119
|
+
unique: boolean().optional()
|
|
8120
|
+
}).strict();
|
|
8121
|
+
var RecordRetentionSchema = union([
|
|
8122
|
+
object({
|
|
8123
|
+
ttlMs: number().int().positive(),
|
|
8124
|
+
from: _enum(["at", "write"])
|
|
8125
|
+
}).strict(),
|
|
8126
|
+
object({
|
|
8127
|
+
maxRows: number().int().positive().optional(),
|
|
8128
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
8129
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
8130
|
+
object({
|
|
8131
|
+
owner: string().min(1),
|
|
8132
|
+
reason: string().min(1)
|
|
8133
|
+
}).strict(),
|
|
8134
|
+
object({ none: string().min(1) }).strict()
|
|
8135
|
+
]);
|
|
8136
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
8137
|
+
var EntryDescriptorSchema = object({
|
|
8138
|
+
title: string().min(1),
|
|
8139
|
+
/** The record body field shown as the entry's name. */
|
|
8140
|
+
nameField: string().min(1),
|
|
8141
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
8142
|
+
fields: record(string(), unknown())
|
|
8143
|
+
}).strict();
|
|
8144
|
+
/** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
|
|
8145
|
+
var RecordKindDeclarationSchema = object({
|
|
8146
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
8147
|
+
class: _enum(RECORD_CLASSES),
|
|
8148
|
+
writeTrigger: string().min(1),
|
|
8149
|
+
device: _enum([
|
|
8150
|
+
"required",
|
|
8151
|
+
"optional",
|
|
8152
|
+
"none"
|
|
8153
|
+
]).default("none"),
|
|
8154
|
+
at: _enum(["required", "none"]).default("none"),
|
|
8155
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
8156
|
+
retention: RecordRetentionSchema,
|
|
8157
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
8158
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
8159
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
8160
|
+
secretPaths: array(string().min(1)).default([]),
|
|
8161
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
8162
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
8163
|
+
/** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
|
|
8164
|
+
adoptsFrom: string().min(1).optional(),
|
|
8165
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
8166
|
+
transactFamily: string().min(1).optional(),
|
|
8167
|
+
entry: EntryDescriptorSchema.optional()
|
|
8168
|
+
}).strict();
|
|
8169
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8170
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
8171
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
8172
|
+
function assertValidDeclaration(name, decl) {
|
|
8173
|
+
const refuse = (why) => {
|
|
8174
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
8175
|
+
};
|
|
8176
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
8177
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8178
|
+
for (const index of decl.indexes) {
|
|
8179
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
8180
|
+
seen.add(index.name);
|
|
8181
|
+
}
|
|
8182
|
+
const { retention } = decl;
|
|
8183
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
8184
|
+
if ("ttlMs" in retention) {
|
|
8185
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
8186
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
8187
|
+
}
|
|
8188
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
8189
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
8190
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
8191
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
8192
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
8193
|
+
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)`);
|
|
8194
|
+
}
|
|
8195
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
8196
|
+
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`);
|
|
8197
|
+
}
|
|
8198
|
+
function bodyFieldsOf(schema) {
|
|
8199
|
+
return { ...toJSONSchema(schema, {
|
|
8200
|
+
unrepresentable: "any",
|
|
8201
|
+
io: "input"
|
|
8202
|
+
}) };
|
|
8203
|
+
}
|
|
8204
|
+
function isRecordLike(value) {
|
|
8205
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8206
|
+
}
|
|
8207
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
8208
|
+
function hasNameField(json, field) {
|
|
8209
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
8210
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
8211
|
+
const properties = json["properties"];
|
|
8212
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
8213
|
+
}
|
|
8214
|
+
/**
|
|
8215
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
8216
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
8217
|
+
* types its handle from.
|
|
8218
|
+
*/
|
|
8219
|
+
function defineRecordKinds(specs) {
|
|
8220
|
+
const out = {};
|
|
8221
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
8222
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
8223
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
8224
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
8225
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
8226
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
8227
|
+
database: spec.database,
|
|
8228
|
+
class: spec.class,
|
|
8229
|
+
writeTrigger: spec.writeTrigger,
|
|
8230
|
+
device: spec.device,
|
|
8231
|
+
at: spec.at,
|
|
8232
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
8233
|
+
retention: spec.retention,
|
|
8234
|
+
deviceRemoval: spec.deviceRemoval,
|
|
8235
|
+
maxDataBytes: spec.maxDataBytes,
|
|
8236
|
+
secretPaths: [...secretPaths],
|
|
8237
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
8238
|
+
adoptsFrom: spec.adoptsFrom,
|
|
8239
|
+
transactFamily: spec.transactFamily,
|
|
8240
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
8241
|
+
title: spec.entry.title,
|
|
8242
|
+
nameField,
|
|
8243
|
+
fields
|
|
8244
|
+
}
|
|
8245
|
+
});
|
|
8246
|
+
assertValidDeclaration(name, parsed);
|
|
8247
|
+
out[name] = {
|
|
8248
|
+
name,
|
|
8249
|
+
schema: spec.schema,
|
|
8250
|
+
declaration: parsed
|
|
8251
|
+
};
|
|
8252
|
+
}
|
|
8253
|
+
return out;
|
|
8254
|
+
}
|
|
8255
|
+
/**
|
|
8256
|
+
* Entry kinds (D881): every list of user-created entries (notification
|
|
8257
|
+
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
8258
|
+
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
8259
|
+
* through the `record-entries` capability with password fields derived from
|
|
8260
|
+
* the schema (`.meta({ secret: true })`).
|
|
8261
|
+
*/
|
|
8262
|
+
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
8263
|
+
function entryBody(shape) {
|
|
8264
|
+
return object({
|
|
8265
|
+
name: string().min(1),
|
|
8266
|
+
...shape
|
|
8267
|
+
});
|
|
8268
|
+
}
|
|
8269
|
+
/**
|
|
8270
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
8271
|
+
* engine, never aged, belonging to no device.
|
|
8272
|
+
*/
|
|
8273
|
+
function defineEntryKind(name, spec) {
|
|
8274
|
+
const defined = defineRecordKinds({ [name]: {
|
|
8275
|
+
schema: spec.schema,
|
|
8276
|
+
class: "config",
|
|
8277
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
8278
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
8279
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
8280
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
8281
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
8282
|
+
...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
|
|
8283
|
+
entry: {
|
|
8284
|
+
title: spec.title,
|
|
8285
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
8286
|
+
}
|
|
8287
|
+
} })[name];
|
|
8288
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
8289
|
+
return defined;
|
|
8290
|
+
}
|
|
8291
|
+
/**
|
|
8292
|
+
* Legacy source for broker entry adoption (B2): brokers live in addon-settings
|
|
8293
|
+
* as one row `<addonId>.brokers` whose value is an array until records-adopt
|
|
8294
|
+
* copies them into the entry kind.
|
|
8295
|
+
*/
|
|
8296
|
+
var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
|
|
8297
|
+
/** The `adoptsFrom` value for an addon's broker entry kind. */
|
|
8298
|
+
function settingsBrokersAdoptsFrom(addonId) {
|
|
8299
|
+
return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
|
|
8300
|
+
}
|
|
7708
8301
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
7709
8302
|
var CamProfileSchema = _enum([
|
|
7710
8303
|
"high",
|
|
@@ -8169,75 +8762,12 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
|
|
|
8169
8762
|
kind: "mutation",
|
|
8170
8763
|
auth: "admin"
|
|
8171
8764
|
}), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
|
|
8172
|
-
function defOf(schema) {
|
|
8173
|
-
return schema._zod?.def ?? {};
|
|
8174
|
-
}
|
|
8175
|
-
function declaredHere(schema) {
|
|
8176
|
-
return globalRegistry.get(schema)?.secret === true;
|
|
8177
|
-
}
|
|
8178
|
-
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8179
|
-
var WRAPPERS = new Set([
|
|
8180
|
-
"optional",
|
|
8181
|
-
"nullable",
|
|
8182
|
-
"default",
|
|
8183
|
-
"prefault",
|
|
8184
|
-
"catch",
|
|
8185
|
-
"readonly",
|
|
8186
|
-
"nonoptional"
|
|
8187
|
-
]);
|
|
8188
|
-
/**
|
|
8189
|
-
* The schema layers that make up ONE field: the schema itself and every
|
|
8190
|
-
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8191
|
-
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8192
|
-
* `.transform` on `in`).
|
|
8193
|
-
*/
|
|
8194
|
-
function layersOf(schema) {
|
|
8195
|
-
const out = [];
|
|
8196
|
-
const queue = [schema];
|
|
8197
|
-
while (queue.length > 0) {
|
|
8198
|
-
const s = queue.shift();
|
|
8199
|
-
if (!s || out.includes(s)) continue;
|
|
8200
|
-
out.push(s);
|
|
8201
|
-
const def = defOf(s);
|
|
8202
|
-
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8203
|
-
if (def.type === "pipe") {
|
|
8204
|
-
if (def.in) queue.push(def.in);
|
|
8205
|
-
if (def.out) queue.push(def.out);
|
|
8206
|
-
}
|
|
8207
|
-
}
|
|
8208
|
-
return out;
|
|
8209
|
-
}
|
|
8210
|
-
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8211
|
-
function isZodSecret(schema) {
|
|
8212
|
-
return layersOf(schema).some(declaredHere);
|
|
8213
|
-
}
|
|
8214
|
-
/**
|
|
8215
|
-
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8216
|
-
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8217
|
-
* object or array is reported as one path and not descended into — everything
|
|
8218
|
-
* under it is secret.
|
|
8219
|
-
*/
|
|
8220
|
-
function collectZodSecretPaths(schema, prefix = "") {
|
|
8221
|
-
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8222
|
-
const paths = [];
|
|
8223
|
-
for (const layer of layersOf(schema)) {
|
|
8224
|
-
const def = defOf(layer);
|
|
8225
|
-
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8226
|
-
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8227
|
-
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8228
|
-
else if (def.type === "intersection") {
|
|
8229
|
-
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8230
|
-
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8231
|
-
}
|
|
8232
|
-
}
|
|
8233
|
-
return [...new Set(paths)];
|
|
8234
|
-
}
|
|
8235
8765
|
object({
|
|
8236
8766
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
8237
8767
|
params: record(string(), union([string(), number()])).optional()
|
|
8238
8768
|
});
|
|
8239
8769
|
//#endregion
|
|
8240
|
-
//#region ../types/dist/err-msg
|
|
8770
|
+
//#region ../types/dist/err-msg--2RrYiLO.mjs
|
|
8241
8771
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
8242
8772
|
DeviceType["Camera"] = "camera";
|
|
8243
8773
|
DeviceType["Hub"] = "hub";
|
|
@@ -8506,6 +9036,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8506
9036
|
/** Virtual HA toggle (input_boolean.*) — distinguishable from a
|
|
8507
9037
|
* real Switch device for UI rendering / export adapters. */
|
|
8508
9038
|
DeviceRole["BinaryHelper"] = "binary-helper";
|
|
9039
|
+
/** A smart plug: a `switch` whose source says it is an outlet (HA
|
|
9040
|
+
* `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
|
|
9041
|
+
DeviceRole["Outlet"] = "outlet";
|
|
8509
9042
|
/** Generic motion / occupancy / moving event source. Distinct from
|
|
8510
9043
|
* the camera accessory PirSensor role: that one is a camera child;
|
|
8511
9044
|
* this is a standalone HA / 3rd-party motion sensor. */
|
|
@@ -8583,7 +9116,7 @@ function errMsg(err) {
|
|
|
8583
9116
|
return String(err);
|
|
8584
9117
|
}
|
|
8585
9118
|
//#endregion
|
|
8586
|
-
//#region ../types/dist/composition-
|
|
9119
|
+
//#region ../types/dist/composition-DOwQB_Ua.mjs
|
|
8587
9120
|
/**
|
|
8588
9121
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
8589
9122
|
*
|
|
@@ -11787,11 +12320,10 @@ var ClipModelMetaSchema = object({
|
|
|
11787
12320
|
/**
|
|
11788
12321
|
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
11789
12322
|
* per index: two models share an index only when their vectors are ranked
|
|
11790
|
-
* against each other, which for CLIP means never across families.
|
|
11791
|
-
*
|
|
11792
|
-
* `modelId`); any other model gets its own.
|
|
12323
|
+
* against each other, which for CLIP means never across families. Every
|
|
12324
|
+
* model gets its own.
|
|
11793
12325
|
*/
|
|
11794
|
-
vectorIndex: string().regex(/^object-clip
|
|
12326
|
+
vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
11795
12327
|
/**
|
|
11796
12328
|
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
11797
12329
|
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
@@ -15573,6 +16105,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
15573
16105
|
keyField: string()
|
|
15574
16106
|
}).optional()
|
|
15575
16107
|
})) });
|
|
16108
|
+
/**
|
|
16109
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
16110
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
16111
|
+
*
|
|
16112
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
16113
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
16114
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
16115
|
+
*/
|
|
16116
|
+
var RawSecretMigrationInputSchema = object({
|
|
16117
|
+
/** `false` (the default of the script) = report only. */
|
|
16118
|
+
apply: boolean() });
|
|
16119
|
+
var RawSecretMigrationReportSchema = object({
|
|
16120
|
+
apply: boolean(),
|
|
16121
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
16122
|
+
rows: number().int(),
|
|
16123
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
16124
|
+
raw: number().int(),
|
|
16125
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
16126
|
+
markers: number().int(),
|
|
16127
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
16128
|
+
migrated: number().int(),
|
|
16129
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
16130
|
+
failed: number().int(),
|
|
16131
|
+
/** After the run: rows still holding plaintext. */
|
|
16132
|
+
remainingRaw: number().int(),
|
|
16133
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
16134
|
+
unresolvedMarkers: number().int(),
|
|
16135
|
+
/**
|
|
16136
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
16137
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
16138
|
+
*/
|
|
16139
|
+
redundantCopies: number().int().optional(),
|
|
16140
|
+
/** True when nothing is raw and every marker resolves. */
|
|
16141
|
+
verified: boolean()
|
|
16142
|
+
});
|
|
15576
16143
|
/** Where a block runs. The operator chooses — a block driving a device on an
|
|
15577
16144
|
* agent is the reason placement is not fixed to the hub. */
|
|
15578
16145
|
var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
|
|
@@ -15799,6 +16366,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
15799
16366
|
}), SettingsUpdateResultSchema, {
|
|
15800
16367
|
kind: "mutation",
|
|
15801
16368
|
auth: "admin"
|
|
16369
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
16370
|
+
kind: "mutation",
|
|
16371
|
+
auth: "admin"
|
|
15802
16372
|
}), method(object({}), object({ libs: array(object({
|
|
15803
16373
|
filePath: string(),
|
|
15804
16374
|
content: string()
|
|
@@ -16062,6 +16632,347 @@ id: union([string(), number()]) }), {
|
|
|
16062
16632
|
auth: "admin"
|
|
16063
16633
|
});
|
|
16064
16634
|
/**
|
|
16635
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
16636
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
16637
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
16638
|
+
*
|
|
16639
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
16640
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
16641
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
16642
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
16643
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
16644
|
+
* addons go through the owner's capability.
|
|
16645
|
+
*
|
|
16646
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
16647
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
16648
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
16649
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
16650
|
+
* row's own ref.
|
|
16651
|
+
*
|
|
16652
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
16653
|
+
*/
|
|
16654
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
16655
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
16656
|
+
var RecordBodySchema = record(string(), unknown());
|
|
16657
|
+
var RecordInputSchema = object({
|
|
16658
|
+
id: RecordIdSchema,
|
|
16659
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
16660
|
+
deviceId: number().int().optional(),
|
|
16661
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
16662
|
+
at: number().int().optional(),
|
|
16663
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
16664
|
+
expiresAt: number().int().optional(),
|
|
16665
|
+
data: RecordBodySchema
|
|
16666
|
+
});
|
|
16667
|
+
var RecordViewSchema = object({
|
|
16668
|
+
id: string(),
|
|
16669
|
+
deviceId: number().int().nullable(),
|
|
16670
|
+
at: number().nullable(),
|
|
16671
|
+
expiresAt: number().nullable(),
|
|
16672
|
+
rev: number().int(),
|
|
16673
|
+
updatedAt: number(),
|
|
16674
|
+
data: RecordBodySchema
|
|
16675
|
+
});
|
|
16676
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
16677
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
16678
|
+
string(),
|
|
16679
|
+
number(),
|
|
16680
|
+
boolean(),
|
|
16681
|
+
object({ in: array(union([
|
|
16682
|
+
string(),
|
|
16683
|
+
number(),
|
|
16684
|
+
boolean()
|
|
16685
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
16686
|
+
object({
|
|
16687
|
+
gt: union([string(), number()]).optional(),
|
|
16688
|
+
gte: union([string(), number()]).optional(),
|
|
16689
|
+
lt: union([string(), number()]).optional(),
|
|
16690
|
+
lte: union([string(), number()]).optional()
|
|
16691
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
16692
|
+
]));
|
|
16693
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
16694
|
+
var TimeWindowShape = {
|
|
16695
|
+
deviceId: number().int().optional(),
|
|
16696
|
+
atFrom: number().optional(),
|
|
16697
|
+
atTo: number().optional()
|
|
16698
|
+
};
|
|
16699
|
+
var RecordQueryInputSchema = object({
|
|
16700
|
+
...KindShape,
|
|
16701
|
+
...TimeWindowShape,
|
|
16702
|
+
where: RecordWhereSchema.optional(),
|
|
16703
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
16704
|
+
order: _enum(["at", "id"]).optional(),
|
|
16705
|
+
desc: boolean().optional(),
|
|
16706
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
16707
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
16708
|
+
cursor: string().min(1).optional()
|
|
16709
|
+
});
|
|
16710
|
+
var RecordQueryResultSchema = object({
|
|
16711
|
+
records: array(RecordViewSchema),
|
|
16712
|
+
nextCursor: string().nullable()
|
|
16713
|
+
});
|
|
16714
|
+
var RecordKindStateSchema = _enum([
|
|
16715
|
+
"created",
|
|
16716
|
+
"unchanged",
|
|
16717
|
+
"updated"
|
|
16718
|
+
]);
|
|
16719
|
+
var DeclareKindResultSchema = object({
|
|
16720
|
+
kindId: number().int(),
|
|
16721
|
+
state: RecordKindStateSchema,
|
|
16722
|
+
createdIndexes: array(string()),
|
|
16723
|
+
/** The boot guard: the kind is empty while its legacy table still holds rows. */
|
|
16724
|
+
adoptionPending: object({
|
|
16725
|
+
legacyTable: string(),
|
|
16726
|
+
legacyRows: number().int()
|
|
16727
|
+
}).nullable()
|
|
16728
|
+
});
|
|
16729
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
16730
|
+
var SecretRefsList = array(string());
|
|
16731
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
16732
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
16733
|
+
kind: "mutation",
|
|
16734
|
+
auth: "admin"
|
|
16735
|
+
}), method(object({
|
|
16736
|
+
...KindShape,
|
|
16737
|
+
id: RecordIdSchema
|
|
16738
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
16739
|
+
...KindShape,
|
|
16740
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16741
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
16742
|
+
...KindShape,
|
|
16743
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16744
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
16745
|
+
...KindShape,
|
|
16746
|
+
record: RecordInputSchema,
|
|
16747
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
16748
|
+
ifRev: number().int().min(0).optional()
|
|
16749
|
+
}), object({
|
|
16750
|
+
rev: number().int(),
|
|
16751
|
+
releasedRefs: SecretRefsList
|
|
16752
|
+
}), {
|
|
16753
|
+
kind: "mutation",
|
|
16754
|
+
auth: "admin"
|
|
16755
|
+
}), method(object({
|
|
16756
|
+
...KindShape,
|
|
16757
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16758
|
+
}), object({
|
|
16759
|
+
count: number().int(),
|
|
16760
|
+
releasedRefs: SecretRefsList
|
|
16761
|
+
}), {
|
|
16762
|
+
kind: "mutation",
|
|
16763
|
+
auth: "admin"
|
|
16764
|
+
}), method(object({
|
|
16765
|
+
...KindShape,
|
|
16766
|
+
id: RecordIdSchema,
|
|
16767
|
+
data: RecordBodySchema,
|
|
16768
|
+
at: number().int().nullable().optional(),
|
|
16769
|
+
expiresAt: number().int().nullable().optional(),
|
|
16770
|
+
ifRev: number().int().min(1).optional()
|
|
16771
|
+
}), object({
|
|
16772
|
+
rev: number().int(),
|
|
16773
|
+
releasedRefs: SecretRefsList
|
|
16774
|
+
}), {
|
|
16775
|
+
kind: "mutation",
|
|
16776
|
+
auth: "admin"
|
|
16777
|
+
}), method(object({
|
|
16778
|
+
...KindShape,
|
|
16779
|
+
id: RecordIdSchema
|
|
16780
|
+
}), object({
|
|
16781
|
+
deleted: boolean(),
|
|
16782
|
+
secretRefs: SecretRefsList
|
|
16783
|
+
}), {
|
|
16784
|
+
kind: "mutation",
|
|
16785
|
+
auth: "admin"
|
|
16786
|
+
}), method(object({
|
|
16787
|
+
...KindShape,
|
|
16788
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16789
|
+
}), object({
|
|
16790
|
+
deleted: number().int(),
|
|
16791
|
+
secretRefs: SecretRefsList
|
|
16792
|
+
}), {
|
|
16793
|
+
kind: "mutation",
|
|
16794
|
+
auth: "admin"
|
|
16795
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16796
|
+
...KindShape,
|
|
16797
|
+
...TimeWindowShape,
|
|
16798
|
+
where: RecordWhereSchema.optional()
|
|
16799
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
16800
|
+
...KindShape,
|
|
16801
|
+
deviceId: number().int().optional(),
|
|
16802
|
+
from: number(),
|
|
16803
|
+
to: number(),
|
|
16804
|
+
bucketMs: number().int().positive()
|
|
16805
|
+
}), object({ buckets: array(object({
|
|
16806
|
+
bucketStart: number(),
|
|
16807
|
+
count: number().int()
|
|
16808
|
+
})) }), { auth: "admin" }), method(object({
|
|
16809
|
+
...KindShape,
|
|
16810
|
+
op: _enum([
|
|
16811
|
+
"sum",
|
|
16812
|
+
"min",
|
|
16813
|
+
"max",
|
|
16814
|
+
"count"
|
|
16815
|
+
]),
|
|
16816
|
+
field: RecordFieldPathSchema.optional(),
|
|
16817
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
16818
|
+
where: RecordWhereSchema.optional()
|
|
16819
|
+
}), object({ rows: array(object({
|
|
16820
|
+
group: union([
|
|
16821
|
+
string(),
|
|
16822
|
+
number(),
|
|
16823
|
+
_null()
|
|
16824
|
+
]),
|
|
16825
|
+
value: number().nullable()
|
|
16826
|
+
})) }), { auth: "admin" }), method(object({
|
|
16827
|
+
...KindShape,
|
|
16828
|
+
deviceId: number().int().optional(),
|
|
16829
|
+
atBefore: number().optional(),
|
|
16830
|
+
where: RecordWhereSchema.optional()
|
|
16831
|
+
}), object({
|
|
16832
|
+
deleted: number().int(),
|
|
16833
|
+
secretRefs: SecretRefsList
|
|
16834
|
+
}), {
|
|
16835
|
+
kind: "mutation",
|
|
16836
|
+
auth: "admin"
|
|
16837
|
+
}), method(object({
|
|
16838
|
+
deviceId: number().int(),
|
|
16839
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
16840
|
+
}), object({
|
|
16841
|
+
deleted: record(string(), number().int()),
|
|
16842
|
+
secretRefs: SecretRefsList
|
|
16843
|
+
}), {
|
|
16844
|
+
kind: "mutation",
|
|
16845
|
+
auth: "admin"
|
|
16846
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
16847
|
+
kind: "mutation",
|
|
16848
|
+
auth: "admin"
|
|
16849
|
+
});
|
|
16850
|
+
/** One table of the settings database. */
|
|
16851
|
+
var StorageTableSchema = object({
|
|
16852
|
+
/** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
|
|
16853
|
+
name: string(),
|
|
16854
|
+
/** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
|
|
16855
|
+
owner: string().nullable(),
|
|
16856
|
+
rows: number().int().nonnegative(),
|
|
16857
|
+
/** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
|
|
16858
|
+
bytes: number().int().nonnegative().nullable(),
|
|
16859
|
+
/** Declared by an addon since this engine process started (a running addon claims it). */
|
|
16860
|
+
declaredThisBoot: boolean()
|
|
16861
|
+
});
|
|
16862
|
+
/** One declared record kind (D881) as System -> Data shows it. */
|
|
16863
|
+
var StorageKindSchema = object({
|
|
16864
|
+
owner: string(),
|
|
16865
|
+
kind: string(),
|
|
16866
|
+
database: _enum(["settings", "events"]),
|
|
16867
|
+
class: string(),
|
|
16868
|
+
state: _enum([
|
|
16869
|
+
"declared",
|
|
16870
|
+
"orphaned",
|
|
16871
|
+
"dropped"
|
|
16872
|
+
]),
|
|
16873
|
+
/** `null` when the caller asked for no counts (`counts: false`). */
|
|
16874
|
+
rows: number().int().nonnegative().nullable(),
|
|
16875
|
+
/** Rows x the average size of a sample; null for an empty kind. */
|
|
16876
|
+
bytesEstimate: number().int().nonnegative().nullable(),
|
|
16877
|
+
writeTrigger: string(),
|
|
16878
|
+
retention: RecordRetentionSchema,
|
|
16879
|
+
/** `true` when the kind is an entry kind (the generic entries UI lists it). */
|
|
16880
|
+
entry: boolean(),
|
|
16881
|
+
/** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
|
|
16882
|
+
declaration: RecordKindDeclarationSchema
|
|
16883
|
+
});
|
|
16884
|
+
method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
|
|
16885
|
+
collection: string().min(1),
|
|
16886
|
+
expectRows: number().int().nonnegative()
|
|
16887
|
+
}), object({
|
|
16888
|
+
dropped: literal(true),
|
|
16889
|
+
rows: number().int().nonnegative()
|
|
16890
|
+
}), {
|
|
16891
|
+
kind: "mutation",
|
|
16892
|
+
auth: "admin"
|
|
16893
|
+
}), method(object({
|
|
16894
|
+
owner: string().min(1).optional(),
|
|
16895
|
+
/** `false` skips the per-kind row count (a catalog read only). Default true. */
|
|
16896
|
+
counts: boolean().optional()
|
|
16897
|
+
}), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
|
|
16898
|
+
owner: string().min(1),
|
|
16899
|
+
kind: RecordKindNameSchema
|
|
16900
|
+
}), RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16901
|
+
owner: string().min(1),
|
|
16902
|
+
kind: RecordKindNameSchema,
|
|
16903
|
+
records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
16904
|
+
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
16905
|
+
complete: boolean().optional()
|
|
16906
|
+
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
|
|
16907
|
+
kind: "mutation",
|
|
16908
|
+
auth: "admin"
|
|
16909
|
+
}), method(object({
|
|
16910
|
+
collection: string().min(1),
|
|
16911
|
+
cursor: string().optional(),
|
|
16912
|
+
limit: number().int().min(1).max(1e3).optional()
|
|
16913
|
+
}), object({
|
|
16914
|
+
rows: array(object({
|
|
16915
|
+
id: string(),
|
|
16916
|
+
data: record(string(), unknown())
|
|
16917
|
+
})),
|
|
16918
|
+
nextCursor: string().nullable()
|
|
16919
|
+
}), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
|
|
16920
|
+
/**
|
|
16921
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
16922
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
16923
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
16924
|
+
*
|
|
16925
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
16926
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
16927
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
16928
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16929
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
16930
|
+
* a secret value, and a locked keychain refuses the write with
|
|
16931
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
16932
|
+
*
|
|
16933
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
16934
|
+
*/
|
|
16935
|
+
var EntryKindInfoSchema = object({
|
|
16936
|
+
owner: string(),
|
|
16937
|
+
kind: RecordKindNameSchema,
|
|
16938
|
+
title: string(),
|
|
16939
|
+
nameField: string(),
|
|
16940
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
16941
|
+
fields: record(string(), unknown()),
|
|
16942
|
+
secretPaths: array(string()),
|
|
16943
|
+
rows: number().int().nonnegative()
|
|
16944
|
+
});
|
|
16945
|
+
var EntryViewSchema = object({
|
|
16946
|
+
id: RecordIdSchema,
|
|
16947
|
+
name: string(),
|
|
16948
|
+
rev: number().int(),
|
|
16949
|
+
updatedAt: number(),
|
|
16950
|
+
/** Secret fields hold the redaction token. */
|
|
16951
|
+
data: RecordBodySchema
|
|
16952
|
+
});
|
|
16953
|
+
var EntryAddress = {
|
|
16954
|
+
owner: string().min(1),
|
|
16955
|
+
kind: RecordKindNameSchema
|
|
16956
|
+
};
|
|
16957
|
+
method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
|
|
16958
|
+
...EntryAddress,
|
|
16959
|
+
id: RecordIdSchema.optional(),
|
|
16960
|
+
data: RecordBodySchema,
|
|
16961
|
+
ifRev: number().int().min(1).optional()
|
|
16962
|
+
}), object({
|
|
16963
|
+
id: string(),
|
|
16964
|
+
rev: number().int()
|
|
16965
|
+
}), {
|
|
16966
|
+
kind: "mutation",
|
|
16967
|
+
auth: "admin"
|
|
16968
|
+
}), method(object({
|
|
16969
|
+
...EntryAddress,
|
|
16970
|
+
id: RecordIdSchema
|
|
16971
|
+
}), object({ deleted: boolean() }), {
|
|
16972
|
+
kind: "mutation",
|
|
16973
|
+
auth: "admin"
|
|
16974
|
+
});
|
|
16975
|
+
/**
|
|
16065
16976
|
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
16066
16977
|
*
|
|
16067
16978
|
* Settings blobs never hold a secret: they hold a marker
|
|
@@ -16602,6 +17513,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
|
|
|
16602
17513
|
kind: "mutation",
|
|
16603
17514
|
auth: "admin",
|
|
16604
17515
|
caller: "required"
|
|
17516
|
+
}), method(object({
|
|
17517
|
+
ref: string().min(1),
|
|
17518
|
+
value: string().min(1)
|
|
17519
|
+
}), object({
|
|
17520
|
+
ref: string(),
|
|
17521
|
+
version: number().int()
|
|
17522
|
+
}), {
|
|
17523
|
+
kind: "mutation",
|
|
17524
|
+
auth: "admin",
|
|
17525
|
+
caller: "required"
|
|
16605
17526
|
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
16606
17527
|
deleted: array(string()).readonly(),
|
|
16607
17528
|
kept: array(object({
|
|
@@ -39393,6 +40314,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
|
|
|
39393
40314
|
}), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
|
|
39394
40315
|
kind: "mutation",
|
|
39395
40316
|
auth: "admin"
|
|
40317
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
40318
|
+
kind: "mutation",
|
|
40319
|
+
auth: "admin"
|
|
39396
40320
|
}), method(ProfileRefInputSchema, _void(), {
|
|
39397
40321
|
kind: "mutation",
|
|
39398
40322
|
auth: "admin"
|
|
@@ -49902,6 +50826,41 @@ var ServerRollbackInfoSchema = object({
|
|
|
49902
50826
|
atMs: number(),
|
|
49903
50827
|
reason: string()
|
|
49904
50828
|
});
|
|
50829
|
+
/**
|
|
50830
|
+
* The runner boot check (D877): the runners this node PLANNED (hub: one per
|
|
50831
|
+
* `resolveRunnerId` over its forked addons; agent: the runners its process
|
|
50832
|
+
* service holds, because only the hub plans) against the states the process
|
|
50833
|
+
* service reports. Kept in memory, recomputed by the same one-shot check after
|
|
50834
|
+
* every boot, served on `getServerPackageStatus`.
|
|
50835
|
+
*
|
|
50836
|
+
* `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
|
|
50837
|
+
* refusal (an addon that said "I will not start, and here is why"), `missing` a
|
|
50838
|
+
* planned runner the process service has no entry for.
|
|
50839
|
+
*/
|
|
50840
|
+
var RunnerRefusalSchema = object({
|
|
50841
|
+
runnerId: string(),
|
|
50842
|
+
addonIds: array(string()),
|
|
50843
|
+
reason: string()
|
|
50844
|
+
});
|
|
50845
|
+
var RunnerBootCheckSchema = object({
|
|
50846
|
+
checkedAtMs: number(),
|
|
50847
|
+
/** Runners planned for this node. */
|
|
50848
|
+
expected: number(),
|
|
50849
|
+
/** Planned runners whose process is `running`. */
|
|
50850
|
+
running: number(),
|
|
50851
|
+
failed: array(string()),
|
|
50852
|
+
refused: array(RunnerRefusalSchema),
|
|
50853
|
+
missing: array(string()),
|
|
50854
|
+
/**
|
|
50855
|
+
* Runners still on their way: `starting`, or `crashed` waiting on a backoff
|
|
50856
|
+
* respawn. The check is FINAL only when this is empty; until then nothing is
|
|
50857
|
+
* pushed and the verdict is re-evaluated on the next runner state change.
|
|
50858
|
+
* Optional for version skew (absent = settled).
|
|
50859
|
+
*/
|
|
50860
|
+
pending: array(string()).optional(),
|
|
50861
|
+
/** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
|
|
50862
|
+
planKnown: boolean()
|
|
50863
|
+
});
|
|
49905
50864
|
var ServerPackageStatusSchema = object({
|
|
49906
50865
|
/** Root package name (`@camstack/server` on the hub). */
|
|
49907
50866
|
packageName: string(),
|
|
@@ -49964,7 +50923,14 @@ var ServerPackageStatusSchema = object({
|
|
|
49964
50923
|
* for version skew: an older provider's payload simply omits it, and an
|
|
49965
50924
|
* absent wrapper is unknown — never `native`.
|
|
49966
50925
|
*/
|
|
49967
|
-
wrapper: WrapperIdentitySchema.optional()
|
|
50926
|
+
wrapper: WrapperIdentitySchema.optional(),
|
|
50927
|
+
/**
|
|
50928
|
+
* What this node PLANNED to run against what its process service reports
|
|
50929
|
+
* (D877). Absent until the one-shot boot check has run (~60 s after boot) and
|
|
50930
|
+
* on a provider that predates it. Absent is "not checked yet", never "all
|
|
50931
|
+
* well": a consumer that needs the answer treats it as pending.
|
|
50932
|
+
*/
|
|
50933
|
+
runners: RunnerBootCheckSchema.optional()
|
|
49968
50934
|
});
|
|
49969
50935
|
var ServerUpdateCheckResultSchema = object({
|
|
49970
50936
|
packageName: string(),
|
|
@@ -50015,6 +50981,13 @@ var ServerUpdateOutcomeSchema = _enum([
|
|
|
50015
50981
|
"refused",
|
|
50016
50982
|
"failed"
|
|
50017
50983
|
]);
|
|
50984
|
+
/** One addon the pre-flight found the target version would refuse (D877). */
|
|
50985
|
+
var UpdateBlockerSchema = object({
|
|
50986
|
+
addonId: string(),
|
|
50987
|
+
reason: string(),
|
|
50988
|
+
/** What the operator does about it. */
|
|
50989
|
+
remedy: string()
|
|
50990
|
+
});
|
|
50018
50991
|
var ServerUpdateActionResultSchema = object({
|
|
50019
50992
|
accepted: boolean(),
|
|
50020
50993
|
targetVersion: string().nullable(),
|
|
@@ -50032,14 +51005,27 @@ var ServerUpdateActionResultSchema = object({
|
|
|
50032
51005
|
* The failure itself, verbatim enough to act on (the npm output for a
|
|
50033
51006
|
* staging install). Non-null only for `failed`.
|
|
50034
51007
|
*/
|
|
50035
|
-
error: string().nullable().optional()
|
|
51008
|
+
error: string().nullable().optional(),
|
|
51009
|
+
/**
|
|
51010
|
+
* The addons the target version would refuse to start on this node's live
|
|
51011
|
+
* store (D877), present when the pre-flight refused the update
|
|
51012
|
+
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
51013
|
+
*/
|
|
51014
|
+
blockers: array(UpdateBlockerSchema).optional()
|
|
50036
51015
|
});
|
|
50037
51016
|
method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
|
|
50038
51017
|
kind: "mutation",
|
|
50039
51018
|
auth: "admin"
|
|
50040
|
-
}), method(object({
|
|
50041
|
-
/** Explicit target version; omitted = latest from the registry. */
|
|
50042
|
-
version: string().optional()
|
|
51019
|
+
}), method(object({
|
|
51020
|
+
/** Explicit target version; omitted = latest from the registry. */
|
|
51021
|
+
version: string().optional(),
|
|
51022
|
+
/**
|
|
51023
|
+
* Apply even though the pre-flight (D877) found addons the target would
|
|
51024
|
+
* refuse to start. Off by default: those addons stay down until the
|
|
51025
|
+
* remedy is run, which is the incident this gate exists to prevent.
|
|
51026
|
+
*/
|
|
51027
|
+
acknowledgeRefusals: boolean().optional()
|
|
51028
|
+
}), ServerUpdateActionResultSchema, {
|
|
50043
51029
|
kind: "mutation",
|
|
50044
51030
|
auth: "admin",
|
|
50045
51031
|
timeoutMs: 16 * 6e4
|
|
@@ -52485,7 +53471,9 @@ var ManifestShapeSchema = object({
|
|
|
52485
53471
|
var AddonProcessSchema = object({
|
|
52486
53472
|
pid: number().optional(),
|
|
52487
53473
|
mode: string(),
|
|
52488
|
-
state: string()
|
|
53474
|
+
state: string(),
|
|
53475
|
+
/** Why the runner is `refused` (an addon's own words), when it is (D877). */
|
|
53476
|
+
reason: string().optional()
|
|
52489
53477
|
});
|
|
52490
53478
|
/**
|
|
52491
53479
|
* Per-addon health snapshot from the kernel's AddonHealthMonitor.
|
|
@@ -53874,6 +54862,12 @@ var ClimateControlStatusSchema = object({
|
|
|
53874
54862
|
/** Horizontal louver swing on/off. Null when the device has no
|
|
53875
54863
|
* horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
|
|
53876
54864
|
swingHorizontal: boolean().nullable(),
|
|
54865
|
+
/** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54866
|
+
minTemp: number().nullable().optional(),
|
|
54867
|
+
/** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54868
|
+
maxTemp: number().nullable().optional(),
|
|
54869
|
+
/** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
|
|
54870
|
+
tempStep: number().positive().nullable().optional(),
|
|
53877
54871
|
/** Ms epoch when the slice was last updated (push or command). */
|
|
53878
54872
|
lastFetchedAt: number()
|
|
53879
54873
|
});
|
|
@@ -56654,7 +57648,19 @@ var TlsStatusSchema = object({
|
|
|
56654
57648
|
sans: array(string()),
|
|
56655
57649
|
caCertPem: string().nullable(),
|
|
56656
57650
|
reissueError: string().nullable(),
|
|
56657
|
-
restartRequired: boolean()
|
|
57651
|
+
restartRequired: boolean(),
|
|
57652
|
+
/** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
|
|
57653
|
+
caMissing: boolean(),
|
|
57654
|
+
/** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
|
|
57655
|
+
localCaConstrained: boolean().nullable(),
|
|
57656
|
+
/** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
|
|
57657
|
+
caReplacedAt: string().nullable(),
|
|
57658
|
+
/** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
|
|
57659
|
+
storedUpload: object({
|
|
57660
|
+
leafFingerprintSha256: string(),
|
|
57661
|
+
validTo: string(),
|
|
57662
|
+
hasCa: boolean()
|
|
57663
|
+
}).nullable()
|
|
56658
57664
|
});
|
|
56659
57665
|
method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
|
|
56660
57666
|
/**
|
|
@@ -56710,6 +57716,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
|
|
|
56710
57716
|
}), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
|
|
56711
57717
|
kind: "mutation",
|
|
56712
57718
|
auth: "admin"
|
|
57719
|
+
}), method(_void(), TlsStatusSchema, {
|
|
57720
|
+
kind: "mutation",
|
|
57721
|
+
auth: "admin"
|
|
56713
57722
|
});
|
|
56714
57723
|
var LockControlStatusSchema = object({
|
|
56715
57724
|
/** Lifecycle state of the lock. `jammed` means the motor reported
|
|
@@ -63203,7 +64212,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
63203
64212
|
kind: "mutation",
|
|
63204
64213
|
auth: "admin",
|
|
63205
64214
|
access: "delete"
|
|
63206
|
-
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(
|
|
64215
|
+
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
64216
|
+
kind: "mutation",
|
|
64217
|
+
auth: "admin",
|
|
64218
|
+
access: "create"
|
|
64219
|
+
}), method(object({
|
|
63207
64220
|
userId: string(),
|
|
63208
64221
|
code: string()
|
|
63209
64222
|
}), object({ valid: boolean() }), {
|
|
@@ -65015,13 +66028,14 @@ var BaseDevice = class {
|
|
|
65015
66028
|
get state() {
|
|
65016
66029
|
if (!this._stateProxyCache) {
|
|
65017
66030
|
const cache = {};
|
|
65018
|
-
const handler = { get: (
|
|
66031
|
+
const handler = { get: (target, key) => {
|
|
65019
66032
|
const k = key;
|
|
65020
|
-
|
|
66033
|
+
const existing = Reflect.get(target, k);
|
|
66034
|
+
if (existing !== void 0) return existing;
|
|
65021
66035
|
const cap = DEVICE_LOCAL_STATE_CAPS[k];
|
|
65022
66036
|
if (!cap) return void 0;
|
|
65023
66037
|
const proxy = this.sliceProxy(cap);
|
|
65024
|
-
|
|
66038
|
+
Reflect.set(target, k, proxy);
|
|
65025
66039
|
return proxy;
|
|
65026
66040
|
} };
|
|
65027
66041
|
this._stateProxyCache = new Proxy(cache, handler);
|
|
@@ -65220,7 +66234,7 @@ var BaseDevice = class {
|
|
|
65220
66234
|
async updateSourceInfo(patch) {
|
|
65221
66235
|
const next = mergeSourceInfo(this.sourceInfo, patch);
|
|
65222
66236
|
this._sourceInfoCache = Object.freeze({ ...next });
|
|
65223
|
-
const action = this.ctx.api
|
|
66237
|
+
const action = this.ctx.api.deviceManager?.setMetadata;
|
|
65224
66238
|
if (action) try {
|
|
65225
66239
|
await action.mutate({
|
|
65226
66240
|
deviceId: this.id,
|
|
@@ -65255,7 +66269,7 @@ var BaseDevice = class {
|
|
|
65255
66269
|
* device boot on a meta refresh.
|
|
65256
66270
|
*/
|
|
65257
66271
|
async refreshFeatures() {
|
|
65258
|
-
const action = this.ctx.api
|
|
66272
|
+
const action = this.ctx.api.deviceManager?.registerDevice;
|
|
65259
66273
|
if (!action) return;
|
|
65260
66274
|
try {
|
|
65261
66275
|
await action.mutate({
|
|
@@ -67329,6 +68343,12 @@ Object.freeze({
|
|
|
67329
68343
|
addonId: null,
|
|
67330
68344
|
access: "view"
|
|
67331
68345
|
},
|
|
68346
|
+
"coreBlocks.migrateRawSecrets": {
|
|
68347
|
+
capName: "core-blocks",
|
|
68348
|
+
capScope: "system",
|
|
68349
|
+
addonId: null,
|
|
68350
|
+
access: "create"
|
|
68351
|
+
},
|
|
67332
68352
|
"coreBlocks.restart": {
|
|
67333
68353
|
capName: "core-blocks",
|
|
67334
68354
|
capScope: "system",
|
|
@@ -69015,6 +70035,12 @@ Object.freeze({
|
|
|
69015
70035
|
addonId: null,
|
|
69016
70036
|
access: "create"
|
|
69017
70037
|
},
|
|
70038
|
+
"keychainAdmin.importSecret": {
|
|
70039
|
+
capName: "keychain-admin",
|
|
70040
|
+
capScope: "system",
|
|
70041
|
+
addonId: null,
|
|
70042
|
+
access: "create"
|
|
70043
|
+
},
|
|
69018
70044
|
"keychainAdmin.listAudit": {
|
|
69019
70045
|
capName: "keychain-admin",
|
|
69020
70046
|
capScope: "system",
|
|
@@ -69183,6 +70209,12 @@ Object.freeze({
|
|
|
69183
70209
|
addonId: null,
|
|
69184
70210
|
access: "view"
|
|
69185
70211
|
},
|
|
70212
|
+
"llm.migrateRawSecrets": {
|
|
70213
|
+
capName: "llm",
|
|
70214
|
+
capScope: "system",
|
|
70215
|
+
addonId: null,
|
|
70216
|
+
access: "create"
|
|
70217
|
+
},
|
|
69186
70218
|
"llm.resolveModelRef": {
|
|
69187
70219
|
capName: "llm",
|
|
69188
70220
|
capScope: "system",
|
|
@@ -69411,6 +70443,12 @@ Object.freeze({
|
|
|
69411
70443
|
addonId: null,
|
|
69412
70444
|
access: "create"
|
|
69413
70445
|
},
|
|
70446
|
+
"localNetwork.useStoredUploadedCertificate": {
|
|
70447
|
+
capName: "local-network",
|
|
70448
|
+
capScope: "system",
|
|
70449
|
+
addonId: null,
|
|
70450
|
+
access: "create"
|
|
70451
|
+
},
|
|
69414
70452
|
"lockControl.getStatus": {
|
|
69415
70453
|
capName: "lock-control",
|
|
69416
70454
|
capScope: "device",
|
|
@@ -72063,6 +73101,30 @@ Object.freeze({
|
|
|
72063
73101
|
addonId: null,
|
|
72064
73102
|
access: "create"
|
|
72065
73103
|
},
|
|
73104
|
+
"recordEntries.deleteEntry": {
|
|
73105
|
+
capName: "record-entries",
|
|
73106
|
+
capScope: "system",
|
|
73107
|
+
addonId: null,
|
|
73108
|
+
access: "delete"
|
|
73109
|
+
},
|
|
73110
|
+
"recordEntries.listEntries": {
|
|
73111
|
+
capName: "record-entries",
|
|
73112
|
+
capScope: "system",
|
|
73113
|
+
addonId: null,
|
|
73114
|
+
access: "view"
|
|
73115
|
+
},
|
|
73116
|
+
"recordEntries.listEntryKinds": {
|
|
73117
|
+
capName: "record-entries",
|
|
73118
|
+
capScope: "system",
|
|
73119
|
+
addonId: null,
|
|
73120
|
+
access: "view"
|
|
73121
|
+
},
|
|
73122
|
+
"recordEntries.putEntry": {
|
|
73123
|
+
capName: "record-entries",
|
|
73124
|
+
capScope: "system",
|
|
73125
|
+
addonId: null,
|
|
73126
|
+
access: "create"
|
|
73127
|
+
},
|
|
72066
73128
|
"recording.getAvailability": {
|
|
72067
73129
|
capName: "recording",
|
|
72068
73130
|
capScope: "device",
|
|
@@ -72363,6 +73425,102 @@ Object.freeze({
|
|
|
72363
73425
|
addonId: null,
|
|
72364
73426
|
access: "view"
|
|
72365
73427
|
},
|
|
73428
|
+
"records.aggregate": {
|
|
73429
|
+
capName: "records",
|
|
73430
|
+
capScope: "system",
|
|
73431
|
+
addonId: null,
|
|
73432
|
+
access: "view"
|
|
73433
|
+
},
|
|
73434
|
+
"records.allocateId": {
|
|
73435
|
+
capName: "records",
|
|
73436
|
+
capScope: "system",
|
|
73437
|
+
addonId: null,
|
|
73438
|
+
access: "create"
|
|
73439
|
+
},
|
|
73440
|
+
"records.count": {
|
|
73441
|
+
capName: "records",
|
|
73442
|
+
capScope: "system",
|
|
73443
|
+
addonId: null,
|
|
73444
|
+
access: "view"
|
|
73445
|
+
},
|
|
73446
|
+
"records.declareKinds": {
|
|
73447
|
+
capName: "records",
|
|
73448
|
+
capScope: "system",
|
|
73449
|
+
addonId: null,
|
|
73450
|
+
access: "create"
|
|
73451
|
+
},
|
|
73452
|
+
"records.delete": {
|
|
73453
|
+
capName: "records",
|
|
73454
|
+
capScope: "system",
|
|
73455
|
+
addonId: null,
|
|
73456
|
+
access: "delete"
|
|
73457
|
+
},
|
|
73458
|
+
"records.deleteDevice": {
|
|
73459
|
+
capName: "records",
|
|
73460
|
+
capScope: "system",
|
|
73461
|
+
addonId: null,
|
|
73462
|
+
access: "delete"
|
|
73463
|
+
},
|
|
73464
|
+
"records.deleteMany": {
|
|
73465
|
+
capName: "records",
|
|
73466
|
+
capScope: "system",
|
|
73467
|
+
addonId: null,
|
|
73468
|
+
access: "delete"
|
|
73469
|
+
},
|
|
73470
|
+
"records.deleteWhere": {
|
|
73471
|
+
capName: "records",
|
|
73472
|
+
capScope: "system",
|
|
73473
|
+
addonId: null,
|
|
73474
|
+
access: "delete"
|
|
73475
|
+
},
|
|
73476
|
+
"records.get": {
|
|
73477
|
+
capName: "records",
|
|
73478
|
+
capScope: "system",
|
|
73479
|
+
addonId: null,
|
|
73480
|
+
access: "view"
|
|
73481
|
+
},
|
|
73482
|
+
"records.getMany": {
|
|
73483
|
+
capName: "records",
|
|
73484
|
+
capScope: "system",
|
|
73485
|
+
addonId: null,
|
|
73486
|
+
access: "view"
|
|
73487
|
+
},
|
|
73488
|
+
"records.histogram": {
|
|
73489
|
+
capName: "records",
|
|
73490
|
+
capScope: "system",
|
|
73491
|
+
addonId: null,
|
|
73492
|
+
access: "view"
|
|
73493
|
+
},
|
|
73494
|
+
"records.patch": {
|
|
73495
|
+
capName: "records",
|
|
73496
|
+
capScope: "system",
|
|
73497
|
+
addonId: null,
|
|
73498
|
+
access: "create"
|
|
73499
|
+
},
|
|
73500
|
+
"records.put": {
|
|
73501
|
+
capName: "records",
|
|
73502
|
+
capScope: "system",
|
|
73503
|
+
addonId: null,
|
|
73504
|
+
access: "create"
|
|
73505
|
+
},
|
|
73506
|
+
"records.putMany": {
|
|
73507
|
+
capName: "records",
|
|
73508
|
+
capScope: "system",
|
|
73509
|
+
addonId: null,
|
|
73510
|
+
access: "create"
|
|
73511
|
+
},
|
|
73512
|
+
"records.query": {
|
|
73513
|
+
capName: "records",
|
|
73514
|
+
capScope: "system",
|
|
73515
|
+
addonId: null,
|
|
73516
|
+
access: "view"
|
|
73517
|
+
},
|
|
73518
|
+
"records.secretRefs": {
|
|
73519
|
+
capName: "records",
|
|
73520
|
+
capScope: "system",
|
|
73521
|
+
addonId: null,
|
|
73522
|
+
access: "view"
|
|
73523
|
+
},
|
|
72366
73524
|
"sceneMonitor.captureReference": {
|
|
72367
73525
|
capName: "scene-monitor",
|
|
72368
73526
|
capScope: "device",
|
|
@@ -72795,6 +73953,48 @@ Object.freeze({
|
|
|
72795
73953
|
addonId: null,
|
|
72796
73954
|
access: "create"
|
|
72797
73955
|
},
|
|
73956
|
+
"storageAdmin.adoptRecords": {
|
|
73957
|
+
capName: "storage-admin",
|
|
73958
|
+
capScope: "system",
|
|
73959
|
+
addonId: null,
|
|
73960
|
+
access: "create"
|
|
73961
|
+
},
|
|
73962
|
+
"storageAdmin.dropCollection": {
|
|
73963
|
+
capName: "storage-admin",
|
|
73964
|
+
capScope: "system",
|
|
73965
|
+
addonId: null,
|
|
73966
|
+
access: "delete"
|
|
73967
|
+
},
|
|
73968
|
+
"storageAdmin.isAdoptedLegacyTable": {
|
|
73969
|
+
capName: "storage-admin",
|
|
73970
|
+
capScope: "system",
|
|
73971
|
+
addonId: null,
|
|
73972
|
+
access: "view"
|
|
73973
|
+
},
|
|
73974
|
+
"storageAdmin.listKinds": {
|
|
73975
|
+
capName: "storage-admin",
|
|
73976
|
+
capScope: "system",
|
|
73977
|
+
addonId: null,
|
|
73978
|
+
access: "view"
|
|
73979
|
+
},
|
|
73980
|
+
"storageAdmin.listTables": {
|
|
73981
|
+
capName: "storage-admin",
|
|
73982
|
+
capScope: "system",
|
|
73983
|
+
addonId: null,
|
|
73984
|
+
access: "view"
|
|
73985
|
+
},
|
|
73986
|
+
"storageAdmin.readLegacyCollection": {
|
|
73987
|
+
capName: "storage-admin",
|
|
73988
|
+
capScope: "system",
|
|
73989
|
+
addonId: null,
|
|
73990
|
+
access: "view"
|
|
73991
|
+
},
|
|
73992
|
+
"storageAdmin.readRecords": {
|
|
73993
|
+
capName: "storage-admin",
|
|
73994
|
+
capScope: "system",
|
|
73995
|
+
addonId: null,
|
|
73996
|
+
access: "view"
|
|
73997
|
+
},
|
|
72798
73998
|
"storageEvictable.evict": {
|
|
72799
73999
|
capName: "storage-evictable",
|
|
72800
74000
|
capScope: "system",
|
|
@@ -73707,6 +74907,12 @@ Object.freeze({
|
|
|
73707
74907
|
addonId: null,
|
|
73708
74908
|
access: "view"
|
|
73709
74909
|
},
|
|
74910
|
+
"userManagement.migrateRawSecrets": {
|
|
74911
|
+
capName: "user-management",
|
|
74912
|
+
capScope: "system",
|
|
74913
|
+
addonId: null,
|
|
74914
|
+
access: "create"
|
|
74915
|
+
},
|
|
73710
74916
|
"userManagement.oauthExchangeCode": {
|
|
73711
74917
|
capName: "user-management",
|
|
73712
74918
|
capScope: "system",
|
|
@@ -76383,6 +77589,37 @@ Object.freeze({
|
|
|
76383
77589
|
form: "single",
|
|
76384
77590
|
optional: false
|
|
76385
77591
|
}],
|
|
77592
|
+
"records.count": [{
|
|
77593
|
+
name: "deviceId",
|
|
77594
|
+
form: "single",
|
|
77595
|
+
optional: true
|
|
77596
|
+
}],
|
|
77597
|
+
"records.deleteDevice": [{
|
|
77598
|
+
name: "deviceId",
|
|
77599
|
+
form: "single",
|
|
77600
|
+
optional: false
|
|
77601
|
+
}],
|
|
77602
|
+
"records.deleteWhere": [{
|
|
77603
|
+
name: "deviceId",
|
|
77604
|
+
form: "single",
|
|
77605
|
+
optional: true
|
|
77606
|
+
}],
|
|
77607
|
+
"records.histogram": [{
|
|
77608
|
+
name: "deviceId",
|
|
77609
|
+
form: "single",
|
|
77610
|
+
optional: true
|
|
77611
|
+
}],
|
|
77612
|
+
"records.putMany": [{
|
|
77613
|
+
name: "records",
|
|
77614
|
+
form: "object-array",
|
|
77615
|
+
optional: false,
|
|
77616
|
+
itemField: "deviceId"
|
|
77617
|
+
}],
|
|
77618
|
+
"records.query": [{
|
|
77619
|
+
name: "deviceId",
|
|
77620
|
+
form: "single",
|
|
77621
|
+
optional: true
|
|
77622
|
+
}],
|
|
76386
77623
|
"sceneMonitor.captureReference": [{
|
|
76387
77624
|
name: "deviceId",
|
|
76388
77625
|
form: "single",
|
|
@@ -76499,6 +77736,17 @@ Object.freeze({
|
|
|
76499
77736
|
form: "single",
|
|
76500
77737
|
optional: false
|
|
76501
77738
|
}],
|
|
77739
|
+
"storageAdmin.adoptRecords": [{
|
|
77740
|
+
name: "records",
|
|
77741
|
+
form: "object-array",
|
|
77742
|
+
optional: false,
|
|
77743
|
+
itemField: "deviceId"
|
|
77744
|
+
}],
|
|
77745
|
+
"storageAdmin.readRecords": [{
|
|
77746
|
+
name: "deviceId",
|
|
77747
|
+
form: "single",
|
|
77748
|
+
optional: true
|
|
77749
|
+
}],
|
|
76502
77750
|
"streamBroker.acquireEgressTranscode": [{
|
|
76503
77751
|
name: "deviceId",
|
|
76504
77752
|
form: "single",
|
|
@@ -78083,12 +79331,12 @@ function toHomematicOptions(config) {
|
|
|
78083
79331
|
};
|
|
78084
79332
|
}
|
|
78085
79333
|
/**
|
|
78086
|
-
*
|
|
78087
|
-
*
|
|
78088
|
-
*
|
|
78089
|
-
*
|
|
79334
|
+
* A single registered Homematic CCU hub ("broker"). One broker entry maps
|
|
79335
|
+
* 1-to-1 with an operator-added integration and holds the validated CCU
|
|
79336
|
+
* connection settings plus an optional back-reference to the spawning
|
|
79337
|
+
* integration (used for cascade-delete when the integration is removed).
|
|
78090
79338
|
*/
|
|
78091
|
-
var
|
|
79339
|
+
var HmBrokerEntrySchema = object({
|
|
78092
79340
|
/** Stable opaque identifier — e.g. 'hm_001', 'hm_002'. */
|
|
78093
79341
|
id: string().min(1),
|
|
78094
79342
|
/** Human-readable label shown in the admin UI. */
|
|
@@ -78097,7 +79345,14 @@ var homematicAddonConfigSchema = object({ brokers: array(object({
|
|
|
78097
79345
|
connection: homematicConfigSchema,
|
|
78098
79346
|
/** FK to the spawning integration — auto-cleanup on integration delete. */
|
|
78099
79347
|
integrationId: string().optional()
|
|
78100
|
-
})
|
|
79348
|
+
});
|
|
79349
|
+
/**
|
|
79350
|
+
* Top-level addon config that replaces the old single-CCU
|
|
79351
|
+
* `{connection: HomematicConfig|null}` shape. Holds an ordered list of
|
|
79352
|
+
* broker entries; the list defaults to empty so a fresh install requires
|
|
79353
|
+
* no explicit initialisation.
|
|
79354
|
+
*/
|
|
79355
|
+
var homematicAddonConfigSchema = object({ brokers: array(HmBrokerEntrySchema).default([]) });
|
|
78101
79356
|
/**
|
|
78102
79357
|
* Coerce a loose settings blob (e.g. from the broker `add`/`setSettings`
|
|
78103
79358
|
* cap) through the connection schema, applying all schema defaults. Throws
|
|
@@ -78256,6 +79511,70 @@ function buildConnectionFormSchema() {
|
|
|
78256
79511
|
}
|
|
78257
79512
|
] };
|
|
78258
79513
|
}
|
|
79514
|
+
var hmBrokersEntryKind = defineEntryKind("brokers", {
|
|
79515
|
+
title: "Homematic brokers",
|
|
79516
|
+
schema: entryBody({
|
|
79517
|
+
connection: HmBrokerEntrySchema.shape.connection,
|
|
79518
|
+
integrationId: string().optional()
|
|
79519
|
+
}),
|
|
79520
|
+
writeTrigger: "an operator adds, edits or removes a Homematic CCU broker connection",
|
|
79521
|
+
adoptsFrom: settingsBrokersAdoptsFrom("provider-homematic")
|
|
79522
|
+
});
|
|
79523
|
+
//#endregion
|
|
79524
|
+
//#region src/hm-broker-store.ts
|
|
79525
|
+
function rowToEntry(id, data) {
|
|
79526
|
+
const parsed = HmBrokerEntrySchema.safeParse({
|
|
79527
|
+
id,
|
|
79528
|
+
name: data.name,
|
|
79529
|
+
connection: data.connection,
|
|
79530
|
+
integrationId: data.integrationId
|
|
79531
|
+
});
|
|
79532
|
+
return parsed.success ? parsed.data : null;
|
|
79533
|
+
}
|
|
79534
|
+
var HmBrokerStore = class HmBrokerStore {
|
|
79535
|
+
kind;
|
|
79536
|
+
constructor(kind) {
|
|
79537
|
+
this.kind = kind;
|
|
79538
|
+
}
|
|
79539
|
+
static of(records) {
|
|
79540
|
+
return new HmBrokerStore(records.kind(hmBrokersEntryKind));
|
|
79541
|
+
}
|
|
79542
|
+
async listResolved() {
|
|
79543
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
79544
|
+
const out = [];
|
|
79545
|
+
for (const record of page.records) {
|
|
79546
|
+
let data = record.data;
|
|
79547
|
+
try {
|
|
79548
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
79549
|
+
if (resolved !== null) data = resolved.data;
|
|
79550
|
+
} catch (err) {
|
|
79551
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
79552
|
+
}
|
|
79553
|
+
const entry = rowToEntry(record.id, data);
|
|
79554
|
+
if (entry !== null) out.push(entry);
|
|
79555
|
+
}
|
|
79556
|
+
return out;
|
|
79557
|
+
}
|
|
79558
|
+
async replaceAll(entries) {
|
|
79559
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
79560
|
+
const nextIds = new Set(entries.map((e) => e.id));
|
|
79561
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
79562
|
+
for (const entry of entries) {
|
|
79563
|
+
const { id, name, connection, integrationId } = entry;
|
|
79564
|
+
const body = {
|
|
79565
|
+
name,
|
|
79566
|
+
connection,
|
|
79567
|
+
...integrationId === void 0 ? {} : { integrationId }
|
|
79568
|
+
};
|
|
79569
|
+
const parsed = hmBrokersEntryKind.schema.safeParse(body);
|
|
79570
|
+
if (!parsed.success) throw new Error(`invalid HM broker '${id}': ${parsed.error.message}`);
|
|
79571
|
+
await this.kind.put({
|
|
79572
|
+
id,
|
|
79573
|
+
data: parsed.data
|
|
79574
|
+
});
|
|
79575
|
+
}
|
|
79576
|
+
}
|
|
79577
|
+
};
|
|
78259
79578
|
//#endregion
|
|
78260
79579
|
//#region ../../node_modules/nodehomematic/node_modules/undici/lib/core/symbols.js
|
|
78261
79580
|
var require_symbols$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -103991,6 +105310,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
103991
105310
|
deviceClasses = { [DeviceType.Container]: HmContainerDevice };
|
|
103992
105311
|
/** Live multi-broker registry, or null before init / after shutdown. */
|
|
103993
105312
|
registry = null;
|
|
105313
|
+
brokerStore = null;
|
|
105314
|
+
activeBrokers = [];
|
|
103994
105315
|
constructor() {
|
|
103995
105316
|
super({ ...DEFAULTS });
|
|
103996
105317
|
}
|
|
@@ -103998,6 +105319,11 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
103998
105319
|
const regs = await super.onInitialize();
|
|
103999
105320
|
const migrated = migrateLegacyConfig(await this.resolveGlobalStore());
|
|
104000
105321
|
if (this.brokersDiffer(migrated.brokers, this.config.brokers)) await this.updateGlobalSettings({ brokers: migrated.brokers });
|
|
105322
|
+
const records = this.ctx.records;
|
|
105323
|
+
if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
|
|
105324
|
+
await records.declare({ brokers: hmBrokersEntryKind });
|
|
105325
|
+
this.brokerStore = HmBrokerStore.of(records);
|
|
105326
|
+
this.activeBrokers = await this.loadPersistedBrokers();
|
|
104001
105327
|
this.registry = new HmBrokerRegistry(this.ctx.logger);
|
|
104002
105328
|
this.registry.setOnBrokerConnected((brokerId) => {
|
|
104003
105329
|
this.ctx.logger.info("Homematic: broker connected", { meta: { brokerId } });
|
|
@@ -104007,8 +105333,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104007
105333
|
this.registry.setOnBrokerDisconnected((brokerId) => {
|
|
104008
105334
|
this.setBrokerDevicesOnline(brokerId, false);
|
|
104009
105335
|
});
|
|
104010
|
-
await this.registry.restore(this.
|
|
104011
|
-
this.ctx.logger.info("Homematic: provider initialised", { meta: { brokerCount: this.
|
|
105336
|
+
await this.registry.restore(this.activeBrokers);
|
|
105337
|
+
this.ctx.logger.info("Homematic: provider initialised", { meta: { brokerCount: this.activeBrokers.length } });
|
|
104012
105338
|
await this.reconcileIntegrationsToBrokers();
|
|
104013
105339
|
this.subscribeIntegrationLifecycle();
|
|
104014
105340
|
return [
|
|
@@ -104030,10 +105356,28 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104030
105356
|
* (persisting the registry-allocated id back when it differs), and apply
|
|
104031
105357
|
* connection updates to existing rows.
|
|
104032
105358
|
*/
|
|
105359
|
+
async loadPersistedBrokers() {
|
|
105360
|
+
const store = this.brokerStore;
|
|
105361
|
+
if (store !== null) {
|
|
105362
|
+
const fromRecords = await store.listResolved();
|
|
105363
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
105364
|
+
}
|
|
105365
|
+
return this.config.brokers;
|
|
105366
|
+
}
|
|
105367
|
+
async persistBrokerEntries(entries) {
|
|
105368
|
+
this.activeBrokers = [...entries];
|
|
105369
|
+
const store = this.brokerStore;
|
|
105370
|
+
if (store !== null) {
|
|
105371
|
+
await store.replaceAll(entries);
|
|
105372
|
+
return;
|
|
105373
|
+
}
|
|
105374
|
+
await this.updateGlobalSettings({ brokers: [...entries] });
|
|
105375
|
+
}
|
|
104033
105376
|
async onConfigChanged() {
|
|
104034
105377
|
const reg = this.registry;
|
|
104035
105378
|
if (!reg) return;
|
|
104036
|
-
|
|
105379
|
+
this.activeBrokers = await this.loadPersistedBrokers();
|
|
105380
|
+
const persisted = this.activeBrokers;
|
|
104037
105381
|
const liveIds = new Set(reg.list().map((b) => b.id));
|
|
104038
105382
|
const persistedIds = new Set(persisted.map((e) => e.id));
|
|
104039
105383
|
for (const liveId of liveIds) if (!persistedIds.has(liveId)) try {
|
|
@@ -104064,7 +105408,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104064
105408
|
...b,
|
|
104065
105409
|
id: created.id
|
|
104066
105410
|
} : b);
|
|
104067
|
-
await this.
|
|
105411
|
+
await this.persistBrokerEntries(next);
|
|
104068
105412
|
}
|
|
104069
105413
|
} catch (err) {
|
|
104070
105414
|
this.ctx.logger.warn("Homematic onConfigChanged: failed to start new broker", { meta: {
|
|
@@ -104129,8 +105473,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104129
105473
|
return buildHmBrokerProvider({
|
|
104130
105474
|
ownerAddonId: this.ctx.id,
|
|
104131
105475
|
registry: this.requireRegistry(),
|
|
104132
|
-
getBrokers: () => this.
|
|
104133
|
-
persistBrokers: (brokers) => this.
|
|
105476
|
+
getBrokers: () => this.activeBrokers,
|
|
105477
|
+
persistBrokers: (brokers) => this.persistBrokerEntries([...brokers]),
|
|
104134
105478
|
cascadeRemoveDevices: (brokerId) => this.cascadeRemoveDevicesForBroker(brokerId),
|
|
104135
105479
|
logger: this.ctx.logger
|
|
104136
105480
|
});
|
|
@@ -104187,7 +105531,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104187
105531
|
brokerId
|
|
104188
105532
|
});
|
|
104189
105533
|
if (brokerId === void 0) continue;
|
|
104190
|
-
if (!this.
|
|
105534
|
+
if (!this.activeBrokers.some((b) => b.id === brokerId)) {
|
|
104191
105535
|
this.ctx.logger.warn("Homematic integration→broker: linked broker not found", { meta: {
|
|
104192
105536
|
integrationId: integration.id,
|
|
104193
105537
|
brokerId
|
|
@@ -104196,9 +105540,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104196
105540
|
}
|
|
104197
105541
|
this.requireRegistry().linkIntegration(integration.id, brokerId);
|
|
104198
105542
|
}
|
|
104199
|
-
const linked = linkBrokersToIntegrations(this.
|
|
104200
|
-
if (linked.some((b, i) => b !== this.
|
|
104201
|
-
const toRemove = computeBrokerCleanup(this.
|
|
105543
|
+
const linked = linkBrokersToIntegrations(this.activeBrokers, integrations);
|
|
105544
|
+
if (linked.some((b, i) => b !== this.activeBrokers[i])) await this.persistBrokerEntries(linked);
|
|
105545
|
+
const toRemove = computeBrokerCleanup(this.activeBrokers, survivingIntegrationIds);
|
|
104202
105546
|
if (toRemove.length === 0) return;
|
|
104203
105547
|
for (const id of toRemove) try {
|
|
104204
105548
|
await this.requireRegistry().removeEntry(id);
|
|
@@ -104209,8 +105553,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
104209
105553
|
error: errMsg(err)
|
|
104210
105554
|
} });
|
|
104211
105555
|
}
|
|
104212
|
-
const nextBrokers = this.
|
|
104213
|
-
await this.
|
|
105556
|
+
const nextBrokers = this.activeBrokers.filter((b) => !toRemove.includes(b.id));
|
|
105557
|
+
await this.persistBrokerEntries(nextBrokers);
|
|
104214
105558
|
this.ctx.logger.info("Homematic integration→broker reconcile", { meta: {
|
|
104215
105559
|
brokerCount: nextBrokers.length,
|
|
104216
105560
|
integrationCount: mine.length,
|