Skip to content

Commit 1c53aad

Browse files
committed
feat(types): add @objectstack/types package with IKernel interface and runtime plugin definitions
1 parent c59706c commit 1c53aad

File tree

8 files changed

+88
-9
lines changed

8 files changed

+88
-9
lines changed

examples/plugin-bi/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"main": "src/index.ts",
55
"license": "MIT",
6+
"private": true,
67
"scripts": {
78
"build": "tsc"
89
},

packages/plugin-hono-server/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
"build": "tsc"
99
},
1010
"dependencies": {
11-
"@objectstack/runtime": "workspace:*",
11+
"@hono/node-server": "^1.2.0",
1212
"@objectstack/spec": "workspace:*",
13-
"hono": "^4.0.0",
14-
"@hono/node-server": "^1.2.0"
13+
"@objectstack/types": "workspace:*",
14+
"hono": "^4.0.0"
1515
},
1616
"devDependencies": {
17+
"@objectstack/runtime": "^0.1.0",
1718
"@types/node": "^20.0.0",
1819
"typescript": "^5.0.0"
20+
},
21+
"peerDependencies": {
22+
"@objectstack/runtime": "^0.1.0"
1923
}
2024
}

packages/plugin-hono-server/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { serveStatic } from '@hono/node-server/serve-static';
33
import { Hono } from 'hono';
44
import { cors } from 'hono/cors';
55
import { logger } from 'hono/logger';
6-
import { ObjectStackKernel, ObjectStackRuntimeProtocol, RuntimePlugin } from '@objectstack/runtime';
6+
import { ObjectStackRuntimeProtocol } from '@objectstack/runtime';
7+
import { RuntimePlugin, IKernel } from '@objectstack/types';
78

89
export interface HonoServerOptions {
910
port?: number;
@@ -32,9 +33,10 @@ export class HonoServerPlugin implements RuntimePlugin {
3233
};
3334
}
3435

35-
async onStart(ctx: { engine: ObjectStackKernel }) {
36+
async onStart(ctx: { engine: IKernel }) {
3637
const app = new Hono();
37-
const protocol = new ObjectStackRuntimeProtocol(ctx.engine);
38+
// TODO: Protocol needs access to actual Kernel instance or we make Protocol an interface too
39+
const protocol = new ObjectStackRuntimeProtocol(ctx.engine as any);
3840

3941
// 1. Middlewares
4042
if (this.options.logger) app.use('*', logger());

packages/runtime/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"@objectstack/objectql": "workspace:*",
13+
"@objectstack/types": "workspace:*",
1314
"@objectstack/spec": "workspace:*"
1415
},
1516
"devDependencies": {

packages/types/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "@objectstack/types",
3+
"version": "0.1.0",
4+
"description": "Shared interfaces describing the ObjectStack Runtime environment",
5+
"main": "src/index.ts",
6+
"types": "src/index.ts",
7+
"dependencies": {
8+
"@objectstack/spec": "workspace:*"
9+
},
10+
"devDependencies": {
11+
"typescript": "^5.0.0"
12+
}
13+
}

packages/types/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Placeholder for Kernel interface to avoid circular dependency
2+
// The actual Kernel implementation will satisfy this interface.
3+
export interface IKernel {
4+
// We can add specific methods here that plugins are allowed to call
5+
// forcing a stricter contract than exposing the whole class.
6+
start(): Promise<void>;
7+
// ... expose other needed public methods
8+
[key: string]: any;
9+
}
10+
11+
export interface RuntimeContext {
12+
engine: IKernel;
13+
}
14+
15+
export interface RuntimePlugin {
16+
name: string;
17+
install?: (ctx: RuntimeContext) => void | Promise<void>;
18+
onStart?: (ctx: RuntimeContext) => void | Promise<void>;
19+
}

packages/types/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src/**/*"],
4+
"compilerOptions": {
5+
"outDir": "dist",
6+
"rootDir": "src"
7+
}
8+
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)