Skip to content

Commit 2e92746

Browse files
Copilothuangyiirene
andcommitted
fix: Improve type safety - use RuntimePlugin instead of any, update config types
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 6b1e2cd commit 2e92746

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

packages/foundation/core/src/app.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
ActionContext,
2222
LoaderPlugin
2323
} from '@objectql/types';
24-
import type { PluginDefinition } from '@objectstack/spec';
25-
import { ObjectStackKernel } from '@objectstack/runtime';
24+
import { ObjectStackKernel, type RuntimePlugin } from '@objectstack/runtime';
2625
import { ObjectRepository } from './repository';
2726
import { ObjectQLPlugin } from './plugin';
2827
// import { createDriverFromConnection } from './driver'; // REMOVE THIS
@@ -47,8 +46,8 @@ export class ObjectQL implements IObjectQL {
4746
private actions: Record<string, ActionEntry> = {};
4847

4948
// ObjectStack Kernel Integration
50-
private kernel: ObjectStackKernel;
51-
private kernelPlugins: any[] = [];
49+
private kernel!: ObjectStackKernel;
50+
private kernelPlugins: RuntimePlugin[] = [];
5251

5352
// Store config for lazy loading in init()
5453
private config: ObjectQLConfig;
@@ -78,7 +77,7 @@ export class ObjectQL implements IObjectQL {
7877
}
7978
}
8079

81-
use(plugin: any) {
80+
use(plugin: RuntimePlugin) {
8281
this.kernelPlugins.push(plugin);
8382
}
8483

packages/foundation/types/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"test": "jest --passWithNoTests"
2828
},
2929
"dependencies": {
30-
"@objectstack/spec": "^0.2.0"
30+
"@objectstack/spec": "^0.2.0",
31+
"@objectstack/runtime": "^0.2.0"
3132
},
3233
"devDependencies": {
3334
"ts-json-schema-generator": "^2.4.0"

packages/foundation/types/src/config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import { MetadataRegistry } from "./registry";
1010
import { Driver } from "./driver";
1111
import { ObjectConfig } from "./object";
12-
import type { PluginDefinition } from "@objectstack/spec";
12+
import type { RuntimePlugin } from "@objectstack/runtime";
1313

1414
export interface ObjectQLConfig {
1515
registry?: MetadataRegistry;
@@ -39,11 +39,10 @@ export interface ObjectQLConfig {
3939
modules?: string[];
4040
/**
4141
* List of plugins to load.
42-
* Can be:
43-
* - An instance of PluginDefinition (from @objectstack/spec)
44-
* - A package name string
42+
* Must implement the RuntimePlugin interface from @objectstack/runtime.
43+
* String plugins (package names) are not supported in core.
4544
*/
46-
plugins?: (PluginDefinition | string)[];
45+
plugins?: (RuntimePlugin | string)[];
4746
/**
4847
* List of remote ObjectQL instances to connect to.
4948
* e.g. ["http://user-service:3000", "http://order-service:3000"]

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)