Small Nest.js-based project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

120 lines
2.7 KiB

export type MovieData = {
internalId: number;
imdbId: string;
title: string;
localTitle: string;
description: string;
localDescription: string;
posterUrl: string;
type: 'movie' | 'series' | 'episode';
seriesImdbId?: string;
episodeNumber?: number;
seasonNumber?: number;
/**
* A whole number of minutes
*/
duration: number;
totalSeasons?: number;
/**
* Two-letter code
*/
originalLanguage: string;
/**
* Two-letter codes
*/
availableLanguages: string[];
productionYear: number;
releaseDate: string;
dvdReleaseDate?: string;
genres: string[];
directors?: string[];
writers: string[];
actors: string[];
studios: string[];
awards?: string;
productionCountries: string[];
boxOffice?: string;
contentRating?: string;
website?: string;
ratings: {
source: string;
value: string;
}[];
};
export type NormalizedOmdbData = Omit<
MovieData,
| 'availableLanguages'
| 'internalId'
| 'localDescription'
| 'localTitle'
| 'originalLanguage'
| 'studios'
>;
export type NormalizedInternalData = Omit<
MovieData,
| 'actors'
| 'awards'
| 'boxOffice'
| 'contentRating'
| 'description'
| 'directors'
| 'dvdReleaseDate'
| 'episodeNumber'
| 'genres'
| 'posterUrl'
| 'productionCountries'
| 'releaseDate'
| 'seasonNumber'
| 'seriesImdbId'
| 'title'
| 'totalSeasons'
| 'type'
| 'website'
| 'writers'
>;
type SearchFilterValue<TDataValue> = TDataValue extends (infer U)[]
? U
: TDataValue;
type GenericSearchFilters<TKeys extends keyof MovieData> = Partial<{
[TKey in keyof MovieData as TKey extends TKeys ? TKey : never]:
| SearchFilterValue<Exclude<MovieData[TKey], undefined>>
| undefined;
}>;
export type SearchFilters = GenericSearchFilters<
| 'actors'
| 'availableLanguages'
| 'directors'
| 'localTitle'
| 'originalLanguage'
| 'productionCountries'
| 'productionYear'
| 'studios'
| 'title'
| 'type'
| 'writers'
>;
export type InternalProvider = {
getMetadataByInternalId(
internalId: number,
): Promise<NormalizedInternalData | undefined>;
getMetadataByImdbId(
imdbId: string,
): Promise<NormalizedInternalData | undefined>;
getAllMetadata(): Promise<NormalizedInternalData[]>;
};
export type OmdbProvider = {
getMetadata(imdbId: string): Promise<NormalizedOmdbData | undefined>;
};
export type EnrichedDataService = {
getMetadataByInternalId(internalId: number): MovieData | undefined;
getMetadataByImdbId(imdbId: string): MovieData | undefined;
getSearchResults(filters: SearchFilters): MovieData[];
};