Skip to content

Commit 322ced2

Browse files
committed
feat: implement protocol service registration with enhanced methods for metadata retrieval
1 parent b3d52b4 commit 322ced2

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

apps/console/src/mocks/createKernel.ts

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ export async function createKernel(options: KernelOptions) {
3333
console.log('[KernelFactory] Loading app:', appConfig.manifest?.id || appConfig.name || 'unknown');
3434
await kernel.use(new AppPlugin(appConfig));
3535
}
36-
37-
// MSW Plugin
38-
await kernel.use(new MSWPlugin({
39-
enableBrowser: enableBrowser,
40-
baseUrl: '/api/v1',
41-
logRequests: true
42-
}));
4336

44-
// --- BROKER SHIM START ---
37+
// Protocol service is registered automatically by ObjectQLPlugin.init()
38+
// via ObjectStackProtocolImplementation (which uses SchemaRegistry internally).
39+
// Do NOT manually set 'protocol' on kernel.services — it would conflict with
40+
// ObjectQLPlugin's ctx.registerService('protocol', ...) during bootstrap.
41+
console.log('[KernelFactory] Protocol service will be registered by ObjectQLPlugin');
42+
43+
// --- BROKER SHIM (MUST be registered BEFORE MSWPlugin) ---
4544
// HttpDispatcher requires a broker to function. We inject a shim.
4645
(kernel as any).broker = {
4746
call: async (action: string, params: any, _opts: any) => {
@@ -290,6 +289,13 @@ export async function createKernel(options: KernelOptions) {
290289
}
291290
};
292291
// --- BROKER SHIM END ---
292+
293+
// MSW Plugin (AFTER protocol service and broker shim are registered)
294+
await kernel.use(new MSWPlugin({
295+
enableBrowser: enableBrowser,
296+
baseUrl: '/api/v1',
297+
logRequests: true
298+
}));
293299

294300
await kernel.bootstrap();
295301

@@ -320,20 +326,5 @@ export async function createKernel(options: KernelOptions) {
320326
}
321327
}
322328

323-
// --- PROTOCOL SERVICE MOCK ---
324-
if ((kernel as any).services instanceof Map) {
325-
(kernel as any).services.set('protocol', {
326-
getUiView: async ({ object, type }: any) => {
327-
return {
328-
type: type || 'list',
329-
name: 'default',
330-
object: object,
331-
title: object,
332-
body: []
333-
};
334-
}
335-
});
336-
}
337-
338329
return kernel;
339330
}

packages/runtime/src/http-dispatcher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ export class HttpDispatcher {
232232
if (protocol && typeof protocol.getMetaItems === 'function') {
233233
try {
234234
const data = await protocol.getMetaItems({ type: typeOrName, packageId });
235-
if (data && ((data.items && data.items.length > 0) || (Array.isArray(data) && data.length > 0))) {
235+
// Return any valid response from protocol (including empty items arrays)
236+
if (data && (data.items !== undefined || Array.isArray(data))) {
236237
return { handled: true, response: this.success(data) };
237238
}
238239
} catch {

0 commit comments

Comments
 (0)