Merge branch 'feat/migration-to-leveldb' into feature/custom-themes

This commit is contained in:
Hachi-R 2025-01-23 15:45:23 -03:00
parent 44aed56461
commit 6bf049d136
131 changed files with 1918 additions and 2597 deletions

176
src/types/download.types.ts Normal file
View file

@ -0,0 +1,176 @@
import type { Download } from "./level.types";
export type DownloadStatus =
| "active"
| "waiting"
| "paused"
| "error"
| "complete"
| "seeding"
| "removed";
export interface DownloadProgress {
downloadSpeed: number;
timeRemaining: number;
numPeers: number;
numSeeds: number;
isDownloadingMetadata: boolean;
isCheckingFiles: boolean;
progress: number;
gameId: string;
download: Download;
}
/* Torbox */
export interface TorBoxUser {
id: number;
email: string;
plan: string;
expiration: string;
}
export interface TorBoxUserRequest {
success: boolean;
detail: string;
error: string;
data: TorBoxUser;
}
export interface TorBoxFile {
id: number;
md5: string;
s3_path: string;
name: string;
size: number;
mimetype: string;
short_name: string;
}
export interface TorBoxTorrentInfo {
id: number;
hash: string;
created_at: string;
updated_at: string;
magnet: string;
size: number;
active: boolean;
cached: boolean;
auth_id: string;
download_state:
| "downloading"
| "uploading"
| "stalled (no seeds)"
| "paused"
| "completed"
| "cached"
| "metaDL"
| "checkingResumeData";
seeds: number;
ratio: number;
progress: number;
download_speed: number;
upload_speed: number;
name: string;
eta: number;
files: TorBoxFile[];
}
export interface TorBoxTorrentInfoRequest {
success: boolean;
detail: string;
error: string;
data: TorBoxTorrentInfo[];
}
export interface TorBoxAddTorrentRequest {
success: boolean;
detail: string;
error: string;
data: {
torrent_id: number;
name: string;
hash: string;
};
}
export interface TorBoxRequestLinkRequest {
success: boolean;
detail: string;
error: string;
data: string;
}
/* Real-Debrid */
export interface RealDebridUnrestrictLink {
id: string;
filename: string;
mimeType: string;
filesize: number;
link: string;
host: string;
host_icon: string;
chunks: number;
crc: number;
download: string;
streamable: number;
}
export interface RealDebridAddMagnet {
id: string;
// URL of the created resource
uri: string;
}
export interface RealDebridTorrentInfo {
id: string;
filename: string;
original_filename: string;
hash: string;
bytes: number;
original_bytes: number;
host: string;
split: number;
progress: number;
status:
| "magnet_error"
| "magnet_conversion"
| "waiting_files_selection"
| "queued"
| "downloading"
| "downloaded"
| "error"
| "virus"
| "compressing"
| "uploading"
| "dead";
added: string;
files: {
id: number;
path: string;
bytes: number;
selected: number;
}[];
links: string[];
ended: string;
speed: number;
seeders: number;
}
export interface RealDebridUser {
id: number;
username: string;
email: string;
points: number;
locale: string;
avatar: string;
type: string;
premium: number;
expiration: string;
}
/* Torrent */
export interface SeedingStatus {
gameId: string;
status: DownloadStatus;
uploadSpeed: number;
}

21
src/types/game.types.ts Normal file
View file

@ -0,0 +1,21 @@
export type GameShop = "steam" | "epic";
export interface UnlockedAchievement {
name: string;
unlockTime: number;
}
export interface SteamAchievement {
name: string;
displayName: string;
description?: string;
icon: string;
icongray: string;
hidden: boolean;
points?: number;
}
export interface UserAchievement extends SteamAchievement {
unlocked: boolean;
unlockTime: number | null;
}

View file

@ -1,16 +1,7 @@
import type { Cracker, DownloadSourceStatus, Downloader } from "@shared";
import type { SteamAppDetails } from "./steam.types";
export type GameStatus =
| "active"
| "waiting"
| "paused"
| "error"
| "complete"
| "seeding"
| "removed";
export type GameShop = "steam" | "epic";
import type { Download, Game, Subscription } from "./level.types";
import type { GameShop } from "./game.types";
export type FriendRequestAction = "ACCEPTED" | "REFUSED" | "CANCEL";
@ -31,48 +22,6 @@ export interface GameRepack {
updatedAt: Date;
}
export interface AchievementData {
name: string;
displayName: string;
description?: string;
icon: string;
icongray: string;
hidden: boolean;
points?: number;
}
export interface UserAchievement {
name: string;
hidden: boolean;
displayName: string;
points?: number;
description?: string;
unlocked: boolean;
unlockTime: number | null;
icon: string;
icongray: string;
}
export interface RemoteUnlockedAchievement {
name: string;
hidden: boolean;
icon: string;
displayName: string;
description?: string;
unlockTime: number;
}
export interface GameAchievement {
name: string;
hidden: boolean;
displayName: string;
description?: string;
unlocked: boolean;
unlockTime: number | null;
icon: string;
icongray: string;
}
export type ShopDetails = SteamAppDetails & {
objectId: string;
};
@ -95,82 +44,15 @@ export interface UserGame {
achievementsPointsEarnedSum: number;
}
export interface DownloadQueue {
id: number;
createdAt: Date;
updatedAt: Date;
}
/* Used by the library */
export interface Game {
id: number;
title: string;
iconUrl: string;
status: GameStatus | null;
folderName: string;
downloadPath: string | null;
progress: number;
bytesDownloaded: number;
playTimeInMilliseconds: number;
downloader: Downloader;
winePrefixPath: string | null;
executablePath: string | null;
launchOptions: string | null;
lastTimePlayed: Date | null;
uri: string | null;
fileSize: number;
objectID: string;
shop: GameShop;
downloadQueue: DownloadQueue | null;
shouldSeed: boolean;
createdAt: Date;
updatedAt: Date;
}
export type LibraryGame = Omit<Game, "repacks">;
export interface GameRunning {
id?: number;
id: string;
title: string;
iconUrl: string | null;
objectID: string;
objectId: string;
shop: GameShop;
sessionDurationInMillis: number;
}
export interface DownloadProgress {
downloadSpeed: number;
timeRemaining: number;
numPeers: number;
numSeeds: number;
isDownloadingMetadata: boolean;
isCheckingFiles: boolean;
progress: number;
gameId: number;
game: LibraryGame;
}
export interface SeedingStatus {
gameId: number;
status: GameStatus;
uploadSpeed: number;
}
export interface UserPreferences {
downloadsPath: string | null;
language: string;
downloadNotificationsEnabled: boolean;
repackUpdatesNotificationsEnabled: boolean;
achievementNotificationsEnabled: boolean;
realDebridApiToken: string | null;
preferQuitInsteadOfHiding: boolean;
runAtStartup: boolean;
startMinimized: boolean;
disableNsfwAlert: boolean;
seedAfterDownloadComplete: boolean;
showHiddenAchievementsDescription: boolean;
}
export interface Steam250Game {
title: string;
objectId: string;
@ -248,16 +130,6 @@ export interface UserProfileCurrentGame extends Omit<GameRunning, "objectId"> {
export type ProfileVisibility = "PUBLIC" | "PRIVATE" | "FRIENDS";
export type SubscriptionStatus = "active" | "pending" | "cancelled";
export interface Subscription {
id: string;
status: SubscriptionStatus;
plan: { id: string; name: string };
expiresAt: string | null;
paymentMethod: "pix" | "paypal";
}
export interface UserDetails {
id: string;
username: string;
@ -353,11 +225,6 @@ export interface UserStats {
unlockedAchievementSum?: number;
}
export interface UnlockedAchievement {
name: string;
unlockTime: number;
}
export interface AchievementFile {
type: Cracker;
filePath: string;
@ -416,8 +283,14 @@ export interface CatalogueSearchPayload {
developers: string[];
}
export interface LibraryGame extends Game {
id: string;
download: Download | null;
}
export * from "./game.types";
export * from "./steam.types";
export * from "./real-debrid.types";
export * from "./download.types";
export * from "./ludusavi.types";
export * from "./how-long-to-beat.types";
export * from "./torbox.types";
export * from "./level.types";

81
src/types/level.types.ts Normal file
View file

@ -0,0 +1,81 @@
import type { Downloader } from "@shared";
import type {
GameShop,
SteamAchievement,
UnlockedAchievement,
} from "./game.types";
import type { DownloadStatus } from "./download.types";
export type SubscriptionStatus = "active" | "pending" | "cancelled";
export interface Subscription {
id: string;
status: SubscriptionStatus;
plan: { id: string; name: string };
expiresAt: string | null;
paymentMethod: "pix" | "paypal";
}
export interface Auth {
accessToken: string;
refreshToken: string;
tokenExpirationTimestamp: number;
}
export interface User {
id: string;
displayName: string;
profileImageUrl: string | null;
backgroundImageUrl: string | null;
subscription: Subscription | null;
}
export interface Game {
title: string;
iconUrl: string | null;
playTimeInMilliseconds: number;
lastTimePlayed: Date | null;
objectId: string;
shop: GameShop;
remoteId: string | null;
isDeleted: boolean;
winePrefixPath?: string | null;
executablePath?: string | null;
launchOptions?: string | null;
}
export interface Download {
shop: GameShop;
objectId: string;
uri: string;
folderName: string | null;
downloadPath: string;
progress: number;
downloader: Downloader;
bytesDownloaded: number;
fileSize: number | null;
shouldSeed: boolean;
status: DownloadStatus | null;
queued: boolean;
timestamp: number;
}
export interface GameAchievement {
achievements: SteamAchievement[];
unlockedAchievements: UnlockedAchievement[];
}
export interface UserPreferences {
downloadsPath: string | null;
language: string;
realDebridApiToken: string | null;
preferQuitInsteadOfHiding: boolean;
runAtStartup: boolean;
startMinimized: boolean;
disableNsfwAlert: boolean;
seedAfterDownloadComplete: boolean;
showHiddenAchievementsDescription: boolean;
downloadNotificationsEnabled: boolean;
repackUpdatesNotificationsEnabled: boolean;
achievementNotificationsEnabled: boolean;
}

View file

@ -1,66 +0,0 @@
export interface RealDebridUnrestrictLink {
id: string;
filename: string;
mimeType: string;
filesize: number;
link: string;
host: string;
host_icon: string;
chunks: number;
crc: number;
download: string;
streamable: number;
}
export interface RealDebridAddMagnet {
id: string;
// URL of the created resource
uri: string;
}
export interface RealDebridTorrentInfo {
id: string;
filename: string;
original_filename: string;
hash: string;
bytes: number;
original_bytes: number;
host: string;
split: number;
progress: number;
status:
| "magnet_error"
| "magnet_conversion"
| "waiting_files_selection"
| "queued"
| "downloading"
| "downloaded"
| "error"
| "virus"
| "compressing"
| "uploading"
| "dead";
added: string;
files: {
id: number;
path: string;
bytes: number;
selected: number;
}[];
links: string[];
ended: string;
speed: number;
seeders: number;
}
export interface RealDebridUser {
id: number;
username: string;
email: string;
points: number;
locale: string;
avatar: string;
type: string;
premium: number;
expiration: string;
}

View file

@ -1,77 +0,0 @@
export interface TorBoxUser {
id: number;
email: string;
plan: string;
expiration: string;
}
export interface TorBoxUserRequest {
success: boolean;
detail: string;
error: string;
data: TorBoxUser;
}
export interface TorBoxFile {
id: number;
md5: string;
s3_path: string;
name: string;
size: number;
mimetype: string;
short_name: string;
}
export interface TorBoxTorrentInfo {
id: number;
hash: string;
created_at: string;
updated_at: string;
magnet: string;
size: number;
active: boolean;
cached: boolean;
auth_id: string;
download_state:
| "downloading"
| "uploading"
| "stalled (no seeds)"
| "paused"
| "completed"
| "cached"
| "metaDL"
| "checkingResumeData";
seeds: number;
ratio: number;
progress: number;
download_speed: number;
upload_speed: number;
name: string;
eta: number;
files: TorBoxFile[];
}
export interface TorBoxTorrentInfoRequest {
success: boolean;
detail: string;
error: string;
data: TorBoxTorrentInfo[];
}
export interface TorBoxAddTorrentRequest {
success: boolean;
detail: string;
error: string;
data: {
torrent_id: number;
name: string;
hash: string;
};
}
export interface TorBoxRequestLinkRequest {
success: boolean;
detail: string;
error: string;
data: string;
}