MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / markRefreshGrantDead

Function markRefreshGrantDead

packages/core/sdk/src/executor.ts:2031–2064  ·  view source on GitHub ↗
(
      row: ConnectionRow,
      detail: string,
    )

Source from the content-addressed store, hash-verified

2029 * which is what re-arms refresh. Best-effort: a bookkeeping write failure
2030 * must not mask the refresh failure being reported. */
2031 const markRefreshGrantDead = (
2032 row: ConnectionRow,
2033 detail: string,
2034 ): Effect.Effect<void, never> => {
2035 const existingState = decodeJsonColumn(row.provider_state);
2036 const mergedState =
2037 existingState != null && typeof existingState === "object" && !Array.isArray(existingState)
2038 ? (existingState as Record<string, unknown>)
2039 : {};
2040 const health: HealthCheckResult = {
2041 status: "expired",
2042 checkedAt: Date.now(),
2043 detail,
2044 };
2045 return core
2046 .updateMany("connection", {
2047 where: (b: AnyCb) =>
2048 b.and(
2049 byOwner(row.owner as Owner)(b),
2050 b("integration", "=", String(row.integration)),
2051 b("name", "=", String(row.name)),
2052 ),
2053 set: {
2054 provider_state: {
2055 ...mergedState,
2056 oauthReauthRequiredAt: Date.now(),
2057 oauthReauthRequiredDetail: detail,
2058 },
2059 last_health: health,
2060 updated_at: new Date(),
2061 },
2062 })
2063 .pipe(Effect.ignore);
2064 };
2065
2066 /** Write a re-minted token back: a ROTATED refresh token into the refresh
2067 * item, the access token into the connection's primary provider item, and

Callers 2

performTokenRefreshFunction · 0.85

Calls 2

decodeJsonColumnFunction · 0.85
byOwnerFunction · 0.85

Tested by

no test coverage detected