TMDB API code generation workflow with selective Zod schemas using pnpm codegen:tmdb. Use when working with TMDB endpoints, regenerating types, adding TMDB API functionality, modifying endpoints-config.js, tmdb-server-functions.ts, Zod schemas, or when the user mentions TMDB codegen, endpoints-config, pnpm codegen:tmdb, needsZodSchema, or auto-generated TMDB files.
This project uses automatic code generation for TMDB API integration with selective Zod schema generation for optimal performance.
NEVER manually edit src/_generated/tmdb-server-functions.ts - it is auto-generated.
Always use pnpm codegen:tmdb to regenerate after making changes to endpoint configurations.
The project uses a selective approach to Zod schema generation:
Zod schemas are only generated for endpoints marked with needsZodSchema: true in endpoints.js.
Why selective?
Location: packages/tmdb-codegen/src/endpoints.js
export const endpoints = [
{
path: "/3/search/movie",
functionName: "searchMovies",
needsZodSchema: true, // ✅ Zod schema generated for AI tools
},
{
path: "/3/movie/{movie_id}",
functionName: "getMovieDetails",
// ❌ No needsZodSchema flag = TypeScript types only
},
];
endpoints.jsneedsZodSchema: true only if needed for AI toolspnpm codegen:tmdb to regenerate{
path: "/3/discover/tv",
functionName: "discoverTvShows",
needsZodSchema: false, // Only TS types needed
}
# Full pipeline (TypeScript types + Zod schemas)
pnpm codegen
# Only regenerate TMDB server functions
pnpm codegen:tmdb
# Only regenerate Zod schemas (fast!)
pnpm codegen:zod
src/_generated/tmdb-server-functions.ts - Server functions with TypeScript typessrc/_generated/tmdb-zod-schemas.ts - Selective Zod schemas (only for endpoints with needsZodSchema: true)These files are git-ignored and must be regenerated after cloning:
pnpm codegen:tmdb
Location: packages/tmdb-codegen/src/generate-schemas-from-source.ts
endpoints.js to find endpoints needing Zod schemas.nullable().optional())Automatically applies fixes for OpenAI Structured Outputs:
// Generated schema with OpenAI compatibility
export const movieSchema = z.object({
id: z.number(),
title: z.string().nullable().optional(), // OpenAI-compatible
overview: z.string().nullable().optional(),
});
import { searchMovies, getMovieDetails } from "@/utils/tmdb-server-functions";
// Use in server components
const movies = await searchMovies({ query: "Inception" });
import { movieSearchSchema } from "@/utils/tmdb-zod-schemas";
// Use with OpenAI Structured Outputs
const completion = await openai.chat.completions.create({
model: "gpt-4",
messages: [...],
response_format: zodResponseFormat(movieSearchSchema, "movies"),
});
Regenerate TMDB code when:
endpoints.js, then run pnpm codegen:tmdbendpoints.js, then regeneratepnpm codegen:tmdbneedsZodSchema: true when needed for AI toolsendpoints.js is version-controlled# 1. Edit configuration
# Add to packages/tmdb-codegen/src/endpoints.js
# 2. Regenerate
pnpm codegen:tmdb
# 3. Use in code
import { newFunction } from "@/utils/tmdb-server-functions";
# 1. Edit configuration
# Set needsZodSchema: true in endpoints.js
# 2. Regenerate Zod schemas only (fast!)
pnpm codegen:zod
# 3. Use schema
import { newSchema } from "@/utils/tmdb-zod-schemas";
pnpm codegen:tmdb
# Regenerate from scratch
rm -rf src/_generated
pnpm codegen:tmdb
Check endpoints.js - ensure needsZodSchema: true is set for that endpoint, then regenerate.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer