penguin-beta-version-1.5 #3

Merged
anonpenguin merged 30 commits from sotiris-beta-version-1.5 into main 2025-07-05 02:53:30 +00:00
4 changed files with 48 additions and 9 deletions
Showing only changes of commit 383419beec - Show all commits

View File

@ -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<any> {
this.performHealthCheck();
return {
healthy: this.status.healthy,
services: { ...this.status.services },
lastCheck: this.status.lastHealthCheck
};
}
// Framework lifecycle
async stop(): Promise<void> {
if (!this.initialized) {

View File

@ -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 {

View File

@ -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];
}
});

View File

@ -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);