@camstack/server 1.2.786 → 1.2.787

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 (101) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/core/cap-providers.js +62 -96
  3. package/dist/api/trpc/generated-cap-mounts.js +1 -10
  4. package/dist/api/trpc/generated-cap-routers.js +2289 -2366
  5. package/dist/core/addon/addon-registry.service.js +17 -13
  6. package/dist/core/addon/instances-of-cap.js +35 -0
  7. package/package.json +31 -40
  8. package/system/dist/addon-utils.mjs +1 -1
  9. package/system/dist/{agent-https-snFEmSqQ.js → agent-https--lvZp4PX.js} +1 -1
  10. package/system/dist/{agent-https-D779EYj3.mjs → agent-https-pSCzmbQd.mjs} +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  15. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  16. package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
  17. package/system/dist/builtins/autotrack/index.js +1 -1
  18. package/system/dist/builtins/autotrack/index.mjs +1 -1
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  20. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  21. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  22. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  23. package/system/dist/builtins/camera-grid/index.js +1 -1
  24. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  25. package/system/dist/builtins/composer/composer.addon.js +3 -3
  26. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  27. package/system/dist/builtins/console-logging/index.js +1 -1
  28. package/system/dist/builtins/console-logging/index.mjs +1 -1
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  31. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  32. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  33. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  34. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  36. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  37. package/system/dist/builtins/keychain/index.js +4 -4
  38. package/system/dist/builtins/keychain/index.mjs +4 -4
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  40. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  41. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  42. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  43. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  44. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  45. package/system/dist/builtins/loki-logging/index.js +1 -1
  46. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  48. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  49. package/system/dist/builtins/platform-probe/index.js +1 -1
  50. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  51. package/system/dist/builtins/record-entries/index.js +1 -1
  52. package/system/dist/builtins/record-entries/index.mjs +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  54. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  55. package/system/dist/builtins/snapshot/index.js +1 -1
  56. package/system/dist/builtins/snapshot/index.mjs +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  59. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +0 -1
  62. package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +2 -4
  63. package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +6 -1
  64. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +7 -4
  65. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +7 -4
  66. package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +4 -8
  67. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +9 -26
  68. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
  69. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -407
  70. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +36 -407
  71. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  72. package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
  73. package/system/dist/builtins/winston-logging/index.js +1 -1
  74. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  75. package/system/dist/{capture-engine-NZ11ORZS.js → capture-engine-CTFHb-UX.js} +1 -1
  76. package/system/dist/{capture-engine-DkTEWrRe.mjs → capture-engine-N1-UaQr0.mjs} +1 -1
  77. package/system/dist/{composition-sources-B9-lkIvO.mjs → composition-sources-Qe3MRI1x.mjs} +1 -1
  78. package/system/dist/{composition-sources-B6GYTy_7.js → composition-sources-Yjz-b6-8.js} +1 -1
  79. package/system/dist/{constants-DR8hdi45.js → constants-7gannWcO.js} +1 -1
  80. package/system/dist/{constants--9ui1LK0.mjs → constants-lWMAnwmj.mjs} +1 -1
  81. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  82. package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
  83. package/system/dist/{device-ca-D-7tAHJ_.mjs → device-ca-8lpRo9Ss.mjs} +1 -1
  84. package/system/dist/{device-ca-sIFmKkGM.js → device-ca-HGx3Pwb6.js} +1 -1
  85. package/system/dist/{dist-D-iGSnX_.mjs → dist-DgZrPBbX.mjs} +668 -839
  86. package/system/dist/{dist-h3Yla8gE.js → dist-j7uy5oG9.js} +668 -839
  87. package/system/dist/file-host-worker.js +1 -1
  88. package/system/dist/file-host-worker.mjs +1 -1
  89. package/system/dist/{hub-mdns-ciao-DuEfM0fI.mjs → hub-mdns-ciao-BM3peDu1.mjs} +2 -2
  90. package/system/dist/{hub-mdns-ciao-C5DkUEZF.js → hub-mdns-ciao-BUKHJL6N.js} +2 -2
  91. package/system/dist/index.d.ts +2 -2
  92. package/system/dist/index.js +40 -220
  93. package/system/dist/index.mjs +253 -431
  94. package/system/dist/{legacy-integration-rows-door-DTDD5wwC.js → legacy-integration-rows-door-D51X6Fdr.js} +1 -1
  95. package/system/dist/{legacy-integration-rows-door-BTdhD-Yp.mjs → legacy-integration-rows-door-DIm4Q3Jj.mjs} +1 -1
  96. package/system/dist/migrations/hub/2026-11-06-drop-legacy-integrations-and-storage-locations.d.ts +12 -0
  97. package/system/dist/{restore-archive-CkAD_-E9.js → restore-archive-8jRnSzmw.js} +1 -1
  98. package/system/dist/{restore-archive-DQWz5Wp-.mjs → restore-archive-D-Wmp8OK.mjs} +94 -94
  99. package/system/dist/{wal-maintenance-DouX1XsY.mjs → wal-maintenance-CBnqPn4u.mjs} +0 -0
  100. package/system/dist/{wal-maintenance-CB-O-GPP.js → wal-maintenance-D0FMnpba.js} +0 -0
  101. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.787] - 2026-11-06
11
+
12
+ ### Changed
13
+
14
+ - Integration creation is gated by the instance test; integrations.testConnection is removed
15
+
10
16
  ## [1.2.786] - 2026-11-06
11
17
 
12
18
  ### Changed
@@ -67,6 +67,7 @@ exports.computeTopologyPass = computeTopologyPass;
67
67
  exports.computeTopology = computeTopology;
68
68
  exports.createNodeRootPackageLookup = createNodeRootPackageLookup;
69
69
  exports.buildNodesProvider = buildNodesProvider;
70
+ exports.requireIntegrationRegistry = requireIntegrationRegistry;
70
71
  exports.buildIntegrationsProvider = buildIntegrationsProvider;
71
72
  exports.dispatchCustomAction = dispatchCustomAction;
72
73
  exports.buildAddonsProvider = buildAddonsProvider;
@@ -752,8 +753,10 @@ function buildNodesProvider(agentRegistry, moleculer, addonRegistry, getNodeRoot
752
753
  }
753
754
  function requireIntegrationRegistry(ar) {
754
755
  const reg = ar.getIntegrationRegistry();
755
- if (!reg)
756
- throw new Error('IntegrationRegistry not available');
756
+ if (!reg) {
757
+ const reason = ar.getIntegrationRegistryUnavailableReason();
758
+ throw new Error(`IntegrationRegistry not available: ${reason ?? 'its records are still being wired'}`);
759
+ }
757
760
  return reg;
758
761
  }
759
762
  function isDeviceProvider(value) {
@@ -765,44 +768,60 @@ function getDeviceProvider(ar, addonId) {
765
768
  const provider = ar.getCapabilityRegistry().getProviderByAddon('device-provider', addonId);
766
769
  return isDeviceProvider(provider) ? provider : null;
767
770
  }
768
- function isConnectionTestProvider(value) {
769
- return (value !== null &&
770
- typeof value === 'object' &&
771
- typeof Reflect.get(value, 'testSettings') === 'function');
772
- }
773
- function getConnectionTestProvider(ar, addonId) {
774
- const provider = ar.getCapabilityRegistry().getProviderByAddon('connection-test', addonId);
775
- return isConnectionTestProvider(provider) ? provider : null;
776
- }
771
+ // ── pre-creation connection test ────────────────────────────────────
772
+ //
773
+ // `integrations.create` gates on the instance's own test (D1016): an integration whose instances
774
+ // declare a Test (`describe().canTest`) is asked through `integration-instances.testInstance`
775
+ // with the draft values; one that declares none is a KNOWN `unsupported`, never a silent pass.
776
+ // There is no default branch and the framework never guesses a test from the shape of the
777
+ // settings.
778
+ /** The addon that keeps the MQTT brokers: the instance a `brokerId` names lives there, not in the consumer. */
779
+ const BROKER_OWNER_ADDON_ID = 'mqtt-broker';
777
780
  /**
778
- * Does this addon declare a pre-creation test at all? Drives
779
- * `getAvailableTypes().canTest`, so the wizard can say "this one cannot be
780
- * tested" instead of offering a button that always answers the same nonsense.
781
- *
782
- * A broker-mode addon declares its test through `integration-instances` (`describe().canTest`,
783
- * read by the caller), never through the broker cap.
781
+ * The instances provider that owns the broker a settings blob NAMES. The consumer (`addonId`) holds a
782
+ * link to a broker, not the broker, so the broker addon is asked first and the consumer's own provider
783
+ * only when it lists that id itself.
784
784
  */
785
- function declaresConnectionTest(ar, addonId) {
786
- return getConnectionTestProvider(ar, addonId) !== null;
785
+ async function findBrokerOwner(ar, addonId, brokerId) {
786
+ for (const candidateId of [BROKER_OWNER_ADDON_ID, addonId]) {
787
+ const candidate = getInstancesProvider(ar, candidateId);
788
+ if (candidate === null || candidate.testInstance === undefined)
789
+ continue;
790
+ const rows = await candidate.listInstances();
791
+ if (rows.some((row) => row.id === brokerId))
792
+ return { addonId: candidateId, provider: candidate };
793
+ }
794
+ return null;
787
795
  }
788
796
  /**
789
- * Run the DECLARED pre-creation test for `(addonId, settings)`.
797
+ * Run the pre-creation test for `(addonId, settings)` through `testInstance`, the one test method.
790
798
  *
791
799
  * Never throws: a test that blows up is `inconclusive`, which is emphatically
792
800
  * NOT `rejected`. A timeout must not read as a refusal — it would block a
793
801
  * perfectly good create on a flaky network, and the operator would have no way
794
802
  * to tell the two apart.
795
803
  */
796
- async function runConnectionTest(ar, addonId, settings, logger) {
804
+ async function testBeforeCreate(ar, addonId, settings, logger, kind) {
797
805
  // 0. An addon that keeps its connection as typed instances tests it there.
798
806
  const instances = getInstancesProvider(ar, addonId);
799
- if (instances !== null &&
800
- instances.testInstance !== undefined &&
801
- (await instances.describe()).canTest) {
807
+ let declaresTest = false;
808
+ if (instances !== null && instances.testInstance !== undefined) {
809
+ try {
810
+ declaresTest = (await instances.describe()).canTest;
811
+ }
812
+ catch (err) {
813
+ logger.warn('could not read whether the integration declares a test', {
814
+ tags: { addonId },
815
+ meta: { phase: 'test', error: (0, types_1.errMsg)(err) },
816
+ });
817
+ }
818
+ }
819
+ if (instances !== null && instances.testInstance !== undefined && declaresTest) {
802
820
  try {
803
821
  const result = await instances.testInstance({
804
822
  id: null,
805
823
  values: settings,
824
+ ...(kind !== undefined ? { kind } : {}),
806
825
  });
807
826
  const status = result.status ?? (result.success ? 'validated' : 'rejected');
808
827
  return {
@@ -825,60 +844,30 @@ async function runConnectionTest(ar, addonId, settings, logger) {
825
844
  };
826
845
  }
827
846
  }
828
- // 1. The provider's own declared test — the primary path.
829
- const tester = getConnectionTestProvider(ar, addonId);
830
- if (tester) {
831
- try {
832
- const outcome = await tester.testSettings({ settings });
833
- if (outcome.outcome === 'validated') {
834
- return {
835
- status: 'validated',
836
- testedBy: addonId,
837
- ...(outcome.latencyMs !== undefined ? { latencyMs: outcome.latencyMs } : {}),
838
- ...(outcome.detail !== undefined ? { detail: outcome.detail } : {}),
839
- };
840
- }
841
- if (outcome.outcome === 'rejected') {
842
- return { status: 'rejected', error: outcome.error, testedBy: addonId };
843
- }
844
- return {
845
- status: 'inconclusive',
846
- error: outcome.error,
847
- testedBy: addonId,
848
- };
849
- }
850
- catch (err) {
851
- logger.warn('connection test could not run', {
852
- tags: { addonId },
853
- meta: { phase: 'test', error: (0, types_1.errMsg)(err) },
854
- });
855
- return {
856
- status: 'inconclusive',
857
- error: `Connection test could not run: ${(0, types_1.errMsg)(err)}`,
858
- testedBy: addonId,
859
- };
860
- }
861
- }
862
- // 2. Broker-backed integrations carry their connection identity as a
847
+ // 1. Broker-backed integrations carry their connection identity as a
863
848
  // `brokerId`; the broker already owns the real semantic check (HA opens a
864
849
  // temporary WS handshake, MQTT pings the bridge). Reached because the
865
850
  // settings NAME a broker, not because nothing else matched.
866
851
  const brokerId = settings['brokerId'];
867
852
  if (typeof brokerId === 'string' && brokerId.length > 0) {
868
- const brokerInstances = getInstancesProvider(ar, addonId);
869
- if (brokerInstances === null || brokerInstances.testInstance === undefined) {
870
- return {
871
- status: 'inconclusive',
872
- error: `Instances provider for addon '${addonId}' is not available`,
873
- testedBy: null,
874
- };
875
- }
876
853
  try {
877
- const result = await brokerInstances.testInstance({ id: brokerId, values: {} });
854
+ const owner = await findBrokerOwner(ar, addonId, brokerId);
855
+ if (owner === null || owner.provider.testInstance === undefined) {
856
+ logger.warn('no instances provider owns the broker a create names', {
857
+ tags: { addonId },
858
+ meta: { phase: 'test', brokerId },
859
+ });
860
+ return {
861
+ status: 'inconclusive',
862
+ error: `No instances provider that owns broker '${brokerId}' is available`,
863
+ testedBy: null,
864
+ };
865
+ }
866
+ const result = await owner.provider.testInstance({ id: brokerId, values: {} });
878
867
  const status = result.status ?? (result.success ? 'validated' : 'rejected');
879
868
  return {
880
869
  status,
881
- testedBy: addonId,
870
+ testedBy: owner.addonId,
882
871
  ...(result.error !== undefined ? { error: result.error } : {}),
883
872
  ...(result.latencyMs !== undefined ? { latencyMs: result.latencyMs } : {}),
884
873
  ...(result.detail !== undefined ? { detail: result.detail } : {}),
@@ -896,7 +885,7 @@ async function runConnectionTest(ar, addonId, settings, logger) {
896
885
  };
897
886
  }
898
887
  }
899
- // 3. Nothing declared. Say so plainly — this must never render as a pass,
888
+ // 2. Nothing declared. Say so plainly — this must never render as a pass,
900
889
  // and must never render as a failure we did not observe.
901
890
  return {
902
891
  status: 'unsupported',
@@ -1056,7 +1045,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
1056
1045
  // those would make every integration lacking the hook uncreatable, and
1057
1046
  // would fail a good create on a flaky network. They pass, and they SAY SO
1058
1047
  // in the log: silence here would read as "validated".
1059
- const verdict = await runConnectionTest(ar, input.addonId, settings ?? {}, logger);
1048
+ const verdict = await testBeforeCreate(ar, input.addonId, settings ?? {}, logger, input.kind);
1060
1049
  if (verdict.status === 'rejected') {
1061
1050
  logger.warn('rejected — connection test refused the settings', {
1062
1051
  tags: { addonId: input.addonId },
@@ -1095,6 +1084,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
1095
1084
  await instances.createInstance({
1096
1085
  id: integration.id,
1097
1086
  name: integration.name,
1087
+ ...(input.kind !== undefined ? { kind: input.kind } : {}),
1098
1088
  });
1099
1089
  if (settings !== undefined && Object.keys(settings).length > 0) {
1100
1090
  await instances.updateInstance({
@@ -1412,7 +1402,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
1412
1402
  kind,
1413
1403
  brokerKind,
1414
1404
  supportsLocationImport,
1415
- canTest: described?.canTest === true || declaresConnectionTest(ar, m.id),
1405
+ canTest: described?.canTest === true,
1416
1406
  existingInstances: existing.map((i) => ({
1417
1407
  id: i.id,
1418
1408
  name: i.name,
@@ -1421,30 +1411,6 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
1421
1411
  };
1422
1412
  }));
1423
1413
  },
1424
- testConnection: async (input) => {
1425
- // The Test button. Routes to the DECLARED test (see `runConnectionTest`)
1426
- // and reports the tri-state verbatim: `success` is true ONLY for
1427
- // `validated`, so a test that never ran can never render as a tick — and
1428
- // `status` lets the UI show "could not be validated" in its own colour
1429
- // instead of a red failure nobody observed.
1430
- const verdict = await runConnectionTest(ar, input.addonId, input.settings, logger);
1431
- logger.info('connection test', {
1432
- tags: { addonId: input.addonId },
1433
- meta: {
1434
- phase: 'test',
1435
- status: verdict.status,
1436
- testedBy: verdict.testedBy,
1437
- },
1438
- });
1439
- return {
1440
- success: verdict.status === 'validated',
1441
- status: verdict.status,
1442
- testedBy: verdict.testedBy,
1443
- ...(verdict.error !== undefined ? { error: verdict.error } : {}),
1444
- ...(verdict.latencyMs !== undefined ? { latencyMs: verdict.latencyMs } : {}),
1445
- ...(verdict.detail !== undefined ? { detail: verdict.detail } : {}),
1446
- };
1447
- },
1448
1414
  };
1449
1415
  }
1450
1416
  // ── addons ──────────────────────────────────────────────────────────
@@ -2,7 +2,7 @@
2
2
  // AUTO-GENERATED by scripts/generate-cap-mounts.ts — DO NOT EDIT
3
3
  // Re-run: npx tsx scripts/generate-cap-mounts.ts
4
4
  //
5
- // Mounted: 200 Skipped (legacy): 3
5
+ // Mounted: 199 Skipped (legacy): 3
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LEGACY_SHAPE_SKIP = void 0;
8
8
  exports.mountAllCaps = mountAllCaps;
@@ -159,15 +159,6 @@ function mountAllCaps(services) {
159
159
  climateControl: (0, generated_cap_routers_js_1.createCapRouter_climateControl)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'climate-control'), remoteCapProxy),
160
160
  color: (0, generated_cap_routers_js_1.createCapRouter_color)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'color'), remoteCapProxy),
161
161
  composer: (0, generated_cap_routers_js_1.createCapRouter_composer)((_ctx) => reg?.getSingleton('composer') ?? null, remoteCapProxy),
162
- connectionTest: (0, generated_cap_routers_js_1.createCapRouter_connectionTest)((_ctx, addonId) => {
163
- if (!reg)
164
- return null;
165
- if (addonId !== undefined) {
166
- return reg.getProviderByAddonId('connection-test', addonId);
167
- }
168
- const entries = reg.getCollectionEntries('connection-test');
169
- return entries[0]?.[1] ?? null;
170
- }, remoteCapProxy),
171
162
  connectivity: (0, generated_cap_routers_js_1.createCapRouter_connectivity)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'connectivity'), remoteCapProxy),
172
163
  consumables: (0, generated_cap_routers_js_1.createCapRouter_consumables)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'consumables'), remoteCapProxy),
173
164
  contact: (0, generated_cap_routers_js_1.createCapRouter_contact)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'contact'), remoteCapProxy),