types(web): unify FederationPeer with shared type

packages/web/src/api/client.ts declared a local FederationPeer that had
drifted from @backspace/shared: it loosened `status` to `string` (losing
the exhaustive 7-value union) and widened `consecutiveFailures` and
`lastSyncedAt` to `number | null`. The latter two are spurious — the
server never returns null for either — and `status: string` defeated
the compiler's ability to flag a missed case when `rejected`,
`awaiting_approval`, or `needs_attention` were added over the course
of the auto-peering / approval-queue / outbox-auth-failure-recovery
work.

Replace the local interface with a re-export of the shared type. All
three status switches in FederationPanel.tsx (peerStatusColor,
peerStatusDotColor, peerStatusLabel) and the StatusFilter union were
already exhaustive over the 7 values, so no behaviour change is
needed — the re-export just pins the compile-time contract.

web tsc --noEmit is clean after the swap.

Follow-up #23 from S2S DM unification backlog.
This commit is contained in:
Jannis Braun
2026-04-21 22:21:47 +02:00
parent 010aa7f7ca
commit 4b398cf45a
+3 -16
View File
@@ -52,8 +52,11 @@ import type {
FederationRegistryEntry,
FederationIdentityDeleteRequest,
FederationIdentityDeleteResponse,
FederationPeer,
} from '@backspace/shared';
export type { FederationPeer };
export class RateLimitError extends Error {
readonly retryAfter: number;
constructor(retryAfter: number) {
@@ -63,22 +66,6 @@ export class RateLimitError extends Error {
}
}
export interface FederationPeer {
id: string;
origin: string;
instanceName: string | null;
status: string;
lastSeenAt: number | null;
lastFailureAt: number | null;
consecutiveFailures: number | null;
consecutiveAuthFailures: number;
lastSyncedAt: number | null;
createdAt: number;
secretRotatedAt: number | null;
rotationInProgress: boolean;
autoRotateIntervalDays: number;
}
export interface ApprovalRequest {
id: string;
origin: string;