import type {
	MetadataSearchQuery,
	MetadataSearchResult,
	MovieInfo,
	ResolvedMovieMetadataResult,
	ResolvedTitleCreditsResult,
} from "@/models";
import type { IProviderLifecycle } from "./lifecycle";

/**
 * Movie search query interface
 * Extends base metadata search query for movie-specific searches
 */
export type MovieSearchQuery = MetadataSearchQuery;

/**
 * Movie search result interface
 * Uses base metadata search result structure
 */
export type MovieSearchResult = MetadataSearchResult;

/**
 * Base interface for movie metadata providers
 * Providers implementing this interface can supply movie metadata and optionally credits
 * Extends IProviderLifecycle for mount/dispose capabilities
 */
export interface BaseMovieProvider extends IProviderLifecycle {
	/**
	 * Search for movies by title and optional year
	 * @param query - Search query containing title and optional year
	 * @returns Promise resolving to search results with movie matches
	 */
	search(query: MovieSearchQuery): Promise<MovieSearchResult>;

	/**
	 * Resolve detailed movie metadata from file information
	 * @param info - Movie information extracted from file
	 * @returns Promise resolving to complete movie metadata or null if not found
	 */
	resolve(info: MovieInfo): Promise<ResolvedMovieMetadataResult>;

	/**
	 * Resolve credits (cast & crew) for a movie
	 * Optional method - not all providers may support credits
	 * @param info - Object containing movieId to fetch credits for
	 * @returns Promise resolving to credits data or null if not found
	 */
	resolveCredits?(info: {
		movieId: string | number;
	}): Promise<ResolvedTitleCreditsResult>;
}
