@borealise/api 1.0.0
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 +205 -0
- package/dist/index.d.mts +569 -0
- package/dist/index.d.ts +569 -0
- package/dist/index.js +623 -0
- package/dist/index.mjs +571 -0
- package/package.json +51 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
interface ApiConfig {
|
|
4
|
+
baseURL: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
/** Set to false to suppress all log output. Defaults to true. */
|
|
8
|
+
logging?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface ApiResponse<T = unknown> {
|
|
11
|
+
data: T;
|
|
12
|
+
status: number;
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
interface BackendErrorResponse {
|
|
16
|
+
success: false;
|
|
17
|
+
error: string;
|
|
18
|
+
}
|
|
19
|
+
declare class ApiError extends Error {
|
|
20
|
+
readonly status?: number;
|
|
21
|
+
readonly code?: string;
|
|
22
|
+
readonly response?: BackendErrorResponse;
|
|
23
|
+
constructor(message: string, status?: number, code?: string, response?: BackendErrorResponse);
|
|
24
|
+
}
|
|
25
|
+
declare class Api {
|
|
26
|
+
private static instance;
|
|
27
|
+
private readonly axios;
|
|
28
|
+
private readonly logger;
|
|
29
|
+
private readonly config;
|
|
30
|
+
private constructor();
|
|
31
|
+
static getInstance(config?: ApiConfig): Api;
|
|
32
|
+
/** Reset the singleton (useful for testing or re-initializing with a new config) */
|
|
33
|
+
static reset(): void;
|
|
34
|
+
private setupInterceptors;
|
|
35
|
+
private parseError;
|
|
36
|
+
setAuthToken(token: string | null): void;
|
|
37
|
+
setHeader(key: string, value: string): void;
|
|
38
|
+
removeHeader(key: string): void;
|
|
39
|
+
get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
40
|
+
post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
41
|
+
put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
42
|
+
patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
43
|
+
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
44
|
+
private wrapResponse;
|
|
45
|
+
get axiosInstance(): AxiosInstance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare class Logger {
|
|
49
|
+
private readonly name;
|
|
50
|
+
private enabled;
|
|
51
|
+
private constructor();
|
|
52
|
+
static create(name: string): Logger;
|
|
53
|
+
enable(): void;
|
|
54
|
+
disable(): void;
|
|
55
|
+
private log;
|
|
56
|
+
debug(message: string, ...args: unknown[]): void;
|
|
57
|
+
info(message: string, ...args: unknown[]): void;
|
|
58
|
+
success(message: string, ...args: unknown[]): void;
|
|
59
|
+
error(message: string, ...args: unknown[]): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface PaginatedResponse<T> {
|
|
63
|
+
data: T[];
|
|
64
|
+
meta: {
|
|
65
|
+
total: number;
|
|
66
|
+
page: number;
|
|
67
|
+
perPage: number;
|
|
68
|
+
lastPage: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
interface ResourceOptions {
|
|
72
|
+
params?: Record<string, unknown>;
|
|
73
|
+
headers?: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
declare abstract class ApiResource<T = unknown> {
|
|
76
|
+
private _logger;
|
|
77
|
+
protected abstract readonly endpoint: string;
|
|
78
|
+
protected get api(): Api;
|
|
79
|
+
protected get logger(): Logger;
|
|
80
|
+
protected buildUrl(path?: string | number): string;
|
|
81
|
+
protected buildConfig(options?: ResourceOptions): AxiosRequestConfig;
|
|
82
|
+
index(options?: ResourceOptions): Promise<ApiResponse<T[]>>;
|
|
83
|
+
paginate(page?: number, perPage?: number, options?: ResourceOptions): Promise<ApiResponse<PaginatedResponse<T>>>;
|
|
84
|
+
show(id: string | number, options?: ResourceOptions): Promise<ApiResponse<T>>;
|
|
85
|
+
store(data: Partial<T>, options?: ResourceOptions): Promise<ApiResponse<T>>;
|
|
86
|
+
update(id: string | number, data: Partial<T>, options?: ResourceOptions): Promise<ApiResponse<T>>;
|
|
87
|
+
patch(id: string | number, data: Partial<T>, options?: ResourceOptions): Promise<ApiResponse<T>>;
|
|
88
|
+
destroy(id: string | number, options?: ResourceOptions): Promise<ApiResponse<void>>;
|
|
89
|
+
protected get<R = T>(path: string, options?: ResourceOptions): Promise<ApiResponse<R>>;
|
|
90
|
+
protected post<R = T>(path: string, data?: unknown, options?: ResourceOptions): Promise<ApiResponse<R>>;
|
|
91
|
+
protected put<R = T>(path: string, data?: unknown, options?: ResourceOptions): Promise<ApiResponse<R>>;
|
|
92
|
+
protected delete<R = void>(path: string, options?: ResourceOptions): Promise<ApiResponse<R>>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface AuthUser {
|
|
96
|
+
id: number;
|
|
97
|
+
email?: string;
|
|
98
|
+
username: string;
|
|
99
|
+
displayName: string | null;
|
|
100
|
+
bio: string | null;
|
|
101
|
+
globalRole: string;
|
|
102
|
+
flags?: number;
|
|
103
|
+
subscriptionType?: string;
|
|
104
|
+
subscriptionExpiresAt?: string | null;
|
|
105
|
+
emailVerified?: boolean;
|
|
106
|
+
createdAt?: string;
|
|
107
|
+
}
|
|
108
|
+
interface LoginCredentials {
|
|
109
|
+
login: string;
|
|
110
|
+
password: string;
|
|
111
|
+
}
|
|
112
|
+
interface RegisterData {
|
|
113
|
+
email: string;
|
|
114
|
+
username: string;
|
|
115
|
+
password: string;
|
|
116
|
+
displayName?: string;
|
|
117
|
+
}
|
|
118
|
+
interface AuthResponse {
|
|
119
|
+
success: boolean;
|
|
120
|
+
message?: string;
|
|
121
|
+
data: {
|
|
122
|
+
user: AuthUser;
|
|
123
|
+
accessToken: string;
|
|
124
|
+
refreshToken: string;
|
|
125
|
+
expiresAt: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
interface RefreshResponse {
|
|
129
|
+
success: boolean;
|
|
130
|
+
data: {
|
|
131
|
+
accessToken: string;
|
|
132
|
+
refreshToken: string;
|
|
133
|
+
expiresAt: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
interface MeResponse {
|
|
137
|
+
success: boolean;
|
|
138
|
+
data: {
|
|
139
|
+
user: AuthUser;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
declare class AuthResource extends ApiResource<AuthUser> {
|
|
143
|
+
protected readonly endpoint = "/auth";
|
|
144
|
+
login(credentials: LoginCredentials): Promise<ApiResponse<AuthResponse>>;
|
|
145
|
+
register(data: RegisterData): Promise<ApiResponse<AuthResponse>>;
|
|
146
|
+
refresh(refreshToken: string): Promise<ApiResponse<RefreshResponse>>;
|
|
147
|
+
logout(): Promise<ApiResponse<{
|
|
148
|
+
success: boolean;
|
|
149
|
+
message: string;
|
|
150
|
+
}>>;
|
|
151
|
+
me(): Promise<ApiResponse<MeResponse>>;
|
|
152
|
+
}
|
|
153
|
+
declare const authResource: AuthResource;
|
|
154
|
+
|
|
155
|
+
interface User extends AuthUser {
|
|
156
|
+
}
|
|
157
|
+
interface UpdateProfileData {
|
|
158
|
+
displayName?: string;
|
|
159
|
+
bio?: string;
|
|
160
|
+
}
|
|
161
|
+
interface UserResponse {
|
|
162
|
+
success: boolean;
|
|
163
|
+
data: {
|
|
164
|
+
user: User;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
declare class UserResource extends ApiResource<User> {
|
|
168
|
+
protected readonly endpoint = "/users";
|
|
169
|
+
getById(id: number): Promise<ApiResponse<User>>;
|
|
170
|
+
getByUsername(username: string): Promise<ApiResponse<UserResponse>>;
|
|
171
|
+
updateProfile(data: UpdateProfileData): Promise<ApiResponse<UserResponse>>;
|
|
172
|
+
deleteAccount(): Promise<ApiResponse<{
|
|
173
|
+
success: boolean;
|
|
174
|
+
message: string;
|
|
175
|
+
}>>;
|
|
176
|
+
}
|
|
177
|
+
declare const userResource: UserResource;
|
|
178
|
+
|
|
179
|
+
type RoomRole = 'user' | 'resident_dj' | 'bouncer' | 'manager' | 'cohost' | 'host';
|
|
180
|
+
interface Room {
|
|
181
|
+
id: number;
|
|
182
|
+
slug: string;
|
|
183
|
+
name: string;
|
|
184
|
+
description: string | null;
|
|
185
|
+
welcomeMessage: string | null;
|
|
186
|
+
hostId: number;
|
|
187
|
+
minChatLevel: number;
|
|
188
|
+
isPrivate: boolean;
|
|
189
|
+
isNsfw: boolean;
|
|
190
|
+
waitlistLocked: boolean;
|
|
191
|
+
waitlistCycleEnabled: boolean;
|
|
192
|
+
population: number;
|
|
193
|
+
totalPlays: number;
|
|
194
|
+
isFeatured: boolean;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
}
|
|
198
|
+
interface RoomMember {
|
|
199
|
+
id: number;
|
|
200
|
+
roomId: number;
|
|
201
|
+
userId: number;
|
|
202
|
+
role: RoomRole;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
updatedAt: string;
|
|
205
|
+
user?: {
|
|
206
|
+
id: number;
|
|
207
|
+
username: string;
|
|
208
|
+
displayName: string | null;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
interface CreateRoomData {
|
|
212
|
+
slug: string;
|
|
213
|
+
name: string;
|
|
214
|
+
description?: string;
|
|
215
|
+
welcomeMessage?: string;
|
|
216
|
+
isPrivate?: boolean;
|
|
217
|
+
isNsfw?: boolean;
|
|
218
|
+
}
|
|
219
|
+
interface UpdateRoomData {
|
|
220
|
+
name?: string;
|
|
221
|
+
description?: string;
|
|
222
|
+
welcomeMessage?: string;
|
|
223
|
+
minChatLevel?: number;
|
|
224
|
+
isPrivate?: boolean;
|
|
225
|
+
isNsfw?: boolean;
|
|
226
|
+
waitlistLocked?: boolean;
|
|
227
|
+
waitlistCycleEnabled?: boolean;
|
|
228
|
+
}
|
|
229
|
+
interface RoomResponse {
|
|
230
|
+
success: boolean;
|
|
231
|
+
data: {
|
|
232
|
+
room: Room;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
interface RoomsResponse {
|
|
236
|
+
success: boolean;
|
|
237
|
+
data: {
|
|
238
|
+
rooms: Room[];
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface RoomStaffResponse {
|
|
242
|
+
success: boolean;
|
|
243
|
+
data: {
|
|
244
|
+
staff: RoomMember[];
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
interface FeaturedRoomsResponse {
|
|
248
|
+
success: boolean;
|
|
249
|
+
data: {
|
|
250
|
+
rooms: Room[];
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
interface RoomUserState {
|
|
254
|
+
userId: number;
|
|
255
|
+
username: string;
|
|
256
|
+
displayName: string | null;
|
|
257
|
+
role: RoomRole;
|
|
258
|
+
joinedAt: number;
|
|
259
|
+
}
|
|
260
|
+
interface BoothDJ {
|
|
261
|
+
userId: number;
|
|
262
|
+
username: string;
|
|
263
|
+
displayName: string | null;
|
|
264
|
+
role: RoomRole;
|
|
265
|
+
}
|
|
266
|
+
interface BoothMedia {
|
|
267
|
+
id: number;
|
|
268
|
+
source: 'youtube' | 'soundcloud';
|
|
269
|
+
sourceId: string;
|
|
270
|
+
title: string;
|
|
271
|
+
artist: string | null;
|
|
272
|
+
duration: number;
|
|
273
|
+
thumbnail: string | null;
|
|
274
|
+
elapsed: number;
|
|
275
|
+
}
|
|
276
|
+
interface WaitlistUser {
|
|
277
|
+
id: number;
|
|
278
|
+
username: string;
|
|
279
|
+
displayName: string | null;
|
|
280
|
+
}
|
|
281
|
+
interface BoothState {
|
|
282
|
+
dj: BoothDJ | null;
|
|
283
|
+
media: BoothMedia | null;
|
|
284
|
+
waitlist: number[];
|
|
285
|
+
votes: {
|
|
286
|
+
woots: number;
|
|
287
|
+
mehs: number;
|
|
288
|
+
grabs: number;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
interface JoinRoomResponse {
|
|
292
|
+
success: boolean;
|
|
293
|
+
data: {
|
|
294
|
+
room: {
|
|
295
|
+
id: number;
|
|
296
|
+
slug: string;
|
|
297
|
+
name: string;
|
|
298
|
+
waitlistLocked: boolean;
|
|
299
|
+
waitlistCycleEnabled: boolean;
|
|
300
|
+
};
|
|
301
|
+
role: RoomRole;
|
|
302
|
+
users: RoomUserState[];
|
|
303
|
+
booth: BoothState;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
interface WaitlistResponse {
|
|
307
|
+
success: boolean;
|
|
308
|
+
data: {
|
|
309
|
+
waitlist: WaitlistUser[];
|
|
310
|
+
locked: boolean;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
interface BoothResponse {
|
|
314
|
+
success: boolean;
|
|
315
|
+
data: BoothState;
|
|
316
|
+
}
|
|
317
|
+
interface VoteResponse {
|
|
318
|
+
success: boolean;
|
|
319
|
+
data: {
|
|
320
|
+
vote: 'woot' | 'meh';
|
|
321
|
+
votes: {
|
|
322
|
+
woots: number;
|
|
323
|
+
mehs: number;
|
|
324
|
+
grabs: number;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
interface GrabResponse {
|
|
329
|
+
success: boolean;
|
|
330
|
+
data: {
|
|
331
|
+
playlistId: number;
|
|
332
|
+
message: string;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
declare class RoomResource extends ApiResource<Room> {
|
|
336
|
+
protected readonly endpoint = "/rooms";
|
|
337
|
+
list(): Promise<ApiResponse<RoomsResponse>>;
|
|
338
|
+
featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
|
|
339
|
+
getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
|
|
340
|
+
create(data: CreateRoomData): Promise<ApiResponse<RoomResponse>>;
|
|
341
|
+
updateRoom(slug: string, data: UpdateRoomData): Promise<ApiResponse<RoomResponse>>;
|
|
342
|
+
deleteRoom(slug: string): Promise<ApiResponse<{
|
|
343
|
+
success: boolean;
|
|
344
|
+
}>>;
|
|
345
|
+
getStaff(slug: string): Promise<ApiResponse<RoomStaffResponse>>;
|
|
346
|
+
updateStaffRole(slug: string, userId: number, role: RoomRole): Promise<ApiResponse<{
|
|
347
|
+
success: boolean;
|
|
348
|
+
}>>;
|
|
349
|
+
removeStaff(slug: string, userId: number): Promise<ApiResponse<{
|
|
350
|
+
success: boolean;
|
|
351
|
+
}>>;
|
|
352
|
+
join(slug: string): Promise<ApiResponse<JoinRoomResponse>>;
|
|
353
|
+
leave(slug: string): Promise<ApiResponse<{
|
|
354
|
+
success: boolean;
|
|
355
|
+
}>>;
|
|
356
|
+
getWaitlist(slug: string): Promise<ApiResponse<WaitlistResponse>>;
|
|
357
|
+
joinWaitlist(slug: string): Promise<ApiResponse<{
|
|
358
|
+
success: boolean;
|
|
359
|
+
data: {
|
|
360
|
+
position: number;
|
|
361
|
+
};
|
|
362
|
+
}>>;
|
|
363
|
+
leaveWaitlist(slug: string): Promise<ApiResponse<{
|
|
364
|
+
success: boolean;
|
|
365
|
+
}>>;
|
|
366
|
+
moveInWaitlist(slug: string, userId: number, position: number): Promise<ApiResponse<{
|
|
367
|
+
success: boolean;
|
|
368
|
+
data: {
|
|
369
|
+
waitlist: WaitlistUser[];
|
|
370
|
+
};
|
|
371
|
+
}>>;
|
|
372
|
+
removeFromWaitlist(slug: string, userId: number): Promise<ApiResponse<{
|
|
373
|
+
success: boolean;
|
|
374
|
+
}>>;
|
|
375
|
+
lockWaitlist(slug: string): Promise<ApiResponse<{
|
|
376
|
+
success: boolean;
|
|
377
|
+
data: {
|
|
378
|
+
locked: boolean;
|
|
379
|
+
};
|
|
380
|
+
}>>;
|
|
381
|
+
unlockWaitlist(slug: string): Promise<ApiResponse<{
|
|
382
|
+
success: boolean;
|
|
383
|
+
data: {
|
|
384
|
+
locked: boolean;
|
|
385
|
+
};
|
|
386
|
+
}>>;
|
|
387
|
+
getBooth(slug: string): Promise<ApiResponse<BoothResponse>>;
|
|
388
|
+
skipTrack(slug: string, options?: {
|
|
389
|
+
stayInBooth?: boolean;
|
|
390
|
+
}): Promise<ApiResponse<{
|
|
391
|
+
success: boolean;
|
|
392
|
+
data?: {
|
|
393
|
+
stayedInBooth: boolean;
|
|
394
|
+
};
|
|
395
|
+
}>>;
|
|
396
|
+
vote(slug: string, type: 'woot' | 'meh'): Promise<ApiResponse<VoteResponse>>;
|
|
397
|
+
grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
|
|
398
|
+
}
|
|
399
|
+
declare const roomResource: RoomResource;
|
|
400
|
+
|
|
401
|
+
interface ChatMessage {
|
|
402
|
+
id: string;
|
|
403
|
+
roomId: number;
|
|
404
|
+
userId: number;
|
|
405
|
+
username: string;
|
|
406
|
+
displayName: string | null;
|
|
407
|
+
role: RoomRole;
|
|
408
|
+
content: string;
|
|
409
|
+
timestamp: number;
|
|
410
|
+
deleted?: boolean;
|
|
411
|
+
}
|
|
412
|
+
interface SendMessageData {
|
|
413
|
+
content: string;
|
|
414
|
+
}
|
|
415
|
+
interface ChatMessagesResponse {
|
|
416
|
+
success: boolean;
|
|
417
|
+
data: {
|
|
418
|
+
messages: ChatMessage[];
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
interface ChatMessageResponse {
|
|
422
|
+
success: boolean;
|
|
423
|
+
data: {
|
|
424
|
+
message: ChatMessage;
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
declare class ChatResource extends ApiResource<ChatMessage> {
|
|
428
|
+
protected readonly endpoint = "/rooms";
|
|
429
|
+
sendMessage(slug: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
430
|
+
getMessages(slug: string, before?: string, limit?: number): Promise<ApiResponse<ChatMessagesResponse>>;
|
|
431
|
+
deleteMessage(slug: string, messageId: string): Promise<ApiResponse<{
|
|
432
|
+
success: boolean;
|
|
433
|
+
}>>;
|
|
434
|
+
}
|
|
435
|
+
declare const chatResource: ChatResource;
|
|
436
|
+
|
|
437
|
+
type MediaSource = 'youtube' | 'soundcloud';
|
|
438
|
+
interface MediaItem {
|
|
439
|
+
id: number;
|
|
440
|
+
playlistId: number;
|
|
441
|
+
source: MediaSource;
|
|
442
|
+
sourceId: string;
|
|
443
|
+
title: string;
|
|
444
|
+
artist: string | null;
|
|
445
|
+
duration: number;
|
|
446
|
+
thumbnail: string | null;
|
|
447
|
+
position: number;
|
|
448
|
+
createdAt: string;
|
|
449
|
+
updatedAt: string;
|
|
450
|
+
}
|
|
451
|
+
interface Playlist {
|
|
452
|
+
id: number;
|
|
453
|
+
userId: number;
|
|
454
|
+
name: string;
|
|
455
|
+
isActive: boolean;
|
|
456
|
+
itemCount?: number;
|
|
457
|
+
items?: MediaItem[];
|
|
458
|
+
createdAt: string;
|
|
459
|
+
updatedAt: string;
|
|
460
|
+
}
|
|
461
|
+
interface PlaylistsResponse {
|
|
462
|
+
success: boolean;
|
|
463
|
+
data: {
|
|
464
|
+
playlists: Playlist[];
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
interface PlaylistResponse {
|
|
468
|
+
success: boolean;
|
|
469
|
+
data: {
|
|
470
|
+
playlist: Playlist;
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
interface MediaItemResponse {
|
|
474
|
+
success: boolean;
|
|
475
|
+
data: {
|
|
476
|
+
item: MediaItem;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
interface AddMediaData {
|
|
480
|
+
source: MediaSource;
|
|
481
|
+
sourceId: string;
|
|
482
|
+
}
|
|
483
|
+
interface ShuffleResponse {
|
|
484
|
+
success: boolean;
|
|
485
|
+
data: {
|
|
486
|
+
shuffled: boolean;
|
|
487
|
+
items?: MediaItem[];
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
interface ImportPlaylistData {
|
|
491
|
+
source?: MediaSource;
|
|
492
|
+
url: string;
|
|
493
|
+
}
|
|
494
|
+
interface ImportResult {
|
|
495
|
+
imported: number;
|
|
496
|
+
skipped: number;
|
|
497
|
+
failed: number;
|
|
498
|
+
errors: string[];
|
|
499
|
+
reachedLimit: boolean;
|
|
500
|
+
}
|
|
501
|
+
interface ImportPlaylistResponse {
|
|
502
|
+
success: boolean;
|
|
503
|
+
data: ImportResult;
|
|
504
|
+
}
|
|
505
|
+
declare class PlaylistResource extends ApiResource<Playlist> {
|
|
506
|
+
protected readonly endpoint = "/playlists";
|
|
507
|
+
getAll(): Promise<ApiResponse<PlaylistsResponse>>;
|
|
508
|
+
getById(playlistId: number): Promise<ApiResponse<PlaylistResponse>>;
|
|
509
|
+
create(name: string): Promise<ApiResponse<PlaylistResponse>>;
|
|
510
|
+
rename(playlistId: number, name: string): Promise<ApiResponse<PlaylistResponse>>;
|
|
511
|
+
remove(playlistId: number): Promise<ApiResponse<{
|
|
512
|
+
success: boolean;
|
|
513
|
+
}>>;
|
|
514
|
+
activate(playlistId: number): Promise<ApiResponse<PlaylistResponse>>;
|
|
515
|
+
shuffle(playlistId: number): Promise<ApiResponse<ShuffleResponse>>;
|
|
516
|
+
addItem(playlistId: number, data: AddMediaData): Promise<ApiResponse<MediaItemResponse>>;
|
|
517
|
+
removeItem(playlistId: number, itemId: number): Promise<ApiResponse<{
|
|
518
|
+
success: boolean;
|
|
519
|
+
}>>;
|
|
520
|
+
moveItem(playlistId: number, itemId: number, position: number): Promise<ApiResponse<MediaItemResponse>>;
|
|
521
|
+
importPlaylist(playlistId: number, data: ImportPlaylistData): Promise<ApiResponse<ImportPlaylistResponse>>;
|
|
522
|
+
}
|
|
523
|
+
declare const playlistResource: PlaylistResource;
|
|
524
|
+
|
|
525
|
+
interface MediaSearchResult {
|
|
526
|
+
source: MediaSource;
|
|
527
|
+
sourceId: string;
|
|
528
|
+
title: string;
|
|
529
|
+
artist: string;
|
|
530
|
+
duration: number;
|
|
531
|
+
thumbnail: string | null;
|
|
532
|
+
permalink?: string;
|
|
533
|
+
}
|
|
534
|
+
interface YouTubeSearchResponse {
|
|
535
|
+
success: boolean;
|
|
536
|
+
data: {
|
|
537
|
+
results: MediaSearchResult[];
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
interface YouTubeVideoResponse {
|
|
541
|
+
success: boolean;
|
|
542
|
+
data: {
|
|
543
|
+
video: MediaSearchResult;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
interface SoundCloudSearchResponse {
|
|
547
|
+
success: boolean;
|
|
548
|
+
data: {
|
|
549
|
+
results: MediaSearchResult[];
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
interface SoundCloudTrackResponse {
|
|
553
|
+
success: boolean;
|
|
554
|
+
data: {
|
|
555
|
+
track: MediaSearchResult;
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
declare class SourceResource extends ApiResource<MediaSearchResult> {
|
|
559
|
+
protected readonly endpoint = "/sources";
|
|
560
|
+
searchYouTube(query: string, limit?: number): Promise<ApiResponse<YouTubeSearchResponse>>;
|
|
561
|
+
getYouTubeVideo(videoId: string): Promise<ApiResponse<YouTubeVideoResponse>>;
|
|
562
|
+
searchSoundCloud(query: string, limit?: number): Promise<ApiResponse<SoundCloudSearchResponse>>;
|
|
563
|
+
getSoundCloudTrack(trackId: string): Promise<ApiResponse<SoundCloudTrackResponse>>;
|
|
564
|
+
resolveSoundCloudUrl(url: string): Promise<ApiResponse<SoundCloudTrackResponse>>;
|
|
565
|
+
searchAll(query: string, limit?: number): Promise<MediaSearchResult[]>;
|
|
566
|
+
}
|
|
567
|
+
declare const sourceResource: SourceResource;
|
|
568
|
+
|
|
569
|
+
export { type AddMediaData, Api, type ApiConfig, ApiError, ApiResource, type ApiResponse, AuthResource, type AuthResponse, type AuthUser, type BackendErrorResponse, type BoothDJ, type BoothMedia, type BoothResponse, type BoothState, type ChatMessage, type ChatMessageResponse, type ChatMessagesResponse, ChatResource, type CreateRoomData, type FeaturedRoomsResponse, type GrabResponse, type ImportPlaylistData, type ImportPlaylistResponse, type ImportResult, type JoinRoomResponse, Logger, type LoginCredentials, type MeResponse, type MediaItem, type MediaItemResponse, type MediaSearchResult, type MediaSource, type PaginatedResponse, type Playlist, PlaylistResource, type PlaylistResponse, type PlaylistsResponse, type RefreshResponse, type RegisterData, type ResourceOptions, type Room, type RoomMember, RoomResource, type RoomResponse, type RoomRole, type RoomStaffResponse, type RoomUserState, type RoomsResponse, type SendMessageData, type ShuffleResponse, type SoundCloudSearchResponse, type SoundCloudTrackResponse, SourceResource, type UpdateProfileData, type UpdateRoomData, type User, UserResource, type UserResponse, type VoteResponse, type WaitlistResponse, type WaitlistUser, type YouTubeSearchResponse, type YouTubeVideoResponse, authResource, chatResource, playlistResource, roomResource, sourceResource, userResource };
|