| 4 | import { TraceabilityOrigin, Track } from '@/utils/sigmfMetadata'; |
| 5 | |
| 6 | export class LocalClient implements DataSourceClient { |
| 7 | files: FileWithDirectoryAndFileHandle[]; |
| 8 | |
| 9 | constructor(files: FileWithDirectoryAndFileHandle[]) { |
| 10 | this.files = files; |
| 11 | } |
| 12 | sync(account: string, container: string): Promise<void> { |
| 13 | throw new Error('sync not supported for local data sources'); |
| 14 | } |
| 15 | query(querystring: string, signal: AbortSignal): Promise<TraceabilityOrigin[]> { |
| 16 | throw new Error('query not supported for blob data sources'); |
| 17 | } |
| 18 | getSasToken(account: string, container: string, filepath: string): Promise<String> { |
| 19 | throw new Error('get sas token not supported for local data sources'); |
| 20 | } |
| 21 | |
| 22 | list(): Promise<DataSource[]> { |
| 23 | const localDirectory: FileWithDirectoryAndFileHandle[] = this.files; |
| 24 | if (!localDirectory) { |
| 25 | return Promise.reject('No local directory found'); |
| 26 | } |
| 27 | let directory = localDirectory[0]; |
| 28 | return Promise.resolve([ |
| 29 | { |
| 30 | name: directory.name, |
| 31 | account: 'local', |
| 32 | container: directory.webkitRelativePath.split('/')[0], |
| 33 | description: directory.name, |
| 34 | } as DataSource, |
| 35 | ]); |
| 36 | } |
| 37 | |
| 38 | get(account: string, container: string): Promise<DataSource> { |
| 39 | const localDirectory: FileWithDirectoryAndFileHandle[] = this.files; |
| 40 | if (!localDirectory) { |
| 41 | return Promise.reject('No local directory found'); |
| 42 | } |
| 43 | return Promise.resolve({ |
| 44 | name: container, |
| 45 | account: account, |
| 46 | container: container, |
| 47 | description: container, |
| 48 | } as DataSource); |
| 49 | } |
| 50 | |
| 51 | create(dataSource: DataSource): Promise<DataSource> { |
| 52 | return Promise.reject('Not implemented'); |
| 53 | } |
| 54 | |
| 55 | update(dataSource: DataSource): Promise<DataSource> { |
| 56 | return Promise.reject('Not implemented'); |
| 57 | } |
| 58 | |
| 59 | features() { |
| 60 | return { |
| 61 | updateMeta: false, |
| 62 | sync: false, |
| 63 | query: false, |
nothing calls this directly
no outgoing calls
no test coverage detected