Skip to content

Commit 4efa9c1

Browse files
committed
feat: enhance app registration and retrieval in SchemaRegistry and HttpDispatcher
1 parent afc4f87 commit 4efa9c1

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

packages/objectql/src/engine.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,15 @@ export class ObjectQL implements IDataEngine {
142142
* Register contribution (Manifest)
143143
*/
144144
registerApp(manifest: any) {
145-
const id = manifest.id;
145+
const id = manifest.id || manifest.name;
146146
this.logger.debug('Registering app manifest', { id });
147147

148+
// Register the App Definition itself
149+
if (manifest.name) {
150+
SchemaRegistry.registerApp(manifest);
151+
this.logger.debug('Registered App Definition', { app: manifest.name });
152+
}
153+
148154
// Register objects
149155
if (manifest.objects) {
150156
if (Array.isArray(manifest.objects)) {

packages/objectql/src/registry.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ export class SchemaRegistry {
110110
return this.listItems<ServiceObject>('object');
111111
}
112112

113+
/**
114+
* App Helpers
115+
*/
116+
static registerApp(app: any) {
117+
this.registerItem('app', app, 'name');
118+
}
119+
120+
static getApp(name: string): any {
121+
return this.getItem('app', name);
122+
}
123+
124+
static getAllApps(): any[] {
125+
return this.listItems('app');
126+
}
127+
113128
/**
114129
* Plugin Helpers
115130
*/

packages/runtime/src/http-dispatcher.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ export class HttpDispatcher {
191191
if (parts.length === 1) {
192192
const typeOrName = parts[0];
193193

194+
// Special handling for common pluralized types mapping to protocol
195+
if (['apps', 'plugins'].includes(typeOrName)) {
196+
const singularType = typeOrName.slice(0, -1);
197+
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService('protocol') : null;
198+
if (protocol && typeof protocol.getMetaItems === 'function') {
199+
const data = await protocol.getMetaItems({ type: singularType });
200+
return { handled: true, response: this.success(data) };
201+
}
202+
}
203+
194204
// Heuristic: if it maps to a known type, list it. Else treat as object name.
195205
if (['objects', 'apps', 'plugins'].includes(typeOrName)) {
196206
if (typeOrName === 'objects') {

0 commit comments

Comments
 (0)