import type { AllAuthCredentials, AuthModeType, AuthOperationType } from '../auth/api.js'; import type { Tags, TimestampsAndDeletedCorrect } from '../db.js'; import type { InternalEndUser } from '../endUser/index.js'; import type { DBEnvironment } from '../environment/db.js'; import type { DBTeam } from '../team/db.js'; import type { ReplaceInObject } from '../utils.js'; import type { Merge, Simplify } from 'type-fest'; export type Metadata = Record; export interface ConnectionConfig { [key: string]: any; oauth_scopes_override?: string[] | undefined; oauth_scopes?: string | undefined; authorization_params?: Record | undefined; } export interface DBConnection extends TimestampsAndDeletedCorrect { id: number; config_id: number; end_user_id: number | null; tags: Tags; /** * @deprecated */ provider_config_key: string; connection_id: string; connection_config: ConnectionConfig; environment_id: number; metadata: Metadata | null; credentials: { encrypted_credentials?: string; }; credentials_iv: string | null; credentials_tag: string | null; last_fetched_at: Date | null; credentials_expires_at: Date | null; last_refresh_failure: Date | null; last_refresh_success: Date | null; refresh_attempts: number | null; refresh_exhausted: boolean; } export type DBConnectionAsJSONRow = Simplify>; export type DBConnectionDecrypted = Merge; export interface RecentlyCreatedConnection { connection: DBConnection; auth_mode: AuthModeType; error?: string; operation: AuthOperationType; environment: DBEnvironment; account: DBTeam; endUser: InternalEndUser | null | undefined; } export interface FailedConnectionError { type: string; description: string; } export interface RecentlyFailedConnection { connection: DBConnection | Pick; auth_mode: AuthModeType; error?: FailedConnectionError; operation: AuthOperationType; environment: DBEnvironment; account: DBTeam; } export type ConnectionInternal = Pick; export type ConnectionJobs = Pick;