Skip to content

Commit d8a8c99

Browse files
Copilothotlong
andcommitted
Fix: Update app.ts and repository.ts to use DriverInterface from @objectstack/spec
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent e5f466f commit d8a8c99

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

packages/foundation/core/src/app.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import {
1919
HookContext,
2020
ActionHandler,
2121
ActionContext,
22-
LoaderPlugin,
23-
Driver
22+
LoaderPlugin
2423
} from '@objectql/types';
2524
import { ObjectRepository } from './repository';
2625

@@ -29,12 +28,13 @@ import { registerHookHelper, triggerHookHelper, HookEntry } from './hook';
2928
import { registerObjectHelper, getConfigsHelper } from './object';
3029
import { convertIntrospectedSchemaToObjects } from './util';
3130

32-
// Import ObjectStack engine (without using its driver types)
31+
// Import ObjectStack engine and standard driver interface
3332
import { ObjectQL as ObjectStackEngine } from '@objectstack/objectql';
33+
import { DriverInterface } from '@objectstack/spec';
3434

3535
export class ObjectQL implements IObjectQL {
3636
public metadata: MetadataRegistry;
37-
private datasources: Record<string, Driver> = {};
37+
private datasources: Record<string, DriverInterface> = {};
3838
private remotes: string[] = [];
3939
private hooks: Record<string, HookEntry[]> = {};
4040
private actions: Record<string, ActionEntry> = {};
@@ -55,9 +55,9 @@ export class ObjectQL implements IObjectQL {
5555
this.stackEngine = new ObjectStackEngine({});
5656

5757
// Register drivers with ObjectStack engine (no wrapping needed)
58-
// Cast to any since our Driver interface is compatible with spec's DriverInterface
5958
for (const [name, driver] of Object.entries(this.datasources)) {
60-
this.stackEngine.registerDriver(driver as any, name === 'default');
59+
this.stackEngine.registerDriver(driver, name === 'default');
60+
}
6161
}
6262

6363
if (config.connection) {
@@ -90,13 +90,12 @@ export class ObjectQL implements IObjectQL {
9090
/**
9191
* Register a new driver with ObjectStack engine
9292
*/
93-
registerDriver(name: string, driver: Driver, isDefault: boolean = false) {
93+
registerDriver(name: string, driver: DriverInterface, isDefault: boolean = false) {
9494
if (this.datasources[name]) {
9595
console.warn(`[ObjectQL] Driver '${name}' already exists. Overwriting...`);
9696
}
9797
this.datasources[name] = driver;
98-
// Cast to any since our Driver interface is compatible with spec's DriverInterface
99-
this.stackEngine.registerDriver(driver as any, isDefault);
98+
this.stackEngine.registerDriver(driver, isDefault);
10099
}
101100

102101
removePackage(name: string) {
@@ -191,7 +190,7 @@ export class ObjectQL implements IObjectQL {
191190
return getConfigsHelper(this.metadata);
192191
}
193192

194-
datasource(name: string): Driver {
193+
datasource(name: string): DriverInterface {
195194
const driver = this.datasources[name];
196195
if (!driver) {
197196
throw new Error(`Datasource '${name}' not found`);

packages/foundation/core/src/repository.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9-
import { ObjectQLContext, IObjectQL, ObjectConfig, Driver, UnifiedQuery, ActionContext, HookAPI, RetrievalHookContext, MutationHookContext, UpdateHookContext, ValidationContext, ValidationError, ValidationRuleResult, FormulaContext } from '@objectql/types';
9+
import { ObjectQLContext, IObjectQL, ObjectConfig, UnifiedQuery, ActionContext, HookAPI, RetrievalHookContext, MutationHookContext, UpdateHookContext, ValidationContext, ValidationError, ValidationRuleResult, FormulaContext } from '@objectql/types';
10+
import { DriverInterface } from '@objectstack/spec';
1011
import { Validator } from './validator';
1112
import { FormulaEngine } from './formula-engine';
1213

@@ -23,7 +24,7 @@ export class ObjectRepository {
2324
this.formulaEngine = new FormulaEngine();
2425
}
2526

26-
private getDriver(): Driver {
27+
private getDriver(): DriverInterface {
2728
const obj = this.getSchema();
2829
const datasourceName = obj.datasource || 'default';
2930
return this.app.datasource(datasourceName);

0 commit comments

Comments
 (0)