@camstack/server 1.2.778 → 1.2.780

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 (114) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/agent/main.js +5 -1
  3. package/dist/agent/stale-addon-gate.js +52 -15
  4. package/dist/api/addon-upload.js +41 -0
  5. package/dist/api/core/cap-providers.js +19 -29
  6. package/dist/api/core/integration-role.js +15 -2
  7. package/dist/api/tarball-manifest.js +10 -1
  8. package/dist/api/trpc/generated-cap-mounts.js +1 -9
  9. package/dist/api/trpc/generated-cap-routers.js +9 -88
  10. package/dist/core/addon/addon-package.service.js +24 -8
  11. package/dist/core/addon/addon-registry.service.js +61 -10
  12. package/dist/core/addon/hub-spawn-gate.js +92 -0
  13. package/dist/core/addon/integration-instances-provider.js +22 -0
  14. package/dist/core/agent/agent-registry.service.js +6 -2
  15. package/dist/core/agent/delivery-requirements.js +22 -6
  16. package/dist/core/updates/required-addon-update.js +188 -0
  17. package/dist/launcher.js +4 -0
  18. package/dist/manual-boot.js +27 -0
  19. package/dist/server-root/index.js +74 -3
  20. package/package.json +33 -11
  21. package/system/dist/addon-runner.js +179 -4
  22. package/system/dist/addon-runner.mjs +180 -5
  23. package/system/dist/{agent-https-DnEHxqTM.js → agent-https-A9wsxVGn.js} +1 -1
  24. package/system/dist/{agent-https-DjiLJBkD.mjs → agent-https-DuxDC67S.mjs} +1 -1
  25. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  26. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  27. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  28. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  29. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  30. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  31. package/system/dist/builtins/autotrack/index.js +1 -1
  32. package/system/dist/builtins/autotrack/index.mjs +1 -1
  33. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  34. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  35. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  36. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  37. package/system/dist/builtins/camera-grid/index.js +1 -1
  38. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  39. package/system/dist/builtins/composer/composer.addon.js +3 -3
  40. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  41. package/system/dist/builtins/console-logging/index.js +1 -1
  42. package/system/dist/builtins/console-logging/index.mjs +1 -1
  43. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  44. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  45. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  46. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  47. package/system/dist/builtins/device-manager/device-manager.addon.js +6 -3
  48. package/system/dist/builtins/device-manager/device-manager.addon.mjs +6 -3
  49. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  50. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  51. package/system/dist/builtins/keychain/index.js +4 -4
  52. package/system/dist/builtins/keychain/index.mjs +4 -4
  53. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  54. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  55. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  56. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  57. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  58. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  59. package/system/dist/builtins/loki-logging/index.js +1 -1
  60. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  61. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  62. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  63. package/system/dist/builtins/platform-probe/index.js +1 -1
  64. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  65. package/system/dist/builtins/record-entries/index.js +1 -1
  66. package/system/dist/builtins/record-entries/index.mjs +1 -1
  67. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  68. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  69. package/system/dist/builtins/snapshot/index.js +1 -1
  70. package/system/dist/builtins/snapshot/index.mjs +1 -1
  71. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  72. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  73. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  74. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  75. package/system/dist/builtins/sqlite-storage/migrations/installed-runner-resolver.d.ts +7 -0
  76. package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +10 -3
  77. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +38 -9
  78. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +38 -9
  79. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  80. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  81. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  82. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  83. package/system/dist/builtins/winston-logging/index.js +1 -1
  84. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  85. package/system/dist/{capture-engine-dY1enbrF.mjs → capture-engine-CEChNpAD.mjs} +1 -1
  86. package/system/dist/{capture-engine-DW3Tts4M.js → capture-engine-D6mXfLFQ.js} +1 -1
  87. package/system/dist/{composition-sources-Ckz1nky_.mjs → composition-sources-6XYW86Kw.mjs} +1 -1
  88. package/system/dist/{composition-sources-Y_vIrdLy.js → composition-sources-cVWKVph4.js} +1 -1
  89. package/system/dist/{constants-Bbu5TQF_.js → constants-B5Yg02ii.js} +1 -1
  90. package/system/dist/{constants-9sQvihXt.mjs → constants-DqwDEYfb.mjs} +1 -1
  91. package/system/dist/{device-ca-CbuTkPXx.js → device-ca-BVz14dRd.js} +1 -1
  92. package/system/dist/{device-ca-2dQqY2z0.mjs → device-ca-oY4Xqd7s.mjs} +1 -1
  93. package/system/dist/{dist-D3StiAs2.js → dist-B4wrqheM.js} +850 -635
  94. package/system/dist/{dist-CV4RPML4.mjs → dist-BX8nZeXV.mjs} +821 -636
  95. package/system/dist/file-host-worker.js +1 -1
  96. package/system/dist/file-host-worker.mjs +1 -1
  97. package/system/dist/{hub-mdns-ciao-BlxgXzRs.mjs → hub-mdns-ciao-BDPMfOgq.mjs} +2 -2
  98. package/system/dist/{hub-mdns-ciao-BJaeVvId.js → hub-mdns-ciao-CiMMA0rT.js} +2 -2
  99. package/system/dist/index.js +418 -16
  100. package/system/dist/index.mjs +413 -18
  101. package/system/dist/kernel/addon-installer.d.ts +44 -1
  102. package/system/dist/kernel/held-installs.d.ts +21 -0
  103. package/system/dist/kernel/index.d.ts +6 -0
  104. package/system/dist/kernel/moleculer/migration-api-facade.d.ts +73 -0
  105. package/system/dist/kernel/requires-registry.d.ts +31 -0
  106. package/system/dist/kernel/transport/acting-addon.d.ts +1 -1
  107. package/system/dist/{legacy-integration-rows-door-CUeUZHro.mjs → legacy-integration-rows-door-DDA3YOxL.mjs} +1 -1
  108. package/system/dist/{legacy-integration-rows-door-BqtcbHNX.js → legacy-integration-rows-door-YuWqHZW4.js} +1 -1
  109. package/system/dist/migrations/hub/__fixtures__/seed.d.ts +23 -0
  110. package/system/dist/{restore-archive-C4r-C6Hj.mjs → restore-archive-BrtpgNCt.mjs} +1 -1
  111. package/system/dist/{restore-archive-DM-QSOiY.js → restore-archive-Cn9OShm4.js} +1 -1
  112. package/system/dist/{wal-maintenance-1dP8IFlA.js → wal-maintenance-BTzu3s-6.js} +0 -0
  113. package/system/dist/{wal-maintenance-sPn0MLRB.mjs → wal-maintenance-jgyV9NbL.mjs} +0 -0
  114. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.780] - 2026-11-06
11
+
12
+ ### Changed
13
+
14
+ - A provider's instances can be listed per section (the kinds that name a function), and an integration is listed for its devices as soon as one of its kinds brings devices
15
+ - The broker routes drop list, get, add, remove, test and settings: a broker is an instance served by integration-instances
16
+ - Generated tRPC router exposes pipelineAnalytics.getMediaLocationCensus (admin read)
17
+ - The hub no longer spawns an addon whose package is older than the running server requires; it is held back and logged until the required-addon update lands
18
+ - After a server update the hub brings every addon below the server's required minimum current on boot, even with auto-update off; a failure raises an alert and boot continues
19
+ - A delivery to an agent is held when its addon minimum is above what the node holds, naming both versions
20
+ - Addon uploads, first-boot installs and registry updates now read the package's requirements and refuse or hold a version the node cannot run, naming both versions; an unreadable requirements document is a refusal
21
+ - First boot installs the newest addon version the running server can host when latest needs a newer server, reads requirements through the same registry and npmrc auth as the install, and raises an alert for an addon it had to hold back.
22
+ - A held addon install raises an alert and resolves it once a later boot installs the package
23
+ - Migrations: in-process builtins get ctx.migrationApi
24
+
25
+ ## [1.2.779] - 2026-11-05
26
+
27
+ ### Changed
28
+
29
+ - Rebuilt against updated dependencies.
30
+
10
31
  ## [1.2.778] - 2026-11-05
11
32
 
12
33
  ### Changed
@@ -144,6 +144,8 @@ async function startAgent(configPath) {
144
144
  const installer = new system_1.AddonInstaller({
145
145
  addonsDir: config.addonsDir,
146
146
  ...(bundledDir && fs.existsSync(bundledDir) ? { bundledAddonsDir: bundledDir } : {}),
147
+ // A registry install at boot is judged against the server this agent runs (D989).
148
+ serverVersion: (0, addon_requirements_js_1.readRunningServerVersion)(),
147
149
  });
148
150
  await installer.ensureRequiredPackages(system_1.AddonInstaller.AGENT_PACKAGES);
149
151
  // Restore repair, mirroring the hub launcher (D338): reinstall ONLY the
@@ -1302,7 +1304,7 @@ async function bootCoreAddons(broker, config, registry, loadedAddons, loggerFact
1302
1304
  function spawnableCandidates(candidates, addonsDir, log) {
1303
1305
  if (candidates.length === 0)
1304
1306
  return candidates;
1305
- const { ready, deferred } = (0, stale_addon_gate_js_1.gateStaleCandidates)(candidates, {
1307
+ const { ready, deferred, unjudged } = (0, stale_addon_gate_js_1.gateStaleCandidates)(candidates, {
1306
1308
  serverVersion: (0, addon_requirements_js_1.readRunningServerVersion)(),
1307
1309
  serverRequiresAddons: (0, addon_requirements_js_1.readRunningServerAddonMinimums)(),
1308
1310
  installedVersions: (0, installed_addon_versions_js_1.readInstalledAddonVersions)(addonsDir),
@@ -1310,6 +1312,8 @@ function spawnableCandidates(candidates, addonsDir, log) {
1310
1312
  });
1311
1313
  for (const d of deferred)
1312
1314
  log(`[Agent] ${d.reason}`);
1315
+ for (const line of unjudged)
1316
+ log(`[Agent] ${line}`);
1313
1317
  return ready;
1314
1318
  }
1315
1319
  async function loadClusterCapableAddons(broker, config, capabilityRegistry, loadedAddons) {
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isUnreadableRequires = isUnreadableRequires;
36
37
  exports.gateStaleCandidates = gateStaleCandidates;
37
38
  exports.readPackageRequires = readPackageRequires;
38
39
  /**
@@ -51,19 +52,40 @@ exports.readPackageRequires = readPackageRequires;
51
52
  * (`requires.addons` of the server), or
52
53
  * - the addon's own `requires.server` is above the running server.
53
54
  *
54
- * A running server version that cannot be read judges nothing (D49: a failed
55
- * read changes nothing); the addon-minimum check does not need it and still runs.
55
+ * A fact that cannot be read is UNKNOWN, never a pass. A package whose own
56
+ * `requires` cannot be read (missing, malformed or schema-invalid package.json)
57
+ * is deferred with the reason. A running server version that cannot be read
58
+ * leaves the addon's own `requires.server` unjudged: it is spawned (every addon
59
+ * held would leave the node empty) but reported in `unjudged`, so the caller
60
+ * logs it. The addon-minimum check does not need the version and still runs.
56
61
  */
57
62
  const fs = __importStar(require("node:fs"));
58
63
  const path = __importStar(require("node:path"));
59
64
  const types_1 = require("@camstack/types");
65
+ function isUnreadableRequires(value) {
66
+ return value !== undefined && 'unreadable' in value;
67
+ }
60
68
  function gateStaleCandidates(candidates, context) {
61
69
  const ready = [];
62
70
  const deferred = [];
71
+ const unjudged = [];
63
72
  for (const candidate of candidates) {
64
73
  const minimum = context.serverRequiresAddons[candidate.packageName];
65
74
  const fromServer = (0, types_1.unmetRequirements)(minimum === undefined ? undefined : { addons: { [candidate.packageName]: minimum } }, { server: context.serverVersion, addons: context.installedVersions, wrapper: null });
66
- const own = context.requiresOfDir(candidate.addonDir);
75
+ const read = context.requiresOfDir(candidate.addonDir);
76
+ const label = `addon "${candidate.addonId}" (${candidate.packageName}@${candidate.packageVersion})`;
77
+ if (isUnreadableRequires(read)) {
78
+ deferred.push({
79
+ candidate,
80
+ unmet: fromServer,
81
+ reason: `${label} deferred: its package requirements could not be read (${read.unreadable})`,
82
+ });
83
+ continue;
84
+ }
85
+ const own = read;
86
+ if (context.serverVersion === null && own?.server !== undefined) {
87
+ unjudged.push(`${label} spawned unjudged: it requires server ${own.server} and the running server version is unknown`);
88
+ }
67
89
  const fromAddon = context.serverVersion === null
68
90
  ? []
69
91
  : (0, types_1.unmetRequirements)(own?.server === undefined ? undefined : { server: own.server }, {
@@ -79,24 +101,39 @@ function gateStaleCandidates(candidates, context) {
79
101
  deferred.push({
80
102
  candidate,
81
103
  unmet,
82
- reason: `addon "${candidate.addonId}" (${candidate.packageName}@${candidate.packageVersion}) deferred until its package is reconciled: ${unmet.map(types_1.describeUnmet).join('; ')}`,
104
+ reason: `${label} deferred until its package is reconciled: ${unmet.map(types_1.describeUnmet).join('; ')}`,
83
105
  });
84
106
  }
85
- return { ready, deferred };
107
+ return { ready, deferred, unjudged };
86
108
  }
87
- /** `camstack.requires` of the package.json in `dir`; `undefined` when absent or malformed. */
109
+ /**
110
+ * `camstack.requires` of the package.json in `dir`: `undefined` when the package
111
+ * declares none, `UnreadableRequires` when the file is missing, not JSON, or
112
+ * declares a `requires` the schema rejects (never a pass).
113
+ */
88
114
  function readPackageRequires(dir) {
115
+ let raw;
89
116
  try {
90
- const raw = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
91
- if (typeof raw !== 'object' || raw === null)
92
- return undefined;
93
- const camstack = Reflect.get(raw, 'camstack');
94
- if (typeof camstack !== 'object' || camstack === null)
95
- return undefined;
96
- const parsed = types_1.PackageRequiresSchema.safeParse(Reflect.get(camstack, 'requires'));
97
- return parsed.success ? parsed.data : undefined;
117
+ raw = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
118
+ }
119
+ catch (err) {
120
+ return { unreadable: `package.json: ${err instanceof Error ? err.message : String(err)}` };
98
121
  }
99
- catch {
122
+ if (typeof raw !== 'object' || raw === null)
123
+ return { unreadable: 'package.json is not an object' };
124
+ const camstack = Reflect.get(raw, 'camstack');
125
+ if (camstack === undefined)
100
126
  return undefined;
127
+ if (typeof camstack !== 'object' || camstack === null) {
128
+ return { unreadable: 'package.json "camstack" is not an object' };
101
129
  }
130
+ const declared = Reflect.get(camstack, 'requires');
131
+ if (declared === undefined)
132
+ return undefined;
133
+ const parsed = types_1.PackageRequiresSchema.safeParse(declared);
134
+ return parsed.success
135
+ ? parsed.data
136
+ : {
137
+ unreadable: `camstack.requires is malformed: ${parsed.error.issues[0]?.message ?? 'invalid'}`,
138
+ };
102
139
  }
@@ -40,7 +40,9 @@ exports.registerAddonUploadRoute = registerAddonUploadRoute;
40
40
  const fs = __importStar(require("node:fs"));
41
41
  const os = __importStar(require("node:os"));
42
42
  const path = __importStar(require("node:path"));
43
+ const types_1 = require("@camstack/types");
43
44
  const addon_package_service_js_1 = require("../core/addon/addon-package.service.js");
45
+ const addon_requirements_js_1 = require("../core/addon/addon-requirements.js");
44
46
  const index_js_1 = require("../server-root/index.js");
45
47
  const agent_addon_delivery_js_1 = require("./agent-addon-delivery.js");
46
48
  const deploy_stage_registry_js_1 = require("./deploy-stage-registry.js");
@@ -182,6 +184,24 @@ convergence) {
182
184
  error: 'Tarball missing or malformed package/package.json (name + version required)',
183
185
  });
184
186
  }
187
+ // Gate (D989, planning#447): an archive that needs a newer server or addon than the
188
+ // target runs is refused BEFORE it is installed or shipped, with the typed reasons.
189
+ const unmet = unmetForTarget(manifest, nodeId, convergence);
190
+ if (unmet.length > 0) {
191
+ const reason = unmet.map(types_1.describeUnmet).join('; ');
192
+ logger.warn('addon upload refused: requirements unmet', {
193
+ meta: {
194
+ package: manifest.name,
195
+ version: manifest.version,
196
+ target: nodeId ?? 'hub',
197
+ unmet: reason,
198
+ },
199
+ });
200
+ return reply.status(409).send({
201
+ error: `Refused: ${manifest.name}@${manifest.version} needs more than ${nodeId && nodeId !== 'hub' ? nodeId : 'the hub'} runs — ${reason}`,
202
+ unmet,
203
+ });
204
+ }
185
205
  // Branch by deployment target. `nodeId === 'hub'` (or absent) installs on
186
206
  // the hub AND broadcasts to every connected agent that can run any of
187
207
  // the package's addons (i.e. anything not marked hub-only). Any other
@@ -193,6 +213,27 @@ convergence) {
193
213
  return deployToAgent(reply, moleculer, logger, nodeId, agentAddonId, buffer, resolveClusterBaseUrl, deliveryLedger, convergence);
194
214
  });
195
215
  }
216
+ /**
217
+ * What the archive's `requires` asks that its target does not meet. The hub
218
+ * knows its own server and installed addons; an agent's roster is not known
219
+ * here, so only the server minimum binds a delivery to it (the reconcile judges
220
+ * the rest against the live roster).
221
+ */
222
+ function unmetForTarget(manifest, nodeId, convergence) {
223
+ if (!nodeId || nodeId === 'hub') {
224
+ return (0, addon_requirements_js_1.unmetAddonRequirements)(manifest.requires, {
225
+ serverVersion: (0, addon_requirements_js_1.readRunningServerVersion)(),
226
+ addonsDir: () => {
227
+ const dataDir = path.resolve(process.env['CAMSTACK_DATA'] ?? 'camstack-data');
228
+ return process.env['CAMSTACK_ADDONS_DIR'] ?? path.resolve(dataDir, 'addons');
229
+ },
230
+ });
231
+ }
232
+ return (0, addon_requirements_js_1.unmetAddonRequirements)(manifest.requires, {
233
+ serverVersion: convergence?.nodeServerVersion?.(nodeId) ?? null,
234
+ addonsDir: () => '',
235
+ }).filter((u) => u.kind === 'server-too-old');
236
+ }
196
237
  /**
197
238
  * Read the on-disk package.json and decide whether the package contains
198
239
  * anything that needs to land on agents. We deliberately read from disk
@@ -774,25 +774,16 @@ function getConnectionTestProvider(ar, addonId) {
774
774
  const provider = ar.getCapabilityRegistry().getProviderByAddon('connection-test', addonId);
775
775
  return isConnectionTestProvider(provider) ? provider : null;
776
776
  }
777
- function isBrokerProvider(value) {
778
- return (value !== null &&
779
- typeof value === 'object' &&
780
- typeof Reflect.get(value, 'testConnection') === 'function');
781
- }
782
777
  /**
783
778
  * Does this addon declare a pre-creation test at all? Drives
784
779
  * `getAvailableTypes().canTest`, so the wizard can say "this one cannot be
785
780
  * tested" instead of offering a button that always answers the same nonsense.
786
781
  *
787
- * Broker-mode addons count: their connection identity is the broker, and the
788
- * broker cap owns a real `testConnection`.
782
+ * A broker-mode addon declares its test through `integration-instances` (`describe().canTest`,
783
+ * read by the caller), never through the broker cap.
789
784
  */
790
- function declaresConnectionTest(ar, addonId, mode) {
791
- if (getConnectionTestProvider(ar, addonId) !== null)
792
- return true;
793
- if (mode !== 'broker')
794
- return false;
795
- return isBrokerProvider(ar.getCapabilityRegistry().getProviderByAddon('broker', addonId));
785
+ function declaresConnectionTest(ar, addonId) {
786
+ return getConnectionTestProvider(ar, addonId) !== null;
796
787
  }
797
788
  /**
798
789
  * Run the DECLARED pre-creation test for `(addonId, settings)`.
@@ -874,25 +865,24 @@ async function runConnectionTest(ar, addonId, settings, logger) {
874
865
  // settings NAME a broker, not because nothing else matched.
875
866
  const brokerId = settings['brokerId'];
876
867
  if (typeof brokerId === 'string' && brokerId.length > 0) {
877
- const brokerProvider = ar
878
- .getCapabilityRegistry()
879
- .getProviderByAddonId('broker', addonId);
880
- if (!brokerProvider) {
868
+ const brokerInstances = getInstancesProvider(ar, addonId);
869
+ if (brokerInstances === null || brokerInstances.testInstance === undefined) {
881
870
  return {
882
871
  status: 'inconclusive',
883
- error: `Broker provider for addon '${addonId}' is not available`,
872
+ error: `Instances provider for addon '${addonId}' is not available`,
884
873
  testedBy: null,
885
874
  };
886
875
  }
887
876
  try {
888
- const result = await brokerProvider.testConnection({ id: brokerId });
889
- return result.ok
890
- ? {
891
- status: 'validated',
892
- latencyMs: result.latencyMs,
893
- testedBy: addonId,
894
- }
895
- : { status: 'rejected', error: result.error, testedBy: addonId };
877
+ const result = await brokerInstances.testInstance({ id: brokerId, values: {} });
878
+ const status = result.status ?? (result.success ? 'validated' : 'rejected');
879
+ return {
880
+ status,
881
+ testedBy: addonId,
882
+ ...(result.error !== undefined ? { error: result.error } : {}),
883
+ ...(result.latencyMs !== undefined ? { latencyMs: result.latencyMs } : {}),
884
+ ...(result.detail !== undefined ? { detail: result.detail } : {}),
885
+ };
896
886
  }
897
887
  catch (err) {
898
888
  logger.warn('broker connection test could not run', {
@@ -934,7 +924,7 @@ exports.INTEGRATION_CAP_MARKERS = new Set(['device-provider', 'device-adoption']
934
924
  * An entry that brings only service connections (`integrationRole: 'services'`, or derived
935
925
  * from `integration-instances`) is configured from its function page (D996): it is neither
936
926
  * an integration type nor a row of the Integrations list. An entry with devices AND
937
- * `integration-instances` declares its role (`devices` or `both`) and is listed for its devices. Decided from the manifest, so a not-yet-registered provider does
927
+ * `integration-instances` declares its role (`devices`) and is listed for its devices. Decided from the manifest, so a not-yet-registered provider does
938
928
  * not flash a row in. A row it already has stays in the registry and reachable by id.
939
929
  */
940
930
  async function hidesFromIntegrations(ar, addonId) {
@@ -945,7 +935,7 @@ async function hidesFromIntegrations(ar, addonId) {
945
935
  const described = declared === undefined ? await describedInstancesOf(getInstancesProvider(ar, addonId)) : null;
946
936
  return !(0, integration_role_js_1.bringsDevices)((0, integration_role_js_1.resolveIntegrationRole)({
947
937
  integrationRole: declared,
948
- describedRole: described?.role,
938
+ describedRole: (0, integration_role_js_1.describedRoleOf)(described),
949
939
  capabilities: addon.manifest.capabilities,
950
940
  }));
951
941
  }
@@ -1385,7 +1375,7 @@ function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
1385
1375
  kind,
1386
1376
  brokerKind,
1387
1377
  supportsLocationImport,
1388
- canTest: described?.canTest === true || declaresConnectionTest(ar, m.id, mode),
1378
+ canTest: described?.canTest === true || declaresConnectionTest(ar, m.id),
1389
1379
  existingInstances: existing.map((i) => ({
1390
1380
  id: i.id,
1391
1381
  name: i.name,
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveIntegrationRole = resolveIntegrationRole;
4
4
  exports.bringsDevices = bringsDevices;
5
+ exports.describedRoleOf = describedRoleOf;
5
6
  const INSTANCES_CAP = 'integration-instances';
6
7
  /**
7
8
  * What an addon entry brings, in this order: the manifest's explicit `integrationRole` (an
8
9
  * override), the `role` its `integration-instances` provider describes, and only for an addon
9
10
  * still on the legacy rows, the capabilities the entry declares (`integration-instances` means
10
- * service connections, anything else devices). A dual entry is never derived — it says `both`.
11
+ * service connections, anything else devices).
11
12
  */
12
13
  function resolveIntegrationRole(source) {
13
14
  if (source.integrationRole !== undefined)
@@ -19,5 +20,17 @@ function resolveIntegrationRole(source) {
19
20
  }
20
21
  /** True when the entry's devices belong on the Integrations page. */
21
22
  function bringsDevices(role) {
22
- return role === 'devices' || role === 'both';
23
+ return role === 'devices';
24
+ }
25
+ /**
26
+ * The role a provider's description stands for: `devices` as soon as ONE of its kinds brings
27
+ * devices (a kind without its own `role` takes the provider's), otherwise the provider's `role`.
28
+ */
29
+ function describedRoleOf(description) {
30
+ if (description === null)
31
+ return undefined;
32
+ const kinds = description.kinds ?? [];
33
+ return kinds.some((kind) => (kind.role ?? description.role) === 'devices')
34
+ ? 'devices'
35
+ : description.role;
23
36
  }
@@ -44,6 +44,7 @@ const node_child_process_1 = require("node:child_process");
44
44
  const fs = __importStar(require("node:fs"));
45
45
  const os = __importStar(require("node:os"));
46
46
  const path = __importStar(require("node:path"));
47
+ const types_1 = require("@camstack/types");
47
48
  const TARBALL_EXTENSIONS = ['.tgz', '.tar.gz'];
48
49
  function isTarballFilename(filename) {
49
50
  return TARBALL_EXTENSIONS.some((ext) => filename.endsWith(ext));
@@ -75,7 +76,15 @@ function readTarballManifest(buffer, filename) {
75
76
  const pkg = parsed;
76
77
  if (typeof pkg['name'] !== 'string' || typeof pkg['version'] !== 'string')
77
78
  return null;
78
- return { name: pkg['name'], version: pkg['version'] };
79
+ const camstack = pkg['camstack'];
80
+ const requires = typeof camstack === 'object' && camstack !== null
81
+ ? types_1.PackageRequiresSchema.safeParse(Reflect.get(camstack, 'requires'))
82
+ : undefined;
83
+ return {
84
+ name: pkg['name'],
85
+ version: pkg['version'],
86
+ ...(requires?.success ? { requires: requires.data } : {}),
87
+ };
79
88
  }
80
89
  catch {
81
90
  return null;
@@ -130,15 +130,7 @@ function mountAllCaps(services) {
130
130
  return reg.getProviderByAddonId('broker', addonId);
131
131
  }
132
132
  const entries = reg.getCollectionEntries('broker');
133
- if (entries.length === 0)
134
- return null;
135
- const providers = entries.map(([, p]) => p);
136
- const first = providers[0];
137
- return {
138
- ...first,
139
- list: (0, cap_mount_helpers_js_1.concatCollection)(providers, 'list'),
140
- listProviders: (0, cap_mount_helpers_js_1.concatCollection)(providers, 'listProviders'),
141
- };
133
+ return entries[0]?.[1] ?? null;
142
134
  }, remoteCapProxy),
143
135
  button: (0, generated_cap_routers_js_1.createCapRouter_button)((_ctx) => (0, cap_mount_helpers_js_1.requireDeviceScoped)(reg, 'button'), remoteCapProxy),
144
136
  calendarSource: (0, generated_cap_routers_js_1.createCapRouter_calendarSource)((_ctx, addonId) => {
@@ -1699,76 +1699,6 @@ function createCapRouter_broker(getProvider, createRemoteProxy) {
1699
1699
  const p = resolveProvider('broker', input?.nodeId, () => getProvider(ctx, input?.addonId), createRemoteProxy);
1700
1700
  return p.getStatus();
1701
1701
  }),
1702
- list: trpc_middleware_js_1.protectedProcedure
1703
- .input(types_27.brokerCapability.methods.list.input.loose())
1704
- .output(types_27.brokerCapability.methods.list.output)
1705
- .query(async ({ input, ctx }) => {
1706
- const { nodeId, addonId, ...methodInput } = input;
1707
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1708
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1709
- return p.list(methodInput);
1710
- }),
1711
- get: trpc_middleware_js_1.protectedProcedure
1712
- .input(types_27.brokerCapability.methods.get.input.loose())
1713
- .output(types_27.brokerCapability.methods.get.output)
1714
- .query(async ({ input, ctx }) => {
1715
- const { nodeId, addonId, ...methodInput } = input;
1716
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1717
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1718
- return p.get(methodInput);
1719
- }),
1720
- listProviders: trpc_middleware_js_1.adminProcedure
1721
- .input(zod_1.z.object({ nodeId: zod_1.z.string().optional(), addonId: zod_1.z.string().optional() }).optional())
1722
- .output(types_27.brokerCapability.methods.listProviders.output)
1723
- .query(async ({ input, ctx }) => {
1724
- const p = resolveProvider('broker', input?.nodeId, () => getProvider(ctx, input?.addonId), createRemoteProxy);
1725
- return p.listProviders();
1726
- }),
1727
- add: trpc_middleware_js_1.adminProcedure
1728
- .input(types_27.brokerCapability.methods.add.input.loose())
1729
- .output(types_27.brokerCapability.methods.add.output)
1730
- .mutation(async ({ input, ctx }) => {
1731
- const { nodeId, addonId, ...methodInput } = input;
1732
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1733
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1734
- return p.add(methodInput);
1735
- }),
1736
- remove: trpc_middleware_js_1.adminProcedure
1737
- .input(types_27.brokerCapability.methods.remove.input.loose())
1738
- .output(types_27.brokerCapability.methods.remove.output)
1739
- .mutation(async ({ input, ctx }) => {
1740
- const { nodeId, addonId, ...methodInput } = input;
1741
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1742
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1743
- return p.remove(methodInput);
1744
- }),
1745
- testConnection: trpc_middleware_js_1.adminProcedure
1746
- .input(types_27.brokerCapability.methods.testConnection.input.loose())
1747
- .output(types_27.brokerCapability.methods.testConnection.output)
1748
- .mutation(async ({ input, ctx }) => {
1749
- const { nodeId, addonId, ...methodInput } = input;
1750
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1751
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1752
- return p.testConnection(methodInput);
1753
- }),
1754
- getSettings: trpc_middleware_js_1.adminProcedure
1755
- .input(types_27.brokerCapability.methods.getSettings.input.loose())
1756
- .output(types_27.brokerCapability.methods.getSettings.output)
1757
- .query(async ({ input, ctx }) => {
1758
- const { nodeId, addonId, ...methodInput } = input;
1759
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1760
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1761
- return p.getSettings(methodInput);
1762
- }),
1763
- setSettings: trpc_middleware_js_1.adminProcedure
1764
- .input(types_27.brokerCapability.methods.setSettings.input.loose())
1765
- .output(types_27.brokerCapability.methods.setSettings.output)
1766
- .mutation(async ({ input, ctx }) => {
1767
- const { nodeId, addonId, ...methodInput } = input;
1768
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1769
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1770
- return p.setSettings(methodInput);
1771
- }),
1772
1702
  getBrokerConfig: trpc_middleware_js_1.adminProcedure
1773
1703
  .input(types_27.brokerCapability.methods.getBrokerConfig.input.loose())
1774
1704
  .output(types_27.brokerCapability.methods.getBrokerConfig.output)
@@ -1778,24 +1708,6 @@ function createCapRouter_broker(getProvider, createRemoteProxy) {
1778
1708
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1779
1709
  return p.getBrokerConfig(methodInput);
1780
1710
  }),
1781
- getSettingsSchema: trpc_middleware_js_1.adminProcedure
1782
- .input(types_27.brokerCapability.methods.getSettingsSchema.input.loose())
1783
- .output(types_27.brokerCapability.methods.getSettingsSchema.output)
1784
- .query(async ({ input, ctx }) => {
1785
- const { nodeId, addonId, ...methodInput } = input;
1786
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1787
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1788
- return p.getSettingsSchema(methodInput);
1789
- }),
1790
- testSettings: trpc_middleware_js_1.adminProcedure
1791
- .input(types_27.brokerCapability.methods.testSettings.input.loose())
1792
- .output(types_27.brokerCapability.methods.testSettings.output)
1793
- .mutation(async ({ input, ctx }) => {
1794
- const { nodeId, addonId, ...methodInput } = input;
1795
- const p = resolveProvider('broker', nodeId, () => getProvider(ctx, addonId), createRemoteProxy);
1796
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
1797
- return p.testSettings(methodInput);
1798
- }),
1799
1711
  publish: trpc_middleware_js_1.adminProcedure
1800
1712
  .input(types_27.brokerCapability.methods.publish.input.loose())
1801
1713
  .output(types_27.brokerCapability.methods.publish.output)
@@ -8814,6 +8726,15 @@ function createCapRouter_pipelineAnalytics(getProvider, createRemoteProxy) {
8814
8726
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
8815
8727
  return p.countUnstampedEventMedia(methodInput);
8816
8728
  }),
8729
+ getMediaLocationCensus: trpc_middleware_js_1.adminProcedure
8730
+ .input(types_113.pipelineAnalyticsCapability.methods.getMediaLocationCensus.input.loose())
8731
+ .output(types_113.pipelineAnalyticsCapability.methods.getMediaLocationCensus.output)
8732
+ .query(async ({ input, ctx }) => {
8733
+ const { nodeId, ...methodInput } = input;
8734
+ const p = resolveProvider('pipeline-analytics', nodeId, () => getProvider(ctx), createRemoteProxy);
8735
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
8736
+ return p.getMediaLocationCensus(methodInput);
8737
+ }),
8817
8738
  countRelocatableMedia: trpc_middleware_js_1.adminProcedure
8818
8739
  .input(types_113.pipelineAnalyticsCapability.methods.countRelocatableMedia.input.loose())
8819
8740
  .output(types_113.pipelineAnalyticsCapability.methods.countRelocatableMedia.output)
@@ -1010,7 +1010,21 @@ class AddonPackageService {
1010
1010
  if (category === 'addon') {
1011
1011
  // D989: a version that needs a newer server (or addon) than this node
1012
1012
  // runs is refused BEFORE it is installed, naming both versions.
1013
- const unmet = this.unmetFor(await this.fetchRequires(name, version ?? 'latest'));
1013
+ const target = await this.fetchRequires(name, version ?? 'latest');
1014
+ // A registry document that cannot be read is NOT "declares nothing": the
1015
+ // package may need a newer server, and a failed read is never a pass (D989).
1016
+ if (!target.read) {
1017
+ this.logger.warn('Addon update refused: the target requirements could not be read', {
1018
+ meta: { name, version, reason: target.reason },
1019
+ });
1020
+ return {
1021
+ success: false,
1022
+ version: '',
1023
+ requiresRestart: false,
1024
+ error: `Refused: ${name}${version ? `@${version}` : ''} — its requirements could not be read from the registry (${target.reason}); nothing was installed`,
1025
+ };
1026
+ }
1027
+ const unmet = this.unmetFor(target.requires);
1014
1028
  if (unmet.length > 0) {
1015
1029
  const reason = unmet.map(types_1.describeUnmet).join('; ');
1016
1030
  this.logger.warn('Addon update refused: requirements unmet', {
@@ -1973,7 +1987,8 @@ class AddonPackageService {
1973
1987
  // fall through to the registry
1974
1988
  }
1975
1989
  }
1976
- return this.fetchRequires(name, version);
1990
+ const target = await this.fetchRequires(name, version);
1991
+ return target.read ? target.requires : undefined;
1977
1992
  }
1978
1993
  /** What a target's `camstack.requires` asks that this node does not meet (D989). */
1979
1994
  unmetFor(requires) {
@@ -1984,8 +1999,8 @@ class AddonPackageService {
1984
1999
  }
1985
2000
  /**
1986
2001
  * The `camstack.requires` of one registry version. An unreadable answer is
1987
- * "declares nothing": the install that follows asks the same registry and
1988
- * fails on its own if it is really down.
2002
+ * reported as such (`read: false`) and never folded into "declares nothing":
2003
+ * the caller that installs refuses, the one that only reports may carry on.
1989
2004
  */
1990
2005
  async fetchRequires(name, spec) {
1991
2006
  try {
@@ -1993,15 +2008,16 @@ class AddonPackageService {
1993
2008
  const response = await fetch(url, {
1994
2009
  signal: AbortSignal.timeout(AddonPackageService.REGISTRY_TIMEOUT_MS),
1995
2010
  });
1996
- if (!response.ok)
1997
- return undefined;
1998
- return (0, addon_requirements_js_1.requiresOfVersionDoc)(await fetchJsonObject(response));
2011
+ if (!response.ok) {
2012
+ return { read: false, reason: `the registry answered ${response.status}` };
2013
+ }
2014
+ return { read: true, requires: (0, addon_requirements_js_1.requiresOfVersionDoc)(await fetchJsonObject(response)) };
1999
2015
  }
2000
2016
  catch (error) {
2001
2017
  this.logger.warn('Could not read the requirements of the target version', {
2002
2018
  meta: { name, spec, error: (0, types_2.errMsg)(error) },
2003
2019
  });
2004
- return undefined;
2020
+ return { read: false, reason: (0, types_2.errMsg)(error) };
2005
2021
  }
2006
2022
  }
2007
2023
  /** Only allow @camstack/* scoped packages */