Skip to content

Commit 5730807

Browse files
committed
feat: Improve metadata retrieval in AppSidebar and HttpDispatcher for dynamic types
1 parent cf74f11 commit 5730807

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

apps/console/src/components/app-sidebar.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export function AppSidebar({ client, selectedObject, onSelectObject, apps, selec
111111
setLoading(true);
112112
try {
113113
// 1. Discover all registered metadata types
114-
const typesResult: any = await client.meta.getTypes();
114+
const typesRaw: any = await client.meta.getTypes();
115+
// Unwrap { success, data } envelope if present
116+
const typesResult = typesRaw?.data ?? typesRaw;
115117
let types: string[] = [];
116118
if (typesResult && Array.isArray(typesResult.types)) {
117119
types = typesResult.types;
@@ -126,7 +128,9 @@ export function AppSidebar({ client, selectedObject, onSelectObject, apps, selec
126128
.filter(t => !HIDDEN_TYPES.has(t))
127129
.map(async (type) => {
128130
try {
129-
const result: any = await client.meta.getItems(type);
131+
const raw: any = await client.meta.getItems(type);
132+
// Unwrap { success, data } envelope if present
133+
const result = raw?.data ?? raw;
130134
let items: any[] = [];
131135
if (Array.isArray(result)) {
132136
items = result;

packages/runtime/src/http-dispatcher.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,21 @@ export class HttpDispatcher {
260260
}
261261
}
262262

263-
// GET /metadata (List Objects - Default)
263+
// GET /metadata — return available metadata types
264264
if (parts.length === 0) {
265-
const data = await broker.call('metadata.objects', {}, { request: context.request });
266-
return { handled: true, response: this.success(data) };
265+
// Try protocol service for dynamic types
266+
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService('protocol') : null;
267+
if (protocol && typeof protocol.getMetaTypes === 'function') {
268+
const result = await protocol.getMetaTypes({});
269+
return { handled: true, response: this.success(result) };
270+
}
271+
// Fallback: ask broker for registered types
272+
try {
273+
const data = await broker.call('metadata.types', {}, { request: context.request });
274+
return { handled: true, response: this.success(data) };
275+
} catch {
276+
return { handled: true, response: this.success({ types: ['object', 'app', 'plugin'] }) };
277+
}
267278
}
268279

269280
return { handled: false };

0 commit comments

Comments
 (0)