@camstack/addon-training 0.1.54 → 0.1.56

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.
Files changed (20) hide show
  1. package/dist/{MotionZonesSettings-DyDTHPys.mjs → MotionZonesSettings-W5TJMIhz.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-axajI4sK.mjs → PrivacyMaskSettings-8bCieYP4.mjs} +2 -2
  3. package/dist/{SceneMonitorEditor-BjLJsI6P.mjs → SceneMonitorEditor-hfbQKb07.mjs} +1 -1
  4. package/dist/_stub.js +2222 -2222
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-CTdPJIbP.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_training_page-DtB9ff7l.mjs} +4 -4
  6. package/dist/{_virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-bhLaA3pg.mjs → _virtual_mf___mfe_internal__addon_training_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CdZst5Eh.mjs} +1 -1
  7. package/dist/addon-training.css +1 -1
  8. package/dist/{dist-21g95f5X.js → dist-DYEQn1Ss.mjs} +437 -205
  9. package/dist/{dist-91Rnxphf.mjs → dist-DnFIVL4Y.js} +649 -23
  10. package/dist/{hostInit-CTK-hcBi.mjs → hostInit-Duj8IUS7.mjs} +3 -3
  11. package/dist/index.js +1 -1
  12. package/dist/orchestrator/training.addon.js +64 -104
  13. package/dist/orchestrator/training.addon.mjs +64 -104
  14. package/dist/{player-overlays-B4kmFVR9.mjs → player-overlays-DBfpI8h8.mjs} +1 -1
  15. package/dist/providers/modal/training-modal.addon.js +22 -1
  16. package/dist/providers/modal/training-modal.addon.mjs +19 -1
  17. package/dist/remoteEntry.js +1 -1
  18. package/dist/{responsive-9DT2DlLH.mjs → responsive-CVlns2k2.mjs} +1 -1
  19. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-Cui1iZ9z.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_training_page__remoteEntry_js-GR9ZahAF.mjs} +1 -1
  20. package/package.json +1 -1
@@ -1,4 +1,37 @@
1
- import "node:crypto";
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
+ key = keys[i];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
+ get: ((k) => from[k]).bind(null, key),
24
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
+ });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
+ require("node:crypto");
2
35
  //#region ../types/dist/event-category-BvOFi6PY.mjs
3
36
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
37
  EventCategory["SystemBoot"] = "system.boot";
@@ -4123,6 +4156,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4123
4156
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4124
4157
  json.type = "boolean";
4125
4158
  };
4159
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4160
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4161
+ };
4162
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4163
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4164
+ };
4126
4165
  var nullProcessor = (_schema, ctx, json, _params) => {
4127
4166
  if (ctx.target === "openapi-3.0") {
4128
4167
  json.type = "string";
@@ -4130,12 +4169,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4130
4169
  json.enum = [null];
4131
4170
  } else json.type = "null";
4132
4171
  };
4172
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4173
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4174
+ };
4133
4175
  var voidProcessor = (_schema, ctx, _json, _params) => {
4134
4176
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4135
4177
  };
4136
4178
  var neverProcessor = (_schema, _ctx, json, _params) => {
4137
4179
  json.not = {};
4138
4180
  };
4181
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4182
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4139
4183
  var dateProcessor = (_schema, ctx, _json, _params) => {
4140
4184
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4141
4185
  };
@@ -4167,12 +4211,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4167
4211
  json.enum = vals;
4168
4212
  }
4169
4213
  };
4214
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4215
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4216
+ };
4217
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4218
+ const _json = json;
4219
+ const pattern = schema._zod.pattern;
4220
+ if (!pattern) throw new Error("Pattern not found in template literal");
4221
+ _json.type = "string";
4222
+ _json.pattern = pattern.source;
4223
+ };
4224
+ var fileProcessor = (schema, _ctx, json, _params) => {
4225
+ const _json = json;
4226
+ const file = {
4227
+ type: "string",
4228
+ format: "binary",
4229
+ contentEncoding: "binary"
4230
+ };
4231
+ const { minimum, maximum, mime } = schema._zod.bag;
4232
+ if (minimum !== void 0) file.minLength = minimum;
4233
+ if (maximum !== void 0) file.maxLength = maximum;
4234
+ if (mime) if (mime.length === 1) {
4235
+ file.contentMediaType = mime[0];
4236
+ Object.assign(_json, file);
4237
+ } else {
4238
+ Object.assign(_json, file);
4239
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4240
+ }
4241
+ else Object.assign(_json, file);
4242
+ };
4243
+ var successProcessor = (_schema, _ctx, json, _params) => {
4244
+ json.type = "boolean";
4245
+ };
4170
4246
  var customProcessor = (_schema, ctx, _json, _params) => {
4171
4247
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4172
4248
  };
4249
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4250
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4251
+ };
4173
4252
  var transformProcessor = (_schema, ctx, _json, _params) => {
4174
4253
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4175
4254
  };
4255
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4256
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4257
+ };
4258
+ var setProcessor = (_schema, ctx, _json, _params) => {
4259
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4260
+ };
4176
4261
  var arrayProcessor = (schema, ctx, _json, params) => {
4177
4262
  const json = _json;
4178
4263
  const def = schema._zod.def;
@@ -4377,6 +4462,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4377
4462
  seen.ref = def.innerType;
4378
4463
  json.readOnly = true;
4379
4464
  };
4465
+ var promiseProcessor = (schema, ctx, _json, params) => {
4466
+ const def = schema._zod.def;
4467
+ process(def.innerType, ctx, params);
4468
+ const seen = ctx.seen.get(schema);
4469
+ seen.ref = def.innerType;
4470
+ };
4380
4471
  var optionalProcessor = (schema, ctx, _json, params) => {
4381
4472
  const def = schema._zod.def;
4382
4473
  process(def.innerType, ctx, params);
@@ -4389,6 +4480,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4389
4480
  const seen = ctx.seen.get(schema);
4390
4481
  seen.ref = innerType;
4391
4482
  };
4483
+ var allProcessors = {
4484
+ string: stringProcessor,
4485
+ number: numberProcessor,
4486
+ boolean: booleanProcessor,
4487
+ bigint: bigintProcessor,
4488
+ symbol: symbolProcessor,
4489
+ null: nullProcessor,
4490
+ undefined: undefinedProcessor,
4491
+ void: voidProcessor,
4492
+ never: neverProcessor,
4493
+ any: anyProcessor,
4494
+ unknown: unknownProcessor,
4495
+ date: dateProcessor,
4496
+ enum: enumProcessor,
4497
+ literal: literalProcessor,
4498
+ nan: nanProcessor,
4499
+ template_literal: templateLiteralProcessor,
4500
+ file: fileProcessor,
4501
+ success: successProcessor,
4502
+ custom: customProcessor,
4503
+ function: functionProcessor,
4504
+ transform: transformProcessor,
4505
+ map: mapProcessor,
4506
+ set: setProcessor,
4507
+ array: arrayProcessor,
4508
+ object: objectProcessor,
4509
+ union: unionProcessor,
4510
+ intersection: intersectionProcessor,
4511
+ tuple: tupleProcessor,
4512
+ record: recordProcessor,
4513
+ nullable: nullableProcessor,
4514
+ nonoptional: nonoptionalProcessor,
4515
+ default: defaultProcessor,
4516
+ prefault: prefaultProcessor,
4517
+ catch: catchProcessor,
4518
+ pipe: pipeProcessor,
4519
+ readonly: readonlyProcessor,
4520
+ promise: promiseProcessor,
4521
+ optional: optionalProcessor,
4522
+ lazy: lazyProcessor
4523
+ };
4524
+ function toJSONSchema(input, params) {
4525
+ if ("_idmap" in input) {
4526
+ const registry = input;
4527
+ const ctx = initializeContext({
4528
+ ...params,
4529
+ processors: allProcessors
4530
+ });
4531
+ const defs = {};
4532
+ for (const entry of registry._idmap.entries()) {
4533
+ const [_, schema] = entry;
4534
+ process(schema, ctx);
4535
+ }
4536
+ const schemas = {};
4537
+ ctx.external = {
4538
+ registry,
4539
+ uri: params?.uri,
4540
+ defs
4541
+ };
4542
+ for (const entry of registry._idmap.entries()) {
4543
+ const [key, schema] = entry;
4544
+ extractDefs(ctx, schema);
4545
+ schemas[key] = finalize(ctx, schema);
4546
+ }
4547
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4548
+ return { schemas };
4549
+ }
4550
+ const ctx = initializeContext({
4551
+ ...params,
4552
+ processors: allProcessors
4553
+ });
4554
+ process(input, ctx);
4555
+ extractDefs(ctx, input);
4556
+ return finalize(ctx, input);
4557
+ }
4392
4558
  //#endregion
4393
4559
  //#region ../../node_modules/zod/v4/classic/iso.js
4394
4560
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5405,7 +5571,7 @@ var ZodIssueCode = {
5405
5571
  var ZodFirstPartyTypeKind;
5406
5572
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5407
5573
  //#endregion
5408
- //#region ../types/dist/sleep-WsrozGDL.mjs
5574
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
5409
5575
  /**
5410
5576
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5411
5577
  * window to float samples (D455).
@@ -5522,7 +5688,7 @@ function isKeychainStoredField(field) {
5522
5688
  var SECRET_CLEAR = { $secretClear: true };
5523
5689
  /** The `'***'` token D634 redaction writes for non-admins. */
5524
5690
  var LEGACY_DEVICE_REDACTION = "***";
5525
- function isRecord$4(value) {
5691
+ function isRecord$5(value) {
5526
5692
  return typeof value === "object" && value !== null && !Array.isArray(value);
5527
5693
  }
5528
5694
  function makeSecretMarker(ref) {
@@ -5533,12 +5699,12 @@ function makeSecretMarker(ref) {
5533
5699
  }
5534
5700
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5535
5701
  function isSecretMarker(value) {
5536
- if (!isRecord$4(value)) return false;
5702
+ if (!isRecord$5(value)) return false;
5537
5703
  const ref = value["$secret"];
5538
5704
  return typeof ref === "string" && ref.length > 0;
5539
5705
  }
5540
5706
  function isSecretClear(value) {
5541
- return isRecord$4(value) && value["$secretClear"] === true;
5707
+ return isRecord$5(value) && value["$secretClear"] === true;
5542
5708
  }
5543
5709
  /**
5544
5710
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6148,7 +6314,7 @@ var KeychainWriteRefusedError = class extends Error {
6148
6314
  }
6149
6315
  };
6150
6316
  var KEEP = { kind: "keep" };
6151
- function isRecord$3(value) {
6317
+ function isRecord$4(value) {
6152
6318
  return typeof value === "object" && value !== null && !Array.isArray(value);
6153
6319
  }
6154
6320
  function defaultMintId() {
@@ -6161,7 +6327,7 @@ function collectSecretMarkerRefs(value, out = []) {
6161
6327
  return out;
6162
6328
  }
6163
6329
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6164
- else if (isRecord$3(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6330
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6165
6331
  return out;
6166
6332
  }
6167
6333
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6216,7 +6382,7 @@ function rowId(row, idKey) {
6216
6382
  return null;
6217
6383
  }
6218
6384
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6219
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$3) : [];
6385
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6220
6386
  if (!Array.isArray(incoming)) {
6221
6387
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6222
6388
  return {
@@ -6232,7 +6398,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6232
6398
  const kept = /* @__PURE__ */ new Set();
6233
6399
  const rows = [];
6234
6400
  for (const row of incoming) {
6235
- if (!isRecord$3(row)) {
6401
+ if (!isRecord$4(row)) {
6236
6402
  rows.push(row);
6237
6403
  continue;
6238
6404
  }
@@ -6257,7 +6423,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6257
6423
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6258
6424
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6259
6425
  case "object": {
6260
- if (!isRecord$3(incoming)) {
6426
+ if (!isRecord$4(incoming)) {
6261
6427
  if (incoming === void 0) return KEEP;
6262
6428
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6263
6429
  return {
@@ -6265,7 +6431,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6265
6431
  value: incoming
6266
6432
  };
6267
6433
  }
6268
- const storedObj = isRecord$3(stored) ? stored : {};
6434
+ const storedObj = isRecord$4(stored) ? stored : {};
6269
6435
  return {
6270
6436
  kind: "value",
6271
6437
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6388,7 +6554,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6388
6554
  value: items
6389
6555
  };
6390
6556
  }
6391
- if (isRecord$3(v)) {
6557
+ if (isRecord$4(v)) {
6392
6558
  const out = {};
6393
6559
  for (const [k, child] of Object.entries(v)) {
6394
6560
  const s = substitute(child);
@@ -6420,7 +6586,7 @@ var SecretOverwriteRefusedError = class extends Error {
6420
6586
  this.name = "SecretOverwriteRefusedError";
6421
6587
  }
6422
6588
  };
6423
- function isRecord$2(value) {
6589
+ function isRecord$3(value) {
6424
6590
  return typeof value === "object" && value !== null && !Array.isArray(value);
6425
6591
  }
6426
6592
  function resolvedValue(pass, marker) {
@@ -6449,7 +6615,7 @@ function inArray(pass, incoming, stored) {
6449
6615
  return incoming.map((item, index) => {
6450
6616
  const twin = stored[index];
6451
6617
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6452
- if (isRecord$2(item) && isRecord$2(twin)) return inArrayRow(pass, item, twin);
6618
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6453
6619
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6454
6620
  return item;
6455
6621
  });
@@ -6460,7 +6626,7 @@ function inArrayRow(pass, incoming, stored) {
6460
6626
  const twin = stored[key];
6461
6627
  if (isSecretMarker(twin)) {
6462
6628
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6463
- } else if (isRecord$2(value) && isRecord$2(twin)) out[key] = inArrayRow(pass, value, twin);
6629
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6464
6630
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6465
6631
  }
6466
6632
  return out;
@@ -6468,7 +6634,7 @@ function inArrayRow(pass, incoming, stored) {
6468
6634
  async function walk(pass, incoming, stored) {
6469
6635
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6470
6636
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6471
- if (!isRecord$2(incoming) || !isRecord$2(stored)) return incoming;
6637
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6472
6638
  const out = { ...incoming };
6473
6639
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6474
6640
  return out;
@@ -6499,7 +6665,7 @@ async function restoreUnchangedSecrets(input) {
6499
6665
  function isJsonEqual(a, b) {
6500
6666
  if (Object.is(a, b)) return true;
6501
6667
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6502
- if (isRecord$2(a) && isRecord$2(b)) {
6668
+ if (isRecord$3(a) && isRecord$3(b)) {
6503
6669
  const keys = Object.keys(a);
6504
6670
  if (keys.length !== Object.keys(b).length) return false;
6505
6671
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -6523,7 +6689,7 @@ function markerKeysOf(blob, owner) {
6523
6689
  }
6524
6690
  function nodeFromStored(value, owner) {
6525
6691
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6526
- if (!isRecord$2(value)) return null;
6692
+ if (!isRecord$3(value)) return null;
6527
6693
  const children = /* @__PURE__ */ new Map();
6528
6694
  for (const [key, child] of Object.entries(value)) {
6529
6695
  const node = nodeFromStored(child, owner);
@@ -7311,7 +7477,7 @@ var BaseAddon = class {
7311
7477
  if (!ctx) return;
7312
7478
  const addonId = ctx.id;
7313
7479
  setImmediate(() => {
7314
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7480
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7315
7481
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7316
7482
  }).catch((err) => {
7317
7483
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7820,6 +7986,136 @@ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7820
7986
  var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7821
7987
  var RECORD_BATCH_MAX = 1e3;
7822
7988
  var RECORD_QUERY_MAX = 1e3;
7989
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7990
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7991
+ var PREFIX = "records/";
7992
+ /** The base of every records failure. `detail` is the human part of the message. */
7993
+ var RecordsError = class extends Error {
7994
+ code;
7995
+ detail;
7996
+ constructor(code, detail) {
7997
+ super(`${PREFIX}${code}: ${detail}`);
7998
+ this.name = "RecordsError";
7999
+ this.code = code;
8000
+ this.detail = detail;
8001
+ }
8002
+ };
8003
+ var InvalidRecordError = class extends RecordsError {
8004
+ constructor(detail) {
8005
+ super("invalid-record", detail);
8006
+ this.name = "InvalidRecordError";
8007
+ }
8008
+ };
8009
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8010
+ var DeclarationRefusedError = class extends RecordsError {
8011
+ constructor(detail) {
8012
+ super("declaration-refused", detail);
8013
+ this.name = "DeclarationRefusedError";
8014
+ }
8015
+ };
8016
+ function defOf(schema) {
8017
+ const zodBag = Reflect.get(schema, "_zod");
8018
+ if (typeof zodBag !== "object" || zodBag === null) return {};
8019
+ const def = Reflect.get(zodBag, "def");
8020
+ if (typeof def !== "object" || def === null) return {};
8021
+ return def;
8022
+ }
8023
+ function declaredHere(schema) {
8024
+ return globalRegistry.get(schema)?.secret === true;
8025
+ }
8026
+ /** Wrapper kinds whose `innerType` is the field itself. */
8027
+ var WRAPPERS = new Set([
8028
+ "optional",
8029
+ "nullable",
8030
+ "default",
8031
+ "prefault",
8032
+ "catch",
8033
+ "readonly",
8034
+ "nonoptional"
8035
+ ]);
8036
+ /**
8037
+ * The schema layers that make up ONE field: the schema itself and every
8038
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8039
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8040
+ * `.transform` on `in`).
8041
+ */
8042
+ function layersOf(schema) {
8043
+ const out = [];
8044
+ const queue = [schema];
8045
+ while (queue.length > 0) {
8046
+ const s = queue.shift();
8047
+ if (!s || out.includes(s)) continue;
8048
+ out.push(s);
8049
+ const def = defOf(s);
8050
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8051
+ if (def.type === "pipe") {
8052
+ if (def.in) queue.push(def.in);
8053
+ if (def.out) queue.push(def.out);
8054
+ }
8055
+ }
8056
+ return out;
8057
+ }
8058
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8059
+ function isZodSecret(schema) {
8060
+ return layersOf(schema).some(declaredHere);
8061
+ }
8062
+ /**
8063
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8064
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8065
+ * object or array is reported as one path and not descended into — everything
8066
+ * under it is secret.
8067
+ */
8068
+ function collectZodSecretPaths(schema, prefix = "") {
8069
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8070
+ const paths = [];
8071
+ for (const layer of layersOf(schema)) {
8072
+ const def = defOf(layer);
8073
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8074
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8075
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8076
+ else if (def.type === "intersection") {
8077
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8078
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8079
+ }
8080
+ }
8081
+ return [...new Set(paths)];
8082
+ }
8083
+ /**
8084
+ * Secret fields of a record, addressed the way a Zod schema declares them
8085
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8086
+ * (`auth.accessToken`, `headers[].value`).
8087
+ *
8088
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8089
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8090
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8091
+ * leaf names its element: `headers[X-Api].value`.
8092
+ *
8093
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8094
+ */
8095
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8096
+ function parseSecretPath(path) {
8097
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8098
+ return path.split(".").map((raw) => {
8099
+ const each = raw.endsWith("[]");
8100
+ const key = each ? raw.slice(0, -2) : raw;
8101
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8102
+ return {
8103
+ key,
8104
+ each
8105
+ };
8106
+ });
8107
+ }
8108
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8109
+ function secretArrayPrefixes(path) {
8110
+ const segments = parseSecretPath(path);
8111
+ const prefixes = [];
8112
+ const walked = [];
8113
+ for (const segment of segments) {
8114
+ walked.push(segment.key);
8115
+ if (segment.each) prefixes.push(walked.join("."));
8116
+ }
8117
+ return prefixes;
8118
+ }
7823
8119
  /**
7824
8120
  * Record kinds (D881): the declaration an addon makes of one kind of fact, the
7825
8121
  * Zod row schema that describes it, and the helper that turns the two into the
@@ -7888,6 +8184,135 @@ var RecordKindDeclarationSchema = object({
7888
8184
  }).strict();
7889
8185
  /** The kind names: lower-case, dash separated, short enough for an index name. */
7890
8186
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8187
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8188
+ function assertValidDeclaration(name, decl) {
8189
+ const refuse = (why) => {
8190
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8191
+ };
8192
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8193
+ const seen = /* @__PURE__ */ new Set();
8194
+ for (const index of decl.indexes) {
8195
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8196
+ seen.add(index.name);
8197
+ }
8198
+ const { retention } = decl;
8199
+ const hasSecrets = decl.secretPaths.length > 0;
8200
+ if ("ttlMs" in retention) {
8201
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8202
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8203
+ }
8204
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8205
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8206
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8207
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8208
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8209
+ 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)`);
8210
+ }
8211
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8212
+ 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`);
8213
+ }
8214
+ function bodyFieldsOf(schema) {
8215
+ return { ...toJSONSchema(schema, {
8216
+ unrepresentable: "any",
8217
+ io: "input"
8218
+ }) };
8219
+ }
8220
+ function isRecordLike(value) {
8221
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8222
+ }
8223
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8224
+ function hasNameField(json, field) {
8225
+ const branches = json["oneOf"] ?? json["anyOf"];
8226
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8227
+ const properties = json["properties"];
8228
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8229
+ }
8230
+ /**
8231
+ * Declare the kinds of a package. The keys are the kind names. The result is
8232
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8233
+ * types its handle from.
8234
+ */
8235
+ function defineRecordKinds(specs) {
8236
+ const out = {};
8237
+ for (const [name, spec] of Object.entries(specs)) {
8238
+ const secretPaths = collectZodSecretPaths(spec.schema);
8239
+ const nameField = spec.entry?.nameField ?? "name";
8240
+ const fields = bodyFieldsOf(spec.schema);
8241
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8242
+ const parsed = RecordKindDeclarationSchema.parse({
8243
+ database: spec.database,
8244
+ class: spec.class,
8245
+ writeTrigger: spec.writeTrigger,
8246
+ device: spec.device,
8247
+ at: spec.at,
8248
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8249
+ retention: spec.retention,
8250
+ deviceRemoval: spec.deviceRemoval,
8251
+ maxDataBytes: spec.maxDataBytes,
8252
+ secretPaths: [...secretPaths],
8253
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8254
+ adoptsFrom: spec.adoptsFrom,
8255
+ transactFamily: spec.transactFamily,
8256
+ entry: spec.entry === void 0 ? void 0 : {
8257
+ title: spec.entry.title,
8258
+ nameField,
8259
+ fields
8260
+ }
8261
+ });
8262
+ assertValidDeclaration(name, parsed);
8263
+ out[name] = {
8264
+ name,
8265
+ schema: spec.schema,
8266
+ declaration: parsed
8267
+ };
8268
+ }
8269
+ return out;
8270
+ }
8271
+ /**
8272
+ * Entry kinds (D881): every list of user-created entries (notification
8273
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8274
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8275
+ * through the `record-entries` capability with password fields derived from
8276
+ * the schema (`.meta({ secret: true })`).
8277
+ */
8278
+ /** The body of a plain entry: a name and the fields the kind adds. */
8279
+ function entryBody(shape) {
8280
+ return object({
8281
+ name: string().min(1),
8282
+ ...shape
8283
+ });
8284
+ }
8285
+ /**
8286
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8287
+ * engine, never aged, belonging to no device.
8288
+ */
8289
+ function defineEntryKind(name, spec) {
8290
+ const defined = defineRecordKinds({ [name]: {
8291
+ schema: spec.schema,
8292
+ class: "config",
8293
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8294
+ retention: { none: "an entry goes only when the operator deletes it" },
8295
+ ...spec.database === void 0 ? {} : { database: spec.database },
8296
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8297
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8298
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8299
+ entry: {
8300
+ title: spec.title,
8301
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8302
+ }
8303
+ } })[name];
8304
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8305
+ return defined;
8306
+ }
8307
+ /**
8308
+ * Legacy source for entry adoption (B3): a list stored under addon-settings
8309
+ * `<addonId>.<key>` until records-adopt copies rows into the entry kind.
8310
+ */
8311
+ var SETTINGS_ARRAY_ADOPTS_PREFIX = "@settings-array/";
8312
+ /** The `adoptsFrom` value for an addon-settings array field. */
8313
+ function settingsArrayAdoptsFrom(addonId, settingsKey) {
8314
+ return `${SETTINGS_ARRAY_ADOPTS_PREFIX}${addonId}/${settingsKey}`;
8315
+ }
7891
8316
  /** Shared Zod schemas used across streaming capabilities. */
7892
8317
  var CamProfileSchema = _enum([
7893
8318
  "high",
@@ -16356,13 +16781,23 @@ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: arr
16356
16781
  }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16357
16782
  owner: string().min(1),
16358
16783
  kind: RecordKindNameSchema,
16359
- records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX),
16784
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16360
16785
  /** The LAST batch: the copy is complete, the boot guard stops asking. */
16361
16786
  complete: boolean().optional()
16362
- }), object({ adopted: number().int() }), {
16787
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16363
16788
  kind: "mutation",
16364
16789
  auth: "admin"
16365
- });
16790
+ }), method(object({
16791
+ collection: string().min(1),
16792
+ cursor: string().optional(),
16793
+ limit: number().int().min(1).max(1e3).optional()
16794
+ }), object({
16795
+ rows: array(object({
16796
+ id: string(),
16797
+ data: record(string(), unknown())
16798
+ })),
16799
+ nextCursor: string().nullable()
16800
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16366
16801
  /**
16367
16802
  * record-entries - the ONE admin surface for every list of user-created entries
16368
16803
  * (D881): notification targets, brokers, LLM profiles, anything an addon
@@ -68434,6 +68869,12 @@ Object.freeze({
68434
68869
  addonId: null,
68435
68870
  access: "delete"
68436
68871
  },
68872
+ "storageAdmin.isAdoptedLegacyTable": {
68873
+ capName: "storage-admin",
68874
+ capScope: "system",
68875
+ addonId: null,
68876
+ access: "view"
68877
+ },
68437
68878
  "storageAdmin.listKinds": {
68438
68879
  capName: "storage-admin",
68439
68880
  capScope: "system",
@@ -68446,6 +68887,12 @@ Object.freeze({
68446
68887
  addonId: null,
68447
68888
  access: "view"
68448
68889
  },
68890
+ "storageAdmin.readLegacyCollection": {
68891
+ capName: "storage-admin",
68892
+ capScope: "system",
68893
+ addonId: null,
68894
+ access: "view"
68895
+ },
68449
68896
  "storageAdmin.readRecords": {
68450
68897
  capName: "storage-admin",
68451
68898
  capScope: "system",
@@ -73654,4 +74101,183 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
73654
74101
  var MB = 1024 * 1024;
73655
74102
  1024 * MB, 3072 * MB;
73656
74103
  //#endregion
73657
- export { number as _, addonPagesSourceCapability as a, string as b, trainingProviderCapability as c, arrayItemFieldPath as d, globalSecretScope as f, boolean as g, toSecretFieldView as h, TrainingResultSchema as i, BaseAddon as l, isSecretMarker as m, TrainingJobSchema as n, parseTrainingEventLine as o, isSecretClear as p, TrainingJobSpecSchema as r, trainingCapability as s, TRAINING_JOB_SCHEMA as t, SECRET_CLEAR as u, object as v, record as y };
74104
+ Object.defineProperty(exports, "BaseAddon", {
74105
+ enumerable: true,
74106
+ get: function() {
74107
+ return BaseAddon;
74108
+ }
74109
+ });
74110
+ Object.defineProperty(exports, "RECORD_MAX_DATA_BYTES", {
74111
+ enumerable: true,
74112
+ get: function() {
74113
+ return RECORD_MAX_DATA_BYTES;
74114
+ }
74115
+ });
74116
+ Object.defineProperty(exports, "SECRET_CLEAR", {
74117
+ enumerable: true,
74118
+ get: function() {
74119
+ return SECRET_CLEAR;
74120
+ }
74121
+ });
74122
+ Object.defineProperty(exports, "TRAINING_JOB_SCHEMA", {
74123
+ enumerable: true,
74124
+ get: function() {
74125
+ return TRAINING_JOB_SCHEMA;
74126
+ }
74127
+ });
74128
+ Object.defineProperty(exports, "TrainingJobSchema", {
74129
+ enumerable: true,
74130
+ get: function() {
74131
+ return TrainingJobSchema;
74132
+ }
74133
+ });
74134
+ Object.defineProperty(exports, "TrainingJobSpecSchema", {
74135
+ enumerable: true,
74136
+ get: function() {
74137
+ return TrainingJobSpecSchema;
74138
+ }
74139
+ });
74140
+ Object.defineProperty(exports, "TrainingResultSchema", {
74141
+ enumerable: true,
74142
+ get: function() {
74143
+ return TrainingResultSchema;
74144
+ }
74145
+ });
74146
+ Object.defineProperty(exports, "__commonJSMin", {
74147
+ enumerable: true,
74148
+ get: function() {
74149
+ return __commonJSMin;
74150
+ }
74151
+ });
74152
+ Object.defineProperty(exports, "__esmMin", {
74153
+ enumerable: true,
74154
+ get: function() {
74155
+ return __esmMin;
74156
+ }
74157
+ });
74158
+ Object.defineProperty(exports, "__exportAll", {
74159
+ enumerable: true,
74160
+ get: function() {
74161
+ return __exportAll;
74162
+ }
74163
+ });
74164
+ Object.defineProperty(exports, "__toCommonJS", {
74165
+ enumerable: true,
74166
+ get: function() {
74167
+ return __toCommonJS;
74168
+ }
74169
+ });
74170
+ Object.defineProperty(exports, "__toESM", {
74171
+ enumerable: true,
74172
+ get: function() {
74173
+ return __toESM;
74174
+ }
74175
+ });
74176
+ Object.defineProperty(exports, "addonPagesSourceCapability", {
74177
+ enumerable: true,
74178
+ get: function() {
74179
+ return addonPagesSourceCapability;
74180
+ }
74181
+ });
74182
+ Object.defineProperty(exports, "arrayItemFieldPath", {
74183
+ enumerable: true,
74184
+ get: function() {
74185
+ return arrayItemFieldPath;
74186
+ }
74187
+ });
74188
+ Object.defineProperty(exports, "boolean", {
74189
+ enumerable: true,
74190
+ get: function() {
74191
+ return boolean;
74192
+ }
74193
+ });
74194
+ Object.defineProperty(exports, "defineEntryKind", {
74195
+ enumerable: true,
74196
+ get: function() {
74197
+ return defineEntryKind;
74198
+ }
74199
+ });
74200
+ Object.defineProperty(exports, "defineRecordKinds", {
74201
+ enumerable: true,
74202
+ get: function() {
74203
+ return defineRecordKinds;
74204
+ }
74205
+ });
74206
+ Object.defineProperty(exports, "entryBody", {
74207
+ enumerable: true,
74208
+ get: function() {
74209
+ return entryBody;
74210
+ }
74211
+ });
74212
+ Object.defineProperty(exports, "globalSecretScope", {
74213
+ enumerable: true,
74214
+ get: function() {
74215
+ return globalSecretScope;
74216
+ }
74217
+ });
74218
+ Object.defineProperty(exports, "isSecretClear", {
74219
+ enumerable: true,
74220
+ get: function() {
74221
+ return isSecretClear;
74222
+ }
74223
+ });
74224
+ Object.defineProperty(exports, "isSecretMarker", {
74225
+ enumerable: true,
74226
+ get: function() {
74227
+ return isSecretMarker;
74228
+ }
74229
+ });
74230
+ Object.defineProperty(exports, "number", {
74231
+ enumerable: true,
74232
+ get: function() {
74233
+ return number;
74234
+ }
74235
+ });
74236
+ Object.defineProperty(exports, "object", {
74237
+ enumerable: true,
74238
+ get: function() {
74239
+ return object;
74240
+ }
74241
+ });
74242
+ Object.defineProperty(exports, "parseTrainingEventLine", {
74243
+ enumerable: true,
74244
+ get: function() {
74245
+ return parseTrainingEventLine;
74246
+ }
74247
+ });
74248
+ Object.defineProperty(exports, "record", {
74249
+ enumerable: true,
74250
+ get: function() {
74251
+ return record;
74252
+ }
74253
+ });
74254
+ Object.defineProperty(exports, "settingsArrayAdoptsFrom", {
74255
+ enumerable: true,
74256
+ get: function() {
74257
+ return settingsArrayAdoptsFrom;
74258
+ }
74259
+ });
74260
+ Object.defineProperty(exports, "string", {
74261
+ enumerable: true,
74262
+ get: function() {
74263
+ return string;
74264
+ }
74265
+ });
74266
+ Object.defineProperty(exports, "toSecretFieldView", {
74267
+ enumerable: true,
74268
+ get: function() {
74269
+ return toSecretFieldView;
74270
+ }
74271
+ });
74272
+ Object.defineProperty(exports, "trainingCapability", {
74273
+ enumerable: true,
74274
+ get: function() {
74275
+ return trainingCapability;
74276
+ }
74277
+ });
74278
+ Object.defineProperty(exports, "trainingProviderCapability", {
74279
+ enumerable: true,
74280
+ get: function() {
74281
+ return trainingProviderCapability;
74282
+ }
74283
+ });