/**
 * Copyright IBM Corp. 2024, 2025
 */

import { APICFileInfo } from '../../apic-mode/models/apic-file-info.model.js';
import { APICProject } from '../../apic-mode/models/apic-project.model.js';
import { Project } from '../../lfs/models/project.model.js';
import { VCSProject } from '../../vcs/models/vcs-project.model.js';
import { ActionType } from '../models/action-type.model.js';
import { FileEntry } from '../models/file-entry.model.js';
import { FileExplorerNode } from '../models/file-explorer.model.js';

export interface IFileEntryManager {
  /**
   * Given a project it generates unique fileName based on files in the project folder
   * for both local and VCS projects
   * @param project Local or VCSProject object
   * @param fileName Base name for generating a unique file name
   * @returns a unique file name in the given project folder
   */
  generateUniqueFileName(
    project: Project | VCSProject | APICProject,
    fileName: string,
    subFolderPath?: string,
  ): Promise<string>;
  /**
   * @deprecated Use the generateUniqueFileName instead.
   */
  generateCreateFilename(existingNames: string[], baseName: string): string;
  sortFiles(subEntries: FileEntry[]): void;
  getVCSSubEntries(
    repoNameWithOwner: string,
    itemName: string,
  ): Promise<FileExplorerNode[]>;
  getVCSSubEntriesForFolderDelete(
    repoNameWithOwner: string,
    itemPath: string,
    depth?: number,
  ): Promise<FileExplorerNode[]>;
  generateUniqueName(
    baseName: string,
    isDirectory: boolean,
    directory?: FileSystemDirectoryHandle | null,
    entries?: FileEntry[],
    index?: number,
  ): Promise<string>;
  validateAction(
    actionType: ActionType,
    name: string,
    entries: FileEntry[],
  ): string | null;
  getAction(actionType: ActionType): void;
  getSubEntries(
    dirHandle: FileSystemDirectoryHandle,
    idFocus?: string,
  ): Promise<FileEntry[]>;
  getAPICSubEntries(
    orgId: string,
    project: APICProject,
  ): Promise<FileExplorerNode[]>;
  getAPICSubEntriesForFolderDeleteAndUpdate(
    project: APICProject,
    itemPath: string,
    targetPath: string,
  ): Promise<(APICFileInfo & { targetPath: string })[]>;
}
