@camstack/types 1.2.380 → 1.2.381

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-CIGOw58l.js");
2
+ const require_sleep = require("./sleep-D8yJVc4r.js");
3
3
  const require_event_category = require("./event-category-Hoe-mqbd.js");
4
4
  const require_composition = require("./composition-CUAOHZ38.js");
5
5
  const require_node_color = require("./node-color.js");
@@ -13949,30 +13949,6 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
13949
13949
  }
13950
13950
  };
13951
13951
  //#endregion
13952
- //#region src/capabilities/caller-stamp.ts
13953
- /**
13954
- * Every cap whose provider reads a `callerAddonId` in its input (the keychain's
13955
- * owner check, device-history's `not-owner`, records' owner).
13956
- *
13957
- * The stamp is set ONLY by the transport (`stampCallerAddonId`, or stated by a
13958
- * hub in-process caller). The generated HTTP/tRPC mount parses input with
13959
- * `.loose()`, so without this a session could add the key itself and act as
13960
- * another addon. The mount strips it for these caps.
13961
- */
13962
- var CALLER_STAMPED_CAPABILITIES = [
13963
- "keychain",
13964
- "device-history",
13965
- "records",
13966
- "integrations",
13967
- "device-manager"
13968
- ];
13969
- /** A copy of `input` without the caller stamp. Anything that is not a plain object passes through. */
13970
- function withoutCallerStamp(input) {
13971
- if (input === null || typeof input !== "object" || Array.isArray(input)) return input;
13972
- if (!Object.prototype.hasOwnProperty.call(input, "callerAddonId")) return input;
13973
- return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "callerAddonId"));
13974
- }
13975
- //#endregion
13976
13952
  //#region src/capabilities/records.cap.ts
13977
13953
  /**
13978
13954
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
@@ -14360,13 +14336,31 @@ var storageAdminCapability = {
14360
14336
  adoptRecords: require_sleep.method(zod.z.object({
14361
14337
  owner: zod.z.string().min(1),
14362
14338
  kind: require_sleep.RecordKindNameSchema,
14363
- records: zod.z.array(RecordInputSchema).min(1).max(require_sleep.RECORD_BATCH_MAX),
14339
+ records: zod.z.array(RecordInputSchema).max(require_sleep.RECORD_BATCH_MAX),
14364
14340
  /** The LAST batch: the copy is complete, the boot guard stops asking. */
14365
14341
  complete: zod.z.boolean().optional()
14366
- }), zod.z.object({ adopted: zod.z.number().int() }), {
14342
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), zod.z.object({ adopted: zod.z.number().int() }), {
14367
14343
  kind: "mutation",
14368
14344
  auth: "admin"
14369
- })
14345
+ }),
14346
+ /**
14347
+ * Read rows from a legacy KV table by physical name, without a running
14348
+ * `declareCollection`. Used by `records-adopt.ts` when the owner already
14349
+ * moved to records and the collection door refuses the name.
14350
+ */
14351
+ readLegacyCollection: require_sleep.method(zod.z.object({
14352
+ collection: zod.z.string().min(1),
14353
+ cursor: zod.z.string().optional(),
14354
+ limit: zod.z.number().int().min(1).max(1e3).optional()
14355
+ }), zod.z.object({
14356
+ rows: zod.z.array(zod.z.object({
14357
+ id: zod.z.string(),
14358
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
14359
+ })),
14360
+ nextCursor: zod.z.string().nullable()
14361
+ }), { auth: "admin" }),
14362
+ /** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
14363
+ isAdoptedLegacyTable: require_sleep.method(zod.z.object({ collection: zod.z.string().min(1) }), zod.z.object({ adopted: zod.z.boolean() }), { auth: "admin" })
14370
14364
  }
14371
14365
  };
14372
14366
  //#endregion
@@ -75230,13 +75224,14 @@ var BaseDevice = class {
75230
75224
  get state() {
75231
75225
  if (!this._stateProxyCache) {
75232
75226
  const cache = {};
75233
- const handler = { get: (_target, key) => {
75227
+ const handler = { get: (target, key) => {
75234
75228
  const k = key;
75235
- if (k in cache) return cache[k];
75229
+ const existing = Reflect.get(target, k);
75230
+ if (existing !== void 0) return existing;
75236
75231
  const cap = DEVICE_LOCAL_STATE_CAPS[k];
75237
75232
  if (!cap) return void 0;
75238
75233
  const proxy = this.sliceProxy(cap);
75239
- cache[k] = proxy;
75234
+ Reflect.set(target, k, proxy);
75240
75235
  return proxy;
75241
75236
  } };
75242
75237
  this._stateProxyCache = new Proxy(cache, handler);
@@ -75435,7 +75430,7 @@ var BaseDevice = class {
75435
75430
  async updateSourceInfo(patch) {
75436
75431
  const next = mergeSourceInfo(this.sourceInfo, patch);
75437
75432
  this._sourceInfoCache = Object.freeze({ ...next });
75438
- const action = this.ctx.api?.deviceManager?.setMetadata;
75433
+ const action = this.ctx.api.deviceManager?.setMetadata;
75439
75434
  if (action) try {
75440
75435
  await action.mutate({
75441
75436
  deviceId: this.id,
@@ -75470,7 +75465,7 @@ var BaseDevice = class {
75470
75465
  * device boot on a meta refresh.
75471
75466
  */
75472
75467
  async refreshFeatures() {
75473
- const action = this.ctx.api?.deviceManager?.registerDevice;
75468
+ const action = this.ctx.api.deviceManager?.registerDevice;
75474
75469
  if (!action) return;
75475
75470
  try {
75476
75471
  await action.mutate({
@@ -77035,6 +77030,12 @@ async function exposeBlockDevices(ctx, input) {
77035
77030
  }
77036
77031
  }
77037
77032
  //#endregion
77033
+ //#region src/device/device-context.ts
77034
+ /** Map entry helper — concrete camera/hub classes widen to `DeviceConstructor<IDevice>`. */
77035
+ function widenDeviceConstructor(ctor) {
77036
+ return ctor;
77037
+ }
77038
+ //#endregion
77038
77039
  //#region src/device/device-control-resolution.ts
77039
77040
  /**
77040
77041
  * Device-control RESOLUTION LOGIC — the single, presentation-free source of
@@ -83981,6 +83982,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
83981
83982
  addonId: null,
83982
83983
  access: "delete"
83983
83984
  },
83985
+ "storageAdmin.isAdoptedLegacyTable": {
83986
+ capName: "storage-admin",
83987
+ capScope: "system",
83988
+ addonId: null,
83989
+ access: "view"
83990
+ },
83984
83991
  "storageAdmin.listKinds": {
83985
83992
  capName: "storage-admin",
83986
83993
  capScope: "system",
@@ -83993,6 +84000,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
83993
84000
  addonId: null,
83994
84001
  access: "view"
83995
84002
  },
84003
+ "storageAdmin.readLegacyCollection": {
84004
+ capName: "storage-admin",
84005
+ capScope: "system",
84006
+ addonId: null,
84007
+ access: "view"
84008
+ },
83996
84009
  "storageAdmin.readRecords": {
83997
84010
  capName: "storage-admin",
83998
84011
  capScope: "system",
@@ -87266,9 +87279,10 @@ var SystemMirror = class {
87266
87279
  for (let i = 0; i < targets.length; i += parallelism) {
87267
87280
  const chunk = targets.slice(i, i + parallelism);
87268
87281
  const settled = await Promise.allSettled(chunk.map(async (proxy) => {
87269
- const cap = proxy[capName];
87270
- if (!cap || typeof cap[methodName] !== "function") throw new Error(`device '${proxy.deviceId}' does not expose '${capName}.${methodName}'`);
87271
- return await cap[methodName](args);
87282
+ const cap = Reflect.get(proxy, capName);
87283
+ const method = typeof cap === "object" && cap !== null ? Reflect.get(cap, methodName) : void 0;
87284
+ if (typeof method !== "function") throw new Error(`device '${proxy.deviceId}' does not expose '${capName}.${methodName}'`);
87285
+ return await Reflect.apply(method, cap, [args]);
87272
87286
  }));
87273
87287
  for (let j = 0; j < settled.length; j++) {
87274
87288
  const proxy = chunk[j];
@@ -87496,7 +87510,7 @@ function matchesString(haystack, match) {
87496
87510
  //#region src/device/zod-to-config-ui.ts
87497
87511
  /** Access Zod v4 internal .def — not in public typings but stable at runtime */
87498
87512
  function zodDef(schema) {
87499
- return schema.def;
87513
+ return Reflect.get(schema, "def");
87500
87514
  }
87501
87515
  /** Access internal properties on a Zod schema instance */
87502
87516
  function zodInternals(schema) {
@@ -92541,21 +92555,8 @@ var SCOPE_PRESETS = [
92541
92555
  * dropping the reference.
92542
92556
  */
92543
92557
  function createSystemProxy(api) {
92544
- const typedApi = api;
92545
- /**
92546
- * Invoke `api.<capProp>.<method>.{query|mutate|subscribe}(input)`.
92547
- * Returns `any` so the caller-side per-method declaration assigns
92548
- * cleanly into the strongly-typed `Pick<InferProvider<...>, ...>`
92549
- * shape on the `SystemProxy` interface — the proxy's contract is
92550
- * enforced by the interface, not the dispatch helper.
92551
- */
92552
92558
  function dispatch(capProp, method, kind, input, push) {
92553
- const leaf = typedApi[capProp]?.[method];
92554
- if (!leaf) throw new Error(`SystemProxy: api has no '${capProp}.${method}'`);
92555
- const fn = leaf;
92556
- if (kind === "mutation") return fn.mutate(input);
92557
- if (kind === "subscription") return fn.subscribe(input, push);
92558
- return fn.query(input);
92559
+ return require_sleep.invokeTrpcLeaf(api, capProp, method, kind, input, push);
92559
92560
  }
92560
92561
  return {
92561
92562
  addonPages: { listPages: (input) => dispatch("addonPages", "listPages", "query", input) },
@@ -101656,13 +101657,11 @@ function pointInPolygon(point, polygon) {
101656
101657
  */
101657
101658
  function bindAddonActions(api, addonId, catalog) {
101658
101659
  const out = {};
101659
- for (const action of Object.keys(catalog)) out[action] = (input) => {
101660
- return api.addons.custom.mutate({
101661
- addonId,
101662
- action,
101663
- input
101664
- });
101665
- };
101660
+ for (const action of Object.keys(catalog)) out[action] = (input) => api.addons.custom.mutate({
101661
+ addonId,
101662
+ action,
101663
+ input
101664
+ });
101666
101665
  return out;
101667
101666
  }
101668
101667
  //#endregion
@@ -102160,7 +102159,7 @@ exports.BrokerTestConnectionResultSchema = TestConnectionResultSchema;
102160
102159
  exports.BrokerUnsubscribeInputSchema = UnsubscribeInputSchema;
102161
102160
  exports.BucketAccumulator = BucketAccumulator;
102162
102161
  exports.BulkRecordSchema = BulkRecordSchema;
102163
- exports.CALLER_STAMPED_CAPABILITIES = CALLER_STAMPED_CAPABILITIES;
102162
+ exports.CALLER_STAMPED_CAPABILITIES = require_sleep.CALLER_STAMPED_CAPABILITIES;
102164
102163
  exports.CAMERA_SENSORS_NOT_LOADED = CAMERA_SENSORS_NOT_LOADED;
102165
102164
  exports.CAMERA_SENSORS_SETTINGS_KEY = CAMERA_SENSORS_SETTINGS_KEY;
102166
102165
  exports.CAMERA_SWITCH_CATALOG = CAMERA_SWITCH_CATALOG;
@@ -103532,6 +103531,8 @@ exports.SENSOR_MAP = SENSOR_MAP;
103532
103531
  exports.SERVER_NAME_MAX_LENGTH = SERVER_NAME_MAX_LENGTH;
103533
103532
  exports.SERVER_NAME_SETTING_KEY = SERVER_NAME_SETTING_KEY;
103534
103533
  exports.SESSION_PLACEMENT_SETTING_KEY = SESSION_PLACEMENT_SETTING_KEY;
103534
+ exports.SETTINGS_ARRAY_ADOPTS_PREFIX = require_sleep.SETTINGS_ARRAY_ADOPTS_PREFIX;
103535
+ exports.SETTINGS_BROKERS_ADOPTS_PREFIX = require_sleep.SETTINGS_BROKERS_ADOPTS_PREFIX;
103535
103536
  exports.SHARE_SOURCE_SETTING_KEY = SHARE_SOURCE_SETTING_KEY;
103536
103537
  exports.SHARE_VIEW_KINDS = require_sleep.SHARE_VIEW_KINDS;
103537
103538
  exports.SINGLE_HUB_ADDRESS_ROLES = SINGLE_HUB_ADDRESS_ROLES;
@@ -104061,6 +104062,8 @@ exports.defineCustomActions = require_sleep.defineCustomActions;
104061
104062
  exports.defineEntryKind = require_sleep.defineEntryKind;
104062
104063
  exports.defineExtensionSlotProvider = defineExtensionSlotProvider;
104063
104064
  exports.defineRecordKinds = require_sleep.defineRecordKinds;
104065
+ exports.dehydrateConfigField = require_sleep.dehydrateConfigField;
104066
+ exports.dehydrateSchema = require_sleep.dehydrateSchema;
104064
104067
  exports.deleteAlarmProfile = deleteAlarmProfile;
104065
104068
  exports.deriveBatteryPresence = deriveBatteryPresence;
104066
104069
  exports.deriveCameraSwitches = deriveCameraSwitches;
@@ -104322,6 +104325,7 @@ exports.logDestinationCapability = logDestinationCapability;
104322
104325
  exports.logLevelAtMost = logLevelAtMost;
104323
104326
  exports.loginMethodCapability = loginMethodCapability;
104324
104327
  exports.looseSchema = looseSchema;
104328
+ exports.makeInMemoryRecords = require_sleep.makeInMemoryRecords;
104325
104329
  exports.makeProfileBrokerId = require_sleep.makeProfileBrokerId;
104326
104330
  exports.makeSecretMarker = require_sleep.makeSecretMarker;
104327
104331
  exports.makeSourceBrokerId = require_sleep.makeSourceBrokerId;
@@ -104412,6 +104416,8 @@ exports.parseSecretPath = require_sleep.parseSecretPath;
104412
104416
  exports.parseSecretRef = require_sleep.parseSecretRef;
104413
104417
  exports.parseSecretStatePath = require_sleep.parseSecretStatePath;
104414
104418
  exports.parseSessionPlacementPolicy = parseSessionPlacementPolicy;
104419
+ exports.parseSettingsArrayAdoptsFrom = require_sleep.parseSettingsArrayAdoptsFrom;
104420
+ exports.parseSettingsBrokersAdoptsFrom = require_sleep.parseSettingsBrokersAdoptsFrom;
104415
104421
  exports.parseShareSource = parseShareSource;
104416
104422
  exports.parseStreamParamsFormPatch = parseStreamParamsFormPatch;
104417
104423
  exports.parseTrainingEventLine = parseTrainingEventLine;
@@ -104585,7 +104591,9 @@ exports.servedTemplateVars = servedTemplateVars;
104585
104591
  exports.serverManagementCapability = serverManagementCapability;
104586
104592
  exports.setByPath = setByPath;
104587
104593
  exports.settingValuesEqual = settingValuesEqual;
104594
+ exports.settingsArrayAdoptsFrom = require_sleep.settingsArrayAdoptsFrom;
104588
104595
  exports.settingsBelow = settingsBelow;
104596
+ exports.settingsBrokersAdoptsFrom = require_sleep.settingsBrokersAdoptsFrom;
104589
104597
  exports.settingsStoreCapability = settingsStoreCapability;
104590
104598
  exports.shortHostname = shortHostname;
104591
104599
  exports.shortSecretRefHash = require_sleep.shortSecretRefHash;
@@ -104699,6 +104707,7 @@ exports.webrtcSessionCapability = webrtcSessionCapability;
104699
104707
  exports.weeklyMaskIndex = weeklyMaskIndex;
104700
104708
  exports.weeklyMaskIsUniform = weeklyMaskIsUniform;
104701
104709
  exports.weeklyMaskToWindows = weeklyMaskToWindows;
104710
+ exports.widenDeviceConstructor = widenDeviceConstructor;
104702
104711
  exports.windowsToWeeklyMask = windowsToWeeklyMask;
104703
104712
  exports.wiringAddonHealthSchema = wiringAddonHealthSchema;
104704
104713
  exports.wiringHealthSnapshotSchema = wiringHealthSnapshotSchema;
@@ -104707,7 +104716,7 @@ exports.wiringProbeKindSchema = wiringProbeKindSchema;
104707
104716
  exports.wiringProbeResultSchema = wiringProbeResultSchema;
104708
104717
  exports.withFieldFrom = withFieldFrom;
104709
104718
  exports.withLocationMode = withLocationMode;
104710
- exports.withoutCallerStamp = withoutCallerStamp;
104719
+ exports.withoutCallerStamp = require_sleep.withoutCallerStamp;
104711
104720
  exports.withoutField = withoutField;
104712
104721
  exports.writeModelBoundSetting = writeModelBoundSetting;
104713
104722
  exports.zodEntriesToConfigUI = zodEntriesToConfigUI;