Skip to content

Commit 1f3b02b

Browse files
Copilothotlong
andcommitted
Docs: Improve documentation and clarify backward-compatible ObjectStack integration
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 260aa68 commit 1f3b02b

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

packages/drivers/sql/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import knex, { Knex } from 'knex';
1111

1212
/**
1313
* SQL Driver for ObjectQL
14-
* Implements Driver interface from @objectql/types
14+
*
15+
* Implements the Driver interface from @objectql/types with optional
16+
* ObjectStack-compatible properties for integration with @objectstack/objectql.
1517
*/
1618
export class SqlDriver implements Driver {
1719
private knex: Knex;
@@ -510,8 +512,6 @@ export class SqlDriver implements Driver {
510512
return data;
511513
}
512514

513-
/**
514-
515515
/**
516516
* Introspect the database schema to discover existing tables, columns, and relationships.
517517
*/

packages/foundation/core/src/app.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ import { registerObjectHelper, getConfigsHelper } from './object';
3030
import { convertIntrospectedSchemaToObjects } from './util';
3131

3232
// Import ObjectStack engine for driver management
33+
// Note: We use type casting when interfacing with ObjectStack to maintain
34+
// backward compatibility with existing Driver implementations
3335
import { ObjectQL as ObjectStackEngine } from '@objectstack/objectql';
3436

37+
/**
38+
* ObjectQL Application
39+
*
40+
* Integrates with @objectstack/objectql for driver management while
41+
* maintaining backward compatibility with existing Driver implementations.
42+
*
43+
* Drivers implementing the extended Driver interface from @objectql/types
44+
* are compatible with DriverInterface from @objectstack/spec through
45+
* optional property extensions.
46+
*/
3547
export class ObjectQL implements IObjectQL {
3648
public metadata: MetadataRegistry;
49+
// Uses Driver from @objectql/types which has been extended to be
50+
// compatible with DriverInterface from @objectstack/spec
3751
private datasources: Record<string, Driver> = {};
3852
private remotes: string[] = [];
3953
private hooks: Record<string, HookEntry[]> = {};
@@ -55,6 +69,8 @@ export class ObjectQL implements IObjectQL {
5569
this.stackEngine = new ObjectStackEngine({});
5670

5771
// Register drivers with ObjectStack engine
72+
// Type casting is used here because Driver from @objectql/types is structurally
73+
// compatible with DriverInterface from @objectstack/spec through optional extensions
5874
for (const [name, driver] of Object.entries(this.datasources)) {
5975
this.stackEngine.registerDriver(driver as any, name === 'default');
6076
}
@@ -81,20 +97,29 @@ export class ObjectQL implements IObjectQL {
8197
}
8298

8399
/**
84-
* Get the ObjectStack engine instance for advanced driver management
100+
* Get access to the ObjectStack engine for advanced driver features
101+
*
102+
* @returns The ObjectStack engine instance managing drivers
85103
*/
86104
getStackEngine(): ObjectStackEngine {
87105
return this.stackEngine;
88106
}
89107

90108
/**
91109
* Register a new driver with ObjectStack engine
110+
*
111+
* @param name - The name of the datasource
112+
* @param driver - Driver instance implementing Driver interface from @objectql/types
113+
* @param isDefault - Whether this driver should be the default datasource
92114
*/
93115
registerDriver(name: string, driver: Driver, isDefault: boolean = false) {
94116
if (this.datasources[name]) {
95117
console.warn(`[ObjectQL] Driver '${name}' already exists. Overwriting...`);
96118
}
97119
this.datasources[name] = driver;
120+
// Type casting for ObjectStack engine compatibility
121+
// Driver from @objectql/types has been extended with optional properties
122+
// to be compatible with DriverInterface from @objectstack/spec
98123
this.stackEngine.registerDriver(driver as any, isDefault);
99124
}
100125

0 commit comments

Comments
 (0)