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
27 changes: 16 additions & 11 deletions projects/api/src/contracts/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import {
collectionMinimalResponseSchema,
collectionMinimalShowResponseSchema,
} from './schema/response/collectionMinimalResponseSchema.ts';
import { collectionResponseSchema } from './schema/response/collectionResponseSchema.ts';
import {
collectedEpisodeSchema,
collectedMovieSchema,
collectedShowSchema,
collectionResponseSchema,
} from './schema/response/collectionResponseSchema.ts';
import { favoritesRemoveResponseSchema } from './schema/response/favoritesRemoveResponseSchema.ts';
import { favoritesResponseSchema } from './schema/response/favoritesResponseSchema.ts';
import { historyRemoveResponseSchema } from './schema/response/historyRemoveResponseSchema.ts';
Expand Down Expand Up @@ -167,7 +172,7 @@ const collection = builder.router({
query: extendedQuerySchemaFactory<['full', 'images', 'available_on']>()
.merge(collectionParamSchema),
responses: {
200: collectionResponseSchema.array(),
200: collectedMovieSchema.array(),
},
},
shows: {
Expand All @@ -176,7 +181,7 @@ const collection = builder.router({
query: extendedQuerySchemaFactory<['full', 'images', 'available_on']>()
.merge(collectionParamSchema),
responses: {
200: collectionResponseSchema.array(),
200: collectedShowSchema.array(),
},
},
episodes: {
Expand All @@ -185,38 +190,35 @@ const collection = builder.router({
query: extendedQuerySchemaFactory<['full', 'images', 'available_on']>()
.merge(collectionParamSchema),
responses: {
200: collectionResponseSchema.array(),
200: collectedEpisodeSchema.array(),
},
},
minimal: builder.router({
movies: {
method: 'GET',
path: '/movies',
query: collectionParamSchema
.merge(minimalParamSchema),
query: collectionParamSchema,
responses: {
200: collectionMinimalResponseSchema,
},
},
shows: {
method: 'GET',
path: '/shows',
query: collectionParamSchema
.merge(minimalParamSchema),
query: collectionParamSchema,
responses: {
200: collectionMinimalShowResponseSchema,
},
},
episodes: {
method: 'GET',
path: '/episodes',
query: collectionParamSchema
.merge(minimalParamSchema),
query: collectionParamSchema,
responses: {
200: collectionMinimalResponseSchema,
},
},
}),
}, { pathPrefix: '/minimal' }),
}, {
pathPrefix: '/collection',
});
Expand Down Expand Up @@ -271,6 +273,9 @@ export type FavoritesRemoveResponse = z.infer<

export type CollectionRequest = z.infer<typeof collectionParamSchema>;
export type CollectionResponse = z.infer<typeof collectionResponseSchema>;
export type CollectionMovieResponse = z.infer<typeof collectedMovieSchema>;
export type CollectionShowResponse = z.infer<typeof collectedShowSchema>;
export type CollectionEpisodeResponse = z.infer<typeof collectedEpisodeSchema>;
export type CollectionMinimalResponse = z.infer<
typeof collectionMinimalResponseSchema
>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const collectedItemSchema = z.object({
updated_at: z.string().datetime(),
}).merge(availableOnSchema);

const collectedMovieSchema = typedMovieResponseSchema
export const collectedMovieSchema = typedMovieResponseSchema
.merge(collectedItemSchema);

const collectedEpisodeSchema = typedEpisodeResponseSchema
export const collectedEpisodeSchema = typedEpisodeResponseSchema
.merge(collectedItemSchema);

const collectedSeasonEpisodeSchema = z.object({
Expand All @@ -36,7 +36,7 @@ const collectedSeasonResponseSchema = z.object({
episodes: collectedSeasonEpisodeSchema.array(),
});

const collectedShowSchema = z.object({
export const collectedShowSchema = z.object({
last_collected_at: z.string().datetime(),
last_updated_at: z.string().datetime(),
seasons: collectedSeasonResponseSchema.array(),
Expand Down
Loading