/** * True iff a resource has been hard-deleted - a base read returns HTTP 410 Gone. * * The `_history` LIST viewers use this to tell a "resource was deleted" state apart from a transient * failure. On our HealthLake datastore the `_history` LIST endpoint returns an opaque 500 for a * hard-deleted resource, so the LIST error alone can't distinguish "deleted" from * "temporary server error" - a base read returning 410 Gone is the reliable signal. Any other * outcome (resource still live, or a different/transient error) returns false. * * `get` throws the app's `HttpError`, which carries `.status`. We read `.status` structurally rather * than importing HttpService so this guard stays dependency-free (and unit-testable without pulling * in the services barrel). */ export async function isResourceDeleted( get: (url: string) => Promise, baseUrl: string, resourceType: string, id: string, ): Promise { try { await get(`${baseUrl}/${resourceType}/${id}`); return false; } catch (err) { return (err as { status?: number } | null | undefined)?.status === 410; } }