forked from odota/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.d.ts
467 lines (418 loc) · 9.3 KB
/
global.d.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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
declare module 'simple-vdf';
declare module 'dotaconstants';
declare namespace Express {
interface Locals {
queryObj: QueryObj;
}
interface User {
account_id: string;
}
}
type QueryObj = {
project: (keyof ParsedPlayerMatch)[];
projectAll?: boolean;
filter?: Map<string, (string | number)[]>;
sort?: keyof ParsedPlayerMatch;
// Number of results to return after client filter/sort
limit?: number;
offset?: number;
having?: number;
// Number of results to fetch from the database (before filter/sort)
dbLimit?: number;
isPrivate?: boolean;
cacheSeconds?: number;
};
type AnyDict = Record<string, any>;
type NumberDict = Record<string, number>;
type BooleanDict = Record<string, boolean>;
type ErrorCb = (
err?: Error | null | undefined | string | unknown,
result?: any,
) => void;
type Match = {
match_id: number;
players: Player[];
start_time: number;
duration: number;
leagueid?: number;
radiant_win: boolean;
lobby_type: number;
game_mode: number;
cluster: number;
patch?: number;
region?: number;
radiant_team_id?: number;
dire_team_id?: number;
picks_bans?: any[];
human_players: number;
// Computed if we have data
replay_url?: string;
replay_salt?: number;
// Added at insert
average_rank?: number;
// Parsed match metadata from .meta file
metadata?: any;
od_data?: GetMatchDataMetadata | null;
};
type GetMatchDataMetadata = {
has_api: boolean;
has_gcdata: boolean;
has_parsed: boolean;
backfill_api?: boolean;
backfill_gc?: boolean;
archive?: boolean;
};
interface LiveMatch extends Match {
lobby_id: string;
}
interface ParsedMatch extends Match {
players: ParsedPlayer[];
version: number;
chat: any[];
cosmetics: any;
objectives: any[];
radiant_gold_adv: number[];
teamfights: any[];
draft_timings: any[];
}
type Player = {
player_slot: number;
account_id?: number;
hero_id: number;
kills: number;
deaths: number;
assists: number;
denies: number;
level: number;
gold_per_min: number;
xp_per_min: number;
last_hits: number;
hero_damage: number;
hero_healing: number;
tower_damage: number;
leaver_status: number;
hero_variant?: number;
ability_upgrades?: any[];
ability_upgrades_arr: number[];
// Computed fields
match_id?: number;
radiant_win?: boolean;
is_radiant: boolean;
isRadiant?: boolean;
win: number;
lose: number;
total_gold: number;
total_xp: number;
kills_per_min: number;
kda: number;
abandons: number;
heroes: PGroup;
benchmarks: AnyDict;
// In Steam API that we're manually removing
scaled_hero_damage?: number;
scaled_tower_damage?: number;
scaled_hero_healing?: number;
aghanims_shard?: number;
aghanims_scepter?: number;
moonshard?: number;
// Added in buildMatch for display
is_subscriber: boolean;
// For storing in player_caches
average_rank?: number;
};
interface ParsedPlayer extends Player {
kills_log: any[];
obs_log: any[];
purchase_log: any[];
pings: any;
purchase: NumberDict;
lane_pos: Record<string, NumberDict>;
gold_t: number[];
xp_t: number[];
lh_t: number[];
item_uses: NumberDict;
buyback_log: any[];
killed: NumberDict;
stuns: number;
obs: any;
sen: any;
lane_role: number | null;
party_size?: number;
// Computed
is_roaming?: boolean | null;
all_word_counts: NumberDict;
my_word_counts: NumberDict;
throw: number | undefined;
comeback: number | undefined;
loss: number | undefined;
stomp: number | undefined;
life_state: NumberDict;
life_state_dead: number;
actions: NumberDict;
actions_per_min: number;
purchase_ward_observer: number;
purchase_ward_sentry: number;
purchase_tpscroll: number;
purchase_rapier: number;
purchase_gem: number;
item_win: NumberDict;
item_usage: NumberDict;
purchase_time: NumberDict;
first_purchase_time: NumberDict;
lane: number | undefined | null;
lane_efficiency: number;
lane_efficiency_pct: number;
buyback_count: number;
observer_uses: number;
sentry_uses: number;
neutral_kills: number;
tower_kills: number;
courier_kills: number;
lane_kills: number;
hero_kills: number;
observer_kills: number;
sentry_kills: number;
roshan_kills: number;
necronomicon_kills: number;
ancient_kills: number;
// Added temporarily
rank_tier?: number;
}
// Data to pass to insertMatch from GC
interface GcMatch {
match_id: number;
cluster: number;
replay_salt: number;
series_type: number;
series_id: number;
players: GcPlayer[];
}
interface GcPlayer {
player_slot: number;
party_id: number;
party_size: number;
permanent_buffs: any[];
// Currently not passed
account_id?: number;
}
interface ParserMatch {
match_id: number;
// Needed to determine whether to insert pro match data
leagueid: number;
// Used for dust and apm calculation
start_time: number;
duration: number;
// Parsed fields
version: number;
chat: any[];
cosmetics: any;
objectives: any[];
radiant_gold_adv: number[];
players: ParserPlayer[];
}
interface ParserPlayer extends Partial<Player> {
player_slot: number;
kills_log: any[];
// plus more parsed properties
}
type PlayerMatch = Player & Match & { players?: Player[] };
type ParsedPlayerMatch = ParsedPlayer &
ParsedMatch & { players?: ParsedPlayer[]; is_contributor?: boolean };
type User = {
account_id: number;
fh_unavailable: boolean;
steamid: string;
personaname: string;
avatarfull: string;
last_match_time: Date;
// Computed fields
is_contributor: boolean;
is_subscriber: boolean;
status: number;
};
type PlayerRating = {
account_id: number;
rank_tier: number;
leaderboard_rank: number;
};
type FullHistoryJob = {
account_id: number;
long_history?: boolean;
// These fields don't exist on the job but we add them during processing
fh_unavailable?: boolean;
};
type MmrJob = {
account_id: number;
match_id: number;
};
type GcDataJob = {
match_id: number;
};
type CountsJob = import('./store/pgroup').ApiMatch;
type ScenariosJob = string;
type CacheJob = string;
type ParseJob = {
match_id: number;
origin?: DataOrigin;
};
type QueueJob = QueueInput['data'];
type QueueName = QueueInput['name'];
type QueueInput =
| {
name: 'mmrQueue';
data: MmrJob;
}
| {
name: 'countsQueue';
data: CountsJob;
}
| {
name: 'fhQueue';
data: FullHistoryJob;
}
| {
name: 'scenariosQueue';
data: ScenariosJob;
}
| {
name: 'parse';
data: ParseJob;
}
| {
name: 'gcQueue';
data: GcDataJob;
}
| {
name: 'cacheQueue';
data: CacheJob;
};
type ReliableQueueRow = {
id: number;
type: string;
timestamp: string;
attempts: number;
data: any;
next_attempt_time: string;
priority: number;
};
type ReliableQueueOptions = { attempts?: number; priority?: number };
type ProPlayer = {
name: string;
account_id: number;
};
type DataType = 'api' | 'parsed' | 'gcdata' | 'meta' | 'identity' | 'ranks';
type DataOrigin = 'scanner';
type CommonInsertOptions = {
origin?: DataOrigin;
skipParse?: boolean;
pgroup?: PGroup;
endedAt?: number;
ifNotExists?: boolean;
};
type ApiInsertOptions = {
type: 'api';
} & CommonInsertOptions;
type NonApiInsertOptions = {
type: DataType;
// We can compute these if API, but otherwise required
pgroup: PGroup;
endedAt: number;
} & CommonInsertOptions;
type InsertMatchOptions = ApiInsertOptions | NonApiInsertOptions;
type PathVerbSpec = {
operationId: string;
summary: string;
description: string;
tags: string[];
parameters?: any[];
responses: {
[key: number]: {
description: string;
content: any;
};
};
route: () => string;
func: (
req: import('express').Request,
res: import('express').Response,
cb: ErrorCb,
) => Promise<any>;
};
type HttpVerb = 'get' | 'post';
type OpenAPISpec = {
openapi: string;
info: any;
servers: any[];
components: any;
paths: {
[path: string]: {
[key in HttpVerb]?: PathVerbSpec;
};
};
};
type MetricName =
| 'parsed'
| 'steam_api_call'
| 'steam_proxy_call'
| 'steam_429'
| 'steam_403'
| 'web_crash'
| '500_error'
| 'api_hits_ui'
| 'api_hits'
| 'skip_seq_num'
| 'retriever_player'
| 'fullhistory'
| 'fullhistory_skip'
| 'fullhistory_op'
| 'fullhistory_short'
| 'match_archive_read'
| 'match_archive_write'
| 'auto_parse'
| 'added_match'
| 'distinct_match_player'
| 'distinct_match_player_user'
| 'distinct_match_player_recent_user'
| 'parser'
| 'meta_parse'
| 'retriever'
| 'build_match'
| 'player_matches'
| 'self_profile_view'
| 'match_cache_hit'
| 'player_cache_hit'
| 'player_cache_miss'
| 'player_cache_wait'
| 'player_cache_write'
| 'distinct_player_cache'
| 'auto_player_cache'
| 'auto_player_cache_hit'
| 'auto_player_cache_miss'
| 'distinct_auto_player_cache'
| 'steam_api_backfill'
| 'steam_api_notfound'
| 'steam_gc_backfill'
| 'request_api_key'
| 'request_ui'
| 'request'
| 'distinct_request'
| 'reparse_early'
| 'reparse'
| 'regcdata'
| 'reapi'
| 'parser_fail'
| 'parser_crash'
| 'parser_skip'
| 'incomplete_archive'
| 'gen_api_key_invalid'
| 'parser_job'
| 'oldparse'
| 'secondary_scanner';
// Object to map player_slot to basic info
type PGroup = {
[player_slot: string]: {
// Optional because some players are anonymous
account_id?: number;
hero_id: number;
};
};