@camstack/addon-mqtt-broker 1.2.125 → 1.2.126
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/mqtt-broker.addon.js +1671 -76
- package/dist/mqtt-broker.addon.mjs +1671 -76
- package/package.json +1 -1
|
@@ -46,7 +46,7 @@ let node_fs = require("node:fs");
|
|
|
46
46
|
node_fs = __toESM(node_fs);
|
|
47
47
|
let node_path = require("node:path");
|
|
48
48
|
node_path = __toESM(node_path);
|
|
49
|
-
//#region ../types/dist/event-category-
|
|
49
|
+
//#region ../types/dist/event-category-BvOFi6PY.mjs
|
|
50
50
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
51
51
|
EventCategory["SystemBoot"] = "system.boot";
|
|
52
52
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -110,6 +110,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
110
110
|
* consumes this category and maps it to the `addon-crash-loop` kind.
|
|
111
111
|
*/
|
|
112
112
|
EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
|
|
113
|
+
/**
|
|
114
|
+
* A runner whose addon refused to start with a typed reason (D877) - parked
|
|
115
|
+
* in `refused`, never counted by the crash breaker, retried on operator
|
|
116
|
+
* action. One event per refusal.
|
|
117
|
+
*/
|
|
118
|
+
EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
|
|
119
|
+
/**
|
|
120
|
+
* A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
|
|
121
|
+
* `refused`. In-process telemetry for the boot check (re-evaluate while any
|
|
122
|
+
* runner is still pending) and the alert centre (close a recovered runner).
|
|
123
|
+
*/
|
|
124
|
+
EventCategory["ProcessStateChanged"] = "process.state-changed";
|
|
125
|
+
/**
|
|
126
|
+
* The node's one-shot runner boot check (D877): planned runners against the
|
|
127
|
+
* process service, `degraded` when any is failed, refused or missing. The
|
|
128
|
+
* alert centre turns it into one alert and a direct critical push.
|
|
129
|
+
*/
|
|
130
|
+
EventCategory["SystemRunnerCheck"] = "system.runner-check";
|
|
113
131
|
EventCategory["AddonError"] = "addon.error";
|
|
114
132
|
EventCategory["AddonPageReady"] = "addon.page-ready";
|
|
115
133
|
EventCategory["AddonWidgetReady"] = "addon.widget-ready";
|
|
@@ -4152,6 +4170,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4152
4170
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4153
4171
|
json.type = "boolean";
|
|
4154
4172
|
};
|
|
4173
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4174
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4175
|
+
};
|
|
4176
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4177
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4178
|
+
};
|
|
4155
4179
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4156
4180
|
if (ctx.target === "openapi-3.0") {
|
|
4157
4181
|
json.type = "string";
|
|
@@ -4159,12 +4183,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4159
4183
|
json.enum = [null];
|
|
4160
4184
|
} else json.type = "null";
|
|
4161
4185
|
};
|
|
4186
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4187
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4188
|
+
};
|
|
4162
4189
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4163
4190
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4164
4191
|
};
|
|
4165
4192
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4166
4193
|
json.not = {};
|
|
4167
4194
|
};
|
|
4195
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4196
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4168
4197
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4169
4198
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4170
4199
|
};
|
|
@@ -4196,12 +4225,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4196
4225
|
json.enum = vals;
|
|
4197
4226
|
}
|
|
4198
4227
|
};
|
|
4228
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4229
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4230
|
+
};
|
|
4231
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4232
|
+
const _json = json;
|
|
4233
|
+
const pattern = schema._zod.pattern;
|
|
4234
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4235
|
+
_json.type = "string";
|
|
4236
|
+
_json.pattern = pattern.source;
|
|
4237
|
+
};
|
|
4238
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4239
|
+
const _json = json;
|
|
4240
|
+
const file = {
|
|
4241
|
+
type: "string",
|
|
4242
|
+
format: "binary",
|
|
4243
|
+
contentEncoding: "binary"
|
|
4244
|
+
};
|
|
4245
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4246
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4247
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4248
|
+
if (mime) if (mime.length === 1) {
|
|
4249
|
+
file.contentMediaType = mime[0];
|
|
4250
|
+
Object.assign(_json, file);
|
|
4251
|
+
} else {
|
|
4252
|
+
Object.assign(_json, file);
|
|
4253
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4254
|
+
}
|
|
4255
|
+
else Object.assign(_json, file);
|
|
4256
|
+
};
|
|
4257
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4258
|
+
json.type = "boolean";
|
|
4259
|
+
};
|
|
4199
4260
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4200
4261
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4201
4262
|
};
|
|
4263
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4264
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4265
|
+
};
|
|
4202
4266
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4203
4267
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4204
4268
|
};
|
|
4269
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4270
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4271
|
+
};
|
|
4272
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4273
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4274
|
+
};
|
|
4205
4275
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4206
4276
|
const json = _json;
|
|
4207
4277
|
const def = schema._zod.def;
|
|
@@ -4406,6 +4476,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4406
4476
|
seen.ref = def.innerType;
|
|
4407
4477
|
json.readOnly = true;
|
|
4408
4478
|
};
|
|
4479
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4480
|
+
const def = schema._zod.def;
|
|
4481
|
+
process$1(def.innerType, ctx, params);
|
|
4482
|
+
const seen = ctx.seen.get(schema);
|
|
4483
|
+
seen.ref = def.innerType;
|
|
4484
|
+
};
|
|
4409
4485
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4410
4486
|
const def = schema._zod.def;
|
|
4411
4487
|
process$1(def.innerType, ctx, params);
|
|
@@ -4418,6 +4494,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4418
4494
|
const seen = ctx.seen.get(schema);
|
|
4419
4495
|
seen.ref = innerType;
|
|
4420
4496
|
};
|
|
4497
|
+
var allProcessors = {
|
|
4498
|
+
string: stringProcessor,
|
|
4499
|
+
number: numberProcessor,
|
|
4500
|
+
boolean: booleanProcessor,
|
|
4501
|
+
bigint: bigintProcessor,
|
|
4502
|
+
symbol: symbolProcessor,
|
|
4503
|
+
null: nullProcessor,
|
|
4504
|
+
undefined: undefinedProcessor,
|
|
4505
|
+
void: voidProcessor,
|
|
4506
|
+
never: neverProcessor,
|
|
4507
|
+
any: anyProcessor,
|
|
4508
|
+
unknown: unknownProcessor,
|
|
4509
|
+
date: dateProcessor,
|
|
4510
|
+
enum: enumProcessor,
|
|
4511
|
+
literal: literalProcessor,
|
|
4512
|
+
nan: nanProcessor,
|
|
4513
|
+
template_literal: templateLiteralProcessor,
|
|
4514
|
+
file: fileProcessor,
|
|
4515
|
+
success: successProcessor,
|
|
4516
|
+
custom: customProcessor,
|
|
4517
|
+
function: functionProcessor,
|
|
4518
|
+
transform: transformProcessor,
|
|
4519
|
+
map: mapProcessor,
|
|
4520
|
+
set: setProcessor,
|
|
4521
|
+
array: arrayProcessor,
|
|
4522
|
+
object: objectProcessor,
|
|
4523
|
+
union: unionProcessor,
|
|
4524
|
+
intersection: intersectionProcessor,
|
|
4525
|
+
tuple: tupleProcessor,
|
|
4526
|
+
record: recordProcessor,
|
|
4527
|
+
nullable: nullableProcessor,
|
|
4528
|
+
nonoptional: nonoptionalProcessor,
|
|
4529
|
+
default: defaultProcessor,
|
|
4530
|
+
prefault: prefaultProcessor,
|
|
4531
|
+
catch: catchProcessor,
|
|
4532
|
+
pipe: pipeProcessor,
|
|
4533
|
+
readonly: readonlyProcessor,
|
|
4534
|
+
promise: promiseProcessor,
|
|
4535
|
+
optional: optionalProcessor,
|
|
4536
|
+
lazy: lazyProcessor
|
|
4537
|
+
};
|
|
4538
|
+
function toJSONSchema(input, params) {
|
|
4539
|
+
if ("_idmap" in input) {
|
|
4540
|
+
const registry = input;
|
|
4541
|
+
const ctx = initializeContext({
|
|
4542
|
+
...params,
|
|
4543
|
+
processors: allProcessors
|
|
4544
|
+
});
|
|
4545
|
+
const defs = {};
|
|
4546
|
+
for (const entry of registry._idmap.entries()) {
|
|
4547
|
+
const [_, schema] = entry;
|
|
4548
|
+
process$1(schema, ctx);
|
|
4549
|
+
}
|
|
4550
|
+
const schemas = {};
|
|
4551
|
+
ctx.external = {
|
|
4552
|
+
registry,
|
|
4553
|
+
uri: params?.uri,
|
|
4554
|
+
defs
|
|
4555
|
+
};
|
|
4556
|
+
for (const entry of registry._idmap.entries()) {
|
|
4557
|
+
const [key, schema] = entry;
|
|
4558
|
+
extractDefs(ctx, schema);
|
|
4559
|
+
schemas[key] = finalize(ctx, schema);
|
|
4560
|
+
}
|
|
4561
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4562
|
+
return { schemas };
|
|
4563
|
+
}
|
|
4564
|
+
const ctx = initializeContext({
|
|
4565
|
+
...params,
|
|
4566
|
+
processors: allProcessors
|
|
4567
|
+
});
|
|
4568
|
+
process$1(input, ctx);
|
|
4569
|
+
extractDefs(ctx, input);
|
|
4570
|
+
return finalize(ctx, input);
|
|
4571
|
+
}
|
|
4421
4572
|
//#endregion
|
|
4422
4573
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4423
4574
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5434,7 +5585,7 @@ var ZodIssueCode = {
|
|
|
5434
5585
|
var ZodFirstPartyTypeKind;
|
|
5435
5586
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5436
5587
|
//#endregion
|
|
5437
|
-
//#region ../types/dist/sleep-
|
|
5588
|
+
//#region ../types/dist/sleep-bZIhUvjd.mjs
|
|
5438
5589
|
/**
|
|
5439
5590
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5440
5591
|
* window to float samples (D455).
|
|
@@ -5551,7 +5702,7 @@ function isKeychainStoredField(field) {
|
|
|
5551
5702
|
var SECRET_CLEAR = { $secretClear: true };
|
|
5552
5703
|
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5553
5704
|
var LEGACY_DEVICE_REDACTION = "***";
|
|
5554
|
-
function isRecord$
|
|
5705
|
+
function isRecord$5(value) {
|
|
5555
5706
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5556
5707
|
}
|
|
5557
5708
|
function makeSecretMarker(ref) {
|
|
@@ -5562,12 +5713,12 @@ function makeSecretMarker(ref) {
|
|
|
5562
5713
|
}
|
|
5563
5714
|
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5564
5715
|
function isSecretMarker(value) {
|
|
5565
|
-
if (!isRecord$
|
|
5716
|
+
if (!isRecord$5(value)) return false;
|
|
5566
5717
|
const ref = value["$secret"];
|
|
5567
5718
|
return typeof ref === "string" && ref.length > 0;
|
|
5568
5719
|
}
|
|
5569
5720
|
function isSecretClear(value) {
|
|
5570
|
-
return isRecord$
|
|
5721
|
+
return isRecord$5(value) && value["$secretClear"] === true;
|
|
5571
5722
|
}
|
|
5572
5723
|
/**
|
|
5573
5724
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
@@ -6177,7 +6328,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6177
6328
|
}
|
|
6178
6329
|
};
|
|
6179
6330
|
var KEEP = { kind: "keep" };
|
|
6180
|
-
function isRecord$
|
|
6331
|
+
function isRecord$4(value) {
|
|
6181
6332
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6182
6333
|
}
|
|
6183
6334
|
function defaultMintId() {
|
|
@@ -6190,7 +6341,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6190
6341
|
return out;
|
|
6191
6342
|
}
|
|
6192
6343
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6193
|
-
else if (isRecord$
|
|
6344
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6194
6345
|
return out;
|
|
6195
6346
|
}
|
|
6196
6347
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -6245,7 +6396,7 @@ function rowId(row, idKey) {
|
|
|
6245
6396
|
return null;
|
|
6246
6397
|
}
|
|
6247
6398
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6248
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
6399
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
6249
6400
|
if (!Array.isArray(incoming)) {
|
|
6250
6401
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6251
6402
|
return {
|
|
@@ -6261,7 +6412,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6261
6412
|
const kept = /* @__PURE__ */ new Set();
|
|
6262
6413
|
const rows = [];
|
|
6263
6414
|
for (const row of incoming) {
|
|
6264
|
-
if (!isRecord$
|
|
6415
|
+
if (!isRecord$4(row)) {
|
|
6265
6416
|
rows.push(row);
|
|
6266
6417
|
continue;
|
|
6267
6418
|
}
|
|
@@ -6286,7 +6437,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6286
6437
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6287
6438
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6288
6439
|
case "object": {
|
|
6289
|
-
if (!isRecord$
|
|
6440
|
+
if (!isRecord$4(incoming)) {
|
|
6290
6441
|
if (incoming === void 0) return KEEP;
|
|
6291
6442
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6292
6443
|
return {
|
|
@@ -6294,7 +6445,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6294
6445
|
value: incoming
|
|
6295
6446
|
};
|
|
6296
6447
|
}
|
|
6297
|
-
const storedObj = isRecord$
|
|
6448
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
6298
6449
|
return {
|
|
6299
6450
|
kind: "value",
|
|
6300
6451
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -6417,7 +6568,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
6417
6568
|
value: items
|
|
6418
6569
|
};
|
|
6419
6570
|
}
|
|
6420
|
-
if (isRecord$
|
|
6571
|
+
if (isRecord$4(v)) {
|
|
6421
6572
|
const out = {};
|
|
6422
6573
|
for (const [k, child] of Object.entries(v)) {
|
|
6423
6574
|
const s = substitute(child);
|
|
@@ -6449,7 +6600,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
6449
6600
|
this.name = "SecretOverwriteRefusedError";
|
|
6450
6601
|
}
|
|
6451
6602
|
};
|
|
6452
|
-
function isRecord(value) {
|
|
6603
|
+
function isRecord$3(value) {
|
|
6453
6604
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6454
6605
|
}
|
|
6455
6606
|
function resolvedValue(pass, marker) {
|
|
@@ -6478,7 +6629,7 @@ function inArray(pass, incoming, stored) {
|
|
|
6478
6629
|
return incoming.map((item, index) => {
|
|
6479
6630
|
const twin = stored[index];
|
|
6480
6631
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
6481
|
-
if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
|
|
6632
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
6482
6633
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
6483
6634
|
return item;
|
|
6484
6635
|
});
|
|
@@ -6489,7 +6640,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6489
6640
|
const twin = stored[key];
|
|
6490
6641
|
if (isSecretMarker(twin)) {
|
|
6491
6642
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
6492
|
-
} else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6643
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6493
6644
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
6494
6645
|
}
|
|
6495
6646
|
return out;
|
|
@@ -6497,7 +6648,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6497
6648
|
async function walk(pass, incoming, stored) {
|
|
6498
6649
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
6499
6650
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
6500
|
-
if (!isRecord(incoming) || !isRecord(stored)) return incoming;
|
|
6651
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
6501
6652
|
const out = { ...incoming };
|
|
6502
6653
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
6503
6654
|
return out;
|
|
@@ -6528,7 +6679,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
6528
6679
|
function isJsonEqual(a, b) {
|
|
6529
6680
|
if (Object.is(a, b)) return true;
|
|
6530
6681
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
6531
|
-
if (isRecord(a) && isRecord(b)) {
|
|
6682
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
6532
6683
|
const keys = Object.keys(a);
|
|
6533
6684
|
if (keys.length !== Object.keys(b).length) return false;
|
|
6534
6685
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -6552,7 +6703,7 @@ function markerKeysOf(blob, owner) {
|
|
|
6552
6703
|
}
|
|
6553
6704
|
function nodeFromStored(value, owner) {
|
|
6554
6705
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
6555
|
-
if (!isRecord(value)) return null;
|
|
6706
|
+
if (!isRecord$3(value)) return null;
|
|
6556
6707
|
const children = /* @__PURE__ */ new Map();
|
|
6557
6708
|
for (const [key, child] of Object.entries(value)) {
|
|
6558
6709
|
const node = nodeFromStored(child, owner);
|
|
@@ -6685,7 +6836,6 @@ function createHandle(raw, opts) {
|
|
|
6685
6836
|
const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
|
|
6686
6837
|
const readAddonStoreResult = raw.readAddonStoreResult;
|
|
6687
6838
|
const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
|
|
6688
|
-
const readDeviceStoreBatch = raw.readDeviceStoreBatch;
|
|
6689
6839
|
const overrides = {
|
|
6690
6840
|
readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
|
|
6691
6841
|
...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
|
|
@@ -6709,12 +6859,12 @@ function createHandle(raw, opts) {
|
|
|
6709
6859
|
};
|
|
6710
6860
|
} } : {},
|
|
6711
6861
|
readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
|
|
6712
|
-
|
|
6713
|
-
const rows = await readDeviceStoreBatch
|
|
6862
|
+
readDeviceStoreBatch: async (deviceIds) => {
|
|
6863
|
+
const rows = await raw.readDeviceStoreBatch(deviceIds);
|
|
6714
6864
|
const out = /* @__PURE__ */ new Map();
|
|
6715
6865
|
for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
|
|
6716
6866
|
return out;
|
|
6717
|
-
}
|
|
6867
|
+
},
|
|
6718
6868
|
writeAddonStore: async (patch) => {
|
|
6719
6869
|
await writeAddon(patch);
|
|
6720
6870
|
},
|
|
@@ -7341,7 +7491,7 @@ var BaseAddon = class {
|
|
|
7341
7491
|
if (!ctx) return;
|
|
7342
7492
|
const addonId = ctx.id;
|
|
7343
7493
|
setImmediate(() => {
|
|
7344
|
-
ctx.api.addons
|
|
7494
|
+
ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
|
|
7345
7495
|
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7346
7496
|
}).catch((err) => {
|
|
7347
7497
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -7541,7 +7691,7 @@ var BaseAddon = class {
|
|
|
7541
7691
|
return this._addonSecretTree;
|
|
7542
7692
|
}
|
|
7543
7693
|
deviceSecretTree() {
|
|
7544
|
-
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7694
|
+
this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
|
|
7545
7695
|
return this._deviceSecretTree;
|
|
7546
7696
|
}
|
|
7547
7697
|
/**
|
|
@@ -7617,42 +7767,135 @@ var BaseAddon = class {
|
|
|
7617
7767
|
this[timerOf] = timer;
|
|
7618
7768
|
}
|
|
7619
7769
|
/**
|
|
7620
|
-
* Wrap `ctx.settings.readAddonStore()` with a
|
|
7621
|
-
*
|
|
7622
|
-
* swap, or any race where the SqliteSettingsBackend is between shutdown and
|
|
7623
|
-
* re-initialize) doesn't propagate up into `initialize()` and leave the
|
|
7770
|
+
* Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
|
|
7771
|
+
* settings-store outage doesn't propagate up into `initialize()` and leave the
|
|
7624
7772
|
* addon permanently broken.
|
|
7625
7773
|
*
|
|
7626
|
-
*
|
|
7627
|
-
*
|
|
7628
|
-
* `
|
|
7774
|
+
* Two kinds of outage, two budgets:
|
|
7775
|
+
* - the store's own restart fingerprints (`SqliteSettingsBackend not
|
|
7776
|
+
* initialized`, `provider not available`): a short budget, then the addon
|
|
7777
|
+
* falls back to `{}` (defaults) - its first successful patch rehydrates;
|
|
7778
|
+
* - a TRANSPORT failure (the hub is restarting while this runner boots:
|
|
7779
|
+
* `discovery deadline exceeded`, `parent could not route`, a refused or
|
|
7780
|
+
* timed-out connection). Since D870 a runner's settings read THROWS instead
|
|
7781
|
+
* of answering `{}`, so without a budget a hub restart ends in a respawn
|
|
7782
|
+
* loop. A long, bounded budget; only after it the error propagates - the
|
|
7783
|
+
* addon never runs on defaults for a store it could not ask.
|
|
7784
|
+
* Anything else propagates immediately so real bugs surface.
|
|
7629
7785
|
*/
|
|
7630
7786
|
async readAddonStoreWithRetry() {
|
|
7631
7787
|
const settings = this.rawSettings();
|
|
7632
7788
|
if (!settings) return {};
|
|
7633
|
-
const delaysMs = [
|
|
7634
|
-
150,
|
|
7635
|
-
350,
|
|
7636
|
-
600,
|
|
7637
|
-
900
|
|
7638
|
-
];
|
|
7639
7789
|
let lastErr;
|
|
7640
|
-
for (let attempt = 0
|
|
7790
|
+
for (let attempt = 0;; attempt++) try {
|
|
7641
7791
|
const stored = await settings.readAddonStore() ?? {};
|
|
7642
7792
|
this.settingsStoreReady = true;
|
|
7643
7793
|
return stored;
|
|
7644
7794
|
} catch (err) {
|
|
7645
7795
|
lastErr = err;
|
|
7646
|
-
const
|
|
7647
|
-
if (
|
|
7648
|
-
|
|
7649
|
-
|
|
7796
|
+
const kind = classifyStoreError(err);
|
|
7797
|
+
if (kind === "permanent") throw err;
|
|
7798
|
+
const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
|
|
7799
|
+
if (delay === void 0) {
|
|
7800
|
+
if (kind === "transport") throw err;
|
|
7801
|
+
break;
|
|
7802
|
+
}
|
|
7803
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
7650
7804
|
}
|
|
7651
7805
|
this.settingsStoreReady = false;
|
|
7652
7806
|
this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
|
|
7653
7807
|
return {};
|
|
7654
7808
|
}
|
|
7655
7809
|
};
|
|
7810
|
+
/** The settings store's own restart fingerprints. */
|
|
7811
|
+
var RESTART_RETRY_DELAYS_MS = [
|
|
7812
|
+
150,
|
|
7813
|
+
350,
|
|
7814
|
+
600,
|
|
7815
|
+
900
|
|
7816
|
+
];
|
|
7817
|
+
/** A hub restarting under a booting runner: ~100 s in total. */
|
|
7818
|
+
var TRANSPORT_RETRY_DELAYS_MS = [
|
|
7819
|
+
150,
|
|
7820
|
+
350,
|
|
7821
|
+
600,
|
|
7822
|
+
900,
|
|
7823
|
+
2e3,
|
|
7824
|
+
5e3,
|
|
7825
|
+
1e4,
|
|
7826
|
+
2e4,
|
|
7827
|
+
3e4,
|
|
7828
|
+
3e4
|
|
7829
|
+
];
|
|
7830
|
+
var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
|
|
7831
|
+
/** Node / socket error codes of a connection that did not happen or broke. */
|
|
7832
|
+
var TRANSPORT_CODES = new Set([
|
|
7833
|
+
"ECONNREFUSED",
|
|
7834
|
+
"ECONNRESET",
|
|
7835
|
+
"ETIMEDOUT",
|
|
7836
|
+
"EPIPE",
|
|
7837
|
+
"EHOSTUNREACH",
|
|
7838
|
+
"ENETUNREACH"
|
|
7839
|
+
]);
|
|
7840
|
+
/** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
|
|
7841
|
+
var UNAVAILABLE_TRPC_CODES = new Set([
|
|
7842
|
+
"TIMEOUT",
|
|
7843
|
+
"SERVICE_UNAVAILABLE",
|
|
7844
|
+
"BAD_GATEWAY",
|
|
7845
|
+
"GATEWAY_TIMEOUT"
|
|
7846
|
+
]);
|
|
7847
|
+
/** The exact phrases OUR transport raises when it cannot reach the hub. */
|
|
7848
|
+
var TRANSPORT_PHRASES = [
|
|
7849
|
+
"discovery deadline exceeded",
|
|
7850
|
+
"parent could not route child unowned cap call",
|
|
7851
|
+
"UDS request timed out after",
|
|
7852
|
+
"channel closed"
|
|
7853
|
+
];
|
|
7854
|
+
/** Moleculer error `type`s of a call that could not be served right now. */
|
|
7855
|
+
var MOLECULER_TRANSIENT_TYPES = new Set([
|
|
7856
|
+
"REQUEST_TIMEOUT",
|
|
7857
|
+
"SERVICE_NOT_FOUND",
|
|
7858
|
+
"SERVICE_NOT_AVAILABLE",
|
|
7859
|
+
"REQUEST_REJECTED",
|
|
7860
|
+
"BROKER_DISCONNECTED"
|
|
7861
|
+
]);
|
|
7862
|
+
function stringProp(value, key) {
|
|
7863
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
7864
|
+
const found = Reflect.get(value, key);
|
|
7865
|
+
return typeof found === "string" ? found : void 0;
|
|
7866
|
+
}
|
|
7867
|
+
/** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
|
|
7868
|
+
function errorCode(err) {
|
|
7869
|
+
const out = {};
|
|
7870
|
+
const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
|
|
7871
|
+
const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
|
|
7872
|
+
const node = stringProp(err, "code") ?? stringProp(cause, "code");
|
|
7873
|
+
if (node !== void 0) out.node = node;
|
|
7874
|
+
const trpc = stringProp(data, "code");
|
|
7875
|
+
if (trpc !== void 0) out.trpc = trpc;
|
|
7876
|
+
return out;
|
|
7877
|
+
}
|
|
7878
|
+
/**
|
|
7879
|
+
* Is a settings read failure worth retrying, and with which budget? Only
|
|
7880
|
+
* EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
|
|
7881
|
+
* one of the exact phrases our own transport raises. A message that merely
|
|
7882
|
+
* contains "timed out" or "unreachable" is not evidence of anything, and
|
|
7883
|
+
* `settings store not wired` is a wiring bug that retrying cannot fix.
|
|
7884
|
+
*/
|
|
7885
|
+
function classifyStoreError(err) {
|
|
7886
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7887
|
+
if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
|
|
7888
|
+
const code = errorCode(err);
|
|
7889
|
+
if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
|
|
7890
|
+
if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
|
|
7891
|
+
if (typeof err === "object" && err !== null) {
|
|
7892
|
+
if (Reflect.get(err, "retryable") === true) return "transport";
|
|
7893
|
+
const type = stringProp(err, "type");
|
|
7894
|
+
if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
|
|
7895
|
+
}
|
|
7896
|
+
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
7897
|
+
return "permanent";
|
|
7898
|
+
}
|
|
7656
7899
|
/**
|
|
7657
7900
|
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
7658
7901
|
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
@@ -7742,6 +7985,365 @@ var PeerBytesTicketSchema = object({
|
|
|
7742
7985
|
*/
|
|
7743
7986
|
declaredBytes: number().int().nonnegative().nullable()
|
|
7744
7987
|
});
|
|
7988
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7989
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7990
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7991
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7992
|
+
var RECORD_CLASSES = [
|
|
7993
|
+
"config",
|
|
7994
|
+
"ledger",
|
|
7995
|
+
"audit",
|
|
7996
|
+
"mirror",
|
|
7997
|
+
"ephemeral"
|
|
7998
|
+
];
|
|
7999
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8000
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8001
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
8002
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
8003
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8004
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8005
|
+
var PREFIX = "records/";
|
|
8006
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8007
|
+
var RecordsError = class extends Error {
|
|
8008
|
+
code;
|
|
8009
|
+
detail;
|
|
8010
|
+
constructor(code, detail) {
|
|
8011
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
8012
|
+
this.name = "RecordsError";
|
|
8013
|
+
this.code = code;
|
|
8014
|
+
this.detail = detail;
|
|
8015
|
+
}
|
|
8016
|
+
};
|
|
8017
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8018
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8019
|
+
constructor(detail) {
|
|
8020
|
+
super("secret-unavailable", detail);
|
|
8021
|
+
this.name = "RecordSecretUnavailableError";
|
|
8022
|
+
}
|
|
8023
|
+
};
|
|
8024
|
+
var InvalidRecordError = class extends RecordsError {
|
|
8025
|
+
constructor(detail) {
|
|
8026
|
+
super("invalid-record", detail);
|
|
8027
|
+
this.name = "InvalidRecordError";
|
|
8028
|
+
}
|
|
8029
|
+
};
|
|
8030
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8031
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
8032
|
+
constructor(detail) {
|
|
8033
|
+
super("declaration-refused", detail);
|
|
8034
|
+
this.name = "DeclarationRefusedError";
|
|
8035
|
+
}
|
|
8036
|
+
};
|
|
8037
|
+
function defOf(schema) {
|
|
8038
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8039
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8040
|
+
const def = Reflect.get(zodBag, "def");
|
|
8041
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8042
|
+
return def;
|
|
8043
|
+
}
|
|
8044
|
+
function declaredHere(schema) {
|
|
8045
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8046
|
+
}
|
|
8047
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8048
|
+
var WRAPPERS = new Set([
|
|
8049
|
+
"optional",
|
|
8050
|
+
"nullable",
|
|
8051
|
+
"default",
|
|
8052
|
+
"prefault",
|
|
8053
|
+
"catch",
|
|
8054
|
+
"readonly",
|
|
8055
|
+
"nonoptional"
|
|
8056
|
+
]);
|
|
8057
|
+
/**
|
|
8058
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8059
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8060
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8061
|
+
* `.transform` on `in`).
|
|
8062
|
+
*/
|
|
8063
|
+
function layersOf(schema) {
|
|
8064
|
+
const out = [];
|
|
8065
|
+
const queue = [schema];
|
|
8066
|
+
while (queue.length > 0) {
|
|
8067
|
+
const s = queue.shift();
|
|
8068
|
+
if (!s || out.includes(s)) continue;
|
|
8069
|
+
out.push(s);
|
|
8070
|
+
const def = defOf(s);
|
|
8071
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8072
|
+
if (def.type === "pipe") {
|
|
8073
|
+
if (def.in) queue.push(def.in);
|
|
8074
|
+
if (def.out) queue.push(def.out);
|
|
8075
|
+
}
|
|
8076
|
+
}
|
|
8077
|
+
return out;
|
|
8078
|
+
}
|
|
8079
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8080
|
+
function isZodSecret(schema) {
|
|
8081
|
+
return layersOf(schema).some(declaredHere);
|
|
8082
|
+
}
|
|
8083
|
+
/**
|
|
8084
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8085
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8086
|
+
* object or array is reported as one path and not descended into — everything
|
|
8087
|
+
* under it is secret.
|
|
8088
|
+
*/
|
|
8089
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8090
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8091
|
+
const paths = [];
|
|
8092
|
+
for (const layer of layersOf(schema)) {
|
|
8093
|
+
const def = defOf(layer);
|
|
8094
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8095
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8096
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8097
|
+
else if (def.type === "intersection") {
|
|
8098
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8099
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8100
|
+
}
|
|
8101
|
+
}
|
|
8102
|
+
return [...new Set(paths)];
|
|
8103
|
+
}
|
|
8104
|
+
/**
|
|
8105
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8106
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8107
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8108
|
+
*
|
|
8109
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8110
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8111
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8112
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8113
|
+
*
|
|
8114
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8115
|
+
*/
|
|
8116
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8117
|
+
function parseSecretPath(path) {
|
|
8118
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8119
|
+
return path.split(".").map((raw) => {
|
|
8120
|
+
const each = raw.endsWith("[]");
|
|
8121
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8122
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8123
|
+
return {
|
|
8124
|
+
key,
|
|
8125
|
+
each
|
|
8126
|
+
};
|
|
8127
|
+
});
|
|
8128
|
+
}
|
|
8129
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8130
|
+
function secretArrayPrefixes(path) {
|
|
8131
|
+
const segments = parseSecretPath(path);
|
|
8132
|
+
const prefixes = [];
|
|
8133
|
+
const walked = [];
|
|
8134
|
+
for (const segment of segments) {
|
|
8135
|
+
walked.push(segment.key);
|
|
8136
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8137
|
+
}
|
|
8138
|
+
return prefixes;
|
|
8139
|
+
}
|
|
8140
|
+
/**
|
|
8141
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8142
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8143
|
+
* JSON the engine stores.
|
|
8144
|
+
*
|
|
8145
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
8146
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
8147
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
8148
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
8149
|
+
* never a field name (D879).
|
|
8150
|
+
*/
|
|
8151
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
8152
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
8153
|
+
var RecordIndexSchema = object({
|
|
8154
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
8155
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
8156
|
+
unique: boolean().optional()
|
|
8157
|
+
}).strict();
|
|
8158
|
+
var RecordRetentionSchema = union([
|
|
8159
|
+
object({
|
|
8160
|
+
ttlMs: number().int().positive(),
|
|
8161
|
+
from: _enum(["at", "write"])
|
|
8162
|
+
}).strict(),
|
|
8163
|
+
object({
|
|
8164
|
+
maxRows: number().int().positive().optional(),
|
|
8165
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
8166
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
8167
|
+
object({
|
|
8168
|
+
owner: string().min(1),
|
|
8169
|
+
reason: string().min(1)
|
|
8170
|
+
}).strict(),
|
|
8171
|
+
object({ none: string().min(1) }).strict()
|
|
8172
|
+
]);
|
|
8173
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
8174
|
+
var EntryDescriptorSchema = object({
|
|
8175
|
+
title: string().min(1),
|
|
8176
|
+
/** The record body field shown as the entry's name. */
|
|
8177
|
+
nameField: string().min(1),
|
|
8178
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
8179
|
+
fields: record(string(), unknown())
|
|
8180
|
+
}).strict();
|
|
8181
|
+
/** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
|
|
8182
|
+
var RecordKindDeclarationSchema = object({
|
|
8183
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
8184
|
+
class: _enum(RECORD_CLASSES),
|
|
8185
|
+
writeTrigger: string().min(1),
|
|
8186
|
+
device: _enum([
|
|
8187
|
+
"required",
|
|
8188
|
+
"optional",
|
|
8189
|
+
"none"
|
|
8190
|
+
]).default("none"),
|
|
8191
|
+
at: _enum(["required", "none"]).default("none"),
|
|
8192
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
8193
|
+
retention: RecordRetentionSchema,
|
|
8194
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
8195
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
8196
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
8197
|
+
secretPaths: array(string().min(1)).default([]),
|
|
8198
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
8199
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
8200
|
+
/** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
|
|
8201
|
+
adoptsFrom: string().min(1).optional(),
|
|
8202
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
8203
|
+
transactFamily: string().min(1).optional(),
|
|
8204
|
+
entry: EntryDescriptorSchema.optional()
|
|
8205
|
+
}).strict();
|
|
8206
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8207
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
8208
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
8209
|
+
function assertValidDeclaration(name, decl) {
|
|
8210
|
+
const refuse = (why) => {
|
|
8211
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
8212
|
+
};
|
|
8213
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
8214
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8215
|
+
for (const index of decl.indexes) {
|
|
8216
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
8217
|
+
seen.add(index.name);
|
|
8218
|
+
}
|
|
8219
|
+
const { retention } = decl;
|
|
8220
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
8221
|
+
if ("ttlMs" in retention) {
|
|
8222
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
8223
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
8224
|
+
}
|
|
8225
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
8226
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
8227
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
8228
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
8229
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
8230
|
+
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)`);
|
|
8231
|
+
}
|
|
8232
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
8233
|
+
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`);
|
|
8234
|
+
}
|
|
8235
|
+
function bodyFieldsOf(schema) {
|
|
8236
|
+
return { ...toJSONSchema(schema, {
|
|
8237
|
+
unrepresentable: "any",
|
|
8238
|
+
io: "input"
|
|
8239
|
+
}) };
|
|
8240
|
+
}
|
|
8241
|
+
function isRecordLike(value) {
|
|
8242
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8243
|
+
}
|
|
8244
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
8245
|
+
function hasNameField(json, field) {
|
|
8246
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
8247
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
8248
|
+
const properties = json["properties"];
|
|
8249
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
8250
|
+
}
|
|
8251
|
+
/**
|
|
8252
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
8253
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
8254
|
+
* types its handle from.
|
|
8255
|
+
*/
|
|
8256
|
+
function defineRecordKinds(specs) {
|
|
8257
|
+
const out = {};
|
|
8258
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
8259
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
8260
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
8261
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
8262
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
8263
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
8264
|
+
database: spec.database,
|
|
8265
|
+
class: spec.class,
|
|
8266
|
+
writeTrigger: spec.writeTrigger,
|
|
8267
|
+
device: spec.device,
|
|
8268
|
+
at: spec.at,
|
|
8269
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
8270
|
+
retention: spec.retention,
|
|
8271
|
+
deviceRemoval: spec.deviceRemoval,
|
|
8272
|
+
maxDataBytes: spec.maxDataBytes,
|
|
8273
|
+
secretPaths: [...secretPaths],
|
|
8274
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
8275
|
+
adoptsFrom: spec.adoptsFrom,
|
|
8276
|
+
transactFamily: spec.transactFamily,
|
|
8277
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
8278
|
+
title: spec.entry.title,
|
|
8279
|
+
nameField,
|
|
8280
|
+
fields
|
|
8281
|
+
}
|
|
8282
|
+
});
|
|
8283
|
+
assertValidDeclaration(name, parsed);
|
|
8284
|
+
out[name] = {
|
|
8285
|
+
name,
|
|
8286
|
+
schema: spec.schema,
|
|
8287
|
+
declaration: parsed
|
|
8288
|
+
};
|
|
8289
|
+
}
|
|
8290
|
+
return out;
|
|
8291
|
+
}
|
|
8292
|
+
/**
|
|
8293
|
+
* Entry kinds (D881): every list of user-created entries (notification
|
|
8294
|
+
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
8295
|
+
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
8296
|
+
* through the `record-entries` capability with password fields derived from
|
|
8297
|
+
* the schema (`.meta({ secret: true })`).
|
|
8298
|
+
*/
|
|
8299
|
+
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
8300
|
+
function entryBody(shape) {
|
|
8301
|
+
return object({
|
|
8302
|
+
name: string().min(1),
|
|
8303
|
+
...shape
|
|
8304
|
+
});
|
|
8305
|
+
}
|
|
8306
|
+
/**
|
|
8307
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
8308
|
+
* engine, never aged, belonging to no device.
|
|
8309
|
+
*/
|
|
8310
|
+
function defineEntryKind(name, spec) {
|
|
8311
|
+
const defined = defineRecordKinds({ [name]: {
|
|
8312
|
+
schema: spec.schema,
|
|
8313
|
+
class: "config",
|
|
8314
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
8315
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
8316
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
8317
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
8318
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
8319
|
+
...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
|
|
8320
|
+
entry: {
|
|
8321
|
+
title: spec.title,
|
|
8322
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
8323
|
+
}
|
|
8324
|
+
} })[name];
|
|
8325
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
8326
|
+
return defined;
|
|
8327
|
+
}
|
|
8328
|
+
/**
|
|
8329
|
+
* Legacy source for broker entry adoption (B2): brokers live in addon-settings
|
|
8330
|
+
* as one row `<addonId>.brokers` whose value is an array until records-adopt
|
|
8331
|
+
* copies them into the entry kind.
|
|
8332
|
+
*/
|
|
8333
|
+
var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
|
|
8334
|
+
/** The `adoptsFrom` value for an addon's broker entry kind. */
|
|
8335
|
+
function settingsBrokersAdoptsFrom(addonId) {
|
|
8336
|
+
return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
|
|
8337
|
+
}
|
|
8338
|
+
/**
|
|
8339
|
+
* Legacy source for entry adoption (B3): a list stored under addon-settings
|
|
8340
|
+
* `<addonId>.<key>` until records-adopt copies rows into the entry kind.
|
|
8341
|
+
*/
|
|
8342
|
+
var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
|
|
8343
|
+
/** The `adoptsFrom` value for an addon-settings array field. */
|
|
8344
|
+
function settingsArrayAdoptsFrom(addonId, settingsKey) {
|
|
8345
|
+
return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
|
|
8346
|
+
}
|
|
7745
8347
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
7746
8348
|
var CamProfileSchema = _enum([
|
|
7747
8349
|
"high",
|
|
@@ -8207,7 +8809,7 @@ object({
|
|
|
8207
8809
|
params: record(string(), union([string(), number()])).optional()
|
|
8208
8810
|
});
|
|
8209
8811
|
//#endregion
|
|
8210
|
-
//#region ../types/dist/err-msg
|
|
8812
|
+
//#region ../types/dist/err-msg--2RrYiLO.mjs
|
|
8211
8813
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
8212
8814
|
DeviceType["Camera"] = "camera";
|
|
8213
8815
|
DeviceType["Hub"] = "hub";
|
|
@@ -8476,6 +9078,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8476
9078
|
/** Virtual HA toggle (input_boolean.*) — distinguishable from a
|
|
8477
9079
|
* real Switch device for UI rendering / export adapters. */
|
|
8478
9080
|
DeviceRole["BinaryHelper"] = "binary-helper";
|
|
9081
|
+
/** A smart plug: a `switch` whose source says it is an outlet (HA
|
|
9082
|
+
* `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
|
|
9083
|
+
DeviceRole["Outlet"] = "outlet";
|
|
8479
9084
|
/** Generic motion / occupancy / moving event source. Distinct from
|
|
8480
9085
|
* the camera accessory PirSensor role: that one is a camera child;
|
|
8481
9086
|
* this is a standalone HA / 3rd-party motion sensor. */
|
|
@@ -8543,7 +9148,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8543
9148
|
return DeviceRole;
|
|
8544
9149
|
}({});
|
|
8545
9150
|
//#endregion
|
|
8546
|
-
//#region ../types/dist/composition-
|
|
9151
|
+
//#region ../types/dist/composition-DOwQB_Ua.mjs
|
|
8547
9152
|
/**
|
|
8548
9153
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
8549
9154
|
*
|
|
@@ -11747,11 +12352,10 @@ var ClipModelMetaSchema = object({
|
|
|
11747
12352
|
/**
|
|
11748
12353
|
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
11749
12354
|
* per index: two models share an index only when their vectors are ranked
|
|
11750
|
-
* against each other, which for CLIP means never across families.
|
|
11751
|
-
*
|
|
11752
|
-
* `modelId`); any other model gets its own.
|
|
12355
|
+
* against each other, which for CLIP means never across families. Every
|
|
12356
|
+
* model gets its own.
|
|
11753
12357
|
*/
|
|
11754
|
-
vectorIndex: string().regex(/^object-clip
|
|
12358
|
+
vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
11755
12359
|
/**
|
|
11756
12360
|
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
11757
12361
|
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
@@ -15427,6 +16031,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
15427
16031
|
keyField: string()
|
|
15428
16032
|
}).optional()
|
|
15429
16033
|
})) });
|
|
16034
|
+
/**
|
|
16035
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
16036
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
16037
|
+
*
|
|
16038
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
16039
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
16040
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
16041
|
+
*/
|
|
16042
|
+
var RawSecretMigrationInputSchema = object({
|
|
16043
|
+
/** `false` (the default of the script) = report only. */
|
|
16044
|
+
apply: boolean() });
|
|
16045
|
+
var RawSecretMigrationReportSchema = object({
|
|
16046
|
+
apply: boolean(),
|
|
16047
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
16048
|
+
rows: number().int(),
|
|
16049
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
16050
|
+
raw: number().int(),
|
|
16051
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
16052
|
+
markers: number().int(),
|
|
16053
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
16054
|
+
migrated: number().int(),
|
|
16055
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
16056
|
+
failed: number().int(),
|
|
16057
|
+
/** After the run: rows still holding plaintext. */
|
|
16058
|
+
remainingRaw: number().int(),
|
|
16059
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
16060
|
+
unresolvedMarkers: number().int(),
|
|
16061
|
+
/**
|
|
16062
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
16063
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
16064
|
+
*/
|
|
16065
|
+
redundantCopies: number().int().optional(),
|
|
16066
|
+
/** True when nothing is raw and every marker resolves. */
|
|
16067
|
+
verified: boolean()
|
|
16068
|
+
});
|
|
15430
16069
|
/** Where a block runs. The operator chooses — a block driving a device on an
|
|
15431
16070
|
* agent is the reason placement is not fixed to the hub. */
|
|
15432
16071
|
var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
|
|
@@ -15653,6 +16292,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
15653
16292
|
}), SettingsUpdateResultSchema, {
|
|
15654
16293
|
kind: "mutation",
|
|
15655
16294
|
auth: "admin"
|
|
16295
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
16296
|
+
kind: "mutation",
|
|
16297
|
+
auth: "admin"
|
|
15656
16298
|
}), method(object({}), object({ libs: array(object({
|
|
15657
16299
|
filePath: string(),
|
|
15658
16300
|
content: string()
|
|
@@ -15916,6 +16558,347 @@ id: union([string(), number()]) }), {
|
|
|
15916
16558
|
auth: "admin"
|
|
15917
16559
|
});
|
|
15918
16560
|
/**
|
|
16561
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
16562
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
16563
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
16564
|
+
*
|
|
16565
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
16566
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
16567
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
16568
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
16569
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
16570
|
+
* addons go through the owner's capability.
|
|
16571
|
+
*
|
|
16572
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
16573
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
16574
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
16575
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
16576
|
+
* row's own ref.
|
|
16577
|
+
*
|
|
16578
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
16579
|
+
*/
|
|
16580
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
16581
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
16582
|
+
var RecordBodySchema = record(string(), unknown());
|
|
16583
|
+
var RecordInputSchema = object({
|
|
16584
|
+
id: RecordIdSchema,
|
|
16585
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
16586
|
+
deviceId: number().int().optional(),
|
|
16587
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
16588
|
+
at: number().int().optional(),
|
|
16589
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
16590
|
+
expiresAt: number().int().optional(),
|
|
16591
|
+
data: RecordBodySchema
|
|
16592
|
+
});
|
|
16593
|
+
var RecordViewSchema = object({
|
|
16594
|
+
id: string(),
|
|
16595
|
+
deviceId: number().int().nullable(),
|
|
16596
|
+
at: number().nullable(),
|
|
16597
|
+
expiresAt: number().nullable(),
|
|
16598
|
+
rev: number().int(),
|
|
16599
|
+
updatedAt: number(),
|
|
16600
|
+
data: RecordBodySchema
|
|
16601
|
+
});
|
|
16602
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
16603
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
16604
|
+
string(),
|
|
16605
|
+
number(),
|
|
16606
|
+
boolean(),
|
|
16607
|
+
object({ in: array(union([
|
|
16608
|
+
string(),
|
|
16609
|
+
number(),
|
|
16610
|
+
boolean()
|
|
16611
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
16612
|
+
object({
|
|
16613
|
+
gt: union([string(), number()]).optional(),
|
|
16614
|
+
gte: union([string(), number()]).optional(),
|
|
16615
|
+
lt: union([string(), number()]).optional(),
|
|
16616
|
+
lte: union([string(), number()]).optional()
|
|
16617
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
16618
|
+
]));
|
|
16619
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
16620
|
+
var TimeWindowShape = {
|
|
16621
|
+
deviceId: number().int().optional(),
|
|
16622
|
+
atFrom: number().optional(),
|
|
16623
|
+
atTo: number().optional()
|
|
16624
|
+
};
|
|
16625
|
+
var RecordQueryInputSchema = object({
|
|
16626
|
+
...KindShape,
|
|
16627
|
+
...TimeWindowShape,
|
|
16628
|
+
where: RecordWhereSchema.optional(),
|
|
16629
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
16630
|
+
order: _enum(["at", "id"]).optional(),
|
|
16631
|
+
desc: boolean().optional(),
|
|
16632
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
16633
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
16634
|
+
cursor: string().min(1).optional()
|
|
16635
|
+
});
|
|
16636
|
+
var RecordQueryResultSchema = object({
|
|
16637
|
+
records: array(RecordViewSchema),
|
|
16638
|
+
nextCursor: string().nullable()
|
|
16639
|
+
});
|
|
16640
|
+
var RecordKindStateSchema = _enum([
|
|
16641
|
+
"created",
|
|
16642
|
+
"unchanged",
|
|
16643
|
+
"updated"
|
|
16644
|
+
]);
|
|
16645
|
+
var DeclareKindResultSchema = object({
|
|
16646
|
+
kindId: number().int(),
|
|
16647
|
+
state: RecordKindStateSchema,
|
|
16648
|
+
createdIndexes: array(string()),
|
|
16649
|
+
/** The boot guard: the kind is empty while its legacy table still holds rows. */
|
|
16650
|
+
adoptionPending: object({
|
|
16651
|
+
legacyTable: string(),
|
|
16652
|
+
legacyRows: number().int()
|
|
16653
|
+
}).nullable()
|
|
16654
|
+
});
|
|
16655
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
16656
|
+
var SecretRefsList = array(string());
|
|
16657
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
16658
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
16659
|
+
kind: "mutation",
|
|
16660
|
+
auth: "admin"
|
|
16661
|
+
}), method(object({
|
|
16662
|
+
...KindShape,
|
|
16663
|
+
id: RecordIdSchema
|
|
16664
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
16665
|
+
...KindShape,
|
|
16666
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16667
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
16668
|
+
...KindShape,
|
|
16669
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16670
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
16671
|
+
...KindShape,
|
|
16672
|
+
record: RecordInputSchema,
|
|
16673
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
16674
|
+
ifRev: number().int().min(0).optional()
|
|
16675
|
+
}), object({
|
|
16676
|
+
rev: number().int(),
|
|
16677
|
+
releasedRefs: SecretRefsList
|
|
16678
|
+
}), {
|
|
16679
|
+
kind: "mutation",
|
|
16680
|
+
auth: "admin"
|
|
16681
|
+
}), method(object({
|
|
16682
|
+
...KindShape,
|
|
16683
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16684
|
+
}), object({
|
|
16685
|
+
count: number().int(),
|
|
16686
|
+
releasedRefs: SecretRefsList
|
|
16687
|
+
}), {
|
|
16688
|
+
kind: "mutation",
|
|
16689
|
+
auth: "admin"
|
|
16690
|
+
}), method(object({
|
|
16691
|
+
...KindShape,
|
|
16692
|
+
id: RecordIdSchema,
|
|
16693
|
+
data: RecordBodySchema,
|
|
16694
|
+
at: number().int().nullable().optional(),
|
|
16695
|
+
expiresAt: number().int().nullable().optional(),
|
|
16696
|
+
ifRev: number().int().min(1).optional()
|
|
16697
|
+
}), object({
|
|
16698
|
+
rev: number().int(),
|
|
16699
|
+
releasedRefs: SecretRefsList
|
|
16700
|
+
}), {
|
|
16701
|
+
kind: "mutation",
|
|
16702
|
+
auth: "admin"
|
|
16703
|
+
}), method(object({
|
|
16704
|
+
...KindShape,
|
|
16705
|
+
id: RecordIdSchema
|
|
16706
|
+
}), object({
|
|
16707
|
+
deleted: boolean(),
|
|
16708
|
+
secretRefs: SecretRefsList
|
|
16709
|
+
}), {
|
|
16710
|
+
kind: "mutation",
|
|
16711
|
+
auth: "admin"
|
|
16712
|
+
}), method(object({
|
|
16713
|
+
...KindShape,
|
|
16714
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16715
|
+
}), object({
|
|
16716
|
+
deleted: number().int(),
|
|
16717
|
+
secretRefs: SecretRefsList
|
|
16718
|
+
}), {
|
|
16719
|
+
kind: "mutation",
|
|
16720
|
+
auth: "admin"
|
|
16721
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16722
|
+
...KindShape,
|
|
16723
|
+
...TimeWindowShape,
|
|
16724
|
+
where: RecordWhereSchema.optional()
|
|
16725
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
16726
|
+
...KindShape,
|
|
16727
|
+
deviceId: number().int().optional(),
|
|
16728
|
+
from: number(),
|
|
16729
|
+
to: number(),
|
|
16730
|
+
bucketMs: number().int().positive()
|
|
16731
|
+
}), object({ buckets: array(object({
|
|
16732
|
+
bucketStart: number(),
|
|
16733
|
+
count: number().int()
|
|
16734
|
+
})) }), { auth: "admin" }), method(object({
|
|
16735
|
+
...KindShape,
|
|
16736
|
+
op: _enum([
|
|
16737
|
+
"sum",
|
|
16738
|
+
"min",
|
|
16739
|
+
"max",
|
|
16740
|
+
"count"
|
|
16741
|
+
]),
|
|
16742
|
+
field: RecordFieldPathSchema.optional(),
|
|
16743
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
16744
|
+
where: RecordWhereSchema.optional()
|
|
16745
|
+
}), object({ rows: array(object({
|
|
16746
|
+
group: union([
|
|
16747
|
+
string(),
|
|
16748
|
+
number(),
|
|
16749
|
+
_null()
|
|
16750
|
+
]),
|
|
16751
|
+
value: number().nullable()
|
|
16752
|
+
})) }), { auth: "admin" }), method(object({
|
|
16753
|
+
...KindShape,
|
|
16754
|
+
deviceId: number().int().optional(),
|
|
16755
|
+
atBefore: number().optional(),
|
|
16756
|
+
where: RecordWhereSchema.optional()
|
|
16757
|
+
}), object({
|
|
16758
|
+
deleted: number().int(),
|
|
16759
|
+
secretRefs: SecretRefsList
|
|
16760
|
+
}), {
|
|
16761
|
+
kind: "mutation",
|
|
16762
|
+
auth: "admin"
|
|
16763
|
+
}), method(object({
|
|
16764
|
+
deviceId: number().int(),
|
|
16765
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
16766
|
+
}), object({
|
|
16767
|
+
deleted: record(string(), number().int()),
|
|
16768
|
+
secretRefs: SecretRefsList
|
|
16769
|
+
}), {
|
|
16770
|
+
kind: "mutation",
|
|
16771
|
+
auth: "admin"
|
|
16772
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
16773
|
+
kind: "mutation",
|
|
16774
|
+
auth: "admin"
|
|
16775
|
+
});
|
|
16776
|
+
/** One table of the settings database. */
|
|
16777
|
+
var StorageTableSchema = object({
|
|
16778
|
+
/** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
|
|
16779
|
+
name: string(),
|
|
16780
|
+
/** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
|
|
16781
|
+
owner: string().nullable(),
|
|
16782
|
+
rows: number().int().nonnegative(),
|
|
16783
|
+
/** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
|
|
16784
|
+
bytes: number().int().nonnegative().nullable(),
|
|
16785
|
+
/** Declared by an addon since this engine process started (a running addon claims it). */
|
|
16786
|
+
declaredThisBoot: boolean()
|
|
16787
|
+
});
|
|
16788
|
+
/** One declared record kind (D881) as System -> Data shows it. */
|
|
16789
|
+
var StorageKindSchema = object({
|
|
16790
|
+
owner: string(),
|
|
16791
|
+
kind: string(),
|
|
16792
|
+
database: _enum(["settings", "events"]),
|
|
16793
|
+
class: string(),
|
|
16794
|
+
state: _enum([
|
|
16795
|
+
"declared",
|
|
16796
|
+
"orphaned",
|
|
16797
|
+
"dropped"
|
|
16798
|
+
]),
|
|
16799
|
+
/** `null` when the caller asked for no counts (`counts: false`). */
|
|
16800
|
+
rows: number().int().nonnegative().nullable(),
|
|
16801
|
+
/** Rows x the average size of a sample; null for an empty kind. */
|
|
16802
|
+
bytesEstimate: number().int().nonnegative().nullable(),
|
|
16803
|
+
writeTrigger: string(),
|
|
16804
|
+
retention: RecordRetentionSchema,
|
|
16805
|
+
/** `true` when the kind is an entry kind (the generic entries UI lists it). */
|
|
16806
|
+
entry: boolean(),
|
|
16807
|
+
/** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
|
|
16808
|
+
declaration: RecordKindDeclarationSchema
|
|
16809
|
+
});
|
|
16810
|
+
method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
|
|
16811
|
+
collection: string().min(1),
|
|
16812
|
+
expectRows: number().int().nonnegative()
|
|
16813
|
+
}), object({
|
|
16814
|
+
dropped: literal(true),
|
|
16815
|
+
rows: number().int().nonnegative()
|
|
16816
|
+
}), {
|
|
16817
|
+
kind: "mutation",
|
|
16818
|
+
auth: "admin"
|
|
16819
|
+
}), method(object({
|
|
16820
|
+
owner: string().min(1).optional(),
|
|
16821
|
+
/** `false` skips the per-kind row count (a catalog read only). Default true. */
|
|
16822
|
+
counts: boolean().optional()
|
|
16823
|
+
}), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
|
|
16824
|
+
owner: string().min(1),
|
|
16825
|
+
kind: RecordKindNameSchema
|
|
16826
|
+
}), RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16827
|
+
owner: string().min(1),
|
|
16828
|
+
kind: RecordKindNameSchema,
|
|
16829
|
+
records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
16830
|
+
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
16831
|
+
complete: boolean().optional()
|
|
16832
|
+
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
|
|
16833
|
+
kind: "mutation",
|
|
16834
|
+
auth: "admin"
|
|
16835
|
+
}), method(object({
|
|
16836
|
+
collection: string().min(1),
|
|
16837
|
+
cursor: string().optional(),
|
|
16838
|
+
limit: number().int().min(1).max(1e3).optional()
|
|
16839
|
+
}), object({
|
|
16840
|
+
rows: array(object({
|
|
16841
|
+
id: string(),
|
|
16842
|
+
data: record(string(), unknown())
|
|
16843
|
+
})),
|
|
16844
|
+
nextCursor: string().nullable()
|
|
16845
|
+
}), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
|
|
16846
|
+
/**
|
|
16847
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
16848
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
16849
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
16850
|
+
*
|
|
16851
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
16852
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
16853
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
16854
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16855
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
16856
|
+
* a secret value, and a locked keychain refuses the write with
|
|
16857
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
16858
|
+
*
|
|
16859
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
16860
|
+
*/
|
|
16861
|
+
var EntryKindInfoSchema = object({
|
|
16862
|
+
owner: string(),
|
|
16863
|
+
kind: RecordKindNameSchema,
|
|
16864
|
+
title: string(),
|
|
16865
|
+
nameField: string(),
|
|
16866
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
16867
|
+
fields: record(string(), unknown()),
|
|
16868
|
+
secretPaths: array(string()),
|
|
16869
|
+
rows: number().int().nonnegative()
|
|
16870
|
+
});
|
|
16871
|
+
var EntryViewSchema = object({
|
|
16872
|
+
id: RecordIdSchema,
|
|
16873
|
+
name: string(),
|
|
16874
|
+
rev: number().int(),
|
|
16875
|
+
updatedAt: number(),
|
|
16876
|
+
/** Secret fields hold the redaction token. */
|
|
16877
|
+
data: RecordBodySchema
|
|
16878
|
+
});
|
|
16879
|
+
var EntryAddress = {
|
|
16880
|
+
owner: string().min(1),
|
|
16881
|
+
kind: RecordKindNameSchema
|
|
16882
|
+
};
|
|
16883
|
+
method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
|
|
16884
|
+
...EntryAddress,
|
|
16885
|
+
id: RecordIdSchema.optional(),
|
|
16886
|
+
data: RecordBodySchema,
|
|
16887
|
+
ifRev: number().int().min(1).optional()
|
|
16888
|
+
}), object({
|
|
16889
|
+
id: string(),
|
|
16890
|
+
rev: number().int()
|
|
16891
|
+
}), {
|
|
16892
|
+
kind: "mutation",
|
|
16893
|
+
auth: "admin"
|
|
16894
|
+
}), method(object({
|
|
16895
|
+
...EntryAddress,
|
|
16896
|
+
id: RecordIdSchema
|
|
16897
|
+
}), object({ deleted: boolean() }), {
|
|
16898
|
+
kind: "mutation",
|
|
16899
|
+
auth: "admin"
|
|
16900
|
+
});
|
|
16901
|
+
/**
|
|
15919
16902
|
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
15920
16903
|
*
|
|
15921
16904
|
* Settings blobs never hold a secret: they hold a marker
|
|
@@ -16456,6 +17439,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
|
|
|
16456
17439
|
kind: "mutation",
|
|
16457
17440
|
auth: "admin",
|
|
16458
17441
|
caller: "required"
|
|
17442
|
+
}), method(object({
|
|
17443
|
+
ref: string().min(1),
|
|
17444
|
+
value: string().min(1)
|
|
17445
|
+
}), object({
|
|
17446
|
+
ref: string(),
|
|
17447
|
+
version: number().int()
|
|
17448
|
+
}), {
|
|
17449
|
+
kind: "mutation",
|
|
17450
|
+
auth: "admin",
|
|
17451
|
+
caller: "required"
|
|
16459
17452
|
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
16460
17453
|
deleted: array(string()).readonly(),
|
|
16461
17454
|
kept: array(object({
|
|
@@ -38925,6 +39918,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
|
|
|
38925
39918
|
}), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
|
|
38926
39919
|
kind: "mutation",
|
|
38927
39920
|
auth: "admin"
|
|
39921
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
39922
|
+
kind: "mutation",
|
|
39923
|
+
auth: "admin"
|
|
38928
39924
|
}), method(ProfileRefInputSchema, _void(), {
|
|
38929
39925
|
kind: "mutation",
|
|
38930
39926
|
auth: "admin"
|
|
@@ -49367,6 +50363,41 @@ var ServerRollbackInfoSchema = object({
|
|
|
49367
50363
|
atMs: number(),
|
|
49368
50364
|
reason: string()
|
|
49369
50365
|
});
|
|
50366
|
+
/**
|
|
50367
|
+
* The runner boot check (D877): the runners this node PLANNED (hub: one per
|
|
50368
|
+
* `resolveRunnerId` over its forked addons; agent: the runners its process
|
|
50369
|
+
* service holds, because only the hub plans) against the states the process
|
|
50370
|
+
* service reports. Kept in memory, recomputed by the same one-shot check after
|
|
50371
|
+
* every boot, served on `getServerPackageStatus`.
|
|
50372
|
+
*
|
|
50373
|
+
* `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
|
|
50374
|
+
* refusal (an addon that said "I will not start, and here is why"), `missing` a
|
|
50375
|
+
* planned runner the process service has no entry for.
|
|
50376
|
+
*/
|
|
50377
|
+
var RunnerRefusalSchema = object({
|
|
50378
|
+
runnerId: string(),
|
|
50379
|
+
addonIds: array(string()),
|
|
50380
|
+
reason: string()
|
|
50381
|
+
});
|
|
50382
|
+
var RunnerBootCheckSchema = object({
|
|
50383
|
+
checkedAtMs: number(),
|
|
50384
|
+
/** Runners planned for this node. */
|
|
50385
|
+
expected: number(),
|
|
50386
|
+
/** Planned runners whose process is `running`. */
|
|
50387
|
+
running: number(),
|
|
50388
|
+
failed: array(string()),
|
|
50389
|
+
refused: array(RunnerRefusalSchema),
|
|
50390
|
+
missing: array(string()),
|
|
50391
|
+
/**
|
|
50392
|
+
* Runners still on their way: `starting`, or `crashed` waiting on a backoff
|
|
50393
|
+
* respawn. The check is FINAL only when this is empty; until then nothing is
|
|
50394
|
+
* pushed and the verdict is re-evaluated on the next runner state change.
|
|
50395
|
+
* Optional for version skew (absent = settled).
|
|
50396
|
+
*/
|
|
50397
|
+
pending: array(string()).optional(),
|
|
50398
|
+
/** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
|
|
50399
|
+
planKnown: boolean()
|
|
50400
|
+
});
|
|
49370
50401
|
var ServerPackageStatusSchema = object({
|
|
49371
50402
|
/** Root package name (`@camstack/server` on the hub). */
|
|
49372
50403
|
packageName: string(),
|
|
@@ -49429,7 +50460,14 @@ var ServerPackageStatusSchema = object({
|
|
|
49429
50460
|
* for version skew: an older provider's payload simply omits it, and an
|
|
49430
50461
|
* absent wrapper is unknown — never `native`.
|
|
49431
50462
|
*/
|
|
49432
|
-
wrapper: WrapperIdentitySchema.optional()
|
|
50463
|
+
wrapper: WrapperIdentitySchema.optional(),
|
|
50464
|
+
/**
|
|
50465
|
+
* What this node PLANNED to run against what its process service reports
|
|
50466
|
+
* (D877). Absent until the one-shot boot check has run (~60 s after boot) and
|
|
50467
|
+
* on a provider that predates it. Absent is "not checked yet", never "all
|
|
50468
|
+
* well": a consumer that needs the answer treats it as pending.
|
|
50469
|
+
*/
|
|
50470
|
+
runners: RunnerBootCheckSchema.optional()
|
|
49433
50471
|
});
|
|
49434
50472
|
var ServerUpdateCheckResultSchema = object({
|
|
49435
50473
|
packageName: string(),
|
|
@@ -49480,6 +50518,13 @@ var ServerUpdateOutcomeSchema = _enum([
|
|
|
49480
50518
|
"refused",
|
|
49481
50519
|
"failed"
|
|
49482
50520
|
]);
|
|
50521
|
+
/** One addon the pre-flight found the target version would refuse (D877). */
|
|
50522
|
+
var UpdateBlockerSchema = object({
|
|
50523
|
+
addonId: string(),
|
|
50524
|
+
reason: string(),
|
|
50525
|
+
/** What the operator does about it. */
|
|
50526
|
+
remedy: string()
|
|
50527
|
+
});
|
|
49483
50528
|
var ServerUpdateActionResultSchema = object({
|
|
49484
50529
|
accepted: boolean(),
|
|
49485
50530
|
targetVersion: string().nullable(),
|
|
@@ -49497,14 +50542,27 @@ var ServerUpdateActionResultSchema = object({
|
|
|
49497
50542
|
* The failure itself, verbatim enough to act on (the npm output for a
|
|
49498
50543
|
* staging install). Non-null only for `failed`.
|
|
49499
50544
|
*/
|
|
49500
|
-
error: string().nullable().optional()
|
|
50545
|
+
error: string().nullable().optional(),
|
|
50546
|
+
/**
|
|
50547
|
+
* The addons the target version would refuse to start on this node's live
|
|
50548
|
+
* store (D877), present when the pre-flight refused the update
|
|
50549
|
+
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
50550
|
+
*/
|
|
50551
|
+
blockers: array(UpdateBlockerSchema).optional()
|
|
49501
50552
|
});
|
|
49502
50553
|
method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
|
|
49503
50554
|
kind: "mutation",
|
|
49504
50555
|
auth: "admin"
|
|
49505
|
-
}), method(object({
|
|
49506
|
-
/** Explicit target version; omitted = latest from the registry. */
|
|
49507
|
-
version: string().optional()
|
|
50556
|
+
}), method(object({
|
|
50557
|
+
/** Explicit target version; omitted = latest from the registry. */
|
|
50558
|
+
version: string().optional(),
|
|
50559
|
+
/**
|
|
50560
|
+
* Apply even though the pre-flight (D877) found addons the target would
|
|
50561
|
+
* refuse to start. Off by default: those addons stay down until the
|
|
50562
|
+
* remedy is run, which is the incident this gate exists to prevent.
|
|
50563
|
+
*/
|
|
50564
|
+
acknowledgeRefusals: boolean().optional()
|
|
50565
|
+
}), ServerUpdateActionResultSchema, {
|
|
49508
50566
|
kind: "mutation",
|
|
49509
50567
|
auth: "admin",
|
|
49510
50568
|
timeoutMs: 16 * 6e4
|
|
@@ -51917,7 +52975,9 @@ var ManifestShapeSchema = object({
|
|
|
51917
52975
|
var AddonProcessSchema = object({
|
|
51918
52976
|
pid: number().optional(),
|
|
51919
52977
|
mode: string(),
|
|
51920
|
-
state: string()
|
|
52978
|
+
state: string(),
|
|
52979
|
+
/** Why the runner is `refused` (an addon's own words), when it is (D877). */
|
|
52980
|
+
reason: string().optional()
|
|
51921
52981
|
});
|
|
51922
52982
|
/**
|
|
51923
52983
|
* Per-addon health snapshot from the kernel's AddonHealthMonitor.
|
|
@@ -52920,6 +53980,12 @@ object({
|
|
|
52920
53980
|
/** Horizontal louver swing on/off. Null when the device has no
|
|
52921
53981
|
* horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
|
|
52922
53982
|
swingHorizontal: boolean().nullable(),
|
|
53983
|
+
/** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
53984
|
+
minTemp: number().nullable().optional(),
|
|
53985
|
+
/** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
53986
|
+
maxTemp: number().nullable().optional(),
|
|
53987
|
+
/** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
|
|
53988
|
+
tempStep: number().positive().nullable().optional(),
|
|
52923
53989
|
/** Ms epoch when the slice was last updated (push or command). */
|
|
52924
53990
|
lastFetchedAt: number()
|
|
52925
53991
|
});
|
|
@@ -54740,7 +55806,19 @@ var TlsStatusSchema = object({
|
|
|
54740
55806
|
sans: array(string()),
|
|
54741
55807
|
caCertPem: string().nullable(),
|
|
54742
55808
|
reissueError: string().nullable(),
|
|
54743
|
-
restartRequired: boolean()
|
|
55809
|
+
restartRequired: boolean(),
|
|
55810
|
+
/** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
|
|
55811
|
+
caMissing: boolean(),
|
|
55812
|
+
/** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
|
|
55813
|
+
localCaConstrained: boolean().nullable(),
|
|
55814
|
+
/** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
|
|
55815
|
+
caReplacedAt: string().nullable(),
|
|
55816
|
+
/** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
|
|
55817
|
+
storedUpload: object({
|
|
55818
|
+
leafFingerprintSha256: string(),
|
|
55819
|
+
validTo: string(),
|
|
55820
|
+
hasCa: boolean()
|
|
55821
|
+
}).nullable()
|
|
54744
55822
|
});
|
|
54745
55823
|
method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
|
|
54746
55824
|
/**
|
|
@@ -54796,6 +55874,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
|
|
|
54796
55874
|
}), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
|
|
54797
55875
|
kind: "mutation",
|
|
54798
55876
|
auth: "admin"
|
|
55877
|
+
}), method(_void(), TlsStatusSchema, {
|
|
55878
|
+
kind: "mutation",
|
|
55879
|
+
auth: "admin"
|
|
54799
55880
|
});
|
|
54800
55881
|
object({
|
|
54801
55882
|
/** Lifecycle state of the lock. `jammed` means the motor reported
|
|
@@ -59925,7 +61006,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
59925
61006
|
kind: "mutation",
|
|
59926
61007
|
auth: "admin",
|
|
59927
61008
|
access: "delete"
|
|
59928
|
-
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(
|
|
61009
|
+
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
61010
|
+
kind: "mutation",
|
|
61011
|
+
auth: "admin",
|
|
61012
|
+
access: "create"
|
|
61013
|
+
}), method(object({
|
|
59929
61014
|
userId: string(),
|
|
59930
61015
|
code: string()
|
|
59931
61016
|
}), object({ valid: boolean() }), {
|
|
@@ -62126,6 +63211,12 @@ Object.freeze({
|
|
|
62126
63211
|
addonId: null,
|
|
62127
63212
|
access: "view"
|
|
62128
63213
|
},
|
|
63214
|
+
"coreBlocks.migrateRawSecrets": {
|
|
63215
|
+
capName: "core-blocks",
|
|
63216
|
+
capScope: "system",
|
|
63217
|
+
addonId: null,
|
|
63218
|
+
access: "create"
|
|
63219
|
+
},
|
|
62129
63220
|
"coreBlocks.restart": {
|
|
62130
63221
|
capName: "core-blocks",
|
|
62131
63222
|
capScope: "system",
|
|
@@ -63812,6 +64903,12 @@ Object.freeze({
|
|
|
63812
64903
|
addonId: null,
|
|
63813
64904
|
access: "create"
|
|
63814
64905
|
},
|
|
64906
|
+
"keychainAdmin.importSecret": {
|
|
64907
|
+
capName: "keychain-admin",
|
|
64908
|
+
capScope: "system",
|
|
64909
|
+
addonId: null,
|
|
64910
|
+
access: "create"
|
|
64911
|
+
},
|
|
63815
64912
|
"keychainAdmin.listAudit": {
|
|
63816
64913
|
capName: "keychain-admin",
|
|
63817
64914
|
capScope: "system",
|
|
@@ -63980,6 +65077,12 @@ Object.freeze({
|
|
|
63980
65077
|
addonId: null,
|
|
63981
65078
|
access: "view"
|
|
63982
65079
|
},
|
|
65080
|
+
"llm.migrateRawSecrets": {
|
|
65081
|
+
capName: "llm",
|
|
65082
|
+
capScope: "system",
|
|
65083
|
+
addonId: null,
|
|
65084
|
+
access: "create"
|
|
65085
|
+
},
|
|
63983
65086
|
"llm.resolveModelRef": {
|
|
63984
65087
|
capName: "llm",
|
|
63985
65088
|
capScope: "system",
|
|
@@ -64208,6 +65311,12 @@ Object.freeze({
|
|
|
64208
65311
|
addonId: null,
|
|
64209
65312
|
access: "create"
|
|
64210
65313
|
},
|
|
65314
|
+
"localNetwork.useStoredUploadedCertificate": {
|
|
65315
|
+
capName: "local-network",
|
|
65316
|
+
capScope: "system",
|
|
65317
|
+
addonId: null,
|
|
65318
|
+
access: "create"
|
|
65319
|
+
},
|
|
64211
65320
|
"lockControl.getStatus": {
|
|
64212
65321
|
capName: "lock-control",
|
|
64213
65322
|
capScope: "device",
|
|
@@ -66860,6 +67969,30 @@ Object.freeze({
|
|
|
66860
67969
|
addonId: null,
|
|
66861
67970
|
access: "create"
|
|
66862
67971
|
},
|
|
67972
|
+
"recordEntries.deleteEntry": {
|
|
67973
|
+
capName: "record-entries",
|
|
67974
|
+
capScope: "system",
|
|
67975
|
+
addonId: null,
|
|
67976
|
+
access: "delete"
|
|
67977
|
+
},
|
|
67978
|
+
"recordEntries.listEntries": {
|
|
67979
|
+
capName: "record-entries",
|
|
67980
|
+
capScope: "system",
|
|
67981
|
+
addonId: null,
|
|
67982
|
+
access: "view"
|
|
67983
|
+
},
|
|
67984
|
+
"recordEntries.listEntryKinds": {
|
|
67985
|
+
capName: "record-entries",
|
|
67986
|
+
capScope: "system",
|
|
67987
|
+
addonId: null,
|
|
67988
|
+
access: "view"
|
|
67989
|
+
},
|
|
67990
|
+
"recordEntries.putEntry": {
|
|
67991
|
+
capName: "record-entries",
|
|
67992
|
+
capScope: "system",
|
|
67993
|
+
addonId: null,
|
|
67994
|
+
access: "create"
|
|
67995
|
+
},
|
|
66863
67996
|
"recording.getAvailability": {
|
|
66864
67997
|
capName: "recording",
|
|
66865
67998
|
capScope: "device",
|
|
@@ -67160,6 +68293,102 @@ Object.freeze({
|
|
|
67160
68293
|
addonId: null,
|
|
67161
68294
|
access: "view"
|
|
67162
68295
|
},
|
|
68296
|
+
"records.aggregate": {
|
|
68297
|
+
capName: "records",
|
|
68298
|
+
capScope: "system",
|
|
68299
|
+
addonId: null,
|
|
68300
|
+
access: "view"
|
|
68301
|
+
},
|
|
68302
|
+
"records.allocateId": {
|
|
68303
|
+
capName: "records",
|
|
68304
|
+
capScope: "system",
|
|
68305
|
+
addonId: null,
|
|
68306
|
+
access: "create"
|
|
68307
|
+
},
|
|
68308
|
+
"records.count": {
|
|
68309
|
+
capName: "records",
|
|
68310
|
+
capScope: "system",
|
|
68311
|
+
addonId: null,
|
|
68312
|
+
access: "view"
|
|
68313
|
+
},
|
|
68314
|
+
"records.declareKinds": {
|
|
68315
|
+
capName: "records",
|
|
68316
|
+
capScope: "system",
|
|
68317
|
+
addonId: null,
|
|
68318
|
+
access: "create"
|
|
68319
|
+
},
|
|
68320
|
+
"records.delete": {
|
|
68321
|
+
capName: "records",
|
|
68322
|
+
capScope: "system",
|
|
68323
|
+
addonId: null,
|
|
68324
|
+
access: "delete"
|
|
68325
|
+
},
|
|
68326
|
+
"records.deleteDevice": {
|
|
68327
|
+
capName: "records",
|
|
68328
|
+
capScope: "system",
|
|
68329
|
+
addonId: null,
|
|
68330
|
+
access: "delete"
|
|
68331
|
+
},
|
|
68332
|
+
"records.deleteMany": {
|
|
68333
|
+
capName: "records",
|
|
68334
|
+
capScope: "system",
|
|
68335
|
+
addonId: null,
|
|
68336
|
+
access: "delete"
|
|
68337
|
+
},
|
|
68338
|
+
"records.deleteWhere": {
|
|
68339
|
+
capName: "records",
|
|
68340
|
+
capScope: "system",
|
|
68341
|
+
addonId: null,
|
|
68342
|
+
access: "delete"
|
|
68343
|
+
},
|
|
68344
|
+
"records.get": {
|
|
68345
|
+
capName: "records",
|
|
68346
|
+
capScope: "system",
|
|
68347
|
+
addonId: null,
|
|
68348
|
+
access: "view"
|
|
68349
|
+
},
|
|
68350
|
+
"records.getMany": {
|
|
68351
|
+
capName: "records",
|
|
68352
|
+
capScope: "system",
|
|
68353
|
+
addonId: null,
|
|
68354
|
+
access: "view"
|
|
68355
|
+
},
|
|
68356
|
+
"records.histogram": {
|
|
68357
|
+
capName: "records",
|
|
68358
|
+
capScope: "system",
|
|
68359
|
+
addonId: null,
|
|
68360
|
+
access: "view"
|
|
68361
|
+
},
|
|
68362
|
+
"records.patch": {
|
|
68363
|
+
capName: "records",
|
|
68364
|
+
capScope: "system",
|
|
68365
|
+
addonId: null,
|
|
68366
|
+
access: "create"
|
|
68367
|
+
},
|
|
68368
|
+
"records.put": {
|
|
68369
|
+
capName: "records",
|
|
68370
|
+
capScope: "system",
|
|
68371
|
+
addonId: null,
|
|
68372
|
+
access: "create"
|
|
68373
|
+
},
|
|
68374
|
+
"records.putMany": {
|
|
68375
|
+
capName: "records",
|
|
68376
|
+
capScope: "system",
|
|
68377
|
+
addonId: null,
|
|
68378
|
+
access: "create"
|
|
68379
|
+
},
|
|
68380
|
+
"records.query": {
|
|
68381
|
+
capName: "records",
|
|
68382
|
+
capScope: "system",
|
|
68383
|
+
addonId: null,
|
|
68384
|
+
access: "view"
|
|
68385
|
+
},
|
|
68386
|
+
"records.secretRefs": {
|
|
68387
|
+
capName: "records",
|
|
68388
|
+
capScope: "system",
|
|
68389
|
+
addonId: null,
|
|
68390
|
+
access: "view"
|
|
68391
|
+
},
|
|
67163
68392
|
"sceneMonitor.captureReference": {
|
|
67164
68393
|
capName: "scene-monitor",
|
|
67165
68394
|
capScope: "device",
|
|
@@ -67592,6 +68821,48 @@ Object.freeze({
|
|
|
67592
68821
|
addonId: null,
|
|
67593
68822
|
access: "create"
|
|
67594
68823
|
},
|
|
68824
|
+
"storageAdmin.adoptRecords": {
|
|
68825
|
+
capName: "storage-admin",
|
|
68826
|
+
capScope: "system",
|
|
68827
|
+
addonId: null,
|
|
68828
|
+
access: "create"
|
|
68829
|
+
},
|
|
68830
|
+
"storageAdmin.dropCollection": {
|
|
68831
|
+
capName: "storage-admin",
|
|
68832
|
+
capScope: "system",
|
|
68833
|
+
addonId: null,
|
|
68834
|
+
access: "delete"
|
|
68835
|
+
},
|
|
68836
|
+
"storageAdmin.isAdoptedLegacyTable": {
|
|
68837
|
+
capName: "storage-admin",
|
|
68838
|
+
capScope: "system",
|
|
68839
|
+
addonId: null,
|
|
68840
|
+
access: "view"
|
|
68841
|
+
},
|
|
68842
|
+
"storageAdmin.listKinds": {
|
|
68843
|
+
capName: "storage-admin",
|
|
68844
|
+
capScope: "system",
|
|
68845
|
+
addonId: null,
|
|
68846
|
+
access: "view"
|
|
68847
|
+
},
|
|
68848
|
+
"storageAdmin.listTables": {
|
|
68849
|
+
capName: "storage-admin",
|
|
68850
|
+
capScope: "system",
|
|
68851
|
+
addonId: null,
|
|
68852
|
+
access: "view"
|
|
68853
|
+
},
|
|
68854
|
+
"storageAdmin.readLegacyCollection": {
|
|
68855
|
+
capName: "storage-admin",
|
|
68856
|
+
capScope: "system",
|
|
68857
|
+
addonId: null,
|
|
68858
|
+
access: "view"
|
|
68859
|
+
},
|
|
68860
|
+
"storageAdmin.readRecords": {
|
|
68861
|
+
capName: "storage-admin",
|
|
68862
|
+
capScope: "system",
|
|
68863
|
+
addonId: null,
|
|
68864
|
+
access: "view"
|
|
68865
|
+
},
|
|
67595
68866
|
"storageEvictable.evict": {
|
|
67596
68867
|
capName: "storage-evictable",
|
|
67597
68868
|
capScope: "system",
|
|
@@ -68504,6 +69775,12 @@ Object.freeze({
|
|
|
68504
69775
|
addonId: null,
|
|
68505
69776
|
access: "view"
|
|
68506
69777
|
},
|
|
69778
|
+
"userManagement.migrateRawSecrets": {
|
|
69779
|
+
capName: "user-management",
|
|
69780
|
+
capScope: "system",
|
|
69781
|
+
addonId: null,
|
|
69782
|
+
access: "create"
|
|
69783
|
+
},
|
|
68507
69784
|
"userManagement.oauthExchangeCode": {
|
|
68508
69785
|
capName: "user-management",
|
|
68509
69786
|
capScope: "system",
|
|
@@ -71180,6 +72457,37 @@ Object.freeze({
|
|
|
71180
72457
|
form: "single",
|
|
71181
72458
|
optional: false
|
|
71182
72459
|
}],
|
|
72460
|
+
"records.count": [{
|
|
72461
|
+
name: "deviceId",
|
|
72462
|
+
form: "single",
|
|
72463
|
+
optional: true
|
|
72464
|
+
}],
|
|
72465
|
+
"records.deleteDevice": [{
|
|
72466
|
+
name: "deviceId",
|
|
72467
|
+
form: "single",
|
|
72468
|
+
optional: false
|
|
72469
|
+
}],
|
|
72470
|
+
"records.deleteWhere": [{
|
|
72471
|
+
name: "deviceId",
|
|
72472
|
+
form: "single",
|
|
72473
|
+
optional: true
|
|
72474
|
+
}],
|
|
72475
|
+
"records.histogram": [{
|
|
72476
|
+
name: "deviceId",
|
|
72477
|
+
form: "single",
|
|
72478
|
+
optional: true
|
|
72479
|
+
}],
|
|
72480
|
+
"records.putMany": [{
|
|
72481
|
+
name: "records",
|
|
72482
|
+
form: "object-array",
|
|
72483
|
+
optional: false,
|
|
72484
|
+
itemField: "deviceId"
|
|
72485
|
+
}],
|
|
72486
|
+
"records.query": [{
|
|
72487
|
+
name: "deviceId",
|
|
72488
|
+
form: "single",
|
|
72489
|
+
optional: true
|
|
72490
|
+
}],
|
|
71183
72491
|
"sceneMonitor.captureReference": [{
|
|
71184
72492
|
name: "deviceId",
|
|
71185
72493
|
form: "single",
|
|
@@ -71296,6 +72604,17 @@ Object.freeze({
|
|
|
71296
72604
|
form: "single",
|
|
71297
72605
|
optional: false
|
|
71298
72606
|
}],
|
|
72607
|
+
"storageAdmin.adoptRecords": [{
|
|
72608
|
+
name: "records",
|
|
72609
|
+
form: "object-array",
|
|
72610
|
+
optional: false,
|
|
72611
|
+
itemField: "deviceId"
|
|
72612
|
+
}],
|
|
72613
|
+
"storageAdmin.readRecords": [{
|
|
72614
|
+
name: "deviceId",
|
|
72615
|
+
form: "single",
|
|
72616
|
+
optional: true
|
|
72617
|
+
}],
|
|
71299
72618
|
"streamBroker.acquireEgressTranscode": [{
|
|
71300
72619
|
name: "deviceId",
|
|
71301
72620
|
form: "single",
|
|
@@ -104879,6 +106198,205 @@ function retiredCiphertextPaths(config) {
|
|
|
104879
106198
|
return out;
|
|
104880
106199
|
}
|
|
104881
106200
|
//#endregion
|
|
106201
|
+
//#region src/mqtt-external-broker-entry.ts
|
|
106202
|
+
var mqttOnboardDescriptorSchema = object({
|
|
106203
|
+
port: number().int().min(1).max(65535),
|
|
106204
|
+
allowAnonymous: boolean()
|
|
106205
|
+
});
|
|
106206
|
+
var MqttExternalBrokerEntrySchema = object({
|
|
106207
|
+
id: string().min(1),
|
|
106208
|
+
name: string().min(1),
|
|
106209
|
+
url: string().min(1),
|
|
106210
|
+
username: string().optional(),
|
|
106211
|
+
password: string().optional().meta({ secret: true }),
|
|
106212
|
+
clientIdPrefix: string().optional(),
|
|
106213
|
+
onboard: mqttOnboardDescriptorSchema.optional()
|
|
106214
|
+
});
|
|
106215
|
+
var mqttBrokersEntryKind = defineEntryKind("brokers", {
|
|
106216
|
+
title: "MQTT external brokers",
|
|
106217
|
+
schema: entryBody({
|
|
106218
|
+
url: string().min(1),
|
|
106219
|
+
username: string().optional(),
|
|
106220
|
+
password: string().optional().meta({ secret: true }),
|
|
106221
|
+
clientIdPrefix: string().optional(),
|
|
106222
|
+
onboard: mqttOnboardDescriptorSchema.optional()
|
|
106223
|
+
}),
|
|
106224
|
+
writeTrigger: "an operator adds or removes an external MQTT broker entry",
|
|
106225
|
+
adoptsFrom: settingsBrokersAdoptsFrom("mqtt-broker")
|
|
106226
|
+
});
|
|
106227
|
+
//#endregion
|
|
106228
|
+
//#region src/mqtt-entry-record-kinds.ts
|
|
106229
|
+
var aclAccessSchema = _enum([
|
|
106230
|
+
"sub",
|
|
106231
|
+
"pub",
|
|
106232
|
+
"both"
|
|
106233
|
+
]);
|
|
106234
|
+
var MqttClientBodySchema = entryBody({ passwordHash: string() });
|
|
106235
|
+
var mqttClientEntryKind = defineEntryKind("mqtt-client", {
|
|
106236
|
+
title: "MQTT embedded clients",
|
|
106237
|
+
schema: MqttClientBodySchema,
|
|
106238
|
+
writeTrigger: "an operator adds or removes an embedded MQTT client credential",
|
|
106239
|
+
adoptsFrom: settingsArrayAdoptsFrom("mqtt-broker", "embeddedClients")
|
|
106240
|
+
});
|
|
106241
|
+
var MqttAclBodySchema = entryBody({
|
|
106242
|
+
username: string().min(1),
|
|
106243
|
+
topicPattern: string().min(1),
|
|
106244
|
+
access: aclAccessSchema
|
|
106245
|
+
});
|
|
106246
|
+
var mqttAclEntryKind = defineEntryKind("mqtt-acl-rule", {
|
|
106247
|
+
title: "MQTT ACL rules",
|
|
106248
|
+
schema: MqttAclBodySchema,
|
|
106249
|
+
writeTrigger: "an operator edits embedded broker ACL rules",
|
|
106250
|
+
adoptsFrom: settingsArrayAdoptsFrom("mqtt-broker", "embeddedAcl")
|
|
106251
|
+
});
|
|
106252
|
+
//#endregion
|
|
106253
|
+
//#region src/mqtt-broker-store.ts
|
|
106254
|
+
function rowToEntry(id, data) {
|
|
106255
|
+
const parsed = MqttExternalBrokerEntrySchema.safeParse({
|
|
106256
|
+
id,
|
|
106257
|
+
name: data.name,
|
|
106258
|
+
url: data.url,
|
|
106259
|
+
username: data.username,
|
|
106260
|
+
password: data.password,
|
|
106261
|
+
clientIdPrefix: data.clientIdPrefix,
|
|
106262
|
+
onboard: data.onboard
|
|
106263
|
+
});
|
|
106264
|
+
return parsed.success ? parsed.data : null;
|
|
106265
|
+
}
|
|
106266
|
+
var MqttBrokerStore = class MqttBrokerStore {
|
|
106267
|
+
kind;
|
|
106268
|
+
constructor(kind) {
|
|
106269
|
+
this.kind = kind;
|
|
106270
|
+
}
|
|
106271
|
+
static of(records) {
|
|
106272
|
+
return new MqttBrokerStore(records.kind(mqttBrokersEntryKind));
|
|
106273
|
+
}
|
|
106274
|
+
async listResolved() {
|
|
106275
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106276
|
+
const out = [];
|
|
106277
|
+
for (const record of page.records) {
|
|
106278
|
+
let data = record.data;
|
|
106279
|
+
try {
|
|
106280
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
106281
|
+
if (resolved !== null) data = resolved.data;
|
|
106282
|
+
} catch (err) {
|
|
106283
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
106284
|
+
}
|
|
106285
|
+
const entry = rowToEntry(record.id, data);
|
|
106286
|
+
if (entry !== null) out.push(entry);
|
|
106287
|
+
}
|
|
106288
|
+
return out;
|
|
106289
|
+
}
|
|
106290
|
+
async replaceAll(entries) {
|
|
106291
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106292
|
+
const nextIds = new Set(entries.map((e) => e.id));
|
|
106293
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
106294
|
+
for (const entry of entries) {
|
|
106295
|
+
const { id, name, url, username, password, clientIdPrefix, onboard } = entry;
|
|
106296
|
+
const body = {
|
|
106297
|
+
name,
|
|
106298
|
+
url,
|
|
106299
|
+
...username === void 0 ? {} : { username },
|
|
106300
|
+
...password === void 0 ? {} : { password },
|
|
106301
|
+
...clientIdPrefix === void 0 ? {} : { clientIdPrefix },
|
|
106302
|
+
...onboard === void 0 ? {} : { onboard }
|
|
106303
|
+
};
|
|
106304
|
+
const parsed = mqttBrokersEntryKind.schema.safeParse(body);
|
|
106305
|
+
if (!parsed.success) throw new Error(`invalid MQTT broker '${id}': ${parsed.error.message}`);
|
|
106306
|
+
await this.kind.put({
|
|
106307
|
+
id,
|
|
106308
|
+
data: parsed.data
|
|
106309
|
+
});
|
|
106310
|
+
}
|
|
106311
|
+
}
|
|
106312
|
+
};
|
|
106313
|
+
//#endregion
|
|
106314
|
+
//#region src/mqtt-entry-store.ts
|
|
106315
|
+
function mqttAclRecordId(rule) {
|
|
106316
|
+
return `${rule.username}\u0000${rule.topicPattern}`;
|
|
106317
|
+
}
|
|
106318
|
+
var MqttClientStore = class MqttClientStore {
|
|
106319
|
+
kind;
|
|
106320
|
+
constructor(kind) {
|
|
106321
|
+
this.kind = kind;
|
|
106322
|
+
}
|
|
106323
|
+
static of(records) {
|
|
106324
|
+
return new MqttClientStore(records.kind(mqttClientEntryKind));
|
|
106325
|
+
}
|
|
106326
|
+
async listResolved() {
|
|
106327
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106328
|
+
const out = [];
|
|
106329
|
+
for (const record of page.records) {
|
|
106330
|
+
const parsed = MqttClientBodySchema.safeParse(record.data);
|
|
106331
|
+
if (!parsed.success) continue;
|
|
106332
|
+
out.push({
|
|
106333
|
+
username: record.id,
|
|
106334
|
+
passwordHash: parsed.data.passwordHash
|
|
106335
|
+
});
|
|
106336
|
+
}
|
|
106337
|
+
return out;
|
|
106338
|
+
}
|
|
106339
|
+
async replaceAll(entries) {
|
|
106340
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106341
|
+
const nextIds = new Set(entries.map((e) => e.username));
|
|
106342
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
106343
|
+
for (const entry of entries) {
|
|
106344
|
+
const body = {
|
|
106345
|
+
name: entry.username,
|
|
106346
|
+
passwordHash: entry.passwordHash
|
|
106347
|
+
};
|
|
106348
|
+
const parsed = mqttClientEntryKind.schema.safeParse(body);
|
|
106349
|
+
if (!parsed.success) throw new Error(`invalid MQTT client '${entry.username}': ${parsed.error.message}`);
|
|
106350
|
+
await this.kind.put({
|
|
106351
|
+
id: entry.username,
|
|
106352
|
+
data: parsed.data
|
|
106353
|
+
});
|
|
106354
|
+
}
|
|
106355
|
+
}
|
|
106356
|
+
};
|
|
106357
|
+
var MqttAclStore = class MqttAclStore {
|
|
106358
|
+
kind;
|
|
106359
|
+
constructor(kind) {
|
|
106360
|
+
this.kind = kind;
|
|
106361
|
+
}
|
|
106362
|
+
static of(records) {
|
|
106363
|
+
return new MqttAclStore(records.kind(mqttAclEntryKind));
|
|
106364
|
+
}
|
|
106365
|
+
async listResolved() {
|
|
106366
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106367
|
+
const out = [];
|
|
106368
|
+
for (const record of page.records) {
|
|
106369
|
+
const parsed = MqttAclBodySchema.safeParse(record.data);
|
|
106370
|
+
if (!parsed.success) continue;
|
|
106371
|
+
out.push({
|
|
106372
|
+
username: parsed.data.username,
|
|
106373
|
+
topicPattern: parsed.data.topicPattern,
|
|
106374
|
+
access: parsed.data.access
|
|
106375
|
+
});
|
|
106376
|
+
}
|
|
106377
|
+
return out;
|
|
106378
|
+
}
|
|
106379
|
+
async replaceAll(entries) {
|
|
106380
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
106381
|
+
const nextIds = new Set(entries.map((e) => mqttAclRecordId(e)));
|
|
106382
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
106383
|
+
for (const entry of entries) {
|
|
106384
|
+
const body = {
|
|
106385
|
+
name: `${entry.username} · ${entry.topicPattern}`,
|
|
106386
|
+
username: entry.username,
|
|
106387
|
+
topicPattern: entry.topicPattern,
|
|
106388
|
+
access: entry.access
|
|
106389
|
+
};
|
|
106390
|
+
const parsed = mqttAclEntryKind.schema.safeParse(body);
|
|
106391
|
+
if (!parsed.success) throw new Error(`invalid MQTT ACL '${entry.username}/${entry.topicPattern}': ${parsed.error.message}`);
|
|
106392
|
+
await this.kind.put({
|
|
106393
|
+
id: mqttAclRecordId(entry),
|
|
106394
|
+
data: parsed.data
|
|
106395
|
+
});
|
|
106396
|
+
}
|
|
106397
|
+
}
|
|
106398
|
+
};
|
|
106399
|
+
//#endregion
|
|
104882
106400
|
//#region src/mqtt-broker.addon.ts
|
|
104883
106401
|
/**
|
|
104884
106402
|
* MQTT Broker addon — broker REGISTRY (not a pub/sub proxy).
|
|
@@ -104912,7 +106430,7 @@ function retiredCiphertextPaths(config) {
|
|
|
104912
106430
|
* integration-type addon.
|
|
104913
106431
|
*
|
|
104914
106432
|
* Lifecycle:
|
|
104915
|
-
* - External broker entries are persisted in `this.
|
|
106433
|
+
* - External broker entries are persisted in `this.activeExternalBrokers`.
|
|
104916
106434
|
* - The embedded broker is persisted as flat `embedded*` config keys
|
|
104917
106435
|
* (`embeddedEnabled`, `embeddedPort`, …) so the standard settings
|
|
104918
106436
|
* form can drive it; {@link MqttBrokerAddon.deriveEmbeddedEntry}
|
|
@@ -105031,11 +106549,86 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105031
106549
|
/** Per-entry onboard `aedes` runtimes, keyed by `ExternalBrokerEntry.id`. */
|
|
105032
106550
|
onboardRuntimes = /* @__PURE__ */ new Map();
|
|
105033
106551
|
probeCache = null;
|
|
106552
|
+
brokerStore = null;
|
|
106553
|
+
clientStore = null;
|
|
106554
|
+
aclStore = null;
|
|
106555
|
+
/** External broker rows (records when B2 is live, else settings mirror). */
|
|
106556
|
+
activeExternalBrokers = [];
|
|
106557
|
+
activeEmbeddedClients = [];
|
|
106558
|
+
activeEmbeddedAcl = [];
|
|
105034
106559
|
constructor() {
|
|
105035
106560
|
super({ ...DEFAULT_CONFIG });
|
|
105036
106561
|
}
|
|
106562
|
+
async loadPersistedExternalBrokers() {
|
|
106563
|
+
const store = this.brokerStore;
|
|
106564
|
+
if (store !== null) {
|
|
106565
|
+
const fromRecords = await store.listResolved();
|
|
106566
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
106567
|
+
}
|
|
106568
|
+
return this.config.brokers;
|
|
106569
|
+
}
|
|
106570
|
+
async persistExternalBrokers(entries) {
|
|
106571
|
+
this.activeExternalBrokers = [...entries];
|
|
106572
|
+
const store = this.brokerStore;
|
|
106573
|
+
if (store !== null) {
|
|
106574
|
+
await store.replaceAll(entries);
|
|
106575
|
+
return;
|
|
106576
|
+
}
|
|
106577
|
+
await this.updateGlobalSettings({ brokers: entries });
|
|
106578
|
+
}
|
|
106579
|
+
async loadEmbeddedClients() {
|
|
106580
|
+
const store = this.clientStore;
|
|
106581
|
+
if (store !== null) {
|
|
106582
|
+
const fromRecords = await store.listResolved();
|
|
106583
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
106584
|
+
}
|
|
106585
|
+
return this.config.embeddedClients;
|
|
106586
|
+
}
|
|
106587
|
+
async loadEmbeddedAcl() {
|
|
106588
|
+
const store = this.aclStore;
|
|
106589
|
+
if (store !== null) {
|
|
106590
|
+
const fromRecords = await store.listResolved();
|
|
106591
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
106592
|
+
}
|
|
106593
|
+
return this.config.embeddedAcl;
|
|
106594
|
+
}
|
|
106595
|
+
async syncEmbeddedEntriesFromConfig() {
|
|
106596
|
+
const clients = [...this.config.embeddedClients];
|
|
106597
|
+
const acl = [...this.config.embeddedAcl];
|
|
106598
|
+
this.activeEmbeddedClients = clients;
|
|
106599
|
+
this.activeEmbeddedAcl = acl;
|
|
106600
|
+
const clientStore = this.clientStore;
|
|
106601
|
+
const aclStore = this.aclStore;
|
|
106602
|
+
if (clientStore !== null) await clientStore.replaceAll(clients);
|
|
106603
|
+
if (aclStore !== null) await aclStore.replaceAll(acl);
|
|
106604
|
+
}
|
|
105037
106605
|
async onInitialize() {
|
|
105038
106606
|
this.reportRetiredCiphertext();
|
|
106607
|
+
const records = this.ctx.records;
|
|
106608
|
+
if (records === void 0) throw new Error("mqtt-broker: ctx.records is required (hub-only addon)");
|
|
106609
|
+
await records.declare({
|
|
106610
|
+
brokers: mqttBrokersEntryKind,
|
|
106611
|
+
"mqtt-client": mqttClientEntryKind,
|
|
106612
|
+
"mqtt-acl-rule": mqttAclEntryKind
|
|
106613
|
+
});
|
|
106614
|
+
this.brokerStore = MqttBrokerStore.of(records);
|
|
106615
|
+
this.clientStore = MqttClientStore.of(records);
|
|
106616
|
+
this.aclStore = MqttAclStore.of(records);
|
|
106617
|
+
this.activeExternalBrokers = await this.loadPersistedExternalBrokers();
|
|
106618
|
+
if ((await this.brokerStore.listResolved()).length === 0 && this.config.brokers.length > 0) {
|
|
106619
|
+
await this.brokerStore.replaceAll(this.config.brokers);
|
|
106620
|
+
this.activeExternalBrokers = await this.loadPersistedExternalBrokers();
|
|
106621
|
+
}
|
|
106622
|
+
this.activeEmbeddedClients = await this.loadEmbeddedClients();
|
|
106623
|
+
this.activeEmbeddedAcl = await this.loadEmbeddedAcl();
|
|
106624
|
+
if ((await this.clientStore.listResolved()).length === 0 && this.config.embeddedClients.length > 0) {
|
|
106625
|
+
await this.clientStore.replaceAll(this.config.embeddedClients);
|
|
106626
|
+
this.activeEmbeddedClients = await this.loadEmbeddedClients();
|
|
106627
|
+
}
|
|
106628
|
+
if ((await this.aclStore.listResolved()).length === 0 && this.config.embeddedAcl.length > 0) {
|
|
106629
|
+
await this.aclStore.replaceAll(this.config.embeddedAcl);
|
|
106630
|
+
this.activeEmbeddedAcl = await this.loadEmbeddedAcl();
|
|
106631
|
+
}
|
|
105039
106632
|
this.probeCache = new BrokerProbeCache({
|
|
105040
106633
|
intervalMs: PROBE_INTERVAL_MS,
|
|
105041
106634
|
onError: (id, err) => {
|
|
@@ -105081,7 +106674,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105081
106674
|
startEmbeddedBroker: async (input) => this.startEmbeddedBroker(input),
|
|
105082
106675
|
stopEmbeddedBroker: async ({ id }) => this.stopEmbeddedBroker(id),
|
|
105083
106676
|
getStatus: async () => ({
|
|
105084
|
-
brokerCount: this.
|
|
106677
|
+
brokerCount: this.activeExternalBrokers.length + (this.config.embeddedEnabled ? 1 : 0),
|
|
105085
106678
|
embeddedRunning: this.embeddedRuntime !== null
|
|
105086
106679
|
})
|
|
105087
106680
|
};
|
|
@@ -105114,7 +106707,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105114
106707
|
error: info.error ?? null
|
|
105115
106708
|
});
|
|
105116
106709
|
const owns = (id) => {
|
|
105117
|
-
if (this.
|
|
106710
|
+
if (this.activeExternalBrokers.some((b) => b.id === id)) return true;
|
|
105118
106711
|
const embedded = this.deriveEmbeddedEntry();
|
|
105119
106712
|
return embedded !== null && embedded.id === id;
|
|
105120
106713
|
};
|
|
@@ -105208,7 +106801,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105208
106801
|
getStatus: async () => {
|
|
105209
106802
|
const all = await this.listBrokers();
|
|
105210
106803
|
return {
|
|
105211
|
-
brokerCount: this.
|
|
106804
|
+
brokerCount: this.activeExternalBrokers.length + (this.config.embeddedEnabled ? 1 : 0),
|
|
105212
106805
|
connectedCount: all.filter((b) => b.status === "connected").length
|
|
105213
106806
|
};
|
|
105214
106807
|
}
|
|
@@ -105220,6 +106813,8 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105220
106813
|
await this.shutdownAllOnboard();
|
|
105221
106814
|
}
|
|
105222
106815
|
async onConfigChanged() {
|
|
106816
|
+
this.activeExternalBrokers = await this.loadPersistedExternalBrokers();
|
|
106817
|
+
await this.syncEmbeddedEntriesFromConfig();
|
|
105223
106818
|
await this.reconcileOnboardRuntimes();
|
|
105224
106819
|
const desired = this.deriveEmbeddedEntry();
|
|
105225
106820
|
const running = this.embeddedRuntime?.entry ?? null;
|
|
@@ -105246,7 +106841,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105246
106841
|
}
|
|
105247
106842
|
async listBrokers() {
|
|
105248
106843
|
const out = [];
|
|
105249
|
-
for (const entry of this.
|
|
106844
|
+
for (const entry of this.activeExternalBrokers) {
|
|
105250
106845
|
if (entry.onboard) {
|
|
105251
106846
|
const running = this.onboardRuntimes.get(entry.id) ?? null;
|
|
105252
106847
|
const status = running !== null ? "connected" : "disconnected";
|
|
@@ -105295,7 +106890,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105295
106890
|
return out;
|
|
105296
106891
|
}
|
|
105297
106892
|
getBrokerConfig(id) {
|
|
105298
|
-
const external = this.
|
|
106893
|
+
const external = this.activeExternalBrokers.find((b) => b.id === id);
|
|
105299
106894
|
if (external) {
|
|
105300
106895
|
const password = this.storedPassword(external.password);
|
|
105301
106896
|
return {
|
|
@@ -105326,8 +106921,8 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105326
106921
|
...input.password !== void 0 ? { password: input.password } : {},
|
|
105327
106922
|
...input.clientIdPrefix !== void 0 ? { clientIdPrefix: input.clientIdPrefix } : {}
|
|
105328
106923
|
};
|
|
105329
|
-
const next = [...this.
|
|
105330
|
-
await this.
|
|
106924
|
+
const next = [...this.activeExternalBrokers, entry];
|
|
106925
|
+
await this.persistExternalBrokers(next);
|
|
105331
106926
|
this.ctx.logger.info("mqtt broker added", { meta: {
|
|
105332
106927
|
id,
|
|
105333
106928
|
url: entry.url
|
|
@@ -105356,8 +106951,8 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105356
106951
|
...built.password !== void 0 ? { password: built.password } : {},
|
|
105357
106952
|
onboard: built.onboard
|
|
105358
106953
|
};
|
|
105359
|
-
const next = [...this.
|
|
105360
|
-
await this.
|
|
106954
|
+
const next = [...this.activeExternalBrokers, entry];
|
|
106955
|
+
await this.persistExternalBrokers(next);
|
|
105361
106956
|
const spawn = this.onboardSpawnEntry(entry);
|
|
105362
106957
|
if (spawn) await this.spawnOnboard(spawn);
|
|
105363
106958
|
this.ctx.logger.info("onboard mqtt broker added", {
|
|
@@ -105373,10 +106968,10 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105373
106968
|
return { id };
|
|
105374
106969
|
}
|
|
105375
106970
|
async removeBroker(id) {
|
|
105376
|
-
const removed = this.
|
|
106971
|
+
const removed = this.activeExternalBrokers.find((b) => b.id === id);
|
|
105377
106972
|
if (removed) {
|
|
105378
|
-
const next = this.
|
|
105379
|
-
await this.
|
|
106973
|
+
const next = this.activeExternalBrokers.filter((b) => b.id !== id);
|
|
106974
|
+
await this.persistExternalBrokers(next);
|
|
105380
106975
|
this.probeCache?.evict(id);
|
|
105381
106976
|
if (removed.onboard) await this.shutdownOnboard(id);
|
|
105382
106977
|
this.ctx.logger.info("mqtt broker removed", { meta: { id } });
|
|
@@ -105597,7 +107192,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105597
107192
|
* entry disappeared, and respawn runtimes whose port changed.
|
|
105598
107193
|
*/
|
|
105599
107194
|
async reconcileOnboardRuntimes() {
|
|
105600
|
-
const desiredEntries = this.
|
|
107195
|
+
const desiredEntries = this.activeExternalBrokers.filter(hasOnboard);
|
|
105601
107196
|
const desired = desiredEntries.map((b) => ({
|
|
105602
107197
|
id: b.id,
|
|
105603
107198
|
port: b.onboard.port
|
|
@@ -105638,7 +107233,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105638
107233
|
done(null, allowAnonymous);
|
|
105639
107234
|
return;
|
|
105640
107235
|
}
|
|
105641
|
-
const match = this.
|
|
107236
|
+
const match = this.activeEmbeddedClients.find((c) => c.username === username);
|
|
105642
107237
|
if (match) {
|
|
105643
107238
|
done(null, bcryptCompareSafe(passwordStr, match.passwordHash));
|
|
105644
107239
|
return;
|
|
@@ -105678,7 +107273,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105678
107273
|
* requested topic and access mode.
|
|
105679
107274
|
*/
|
|
105680
107275
|
isAclAllowed(client, topic, access) {
|
|
105681
|
-
const acl = this.
|
|
107276
|
+
const acl = this.activeEmbeddedAcl;
|
|
105682
107277
|
if (acl.length === 0) return true;
|
|
105683
107278
|
const username = readClientUsername(client);
|
|
105684
107279
|
if (!username) return true;
|
|
@@ -105705,7 +107300,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105705
107300
|
runtime.aedes.authorizeSubscribe = this.makeSubscribeAuthorizer();
|
|
105706
107301
|
runtime.credentialsSnapshot = nextSnapshot;
|
|
105707
107302
|
if (affectedUsers.length === 0) {
|
|
105708
|
-
this.ctx.logger.debug("mqtt embedded hot-reload — no password changes", { meta: { aclRules: this.
|
|
107303
|
+
this.ctx.logger.debug("mqtt embedded hot-reload — no password changes", { meta: { aclRules: this.activeEmbeddedAcl.length } });
|
|
105709
107304
|
return;
|
|
105710
107305
|
}
|
|
105711
107306
|
const clients = readClientMap(runtime.aedes);
|
|
@@ -105731,7 +107326,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105731
107326
|
}
|
|
105732
107327
|
buildCredentialsSnapshot() {
|
|
105733
107328
|
const m = /* @__PURE__ */ new Map();
|
|
105734
|
-
for (const c of this.
|
|
107329
|
+
for (const c of this.activeEmbeddedClients) m.set(c.username, c.passwordHash);
|
|
105735
107330
|
return m;
|
|
105736
107331
|
}
|
|
105737
107332
|
/**
|
|
@@ -105756,7 +107351,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105756
107351
|
}
|
|
105757
107352
|
collectExternalProbeInputs() {
|
|
105758
107353
|
const out = [];
|
|
105759
|
-
for (const b of this.
|
|
107354
|
+
for (const b of this.activeExternalBrokers) {
|
|
105760
107355
|
if (b.onboard !== void 0) continue;
|
|
105761
107356
|
let password;
|
|
105762
107357
|
try {
|
|
@@ -105793,7 +107388,7 @@ var MqttBrokerAddon = class extends BaseAddon {
|
|
|
105793
107388
|
const paths = retiredCiphertextPaths(this.config);
|
|
105794
107389
|
if (paths.length === 0) return;
|
|
105795
107390
|
const unreadable = [];
|
|
105796
|
-
const values = [...this.
|
|
107391
|
+
const values = [...this.activeExternalBrokers.map((b) => ({
|
|
105797
107392
|
id: `brokers[${b.id}].password`,
|
|
105798
107393
|
v: b.password
|
|
105799
107394
|
})), {
|