(
row: ConnectionRow,
detail: string,
)
| 1765 | * which is what re-arms refresh. Best-effort: a bookkeeping write failure |
| 1766 | * must not mask the refresh failure being reported. */ |
| 1767 | const markRefreshGrantDead = ( |
| 1768 | row: ConnectionRow, |
| 1769 | detail: string, |
| 1770 | ): Effect.Effect<void, never> => { |
| 1771 | const existingState = decodeJsonColumn(row.provider_state); |
| 1772 | const mergedState = |
| 1773 | existingState != null && typeof existingState === "object" && !Array.isArray(existingState) |
| 1774 | ? (existingState as Record<string, unknown>) |
| 1775 | : {}; |
| 1776 | const health: HealthCheckResult = { |
| 1777 | status: "expired", |
| 1778 | checkedAt: Date.now(), |
| 1779 | detail, |
| 1780 | }; |
| 1781 | return core |
| 1782 | .updateMany("connection", { |
| 1783 | where: (b: AnyCb) => |
| 1784 | b.and( |
| 1785 | byOwner(row.owner as Owner)(b), |
| 1786 | b("integration", "=", String(row.integration)), |
| 1787 | b("name", "=", String(row.name)), |
| 1788 | ), |
| 1789 | set: { |
| 1790 | provider_state: { ...mergedState, oauthReauthRequiredAt: Date.now() }, |
| 1791 | last_health: health, |
| 1792 | updated_at: new Date(), |
| 1793 | }, |
| 1794 | }) |
| 1795 | .pipe(Effect.ignore); |
| 1796 | }; |
| 1797 | |
| 1798 | // Perform the actual refresh-token grant and persist the rotated material. |
| 1799 | const performTokenRefresh = ( |
no test coverage detected