@@ -110,18 +110,24 @@ export class ObjectQL implements IObjectQL {
110110 return items . map ( unwrapContent ) ;
111111 } ,
112112 unregister : ( type : string , name : string ) => {
113- // Access private static storage using any cast
114- const metadata = ( SchemaRegistry as any ) . metadata ;
115- if ( metadata instanceof Map ) {
116- const collection = metadata . get ( type ) ;
117- if ( collection instanceof Map ) {
118- collection . delete ( name ) ;
113+ // Use the official unregisterItem API when available (added in @objectstack/objectql v0.9.2)
114+ // Fallback to direct metadata access for older versions or test mocks
115+ if ( typeof SchemaRegistry . unregisterItem === 'function' ) {
116+ SchemaRegistry . unregisterItem ( type , name ) ;
117+ } else {
118+ // Fallback: try to access metadata Map directly
119+ const metadata = ( SchemaRegistry as any ) . metadata ;
120+ if ( metadata && metadata instanceof Map ) {
121+ const collection = metadata . get ( type ) ;
122+ if ( collection && collection instanceof Map ) {
123+ collection . delete ( name ) ;
124+ }
119125 }
120126 }
121127 } ,
122128 unregisterPackage : ( packageName : string ) => {
123129 const metadata = ( SchemaRegistry as any ) . metadata ;
124- if ( metadata instanceof Map ) {
130+ if ( metadata && metadata instanceof Map ) {
125131 for ( const [ type , collection ] of metadata . entries ( ) ) {
126132 if ( collection instanceof Map ) {
127133 for ( const [ key , item ] of collection . entries ( ) ) {
@@ -395,6 +401,21 @@ export class ObjectQL implements IObjectQL {
395401 await ( this . kernel as any ) . bootstrap ( ) ;
396402 } else {
397403 console . warn ( 'ObjectKernel does not have start() or bootstrap() method' ) ;
404+
405+ // Manually initialize plugins if kernel doesn't support lifecycle
406+ for ( const plugin of this . kernelPlugins ) {
407+ try {
408+ if ( typeof ( plugin as any ) . init === 'function' ) {
409+ await ( plugin as any ) . init ( ) ;
410+ }
411+ if ( typeof ( plugin as any ) . start === 'function' ) {
412+ await ( plugin as any ) . start ( ) ;
413+ }
414+ } catch ( error ) {
415+ console . error ( `Failed to initialize plugin ${ ( plugin as any ) . name || 'unknown' } :` , error ) ;
416+ // Continue with other plugins even if one fails
417+ }
418+ }
398419 }
399420
400421 // TEMPORARY: Set driver for backward compatibility during migration
0 commit comments