This release is 13 versions behind 0.1.31 — the latest version of @trakt/api. Jump to latest
The core library that implements Trakt API interactions using ts-rest and zod for type-safe communication and validation.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
17%
Published
4 weeks ago (0.1.18)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import { builder } from '../../_internal/builder.ts'; import { extendedQuerySchemaFactory } from '../../_internal/request/extendedQuerySchemaFactory.ts'; import { pageQuerySchema } from '../../_internal/request/pageQuerySchema.ts'; import type { z } from '../../_internal/z.ts'; import { dateRangeParamsSchema } from '../_internal/request/dateRangeParamsSchema.ts'; import { historyItemIdParamsSchema } from '../_internal/request/historyItemIdParamsSchema.ts'; import { profileParamsSchema } from '../_internal/request/profileParamsSchema.ts'; import { activityHistoryResponseSchema } from '../_internal/response/activityHistoryResponseSchema.ts'; import { episodeActivityHistoryResponseSchema } from '../_internal/response/episodeActivityHistoryResponseSchema.ts'; import { movieActivityHistoryResponseSchema } from '../_internal/response/movieActivityHistoryResponseSchema.ts'; import { showActivityHistoryResponseSchema } from '../_internal/response/showActivityHistoryResponseSchema.ts'; export const history = builder.router({ all: { path: '/', method: 'GET', pathParams: profileParamsSchema, query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: activityHistoryResponseSchema.array(), }, }, movies: { path: '/movies', method: 'GET', pathParams: profileParamsSchema, query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: movieActivityHistoryResponseSchema.array(), }, }, shows: { path: '/shows', method: 'GET', pathParams: profileParamsSchema, query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: showActivityHistoryResponseSchema.array(), }, }, episodes: { path: '/episodes', method: 'GET', pathParams: profileParamsSchema, query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: episodeActivityHistoryResponseSchema.array(), }, }, movie: { path: '/movies/:item_id', method: 'GET', pathParams: profileParamsSchema .merge(historyItemIdParamsSchema), query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: movieActivityHistoryResponseSchema.array(), }, }, show: { path: '/shows/:item_id', method: 'GET', pathParams: profileParamsSchema .merge(historyItemIdParamsSchema), query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: showActivityHistoryResponseSchema.array(), }, }, episode: { path: '/episodes/:item_id', method: 'GET', pathParams: profileParamsSchema .merge(historyItemIdParamsSchema), query: extendedQuerySchemaFactory<['full', 'images']>() .merge(dateRangeParamsSchema) .merge(pageQuerySchema), responses: { 200: episodeActivityHistoryResponseSchema.array(), }, }, }, { pathPrefix: '/:id/history', }); export type MovieActivityHistoryResponse = z.infer< typeof movieActivityHistoryResponseSchema >; export type ShowActivityHistoryResponse = z.infer< typeof showActivityHistoryResponseSchema >; export type ActivityHistoryResponse = z.infer< typeof activityHistoryResponseSchema >; export type EpisodeActivityHistoryResponse = z.infer< typeof episodeActivityHistoryResponseSchema >;