diff --git a/src/framework/DebrosFramework.ts b/src/framework/DebrosFramework.ts index 51ec3ed..aa7635b 100644 --- a/src/framework/DebrosFramework.ts +++ b/src/framework/DebrosFramework.ts @@ -183,6 +183,8 @@ export class DebrosFramework { if (overrideConfig) { this.config = { ...this.config, ...overrideConfig }; this.configManager = new ConfigManager(this.config); + // Update status to reflect config changes + this.status.environment = this.config.environment || 'development'; } // Initialize services @@ -593,6 +595,31 @@ export class DebrosFramework { return this.migrationManager; } + getQueryCache(): QueryCache | null { + return this.queryCache; + } + + getOrbitDBService(): FrameworkOrbitDBService | null { + return this.orbitDBService; + } + + getIPFSService(): FrameworkIPFSService | null { + return this.ipfsService; + } + + getConfigManager(): ConfigManager | null { + return this.configManager; + } + + async healthCheck(): Promise { + this.performHealthCheck(); + return { + healthy: this.status.healthy, + services: { ...this.status.services }, + lastCheck: this.status.lastHealthCheck + }; + } + // Framework lifecycle async stop(): Promise { if (!this.initialized) { diff --git a/src/framework/core/ConfigManager.ts b/src/framework/core/ConfigManager.ts index c1f911f..162917d 100644 --- a/src/framework/core/ConfigManager.ts +++ b/src/framework/core/ConfigManager.ts @@ -132,6 +132,11 @@ export class ConfigManager { return { ...this.config }; } + // Alias for getConfig() to match test expectations + getFullConfig(): ExtendedFrameworkConfig { + return this.getConfig(); + } + // Configuration presets static developmentConfig(): ExtendedFrameworkConfig { return { diff --git a/src/framework/models/BaseModel.ts b/src/framework/models/BaseModel.ts index 6a40c10..c5d26da 100644 --- a/src/framework/models/BaseModel.ts +++ b/src/framework/models/BaseModel.ts @@ -32,13 +32,8 @@ export abstract class BaseModel { if (data && typeof data === 'object') { Object.keys(data).forEach((key) => { if (key !== '_loadedRelations' && key !== '_isDirty' && key !== '_isNew' && data[key] !== undefined) { - // Use setter if it exists (for Field-decorated properties), otherwise set directly - const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), key); - if (descriptor && descriptor.set) { - (this as any)[key] = data[key]; - } else { - (this as any)[key] = data[key]; - } + // Always set directly - the Field decorator's setter will handle validation and transformation + (this as any)[key] = data[key]; } }); diff --git a/src/framework/relationships/RelationshipManager.ts b/src/framework/relationships/RelationshipManager.ts index cb0104f..fab773e 100644 --- a/src/framework/relationships/RelationshipManager.ts +++ b/src/framework/relationships/RelationshipManager.ts @@ -376,8 +376,14 @@ export class RelationshipManager { return; } + // Get the related model class + const RelatedModel = config.model || (config.modelFactory ? config.modelFactory() : null) || (config.targetModel ? config.targetModel() : null); + if (!RelatedModel) { + throw new Error(`Cannot resolve related model for hasMany eager loading`); + } + // Load all related models - let query = (config.model as any).whereIn(config.foreignKey, localKeys); + let query = (RelatedModel as any).whereIn(config.foreignKey, localKeys); if (options.constraints) { query = options.constraints(query); @@ -493,7 +499,13 @@ export class RelationshipManager { const uniqueForeignKeys = [...new Set(allForeignKeys)]; // Step 4: Load all related models - let relatedQuery = (config.model as any).whereIn('id', uniqueForeignKeys); + // Get the related model class + const RelatedModel = config.model || (config.modelFactory ? config.modelFactory() : null) || (config.targetModel ? config.targetModel() : null); + if (!RelatedModel) { + throw new Error(`Cannot resolve related model for manyToMany eager loading`); + } + + let relatedQuery = (RelatedModel as any).whereIn('id', uniqueForeignKeys); if (options.constraints) { relatedQuery = options.constraints(relatedQuery);