feat(record-settings): publish connection health for a managed record's integrations

The guardian's read of a managed record's connections now carries the same
server-resolved health the owner's own envelope does, loaded for the record
and never for the guardian. The legacy state stays on the wire for one
transition release.
This commit is contained in:
Marc-André Bombeck committed 2026-10-15 15:06:02 +02:00
1 parent 8ebc6fe546
commit b17a250894
16 files changed
+3201 -12

No files matched your search

@@ -9,6 +9,7 @@ import {
getIntegrationStatus,
type IntegrationKey,
} from "@/lib/integrations/status";
import { loadConnectionHealth } from "@/lib/integrations/connection-health-load";
import { annotate } from "@/lib/logging/context";
import {
resolveGuardianRecordSettingsAccess,
@@ -70,6 +71,13 @@ export const GET = apiHandler(async () => {
oura: context.user.ouraAccessTokenEncrypted !== null,
strava: context.user.stravaAccessTokenEncrypted !== null,
};
// The one server-resolved state per connection, from the same loader the
// owner's own envelope uses, so a guardian reads the record's connections in
// the words the record's owner would.
const health = await loadConnectionHealth(
access.recordId,
MANAGED_INTEGRATIONS,
);
const integrations = statuses.map((status) => ({
integration: status.integration,
state: resolveManagedIntegrationState(
@@ -79,6 +87,7 @@ export const GET = apiHandler(async () => {
),
lastSuccessAt: status.lastSuccessAt,
lastAttemptAt: status.lastAttemptAt,
health: health[status.integration],
}));
annotate({ action: { name: "record-settings.integrations.get" } });