fix(public-api): paginate Trakt sign-in import and keep it under the response limit

Follow Trakt's pagination headers, slim items to the fields Sofa reads,
keep the most recent plays when the payload would exceed Vercel's 4.5 MB
response limit, surface failed/truncated lists as warnings, and return a
readable fetch_error instead of an oversized response for every provider.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
jakeandClaude Sonnet 5.5 committed 2026-10-04 17:27:26 -04:00
1 parent 57aaa5e7d2
commit 6a1b753a49
7 files changed
+505 -27

No files matched your search

@@ -24,6 +24,15 @@ function createLetterboxdZip(files: Record<string, string>): Blob {
// ─── parseTraktPayload ───────────────────────────────────────────────
describe("parseTraktPayload", () => {
test("passes through warnings from the OAuth proxy", () => {
const result = parseTraktPayload({
history: { movies: [] },
warnings: ["Only some history fit", 42],
} as never);
expect(result.warnings).toContain("Only some history fit");
expect(result.warnings.every((w) => typeof w === "string")).toBe(true);
});
test("parses valid data with movies, episodes, watchlist, and ratings", () => {
const result = parseTraktPayload({
history: {