tmdb-kit 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,452 @@
1
+ /** Primitive JSON values returned by TMDB. */
2
+ export type JsonPrimitive = string | number | boolean | null;
3
+ /** JSON object/array tree returned by TMDB for fields this SDK does not model yet. */
4
+ export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
5
+ export interface JsonObject {
6
+ [key: string]: JsonValue | undefined;
7
+ }
8
+ /** Escape hatch for append_to_response payloads and future TMDB fields. */
9
+ export type TMDBObject = Record<string, unknown>;
10
+ /** Date string in TMDB format (typically `YYYY-MM-DD`). */
11
+ export type TMDBDateString = string;
12
+ /** ISO 639-1 language code (e.g. `"en"`, `"zh"`). */
13
+ export type LanguageCode = string;
14
+ /** ISO 3166-1 country/region code (e.g. `"US"`, `"CN"`). */
15
+ export type RegionCode = string;
16
+ /** Supported media types for multi-search results. */
17
+ export type MediaType = 'movie' | 'tv' | 'person';
18
+ /** Time window for trending endpoints: `"day"` or `"week"`. */
19
+ export type TrendingTimeWindow = 'day' | 'week';
20
+ export interface PagedResponse<T> {
21
+ page: number;
22
+ results: T[];
23
+ total_pages: number;
24
+ total_results: number;
25
+ }
26
+ export interface Genre {
27
+ id: number;
28
+ name: string;
29
+ }
30
+ export interface ProductionCompany {
31
+ id: number;
32
+ logo_path: string | null;
33
+ name: string;
34
+ origin_country: string;
35
+ }
36
+ export interface ProductionCountry {
37
+ iso_3166_1: string;
38
+ name: string;
39
+ }
40
+ export interface SpokenLanguage {
41
+ english_name: string;
42
+ iso_639_1: string;
43
+ name: string;
44
+ }
45
+ export interface CollectionSummary {
46
+ id: number;
47
+ name: string;
48
+ poster_path: string | null;
49
+ backdrop_path: string | null;
50
+ }
51
+ export interface MovieSummary {
52
+ adult: boolean;
53
+ backdrop_path: string | null;
54
+ genre_ids: number[];
55
+ id: number;
56
+ original_language: string;
57
+ original_title: string;
58
+ overview: string;
59
+ popularity: number;
60
+ poster_path: string | null;
61
+ release_date: TMDBDateString;
62
+ title: string;
63
+ video: boolean;
64
+ vote_average: number;
65
+ vote_count: number;
66
+ }
67
+ export interface MovieDetails extends Omit<MovieSummary, 'genre_ids'> {
68
+ belongs_to_collection: CollectionSummary | null;
69
+ budget: number;
70
+ genres: Genre[];
71
+ homepage: string | null;
72
+ imdb_id: string | null;
73
+ production_companies: ProductionCompany[];
74
+ production_countries: ProductionCountry[];
75
+ revenue: number;
76
+ runtime: number | null;
77
+ spoken_languages: SpokenLanguage[];
78
+ status: string;
79
+ tagline: string | null;
80
+ }
81
+ export interface TVSummary {
82
+ adult?: boolean;
83
+ backdrop_path: string | null;
84
+ first_air_date: TMDBDateString;
85
+ genre_ids: number[];
86
+ id: number;
87
+ name: string;
88
+ origin_country: string[];
89
+ original_language: string;
90
+ original_name: string;
91
+ overview: string;
92
+ popularity: number;
93
+ poster_path: string | null;
94
+ vote_average: number;
95
+ vote_count: number;
96
+ }
97
+ export interface CreatedBy {
98
+ id: number;
99
+ credit_id: string;
100
+ name: string;
101
+ gender: number;
102
+ profile_path: string | null;
103
+ }
104
+ export interface Network {
105
+ id: number;
106
+ logo_path: string | null;
107
+ name: string;
108
+ origin_country: string;
109
+ }
110
+ export interface SeasonSummary {
111
+ air_date: TMDBDateString | null;
112
+ episode_count: number;
113
+ id: number;
114
+ name: string;
115
+ overview: string;
116
+ poster_path: string | null;
117
+ season_number: number;
118
+ vote_average: number;
119
+ }
120
+ export interface EpisodeGuestStar {
121
+ adult: boolean;
122
+ character: string;
123
+ credit_id: string;
124
+ gender: number | null;
125
+ id: number;
126
+ known_for_department: string;
127
+ name: string;
128
+ order: number;
129
+ original_name: string;
130
+ popularity: number;
131
+ profile_path: string | null;
132
+ }
133
+ export interface EpisodeSummary {
134
+ air_date: TMDBDateString | null;
135
+ crew: CreditCrewMember[];
136
+ episode_number: number;
137
+ episode_type: string;
138
+ guest_stars: EpisodeGuestStar[];
139
+ id: number;
140
+ name: string;
141
+ overview: string;
142
+ production_code: string | null;
143
+ runtime: number | null;
144
+ season_number: number;
145
+ show_id: number;
146
+ still_path: string | null;
147
+ vote_average: number;
148
+ vote_count: number;
149
+ }
150
+ export interface TVSeasonDetails {
151
+ _id: string;
152
+ air_date: TMDBDateString | null;
153
+ episodes: EpisodeSummary[];
154
+ id: number;
155
+ name: string;
156
+ overview: string;
157
+ poster_path: string | null;
158
+ season_number: number;
159
+ vote_average: number;
160
+ }
161
+ export type TVSeasonAppendToResponse = 'account_states' | 'aggregate_credits' | 'credits' | 'external_ids' | 'images' | 'translations' | 'videos' | (string & {});
162
+ export interface TVSeasonDetailsOptions extends LanguageOptions {
163
+ appendToResponse?: TVSeasonAppendToResponse | readonly TVSeasonAppendToResponse[];
164
+ }
165
+ export interface TVDetails extends Omit<TVSummary, 'genre_ids'> {
166
+ created_by: CreatedBy[];
167
+ episode_run_time: number[];
168
+ genres: Genre[];
169
+ homepage: string | null;
170
+ in_production: boolean;
171
+ languages: string[];
172
+ last_air_date: TMDBDateString | null;
173
+ networks: Network[];
174
+ number_of_episodes: number;
175
+ number_of_seasons: number;
176
+ production_companies: ProductionCompany[];
177
+ production_countries: ProductionCountry[];
178
+ seasons: SeasonSummary[];
179
+ spoken_languages: SpokenLanguage[];
180
+ status: string;
181
+ tagline: string | null;
182
+ type: string;
183
+ }
184
+ export interface PersonKnownForMovie extends MovieSummary {
185
+ media_type: 'movie';
186
+ }
187
+ export interface PersonKnownForTV extends TVSummary {
188
+ media_type: 'tv';
189
+ }
190
+ export type PersonKnownFor = PersonKnownForMovie | PersonKnownForTV;
191
+ export interface PersonSummary {
192
+ adult: boolean;
193
+ gender: number;
194
+ id: number;
195
+ known_for: PersonKnownFor[];
196
+ known_for_department: string;
197
+ name: string;
198
+ original_name?: string;
199
+ popularity: number;
200
+ profile_path: string | null;
201
+ }
202
+ export interface PersonDetails extends Omit<PersonSummary, 'known_for'> {
203
+ also_known_as: string[];
204
+ biography: string;
205
+ birthday: TMDBDateString | null;
206
+ deathday: TMDBDateString | null;
207
+ homepage: string | null;
208
+ imdb_id: string | null;
209
+ place_of_birth: string | null;
210
+ }
211
+ export interface PersonCombinedCastMovie extends MovieSummary {
212
+ character: string;
213
+ credit_id: string;
214
+ media_type: 'movie';
215
+ order?: number;
216
+ }
217
+ export interface PersonCombinedCastTV extends TVSummary {
218
+ character: string;
219
+ credit_id: string;
220
+ episode_count?: number;
221
+ media_type: 'tv';
222
+ }
223
+ export type PersonCombinedCast = PersonCombinedCastMovie | PersonCombinedCastTV;
224
+ export interface PersonCombinedCrewMovie extends MovieSummary {
225
+ credit_id: string;
226
+ department: string;
227
+ job: string;
228
+ media_type: 'movie';
229
+ }
230
+ export interface PersonCombinedCrewTV extends TVSummary {
231
+ credit_id: string;
232
+ department: string;
233
+ job: string;
234
+ media_type: 'tv';
235
+ }
236
+ export type PersonCombinedCrew = PersonCombinedCrewMovie | PersonCombinedCrewTV;
237
+ export interface PersonCombinedCreditsResponse {
238
+ cast: PersonCombinedCast[];
239
+ crew: PersonCombinedCrew[];
240
+ id: number;
241
+ }
242
+ export interface MovieSearchResult extends MovieSummary {
243
+ media_type?: 'movie';
244
+ }
245
+ export interface TVSearchResult extends TVSummary {
246
+ media_type?: 'tv';
247
+ }
248
+ export interface PersonSearchResult extends PersonSummary {
249
+ media_type?: 'person';
250
+ }
251
+ export type SearchMultiResult = (MovieSummary & {
252
+ media_type: 'movie';
253
+ }) | (TVSummary & {
254
+ media_type: 'tv';
255
+ }) | (PersonSummary & {
256
+ media_type: 'person';
257
+ });
258
+ /** A single multi-search result narrowed to a specific media type. */
259
+ export type MovieMultiResult = MovieSummary & {
260
+ media_type: 'movie';
261
+ };
262
+ export type TVMultiResult = TVSummary & {
263
+ media_type: 'tv';
264
+ };
265
+ export type PersonMultiResult = PersonSummary & {
266
+ media_type: 'person';
267
+ };
268
+ export type TrendingResult = SearchMultiResult;
269
+ export interface CreditCastMember {
270
+ adult?: boolean;
271
+ cast_id?: number;
272
+ character: string;
273
+ credit_id: string;
274
+ gender: number | null;
275
+ id: number;
276
+ known_for_department: string;
277
+ name: string;
278
+ order: number;
279
+ original_name: string;
280
+ popularity: number;
281
+ profile_path: string | null;
282
+ }
283
+ export interface CreditCrewMember {
284
+ adult?: boolean;
285
+ credit_id: string;
286
+ department: string;
287
+ gender: number | null;
288
+ id: number;
289
+ job: string;
290
+ known_for_department: string;
291
+ name: string;
292
+ original_name: string;
293
+ popularity: number;
294
+ profile_path: string | null;
295
+ }
296
+ export interface CreditsResponse {
297
+ id: number;
298
+ cast: CreditCastMember[];
299
+ crew: CreditCrewMember[];
300
+ }
301
+ export interface Video {
302
+ id: string;
303
+ iso_3166_1: string;
304
+ iso_639_1: string;
305
+ key: string;
306
+ name: string;
307
+ official: boolean;
308
+ published_at: string;
309
+ site: string;
310
+ size: number;
311
+ type: string;
312
+ }
313
+ export interface VideosResponse {
314
+ id: number;
315
+ results: Video[];
316
+ }
317
+ export interface ImageItem {
318
+ aspect_ratio: number;
319
+ height: number;
320
+ iso_639_1: string | null;
321
+ file_path: string;
322
+ vote_average: number;
323
+ vote_count: number;
324
+ width: number;
325
+ }
326
+ export interface ImagesResponse {
327
+ id: number;
328
+ backdrops: ImageItem[];
329
+ logos?: ImageItem[];
330
+ posters: ImageItem[];
331
+ }
332
+ export interface ConfigurationImages {
333
+ base_url: string;
334
+ secure_base_url: string;
335
+ backdrop_sizes: string[];
336
+ logo_sizes: string[];
337
+ poster_sizes: string[];
338
+ profile_sizes: string[];
339
+ still_sizes: string[];
340
+ }
341
+ export interface Configuration {
342
+ images: ConfigurationImages;
343
+ change_keys: string[];
344
+ }
345
+ export interface Country {
346
+ iso_3166_1: string;
347
+ english_name: string;
348
+ native_name: string;
349
+ }
350
+ export interface Language {
351
+ iso_639_1: string;
352
+ english_name: string;
353
+ name: string;
354
+ }
355
+ export interface Timezone {
356
+ iso_3166_1: string;
357
+ zones: string[];
358
+ }
359
+ export interface JobDepartment {
360
+ department: string;
361
+ jobs: string[];
362
+ }
363
+ export interface GenresResponse {
364
+ genres: Genre[];
365
+ }
366
+ export type BackdropSize = 'w300' | 'w780' | 'w1280' | 'original' | (string & {});
367
+ export type LogoSize = 'w45' | 'w92' | 'w154' | 'w185' | 'w300' | 'w500' | 'original' | (string & {});
368
+ export type PosterSize = 'w92' | 'w154' | 'w185' | 'w342' | 'w500' | 'w780' | 'original' | (string & {});
369
+ export type ProfileSize = 'w45' | 'w185' | 'h632' | 'original' | (string & {});
370
+ export type StillSize = 'w92' | 'w185' | 'w300' | 'original' | (string & {});
371
+ export type ImageSize = BackdropSize | LogoSize | PosterSize | ProfileSize | StillSize;
372
+ /**
373
+ * Public set of image sizes TMDB currently documents. The SDK does not
374
+ * pin to a static copy of the TMDB docs — TMDB has added new sizes in
375
+ * the past (e.g. `h632` for profile) without notice — but exposing the
376
+ * canonical list lets callers:
377
+ *
378
+ * - iterate over the set to build a size picker
379
+ * - validate user-supplied sizes with `isKnownBackdropSize(...)` etc.
380
+ * - type a variable as a "known" size without giving up the
381
+ * `(string & {})` escape hatch for forward-compatibility
382
+ *
383
+ * If TMDB publishes a new size, the SDK will still accept it at runtime
384
+ * (every helper is `(string & {})` permissive), but you will need to
385
+ * add the literal to these constants to get autocomplete on it.
386
+ */
387
+ export declare const KNOWN_BACKDROP_SIZES: readonly ['w300', 'w780', 'w1280', 'original'];
388
+ export declare const KNOWN_LOGO_SIZES: readonly ['w45', 'w92', 'w154', 'w185', 'w300', 'w500', 'original'];
389
+ export declare const KNOWN_POSTER_SIZES: readonly [
390
+ 'w92',
391
+ 'w154',
392
+ 'w185',
393
+ 'w342',
394
+ 'w500',
395
+ 'w780',
396
+ 'original'
397
+ ];
398
+ export declare const KNOWN_PROFILE_SIZES: readonly ['w45', 'w185', 'h632', 'original'];
399
+ export declare const KNOWN_STILL_SIZES: readonly ['w92', 'w185', 'w300', 'original'];
400
+ export type KnownBackdropSize = (typeof KNOWN_BACKDROP_SIZES)[number];
401
+ export type KnownLogoSize = (typeof KNOWN_LOGO_SIZES)[number];
402
+ export type KnownPosterSize = (typeof KNOWN_POSTER_SIZES)[number];
403
+ export type KnownProfileSize = (typeof KNOWN_PROFILE_SIZES)[number];
404
+ export type KnownStillSize = (typeof KNOWN_STILL_SIZES)[number];
405
+ export type KnownImageSize = KnownBackdropSize | KnownLogoSize | KnownPosterSize | KnownProfileSize | KnownStillSize;
406
+ /** Union of every documented image size. */
407
+ export declare const KNOWN_IMAGE_SIZES: readonly KnownImageSize[];
408
+ export declare function isKnownBackdropSize(value: string): value is KnownBackdropSize;
409
+ export declare function isKnownLogoSize(value: string): value is KnownLogoSize;
410
+ export declare function isKnownPosterSize(value: string): value is KnownPosterSize;
411
+ export declare function isKnownProfileSize(value: string): value is KnownProfileSize;
412
+ export declare function isKnownStillSize(value: string): value is KnownStillSize;
413
+ /** True if `value` is in any documented size set. */
414
+ export declare function isKnownImageSize(value: string): value is KnownImageSize;
415
+ export type MovieAppendToResponse = 'account_states' | 'alternative_titles' | 'changes' | 'credits' | 'external_ids' | 'images' | 'keywords' | 'lists' | 'recommendations' | 'release_dates' | 'reviews' | 'similar' | 'translations' | 'videos' | 'watch/providers' | (string & {});
416
+ export type TVAppendToResponse = 'account_states' | 'aggregate_credits' | 'alternative_titles' | 'changes' | 'content_ratings' | 'credits' | 'episode_groups' | 'external_ids' | 'images' | 'keywords' | 'recommendations' | 'reviews' | 'screened_theatrically' | 'similar' | 'translations' | 'videos' | 'watch/providers' | (string & {});
417
+ export interface ListOptions {
418
+ language?: LanguageCode;
419
+ page?: number;
420
+ region?: RegionCode;
421
+ }
422
+ export interface LanguageOptions {
423
+ language?: LanguageCode;
424
+ }
425
+ export interface MovieDetailsOptions extends LanguageOptions {
426
+ appendToResponse?: MovieAppendToResponse | readonly MovieAppendToResponse[];
427
+ }
428
+ export interface TVDetailsOptions extends LanguageOptions {
429
+ appendToResponse?: TVAppendToResponse | readonly TVAppendToResponse[];
430
+ }
431
+ export interface MovieSearchOptions extends ListOptions {
432
+ includeAdult?: boolean;
433
+ primaryReleaseYear?: string | number;
434
+ year?: string | number;
435
+ }
436
+ export interface TVSearchOptions extends Omit<ListOptions, 'region'> {
437
+ firstAirDateYear?: string | number;
438
+ includeAdult?: boolean;
439
+ year?: string | number;
440
+ }
441
+ export interface MultiSearchOptions extends Omit<ListOptions, 'region'> {
442
+ includeAdult?: boolean;
443
+ /**
444
+ * Media types to exclude from a `search.multi()` response. Filtering is
445
+ * performed client-side because the TMDB multi-search endpoint does not
446
+ * support a server-side media_type filter.
447
+ */
448
+ exclude?: ReadonlyArray<MediaType>;
449
+ }
450
+ export interface ImageQueryOptions extends LanguageOptions {
451
+ includeImageLanguage?: string | readonly string[];
452
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "tmdb-kit",
3
3
  "type": "module",
4
- "version": "1.0.0",
5
- "description": "A tiny, typed, zero-runtime-dependency TMDB SDK for Node.js, Bun, Deno, and edge runtimes.",
4
+ "version": "1.1.0",
5
+ "description": "A tiny, typed, zero-runtime-dependency TMDB SDK and CLI for Node.js, Bun, Deno, and edge runtimes.",
6
6
  "author": "isaced",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/isaced/tmdb-kit#readme",
@@ -13,6 +13,7 @@
13
13
  "typescript",
14
14
  "node",
15
15
  "bun",
16
+ "cli",
16
17
  "deno",
17
18
  "edge",
18
19
  "esm",
@@ -29,7 +30,7 @@
29
30
  "engines": {
30
31
  "node": ">=18"
31
32
  },
32
- "packageManager": "npm@11.12.1",
33
+ "packageManager": "bun@1.4.4",
33
34
  "exports": {
34
35
  ".": {
35
36
  "import": {
@@ -47,6 +48,10 @@
47
48
  "main": "./dist/index.cjs",
48
49
  "module": "./dist/index.js",
49
50
  "types": "./dist/index.d.ts",
51
+ "bin": {
52
+ "tmdb": "./dist/cli.js",
53
+ "tmdb-kit": "./dist/cli.js"
54
+ },
50
55
  "files": [
51
56
  "dist",
52
57
  "README.md"
@@ -56,26 +61,28 @@
56
61
  "provenance": true
57
62
  },
58
63
  "scripts": {
59
- "build": "tsdown",
60
- "dev": "tsdown --watch",
61
- "test": "vitest run",
62
- "test:resources": "vitest run tests/resources",
63
- "test:unit": "vitest run tests/unit",
64
- "test:watch": "vitest",
65
- "test:coverage": "vitest run --coverage",
66
- "test:integration": "vitest run --config vitest.integration.config.ts",
67
- "typecheck": "tsc --noEmit",
68
- "ci": "npm run typecheck && npm run test:coverage && npm run build",
64
+ "build": "bun run scripts/build.ts",
65
+ "build:cli": "bun run scripts/build.ts --cli",
66
+ "cli": "bun run build:cli && bun ./dist/cli.js",
67
+ "dev": "bun build ./src/index.ts --outdir ./dist --entry-naming '[name].js' --format esm --target browser --sourcemap=linked --watch",
68
+ "test": "bun test --isolate tests/unit tests/resources tests/cli",
69
+ "test:resources": "bun test --isolate tests/resources",
70
+ "test:unit": "bun test --isolate tests/unit",
71
+ "test:watch": "bun test --isolate --watch tests/unit tests/resources tests/cli",
72
+ "test:coverage": "bun test --isolate --coverage tests/unit tests/resources tests/cli",
73
+ "test:integration": "bun test --isolate tests/integration",
74
+ "typecheck": "bun check",
75
+ "format": "bun fmt",
76
+ "format:check": "bun fmt --check",
77
+ "ci": "bun run format:check && bun run typecheck && bun run test:coverage && bun run build",
69
78
  "release": "bumpp",
70
- "prepublishOnly": "npm run ci"
79
+ "prepublishOnly": "bun run ci"
71
80
  },
72
81
  "devDependencies": {
82
+ "@types/bun": "^1.4.4",
73
83
  "@types/node": "^25.6.2",
74
- "@vitest/coverage-v8": "^4.1.5",
75
- "@typescript/native-preview": "7.0.0-dev.20260509.2",
76
84
  "bumpp": "^11.1.0",
77
- "tsdown": "^0.22.0",
78
- "typescript": "^6.0.3",
79
- "vitest": "^4.1.5"
85
+ "citty": "^0.2.2",
86
+ "typescript": "^6.0.3"
80
87
  }
81
88
  }