Skip to content

YIR: adds more data needed for native yir#807

Merged
vladjerca merged 2 commits into
masterfrom
feat/additional_yir_methods
Jun 9, 2026
Merged

YIR: adds more data needed for native yir#807
vladjerca merged 2 commits into
masterfrom
feat/additional_yir_methods

Conversation

@rectifyer

Copy link
Copy Markdown
Contributor

Description

Wires the newly-merged Year in Review / Month in Review data expansion into the @trakt/api ts-rest contracts.

Same endpoints (GET /users/:id/yir/:year and GET /users/:id/mir/:year/:month), but the API now surfaces four sections that already existed in the web experience and weren't exposed over the API. The contract's yearInReviewResponseSchema was aliased to monthInReviewResponseSchema, which only modeled stats / images / first_watched / last_watched — so typed clients would never see the new data. This adds them.

New sections

Section Endpoints Shape
countries YIR + MIR per type (shows/movies): country_count + countries[] of { country, count }
trends YIR + MIR per type: up to 12 entries of { month, month_name, watchers, watched, show | movie }
thanks YIR + MIR per type: array of { show } / { movie } (popular titles the user hasn't watched)
streaming_services MIR only { country, services[] } with per-service { source, name, shows, movies, all }
  • trends.watchers is the global play count; trends.watched is whether this user watched it.
  • trends/thanks elements carry a nested show/movie media object with no type discriminator (the type field is only emitted for first_watched/last_watched), so they wrap showResponseSchema / movieResponseSchema directly rather than the typed* variants.
  • streaming_services is Month-in-Review only — its catalog scan is bounded to a single month — so it must not appear on the Year in Review shape.

Implementation

  • monthInReviewResponseSchema.ts: added countries, trends, thanks, streaming_services. Split out an exported reviewBaseSchema (shared fields + countries/trends/thanks); monthInReviewResponseSchema = reviewBaseSchema + streaming_services.
  • yearInReviewResponseSchema.ts: now = reviewBaseSchema (drops the previous plain alias so it excludes streaming_services).
  • New section schemas kept inline as private helpers, matching the file's existing convention (statsSchema, watchedItemSchema, …).
  • No route, traktContract.ts, or src/index.ts changes — the existing MonthInReviewResponse / YearInReviewResponse type aliases pick up the new fields automatically.
  • Bumped @trakt/api to 0.4.15.

Testing

  • deno check src/index.ts — passes.
  • deno lint + deno fmt --check — clean.
  • OpenAPI generate + validate — pass; the generated spec confirms the per-endpoint shapes:
Endpoint 200 properties
GET /users/{id}/mir/{year}/{month} stats, images, first_watched, last_watched, countries, trends, thanks, streaming_services
GET /users/{id}/yir/{year} stats, images, first_watched, last_watched, countries, trends, thanks

Checklist

  • Clear and concise title
  • Detailed description
  • Coding standards (deno fmt / deno lint clean)
  • Documentation (OpenAPI regenerated & validated)
  • Tests — no new contract tests added (consistent with prior contract additions)

@rectifyer rectifyer mentioned this pull request Jun 9, 2026
6 tasks
@rectifyer rectifyer requested review from seferturan and vladjerca June 9, 2026 03:28
@rectifyer rectifyer mentioned this pull request Jun 9, 2026
11 tasks
@vladjerca vladjerca merged commit fac84ff into master Jun 9, 2026
3 checks passed
@vladjerca vladjerca deleted the feat/additional_yir_methods branch June 9, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants