import { ICrudable , IModel } from './crudable' ; import { IJwt , IMicroflowStorage } from './types' ; interface EntityConstructor < T extends IModel , U > { new ( model , store , storage , jwt , timeout ) : U ; } export class MicroflowCore < T extends IModel , U > { constructor ( private ctor , private store , private storage ? , private jwt ? , private timeout ? ) { } async create ( data ) { const model = await this . store . create ( data ) ; return new this . ctor ( model , this . store , this . storage , this . jwt , this . timeout ) ; } async read ( id ) { const model = await this . store . read ( id ) ; return new this . ctor ( model , this . store , this . storage , this . jwt , this . timeout ) ; } async update ( id , data ) { const model = await this . store . update ( id , data ) ; return new this . ctor ( model , this . store , this . storage , this . jwt , this . timeout ) ; } async delete ( id ) { return this . store . delete ( id ) ; } }