/** * Shared ConnectionProvider interface and related types. * * These types are the contract every provider package must implement. */ export type ProxyMethod = "DELETE" | "GET" | "PATCH" | "POST" | "PUT"; export type ProxyHeaders = Record; export type ProxyQuery = Record; /** Request sent through a connection provider's proxy. */ export interface ProxyRequest { method: ProxyMethod; /** Base API URL for the upstream service. */ baseUrl: string; endpoint: string; connectionId: string; headers?: ProxyHeaders; body?: unknown; query?: ProxyQuery; } /** Response returned from a proxied request. */ export interface ProxyResponse { status: number; headers: ProxyHeaders; data: T; } /** Webhook normalized into a provider-agnostic shape. */ export interface NormalizedWebhook { provider: string; connectionId: string; eventType: string; objectType: string; objectId: string; payload: Record; } /** Interface every connection provider must implement. */ export interface ConnectionProvider { readonly name: string; proxy(request: ProxyRequest): Promise>; healthCheck(connectionId: string): Promise; handleWebhook?(rawPayload: unknown): Promise; getConnection?(connectionId: string): Promise>; listConnections?(): Promise>>; } /** * Maps a relayfile provider slug (e.g. "github", "linear") to the provider * config key it is registered under in your credential backend (e.g. the Nango * `providerConfigKey`). The relayfile slug is NOT guaranteed to equal the * upstream config key, so self-host callers supply this mapping explicitly. */ export type ProviderConfigKeyMap = Record; export interface CreateConnectSessionInput { relayfileProvider: string; providerConfigKey: string; endUserId: string; connectionId?: string; metadata?: Record; } export interface ConnectSession { connectLink: string | null; sessionToken: string | null; expiresAt: string | null; connectionId: string; } export interface GetConnectConnectionStatusInput { relayfileProvider: string; providerConfigKey: string; connectionId: string; } export interface ConnectConnectionStatus { connectionId: string; state: string; ready?: boolean; raw?: unknown; } export interface ConnectCapableProvider extends ConnectionProvider { createConnectSession(input: CreateConnectSessionInput): Promise; getConnectionStatus(input: GetConnectConnectionStatusInput): Promise; } export declare function supportsConnect(provider: ConnectionProvider): provider is ConnectCapableProvider;