import axios , { AxiosInstance } from 'axios' ; import { StorageItem , StorageItemMetaData } from '@/storage/storage-item' ; export class StorageRest { private readonly http : AxiosInstance ; constructor ( private readonly storageServiceUrl ) { this . http = axios . create ( { baseURL : storageServiceUrl , headers : { 'Content-Type' : 'application/json' } , } ) ; } async getStoredItems ( pipelineId ) { const response = await this . http . get ( `/${ pipelineId }?select=id,timestamp,pipelineId` ) ; return response . data as StorageItemMetaData [ ] ; } async getStoredItem ( pipelineId , storageItemId ) { const response = await this . http . get ( `/${ pipelineId }?id=eq.${ storageItemId }` ) ; return ( response . data as StorageItem [ ] ) [ 0 ] ; } createUrlForItem ( pipelineId , itemId ) { return `${ this . storageServiceUrl }/${ pipelineId }?id=eq.${ itemId }` ; } createUrlForLatestItem ( pipelineId ) { return `${ this . storageServiceUrl }/${ pipelineId }?order=id.desc&limit=1` ; } }