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