|
1 | | -import { QueryAST } from '@objectstack/spec/data'; |
2 | | -import { DriverOptions } from '@objectstack/spec/system'; |
| 1 | +import { |
| 2 | + DataEngineQueryOptions, |
| 3 | + DataEngineInsertOptions, |
| 4 | + DataEngineUpdateOptions, |
| 5 | + DataEngineDeleteOptions, |
| 6 | + DataEngineAggregateOptions, |
| 7 | + DataEngineCountOptions, |
| 8 | + DataEngineRequest // Added Request type for batch |
| 9 | +} from '@objectstack/spec/data'; |
3 | 10 |
|
4 | 11 | /** |
5 | 12 | * IDataEngine - Standard Data Engine Interface |
6 | 13 | * |
7 | 14 | * Abstract interface for data persistence capabilities. |
8 | 15 | * Following the Dependency Inversion Principle - plugins depend on this interface, |
9 | 16 | * not on concrete database implementations. |
| 17 | + * |
| 18 | + * Aligned with 'src/data/data-engine.zod.ts' in @objectstack/spec. |
10 | 19 | */ |
11 | 20 |
|
12 | | -export interface DataEngineFilter { |
13 | | - [key: string]: any; |
14 | | -} |
15 | | - |
16 | | -export interface DataEngineQueryOptions { |
17 | | - /** Filter conditions */ |
18 | | - filter?: DataEngineFilter; |
19 | | - /** Fields to select */ |
20 | | - select?: string[]; |
21 | | - /** Sort order */ |
22 | | - sort?: Record<string, 1 | -1 | 'asc' | 'desc'>; |
23 | | - /** Limit number of results */ |
24 | | - limit?: number; |
25 | | - /** Skip number of results */ |
26 | | - skip?: number; |
27 | | - /** Maximum number of results */ |
28 | | - top?: number; |
29 | | -} |
30 | | - |
31 | 21 | export interface IDataEngine { |
32 | | - insert(objectName: string, data: any): Promise<any>; |
33 | 22 | find(objectName: string, query?: DataEngineQueryOptions): Promise<any[]>; |
34 | | - update(objectName: string, id: any, data: any): Promise<any>; |
35 | | - delete(objectName: string, id: any): Promise<boolean>; |
| 23 | + findOne(objectName: string, query?: DataEngineQueryOptions): Promise<any>; |
| 24 | + insert(objectName: string, data: any | any[], options?: DataEngineInsertOptions): Promise<any>; |
| 25 | + update(objectName: string, data: any, options?: DataEngineUpdateOptions): Promise<any>; |
| 26 | + delete(objectName: string, options?: DataEngineDeleteOptions): Promise<any>; |
| 27 | + count(objectName: string, query?: DataEngineCountOptions): Promise<number>; |
| 28 | + aggregate(objectName: string, query: DataEngineAggregateOptions): Promise<any[]>; |
| 29 | + |
| 30 | + /** |
| 31 | + * Vector Search (AI/RAG) |
| 32 | + */ |
| 33 | + vectorFind?(objectName: string, vector: number[], options?: { filter?: any, limit?: number, select?: string[], threshold?: number }): Promise<any[]>; |
| 34 | + |
| 35 | + /** |
| 36 | + * Batch Operations (Transactional) |
| 37 | + */ |
| 38 | + batch?(requests: DataEngineRequest[], options?: { transaction?: boolean }): Promise<any[]>; |
| 39 | + |
| 40 | + * Execute raw command (Escape hatch) |
| 41 | + */ |
| 42 | + execute?(command: any, options?: Record<string, any>): Promise<any>; |
36 | 43 | } |
37 | 44 |
|
38 | 45 | export interface DriverInterface { |
|
0 commit comments