import SessionFactory from './SessionFactory.ts' import SessionInterface from './SessionInterface.ts' import {Model} from '../../../../orm/src/model/Model.ts' import {StaticClass} from '../../../../di/src/type/StaticClass.ts' import {isInstantiable} from '../../../../di/src/type/Instantiable.ts' export default class ModelSessionFactory extends SessionFactory { constructor( protected readonly ModelClass: StaticClass, ) { super() } produce(dependencies: any[], parameters: any[]): SessionInterface { if ( isInstantiable(this.ModelClass) ) return new this.ModelClass() as SessionInterface else throw new TypeError(`Session model class ${this.ModelClass} is not instantiable.`) } }