@camstack/server 1.2.931 → 1.2.933

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 (30) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/trpc/generated-cap-routers.js +20 -0
  3. package/package.json +7 -51
  4. package/system/dist/{base-device-IuM1AwXZ.mjs → base-device-Bwiblqmn.mjs} +1 -1
  5. package/system/dist/{base-device-2sL1DMm1.js → base-device-C1z4zYGR.js} +1 -1
  6. package/system/dist/builtins/alerts/alerts.addon.js +2 -2
  7. package/system/dist/builtins/alerts/alerts.addon.mjs +2 -2
  8. package/system/dist/builtins/camera-grid/index.js +2 -2
  9. package/system/dist/builtins/camera-grid/index.mjs +2 -2
  10. package/system/dist/builtins/composer/composer.addon.js +5 -5
  11. package/system/dist/builtins/composer/composer.addon.mjs +5 -5
  12. package/system/dist/builtins/core-blocks/cap-links.d.ts +34 -0
  13. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +4 -0
  14. package/system/dist/builtins/core-blocks/core-blocks.addon.js +282 -8
  15. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +282 -8
  16. package/system/dist/builtins/device-manager/device-manager.addon.js +18 -4
  17. package/system/dist/builtins/device-manager/device-manager.addon.mjs +18 -4
  18. package/system/dist/{composition-sources-BEUWn2s_.mjs → composition-sources-B0QW4g86.mjs} +2 -2
  19. package/system/dist/{composition-sources-acfR4hDq.js → composition-sources-BtUx1MfU.js} +2 -2
  20. package/system/dist/{core-blocks.cap-BRPsLAij.mjs → core-blocks.cap-CnwBuf7E.mjs} +1524 -1267
  21. package/system/dist/{core-blocks.cap-BMeMCBrx.js → core-blocks.cap-DlEuHq-S.js} +1555 -1268
  22. package/system/dist/{error.cap-CSM_SRfR.mjs → error.cap-5zNPAgU2.mjs} +19 -2
  23. package/system/dist/{error.cap-DBhgPeWK.js → error.cap-BCqzFlo2.js} +24 -1
  24. package/system/dist/index.js +2 -2
  25. package/system/dist/index.mjs +2 -2
  26. package/system/dist/{prefix-walk-ifwg_ukx.mjs → prefix-walk-CRnbYJcC.mjs} +2 -2
  27. package/system/dist/{prefix-walk-BkMxoXpL.js → prefix-walk-DD1BM923.js} +2 -2
  28. package/system/dist/{rename-composition-block-BJsL58Ih.js → rename-composition-block-BRgyBO25.js} +20 -2
  29. package/system/dist/{rename-composition-block-OAtErZgq.mjs → rename-composition-block-BYRBlx-V.mjs} +20 -2
  30. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,11 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.933] - 2026-11-21
11
+
12
+ ### Added
13
+
14
+ - A light or a switch can now be linked to the relay that feeds it as its power source.
15
+
16
+ ### Changed
17
+
18
+ - Whole-capability links: the composer expands one link into the claims of every field, and core-blocks reads link state and converts per-field links on request.
19
+
20
+ ## [1.2.932] - 2026-11-21
21
+
22
+ ### Changed
23
+
24
+ - Rebuilt against updated dependencies.
25
+
10
26
  ## [1.2.931] - 2026-11-21
11
27
 
12
28
  ### Changed
13
29
 
14
30
  - Rebuilt against updated dependencies.
31
+ ### Changed
32
+
15
33
 
16
34
  ## [1.2.930] - 2026-11-21
17
35
 
@@ -2498,6 +2498,26 @@ function createCapRouter_coreBlocks(getProvider, createRemoteProxy) {
2498
2498
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
2499
2499
  return p.getCustomization(methodInput);
2500
2500
  }),
2501
+ getCapLinks: trpc_middleware_js_1.protectedProcedure
2502
+ .input(types_39.coreBlocksCapability.methods.getCapLinks.input.loose())
2503
+ .output(types_39.coreBlocksCapability.methods.getCapLinks.output)
2504
+ .query(async ({ input, ctx }) => {
2505
+ const parsedInput = ctx.req !== undefined ? (0, types_3.withoutCallerStamp)(input) : input;
2506
+ const { nodeId, ...methodInput } = parsedInput;
2507
+ const p = resolveProvider('core-blocks', nodeId, () => getProvider(ctx), createRemoteProxy);
2508
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
2509
+ return p.getCapLinks(methodInput);
2510
+ }),
2511
+ migrateCapLinks: trpc_middleware_js_1.adminProcedure
2512
+ .input(types_39.coreBlocksCapability.methods.migrateCapLinks.input.loose())
2513
+ .output(types_39.coreBlocksCapability.methods.migrateCapLinks.output)
2514
+ .mutation(async ({ input, ctx }) => {
2515
+ const parsedInput = ctx.req !== undefined ? (0, types_3.withoutCallerStamp)(input) : input;
2516
+ const { nodeId, ...methodInput } = parsedInput;
2517
+ const p = resolveProvider('core-blocks', nodeId, () => getProvider(ctx), createRemoteProxy);
2518
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
2519
+ return p.migrateCapLinks(methodInput);
2520
+ }),
2501
2521
  listComposableCaps: trpc_middleware_js_1.adminProcedure
2502
2522
  .input(types_39.coreBlocksCapability.methods.listComposableCaps.input.loose())
2503
2523
  .output(types_39.coreBlocksCapability.methods.listComposableCaps.output)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.931",
3
+ "version": "1.2.933",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,52 +66,8 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.729",
70
- "@camstack/addon-agent-ui": ">=1.2.428",
71
- "@camstack/addon-ai": ">=0.4.184",
72
- "@camstack/addon-auth": ">=1.2.183",
73
- "@camstack/addon-benchmark": ">=1.2.314",
74
- "@camstack/addon-cloudflare": ">=1.2.163",
75
- "@camstack/addon-decoder-nodeav": ">=1.2.150",
76
- "@camstack/addon-export-google": ">=0.1.139",
77
- "@camstack/addon-export-hap": ">=1.2.209",
78
- "@camstack/addon-google-services": ">=0.2.53",
79
- "@camstack/addon-import-alexa": ">=0.2.209",
80
- "@camstack/addon-matter-broker": ">=0.2.173",
81
- "@camstack/addon-model-studio": ">=1.1.347",
82
- "@camstack/addon-mqtt-broker": ">=1.2.161",
83
- "@camstack/addon-notifiers": ">=1.2.642",
84
- "@camstack/addon-osd-manager": ">=0.1.321",
85
- "@camstack/addon-pipeline-orchestrator": ">=1.2.713",
86
- "@camstack/addon-provider-amcrest": ">=0.2.177",
87
- "@camstack/addon-provider-bosch": ">=0.1.63",
88
- "@camstack/addon-provider-dreame": ">=0.2.182",
89
- "@camstack/addon-provider-dreo": ">=0.2.171",
90
- "@camstack/addon-provider-ecowitt": ">=0.2.174",
91
- "@camstack/addon-provider-enpal": ">=0.1.29",
92
- "@camstack/addon-provider-esphome": ">=0.1.28",
93
- "@camstack/addon-provider-gree": ">=0.2.165",
94
- "@camstack/addon-provider-hikvision": ">=1.2.194",
95
- "@camstack/addon-provider-homeassistant": ">=1.2.700",
96
- "@camstack/addon-provider-mqtt-ha": ">=0.1.54",
97
- "@camstack/addon-provider-onvif": ">=1.2.163",
98
- "@camstack/addon-provider-petkit": ">=0.2.173",
99
- "@camstack/addon-provider-rademacher": ">=0.2.169",
100
- "@camstack/addon-provider-reolink": ">=1.2.258",
101
- "@camstack/addon-provider-rtsp": ">=1.2.160",
102
- "@camstack/addon-provider-tuya": ">=0.2.164",
103
- "@camstack/addon-provider-unifi": ">=0.2.174",
104
- "@camstack/addon-provider-unraid": ">=0.2.176",
105
- "@camstack/addon-provider-velux": ">=0.2.176",
106
- "@camstack/addon-provider-vesync": ">=0.2.171",
107
- "@camstack/addon-provider-wyze": ">=0.2.177",
108
- "@camstack/addon-remote-storage": ">=1.2.147",
109
- "@camstack/addon-smtp-nodemailer": ">=1.2.158",
110
- "@camstack/addon-static-turn": ">=1.2.149",
111
- "@camstack/addon-tailscale": ">=1.2.156",
112
- "@camstack/addon-terminal": ">=0.1.169",
113
- "@camstack/addon-training": ">=0.1.140",
114
- "@camstack/addon-waste-collections": ">=0.1.45"
69
+ "@camstack/addon-admin-ui": ">=1.2.731",
70
+ "@camstack/addon-agent-ui": ">=1.2.430"
115
71
  },
116
72
  "wrapper": {
117
73
  "desktop": ">=0.0.1",
@@ -120,8 +76,8 @@
120
76
  }
121
77
  },
122
78
  "dependencies": {
123
- "@camstack/addon-admin-ui": "1.2.729",
124
- "@camstack/addon-agent-ui": "1.2.428",
79
+ "@camstack/addon-admin-ui": "1.2.731",
80
+ "@camstack/addon-agent-ui": "1.2.430",
125
81
  "@camstack/addon-auth": "1.2.183",
126
82
  "@camstack/addon-benchmark": "1.2.314",
127
83
  "@camstack/addon-decoder-nodeav": "1.2.150",
@@ -131,8 +87,8 @@
131
87
  "@camstack/addon-post-analysis": "1.2.721",
132
88
  "@camstack/develop": "0.1.56",
133
89
  "@camstack/sdk": "1.2.160",
134
- "@camstack/types": "1.2.619",
135
- "@camstack/ui-library": "1.2.491",
90
+ "@camstack/types": "1.2.620",
91
+ "@camstack/ui-library": "1.2.493",
136
92
  "@fastify/compress": "^9.0.0",
137
93
  "@fastify/cookie": "^11.0.2",
138
94
  "@fastify/cors": "^11.2.0",
@@ -3,7 +3,7 @@ import { p as createEvent } from "./base-addon-Md14i7pe.mjs";
3
3
  import { Z as errMsg } from "./scoped-settings-DVWUIP7Z.mjs";
4
4
  import { t as collectZodSecretPaths } from "./zod-secret-zY4nM61M.mjs";
5
5
  import { a as isEmptyIdentifiers, s as normaliseIdentifiers, t as DEVICE_IDENTIFIER_KEYS } from "./device-identifiers-iSuQCKmK.mjs";
6
- import { n as ERROR_STATUS_COLD, r as errorCapability } from "./error.cap-CSM_SRfR.mjs";
6
+ import { n as ERROR_STATUS_COLD, r as errorCapability } from "./error.cap-5zNPAgU2.mjs";
7
7
  import { i as mergeSourceInfo, o as synthesizeSourceInfo, r as extractSourceInfoFromMetadata, t as SOURCE_INFO_METADATA_KEY } from "./source-info-DGB7SdB_.mjs";
8
8
  //#region ../types/dist/esm/device/device-config.mjs
9
9
  var DeviceConfig = class DeviceConfig {
@@ -3,7 +3,7 @@ const require_base_addon = require("./base-addon-DD5dIfcZ.js");
3
3
  const require_scoped_settings = require("./scoped-settings-CylSSq_8.js");
4
4
  const require_zod_secret = require("./zod-secret-DS7mj1bk.js");
5
5
  const require_device_identifiers = require("./device-identifiers-BQg9EQi1.js");
6
- const require_error_cap = require("./error.cap-DBhgPeWK.js");
6
+ const require_error_cap = require("./error.cap-BCqzFlo2.js");
7
7
  const require_source_info = require("./source-info-DtWf4k2j.js");
8
8
  //#region ../types/dist/esm/device/device-config.mjs
9
9
  var DeviceConfig = class DeviceConfig {
@@ -6,8 +6,8 @@ const require_chunk = require("../../chunk-Cek0wNdY.js");
6
6
  const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
7
7
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
8
8
  const require_record_kind = require("../../record-kind-DoBfYHCs.js");
9
- const require_core_blocks_cap = require("../../core-blocks.cap-BMeMCBrx.js");
10
- const require_error_cap = require("../../error.cap-DBhgPeWK.js");
9
+ const require_core_blocks_cap = require("../../core-blocks.cap-DlEuHq-S.js");
10
+ const require_error_cap = require("../../error.cap-BCqzFlo2.js");
11
11
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
12
12
  const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
13
13
  let zod = require("zod");
@@ -1,8 +1,8 @@
1
1
  import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
2
2
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
3
3
  import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
4
- import { $ as alertsCapability, Q as AlertSchema, n as CORE_BLOCK_ADDON_PREFIX } from "../../core-blocks.cap-BRPsLAij.mjs";
5
- import { t as DeviceFaultSchema } from "../../error.cap-CSM_SRfR.mjs";
4
+ import { it as alertsCapability, n as CORE_BLOCK_ADDON_PREFIX, rt as AlertSchema } from "../../core-blocks.cap-CnwBuf7E.mjs";
5
+ import { t as DeviceFaultSchema } from "../../error.cap-5zNPAgU2.mjs";
6
6
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
7
7
  import { a as redactLogText } from "../../log-redactor-XLDrPzOi.mjs";
8
8
  import { z } from "zod";
@@ -9,10 +9,10 @@ const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
9
9
  const require_pinned_binary = require("../../pinned-binary-BOhOSNff.js");
10
10
  const require_device_identifiers = require("../../device-identifiers-BQg9EQi1.js");
11
11
  const require_device_type = require("../../device-type-CbQsnFdC.js");
12
- const require_error_cap = require("../../error.cap-DBhgPeWK.js");
12
+ const require_error_cap = require("../../error.cap-BCqzFlo2.js");
13
13
  const require_snapshot_cap = require("../../snapshot.cap-3suPdBHV.js");
14
14
  const require_declared_device = require("../../declared-device-BWphj9WE.js");
15
- const require_base_device = require("../../base-device-2sL1DMm1.js");
15
+ const require_base_device = require("../../base-device-C1z4zYGR.js");
16
16
  const require_addon_id = require("../../addon-id-Di0lNJ89.js");
17
17
  let zod = require("zod");
18
18
  let _camstack_types_node = require("@camstack/types/node");
@@ -4,10 +4,10 @@ import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
4
4
  import { t as memoizePinnedFfmpeg } from "../../pinned-binary-CrIRAi4G.mjs";
5
5
  import { f as DERIVED_CAMERA_SILENCED_CAP_NAMES } from "../../device-identifiers-iSuQCKmK.mjs";
6
6
  import { t as DeviceFeature } from "../../device-type-DgEvK3ch.mjs";
7
- import { R as COMPOSED_DEVICE_STABLE_ID_PREFIX, i as compileHelper, x as COMPOSER_ADDON_ID } from "../../error.cap-CSM_SRfR.mjs";
7
+ import { R as COMPOSED_DEVICE_STABLE_ID_PREFIX, i as compileHelper, x as COMPOSER_ADDON_ID } from "../../error.cap-5zNPAgU2.mjs";
8
8
  import { t as snapshotCapability } from "../../snapshot.cap-Bs8Oyaqh.mjs";
9
9
  import { n as declarationOwnerNodeId, t as DeclaredDevices } from "../../declared-device-CKERA1Hi.mjs";
10
- import { t as BaseDevice } from "../../base-device-IuM1AwXZ.mjs";
10
+ import { t as BaseDevice } from "../../base-device-Bwiblqmn.mjs";
11
11
  import { t as bareAddonId } from "../../addon-id-CVg1_r5E.mjs";
12
12
  import { z } from "zod";
13
13
  import { FfmpegProcess } from "@camstack/types/node";
@@ -6,16 +6,16 @@ require("../../chunk-Cek0wNdY.js");
6
6
  const require_stream_catalog_cap = require("../../stream-catalog.cap-D3uwePiA.js");
7
7
  const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
8
8
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
9
- const require_rename_composition_block = require("../../rename-composition-block-BJsL58Ih.js");
9
+ const require_rename_composition_block = require("../../rename-composition-block-BRgyBO25.js");
10
10
  const require_quantity = require("../../quantity-lY1KiTSZ.js");
11
11
  const require_device_type = require("../../device-type-CbQsnFdC.js");
12
- const require_core_blocks_cap = require("../../core-blocks.cap-BMeMCBrx.js");
12
+ const require_core_blocks_cap = require("../../core-blocks.cap-DlEuHq-S.js");
13
13
  const require_addon_settings_cap = require("../../addon-settings.cap-DAiE0Nb0.js");
14
- const require_error_cap = require("../../error.cap-DBhgPeWK.js");
14
+ const require_error_cap = require("../../error.cap-BCqzFlo2.js");
15
15
  const require_source_info = require("../../source-info-DtWf4k2j.js");
16
- const require_composition_sources = require("../../composition-sources-acfR4hDq.js");
16
+ const require_composition_sources = require("../../composition-sources-BtUx1MfU.js");
17
17
  const require_declared_device = require("../../declared-device-BWphj9WE.js");
18
- const require_base_device = require("../../base-device-2sL1DMm1.js");
18
+ const require_base_device = require("../../base-device-C1z4zYGR.js");
19
19
  const require_capture_engine = require("../../capture-engine-DZ0LIUqA.js");
20
20
  const require_retention = require("../../retention-BcOSL6b9.js");
21
21
  let zod = require("zod");
@@ -1,16 +1,16 @@
1
1
  import { i as motionCapability } from "../../stream-catalog.cap-Bp7SkgIf.mjs";
2
2
  import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-Md14i7pe.mjs";
3
3
  import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
4
- import { An as colorCapability, E as valveCapability, En as consumablesCapability, Jt as groupCommandsCapability, Kt as GroupCommandResultSchema, Ln as brightnessCapability, Nn as HvacModeSchema, On as composerCapability, Pn as climateControlCapability, U as RUNNING_CUSTOMIZE_DEVICE_TYPES, c as kebabToCamel, ct as petFountainWaterItem, gt as lockControlCapability, in as FanDirectionSchema, jn as parseColorInput, m as ALL_CAPABILITY_DEFINITIONS, n as renameCompositionBlock, ot as PetFountainStatusSchema, sn as fanControlCapability, st as petFountainCapability, wn as ConsumableItemSchema, xn as coverCapability, z as switchCapability } from "../../rename-composition-block-OAtErZgq.mjs";
4
+ import { An as colorCapability, E as valveCapability, En as consumablesCapability, Jt as groupCommandsCapability, Kt as GroupCommandResultSchema, Ln as brightnessCapability, Nn as HvacModeSchema, On as composerCapability, Pn as climateControlCapability, U as RUNNING_CUSTOMIZE_DEVICE_TYPES, c as kebabToCamel, ct as petFountainWaterItem, gt as lockControlCapability, in as FanDirectionSchema, jn as parseColorInput, m as ALL_CAPABILITY_DEFINITIONS, n as renameCompositionBlock, ot as PetFountainStatusSchema, sn as fanControlCapability, st as petFountainCapability, wn as ConsumableItemSchema, xn as coverCapability, z as switchCapability } from "../../rename-composition-block-BYRBlx-V.mjs";
5
5
  import { i as isReadingQuantity } from "../../quantity-D3g5SxsZ.mjs";
6
6
  import { i as featuresOfBoundCaps, r as DeviceType, t as DeviceFeature } from "../../device-type-DgEvK3ch.mjs";
7
- import { D as COMPOSED_ITEM_FIXED_FIELDS, E as featureForwards, M as mediaPlayerCapability, O as expressionContainsBuiltinCall, T as commandedMethods, Z as compositionFieldKey, g as planComposition, p as buildCapabilityLookup } from "../../core-blocks.cap-BRPsLAij.mjs";
7
+ import { D as featureForwards, E as commandedMethods, O as COMPOSED_ITEM_FIXED_FIELDS, g as planComposition, j as mediaPlayerCapability, k as expressionContainsBuiltinCall, nt as compositionFieldKey, p as buildCapabilityLookup } from "../../core-blocks.cap-CnwBuf7E.mjs";
8
8
  import { a as tryConvertUnit } from "../../addon-settings.cap-3-TIIMq_.mjs";
9
- import { $ as planResetTier, A as compositionItemFieldPath, D as composedDeviceRef, G as HISTORY_FAST_MS, H as isHistoryHelper, J as MINUTE_MS, K as HISTORY_SLOW_MS, L as isForwardInputRef, M as compositionSliceKey, N as compositionSourceKey, O as composedDeviceStableId, Q as openStatistic, V as isEngineHostedHelper, W as DEFAULT_HISTORY_RETENTION, X as nextLocalMidnight, Y as historyRetentionFromSettings, Z as openReset, _ as groupTemplate, at as cloneStatefulExpressionMemory, ct as evaluateStatefulExpressionCall, et as planStatisticTier, g as sharedColorModes, gt as evaluateCount, h as runFanOut, ht as disarmRoseMemory, it as integrateReading, k as compositionFeatureEnabled, lt as toExpressionValue, m as fanOutTargets, nt as evaluateDerivative, ot as createStatefulExpressionMemory, p as declaredSeriesKind, q as HOUR_MS, rt as evaluateStatistic, st as evaluateExpressionSource, tt as statisticCadenceMs, x as COMPOSER_ADDON_ID } from "../../error.cap-CSM_SRfR.mjs";
9
+ import { $ as openStatistic, A as compositionItemFieldPath, D as composedDeviceRef, G as DEFAULT_HISTORY_RETENTION, H as isHistoryHelper, J as HOUR_MS, K as HISTORY_FAST_MS, L as isForwardInputRef, M as compositionSliceKey, N as compositionSourceKey, O as composedDeviceStableId, Q as openReset, V as isEngineHostedHelper, X as historyRetentionFromSettings, Y as MINUTE_MS, Z as nextLocalMidnight, _ as groupTemplate, _t as evaluateCount, at as integrateReading, ct as evaluateExpressionSource, et as planResetTier, g as sharedColorModes, gt as disarmRoseMemory, h as runFanOut, it as evaluateStatistic, k as compositionFeatureEnabled, lt as evaluateStatefulExpressionCall, m as fanOutTargets, nt as statisticCadenceMs, ot as cloneStatefulExpressionMemory, p as declaredSeriesKind, q as HISTORY_SLOW_MS, rt as evaluateDerivative, st as createStatefulExpressionMemory, tt as planStatisticTier, ut as toExpressionValue, x as COMPOSER_ADDON_ID } from "../../error.cap-5zNPAgU2.mjs";
10
10
  import { a as normalizeUnit } from "../../source-info-DGB7SdB_.mjs";
11
- import { n as normalizedNativeOwner, r as compileScalarOverride } from "../../composition-sources-BEUWn2s_.mjs";
11
+ import { n as normalizedNativeOwner, r as compileScalarOverride } from "../../composition-sources-B0QW4g86.mjs";
12
12
  import { t as DeclaredDevices } from "../../declared-device-CKERA1Hi.mjs";
13
- import { t as BaseDevice } from "../../base-device-IuM1AwXZ.mjs";
13
+ import { t as BaseDevice } from "../../base-device-Bwiblqmn.mjs";
14
14
  import { i as capSeriesKey, m as parseConfirmedStateChanged, p as isRecord$4 } from "../../capture-engine-DiwbjoWp.mjs";
15
15
  import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-CUOVI1p7.mjs";
16
16
  import { z } from "zod";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Whole-capability links at runtime (D1076): the read behind `getCapLinks` and
3
+ * the one-off conversion behind `migrateCapLinks`.
4
+ *
5
+ * The compile path is not here: a `capLink` is expanded by `planComposition`
6
+ * into the field claims the composer already runs. This file only READS the
7
+ * stored links (state per link, `not-loaded` until the compositions were read,
8
+ * D315) and REWRITES plain per-field links into one link (bounded, idempotent,
9
+ * D345).
10
+ */
11
+ import { type CapLinksRead, type Composition, type CompositionSourceRef, type CoreBlock, type IScopedLogger, type MigrateCapLinksReport } from "@camstack/types";
12
+ export interface CapLinksPorts {
13
+ /** The stored blocks, or null until the table has been READ. */
14
+ readonly blocks: () => readonly CoreBlock[] | null;
15
+ /** The stable identity of a device; null when the row is gone. */
16
+ readonly refOfDevice: (deviceId: number) => Promise<CompositionSourceRef | null>;
17
+ /** The numeric id of a device identity; null when no row carries it. */
18
+ readonly deviceIdOf: (ref: CompositionSourceRef) => Promise<number | null>;
19
+ /** One composition write, judged by the composition API. */
20
+ /** The top-level state fields of a cap (what a project link serves); null for an unknown cap. */
21
+ readonly hostFieldsOf: (cap: string) => readonly string[] | null;
22
+ readonly rewrite: (block: CoreBlock, composition: Composition) => Promise<CoreBlock>;
23
+ readonly logger: IScopedLogger;
24
+ }
25
+ export declare class CapLinksService {
26
+ private readonly ports;
27
+ /** `host:cap:link` keys whose source-gone was already logged: one line per loss, not per read. */
28
+ private readonly goneLogged;
29
+ constructor(ports: CapLinksPorts);
30
+ read(deviceId: number): Promise<CapLinksRead>;
31
+ private logGone;
32
+ migrate(dryRun: boolean): Promise<MigrateCapLinksReport>;
33
+ private migrateBlock;
34
+ }
@@ -132,6 +132,10 @@ export declare class CoreBlocksAddon extends BaseAddon {
132
132
  */
133
133
  private maybeCacheSettingsSchema;
134
134
  private buildProvider;
135
+ private capLinks;
136
+ /** Whole-capability links (D1076): the read and the one-off migration, over `ctx.api`. */
137
+ private sharedCapLinks;
138
+ private buildCapLinks;
135
139
  private sharedCompositionApi;
136
140
  /** The device id of a composition target ref; null when no row carries it. */
137
141
  private deviceIdOfRef;
@@ -3,7 +3,7 @@ const require_chunk = require("../../chunk-Cek0wNdY.js");
3
3
  const require_stream_catalog_cap = require("../../stream-catalog.cap-D3uwePiA.js");
4
4
  const require_base_addon = require("../../base-addon-DD5dIfcZ.js");
5
5
  const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
6
- const require_rename_composition_block = require("../../rename-composition-block-BJsL58Ih.js");
6
+ const require_rename_composition_block = require("../../rename-composition-block-BRgyBO25.js");
7
7
  const require_notification_targets = require("../../notification-targets-CRH-9Dy5.js");
8
8
  const require_notification_rules_cap = require("../../notification-rules.cap-BDh0LDhV.js");
9
9
  const require_record_kind = require("../../record-kind-DoBfYHCs.js");
@@ -14,13 +14,13 @@ const require_quantity = require("../../quantity-lY1KiTSZ.js");
14
14
  const require_tag = require("../../tag-BxLazvVb.js");
15
15
  const require_device_type = require("../../device-type-CbQsnFdC.js");
16
16
  const require_device_kind = require("../../device-kind-CsSiv_YF.js");
17
- const require_core_blocks_cap = require("../../core-blocks.cap-BMeMCBrx.js");
18
- const require_error_cap = require("../../error.cap-DBhgPeWK.js");
19
- const require_prefix_walk = require("../../prefix-walk-BkMxoXpL.js");
17
+ const require_core_blocks_cap = require("../../core-blocks.cap-DlEuHq-S.js");
18
+ const require_error_cap = require("../../error.cap-BCqzFlo2.js");
19
+ const require_prefix_walk = require("../../prefix-walk-DD1BM923.js");
20
20
  const require_l10n = require("../../l10n-CGMvp7NF.js");
21
21
  const require_integration_instances_cap = require("../../integration-instances.cap-dJIxg2_s.js");
22
22
  const require_cap_call_context = require("../../cap-call-context-Bd76CbOW.js");
23
- const require_composition_sources = require("../../composition-sources-acfR4hDq.js");
23
+ const require_composition_sources = require("../../composition-sources-BtUx1MfU.js");
24
24
  const require_declared_device = require("../../declared-device-BWphj9WE.js");
25
25
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
26
26
  const require_capture_engine = require("../../capture-engine-DZ0LIUqA.js");
@@ -14752,6 +14752,233 @@ var RemoteComponentsService = class {
14752
14752
  }
14753
14753
  };
14754
14754
  //#endregion
14755
+ //#region src/builtins/core-blocks/cap-links.ts
14756
+ /**
14757
+ * Whole-capability links at runtime (D1076): the read behind `getCapLinks` and
14758
+ * the one-off conversion behind `migrateCapLinks`.
14759
+ *
14760
+ * The compile path is not here: a `capLink` is expanded by `planComposition`
14761
+ * into the field claims the composer already runs. This file only READS the
14762
+ * stored links (state per link, `not-loaded` until the compositions were read,
14763
+ * D315) and REWRITES plain per-field links into one link (bounded, idempotent,
14764
+ * D345).
14765
+ */
14766
+ function hostBlock(blocks, host) {
14767
+ const key = require_error_cap.compositionSourceKey(host);
14768
+ return blocks.find((block) => {
14769
+ const target = require_core_blocks_cap.coreBlockComposition(block)?.target;
14770
+ return target?.kind === "existing" && require_error_cap.compositionSourceKey(target.device) === key;
14771
+ }) ?? null;
14772
+ }
14773
+ function capLinkFeatures(composition) {
14774
+ return (composition?.features ?? []).flatMap((feature) => feature.kind === "capLink" ? [feature] : []);
14775
+ }
14776
+ var CapLinksService = class {
14777
+ ports;
14778
+ /** `host:cap:link` keys whose source-gone was already logged: one line per loss, not per read. */
14779
+ goneLogged = /* @__PURE__ */ new Set();
14780
+ constructor(ports) {
14781
+ this.ports = ports;
14782
+ }
14783
+ async read(deviceId) {
14784
+ const blocks = this.ports.blocks();
14785
+ if (blocks === null) return { status: "not-loaded" };
14786
+ const host = await this.ports.refOfDevice(deviceId);
14787
+ if (host === null) return {
14788
+ status: "ok",
14789
+ links: []
14790
+ };
14791
+ const block = hostBlock(blocks, host);
14792
+ const features = capLinkFeatures(block === null ? null : require_core_blocks_cap.coreBlockComposition(block));
14793
+ const links = [];
14794
+ for (const feature of features) {
14795
+ const declared = require_core_blocks_cap.declaredCapLink(feature.cap, feature.linkId);
14796
+ if (declared === void 0) continue;
14797
+ const sourceId = await this.ports.deviceIdOf(feature.source);
14798
+ const gone = sourceId === null;
14799
+ const state = !require_error_cap.compositionFeatureEnabled(feature) ? "disabled" : gone ? "source-gone" : "linked";
14800
+ if (state === "source-gone") this.logGone(deviceId, feature);
14801
+ else this.goneLogged.delete(goneKey(deviceId, feature));
14802
+ links.push({
14803
+ linkId: feature.linkId,
14804
+ cap: feature.cap,
14805
+ slot: declared.slot ?? null,
14806
+ mode: declared.mode,
14807
+ source: {
14808
+ deviceId: sourceId,
14809
+ cap: declared.sourceCap
14810
+ },
14811
+ state
14812
+ });
14813
+ }
14814
+ return {
14815
+ status: "ok",
14816
+ links
14817
+ };
14818
+ }
14819
+ logGone(deviceId, feature) {
14820
+ const key = goneKey(deviceId, feature);
14821
+ if (this.goneLogged.has(key)) return;
14822
+ this.goneLogged.add(key);
14823
+ this.ports.logger.warn("cap link: the source device is gone — the linked cap reads unknown", {
14824
+ tags: { deviceId },
14825
+ meta: {
14826
+ cap: feature.cap,
14827
+ linkId: feature.linkId,
14828
+ source: feature.source
14829
+ }
14830
+ });
14831
+ }
14832
+ async migrate(dryRun) {
14833
+ const blocks = this.ports.blocks();
14834
+ if (blocks === null) throw new Error("core-blocks: the compositions have not loaded yet — migrateCapLinks refused");
14835
+ const report = {
14836
+ dryRun,
14837
+ converted: [],
14838
+ mixed: [],
14839
+ skipped: 0,
14840
+ alreadyLinked: 0
14841
+ };
14842
+ for (const block of blocks) {
14843
+ const composition = require_core_blocks_cap.coreBlockComposition(block);
14844
+ if (composition === null || composition.target.kind !== "existing") continue;
14845
+ const deviceId = await this.ports.deviceIdOf(composition.target.device);
14846
+ if (deviceId === null) {
14847
+ this.ports.logger.warn("cap link migration: host device not found — customization left as is", { meta: { blockId: block.id } });
14848
+ continue;
14849
+ }
14850
+ await this.migrateBlock(block, composition, deviceId, dryRun, report);
14851
+ }
14852
+ return report;
14853
+ }
14854
+ async migrateBlock(stored, composition, deviceId, dryRun, report) {
14855
+ const caps = [...new Set(composition.features.flatMap((f) => f.kind === "fields" || f.kind === "capLink" ? [f.cap] : []))];
14856
+ let block = stored;
14857
+ let next = composition;
14858
+ for (const cap of caps) {
14859
+ const link = require_core_blocks_cap.projectCapLinkOf(cap);
14860
+ if (link === void 0) continue;
14861
+ if (capLinkFeatures(next).some((f) => f.cap === cap)) {
14862
+ report.alreadyLinked += 1;
14863
+ continue;
14864
+ }
14865
+ const plain = next.features.filter((f) => f.kind === "fields" && f.cap === cap);
14866
+ const candidates = plain.filter((f) => f.contributedBy === void 0 && require_error_cap.compositionFeatureEnabled(f));
14867
+ report.skipped += plain.length - candidates.length;
14868
+ if (candidates.length === 0) continue;
14869
+ const verdict = identityGroup(candidates, link.sourceCap, link.map);
14870
+ const hostFields = this.ports.hostFieldsOf(cap);
14871
+ const reasons = "reasons" in verdict ? verdict.reasons : hostFields === null ? [`the capability ${cap} is unknown here`] : widening(require_core_blocks_cap.capLinkServedFields(link, hostFields), verdict.fields, next, candidates);
14872
+ if ("reasons" in verdict || reasons.length > 0) {
14873
+ report.mixed.push({
14874
+ deviceId,
14875
+ cap,
14876
+ reasons
14877
+ });
14878
+ continue;
14879
+ }
14880
+ if ("reasons" in verdict) continue;
14881
+ const feature = {
14882
+ kind: "capLink",
14883
+ cap,
14884
+ linkId: link.id,
14885
+ source: verdict.source
14886
+ };
14887
+ const replaced = new Set(candidates);
14888
+ const kept = next.features.filter((f) => !replaced.has(f));
14889
+ const candidate = {
14890
+ ...next,
14891
+ features: kept.concat(feature)
14892
+ };
14893
+ const converted = {
14894
+ deviceId,
14895
+ cap,
14896
+ linkId: link.id,
14897
+ source: verdict.source,
14898
+ fields: verdict.fields
14899
+ };
14900
+ if (!dryRun) try {
14901
+ block = await this.ports.rewrite(block, candidate);
14902
+ } catch (err) {
14903
+ report.mixed.push({
14904
+ deviceId,
14905
+ cap,
14906
+ reasons: [`the link was refused: ${require_scoped_settings.errMsg(err)}`]
14907
+ });
14908
+ this.ports.logger.warn("cap link migration: conversion refused — left as it was", {
14909
+ tags: { deviceId },
14910
+ meta: {
14911
+ cap,
14912
+ error: require_scoped_settings.errMsg(err)
14913
+ }
14914
+ });
14915
+ continue;
14916
+ }
14917
+ next = candidate;
14918
+ report.converted.push(converted);
14919
+ }
14920
+ }
14921
+ };
14922
+ /**
14923
+ * Why converting would change what the device claims. The link serves EVERY host
14924
+ * field of the cap (and the clock as `now`): a set that covers fewer would newly
14925
+ * take the rest from the source, and an enabled feature another writer left on
14926
+ * the cap would overlap the link. The operator decides per device.
14927
+ */
14928
+ function widening(served, carried, next, candidates) {
14929
+ const reasons = [];
14930
+ const missing = served.filter((path) => !carried.includes(path));
14931
+ if (missing.length > 0) reasons.push(`partial-set: would also take ${missing.join(", ")}`);
14932
+ const taken = new Set(candidates);
14933
+ for (const other of next.features) {
14934
+ if (other.kind !== "fields" || taken.has(other) || !require_error_cap.compositionFeatureEnabled(other)) continue;
14935
+ const clash = Object.keys(other.fields).filter((path) => served.includes(path));
14936
+ if (clash.length > 0) {
14937
+ const by = other.contributedBy === void 0 ? "another feature" : `the device link ${other.contributedBy.linkId}`;
14938
+ reasons.push(`overlap: ${by} also writes ${clash.join(", ")}, which the link would serve`);
14939
+ }
14940
+ }
14941
+ return reasons;
14942
+ }
14943
+ function goneKey(deviceId, feature) {
14944
+ return `${deviceId}:${feature.cap}:${feature.linkId}`;
14945
+ }
14946
+ /**
14947
+ * The features are ONE link when every field is a plain read of the SAME source
14948
+ * device's `sourceCap`, at the path the link maps it to (the same path without a
14949
+ * map), plus the `now` clock. Anything else is named, per field.
14950
+ */
14951
+ function identityGroup(features, sourceCap, map) {
14952
+ const reasons = [];
14953
+ const sources = /* @__PURE__ */ new Map();
14954
+ const fields = [];
14955
+ for (const feature of features) {
14956
+ for (const [path, value] of Object.entries(feature.fields)) {
14957
+ fields.push(path);
14958
+ if (value.kind === "expression" && value.expr === "now" && path === "lastFetchedAt") continue;
14959
+ if (path === "lastFetchedAt") {
14960
+ reasons.push("lastFetchedAt: reads the source clock, the link writes now");
14961
+ continue;
14962
+ }
14963
+ if (value.kind !== "from") {
14964
+ reasons.push(`${path}: a ${value.kind} source`);
14965
+ continue;
14966
+ }
14967
+ if (value.cap !== sourceCap) reasons.push(`${path}: reads ${value.cap}, not ${sourceCap}`);
14968
+ else if (value.fieldPath !== (map?.[path] ?? path)) reasons.push(`${path}: reads ${value.fieldPath}, not the same path`);
14969
+ sources.set(require_error_cap.compositionSourceKey(value.source), value.source);
14970
+ }
14971
+ for (const extra of ["items", "commands"]) if (feature[extra] !== void 0) reasons.push(`the feature carries ${extra}`);
14972
+ }
14973
+ const [first] = [...sources.values()];
14974
+ if (sources.size > 1) reasons.push(`${sources.size} different source devices`);
14975
+ if (first === void 0 && reasons.length === 0) reasons.push("no source device");
14976
+ return reasons.length > 0 || first === void 0 ? { reasons } : {
14977
+ source: first,
14978
+ fields
14979
+ };
14980
+ }
14981
+ //#endregion
14755
14982
  //#region src/builtins/core-blocks/hero-layout-service.ts
14756
14983
  /**
14757
14984
  * The `hero-layout` provider of core-blocks (D1023): serves the FIXED layouts
@@ -17292,7 +17519,8 @@ function replacedOf(stored, description, lookupCap) {
17292
17519
  return require_core_blocks_cap.replacedFieldKeys(require_core_blocks_cap.planComposition(stored.composition, lookupCap, description));
17293
17520
  }
17294
17521
  function peerOf(stored, targets, lookupCap, candidateBlockId) {
17295
- const { blockId, composition } = stored;
17522
+ const { blockId } = stored;
17523
+ const composition = require_core_blocks_cap.expandCapLinks(stored.composition, (cap) => require_core_blocks_cap.topLevelFieldsOf(cap, lookupCap));
17296
17524
  if (composition.target.kind === "new") return {
17297
17525
  peer: {
17298
17526
  blockId,
@@ -17303,7 +17531,10 @@ function peerOf(stored, targets, lookupCap, candidateBlockId) {
17303
17531
  };
17304
17532
  const device = composition.target.device;
17305
17533
  const key = require_error_cap.compositionSourceKey(device);
17306
- const replaced = replacedOf(stored, targets.get(key), lookupCap);
17534
+ const replaced = replacedOf({
17535
+ blockId,
17536
+ composition
17537
+ }, targets.get(key), lookupCap);
17307
17538
  if (!("error" in replaced)) return {
17308
17539
  peer: {
17309
17540
  blockId,
@@ -19538,8 +19769,51 @@ var CoreBlocksAddon = class extends require_base_addon.BaseAddon {
19538
19769
  })) };
19539
19770
  },
19540
19771
  ...this.requireActions().runsApi,
19541
- ...this.sharedCompositionApi()
19772
+ ...this.sharedCompositionApi(),
19773
+ getCapLinks: async ({ deviceId }) => this.sharedCapLinks().read(deviceId),
19774
+ migrateCapLinks: async ({ dryRun }) => this.sharedCapLinks().migrate(dryRun)
19775
+ };
19776
+ }
19777
+ capLinks = null;
19778
+ /** Whole-capability links (D1076): the read and the one-off migration, over `ctx.api`. */
19779
+ sharedCapLinks() {
19780
+ this.capLinks ??= this.buildCapLinks();
19781
+ return this.capLinks;
19782
+ }
19783
+ buildCapLinks() {
19784
+ const requireApi = () => {
19785
+ const api = this.ctx.api;
19786
+ if (!api) throw new Error("core-blocks: no ctx.api on this node — cap links cannot be read");
19787
+ return api;
19542
19788
  };
19789
+ const store = this.requireStore();
19790
+ const compositions = this.sharedCompositionApi();
19791
+ const lookupCap = require_core_blocks_cap.buildCapabilityLookup(require_rename_composition_block.ALL_CAPABILITY_DEFINITIONS);
19792
+ return new CapLinksService({
19793
+ blocks: () => store.isLoaded() ? store.list() : null,
19794
+ refOfDevice: async (deviceId) => {
19795
+ const found = await requireApi().deviceManager.getDevice.query({ deviceId });
19796
+ return found === null ? null : {
19797
+ addonId: found.addonId,
19798
+ stableId: found.stableId
19799
+ };
19800
+ },
19801
+ deviceIdOf: (ref) => this.deviceIdOfRef(ref),
19802
+ hostFieldsOf: (cap) => require_core_blocks_cap.topLevelFieldsOf(cap, lookupCap),
19803
+ rewrite: async (block, composition) => {
19804
+ const { block: updated } = await compositions.updateComposition({
19805
+ blockId: block.id,
19806
+ expectedUpdatedAt: block.updatedAt,
19807
+ block: { composition },
19808
+ caller: {
19809
+ userId: "cap-links-migration",
19810
+ isAdmin: true
19811
+ }
19812
+ });
19813
+ return updated;
19814
+ },
19815
+ logger: this.ctx.logger.child("cap-links")
19816
+ });
19543
19817
  }
19544
19818
  sharedCompositionApi() {
19545
19819
  this.compositionApi ??= this.buildCompositionApi();