diff --git a/.changeset/25921-types-driver-datasource-block.md b/.changeset/25921-types-driver-datasource-block.md new file mode 100644 index 00000000000..b4177c0bfdf --- /dev/null +++ b/.changeset/25921-types-driver-datasource-block.md @@ -0,0 +1,19 @@ +--- +'@object-ui/types': patch +--- + +refactor(types)!: delete the fifteen driver and datasource interfaces nothing reads + +Clause-②: no (narrowing) +Metadata-protocol: none + + + +**BREAKING** for a host that imports any of these fifteen types from `@object-ui/types`. None had an importer anywhere in the workspace or in hotcrm, so the Console and every `@object-ui/*` package are unaffected. + +They are **gone from the package, not only from the entry**: the "Phase 3.6" driver interfaces and the "Phase 3.7" datasource interfaces at the end of `data-protocol.ts` were read only by each other. Nothing implemented the driver interface and nothing constructed the datasource manager; the client talks to data through the `DataSource` interface instead. Every other name of `data-protocol.ts` stays exported unchanged, among them `DriverQueryConfig`, `SqlQueryAST`, the query-AST node types, `AdvancedFilterSchema`, `FilterBuilderConfig` and `ObjectValidationRule` with its variants. + +What leaves, and what to write instead: + +- FROM `SqlDriverInterface`, `ConnectionConfig`, `DriverQueryResult`, `BatchOperation`, `BatchResult`, `TransactionContext`, `CacheManager`, `ConnectionPool` TO no replacement in this package. A client reads and writes data through `DataSource` (`BatchTransactionOperation` with `DataSource.batchTransaction` for a transactional batch); the platform's runtime driver contract is `DriverInterface` from `@objectstack/spec/data`. +- FROM `DatasourceRegistration`, `DatasourceType`, `DatasourceMetric`, `DatasourceAlert`, `DatasourceManager`, `HealthCheckResult`, `DatasourceMetrics` TO no replacement in this package. An authored datasource is `DatasourceSchema` from `@objectstack/spec/data`; a host that kept its own registry declares these shapes locally. diff --git a/ui/packages/types/src/__tests__/report-chart-query-spec-parity.test.ts b/ui/packages/types/src/__tests__/report-chart-query-spec-parity.test.ts index e81c19f796e..5c07db60105 100644 --- a/ui/packages/types/src/__tests__/report-chart-query-spec-parity.test.ts +++ b/ui/packages/types/src/__tests__/report-chart-query-spec-parity.test.ts @@ -19,7 +19,7 @@ * spec owns, or a divergence outliving the reason it was granted. Four-way * parity, in the shape `select-option-spec-parity.test.ts` established. * - **Renamed** (`ChartDataSeries`, `ChartDataSeriesSchema`, `SqlQueryAST`, - * `DriverQueryConfig`, `SqlDriverInterface`, `DatasourceRegistration`): the + * `DriverQueryConfig`): the * concepts genuinely differ from the spec exports whose names they were * wearing. The risk is picking a new name the spec ALREADY owns — the * `PageComponentSchema` mistake from objectui#3074 — so each new name is @@ -750,8 +750,6 @@ describe('renamed local dialects do not collide with a spec export (objectui#307 ['ChartDataSeriesSchema', 'zod twin of ChartDataSeries'], ['SqlQueryAST', 'compiled SQL syntax tree, not the spec ObjectQL request'], ['DriverQueryConfig', 'high-level query config the SQL AST builder consumes'], - ['SqlDriverInterface', "objectui's SQL-oriented client driver abstraction"], - ['DatasourceRegistration', 'in-memory datasource registration record'], // objectui#3162 batch 8. `JoinNode` was ledgered as "erased to `any` upstream, // re-export once objectstack#4171 lands". #4171 landed — and the symbol it was // waiting on no longer exists: spec 17.0.0 retired `query.joins` and the whole diff --git a/ui/packages/types/src/data-protocol.ts b/ui/packages/types/src/data-protocol.ts index 4567f00cb48..c211ad8f7da 100644 --- a/ui/packages/types/src/data-protocol.ts +++ b/ui/packages/types/src/data-protocol.ts @@ -9,8 +9,8 @@ /** * @object-ui/types - Data Protocol Advanced Types * - * Phase 3: Complete implementation of DriverQueryConfig, FilterSchema, - * object-level validation rules, SqlDriverInterface, and DatasourceRegistration. + * Phase 3: DriverQueryConfig and the SQL query AST, FilterSchema, and the + * object-level validation rules. * * @module data-protocol * @packageDocumentation @@ -924,679 +924,3 @@ export type ObjectValidationRule = | UniquenessValidation | AsyncValidation | RangeValidation; - -/** - * ============================================================================= - * Phase 3.6: SqlDriverInterface - Database Driver Abstraction - * ============================================================================= - */ - -/** - * Database driver abstraction (Phase 3.6). - * - * Renamed off `DriverInterface` (objectstack#4115): `@objectstack/spec/data` - * owns that name for the platform's **runtime driver contract** - * (`supports`/`execute`/`findStream`/pool stats, and `find()` taking an ObjectQL - * `SqlQueryAST`). This is objectui's own SQL-oriented client abstraction — - * `query(sql, params)`, `executeAST()`, `batch()` — and the two interfaces are - * not mutually assignable. Import the spec's `DriverInterface` when you mean the - * platform contract. - */ -export interface SqlDriverInterface { - /** - * Driver name - */ - name: string; - - /** - * Driver version - */ - version?: string; - - /** - * Connect to database - */ - connect(config: ConnectionConfig): Promise; - - /** - * Disconnect from database - */ - disconnect(): Promise; - - /** - * Execute query - */ - query(sql: string, params?: any[]): Promise>; - - /** - * Execute query from AST - */ - executeAST(ast: SqlQueryAST): Promise>; - - /** - * Find records - */ - find(table: string, query: DriverQueryConfig): Promise>; - - /** - * Find one record - */ - findOne(table: string, id: any): Promise; - - /** - * Insert record - */ - insert(table: string, data: Partial): Promise; - - /** - * Update record - */ - update(table: string, id: any, data: Partial): Promise; - - /** - * Delete record - */ - delete(table: string, id: any): Promise; - - /** - * Batch operations (Phase 3.6.2) - */ - batch(operations: BatchOperation[]): Promise>; - - /** - * Transaction support (Phase 3.6.1) - */ - transaction( - callback: (trx: TransactionContext) => Promise - ): Promise; - - /** - * Get object schema - */ - getSchema(objectName: string): Promise; - - /** - * Cache management (Phase 3.6.4) - */ - cache?: CacheManager; - - /** - * Connection pool (Phase 3.6.3) - */ - pool?: ConnectionPool; -} - -/** - * Connection configuration - */ -export interface ConnectionConfig { - /** - * Database host - */ - host?: string; - - /** - * Database port - */ - port?: number; - - /** - * Database name - */ - database?: string; - - /** - * Username - */ - username?: string; - - /** - * Password - */ - password?: string; - - /** - * Connection URL - */ - url?: string; - - /** - * SSL configuration - */ - ssl?: boolean | object; - - /** - * Pool configuration (Phase 3.6.3) - */ - pool?: { - min?: number; - max?: number; - idle_timeout?: number; - connection_timeout?: number; - }; - - /** - * Additional driver-specific options - */ - options?: Record; -} - -/** - * Query result with metadata (extends base QueryResult from data.ts) - */ -export interface DriverQueryResult { - /** - * Result data - */ - data: T[]; - - /** - * Total count - */ - total?: number; - - /** - * Current page number (1-indexed) - */ - page?: number; - - /** - * Page size - */ - pageSize?: number; - - /** - * Whether there are more records - */ - hasMore?: boolean; - - /** - * Cursor for cursor-based pagination - */ - cursor?: string; - - /** - * Execution metadata - */ - metadata?: { - /** - * Execution time in ms - */ - execution_time?: number; - - /** - * Whether result was cached - */ - from_cache?: boolean; - - /** - * Number of rows affected - */ - rows_affected?: number; - }; -} - -/** - * Batch operation (Phase 3.6.2) - */ -export interface BatchOperation { - /** - * Operation type - */ - type: 'insert' | 'update' | 'delete'; - - /** - * Target table - */ - table: string; - - /** - * Operation data - */ - data?: any; - - /** - * Record ID (for update/delete) - */ - id?: any; -} - -/** - * Batch operation result - */ -export interface BatchResult { - /** - * Successful operations - */ - success: T[]; - - /** - * Failed operations - */ - failed: Array<{ - operation: BatchOperation; - error: Error; - }>; - - /** - * Total operations - */ - total: number; - - /** - * Success count - */ - success_count: number; - - /** - * Failure count - */ - failure_count: number; -} - -/** - * Transaction context (Phase 3.6.1) - */ -export interface TransactionContext { - /** - * Execute query within transaction - */ - query(sql: string, params?: any[]): Promise>; - - /** - * Insert within transaction - */ - insert(table: string, data: Partial): Promise; - - /** - * Update within transaction - */ - update(table: string, id: any, data: Partial): Promise; - - /** - * Delete within transaction - */ - delete(table: string, id: any): Promise; - - /** - * Commit transaction - */ - commit(): Promise; - - /** - * Rollback transaction - */ - rollback(): Promise; -} - -/** - * Cache manager (Phase 3.6.4) - */ -export interface CacheManager { - /** - * Get cached value - */ - get(key: string): Promise; - - /** - * Set cached value - */ - set(key: string, value: T, ttl?: number): Promise; - - /** - * Delete cached value - */ - delete(key: string): Promise; - - /** - * Clear all cache - */ - clear(): Promise; - - /** - * Check if key exists - */ - has(key: string): Promise; -} - -/** - * Connection pool (Phase 3.6.3) - */ -export interface ConnectionPool { - /** - * Get connection from pool - */ - acquire(): Promise; - - /** - * Release connection back to pool - */ - release(connection: any): Promise; - - /** - * Pool statistics - */ - stats(): { - total: number; - idle: number; - active: number; - waiting: number; - }; - - /** - * Close all connections - */ - close(): Promise; -} - -/** - * ============================================================================= - * Phase 3.7: DatasourceRegistration - Multi-Datasource Management - * ============================================================================= - */ - -/** - * A datasource as registered with {@link DatasourceManager} at runtime (Phase 3.7). - * - * Renamed off `DatasourceSchema` (objectstack#4115): `@objectstack/spec/data` - * exports `DatasourceSchema` as the **authored datasource metadata document** - * (`driver` is a driver NAME, `config` a record, plus `pool`/`ssl`/`retryPolicy`/ - * `capabilities`/`schemaMode`). This is the in-memory registration record — its - * `driver` is a live {@link SqlDriverInterface} instance and its connection lives - * under `connection`, so the two never describe the same value. - */ -export interface DatasourceRegistration { - /** - * Datasource name - */ - name: string; - - /** - * Datasource type - */ - type: DatasourceType; - - /** - * Display label - */ - label?: string; - - /** - * Connection configuration - */ - connection: ConnectionConfig; - - /** - * Driver interface - */ - driver?: SqlDriverInterface; - - /** - * Whether datasource is default - */ - is_default?: boolean; - - /** - * Health check configuration (Phase 3.7.4) - */ - health_check?: { - /** - * Enable health checks - */ - enabled?: boolean; - - /** - * Check interval in seconds - */ - interval?: number; - - /** - * Timeout in milliseconds - */ - timeout?: number; - - /** - * Health check query - */ - query?: string; - }; - - /** - * Monitoring configuration (Phase 3.7.5) - */ - monitoring?: { - /** - * Enable monitoring - */ - enabled?: boolean; - - /** - * Metrics to collect - */ - metrics?: DatasourceMetric[]; - - /** - * Alert thresholds - */ - alerts?: DatasourceAlert[]; - }; - - /** - * Retry configuration - */ - retry?: { - /** - * Max retry attempts - */ - max_attempts?: number; - - /** - * Retry delay in milliseconds - */ - delay?: number; - - /** - * Exponential backoff - */ - backoff?: boolean; - }; - - /** - * Metadata - */ - metadata?: Record; -} - -/** - * Datasource types - */ -export type DatasourceType = - | 'postgres' - | 'mysql' - | 'mongodb' - | 'sqlite' - | 'mssql' - | 'oracle' - | 'rest' - | 'graphql' - | 'objectql' - | 'custom'; - -/** - * Datasource metric types (Phase 3.7.5) - */ -export type DatasourceMetric = - | 'query_count' - | 'query_duration' - | 'error_rate' - | 'connection_count' - | 'cache_hit_rate' - | 'throughput'; - -/** - * Datasource alert configuration (Phase 3.7.5) - */ -export interface DatasourceAlert { - /** - * Alert name - */ - name: string; - - /** - * Metric to monitor - */ - metric: DatasourceMetric; - - /** - * Threshold value - */ - threshold: number; - - /** - * Comparison operator - */ - operator: '>' | '<' | '>=' | '<=' | '='; - - /** - * Alert severity - */ - severity: 'info' | 'warning' | 'error' | 'critical'; - - /** - * Alert actions - */ - actions?: Array<'log' | 'email' | 'slack' | 'webhook'>; -} - -/** - * Multi-datasource manager (Phase 3.7.2) - */ -export interface DatasourceManager { - /** - * Register a datasource - */ - register(datasource: DatasourceRegistration): void; - - /** - * Unregister a datasource - */ - unregister(name: string): void; - - /** - * Get datasource by name - */ - get(name: string): DatasourceRegistration | undefined; - - /** - * Get default datasource - */ - getDefault(): DatasourceRegistration | undefined; - - /** - * Switch active datasource (Phase 3.7.3) - */ - switch(name: string): void; - - /** - * Get active datasource - */ - getActive(): DatasourceRegistration | undefined; - - /** - * List all datasources - */ - list(): DatasourceRegistration[]; - - /** - * Check datasource health (Phase 3.7.4) - */ - checkHealth(name: string): Promise; - - /** - * Get datasource metrics (Phase 3.7.5) - */ - getMetrics(name: string): Promise; -} - -/** - * Health check result (Phase 3.7.4) - */ -export interface HealthCheckResult { - /** - * Datasource name - */ - datasource: string; - - /** - * Health status - */ - status: 'healthy' | 'degraded' | 'unhealthy'; - - /** - * Response time in ms - */ - response_time?: number; - - /** - * Error message if unhealthy - */ - error?: string; - - /** - * Timestamp - */ - timestamp: Date; - - /** - * Additional details - */ - details?: Record; -} - -/** - * Datasource metrics (Phase 3.7.5) - */ -export interface DatasourceMetrics { - /** - * Datasource name - */ - datasource: string; - - /** - * Query metrics - */ - queries: { - total: number; - success: number; - failed: number; - avg_duration: number; - }; - - /** - * Connection metrics - */ - connections: { - active: number; - idle: number; - total: number; - }; - - /** - * Cache metrics - */ - cache?: { - hits: number; - misses: number; - hit_rate: number; - }; - - /** - * Error rate - */ - error_rate: number; - - /** - * Timestamp - */ - timestamp: Date; -} diff --git a/ui/packages/types/src/data.ts b/ui/packages/types/src/data.ts index b5c4cdf1ac3..29e51bfc8f2 100644 --- a/ui/packages/types/src/data.ts +++ b/ui/packages/types/src/data.ts @@ -227,9 +227,8 @@ export interface BatchRef { * server contract of `POST /api/v1/batch` (objectstack-ai/objectstack#1604 / * ADR-0034 item 4). * - * Distinct from the driver-level `BatchOperation` in `data-protocol.ts` - * (which speaks `type`/`table`) — this is the DataSource-level, object-aware - * shape consumed by {@link DataSource.batchTransaction}. + * This is the DataSource-level, object-aware shape consumed by + * {@link DataSource.batchTransaction}. */ export interface BatchTransactionOperation { /** Target object/table name. */ diff --git a/ui/packages/types/src/index.ts b/ui/packages/types/src/index.ts index 70f02ccfeee..9e7fa0ab02e 100644 --- a/ui/packages/types/src/index.ts +++ b/ui/packages/types/src/index.ts @@ -702,23 +702,6 @@ export type { FormatValidation, RangeValidation, ObjectValidationRule, - // Driver Interface (Phase 3.6) - SqlDriverInterface, - ConnectionConfig, - DriverQueryResult, - BatchOperation, - BatchResult, - TransactionContext, - CacheManager, - ConnectionPool, - // Datasource Schema (Phase 3.7) - DatasourceRegistration, - DatasourceType, - DatasourceMetric, - DatasourceAlert, - DatasourceManager, - HealthCheckResult, - DatasourceMetrics, } from './data-protocol.js'; // ============================================================================