erlc-v2 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +575 -572
- package/index.d.ts +429 -430
- package/package.json +7 -7
- package/src/Client.js +460 -465
- package/src/api/LocalApiServer.js +530 -533
- package/src/map/renderPlayerMap.js +2 -2
package/index.d.ts
CHANGED
|
@@ -1,437 +1,436 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import { Buffer } from "buffer";
|
|
3
|
-
|
|
4
|
-
export interface LoggerLike {
|
|
5
|
-
info?: (...args: any[]) => void;
|
|
6
|
-
warn?: (...args: any[]) => void;
|
|
7
|
-
error?: (...args: any[]) => void;
|
|
8
|
-
debug?: (...args: any[]) => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface CacheOptions {
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
ttlMs?: number;
|
|
14
|
-
maxSize?: number;
|
|
15
|
-
provider?: "memory" | "redis";
|
|
16
|
-
redisUrl?: string;
|
|
17
|
-
redisPrefix?: string;
|
|
18
|
-
redisClient?: {
|
|
19
|
-
get?: (key: string) => Promise<string | null> | string | null;
|
|
20
|
-
set?: (...args: any[]) => Promise<any> | any;
|
|
21
|
-
del?: (...args: any[]) => Promise<any> | any;
|
|
22
|
-
connect?: () => Promise<void> | void;
|
|
23
|
-
isOpen?: boolean;
|
|
24
|
-
status?: string;
|
|
25
|
-
sAdd?: (...args: any[]) => Promise<any> | any;
|
|
26
|
-
sadd?: (...args: any[]) => Promise<any> | any;
|
|
27
|
-
sRem?: (...args: any[]) => Promise<any> | any;
|
|
28
|
-
srem?: (...args: any[]) => Promise<any> | any;
|
|
29
|
-
sMembers?: (...args: any[]) => Promise<string[]> | string[];
|
|
30
|
-
smembers?: (...args: any[]) => Promise<string[]> | string[];
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface RateLimitOptions {
|
|
36
|
-
enabled?: boolean;
|
|
37
|
-
strictSerial?: boolean;
|
|
38
|
-
bucketLimit?: number;
|
|
39
|
-
totalLimit?: number;
|
|
40
|
-
unauthLimit?: number;
|
|
41
|
-
perBucketConcurrency?: number;
|
|
42
|
-
globalConcurrency?: number;
|
|
43
|
-
unauthorizedThreshold?: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface PollingOptions {
|
|
47
|
-
enabled?: boolean;
|
|
48
|
-
intervalMs?: number;
|
|
49
|
-
bypassCache?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface ApiServerOptions {
|
|
53
|
-
enabled?: boolean;
|
|
54
|
-
host?: string;
|
|
55
|
-
port?: number;
|
|
56
|
-
path?: string;
|
|
57
|
-
webhookPath?: string;
|
|
58
|
-
publicUrl?: string;
|
|
59
|
-
token?: string;
|
|
60
|
-
logRequests?: boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface ClientOptions {
|
|
64
|
-
serverKey: string;
|
|
65
|
-
globalKey?: string;
|
|
66
|
-
logging?: boolean;
|
|
67
|
-
logger?: LoggerLike | null;
|
|
68
|
-
cache?: CacheOptions;
|
|
69
|
-
rateLimit?: RateLimitOptions;
|
|
70
|
-
polling?: PollingOptions;
|
|
71
|
-
api?: ApiServerOptions;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface ServerFetchFlags {
|
|
75
|
-
players?: boolean;
|
|
76
|
-
staff?: boolean;
|
|
77
|
-
joinLogs?: boolean;
|
|
78
|
-
queue?: boolean;
|
|
79
|
-
killLogs?: boolean;
|
|
80
|
-
commandLogs?: boolean;
|
|
81
|
-
modCalls?: boolean;
|
|
82
|
-
emergencyCalls?: boolean;
|
|
83
|
-
vehicles?: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface RequestOptions {
|
|
87
|
-
bypassCache?: boolean;
|
|
88
|
-
cacheTtlMs?: number;
|
|
89
|
-
dedupe?: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface CommandRequestOptions {
|
|
93
|
-
dedupe?: boolean;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface CommandExecuteResult {
|
|
97
|
-
ok: boolean;
|
|
98
|
-
status: number;
|
|
99
|
-
endpoint: string;
|
|
100
|
-
bucket: string;
|
|
101
|
-
message: string | null;
|
|
102
|
-
commandId: string | null;
|
|
103
|
-
rateLimit: {
|
|
104
|
-
limit: number;
|
|
105
|
-
remaining: number;
|
|
106
|
-
resetEpochMs: number | null;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface VehicleData {
|
|
111
|
-
Name?: string;
|
|
112
|
-
Owner?: string;
|
|
113
|
-
Plate?: string;
|
|
114
|
-
Texture?: string | null;
|
|
115
|
-
ColorHex?: string;
|
|
116
|
-
ColorName?: string;
|
|
117
|
-
[key: string]: any;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface EmergencyCallData {
|
|
121
|
-
Team?: string;
|
|
122
|
-
Caller?: number;
|
|
123
|
-
Players?: number[];
|
|
124
|
-
Position?: number[];
|
|
125
|
-
StartedAt?: number;
|
|
126
|
-
CallNumber?: number;
|
|
127
|
-
Description?: string;
|
|
128
|
-
PositionDescriptor?: string;
|
|
129
|
-
[key: string]: any;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export interface VehicleSearchFilters {
|
|
133
|
-
query?: string;
|
|
134
|
-
search?: string;
|
|
135
|
-
plate?: string;
|
|
136
|
-
owner?: string;
|
|
137
|
-
name?: string;
|
|
138
|
-
color?: string;
|
|
139
|
-
colorName?: string;
|
|
140
|
-
texture?: string;
|
|
141
|
-
exact?: boolean;
|
|
142
|
-
limit?: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface ApiServerInfo {
|
|
146
|
-
running: boolean;
|
|
147
|
-
host: string;
|
|
148
|
-
port: number | null;
|
|
149
|
-
path: string;
|
|
150
|
-
webhookPath: string;
|
|
151
|
-
localUrl: string | null;
|
|
152
|
-
webhookUrl: string | null;
|
|
153
|
-
publicUrl: string | null;
|
|
154
|
-
tokenEnabled: boolean;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface WebhookPayload {
|
|
158
|
-
type: "command" | "emergencyCall" | "verification" | "unknown";
|
|
159
|
-
body: Record<string, any>;
|
|
160
|
-
timestamp: string | null;
|
|
161
|
-
signature: string | null;
|
|
162
|
-
rawBody: Buffer | null;
|
|
163
|
-
headers: Record<string, any>;
|
|
164
|
-
server: string | null;
|
|
165
|
-
events: Array<{
|
|
166
|
-
event: string | null;
|
|
167
|
-
origin: string | null;
|
|
168
|
-
eventTimestamp: number | null;
|
|
169
|
-
data: Record<string, any>;
|
|
170
|
-
command: string | null;
|
|
171
|
-
argument: string;
|
|
172
|
-
args: string;
|
|
173
|
-
}>;
|
|
174
|
-
entry: {
|
|
175
|
-
event: string | null;
|
|
176
|
-
origin: string | null;
|
|
177
|
-
eventTimestamp: number | null;
|
|
178
|
-
data: Record<string, any>;
|
|
179
|
-
command: string | null;
|
|
180
|
-
argument: string;
|
|
181
|
-
args: string;
|
|
182
|
-
} | null;
|
|
183
|
-
event: string | null;
|
|
184
|
-
origin: string | null;
|
|
185
|
-
eventTimestamp: number | null;
|
|
186
|
-
data: Record<string, any> | null;
|
|
187
|
-
command: string | null;
|
|
188
|
-
argument: string;
|
|
189
|
-
args: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface ApiRequestPayload {
|
|
193
|
-
method: string;
|
|
194
|
-
path: string;
|
|
195
|
-
query: Record<string, string>;
|
|
196
|
-
kind: "route" | "webhook";
|
|
197
|
-
status: number;
|
|
198
|
-
type: string | null;
|
|
199
|
-
body: any;
|
|
200
|
-
note: string;
|
|
201
|
-
tookMs: number;
|
|
202
|
-
ip: string | string[] | null;
|
|
203
|
-
at: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface MapCoordinateBounds {
|
|
207
|
-
minX: number;
|
|
208
|
-
maxX: number;
|
|
209
|
-
minY: number;
|
|
210
|
-
maxY: number;
|
|
211
|
-
invertY?: boolean;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface MapMarkerOptions {
|
|
215
|
-
outerRadius?: number;
|
|
216
|
-
innerRadius?: number;
|
|
217
|
-
tipLength?: number;
|
|
218
|
-
tipWidth?: number;
|
|
219
|
-
fillColor?: string;
|
|
220
|
-
shadow?: boolean;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface MapRenderOptions {
|
|
224
|
-
userId?: number | string;
|
|
225
|
-
userIds?: Array<number | string>;
|
|
226
|
-
players?: any[];
|
|
227
|
-
mapUrl?: string;
|
|
228
|
-
season?: string;
|
|
229
|
-
type?: string;
|
|
230
|
-
mapSeason?: string;
|
|
231
|
-
mapType?: string;
|
|
232
|
-
coordinateBounds?: MapCoordinateBounds;
|
|
233
|
-
clampToMap?: boolean;
|
|
234
|
-
robloxHeadshotSize?: string;
|
|
235
|
-
marker?: MapMarkerOptions;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export interface MapRenderedPlayer {
|
|
239
|
-
userId: number | null;
|
|
240
|
-
name: string | null;
|
|
241
|
-
avatarUrl: string | null;
|
|
242
|
-
sourceX: number;
|
|
243
|
-
sourceY: number;
|
|
244
|
-
sourceType: string;
|
|
245
|
-
pixelX: number;
|
|
246
|
-
pixelY: number;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface MapSkippedPlayer {
|
|
250
|
-
userId: number | null;
|
|
251
|
-
name: string | null;
|
|
252
|
-
reason: string;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
export interface MapRenderResult {
|
|
256
|
-
buffer: Buffer;
|
|
257
|
-
mimeType: "image/png";
|
|
258
|
-
map: {
|
|
259
|
-
url: string;
|
|
260
|
-
season: string | null;
|
|
261
|
-
type: string | null;
|
|
262
|
-
width: number;
|
|
263
|
-
height: number;
|
|
264
|
-
};
|
|
265
|
-
players: MapRenderedPlayer[];
|
|
266
|
-
skipped: MapSkippedPlayer[];
|
|
267
|
-
requestedUserIds: number[];
|
|
268
|
-
unmatchedUserIds: number[];
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export interface ServerResponse {
|
|
272
|
-
name: string | null;
|
|
273
|
-
ownerId: number | null;
|
|
274
|
-
coOwnerIds: number[];
|
|
275
|
-
currentPlayers: number;
|
|
276
|
-
maxPlayers: number;
|
|
277
|
-
joinKey: string | null;
|
|
278
|
-
accVerifiedReq: string | null;
|
|
279
|
-
teamBalance: boolean | null;
|
|
280
|
-
players: any[];
|
|
281
|
-
staff: any;
|
|
282
|
-
joinLogs: any[];
|
|
283
|
-
queue: any[];
|
|
284
|
-
killLogs: any[];
|
|
285
|
-
commandLogs: any[];
|
|
286
|
-
modCalls: any[];
|
|
287
|
-
emergencyCalls: EmergencyCallData[];
|
|
288
|
-
vehicles: VehicleData[];
|
|
289
|
-
raw: Record<string, any>;
|
|
290
|
-
meta: {
|
|
291
|
-
status: number;
|
|
292
|
-
endpoint: string;
|
|
293
|
-
bucket: string;
|
|
294
|
-
rateLimit: {
|
|
295
|
-
limit: number;
|
|
296
|
-
remaining: number;
|
|
297
|
-
resetEpochMs: number | null;
|
|
298
|
-
};
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export class ERLCError extends Error {
|
|
303
|
-
details: Record<string, any>;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export class ERLCHttpError extends ERLCError {
|
|
307
|
-
status: number | null;
|
|
308
|
-
endpoint: string | null;
|
|
309
|
-
bucket: string | null;
|
|
310
|
-
body: any;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export class ERLCAPIError extends ERLCHttpError {
|
|
314
|
-
errorCode: number;
|
|
315
|
-
apiMessage: string;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export class RateLimitError extends ERLCAPIError {
|
|
319
|
-
retryAfterMs: number;
|
|
320
|
-
resetEpochMs: number | null;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export class KeyExpiredError extends ERLCAPIError {}
|
|
324
|
-
export class KeyBannedError extends ERLCAPIError {}
|
|
325
|
-
export class InvalidGlobalKeyError extends ERLCAPIError {}
|
|
326
|
-
export class ServerOfflineError extends ERLCAPIError {}
|
|
327
|
-
export class RestrictedError extends ERLCAPIError {}
|
|
328
|
-
export class ModuleOutOfDateError extends ERLCAPIError {}
|
|
329
|
-
|
|
330
|
-
export class Client extends EventEmitter {
|
|
331
|
-
constructor(options: ClientOptions);
|
|
332
|
-
cache: {
|
|
333
|
-
clear: () => void | Promise<void>;
|
|
334
|
-
destroy?: () => void | Promise<void>;
|
|
335
|
-
};
|
|
336
|
-
server: {
|
|
337
|
-
fetch: (
|
|
338
|
-
flags?: ServerFetchFlags,
|
|
339
|
-
requestOptions?: RequestOptions,
|
|
340
|
-
) => Promise<ServerResponse>;
|
|
341
|
-
};
|
|
342
|
-
players: {
|
|
343
|
-
list: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
344
|
-
};
|
|
345
|
-
map: {
|
|
346
|
-
render: (
|
|
347
|
-
options?: MapRenderOptions,
|
|
348
|
-
requestOptions?: RequestOptions,
|
|
349
|
-
) => Promise<MapRenderResult>;
|
|
350
|
-
renderUser: (
|
|
351
|
-
userId: number | string,
|
|
352
|
-
options?: Omit<MapRenderOptions, "userId" | "userIds">,
|
|
353
|
-
requestOptions?: RequestOptions,
|
|
354
|
-
) => Promise<MapRenderResult>;
|
|
355
|
-
};
|
|
356
|
-
staff: {
|
|
357
|
-
list: (requestOptions?: RequestOptions) => Promise<any>;
|
|
358
|
-
};
|
|
359
|
-
logs: {
|
|
360
|
-
kills: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
361
|
-
joins: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
362
|
-
commands: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
363
|
-
modCalls: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
364
|
-
emergencyCalls: (
|
|
365
|
-
requestOptions?: RequestOptions,
|
|
366
|
-
) => Promise<EmergencyCallData[]>;
|
|
367
|
-
};
|
|
368
|
-
commands: {
|
|
369
|
-
execute: (
|
|
370
|
-
command: string,
|
|
371
|
-
requestOptions?: CommandRequestOptions,
|
|
372
|
-
) => Promise<CommandExecuteResult>;
|
|
373
|
-
};
|
|
374
|
-
vehicles: {
|
|
375
|
-
list: (requestOptions?: RequestOptions) => Promise<VehicleData[]>;
|
|
376
|
-
search: (
|
|
377
|
-
filters?: string | VehicleSearchFilters,
|
|
378
|
-
requestOptions?: RequestOptions,
|
|
379
|
-
) => Promise<VehicleData[]>;
|
|
380
|
-
findByPlate: (
|
|
381
|
-
plate: string,
|
|
382
|
-
requestOptions?: RequestOptions,
|
|
383
|
-
) => Promise<VehicleData | null>;
|
|
384
|
-
findByOwner: (
|
|
385
|
-
owner: string,
|
|
386
|
-
requestOptions?: RequestOptions,
|
|
387
|
-
) => Promise<VehicleData[]>;
|
|
388
|
-
findOne: (
|
|
389
|
-
filters?: string | VehicleSearchFilters,
|
|
390
|
-
requestOptions?: RequestOptions,
|
|
391
|
-
) => Promise<VehicleData | null>;
|
|
392
|
-
};
|
|
393
|
-
queue: {
|
|
394
|
-
get: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
395
|
-
};
|
|
396
|
-
api: {
|
|
397
|
-
start: () => Promise<ApiServerInfo>;
|
|
398
|
-
stop: () => void;
|
|
399
|
-
info: () => ApiServerInfo;
|
|
400
|
-
};
|
|
401
|
-
onReady(listener: (...args: any[]) => void): this;
|
|
402
|
-
onJoin(listener: (...args: any[]) => void): this;
|
|
403
|
-
onLeave(listener: (...args: any[]) => void): this;
|
|
404
|
-
onKill(listener: (...args: any[]) => void): this;
|
|
405
|
-
onVehicleSpawn(listener: (...args: any[]) => void): this;
|
|
406
|
-
onVehicleDespawn(listener: (...args: any[]) => void): this;
|
|
407
|
-
onQueueUpdate(listener: (...args: any[]) => void): this;
|
|
408
|
-
onStaffUpdate(listener: (...args: any[]) => void): this;
|
|
409
|
-
onModCall(listener: (...args: any[]) => void): this;
|
|
410
|
-
onEmergencyCall(listener: (...args: any[]) => void): this;
|
|
411
|
-
onCommandLog(listener: (...args: any[]) => void): this;
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
|
|
4
|
+
export interface LoggerLike {
|
|
5
|
+
info?: (...args: any[]) => void;
|
|
6
|
+
warn?: (...args: any[]) => void;
|
|
7
|
+
error?: (...args: any[]) => void;
|
|
8
|
+
debug?: (...args: any[]) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CacheOptions {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
ttlMs?: number;
|
|
14
|
+
maxSize?: number;
|
|
15
|
+
provider?: "memory" | "redis";
|
|
16
|
+
redisUrl?: string;
|
|
17
|
+
redisPrefix?: string;
|
|
18
|
+
redisClient?: {
|
|
19
|
+
get?: (key: string) => Promise<string | null> | string | null;
|
|
20
|
+
set?: (...args: any[]) => Promise<any> | any;
|
|
21
|
+
del?: (...args: any[]) => Promise<any> | any;
|
|
22
|
+
connect?: () => Promise<void> | void;
|
|
23
|
+
isOpen?: boolean;
|
|
24
|
+
status?: string;
|
|
25
|
+
sAdd?: (...args: any[]) => Promise<any> | any;
|
|
26
|
+
sadd?: (...args: any[]) => Promise<any> | any;
|
|
27
|
+
sRem?: (...args: any[]) => Promise<any> | any;
|
|
28
|
+
srem?: (...args: any[]) => Promise<any> | any;
|
|
29
|
+
sMembers?: (...args: any[]) => Promise<string[]> | string[];
|
|
30
|
+
smembers?: (...args: any[]) => Promise<string[]> | string[];
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RateLimitOptions {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
strictSerial?: boolean;
|
|
38
|
+
bucketLimit?: number;
|
|
39
|
+
totalLimit?: number;
|
|
40
|
+
unauthLimit?: number;
|
|
41
|
+
perBucketConcurrency?: number;
|
|
42
|
+
globalConcurrency?: number;
|
|
43
|
+
unauthorizedThreshold?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface PollingOptions {
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
intervalMs?: number;
|
|
49
|
+
bypassCache?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ApiServerOptions {
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
host?: string;
|
|
55
|
+
port?: number;
|
|
56
|
+
path?: string;
|
|
57
|
+
webhookPath?: string;
|
|
58
|
+
publicUrl?: string;
|
|
59
|
+
token?: string;
|
|
60
|
+
logRequests?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface ClientOptions {
|
|
64
|
+
serverKey: string;
|
|
65
|
+
globalKey?: string;
|
|
66
|
+
logging?: boolean;
|
|
67
|
+
logger?: LoggerLike | null;
|
|
68
|
+
cache?: CacheOptions;
|
|
69
|
+
rateLimit?: RateLimitOptions;
|
|
70
|
+
polling?: PollingOptions;
|
|
71
|
+
api?: ApiServerOptions;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ServerFetchFlags {
|
|
75
|
+
players?: boolean;
|
|
76
|
+
staff?: boolean;
|
|
77
|
+
joinLogs?: boolean;
|
|
78
|
+
queue?: boolean;
|
|
79
|
+
killLogs?: boolean;
|
|
80
|
+
commandLogs?: boolean;
|
|
81
|
+
modCalls?: boolean;
|
|
82
|
+
emergencyCalls?: boolean;
|
|
83
|
+
vehicles?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface RequestOptions {
|
|
87
|
+
bypassCache?: boolean;
|
|
88
|
+
cacheTtlMs?: number;
|
|
89
|
+
dedupe?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface CommandRequestOptions {
|
|
93
|
+
dedupe?: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CommandExecuteResult {
|
|
97
|
+
ok: boolean;
|
|
98
|
+
status: number;
|
|
99
|
+
endpoint: string;
|
|
100
|
+
bucket: string;
|
|
101
|
+
message: string | null;
|
|
102
|
+
commandId: string | null;
|
|
103
|
+
rateLimit: {
|
|
104
|
+
limit: number;
|
|
105
|
+
remaining: number;
|
|
106
|
+
resetEpochMs: number | null;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface VehicleData {
|
|
111
|
+
Name?: string;
|
|
112
|
+
Owner?: string;
|
|
113
|
+
Plate?: string;
|
|
114
|
+
Texture?: string | null;
|
|
115
|
+
ColorHex?: string;
|
|
116
|
+
ColorName?: string;
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface EmergencyCallData {
|
|
121
|
+
Team?: string;
|
|
122
|
+
Caller?: number;
|
|
123
|
+
Players?: number[];
|
|
124
|
+
Position?: number[];
|
|
125
|
+
StartedAt?: number;
|
|
126
|
+
CallNumber?: number;
|
|
127
|
+
Description?: string;
|
|
128
|
+
PositionDescriptor?: string;
|
|
129
|
+
[key: string]: any;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface VehicleSearchFilters {
|
|
133
|
+
query?: string;
|
|
134
|
+
search?: string;
|
|
135
|
+
plate?: string;
|
|
136
|
+
owner?: string;
|
|
137
|
+
name?: string;
|
|
138
|
+
color?: string;
|
|
139
|
+
colorName?: string;
|
|
140
|
+
texture?: string;
|
|
141
|
+
exact?: boolean;
|
|
142
|
+
limit?: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface ApiServerInfo {
|
|
146
|
+
running: boolean;
|
|
147
|
+
host: string;
|
|
148
|
+
port: number | null;
|
|
149
|
+
path: string;
|
|
150
|
+
webhookPath: string;
|
|
151
|
+
localUrl: string | null;
|
|
152
|
+
webhookUrl: string | null;
|
|
153
|
+
publicUrl: string | null;
|
|
154
|
+
tokenEnabled: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface WebhookPayload {
|
|
158
|
+
type: "command" | "emergencyCall" | "verification" | "unknown";
|
|
159
|
+
body: Record<string, any>;
|
|
160
|
+
timestamp: string | null;
|
|
161
|
+
signature: string | null;
|
|
162
|
+
rawBody: Buffer | null;
|
|
163
|
+
headers: Record<string, any>;
|
|
164
|
+
server: string | null;
|
|
165
|
+
events: Array<{
|
|
166
|
+
event: string | null;
|
|
167
|
+
origin: string | null;
|
|
168
|
+
eventTimestamp: number | null;
|
|
169
|
+
data: Record<string, any>;
|
|
170
|
+
command: string | null;
|
|
171
|
+
argument: string;
|
|
172
|
+
args: string;
|
|
173
|
+
}>;
|
|
174
|
+
entry: {
|
|
175
|
+
event: string | null;
|
|
176
|
+
origin: string | null;
|
|
177
|
+
eventTimestamp: number | null;
|
|
178
|
+
data: Record<string, any>;
|
|
179
|
+
command: string | null;
|
|
180
|
+
argument: string;
|
|
181
|
+
args: string;
|
|
182
|
+
} | null;
|
|
183
|
+
event: string | null;
|
|
184
|
+
origin: string | null;
|
|
185
|
+
eventTimestamp: number | null;
|
|
186
|
+
data: Record<string, any> | null;
|
|
187
|
+
command: string | null;
|
|
188
|
+
argument: string;
|
|
189
|
+
args: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface ApiRequestPayload {
|
|
193
|
+
method: string;
|
|
194
|
+
path: string;
|
|
195
|
+
query: Record<string, string>;
|
|
196
|
+
kind: "route" | "webhook";
|
|
197
|
+
status: number;
|
|
198
|
+
type: string | null;
|
|
199
|
+
body: any;
|
|
200
|
+
note: string;
|
|
201
|
+
tookMs: number;
|
|
202
|
+
ip: string | string[] | null;
|
|
203
|
+
at: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface MapCoordinateBounds {
|
|
207
|
+
minX: number;
|
|
208
|
+
maxX: number;
|
|
209
|
+
minY: number;
|
|
210
|
+
maxY: number;
|
|
211
|
+
invertY?: boolean;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface MapMarkerOptions {
|
|
215
|
+
outerRadius?: number;
|
|
216
|
+
innerRadius?: number;
|
|
217
|
+
tipLength?: number;
|
|
218
|
+
tipWidth?: number;
|
|
219
|
+
fillColor?: string;
|
|
220
|
+
shadow?: boolean;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface MapRenderOptions {
|
|
224
|
+
userId?: number | string;
|
|
225
|
+
userIds?: Array<number | string>;
|
|
226
|
+
players?: any[];
|
|
227
|
+
mapUrl?: string;
|
|
228
|
+
season?: string;
|
|
229
|
+
type?: string;
|
|
230
|
+
mapSeason?: string;
|
|
231
|
+
mapType?: string;
|
|
232
|
+
coordinateBounds?: MapCoordinateBounds;
|
|
233
|
+
clampToMap?: boolean;
|
|
234
|
+
robloxHeadshotSize?: string;
|
|
235
|
+
marker?: MapMarkerOptions;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface MapRenderedPlayer {
|
|
239
|
+
userId: number | null;
|
|
240
|
+
name: string | null;
|
|
241
|
+
avatarUrl: string | null;
|
|
242
|
+
sourceX: number;
|
|
243
|
+
sourceY: number;
|
|
244
|
+
sourceType: string;
|
|
245
|
+
pixelX: number;
|
|
246
|
+
pixelY: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface MapSkippedPlayer {
|
|
250
|
+
userId: number | null;
|
|
251
|
+
name: string | null;
|
|
252
|
+
reason: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface MapRenderResult {
|
|
256
|
+
buffer: Buffer;
|
|
257
|
+
mimeType: "image/png";
|
|
258
|
+
map: {
|
|
259
|
+
url: string;
|
|
260
|
+
season: string | null;
|
|
261
|
+
type: string | null;
|
|
262
|
+
width: number;
|
|
263
|
+
height: number;
|
|
264
|
+
};
|
|
265
|
+
players: MapRenderedPlayer[];
|
|
266
|
+
skipped: MapSkippedPlayer[];
|
|
267
|
+
requestedUserIds: number[];
|
|
268
|
+
unmatchedUserIds: number[];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export interface ServerResponse {
|
|
272
|
+
name: string | null;
|
|
273
|
+
ownerId: number | null;
|
|
274
|
+
coOwnerIds: number[];
|
|
275
|
+
currentPlayers: number;
|
|
276
|
+
maxPlayers: number;
|
|
277
|
+
joinKey: string | null;
|
|
278
|
+
accVerifiedReq: string | null;
|
|
279
|
+
teamBalance: boolean | null;
|
|
280
|
+
players: any[];
|
|
281
|
+
staff: any;
|
|
282
|
+
joinLogs: any[];
|
|
283
|
+
queue: any[];
|
|
284
|
+
killLogs: any[];
|
|
285
|
+
commandLogs: any[];
|
|
286
|
+
modCalls: any[];
|
|
287
|
+
emergencyCalls: EmergencyCallData[];
|
|
288
|
+
vehicles: VehicleData[];
|
|
289
|
+
raw: Record<string, any>;
|
|
290
|
+
meta: {
|
|
291
|
+
status: number;
|
|
292
|
+
endpoint: string;
|
|
293
|
+
bucket: string;
|
|
294
|
+
rateLimit: {
|
|
295
|
+
limit: number;
|
|
296
|
+
remaining: number;
|
|
297
|
+
resetEpochMs: number | null;
|
|
298
|
+
};
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export class ERLCError extends Error {
|
|
303
|
+
details: Record<string, any>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export class ERLCHttpError extends ERLCError {
|
|
307
|
+
status: number | null;
|
|
308
|
+
endpoint: string | null;
|
|
309
|
+
bucket: string | null;
|
|
310
|
+
body: any;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export class ERLCAPIError extends ERLCHttpError {
|
|
314
|
+
errorCode: number;
|
|
315
|
+
apiMessage: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export class RateLimitError extends ERLCAPIError {
|
|
319
|
+
retryAfterMs: number;
|
|
320
|
+
resetEpochMs: number | null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export class KeyExpiredError extends ERLCAPIError {}
|
|
324
|
+
export class KeyBannedError extends ERLCAPIError {}
|
|
325
|
+
export class InvalidGlobalKeyError extends ERLCAPIError {}
|
|
326
|
+
export class ServerOfflineError extends ERLCAPIError {}
|
|
327
|
+
export class RestrictedError extends ERLCAPIError {}
|
|
328
|
+
export class ModuleOutOfDateError extends ERLCAPIError {}
|
|
329
|
+
|
|
330
|
+
export class Client extends EventEmitter {
|
|
331
|
+
constructor(options: ClientOptions);
|
|
332
|
+
cache: {
|
|
333
|
+
clear: () => void | Promise<void>;
|
|
334
|
+
destroy?: () => void | Promise<void>;
|
|
335
|
+
};
|
|
336
|
+
server: {
|
|
337
|
+
fetch: (
|
|
338
|
+
flags?: ServerFetchFlags,
|
|
339
|
+
requestOptions?: RequestOptions,
|
|
340
|
+
) => Promise<ServerResponse>;
|
|
341
|
+
};
|
|
342
|
+
players: {
|
|
343
|
+
list: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
344
|
+
};
|
|
345
|
+
map: {
|
|
346
|
+
render: (
|
|
347
|
+
options?: MapRenderOptions,
|
|
348
|
+
requestOptions?: RequestOptions,
|
|
349
|
+
) => Promise<MapRenderResult>;
|
|
350
|
+
renderUser: (
|
|
351
|
+
userId: number | string,
|
|
352
|
+
options?: Omit<MapRenderOptions, "userId" | "userIds">,
|
|
353
|
+
requestOptions?: RequestOptions,
|
|
354
|
+
) => Promise<MapRenderResult>;
|
|
355
|
+
};
|
|
356
|
+
staff: {
|
|
357
|
+
list: (requestOptions?: RequestOptions) => Promise<any>;
|
|
358
|
+
};
|
|
359
|
+
logs: {
|
|
360
|
+
kills: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
361
|
+
joins: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
362
|
+
commands: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
363
|
+
modCalls: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
364
|
+
emergencyCalls: (
|
|
365
|
+
requestOptions?: RequestOptions,
|
|
366
|
+
) => Promise<EmergencyCallData[]>;
|
|
367
|
+
};
|
|
368
|
+
commands: {
|
|
369
|
+
execute: (
|
|
370
|
+
command: string,
|
|
371
|
+
requestOptions?: CommandRequestOptions,
|
|
372
|
+
) => Promise<CommandExecuteResult>;
|
|
373
|
+
};
|
|
374
|
+
vehicles: {
|
|
375
|
+
list: (requestOptions?: RequestOptions) => Promise<VehicleData[]>;
|
|
376
|
+
search: (
|
|
377
|
+
filters?: string | VehicleSearchFilters,
|
|
378
|
+
requestOptions?: RequestOptions,
|
|
379
|
+
) => Promise<VehicleData[]>;
|
|
380
|
+
findByPlate: (
|
|
381
|
+
plate: string,
|
|
382
|
+
requestOptions?: RequestOptions,
|
|
383
|
+
) => Promise<VehicleData | null>;
|
|
384
|
+
findByOwner: (
|
|
385
|
+
owner: string,
|
|
386
|
+
requestOptions?: RequestOptions,
|
|
387
|
+
) => Promise<VehicleData[]>;
|
|
388
|
+
findOne: (
|
|
389
|
+
filters?: string | VehicleSearchFilters,
|
|
390
|
+
requestOptions?: RequestOptions,
|
|
391
|
+
) => Promise<VehicleData | null>;
|
|
392
|
+
};
|
|
393
|
+
queue: {
|
|
394
|
+
get: (requestOptions?: RequestOptions) => Promise<any[]>;
|
|
395
|
+
};
|
|
396
|
+
api: {
|
|
397
|
+
start: () => Promise<ApiServerInfo>;
|
|
398
|
+
stop: () => void;
|
|
399
|
+
info: () => ApiServerInfo;
|
|
400
|
+
};
|
|
401
|
+
onReady(listener: (...args: any[]) => void): this;
|
|
402
|
+
onJoin(listener: (...args: any[]) => void): this;
|
|
403
|
+
onLeave(listener: (...args: any[]) => void): this;
|
|
404
|
+
onKill(listener: (...args: any[]) => void): this;
|
|
405
|
+
onVehicleSpawn(listener: (...args: any[]) => void): this;
|
|
406
|
+
onVehicleDespawn(listener: (...args: any[]) => void): this;
|
|
407
|
+
onQueueUpdate(listener: (...args: any[]) => void): this;
|
|
408
|
+
onStaffUpdate(listener: (...args: any[]) => void): this;
|
|
409
|
+
onModCall(listener: (...args: any[]) => void): this;
|
|
410
|
+
onEmergencyCall(listener: (...args: any[]) => void): this;
|
|
411
|
+
onCommandLog(listener: (...args: any[]) => void): this;
|
|
412
412
|
onLogCommand(listener: (...args: any[]) => void): this;
|
|
413
413
|
onServerUpdate(listener: (...args: any[]) => void): this;
|
|
414
414
|
onApiRequest(listener: (payload: ApiRequestPayload) => void): this;
|
|
415
415
|
onWebhook(listener: (payload: WebhookPayload) => void): this;
|
|
416
|
-
onWebhookCommand(listener: (payload: WebhookPayload) => void): this;
|
|
417
416
|
onWebhookEmergencyCall(listener: (payload: WebhookPayload) => void): this;
|
|
418
417
|
onError(listener: (...args: any[]) => void): this;
|
|
419
418
|
onDisconnect(listener: (...args: any[]) => void): this;
|
|
420
|
-
destroy(): void;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
declare const _default: {
|
|
424
|
-
Client: typeof Client;
|
|
425
|
-
ERLCError: typeof ERLCError;
|
|
426
|
-
ERLCHttpError: typeof ERLCHttpError;
|
|
427
|
-
ERLCAPIError: typeof ERLCAPIError;
|
|
428
|
-
RateLimitError: typeof RateLimitError;
|
|
429
|
-
KeyExpiredError: typeof KeyExpiredError;
|
|
430
|
-
KeyBannedError: typeof KeyBannedError;
|
|
431
|
-
InvalidGlobalKeyError: typeof InvalidGlobalKeyError;
|
|
432
|
-
ServerOfflineError: typeof ServerOfflineError;
|
|
433
|
-
RestrictedError: typeof RestrictedError;
|
|
434
|
-
ModuleOutOfDateError: typeof ModuleOutOfDateError;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
export default _default;
|
|
419
|
+
destroy(): void;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
declare const _default: {
|
|
423
|
+
Client: typeof Client;
|
|
424
|
+
ERLCError: typeof ERLCError;
|
|
425
|
+
ERLCHttpError: typeof ERLCHttpError;
|
|
426
|
+
ERLCAPIError: typeof ERLCAPIError;
|
|
427
|
+
RateLimitError: typeof RateLimitError;
|
|
428
|
+
KeyExpiredError: typeof KeyExpiredError;
|
|
429
|
+
KeyBannedError: typeof KeyBannedError;
|
|
430
|
+
InvalidGlobalKeyError: typeof InvalidGlobalKeyError;
|
|
431
|
+
ServerOfflineError: typeof ServerOfflineError;
|
|
432
|
+
RestrictedError: typeof RestrictedError;
|
|
433
|
+
ModuleOutOfDateError: typeof ModuleOutOfDateError;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export default _default;
|