@@ -68,18 +68,34 @@ export class DataEngine {
6868 try {
6969 await this . ql . insert ( 'SystemStatus' , { status : 'OK' , uptime : 0 } ) ;
7070
71- // Seed some Todo Tasks if table is empty
72- // Use try-catch because find might throw if object not registered (though it should be)
73- try {
74- const tasks = await this . ql . find ( 'todo_task' , { top : 1 } ) ;
75- if ( tasks . length === 0 ) {
76- console . log ( '[DataEngine] Seeding initial Todo Data...' ) ;
77- await this . ql . insert ( 'todo_task' , { subject : 'Review PR #102' , is_completed : true , priority : 3 , due_date : new Date ( ) } ) ;
78- await this . ql . insert ( 'todo_task' , { subject : 'Write Documentation' , is_completed : false , priority : 2 , due_date : new Date ( Date . now ( ) + 86400000 ) } ) ;
79- await this . ql . insert ( 'todo_task' , { subject : 'Fix specific Server bug' , is_completed : false , priority : 1 } ) ;
80- }
81- } catch ( e ) {
82- console . warn ( '[DataEngine] Failed to seed todo_task' , e ) ;
71+ // Iterate over all registered plugins/apps and check for 'data' property in manifest
72+ const plugins = SchemaRegistry . getRegisteredTypes ( ) ; // This returns types like 'plugin', 'app'
73+
74+ // This is a bit hacky because we don't have a direct "getAllManifests" API exposed easily
75+ // We will iterate known apps for now, or improve Registry API later.
76+ // Actually, SchemaRegistry.listItems('app') returns the manifests!
77+
78+ const apps = [ ...SchemaRegistry . listItems ( 'app' ) , ...SchemaRegistry . listItems ( 'plugin' ) ] ;
79+
80+ for ( const appItem of apps ) {
81+ const app = appItem as any ; // Cast to access data prop safely
82+ if ( app . data && Array . isArray ( app . data ) ) {
83+ console . log ( `[DataEngine] Seeding data for ${ app . name || app . id } ...` ) ;
84+ for ( const seed of app . data ) {
85+ try {
86+ // Check if data exists
87+ const existing = await this . ql . find ( seed . object , { top : 1 } ) ;
88+ if ( existing . length === 0 ) {
89+ console . log ( `[DataEngine] Inserting ${ seed . records . length } records into ${ seed . object } ` ) ;
90+ for ( const record of seed . records ) {
91+ await this . ql . insert ( seed . object , record ) ;
92+ }
93+ }
94+ } catch ( e ) {
95+ console . warn ( `[DataEngine] Failed to seed ${ seed . object } ` , e ) ;
96+ }
97+ }
98+ }
8399 }
84100
85101 } catch ( e ) {
0 commit comments