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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { z } from '../z.ts';
import {
externalRatingsResponseSchema,
ratingsResponseSchema,
} from './ratingsResponseSchema.ts';

/**
* Zod schema for the movie ratings response - the shared ratings shape plus the
* film-specific Letterboxd and MyAnimeList blocks.
*/
export const movieRatingsResponseSchema = ratingsResponseSchema.extend({
/***
* Letterboxd audience rating on a 0-5 scale. Films only.
* Available if requesting extended `all`.
*/
letterboxd: externalRatingsResponseSchema.extend({
votes: z.number().int().nullish(),
}).nullish(),
/***
* MyAnimeList audience rating on a 0-10 scale. Anime only.
* Available if requesting extended `all`.
*/
mal: externalRatingsResponseSchema.extend({
votes: z.number().int().nullish(),
}).nullish(),
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { float, z } from '../z.ts';
import { distributionResponseSchema } from './distributionResponseSchema.ts';

const externalRatingsResponseSchema = z.object({
/** Shared shape for an external rating source: a rating and a link, both nullish. */
export const externalRatingsResponseSchema = z.object({
rating: float(z.number()).nullish(),
link: z.string().nullish(),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from '../z.ts';
import {
externalRatingsResponseSchema,
ratingsResponseSchema,
} from './ratingsResponseSchema.ts';

/**
* Zod schema for the show ratings response - the shared ratings shape plus the
* MyAnimeList block. Letterboxd is films-only, so it is absent here.
*/
export const showRatingsResponseSchema = ratingsResponseSchema.extend({
/***
* MyAnimeList audience rating on a 0-10 scale. Anime only.
* Available if requesting extended `all`.
*/
mal: externalRatingsResponseSchema.extend({
votes: z.number().int().nullish(),
}).nullish(),
});
4 changes: 2 additions & 2 deletions projects/api/src/contracts/movies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
peopleResponseSchema,
} from '../_internal/response/peopleResponseSchema.ts';
import { profileResponseSchema } from '../_internal/response/profileResponseSchema.ts';
import { ratingsResponseSchema } from '../_internal/response/ratingsResponseSchema.ts';
import { movieRatingsResponseSchema } from '../_internal/response/movieRatingsResponseSchema.ts';
import { sentimentsResponseSchema } from '../_internal/response/sentimentsResponseSchema.ts';
import { studioResponseSchema } from '../_internal/response/studioResponseSchema.ts';
import { translationResponseSchema } from '../_internal/response/translationResponseSchema.ts';
Expand Down Expand Up @@ -99,7 +99,7 @@ Returns a single movie's details.
query: extendedQuerySchemaFactory<['all']>(),
pathParams: idParamsSchema,
responses: {
200: ratingsResponseSchema,
200: movieRatingsResponseSchema,
},
},
stats: {
Expand Down
3 changes: 2 additions & 1 deletion projects/api/src/contracts/shows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { listTypeSchema } from '../_internal/response/listTypeSchema.ts';
import { peopleResponseSchema } from '../_internal/response/peopleResponseSchema.ts';
import { profileResponseSchema } from '../_internal/response/profileResponseSchema.ts';
import { ratingsResponseSchema } from '../_internal/response/ratingsResponseSchema.ts';
import { showRatingsResponseSchema } from '../_internal/response/showRatingsResponseSchema.ts';
import { sentimentsResponseSchema } from '../_internal/response/sentimentsResponseSchema.ts';
import { showCertificationResponseSchema } from '../_internal/response/showCertificationResponseSchema.ts';
import { showResponseSchema } from '../_internal/response/showResponseSchema.ts';
Expand Down Expand Up @@ -288,7 +289,7 @@ Returns a single shows's details. If you request extended info, the \`airs\` obj
query: extendedQuerySchemaFactory<['all']>(),
pathParams: idParamsSchema,
responses: {
200: ratingsResponseSchema,
200: showRatingsResponseSchema,
},
},
stats: {
Expand Down
Loading