-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
216 lines (193 loc) · 7.85 KB
/
types.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
import { Transform } from "stream"
import { EventEmitter } from "events";
import { Worker } from "worker_threads";
export type Logger = {
info(message: any, worker?: string): void;
warn(message: any, worker?: string): void;
error(message: any, worker?: string): void;
}
export type Mixin<T extends { [key: string | number | symbol]: any }, SR extends Array<{ [key: string | number | symbol]: any }>> = SR extends Array<infer O> ? T & O : never;
export type Utils = {
noop(): void;
processLoad(): Promise<number>;
isObject<T>(value: T): value is Record<any, any>;
isValidKey(key: string): boolean;
mixin<T extends Record<string, any>, S extends Array<Record<string, any>>>(target: T, ...sources: S): Mixin<T, S>;
createTimeoutForPromise<T>(promise: PromiseLike<T>, timeout: number): Promise<T>;
connect(url: string, opts?: { method?: string, headers?: { [header: string]: any } }): Promise<import("net").Socket>;
socketToRequest(socket: import("net").Socket): Promise<ConnectionResponse>;
requestBody(req: import("http").IncomingMessage, timeout?: number): Promise<Buffer>;
/** An improved JSON.stringify that supports BigInts and Circular references, which can produce bad results and is mostly for logging */
stringify(data: any, ignoreQuotes?: boolean): string;
getStats(): Promise<{ players: number, playingPlayers: number, uptime: number, memory: { reservable: number, used: number, free: number, allocated: number }, cpu: { cores: number, systemLoad: number, lavalinkLoad: number }, frameStats: { sent: number, nulled: number, deficit: number } }>
}
export interface ConnectionResponseEvents {
headers: [ConnectionResponse["headers"]];
readable: [];
data: [any];
end: [];
close: [];
error: [Error];
}
export interface ConnectionResponse {
addListener<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
emit<E extends keyof ConnectionResponseEvents>(event: E, ...args: ConnectionResponseEvents[E]): boolean;
eventNames(): Array<keyof ConnectionResponseEvents>;
listenerCount(event: keyof ConnectionResponseEvents): number;
listeners(event: keyof ConnectionResponseEvents): Array<(...args: Array<any>) => any>;
off<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
on<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
once<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
prependListener<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
prependOnceListener<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
rawListeners(event: keyof ConnectionResponseEvents): Array<(...args: Array<any>) => any>;
removeAllListeners(event?: keyof ConnectionResponseEvents): this;
removeListener<E extends keyof ConnectionResponseEvents>(event: E, listener: (...args: ConnectionResponseEvents[E]) => any): this;
}
export class ConnectionResponse extends Transform {
public headers: { [header: string]: string };
/**
* Example: HTTP/1.1 or ICY
*/
public protocol: string;
/**
* The HTTP status code like 200
*/
public status: number;
/**
* The HTTP message if available, otherwise an empty string
*/
public message: string;
}
export type TrackInfo = {
title: string;
author: string;
identifier: string;
uri: string;
length: number;
isStream: boolean;
}
export type TrackData = {
entries: Array<TrackInfo>,
plData?: {
name: string;
selectedTrack: number;
}
}
export type StreamData = {
type?: string;
stream: import("stream").Readable;
}
export type LavaLinkConfig = {
server?: {
port?: number;
address?: string;
};
spring?: {
main?: {
"banner-mode"?: "log";
};
};
lavalink?: {
server?: {
password?: string;
youtubeCookie?: string;
sources?: {
youtube?: boolean,
bandcamp?: boolean,
soundcloud?: boolean,
twitch?: boolean,
http?: boolean,
local?: boolean
};
trackStuckThresholdMs: number;
youtubePlaylistLoadLimit?: number;
playerUpdateInterval?: number;
youtubeSearchEnabled?: boolean;
youtubeTimeout?: number;
soundcloudSearchEnabled?: boolean;
"gc-warnings"?: boolean;
ratelimit?: {
ipBlocks?: Array<string>;
excludedIps?: Array<string>;
strategy?: "RotateOnBan" | "LoadBalance" | "NanoSwitch" | "RotatingNanoSwitch";
searchTriggersFail?: boolean;
retryLimit?: number;
};
};
};
logging?: {
file?: {
"max-history"?: number;
"max-size"?: string;
};
path?: string;
level?: {
root?: "INFO" | "WARN" | "ERROR";
lavalink?: "INFO" | "WARN" | "ERROR";
};
};
}
export class SingleUseMap<K, V> extends Map<K, V> {
public use(key: K): V | undefined;
}
export class ThreadBasedReplier extends EventEmitter {
public outgoing:SingleUseMap<string, (value: unknown) => void>;
public outgoingPersist: Set<string>;
public lastThreadID: number;
public nextThreadID(): string;
public buildRequest(op: number, data: any): { threadID: string; op: number; data: any; };
public baseRequest(op: number, data: any, sendFn: (data: any) => any): Promise<any>;
}
export type ThreadMessage = {
op: number;
data?: any;
}
export interface ThreadPoolEvents {
message: [number, any];
spawn: [number, Worker];
ready: [number, Worker];
death: [number];
datareq: [number, any];
}
export interface ThreadPool {
addListener<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
emit<E extends keyof ThreadPoolEvents>(event: E, ...args: ThreadPoolEvents[E]): boolean;
eventNames(): Array<keyof ThreadPoolEvents>;
listenerCount(event: keyof ThreadPoolEvents): number;
listeners(event: keyof ThreadPoolEvents): Array<(...args: Array<any>) => any>;
off<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
on<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
once<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
prependListener<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
prependOnceListener<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
rawListeners(event: keyof ThreadPoolEvents): Array<(...args: Array<any>) => any>;
removeAllListeners(event?: keyof ThreadPoolEvents): this;
removeListener<E extends keyof ThreadPoolEvents>(event: E, listener: (...args: ThreadPoolEvents[E]) => any): this;
}
export class ThreadPool extends ThreadBasedReplier {
public count: number;
public dir: string;
public children: Map<number, Worker>;
public taskSizeMap: Map<number, number>;
public constructor(options: { size: number; dir: string; })
public execute(message: ThreadMessage): Promise<any>;
public dump(): Promise<void>;
public send(id: number, message: ThreadMessage): Promise<any>;
public broadcast(message: ThreadMessage): Promise<Array<any>>;
}
export class Plugin {
public logger: Logger;
public utils: Utils;
public version: string;
public source?: string;
public searchShorts?: Array<string>;
public constructor(logger: Logger, utils: Utils);
public initialize?(): any;
public canBeUsed?(resource: string, searchShort?: string): boolean;
public infoHandler?(resource: string, searchShort?: string): TrackData | Promise<TrackData>;
public streamHandler?(info: any, usingFFMPEG: boolean): StreamData | Promise<StreamData>;
public streamPipeline?(stream: import("stream").Readable, filters?: Array<string>): StreamData | Promise<StreamData>;
public onWSMessage?(packet: Record<any, any>, socket: WebSocket): any;
public routeHandler?(url: URL, req: import("http").IncomingMessage, res: import("http").ServerResponse): any;
}