@camstack/types 1.2.592 → 1.2.593

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-D2Ny6tvi.js");
2
+ const require_sleep = require("./sleep-BOK28JE0.js");
3
3
  const require_event_category = require("./event-category-BKxXXxnV.js");
4
4
  const require_composed_stable_id = require("./composed-stable-id-BdeYe5dD.js");
5
5
  const require_implemented_methods = require("./implemented-methods-BarLh7tc.js");
@@ -60182,6 +60182,116 @@ onChanged: require_sleep.event(zod.z.object({
60182
60182
  vocabulary: { notOperatorFacing: "the runtime-state mirror every trigger already reads through" }
60183
60183
  };
60184
60184
  //#endregion
60185
+ //#region src/device/state-refresh.ts
60186
+ /**
60187
+ * Server-driven device state refresh (D1062): the core decides WHEN a device is
60188
+ * re-read, the integration only knows HOW.
60189
+ *
60190
+ * A provider states its policy where it registers the device's
60191
+ * `device-state-refresh` cap (`ctx.registerNativeCap(cap, provider, {
60192
+ * stateRefresh })`). It reaches the hub by the road the command-hold options
60193
+ * take (D1061): written directly in-process, carried on a forked child's cap
60194
+ * descriptors otherwise. Plain data, wire-safe.
60195
+ */
60196
+ /** Why the core asks for a refresh. */
60197
+ var StateRefreshReasonSchema = zod.z.enum([
60198
+ "schedule",
60199
+ "command",
60200
+ "burst"
60201
+ ]);
60202
+ /**
60203
+ * What arrives without asking: `none` (everything is read), `partial` (some
60204
+ * fields arrive by push, the rest is read on the schedule), `full` (everything
60205
+ * arrives by push — never read on a schedule).
60206
+ */
60207
+ var StateRefreshPushSchema = zod.z.enum([
60208
+ "none",
60209
+ "partial",
60210
+ "full"
60211
+ ]);
60212
+ /** The fastest base cadence the core accepts from any provider. */
60213
+ var MIN_STATE_REFRESH_INTERVAL_MS = 1e3;
60214
+ var StateRefreshPolicySchema = zod.z.object({
60215
+ /**
60216
+ * The integration instance the device belongs to. Devices of one instance
60217
+ * share one schedule group: a batching provider is asked once for all of
60218
+ * them, and the heartbeat is judged across them.
60219
+ */
60220
+ integrationId: zod.z.string().min(1),
60221
+ /** The fastest interval the integration can afford for its devices. The core polls at it by default. */
60222
+ minIntervalMs: zod.z.number().int().min(MIN_STATE_REFRESH_INTERVAL_MS),
60223
+ /**
60224
+ * The operator's per-integration setting, when there is one. It can only SLOW
60225
+ * the cadence: the core polls at `max(minIntervalMs, intervalMs)`.
60226
+ */
60227
+ intervalMs: zod.z.number().int().positive().optional(),
60228
+ /** One `refresh` call can read every device of the integration at once. */
60229
+ batch: zod.z.boolean(),
60230
+ push: StateRefreshPushSchema,
60231
+ /** Longest silence a push integration may keep before the core re-reads it and asks it to resubscribe. */
60232
+ heartbeatMs: zod.z.number().int().positive().optional(),
60233
+ /**
60234
+ * Bumped by the provider each time its push subscription reconnected on its
60235
+ * own. A change makes the core re-read every device of the integration
60236
+ * (pushes lost while it was down; events may be dropped, D8).
60237
+ */
60238
+ connectionEpoch: zod.z.number().int().nonnegative().optional()
60239
+ });
60240
+ /** The cadence the core runs a policy at: the declared minimum, slowed (never sped up) by the setting. */
60241
+ function effectiveRefreshIntervalMs(policy) {
60242
+ const setting = policy.intervalMs ?? 0;
60243
+ return Math.max(policy.minIntervalMs, setting);
60244
+ }
60245
+ /** The burst after a command on a read (non-push) device: offsets from the command, in ms. */
60246
+ var COMMAND_BURST_OFFSETS_MS = [3e3, 1e4];
60247
+ /** How long the core waits for a push device to confirm a command before reading it once. */
60248
+ var PUSH_CONFIRM_WINDOW_MS = 2500;
60249
+ //#endregion
60250
+ //#region src/capabilities/device-state-refresh.cap.ts
60251
+ /**
60252
+ * device-state-refresh — the HOW of a device's state refresh, called by the
60253
+ * core, which owns the WHEN (D1062).
60254
+ *
60255
+ * The provider registers it per device with its policy
60256
+ * (`registerNativeCap(cap, provider, { stateRefresh })`). The hub's scheduler
60257
+ * calls `refresh` on the schedule, after a command and in the burst that
60258
+ * follows it, and `resubscribe` when a push integration fell silent. The
60259
+ * provider re-reads and writes the slices it already writes; nothing is
60260
+ * returned but completion.
60261
+ */
60262
+ var DeviceStateRefreshInputSchema = zod.z.object({
60263
+ /** The device the call is routed by (one of `deviceIds`). */
60264
+ deviceId: zod.z.number().int().nonnegative(),
60265
+ /** Every device to re-read: one, or the integration's whole set when the provider batches. */
60266
+ deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1),
60267
+ reason: StateRefreshReasonSchema
60268
+ });
60269
+ var DeviceStateResubscribeInputSchema = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
60270
+ var DeviceStateRefreshResultSchema = zod.z.object({ ok: zod.z.literal(true) });
60271
+ var NOT_OPERATOR_FACING = "the core schedules state refreshes itself; an operator never asks for one";
60272
+ var deviceStateRefreshCapability = {
60273
+ name: "device-state-refresh",
60274
+ scope: "device",
60275
+ deviceNative: true,
60276
+ mode: "singleton",
60277
+ methods: {
60278
+ refresh: require_sleep.method(DeviceStateRefreshInputSchema, DeviceStateRefreshResultSchema, {
60279
+ kind: "mutation",
60280
+ auth: "admin",
60281
+ notOperatorFacing: NOT_OPERATOR_FACING
60282
+ }),
60283
+ resubscribe: require_sleep.method(DeviceStateResubscribeInputSchema, DeviceStateRefreshResultSchema, {
60284
+ kind: "mutation",
60285
+ auth: "admin",
60286
+ notOperatorFacing: NOT_OPERATOR_FACING
60287
+ })
60288
+ },
60289
+ vocabulary: {
60290
+ noun: require_sleep.t("State refresh", "Aggiornamento dello stato"),
60291
+ order: 3247
60292
+ }
60293
+ };
60294
+ //#endregion
60185
60295
  //#region src/capabilities/device-status.cap.ts
60186
60296
  /**
60187
60297
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
@@ -104597,6 +104707,7 @@ var CAPABILITY_NAMES = {
104597
104707
  deviceRemovalHook: "device-removal-hook",
104598
104708
  deviceRuns: "device-runs",
104599
104709
  deviceState: "device-state",
104710
+ deviceStateRefresh: "device-state-refresh",
104600
104711
  deviceStatus: "device-status",
104601
104712
  deviceTransitions: "device-transitions",
104602
104713
  dishwasher: "dishwasher",
@@ -105002,6 +105113,10 @@ var CAPABILITY_ROUTER_KEYS = [
105002
105113
  key: "deviceState",
105003
105114
  name: "device-state"
105004
105115
  },
105116
+ {
105117
+ key: "deviceStateRefresh",
105118
+ name: "device-state-refresh"
105119
+ },
105005
105120
  {
105006
105121
  key: "deviceStatus",
105007
105122
  name: "device-status"
@@ -105676,6 +105791,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
105676
105791
  deviceRemovalHookCapability,
105677
105792
  deviceRunsCapability,
105678
105793
  deviceStateCapability,
105794
+ deviceStateRefreshCapability,
105679
105795
  deviceStatusCapability,
105680
105796
  deviceTransitionsCapability,
105681
105797
  dishwasherCapability,
@@ -123388,6 +123504,20 @@ var METHOD_ACCESS_MAP = Object.freeze({
123388
123504
  access: "create",
123389
123505
  role: "admin"
123390
123506
  },
123507
+ "deviceStateRefresh.refresh": {
123508
+ capName: "device-state-refresh",
123509
+ capScope: "device",
123510
+ addonId: null,
123511
+ access: "create",
123512
+ role: "admin"
123513
+ },
123514
+ "deviceStateRefresh.resubscribe": {
123515
+ capName: "device-state-refresh",
123516
+ capScope: "device",
123517
+ addonId: null,
123518
+ access: "create",
123519
+ role: "admin"
123520
+ },
123391
123521
  "deviceStatus.getStatus": {
123392
123522
  capName: "device-status",
123393
123523
  capScope: "device",
@@ -131028,6 +131158,7 @@ var KNOWN_CAP_NAMES = [
131028
131158
  "device-removal-hook",
131029
131159
  "device-runs",
131030
131160
  "device-state",
131161
+ "device-state-refresh",
131031
131162
  "device-status",
131032
131163
  "device-transitions",
131033
131164
  "dishwasher",
@@ -131210,6 +131341,7 @@ var DEVICE_CAP_NAMES = [
131210
131341
  "device-extension",
131211
131342
  "device-ops",
131212
131343
  "device-runs",
131344
+ "device-state-refresh",
131213
131345
  "device-status",
131214
131346
  "device-transitions",
131215
131347
  "dishwasher",
@@ -134329,6 +134461,20 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
134329
134461
  form: "single",
134330
134462
  optional: false
134331
134463
  }],
134464
+ "deviceStateRefresh.refresh": [{
134465
+ name: "deviceId",
134466
+ form: "single",
134467
+ optional: false
134468
+ }, {
134469
+ name: "deviceIds",
134470
+ form: "array",
134471
+ optional: false
134472
+ }],
134473
+ "deviceStateRefresh.resubscribe": [{
134474
+ name: "deviceId",
134475
+ form: "single",
134476
+ optional: false
134477
+ }],
134332
134478
  "deviceStatus.getStatus": [{
134333
134479
  name: "deviceId",
134334
134480
  form: "single",
@@ -151365,6 +151511,7 @@ exports.CLUSTER_MODEL_SECTION_ID = CLUSTER_MODEL_SECTION_ID;
151365
151511
  exports.CLUSTER_STEP_SETTING_FIELDS = CLUSTER_STEP_SETTING_FIELDS;
151366
151512
  exports.COCO_80_LABELS = COCO_80_LABELS;
151367
151513
  exports.COCO_TO_MACRO = COCO_TO_MACRO;
151514
+ exports.COMMAND_BURST_OFFSETS_MS = COMMAND_BURST_OFFSETS_MS;
151368
151515
  exports.COMPOSED_DEVICE_STABLE_ID_PREFIX = require_composed_stable_id.COMPOSED_DEVICE_STABLE_ID_PREFIX;
151369
151516
  exports.COMPOSED_ITEM_FIXED_FIELDS = COMPOSED_ITEM_FIXED_FIELDS;
151370
151517
  exports.COMPOSER_ADDON_ID = require_implemented_methods.COMPOSER_ADDON_ID;
@@ -151810,6 +151957,9 @@ exports.DeviceSearchRequiresSchema = DeviceSearchRequiresSchema;
151810
151957
  exports.DeviceSearchResultSchema = DeviceSearchResultSchema;
151811
151958
  exports.DeviceSelectorSchema = DeviceSelectorSchema;
151812
151959
  exports.DeviceSignaturePurposeSchema = DeviceSignaturePurposeSchema;
151960
+ exports.DeviceStateRefreshInputSchema = DeviceStateRefreshInputSchema;
151961
+ exports.DeviceStateRefreshResultSchema = DeviceStateRefreshResultSchema;
151962
+ exports.DeviceStateResubscribeInputSchema = DeviceStateResubscribeInputSchema;
151813
151963
  exports.DeviceStatusSchema = DeviceStatusSchema;
151814
151964
  exports.DeviceTemplateRefusalSchema = DeviceTemplateRefusalSchema;
151815
151965
  exports.DeviceTemplateRenderSchema = DeviceTemplateRenderSchema;
@@ -152409,6 +152559,7 @@ exports.MIN_CUSTOM_MINUTES = require_implemented_methods.MIN_CUSTOM_MINUTES;
152409
152559
  exports.MIN_RUN_MS = MIN_RUN_MS;
152410
152560
  exports.MIN_SCRUBBED_LENGTH = require_sleep.MIN_SCRUBBED_LENGTH;
152411
152561
  exports.MIN_SESSIONS_PER_DEVICE_RANGE = MIN_SESSIONS_PER_DEVICE_RANGE;
152562
+ exports.MIN_STATE_REFRESH_INTERVAL_MS = MIN_STATE_REFRESH_INTERVAL_MS;
152412
152563
  exports.MODEL_FORMATS = require_sleep.MODEL_FORMATS;
152413
152564
  exports.MODEL_HOSTING = MODEL_HOSTING;
152414
152565
  exports.MODEL_PROVIDER_IDS = MODEL_PROVIDER_IDS;
@@ -152885,6 +153036,7 @@ exports.PROVIDER_KIND_CAP_NAMES = PROVIDER_KIND_CAP_NAMES;
152885
153036
  exports.PROVIDER_PIN_FIELD = require_sleep.PROVIDER_PIN_FIELD;
152886
153037
  exports.PUBLIC_ENDPOINT_HTTP_REASON = PUBLIC_ENDPOINT_HTTP_REASON;
152887
153038
  exports.PULSE_MAX_MS = PULSE_MAX_MS;
153039
+ exports.PUSH_CONFIRM_WINDOW_MS = PUSH_CONFIRM_WINDOW_MS;
152888
153040
  exports.PYTHON_SCRIPT = PYTHON_SCRIPT;
152889
153041
  exports.PackageInstallationSchema = PackageInstallationSchema;
152890
153042
  exports.PackageInstallationsSchema = PackageInstallationsSchema;
@@ -153433,6 +153585,9 @@ exports.StaleSettingsKeyFindingSchema = StaleSettingsKeyFindingSchema;
153433
153585
  exports.StartClusterUpdateResultSchema = StartClusterUpdateResultSchema;
153434
153586
  exports.StartEmbeddedInputSchema = StartEmbeddedInputSchema;
153435
153587
  exports.StartEnrollmentOutputSchema = StartEnrollmentOutputSchema;
153588
+ exports.StateRefreshPolicySchema = StateRefreshPolicySchema;
153589
+ exports.StateRefreshPushSchema = StateRefreshPushSchema;
153590
+ exports.StateRefreshReasonSchema = StateRefreshReasonSchema;
153436
153591
  exports.StationaryObjectSchema = StationaryObjectSchema;
153437
153592
  exports.StationarySubjectSchema = StationarySubjectSchema;
153438
153593
  exports.StatisticHelperSpecSchema = require_implemented_methods.StatisticHelperSpecSchema;
@@ -154197,6 +154352,7 @@ exports.deviceRunsCapability = deviceRunsCapability;
154197
154352
  exports.deviceSelectorMatches = deviceSelectorMatches;
154198
154353
  exports.deviceSleeps = deviceSleeps;
154199
154354
  exports.deviceStateCapability = deviceStateCapability;
154355
+ exports.deviceStateRefreshCapability = deviceStateRefreshCapability;
154200
154356
  exports.deviceStatusCapability = deviceStatusCapability;
154201
154357
  exports.deviceTemplateCallableBounds = require_device_template_catalogue.deviceTemplateCallableBounds;
154202
154358
  exports.deviceTemplateCameraValues = require_device_template_catalogue.deviceTemplateCameraValues;
@@ -154223,6 +154379,7 @@ exports.doorbellCapability = doorbellCapability;
154223
154379
  exports.droppedConditionsForKind = droppedConditionsForKind;
154224
154380
  exports.edgetpuDelegateDevice = edgetpuDelegateDevice;
154225
154381
  exports.effectConditionHolds = require_sleep.effectConditionHolds;
154382
+ exports.effectiveRefreshIntervalMs = effectiveRefreshIntervalMs;
154226
154383
  exports.effectiveStepSettings = effectiveStepSettings;
154227
154384
  exports.egressTranscodeSharingKey = egressTranscodeSharingKey;
154228
154385
  exports.egressTransportFromRequest = egressTransportFromRequest;