forked from jordanlambrecht/tracker-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
228 lines (211 loc) · 5.1 KB
/
Copy pathtypes.ts
File metadata and controls
228 lines (211 loc) · 5.1 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
217
218
219
220
221
222
223
224
225
226
227
228
// src/lib/adapters/types.ts
import type { Agent as HttpAgent } from "node:http"
export interface TrackerStats {
username: string
group: string
uploadedBytes: bigint
downloadedBytes: bigint
ratio: number
bufferBytes: bigint
seedingCount: number
leechingCount: number
seedbonus: number | null
hitAndRuns: number | null
requiredRatio: number | null
warned: boolean | null
freeleechTokens: number | null
remoteUserId?: number
joinedDate?: string
lastAccessDate?: string
shareScore?: number
avatarUrl?: string
platformMeta?:
| GGnPlatformMeta
| GazellePlatformMeta
| NebulancePlatformMeta
| MamPlatformMeta
| AvistazPlatformMeta
| DigitalCorePlatformMeta
}
export interface GGnPlatformMeta {
achievements?: {
userLevel: string
nextLevel: string
totalPoints: number
pointsToNextLvl: number
}
buffs?: Record<string, number>
donor?: boolean
parked?: boolean
enabled?: boolean
invites?: number
onIRC?: boolean
hourlyGold?: number
snatched?: number
uniqueSnatched?: number
}
export interface GazelleRanks {
uploaded: number
downloaded: number
uploads: number
requests: number
bounty: number
posts: number
artists: number
overall: number
}
export interface GazelleCommunity {
posts: number
torrentComments: number
artistComments: number
collageComments: number
requestComments: number
collagesStarted: number
collagesContrib: number
requestsFilled: number
requestsVoted: number
perfectFlacs: number
uploaded: number
groups: number
snatched: number
invited: number
bountyEarned: number | null
bountySpent: number | null
}
export interface GazellePlatformMeta {
donor?: boolean
enabled?: boolean
paranoia?: number
paranoiaText?: string
ranks?: GazelleRanks
community?: GazelleCommunity
notifications?: {
messages: number
notifications: number
newAnnouncement: boolean
newBlog: boolean
}
giftTokens?: number
meritTokens?: number
}
export interface NebulancePlatformMeta {
snatched?: number
grabbed?: number
forumPosts?: number
invites?: number
}
export interface MamPlatformMeta {
vipUntil?: string
connectable?: string
unsatisfiedCount?: number
unsatisfiedLimit?: number
inactiveSatisfiedCount?: number
seedingHnrCount?: number
inactiveUnsatisfiedCount?: number
trackerErrorCount?: number
recentlyDeleted?: number
unreadPMs?: number
openTickets?: number
pendingRequests?: number
unreadTopics?: number
}
export interface DigitalCorePlatformMeta {
donor?: boolean
seedboxDonor?: boolean
parked?: boolean
enabled?: boolean
invites?: number
invitees?: number
leechBonus?: number
uploadedReal?: number
downloadedReal?: number
torrents?: number
requests?: number
forumPosts?: number
torrentComments?: number
hnr?: number
hnrWarned?: boolean
downloadBan?: boolean
uploadBan?: boolean
connectable?: boolean
crown?: boolean
skull?: boolean
pokal?: boolean
coin?: boolean
hearts?: number
}
export interface AvistazPlatformMeta {
donor?: boolean
vipExpiry?: string | null
invites?: number
canDownload?: boolean
canUpload?: boolean
totalUploads?: number
totalDownloads?: number
reseedRequests?: number
twoFactorEnabled?: boolean
bonusPerHour?: number
bonusBreakdown?: {
totalTorrents: { count: number; points: number }
oldTorrents: { count: number; points: number }
bigTorrents: { count: number; points: number }
hugeTorrents: { count: number; points: number }
}
}
/** Union of all platform-specific metadata types */
export type PlatformMeta =
| GGnPlatformMeta
| GazellePlatformMeta
| NebulancePlatformMeta
| MamPlatformMeta
| AvistazPlatformMeta
| DigitalCorePlatformMeta
/** Maps platformType string → the corresponding PlatformMeta variant */
export interface PlatformMetaMap {
ggn: GGnPlatformMeta
gazelle: GazellePlatformMeta
nebulance: NebulancePlatformMeta
mam: MamPlatformMeta
avistaz: AvistazPlatformMeta
digitalcore: DigitalCorePlatformMeta
}
/**
* Type-safe narrowing of PlatformMeta using the existing platformType discriminant.
* Returns the narrowed meta if `ctx.tracker.platformType` matches, otherwise `null`.
*/
export function metaFor<P extends keyof PlatformMetaMap>(
ctx: { tracker: { platformType: string }; meta: PlatformMeta | null },
platform: P
): PlatformMetaMap[P] | null {
if (!ctx.meta || ctx.tracker.platformType !== platform) return null
return ctx.meta as PlatformMetaMap[P]
}
export type GazelleAuthStyle = "token" | "raw"
export type Unit3dAuthStyle = "bearer" | "query"
export interface FetchOptions {
proxyAgent?: HttpAgent
remoteUserId?: number
authStyle?: GazelleAuthStyle
unit3dAuthStyle?: Unit3dAuthStyle
enrich?: boolean
}
export interface DebugApiCall {
label: string
endpoint: string
data: unknown | null
error: string | null
}
export interface TrackerAdapter {
fetchStats(
baseUrl: string,
apiToken: string,
apiPath: string,
options?: FetchOptions
): Promise<TrackerStats>
fetchRaw?(
baseUrl: string,
apiToken: string,
apiPath: string,
options?: FetchOptions
): Promise<DebugApiCall[]>
}