@camstack/server 1.2.593 → 1.2.594

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 (256) hide show
  1. package/dist/addon-root-inventory.js +11 -50
  2. package/dist/agent/addon-scan.js +6 -44
  3. package/dist/agent/agent-addon-runtime.js +3 -8
  4. package/dist/agent/agent-addon-updates.js +12 -52
  5. package/dist/agent/agent-cap-dispatch-service.js +3 -5
  6. package/dist/agent/agent-config.js +7 -42
  7. package/dist/agent/agent-deploy-swap.js +5 -41
  8. package/dist/agent/agent-group-runner.js +8 -47
  9. package/dist/agent/agent-http-auth.js +10 -22
  10. package/dist/agent/agent-http.js +69 -115
  11. package/dist/agent/agent-hub-addon-update.js +10 -16
  12. package/dist/agent/agent-hub-registration.js +4 -7
  13. package/dist/agent/agent-infra-capabilities.js +5 -9
  14. package/dist/agent/agent-json-file.js +5 -42
  15. package/dist/agent/agent-mesh-gate.js +5 -8
  16. package/dist/agent/agent-node-certificates.js +25 -28
  17. package/dist/agent/agent-pairing-local.js +10 -47
  18. package/dist/agent/agent-pairing-routes.js +16 -20
  19. package/dist/agent/agent-pairing-store.js +18 -58
  20. package/dist/agent/agent-reconnect.js +1 -4
  21. package/dist/agent/agent-service.js +42 -78
  22. package/dist/agent/agent-sniffing-listener.js +11 -48
  23. package/dist/agent/agent-undeploy.js +5 -41
  24. package/dist/agent/agent-update-routes.js +14 -19
  25. package/dist/agent/agent-update-service.js +38 -80
  26. package/dist/agent/apply-model-distribution.js +1 -4
  27. package/dist/agent/apply-stage-dev-uploads.js +6 -9
  28. package/dist/agent/derive-hub-url.js +3 -8
  29. package/dist/agent/fetch-bundle-from-hub.js +6 -9
  30. package/dist/agent/hubs-found.js +6 -43
  31. package/dist/agent/infra-boot-guard.js +1 -4
  32. package/dist/agent/infra-boot-plan.js +2 -6
  33. package/dist/agent/main.js +158 -186
  34. package/dist/agent/register-agent-cap-dispatch.js +3 -6
  35. package/dist/agent/serial-queue.js +2 -7
  36. package/dist/agent-status-page.js +1 -4
  37. package/dist/api/addon-upload.js +22 -61
  38. package/dist/api/agent-addon-delivery.js +6 -11
  39. package/dist/api/auth-whoami.js +1 -4
  40. package/dist/api/backup-download-pump.js +5 -9
  41. package/dist/api/backup-download.js +7 -10
  42. package/dist/api/core/addon-settings.router.js +16 -19
  43. package/dist/api/core/agent-pairing.router.js +76 -79
  44. package/dist/api/core/agents.router.js +21 -24
  45. package/dist/api/core/auth-admin-tokens.procedures.js +48 -52
  46. package/dist/api/core/auth-device-cert.procedures.js +62 -67
  47. package/dist/api/core/auth-limits.js +16 -25
  48. package/dist/api/core/auth-reauth.procedures.js +32 -37
  49. package/dist/api/core/auth-revoke-credentials.procedures.js +22 -26
  50. package/dist/api/core/auth-sessions.procedures.js +52 -56
  51. package/dist/api/core/auth.router.js +300 -304
  52. package/dist/api/core/cap-providers.js +74 -121
  53. package/dist/api/core/capabilities.router.js +34 -37
  54. package/dist/api/core/capability-preference-writes.js +10 -17
  55. package/dist/api/core/certificates.router.js +106 -109
  56. package/dist/api/core/cluster-nodes.router.js +15 -18
  57. package/dist/api/core/collection-preference.js +2 -6
  58. package/dist/api/core/event-bus-proxy.router.js +34 -37
  59. package/dist/api/core/failure-contributions.js +4 -8
  60. package/dist/api/core/hwaccel.router.js +17 -20
  61. package/dist/api/core/integration-secrets.js +8 -12
  62. package/dist/api/core/lifecycle-job-runner.js +13 -49
  63. package/dist/api/core/live-events.router.js +29 -32
  64. package/dist/api/core/load-contributions.js +4 -8
  65. package/dist/api/core/logging-settings.js +30 -43
  66. package/dist/api/core/logs.router.js +40 -43
  67. package/dist/api/core/notifications.router.js +15 -18
  68. package/dist/api/core/public-event-filter.js +4 -8
  69. package/dist/api/core/repl.router.js +18 -21
  70. package/dist/api/core/request-census-settings.js +11 -16
  71. package/dist/api/core/server-management.provider.js +1 -4
  72. package/dist/api/core/server-name.js +9 -17
  73. package/dist/api/core/site-location.js +16 -24
  74. package/dist/api/core/stream-probe.router.js +21 -24
  75. package/dist/api/core/system-events.router.js +23 -26
  76. package/dist/api/cors/cors-policy.js +20 -29
  77. package/dist/api/cors/register-cors-policy.js +9 -14
  78. package/dist/api/deploy-stage-registry.js +6 -10
  79. package/dist/api/dev-uploads-bundle.js +12 -50
  80. package/dist/api/health/adaptive-probe.routes.js +9 -13
  81. package/dist/api/health/health.routes.js +8 -13
  82. package/dist/api/hub-cluster-url.js +3 -9
  83. package/dist/api/model-distributor.js +12 -50
  84. package/dist/api/oauth2/consent-page.js +10 -13
  85. package/dist/api/oauth2/oauth2-routes.js +17 -25
  86. package/dist/api/oauth2/private-host.js +1 -4
  87. package/dist/api/server-upload-propagate.js +15 -51
  88. package/dist/api/server-upload.js +13 -50
  89. package/dist/api/sse-no-compression.js +1 -4
  90. package/dist/api/static/frame-policy.js +4 -9
  91. package/dist/api/static/precompressed-asset.js +15 -57
  92. package/dist/api/static/spa-mount.js +8 -47
  93. package/dist/api/static/spa-static.js +5 -12
  94. package/dist/api/tarball-manifest.js +7 -44
  95. package/dist/api/trpc/cap-mount-helpers.js +7 -12
  96. package/dist/api/trpc/cap-route-error-formatter.js +10 -13
  97. package/dist/api/trpc/cap-router-runtime.js +40 -51
  98. package/dist/api/trpc/client-ip.js +9 -20
  99. package/dist/api/trpc/core-cap-bridge.js +32 -42
  100. package/dist/api/trpc/device-collection-dispatch.js +23 -27
  101. package/dist/api/trpc/device-config-secret-redaction.js +24 -40
  102. package/dist/api/trpc/generated-cap-mounts.js +218 -222
  103. package/dist/api/trpc/generated-cap-routers.js +4688 -4850
  104. package/dist/api/trpc/http-request-census-hook.js +8 -11
  105. package/dist/api/trpc/http-request-census.js +34 -41
  106. package/dist/api/trpc/http-request-census.singleton.js +4 -8
  107. package/dist/api/trpc/localized-schema-paths.js +1 -4
  108. package/dist/api/trpc/principal-visibility.js +14 -22
  109. package/dist/api/trpc/remote-addon-update-grant.js +1 -4
  110. package/dist/api/trpc/scope-access.js +10 -15
  111. package/dist/api/trpc/server-provided-caps.js +3 -7
  112. package/dist/api/trpc/share-view-access.js +6 -14
  113. package/dist/api/trpc/trpc-error-device-tags.js +3 -6
  114. package/dist/api/trpc/trpc-error-principal.js +2 -6
  115. package/dist/api/trpc/trpc.context.js +20 -25
  116. package/dist/api/trpc/trpc.middleware.js +38 -46
  117. package/dist/api/trpc/trpc.router.js +58 -99
  118. package/dist/api/trpc/user-error.js +5 -8
  119. package/dist/api/trpc/ws-request-census.js +17 -24
  120. package/dist/api/trpc/ws-slow-consumer-guard.js +11 -16
  121. package/dist/api/upload-auth.js +5 -9
  122. package/dist/auth/addon-route-jwt-gate.js +4 -7
  123. package/dist/auth/addon-route-share-gate.js +7 -12
  124. package/dist/auth/app-confirm-page.js +17 -22
  125. package/dist/auth/app-confirm-routes.js +26 -31
  126. package/dist/auth/app-confirmations.js +7 -44
  127. package/dist/auth/app-page-shell.js +17 -30
  128. package/dist/auth/app-page-strings.js +11 -17
  129. package/dist/auth/app-passkey-page.js +16 -21
  130. package/dist/auth/app-passkey-routes.js +37 -41
  131. package/dist/auth/app-refused-route.js +13 -18
  132. package/dist/auth/auth-network-policy.js +11 -15
  133. package/dist/auth/auth-provider-gate.js +4 -9
  134. package/dist/auth/auth-rate-limit.js +3 -7
  135. package/dist/auth/client-address.js +6 -9
  136. package/dist/auth/device-enroll-proofs.js +6 -43
  137. package/dist/auth/external-link-intents.js +3 -7
  138. package/dist/auth/hub-sessions.js +6 -12
  139. package/dist/auth/native-link-completions.js +7 -11
  140. package/dist/auth/native-return.js +9 -13
  141. package/dist/auth/passkey-provider.js +26 -32
  142. package/dist/auth/second-factors.js +6 -10
  143. package/dist/auth/session-connections.js +6 -12
  144. package/dist/auth/session-cookie.js +12 -23
  145. package/dist/auth/session-lifetimes.js +8 -12
  146. package/dist/auth/session-mint.js +4 -11
  147. package/dist/auth/sso-finish-app.js +13 -16
  148. package/dist/auth/sso-finish-deps.js +21 -27
  149. package/dist/auth/sso-finish.js +28 -38
  150. package/dist/auth/sso-routes.js +22 -25
  151. package/dist/auth/used-bridge-ids.js +1 -5
  152. package/dist/boot/boot-config.js +16 -55
  153. package/dist/boot/init-sequence.js +1 -4
  154. package/dist/boot/integration-id-backfill.js +3 -8
  155. package/dist/boot/platform-keychain-key.js +5 -42
  156. package/dist/boot/post-boot.service.js +14 -18
  157. package/dist/boot/reconcile-lifecycle-jobs.js +3 -6
  158. package/dist/boot/retired-public-url-env.js +4 -8
  159. package/dist/bootstrap-packages.js +1 -4
  160. package/dist/closure-node-modules.js +2 -38
  161. package/dist/closure-patches/patch-reach.json +6 -2
  162. package/dist/core/addon/addon-call-gateway.js +1 -5
  163. package/dist/core/addon/addon-package.service.js +83 -123
  164. package/dist/core/addon/addon-process-view.js +2 -6
  165. package/dist/core/addon/addon-realign-plan.js +1 -4
  166. package/dist/core/addon/addon-registry.service.js +199 -185
  167. package/dist/core/addon/addon-row-manifest.js +1 -4
  168. package/dist/core/addon/addon-search.service.js +3 -7
  169. package/dist/core/addon/addon-settings-provider.js +1 -3
  170. package/dist/core/addon/addon-uninstall.js +4 -11
  171. package/dist/core/addon/addon.tokens.js +2 -5
  172. package/dist/core/addon/device-meta-mirror.js +8 -13
  173. package/dist/core/addon/forked-custom-actions.js +6 -11
  174. package/dist/core/addon/integration-visibility.js +3 -6
  175. package/dist/core/addon/materialize-route-path.js +1 -4
  176. package/dist/core/addon/package-dir-utils.js +8 -45
  177. package/dist/core/addon/prune-misplaced-addons.js +5 -43
  178. package/dist/core/addon/runner-convergence.js +1 -4
  179. package/dist/core/addon/runner-serialization.js +1 -4
  180. package/dist/core/addon/runner-spawn-fanout.js +3 -8
  181. package/dist/core/addon/settings-door-wiring.js +5 -8
  182. package/dist/core/addon/single-flight-refresh.js +1 -4
  183. package/dist/core/addon-bridge/addon-bridge.service.js +7 -44
  184. package/dist/core/addon-pages/addon-pages.service.js +3 -40
  185. package/dist/core/addon-widgets/addon-widgets.service.js +4 -42
  186. package/dist/core/agent/agent-addon-backfill.js +9 -17
  187. package/dist/core/agent/agent-delivery-ledger.js +3 -7
  188. package/dist/core/agent/agent-liveness-event.js +2 -6
  189. package/dist/core/agent/agent-pairing-http.js +41 -45
  190. package/dist/core/agent/agent-registry.service.js +53 -92
  191. package/dist/core/agent/cluster-node-history-mirror.js +3 -7
  192. package/dist/core/agent/cluster-node-history-store.js +113 -58
  193. package/dist/core/agent/hub-agent-pairing.js +1 -5
  194. package/dist/core/agent/node-certificates-client.js +3 -6
  195. package/dist/core/agent/node-directory.js +1 -4
  196. package/dist/core/app-links/well-known-app-links.js +2 -6
  197. package/dist/core/auth/auth.service.js +3 -8
  198. package/dist/core/auth/handoff-code.service.js +11 -49
  199. package/dist/core/auth/record-kinds.js +35 -0
  200. package/dist/core/auth/share-token.service.js +174 -122
  201. package/dist/core/capability/capability.service.js +1 -5
  202. package/dist/core/config/config.schema.js +1 -6
  203. package/dist/core/config/config.service.js +2 -6
  204. package/dist/core/events/event-bus.service.js +3 -7
  205. package/dist/core/feature/feature.service.js +2 -6
  206. package/dist/core/lifecycle/lifecycle-runner.singleton.js +5 -10
  207. package/dist/core/lifecycle/lifecycle-state-machine.js +1 -5
  208. package/dist/core/logging/log-ring-buffer.js +1 -5
  209. package/dist/core/logging/logging.service.js +5 -9
  210. package/dist/core/logging/scoped-logger.js +1 -5
  211. package/dist/core/moleculer/agent-readiness-pull.js +1 -4
  212. package/dist/core/moleculer/agent-registration-request.js +3 -7
  213. package/dist/core/moleculer/cap-call-fn.js +39 -5
  214. package/dist/core/moleculer/cap-route-authority.js +3 -8
  215. package/dist/core/moleculer/hub-mesh-guard.js +5 -9
  216. package/dist/core/moleculer/moleculer.service.js +108 -119
  217. package/dist/core/network/network-quality.service.js +2 -6
  218. package/dist/core/notification/notification-wrapper.service.js +3 -7
  219. package/dist/core/notification/toast-wrapper.service.js +3 -7
  220. package/dist/core/provider/provider.tokens.js +1 -4
  221. package/dist/core/repl/repl-engine.service.js +4 -8
  222. package/dist/core/runner-health/runner-boot-check.js +7 -15
  223. package/dist/core/runner-health/update-preflight.js +9 -14
  224. package/dist/core/server-update/server-update.service.js +12 -49
  225. package/dist/core/server-update/system-apply-closure-patches.js +6 -42
  226. package/dist/core/server-update/system-ensure-prebuilds.js +3 -6
  227. package/dist/core/server-update/system-exec-npm.js +2 -5
  228. package/dist/core/storage/fs-storage-backend.js +1 -5
  229. package/dist/core/storage/storage-location-manager.js +1 -5
  230. package/dist/core/storage/storage.service.js +2 -6
  231. package/dist/core/streaming/ffmpeg-stream-info.js +3 -8
  232. package/dist/core/streaming/stream-probe.service.js +12 -16
  233. package/dist/core/streaming/ttl-cache.js +1 -5
  234. package/dist/core/topology/topology-emitter.service.js +19 -23
  235. package/dist/core/update-availability-emitter.js +3 -7
  236. package/dist/core/update-availability-store.js +8 -45
  237. package/dist/core/updates/agent-installed-packages.js +5 -9
  238. package/dist/core/updates/restart-marker.js +3 -8
  239. package/dist/core/updates/update-check-scheduler.js +13 -18
  240. package/dist/core/updates/wrapper-update-checker.js +3 -7
  241. package/dist/first-boot-addon-plan.js +2 -6
  242. package/dist/framework-nodepath.js +2 -38
  243. package/dist/i18n/request-lang.js +7 -11
  244. package/dist/launcher.js +30 -65
  245. package/dist/lifecycle-journal-path.js +2 -38
  246. package/dist/main.js +287 -324
  247. package/dist/manual-boot.js +120 -157
  248. package/dist/node-role.js +1 -4
  249. package/dist/package-inventory.js +7 -48
  250. package/dist/pending-restore.js +7 -43
  251. package/dist/single-copy-cleanup-runner.js +9 -45
  252. package/dist/single-copy-cleanup.js +7 -15
  253. package/dist/sqlite-restore.js +9 -48
  254. package/dist/starter.js +4 -39
  255. package/dist/ui-serving/lazy-ui-serving.js +3 -39
  256. package/package.json +13 -13
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * The logging settings DOCUMENT — one authority over log levels and armed
4
3
  * diagnostics, read and written whole through `system.getLoggingSettings` /
@@ -60,24 +59,13 @@
60
59
  * this service is its only caller, so there is exactly one write authority
61
60
  * over the window (D245).
62
61
  */
63
- Object.defineProperty(exports, "__esModule", { value: true });
64
- exports.LoggingSettingsService = exports.MAX_CHANNEL_WINDOW_MS = exports.EMPTY_LOG_CHANNEL_PLANE = exports.OPS_LOG_RETENTION_DEFAULT_DAYS = exports.HUB_NODE_ID = exports.LOGGING_SETTINGS_KEY = void 0;
65
- exports.buildLogChannelPlane = buildLogChannelPlane;
66
- exports.toLoggingSettingsRecord = toLoggingSettingsRecord;
67
- exports.resolveLevel = resolveLevel;
68
- exports.describeLayers = describeLayers;
69
- exports.mergeLevel = mergeLevel;
70
- exports.validateChannelPatch = validateChannelPatch;
71
- exports.mergeChannelWindows = mergeChannelWindows;
72
- exports.liveChannelWindows = liveChannelWindows;
73
- exports.describeChannelWindows = describeChannelWindows;
74
- const types_1 = require("@camstack/types");
75
- const system_1 = require("@camstack/system");
62
+ import { errMsg, } from '@camstack/types';
63
+ import { DEFAULT_LOG_LEVEL } from '@camstack/system';
76
64
  /** The `system-settings` row this module owns. */
77
- exports.LOGGING_SETTINGS_KEY = 'logging-settings';
65
+ export const LOGGING_SETTINGS_KEY = 'logging-settings';
78
66
  const SYSTEM_SETTINGS_COLLECTION = 'system-settings';
79
67
  /** The node a hub speaks for when a caller does not name one. */
80
- exports.HUB_NODE_ID = 'hub';
68
+ export const HUB_NODE_ID = 'hub';
81
69
  const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
82
70
  /**
83
71
  * The persisted row. Every field optional — an older row must still read, and
@@ -94,9 +82,9 @@ const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
94
82
  * sweep". That reasoning is why the value stays 30 by default; it was never a
95
83
  * reason for the value to be unreachable.
96
84
  */
97
- exports.OPS_LOG_RETENTION_DEFAULT_DAYS = 30;
85
+ export const OPS_LOG_RETENTION_DEFAULT_DAYS = 30;
98
86
  /** A plane that reaches nothing. The shape of a hub with no addon booted yet. */
99
- exports.EMPTY_LOG_CHANNEL_PLANE = {
87
+ export const EMPTY_LOG_CHANNEL_PLANE = {
100
88
  declarations: async () => [],
101
89
  apply: async () => { },
102
90
  };
@@ -113,7 +101,7 @@ exports.EMPTY_LOG_CHANNEL_PLANE = {
113
101
  * own, a failure is reported to `onProviderError` (a branch that drops work
114
102
  * logs it), and the remaining providers still get the value.
115
103
  */
116
- function buildLogChannelPlane(source, onProviderError) {
104
+ export function buildLogChannelPlane(source, onProviderError) {
117
105
  return {
118
106
  declarations: async () => {
119
107
  const seen = new Map();
@@ -129,7 +117,7 @@ function buildLogChannelPlane(source, onProviderError) {
129
117
  }
130
118
  }
131
119
  catch (err) {
132
- onProviderError?.(addonId, 'list', (0, types_1.errMsg)(err));
120
+ onProviderError?.(addonId, 'list', errMsg(err));
133
121
  }
134
122
  }
135
123
  return [...seen.values()].sort((a, b) => a.name.localeCompare(b.name));
@@ -140,7 +128,7 @@ function buildLogChannelPlane(source, onProviderError) {
140
128
  await provider.apply({ windows });
141
129
  }
142
130
  catch (err) {
143
- onProviderError?.(addonId, 'apply', (0, types_1.errMsg)(err));
131
+ onProviderError?.(addonId, 'apply', errMsg(err));
144
132
  }
145
133
  }
146
134
  },
@@ -151,8 +139,8 @@ function buildLogChannelPlane(source, onProviderError) {
151
139
  * for the same reason: a diagnostic you can leave on becomes a tax nobody
152
140
  * remembers enabling.
153
141
  */
154
- exports.MAX_CHANNEL_WINDOW_MS = 30 * 60_000;
155
- class LoggingSettingsService {
142
+ export const MAX_CHANNEL_WINDOW_MS = 30 * 60_000;
143
+ export class LoggingSettingsService {
156
144
  store;
157
145
  gate;
158
146
  requestCensus;
@@ -164,10 +152,10 @@ class LoggingSettingsService {
164
152
  this.store = deps.store;
165
153
  this.gate = deps.gate;
166
154
  this.requestCensus = deps.requestCensus;
167
- this.localNodeId = deps.localNodeId ?? exports.HUB_NODE_ID;
155
+ this.localNodeId = deps.localNodeId ?? HUB_NODE_ID;
168
156
  this.logger = deps.logger;
169
157
  this.now = deps.now ?? Date.now;
170
- this.channels = deps.channels ?? exports.EMPTY_LOG_CHANNEL_PLANE;
158
+ this.channels = deps.channels ?? EMPTY_LOG_CHANNEL_PLANE;
171
159
  }
172
160
  /**
173
161
  * The document as it stands, resolved for `nodeId` (absent = the cluster).
@@ -293,7 +281,7 @@ class LoggingSettingsService {
293
281
  }
294
282
  catch (err) {
295
283
  this.logger?.warn('log channel windows written but NOT pushed to every gate', {
296
- meta: { error: (0, types_1.errMsg)(err) },
284
+ meta: { error: errMsg(err) },
297
285
  });
298
286
  }
299
287
  }
@@ -307,7 +295,7 @@ class LoggingSettingsService {
307
295
  activeWindows: await this.describeWindows(),
308
296
  channels: await this.declaredChannels(),
309
297
  activeChannels: describeChannelWindows(record ?? {}, this.now()),
310
- opsLogRetentionDays: record?.opsLogRetentionDays ?? exports.OPS_LOG_RETENTION_DEFAULT_DAYS,
298
+ opsLogRetentionDays: record?.opsLogRetentionDays ?? OPS_LOG_RETENTION_DEFAULT_DAYS,
311
299
  persisted: record !== null,
312
300
  };
313
301
  }
@@ -326,7 +314,7 @@ class LoggingSettingsService {
326
314
  }
327
315
  catch (err) {
328
316
  this.logger?.warn('log channel declarations unreadable - reporting none', {
329
- meta: { error: (0, types_1.errMsg)(err) },
317
+ meta: { error: errMsg(err) },
330
318
  });
331
319
  return [];
332
320
  }
@@ -364,13 +352,13 @@ class LoggingSettingsService {
364
352
  try {
365
353
  const raw = await this.store.get({
366
354
  collection: SYSTEM_SETTINGS_COLLECTION,
367
- key: exports.LOGGING_SETTINGS_KEY,
355
+ key: LOGGING_SETTINGS_KEY,
368
356
  });
369
357
  return toLoggingSettingsRecord(raw);
370
358
  }
371
359
  catch (err) {
372
360
  this.logger?.warn('logging settings read failed - mirror left untouched', {
373
- meta: { error: (0, types_1.errMsg)(err) },
361
+ meta: { error: errMsg(err) },
374
362
  });
375
363
  return null;
376
364
  }
@@ -379,21 +367,20 @@ class LoggingSettingsService {
379
367
  try {
380
368
  await this.store.set({
381
369
  collection: SYSTEM_SETTINGS_COLLECTION,
382
- key: exports.LOGGING_SETTINGS_KEY,
370
+ key: LOGGING_SETTINGS_KEY,
383
371
  value: record,
384
372
  });
385
373
  return true;
386
374
  }
387
375
  catch (err) {
388
- this.logger?.warn('logging settings applied in memory but NOT persisted - they will not survive a restart', { meta: { error: (0, types_1.errMsg)(err) } });
376
+ this.logger?.warn('logging settings applied in memory but NOT persisted - they will not survive a restart', { meta: { error: errMsg(err) } });
389
377
  return false;
390
378
  }
391
379
  }
392
380
  }
393
- exports.LoggingSettingsService = LoggingSettingsService;
394
381
  // ── pure helpers ────────────────────────────────────────────────────
395
382
  /** Structural read of the stored row. Anything unrecognised reads as absent. */
396
- function toLoggingSettingsRecord(value) {
383
+ export function toLoggingSettingsRecord(value) {
397
384
  if (typeof value !== 'object' || value === null)
398
385
  return {};
399
386
  const clusterLevel = asLogLevel(Reflect.get(value, 'clusterLevel'));
@@ -424,7 +411,7 @@ function toLoggingSettingsRecord(value) {
424
411
  * `stream-broker.webrtc` louder" is the request; "this node's level, but only
425
412
  * where it is not a channel" is not a request anybody makes.
426
413
  */
427
- function resolveLevel(record, nodeId, component = null) {
414
+ export function resolveLevel(record, nodeId, component = null) {
428
415
  const componentLevel = component === null ? undefined : record.componentLevels?.[component];
429
416
  if (componentLevel !== undefined)
430
417
  return { level: componentLevel, source: 'component' };
@@ -433,13 +420,13 @@ function resolveLevel(record, nodeId, component = null) {
433
420
  return { level: nodeLevel, source: 'node' };
434
421
  if (record.clusterLevel !== undefined)
435
422
  return { level: record.clusterLevel, source: 'cluster' };
436
- return { level: system_1.DEFAULT_LOG_LEVEL, source: 'default' };
423
+ return { level: DEFAULT_LOG_LEVEL, source: 'default' };
437
424
  }
438
425
  /**
439
426
  * The layers as they stand, general → specific. `level: null` means the layer
440
427
  * carries no explicit value and inherits.
441
428
  */
442
- function describeLayers(record, nodeId, component = null) {
429
+ export function describeLayers(record, nodeId, component = null) {
443
430
  const layers = [
444
431
  { scope: 'cluster', nodeId: null, component: null, level: record.clusterLevel ?? null },
445
432
  ];
@@ -472,7 +459,7 @@ function describeLayers(record, nodeId, component = null) {
472
459
  * addressing the component layer, because a component level is cluster-wide
473
460
  * and the node selector has no meaning there.
474
461
  */
475
- function mergeLevel(record, nodeId, component, next, updatedAt) {
462
+ export function mergeLevel(record, nodeId, component, next, updatedAt) {
476
463
  if (component !== null) {
477
464
  const { [component]: _clearedComponent, ...otherComponents } = record.componentLevels ?? {};
478
465
  const componentLevels = {
@@ -511,7 +498,7 @@ function mergeLevel(record, nodeId, component, next, updatedAt) {
511
498
  * worse: the operator would believe per-camera filtering works there, and
512
499
  * conclude from the first unrelated line that the wrong camera is at fault.
513
500
  */
514
- function validateChannelPatch(patches, declared) {
501
+ export function validateChannelPatch(patches, declared) {
515
502
  const byName = new Map(declared.map((d) => [d.name, d]));
516
503
  const reasons = [];
517
504
  for (const patch of patches) {
@@ -538,7 +525,7 @@ function validateChannelPatch(patches, declared) {
538
525
  * whatever window it had, so the Levels page and the Diagnostics page cannot
539
526
  * disarm each other's work.
540
527
  */
541
- function mergeChannelWindows(record, patches, nowMs) {
528
+ export function mergeChannelWindows(record, patches, nowMs) {
542
529
  const windows = { ...record.channelWindows };
543
530
  for (const patch of patches) {
544
531
  if (patch.armMs <= 0) {
@@ -547,7 +534,7 @@ function mergeChannelWindows(record, patches, nowMs) {
547
534
  }
548
535
  const ids = patch.deviceIds;
549
536
  windows[patch.channel] = {
550
- armedUntilMs: nowMs + Math.min(patch.armMs, exports.MAX_CHANNEL_WINDOW_MS),
537
+ armedUntilMs: nowMs + Math.min(patch.armMs, MAX_CHANNEL_WINDOW_MS),
551
538
  deviceIds: ids === undefined || ids === null || ids.length === 0 ? null : [...ids],
552
539
  };
553
540
  }
@@ -560,7 +547,7 @@ function mergeChannelWindows(record, patches, nowMs) {
560
547
  * restore from re-arming a diagnostic somebody forgot months ago, which is the
561
548
  * one failure a deadline exists to prevent.
562
549
  */
563
- function liveChannelWindows(record, nowMs) {
550
+ export function liveChannelWindows(record, nowMs) {
564
551
  const out = [];
565
552
  for (const [channel, window] of Object.entries(record.channelWindows ?? {})) {
566
553
  if (window.armedUntilMs <= nowMs)
@@ -570,7 +557,7 @@ function liveChannelWindows(record, nowMs) {
570
557
  return out.sort((a, b) => a.channel.localeCompare(b.channel));
571
558
  }
572
559
  /** The windows as the page shows them: deadline plus time left, never a flag. */
573
- function describeChannelWindows(record, nowMs) {
560
+ export function describeChannelWindows(record, nowMs) {
574
561
  const out = [];
575
562
  for (const [channel, window] of Object.entries(record.channelWindows ?? {})) {
576
563
  const armed = window.armedUntilMs > nowMs;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLogsRouter = createLogsRouter;
4
1
  /**
5
2
  * Logs router — fixed core API (not a capability).
6
3
  *
@@ -9,25 +6,25 @@ exports.createLogsRouter = createLogsRouter;
9
6
  * everything; viewers/protected users only see entries matching their
10
7
  * allowed providers scope (filtered in `query`).
11
8
  */
12
- const zod_1 = require("zod");
13
- const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
14
- const types_1 = require("@camstack/types");
15
- const LogLevelSchema = zod_1.z.enum(['debug', 'info', 'warn', 'error']);
16
- const LogTagsSchema = zod_1.z.object({
17
- agentId: zod_1.z.string().optional(),
18
- nodeId: zod_1.z.string().optional(),
9
+ import { z } from 'zod';
10
+ import { trpcRouter, adminProcedure, iterableSubscription } from '../trpc/trpc.middleware.js';
11
+ import { bareAddonId } from '@camstack/types';
12
+ const LogLevelSchema = z.enum(['debug', 'info', 'warn', 'error']);
13
+ const LogTagsSchema = z.object({
14
+ agentId: z.string().optional(),
15
+ nodeId: z.string().optional(),
19
16
  /** Numeric progressive id (or its string form for legacy callers). */
20
- deviceId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
17
+ deviceId: z.union([z.string(), z.number()]).optional(),
21
18
  /** Parent container id — set on every accessory child's logs (and on the
22
19
  * container's own logs). Filtering by it returns the whole container subtree
23
20
  * (container + all children) in one query. */
24
- containerDeviceId: zod_1.z.union([zod_1.z.string(), zod_1.z.number()]).optional(),
25
- deviceName: zod_1.z.string().optional(),
26
- integrationId: zod_1.z.string().optional(),
27
- addonId: zod_1.z.string().optional(),
28
- streamId: zod_1.z.string().optional(),
29
- streamName: zod_1.z.string().optional(),
30
- sessionId: zod_1.z.string().optional(),
21
+ containerDeviceId: z.union([z.string(), z.number()]).optional(),
22
+ deviceName: z.string().optional(),
23
+ integrationId: z.string().optional(),
24
+ addonId: z.string().optional(),
25
+ streamId: z.string().optional(),
26
+ streamName: z.string().optional(),
27
+ sessionId: z.string().optional(),
31
28
  /**
32
29
  * Correlation id used to scope a single short-lived operation
33
30
  * (e.g. a `testCreationField` probe). The Add-Device modal generates
@@ -35,32 +32,32 @@ const LogTagsSchema = zod_1.z.object({
35
32
  * modal can stream test logs without a deviceId (the device doesn't
36
33
  * exist yet).
37
34
  */
38
- requestId: zod_1.z.string().optional(),
35
+ requestId: z.string().optional(),
39
36
  });
40
37
  /** Wire shape of a log entry — timestamp is serialised to ISO string by tRPC. */
41
- const LogEntrySchema = zod_1.z.object({
42
- timestamp: zod_1.z.string(),
43
- level: zod_1.z.string(),
44
- scope: zod_1.z.string().optional(),
45
- message: zod_1.z.string(),
46
- tags: zod_1.z.record(zod_1.z.string(), zod_1.z.string().optional()).optional(),
38
+ const LogEntrySchema = z.object({
39
+ timestamp: z.string(),
40
+ level: z.string(),
41
+ scope: z.string().optional(),
42
+ message: z.string(),
43
+ tags: z.record(z.string(), z.string().optional()).optional(),
47
44
  /**
48
45
  * Ad-hoc structured payload attached to the log call (e.g.
49
46
  * `{error, brokerId, sourceType, url}` for stream-broker errors).
50
47
  * Tags are filterable structural fields; meta is the per-call
51
48
  * payload operators read in the expanded LogStream row.
52
49
  */
53
- meta: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional(),
50
+ meta: z.record(z.string(), z.unknown()).optional(),
54
51
  });
55
- const LogEntryArraySchema = zod_1.z.array(LogEntrySchema);
56
- function createLogsRouter(logging) {
57
- return (0, trpc_middleware_js_1.trpcRouter)({
58
- query: trpc_middleware_js_1.adminProcedure
59
- .input(zod_1.z.object({
52
+ const LogEntryArraySchema = z.array(LogEntrySchema);
53
+ export function createLogsRouter(logging) {
54
+ return trpcRouter({
55
+ query: adminProcedure
56
+ .input(z.object({
60
57
  level: LogLevelSchema.optional(),
61
- since: zod_1.z.number().optional(),
62
- until: zod_1.z.number().optional(),
63
- limit: zod_1.z.number().optional(),
58
+ since: z.number().optional(),
59
+ until: z.number().optional(),
60
+ limit: z.number().optional(),
64
61
  tags: LogTagsSchema.optional(),
65
62
  }))
66
63
  .output(LogEntryArraySchema)
@@ -85,7 +82,7 @@ function createLogsRouter(logging) {
85
82
  if (typeof addonId !== 'string')
86
83
  return false;
87
84
  return allowed.some((p) => {
88
- const bare = (0, types_1.bareAddonId)(p);
85
+ const bare = bareAddonId(p);
89
86
  return addonId === bare || addonId.startsWith(bare);
90
87
  });
91
88
  });
@@ -118,14 +115,14 @@ function createLogsRouter(logging) {
118
115
  * `query`. Admin-only so a viewer can't wipe context other ops
119
116
  * are reading.
120
117
  */
121
- clear: trpc_middleware_js_1.adminProcedure
122
- .input(zod_1.z.object({
118
+ clear: adminProcedure
119
+ .input(z.object({
123
120
  level: LogLevelSchema.optional(),
124
- since: zod_1.z.number().optional(),
125
- until: zod_1.z.number().optional(),
121
+ since: z.number().optional(),
122
+ until: z.number().optional(),
126
123
  tags: LogTagsSchema.optional(),
127
124
  }))
128
- .output(zod_1.z.object({ removed: zod_1.z.number().int().nonnegative() }))
125
+ .output(z.object({ removed: z.number().int().nonnegative() }))
129
126
  .mutation(({ input }) => {
130
127
  const filter = {};
131
128
  if (input.level)
@@ -145,13 +142,13 @@ function createLogsRouter(logging) {
145
142
  // `adminProcedure`; `subscribe` was the one non-admin door onto the same
146
143
  // data, so it is gated to match. (A scoped, device-projected log view is a
147
144
  // later, larger change — not a security hotfix.)
148
- subscribe: trpc_middleware_js_1.adminProcedure
149
- .input(zod_1.z.object({
145
+ subscribe: adminProcedure
146
+ .input(z.object({
150
147
  level: LogLevelSchema.optional(),
151
148
  tags: LogTagsSchema.optional(),
152
149
  }))
153
150
  .subscription(({ input }) => {
154
- return (0, trpc_middleware_js_1.iterableSubscription)((push) => {
151
+ return iterableSubscription((push) => {
155
152
  return logging.subscribe({
156
153
  level: input.level,
157
154
  tags: input.tags,
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNotificationsRouter = createNotificationsRouter;
4
1
  /**
5
2
  * Notifications router — fixed core API (not a capability).
6
3
  *
@@ -11,17 +8,17 @@ exports.createNotificationsRouter = createNotificationsRouter;
11
8
  * test panel live on the cap surface (`api.notificationOutput.*`); this
12
9
  * legacy router only exposes category→target routing.
13
10
  */
14
- const zod_1 = require("zod");
15
- const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
16
- const NotificationTargetRefSchema = zod_1.z.object({
17
- addonId: zod_1.z.string(),
18
- targetId: zod_1.z.string(),
11
+ import { z } from 'zod';
12
+ import { trpcRouter, protectedProcedure, adminProcedure } from '../trpc/trpc.middleware.js';
13
+ const NotificationTargetRefSchema = z.object({
14
+ addonId: z.string(),
15
+ targetId: z.string(),
19
16
  });
20
- function createNotificationsRouter(ns) {
21
- return (0, trpc_middleware_js_1.trpcRouter)({
22
- getRouting: trpc_middleware_js_1.protectedProcedure
23
- .input(zod_1.z.void())
24
- .output(zod_1.z.record(zod_1.z.string(), zod_1.z.array(NotificationTargetRefSchema)))
17
+ export function createNotificationsRouter(ns) {
18
+ return trpcRouter({
19
+ getRouting: protectedProcedure
20
+ .input(z.void())
21
+ .output(z.record(z.string(), z.array(NotificationTargetRefSchema)))
25
22
  .query(() => {
26
23
  if (!ns)
27
24
  return {};
@@ -32,12 +29,12 @@ function createNotificationsRouter(ns) {
32
29
  }
33
30
  return result;
34
31
  }),
35
- setRouting: trpc_middleware_js_1.adminProcedure
36
- .input(zod_1.z.object({
37
- category: zod_1.z.string(),
38
- targets: zod_1.z.array(NotificationTargetRefSchema),
32
+ setRouting: adminProcedure
33
+ .input(z.object({
34
+ category: z.string(),
35
+ targets: z.array(NotificationTargetRefSchema),
39
36
  }))
40
- .output(zod_1.z.void())
37
+ .output(z.void())
41
38
  .mutation(({ input }) => {
42
39
  if (!ns)
43
40
  throw new Error('Notification service unavailable');
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isPublicEvent = isPublicEvent;
4
- exports.publicRecent = publicRecent;
5
1
  /**
6
2
  * The one predicate every public event procedure applies before an event
7
3
  * leaves the hub (D224, D663): an owner-only category — today the native
@@ -14,11 +10,11 @@ exports.publicRecent = publicRecent;
14
10
  * never costs the caller a slot. The ring is bounded (`MAX_RECENT_EVENTS`), so
15
11
  * reading it whole and cutting afterwards is one bounded pass.
16
12
  */
17
- const types_1 = require("@camstack/types");
18
- function isPublicEvent(evt) {
19
- return !(0, types_1.isOwnerOnlyEventCategory)(evt.category);
13
+ import { isOwnerOnlyEventCategory } from '@camstack/types';
14
+ export function isPublicEvent(evt) {
15
+ return !isOwnerOnlyEventCategory(evt.category);
20
16
  }
21
- function publicRecent(source, filter, limit, keep) {
17
+ export function publicRecent(source, filter, limit, keep) {
22
18
  const visible = source
23
19
  .getRecent(filter)
24
20
  .filter((evt) => isPublicEvent(evt) && (keep === null || keep(evt)));
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createReplRouter = createReplRouter;
4
1
  /**
5
2
  * REPL router — fixed core API (not a capability).
6
3
  *
@@ -8,28 +5,28 @@ exports.createReplRouter = createReplRouter;
8
5
  * (`ReplEngineService` extends `ReplEngine` from `@camstack/system`).
9
6
  * Only super_admin can execute code.
10
7
  */
11
- const zod_1 = require("zod");
12
- const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
13
- const ReplScopeSchema = zod_1.z.discriminatedUnion('type', [
14
- zod_1.z.object({ type: zod_1.z.literal('system') }),
15
- zod_1.z.object({ type: zod_1.z.literal('device'), deviceId: zod_1.z.number() }),
16
- zod_1.z.object({ type: zod_1.z.literal('provider'), providerId: zod_1.z.string() }),
17
- zod_1.z.object({ type: zod_1.z.literal('addon'), addonId: zod_1.z.string() }),
8
+ import { z } from 'zod';
9
+ import { trpcRouter, adminProcedure } from '../trpc/trpc.middleware.js';
10
+ const ReplScopeSchema = z.discriminatedUnion('type', [
11
+ z.object({ type: z.literal('system') }),
12
+ z.object({ type: z.literal('device'), deviceId: z.number() }),
13
+ z.object({ type: z.literal('provider'), providerId: z.string() }),
14
+ z.object({ type: z.literal('addon'), addonId: z.string() }),
18
15
  ]);
19
- const ReplResultSchema = zod_1.z.object({
20
- output: zod_1.z.string(),
21
- error: zod_1.z.string().optional(),
22
- duration: zod_1.z.number().optional(),
16
+ const ReplResultSchema = z.object({
17
+ output: z.string(),
18
+ error: z.string().optional(),
19
+ duration: z.number().optional(),
23
20
  });
24
- function createReplRouter(repl) {
25
- return (0, trpc_middleware_js_1.trpcRouter)({
26
- execute: trpc_middleware_js_1.adminProcedure
27
- .input(zod_1.z.object({ code: zod_1.z.string().max(10000), scope: ReplScopeSchema }))
21
+ export function createReplRouter(repl) {
22
+ return trpcRouter({
23
+ execute: adminProcedure
24
+ .input(z.object({ code: z.string().max(10000), scope: ReplScopeSchema }))
28
25
  .output(ReplResultSchema)
29
26
  .mutation(({ input }) => repl.execute(input.code, { scope: input.scope, variables: {} })),
30
- completions: trpc_middleware_js_1.adminProcedure
31
- .input(zod_1.z.object({ partial: zod_1.z.string(), scope: ReplScopeSchema }))
32
- .output(zod_1.z.array(zod_1.z.string()).readonly())
27
+ completions: adminProcedure
28
+ .input(z.object({ partial: z.string(), scope: ReplScopeSchema }))
29
+ .output(z.array(z.string()).readonly())
33
30
  .query(({ input }) => repl.getCompletions(input.partial, { scope: input.scope, variables: {} })),
34
31
  });
35
32
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * The switch for the TRANSPORT census - a SYSTEM SETTING, not an env var.
4
3
  *
@@ -38,18 +37,15 @@
38
37
  * cached flag it cannot claim a window survives a restart when the write that
39
38
  * would have made it survive failed.
40
39
  */
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.RequestCensusService = exports.REQUEST_CENSUS_KEY = void 0;
43
- exports.toRecord = toRecord;
44
- const types_1 = require("@camstack/types");
45
- const http_request_census_js_1 = require("../trpc/http-request-census.js");
40
+ import { errMsg } from '@camstack/types';
41
+ import { DEFAULT_REPORT_EVERY_MS } from '../trpc/http-request-census.js';
46
42
  /** The `system-settings` row this module owns. */
47
- exports.REQUEST_CENSUS_KEY = 'http-request-census';
43
+ export const REQUEST_CENSUS_KEY = 'http-request-census';
48
44
  const SYSTEM_SETTINGS_COLLECTION = 'system-settings';
49
45
  /**
50
46
  * Arm / disarm / read the census, keeping the persisted deadline in step.
51
47
  */
52
- class RequestCensusService {
48
+ export class RequestCensusService {
53
49
  census;
54
50
  store;
55
51
  logger;
@@ -75,7 +71,7 @@ class RequestCensusService {
75
71
  * a restart, and blamed on the instrument.
76
72
  */
77
73
  async set(input) {
78
- const reportEveryMs = input.reportEveryMs ?? http_request_census_js_1.DEFAULT_REPORT_EVERY_MS;
74
+ const reportEveryMs = input.reportEveryMs ?? DEFAULT_REPORT_EVERY_MS;
79
75
  if (input.armMs <= 0)
80
76
  this.census.disarm('operator-disarmed');
81
77
  else
@@ -116,7 +112,7 @@ class RequestCensusService {
116
112
  });
117
113
  return false;
118
114
  }
119
- this.census.arm(remainingMs, record?.reportEveryMs ?? http_request_census_js_1.DEFAULT_REPORT_EVERY_MS);
115
+ this.census.arm(remainingMs, record?.reportEveryMs ?? DEFAULT_REPORT_EVERY_MS);
120
116
  this.logger?.info('transport census restored from system-settings', {
121
117
  meta: { remainingMs, armedUntilMs: this.census.armedUntilMs },
122
118
  });
@@ -131,7 +127,7 @@ class RequestCensusService {
131
127
  try {
132
128
  const raw = await this.store.get({
133
129
  collection: SYSTEM_SETTINGS_COLLECTION,
134
- key: exports.REQUEST_CENSUS_KEY,
130
+ key: REQUEST_CENSUS_KEY,
135
131
  });
136
132
  return toRecord(raw);
137
133
  }
@@ -140,7 +136,7 @@ class RequestCensusService {
140
136
  // census. It is logged because a branch that drops work silently reads
141
137
  // as "never happened".
142
138
  this.logger?.warn('transport census settings read failed', {
143
- meta: { error: (0, types_1.errMsg)(err) },
139
+ meta: { error: errMsg(err) },
144
140
  });
145
141
  return null;
146
142
  }
@@ -149,20 +145,19 @@ class RequestCensusService {
149
145
  try {
150
146
  await this.store.set({
151
147
  collection: SYSTEM_SETTINGS_COLLECTION,
152
- key: exports.REQUEST_CENSUS_KEY,
148
+ key: REQUEST_CENSUS_KEY,
153
149
  value: record,
154
150
  });
155
151
  return true;
156
152
  }
157
153
  catch (err) {
158
- this.logger?.warn('transport census armed in memory but NOT persisted - it will not survive a restart', { meta: { error: (0, types_1.errMsg)(err) } });
154
+ this.logger?.warn('transport census armed in memory but NOT persisted - it will not survive a restart', { meta: { error: errMsg(err) } });
159
155
  return false;
160
156
  }
161
157
  }
162
158
  }
163
- exports.RequestCensusService = RequestCensusService;
164
159
  /** Structural read of the stored row. Anything unrecognised reads as absent. */
165
- function toRecord(value) {
160
+ export function toRecord(value) {
166
161
  if (typeof value !== 'object' || value === null)
167
162
  return null;
168
163
  const armedUntilMs = Reflect.get(value, 'armedUntilMs');
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildServerManagementProvider = buildServerManagementProvider;
4
- function buildServerManagementProvider(service) {
1
+ export function buildServerManagementProvider(service) {
5
2
  if (service === null)
6
3
  return null;
7
4
  return {