feat(search): add basic search functionality

this commit adds basic search feature.

fix: https://codeberg.org/zyachel/libremdb/issues/9, https://github.com/zyachel/libremdb/issues/10
This commit is contained in:
zyachel
2022-12-31 22:21:36 +05:30
parent 81eaf2fd5e
commit 0cff34a766
25 changed files with 1191 additions and 60 deletions

View File

@ -0,0 +1,83 @@
import { ResultMetaTitleTypes, ResultMetaTypes } from '../shared/search';
export default interface RawFind {
props: {
pageProps: {
findPageMeta: {
searchTerm: string;
includeAdult: false;
isExactMatch: boolean;
searchType?: ResultMetaTypes;
titleSearchType?: ResultMetaTitleTypes[];
};
nameResults: {
results: Array<{
id: string;
displayNameText: string;
knownForJobCategory: string | 0;
knownForTitleText: string | 0;
knownForTitleYear: string | 0;
avatarImageModel?: {
url: string;
// maxHeight: number;
// maxWidth: number;
caption: string;
};
akaName?: string;
}>;
// nextCursor?: string;
// hasExactMatches?: boolean;
};
titleResults: {
results: Array<{
id: string;
titleNameText: string;
titleReleaseText?: string;
titleTypeText: string;
titlePosterImageModel?: {
url: string;
// maxHeight: number;
// maxWidth: number;
caption: string;
};
topCredits: Array<string>;
imageType: string;
seriesId?: string;
seriesNameText?: string;
seriesReleaseText?: string;
seriesTypeText?: string;
seriesSeasonText?: string;
seriesEpisodeText?: string;
}>;
// nextCursor?: string;
// hasExactMatches?: boolean;
};
companyResults: {
results: Array<{
id: string;
companyName: string;
countryText: string;
typeText: string | 0;
}>;
// nextCursor?: string;
// hasExactMatches?: boolean;
};
keywordResults: {
results: Array<{
id: string;
keywordText: string;
numTitles: number;
}>;
// nextCursor?: string;
// hasExactMatches?: boolean;
};
resultsSectionOrder: Array<string>;
};
};
}
// const x: RawFind<'tt'> = {
// props: {pageProps: {findPageMeta: {
// titleSearchType: ['MOVIE']
// }}}
// }

View File

@ -0,0 +1,28 @@
import cleanFind from '../../utils/cleaners/find';
import { resultTitleTypes, resultTypes } from '../../utils/constants/find';
type BasicSearch = ReturnType<typeof cleanFind>;
export type { BasicSearch as default };
export type Titles = BasicSearch['titles'];
export type People = BasicSearch['people'];
export type Companies = BasicSearch['companies'];
export type Keywords = BasicSearch['keywords'];
// q=babylon&s=tt&ttype=ft&exact=true
export type FindQueryParams = {
q: string;
exact?: 'true';
s?: QueryTypes;
ttype?: QueryTitleTypes;
};
export type ResultMetaTypes = typeof resultTypes.types[number]['id'] | null;
export type ResultMetaTitleTypes =
| typeof resultTitleTypes.types[number]['id']
| null;
export type QueryTypes = typeof resultTypes.types[number]['val'];
export type QueryTitleTypes = typeof resultTitleTypes.types[number]['val'];