@camstack/addon-waste-collections 0.1.7 → 0.1.8
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/waste-collections.addon.js +1150 -27
- package/dist/waste-collections.addon.mjs +1150 -27
- package/package.json +1 -1
|
@@ -4130,6 +4130,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
4130
4130
|
var booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
4131
4131
|
json.type = "boolean";
|
|
4132
4132
|
};
|
|
4133
|
+
var bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
4134
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
4135
|
+
};
|
|
4136
|
+
var symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
4137
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
4138
|
+
};
|
|
4133
4139
|
var nullProcessor = (_schema, ctx, json, _params) => {
|
|
4134
4140
|
if (ctx.target === "openapi-3.0") {
|
|
4135
4141
|
json.type = "string";
|
|
@@ -4137,12 +4143,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
|
|
|
4137
4143
|
json.enum = [null];
|
|
4138
4144
|
} else json.type = "null";
|
|
4139
4145
|
};
|
|
4146
|
+
var undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
4147
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
4148
|
+
};
|
|
4140
4149
|
var voidProcessor = (_schema, ctx, _json, _params) => {
|
|
4141
4150
|
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
4142
4151
|
};
|
|
4143
4152
|
var neverProcessor = (_schema, _ctx, json, _params) => {
|
|
4144
4153
|
json.not = {};
|
|
4145
4154
|
};
|
|
4155
|
+
var anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4156
|
+
var unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
4146
4157
|
var dateProcessor = (_schema, ctx, _json, _params) => {
|
|
4147
4158
|
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
4148
4159
|
};
|
|
@@ -4174,12 +4185,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
4174
4185
|
json.enum = vals;
|
|
4175
4186
|
}
|
|
4176
4187
|
};
|
|
4188
|
+
var nanProcessor = (_schema, ctx, _json, _params) => {
|
|
4189
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
4190
|
+
};
|
|
4191
|
+
var templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
4192
|
+
const _json = json;
|
|
4193
|
+
const pattern = schema._zod.pattern;
|
|
4194
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
4195
|
+
_json.type = "string";
|
|
4196
|
+
_json.pattern = pattern.source;
|
|
4197
|
+
};
|
|
4198
|
+
var fileProcessor = (schema, _ctx, json, _params) => {
|
|
4199
|
+
const _json = json;
|
|
4200
|
+
const file = {
|
|
4201
|
+
type: "string",
|
|
4202
|
+
format: "binary",
|
|
4203
|
+
contentEncoding: "binary"
|
|
4204
|
+
};
|
|
4205
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
4206
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
4207
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
4208
|
+
if (mime) if (mime.length === 1) {
|
|
4209
|
+
file.contentMediaType = mime[0];
|
|
4210
|
+
Object.assign(_json, file);
|
|
4211
|
+
} else {
|
|
4212
|
+
Object.assign(_json, file);
|
|
4213
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
4214
|
+
}
|
|
4215
|
+
else Object.assign(_json, file);
|
|
4216
|
+
};
|
|
4217
|
+
var successProcessor = (_schema, _ctx, json, _params) => {
|
|
4218
|
+
json.type = "boolean";
|
|
4219
|
+
};
|
|
4177
4220
|
var customProcessor = (_schema, ctx, _json, _params) => {
|
|
4178
4221
|
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
4179
4222
|
};
|
|
4223
|
+
var functionProcessor = (_schema, ctx, _json, _params) => {
|
|
4224
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
4225
|
+
};
|
|
4180
4226
|
var transformProcessor = (_schema, ctx, _json, _params) => {
|
|
4181
4227
|
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
4182
4228
|
};
|
|
4229
|
+
var mapProcessor = (_schema, ctx, _json, _params) => {
|
|
4230
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
4231
|
+
};
|
|
4232
|
+
var setProcessor = (_schema, ctx, _json, _params) => {
|
|
4233
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
4234
|
+
};
|
|
4183
4235
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
4184
4236
|
const json = _json;
|
|
4185
4237
|
const def = schema._zod.def;
|
|
@@ -4384,6 +4436,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
|
|
|
4384
4436
|
seen.ref = def.innerType;
|
|
4385
4437
|
json.readOnly = true;
|
|
4386
4438
|
};
|
|
4439
|
+
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
4440
|
+
const def = schema._zod.def;
|
|
4441
|
+
process(def.innerType, ctx, params);
|
|
4442
|
+
const seen = ctx.seen.get(schema);
|
|
4443
|
+
seen.ref = def.innerType;
|
|
4444
|
+
};
|
|
4387
4445
|
var optionalProcessor = (schema, ctx, _json, params) => {
|
|
4388
4446
|
const def = schema._zod.def;
|
|
4389
4447
|
process(def.innerType, ctx, params);
|
|
@@ -4396,6 +4454,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
|
|
|
4396
4454
|
const seen = ctx.seen.get(schema);
|
|
4397
4455
|
seen.ref = innerType;
|
|
4398
4456
|
};
|
|
4457
|
+
var allProcessors = {
|
|
4458
|
+
string: stringProcessor,
|
|
4459
|
+
number: numberProcessor,
|
|
4460
|
+
boolean: booleanProcessor,
|
|
4461
|
+
bigint: bigintProcessor,
|
|
4462
|
+
symbol: symbolProcessor,
|
|
4463
|
+
null: nullProcessor,
|
|
4464
|
+
undefined: undefinedProcessor,
|
|
4465
|
+
void: voidProcessor,
|
|
4466
|
+
never: neverProcessor,
|
|
4467
|
+
any: anyProcessor,
|
|
4468
|
+
unknown: unknownProcessor,
|
|
4469
|
+
date: dateProcessor,
|
|
4470
|
+
enum: enumProcessor,
|
|
4471
|
+
literal: literalProcessor,
|
|
4472
|
+
nan: nanProcessor,
|
|
4473
|
+
template_literal: templateLiteralProcessor,
|
|
4474
|
+
file: fileProcessor,
|
|
4475
|
+
success: successProcessor,
|
|
4476
|
+
custom: customProcessor,
|
|
4477
|
+
function: functionProcessor,
|
|
4478
|
+
transform: transformProcessor,
|
|
4479
|
+
map: mapProcessor,
|
|
4480
|
+
set: setProcessor,
|
|
4481
|
+
array: arrayProcessor,
|
|
4482
|
+
object: objectProcessor,
|
|
4483
|
+
union: unionProcessor,
|
|
4484
|
+
intersection: intersectionProcessor,
|
|
4485
|
+
tuple: tupleProcessor,
|
|
4486
|
+
record: recordProcessor,
|
|
4487
|
+
nullable: nullableProcessor,
|
|
4488
|
+
nonoptional: nonoptionalProcessor,
|
|
4489
|
+
default: defaultProcessor,
|
|
4490
|
+
prefault: prefaultProcessor,
|
|
4491
|
+
catch: catchProcessor,
|
|
4492
|
+
pipe: pipeProcessor,
|
|
4493
|
+
readonly: readonlyProcessor,
|
|
4494
|
+
promise: promiseProcessor,
|
|
4495
|
+
optional: optionalProcessor,
|
|
4496
|
+
lazy: lazyProcessor
|
|
4497
|
+
};
|
|
4498
|
+
function toJSONSchema(input, params) {
|
|
4499
|
+
if ("_idmap" in input) {
|
|
4500
|
+
const registry = input;
|
|
4501
|
+
const ctx = initializeContext({
|
|
4502
|
+
...params,
|
|
4503
|
+
processors: allProcessors
|
|
4504
|
+
});
|
|
4505
|
+
const defs = {};
|
|
4506
|
+
for (const entry of registry._idmap.entries()) {
|
|
4507
|
+
const [_, schema] = entry;
|
|
4508
|
+
process(schema, ctx);
|
|
4509
|
+
}
|
|
4510
|
+
const schemas = {};
|
|
4511
|
+
ctx.external = {
|
|
4512
|
+
registry,
|
|
4513
|
+
uri: params?.uri,
|
|
4514
|
+
defs
|
|
4515
|
+
};
|
|
4516
|
+
for (const entry of registry._idmap.entries()) {
|
|
4517
|
+
const [key, schema] = entry;
|
|
4518
|
+
extractDefs(ctx, schema);
|
|
4519
|
+
schemas[key] = finalize(ctx, schema);
|
|
4520
|
+
}
|
|
4521
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
4522
|
+
return { schemas };
|
|
4523
|
+
}
|
|
4524
|
+
const ctx = initializeContext({
|
|
4525
|
+
...params,
|
|
4526
|
+
processors: allProcessors
|
|
4527
|
+
});
|
|
4528
|
+
process(input, ctx);
|
|
4529
|
+
extractDefs(ctx, input);
|
|
4530
|
+
return finalize(ctx, input);
|
|
4531
|
+
}
|
|
4399
4532
|
//#endregion
|
|
4400
4533
|
//#region ../../node_modules/zod/v4/classic/iso.js
|
|
4401
4534
|
var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
@@ -5412,7 +5545,7 @@ var ZodIssueCode = {
|
|
|
5412
5545
|
var ZodFirstPartyTypeKind;
|
|
5413
5546
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5414
5547
|
//#endregion
|
|
5415
|
-
//#region ../types/dist/sleep-
|
|
5548
|
+
//#region ../types/dist/sleep-bZIhUvjd.mjs
|
|
5416
5549
|
/**
|
|
5417
5550
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5418
5551
|
* window to float samples (D455).
|
|
@@ -5539,7 +5672,7 @@ function isKeychainStoredField(field) {
|
|
|
5539
5672
|
var SECRET_CLEAR = { $secretClear: true };
|
|
5540
5673
|
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5541
5674
|
var LEGACY_DEVICE_REDACTION = "***";
|
|
5542
|
-
function isRecord$
|
|
5675
|
+
function isRecord$5(value) {
|
|
5543
5676
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5544
5677
|
}
|
|
5545
5678
|
function makeSecretMarker(ref) {
|
|
@@ -5550,12 +5683,12 @@ function makeSecretMarker(ref) {
|
|
|
5550
5683
|
}
|
|
5551
5684
|
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5552
5685
|
function isSecretMarker(value) {
|
|
5553
|
-
if (!isRecord$
|
|
5686
|
+
if (!isRecord$5(value)) return false;
|
|
5554
5687
|
const ref = value["$secret"];
|
|
5555
5688
|
return typeof ref === "string" && ref.length > 0;
|
|
5556
5689
|
}
|
|
5557
5690
|
function isSecretClear(value) {
|
|
5558
|
-
return isRecord$
|
|
5691
|
+
return isRecord$5(value) && value["$secretClear"] === true;
|
|
5559
5692
|
}
|
|
5560
5693
|
/**
|
|
5561
5694
|
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
@@ -6165,7 +6298,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6165
6298
|
}
|
|
6166
6299
|
};
|
|
6167
6300
|
var KEEP = { kind: "keep" };
|
|
6168
|
-
function isRecord$
|
|
6301
|
+
function isRecord$4(value) {
|
|
6169
6302
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6170
6303
|
}
|
|
6171
6304
|
function defaultMintId() {
|
|
@@ -6178,7 +6311,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6178
6311
|
return out;
|
|
6179
6312
|
}
|
|
6180
6313
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6181
|
-
else if (isRecord$
|
|
6314
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6182
6315
|
return out;
|
|
6183
6316
|
}
|
|
6184
6317
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -6233,7 +6366,7 @@ function rowId(row, idKey) {
|
|
|
6233
6366
|
return null;
|
|
6234
6367
|
}
|
|
6235
6368
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6236
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
6369
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
6237
6370
|
if (!Array.isArray(incoming)) {
|
|
6238
6371
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6239
6372
|
return {
|
|
@@ -6249,7 +6382,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
6249
6382
|
const kept = /* @__PURE__ */ new Set();
|
|
6250
6383
|
const rows = [];
|
|
6251
6384
|
for (const row of incoming) {
|
|
6252
|
-
if (!isRecord$
|
|
6385
|
+
if (!isRecord$4(row)) {
|
|
6253
6386
|
rows.push(row);
|
|
6254
6387
|
continue;
|
|
6255
6388
|
}
|
|
@@ -6274,7 +6407,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6274
6407
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6275
6408
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6276
6409
|
case "object": {
|
|
6277
|
-
if (!isRecord$
|
|
6410
|
+
if (!isRecord$4(incoming)) {
|
|
6278
6411
|
if (incoming === void 0) return KEEP;
|
|
6279
6412
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6280
6413
|
return {
|
|
@@ -6282,7 +6415,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
6282
6415
|
value: incoming
|
|
6283
6416
|
};
|
|
6284
6417
|
}
|
|
6285
|
-
const storedObj = isRecord$
|
|
6418
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
6286
6419
|
return {
|
|
6287
6420
|
kind: "value",
|
|
6288
6421
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -6405,7 +6538,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
6405
6538
|
value: items
|
|
6406
6539
|
};
|
|
6407
6540
|
}
|
|
6408
|
-
if (isRecord$
|
|
6541
|
+
if (isRecord$4(v)) {
|
|
6409
6542
|
const out = {};
|
|
6410
6543
|
for (const [k, child] of Object.entries(v)) {
|
|
6411
6544
|
const s = substitute(child);
|
|
@@ -6437,7 +6570,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
6437
6570
|
this.name = "SecretOverwriteRefusedError";
|
|
6438
6571
|
}
|
|
6439
6572
|
};
|
|
6440
|
-
function isRecord(value) {
|
|
6573
|
+
function isRecord$3(value) {
|
|
6441
6574
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6442
6575
|
}
|
|
6443
6576
|
function resolvedValue(pass, marker) {
|
|
@@ -6466,7 +6599,7 @@ function inArray(pass, incoming, stored) {
|
|
|
6466
6599
|
return incoming.map((item, index) => {
|
|
6467
6600
|
const twin = stored[index];
|
|
6468
6601
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
6469
|
-
if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
|
|
6602
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
6470
6603
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
6471
6604
|
return item;
|
|
6472
6605
|
});
|
|
@@ -6477,7 +6610,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6477
6610
|
const twin = stored[key];
|
|
6478
6611
|
if (isSecretMarker(twin)) {
|
|
6479
6612
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
6480
|
-
} else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6613
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6481
6614
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
6482
6615
|
}
|
|
6483
6616
|
return out;
|
|
@@ -6485,7 +6618,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
6485
6618
|
async function walk(pass, incoming, stored) {
|
|
6486
6619
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
6487
6620
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
6488
|
-
if (!isRecord(incoming) || !isRecord(stored)) return incoming;
|
|
6621
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
6489
6622
|
const out = { ...incoming };
|
|
6490
6623
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
6491
6624
|
return out;
|
|
@@ -6516,7 +6649,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
6516
6649
|
function isJsonEqual(a, b) {
|
|
6517
6650
|
if (Object.is(a, b)) return true;
|
|
6518
6651
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
6519
|
-
if (isRecord(a) && isRecord(b)) {
|
|
6652
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
6520
6653
|
const keys = Object.keys(a);
|
|
6521
6654
|
if (keys.length !== Object.keys(b).length) return false;
|
|
6522
6655
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -6540,7 +6673,7 @@ function markerKeysOf(blob, owner) {
|
|
|
6540
6673
|
}
|
|
6541
6674
|
function nodeFromStored(value, owner) {
|
|
6542
6675
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
6543
|
-
if (!isRecord(value)) return null;
|
|
6676
|
+
if (!isRecord$3(value)) return null;
|
|
6544
6677
|
const children = /* @__PURE__ */ new Map();
|
|
6545
6678
|
for (const [key, child] of Object.entries(value)) {
|
|
6546
6679
|
const node = nodeFromStored(child, owner);
|
|
@@ -7328,7 +7461,7 @@ var BaseAddon = class {
|
|
|
7328
7461
|
if (!ctx) return;
|
|
7329
7462
|
const addonId = ctx.id;
|
|
7330
7463
|
setImmediate(() => {
|
|
7331
|
-
ctx.api.addons
|
|
7464
|
+
ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
|
|
7332
7465
|
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
7333
7466
|
}).catch((err) => {
|
|
7334
7467
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
@@ -7822,6 +7955,355 @@ var PeerBytesTicketSchema = object({
|
|
|
7822
7955
|
*/
|
|
7823
7956
|
declaredBytes: number().int().nonnegative().nullable()
|
|
7824
7957
|
});
|
|
7958
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7959
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7960
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7961
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7962
|
+
var RECORD_CLASSES = [
|
|
7963
|
+
"config",
|
|
7964
|
+
"ledger",
|
|
7965
|
+
"audit",
|
|
7966
|
+
"mirror",
|
|
7967
|
+
"ephemeral"
|
|
7968
|
+
];
|
|
7969
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
7970
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
7971
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
7972
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
7973
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
7974
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7975
|
+
var PREFIX = "records/";
|
|
7976
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
7977
|
+
var RecordsError = class extends Error {
|
|
7978
|
+
code;
|
|
7979
|
+
detail;
|
|
7980
|
+
constructor(code, detail) {
|
|
7981
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
7982
|
+
this.name = "RecordsError";
|
|
7983
|
+
this.code = code;
|
|
7984
|
+
this.detail = detail;
|
|
7985
|
+
}
|
|
7986
|
+
};
|
|
7987
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
7988
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
7989
|
+
constructor(detail) {
|
|
7990
|
+
super("secret-unavailable", detail);
|
|
7991
|
+
this.name = "RecordSecretUnavailableError";
|
|
7992
|
+
}
|
|
7993
|
+
};
|
|
7994
|
+
var InvalidRecordError = class extends RecordsError {
|
|
7995
|
+
constructor(detail) {
|
|
7996
|
+
super("invalid-record", detail);
|
|
7997
|
+
this.name = "InvalidRecordError";
|
|
7998
|
+
}
|
|
7999
|
+
};
|
|
8000
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8001
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
8002
|
+
constructor(detail) {
|
|
8003
|
+
super("declaration-refused", detail);
|
|
8004
|
+
this.name = "DeclarationRefusedError";
|
|
8005
|
+
}
|
|
8006
|
+
};
|
|
8007
|
+
function defOf(schema) {
|
|
8008
|
+
const zodBag = Reflect.get(schema, "_zod");
|
|
8009
|
+
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
8010
|
+
const def = Reflect.get(zodBag, "def");
|
|
8011
|
+
if (typeof def !== "object" || def === null) return {};
|
|
8012
|
+
return def;
|
|
8013
|
+
}
|
|
8014
|
+
function declaredHere(schema) {
|
|
8015
|
+
return globalRegistry.get(schema)?.secret === true;
|
|
8016
|
+
}
|
|
8017
|
+
/** Wrapper kinds whose `innerType` is the field itself. */
|
|
8018
|
+
var WRAPPERS = new Set([
|
|
8019
|
+
"optional",
|
|
8020
|
+
"nullable",
|
|
8021
|
+
"default",
|
|
8022
|
+
"prefault",
|
|
8023
|
+
"catch",
|
|
8024
|
+
"readonly",
|
|
8025
|
+
"nonoptional"
|
|
8026
|
+
]);
|
|
8027
|
+
/**
|
|
8028
|
+
* The schema layers that make up ONE field: the schema itself and every
|
|
8029
|
+
* wrapper below it (optional / default / nullable / readonly / catch), plus
|
|
8030
|
+
* both sides of a pipe (`z.preprocess` puts the real schema on `out`,
|
|
8031
|
+
* `.transform` on `in`).
|
|
8032
|
+
*/
|
|
8033
|
+
function layersOf(schema) {
|
|
8034
|
+
const out = [];
|
|
8035
|
+
const queue = [schema];
|
|
8036
|
+
while (queue.length > 0) {
|
|
8037
|
+
const s = queue.shift();
|
|
8038
|
+
if (!s || out.includes(s)) continue;
|
|
8039
|
+
out.push(s);
|
|
8040
|
+
const def = defOf(s);
|
|
8041
|
+
if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
|
|
8042
|
+
if (def.type === "pipe") {
|
|
8043
|
+
if (def.in) queue.push(def.in);
|
|
8044
|
+
if (def.out) queue.push(def.out);
|
|
8045
|
+
}
|
|
8046
|
+
}
|
|
8047
|
+
return out;
|
|
8048
|
+
}
|
|
8049
|
+
/** True when any layer of this field declares `.meta({ secret: true })`. */
|
|
8050
|
+
function isZodSecret(schema) {
|
|
8051
|
+
return layersOf(schema).some(declaredHere);
|
|
8052
|
+
}
|
|
8053
|
+
/**
|
|
8054
|
+
* Every declared secret path in a config schema: dotted keys, `[]` for "each
|
|
8055
|
+
* element of this array" (`connection.password`, `rows[].token`). A declared
|
|
8056
|
+
* object or array is reported as one path and not descended into — everything
|
|
8057
|
+
* under it is secret.
|
|
8058
|
+
*/
|
|
8059
|
+
function collectZodSecretPaths(schema, prefix = "") {
|
|
8060
|
+
if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
|
|
8061
|
+
const paths = [];
|
|
8062
|
+
for (const layer of layersOf(schema)) {
|
|
8063
|
+
const def = defOf(layer);
|
|
8064
|
+
if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
|
|
8065
|
+
else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
|
|
8066
|
+
else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
|
|
8067
|
+
else if (def.type === "intersection") {
|
|
8068
|
+
if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
|
|
8069
|
+
if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
return [...new Set(paths)];
|
|
8073
|
+
}
|
|
8074
|
+
/**
|
|
8075
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8076
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8077
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
8078
|
+
*
|
|
8079
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8080
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8081
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8082
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
8083
|
+
*
|
|
8084
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8085
|
+
*/
|
|
8086
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8087
|
+
function parseSecretPath(path) {
|
|
8088
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8089
|
+
return path.split(".").map((raw) => {
|
|
8090
|
+
const each = raw.endsWith("[]");
|
|
8091
|
+
const key = each ? raw.slice(0, -2) : raw;
|
|
8092
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8093
|
+
return {
|
|
8094
|
+
key,
|
|
8095
|
+
each
|
|
8096
|
+
};
|
|
8097
|
+
});
|
|
8098
|
+
}
|
|
8099
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8100
|
+
function secretArrayPrefixes(path) {
|
|
8101
|
+
const segments = parseSecretPath(path);
|
|
8102
|
+
const prefixes = [];
|
|
8103
|
+
const walked = [];
|
|
8104
|
+
for (const segment of segments) {
|
|
8105
|
+
walked.push(segment.key);
|
|
8106
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
8107
|
+
}
|
|
8108
|
+
return prefixes;
|
|
8109
|
+
}
|
|
8110
|
+
/**
|
|
8111
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
8112
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8113
|
+
* JSON the engine stores.
|
|
8114
|
+
*
|
|
8115
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
8116
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
8117
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
8118
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
8119
|
+
* never a field name (D879).
|
|
8120
|
+
*/
|
|
8121
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
8122
|
+
var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
8123
|
+
var RecordIndexSchema = object({
|
|
8124
|
+
name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
8125
|
+
fields: array(RecordFieldPathSchema).min(1).max(4),
|
|
8126
|
+
unique: boolean().optional()
|
|
8127
|
+
}).strict();
|
|
8128
|
+
var RecordRetentionSchema = union([
|
|
8129
|
+
object({
|
|
8130
|
+
ttlMs: number().int().positive(),
|
|
8131
|
+
from: _enum(["at", "write"])
|
|
8132
|
+
}).strict(),
|
|
8133
|
+
object({
|
|
8134
|
+
maxRows: number().int().positive().optional(),
|
|
8135
|
+
maxRowsPerDevice: number().int().positive().optional()
|
|
8136
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
8137
|
+
object({
|
|
8138
|
+
owner: string().min(1),
|
|
8139
|
+
reason: string().min(1)
|
|
8140
|
+
}).strict(),
|
|
8141
|
+
object({ none: string().min(1) }).strict()
|
|
8142
|
+
]);
|
|
8143
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
8144
|
+
var EntryDescriptorSchema = object({
|
|
8145
|
+
title: string().min(1),
|
|
8146
|
+
/** The record body field shown as the entry's name. */
|
|
8147
|
+
nameField: string().min(1),
|
|
8148
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
8149
|
+
fields: record(string(), unknown())
|
|
8150
|
+
}).strict();
|
|
8151
|
+
/** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
|
|
8152
|
+
var RecordKindDeclarationSchema = object({
|
|
8153
|
+
database: _enum(RECORD_DATABASES).default("settings"),
|
|
8154
|
+
class: _enum(RECORD_CLASSES),
|
|
8155
|
+
writeTrigger: string().min(1),
|
|
8156
|
+
device: _enum([
|
|
8157
|
+
"required",
|
|
8158
|
+
"optional",
|
|
8159
|
+
"none"
|
|
8160
|
+
]).default("none"),
|
|
8161
|
+
at: _enum(["required", "none"]).default("none"),
|
|
8162
|
+
indexes: array(RecordIndexSchema).max(8).default([]),
|
|
8163
|
+
retention: RecordRetentionSchema,
|
|
8164
|
+
deviceRemoval: _enum(["delete", "none"]).default("none"),
|
|
8165
|
+
maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
8166
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
8167
|
+
secretPaths: array(string().min(1)).default([]),
|
|
8168
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
8169
|
+
secretArrayKeys: record(string(), string()).default({}),
|
|
8170
|
+
/** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
|
|
8171
|
+
adoptsFrom: string().min(1).optional(),
|
|
8172
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
8173
|
+
transactFamily: string().min(1).optional(),
|
|
8174
|
+
entry: EntryDescriptorSchema.optional()
|
|
8175
|
+
}).strict();
|
|
8176
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
8177
|
+
var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
8178
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
8179
|
+
function assertValidDeclaration(name, decl) {
|
|
8180
|
+
const refuse = (why) => {
|
|
8181
|
+
throw new DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
8182
|
+
};
|
|
8183
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
8184
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8185
|
+
for (const index of decl.indexes) {
|
|
8186
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
8187
|
+
seen.add(index.name);
|
|
8188
|
+
}
|
|
8189
|
+
const { retention } = decl;
|
|
8190
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
8191
|
+
if ("ttlMs" in retention) {
|
|
8192
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
8193
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
8194
|
+
}
|
|
8195
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
8196
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
8197
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
8198
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
8199
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
8200
|
+
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)`);
|
|
8201
|
+
}
|
|
8202
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
8203
|
+
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`);
|
|
8204
|
+
}
|
|
8205
|
+
function bodyFieldsOf(schema) {
|
|
8206
|
+
return { ...toJSONSchema(schema, {
|
|
8207
|
+
unrepresentable: "any",
|
|
8208
|
+
io: "input"
|
|
8209
|
+
}) };
|
|
8210
|
+
}
|
|
8211
|
+
function isRecordLike(value) {
|
|
8212
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8213
|
+
}
|
|
8214
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
8215
|
+
function hasNameField(json, field) {
|
|
8216
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
8217
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
8218
|
+
const properties = json["properties"];
|
|
8219
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
8220
|
+
}
|
|
8221
|
+
/**
|
|
8222
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
8223
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
8224
|
+
* types its handle from.
|
|
8225
|
+
*/
|
|
8226
|
+
function defineRecordKinds(specs) {
|
|
8227
|
+
const out = {};
|
|
8228
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
8229
|
+
const secretPaths = collectZodSecretPaths(spec.schema);
|
|
8230
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
8231
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
8232
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
8233
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
8234
|
+
database: spec.database,
|
|
8235
|
+
class: spec.class,
|
|
8236
|
+
writeTrigger: spec.writeTrigger,
|
|
8237
|
+
device: spec.device,
|
|
8238
|
+
at: spec.at,
|
|
8239
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
8240
|
+
retention: spec.retention,
|
|
8241
|
+
deviceRemoval: spec.deviceRemoval,
|
|
8242
|
+
maxDataBytes: spec.maxDataBytes,
|
|
8243
|
+
secretPaths: [...secretPaths],
|
|
8244
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
8245
|
+
adoptsFrom: spec.adoptsFrom,
|
|
8246
|
+
transactFamily: spec.transactFamily,
|
|
8247
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
8248
|
+
title: spec.entry.title,
|
|
8249
|
+
nameField,
|
|
8250
|
+
fields
|
|
8251
|
+
}
|
|
8252
|
+
});
|
|
8253
|
+
assertValidDeclaration(name, parsed);
|
|
8254
|
+
out[name] = {
|
|
8255
|
+
name,
|
|
8256
|
+
schema: spec.schema,
|
|
8257
|
+
declaration: parsed
|
|
8258
|
+
};
|
|
8259
|
+
}
|
|
8260
|
+
return out;
|
|
8261
|
+
}
|
|
8262
|
+
/**
|
|
8263
|
+
* Entry kinds (D881): every list of user-created entries (notification
|
|
8264
|
+
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
8265
|
+
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
8266
|
+
* through the `record-entries` capability with password fields derived from
|
|
8267
|
+
* the schema (`.meta({ secret: true })`).
|
|
8268
|
+
*/
|
|
8269
|
+
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
8270
|
+
function entryBody(shape) {
|
|
8271
|
+
return object({
|
|
8272
|
+
name: string().min(1),
|
|
8273
|
+
...shape
|
|
8274
|
+
});
|
|
8275
|
+
}
|
|
8276
|
+
/**
|
|
8277
|
+
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
8278
|
+
* engine, never aged, belonging to no device.
|
|
8279
|
+
*/
|
|
8280
|
+
function defineEntryKind(name, spec) {
|
|
8281
|
+
const defined = defineRecordKinds({ [name]: {
|
|
8282
|
+
schema: spec.schema,
|
|
8283
|
+
class: "config",
|
|
8284
|
+
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
8285
|
+
retention: { none: "an entry goes only when the operator deletes it" },
|
|
8286
|
+
...spec.database === void 0 ? {} : { database: spec.database },
|
|
8287
|
+
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
8288
|
+
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
8289
|
+
...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
|
|
8290
|
+
entry: {
|
|
8291
|
+
title: spec.title,
|
|
8292
|
+
...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
|
|
8293
|
+
}
|
|
8294
|
+
} })[name];
|
|
8295
|
+
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
8296
|
+
return defined;
|
|
8297
|
+
}
|
|
8298
|
+
/**
|
|
8299
|
+
* Legacy source for entry adoption (B3): a list stored under addon-settings
|
|
8300
|
+
* `<addonId>.<key>` until records-adopt copies rows into the entry kind.
|
|
8301
|
+
*/
|
|
8302
|
+
var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
|
|
8303
|
+
/** The `adoptsFrom` value for an addon-settings array field. */
|
|
8304
|
+
function settingsArrayAdoptsFrom(addonId, settingsKey) {
|
|
8305
|
+
return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
|
|
8306
|
+
}
|
|
7825
8307
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
7826
8308
|
var CamProfileSchema = _enum([
|
|
7827
8309
|
"high",
|
|
@@ -16008,6 +16490,222 @@ id: union([string(), number()]) }), {
|
|
|
16008
16490
|
kind: "mutation",
|
|
16009
16491
|
auth: "admin"
|
|
16010
16492
|
});
|
|
16493
|
+
/**
|
|
16494
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
16495
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
16496
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
16497
|
+
*
|
|
16498
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
16499
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
16500
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
16501
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
16502
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
16503
|
+
* addons go through the owner's capability.
|
|
16504
|
+
*
|
|
16505
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
16506
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
16507
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
16508
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
16509
|
+
* row's own ref.
|
|
16510
|
+
*
|
|
16511
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
16512
|
+
*/
|
|
16513
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
16514
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
16515
|
+
var RecordBodySchema = record(string(), unknown());
|
|
16516
|
+
var RecordInputSchema = object({
|
|
16517
|
+
id: RecordIdSchema,
|
|
16518
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
16519
|
+
deviceId: number().int().optional(),
|
|
16520
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
16521
|
+
at: number().int().optional(),
|
|
16522
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
16523
|
+
expiresAt: number().int().optional(),
|
|
16524
|
+
data: RecordBodySchema
|
|
16525
|
+
});
|
|
16526
|
+
var RecordViewSchema = object({
|
|
16527
|
+
id: string(),
|
|
16528
|
+
deviceId: number().int().nullable(),
|
|
16529
|
+
at: number().nullable(),
|
|
16530
|
+
expiresAt: number().nullable(),
|
|
16531
|
+
rev: number().int(),
|
|
16532
|
+
updatedAt: number(),
|
|
16533
|
+
data: RecordBodySchema
|
|
16534
|
+
});
|
|
16535
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
16536
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
16537
|
+
string(),
|
|
16538
|
+
number(),
|
|
16539
|
+
boolean(),
|
|
16540
|
+
object({ in: array(union([
|
|
16541
|
+
string(),
|
|
16542
|
+
number(),
|
|
16543
|
+
boolean()
|
|
16544
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
16545
|
+
object({
|
|
16546
|
+
gt: union([string(), number()]).optional(),
|
|
16547
|
+
gte: union([string(), number()]).optional(),
|
|
16548
|
+
lt: union([string(), number()]).optional(),
|
|
16549
|
+
lte: union([string(), number()]).optional()
|
|
16550
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
16551
|
+
]));
|
|
16552
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
16553
|
+
var TimeWindowShape = {
|
|
16554
|
+
deviceId: number().int().optional(),
|
|
16555
|
+
atFrom: number().optional(),
|
|
16556
|
+
atTo: number().optional()
|
|
16557
|
+
};
|
|
16558
|
+
var RecordQueryInputSchema = object({
|
|
16559
|
+
...KindShape,
|
|
16560
|
+
...TimeWindowShape,
|
|
16561
|
+
where: RecordWhereSchema.optional(),
|
|
16562
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
16563
|
+
order: _enum(["at", "id"]).optional(),
|
|
16564
|
+
desc: boolean().optional(),
|
|
16565
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
16566
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
16567
|
+
cursor: string().min(1).optional()
|
|
16568
|
+
});
|
|
16569
|
+
var RecordQueryResultSchema = object({
|
|
16570
|
+
records: array(RecordViewSchema),
|
|
16571
|
+
nextCursor: string().nullable()
|
|
16572
|
+
});
|
|
16573
|
+
var RecordKindStateSchema = _enum([
|
|
16574
|
+
"created",
|
|
16575
|
+
"unchanged",
|
|
16576
|
+
"updated"
|
|
16577
|
+
]);
|
|
16578
|
+
var DeclareKindResultSchema = object({
|
|
16579
|
+
kindId: number().int(),
|
|
16580
|
+
state: RecordKindStateSchema,
|
|
16581
|
+
createdIndexes: array(string()),
|
|
16582
|
+
/** The boot guard: the kind is empty while its legacy table still holds rows. */
|
|
16583
|
+
adoptionPending: object({
|
|
16584
|
+
legacyTable: string(),
|
|
16585
|
+
legacyRows: number().int()
|
|
16586
|
+
}).nullable()
|
|
16587
|
+
});
|
|
16588
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
16589
|
+
var SecretRefsList = array(string());
|
|
16590
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
16591
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
16592
|
+
kind: "mutation",
|
|
16593
|
+
auth: "admin"
|
|
16594
|
+
}), method(object({
|
|
16595
|
+
...KindShape,
|
|
16596
|
+
id: RecordIdSchema
|
|
16597
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
16598
|
+
...KindShape,
|
|
16599
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16600
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
16601
|
+
...KindShape,
|
|
16602
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16603
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
16604
|
+
...KindShape,
|
|
16605
|
+
record: RecordInputSchema,
|
|
16606
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
16607
|
+
ifRev: number().int().min(0).optional()
|
|
16608
|
+
}), object({
|
|
16609
|
+
rev: number().int(),
|
|
16610
|
+
releasedRefs: SecretRefsList
|
|
16611
|
+
}), {
|
|
16612
|
+
kind: "mutation",
|
|
16613
|
+
auth: "admin"
|
|
16614
|
+
}), method(object({
|
|
16615
|
+
...KindShape,
|
|
16616
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16617
|
+
}), object({
|
|
16618
|
+
count: number().int(),
|
|
16619
|
+
releasedRefs: SecretRefsList
|
|
16620
|
+
}), {
|
|
16621
|
+
kind: "mutation",
|
|
16622
|
+
auth: "admin"
|
|
16623
|
+
}), method(object({
|
|
16624
|
+
...KindShape,
|
|
16625
|
+
id: RecordIdSchema,
|
|
16626
|
+
data: RecordBodySchema,
|
|
16627
|
+
at: number().int().nullable().optional(),
|
|
16628
|
+
expiresAt: number().int().nullable().optional(),
|
|
16629
|
+
ifRev: number().int().min(1).optional()
|
|
16630
|
+
}), object({
|
|
16631
|
+
rev: number().int(),
|
|
16632
|
+
releasedRefs: SecretRefsList
|
|
16633
|
+
}), {
|
|
16634
|
+
kind: "mutation",
|
|
16635
|
+
auth: "admin"
|
|
16636
|
+
}), method(object({
|
|
16637
|
+
...KindShape,
|
|
16638
|
+
id: RecordIdSchema
|
|
16639
|
+
}), object({
|
|
16640
|
+
deleted: boolean(),
|
|
16641
|
+
secretRefs: SecretRefsList
|
|
16642
|
+
}), {
|
|
16643
|
+
kind: "mutation",
|
|
16644
|
+
auth: "admin"
|
|
16645
|
+
}), method(object({
|
|
16646
|
+
...KindShape,
|
|
16647
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
16648
|
+
}), object({
|
|
16649
|
+
deleted: number().int(),
|
|
16650
|
+
secretRefs: SecretRefsList
|
|
16651
|
+
}), {
|
|
16652
|
+
kind: "mutation",
|
|
16653
|
+
auth: "admin"
|
|
16654
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16655
|
+
...KindShape,
|
|
16656
|
+
...TimeWindowShape,
|
|
16657
|
+
where: RecordWhereSchema.optional()
|
|
16658
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
16659
|
+
...KindShape,
|
|
16660
|
+
deviceId: number().int().optional(),
|
|
16661
|
+
from: number(),
|
|
16662
|
+
to: number(),
|
|
16663
|
+
bucketMs: number().int().positive()
|
|
16664
|
+
}), object({ buckets: array(object({
|
|
16665
|
+
bucketStart: number(),
|
|
16666
|
+
count: number().int()
|
|
16667
|
+
})) }), { auth: "admin" }), method(object({
|
|
16668
|
+
...KindShape,
|
|
16669
|
+
op: _enum([
|
|
16670
|
+
"sum",
|
|
16671
|
+
"min",
|
|
16672
|
+
"max",
|
|
16673
|
+
"count"
|
|
16674
|
+
]),
|
|
16675
|
+
field: RecordFieldPathSchema.optional(),
|
|
16676
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
16677
|
+
where: RecordWhereSchema.optional()
|
|
16678
|
+
}), object({ rows: array(object({
|
|
16679
|
+
group: union([
|
|
16680
|
+
string(),
|
|
16681
|
+
number(),
|
|
16682
|
+
_null()
|
|
16683
|
+
]),
|
|
16684
|
+
value: number().nullable()
|
|
16685
|
+
})) }), { auth: "admin" }), method(object({
|
|
16686
|
+
...KindShape,
|
|
16687
|
+
deviceId: number().int().optional(),
|
|
16688
|
+
atBefore: number().optional(),
|
|
16689
|
+
where: RecordWhereSchema.optional()
|
|
16690
|
+
}), object({
|
|
16691
|
+
deleted: number().int(),
|
|
16692
|
+
secretRefs: SecretRefsList
|
|
16693
|
+
}), {
|
|
16694
|
+
kind: "mutation",
|
|
16695
|
+
auth: "admin"
|
|
16696
|
+
}), method(object({
|
|
16697
|
+
deviceId: number().int(),
|
|
16698
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
16699
|
+
}), object({
|
|
16700
|
+
deleted: record(string(), number().int()),
|
|
16701
|
+
secretRefs: SecretRefsList
|
|
16702
|
+
}), {
|
|
16703
|
+
kind: "mutation",
|
|
16704
|
+
auth: "admin"
|
|
16705
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
16706
|
+
kind: "mutation",
|
|
16707
|
+
auth: "admin"
|
|
16708
|
+
});
|
|
16011
16709
|
/** One table of the settings database. */
|
|
16012
16710
|
var StorageTableSchema = object({
|
|
16013
16711
|
/** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
|
|
@@ -16020,6 +16718,28 @@ var StorageTableSchema = object({
|
|
|
16020
16718
|
/** Declared by an addon since this engine process started (a running addon claims it). */
|
|
16021
16719
|
declaredThisBoot: boolean()
|
|
16022
16720
|
});
|
|
16721
|
+
/** One declared record kind (D881) as System -> Data shows it. */
|
|
16722
|
+
var StorageKindSchema = object({
|
|
16723
|
+
owner: string(),
|
|
16724
|
+
kind: string(),
|
|
16725
|
+
database: _enum(["settings", "events"]),
|
|
16726
|
+
class: string(),
|
|
16727
|
+
state: _enum([
|
|
16728
|
+
"declared",
|
|
16729
|
+
"orphaned",
|
|
16730
|
+
"dropped"
|
|
16731
|
+
]),
|
|
16732
|
+
/** `null` when the caller asked for no counts (`counts: false`). */
|
|
16733
|
+
rows: number().int().nonnegative().nullable(),
|
|
16734
|
+
/** Rows x the average size of a sample; null for an empty kind. */
|
|
16735
|
+
bytesEstimate: number().int().nonnegative().nullable(),
|
|
16736
|
+
writeTrigger: string(),
|
|
16737
|
+
retention: RecordRetentionSchema,
|
|
16738
|
+
/** `true` when the kind is an entry kind (the generic entries UI lists it). */
|
|
16739
|
+
entry: boolean(),
|
|
16740
|
+
/** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
|
|
16741
|
+
declaration: RecordKindDeclarationSchema
|
|
16742
|
+
});
|
|
16023
16743
|
method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
|
|
16024
16744
|
collection: string().min(1),
|
|
16025
16745
|
expectRows: number().int().nonnegative()
|
|
@@ -16029,6 +16749,87 @@ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: arr
|
|
|
16029
16749
|
}), {
|
|
16030
16750
|
kind: "mutation",
|
|
16031
16751
|
auth: "admin"
|
|
16752
|
+
}), method(object({
|
|
16753
|
+
owner: string().min(1).optional(),
|
|
16754
|
+
/** `false` skips the per-kind row count (a catalog read only). Default true. */
|
|
16755
|
+
counts: boolean().optional()
|
|
16756
|
+
}), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
|
|
16757
|
+
owner: string().min(1),
|
|
16758
|
+
kind: RecordKindNameSchema
|
|
16759
|
+
}), RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
16760
|
+
owner: string().min(1),
|
|
16761
|
+
kind: RecordKindNameSchema,
|
|
16762
|
+
records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
|
|
16763
|
+
/** The LAST batch: the copy is complete, the boot guard stops asking. */
|
|
16764
|
+
complete: boolean().optional()
|
|
16765
|
+
}).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
|
|
16766
|
+
kind: "mutation",
|
|
16767
|
+
auth: "admin"
|
|
16768
|
+
}), method(object({
|
|
16769
|
+
collection: string().min(1),
|
|
16770
|
+
cursor: string().optional(),
|
|
16771
|
+
limit: number().int().min(1).max(1e3).optional()
|
|
16772
|
+
}), object({
|
|
16773
|
+
rows: array(object({
|
|
16774
|
+
id: string(),
|
|
16775
|
+
data: record(string(), unknown())
|
|
16776
|
+
})),
|
|
16777
|
+
nextCursor: string().nullable()
|
|
16778
|
+
}), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
|
|
16779
|
+
/**
|
|
16780
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
16781
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
16782
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
16783
|
+
*
|
|
16784
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
16785
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
16786
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
16787
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16788
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
16789
|
+
* a secret value, and a locked keychain refuses the write with
|
|
16790
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
16791
|
+
*
|
|
16792
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
16793
|
+
*/
|
|
16794
|
+
var EntryKindInfoSchema = object({
|
|
16795
|
+
owner: string(),
|
|
16796
|
+
kind: RecordKindNameSchema,
|
|
16797
|
+
title: string(),
|
|
16798
|
+
nameField: string(),
|
|
16799
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
16800
|
+
fields: record(string(), unknown()),
|
|
16801
|
+
secretPaths: array(string()),
|
|
16802
|
+
rows: number().int().nonnegative()
|
|
16803
|
+
});
|
|
16804
|
+
var EntryViewSchema = object({
|
|
16805
|
+
id: RecordIdSchema,
|
|
16806
|
+
name: string(),
|
|
16807
|
+
rev: number().int(),
|
|
16808
|
+
updatedAt: number(),
|
|
16809
|
+
/** Secret fields hold the redaction token. */
|
|
16810
|
+
data: RecordBodySchema
|
|
16811
|
+
});
|
|
16812
|
+
var EntryAddress = {
|
|
16813
|
+
owner: string().min(1),
|
|
16814
|
+
kind: RecordKindNameSchema
|
|
16815
|
+
};
|
|
16816
|
+
method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
|
|
16817
|
+
...EntryAddress,
|
|
16818
|
+
id: RecordIdSchema.optional(),
|
|
16819
|
+
data: RecordBodySchema,
|
|
16820
|
+
ifRev: number().int().min(1).optional()
|
|
16821
|
+
}), object({
|
|
16822
|
+
id: string(),
|
|
16823
|
+
rev: number().int()
|
|
16824
|
+
}), {
|
|
16825
|
+
kind: "mutation",
|
|
16826
|
+
auth: "admin"
|
|
16827
|
+
}), method(object({
|
|
16828
|
+
...EntryAddress,
|
|
16829
|
+
id: RecordIdSchema
|
|
16830
|
+
}), object({ deleted: boolean() }), {
|
|
16831
|
+
kind: "mutation",
|
|
16832
|
+
auth: "admin"
|
|
16032
16833
|
});
|
|
16033
16834
|
/**
|
|
16034
16835
|
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
@@ -67092,6 +67893,30 @@ Object.freeze({
|
|
|
67092
67893
|
addonId: null,
|
|
67093
67894
|
access: "create"
|
|
67094
67895
|
},
|
|
67896
|
+
"recordEntries.deleteEntry": {
|
|
67897
|
+
capName: "record-entries",
|
|
67898
|
+
capScope: "system",
|
|
67899
|
+
addonId: null,
|
|
67900
|
+
access: "delete"
|
|
67901
|
+
},
|
|
67902
|
+
"recordEntries.listEntries": {
|
|
67903
|
+
capName: "record-entries",
|
|
67904
|
+
capScope: "system",
|
|
67905
|
+
addonId: null,
|
|
67906
|
+
access: "view"
|
|
67907
|
+
},
|
|
67908
|
+
"recordEntries.listEntryKinds": {
|
|
67909
|
+
capName: "record-entries",
|
|
67910
|
+
capScope: "system",
|
|
67911
|
+
addonId: null,
|
|
67912
|
+
access: "view"
|
|
67913
|
+
},
|
|
67914
|
+
"recordEntries.putEntry": {
|
|
67915
|
+
capName: "record-entries",
|
|
67916
|
+
capScope: "system",
|
|
67917
|
+
addonId: null,
|
|
67918
|
+
access: "create"
|
|
67919
|
+
},
|
|
67095
67920
|
"recording.getAvailability": {
|
|
67096
67921
|
capName: "recording",
|
|
67097
67922
|
capScope: "device",
|
|
@@ -67392,6 +68217,102 @@ Object.freeze({
|
|
|
67392
68217
|
addonId: null,
|
|
67393
68218
|
access: "view"
|
|
67394
68219
|
},
|
|
68220
|
+
"records.aggregate": {
|
|
68221
|
+
capName: "records",
|
|
68222
|
+
capScope: "system",
|
|
68223
|
+
addonId: null,
|
|
68224
|
+
access: "view"
|
|
68225
|
+
},
|
|
68226
|
+
"records.allocateId": {
|
|
68227
|
+
capName: "records",
|
|
68228
|
+
capScope: "system",
|
|
68229
|
+
addonId: null,
|
|
68230
|
+
access: "create"
|
|
68231
|
+
},
|
|
68232
|
+
"records.count": {
|
|
68233
|
+
capName: "records",
|
|
68234
|
+
capScope: "system",
|
|
68235
|
+
addonId: null,
|
|
68236
|
+
access: "view"
|
|
68237
|
+
},
|
|
68238
|
+
"records.declareKinds": {
|
|
68239
|
+
capName: "records",
|
|
68240
|
+
capScope: "system",
|
|
68241
|
+
addonId: null,
|
|
68242
|
+
access: "create"
|
|
68243
|
+
},
|
|
68244
|
+
"records.delete": {
|
|
68245
|
+
capName: "records",
|
|
68246
|
+
capScope: "system",
|
|
68247
|
+
addonId: null,
|
|
68248
|
+
access: "delete"
|
|
68249
|
+
},
|
|
68250
|
+
"records.deleteDevice": {
|
|
68251
|
+
capName: "records",
|
|
68252
|
+
capScope: "system",
|
|
68253
|
+
addonId: null,
|
|
68254
|
+
access: "delete"
|
|
68255
|
+
},
|
|
68256
|
+
"records.deleteMany": {
|
|
68257
|
+
capName: "records",
|
|
68258
|
+
capScope: "system",
|
|
68259
|
+
addonId: null,
|
|
68260
|
+
access: "delete"
|
|
68261
|
+
},
|
|
68262
|
+
"records.deleteWhere": {
|
|
68263
|
+
capName: "records",
|
|
68264
|
+
capScope: "system",
|
|
68265
|
+
addonId: null,
|
|
68266
|
+
access: "delete"
|
|
68267
|
+
},
|
|
68268
|
+
"records.get": {
|
|
68269
|
+
capName: "records",
|
|
68270
|
+
capScope: "system",
|
|
68271
|
+
addonId: null,
|
|
68272
|
+
access: "view"
|
|
68273
|
+
},
|
|
68274
|
+
"records.getMany": {
|
|
68275
|
+
capName: "records",
|
|
68276
|
+
capScope: "system",
|
|
68277
|
+
addonId: null,
|
|
68278
|
+
access: "view"
|
|
68279
|
+
},
|
|
68280
|
+
"records.histogram": {
|
|
68281
|
+
capName: "records",
|
|
68282
|
+
capScope: "system",
|
|
68283
|
+
addonId: null,
|
|
68284
|
+
access: "view"
|
|
68285
|
+
},
|
|
68286
|
+
"records.patch": {
|
|
68287
|
+
capName: "records",
|
|
68288
|
+
capScope: "system",
|
|
68289
|
+
addonId: null,
|
|
68290
|
+
access: "create"
|
|
68291
|
+
},
|
|
68292
|
+
"records.put": {
|
|
68293
|
+
capName: "records",
|
|
68294
|
+
capScope: "system",
|
|
68295
|
+
addonId: null,
|
|
68296
|
+
access: "create"
|
|
68297
|
+
},
|
|
68298
|
+
"records.putMany": {
|
|
68299
|
+
capName: "records",
|
|
68300
|
+
capScope: "system",
|
|
68301
|
+
addonId: null,
|
|
68302
|
+
access: "create"
|
|
68303
|
+
},
|
|
68304
|
+
"records.query": {
|
|
68305
|
+
capName: "records",
|
|
68306
|
+
capScope: "system",
|
|
68307
|
+
addonId: null,
|
|
68308
|
+
access: "view"
|
|
68309
|
+
},
|
|
68310
|
+
"records.secretRefs": {
|
|
68311
|
+
capName: "records",
|
|
68312
|
+
capScope: "system",
|
|
68313
|
+
addonId: null,
|
|
68314
|
+
access: "view"
|
|
68315
|
+
},
|
|
67395
68316
|
"sceneMonitor.captureReference": {
|
|
67396
68317
|
capName: "scene-monitor",
|
|
67397
68318
|
capScope: "device",
|
|
@@ -67824,18 +68745,48 @@ Object.freeze({
|
|
|
67824
68745
|
addonId: null,
|
|
67825
68746
|
access: "create"
|
|
67826
68747
|
},
|
|
68748
|
+
"storageAdmin.adoptRecords": {
|
|
68749
|
+
capName: "storage-admin",
|
|
68750
|
+
capScope: "system",
|
|
68751
|
+
addonId: null,
|
|
68752
|
+
access: "create"
|
|
68753
|
+
},
|
|
67827
68754
|
"storageAdmin.dropCollection": {
|
|
67828
68755
|
capName: "storage-admin",
|
|
67829
68756
|
capScope: "system",
|
|
67830
68757
|
addonId: null,
|
|
67831
68758
|
access: "delete"
|
|
67832
68759
|
},
|
|
68760
|
+
"storageAdmin.isAdoptedLegacyTable": {
|
|
68761
|
+
capName: "storage-admin",
|
|
68762
|
+
capScope: "system",
|
|
68763
|
+
addonId: null,
|
|
68764
|
+
access: "view"
|
|
68765
|
+
},
|
|
68766
|
+
"storageAdmin.listKinds": {
|
|
68767
|
+
capName: "storage-admin",
|
|
68768
|
+
capScope: "system",
|
|
68769
|
+
addonId: null,
|
|
68770
|
+
access: "view"
|
|
68771
|
+
},
|
|
67833
68772
|
"storageAdmin.listTables": {
|
|
67834
68773
|
capName: "storage-admin",
|
|
67835
68774
|
capScope: "system",
|
|
67836
68775
|
addonId: null,
|
|
67837
68776
|
access: "view"
|
|
67838
68777
|
},
|
|
68778
|
+
"storageAdmin.readLegacyCollection": {
|
|
68779
|
+
capName: "storage-admin",
|
|
68780
|
+
capScope: "system",
|
|
68781
|
+
addonId: null,
|
|
68782
|
+
access: "view"
|
|
68783
|
+
},
|
|
68784
|
+
"storageAdmin.readRecords": {
|
|
68785
|
+
capName: "storage-admin",
|
|
68786
|
+
capScope: "system",
|
|
68787
|
+
addonId: null,
|
|
68788
|
+
access: "view"
|
|
68789
|
+
},
|
|
67839
68790
|
"storageEvictable.evict": {
|
|
67840
68791
|
capName: "storage-evictable",
|
|
67841
68792
|
capScope: "system",
|
|
@@ -71430,6 +72381,37 @@ Object.freeze({
|
|
|
71430
72381
|
form: "single",
|
|
71431
72382
|
optional: false
|
|
71432
72383
|
}],
|
|
72384
|
+
"records.count": [{
|
|
72385
|
+
name: "deviceId",
|
|
72386
|
+
form: "single",
|
|
72387
|
+
optional: true
|
|
72388
|
+
}],
|
|
72389
|
+
"records.deleteDevice": [{
|
|
72390
|
+
name: "deviceId",
|
|
72391
|
+
form: "single",
|
|
72392
|
+
optional: false
|
|
72393
|
+
}],
|
|
72394
|
+
"records.deleteWhere": [{
|
|
72395
|
+
name: "deviceId",
|
|
72396
|
+
form: "single",
|
|
72397
|
+
optional: true
|
|
72398
|
+
}],
|
|
72399
|
+
"records.histogram": [{
|
|
72400
|
+
name: "deviceId",
|
|
72401
|
+
form: "single",
|
|
72402
|
+
optional: true
|
|
72403
|
+
}],
|
|
72404
|
+
"records.putMany": [{
|
|
72405
|
+
name: "records",
|
|
72406
|
+
form: "object-array",
|
|
72407
|
+
optional: false,
|
|
72408
|
+
itemField: "deviceId"
|
|
72409
|
+
}],
|
|
72410
|
+
"records.query": [{
|
|
72411
|
+
name: "deviceId",
|
|
72412
|
+
form: "single",
|
|
72413
|
+
optional: true
|
|
72414
|
+
}],
|
|
71433
72415
|
"sceneMonitor.captureReference": [{
|
|
71434
72416
|
name: "deviceId",
|
|
71435
72417
|
form: "single",
|
|
@@ -71546,6 +72528,17 @@ Object.freeze({
|
|
|
71546
72528
|
form: "single",
|
|
71547
72529
|
optional: false
|
|
71548
72530
|
}],
|
|
72531
|
+
"storageAdmin.adoptRecords": [{
|
|
72532
|
+
name: "records",
|
|
72533
|
+
form: "object-array",
|
|
72534
|
+
optional: false,
|
|
72535
|
+
itemField: "deviceId"
|
|
72536
|
+
}],
|
|
72537
|
+
"storageAdmin.readRecords": [{
|
|
72538
|
+
name: "deviceId",
|
|
72539
|
+
form: "single",
|
|
72540
|
+
optional: true
|
|
72541
|
+
}],
|
|
71549
72542
|
"streamBroker.acquireEgressTranscode": [{
|
|
71550
72543
|
name: "deviceId",
|
|
71551
72544
|
form: "single",
|
|
@@ -73376,7 +74369,31 @@ function createWasteCalendarSource(deps) {
|
|
|
73376
74369
|
}
|
|
73377
74370
|
//#endregion
|
|
73378
74371
|
//#region src/waste-catalog.ts
|
|
73379
|
-
var catalog = {
|
|
74372
|
+
var catalog = object({
|
|
74373
|
+
generatedAt: string(),
|
|
74374
|
+
sourceHash: string(),
|
|
74375
|
+
countries: array(object({
|
|
74376
|
+
id: string(),
|
|
74377
|
+
label: string()
|
|
74378
|
+
})),
|
|
74379
|
+
services: array(object({
|
|
74380
|
+
id: string(),
|
|
74381
|
+
countryId: string(),
|
|
74382
|
+
label: string(),
|
|
74383
|
+
module: string(),
|
|
74384
|
+
defaultArgs: record(string(), string()),
|
|
74385
|
+
fields: array(object({
|
|
74386
|
+
key: string(),
|
|
74387
|
+
label: string(),
|
|
74388
|
+
required: boolean(),
|
|
74389
|
+
kind: _enum([
|
|
74390
|
+
"text",
|
|
74391
|
+
"number",
|
|
74392
|
+
"boolean"
|
|
74393
|
+
])
|
|
74394
|
+
}))
|
|
74395
|
+
}))
|
|
74396
|
+
}).parse({
|
|
73380
74397
|
generatedAt: "2026-10-12T16:54:36.612Z",
|
|
73381
74398
|
sourceHash: "35f2f21decca0a4beae07ec89164a2ae5ea34ff5832c440a046d79d69b5963ea",
|
|
73382
74399
|
entries: [
|
|
@@ -159243,7 +160260,7 @@ var catalog = {
|
|
|
159243
160260
|
}]
|
|
159244
160261
|
}
|
|
159245
160262
|
]
|
|
159246
|
-
};
|
|
160263
|
+
});
|
|
159247
160264
|
function listCatalogCountries() {
|
|
159248
160265
|
return catalog.countries;
|
|
159249
160266
|
}
|
|
@@ -159370,6 +160387,79 @@ function allocateSourceId(label, existingIds) {
|
|
|
159370
160387
|
throw new Error("could not allocate a unique source id");
|
|
159371
160388
|
}
|
|
159372
160389
|
//#endregion
|
|
160390
|
+
//#region src/waste-source-record-kinds.ts
|
|
160391
|
+
var WASTE_COLLECTIONS_OWNER = "waste-collections";
|
|
160392
|
+
var WasteSourceBodySchema = entryBody({
|
|
160393
|
+
module: string().min(1),
|
|
160394
|
+
args: preprocess((v) => v ?? {}, record(string(), WasteArgValueSchema)),
|
|
160395
|
+
enabled: boolean().default(true)
|
|
160396
|
+
});
|
|
160397
|
+
var wasteSourceEntryKind = defineEntryKind("waste-source", {
|
|
160398
|
+
title: "Waste collection sources",
|
|
160399
|
+
schema: WasteSourceBodySchema,
|
|
160400
|
+
writeTrigger: "an operator adds or edits a municipal waste calendar source",
|
|
160401
|
+
adoptsFrom: settingsArrayAdoptsFrom(WASTE_COLLECTIONS_OWNER, "sources")
|
|
160402
|
+
});
|
|
160403
|
+
//#endregion
|
|
160404
|
+
//#region src/waste-source-store.ts
|
|
160405
|
+
function rowToSource(id, data) {
|
|
160406
|
+
const parsed = WasteSourceConfigSchema.safeParse({
|
|
160407
|
+
id,
|
|
160408
|
+
label: data.name,
|
|
160409
|
+
module: data.module,
|
|
160410
|
+
args: data.args,
|
|
160411
|
+
enabled: data.enabled
|
|
160412
|
+
});
|
|
160413
|
+
return parsed.success ? parsed.data : null;
|
|
160414
|
+
}
|
|
160415
|
+
var WasteSourceStore = class WasteSourceStore {
|
|
160416
|
+
kind;
|
|
160417
|
+
constructor(kind) {
|
|
160418
|
+
this.kind = kind;
|
|
160419
|
+
}
|
|
160420
|
+
static of(records) {
|
|
160421
|
+
return new WasteSourceStore(records.kind(wasteSourceEntryKind));
|
|
160422
|
+
}
|
|
160423
|
+
async listResolved() {
|
|
160424
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
160425
|
+
const out = [];
|
|
160426
|
+
for (const record of page.records) {
|
|
160427
|
+
let data = record.data;
|
|
160428
|
+
try {
|
|
160429
|
+
const resolved = await this.kind.getResolved(record.id);
|
|
160430
|
+
if (resolved !== null) data = resolved.data;
|
|
160431
|
+
} catch (err) {
|
|
160432
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
160433
|
+
}
|
|
160434
|
+
const parsed = WasteSourceBodySchema.safeParse(data);
|
|
160435
|
+
if (!parsed.success) continue;
|
|
160436
|
+
const row = rowToSource(record.id, parsed.data);
|
|
160437
|
+
if (row !== null) out.push(row);
|
|
160438
|
+
}
|
|
160439
|
+
return out;
|
|
160440
|
+
}
|
|
160441
|
+
async replaceAll(sources) {
|
|
160442
|
+
const page = await this.kind.query({ limit: 1e3 });
|
|
160443
|
+
const nextIds = new Set(sources.map((s) => s.id));
|
|
160444
|
+
for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
|
|
160445
|
+
for (const source of sources) {
|
|
160446
|
+
const { id, label, module, args, enabled } = source;
|
|
160447
|
+
const body = {
|
|
160448
|
+
name: label,
|
|
160449
|
+
module,
|
|
160450
|
+
args,
|
|
160451
|
+
enabled
|
|
160452
|
+
};
|
|
160453
|
+
const parsed = wasteSourceEntryKind.schema.safeParse(body);
|
|
160454
|
+
if (!parsed.success) throw new Error(`invalid waste source '${id}': ${parsed.error.message}`);
|
|
160455
|
+
await this.kind.put({
|
|
160456
|
+
id,
|
|
160457
|
+
data: parsed.data
|
|
160458
|
+
});
|
|
160459
|
+
}
|
|
160460
|
+
}
|
|
160461
|
+
};
|
|
160462
|
+
//#endregion
|
|
159373
160463
|
//#region src/waste-collections.addon.ts
|
|
159374
160464
|
/**
|
|
159375
160465
|
* Waste Collections — hub-only calendar-source over the vendored HACS
|
|
@@ -159384,12 +160474,23 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159384
160474
|
cache = /* @__PURE__ */ new Map();
|
|
159385
160475
|
refreshTimer = null;
|
|
159386
160476
|
refreshInFlight = null;
|
|
160477
|
+
sourceStore = null;
|
|
160478
|
+
activeSources = [];
|
|
159387
160479
|
constructor() {
|
|
159388
160480
|
super({ ...DEFAULT_WASTE_CONFIG });
|
|
159389
160481
|
}
|
|
159390
160482
|
async onInitialize() {
|
|
159391
160483
|
this.scriptPath = resolveFetchScript();
|
|
159392
160484
|
this.loadCacheFromDisk();
|
|
160485
|
+
const records = this.ctx.records;
|
|
160486
|
+
if (records === void 0) throw new Error("waste-collections: ctx.records is required (hub-only addon)");
|
|
160487
|
+
await records.declare({ "waste-source": wasteSourceEntryKind });
|
|
160488
|
+
this.sourceStore = WasteSourceStore.of(records);
|
|
160489
|
+
this.activeSources = await this.loadPersistedSources();
|
|
160490
|
+
if ((await this.sourceStore.listResolved()).length === 0 && this.config.sources.length > 0) {
|
|
160491
|
+
await this.sourceStore.replaceAll(this.parseConfigSources(this.config.sources));
|
|
160492
|
+
this.activeSources = await this.loadPersistedSources();
|
|
160493
|
+
}
|
|
159393
160494
|
try {
|
|
159394
160495
|
this.pythonPath = await this.ctx.deps.ensurePython();
|
|
159395
160496
|
} catch (err) {
|
|
@@ -159447,6 +160548,7 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159447
160548
|
};
|
|
159448
160549
|
}
|
|
159449
160550
|
async onConfigChanged() {
|
|
160551
|
+
this.activeSources = await this.loadPersistedSources();
|
|
159450
160552
|
const ids = new Set(this.configuredSources().map((s) => s.id));
|
|
159451
160553
|
for (const key of [...this.cache.keys()]) if (!ids.has(key)) this.cache.delete(key);
|
|
159452
160554
|
this.persistCache();
|
|
@@ -159457,15 +160559,36 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159457
160559
|
* is skipped AND logged: a source that silently vanishes reads as a calendar
|
|
159458
160560
|
* that never existed.
|
|
159459
160561
|
*/
|
|
159460
|
-
|
|
160562
|
+
parseConfigSources(rawList) {
|
|
159461
160563
|
const out = [];
|
|
159462
|
-
for (const raw of
|
|
160564
|
+
for (const raw of rawList) {
|
|
159463
160565
|
const parsed = WasteSourceConfigSchema.safeParse(raw);
|
|
159464
160566
|
if (parsed.success) out.push(parsed.data);
|
|
159465
|
-
else this.ctx.logger.warn("waste-collections: a stored source does not parse - skipped", { meta: { sourceId: typeof raw
|
|
160567
|
+
else this.ctx.logger.warn("waste-collections: a stored source does not parse - skipped", { meta: { sourceId: typeof raw === "object" && raw !== null && "id" in raw && typeof raw.id === "string" ? raw.id : null } });
|
|
159466
160568
|
}
|
|
159467
160569
|
return out;
|
|
159468
160570
|
}
|
|
160571
|
+
async loadPersistedSources() {
|
|
160572
|
+
const store = this.sourceStore;
|
|
160573
|
+
if (store !== null) {
|
|
160574
|
+
const fromRecords = await store.listResolved();
|
|
160575
|
+
if (fromRecords.length > 0) return fromRecords;
|
|
160576
|
+
}
|
|
160577
|
+
return this.parseConfigSources(this.config.sources);
|
|
160578
|
+
}
|
|
160579
|
+
async persistSources(sources) {
|
|
160580
|
+
this.activeSources = [...sources];
|
|
160581
|
+
const store = this.sourceStore;
|
|
160582
|
+
if (store !== null) {
|
|
160583
|
+
await store.replaceAll(sources);
|
|
160584
|
+
return;
|
|
160585
|
+
}
|
|
160586
|
+
await this.updateGlobalSettings({ sources: [...sources] });
|
|
160587
|
+
}
|
|
160588
|
+
configuredSources() {
|
|
160589
|
+
if (this.activeSources.length > 0) return this.activeSources;
|
|
160590
|
+
return this.parseConfigSources(this.config.sources);
|
|
160591
|
+
}
|
|
159469
160592
|
listSources() {
|
|
159470
160593
|
return this.configuredSources().map((s) => {
|
|
159471
160594
|
let args = {};
|
|
@@ -159509,7 +160632,7 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159509
160632
|
args: this.typedArgs(mergeServiceArgs(service, restoreRedactedArgs(input.args, {}))),
|
|
159510
160633
|
enabled: input.enabled ?? true
|
|
159511
160634
|
});
|
|
159512
|
-
await this.
|
|
160635
|
+
await this.persistSources([...this.configuredSources(), row]);
|
|
159513
160636
|
return { id };
|
|
159514
160637
|
}
|
|
159515
160638
|
async updateSource(input) {
|
|
@@ -159545,7 +160668,7 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159545
160668
|
args: this.typedArgs(args),
|
|
159546
160669
|
enabled: input.enabled ?? prev.enabled
|
|
159547
160670
|
});
|
|
159548
|
-
await this.
|
|
160671
|
+
await this.persistSources(sources.map((s, i) => i === idx ? next : s));
|
|
159549
160672
|
return { ok: true };
|
|
159550
160673
|
}
|
|
159551
160674
|
/** Validate an argument bag against the typed value schema (a nested object is refused). */
|
|
@@ -159612,7 +160735,7 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159612
160735
|
remainingRaw: legacy.length
|
|
159613
160736
|
});
|
|
159614
160737
|
try {
|
|
159615
|
-
await this.
|
|
160738
|
+
await this.persistSources(migrated);
|
|
159616
160739
|
} catch {
|
|
159617
160740
|
return report({ failed: legacy.length });
|
|
159618
160741
|
}
|
|
@@ -159652,7 +160775,7 @@ var WasteCollectionsAddon = class extends BaseAddon {
|
|
|
159652
160775
|
async deleteSource(input) {
|
|
159653
160776
|
const sources = this.configuredSources();
|
|
159654
160777
|
if (!sources.some((s) => s.id === input.id)) throw new Error(`source '${input.id}' not found`);
|
|
159655
|
-
await this.
|
|
160778
|
+
await this.persistSources(sources.filter((s) => s.id !== input.id));
|
|
159656
160779
|
return { ok: true };
|
|
159657
160780
|
}
|
|
159658
160781
|
async fetchNow(input) {
|