@untidy/thetvdb
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -50,2 +50,7 @@ import { Base } from './core.js'; | ||
} | ||
interface Source extends Genre { | ||
postfix: string; | ||
prefix: string; | ||
sort: number; | ||
} | ||
interface Inspiration extends Shared { | ||
@@ -61,2 +66,3 @@ description: string; | ||
type GetGenres = Data<Genre[]>; | ||
type GetGenreById = Data<Genre>; | ||
type GetInspirationTypes = Data<Inspiration[]>; | ||
@@ -67,2 +73,3 @@ type GetLanguages = Data<Language[]>; | ||
type GetArtworkTypes = Data<ArtworkType[]>; | ||
type GetSourceTypes = Data<Source[]>; | ||
export declare class TheTVDBExtended extends Base { | ||
@@ -76,6 +83,8 @@ getArtworkStatuses(): Promise<GetArtworkStatuses>; | ||
getGenres(): Promise<GetGenres>; | ||
getGenreById(id: string): Promise<GetGenreById>; | ||
getInspirationTypes(): Promise<GetInspirationTypes>; | ||
getLanguages(): Promise<GetLanguages>; | ||
getSourceTypes(): Promise<GetSourceTypes>; | ||
getUpdates(options: updateO): Promise<GetUpdates>; | ||
} | ||
export {}; |
@@ -24,2 +24,6 @@ import { Base } from './core.js'; | ||
} | ||
async getGenreById(id) { | ||
this.validateInput(id, 'Required genre id'); | ||
return await this.fetcher(this.api + '/v4/genres/' + id); | ||
} | ||
async getInspirationTypes() { | ||
@@ -31,2 +35,5 @@ return await this.fetcher(this.api + '/v4/inspiration/types'); | ||
} | ||
async getSourceTypes() { | ||
return await this.fetcher(this.api + '/v4/sources/types'); | ||
} | ||
async getUpdates(options) { | ||
@@ -33,0 +40,0 @@ this.validateInput(options?.since, 'Required since option'); |
@@ -45,2 +45,8 @@ import { Base } from './core.js'; | ||
} | ||
interface StatusHelper { | ||
id: number; | ||
keepUpdated: boolean; | ||
name: string; | ||
recordType: string; | ||
} | ||
interface StudiosHelper { | ||
@@ -183,2 +189,16 @@ id: number; | ||
type EpisodeExtended = Omit<EpisodeMeta, 'translations'>; | ||
interface List extends SharedProps { | ||
overview: string; | ||
url: string; | ||
isOfficial: boolean; | ||
aliases: Aliases[]; | ||
score: number; | ||
imageIsFallback: boolean; | ||
remoteIds: null; | ||
tags: null; | ||
} | ||
interface ListExtended extends Omit<List, 'tags'> { | ||
tags: TagOptions[]; | ||
entities: Array<Record<'order' | 'seriesId' | 'movieId', number | null>>; | ||
} | ||
interface Movie extends SharedProps { | ||
@@ -189,8 +209,3 @@ slug: string; | ||
runtime: number; | ||
status: { | ||
id: number; | ||
keepUpdated: boolean; | ||
name: string; | ||
recordType: string; | ||
}; | ||
status: StatusHelper; | ||
lastUpdated: string; | ||
@@ -234,3 +249,6 @@ year: string; | ||
type MovieExtendedMetaShort = Omit<MovieExtendedMeta, 'characters' | 'artworks' | 'trailers'> & MovieShort; | ||
type People = Pick<Character, 'id' | 'name' | 'image' | 'nameTranslations' | 'overviewTranslations' | 'aliases'>; | ||
interface People extends SharedProps { | ||
aliases: Aliases[]; | ||
lastUpdated: string; | ||
} | ||
interface PeopleMeta extends People { | ||
@@ -304,5 +322,21 @@ birth: string | null; | ||
originalLanguage: string; | ||
overview: string; | ||
} | ||
interface SerieLanguage extends Omit<Serie, 'episodes'> { | ||
episodes: Episode[]; | ||
} | ||
interface SerieArtworks extends Serie { | ||
artworks: Artwork[]; | ||
companies: null; | ||
genres: null; | ||
trailers: null; | ||
lists: null; | ||
remoteIds: null; | ||
characters: null; | ||
airsTime: null; | ||
seasons: null; | ||
tags: null; | ||
contentRatings: null; | ||
} | ||
interface SerieExtended extends Serie { | ||
overview: string; | ||
artworks: Artwork[]; | ||
@@ -342,2 +376,6 @@ companies: unknown; | ||
} | ||
interface SerieEpisodesSeasonType { | ||
series: Serie; | ||
episodes: Episode[]; | ||
} | ||
interface Options { | ||
@@ -384,2 +422,16 @@ id: string; | ||
} | ||
interface SerieEpisodesLanguage { | ||
id: string; | ||
type: string; | ||
language: string; | ||
page?: string; | ||
} | ||
interface SerieEpisodes { | ||
id: string; | ||
type: string; | ||
page?: string; | ||
season?: string; | ||
episodeNumber?: string; | ||
airDate?: string; | ||
} | ||
type GetArtwork<O extends ArtworkOptions> = O['extended'] extends true ? Data<ArtworkExtended> : Data<Artwork>; | ||
@@ -398,7 +450,32 @@ type GetAwards = Data<AwardsHelper[]>; | ||
type GetEpisode<O extends Options> = O['extended'] extends true ? O['meta'] extends true ? Data<EpisodeMeta> : Data<EpisodeExtended> : Data<Episode>; | ||
type GetEpisodeByLanguage = Data<TranslationHelper>; | ||
type GetEpisodesByPage = DataLink<Episode[]>; | ||
type GetLists = DataLink<List[]>; | ||
type GetListById = Data<List>; | ||
type GetListByIdExtended = Data<ListExtended>; | ||
type GetListByLanguage = Data<TranslationHelper[]>; | ||
type GetListBySlug = Data<List>; | ||
type GetMovie<O extends MovieOptions> = O['extended'] extends true ? O['meta'] extends true ? O['short'] extends true ? Data<MovieExtendedMetaShort> : Data<MovieExtendedMeta> : O['short'] extends true ? Data<MovieExtendedShort> : Data<MovieExtended> : Data<Movie>; | ||
type GetMoviesByPage = DataLink<Movie[]>; | ||
type GetMovieByLanguage = Data<Pick<TranslationHelper, 'name' | 'overview' | 'language'>>; | ||
type GetMovieBySlug = Data<Movie>; | ||
type GetMovieStatus = DataLink<StatusHelper[]>; | ||
type GetPeople<O extends Options> = O['extended'] extends true ? O['meta'] extends true ? Data<PeopleMeta> : Data<PeopleExtended> : Data<People>; | ||
type GetPeopleByLanguage = Data<Pick<TranslationHelper, 'name' | 'overview' | 'language'>>; | ||
type GetPeopleByPage = DataLink<People[]>; | ||
type GetPeopleTypes = DataLink<AwardsHelper[]>; | ||
type GetSearch = DataLink<Search[]>; | ||
type GetSeason<O extends Options> = O['extended'] extends true ? O['meta'] extends true ? Data<SeasonExtendedMeta> : Data<SeasonExtended> : Data<Season>; | ||
type GetSeasonByLanguage = Data<TranslationHelper>; | ||
type GetSeasonTypes = DataLink<SeasonType[]>; | ||
type GetSeasonsByPage = DataLink<Season[]>; | ||
type GetSerie<O extends SeriesOptions> = O['extended'] extends true ? O['meta'] extends 'translations' ? O['short'] extends true ? Data<SerieExtendedTranslationsShort> : Data<SerieExtendedTranslations> : O['meta'] extends 'episodes' ? O['short'] extends true ? Data<SerieExtendedEpisodesShort> : Data<SerieExtendedEpisodes> : O['short'] extends true ? Data<SerieExtendedShort> : Data<SerieExtended> : Data<Serie>; | ||
type GetSerieEpisodes = DataLink<SerieEpisodesSeasonType>; | ||
type GetSerieEpisodesWithLanguage = DataLink<SerieLanguage>; | ||
type GetSerieArtworks = Data<SerieArtworks>; | ||
type GetSerieNextAired = Data<Serie>; | ||
type GetSeriesByPage = DataLink<Serie[]>; | ||
type GetSerieBySlug = Data<Serie>; | ||
type GetSerieByLanguage = Data<TranslationHelper>; | ||
type GetSerieStatus = DataLink<StatusHelper[]>; | ||
export declare class TheTVDB extends Base { | ||
@@ -418,8 +495,33 @@ getArtwork<O extends ArtworkOptions>(options: O): Promise<GetArtwork<O>>; | ||
getEpisode<O extends Options>(options: O): Promise<GetEpisode<O>>; | ||
getEpisodeByLanguage(id: string, language: string): Promise<GetEpisodeByLanguage>; | ||
getEpisodesByPage(page?: string): Promise<GetEpisodesByPage>; | ||
getLists(page?: string): Promise<GetLists>; | ||
getListById(id: string): Promise<GetListById>; | ||
getListByIdExtended(id: string): Promise<GetListByIdExtended>; | ||
getListByLanguage(id: string, language: string): Promise<GetListByLanguage>; | ||
getListBySlug(slug: string): Promise<GetListBySlug>; | ||
getMovie<O extends MovieOptions>(options: O): Promise<GetMovie<O>>; | ||
getMoviesByPage(page?: string): Promise<GetMoviesByPage>; | ||
getMovieByLanguage(id: string, language: string): Promise<GetMovieByLanguage>; | ||
getMovieBySlug(slug: string): Promise<GetMovieBySlug>; | ||
getMovieStatus(): Promise<GetMovieStatus>; | ||
getPeople<O extends Options>(options: O): Promise<GetPeople<O>>; | ||
getPeopleByLanguage(id: string, language: string): Promise<GetPeopleByLanguage>; | ||
getPeopleByPage(page?: string): Promise<GetPeopleByPage>; | ||
getPeopleTypes(): Promise<GetPeopleTypes>; | ||
getSearch(options: SearchOptions): Promise<GetSearch>; | ||
getSeason<O extends Options>(options: O): Promise<GetSeason<O>>; | ||
getSeasonByLanguage(id: string, language: string): Promise<GetSeasonByLanguage>; | ||
getSeasonTypes(): Promise<GetSeasonTypes>; | ||
getSeasonsByPage(page?: string): Promise<GetSeasonsByPage>; | ||
getSerie<O extends SeriesOptions>(options: O): Promise<GetSerie<O>>; | ||
getSeriesByPage(page?: string): Promise<GetSeriesByPage>; | ||
getSerieArtworks(id: string, language: string, type: string): Promise<GetSerieArtworks>; | ||
getSerieBySlug(slug: string): Promise<GetSerieBySlug>; | ||
getSerieByLanguage(id: string, language: string): Promise<GetSerieByLanguage>; | ||
getSerieEpisodes(options: SerieEpisodes): Promise<GetSerieEpisodes>; | ||
getSerieEpisodesWithLanguage(options: SerieEpisodesLanguage): Promise<GetSerieEpisodesWithLanguage>; | ||
getSerieNextAired(id: string): Promise<GetSerieNextAired>; | ||
getSerieStatus(): Promise<GetSerieStatus>; | ||
} | ||
export {}; |
163
dist/main.js
@@ -11,29 +11,23 @@ import { Base } from './core.js'; | ||
async getAwards() { | ||
const endpoint = this.api + '/v4/awards'; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(this.api + '/v4/awards'); | ||
} | ||
async getAwardsById(id) { | ||
this.validateInput(id, 'Required id'); | ||
const endpoint = `${this.api}/v4/awards/${id}`; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(`${this.api}/v4/awards/${id}`); | ||
} | ||
async getAwardsByIdExtended(id) { | ||
this.validateInput(id, 'Required id'); | ||
const endpoint = `${this.api}/v4/awards/${id}/extended`; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(`${this.api}/v4/awards/${id}/extended`); | ||
} | ||
async getAwardsCategoriesById(id) { | ||
this.validateInput(id, 'Required id'); | ||
const endpoint = `${this.api}/v4/awards/categories/${id}`; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(`${this.api}/v4/awards/categories/${id}`); | ||
} | ||
async getAwardsCategoriesByIdExtended(id) { | ||
this.validateInput(id, 'Required id'); | ||
const endpoint = `${this.api}/v4/awards/categories/${id}/extended`; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(`${this.api}/v4/awards/categories/${id}/extended`); | ||
} | ||
async getCharacter(id) { | ||
this.validateInput(id, 'Required character id'); | ||
const endpoint = this.api + '/v4/characters/' + id; | ||
return await this.fetcher(endpoint); | ||
return await this.fetcher(this.api + '/v4/characters/' + id); | ||
} | ||
@@ -77,2 +71,38 @@ async getCompanies(page) { | ||
} | ||
async getEpisodeByLanguage(id, language) { | ||
this.validateInput(id, 'Required episode id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(this.api + '/v4/episodes/' + id + '/translations/' + language); | ||
} | ||
async getEpisodesByPage(page) { | ||
let endpoint = this.api + '/v4/episodes'; | ||
if (typeof page === 'string' && page.length > 0 && page.length <= 5) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getLists(page) { | ||
let endpoint = this.api + '/v4/lists'; | ||
if (typeof page === 'string' && page.length > 0 && page.length < 3) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getListById(id) { | ||
this.validateInput(id, 'Required list id'); | ||
return await this.fetcher(this.api + '/v4/lists/' + id); | ||
} | ||
async getListByIdExtended(id) { | ||
this.validateInput(id, 'Required list id'); | ||
return await this.fetcher(this.api + '/v4/lists/' + id + '/extended'); | ||
} | ||
async getListByLanguage(id, language) { | ||
this.validateInput(id, 'Required list id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(`${this.api}/v4/lists/${id}/translations/${language}`); | ||
} | ||
async getListBySlug(slug) { | ||
this.validateInput(slug, 'Required list slug'); | ||
return await this.fetcher(this.api + '/v4/lists/slug/' + slug); | ||
} | ||
async getMovie(options) { | ||
@@ -92,2 +122,21 @@ this.validateInput(options?.id, 'Required movie id'); | ||
} | ||
async getMoviesByPage(page) { | ||
let endpoint = this.api + '/v4/movies'; | ||
if (typeof page === 'string' && page.length > 0 && page.length <= 3) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getMovieByLanguage(id, language) { | ||
this.validateInput(id, 'Required movie id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(this.api + '/v4/movies/' + id + '/translations/' + language); | ||
} | ||
async getMovieBySlug(slug) { | ||
this.validateInput(slug, 'Required slug'); | ||
return await this.fetcher(this.api + '/v4/movies/slug/' + slug); | ||
} | ||
async getMovieStatus() { | ||
return await this.fetcher(this.api + '/v4/movies/statuses'); | ||
} | ||
async getPeople(options) { | ||
@@ -102,2 +151,17 @@ this.validateInput(options?.id, 'Required people id'); | ||
} | ||
async getPeopleByLanguage(id, language) { | ||
this.validateInput(id, 'Required people id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(this.api + '/v4/people/' + id + '/translations/' + language); | ||
} | ||
async getPeopleByPage(page) { | ||
let endpoint = this.api + '/v4/people'; | ||
if (typeof page === 'string' && page.length > 0 && page.length <= 4) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getPeopleTypes() { | ||
return await this.fetcher(this.api + '/v4/people/types'); | ||
} | ||
async getSearch(options) { | ||
@@ -118,2 +182,17 @@ this.validateInput(options?.query, 'Required search query'); | ||
} | ||
async getSeasonByLanguage(id, language) { | ||
this.validateInput(id, 'Required season id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(this.api + '/v4/seasons/' + id + '/translations/' + language); | ||
} | ||
async getSeasonTypes() { | ||
return await this.fetcher(this.api + '/v4/seasons/types'); | ||
} | ||
async getSeasonsByPage(page) { | ||
let endpoint = this.api + '/v4/seasons'; | ||
if (typeof page === 'string' && page.length > 0 && page.length <= 4) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getSerie(options) { | ||
@@ -133,2 +212,62 @@ this.validateInput(options?.id, 'Required series id'); | ||
} | ||
async getSeriesByPage(page) { | ||
let endpoint = this.api + '/v4/series'; | ||
if (typeof page === 'string' && page.length > 0 && page.length <= 3) { | ||
endpoint += `?page=${page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getSerieArtworks(id, language, type) { | ||
this.validateInput(id, 'Required id serie'); | ||
this.validateInput(language, 'Required language'); | ||
this.validateInput(type, 'Required type of artwork'); | ||
const endpoint = this.createURL(`/v4/series/${id}/artworks`); | ||
endpoint.searchParams.set('lang', language); | ||
endpoint.searchParams.set('type', type); | ||
return await this.fetcher(endpoint.href); | ||
} | ||
async getSerieBySlug(slug) { | ||
this.validateInput(slug, 'Required slug'); | ||
return await this.fetcher(this.api + '/v4/series/slug/' + slug); | ||
} | ||
async getSerieByLanguage(id, language) { | ||
this.validateInput(id, 'Required serie id'); | ||
this.validateInput(language, 'Required language'); | ||
return await this.fetcher(this.api + '/v4/series/' + id + '/translations/' + language); | ||
} | ||
async getSerieEpisodes(options) { | ||
this.validateInput(options?.id, 'Required serie id'); | ||
this.validateInput(options?.type, 'Required season type'); | ||
const endpoint = this.createURL(`/v4/series/${options.id}/episodes/${options.type}`); | ||
if (typeof options.page === 'string' && options.page.length > 0 && options.page.length <= 3) { | ||
endpoint.searchParams.set('page', options.page); | ||
} | ||
if (typeof options.season === 'string' && options.season.length > 0) { | ||
endpoint.searchParams.set('season', options.season); | ||
} | ||
if (typeof options.episodeNumber === 'string' && options.episodeNumber.length > 0) { | ||
endpoint.searchParams.set('episodeNumber', options.episodeNumber); | ||
} | ||
if (typeof options.airDate === 'string' && options.airDate.length > 0) { | ||
endpoint.searchParams.set('airDate', options.airDate); | ||
} | ||
return await this.fetcher(endpoint.href); | ||
} | ||
async getSerieEpisodesWithLanguage(options) { | ||
this.validateInput(options?.id, 'Required serie id'); | ||
this.validateInput(options?.type, 'Required season type'); | ||
this.validateInput(options?.language, 'Required language'); | ||
let endpoint = this.api + '/v4/series/' + options.id + '/episodes/' + options.type + '/' + options.language; | ||
if (typeof options.page === 'string' && options.page.length > 0 && options.page.length <= 3) { | ||
endpoint += `?page=${options.page}`; | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
async getSerieNextAired(id) { | ||
this.validateInput(id, 'Required serie id'); | ||
return await this.fetcher(this.api + '/v4/series/' + id + '/nextAired'); | ||
} | ||
async getSerieStatus() { | ||
return await this.fetcher(this.api + '/v4/series/statuses'); | ||
} | ||
} |
{ | ||
"name": "@untidy/thetvdb", | ||
"description": "fully-typed client for accessing the TheTVDB API V4 for Node.js", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"type": "module", | ||
@@ -27,22 +27,22 @@ "exports": { | ||
"@changesets/cli": "^2.26.2", | ||
"@swc/core": "^1.3.95", | ||
"@swc/core": "^1.3.96", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.6", | ||
"@types/node": "^20.8.8", | ||
"@typescript-eslint/eslint-plugin": "^6.9.0", | ||
"@typescript-eslint/parser": "^6.9.0", | ||
"@types/jest": "^29.5.8", | ||
"@types/node": "^20.9.0", | ||
"@typescript-eslint/eslint-plugin": "^6.11.0", | ||
"@typescript-eslint/parser": "^6.11.0", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.52.0", | ||
"eslint": "^8.53.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-jest": "^27.4.3", | ||
"eslint-plugin-n": "^16.2.0", | ||
"eslint-plugin-jest": "^27.6.0", | ||
"eslint-plugin-n": "^16.3.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"jest": "^29.7.0", | ||
"msw": "^2.0.0", | ||
"prettier": "^3.0.3", | ||
"tsx": "^3.14.0", | ||
"msw": "^2.0.6", | ||
"prettier": "^3.1.0", | ||
"tsx": "^4.1.1", | ||
"typescript": "^5.2.2", | ||
"vitepress": "1.0.0-rc.24" | ||
"vitepress": "1.0.0-rc.25" | ||
}, | ||
@@ -60,3 +60,3 @@ "engines": { | ||
}, | ||
"packageManager": "pnpm@8.9.2", | ||
"packageManager": "pnpm@8.10.4", | ||
"scripts": { | ||
@@ -63,0 +63,0 @@ "dev": "tsx src/playground.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49676
962