-
Notifications
You must be signed in to change notification settings - Fork 2
fix: align all packages with @objectstack/spec v2.0.1 protocol #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,8 +68,10 @@ export interface IntrospectedSchema { | |
|
|
||
| /** | ||
| * Transaction isolation levels supported by the driver. | ||
| * | ||
| * Aligned with @objectstack/spec DriverCapabilitiesSchema — uses snake_case per protocol convention. | ||
| */ | ||
| export type IsolationLevel = 'read-uncommitted' | 'read-committed' | 'repeatable-read' | 'serializable'; | ||
| export type IsolationLevel = 'read_uncommitted' | 'read_committed' | 'repeatable_read' | 'serializable' | 'snapshot'; | ||
|
|
||
| /** | ||
| * Driver Capabilities | ||
|
|
@@ -131,8 +133,18 @@ export interface DriverCapabilities { | |
| readonly connectionPooling?: boolean; | ||
| readonly preparedStatements?: boolean; | ||
| readonly queryCache?: boolean; | ||
| } | ||
|
|
||
| // Sync support (Q3 — Offline-First Sync Protocol) | ||
| /** | ||
| * Runtime Driver Capabilities (extends spec with sync-specific properties) | ||
| * | ||
| * These properties are NOT part of the @objectstack/spec DriverCapabilitiesSchema | ||
| * (which sets additionalProperties: false). They are runtime-only extensions | ||
| * used by the Offline-First Sync Protocol (Q3). | ||
| * | ||
| * Use this interface for drivers that need sync capabilities. | ||
| */ | ||
| export interface RuntimeDriverCapabilities extends DriverCapabilities { | ||
| /** Driver can record mutations to an append-only log for offline sync */ | ||
| readonly mutationLog?: boolean; | ||
| /** Driver supports checkpoint-based change tracking */ | ||
|
|
@@ -190,8 +202,14 @@ export interface Driver { | |
|
|
||
| // Transaction support | ||
| beginTransaction?(): Promise<any>; | ||
| /** @deprecated Use `commit` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */ | ||
| commitTransaction?(transaction: any): Promise<void>; | ||
| /** @deprecated Use `rollback` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */ | ||
| rollbackTransaction?(transaction: any): Promise<void>; | ||
| /** Commit a transaction (spec-aligned name) */ | ||
| commit?(transaction: any): Promise<void>; | ||
| /** Rollback a transaction (spec-aligned name) */ | ||
| rollback?(transaction: any): Promise<void>; | ||
|
|
||
| // Schema / Lifecycle | ||
| init?(objects: any[]): Promise<void>; | ||
|
|
@@ -229,5 +247,67 @@ export interface Driver { | |
| */ | ||
| directQuery?(sql: string, params?: any[]): Promise<any[]>; | ||
| query?(sql: string, params?: any[]): Promise<any[]>; | ||
|
|
||
| // ======================================================================== | ||
| // Methods from @objectstack/spec DriverInterfaceSchema | ||
| // ======================================================================== | ||
|
|
||
| /** | ||
| * Upsert (create or update) a record. | ||
| * If the record exists (matched by ID or unique key), update it; otherwise, create it. | ||
| * | ||
| * @param objectName - The object name. | ||
| * @param data - Key-value map of field data (must include ID or unique key). | ||
| * @param options - Driver options. | ||
| * @returns The upserted record. | ||
| */ | ||
| upsert?(objectName: string, data: Record<string, unknown>, options?: any): Promise<any>; | ||
|
|
||
| /** | ||
| * Stream records matching the structured query. | ||
| * Optimized for large datasets to avoid memory overflow. | ||
| * | ||
| * @param objectName - The name of the object. | ||
| * @param query - The structured QueryAST. | ||
| * @param options - Driver options. | ||
| * @returns AsyncIterable/ReadableStream of records. | ||
| */ | ||
| findStream?(objectName: string, query: any, options?: any): AsyncIterable<any> | any; | ||
|
|
||
|
Comment on lines
+271
to
+276
|
||
| /** | ||
| * Get connection pool statistics. | ||
| * Useful for monitoring database load. | ||
| * | ||
| * @returns Pool stats object, or undefined if pooling is not supported by the driver. | ||
| */ | ||
| getPoolStats?(): { total: number; idle: number; active: number; waiting: number } | undefined; | ||
|
|
||
| /** | ||
| * Synchronize the schema for one or more objects. | ||
| * Creates or alters tables/collections to match the object definitions. | ||
| * | ||
| * @param objects - Object definitions to synchronize. | ||
| * @param options - Driver options. | ||
| */ | ||
| syncSchema?(objects: any[], options?: any): Promise<void>; | ||
|
|
||
| /** | ||
| * Drop a table/collection by name. | ||
| * | ||
| * @param objectName - The name of the object/table to drop. | ||
| * @param options - Driver options. | ||
| */ | ||
| dropTable?(objectName: string, options?: any): Promise<void>; | ||
|
|
||
| /** | ||
| * Explain the execution plan for a query. | ||
| * Useful for debugging and performance optimization. | ||
| * | ||
| * @param objectName - The name of the object. | ||
| * @param query - The structured QueryAST. | ||
| * @param options - Driver options. | ||
| * @returns Execution plan details. | ||
| */ | ||
| explain?(objectName: string, query: any, options?: any): Promise<any>; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test name says "support all isolation levels", but the assertions only cover 4 values and omit
snapshot(which is now part of theIsolationLevelunion). Either includesnapshotin the driver capability + assertions, or rename the test to avoid claiming full coverage.