@untidy/thetvdb
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -20,3 +20,3 @@ import { Base } from './core.js'; | ||
async getUpdates(options) { | ||
this.validateInput(options.since, 'Required since option'); | ||
this.validateInput(options?.since, 'Required since option'); | ||
const endpoint = this.createURL('/v4/updates'); | ||
@@ -23,0 +23,0 @@ const query = this.createQuery(endpoint, options); |
@@ -209,2 +209,10 @@ import { Base } from './core.js'; | ||
} | ||
interface SeasonExtendedMeta extends Season { | ||
artworks: Artwork[]; | ||
episodes: Episode[]; | ||
trailers: Trailer[]; | ||
tagOptions: TagOptions[]; | ||
translations: Translations; | ||
} | ||
type SeasonExtended = Omit<SeasonExtendedMeta, 'translations'>; | ||
interface Search { | ||
@@ -241,2 +249,12 @@ country: string; | ||
} | ||
interface FilterOptions { | ||
country: string; | ||
lang: string; | ||
company?: string; | ||
contentRating?: string; | ||
genre?: string; | ||
sort?: 'score' | 'firstAired' | 'name'; | ||
status?: '1' | '2' | '3'; | ||
year?: string; | ||
} | ||
type ArtworkOptions = Omit<Options, 'meta'>; | ||
@@ -262,2 +280,3 @@ interface MovieOptions extends Options { | ||
type GetCharacter = Data<Character>; | ||
type GetFilteredMovie = DataLink<Movie[]>; | ||
type GetEpisode<O extends Options> = O['extended'] extends true ? O['meta'] extends true ? Data<EpisodeMeta> : Data<EpisodeExtended> : Data<Episode>; | ||
@@ -267,5 +286,7 @@ 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 GetSearch = DataLink<Search[]>; | ||
type GetSeason<O extends Options> = O['extended'] extends true ? O['meta'] extends true ? Data<SeasonExtendedMeta> : Data<SeasonExtended> : Data<Season>; | ||
export declare class TheTVDB extends Base { | ||
getArtwork<O extends ArtworkOptions>(options: O): Promise<GetArtwork<O>>; | ||
getCharacter(id: string): Promise<GetCharacter>; | ||
getFilteredMovie(options: FilterOptions): Promise<GetFilteredMovie>; | ||
getEpisode<O extends Options>(options: O): Promise<GetEpisode<O>>; | ||
@@ -275,3 +296,4 @@ getMovie<O extends MovieOptions>(options: O): Promise<GetMovie<O>>; | ||
getSearch(options: SearchOptions): Promise<GetSearch>; | ||
getSeason<O extends Options>(options: O): Promise<GetSeason<O>>; | ||
} | ||
export {}; |
import { Base } from './core.js'; | ||
export class TheTVDB extends Base { | ||
async getArtwork(options) { | ||
this.validateInput(options.id, 'Required artwork id'); | ||
this.validateInput(options?.id, 'Required artwork id'); | ||
let endpoint = this.api + '/v4/artwork/' + options.id; | ||
@@ -15,4 +15,12 @@ if (typeof options.extended === 'boolean' && options.extended) | ||
} | ||
async getFilteredMovie(options) { | ||
this.validateInput(options?.country, 'Required country of origin'); | ||
this.validateInput(options?.lang, 'Required language'); | ||
const endpoint = this.createURL('/v4/movies/filter'); | ||
const query = this.createQuery(endpoint, options); | ||
console.log(query); | ||
return await this.fetcher(query); | ||
} | ||
async getEpisode(options) { | ||
this.validateInput(options.id, 'Required episode id'); | ||
this.validateInput(options?.id, 'Required episode id'); | ||
let endpoint = this.api + '/v4/episodes/' + options.id; | ||
@@ -26,3 +34,3 @@ if (typeof options.extended === 'boolean' && options.extended) { | ||
async getMovie(options) { | ||
this.validateInput(options.id, 'Required movie id'); | ||
this.validateInput(options?.id, 'Required movie id'); | ||
const endpoint = this.createURL('/v4/movies/' + options.id); | ||
@@ -41,3 +49,3 @@ if (typeof options.extended === 'boolean' && options.extended) { | ||
async getPeople(options) { | ||
this.validateInput(options.id, 'Required people id'); | ||
this.validateInput(options?.id, 'Required people id'); | ||
let endpoint = this.api + '/v4/people/' + options.id; | ||
@@ -51,3 +59,3 @@ if (typeof options.extended === 'boolean' && options.extended) { | ||
async getSearch(options) { | ||
this.validateInput(options.query, 'Required search query'); | ||
this.validateInput(options?.query, 'Required search query'); | ||
const endpoint = this.createURL('/v4/search'); | ||
@@ -57,2 +65,11 @@ const query = this.createQuery(endpoint, options); | ||
} | ||
async getSeason(options) { | ||
this.validateInput(options?.id, 'Required season id'); | ||
let endpoint = this.api + '/v4/seasons/' + options.id; | ||
if (typeof options.extended === 'boolean' && options.extended) { | ||
endpoint += '/extended'; | ||
(options.meta ?? false) && (endpoint += '?meta=translations'); | ||
} | ||
return await this.fetcher(endpoint); | ||
} | ||
} |
{ | ||
"name": "@untidy/thetvdb", | ||
"description": "fully-typed client for accessing the TheTVDB API V4 for Node.js", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
@@ -18,10 +19,10 @@ "exports": "./dist/index.js", | ||
"@changesets/cli": "^2.26.1", | ||
"@swc/core": "^1.3.58", | ||
"@swc/core": "^1.3.59", | ||
"@swc/jest": "^0.2.26", | ||
"@types/jest": "^29.5.1", | ||
"@types/node": "^20.1.4", | ||
"@types/node": "^20.2.1", | ||
"@typescript-eslint/eslint-plugin": "^5.59.6", | ||
"@typescript-eslint/parser": "^5.59.6", | ||
"dotenv": "^16.0.3", | ||
"eslint": "^8.40.0", | ||
"eslint": "^8.41.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
@@ -32,3 +33,3 @@ "eslint-config-standard-with-typescript": "^34.0.1", | ||
"eslint-plugin-jest": "^27.2.1", | ||
"eslint-plugin-n": "^15.7.0", | ||
"eslint-plugin-n": "^16.0.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
@@ -35,0 +36,0 @@ "jest": "^29.5.0", |
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
53674
12
514