@@ -50,42 +50,7 @@ export class ObjectQL implements IDataEngine {
5050 async use ( manifestPart : any , runtimePart ?: any ) {
5151 // 1. Validate / Register Manifest
5252 if ( manifestPart ) {
53- // 1. Handle Module Imports (commonjs/esm interop)
54- // If the passed object is a module namespace with a default export, use that.
55- const manifest = manifestPart . default || manifestPart ;
56-
57- // In a real scenario, we might strictly parse this using Zod
58- // For now, simple ID check
59- const id = manifest . id || manifest . name ;
60- if ( ! id ) {
61- console . warn ( `[ObjectQL] Plugin manifest missing ID (keys: ${ Object . keys ( manifest ) } )` , manifest ) ;
62- // Don't return, try to proceed if it looks like an App (Apps might use 'name' instead of 'id')
63- // return;
64- }
65-
66- console . log ( `[ObjectQL] Loading Plugin: ${ id } ` ) ;
67- SchemaRegistry . registerPlugin ( manifest as ObjectStackManifest ) ;
68-
69- // Register Objects from App/Plugin
70- if ( manifest . objects ) {
71- for ( const obj of manifest . objects ) {
72- // Ensure object name is registered globally
73- SchemaRegistry . registerObject ( obj ) ;
74- console . log ( `[ObjectQL] Registered Object: ${ obj . name } ` ) ;
75- }
76- }
77-
78- // Register contributions
79- if ( manifest . contributes ?. kinds ) {
80- for ( const kind of manifest . contributes . kinds ) {
81- SchemaRegistry . registerKind ( kind ) ;
82- }
83- }
84-
85- // Register Data Seeding (Lazy execution or immediate?)
86- // We store it in a temporary registry or execute immediately if engine is ready.
87- // Since `use` is init time, we might need to store it and run later in `seed()`.
88- // For this MVP, let's attach it to the manifest object in registry so Kernel can find it.
53+ this . registerApp ( manifestPart ) ;
8954 }
9055
9156 // 2. Execute Runtime
@@ -128,6 +93,44 @@ export class ObjectQL implements IDataEngine {
12893 }
12994 }
13095
96+ registerApp ( manifestPart : any ) {
97+ // 1. Handle Module Imports (commonjs/esm interop)
98+ // If the passed object is a module namespace with a default export, use that.
99+ const raw = manifestPart . default || manifestPart ;
100+
101+ // Support nested manifest property (Stack Definition)
102+ // We merge the inner manifest metadata (id, version, etc) with the outer container (objects, apps)
103+ const manifest = raw . manifest ? { ...raw , ...raw . manifest } : raw ;
104+
105+ // In a real scenario, we might strictly parse this using Zod
106+ // For now, simple ID check
107+ const id = manifest . id || manifest . name ;
108+ if ( ! id ) {
109+ console . warn ( `[ObjectQL] Plugin manifest missing ID (keys: ${ Object . keys ( manifest ) } )` , manifest ) ;
110+ // Don't return, try to proceed if it looks like an App (Apps might use 'name' instead of 'id')
111+ // return;
112+ }
113+
114+ console . log ( `[ObjectQL] Loading App: ${ id } ` ) ;
115+ SchemaRegistry . registerPlugin ( manifest as ObjectStackManifest ) ;
116+
117+ // Register Objects from App/Plugin
118+ if ( manifest . objects ) {
119+ for ( const obj of manifest . objects ) {
120+ // Ensure object name is registered globally
121+ SchemaRegistry . registerObject ( obj ) ;
122+ console . log ( `[ObjectQL] Registered Object: ${ obj . name } ` ) ;
123+ }
124+ }
125+
126+ // Register contributions
127+ if ( manifest . contributes ?. kinds ) {
128+ for ( const kind of manifest . contributes . kinds ) {
129+ SchemaRegistry . registerKind ( kind ) ;
130+ }
131+ }
132+ }
133+
131134 /**
132135 * Register a new storage driver
133136 */
0 commit comments