Skip to content

Commit 281dd58

Browse files
committed
feat: enhance ObjectQL to expose SchemaRegistry for plugin metadata registration
1 parent f02322b commit 281dd58

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

packages/metadata/src/plugin.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,29 @@ export class MetadataPlugin implements Plugin {
5555
if (items.length > 0) {
5656
ctx.logger.info(`Loaded ${items.length} ${type}`);
5757

58-
// Helper: Register with ObjectQL if it is an Object
59-
if (type === 'objects') {
60-
const ql = ctx.getService('objectql');
61-
if (ql && ql.registry && typeof ql.registry.registerObject === 'function') {
62-
items.forEach((obj: any) => {
63-
ql.registry.registerObject(obj.name, obj);
64-
});
65-
}
58+
// Helper: Register with ObjectQL Registry
59+
const ql = ctx.getService('objectql');
60+
if (ql && ql.registry) {
61+
items.forEach((item: any) => {
62+
// Determine key field (id or name)
63+
const keyField = item.id ? 'id' : 'name';
64+
65+
// Map plural type to singular/registry type if needed
66+
// For now, we use the singular form for standard types:
67+
// objects -> object, apps -> app, etc.
68+
// But Registry seems to accept arbitrary strings.
69+
// To match Protocol standard, we might want to normalize.
70+
// Let's use the directory name (plural) as the type for now,
71+
// OR map 'objects' -> 'object' specifically.
72+
73+
let registryType = type;
74+
if (type === 'objects') registryType = 'object';
75+
if (type === 'apps') registryType = 'app';
76+
if (type === 'plugins') registryType = 'plugin';
77+
if (type === 'functions') registryType = 'function';
78+
79+
ql.registry.registerItem(registryType, item, keyField);
80+
});
6681
}
6782
}
6883
} catch (e: any) {

packages/objectql/src/engine.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export class ObjectQL implements IDataEngine {
5050
this.logger.info('ObjectQL Engine Instance Created');
5151
}
5252

53+
/**
54+
* Expose the SchemaRegistry for plugins to register metadata
55+
*/
56+
get registry() {
57+
return SchemaRegistry;
58+
}
59+
5360
/**
5461
* Load and Register a Plugin
5562
*/

0 commit comments

Comments
 (0)