Skip to content

Commit 949fd82

Browse files
committed
重构数据引擎,删除 DataEngine 类,添加 ObjectStackKernel 类以支持插件和应用生命周期管理;更新相关接口和依赖
1 parent dc59963 commit 949fd82

File tree

8 files changed

+23
-26
lines changed

8 files changed

+23
-26
lines changed

content/docs/references/meta.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"data",
66
"ui",
77
"system",
8-
"client-sdk",
98
"ai",
109
"misc"
1110
]

examples/server/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DataEngine } from '@objectstack/runtime';
1+
import { ObjectStackKernel } from '@objectstack/runtime';
22
import { InMemoryDriver } from '@objectstack/driver-memory';
33
import { HonoServerPlugin } from '@objectstack/plugin-hono-server';
44

@@ -9,7 +9,7 @@ import BiPluginManifest from '@objectstack/plugin-bi/objectstack.config';
99
(async () => {
1010
console.log('🚀 Booting Kernel...');
1111

12-
const kernel = new DataEngine([
12+
const kernel = new ObjectStackKernel([
1313
CrmApp,
1414
TodoApp,
1515
BiPluginManifest,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ 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 { DataEngine, ObjectStackRuntimeProtocol, RuntimePlugin } from '@objectstack/runtime';
6+
import { ObjectStackKernel, ObjectStackRuntimeProtocol, RuntimePlugin } from '@objectstack/runtime';
77

88
export interface HonoServerOptions {
99
port?: number;
@@ -32,7 +32,7 @@ export class HonoServerPlugin implements RuntimePlugin {
3232
};
3333
}
3434

35-
async onStart(ctx: { engine: DataEngine }) {
35+
async onStart(ctx: { engine: ObjectStackKernel }) {
3636
const app = new Hono();
3737
const protocol = new ObjectStackRuntimeProtocol(ctx.engine);
3838

packages/runtime/src/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export class ObjectQL {
6868
// Register Data Seeding (Lazy execution or immediate?)
6969
// We store it in a temporary registry or execute immediately if engine is ready.
7070
// Since `use` is init time, we might need to store it and run later in `seed()`.
71-
// For this MVP, let's attach it to the manifest object in registry so DataEngine can find it.
71+
// For this MVP, let's attach it to the manifest object in registry so Kernel can find it.
7272
}
7373

7474
// 2. Execute Runtime

packages/runtime/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Export core engine
22
export { ObjectQL } from './engine';
33
export { SchemaRegistry } from './registry';
4-
export { DataEngine } from './data-engine';
4+
export { ObjectStackKernel } from './kernel';
55
export { ObjectStackRuntimeProtocol } from './protocol';
66

77

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import { SchemaRegistry } from './registry';
33
import { ObjectQL } from './engine';
44

55
/**
6-
* Server Data Engine Wrapper
6+
* ObjectStack Kernel (Microkernel)
77
*
8-
* This class is now a thin wrapper that initializes the ObjectQL Engine
9-
* with the appropriate Server-Side configuration (Registry, Drivers).
10-
*
11-
* The core logic has been moved to @objectstack/objectql.
8+
* The central container orchestrating the application lifecycle,
9+
* plugins, and the core ObjectQL engine.
1210
*/
13-
export class DataEngine {
11+
export class ObjectStackKernel {
1412
public ql: ObjectQL;
1513
private plugins: any[];
1614

@@ -23,26 +21,26 @@ export class DataEngine {
2321
}
2422

2523
async start() {
26-
console.log('[DataEngine] Starting...');
24+
console.log('[Kernel] Starting...');
2725

2826
// 0. Register Provided Plugins
2927
for (const p of this.plugins) {
3028
// Check if it is a Runtime Plugin (System Capability)
3129
if ('onStart' in p || 'install' in p) {
32-
console.log(`[DataEngine] Loading Runtime Plugin: ${p.name}`);
30+
console.log(`[Kernel] Loading Runtime Plugin: ${p.name}`);
3331
if (p.install) await p.install({ engine: this });
3432
continue;
3533
}
3634

3735
// Otherwise treat as App Manifest
38-
console.log(`[DataEngine] Loading App Manifest: ${p.id || p.name}`);
36+
console.log(`[Kernel] Loading App Manifest: ${p.id || p.name}`);
3937
SchemaRegistry.registerPlugin(p);
4038

4139
// Register Objects from App/Plugin
4240
if (p.objects) {
4341
for (const obj of p.objects) {
4442
SchemaRegistry.registerObject(obj);
45-
console.log(`[DataEngine] Registered Object: ${obj.name}`);
43+
console.log(`[Kernel] Registered Object: ${obj.name}`);
4644
}
4745
}
4846
}
@@ -72,7 +70,7 @@ export class DataEngine {
7270
// 4. Start Runtime Plugins
7371
for (const p of this.plugins) {
7472
if (('onStart' in p) && typeof p.onStart === 'function') {
75-
console.log(`[DataEngine] Starting Plugin: ${p.name}`);
73+
console.log(`[Kernel] Starting Plugin: ${p.name}`);
7674
await p.onStart({ engine: this });
7775
}
7876
}
@@ -101,19 +99,19 @@ export class DataEngine {
10199
for (const appItem of apps) {
102100
const app = appItem as any; // Cast to access data prop safely
103101
if (app.data && Array.isArray(app.data)) {
104-
console.log(`[DataEngine] Seeding data for ${app.name || app.id}...`);
102+
console.log(`[Kernel] Seeding data for ${app.name || app.id}...`);
105103
for (const seed of app.data) {
106104
try {
107105
// Check if data exists
108106
const existing = await this.ql.find(seed.object, { top: 1 });
109107
if (existing.length === 0) {
110-
console.log(`[DataEngine] Inserting ${seed.records.length} records into ${seed.object}`);
108+
console.log(`[Kernel] Inserting ${seed.records.length} records into ${seed.object}`);
111109
for (const record of seed.records) {
112110
await this.ql.insert(seed.object, record);
113111
}
114112
}
115113
} catch (e) {
116-
console.warn(`[DataEngine] Failed to seed ${seed.object}`, e);
114+
console.warn(`[Kernel] Failed to seed ${seed.object}`, e);
117115
}
118116
}
119117
}

packages/runtime/src/protocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SchemaRegistry } from './registry';
2-
import { DataEngine } from './data-engine';
2+
import { ObjectStackKernel } from './kernel';
33

44
export interface ApiRequest {
55
params: Record<string, string>;
@@ -8,9 +8,9 @@ export interface ApiRequest {
88
}
99

1010
export class ObjectStackRuntimeProtocol {
11-
private engine: DataEngine;
11+
private engine: ObjectStackKernel;
1212

13-
constructor(engine: DataEngine) {
13+
constructor(engine: ObjectStackKernel) {
1414
this.engine = engine;
1515
}
1616

packages/runtime/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { DataEngine } from './data-engine';
1+
import { ObjectStackKernel } from './kernel';
22

33
export interface RuntimeContext {
4-
engine: DataEngine;
4+
engine: ObjectStackKernel;
55
}
66

77
export interface RuntimePlugin {

0 commit comments

Comments
 (0)