UNPKG

@pompeii-labs/aqueducts

Version:

The Aqueducts integration SDK from Pompeii Labs

130 lines (126 loc) 3.96 kB
declare const Providers: readonly ["github", "slack_bot", "slack_user", "hubspot", "google", "drive", "gcal", "gmail", "linear", "notion", "spotify", "quickbooks", "quickbooks_dev", "attio", "airtable"]; type ProviderType = (typeof Providers)[number]; interface Integration { id: number; createdAt: string; provider: ProviderType; projectId: number; scopes: string[]; metadata: Record<string, any>; } interface AuthUrlOptions { /** * The provider of the connection */ provider: ProviderType; /** * The ID of the user associated with this connection */ userId: string; /** * The metadata of the connection (optional) */ metadata?: Record<string, string>; /** * The redirect URI of the connection (optional) */ redirectUri?: string; } type ConnectionStatus = 'active' | 'inactive' | 'expired'; interface ConnectionCredentials { access_token: string; refresh_token: string; expires_in: number; token_type?: string; scope?: string; } interface ConnectionData { id: number; connectionId: string; userId: string; createdAt: string; integrationId: number; projectId: number; provider: ProviderType; status: ConnectionStatus; credentials: ConnectionCredentials; expiresAt: Date; metadata: Record<string, any>; } declare class Connection implements ConnectionData { id: number; connectionId: string; userId: string; createdAt: string; integrationId: number; projectId: number; provider: ProviderType; status: ConnectionStatus; credentials: ConnectionCredentials; expiresAt: Date; metadata: Record<string, any>; private client; constructor(data: ConnectionData, client?: Aqueduct); updateMetadata(metadata: Record<string, any>): Promise<this>; delete(): Promise<void>; toJSON(): { id: number; connectionId: string; userId: string; createdAt: string; integrationId: number; projectId: number; provider: "github" | "slack_bot" | "slack_user" | "hubspot" | "google" | "drive" | "gcal" | "gmail" | "linear" | "notion" | "spotify" | "quickbooks" | "quickbooks_dev" | "attio" | "airtable"; status: ConnectionStatus; credentials: ConnectionCredentials; expiresAt: Date; metadata: Record<string, any>; }; } declare class Aqueduct { private readonly apiKey; constructor(apiKey?: string); /** * Make a request to the Aqueduct API * * @param route The route to make the request to * @param args The arguments to pass to the request * @returns The response from the request */ request(route: string, args?: Partial<RequestInit>): Promise<Response>; /** * Test the connection to the Aqueduct API * * @return nothing if successful * @throws Error if the request fails */ test(): Promise<void>; /** * List all integrations set up for the project * * @returns The integrations */ listIntegrations(): Promise<Integration[]>; getConnection({ provider, connectionId, userId, force_refresh, metadata, }: { provider: ProviderType; connectionId?: string; userId?: string; force_refresh?: boolean; metadata?: Record<string, string>; }): Promise<Connection | null>; listConnections({ provider, connectionId, userId, metadata, forceRefresh, }: { provider?: ProviderType; connectionId?: string; userId?: string; metadata?: Record<string, string>; forceRefresh?: boolean; }): Promise<Connection[] | null>; /** * Get the auth URL for a connection * * @param options The options for the auth URL * @returns The auth URL */ authUrl({ provider, userId, metadata, redirectUri }: AuthUrlOptions): Promise<string>; } export { Aqueduct, Connection };