import type { IStorageDataProvider } from '@design.estate/dees-catalog';
import { apiService } from '../services/index.js';

/**
 * Adapter that implements IStorageDataProvider by delegating to tsview's ApiService
 */
export class TsviewS3DataProvider implements IStorageDataProvider {
  async listObjects(bucket: string, prefix?: string, delimiter?: string) {
    return apiService.listObjects(bucket, prefix, delimiter);
  }

  async getObject(bucket: string, key: string) {
    return apiService.getObject(bucket, key);
  }

  async putObject(bucket: string, key: string, base64Content: string, contentType: string) {
    return apiService.putObject(bucket, key, base64Content, contentType);
  }

  async deleteObject(bucket: string, key: string) {
    return apiService.deleteObject(bucket, key);
  }

  async deletePrefix(bucket: string, prefix: string) {
    return apiService.deletePrefix(bucket, prefix);
  }

  async getObjectUrl(bucket: string, key: string) {
    return apiService.getObjectUrl(bucket, key);
  }

  async moveObject(bucket: string, sourceKey: string, destKey: string) {
    return apiService.moveObject(bucket, sourceKey, destKey);
  }

  async movePrefix(bucket: string, sourcePrefix: string, destPrefix: string) {
    return apiService.movePrefix(bucket, sourcePrefix, destPrefix);
  }
}

export const s3DataProvider = new TsviewS3DataProvider();
