/** * Connection-related type definitions */ import { DatabaseType } from './enums'; /** * Environment-specific database configuration */ export interface IDatabaseEnvConfig { /** Environment identifier (e.g., 'dev', 'staging', 'prd') */ slug: string; /** Database connection string */ connection_url: string; /** Optional description for this environment */ description?: string; authMode?: 'manual' | 'cloud_connection'; cloudConnectionId?: string; /** Workspace cloud connection tag */ cloud?: string; /** RDS / Cloud SQL / PostgreSQL instance id when linking via cloud (provision on save) */ instance?: string; region?: string; /** MongoDB database name — required when linking to MongoDB Atlas via a cloud connection. * Without this, the connection URL will have no database name and the adapter will throw at connect time. * Example: "myapp_snd" for sandbox, "myapp_prd" for production. */ dbName?: string; /** Master password for cloud-provisioned databases (used at provision time only, not stored) */ masterPassword?: string; } /** * Full database configuration for registration */ export interface IDatabaseConfig { /** Product tag to persist to (optional - if not provided, only stored locally) */ product: string; /** Human-readable display name */ name: string; /** Unique identifier for the database */ tag: string; /** Database type */ type: DatabaseType; /** Optional description of what the database stores */ description?: string; /** Environment-specific connection configurations */ envs: IDatabaseEnvConfig[]; } /** * Connection configuration for establishing database connection */ export interface IConnectionConfig { /** Environment identifier (e.g., 'dev', 'staging', 'prd') */ env: string; /** Product tag */ product: string; /** Database tag */ database: string; /** Optional connection options */ options?: IConnectionOptions; } /** * Optional connection configuration options */ export interface IConnectionOptions { /** Connection pool size */ poolSize?: number; /** Connection timeout in milliseconds */ connectionTimeout?: number; /** Idle timeout in milliseconds */ idleTimeout?: number; /** Enable SSL */ ssl?: boolean | ISSLConfig; /** Application name for tracking */ applicationName?: string; } /** * SSL configuration options */ export interface ISSLConfig { /** Reject unauthorized certificates */ rejectUnauthorized?: boolean; /** CA certificate */ ca?: string; /** Client certificate */ cert?: string; /** Client key */ key?: string; } /** * Result of a connection attempt */ export interface IConnectionResult { /** Whether the connection was successful */ connected: boolean; /** Database version (if connected) */ version?: string; /** Connection latency in milliseconds */ latency?: number; /** Error message (if connection failed) */ error?: string; } /** * Internal connection context tracking */ export interface IConnectionContext { /** Database tag */ database: string; /** Environment slug */ env: string; /** Database type */ type: DatabaseType; /** Connection URL */ connectionUrl: string; /** Whether currently connected */ connected: boolean; /** Associated product tag */ product?: string; /** Database display name */ name?: string; /** Database description */ description?: string; authMode?: 'manual' | 'cloud_connection'; cloudConnectionId?: string; /** Workspace cloud connection tag */ cloud?: string; } /** * Internal adapter connection options */ export interface IVpcConnectorTunnelOptions { cloudTag: string; host: string; port: number; environment: import('../../types').EnvType; auth: import('../../types').IRequestExtension; } export interface IAdapterConnectionOptions { /** Connection URL */ connectionUrl: string; /** Pool size */ poolSize?: number; /** Connection timeout */ connectionTimeout?: number; /** Idle timeout */ idleTimeout?: number; /** SSL configuration */ ssl?: boolean | ISSLConfig; /** Application name */ applicationName?: string; } /** * Internal adapter connection result */ export interface IAdapterConnectionResult { /** Whether connected */ connected: boolean; /** Database version */ version?: string; /** Native client reference (database-specific) */ client?: any; /** Error message if connection failed */ error?: string; }