@fubar-it-co/tmdb-client 0.0.5
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.
- package/.eslintignore +1 -0
- package/CHANGELOG.md +256 -0
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/eslint.config.js +15 -0
- package/openapi-ts.config.ts +43 -0
- package/package.json +46 -0
- package/publish-local.sh +86 -0
- package/publish.sh +114 -0
- package/scripts/add-ts-nocheck.js +85 -0
- package/src/client/@tanstack/react-query.gen.ts +4398 -0
- package/src/client/client/client.gen.ts +289 -0
- package/src/client/client/index.ts +26 -0
- package/src/client/client/types.gen.ts +214 -0
- package/src/client/client/utils.gen.ts +317 -0
- package/src/client/client.gen.ts +19 -0
- package/src/client/core/auth.gen.ts +42 -0
- package/src/client/core/bodySerializer.gen.ts +85 -0
- package/src/client/core/params.gen.ts +170 -0
- package/src/client/core/pathSerializer.gen.ts +172 -0
- package/src/client/core/queryKeySerializer.gen.ts +118 -0
- package/src/client/core/serverSentEvents.gen.ts +244 -0
- package/src/client/core/types.gen.ts +105 -0
- package/src/client/core/utils.gen.ts +141 -0
- package/src/client/index.ts +6 -0
- package/src/client/sdk.gen.ts +1682 -0
- package/src/client/types.gen.ts +9574 -0
- package/src/index.ts +28 -0
- package/src/tmdb-config.ts +47 -0
- package/src/types/errors.ts +32 -0
- package/src/vite-env.d.ts +9 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +17 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview TMDB HTTP Client package entry point.
|
|
3
|
+
*
|
|
4
|
+
* This package provides a type-safe HTTP client for the TMDB API,
|
|
5
|
+
* generated from the official OpenAPI specification using heyAPI.
|
|
6
|
+
*
|
|
7
|
+
* **Note**: The `./client` folder is generated by heyAPI.
|
|
8
|
+
* Run `pnpm generate` to create it.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Import SDK functions
|
|
13
|
+
* import { moviePopularList, movieDetails } from '@fubar-it-co/tmdb-client'
|
|
14
|
+
*
|
|
15
|
+
* // Use with TanStack Query
|
|
16
|
+
* import { moviePopularListOptions } from '@fubar-it-co/tmdb-client'
|
|
17
|
+
* const { data } = useQuery(moviePopularListOptions())
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @see https://developer.themoviedb.org/docs - TMDB API Documentation
|
|
21
|
+
* @see https://heyapi.dev - heyAPI Documentation
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Re-export generated client
|
|
25
|
+
export * from './client'
|
|
26
|
+
|
|
27
|
+
// Re-export custom types
|
|
28
|
+
export type { TMDBError } from './types/errors'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview TMDB API client runtime configuration.
|
|
5
|
+
*
|
|
6
|
+
* This file is referenced by heyAPI during client generation via the
|
|
7
|
+
* `runtimeConfigPath` option in `openapi-ts.config.ts`.
|
|
8
|
+
*
|
|
9
|
+
* It provides the base URL and authentication headers for all TMDB API requests.
|
|
10
|
+
* The API token is read from the environment variable `VITE_TMDB_API_TOKEN`.
|
|
11
|
+
*
|
|
12
|
+
* @see https://heyapi.dev/openapi-ts/clients/fetch#runtime-api
|
|
13
|
+
*/
|
|
14
|
+
import type { Config } from './client/client/types.gen'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* TMDB API Bearer token from environment variables.
|
|
18
|
+
* Must be set in `.env.local` at the monorepo root.
|
|
19
|
+
*/
|
|
20
|
+
const TMDB_API_TOKEN = import.meta.env.VITE_TMDB_API_TOKEN
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates the client configuration for TMDB API requests.
|
|
24
|
+
*
|
|
25
|
+
* This function is called by the generated `client.gen.ts` before
|
|
26
|
+
* initializing the client instance. It sets:
|
|
27
|
+
* - `baseUrl`: The TMDB API base URL
|
|
28
|
+
* - `Authorization`: Bearer token for authentication
|
|
29
|
+
*
|
|
30
|
+
* @param config - The default configuration from heyAPI
|
|
31
|
+
* @returns The merged configuration with TMDB-specific settings
|
|
32
|
+
*/
|
|
33
|
+
export const createClientConfig = <T extends Config>(config: T): T => {
|
|
34
|
+
const existingHeaders =
|
|
35
|
+
config.headers && !Array.isArray(config.headers)
|
|
36
|
+
? (config.headers as Record<string, string>)
|
|
37
|
+
: {}
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
...config,
|
|
41
|
+
baseUrl: 'https://api.themoviedb.org',
|
|
42
|
+
headers: {
|
|
43
|
+
...existingHeaders,
|
|
44
|
+
Authorization: `Bearer ${TMDB_API_TOKEN}`,
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TMDB API Error Response
|
|
3
|
+
*
|
|
4
|
+
* This is the error format returned by the TMDB API when a request fails.
|
|
5
|
+
* The API returns this JSON structure with an HTTP error status code (401, 404, 500, etc.).
|
|
6
|
+
*
|
|
7
|
+
* @see https://developer.themoviedb.org/docs/errors
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // 401 Unauthorized (Invalid API key)
|
|
11
|
+
* {
|
|
12
|
+
* success: false,
|
|
13
|
+
* status_code: 7,
|
|
14
|
+
* status_message: "Invalid API key: You must be granted a valid key."
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // 404 Not Found (Resource not found)
|
|
19
|
+
* {
|
|
20
|
+
* success: false,
|
|
21
|
+
* status_code: 34,
|
|
22
|
+
* status_message: "The resource you requested could not be found."
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
export interface TMDBError {
|
|
26
|
+
/** Always false for error responses */
|
|
27
|
+
success: false
|
|
28
|
+
/** TMDB internal status code (e.g., 7 for invalid API key, 34 for not found) */
|
|
29
|
+
status_code: number
|
|
30
|
+
/** Human-readable error message */
|
|
31
|
+
status_message: string
|
|
32
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"types": ["vite/client"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/index.ts", "src/tmdb-config.ts", "src/vite-env.d.ts"],
|
|
16
|
+
"exclude": ["node_modules"]
|
|
17
|
+
}
|