import type SafeTracer from '../../utils/SafeTracer.js'; import type { CDCChange, CDCConfig, } from '../../storage/dataWarehouse/IDataWarehouseAnalytics.js'; import type { AnalyticsEventInput, AnalyticsQueryResult, AnalyticsWriteOptions, } from './types.js'; /** * Contract implemented by every analytics adapter. * * Adapters are free to batch, buffer, or stream writes however they like. * The core application will await each call; adapters should ensure the * returned promise resolves once the data is durable (or appropriately queued) * according to their guarantees. */ export interface IAnalyticsAdapter { /** Human friendly provider name for logging / diagnostics. */ readonly name: string; /** * Write analytics events to a logical table. * * @param table - Logical table identifier (e.g. 'RULE_EXECUTIONS'). * @param events - Rows to persist. Adapters may mutate or enrich rows before * persistence, but should NOT mutate the original array. */ writeEvents( table: string, events: readonly AnalyticsEventInput[], options?: AnalyticsWriteOptions, ): Promise; /** * Execute an analytics query. Most adapters will translate the SQL string * into their native dialect before execution. */ query( sql: string, params?: readonly unknown[], ): Promise; /** Flush any in-memory buffers. Called during graceful shutdown. */ flush(): Promise; /** Release external resources (connections, clients, etc.). */ close(): Promise; /** Optional support for change data capture streams. */ createCDCStream?( config: CDCConfig, ): Promise; consumeCDCChanges?( streamName: string, callback: (changes: CDCChange[]) => Promise, tracer?: SafeTracer, ): Promise; supportsCDC?(): boolean; }