-
Notifications
You must be signed in to change notification settings - Fork 1
/
task.ts
96 lines (84 loc) · 2.1 KB
/
task.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
export enum TaskType {
Download,
ExportZip,
UpdateMeiliSearchData,
FixGalleryPage,
Import,
UpdateTagTranslation,
}
export type Task<T extends TaskType = TaskType> = {
id: number | bigint;
type: T;
gid: number | bigint;
token: string;
pid: number | bigint;
details: string | null;
};
export type TaskDownloadSingleProgress = {
index: number;
token: string;
name: string;
width: number;
height: number;
is_original: boolean;
total: number;
started: number;
downloaded: number;
speed: number;
last_updated: number;
};
export type TaskDownloadProgess = {
downloaded_page: number;
failed_page: number;
total_page: number;
started: number;
downloaded_bytes: number;
details: TaskDownloadSingleProgress[];
};
export type TaskExportZipProgress = {
added_page: number;
total_page: number;
};
export type TaskUpdateMeiliSearchDataProgress = {
total_gallery: number | bigint;
updated_gallery: number;
};
export type TaskFixGalleryPageProgress = {
total_gallery: number | bigint;
checked_gallery: number;
};
export type TaskImportProgress = {
imported_page: number;
failed_page: number;
total_page: number;
};
export type TaskUpdateTagTranslationProgress = {
added_tag: number;
total_tag: number;
};
export type TaskProgressBasicType = {
[TaskType.Download]: TaskDownloadProgess;
[TaskType.ExportZip]: TaskExportZipProgress;
[TaskType.UpdateMeiliSearchData]: TaskUpdateMeiliSearchDataProgress;
[TaskType.FixGalleryPage]: TaskFixGalleryPageProgress;
[TaskType.Import]: TaskImportProgress;
[TaskType.UpdateTagTranslation]: TaskUpdateTagTranslationProgress;
};
export type TaskProgress<T extends TaskType = TaskType> = {
type: T;
task_id: number | bigint;
detail: TaskProgressBasicType[T];
};
export enum TaskStatus {
Wait,
Running,
Finished,
Failed,
}
export type TaskDetail<T extends TaskType = TaskType> = {
base: Task<T>;
progress?: TaskProgressBasicType[T];
status: TaskStatus;
error?: string;
fataled?: boolean;
};