Skip to content

Commit b8d9c80

Browse files
committed
feat(calendar): add hot releases endpoint contract
Adds the `/calendars/releases/hot/:start_date/:days` contract: a global-only merged feed of upcoming movies and episodes that are trending or highly anticipated, ordered by availability date. Optional `type` query narrows to a single media type; the response is a union of the movie and episode calendar entries. Bumps the package to 0.4.22.
1 parent baeafea commit b8d9c80

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

projects/api/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@trakt/api",
33
"exports": "./src/index.ts",
4-
"version": "0.4.21",
4+
"version": "0.4.22",
55
"imports": {
66
"@anatine/zod-openapi": "npm:@anatine/zod-openapi@^2.2.6",
77
"@std/testing": "jsr:@std/testing@^1.0.5",

projects/api/src/contracts/calendars/index.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { builder } from '../_internal/builder.ts';
22
import { extendedMediaQuerySchema } from '../_internal/request/extendedMediaQuerySchema.ts';
33
import { ignoreQuerySchema } from '../_internal/request/ignoreQuerySchema.ts';
44
import { mediaFilterParamsSchema } from '../_internal/request/mediaFilterParamsSchema.ts';
5-
import type { z } from '../_internal/z.ts';
5+
import { z } from '../_internal/z.ts';
66
import { calendarRequestParamsSchema } from './schema/request/calendarParamsSchema.ts';
77
import { calendarMovieResponseSchema } from './schema/response/calendarMovieResponseSchema.ts';
88
import { calendarShowResponseSchema } from './schema/response/calendarShowListResponseSchema.ts';
9+
import { hotReleaseResponseSchema } from './schema/response/hotReleaseResponseSchema.ts';
910

1011
export const calendars = builder.router({
1112
shows: {
@@ -106,6 +107,25 @@ Returns DVD and physical media releases during the requested UTC date range. Use
106107
200: calendarMovieResponseSchema.array(),
107108
},
108109
},
110+
releasesHot: {
111+
summary: 'Get hot releases',
112+
description: `#### ✨ Extended Info 🎚 Filters
113+
Returns the merged feed of upcoming movies and episodes during the requested UTC date range that are trending or highly anticipated, ordered by availability date. This is the global feed only; use \`type\` to narrow to a single media type.`,
114+
method: 'GET',
115+
path: '/releases/hot/:start_date/:days',
116+
query: extendedMediaQuerySchema
117+
.merge(mediaFilterParamsSchema)
118+
.merge(z.object({
119+
type: z.enum(['movie', 'show']).optional().openapi({
120+
description:
121+
'Narrow the feed to a single media type. Omit to return both.',
122+
}),
123+
})),
124+
pathParams: calendarRequestParamsSchema.omit({ target: true }),
125+
responses: {
126+
200: hotReleaseResponseSchema.array(),
127+
},
128+
},
109129
}, { pathPrefix: '/calendars' });
110130

111131
export { calendarRequestParamsSchema };
@@ -118,3 +138,6 @@ export type CalendarShowResponse = z.infer<
118138

119139
export { calendarMovieResponseSchema };
120140
export type CalendarMovieResponse = z.infer<typeof calendarMovieResponseSchema>;
141+
142+
export { hotReleaseResponseSchema };
143+
export type HotReleaseResponse = z.infer<typeof hotReleaseResponseSchema>;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { z } from '../../../_internal/z.ts';
2+
import { calendarMovieResponseSchema } from './calendarMovieResponseSchema.ts';
3+
import { calendarShowResponseSchema } from './calendarShowListResponseSchema.ts';
4+
5+
/**
6+
* A single entry in the merged hot-releases feed: either an upcoming movie or
7+
* an upcoming episode. Discriminate by shape — movie entries carry `movie`,
8+
* episode entries carry `episode`/`show`.
9+
*/
10+
export const hotReleaseResponseSchema = z.union([
11+
calendarMovieResponseSchema,
12+
calendarShowResponseSchema,
13+
]);

0 commit comments

Comments
 (0)