-
-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathserver.d.ts
More file actions
247 lines (219 loc) · 5.23 KB
/
server.d.ts
File metadata and controls
247 lines (219 loc) · 5.23 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import type {
ScannerModels,
ScannerModelKeys,
RmModels,
RmModelKeys,
ModelKeys,
Station,
Backup,
Nest,
NestSubmission,
Pokestop,
Gym,
Pokemon,
} from 'server/src/models'
import { Knex } from 'knex'
import { Model } from 'objection'
import { NextFunction, Request, Response } from 'express'
import { VerifyCallback } from 'passport-oauth2'
import type { DbManager } from 'server/src/services/DbManager'
import type { EventManager } from 'server/src/services/EventManager'
import { ModelReturn, OnlyType } from './utility'
import { Profile } from 'passport-discord'
import { User } from './models'
import { Config } from '@rm/types'
import { OperationTypeNode } from 'graphql'
export interface DbContext {
isMad: boolean
pvpV2: boolean
mem: string
secret: string
hasSize: boolean
hasHeight: boolean
hasRewardAmount: boolean
hasPowerUp: boolean
hasAltQuests: boolean
hasLayerColumn: boolean
hasMultiInvasions: boolean
multiInvasionMs: boolean
hasConfirmed: boolean
availableSlotsCol: string
polygon: boolean
hasAlignment: boolean
hasShowcaseData: boolean
hasShowcaseForm: boolean
hasShowcaseType: boolean
}
export interface ExpressUser extends User {
perms: Permissions
valid: boolean
avatar: string
webhookStrategy?: Strategy
rmStrategy: string
}
export interface AvailablePokemon {
id: number
form: number
count: number
}
export interface Available {
pokemon: ModelReturn<typeof Pokemon, 'getAvailable'>
gyms: ModelReturn<typeof Gym, 'getAvailable'>
pokestops: ModelReturn<typeof Pokestop, 'getAvailable'>
nests: ModelReturn<typeof Nest, 'getAvailable'>
stations: ModelReturn<typeof Station, 'getAvailable'>
}
export interface ApiEndpoint {
type: string
endpoint: string
secret: string
useFor: Lowercase<ModelKeys>[]
}
export interface DbConnection {
host: string
port: number
username: string
password: string
database: string
useFor: Lowercase<ModelKeys>[]
}
export type Schema = ApiEndpoint | DbConnection
export interface DbManagerClass {
models: {
[key in ScannerModelKeys]?: (DbContext & {
connection: number
SubModel: ScannerModels[key]
})[]
} & Partial<RmModels>
validModels: ScannerModelKeys[]
singleModels: readonly RmModelKeys[]
searchLimit: number
endpoints: { [key: number]: ApiEndpoint }
connections: (Knex | null)[]
rarity: Rarity
historical: Rarity
questConditions: { [key: string]: string[] }
rarityPercents: RarityPercents
reactMapDb: null | number
filterContext: {
Route: { maxDistance: number; maxDuration: number }
Pokestop: { hasConfirmedInvasions: boolean }
}
}
export interface RarityPercents {
common: number
uncommon: number
rare: number
ultraRare: number
regional: number
never: number
event: number
}
export type Rarity = { [key: string]: keyof RarityPercents }
export interface BaseRecord {
id: number | string
lat: number
lon: number
updated: number
distance?: number
}
export interface GqlContext {
userId: number
req: Request
res: Response
Db: DbManager
Event: EventManager
perms: Permissions
username: string
operation: OperationTypeNode
startTime?: number
}
type BasePerms = { [K in keyof Config['authentication']['perms']]: boolean }
export interface Permissions extends BasePerms {
blockedGuildNames: string[]
scanner: string[]
areaRestrictions: string[]
webhooks: string[]
trial: boolean
scannerCooldowns: Record<string, number>
}
export interface FilterId {
id: number
form?: number
}
export interface DnfMinMax {
min: number
max: number
}
export interface DnfFilter {
pokemon?: FilterId | FilterId[]
iv?: DnfMinMax
level?: DnfMinMax
cp?: DnfMinMax
atk_iv?: DnfMinMax
def_iv?: DnfMinMax
sta_iv?: DnfMinMax
gender?: DnfMinMax
size?: DnfMinMax
pvp_little?: DnfMinMax
pvp_great?: DnfMinMax
pvp_ultra?: DnfMinMax
}
export type DiscordVerifyFunction = (
req: Request,
accessToken: string,
refreshToken: string,
profile: Profile,
done: VerifyCallback,
) => void
export type BaseFilter = import('server/src/filters/Base').BaseFilter
export type PokemonFilter =
import('server/src/filters/pokemon/Frontend').PokemonFilter
export type AllFilters = ReturnType<
(typeof import('server/src/filters/builder/base'))['buildDefaultFilters']
>
export type Categories = keyof AllFilters
export type AdvCategories =
| 'pokemon'
| 'gyms'
| 'pokestops'
| 'nests'
| 'stations'
export type UIObject = ReturnType<
(typeof import('server/src/ui/drawer'))['drawer']
>
export interface PokemonGlow
extends Partial<Omit<Config['clientSideOptions']['pokemon'], 'glow'>> {
glow: boolean
Hundo?: string
Nundo?: string
'Top PVP Rank'?: string
Multiple?: string
}
export interface ClientOptions
extends Partial<Omit<Config['clientSideOptions'], 'pokemon'>> {
pokemon: PokemonGlow
}
export type ExpressMiddleware = (
req: Request,
res: Response,
next: NextFunction,
) => any
export type ExpressErrorMiddleware = (
err: Error,
req: Request,
res: Response,
next: NextFunction,
) => any
export interface StateReportObj {
database: boolean
pvp: boolean
icons: boolean
audio: boolean
historical: boolean
masterfile: boolean
invasions: boolean
webhooks: boolean
events: boolean
strategies: boolean
}