UNPKG

cline-sdk

Version:

Comprehensive SDK for Cline - AI-powered development assistant with database integration, execution modes, and custom functions

182 lines 4.47 kB
/** * PostgreSQL Database Manager * * Comprehensive database management system for Cline SDK that provides: * - Database connection management * - Schema introspection and management * - CRUD operations with permission control * - Row Level Security (RLS) management * - AI-powered database interaction */ import { EventEmitter } from "events"; export interface PostgreSQLConfig { host: string; port: number; database: string; username: string; password: string; ssl?: boolean | object; maxConnections?: number; idleTimeoutMillis?: number; connectionTimeoutMillis?: number; } export interface TableSchema { tableName: string; schemaName: string; columns: ColumnInfo[]; primaryKeys: string[]; foreignKeys: ForeignKeyInfo[]; indexes: IndexInfo[]; constraints: ConstraintInfo[]; permissions: TablePermissions; description?: string; rowLevelSecurity: boolean; policies: RLSPolicy[]; } export interface ColumnInfo { columnName: string; dataType: string; isNullable: boolean; defaultValue?: string; maxLength?: number; description?: string; isPrimaryKey: boolean; isForeignKey: boolean; referencedTable?: string; referencedColumn?: string; } export interface ForeignKeyInfo { constraintName: string; columnName: string; referencedTable: string; referencedColumn: string; onDelete: string; onUpdate: string; } export interface IndexInfo { indexName: string; columns: string[]; isUnique: boolean; indexType: string; } export interface ConstraintInfo { constraintName: string; constraintType: string; columns: string[]; definition: string; } export interface TablePermissions { select: boolean; insert: boolean; update: boolean; delete: boolean; truncate: boolean; references: boolean; trigger: boolean; } export interface RLSPolicy { policyName: string; command: "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "ALL"; roles: string[]; using?: string; withCheck?: string; description?: string; } export interface DatabasePermissions { allowRead: boolean; allowWrite: boolean; allowDelete: boolean; allowSchemaChanges: boolean; allowRLSManagement: boolean; restrictedTables: string[]; allowedTables: string[]; } export interface QueryResult { success: boolean; data?: any[]; rowCount?: number; error?: string; executionTime: number; query: string; cost?: { tokensUsed: number; estimatedCost: number; }; } export declare class PostgreSQLManager extends EventEmitter { private pool; private config; private permissions; private isConnected; private schemas; constructor(config: PostgreSQLConfig, permissions: DatabasePermissions); /** * Test database connection */ testConnection(): Promise<{ connected: boolean; message: string; version?: string; }>; /** * Get all database schemas and tables */ introspectDatabase(): Promise<Map<string, TableSchema[]>>; /** * Get detailed information about tables in a schema */ private getTablesInSchema; /** * Get column information for a table */ private getTableColumns; /** * Get primary keys for a table */ private getPrimaryKeys; /** * Get foreign keys for a table */ private getForeignKeys; /** * Get indexes for a table */ private getIndexes; /** * Get constraints for a table */ private getConstraints; /** * Get table permissions (simplified - would need actual permission checking) */ private getTablePermissions; /** * Get Row Level Security information */ private getRLSInfo; /** * Execute a SQL query with permission checking */ executeQuery(query: string, params?: any[]): Promise<QueryResult>; /** * Validate query permissions */ private validateQueryPermissions; /** * Get database schema information for AI context */ getSchemaContext(): string; /** * Close database connections */ close(): Promise<void>; /** * Get connection status */ getConnectionStatus(): { connected: boolean; activeConnections: number; config: any; }; } //# sourceMappingURL=postgres-manager.d.ts.map