Files
anyame-frontend-vue/app/openapi/search.ts
2025-07-19 23:03:04 +05:00

137 lines
3.1 KiB
TypeScript

/**
* Generated by orval v7.10.0 🍺
* Do not edit manually.
* OpenAPI definition
* OpenAPI spec version: v0
*/
export interface KodikResponse {
total?: number;
results?: Result[];
}
export interface MaterialData {
title?: string;
year?: number;
description?: string;
screenshots?: string[];
duration?: number;
countries?: string[];
genres?: string[];
actors?: string[];
directors?: string[];
producers?: string[];
writers?: string[];
composers?: string[];
editors?: string[];
designers?: string[];
operators?: string[];
anime_title?: string;
title_en?: string;
other_titles?: string[];
other_titles_en?: string[];
other_titles_jp?: string[];
anime_license_name?: string;
anime_licensed_by?: string[];
anime_kind?: string;
all_status?: string;
anime_status?: string;
anime_description?: string;
poster_url?: string;
anime_poster_url?: string;
all_genres?: string[];
anime_genres?: string[];
anime_studios?: string[];
kinopoisk_rating?: number;
kinopoisk_votes?: number;
imdb_rating?: number;
imdb_votes?: number;
shikimori_rating?: number;
shikimori_votes?: number;
premiere_world?: string;
aired_at?: string;
released_at?: string;
rating_mpaa?: string;
minimal_age?: number;
episodes_total?: number;
episodes_aired?: number;
}
export interface Result {
id?: string;
type?: string;
link?: string;
title?: string;
translation?: Translation;
year?: number;
quality?: string;
camrip?: boolean;
lgbt?: boolean;
screenshots?: string[];
title_orig?: string;
other_title?: string;
last_season?: number;
last_episode?: number;
episodes_count?: number;
kinopoisk_id?: string;
imdb_id?: string;
worldart_link?: string;
shikimori_id?: string;
blocked_countries?: string[];
created_at?: string;
updated_at?: string;
material_data?: MaterialData;
}
export interface Translation {
id?: number;
title?: string;
type?: string;
}
export type SearchParams = {
title: string;
};
export type searchResponse200 = {
data: KodikResponse
status: 200
}
export type searchResponseComposite = searchResponse200;
export type searchResponse = searchResponseComposite & {
headers: Headers;
}
export const getSearchUrl = (params: SearchParams,) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? 'null' : value.toString())
}
});
const stringifiedParams = normalizedParams.toString();
return stringifiedParams.length > 0 ? `http://localhost:8080/search?${stringifiedParams}` : `http://localhost:8080/search`
}
export const search = async (params: SearchParams, options?: RequestInit): Promise<searchResponse> => {
const res = await fetch(getSearchUrl(params),
{
...options,
method: 'GET'
}
)
const body = [204, 205, 304].includes(res.status) ? null : await res.text()
const data: searchResponse['data'] = body ? JSON.parse(body) : {}
return { data, status: res.status, headers: res.headers } as searchResponse
}