@camstack/server 1.2.785 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/api/core/cap-providers.js +106 -103
- package/dist/api/trpc/generated-cap-mounts.js +1 -10
- package/dist/api/trpc/generated-cap-routers.js +2289 -2375
- package/dist/core/addon/addon-registry.service.js +17 -13
- package/dist/core/addon/instances-of-cap.js +35 -0
- package/package.json +32 -13
- package/system/dist/addon-runner.js +11 -2
- package/system/dist/addon-runner.mjs +12 -3
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-B7lqIrF1.js → agent-https--lvZp4PX.js} +1 -1
- package/system/dist/{agent-https-CACfLh65.mjs → agent-https-pSCzmbQd.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composed-device.d.ts +16 -0
- package/system/dist/builtins/composer/composer.addon.js +62 -13
- package/system/dist/builtins/composer/composer.addon.mjs +62 -13
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +16 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +235 -37
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +235 -37
- package/system/dist/builtins/core-blocks/migrations/fountain-drink-drop.d.ts +21 -0
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -2
- package/system/dist/builtins/loki-logging/index.mjs +2 -2
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +0 -1
- package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +2 -4
- package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +6 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +7 -4
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +7 -4
- package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +4 -8
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +9 -26
- package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -407
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +36 -407
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +285 -285
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-n5mJUHzf.js → capture-engine-CTFHb-UX.js} +1 -1
- package/system/dist/{capture-engine-Dw82x5UW.mjs → capture-engine-N1-UaQr0.mjs} +1 -1
- package/system/dist/{composition-sources-D-bbLadz.mjs → composition-sources-Qe3MRI1x.mjs} +1 -1
- package/system/dist/{composition-sources-Cdow6PNn.js → composition-sources-Yjz-b6-8.js} +1 -1
- package/system/dist/{constants-Dmc-T4Zw.js → constants-7gannWcO.js} +1 -1
- package/system/dist/{constants-C6UsfDdP.mjs → constants-lWMAnwmj.mjs} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-OQqtK7Yy.mjs → device-ca-8lpRo9Ss.mjs} +1 -1
- package/system/dist/{device-ca-v8lGdWVk.js → device-ca-HGx3Pwb6.js} +1 -1
- package/system/dist/{dist-CRWinpyX.mjs → dist-DgZrPBbX.mjs} +1865 -1818
- package/system/dist/{dist-1X5ccoX2.js → dist-j7uy5oG9.js} +1876 -1775
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-BQqm5eSM.mjs → hub-mdns-ciao-BM3peDu1.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-hBZgojNT.js → hub-mdns-ciao-BUKHJL6N.js} +2 -2
- package/system/dist/index.d.ts +2 -2
- package/system/dist/index.js +51 -222
- package/system/dist/index.mjs +265 -434
- package/system/dist/kernel/moleculer/migration-api-facade.d.ts +2 -0
- package/system/dist/kernel/transport/local-child-client.d.ts +9 -0
- package/system/dist/{legacy-integration-rows-door-BUjw8YoW.js → legacy-integration-rows-door-D51X6Fdr.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-B7bwfRev.mjs → legacy-integration-rows-door-DIm4Q3Jj.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-06-drop-legacy-integrations-and-storage-locations.d.ts +12 -0
- package/system/dist/{restore-archive-D9vM-Kzb.js → restore-archive-8jRnSzmw.js} +1 -1
- package/system/dist/{restore-archive-TST7tvBk.mjs → restore-archive-D-Wmp8OK.mjs} +150 -150
- package/system/dist/{wal-maintenance-C7dJSaPS.mjs → wal-maintenance-CBnqPn4u.mjs} +0 -0
- package/system/dist/{wal-maintenance-wfVwXxO4.js → wal-maintenance-D0FMnpba.js} +0 -0
- package/system/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ 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
|
+
|
|
16
|
+
## [1.2.786] - 2026-11-06
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Pet fountain tRPC routes lose the drink counters and the Clear daily count call
|
|
21
|
+
- The integrations list shows the on/off state of the instance itself; integrations.update no longer switches ordinary integrations
|
|
22
|
+
|
|
10
23
|
## [1.2.785] - 2026-11-06
|
|
11
24
|
|
|
12
25
|
### 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
|
-
|
|
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
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
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
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
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
|
|
786
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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.
|
|
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
|
|
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
|
-
//
|
|
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',
|
|
@@ -960,6 +949,35 @@ function wizardDiscoveryMode(described) {
|
|
|
960
949
|
function getInstancesProvider(ar, addonId) {
|
|
961
950
|
return (0, integration_instances_provider_js_1.findInstancesProvider)(ar.getCapabilityRegistry(), addonId);
|
|
962
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* An integration's `enabled` is a projection of its instance body (epic #440, step 3): the one
|
|
954
|
+
* switch is `setInstanceEnabled`, stored in the addon's record. One `listInstances` call per
|
|
955
|
+
* addon answers every row of it. An addon whose provider is not up, that keeps no instance for the
|
|
956
|
+
* row, or that fails to answer keeps the registry's stored flag for that row, and a failure is
|
|
957
|
+
* logged: a listing never fails because one addon did not answer.
|
|
958
|
+
*/
|
|
959
|
+
async function projectSwitches(ar, logger, integrations) {
|
|
960
|
+
const byAddon = new Map();
|
|
961
|
+
for (const addonId of new Set(integrations.map((i) => i.addonId))) {
|
|
962
|
+
const provider = getInstancesProvider(ar, addonId);
|
|
963
|
+
if (provider === null)
|
|
964
|
+
continue;
|
|
965
|
+
try {
|
|
966
|
+
const instances = await provider.listInstances();
|
|
967
|
+
byAddon.set(addonId, new Map(instances.map((i) => [i.id, i.enabled !== false])));
|
|
968
|
+
}
|
|
969
|
+
catch (err) {
|
|
970
|
+
logger.warn('integration switch not projected: the addon did not answer', {
|
|
971
|
+
tags: { addonId },
|
|
972
|
+
meta: { error: (0, types_1.errMsg)(err) },
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return integrations.map((i) => {
|
|
977
|
+
const enabled = byAddon.get(i.addonId)?.get(i.id);
|
|
978
|
+
return enabled === undefined ? i : { ...i, enabled };
|
|
979
|
+
});
|
|
980
|
+
}
|
|
963
981
|
function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
964
982
|
const logger = loggingService.createLogger('integrations');
|
|
965
983
|
const withProcessState = (i) => ({
|
|
@@ -973,15 +991,23 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
973
991
|
for (const addonId of new Set(integrations.map((i) => i.addonId))) {
|
|
974
992
|
hidden.set(addonId, await hidesFromIntegrations(ar, addonId));
|
|
975
993
|
}
|
|
976
|
-
|
|
994
|
+
const visible = integrations.filter((i) => hidden.get(i.addonId) !== true);
|
|
995
|
+
return (await projectSwitches(ar, logger, visible)).map(withProcessState);
|
|
977
996
|
},
|
|
978
997
|
get: async (input) => {
|
|
979
998
|
const integration = await requireIntegrationRegistry(ar).getIntegration(input.id);
|
|
980
999
|
if (!integration)
|
|
981
1000
|
throw new Error(`Integration "${input.id}" not found`);
|
|
982
|
-
|
|
1001
|
+
const [projected] = await projectSwitches(ar, logger, [integration]);
|
|
1002
|
+
return withProcessState(projected ?? integration);
|
|
1003
|
+
},
|
|
1004
|
+
getByAddonId: async (input) => {
|
|
1005
|
+
const integration = await requireIntegrationRegistry(ar).getIntegrationByAddonId(input.addonId);
|
|
1006
|
+
if (!integration)
|
|
1007
|
+
return integration;
|
|
1008
|
+
const [projected] = await projectSwitches(ar, logger, [integration]);
|
|
1009
|
+
return projected ?? integration;
|
|
983
1010
|
},
|
|
984
|
-
getByAddonId: async (input) => requireIntegrationRegistry(ar).getIntegrationByAddonId(input.addonId),
|
|
985
1011
|
create: async (input) => {
|
|
986
1012
|
const { settings, ...rest } = input;
|
|
987
1013
|
const payload = rest;
|
|
@@ -1019,7 +1045,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1019
1045
|
// those would make every integration lacking the hook uncreatable, and
|
|
1020
1046
|
// would fail a good create on a flaky network. They pass, and they SAY SO
|
|
1021
1047
|
// in the log: silence here would read as "validated".
|
|
1022
|
-
const verdict = await
|
|
1048
|
+
const verdict = await testBeforeCreate(ar, input.addonId, settings ?? {}, logger, input.kind);
|
|
1023
1049
|
if (verdict.status === 'rejected') {
|
|
1024
1050
|
logger.warn('rejected — connection test refused the settings', {
|
|
1025
1051
|
tags: { addonId: input.addonId },
|
|
@@ -1058,6 +1084,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1058
1084
|
await instances.createInstance({
|
|
1059
1085
|
id: integration.id,
|
|
1060
1086
|
name: integration.name,
|
|
1087
|
+
...(input.kind !== undefined ? { kind: input.kind } : {}),
|
|
1061
1088
|
});
|
|
1062
1089
|
if (settings !== undefined && Object.keys(settings).length > 0) {
|
|
1063
1090
|
await instances.updateInstance({
|
|
@@ -1118,6 +1145,9 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1118
1145
|
});
|
|
1119
1146
|
throw new Error(`Integration "${input.id}" not found`);
|
|
1120
1147
|
}
|
|
1148
|
+
if (input.enabled !== undefined && previous.info['fixed'] !== true) {
|
|
1149
|
+
throw new Error(`Integration "${input.id}" is switched through integration-instances.setInstanceEnabled, not integrations.update`);
|
|
1150
|
+
}
|
|
1121
1151
|
const { id, ...updates } = input;
|
|
1122
1152
|
const changedFields = Object.keys(updates).filter((k) => updates[k] !== undefined);
|
|
1123
1153
|
logger.info('request', {
|
|
@@ -1139,10 +1169,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1139
1169
|
timestamp: new Date(),
|
|
1140
1170
|
source: { type: 'integration', id: result.id },
|
|
1141
1171
|
category,
|
|
1142
|
-
data: {
|
|
1143
|
-
integrationId: result.id,
|
|
1144
|
-
addonId: result.addonId,
|
|
1145
|
-
},
|
|
1172
|
+
data: { integrationId: result.id, addonId: result.addonId },
|
|
1146
1173
|
});
|
|
1147
1174
|
}
|
|
1148
1175
|
if (input.name !== undefined && input.name !== previous.name) {
|
|
@@ -1375,7 +1402,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1375
1402
|
kind,
|
|
1376
1403
|
brokerKind,
|
|
1377
1404
|
supportsLocationImport,
|
|
1378
|
-
canTest: described?.canTest === true
|
|
1405
|
+
canTest: described?.canTest === true,
|
|
1379
1406
|
existingInstances: existing.map((i) => ({
|
|
1380
1407
|
id: i.id,
|
|
1381
1408
|
name: i.name,
|
|
@@ -1384,30 +1411,6 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
|
1384
1411
|
};
|
|
1385
1412
|
}));
|
|
1386
1413
|
},
|
|
1387
|
-
testConnection: async (input) => {
|
|
1388
|
-
// The Test button. Routes to the DECLARED test (see `runConnectionTest`)
|
|
1389
|
-
// and reports the tri-state verbatim: `success` is true ONLY for
|
|
1390
|
-
// `validated`, so a test that never ran can never render as a tick — and
|
|
1391
|
-
// `status` lets the UI show "could not be validated" in its own colour
|
|
1392
|
-
// instead of a red failure nobody observed.
|
|
1393
|
-
const verdict = await runConnectionTest(ar, input.addonId, input.settings, logger);
|
|
1394
|
-
logger.info('connection test', {
|
|
1395
|
-
tags: { addonId: input.addonId },
|
|
1396
|
-
meta: {
|
|
1397
|
-
phase: 'test',
|
|
1398
|
-
status: verdict.status,
|
|
1399
|
-
testedBy: verdict.testedBy,
|
|
1400
|
-
},
|
|
1401
|
-
});
|
|
1402
|
-
return {
|
|
1403
|
-
success: verdict.status === 'validated',
|
|
1404
|
-
status: verdict.status,
|
|
1405
|
-
testedBy: verdict.testedBy,
|
|
1406
|
-
...(verdict.error !== undefined ? { error: verdict.error } : {}),
|
|
1407
|
-
...(verdict.latencyMs !== undefined ? { latencyMs: verdict.latencyMs } : {}),
|
|
1408
|
-
...(verdict.detail !== undefined ? { detail: verdict.detail } : {}),
|
|
1409
|
-
};
|
|
1410
|
-
},
|
|
1411
1414
|
};
|
|
1412
1415
|
}
|
|
1413
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:
|
|
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),
|