diff --git a/server/scripts/import-boundaries-baseline.json b/server/scripts/import-boundaries-baseline.json index 5a9efa192..d9d0ba6e6 100644 --- a/server/scripts/import-boundaries-baseline.json +++ b/server/scripts/import-boundaries-baseline.json @@ -12,27 +12,10 @@ "assignments -> mcp-shared", "assignments -> realtime", "atlas -> addons", - "auth -> budget", - "auth -> files", - "auth -> notifications", "auth -> plugins", "budget -> addons", "budget -> mcp-shared", "budget -> realtime", - "calendar -> days", - "calendar -> reservations", - "categories -> mcp-shared", - "collab -> addons", - "collab -> files", - "collab -> mcp-shared", - "collab -> notifications", - "collab -> realtime", - "collections -> addons", - "collections -> notifications", - "collections -> places", - "collections -> realtime", - "day-notes -> mcp-shared", - "day-notes -> realtime", "days -> accommodations", "days -> assignments", "days -> mcp-shared", @@ -55,7 +38,6 @@ "journey -> memories", "journey -> photos", "journey -> realtime", - "llm-parse -> addons", "maps -> geo", "mcp-shared -> realtime", "memories -> addons", @@ -63,10 +45,6 @@ "memories -> photos", "memories -> realtime", "notifications -> realtime", - "packing -> addons", - "packing -> mcp-shared", - "packing -> notifications", - "packing -> realtime", "photos -> memories", "places -> accommodations", "places -> assignments", @@ -74,29 +52,9 @@ "places -> journey", "places -> mcp-shared", "places -> realtime", - "plugins -> accommodations", - "plugins -> addons", - "plugins -> assignments", - "plugins -> atlas", - "plugins -> budget", - "plugins -> categories", - "plugins -> collab", - "plugins -> collections", - "plugins -> day-notes", - "plugins -> days", - "plugins -> files", - "plugins -> journey", - "plugins -> llm-parse", - "plugins -> notifications", - "plugins -> packing", - "plugins -> places", - "plugins -> realtime", - "plugins -> reservations", - "plugins -> todo", "plugins -> trips", "plugins -> vacay", "realtime -> journey", - "realtime -> plugins", "reservations -> accommodations", "reservations -> assignments", "reservations -> budget", @@ -105,48 +63,17 @@ "reservations -> mcp-shared", "reservations -> notifications", "reservations -> realtime", - "todo -> addons", - "todo -> mcp-shared", - "todo -> realtime", "transit -> days", "transit -> mcp-shared", "transit -> reservations", "trip-members -> auth", - "trip-members -> budget", - "trip-members -> notifications", - "trip-members -> realtime", "trip-members -> trips", - "trip-read-model -> accommodations", - "trip-read-model -> budget", - "trip-read-model -> collab", - "trip-read-model -> days", - "trip-read-model -> files", - "trip-read-model -> packing", - "trip-read-model -> places", - "trip-read-model -> reservations", - "trip-read-model -> todo", "trip-read-model -> trip-members", "trip-read-model -> trips", - "trips -> accommodations", - "trips -> addons", - "trips -> budget", - "trips -> calendar", - "trips -> collab", - "trips -> days", - "trips -> files", - "trips -> mcp-shared", - "trips -> packing", - "trips -> places", - "trips -> realtime", - "trips -> reservations", - "trips -> todo", "trips -> trip-members", "trips -> trip-read-model", "trips -> vacay", - "vacay -> addons", - "vacay -> auth", - "vacay -> notifications", - "vacay -> realtime" + "vacay -> auth" ], "sharedImportsDomain": [ "nest/common/idempotency-cleanup.job.ts -> nest/audit/audit-log.logger.ts", @@ -201,7 +128,6 @@ "plugins -> maps/maps.helpers.ts", "plugins -> notifications/channel-registry.ts", "plugins -> notifications/notification-events.ts", - "realtime -> plugins/install/host-compat.ts", "receipt-scan -> llm-parse/image-input.ts", "reservation-import -> integrations/airtrail.dto.ts", "reservation-import -> llm-parse/image-input.ts", diff --git a/server/src/app-config/index.ts b/server/src/app-config/index.ts index 5329820c8..f5e3c392f 100644 --- a/server/src/app-config/index.ts +++ b/server/src/app-config/index.ts @@ -1,5 +1,6 @@ export { readEnv, validateEnvAtBoot } from './env'; export { getAppUrl, getMcpSafeUrl } from './app-url'; +export { runningVersion } from './running-version'; export type { AppEnv, RawEnv } from './env'; export { deriveAll, diff --git a/server/src/app-config/running-version.ts b/server/src/app-config/running-version.ts new file mode 100644 index 000000000..861cb92c8 --- /dev/null +++ b/server/src/app-config/running-version.ts @@ -0,0 +1,11 @@ +import { readEnv } from './env'; + +/** + * The running TREK version: the image's VERSION file or APP_VERSION (both behind + * `readEnv().app.appVersion`), else server/package.json. The websocket welcome + * frame and the plugin host-compatibility checks both announce it, so it lives + * here rather than inside either domain. + */ +export function runningVersion(): string { + return readEnv().app.appVersion || (require('../../package.json') as { version: string }).version; +} diff --git a/server/src/nest/plugins/install/host-compat.ts b/server/src/nest/plugins/install/host-compat.ts index ee4135ffa..a42c670f6 100644 --- a/server/src/nest/plugins/install/host-compat.ts +++ b/server/src/nest/plugins/install/host-compat.ts @@ -1,5 +1,5 @@ import semver from 'semver'; -import { readEnv } from '../../../app-config'; +import { readEnv, runningVersion } from '../../../app-config'; /** * Host-version compatibility for plugins (#plugins). A manifest declares the TREK @@ -12,7 +12,7 @@ import { readEnv } from '../../../app-config'; /** The running TREK version (same source as the rest of the app). */ export function hostVersion(): string { - return readEnv().app.appVersion || (require('../../../../package.json') as { version: string }).version; + return runningVersion(); } let warnedUnparseable = false; diff --git a/server/src/nest/realtime/realtime.gateway.ts b/server/src/nest/realtime/realtime.gateway.ts index 0b2dde53f..aac4bec3f 100644 --- a/server/src/nest/realtime/realtime.gateway.ts +++ b/server/src/nest/realtime/realtime.gateway.ts @@ -31,8 +31,8 @@ import { type TrekWebSocket, } from './ws-state'; import { JourneyDomainService } from '../journey/journey-domain.service'; -import { hostVersion } from '../plugins/install/host-compat'; import { readAppSetting } from '../common/app-settings.registry'; +import { runningVersion } from '../../app-config'; const HEARTBEAT_INTERVAL = 30_000; @@ -159,7 +159,7 @@ export class RealtimeGateway // The version lets a client that stayed open across a deploy notice it // runs the previous build: a deploy restarts the server, so every open // client reconnects and reads this again. - socket.send(JSON.stringify({ type: 'welcome', socketId: sid, version: hostVersion() })); + socket.send(JSON.stringify({ type: 'welcome', socketId: sid, version: runningVersion() })); socket.on('pong', () => { socket.isAlive = true; }); } catch (err) { logError(`ws handshake failed: ${err instanceof Error ? err.message : String(err)}`); diff --git a/server/tests/unit/app-config/running-version.test.ts b/server/tests/unit/app-config/running-version.test.ts new file mode 100644 index 000000000..a091b48c8 --- /dev/null +++ b/server/tests/unit/app-config/running-version.test.ts @@ -0,0 +1,25 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { runningVersion } from '../../../src/app-config'; +import { hostVersion } from '../../../src/nest/plugins/install/host-compat'; +import pkg from '../../../package.json'; + +afterEach(() => { + vi.unstubAllEnvs(); +}); + +describe('runningVersion', () => { + it('announces APP_VERSION when it is set', () => { + vi.stubEnv('APP_VERSION', '9.8.7'); + expect(runningVersion()).toBe('9.8.7'); + }); + + it('falls back to the server package version', () => { + vi.stubEnv('APP_VERSION', ''); + expect(runningVersion()).toBe(pkg.version); + }); + + it('is what the plugin host-compatibility checks call the host version', () => { + vi.stubEnv('APP_VERSION', '1.2.3'); + expect(hostVersion()).toBe(runningVersion()); + }); +});