Skip to content

Commit bd67633

Browse files
Copilothotlong
andcommitted
Remove all ObjectStackKernel references from plugins
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent bfe329f commit bd67633

File tree

2 files changed

+5
-141
lines changed

2 files changed

+5
-141
lines changed

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

Lines changed: 1 addition & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { logger } from 'hono/logger';
66
import {
77
Plugin,
88
PluginContext,
9-
RuntimePlugin,
10-
RuntimeContext,
119
ObjectStackRuntimeProtocol
1210
} from '@objectstack/runtime';
1311

@@ -30,7 +28,7 @@ export interface HonoPluginOptions {
3028
* const server = new HonoServerPlugin({ port: 3000 });
3129
* kernel.use(server);
3230
*/
33-
export class HonoServerPlugin implements Plugin, RuntimePlugin {
31+
export class HonoServerPlugin implements Plugin {
3432
name = 'com.objectstack.server.hono';
3533
version = '1.0.0';
3634

@@ -116,111 +114,4 @@ export class HonoServerPlugin implements Plugin, RuntimePlugin {
116114
console.log('[HonoServerPlugin] Server stopped');
117115
}
118116
}
119-
120-
/**
121-
* Legacy install method for backward compatibility
122-
* @deprecated Use init/start lifecycle hooks instead
123-
*/
124-
install(ctx: RuntimeContext) {
125-
const { engine } = ctx;
126-
const protocol = new ObjectStackRuntimeProtocol(engine);
127-
128-
// --- Bind Protocol to Hono ---
129-
130-
// 1. Discovery
131-
this.app.get('/api/v1', (c) => c.json(protocol.getDiscovery()));
132-
133-
// 2. Meta
134-
this.app.get('/api/v1/meta', (c) => c.json(protocol.getMetaTypes()));
135-
this.app.get('/api/v1/meta/:type', (c) => c.json(protocol.getMetaItems(c.req.param('type'))));
136-
this.app.get('/api/v1/meta/:type/:name', (c) => {
137-
try {
138-
return c.json(protocol.getMetaItem(c.req.param('type'), c.req.param('name')));
139-
} catch (e: any) {
140-
return c.json({ error: e.message }, 404);
141-
}
142-
});
143-
144-
// 3. Data
145-
this.app.get('/api/v1/data/:object', async (c) => {
146-
try {
147-
const result = await protocol.findData(c.req.param('object'), c.req.query());
148-
return c.json(result);
149-
} catch (e: any) {
150-
return c.json({ error: e.message }, 404);
151-
}
152-
});
153-
154-
this.app.get('/api/v1/data/:object/:id', async (c) => {
155-
try {
156-
const result = await protocol.getData(c.req.param('object'), c.req.param('id'));
157-
return c.json(result);
158-
} catch (e: any) {
159-
return c.json({ error: e.message }, 404);
160-
}
161-
});
162-
163-
this.app.post('/api/v1/data/:object', async (c) => {
164-
try {
165-
const body = await c.req.json();
166-
const result = await protocol.createData(c.req.param('object'), body);
167-
return c.json(result, 201);
168-
} catch (e: any) {
169-
return c.json({ error: e.message }, 400);
170-
}
171-
});
172-
173-
this.app.patch('/api/v1/data/:object/:id', async (c) => {
174-
try {
175-
const body = await c.req.json();
176-
const result = await protocol.updateData(c.req.param('object'), c.req.param('id'), body);
177-
return c.json(result);
178-
} catch (e: any) {
179-
return c.json({ error: e.message }, 400);
180-
}
181-
});
182-
183-
this.app.delete('/api/v1/data/:object/:id', async (c) => {
184-
try {
185-
const result = await protocol.deleteData(c.req.param('object'), c.req.param('id'));
186-
return c.json(result);
187-
} catch (e: any) {
188-
return c.json({ error: e.message }, 400);
189-
}
190-
});
191-
192-
// 4. UI Protocol
193-
this.app.get('/api/v1/ui/view/:object', (c) => {
194-
try {
195-
// @ts-ignore
196-
const view = protocol.getUiView(c.req.param('object'), c.req.query('type') || 'list');
197-
return c.json(view);
198-
} catch (e: any) {
199-
return c.json({ error: e.message }, 404);
200-
}
201-
});
202-
203-
// Static Files
204-
if (this.options.staticRoot) {
205-
this.app.get('/', serveStatic({ root: this.options.staticRoot, path: 'index.html' }));
206-
this.app.get('/*', serveStatic({ root: this.options.staticRoot }));
207-
}
208-
209-
console.log(`[HonoPlugin] Installed routes and middleware.`);
210-
}
211-
212-
/**
213-
* Legacy onStart method for backward compatibility
214-
* @deprecated Use start lifecycle hook instead
215-
*/
216-
async onStart(ctx: RuntimeContext) {
217-
const port = this.options.port;
218-
console.log(`[HonoPlugin] Starting server...`);
219-
console.log(`✅ Server is running on http://localhost:${port}`);
220-
221-
serve({
222-
fetch: this.app.fetch,
223-
port
224-
});
225-
}
226117
}

packages/plugin-msw/src/msw-plugin.ts

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { http, HttpResponse } from 'msw';
22
import { setupWorker } from 'msw/browser';
33
import {
4-
RuntimePlugin,
5-
RuntimeContext,
64
Plugin,
75
PluginContext,
86
ObjectStackRuntimeProtocol,
@@ -156,8 +154,6 @@ export class ObjectStackServer {
156154
* This plugin enables Mock Service Worker integration for testing and development.
157155
* It automatically mocks API endpoints using the ObjectStack runtime protocol.
158156
*
159-
* Supports both legacy RuntimePlugin and new Plugin interfaces.
160-
*
161157
* @example
162158
* ```typescript
163159
* import { MSWPlugin } from '@objectstack/plugin-msw';
@@ -170,7 +166,7 @@ export class ObjectStackServer {
170166
* }));
171167
* ```
172168
*/
173-
export class MSWPlugin implements Plugin, RuntimePlugin {
169+
export class MSWPlugin implements Plugin {
174170
name = 'com.objectstack.plugin.msw';
175171
version = '1.0.0';
176172

@@ -189,15 +185,15 @@ export class MSWPlugin implements Plugin, RuntimePlugin {
189185
}
190186

191187
/**
192-
* New Plugin interface - init phase
188+
* Init phase
193189
*/
194190
async init(ctx: PluginContext) {
195191
// Protocol will be created in start phase
196192
ctx.logger.log('[MSWPlugin] Initialized');
197193
}
198194

199195
/**
200-
* New Plugin interface - start phase
196+
* Start phase
201197
*/
202198
async start(ctx: PluginContext) {
203199
// Get the kernel and create protocol
@@ -213,35 +209,12 @@ export class MSWPlugin implements Plugin, RuntimePlugin {
213209
}
214210

215211
/**
216-
* New Plugin interface - destroy phase
212+
* Destroy phase
217213
*/
218214
async destroy() {
219215
await this.stopWorker();
220216
}
221217

222-
/**
223-
* Legacy RuntimePlugin interface - install
224-
*/
225-
install(ctx: RuntimeContext) {
226-
const { engine } = ctx;
227-
this.protocol = new ObjectStackRuntimeProtocol(engine);
228-
this.setupHandlers();
229-
}
230-
231-
/**
232-
* Legacy RuntimePlugin interface - onStart
233-
*/
234-
async onStart(ctx: RuntimeContext) {
235-
await this.startWorker();
236-
}
237-
238-
/**
239-
* Legacy RuntimePlugin interface - onStop
240-
*/
241-
async onStop() {
242-
await this.stopWorker();
243-
}
244-
245218
/**
246219
* Setup MSW handlers
247220
*/

0 commit comments

Comments
 (0)