import { ITransport } from '../transport' ; import { QueryOne , OneItem , PartialItem } from '../items' ; import { ISingleton } from '../singleton' ; export class SingletonHandler < T > implements ISingleton < T > { protected collection : string ; protected transport : ITransport ; protected endpoint : string ; constructor ( collection , transport ) { this . collection = collection ; this . transport = transport ; this . endpoint = collection . startsWith ( 'directus_' ) ? `/${ collection . substring ( 9 ) }` : `/items/${ collection }` ; } async read ( query ? ) { const item = await this . transport . get < T > ( `${ this . endpoint }` , { params : query , } ) ; return item . data ; } async update ( data , _query ? ) { const item = await this . transport . patch < T > ( `${ this . endpoint }` , data , { params : _query , } ) ; return item . data ; } }