Skip to content

Younify: adds all methods#803

Merged
vladjerca merged 2 commits into
masterfrom
feat/younify_methods
Jun 4, 2026
Merged

Younify: adds all methods#803
vladjerca merged 2 commits into
masterfrom
feat/younify_methods

Conversation

@rectifyer

@rectifyer rectifyer commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

Wires the newly-merged v2 younify streaming-sync management endpoints into the @trakt/api ts-rest contracts, so native clients can port the web /settings/scrobblers ("Streaming Sync") page.

All routes require an official Trakt app API key and a user OAuth token, consistent with the existing /younify/* endpoints.

1. New top-level younify contract (/younify, authMetadata('required'))

Route Method & Path Response
connections GET /younify/connections 200connectionSchema[]
connect POST /younify/connect 200{ url }, 400/422
refresh POST /younify/users/refresh/:service_id 204
refreshAll POST /younify/users/refresh/:service_id/:all_data 204
disconnect DELETE /younify/users/services/:service_id 204
  • connections returns every connectable service with the user's status merged in. Array order is significant — clients must preserve response order when rendering the grid (documented in the route description).
  • connect mints a signed younify web-auth URL from the client's return_url.
  • refresh/refreshAll/disconnect are the existing reused actions the native page depends on (they weren't yet in the contract). The optional Rails segment (/:all_data) is modeled as a second explicit route (refreshAll), since ts-rest can't express truly-optional path segments.

2. New syncs sub-router on the users contract (collection-level, /users/syncs)

Route Method & Path Response
list GET /users/syncs 200syncSchema[]
listByType GET /users/syncs/:type 200syncSchema[]
details GET /users/syncs/:id 200syncSchema
paused GET /users/syncs/:id/paused 200syncItemSchema[]
skipped GET /users/syncs/:id/skipped 200syncItemSchema[]
undo DELETE /users/syncs/:id 204
  • Paginated via pageQuerySchema + standard X-Pagination-* headers (X-Pagination-Item-Count = total sync count for the "synced N times" banner).
  • syncSchema is counts-only (added counts + paused_count/skipped_count); the potentially-huge paused/skipped item arrays are split into their own paginated routes.
  • syncItemSchema is the raw stored item + a normalized envelope, made permissive with .passthrough() (preserves source-specific plex fields) and a discriminated trakt_item. kind discriminates history vs rating (paused is always history; skipped mixes both).
  • Timestamps are documented as API-standard .000Z; an unknown :type 404s; :id/:type path collision is fine (ts-rest dispatches by route key).

Conventions: placed alongside the existing inline GLOBAL_LEVEL/ENTITY_LEVEL routers in users/index.ts; one schema per file under schema/request|response; #### 🔒 OAuth Required descriptions; z.infer type aliases + schema re-exports; error responses use z.undefined() to match the repo-wide norm. Registered in both traktContract.ts and src/index.ts, and bumped @trakt/api to 0.4.14.

Testing

  • deno check src/index.ts — passes.
  • deno lint + deno fmt --check — clean on all changed files.
  • OpenAPI generate + validate — pass; all 9 new paths appear in the generated spec (.passthrough() and discriminated unions generate valid OpenAPI).

Note: deno test surfaces 5 pre-existing type errors in sync/HistoryRequest.test.ts, unrelated to this change.

Checklist

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing v2 younify “Streaming Sync” management endpoints and introduces a new /users/syncs contract surface for listing/inspecting/undoing data sync runs (including paginated paused/skipped item views), wiring everything into the @trakt/api exports and top-level contract.

Changes:

  • Add a new top-level younify router (/younify) with connection listing, connect URL minting, refresh, and disconnect routes.
  • Add a new users.syncs sub-router (/users/syncs) with list/filter/details, paused/skipped paginated items, and undo.
  • Register exports/contract wiring and bump package version + commitlint scope.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
projects/api/src/index.ts Re-exports the new younify contract module from the package entrypoint.
projects/api/src/contracts/younify/index.ts Defines the new /younify contract router and route metadata.
projects/api/src/contracts/younify/schema/request/connectRequestSchema.ts Request body schema for creating a streaming connection.
projects/api/src/contracts/younify/schema/request/serviceIdParamsSchema.ts Shared service_id path params schema.
projects/api/src/contracts/younify/schema/request/refreshParamsSchema.ts Path params schema for the “full refresh” variant including all_data.
projects/api/src/contracts/younify/schema/response/connectResponseSchema.ts Response schema for the minted connect URL.
projects/api/src/contracts/younify/schema/response/connectionResponseSchema.ts Response schema representing a connectable service + user connection state.
projects/api/src/contracts/users/index.ts Adds syncs sub-router under /users, plus re-exports/types for new sync schemas/params.
projects/api/src/contracts/users/schema/response/syncResponseSchema.ts Defines the syncSchema response model (counts-only sync run summary).
projects/api/src/contracts/users/schema/response/syncItemResponseSchema.ts Defines syncItemSchema (+ traktItemSchema) for paused/skipped item payloads.
projects/api/src/contracts/users/schema/request/syncTypeParamsSchema.ts Path params schema for sync filtering by kind/type.
projects/api/src/contracts/users/schema/request/syncIdParamsSchema.ts Path params schema for numeric sync id routes.
projects/api/src/contracts/traktContract.ts Registers the new younify router at the top-level contract.
projects/api/deno.json Bumps @trakt/api version to 0.4.14.
commitlint.config.js Allows younify as a commit scope.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread projects/api/src/contracts/users/index.ts
Comment thread projects/api/src/contracts/users/index.ts
Comment thread projects/api/src/contracts/users/index.ts
Comment thread projects/api/src/contracts/users/index.ts
Comment thread projects/api/src/contracts/users/index.ts
@vladjerca vladjerca merged commit 08122d8 into master Jun 4, 2026
3 checks passed
@vladjerca vladjerca deleted the feat/younify_methods branch June 4, 2026 23:03
@rectifyer rectifyer mentioned this pull request Jun 8, 2026
6 tasks
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.

3 participants