diff --git a/front/src/models/index.ts b/front/src/models/index.ts new file mode 100644 index 00000000..6a3d05fe --- /dev/null +++ b/front/src/models/index.ts @@ -0,0 +1,24 @@ +/* + * 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 type { Page } from "./page"; +export type { KyooErrors } from "./kyoo-errors"; +export * from "./traits"; +export * from "./resources"; diff --git a/front/src/models/kyoo-errors.ts b/front/src/models/kyoo-errors.ts new file mode 100644 index 00000000..329fc7bb --- /dev/null +++ b/front/src/models/kyoo-errors.ts @@ -0,0 +1,31 @@ +/* + * 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 . + */ + +/** + * The list of errors that where made in the request. + */ +export interface KyooErrors { + /** + * The list of errors that where made in the request. + * + * @example `["InvalidFilter: no field 'startYear' on a collection"]` + */ + errors: string[]; +} diff --git a/front/src/models/page.ts b/front/src/models/page.ts new file mode 100644 index 00000000..bd2c28db --- /dev/null +++ b/front/src/models/page.ts @@ -0,0 +1,55 @@ +/* + * 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 . + */ + +/** + * A page of resource that contains information about the pagination of resources. + */ +export interface Page { + /** + * The link of the current page. + * + * @format uri + */ + this: string; + + /** + * The link of the first page. + * + * @format uri + */ + first: string; + + /** + * The link of the next page. + * + * @format uri + */ + next?: string; + + /** + * The number of items in the current page. + */ + count: number; + + /** + * The list of items in the page. + */ + items: T[]; +} diff --git a/front/src/models/resources/collection.ts b/front/src/models/resources/collection.ts new file mode 100644 index 00000000..7646cf9a --- /dev/null +++ b/front/src/models/resources/collection.ts @@ -0,0 +1,36 @@ +/* + * 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 { Images, Resource } from "../traits"; + +/** + * A class representing collections of show or movies. + */ +export interface Collection extends Resource, Images { + /** + * The name of this collection. + */ + name: string; + + /** + * The description of this collection. + */ + overview: string; +} diff --git a/front/src/models/resources/index.ts b/front/src/models/resources/index.ts new file mode 100644 index 00000000..38a8af5f --- /dev/null +++ b/front/src/models/resources/index.ts @@ -0,0 +1,25 @@ +/* + * 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"; +export * from "./library-item"; +export * from "./show"; +export * from "./movie"; +export * from "./collection"; diff --git a/front/src/models/resources/library-item.ts b/front/src/models/resources/library-item.ts new file mode 100644 index 00000000..e8ead6d6 --- /dev/null +++ b/front/src/models/resources/library-item.ts @@ -0,0 +1,40 @@ +/* + * 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 { Collection } from "./collection"; +import { Movie } from "./movie"; +import { Show } from "./show"; + +/** + * An item that can be contained by a Library (so a Show, a Movie or a Collection). + */ +export type LibraryItem = + | (Show & { type: ItemType.Show }) + | (Movie & { type: ItemType.Movie }) + | (Collection & { type: ItemType.Collection }); + +/** + * The type of item, ether a show, a movie or a collection. + */ +export enum ItemType { + Show = 0, + Movie = 1, + Collection = 2, +} diff --git a/front/src/models/resources/library.ts b/front/src/models/resources/library.ts new file mode 100644 index 00000000..cf1f0097 --- /dev/null +++ b/front/src/models/resources/library.ts @@ -0,0 +1,36 @@ +/* + * 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 { Resource } from "../traits/resource"; + +/** + * The library that will contain Shows, Collections... + */ +export interface Library extends Resource { + /** + * The name of this library. + */ + name: string; + + /** + * The list of paths that this library is responsible for. This is mainly used by the Scan task. + */ + paths: string[]; +} diff --git a/front/src/models/resources/movie.ts b/front/src/models/resources/movie.ts new file mode 100644 index 00000000..0f7f4505 --- /dev/null +++ b/front/src/models/resources/movie.ts @@ -0,0 +1,51 @@ +/* + * 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 { Resource, Images } from "../traits"; + +/** + * A series or a movie. + */ +export interface Movie extends Resource, Images { + /** + * The title of this show. + */ + name: string; + + /** + * The list of alternative titles of this movie. + */ + aliases: string[]; + + /** + * The summary of this show. + */ + overview: string; + + /** + * Is this movie aired or planned + */ + isPlanned: boolean; + + /** + * The date this mavie aired. It can also be null if this is unknown. + */ + airDate: Date | null; +} diff --git a/front/src/models/resources/show.ts b/front/src/models/resources/show.ts new file mode 100644 index 00000000..ff0e90a4 --- /dev/null +++ b/front/src/models/resources/show.ts @@ -0,0 +1,66 @@ +/* + * 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 { Resource, Images } from "../traits"; + +/** + * A series or a movie. + */ +export interface Show extends Resource, Images { + /** + * The title of this show. + */ + name: string; + + /** + * The list of alternative titles of this show. + */ + aliases: string[]; + + /** + * The summary of this show. + */ + overview: string; + + /** + * Is this show airing, not aired yet or finished? + */ + status: Status; + + /** + * The date this show started airing. It can be null if this is unknown. + */ + startAir: Date | null; + + /** + * The date this show finished airing. It can also be null if this is unknown. + */ + endAir: Date | null; +} + +/** + * The enum containing show's status. + */ +export enum Status { + Unknown = 0, + Finished = 1, + Airing = 2, + Planned = 3, +} diff --git a/front/src/models/traits/images.ts b/front/src/models/traits/images.ts new file mode 100644 index 00000000..8fba648a --- /dev/null +++ b/front/src/models/traits/images.ts @@ -0,0 +1,55 @@ +/* + * 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 . + */ + +/** + * Base traits for items that has image resources. + */ +export interface Images { + /** + * An url to the poster of this resource. If this resource does not have an image, the link will + * be null. If the kyoo's instance is not capable of handling this kind of image for the specific + * resource, this field won't be present. + */ + poster?: string; + + /** + * An url to the thumbnail of this resource. If this resource does not have an image, the link + * will be null. If the kyoo's instance is not capable of handling this kind of image for the + * specific resource, this field won't be present. + */ + thumbnail?: string; + + /** + * An url to the logo of this resource. If this resource does not have an image, the link will be + * null. If the kyoo's instance is not capable of handling this kind of image for the specific + * resource, this field won't be present. + */ + logo?: string; + + /** + * An url to the thumbnail of this resource. If this resource does not have an image, the link + * will be null. If the kyoo's instance is not capable of handling this kind of image for the + * specific resource, this field won't be present. + */ + + trailer?: string; +}; + +export const imageList = ["poster", "thumbnail", "logo", "trailer"]; diff --git a/front/src/models/traits/index.ts b/front/src/models/traits/index.ts new file mode 100644 index 00000000..dfa86ed8 --- /dev/null +++ b/front/src/models/traits/index.ts @@ -0,0 +1,22 @@ +/* + * 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/src/models/traits/resource.ts b/front/src/models/traits/resource.ts new file mode 100644 index 00000000..78372b0b --- /dev/null +++ b/front/src/models/traits/resource.ts @@ -0,0 +1,35 @@ +/* + * 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 . + */ + +/** + * The base trait used to represent identifiable resources. + */ +export interface Resource { + /** + * A unique ID for this type of resource. This can't be changed and duplicates are not allowed. + */ + id: number; + + /** + * 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: string; +}