Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/api/deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trakt/api",
"exports": "./src/index.ts",
"version": "0.4.23",
"version": "0.4.24",
"imports": {
"@anatine/zod-openapi": "npm:@anatine/zod-openapi@^2.2.6",
"@std/testing": "jsr:@std/testing@^1.0.5",
Expand Down
16 changes: 13 additions & 3 deletions projects/api/src/contracts/calendars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import { calendarMovieResponseSchema } from './schema/response/calendarMovieResp
import { calendarShowResponseSchema } from './schema/response/calendarShowListResponseSchema.ts';
import { hotReleaseResponseSchema } from './schema/response/hotReleaseResponseSchema.ts';

const groupQuery = z.object({
group: z.enum(['day']).optional().openapi({
description:
'Collapse same-show-same-day episodes into a single card (`full_season` / `multiple_episodes`). Omit for one entry per episode.',
}),
});

export const calendars = builder.router({
shows: {
summary: 'Get shows',
Expand All @@ -17,7 +24,8 @@ Returns shows airing during the requested UTC date range. Use \`target\` to choo
path: '/:target/shows/:start_date/:days',
query: extendedMediaQuerySchema
.merge(mediaFilterParamsSchema)
.merge(ignoreQuerySchema),
.merge(ignoreQuerySchema)
.merge(groupQuery),
pathParams: calendarRequestParamsSchema,
responses: {
200: calendarShowResponseSchema.array(),
Expand Down Expand Up @@ -120,7 +128,8 @@ Returns the merged feed of movies and episodes during the requested UTC date ran
description:
'Narrow the feed to a single media type. Omit to return both.',
}),
})),
}))
.merge(groupQuery),
pathParams: calendarRequestParamsSchema,
responses: {
200: hotReleaseResponseSchema.array(),
Expand All @@ -139,7 +148,8 @@ Returns the merged feed of upcoming movies and episodes during the requested UTC
description:
'Narrow the feed to a single media type. Omit to return both.',
}),
})),
}))
.merge(groupQuery),
pathParams: calendarRequestParamsSchema.omit({ target: true }),
responses: {
200: hotReleaseResponseSchema.array(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { episodeResponseSchema } from '../../../_internal/response/episodeResponseSchema.ts';
import { z } from '../../../_internal/z.ts';

/**
* Episode as returned by the calendar endpoints. Extends the shared episode
* with the day-grouping fields that `?group=day` populates: `episode_type` can
* additionally be a computed card type, and `episodes` holds the collapsed
* group. Both are nullish, so a single shape covers the raw and grouped feeds
* without touching the shared `episodeResponseSchema`.
*/
export const calendarEpisodeResponseSchema = episodeResponseSchema.extend({
episode_type: z
.enum([
'standard',
'series_premiere',
'season_premiere',
'mid_season_finale',
'mid_season_premiere',
'season_finale',
'series_finale',
'full_season',
'multiple_episodes',
])
.nullish(),
episodes: episodeResponseSchema.array().nullish(),
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { episodeResponseSchema } from '../../../_internal/response/episodeResponseSchema.ts';
import { showResponseSchema } from '../../../_internal/response/showResponseSchema.ts';
import { z } from '../../../_internal/z.ts';
import { calendarEpisodeResponseSchema } from './calendarEpisodeResponseSchema.ts';

export const calendarShowResponseSchema = z.object({
first_aired: z.string(),
episode: episodeResponseSchema,
episode: calendarEpisodeResponseSchema,
show: showResponseSchema,
});
Loading