// Data-import APPLICATION — ports (gateway interfaces). The use-cases depend on THESE interfaces,
// never on axios/apiClient; the infrastructure layer implements them. This inverts the dependency
// at the I/O boundary so the (illustrative, partly not-yet-built) backend is absorbed entirely in
// infrastructure. Source: data-import-spec.md §7.2 (API surface).

import type { DataType, ItemsListTask, SamplePathPreview } from '../domain';

// --- Direct Upload (Phase 1 — converged onto the existing content-addressed dataset upload) ---

export interface DirectUploadResult {
  /** How many files the server accepted. */
  uploadedCount: number;
  /** How many were content-address dedupes (already present). */
  dedupedCount: number;
  /** Logical paths created/replaced on the dataset. */
  paths: string[];
}

export interface DirectUploadGateway {
  upload(input: {
    datasetId: string;
    files: File[];
    /** Coarse 0..100 progress; the converged endpoint reports begin/end until it threads real % . */
    onProgress?: (pct: number) => void;
  }): Promise<DirectUploadResult>;
}

// --- Cloud Import (Phase 4 — implemented once be0 Phases 2-3 land the StorageMethod + endpoints) ---

export interface CloudImportResult {
  createdTaskIds: string[];
  /** Per-entry failures for a partial import (P2 / import-valid-skip-invalid). */
  perEntryErrors: { entry: string; message: string }[];
}

export interface CloudImportGateway {
  importItemsList(input: {
    datasetId: string;
    /** A verified StorageMethod id, or the literal 'public'. */
    storageMethodId: string;
    tasks: ItemsListTask[];
    dataType: DataType;
  }): Promise<CloudImportResult>;
}

export interface SamplePathGateway {
  /** Resolve a bucket-relative sample path (§6 / V2). Rejects with a reason on bad-path/permission/CORS. */
  verify(input: { storageMethodId: string; path: string }): Promise<SamplePathPreview>;
}
