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