-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdata-engine.ts
More file actions
62 lines (55 loc) · 2.33 KB
/
Copy pathdata-engine.ts
File metadata and controls
62 lines (55 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import {
EngineQueryOptions,
DataEngineInsertOptions,
EngineUpdateOptions,
EngineDeleteOptions,
EngineAggregateOptions,
EngineCountOptions,
DataEngineRequest,
DroppedFieldsEvent,
} from '@objectstack/spec/data';
/**
* In-process write-observability hooks for `insert`/`update` (#3407).
* Mirror of `WriteObservabilityOptions` in `@objectstack/spec/contracts` —
* see that definition for the full rationale (in-process only; never part of
* the serializable options schemas or the RPC boundary).
*/
export interface WriteObservabilityOptions {
/** Called once per strip pass that dropped ≥1 caller-supplied field. */
onFieldsDropped?: (event: DroppedFieldsEvent) => void;
}
/**
* IDataEngine - Standard Data Engine Interface
*
* Abstract interface for data persistence capabilities.
* Following the Dependency Inversion Principle - plugins depend on this interface,
* not on concrete database implementations.
*
* All query methods use standard QueryAST parameter names
* (where/fields/orderBy/limit/offset/expand) to eliminate mechanical translation
* between the Engine and Driver layers.
*
* Aligned with 'src/data/data-engine.zod.ts' in @objectstack/spec.
*/
export interface IDataEngine {
find(objectName: string, query?: EngineQueryOptions): Promise<any[]>;
findOne(objectName: string, query?: EngineQueryOptions): Promise<any>;
insert(objectName: string, data: any | any[], options?: DataEngineInsertOptions & WriteObservabilityOptions): Promise<any>;
update(objectName: string, data: any, options?: EngineUpdateOptions & WriteObservabilityOptions): Promise<any>;
delete(objectName: string, options?: EngineDeleteOptions): Promise<any>;
count(objectName: string, query?: EngineCountOptions): Promise<number>;
aggregate(objectName: string, query: EngineAggregateOptions): Promise<any[]>;
/**
* Vector Search (AI/RAG)
*/
vectorFind?(objectName: string, vector: number[], options?: { where?: any, limit?: number, fields?: string[], threshold?: number }): Promise<any[]>;
/**
* Batch Operations (Transactional)
*/
batch?(requests: DataEngineRequest[], options?: { transaction?: boolean }): Promise<any[]>;
/**
* Execute raw command (Escape hatch)
*/
execute?(command: any, options?: Record<string, any>): Promise<any>;
}