-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.ts
More file actions
216 lines (196 loc) · 5.28 KB
/
api.ts
File metadata and controls
216 lines (196 loc) · 5.28 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// src/types/api.ts
export type {
AvistazPlatformMeta,
DigitalCorePlatformMeta,
GazellePlatformMeta,
GazelleRanks,
GGnPlatformMeta,
MamPlatformMeta,
NebulancePlatformMeta,
PlatformMeta,
} from "@/lib/adapters/types"
import type { PlatformType } from "@/lib/adapters/constants"
import type { PlatformMeta } from "@/lib/adapters/types"
import type { DownloadClientRow, NotificationTargetRow } from "@/lib/db/schema"
import type { SystemEvent } from "@/lib/events"
import type { NotificationThresholds } from "@/lib/notifications/types"
/** Fields shared between TrackerLatestStats and Snapshot */
interface TrackerStatFields {
ratio: number | null
seedingCount: number | null
leechingCount: number | null
requiredRatio: number | null
warned: boolean | null
freeleechTokens: number | null
hitAndRuns: number | null
seedbonus: number | null
shareScore: number | null
username: string | null
group: string | null
}
export interface TrackerLatestStats extends TrackerStatFields {
uploadedBytes: string | null
downloadedBytes: string | null
bufferBytes: string | null
}
export interface TrackerSummary {
id: number
name: string
baseUrl: string
platformType: PlatformType
isActive: boolean
lastPolledAt: string | null
lastError: string | null
lastErrorAt: string | null
consecutiveFailures: number
pausedAt: string | null
userPausedAt: string | null
color: string
qbtTag: string | null
mouseholeUrl: string | null
useProxy: boolean
countCrossSeedUnsatisfied: boolean
hideUnreadBadges: boolean
isFavorite: boolean
sortOrder: number | null
joinedAt: string | null
lastAccessAt: string | null
remoteUserId: number | null
platformMeta: PlatformMeta | null
createdAt: string
latestStats: TrackerLatestStats | null
}
export interface Snapshot extends TrackerStatFields {
polledAt: string
uploadedBytes: string
downloadedBytes: string
bufferBytes: string
isManual: boolean
}
export interface TagGroupMember {
id: number
groupId: number
tag: string
label: string
color: string | null
sortOrder: number
}
export type TagGroupChartType = "bar" | "donut" | "treemap" | "numbers"
export const VALID_CHART_TYPES = ["bar", "donut", "treemap", "numbers"] as const
export interface TagGroup {
id: number
name: string
emoji: string | null
chartType: TagGroupChartType
description: string | null
sortOrder: number
countUnmatched: boolean
members: TagGroupMember[]
}
export interface QbitmanageTagEntry {
enabled: boolean
tag: string
}
export interface QbitmanageTagConfig {
issue: QbitmanageTagEntry
minTimeNotReached: QbitmanageTagEntry
noHardlinks: QbitmanageTagEntry
minSeedsNotMet: QbitmanageTagEntry
lastActiveLimitNotReached: QbitmanageTagEntry
lastActiveNotReached: QbitmanageTagEntry
}
export interface DashboardSettings {
showHealthIndicators: boolean
showLoginTimers: boolean
showTodayAtAGlance: boolean
}
export interface TodayAtAGlance {
fleet: {
uploadDelta: string
downloadDelta: string
bufferDelta: string
ratioChange: number | null
seedbonusChange: number | null
uploadDeltaYesterday: string | null
downloadDeltaYesterday: string | null
bufferDeltaYesterday: string | null
}
trackers: Array<{
id: number
name: string
color: string | null
uploadDelta: string
downloadDelta: string
bufferDelta: string
}>
activity: {
addedToday: number
completedToday: number
}
movers: {
topUploaders: Array<{
hash: string
name: string
qbtTag: string | null
trackerColor: string | null
clientName: string | null
uploadedToday: string
}>
topDownloaders: Array<{
hash: string
name: string
qbtTag: string | null
trackerColor: string | null
clientName: string | null
downloadedToday: string
}>
}
trackerLastUpdated: string | null
clientLastUpdated: string | null
}
/** Response from GET /api/auth/status */
/** Response from GET /api/settings/events */
export interface EventsPageResponse {
events: SystemEvent[]
total: number
hasMore: boolean
logSizeBytes?: number
}
/** Upload/download delta pair returned by computeDelta() */
export type DeltaDisplay = { uploaded: string; downloaded: string } | null
/** Time range selection for snapshot queries */
export type DayRange = 0 | 1 | 7 | 30 | 90 | 365
export const DASHBOARD_SETTINGS_DEFAULTS: DashboardSettings = {
showHealthIndicators: true,
showLoginTimers: true,
showTodayAtAGlance: true,
}
/** API response shape for download clients (credentials stripped, dates serialized) */
export type SafeDownloadClient = Omit<
DownloadClientRow,
| "encryptedUsername"
| "encryptedPassword"
| "cachedTorrents"
| "cachedTorrentsAt"
| "lastPolledAt"
| "errorSince"
| "createdAt"
| "updatedAt"
> & {
hasCredentials: boolean
lastPolledAt: string | null
errorSince: string | null
createdAt: string
updatedAt: string
}
/** API response shape for notification targets (encrypted config stripped, dates serialized) */
export type SafeNotificationTarget = Omit<
NotificationTargetRow,
"encryptedConfig" | "lastDeliveryAt" | "createdAt" | "updatedAt" | "thresholds"
> & {
hasConfig: boolean
thresholds: NotificationThresholds | null
lastDeliveryAt: string | null
createdAt: string
updatedAt: string
}