(
ref: ConnectionRef,
options?: {
/** Skip the probe and return the persisted verdict when it is younger
* than this. The server owns the freshness decision so N open tabs
* revalidating on load cannot stampede an upstream. Omit = always
* probe (the manual "Check now"). */
readonly ifStaleMs?: number;
},
)
| 2798 | }); |
| 2799 | |
| 2800 | const connectionCheckHealth = ( |
| 2801 | ref: ConnectionRef, |
| 2802 | options?: { |
| 2803 | /** Skip the probe and return the persisted verdict when it is younger |
| 2804 | * than this. The server owns the freshness decision so N open tabs |
| 2805 | * revalidating on load cannot stampede an upstream. Omit = always |
| 2806 | * probe (the manual "Check now"). */ |
| 2807 | readonly ifStaleMs?: number; |
| 2808 | }, |
| 2809 | ): Effect.Effect< |
| 2810 | HealthCheckResult, |
| 2811 | ConnectionNotFoundError | IntegrationNotFoundError | StorageFailure |
| 2812 | > => |
| 2813 | Effect.gen(function* () { |
| 2814 | const connectionRow = yield* findConnectionRow(ref); |
| 2815 | if (!connectionRow) { |
| 2816 | return yield* new ConnectionNotFoundError({ |
| 2817 | owner: ref.owner, |
| 2818 | integration: ref.integration, |
| 2819 | name: ref.name, |
| 2820 | }); |
| 2821 | } |
| 2822 | if (options?.ifStaleMs !== undefined) { |
| 2823 | const cached = Option.getOrNull(decodeLastHealth(connectionRow.last_health)); |
| 2824 | if (cached && Date.now() - cached.checkedAt < options.ifStaleMs) return cached; |
| 2825 | } |
| 2826 | const integrationRow = yield* findIntegrationRow(ref.integration); |
| 2827 | if (!integrationRow) { |
| 2828 | return yield* new IntegrationNotFoundError({ slug: ref.integration }); |
| 2829 | } |
| 2830 | const runtime = runtimes.get(integrationRow.plugin_id); |
| 2831 | const check = runtime?.plugin.checkHealth; |
| 2832 | if (!runtime || !check) return unknownHealth(); |
| 2833 | const spec = describeHealthCheckForRow(integrationRow) ?? undefined; |
| 2834 | if (spec === undefined && connectionRow.oauth_client != null) { |
| 2835 | const result = yield* oauthCredentialHealthWithoutProbe(connectionRow); |
| 2836 | yield* persistHealthResult(ref, result); |
| 2837 | return result; |
| 2838 | } |
| 2839 | |
| 2840 | const result = yield* Effect.gen(function* () { |
| 2841 | const values = yield* resolveConnectionValues(connectionRow); |
| 2842 | const record = rowToIntegrationRecord( |
| 2843 | integrationRow, |
| 2844 | describeAuthMethodsForRow(integrationRow), |
| 2845 | ); |
| 2846 | const grantedScopes = grantedScopesFromRow(connectionRow); |
| 2847 | const credential: ToolInvocationCredential = { |
| 2848 | owner: connectionRow.owner as Owner, |
| 2849 | integration: ref.integration, |
| 2850 | connection: ConnectionName.make(connectionRow.name), |
| 2851 | template: AuthTemplateSlug.make(connectionRow.template), |
| 2852 | value: values[PRIMARY_INPUT_VARIABLE] ?? null, |
| 2853 | values, |
| 2854 | config: record.config, |
| 2855 | ...(grantedScopes ? { grantedScopes } : {}), |
| 2856 | }; |
| 2857 | // Core resolves the declared spec (its own column) and hands it to the |
nothing calls this directly
no test coverage detected