(
row: ConnectionRow,
detail: string,
)
| 1791 | * which is what re-arms refresh. Best-effort: a bookkeeping write failure |
| 1792 | * must not mask the refresh failure being reported. */ |
| 1793 | const markRefreshGrantDead = ( |
| 1794 | row: ConnectionRow, |
| 1795 | detail: string, |
| 1796 | ): Effect.Effect<void, never> => { |
| 1797 | const existingState = decodeJsonColumn(row.provider_state); |
| 1798 | const mergedState = |
| 1799 | existingState != null && typeof existingState === "object" && !Array.isArray(existingState) |
| 1800 | ? (existingState as Record<string, unknown>) |
| 1801 | : {}; |
| 1802 | const health: HealthCheckResult = { |
| 1803 | status: "expired", |
| 1804 | checkedAt: Date.now(), |
| 1805 | detail, |
| 1806 | }; |
| 1807 | return core |
| 1808 | .updateMany("connection", { |
| 1809 | where: (b: AnyCb) => |
| 1810 | b.and( |
| 1811 | byOwner(row.owner as Owner)(b), |
| 1812 | b("integration", "=", String(row.integration)), |
| 1813 | b("name", "=", String(row.name)), |
| 1814 | ), |
| 1815 | set: { |
| 1816 | provider_state: { |
| 1817 | ...mergedState, |
| 1818 | oauthReauthRequiredAt: Date.now(), |
| 1819 | oauthReauthRequiredDetail: detail, |
| 1820 | }, |
| 1821 | last_health: health, |
| 1822 | updated_at: new Date(), |
| 1823 | }, |
| 1824 | }) |
| 1825 | .pipe(Effect.ignore); |
| 1826 | }; |
| 1827 | |
| 1828 | // Perform the actual refresh-token grant and persist the rotated material. |
| 1829 | const performTokenRefresh = ( |
no test coverage detected