@@ -68,8 +68,10 @@ export interface IntrospectedSchema {
6868
6969/**
7070 * Transaction isolation levels supported by the driver.
71+ *
72+ * Aligned with @objectstack/spec DriverCapabilitiesSchema — uses snake_case per protocol convention.
7173 */
72- export type IsolationLevel = 'read-uncommitted ' | 'read-committed ' | 'repeatable-read ' | 'serializable' ;
74+ export type IsolationLevel = 'read_uncommitted ' | 'read_committed ' | 'repeatable_read ' | 'serializable' | 'snapshot ';
7375
7476/**
7577 * Driver Capabilities
@@ -131,8 +133,18 @@ export interface DriverCapabilities {
131133 readonly connectionPooling ?: boolean ;
132134 readonly preparedStatements ?: boolean ;
133135 readonly queryCache ?: boolean ;
136+ }
134137
135- // Sync support (Q3 — Offline-First Sync Protocol)
138+ /**
139+ * Runtime Driver Capabilities (extends spec with sync-specific properties)
140+ *
141+ * These properties are NOT part of the @objectstack/spec DriverCapabilitiesSchema
142+ * (which sets additionalProperties: false). They are runtime-only extensions
143+ * used by the Offline-First Sync Protocol (Q3).
144+ *
145+ * Use this interface for drivers that need sync capabilities.
146+ */
147+ export interface RuntimeDriverCapabilities extends DriverCapabilities {
136148 /** Driver can record mutations to an append-only log for offline sync */
137149 readonly mutationLog ?: boolean ;
138150 /** Driver supports checkpoint-based change tracking */
@@ -190,8 +202,14 @@ export interface Driver {
190202
191203 // Transaction support
192204 beginTransaction ?( ) : Promise < any > ;
205+ /** @deprecated Use `commit` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */
193206 commitTransaction ?( transaction : any ) : Promise < void > ;
207+ /** @deprecated Use `rollback` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */
194208 rollbackTransaction ?( transaction : any ) : Promise < void > ;
209+ /** Commit a transaction (spec-aligned name) */
210+ commit ?( transaction : any ) : Promise < void > ;
211+ /** Rollback a transaction (spec-aligned name) */
212+ rollback ?( transaction : any ) : Promise < void > ;
195213
196214 // Schema / Lifecycle
197215 init ?( objects : any [ ] ) : Promise < void > ;
@@ -229,5 +247,67 @@ export interface Driver {
229247 */
230248 directQuery ?( sql : string , params ?: any [ ] ) : Promise < any [ ] > ;
231249 query ?( sql : string , params ?: any [ ] ) : Promise < any [ ] > ;
250+
251+ // ========================================================================
252+ // Methods from @objectstack /spec DriverInterfaceSchema
253+ // ========================================================================
254+
255+ /**
256+ * Upsert (create or update) a record.
257+ * If the record exists (matched by ID or unique key), update it; otherwise, create it.
258+ *
259+ * @param objectName - The object name.
260+ * @param data - Key-value map of field data (must include ID or unique key).
261+ * @param options - Driver options.
262+ * @returns The upserted record.
263+ */
264+ upsert ?( objectName : string , data : Record < string , unknown > , options ?: any ) : Promise < any > ;
265+
266+ /**
267+ * Stream records matching the structured query.
268+ * Optimized for large datasets to avoid memory overflow.
269+ *
270+ * @param objectName - The name of the object.
271+ * @param query - The structured QueryAST.
272+ * @param options - Driver options.
273+ * @returns AsyncIterable/ReadableStream of records.
274+ */
275+ findStream ?( objectName : string , query : any , options ?: any ) : AsyncIterable < any > | any ;
276+
277+ /**
278+ * Get connection pool statistics.
279+ * Useful for monitoring database load.
280+ *
281+ * @returns Pool stats object, or undefined if pooling is not supported by the driver.
282+ */
283+ getPoolStats ?( ) : { total : number ; idle : number ; active : number ; waiting : number } | undefined ;
284+
285+ /**
286+ * Synchronize the schema for one or more objects.
287+ * Creates or alters tables/collections to match the object definitions.
288+ *
289+ * @param objects - Object definitions to synchronize.
290+ * @param options - Driver options.
291+ */
292+ syncSchema ?( objects : any [ ] , options ?: any ) : Promise < void > ;
293+
294+ /**
295+ * Drop a table/collection by name.
296+ *
297+ * @param objectName - The name of the object/table to drop.
298+ * @param options - Driver options.
299+ */
300+ dropTable ?( objectName : string , options ?: any ) : Promise < void > ;
301+
302+ /**
303+ * Explain the execution plan for a query.
304+ * Useful for debugging and performance optimization.
305+ *
306+ * @param objectName - The name of the object.
307+ * @param query - The structured QueryAST.
308+ * @param options - Driver options.
309+ * @returns Execution plan details.
310+ */
311+ explain ?( objectName : string , query : any , options ?: any ) : Promise < any > ;
232312}
233313
0 commit comments