diff --git a/front/packages/models/src/resources/collection.ts b/front/packages/models/src/resources/collection.ts
deleted file mode 100644
index aa85e4c9..00000000
--- a/front/packages/models/src/resources/collection.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { ImagesP, ResourceP } from "../traits";
-
-export const CollectionP = ResourceP("collection")
- .merge(ImagesP)
- .extend({
- /**
- * The title of this collection.
- */
- name: z.string(),
- /**
- * The summary of this show.
- */
- overview: z.string().nullable(),
- })
- .transform((x) => ({
- ...x,
- href: `/collection/${x.slug}`,
- }));
-
-/**
- * A class representing collections of show or movies.
- */
-export type Collection = z.infer;
diff --git a/front/packages/models/src/resources/genre.ts b/front/packages/models/src/resources/genre.ts
deleted file mode 100644
index c54004bb..00000000
--- a/front/packages/models/src/resources/genre.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-export enum Genre {
- Action = "Action",
- Adventure = "Adventure",
- Animation = "Animation",
- Comedy = "Comedy",
- Crime = "Crime",
- Documentary = "Documentary",
- Drama = "Drama",
- Family = "Family",
- Fantasy = "Fantasy",
- History = "History",
- Horror = "Horror",
- Music = "Music",
- Mystery = "Mystery",
- Romance = "Romance",
- ScienceFiction = "ScienceFiction",
- Thriller = "Thriller",
- War = "War",
- Western = "Western",
- Kids = "Kids",
- News = "News",
- Reality = "Reality",
- Soap = "Soap",
- Talk = "Talk",
- Politics = "Politics",
-}
diff --git a/front/packages/models/src/resources/index.ts b/front/packages/models/src/resources/index.ts
deleted file mode 100644
index 2070550d..00000000
--- a/front/packages/models/src/resources/index.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-export * from "./library-item";
-export * from "./news";
-export * from "./show";
-export * from "./movie";
-export * from "./collection";
-export * from "./genre";
-export * from "./person";
-export * from "./studio";
-export * from "./episode";
-export * from "./season";
-export * from "./watch-info";
-export * from "./watch-status";
-export * from "./watchlist";
-export * from "./user";
-export * from "./server-info";
diff --git a/front/packages/models/src/resources/library-item.ts b/front/packages/models/src/resources/library-item.ts
deleted file mode 100644
index aab0ab11..00000000
--- a/front/packages/models/src/resources/library-item.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { CollectionP } from "./collection";
-import { MovieP } from "./movie";
-import { ShowP } from "./show";
-
-export const LibraryItemP = z.union([
- /*
- * Either a Show
- */
- ShowP,
- /*
- * Or a Movie
- */
- MovieP,
- /*
- * Or a Collection
- */
- CollectionP,
-]);
-
-/**
- * An item that can be contained by a Library (so a Show, a Movie or a Collection).
- */
-export type LibraryItem = z.infer;
diff --git a/front/packages/models/src/resources/metadata.ts b/front/packages/models/src/resources/metadata.ts
deleted file mode 100644
index 082155a7..00000000
--- a/front/packages/models/src/resources/metadata.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-
-export const MetadataP = z.preprocess(
- (x) =>
- typeof x === "object" && x ? Object.fromEntries(Object.entries(x).filter(([_, v]) => v)) : x,
- z.record(
- z.object({
- /*
- * The ID of the resource on the external provider.
- */
- dataId: z.string(),
-
- /*
- * The URL of the resource on the external provider.
- */
- link: z.string().nullable(),
- }),
- ),
-);
-
-export type Metadata = z.infer;
diff --git a/front/packages/models/src/resources/news.ts b/front/packages/models/src/resources/news.ts
deleted file mode 100644
index 0e04ab27..00000000
--- a/front/packages/models/src/resources/news.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { EpisodeP } from "./episode";
-import { MovieP } from "./movie";
-
-export const NewsP = z.union([
- /*
- * Either an episode
- */
- EpisodeP,
- /*
- * Or a Movie
- */
- MovieP,
-]);
-
-/**
- * A new item added to kyoo.
- */
-export type News = z.infer;
diff --git a/front/packages/models/src/resources/person.ts b/front/packages/models/src/resources/person.ts
deleted file mode 100644
index f069efa7..00000000
--- a/front/packages/models/src/resources/person.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { ImagesP, ResourceP } from "../traits";
-
-export const PersonP = ResourceP("people").merge(ImagesP).extend({
- /**
- * The name of this person.
- */
- name: z.string(),
- /**
- * The type of work the person has done for the show. That can be something like "Actor",
- * "Writer", "Music", "Voice Actor"...
- */
- type: z.string().optional(),
-
- /**
- * The role the People played. This is mostly used to inform witch character was played for actor
- * and voice actors.
- */
- role: z.string().optional(),
-});
-
-/**
- * A studio that make shows.
- */
-export type Person = z.infer;
diff --git a/front/packages/models/src/resources/quality.ts b/front/packages/models/src/resources/quality.ts
deleted file mode 100644
index 217ce465..00000000
--- a/front/packages/models/src/resources/quality.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-
-export const QualityP = z
- .union([
- z.literal("original"),
- z.literal("8k"),
- z.literal("4k"),
- z.literal("1440p"),
- z.literal("1080p"),
- z.literal("720p"),
- z.literal("480p"),
- z.literal("360p"),
- z.literal("240p"),
- ])
- .default("original");
-
-/**
- * A Video Quality Enum.
- */
-export type Quality = z.infer;
diff --git a/front/packages/models/src/resources/season.ts b/front/packages/models/src/resources/season.ts
deleted file mode 100644
index 6229d56d..00000000
--- a/front/packages/models/src/resources/season.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { ImagesP, ResourceP } from "../traits";
-import { zdate } from "../utils";
-
-export const SeasonP = ResourceP("season").merge(ImagesP).extend({
- /**
- * The name of this season.
- */
- name: z.string(),
- /**
- * The number of this season. This can be set to 0 to indicate specials.
- */
- seasonNumber: z.number(),
- /**
- * A quick overview of this season.
- */
- overview: z.string().nullable(),
- /**
- * The starting air date of this season.
- */
- startDate: zdate().nullable(),
- /**
- * The ending date of this season.
- */
- endDate: zdate().nullable(),
- /**
- * The number of episodes available on kyoo of this season.
- */
- episodesCount: z.number(),
-});
-
-/**
- * A season of a Show.
- */
-export type Season = z.infer;
diff --git a/front/packages/models/src/resources/studio.ts b/front/packages/models/src/resources/studio.ts
deleted file mode 100644
index 15330a53..00000000
--- a/front/packages/models/src/resources/studio.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { ResourceP } from "../traits/resource";
-
-export const StudioP = ResourceP("studio").extend({
- /**
- * The name of this studio.
- */
- name: z.string(),
-});
-
-/**
- * A studio that make shows.
- */
-export type Studio = z.infer;
diff --git a/front/packages/models/src/resources/watchlist.ts b/front/packages/models/src/resources/watchlist.ts
deleted file mode 100644
index 3f6e0e4e..00000000
--- a/front/packages/models/src/resources/watchlist.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-import { MovieP } from "./movie";
-import { ShowP } from "./show";
-
-export const WatchlistP = z.union([
- /*
- * Either a show
- */
- ShowP,
- /*
- * Or a Movie
- */
- MovieP,
-]);
-
-/**
- * A item in the user's watchlist.
- */
-export type Watchlist = z.infer;
diff --git a/front/packages/models/src/traits/index.ts b/front/packages/models/src/traits/index.ts
deleted file mode 100644
index dfa86ed8..00000000
--- a/front/packages/models/src/traits/index.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-export * from "./resource";
-export * from "./images";
diff --git a/front/packages/models/src/traits/resource.ts b/front/packages/models/src/traits/resource.ts
deleted file mode 100644
index 87833f19..00000000
--- a/front/packages/models/src/traits/resource.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { z } from "zod";
-
-export const ResourceP = (kind: T) =>
- z.object({
- /**
- * A unique ID for this type of resource. This can't be changed and duplicates are not allowed.
- */
- id: z.string(),
-
- /**
- * A human-readable identifier that can be used instead of an ID. A slug must be unique for a type
- * of resource but it can be changed.
- */
- slug: z.string(),
-
- /**
- * The type of resource
- */
- kind: z.literal(kind),
- });
-
-/**
- * The base trait used to represent identifiable resources.
- */
-export type Resource = z.infer>;
diff --git a/front/src/models/index.ts b/front/src/models/index.ts
new file mode 100644
index 00000000..825e1633
--- /dev/null
+++ b/front/src/models/index.ts
@@ -0,0 +1,3 @@
+export * from "./page";
+export * from "./kyoo-error";
+export * from "./resources";
diff --git a/front/src/models/resources/collection.ts b/front/src/models/resources/collection.ts
new file mode 100644
index 00000000..1442db15
--- /dev/null
+++ b/front/src/models/resources/collection.ts
@@ -0,0 +1,24 @@
+import { z } from "zod";
+import { ImagesP, ResourceP } from "../traits";
+
+export const CollectionP = ResourceP("collection")
+ .merge(ImagesP)
+ .extend({
+ /**
+ * The title of this collection.
+ */
+ name: z.string(),
+ /**
+ * The summary of this show.
+ */
+ overview: z.string().nullable(),
+ })
+ .transform((x) => ({
+ ...x,
+ href: `/collection/${x.slug}`,
+ }));
+
+/**
+ * A class representing collections of show or movies.
+ */
+export type Collection = z.infer;
diff --git a/front/packages/models/src/resources/episode.base.ts b/front/src/models/resources/episode.base.ts
similarity index 58%
rename from front/packages/models/src/resources/episode.base.ts
rename to front/src/models/resources/episode.base.ts
index aa9280c6..117ba2e6 100644
--- a/front/packages/models/src/resources/episode.base.ts
+++ b/front/src/models/resources/episode.base.ts
@@ -1,26 +1,5 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
-import { ImagesP, imageFn } from "../traits";
-import { ResourceP } from "../traits/resource";
+import { ImagesP, ResourceP } from "../traits";
import { zdate } from "../utils";
export const BaseEpisodeP = ResourceP("episode")
@@ -62,11 +41,11 @@ export const BaseEpisodeP = ResourceP("episode")
/**
* The direct link to the unprocessed video (pristine quality).
*/
- direct: z.string().transform(imageFn),
+ direct: z.string(),
/**
* The link to an HLS master playlist containing all qualities available for this video.
*/
- hls: z.string().transform(imageFn).nullable(),
+ hls: z.string().nullable(),
}),
/**
* The id of the show containing this episode
diff --git a/front/packages/models/src/resources/episode.ts b/front/src/models/resources/episode.ts
similarity index 55%
rename from front/packages/models/src/resources/episode.ts
rename to front/src/models/resources/episode.ts
index bac4ee07..0d67f48e 100644
--- a/front/packages/models/src/resources/episode.ts
+++ b/front/src/models/resources/episode.ts
@@ -1,23 +1,3 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
import { BaseEpisodeP } from "./episode.base";
import { ShowP } from "./show";
diff --git a/front/src/models/resources/genre.ts b/front/src/models/resources/genre.ts
new file mode 100644
index 00000000..a1435860
--- /dev/null
+++ b/front/src/models/resources/genre.ts
@@ -0,0 +1,26 @@
+export enum Genre {
+ Action = "Action",
+ Adventure = "Adventure",
+ Animation = "Animation",
+ Comedy = "Comedy",
+ Crime = "Crime",
+ Documentary = "Documentary",
+ Drama = "Drama",
+ Family = "Family",
+ Fantasy = "Fantasy",
+ History = "History",
+ Horror = "Horror",
+ Music = "Music",
+ Mystery = "Mystery",
+ Romance = "Romance",
+ ScienceFiction = "ScienceFiction",
+ Thriller = "Thriller",
+ War = "War",
+ Western = "Western",
+ Kids = "Kids",
+ News = "News",
+ Reality = "Reality",
+ Soap = "Soap",
+ Talk = "Talk",
+ Politics = "Politics",
+}
diff --git a/front/src/models/resources/index.ts b/front/src/models/resources/index.ts
new file mode 100644
index 00000000..3960c22c
--- /dev/null
+++ b/front/src/models/resources/index.ts
@@ -0,0 +1,15 @@
+export * from "./library-item";
+export * from "./news";
+export * from "./show";
+export * from "./movie";
+export * from "./collection";
+export * from "./genre";
+export * from "./person";
+export * from "./studio";
+export * from "./episode";
+export * from "./season";
+export * from "./watch-info";
+export * from "./watch-status";
+export * from "./watchlist";
+export * from "./user";
+export * from "./server-info";
diff --git a/front/src/models/resources/library-item.ts b/front/src/models/resources/library-item.ts
new file mode 100644
index 00000000..bafd669a
--- /dev/null
+++ b/front/src/models/resources/library-item.ts
@@ -0,0 +1,24 @@
+import { z } from "zod";
+import { CollectionP } from "./collection";
+import { MovieP } from "./movie";
+import { ShowP } from "./show";
+
+export const LibraryItemP = z.union([
+ /*
+ * Either a Show
+ */
+ ShowP,
+ /*
+ * Or a Movie
+ */
+ MovieP,
+ /*
+ * Or a Collection
+ */
+ CollectionP,
+]);
+
+/**
+ * An item that can be contained by a Library (so a Show, a Movie or a Collection).
+ */
+export type LibraryItem = z.infer;
diff --git a/front/src/models/resources/metadata.ts b/front/src/models/resources/metadata.ts
new file mode 100644
index 00000000..593de0d9
--- /dev/null
+++ b/front/src/models/resources/metadata.ts
@@ -0,0 +1,21 @@
+import { z } from "zod";
+
+export const MetadataP = z.preprocess(
+ (x) =>
+ typeof x === "object" && x ? Object.fromEntries(Object.entries(x).filter(([_, v]) => v)) : x,
+ z.record(
+ z.object({
+ /*
+ * The ID of the resource on the external provider.
+ */
+ dataId: z.string(),
+
+ /*
+ * The URL of the resource on the external provider.
+ */
+ link: z.string().nullable(),
+ }),
+ ),
+);
+
+export type Metadata = z.infer;
diff --git a/front/packages/models/src/resources/movie.ts b/front/src/models/resources/movie.ts
similarity index 73%
rename from front/packages/models/src/resources/movie.ts
rename to front/src/models/resources/movie.ts
index 74108101..c0c186a5 100644
--- a/front/packages/models/src/resources/movie.ts
+++ b/front/src/models/resources/movie.ts
@@ -1,25 +1,5 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
-import { ImagesP, ResourceP, imageFn } from "../traits";
+import { ImagesP, ResourceP } from "../traits";
import { zdate } from "../utils";
import { CollectionP } from "./collection";
import { Genre } from "./genre";
@@ -90,12 +70,12 @@ export const MovieP = ResourceP("movie")
/**
* The direct link to the unprocessed video (pristine quality).
*/
- direct: z.string().transform(imageFn),
+ direct: z.string(),
/**
* The link to an HLS master playlist containing all qualities available for this video.
*/
- hls: z.string().transform(imageFn).nullable(),
+ hls: z.string().nullable(),
}),
/**
* The link to metadata providers that this show has.
diff --git a/front/src/models/resources/news.ts b/front/src/models/resources/news.ts
new file mode 100644
index 00000000..cb7f4cc5
--- /dev/null
+++ b/front/src/models/resources/news.ts
@@ -0,0 +1,19 @@
+import { z } from "zod";
+import { EpisodeP } from "./episode";
+import { MovieP } from "./movie";
+
+export const NewsP = z.union([
+ /*
+ * Either an episode
+ */
+ EpisodeP,
+ /*
+ * Or a Movie
+ */
+ MovieP,
+]);
+
+/**
+ * A new item added to kyoo.
+ */
+export type News = z.infer;
diff --git a/front/src/models/resources/person.ts b/front/src/models/resources/person.ts
new file mode 100644
index 00000000..7d666181
--- /dev/null
+++ b/front/src/models/resources/person.ts
@@ -0,0 +1,25 @@
+import { z } from "zod";
+import { ImagesP, ResourceP } from "../traits";
+
+export const PersonP = ResourceP("people").merge(ImagesP).extend({
+ /**
+ * The name of this person.
+ */
+ name: z.string(),
+ /**
+ * The type of work the person has done for the show. That can be something like "Actor",
+ * "Writer", "Music", "Voice Actor"...
+ */
+ type: z.string().optional(),
+
+ /**
+ * The role the People played. This is mostly used to inform witch character was played for actor
+ * and voice actors.
+ */
+ role: z.string().optional(),
+});
+
+/**
+ * A studio that make shows.
+ */
+export type Person = z.infer;
diff --git a/front/src/models/resources/quality.ts b/front/src/models/resources/quality.ts
new file mode 100644
index 00000000..305688a8
--- /dev/null
+++ b/front/src/models/resources/quality.ts
@@ -0,0 +1,20 @@
+import { z } from "zod";
+
+export const QualityP = z
+ .union([
+ z.literal("original"),
+ z.literal("8k"),
+ z.literal("4k"),
+ z.literal("1440p"),
+ z.literal("1080p"),
+ z.literal("720p"),
+ z.literal("480p"),
+ z.literal("360p"),
+ z.literal("240p"),
+ ])
+ .default("original");
+
+/**
+ * A Video Quality Enum.
+ */
+export type Quality = z.infer;
diff --git a/front/src/models/resources/season.ts b/front/src/models/resources/season.ts
new file mode 100644
index 00000000..b1f79c49
--- /dev/null
+++ b/front/src/models/resources/season.ts
@@ -0,0 +1,35 @@
+import { z } from "zod";
+import { ImagesP, ResourceP } from "../traits";
+import { zdate } from "../utils";
+
+export const SeasonP = ResourceP("season").merge(ImagesP).extend({
+ /**
+ * The name of this season.
+ */
+ name: z.string(),
+ /**
+ * The number of this season. This can be set to 0 to indicate specials.
+ */
+ seasonNumber: z.number(),
+ /**
+ * A quick overview of this season.
+ */
+ overview: z.string().nullable(),
+ /**
+ * The starting air date of this season.
+ */
+ startDate: zdate().nullable(),
+ /**
+ * The ending date of this season.
+ */
+ endDate: zdate().nullable(),
+ /**
+ * The number of episodes available on kyoo of this season.
+ */
+ episodesCount: z.number(),
+});
+
+/**
+ * A season of a Show.
+ */
+export type Season = z.infer;
diff --git a/front/packages/models/src/resources/server-info.ts b/front/src/models/resources/server-info.ts
similarity index 57%
rename from front/packages/models/src/resources/server-info.ts
rename to front/src/models/resources/server-info.ts
index 05fa90e6..a8259eb9 100644
--- a/front/packages/models/src/resources/server-info.ts
+++ b/front/src/models/resources/server-info.ts
@@ -1,26 +1,5 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { Platform } from "react-native";
import { z } from "zod";
-import { imageFn } from "..";
export const OidcInfoP = z.object({
/*
@@ -28,7 +7,7 @@ export const OidcInfoP = z.object({
*/
displayName: z.string(),
/*
- * A url returing a square logo for this provider.
+ * A url returning a square logo for this provider.
*/
logoUrl: z.string().nullable(),
});
@@ -71,7 +50,7 @@ export const ServerInfoP = z
provider,
{
...info,
- link: imageFn(`/auth/login/${provider}?redirectUrl=${baseUrl}/login/callback`),
+ link: `/auth/login/${provider}?redirectUrl=${baseUrl}/login/callback`,
},
]),
),
diff --git a/front/packages/models/src/resources/show.ts b/front/src/models/resources/show.ts
similarity index 76%
rename from front/packages/models/src/resources/show.ts
rename to front/src/models/resources/show.ts
index c6b52c54..5d5d68ea 100644
--- a/front/packages/models/src/resources/show.ts
+++ b/front/src/models/resources/show.ts
@@ -1,23 +1,3 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
import { ImagesP, ResourceP } from "../traits";
import { zdate } from "../utils";
diff --git a/front/src/models/resources/studio.ts b/front/src/models/resources/studio.ts
new file mode 100644
index 00000000..2d25e7d5
--- /dev/null
+++ b/front/src/models/resources/studio.ts
@@ -0,0 +1,14 @@
+import { z } from "zod";
+import { ResourceP } from "../traits";
+
+export const StudioP = ResourceP("studio").extend({
+ /**
+ * The name of this studio.
+ */
+ name: z.string(),
+});
+
+/**
+ * A studio that make shows.
+ */
+export type Studio = z.infer;
diff --git a/front/packages/models/src/resources/user.ts b/front/src/models/resources/user.ts
similarity index 61%
rename from front/packages/models/src/resources/user.ts
rename to front/src/models/resources/user.ts
index 0f087a10..50d96564 100644
--- a/front/packages/models/src/resources/user.ts
+++ b/front/src/models/resources/user.ts
@@ -1,26 +1,5 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
-import { imageFn } from "../traits/images";
-import { ResourceP } from "../traits/resource";
+import { ResourceP } from "../traits";
export const UserP = ResourceP("user")
.extend({
@@ -80,7 +59,7 @@ export const UserP = ResourceP("user")
})
.transform((x) => ({
...x,
- logo: imageFn(`/user/${x.slug}/logo`),
+ logo: `/user/${x.slug}/logo`,
isVerified: x.permissions.length > 0,
isAdmin: x.permissions?.includes("admin.write"),
}));
diff --git a/front/packages/models/src/resources/watch-info.ts b/front/src/models/resources/watch-info.ts
similarity index 82%
rename from front/packages/models/src/resources/watch-info.ts
rename to front/src/models/resources/watch-info.ts
index 4363aa0f..a4a3ca8b 100644
--- a/front/packages/models/src/resources/watch-info.ts
+++ b/front/src/models/resources/watch-info.ts
@@ -1,25 +1,4 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
-import { imageFn } from "../traits";
import { QualityP } from "./quality";
/**
@@ -90,7 +69,7 @@ export const SubtitleP = TrackP.extend({
/*
* The url of this track (only if this is a subtitle)..
*/
- link: z.string().transform(imageFn).nullable(),
+ link: z.string().nullable(),
/*
* Is this an external subtitle (as in stored in a different file)
*/
@@ -169,7 +148,7 @@ export const WatchInfoP = z
/**
* The list of fonts that can be used to display subtitles.
*/
- fonts: z.array(z.string().transform(imageFn)),
+ fonts: z.array(z.string()),
/**
* The list of chapters. See Chapter for more information.
*/
diff --git a/front/packages/models/src/resources/watch-status.ts b/front/src/models/resources/watch-status.ts
similarity index 64%
rename from front/packages/models/src/resources/watch-status.ts
rename to front/src/models/resources/watch-status.ts
index 43dff66d..3b23cd80 100644
--- a/front/packages/models/src/resources/watch-status.ts
+++ b/front/src/models/resources/watch-status.ts
@@ -1,23 +1,3 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
import { z } from "zod";
import { zdate } from "../utils";
import { BaseEpisodeP } from "./episode.base";
diff --git a/front/src/models/resources/watchlist.ts b/front/src/models/resources/watchlist.ts
new file mode 100644
index 00000000..550cf01f
--- /dev/null
+++ b/front/src/models/resources/watchlist.ts
@@ -0,0 +1,19 @@
+import { z } from "zod";
+import { MovieP } from "./movie";
+import { ShowP } from "./show";
+
+export const WatchlistP = z.union([
+ /*
+ * Either a show
+ */
+ ShowP,
+ /*
+ * Or a Movie
+ */
+ MovieP,
+]);
+
+/**
+ * A item in the user's watchlist.
+ */
+export type Watchlist = z.infer;
diff --git a/front/packages/models/src/traits/images.ts b/front/src/models/traits/images.ts
similarity index 50%
rename from front/packages/models/src/traits/images.ts
rename to front/src/models/traits/images.ts
index 57627532..f2a29380 100644
--- a/front/packages/models/src/traits/images.ts
+++ b/front/src/models/traits/images.ts
@@ -1,36 +1,11 @@
-/*
- * Kyoo - A portable and vast media library solution.
- * Copyright (c) Kyoo.
- *
- * See AUTHORS.md and LICENSE file in the project root for full license information.
- *
- * Kyoo is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * Kyoo is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Kyoo. If not, see .
- */
-
-import { Platform } from "react-native";
import { z } from "zod";
-import { lastUsedUrl } from "..";
-
-export const imageFn = (url: string) =>
- Platform.OS === "web" ? `/api${url}` : `${lastUsedUrl}${url}`;
export const Img = z.object({
source: z.string(),
blurhash: z.string(),
- low: z.string().transform(imageFn),
- medium: z.string().transform(imageFn),
- high: z.string().transform(imageFn),
+ low: z.string(),
+ medium: z.string(),
+ high: z.string(),
});
export const ImagesP = z.object({
diff --git a/front/src/models/traits/index.ts b/front/src/models/traits/index.ts
new file mode 100644
index 00000000..3c73c1fe
--- /dev/null
+++ b/front/src/models/traits/index.ts
@@ -0,0 +1,2 @@
+export * from "./resource";
+export * from "./images";
diff --git a/front/src/models/traits/resource.ts b/front/src/models/traits/resource.ts
new file mode 100644
index 00000000..005a3000
--- /dev/null
+++ b/front/src/models/traits/resource.ts
@@ -0,0 +1,25 @@
+import { z } from "zod";
+
+export const ResourceP = (kind: T) =>
+ z.object({
+ /**
+ * A unique ID for this type of resource. This can't be changed and duplicates are not allowed.
+ */
+ id: z.string(),
+
+ /**
+ * A human-readable identifier that can be used instead of an ID. A slug must be unique for a type
+ * of resource but it can be changed.
+ */
+ slug: z.string(),
+
+ /**
+ * The type of resource
+ */
+ kind: z.literal(kind),
+ });
+
+/**
+ * The base trait used to represent identifiable resources.
+ */
+export type Resource = z.infer>;
diff --git a/front/src/models/utils.ts b/front/src/models/utils.ts
new file mode 100644
index 00000000..d85e7087
--- /dev/null
+++ b/front/src/models/utils.ts
@@ -0,0 +1,3 @@
+import { z } from "zod";
+
+export const zdate = z.coerce.date;
diff --git a/front/src/providers.tsx b/front/src/providers.tsx
index 62741c4d..0245254b 100644
--- a/front/src/providers.tsx
+++ b/front/src/providers.tsx
@@ -1,6 +1,6 @@
import { QueryClientProvider } from "@tanstack/react-query";
import { type ReactNode, useState } from "react";
-import { createQueryClient } from "~/models/query";
+import { createQueryClient } from "~/query";
// import { useUserTheme } from "@kyoo/models";
import { ThemeSelector } from "~/primitives/theme";
diff --git a/front/src/models/query.tsx b/front/src/query.tsx
similarity index 98%
rename from front/src/models/query.tsx
rename to front/src/query.tsx
index d6c6c3e2..9ce6e00c 100644
--- a/front/src/models/query.tsx
+++ b/front/src/query.tsx
@@ -6,9 +6,8 @@ import {
} from "@tanstack/react-query";
import type { ComponentType, ReactElement } from "react";
import type { z } from "zod";
-import type { KyooError } from "./kyoo-error";
+import { type KyooError, type Page, Paged } from "~/models";
// import { getToken, getTokenWJ } from "./login";
-import { type Page, Paged } from "./page";
export let lastUsedUrl: string = null!;