mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 12:42:38 +00:00
1554540431
lib/scopedFetch.ts becomes lib/apiClient.ts: ApiError carries retryAfterSeconds (body first, Retry-After header second), fetchJson<T> refuses empty and malformed 2xx bodies instead of handing back undefined, sets Content-Type for string bodies, fetchOk covers action calls and fetchBlob downloads. describeApiError renders 429/503 with the server's retry advice; apiErrorText is the one-string form for inline error slots; apiErrorNotification folds the "Session Expired" dialect into one place and NotificationContext.notifyError uses it. useAuthenticatedFetch throws ApiError (correlation id preserved), drops the dead 204 branch and onTokenExpired. dedupedFetchJson<T> for the three feature-flag readers. lib/__tests__/apiClient.guard.test.ts ratchets raw authenticatedFetch(/dedupedAuthFetch(/ .json()/instanceof TokenExpiredError per file against a baseline that may only shrink (a count above fails as a new site, below as a stale entry); fetchJson without a type argument is a violation. Baseline today: 228 raw fetches, 221 parses, 140 token checks. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>