@camstack/addon-notifiers 1.2.135 → 1.2.601
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1362 -189
- package/dist/addon.mjs +1363 -188
- package/dist/index.js +0 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -29,7 +29,7 @@ let node_fs = require("node:fs");
|
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
31
|
let node_url = require("node:url");
|
|
32
|
-
//#region ../types/dist/event-category-
|
|
32
|
+
//#region ../types/dist/event-category-BvOFi6PY.mjs
|
|
33
33
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
34
34
|
EventCategory["SystemBoot"] = "system.boot";
|
|
35
35
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -93,6 +93,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
93
93
|
* consumes this category and maps it to the `addon-crash-loop` kind.
|
|
94
94
|
*/
|
|
95
95
|
EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
|
|
96
|
+
/**
|
|
97
|
+
* A runner whose addon refused to start with a typed reason (D877) - parked
|
|
98
|
+
* in `refused`, never counted by the crash breaker, retried on operator
|
|
99
|
+
* action. One event per refusal.
|
|
100
|
+
*/
|
|
101
|
+
EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
|
|
102
|
+
/**
|
|
103
|
+
* A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
|
|
104
|
+
* `refused`. In-process telemetry for the boot check (re-evaluate while any
|
|
105
|
+
* runner is still pending) and the alert centre (close a recovered runner).
|
|
106
|
+
*/
|
|
107
|
+
EventCategory["ProcessStateChanged"] = "process.state-changed";
|
|
108
|
+
/**
|
|
109
|
+
* The node's one-shot runner boot check (D877): planned runners against the
|
|
110
|
+
* process service, `degraded` when any is failed, refused or missing. The
|
|
111
|
+
* alert centre turns it into one alert and a direct critical push.
|
|
112
|
+
*/
|
|
113
|
+
EventCategory["SystemRunnerCheck"] = "system.runner-check";
|
|
96
114
|
EventCategory["AddonError"] = "addon.error";
|
|
97
115
|
EventCategory["AddonPageReady"] = "addon.page-ready";
|
|
98
116
|
EventCategory["AddonWidgetReady"] = "addon.widget-ready";
|
|
@@ -4135,6 +4153,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4135
4153
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4136
4154
|
json.type = "boolean";
|
|
4137
4155
|
};
|
|
4156
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4157
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4158
|
+
};
|
|
4159
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4160
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4161
|
+
};
|
|
4138
4162
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4139
4163
|
if (ctx.target === "openapi-3.0") {
|
|
4140
4164
|
json.type = "string";
|
|
@@ -4142,12 +4166,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4142
4166
|
json.enum = [null];
|
|
4143
4167
|
} else json.type = "null";
|
|
4144
4168
|
};
|
|
4169
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4170
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4171
|
+
};
|
|
4145
4172
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4146
4173
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4147
4174
|
};
|
|
4148
4175
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4149
4176
|
json.not = {};
|
|
4150
4177
|
};
|
|
4178
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4179
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4151
4180
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4152
4181
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4153
4182
|
};
|
|
@@ -4179,12 +4208,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4179
4208
|
json.enum = vals;
|
|
4180
4209
|
}
|
|
4181
4210
|
};
|
|
4211
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4212
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4213
|
+
};
|
|
4214
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4215
|
+
const _json = json;
|
|
4216
|
+
const pattern = schema._zod.pattern;
|
|
4217
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4218
|
+
_json.type = "string";
|
|
4219
|
+
_json.pattern = pattern.source;
|
|
4220
|
+
};
|
|
4221
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4222
|
+
const _json = json;
|
|
4223
|
+
const file = {
|
|
4224
|
+
type: "string",
|
|
4225
|
+
format: "binary",
|
|
4226
|
+
contentEncoding: "binary"
|
|
4227
|
+
};
|
|
4228
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4229
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4230
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4231
|
+
if (mime) if (mime.length === 1) {
|
|
4232
|
+
file.contentMediaType = mime[0];
|
|
4233
|
+
Object.assign(_json, file);
|
|
4234
|
+
} else {
|
|
4235
|
+
Object.assign(_json, file);
|
|
4236
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4237
|
+
}
|
|
4238
|
+
else Object.assign(_json, file);
|
|
4239
|
+
};
|
|
4240
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4241
|
+
json.type = "boolean";
|
|
4242
|
+
};
|
|
4182
4243
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4183
4244
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4184
4245
|
};
|
|
4246
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4247
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4248
|
+
};
|
|
4185
4249
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4186
4250
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4187
4251
|
};
|
|
4252
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4253
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4254
|
+
};
|
|
4255
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4256
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4257
|
+
};
|
|
4188
4258
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4189
4259
|
const json = _json;
|
|
4190
4260
|
const def = schema._zod.def;
|
|
@@ -4389,6 +4459,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4389
4459
|
seen.ref = def.innerType;
|
|
4390
4460
|
json.readOnly = true;
|
|
4391
4461
|
};
|
|
4462
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4463
|
+
const def = schema._zod.def;
|
|
4464
|
+
process(def.innerType, ctx, params);
|
|
4465
|
+
const seen = ctx.seen.get(schema);
|
|
4466
|
+
seen.ref = def.innerType;
|
|
4467
|
+
};
|
|
4392
4468
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4393
4469
|
const def = schema._zod.def;
|
|
4394
4470
|
process(def.innerType, ctx, params);
|
|
@@ -4401,6 +4477,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4401
4477
|
const seen = ctx.seen.get(schema);
|
|
4402
4478
|
seen.ref = innerType;
|
|
4403
4479
|
};
|
|
4480
|
+
var allProcessors = {
|
|
4481
|
+
string: stringProcessor,
|
|
4482
|
+
number: numberProcessor,
|
|
4483
|
+
boolean: booleanProcessor,
|
|
4484
|
+
bigint: bigintProcessor,
|
|
4485
|
+
symbol: symbolProcessor,
|
|
4486
|
+
null: nullProcessor,
|
|
4487
|
+
undefined: undefinedProcessor,
|
|
4488
|
+
void: voidProcessor,
|
|
4489
|
+
never: neverProcessor,
|
|
4490
|
+
any: anyProcessor,
|
|
4491
|
+
unknown: unknownProcessor,
|
|
4492
|
+
date: dateProcessor,
|
|
4493
|
+
enum: enumProcessor,
|
|
4494
|
+
literal: literalProcessor,
|
|
4495
|
+
nan: nanProcessor,
|
|
4496
|
+
template_literal: templateLiteralProcessor,
|
|
4497
|
+
file: fileProcessor,
|
|
4498
|
+
success: successProcessor,
|
|
4499
|
+
custom: customProcessor,
|
|
4500
|
+
function: functionProcessor,
|
|
4501
|
+
transform: transformProcessor,
|
|
4502
|
+
map: mapProcessor,
|
|
4503
|
+
set: setProcessor,
|
|
4504
|
+
array: arrayProcessor,
|
|
4505
|
+
object: objectProcessor,
|
|
4506
|
+
union: unionProcessor,
|
|
4507
|
+
intersection: intersectionProcessor,
|
|
4508
|
+
tuple: tupleProcessor,
|
|
4509
|
+
record: recordProcessor,
|
|
4510
|
+
nullable: nullableProcessor,
|
|
4511
|
+
nonoptional: nonoptionalProcessor,
|
|
4512
|
+
default: defaultProcessor,
|
|
4513
|
+
prefault: prefaultProcessor,
|
|
4514
|
+
catch: catchProcessor,
|
|
4515
|
+
pipe: pipeProcessor,
|
|
4516
|
+
readonly: readonlyProcessor,
|
|
4517
|
+
promise: promiseProcessor,
|
|
4518
|
+
optional: optionalProcessor,
|
|
4519
|
+
lazy: lazyProcessor
|
|
4520
|
+
};
|
|
4521
|
+
function toJSONSchema(input, params) {
|
|
4522
|
+
if ("_idmap" in input) {
|
|
4523
|
+
const registry = input;
|
|
4524
|
+
const ctx = initializeContext({
|
|
4525
|
+
...params,
|
|
4526
|
+
processors: allProcessors
|
|
4527
|
+
});
|
|
4528
|
+
const defs = {};
|
|
4529
|
+
for (const entry of registry._idmap.entries()) {
|
|
4530
|
+
const [_, schema] = entry;
|
|
4531
|
+
process(schema, ctx);
|
|
4532
|
+
}
|
|
4533
|
+
const schemas = {};
|
|
4534
|
+
ctx.external = {
|
|
4535
|
+
registry,
|
|
4536
|
+
uri: params?.uri,
|
|
4537
|
+
defs
|
|
4538
|
+
};
|
|
4539
|
+
for (const entry of registry._idmap.entries()) {
|
|
4540
|
+
const [key, schema] = entry;
|
|
4541
|
+
extractDefs(ctx, schema);
|
|
4542
|
+
schemas[key] = finalize(ctx, schema);
|
|
4543
|
+
}
|
|
4544
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4545
|
+
return { schemas };
|
|
4546
|
+
}
|
|
4547
|
+
const ctx = initializeContext({
|
|
4548
|
+
...params,
|
|
4549
|
+
processors: allProcessors
|
|
4550
|
+
});
|
|
4551
|
+
process(input, ctx);
|
|
4552
|
+
extractDefs(ctx, input);
|
|
4553
|
+
return finalize(ctx, input);
|
|
4554
|
+
}
|
|
4404
4555
|
//#endregion
|
|
4405
4556
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4406
4557
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5417,7 +5568,7 @@ var ZodIssueCode = {
|
|
|
5417
5568
|
var ZodFirstPartyTypeKind;
|
|
5418
5569
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5419
5570
|
//#endregion
|
|
5420
|
-
//#region ../types/dist/sleep-
|
|
5571
|
+
//#region ../types/dist/sleep-bZIhUvjd.mjs
|
|
5421
5572
|
/**
|
|
5422
5573
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5423
5574
|
* window to float samples (D455).
|
|
@@ -5534,7 +5685,7 @@ function isKeychainStoredField(field) {
|
|
|
5534
5685
|
var SECRET_CLEAR = { $secretClear: true };
|
|
5535
5686
|
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5536
5687
|
var LEGACY_DEVICE_REDACTION = "***";
|
|
5537
|
-
function isRecord$
|
|
5688
|
+
function isRecord$5(value) {
|
|
5538
5689
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5539
5690
|
}
|
|
5540
5691
|
function makeSecretMarker(ref) {
|
|
@@ -5545,12 +5696,12 @@ function makeSecretMarker(ref) {
|
|
|
5545
5696
|
}
|
|
5546
5697
|
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5547
5698
|
function isSecretMarker(value) {
|
|
5548
|
-
if (!isRecord$
|
|
5699
|
+
if (!isRecord$5(value)) return false;
|
|
5549
5700
|
const ref = value["$secret"];
|
|
5550
5701
|
return typeof ref === "string" && ref.length > 0;
|
|
5551
5702
|
}
|
|
5552
5703
|
function isSecretClear(value) {
|
|
5553
|
-
return isRecord$
|
|
5704
|
+
return isRecord$5(value) && value["$secretClear"] === true;
|
|
5554
5705
|
}
|
|
5555
5706
|
/**
|
|
5556
5707
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
@@ -6160,7 +6311,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6160
6311
|
}
|
|
6161
6312
|
};
|
|
6162
6313
|
var KEEP = { kind: "keep" };
|
|
6163
|
-
function isRecord$
|
|
6314
|
+
function isRecord$4(value) {
|
|
6164
6315
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6165
6316
|
}
|
|
6166
6317
|
function defaultMintId() {
|
|
@@ -6173,7 +6324,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6173
6324
|
return out;
|
|
6174
6325
|
}
|
|
6175
6326
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6176
|
-
else if (isRecord$
|
|
6327
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6177
6328
|
return out;
|
|
6178
6329
|
}
|
|
6179
6330
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -6228,7 +6379,7 @@ function rowId(row, idKey) {
|
|
|
6228
6379
|
return null;
|
|
6229
6380
|
}
|
|
6230
6381
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6231
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
6382
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
6232
6383
|
if (!Array.isArray(incoming)) {
|
|
6233
6384
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6234
6385
|
return {
|
|
@@ -6244,7 +6395,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6244
6395
|
const kept = /* @__PURE__ */ new Set();
|
|
6245
6396
|
const rows = [];
|
|
6246
6397
|
for (const row of incoming) {
|
|
6247
|
-
if (!isRecord$
|
|
6398
|
+
if (!isRecord$4(row)) {
|
|
6248
6399
|
rows.push(row);
|
|
6249
6400
|
continue;
|
|
6250
6401
|
}
|
|
@@ -6269,7 +6420,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6269
6420
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6270
6421
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6271
6422
|
case "object": {
|
|
6272
|
-
if (!isRecord$
|
|
6423
|
+
if (!isRecord$4(incoming)) {
|
|
6273
6424
|
if (incoming === void 0) return KEEP;
|
|
6274
6425
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6275
6426
|
return {
|
|
@@ -6277,7 +6428,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6277
6428
|
value: incoming
|
|
6278
6429
|
};
|
|
6279
6430
|
}
|
|
6280
|
-
const storedObj = isRecord$
|
|
6431
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
6281
6432
|
return {
|
|
6282
6433
|
kind: "value",
|
|
6283
6434
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -6400,7 +6551,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
6400
6551
|
value: items
|
|
6401
6552
|
};
|
|
6402
6553
|
}
|
|
6403
|
-
if (isRecord$
|
|
6554
|
+
if (isRecord$4(v)) {
|
|
6404
6555
|
const out = {};
|
|
6405
6556
|
for (const [k, child] of Object.entries(v)) {
|
|
6406
6557
|
const s = substitute(child);
|
|
@@ -6668,7 +6819,6 @@ function createHandle(raw, opts) {
|
|
|
6668
6819
|
const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
|
|
6669
6820
|
const readAddonStoreResult = raw.readAddonStoreResult;
|
|
6670
6821
|
const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
|
|
6671
|
-
const readDeviceStoreBatch = raw.readDeviceStoreBatch;
|
|
6672
6822
|
const overrides = {
|
|
6673
6823
|
readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
|
|
6674
6824
|
...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
|
|
@@ -6692,12 +6842,12 @@ function createHandle(raw, opts) {
|
|
|
6692
6842
|
};
|
|
6693
6843
|
} } : {},
|
|
6694
6844
|
readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
|
|
6695
|
-
|
|
6696
|
-
const rows = await readDeviceStoreBatch
|
|
6845
|
+
readDeviceStoreBatch: async (deviceIds) => {
|
|
6846
|
+
const rows = await raw.readDeviceStoreBatch(deviceIds);
|
|
6697
6847
|
const out = /* @__PURE__ */ new Map();
|
|
6698
6848
|
for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
|
|
6699
6849
|
return out;
|
|
6700
|
-
}
|
|
6850
|
+
},
|
|
6701
6851
|
writeAddonStore: async (patch) => {
|
|
6702
6852
|
await writeAddon(patch);
|
|
6703
6853
|
},
|
|
@@ -7324,7 +7474,7 @@ var BaseAddon = class {
|
|
|
7324
7474
|
if (!ctx) return;
|
|
7325
7475
|
const addonId = ctx.id;
|
|
7326
7476
|
setImmediate(() => {
|
|
7327
|
-
ctx.api.addons
|
|
7477
|
+
ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
|
|
7328
7478
|
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7329
7479
|
}).catch((err) => {
|
|
7330
7480
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -7524,7 +7674,7 @@ var BaseAddon = class {
|
|
|
7524
7674
|
return this._addonSecretTree;
|
|
7525
7675
|
}
|
|
7526
7676
|
deviceSecretTree() {
|
|
7527
|
-
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7677
|
+
this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
|
|
7528
7678
|
return this._deviceSecretTree;
|
|
7529
7679
|
}
|
|
7530
7680
|
/**
|
|
@@ -7600,42 +7750,135 @@ var BaseAddon = class {
|
|
|
7600
7750
|
this[timerOf] = timer;
|
|
7601
7751
|
}
|
|
7602
7752
|
/**
|
|
7603
|
-
* Wrap `ctx.settings.readAddonStore()` with a
|
|
7604
|
-
*
|
|
7605
|
-
* swap, or any race where the SqliteSettingsBackend is between shutdown and
|
|
7606
|
-
* re-initialize) doesn't propagate up into `initialize()` and leave the
|
|
7753
|
+
* Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
|
|
7754
|
+
* settings-store outage doesn't propagate up into `initialize()` and leave the
|
|
7607
7755
|
* addon permanently broken.
|
|
7608
7756
|
*
|
|
7609
|
-
*
|
|
7610
|
-
*
|
|
7611
|
-
* `
|
|
7757
|
+
* Two kinds of outage, two budgets:
|
|
7758
|
+
* - the store's own restart fingerprints (`SqliteSettingsBackend not
|
|
7759
|
+
* initialized`, `provider not available`): a short budget, then the addon
|
|
7760
|
+
* falls back to `{}` (defaults) - its first successful patch rehydrates;
|
|
7761
|
+
* - a TRANSPORT failure (the hub is restarting while this runner boots:
|
|
7762
|
+
* `discovery deadline exceeded`, `parent could not route`, a refused or
|
|
7763
|
+
* timed-out connection). Since D870 a runner's settings read THROWS instead
|
|
7764
|
+
* of answering `{}`, so without a budget a hub restart ends in a respawn
|
|
7765
|
+
* loop. A long, bounded budget; only after it the error propagates - the
|
|
7766
|
+
* addon never runs on defaults for a store it could not ask.
|
|
7767
|
+
* Anything else propagates immediately so real bugs surface.
|
|
7612
7768
|
*/
|
|
7613
7769
|
async readAddonStoreWithRetry() {
|
|
7614
7770
|
const settings = this.rawSettings();
|
|
7615
7771
|
if (!settings) return {};
|
|
7616
|
-
const delaysMs = [
|
|
7617
|
-
150,
|
|
7618
|
-
350,
|
|
7619
|
-
600,
|
|
7620
|
-
900
|
|
7621
|
-
];
|
|
7622
7772
|
let lastErr;
|
|
7623
|
-
for (let attempt = 0
|
|
7773
|
+
for (let attempt = 0;; attempt++) try {
|
|
7624
7774
|
const stored = await settings.readAddonStore() ?? {};
|
|
7625
7775
|
this.settingsStoreReady = true;
|
|
7626
7776
|
return stored;
|
|
7627
7777
|
} catch (err) {
|
|
7628
7778
|
lastErr = err;
|
|
7629
|
-
const
|
|
7630
|
-
if (
|
|
7631
|
-
|
|
7632
|
-
|
|
7779
|
+
const kind = classifyStoreError(err);
|
|
7780
|
+
if (kind === "permanent") throw err;
|
|
7781
|
+
const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
|
|
7782
|
+
if (delay === void 0) {
|
|
7783
|
+
if (kind === "transport") throw err;
|
|
7784
|
+
break;
|
|
7785
|
+
}
|
|
7786
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
7633
7787
|
}
|
|
7634
7788
|
this.settingsStoreReady = false;
|
|
7635
7789
|
this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
|
|
7636
7790
|
return {};
|
|
7637
7791
|
}
|
|
7638
7792
|
};
|
|
7793
|
+
/** The settings store's own restart fingerprints. */
|
|
7794
|
+
var RESTART_RETRY_DELAYS_MS = [
|
|
7795
|
+
150,
|
|
7796
|
+
350,
|
|
7797
|
+
600,
|
|
7798
|
+
900
|
|
7799
|
+
];
|
|
7800
|
+
/** A hub restarting under a booting runner: ~100 s in total. */
|
|
7801
|
+
var TRANSPORT_RETRY_DELAYS_MS = [
|
|
7802
|
+
150,
|
|
7803
|
+
350,
|
|
7804
|
+
600,
|
|
7805
|
+
900,
|
|
7806
|
+
2e3,
|
|
7807
|
+
5e3,
|
|
7808
|
+
1e4,
|
|
7809
|
+
2e4,
|
|
7810
|
+
3e4,
|
|
7811
|
+
3e4
|
|
7812
|
+
];
|
|
7813
|
+
var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
|
|
7814
|
+
/** Node / socket error codes of a connection that did not happen or broke. */
|
|
7815
|
+
var TRANSPORT_CODES = new Set([
|
|
7816
|
+
"ECONNREFUSED",
|
|
7817
|
+
"ECONNRESET",
|
|
7818
|
+
"ETIMEDOUT",
|
|
7819
|
+
"EPIPE",
|
|
7820
|
+
"EHOSTUNREACH",
|
|
7821
|
+
"ENETUNREACH"
|
|
7822
|
+
]);
|
|
7823
|
+
/** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
|
|
7824
|
+
var UNAVAILABLE_TRPC_CODES = new Set([
|
|
7825
|
+
"TIMEOUT",
|
|
7826
|
+
"SERVICE_UNAVAILABLE",
|
|
7827
|
+
"BAD_GATEWAY",
|
|
7828
|
+
"GATEWAY_TIMEOUT"
|
|
7829
|
+
]);
|
|
7830
|
+
/** The exact phrases OUR transport raises when it cannot reach the hub. */
|
|
7831
|
+
var TRANSPORT_PHRASES = [
|
|
7832
|
+
"discovery deadline exceeded",
|
|
7833
|
+
"parent could not route child unowned cap call",
|
|
7834
|
+
"UDS request timed out after",
|
|
7835
|
+
"channel closed"
|
|
7836
|
+
];
|
|
7837
|
+
/** Moleculer error `type`s of a call that could not be served right now. */
|
|
7838
|
+
var MOLECULER_TRANSIENT_TYPES = new Set([
|
|
7839
|
+
"REQUEST_TIMEOUT",
|
|
7840
|
+
"SERVICE_NOT_FOUND",
|
|
7841
|
+
"SERVICE_NOT_AVAILABLE",
|
|
7842
|
+
"REQUEST_REJECTED",
|
|
7843
|
+
"BROKER_DISCONNECTED"
|
|
7844
|
+
]);
|
|
7845
|
+
function stringProp(value, key) {
|
|
7846
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
7847
|
+
const found = Reflect.get(value, key);
|
|
7848
|
+
return typeof found === "string" ? found : void 0;
|
|
7849
|
+
}
|
|
7850
|
+
/** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
|
|
7851
|
+
function errorCode(err) {
|
|
7852
|
+
const out = {};
|
|
7853
|
+
const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
|
|
7854
|
+
const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
|
|
7855
|
+
const node = stringProp(err, "code") ?? stringProp(cause, "code");
|
|
7856
|
+
if (node !== void 0) out.node = node;
|
|
7857
|
+
const trpc = stringProp(data, "code");
|
|
7858
|
+
if (trpc !== void 0) out.trpc = trpc;
|
|
7859
|
+
return out;
|
|
7860
|
+
}
|
|
7861
|
+
/**
|
|
7862
|
+
* Is a settings read failure worth retrying, and with which budget? Only
|
|
7863
|
+
* EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
|
|
7864
|
+
* one of the exact phrases our own transport raises. A message that merely
|
|
7865
|
+
* contains "timed out" or "unreachable" is not evidence of anything, and
|
|
7866
|
+
* `settings store not wired` is a wiring bug that retrying cannot fix.
|
|
7867
|
+
*/
|
|
7868
|
+
function classifyStoreError(err) {
|
|
7869
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7870
|
+
if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
|
|
7871
|
+
const code = errorCode(err);
|
|
7872
|
+
if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
|
|
7873
|
+
if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
|
|
7874
|
+
if (typeof err === "object" && err !== null) {
|
|
7875
|
+
if (Reflect.get(err, "retryable") === true) return "transport";
|
|
7876
|
+
const type = stringProp(err, "type");
|
|
7877
|
+
if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
|
|
7878
|
+
}
|
|
7879
|
+
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
7880
|
+
return "permanent";
|
|
7881
|
+
}
|
|
7639
7882
|
/**
|
|
7640
7883
|
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
7641
7884
|
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
@@ -7725,6 +7968,303 @@ var PeerBytesTicketSchema = object({
|
|
|
7725
7968
|
*/
|
|
7726
7969
|
declaredBytes: number().int().nonnegative().nullable()
|
|
7727
7970
|
});
|
|
7971
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7972
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7973
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7974
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7975
|
+
var RECORD_CLASSES = [
|
|
7976
|
+
"config",
|
|
7977
|
+
"ledger",
|
|
7978
|
+
"audit",
|
|
7979
|
+
"mirror",
|
|
7980
|
+
"ephemeral"
|
|
7981
|
+
];
|
|
7982
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
7983
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
7984
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
7985
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
7986
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
7987
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7988
|
+
var PREFIX = "records/";
|
|
7989
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
7990
|
+
var RecordsError = class extends Error {
|
|
7991
|
+
code;
|
|
7992
|
+
detail;
|
|
7993
|
+
constructor(code, detail) {
|
|
7994
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
7995
|
+
this.name = "RecordsError";
|
|
7996
|
+
this.code = code;
|
|
7997
|
+
this.detail = detail;
|
|
7998
|
+
}
|
|
7999
|
+
};
|
|
8000
|
+
var InvalidRecordError = class extends RecordsError {
|
|
8001
|
+
constructor(detail) {
|
|
8002
|
+
super("invalid-record", detail);
|
|
8003
|
+
this.name = "InvalidRecordError";
|
|
8004
|
+
}
|
|
8005
|
+
};
|
|
8006
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8007
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
8008
|
+
constructor(detail) {
|
|
8009
|
+
super("declaration-refused", detail);
|
|
8010
|
+
this.name = "DeclarationRefusedError";
|
|
8011
|
+
}
|
|
8012
|
+
};
|
|
8013
|
+
function defOf(schema) {
|
|
8014
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8015
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8016
|
+
const def = Reflect.get(zodBag, "def");
|
|
8017
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8018
|
+
return def;
|
|
8019
|
+
}
|
|
8020
|
+
function declaredHere(schema) {
|
|
8021
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8022
|
+
}
|
|
8023
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8024
|
+
var WRAPPERS = new Set([
|
|
8025
|
+
"optional",
|
|
8026
|
+
"nullable",
|
|
8027
|
+
"default",
|
|
8028
|
+
"prefault",
|
|
8029
|
+
"catch",
|
|
8030
|
+
"readonly",
|
|
8031
|
+
"nonoptional"
|
|
8032
|
+
]);
|
|
8033
|
+
/**
|
|
8034
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8035
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8036
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8037
|
+
* `.transform` on `in`).
|
|
8038
|
+
*/
|
|
8039
|
+
function layersOf(schema) {
|
|
8040
|
+
const out = [];
|
|
8041
|
+
const queue = [schema];
|
|
8042
|
+
while (queue.length > 0) {
|
|
8043
|
+
const s = queue.shift();
|
|
8044
|
+
if (!s || out.includes(s)) continue;
|
|
8045
|
+
out.push(s);
|
|
8046
|
+
const def = defOf(s);
|
|
8047
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8048
|
+
if (def.type === "pipe") {
|
|
8049
|
+
if (def.in) queue.push(def.in);
|
|
8050
|
+
if (def.out) queue.push(def.out);
|
|
8051
|
+
}
|
|
8052
|
+
}
|
|
8053
|
+
return out;
|
|
8054
|
+
}
|
|
8055
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8056
|
+
function isZodSecret(schema) {
|
|
8057
|
+
return layersOf(schema).some(declaredHere);
|
|
8058
|
+
}
|
|
8059
|
+
/**
|
|
8060
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8061
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8062
|
+
* object or array is reported as one path and not descended into — everything
|
|
8063
|
+
* under it is secret.
|
|
8064
|
+
*/
|
|
8065
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8066
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8067
|
+
const paths = [];
|
|
8068
|
+
for (const layer of layersOf(schema)) {
|
|
8069
|
+
const def = defOf(layer);
|
|
8070
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8071
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8072
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8073
|
+
else if (def.type === "intersection") {
|
|
8074
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8075
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8076
|
+
}
|
|
8077
|
+
}
|
|
8078
|
+
return [...new Set(paths)];
|
|
8079
|
+
}
|
|
8080
|
+
/**
|
|
8081
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8082
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8083
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8084
|
+
*
|
|
8085
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8086
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8087
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8088
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8089
|
+
*
|
|
8090
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8091
|
+
*/
|
|
8092
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8093
|
+
function parseSecretPath(path) {
|
|
8094
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8095
|
+
return path.split(".").map((raw) => {
|
|
8096
|
+
const each = raw.endsWith("[]");
|
|
8097
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8098
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8099
|
+
return {
|
|
8100
|
+
key,
|
|
8101
|
+
each
|
|
8102
|
+
};
|
|
8103
|
+
});
|
|
8104
|
+
}
|
|
8105
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8106
|
+
function secretArrayPrefixes(path) {
|
|
8107
|
+
const segments = parseSecretPath(path);
|
|
8108
|
+
const prefixes = [];
|
|
8109
|
+
const walked = [];
|
|
8110
|
+
for (const segment of segments) {
|
|
8111
|
+
walked.push(segment.key);
|
|
8112
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8113
|
+
}
|
|
8114
|
+
return prefixes;
|
|
8115
|
+
}
|
|
8116
|
+
/**
|
|
8117
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8118
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8119
|
+
* JSON the engine stores.
|
|
8120
|
+
*
|
|
8121
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
8122
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
8123
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
8124
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
8125
|
+
* never a field name (D879).
|
|
8126
|
+
*/
|
|
8127
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
8128
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
8129
|
+
var RecordIndexSchema = object({
|
|
8130
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
8131
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
8132
|
+
unique: boolean().optional()
|
|
8133
|
+
}).strict();
|
|
8134
|
+
var RecordRetentionSchema = union([
|
|
8135
|
+
object({
|
|
8136
|
+
ttlMs: number().int().positive(),
|
|
8137
|
+
from: _enum(["at", "write"])
|
|
8138
|
+
}).strict(),
|
|
8139
|
+
object({
|
|
8140
|
+
maxRows: number().int().positive().optional(),
|
|
8141
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
8142
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
8143
|
+
object({
|
|
8144
|
+
owner: string().min(1),
|
|
8145
|
+
reason: string().min(1)
|
|
8146
|
+
}).strict(),
|
|
8147
|
+
object({ none: string().min(1) }).strict()
|
|
8148
|
+
]);
|
|
8149
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
8150
|
+
var EntryDescriptorSchema = object({
|
|
8151
|
+
title: string().min(1),
|
|
8152
|
+
/** The record body field shown as the entry's name. */
|
|
8153
|
+
nameField: string().min(1),
|
|
8154
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
8155
|
+
fields: record(string(), unknown())
|
|
8156
|
+
}).strict();
|
|
8157
|
+
/** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
|
|
8158
|
+
var RecordKindDeclarationSchema = object({
|
|
8159
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
8160
|
+
class: _enum(RECORD_CLASSES),
|
|
8161
|
+
writeTrigger: string().min(1),
|
|
8162
|
+
device: _enum([
|
|
8163
|
+
"required",
|
|
8164
|
+
"optional",
|
|
8165
|
+
"none"
|
|
8166
|
+
]).default("none"),
|
|
8167
|
+
at: _enum(["required", "none"]).default("none"),
|
|
8168
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
8169
|
+
retention: RecordRetentionSchema,
|
|
8170
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
8171
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
8172
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
8173
|
+
secretPaths: array(string().min(1)).default([]),
|
|
8174
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
8175
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
8176
|
+
/** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
|
|
8177
|
+
adoptsFrom: string().min(1).optional(),
|
|
8178
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
8179
|
+
transactFamily: string().min(1).optional(),
|
|
8180
|
+
entry: EntryDescriptorSchema.optional()
|
|
8181
|
+
}).strict();
|
|
8182
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8183
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
8184
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
8185
|
+
function assertValidDeclaration(name, decl) {
|
|
8186
|
+
const refuse = (why) => {
|
|
8187
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
8188
|
+
};
|
|
8189
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
8190
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8191
|
+
for (const index of decl.indexes) {
|
|
8192
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
8193
|
+
seen.add(index.name);
|
|
8194
|
+
}
|
|
8195
|
+
const { retention } = decl;
|
|
8196
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
8197
|
+
if ("ttlMs" in retention) {
|
|
8198
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
8199
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
8200
|
+
}
|
|
8201
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
8202
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
8203
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
8204
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
8205
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
8206
|
+
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)`);
|
|
8207
|
+
}
|
|
8208
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
8209
|
+
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`);
|
|
8210
|
+
}
|
|
8211
|
+
function bodyFieldsOf(schema) {
|
|
8212
|
+
return { ...toJSONSchema(schema, {
|
|
8213
|
+
unrepresentable: "any",
|
|
8214
|
+
io: "input"
|
|
8215
|
+
}) };
|
|
8216
|
+
}
|
|
8217
|
+
function isRecordLike(value) {
|
|
8218
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8219
|
+
}
|
|
8220
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
8221
|
+
function hasNameField(json, field) {
|
|
8222
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
8223
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
8224
|
+
const properties = json["properties"];
|
|
8225
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
8226
|
+
}
|
|
8227
|
+
/**
|
|
8228
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
8229
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
8230
|
+
* types its handle from.
|
|
8231
|
+
*/
|
|
8232
|
+
function defineRecordKinds(specs) {
|
|
8233
|
+
const out = {};
|
|
8234
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
8235
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
8236
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
8237
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
8238
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
8239
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
8240
|
+
database: spec.database,
|
|
8241
|
+
class: spec.class,
|
|
8242
|
+
writeTrigger: spec.writeTrigger,
|
|
8243
|
+
device: spec.device,
|
|
8244
|
+
at: spec.at,
|
|
8245
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
8246
|
+
retention: spec.retention,
|
|
8247
|
+
deviceRemoval: spec.deviceRemoval,
|
|
8248
|
+
maxDataBytes: spec.maxDataBytes,
|
|
8249
|
+
secretPaths: [...secretPaths],
|
|
8250
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
8251
|
+
adoptsFrom: spec.adoptsFrom,
|
|
8252
|
+
transactFamily: spec.transactFamily,
|
|
8253
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
8254
|
+
title: spec.entry.title,
|
|
8255
|
+
nameField,
|
|
8256
|
+
fields
|
|
8257
|
+
}
|
|
8258
|
+
});
|
|
8259
|
+
assertValidDeclaration(name, parsed);
|
|
8260
|
+
out[name] = {
|
|
8261
|
+
name,
|
|
8262
|
+
schema: spec.schema,
|
|
8263
|
+
declaration: parsed
|
|
8264
|
+
};
|
|
8265
|
+
}
|
|
8266
|
+
return out;
|
|
8267
|
+
}
|
|
7728
8268
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
7729
8269
|
var CamProfileSchema = _enum([
|
|
7730
8270
|
"high",
|
|
@@ -8226,7 +8766,7 @@ function userError(code, params, englishFallback) {
|
|
|
8226
8766
|
return new CamstackError(code, params, englishFallback);
|
|
8227
8767
|
}
|
|
8228
8768
|
//#endregion
|
|
8229
|
-
//#region ../types/dist/err-msg
|
|
8769
|
+
//#region ../types/dist/err-msg--2RrYiLO.mjs
|
|
8230
8770
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
8231
8771
|
DeviceType["Camera"] = "camera";
|
|
8232
8772
|
DeviceType["Hub"] = "hub";
|
|
@@ -8495,6 +9035,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8495
9035
|
/** Virtual HA toggle (input_boolean.*) — distinguishable from a
|
|
8496
9036
|
* real Switch device for UI rendering / export adapters. */
|
|
8497
9037
|
DeviceRole["BinaryHelper"] = "binary-helper";
|
|
9038
|
+
/** A smart plug: a `switch` whose source says it is an outlet (HA
|
|
9039
|
+
* `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
|
|
9040
|
+
DeviceRole["Outlet"] = "outlet";
|
|
8498
9041
|
/** Generic motion / occupancy / moving event source. Distinct from
|
|
8499
9042
|
* the camera accessory PirSensor role: that one is a camera child;
|
|
8500
9043
|
* this is a standalone HA / 3rd-party motion sensor. */
|
|
@@ -8562,7 +9105,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8562
9105
|
return DeviceRole;
|
|
8563
9106
|
}({});
|
|
8564
9107
|
//#endregion
|
|
8565
|
-
//#region ../types/dist/composition-
|
|
9108
|
+
//#region ../types/dist/composition-DOwQB_Ua.mjs
|
|
8566
9109
|
/**
|
|
8567
9110
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
8568
9111
|
*
|
|
@@ -11883,11 +12426,10 @@ var ClipModelMetaSchema = object({
|
|
|
11883
12426
|
/**
|
|
11884
12427
|
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
11885
12428
|
* per index: two models share an index only when their vectors are ranked
|
|
11886
|
-
* against each other, which for CLIP means never across families.
|
|
11887
|
-
*
|
|
11888
|
-
* `modelId`); any other model gets its own.
|
|
12429
|
+
* against each other, which for CLIP means never across families. Every
|
|
12430
|
+
* model gets its own.
|
|
11889
12431
|
*/
|
|
11890
|
-
vectorIndex: string().regex(/^object-clip
|
|
12432
|
+
vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
11891
12433
|
/**
|
|
11892
12434
|
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
11893
12435
|
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
@@ -15533,6 +16075,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
|
|
|
15533
16075
|
keyField: string()
|
|
15534
16076
|
}).optional()
|
|
15535
16077
|
})) });
|
|
16078
|
+
/**
|
|
16079
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
16080
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
16081
|
+
*
|
|
16082
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
16083
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
16084
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
16085
|
+
*/
|
|
16086
|
+
var RawSecretMigrationInputSchema = object({
|
|
16087
|
+
/** `false` (the default of the script) = report only. */
|
|
16088
|
+
apply: boolean() });
|
|
16089
|
+
var RawSecretMigrationReportSchema = object({
|
|
16090
|
+
apply: boolean(),
|
|
16091
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
16092
|
+
rows: number().int(),
|
|
16093
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
16094
|
+
raw: number().int(),
|
|
16095
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
16096
|
+
markers: number().int(),
|
|
16097
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
16098
|
+
migrated: number().int(),
|
|
16099
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
16100
|
+
failed: number().int(),
|
|
16101
|
+
/** After the run: rows still holding plaintext. */
|
|
16102
|
+
remainingRaw: number().int(),
|
|
16103
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
16104
|
+
unresolvedMarkers: number().int(),
|
|
16105
|
+
/**
|
|
16106
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
16107
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
16108
|
+
*/
|
|
16109
|
+
redundantCopies: number().int().optional(),
|
|
16110
|
+
/** True when nothing is raw and every marker resolves. */
|
|
16111
|
+
verified: boolean()
|
|
16112
|
+
});
|
|
15536
16113
|
/** Where a block runs. The operator chooses — a block driving a device on an
|
|
15537
16114
|
* agent is the reason placement is not fixed to the hub. */
|
|
15538
16115
|
var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
|
|
@@ -15759,6 +16336,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
15759
16336
|
}), SettingsUpdateResultSchema, {
|
|
15760
16337
|
kind: "mutation",
|
|
15761
16338
|
auth: "admin"
|
|
16339
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
16340
|
+
kind: "mutation",
|
|
16341
|
+
auth: "admin"
|
|
15762
16342
|
}), method(object({}), object({ libs: array(object({
|
|
15763
16343
|
filePath: string(),
|
|
15764
16344
|
content: string()
|
|
@@ -16022,6 +16602,347 @@ id: union([string(), number()]) }), {
|
|
|
16022
16602
|
auth: "admin"
|
|
16023
16603
|
});
|
|
16024
16604
|
/**
|
|
16605
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
16606
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
16607
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
16608
|
+
*
|
|
16609
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
16610
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
16611
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
16612
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
16613
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
16614
|
+
* addons go through the owner's capability.
|
|
16615
|
+
*
|
|
16616
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
16617
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
16618
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
16619
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
16620
|
+
* row's own ref.
|
|
16621
|
+
*
|
|
16622
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
16623
|
+
*/
|
|
16624
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
16625
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
16626
|
+
var RecordBodySchema = record(string(), unknown());
|
|
16627
|
+
var RecordInputSchema = object({
|
|
16628
|
+
id: RecordIdSchema,
|
|
16629
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
16630
|
+
deviceId: number().int().optional(),
|
|
16631
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
16632
|
+
at: number().int().optional(),
|
|
16633
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
16634
|
+
expiresAt: number().int().optional(),
|
|
16635
|
+
data: RecordBodySchema
|
|
16636
|
+
});
|
|
16637
|
+
var RecordViewSchema = object({
|
|
16638
|
+
id: string(),
|
|
16639
|
+
deviceId: number().int().nullable(),
|
|
16640
|
+
at: number().nullable(),
|
|
16641
|
+
expiresAt: number().nullable(),
|
|
16642
|
+
rev: number().int(),
|
|
16643
|
+
updatedAt: number(),
|
|
16644
|
+
data: RecordBodySchema
|
|
16645
|
+
});
|
|
16646
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
16647
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
16648
|
+
string(),
|
|
16649
|
+
number(),
|
|
16650
|
+
boolean(),
|
|
16651
|
+
object({ in: array(union([
|
|
16652
|
+
string(),
|
|
16653
|
+
number(),
|
|
16654
|
+
boolean()
|
|
16655
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
16656
|
+
object({
|
|
16657
|
+
gt: union([string(), number()]).optional(),
|
|
16658
|
+
gte: union([string(), number()]).optional(),
|
|
16659
|
+
lt: union([string(), number()]).optional(),
|
|
16660
|
+
lte: union([string(), number()]).optional()
|
|
16661
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
16662
|
+
]));
|
|
16663
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
16664
|
+
var TimeWindowShape = {
|
|
16665
|
+
deviceId: number().int().optional(),
|
|
16666
|
+
atFrom: number().optional(),
|
|
16667
|
+
atTo: number().optional()
|
|
16668
|
+
};
|
|
16669
|
+
var RecordQueryInputSchema = object({
|
|
16670
|
+
...KindShape,
|
|
16671
|
+
...TimeWindowShape,
|
|
16672
|
+
where: RecordWhereSchema.optional(),
|
|
16673
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
16674
|
+
order: _enum(["at", "id"]).optional(),
|
|
16675
|
+
desc: boolean().optional(),
|
|
16676
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
16677
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
16678
|
+
cursor: string().min(1).optional()
|
|
16679
|
+
});
|
|
16680
|
+
var RecordQueryResultSchema = object({
|
|
16681
|
+
records: array(RecordViewSchema),
|
|
16682
|
+
nextCursor: string().nullable()
|
|
16683
|
+
});
|
|
16684
|
+
var RecordKindStateSchema = _enum([
|
|
16685
|
+
"created",
|
|
16686
|
+
"unchanged",
|
|
16687
|
+
"updated"
|
|
16688
|
+
]);
|
|
16689
|
+
var DeclareKindResultSchema = object({
|
|
16690
|
+
kindId: number().int(),
|
|
16691
|
+
state: RecordKindStateSchema,
|
|
16692
|
+
createdIndexes: array(string()),
|
|
16693
|
+
/** The boot guard: the kind is empty while its legacy table still holds rows. */
|
|
16694
|
+
adoptionPending: object({
|
|
16695
|
+
legacyTable: string(),
|
|
16696
|
+
legacyRows: number().int()
|
|
16697
|
+
}).nullable()
|
|
16698
|
+
});
|
|
16699
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
16700
|
+
var SecretRefsList = array(string());
|
|
16701
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
16702
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
16703
|
+
kind: "mutation",
|
|
16704
|
+
auth: "admin"
|
|
16705
|
+
}), method(object({
|
|
16706
|
+
...KindShape,
|
|
16707
|
+
id: RecordIdSchema
|
|
16708
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
16709
|
+
...KindShape,
|
|
16710
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16711
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
16712
|
+
...KindShape,
|
|
16713
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16714
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
16715
|
+
...KindShape,
|
|
16716
|
+
record: RecordInputSchema,
|
|
16717
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
16718
|
+
ifRev: number().int().min(0).optional()
|
|
16719
|
+
}), object({
|
|
16720
|
+
rev: number().int(),
|
|
16721
|
+
releasedRefs: SecretRefsList
|
|
16722
|
+
}), {
|
|
16723
|
+
kind: "mutation",
|
|
16724
|
+
auth: "admin"
|
|
16725
|
+
}), method(object({
|
|
16726
|
+
...KindShape,
|
|
16727
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16728
|
+
}), object({
|
|
16729
|
+
count: number().int(),
|
|
16730
|
+
releasedRefs: SecretRefsList
|
|
16731
|
+
}), {
|
|
16732
|
+
kind: "mutation",
|
|
16733
|
+
auth: "admin"
|
|
16734
|
+
}), method(object({
|
|
16735
|
+
...KindShape,
|
|
16736
|
+
id: RecordIdSchema,
|
|
16737
|
+
data: RecordBodySchema,
|
|
16738
|
+
at: number().int().nullable().optional(),
|
|
16739
|
+
expiresAt: number().int().nullable().optional(),
|
|
16740
|
+
ifRev: number().int().min(1).optional()
|
|
16741
|
+
}), object({
|
|
16742
|
+
rev: number().int(),
|
|
16743
|
+
releasedRefs: SecretRefsList
|
|
16744
|
+
}), {
|
|
16745
|
+
kind: "mutation",
|
|
16746
|
+
auth: "admin"
|
|
16747
|
+
}), method(object({
|
|
16748
|
+
...KindShape,
|
|
16749
|
+
id: RecordIdSchema
|
|
16750
|
+
}), object({
|
|
16751
|
+
deleted: boolean(),
|
|
16752
|
+
secretRefs: SecretRefsList
|
|
16753
|
+
}), {
|
|
16754
|
+
kind: "mutation",
|
|
16755
|
+
auth: "admin"
|
|
16756
|
+
}), method(object({
|
|
16757
|
+
...KindShape,
|
|
16758
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16759
|
+
}), object({
|
|
16760
|
+
deleted: number().int(),
|
|
16761
|
+
secretRefs: SecretRefsList
|
|
16762
|
+
}), {
|
|
16763
|
+
kind: "mutation",
|
|
16764
|
+
auth: "admin"
|
|
16765
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16766
|
+
...KindShape,
|
|
16767
|
+
...TimeWindowShape,
|
|
16768
|
+
where: RecordWhereSchema.optional()
|
|
16769
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
16770
|
+
...KindShape,
|
|
16771
|
+
deviceId: number().int().optional(),
|
|
16772
|
+
from: number(),
|
|
16773
|
+
to: number(),
|
|
16774
|
+
bucketMs: number().int().positive()
|
|
16775
|
+
}), object({ buckets: array(object({
|
|
16776
|
+
bucketStart: number(),
|
|
16777
|
+
count: number().int()
|
|
16778
|
+
})) }), { auth: "admin" }), method(object({
|
|
16779
|
+
...KindShape,
|
|
16780
|
+
op: _enum([
|
|
16781
|
+
"sum",
|
|
16782
|
+
"min",
|
|
16783
|
+
"max",
|
|
16784
|
+
"count"
|
|
16785
|
+
]),
|
|
16786
|
+
field: RecordFieldPathSchema.optional(),
|
|
16787
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
16788
|
+
where: RecordWhereSchema.optional()
|
|
16789
|
+
}), object({ rows: array(object({
|
|
16790
|
+
group: union([
|
|
16791
|
+
string(),
|
|
16792
|
+
number(),
|
|
16793
|
+
_null()
|
|
16794
|
+
]),
|
|
16795
|
+
value: number().nullable()
|
|
16796
|
+
})) }), { auth: "admin" }), method(object({
|
|
16797
|
+
...KindShape,
|
|
16798
|
+
deviceId: number().int().optional(),
|
|
16799
|
+
atBefore: number().optional(),
|
|
16800
|
+
where: RecordWhereSchema.optional()
|
|
16801
|
+
}), object({
|
|
16802
|
+
deleted: number().int(),
|
|
16803
|
+
secretRefs: SecretRefsList
|
|
16804
|
+
}), {
|
|
16805
|
+
kind: "mutation",
|
|
16806
|
+
auth: "admin"
|
|
16807
|
+
}), method(object({
|
|
16808
|
+
deviceId: number().int(),
|
|
16809
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
16810
|
+
}), object({
|
|
16811
|
+
deleted: record(string(), number().int()),
|
|
16812
|
+
secretRefs: SecretRefsList
|
|
16813
|
+
}), {
|
|
16814
|
+
kind: "mutation",
|
|
16815
|
+
auth: "admin"
|
|
16816
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
16817
|
+
kind: "mutation",
|
|
16818
|
+
auth: "admin"
|
|
16819
|
+
});
|
|
16820
|
+
/** One table of the settings database. */
|
|
16821
|
+
var StorageTableSchema = object({
|
|
16822
|
+
/** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
|
|
16823
|
+
name: string(),
|
|
16824
|
+
/** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
|
|
16825
|
+
owner: string().nullable(),
|
|
16826
|
+
rows: number().int().nonnegative(),
|
|
16827
|
+
/** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
|
|
16828
|
+
bytes: number().int().nonnegative().nullable(),
|
|
16829
|
+
/** Declared by an addon since this engine process started (a running addon claims it). */
|
|
16830
|
+
declaredThisBoot: boolean()
|
|
16831
|
+
});
|
|
16832
|
+
/** One declared record kind (D881) as System -> Data shows it. */
|
|
16833
|
+
var StorageKindSchema = object({
|
|
16834
|
+
owner: string(),
|
|
16835
|
+
kind: string(),
|
|
16836
|
+
database: _enum(["settings", "events"]),
|
|
16837
|
+
class: string(),
|
|
16838
|
+
state: _enum([
|
|
16839
|
+
"declared",
|
|
16840
|
+
"orphaned",
|
|
16841
|
+
"dropped"
|
|
16842
|
+
]),
|
|
16843
|
+
/** `null` when the caller asked for no counts (`counts: false`). */
|
|
16844
|
+
rows: number().int().nonnegative().nullable(),
|
|
16845
|
+
/** Rows x the average size of a sample; null for an empty kind. */
|
|
16846
|
+
bytesEstimate: number().int().nonnegative().nullable(),
|
|
16847
|
+
writeTrigger: string(),
|
|
16848
|
+
retention: RecordRetentionSchema,
|
|
16849
|
+
/** `true` when the kind is an entry kind (the generic entries UI lists it). */
|
|
16850
|
+
entry: boolean(),
|
|
16851
|
+
/** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
|
|
16852
|
+
declaration: RecordKindDeclarationSchema
|
|
16853
|
+
});
|
|
16854
|
+
method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
|
|
16855
|
+
collection: string().min(1),
|
|
16856
|
+
expectRows: number().int().nonnegative()
|
|
16857
|
+
}), object({
|
|
16858
|
+
dropped: literal(true),
|
|
16859
|
+
rows: number().int().nonnegative()
|
|
16860
|
+
}), {
|
|
16861
|
+
kind: "mutation",
|
|
16862
|
+
auth: "admin"
|
|
16863
|
+
}), method(object({
|
|
16864
|
+
owner: string().min(1).optional(),
|
|
16865
|
+
/** `false` skips the per-kind row count (a catalog read only). Default true. */
|
|
16866
|
+
counts: boolean().optional()
|
|
16867
|
+
}), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
|
|
16868
|
+
owner: string().min(1),
|
|
16869
|
+
kind: RecordKindNameSchema
|
|
16870
|
+
}), RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16871
|
+
owner: string().min(1),
|
|
16872
|
+
kind: RecordKindNameSchema,
|
|
16873
|
+
records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
16874
|
+
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
16875
|
+
complete: boolean().optional()
|
|
16876
|
+
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
|
|
16877
|
+
kind: "mutation",
|
|
16878
|
+
auth: "admin"
|
|
16879
|
+
}), method(object({
|
|
16880
|
+
collection: string().min(1),
|
|
16881
|
+
cursor: string().optional(),
|
|
16882
|
+
limit: number().int().min(1).max(1e3).optional()
|
|
16883
|
+
}), object({
|
|
16884
|
+
rows: array(object({
|
|
16885
|
+
id: string(),
|
|
16886
|
+
data: record(string(), unknown())
|
|
16887
|
+
})),
|
|
16888
|
+
nextCursor: string().nullable()
|
|
16889
|
+
}), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
|
|
16890
|
+
/**
|
|
16891
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
16892
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
16893
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
16894
|
+
*
|
|
16895
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
16896
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
16897
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
16898
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16899
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
16900
|
+
* a secret value, and a locked keychain refuses the write with
|
|
16901
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
16902
|
+
*
|
|
16903
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
16904
|
+
*/
|
|
16905
|
+
var EntryKindInfoSchema = object({
|
|
16906
|
+
owner: string(),
|
|
16907
|
+
kind: RecordKindNameSchema,
|
|
16908
|
+
title: string(),
|
|
16909
|
+
nameField: string(),
|
|
16910
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
16911
|
+
fields: record(string(), unknown()),
|
|
16912
|
+
secretPaths: array(string()),
|
|
16913
|
+
rows: number().int().nonnegative()
|
|
16914
|
+
});
|
|
16915
|
+
var EntryViewSchema = object({
|
|
16916
|
+
id: RecordIdSchema,
|
|
16917
|
+
name: string(),
|
|
16918
|
+
rev: number().int(),
|
|
16919
|
+
updatedAt: number(),
|
|
16920
|
+
/** Secret fields hold the redaction token. */
|
|
16921
|
+
data: RecordBodySchema
|
|
16922
|
+
});
|
|
16923
|
+
var EntryAddress = {
|
|
16924
|
+
owner: string().min(1),
|
|
16925
|
+
kind: RecordKindNameSchema
|
|
16926
|
+
};
|
|
16927
|
+
method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
|
|
16928
|
+
...EntryAddress,
|
|
16929
|
+
id: RecordIdSchema.optional(),
|
|
16930
|
+
data: RecordBodySchema,
|
|
16931
|
+
ifRev: number().int().min(1).optional()
|
|
16932
|
+
}), object({
|
|
16933
|
+
id: string(),
|
|
16934
|
+
rev: number().int()
|
|
16935
|
+
}), {
|
|
16936
|
+
kind: "mutation",
|
|
16937
|
+
auth: "admin"
|
|
16938
|
+
}), method(object({
|
|
16939
|
+
...EntryAddress,
|
|
16940
|
+
id: RecordIdSchema
|
|
16941
|
+
}), object({ deleted: boolean() }), {
|
|
16942
|
+
kind: "mutation",
|
|
16943
|
+
auth: "admin"
|
|
16944
|
+
});
|
|
16945
|
+
/**
|
|
16025
16946
|
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
16026
16947
|
*
|
|
16027
16948
|
* Settings blobs never hold a secret: they hold a marker
|
|
@@ -16562,6 +17483,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
|
|
|
16562
17483
|
kind: "mutation",
|
|
16563
17484
|
auth: "admin",
|
|
16564
17485
|
caller: "required"
|
|
17486
|
+
}), method(object({
|
|
17487
|
+
ref: string().min(1),
|
|
17488
|
+
value: string().min(1)
|
|
17489
|
+
}), object({
|
|
17490
|
+
ref: string(),
|
|
17491
|
+
version: number().int()
|
|
17492
|
+
}), {
|
|
17493
|
+
kind: "mutation",
|
|
17494
|
+
auth: "admin",
|
|
17495
|
+
caller: "required"
|
|
16565
17496
|
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
16566
17497
|
deleted: array(string()).readonly(),
|
|
16567
17498
|
kept: array(object({
|
|
@@ -39031,6 +39962,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
|
|
|
39031
39962
|
}), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
|
|
39032
39963
|
kind: "mutation",
|
|
39033
39964
|
auth: "admin"
|
|
39965
|
+
}), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
39966
|
+
kind: "mutation",
|
|
39967
|
+
auth: "admin"
|
|
39034
39968
|
}), method(ProfileRefInputSchema, _void(), {
|
|
39035
39969
|
kind: "mutation",
|
|
39036
39970
|
auth: "admin"
|
|
@@ -49476,6 +50410,41 @@ var ServerRollbackInfoSchema = object({
|
|
|
49476
50410
|
atMs: number(),
|
|
49477
50411
|
reason: string()
|
|
49478
50412
|
});
|
|
50413
|
+
/**
|
|
50414
|
+
* The runner boot check (D877): the runners this node PLANNED (hub: one per
|
|
50415
|
+
* `resolveRunnerId` over its forked addons; agent: the runners its process
|
|
50416
|
+
* service holds, because only the hub plans) against the states the process
|
|
50417
|
+
* service reports. Kept in memory, recomputed by the same one-shot check after
|
|
50418
|
+
* every boot, served on `getServerPackageStatus`.
|
|
50419
|
+
*
|
|
50420
|
+
* `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
|
|
50421
|
+
* refusal (an addon that said "I will not start, and here is why"), `missing` a
|
|
50422
|
+
* planned runner the process service has no entry for.
|
|
50423
|
+
*/
|
|
50424
|
+
var RunnerRefusalSchema = object({
|
|
50425
|
+
runnerId: string(),
|
|
50426
|
+
addonIds: array(string()),
|
|
50427
|
+
reason: string()
|
|
50428
|
+
});
|
|
50429
|
+
var RunnerBootCheckSchema = object({
|
|
50430
|
+
checkedAtMs: number(),
|
|
50431
|
+
/** Runners planned for this node. */
|
|
50432
|
+
expected: number(),
|
|
50433
|
+
/** Planned runners whose process is `running`. */
|
|
50434
|
+
running: number(),
|
|
50435
|
+
failed: array(string()),
|
|
50436
|
+
refused: array(RunnerRefusalSchema),
|
|
50437
|
+
missing: array(string()),
|
|
50438
|
+
/**
|
|
50439
|
+
* Runners still on their way: `starting`, or `crashed` waiting on a backoff
|
|
50440
|
+
* respawn. The check is FINAL only when this is empty; until then nothing is
|
|
50441
|
+
* pushed and the verdict is re-evaluated on the next runner state change.
|
|
50442
|
+
* Optional for version skew (absent = settled).
|
|
50443
|
+
*/
|
|
50444
|
+
pending: array(string()).optional(),
|
|
50445
|
+
/** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
|
|
50446
|
+
planKnown: boolean()
|
|
50447
|
+
});
|
|
49479
50448
|
var ServerPackageStatusSchema = object({
|
|
49480
50449
|
/** Root package name (`@camstack/server` on the hub). */
|
|
49481
50450
|
packageName: string(),
|
|
@@ -49538,7 +50507,14 @@ var ServerPackageStatusSchema = object({
|
|
|
49538
50507
|
* for version skew: an older provider's payload simply omits it, and an
|
|
49539
50508
|
* absent wrapper is unknown — never `native`.
|
|
49540
50509
|
*/
|
|
49541
|
-
wrapper: WrapperIdentitySchema.optional()
|
|
50510
|
+
wrapper: WrapperIdentitySchema.optional(),
|
|
50511
|
+
/**
|
|
50512
|
+
* What this node PLANNED to run against what its process service reports
|
|
50513
|
+
* (D877). Absent until the one-shot boot check has run (~60 s after boot) and
|
|
50514
|
+
* on a provider that predates it. Absent is "not checked yet", never "all
|
|
50515
|
+
* well": a consumer that needs the answer treats it as pending.
|
|
50516
|
+
*/
|
|
50517
|
+
runners: RunnerBootCheckSchema.optional()
|
|
49542
50518
|
});
|
|
49543
50519
|
var ServerUpdateCheckResultSchema = object({
|
|
49544
50520
|
packageName: string(),
|
|
@@ -49589,6 +50565,13 @@ var ServerUpdateOutcomeSchema = _enum([
|
|
|
49589
50565
|
"refused",
|
|
49590
50566
|
"failed"
|
|
49591
50567
|
]);
|
|
50568
|
+
/** One addon the pre-flight found the target version would refuse (D877). */
|
|
50569
|
+
var UpdateBlockerSchema = object({
|
|
50570
|
+
addonId: string(),
|
|
50571
|
+
reason: string(),
|
|
50572
|
+
/** What the operator does about it. */
|
|
50573
|
+
remedy: string()
|
|
50574
|
+
});
|
|
49592
50575
|
var ServerUpdateActionResultSchema = object({
|
|
49593
50576
|
accepted: boolean(),
|
|
49594
50577
|
targetVersion: string().nullable(),
|
|
@@ -49606,14 +50589,27 @@ var ServerUpdateActionResultSchema = object({
|
|
|
49606
50589
|
* The failure itself, verbatim enough to act on (the npm output for a
|
|
49607
50590
|
* staging install). Non-null only for `failed`.
|
|
49608
50591
|
*/
|
|
49609
|
-
error: string().nullable().optional()
|
|
50592
|
+
error: string().nullable().optional(),
|
|
50593
|
+
/**
|
|
50594
|
+
* The addons the target version would refuse to start on this node's live
|
|
50595
|
+
* store (D877), present when the pre-flight refused the update
|
|
50596
|
+
* (`reason: 'addon-would-refuse'`). Optional for version skew.
|
|
50597
|
+
*/
|
|
50598
|
+
blockers: array(UpdateBlockerSchema).optional()
|
|
49610
50599
|
});
|
|
49611
50600
|
method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
|
|
49612
50601
|
kind: "mutation",
|
|
49613
50602
|
auth: "admin"
|
|
49614
|
-
}), method(object({
|
|
49615
|
-
/** Explicit target version; omitted = latest from the registry. */
|
|
49616
|
-
version: string().optional()
|
|
50603
|
+
}), method(object({
|
|
50604
|
+
/** Explicit target version; omitted = latest from the registry. */
|
|
50605
|
+
version: string().optional(),
|
|
50606
|
+
/**
|
|
50607
|
+
* Apply even though the pre-flight (D877) found addons the target would
|
|
50608
|
+
* refuse to start. Off by default: those addons stay down until the
|
|
50609
|
+
* remedy is run, which is the incident this gate exists to prevent.
|
|
50610
|
+
*/
|
|
50611
|
+
acknowledgeRefusals: boolean().optional()
|
|
50612
|
+
}), ServerUpdateActionResultSchema, {
|
|
49617
50613
|
kind: "mutation",
|
|
49618
50614
|
auth: "admin",
|
|
49619
50615
|
timeoutMs: 16 * 6e4
|
|
@@ -52026,7 +53022,9 @@ var ManifestShapeSchema = object({
|
|
|
52026
53022
|
var AddonProcessSchema = object({
|
|
52027
53023
|
pid: number().optional(),
|
|
52028
53024
|
mode: string(),
|
|
52029
|
-
state: string()
|
|
53025
|
+
state: string(),
|
|
53026
|
+
/** Why the runner is `refused` (an addon's own words), when it is (D877). */
|
|
53027
|
+
reason: string().optional()
|
|
52030
53028
|
});
|
|
52031
53029
|
/**
|
|
52032
53030
|
* Per-addon health snapshot from the kernel's AddonHealthMonitor.
|
|
@@ -53029,6 +54027,12 @@ object({
|
|
|
53029
54027
|
/** Horizontal louver swing on/off. Null when the device has no
|
|
53030
54028
|
* horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
|
|
53031
54029
|
swingHorizontal: boolean().nullable(),
|
|
54030
|
+
/** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54031
|
+
minTemp: number().nullable().optional(),
|
|
54032
|
+
/** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
|
|
54033
|
+
maxTemp: number().nullable().optional(),
|
|
54034
|
+
/** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
|
|
54035
|
+
tempStep: number().positive().nullable().optional(),
|
|
53032
54036
|
/** Ms epoch when the slice was last updated (push or command). */
|
|
53033
54037
|
lastFetchedAt: number()
|
|
53034
54038
|
});
|
|
@@ -54849,7 +55853,19 @@ var TlsStatusSchema = object({
|
|
|
54849
55853
|
sans: array(string()),
|
|
54850
55854
|
caCertPem: string().nullable(),
|
|
54851
55855
|
reissueError: string().nullable(),
|
|
54852
|
-
restartRequired: boolean()
|
|
55856
|
+
restartRequired: boolean(),
|
|
55857
|
+
/** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
|
|
55858
|
+
caMissing: boolean(),
|
|
55859
|
+
/** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
|
|
55860
|
+
localCaConstrained: boolean().nullable(),
|
|
55861
|
+
/** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
|
|
55862
|
+
caReplacedAt: string().nullable(),
|
|
55863
|
+
/** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
|
|
55864
|
+
storedUpload: object({
|
|
55865
|
+
leafFingerprintSha256: string(),
|
|
55866
|
+
validTo: string(),
|
|
55867
|
+
hasCa: boolean()
|
|
55868
|
+
}).nullable()
|
|
54853
55869
|
});
|
|
54854
55870
|
method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
|
|
54855
55871
|
/**
|
|
@@ -54905,6 +55921,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
|
|
|
54905
55921
|
}), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
|
|
54906
55922
|
kind: "mutation",
|
|
54907
55923
|
auth: "admin"
|
|
55924
|
+
}), method(_void(), TlsStatusSchema, {
|
|
55925
|
+
kind: "mutation",
|
|
55926
|
+
auth: "admin"
|
|
54908
55927
|
});
|
|
54909
55928
|
object({
|
|
54910
55929
|
/** Lifecycle state of the lock. `jammed` means the motor reported
|
|
@@ -60034,7 +61053,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
60034
61053
|
kind: "mutation",
|
|
60035
61054
|
auth: "admin",
|
|
60036
61055
|
access: "delete"
|
|
60037
|
-
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(
|
|
61056
|
+
}), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
|
|
61057
|
+
kind: "mutation",
|
|
61058
|
+
auth: "admin",
|
|
61059
|
+
access: "create"
|
|
61060
|
+
}), method(object({
|
|
60038
61061
|
userId: string(),
|
|
60039
61062
|
code: string()
|
|
60040
61063
|
}), object({ valid: boolean() }), {
|
|
@@ -62235,6 +63258,12 @@ Object.freeze({
|
|
|
62235
63258
|
addonId: null,
|
|
62236
63259
|
access: "view"
|
|
62237
63260
|
},
|
|
63261
|
+
"coreBlocks.migrateRawSecrets": {
|
|
63262
|
+
capName: "core-blocks",
|
|
63263
|
+
capScope: "system",
|
|
63264
|
+
addonId: null,
|
|
63265
|
+
access: "create"
|
|
63266
|
+
},
|
|
62238
63267
|
"coreBlocks.restart": {
|
|
62239
63268
|
capName: "core-blocks",
|
|
62240
63269
|
capScope: "system",
|
|
@@ -63921,6 +64950,12 @@ Object.freeze({
|
|
|
63921
64950
|
addonId: null,
|
|
63922
64951
|
access: "create"
|
|
63923
64952
|
},
|
|
64953
|
+
"keychainAdmin.importSecret": {
|
|
64954
|
+
capName: "keychain-admin",
|
|
64955
|
+
capScope: "system",
|
|
64956
|
+
addonId: null,
|
|
64957
|
+
access: "create"
|
|
64958
|
+
},
|
|
63924
64959
|
"keychainAdmin.listAudit": {
|
|
63925
64960
|
capName: "keychain-admin",
|
|
63926
64961
|
capScope: "system",
|
|
@@ -64089,6 +65124,12 @@ Object.freeze({
|
|
|
64089
65124
|
addonId: null,
|
|
64090
65125
|
access: "view"
|
|
64091
65126
|
},
|
|
65127
|
+
"llm.migrateRawSecrets": {
|
|
65128
|
+
capName: "llm",
|
|
65129
|
+
capScope: "system",
|
|
65130
|
+
addonId: null,
|
|
65131
|
+
access: "create"
|
|
65132
|
+
},
|
|
64092
65133
|
"llm.resolveModelRef": {
|
|
64093
65134
|
capName: "llm",
|
|
64094
65135
|
capScope: "system",
|
|
@@ -64317,6 +65358,12 @@ Object.freeze({
|
|
|
64317
65358
|
addonId: null,
|
|
64318
65359
|
access: "create"
|
|
64319
65360
|
},
|
|
65361
|
+
"localNetwork.useStoredUploadedCertificate": {
|
|
65362
|
+
capName: "local-network",
|
|
65363
|
+
capScope: "system",
|
|
65364
|
+
addonId: null,
|
|
65365
|
+
access: "create"
|
|
65366
|
+
},
|
|
64320
65367
|
"lockControl.getStatus": {
|
|
64321
65368
|
capName: "lock-control",
|
|
64322
65369
|
capScope: "device",
|
|
@@ -66969,6 +68016,30 @@ Object.freeze({
|
|
|
66969
68016
|
addonId: null,
|
|
66970
68017
|
access: "create"
|
|
66971
68018
|
},
|
|
68019
|
+
"recordEntries.deleteEntry": {
|
|
68020
|
+
capName: "record-entries",
|
|
68021
|
+
capScope: "system",
|
|
68022
|
+
addonId: null,
|
|
68023
|
+
access: "delete"
|
|
68024
|
+
},
|
|
68025
|
+
"recordEntries.listEntries": {
|
|
68026
|
+
capName: "record-entries",
|
|
68027
|
+
capScope: "system",
|
|
68028
|
+
addonId: null,
|
|
68029
|
+
access: "view"
|
|
68030
|
+
},
|
|
68031
|
+
"recordEntries.listEntryKinds": {
|
|
68032
|
+
capName: "record-entries",
|
|
68033
|
+
capScope: "system",
|
|
68034
|
+
addonId: null,
|
|
68035
|
+
access: "view"
|
|
68036
|
+
},
|
|
68037
|
+
"recordEntries.putEntry": {
|
|
68038
|
+
capName: "record-entries",
|
|
68039
|
+
capScope: "system",
|
|
68040
|
+
addonId: null,
|
|
68041
|
+
access: "create"
|
|
68042
|
+
},
|
|
66972
68043
|
"recording.getAvailability": {
|
|
66973
68044
|
capName: "recording",
|
|
66974
68045
|
capScope: "device",
|
|
@@ -67269,6 +68340,102 @@ Object.freeze({
|
|
|
67269
68340
|
addonId: null,
|
|
67270
68341
|
access: "view"
|
|
67271
68342
|
},
|
|
68343
|
+
"records.aggregate": {
|
|
68344
|
+
capName: "records",
|
|
68345
|
+
capScope: "system",
|
|
68346
|
+
addonId: null,
|
|
68347
|
+
access: "view"
|
|
68348
|
+
},
|
|
68349
|
+
"records.allocateId": {
|
|
68350
|
+
capName: "records",
|
|
68351
|
+
capScope: "system",
|
|
68352
|
+
addonId: null,
|
|
68353
|
+
access: "create"
|
|
68354
|
+
},
|
|
68355
|
+
"records.count": {
|
|
68356
|
+
capName: "records",
|
|
68357
|
+
capScope: "system",
|
|
68358
|
+
addonId: null,
|
|
68359
|
+
access: "view"
|
|
68360
|
+
},
|
|
68361
|
+
"records.declareKinds": {
|
|
68362
|
+
capName: "records",
|
|
68363
|
+
capScope: "system",
|
|
68364
|
+
addonId: null,
|
|
68365
|
+
access: "create"
|
|
68366
|
+
},
|
|
68367
|
+
"records.delete": {
|
|
68368
|
+
capName: "records",
|
|
68369
|
+
capScope: "system",
|
|
68370
|
+
addonId: null,
|
|
68371
|
+
access: "delete"
|
|
68372
|
+
},
|
|
68373
|
+
"records.deleteDevice": {
|
|
68374
|
+
capName: "records",
|
|
68375
|
+
capScope: "system",
|
|
68376
|
+
addonId: null,
|
|
68377
|
+
access: "delete"
|
|
68378
|
+
},
|
|
68379
|
+
"records.deleteMany": {
|
|
68380
|
+
capName: "records",
|
|
68381
|
+
capScope: "system",
|
|
68382
|
+
addonId: null,
|
|
68383
|
+
access: "delete"
|
|
68384
|
+
},
|
|
68385
|
+
"records.deleteWhere": {
|
|
68386
|
+
capName: "records",
|
|
68387
|
+
capScope: "system",
|
|
68388
|
+
addonId: null,
|
|
68389
|
+
access: "delete"
|
|
68390
|
+
},
|
|
68391
|
+
"records.get": {
|
|
68392
|
+
capName: "records",
|
|
68393
|
+
capScope: "system",
|
|
68394
|
+
addonId: null,
|
|
68395
|
+
access: "view"
|
|
68396
|
+
},
|
|
68397
|
+
"records.getMany": {
|
|
68398
|
+
capName: "records",
|
|
68399
|
+
capScope: "system",
|
|
68400
|
+
addonId: null,
|
|
68401
|
+
access: "view"
|
|
68402
|
+
},
|
|
68403
|
+
"records.histogram": {
|
|
68404
|
+
capName: "records",
|
|
68405
|
+
capScope: "system",
|
|
68406
|
+
addonId: null,
|
|
68407
|
+
access: "view"
|
|
68408
|
+
},
|
|
68409
|
+
"records.patch": {
|
|
68410
|
+
capName: "records",
|
|
68411
|
+
capScope: "system",
|
|
68412
|
+
addonId: null,
|
|
68413
|
+
access: "create"
|
|
68414
|
+
},
|
|
68415
|
+
"records.put": {
|
|
68416
|
+
capName: "records",
|
|
68417
|
+
capScope: "system",
|
|
68418
|
+
addonId: null,
|
|
68419
|
+
access: "create"
|
|
68420
|
+
},
|
|
68421
|
+
"records.putMany": {
|
|
68422
|
+
capName: "records",
|
|
68423
|
+
capScope: "system",
|
|
68424
|
+
addonId: null,
|
|
68425
|
+
access: "create"
|
|
68426
|
+
},
|
|
68427
|
+
"records.query": {
|
|
68428
|
+
capName: "records",
|
|
68429
|
+
capScope: "system",
|
|
68430
|
+
addonId: null,
|
|
68431
|
+
access: "view"
|
|
68432
|
+
},
|
|
68433
|
+
"records.secretRefs": {
|
|
68434
|
+
capName: "records",
|
|
68435
|
+
capScope: "system",
|
|
68436
|
+
addonId: null,
|
|
68437
|
+
access: "view"
|
|
68438
|
+
},
|
|
67272
68439
|
"sceneMonitor.captureReference": {
|
|
67273
68440
|
capName: "scene-monitor",
|
|
67274
68441
|
capScope: "device",
|
|
@@ -67701,6 +68868,48 @@ Object.freeze({
|
|
|
67701
68868
|
addonId: null,
|
|
67702
68869
|
access: "create"
|
|
67703
68870
|
},
|
|
68871
|
+
"storageAdmin.adoptRecords": {
|
|
68872
|
+
capName: "storage-admin",
|
|
68873
|
+
capScope: "system",
|
|
68874
|
+
addonId: null,
|
|
68875
|
+
access: "create"
|
|
68876
|
+
},
|
|
68877
|
+
"storageAdmin.dropCollection": {
|
|
68878
|
+
capName: "storage-admin",
|
|
68879
|
+
capScope: "system",
|
|
68880
|
+
addonId: null,
|
|
68881
|
+
access: "delete"
|
|
68882
|
+
},
|
|
68883
|
+
"storageAdmin.isAdoptedLegacyTable": {
|
|
68884
|
+
capName: "storage-admin",
|
|
68885
|
+
capScope: "system",
|
|
68886
|
+
addonId: null,
|
|
68887
|
+
access: "view"
|
|
68888
|
+
},
|
|
68889
|
+
"storageAdmin.listKinds": {
|
|
68890
|
+
capName: "storage-admin",
|
|
68891
|
+
capScope: "system",
|
|
68892
|
+
addonId: null,
|
|
68893
|
+
access: "view"
|
|
68894
|
+
},
|
|
68895
|
+
"storageAdmin.listTables": {
|
|
68896
|
+
capName: "storage-admin",
|
|
68897
|
+
capScope: "system",
|
|
68898
|
+
addonId: null,
|
|
68899
|
+
access: "view"
|
|
68900
|
+
},
|
|
68901
|
+
"storageAdmin.readLegacyCollection": {
|
|
68902
|
+
capName: "storage-admin",
|
|
68903
|
+
capScope: "system",
|
|
68904
|
+
addonId: null,
|
|
68905
|
+
access: "view"
|
|
68906
|
+
},
|
|
68907
|
+
"storageAdmin.readRecords": {
|
|
68908
|
+
capName: "storage-admin",
|
|
68909
|
+
capScope: "system",
|
|
68910
|
+
addonId: null,
|
|
68911
|
+
access: "view"
|
|
68912
|
+
},
|
|
67704
68913
|
"storageEvictable.evict": {
|
|
67705
68914
|
capName: "storage-evictable",
|
|
67706
68915
|
capScope: "system",
|
|
@@ -68613,6 +69822,12 @@ Object.freeze({
|
|
|
68613
69822
|
addonId: null,
|
|
68614
69823
|
access: "view"
|
|
68615
69824
|
},
|
|
69825
|
+
"userManagement.migrateRawSecrets": {
|
|
69826
|
+
capName: "user-management",
|
|
69827
|
+
capScope: "system",
|
|
69828
|
+
addonId: null,
|
|
69829
|
+
access: "create"
|
|
69830
|
+
},
|
|
68616
69831
|
"userManagement.oauthExchangeCode": {
|
|
68617
69832
|
capName: "user-management",
|
|
68618
69833
|
capScope: "system",
|
|
@@ -71289,6 +72504,37 @@ Object.freeze({
|
|
|
71289
72504
|
form: "single",
|
|
71290
72505
|
optional: false
|
|
71291
72506
|
}],
|
|
72507
|
+
"records.count": [{
|
|
72508
|
+
name: "deviceId",
|
|
72509
|
+
form: "single",
|
|
72510
|
+
optional: true
|
|
72511
|
+
}],
|
|
72512
|
+
"records.deleteDevice": [{
|
|
72513
|
+
name: "deviceId",
|
|
72514
|
+
form: "single",
|
|
72515
|
+
optional: false
|
|
72516
|
+
}],
|
|
72517
|
+
"records.deleteWhere": [{
|
|
72518
|
+
name: "deviceId",
|
|
72519
|
+
form: "single",
|
|
72520
|
+
optional: true
|
|
72521
|
+
}],
|
|
72522
|
+
"records.histogram": [{
|
|
72523
|
+
name: "deviceId",
|
|
72524
|
+
form: "single",
|
|
72525
|
+
optional: true
|
|
72526
|
+
}],
|
|
72527
|
+
"records.putMany": [{
|
|
72528
|
+
name: "records",
|
|
72529
|
+
form: "object-array",
|
|
72530
|
+
optional: false,
|
|
72531
|
+
itemField: "deviceId"
|
|
72532
|
+
}],
|
|
72533
|
+
"records.query": [{
|
|
72534
|
+
name: "deviceId",
|
|
72535
|
+
form: "single",
|
|
72536
|
+
optional: true
|
|
72537
|
+
}],
|
|
71292
72538
|
"sceneMonitor.captureReference": [{
|
|
71293
72539
|
name: "deviceId",
|
|
71294
72540
|
form: "single",
|
|
@@ -71405,6 +72651,17 @@ Object.freeze({
|
|
|
71405
72651
|
form: "single",
|
|
71406
72652
|
optional: false
|
|
71407
72653
|
}],
|
|
72654
|
+
"storageAdmin.adoptRecords": [{
|
|
72655
|
+
name: "records",
|
|
72656
|
+
form: "object-array",
|
|
72657
|
+
optional: false,
|
|
72658
|
+
itemField: "deviceId"
|
|
72659
|
+
}],
|
|
72660
|
+
"storageAdmin.readRecords": [{
|
|
72661
|
+
name: "deviceId",
|
|
72662
|
+
form: "single",
|
|
72663
|
+
optional: true
|
|
72664
|
+
}],
|
|
71408
72665
|
"streamBroker.acquireEgressTranscode": [{
|
|
71409
72666
|
name: "deviceId",
|
|
71410
72667
|
form: "single",
|
|
@@ -76694,163 +77951,81 @@ function createNotificationOutputProvider(deps) {
|
|
|
76694
77951
|
}
|
|
76695
77952
|
};
|
|
76696
77953
|
}
|
|
76697
|
-
|
|
76698
|
-
|
|
76699
|
-
|
|
76700
|
-
|
|
76701
|
-
|
|
76702
|
-
|
|
76703
|
-
|
|
76704
|
-
|
|
76705
|
-
|
|
76706
|
-
|
|
76707
|
-
insert: async (collection, record) => {
|
|
76708
|
-
await api.settingsStore.insert.mutate({
|
|
76709
|
-
collection,
|
|
76710
|
-
record: {
|
|
76711
|
-
id: record.id,
|
|
76712
|
-
data: { ...record.data }
|
|
76713
|
-
}
|
|
76714
|
-
});
|
|
76715
|
-
},
|
|
76716
|
-
update: async (collection, id, data) => {
|
|
76717
|
-
await api.settingsStore.update.mutate({
|
|
76718
|
-
collection,
|
|
76719
|
-
id,
|
|
76720
|
-
data
|
|
76721
|
-
});
|
|
76722
|
-
},
|
|
76723
|
-
remove: async (collection, id) => {
|
|
76724
|
-
await api.settingsStore.delete.mutate({
|
|
76725
|
-
collection,
|
|
76726
|
-
key: id
|
|
76727
|
-
});
|
|
76728
|
-
},
|
|
76729
|
-
declareCollection: async (collection, columns) => {
|
|
76730
|
-
await api.settingsStore.declareCollection.mutate({
|
|
76731
|
-
collection,
|
|
76732
|
-
columns: columns.map((c) => ({ ...c }))
|
|
76733
|
-
});
|
|
76734
|
-
}
|
|
76735
|
-
};
|
|
76736
|
-
}
|
|
76737
|
-
/** In-memory port — a resilient fallback when no `api` is available. */
|
|
76738
|
-
function createMemorySettingsStorePort() {
|
|
76739
|
-
const collections = /* @__PURE__ */ new Map();
|
|
76740
|
-
const bucket = (collection) => {
|
|
76741
|
-
let map = collections.get(collection);
|
|
76742
|
-
if (!map) {
|
|
76743
|
-
map = /* @__PURE__ */ new Map();
|
|
76744
|
-
collections.set(collection, map);
|
|
76745
|
-
}
|
|
76746
|
-
return map;
|
|
76747
|
-
};
|
|
76748
|
-
return {
|
|
76749
|
-
query: async (collection) => [...bucket(collection).values()],
|
|
76750
|
-
insert: async (collection, record) => {
|
|
76751
|
-
bucket(collection).set(record.id, {
|
|
76752
|
-
id: record.id,
|
|
76753
|
-
data: { ...record.data }
|
|
76754
|
-
});
|
|
76755
|
-
},
|
|
76756
|
-
update: async (collection, id, data) => {
|
|
76757
|
-
bucket(collection).set(id, {
|
|
76758
|
-
id,
|
|
76759
|
-
data: { ...data }
|
|
76760
|
-
});
|
|
76761
|
-
},
|
|
76762
|
-
remove: async (collection, id) => {
|
|
76763
|
-
bucket(collection).delete(id);
|
|
76764
|
-
},
|
|
76765
|
-
declareCollection: async (collection) => {
|
|
76766
|
-
bucket(collection);
|
|
76767
|
-
}
|
|
76768
|
-
};
|
|
76769
|
-
}
|
|
77954
|
+
var notifiersRecordKinds = defineRecordKinds({ "notification-targets": {
|
|
77955
|
+
schema: TargetSchema.omit({ id: true }),
|
|
77956
|
+
class: "config",
|
|
77957
|
+
writeTrigger: "an operator creates, updates, enables/disables or deletes a notification target",
|
|
77958
|
+
device: "none",
|
|
77959
|
+
at: "none",
|
|
77960
|
+
retention: { none: "a row goes only on an explicit operator delete; bounded by the number of notification targets the operator configures" },
|
|
77961
|
+
adoptsFrom: "notifiers:notification-targets",
|
|
77962
|
+
entry: { title: "Notification targets" }
|
|
77963
|
+
} });
|
|
76770
77964
|
//#endregion
|
|
76771
77965
|
//#region src/target-store.ts
|
|
76772
77966
|
/**
|
|
76773
|
-
* Persistence for notification targets over the `
|
|
77967
|
+
* Persistence for notification targets over the `notification-targets` record
|
|
77968
|
+
* kind (records plan phase 2, step 17).
|
|
76774
77969
|
*
|
|
76775
|
-
* The store is addressed through a
|
|
76776
|
-
*
|
|
76777
|
-
*
|
|
76778
|
-
* `
|
|
76779
|
-
* calling addon's id automatically — the store-isolation fix).
|
|
77970
|
+
* The store is addressed through a `RecordKindHandle<TargetBody>` — the
|
|
77971
|
+
* records facade handles all transport, boot-guard, and index concerns. No
|
|
77972
|
+
* `init()` or `declareCollection` call: kinds are declared at addon boot via
|
|
77973
|
+
* `ctx.records.declare(notifiersRecordKinds)` before this store is constructed.
|
|
76780
77974
|
*
|
|
76781
|
-
* A row is `{
|
|
76782
|
-
* inside `config
|
|
76783
|
-
*
|
|
77975
|
+
* A row body is `{ name, kind, addonId, enabled, config }` (the record id IS
|
|
77976
|
+
* the target id). Secrets inside `config` are handled at the provider level by
|
|
77977
|
+
* `secrets.ts` (redact on read, merge on write); the records layer stores
|
|
77978
|
+
* the blob verbatim.
|
|
76784
77979
|
*/
|
|
76785
|
-
/**
|
|
77980
|
+
/** Legacy collection name — kept for the adoption mapper and docs. */
|
|
76786
77981
|
var TARGETS_COLLECTION = "notifiers:notification-targets";
|
|
76787
|
-
|
|
76788
|
-
|
|
76789
|
-
|
|
76790
|
-
|
|
76791
|
-
|
|
76792
|
-
notNull: true
|
|
76793
|
-
}];
|
|
76794
|
-
function rowToTarget(row) {
|
|
76795
|
-
const candidate = {
|
|
76796
|
-
id: row.id,
|
|
76797
|
-
...row.data
|
|
76798
|
-
};
|
|
76799
|
-
const parsed = TargetSchema.safeParse(candidate);
|
|
77982
|
+
function rowToTarget(id, data) {
|
|
77983
|
+
const parsed = TargetSchema.safeParse({
|
|
77984
|
+
id,
|
|
77985
|
+
...data
|
|
77986
|
+
});
|
|
76800
77987
|
return parsed.success ? parsed.data : null;
|
|
76801
77988
|
}
|
|
76802
|
-
|
|
76803
|
-
|
|
76804
|
-
|
|
76805
|
-
kind
|
|
76806
|
-
addonId: target.addonId,
|
|
76807
|
-
enabled: target.enabled,
|
|
76808
|
-
config: target.config
|
|
76809
|
-
};
|
|
76810
|
-
}
|
|
76811
|
-
var TargetStore = class {
|
|
76812
|
-
store;
|
|
76813
|
-
collection;
|
|
76814
|
-
constructor(store, collection = TARGETS_COLLECTION) {
|
|
76815
|
-
this.store = store;
|
|
76816
|
-
this.collection = collection;
|
|
77989
|
+
var TargetStore = class TargetStore {
|
|
77990
|
+
kind;
|
|
77991
|
+
constructor(kind) {
|
|
77992
|
+
this.kind = kind;
|
|
76817
77993
|
}
|
|
76818
|
-
/**
|
|
76819
|
-
|
|
76820
|
-
|
|
76821
|
-
async init() {
|
|
76822
|
-
await this.store.declareCollection(this.collection, KV_BLOB_COLUMNS);
|
|
77994
|
+
/** Factory: build from a declared `RecordsAccess` (after `ctx.records.declare`). */
|
|
77995
|
+
static of(records) {
|
|
77996
|
+
return new TargetStore(records.kind(notifiersRecordKinds["notification-targets"]));
|
|
76823
77997
|
}
|
|
76824
77998
|
async list() {
|
|
76825
|
-
const
|
|
76826
|
-
const
|
|
76827
|
-
for (const
|
|
76828
|
-
const target = rowToTarget(
|
|
76829
|
-
if (target)
|
|
77999
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
78000
|
+
const out = [];
|
|
78001
|
+
for (const record of page.records) {
|
|
78002
|
+
const target = rowToTarget(record.id, record.data);
|
|
78003
|
+
if (target !== null) out.push(target);
|
|
76830
78004
|
}
|
|
76831
|
-
return
|
|
78005
|
+
return out;
|
|
76832
78006
|
}
|
|
76833
78007
|
async getById(id) {
|
|
76834
|
-
const row =
|
|
76835
|
-
|
|
78008
|
+
const row = await this.kind.get(id);
|
|
78009
|
+
if (row === null) return null;
|
|
78010
|
+
return rowToTarget(row.id, row.data);
|
|
76836
78011
|
}
|
|
76837
|
-
/** Upsert by id — inserts a new row or
|
|
78012
|
+
/** Upsert by id — inserts a new row or replaces the existing one. */
|
|
76838
78013
|
async upsert(target) {
|
|
76839
|
-
const
|
|
76840
|
-
const
|
|
76841
|
-
if (
|
|
76842
|
-
|
|
76843
|
-
id
|
|
76844
|
-
data
|
|
78014
|
+
const { id, ...rest } = target;
|
|
78015
|
+
const parsed = notifiersRecordKinds["notification-targets"].schema.safeParse(rest);
|
|
78016
|
+
if (!parsed.success) throw new Error(`invalid target '${id}': ${parsed.error.message}`);
|
|
78017
|
+
await this.kind.put({
|
|
78018
|
+
id,
|
|
78019
|
+
data: parsed.data
|
|
76845
78020
|
});
|
|
76846
78021
|
}
|
|
76847
78022
|
async delete(id) {
|
|
76848
|
-
await this.
|
|
78023
|
+
await this.kind.delete(id);
|
|
76849
78024
|
}
|
|
76850
78025
|
/** Flip `enabled` on an existing target. Returns the updated target, or null if absent. */
|
|
76851
78026
|
async setEnabled(id, enabled) {
|
|
76852
78027
|
const target = await this.getById(id);
|
|
76853
|
-
if (
|
|
78028
|
+
if (target === null) return null;
|
|
76854
78029
|
const next = {
|
|
76855
78030
|
...target,
|
|
76856
78031
|
enabled
|
|
@@ -76878,10 +78053,10 @@ var NotifiersAddon = class extends BaseAddon {
|
|
|
76878
78053
|
}
|
|
76879
78054
|
async onInitialize() {
|
|
76880
78055
|
const api = this.ctx.api;
|
|
76881
|
-
const
|
|
76882
|
-
if (
|
|
76883
|
-
|
|
76884
|
-
|
|
78056
|
+
const records = this.ctx.records;
|
|
78057
|
+
if (records === void 0) throw new Error("notifiers (hub) needs ctx.records — check execution.placement");
|
|
78058
|
+
await records.declare(notifiersRecordKinds);
|
|
78059
|
+
const store = TargetStore.of(records);
|
|
76885
78060
|
const listProviders = async () => {
|
|
76886
78061
|
if (api === void 0) return [];
|
|
76887
78062
|
const [providers, addons] = await Promise.all([api.addons.listCapabilityProviders.query({ capName: "smtp-provider" }), api.addons.list.query()]);
|
|
@@ -76970,8 +78145,6 @@ exports.default = NotifiersAddon;
|
|
|
76970
78145
|
exports.REDACTED_MARKER = REDACTED_MARKER;
|
|
76971
78146
|
exports.TARGETS_COLLECTION = TARGETS_COLLECTION;
|
|
76972
78147
|
exports.TargetStore = TargetStore;
|
|
76973
|
-
exports.createApiSettingsStorePort = createApiSettingsStorePort;
|
|
76974
|
-
exports.createMemorySettingsStorePort = createMemorySettingsStorePort;
|
|
76975
78148
|
exports.createNotificationOutputProvider = createNotificationOutputProvider;
|
|
76976
78149
|
exports.fetchAttachmentBytes = fetchAttachmentBytes;
|
|
76977
78150
|
exports.fetchWithTimeout = fetchWithTimeout;
|