@borealise/api 1.1.11 → 2.0.0-alpha.1
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 +286 -205
- package/dist/index.d.mts +42 -81
- package/dist/index.d.ts +42 -81
- package/dist/index.js +179 -545
- package/dist/index.mjs +168 -526
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -23,14 +23,10 @@ declare class ApiError extends Error {
|
|
|
23
23
|
constructor(message: string, status?: number, code?: string, response?: BackendErrorResponse);
|
|
24
24
|
}
|
|
25
25
|
declare class Api {
|
|
26
|
-
private static instance;
|
|
27
26
|
private readonly axios;
|
|
28
27
|
private readonly logger;
|
|
29
28
|
private readonly config;
|
|
30
|
-
|
|
31
|
-
static getInstance(config?: ApiConfig): Api;
|
|
32
|
-
/** Reset the singleton (useful for testing or re-initializing with a new config) */
|
|
33
|
-
static reset(): void;
|
|
29
|
+
constructor(config: ApiConfig);
|
|
34
30
|
private setupInterceptors;
|
|
35
31
|
private parseError;
|
|
36
32
|
setAuthToken(token: string | null): void;
|
|
@@ -44,11 +40,12 @@ declare class Api {
|
|
|
44
40
|
private wrapResponse;
|
|
45
41
|
get axiosInstance(): AxiosInstance;
|
|
46
42
|
}
|
|
43
|
+
declare const createApi: (config: ApiConfig) => Api;
|
|
47
44
|
|
|
48
45
|
declare class Logger {
|
|
49
46
|
private readonly name;
|
|
50
47
|
private enabled;
|
|
51
|
-
|
|
48
|
+
constructor(name: string, enabled?: boolean);
|
|
52
49
|
static create(name: string): Logger;
|
|
53
50
|
enable(): void;
|
|
54
51
|
disable(): void;
|
|
@@ -59,39 +56,6 @@ declare class Logger {
|
|
|
59
56
|
error(message: string, ...args: unknown[]): void;
|
|
60
57
|
}
|
|
61
58
|
|
|
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
59
|
interface AuthUser {
|
|
96
60
|
id: number;
|
|
97
61
|
email?: string;
|
|
@@ -144,8 +108,7 @@ interface MeResponse {
|
|
|
144
108
|
user: AuthUser;
|
|
145
109
|
};
|
|
146
110
|
}
|
|
147
|
-
|
|
148
|
-
protected readonly endpoint = "/auth";
|
|
111
|
+
interface AuthResource {
|
|
149
112
|
login(credentials: LoginCredentials): Promise<ApiResponse<AuthResponse>>;
|
|
150
113
|
register(data: RegisterData): Promise<ApiResponse<AuthResponse>>;
|
|
151
114
|
refresh(refreshToken: string): Promise<ApiResponse<RefreshResponse>>;
|
|
@@ -155,7 +118,7 @@ declare class AuthResource extends ApiResource<AuthUser> {
|
|
|
155
118
|
}>>;
|
|
156
119
|
me(): Promise<ApiResponse<MeResponse>>;
|
|
157
120
|
}
|
|
158
|
-
declare const
|
|
121
|
+
declare const createAuthResource: (api: Api) => AuthResource;
|
|
159
122
|
|
|
160
123
|
interface User extends AuthUser {
|
|
161
124
|
}
|
|
@@ -170,9 +133,8 @@ interface UserResponse {
|
|
|
170
133
|
user: User;
|
|
171
134
|
};
|
|
172
135
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
getById(id: number): Promise<ApiResponse<User>>;
|
|
136
|
+
interface UserResource {
|
|
137
|
+
getById(id: number): Promise<ApiResponse<UserResponse>>;
|
|
176
138
|
getByUsername(username: string): Promise<ApiResponse<UserResponse>>;
|
|
177
139
|
updateProfile(data: UpdateProfileData): Promise<ApiResponse<UserResponse>>;
|
|
178
140
|
deleteAccount(): Promise<ApiResponse<{
|
|
@@ -185,7 +147,7 @@ declare class UserResource extends ApiResource<User> {
|
|
|
185
147
|
data: null;
|
|
186
148
|
}>>;
|
|
187
149
|
}
|
|
188
|
-
declare const
|
|
150
|
+
declare const createUserResource: (api: Api) => UserResource;
|
|
189
151
|
|
|
190
152
|
type RoomRole = 'user' | 'resident_dj' | 'bouncer' | 'manager' | 'cohost' | 'host';
|
|
191
153
|
interface Room {
|
|
@@ -368,11 +330,8 @@ interface BoothState {
|
|
|
368
330
|
};
|
|
369
331
|
}
|
|
370
332
|
interface JoinMuteInfo {
|
|
371
|
-
/** ISO timestamp when the mute expires, or null if permanent */
|
|
372
333
|
expiresAt: string | null;
|
|
373
|
-
/** Seconds remaining until unmute, or null if permanent */
|
|
374
334
|
remainingSeconds: number | null;
|
|
375
|
-
/** Optional reason given by the moderator */
|
|
376
335
|
reason: string | null;
|
|
377
336
|
}
|
|
378
337
|
interface JoinRoomResponse {
|
|
@@ -388,7 +347,6 @@ interface JoinRoomResponse {
|
|
|
388
347
|
role: RoomRole;
|
|
389
348
|
users: RoomUserState[];
|
|
390
349
|
booth: BoothState;
|
|
391
|
-
/** Present when the joining user is currently muted in this room */
|
|
392
350
|
mute: JoinMuteInfo | null;
|
|
393
351
|
};
|
|
394
352
|
}
|
|
@@ -458,8 +416,7 @@ interface RoomHistoryResponse {
|
|
|
458
416
|
pagination: PaginationMeta;
|
|
459
417
|
};
|
|
460
418
|
}
|
|
461
|
-
|
|
462
|
-
protected readonly endpoint = "/rooms";
|
|
419
|
+
interface RoomResource {
|
|
463
420
|
list(): Promise<ApiResponse<RoomsResponse>>;
|
|
464
421
|
featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
|
|
465
422
|
getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
|
|
@@ -546,7 +503,7 @@ declare class RoomResource extends ApiResource<Room> {
|
|
|
546
503
|
grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
|
|
547
504
|
getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
|
|
548
505
|
}
|
|
549
|
-
declare const
|
|
506
|
+
declare const createRoomResource: (api: Api) => RoomResource;
|
|
550
507
|
|
|
551
508
|
interface ChatMessage {
|
|
552
509
|
id: string;
|
|
@@ -578,8 +535,7 @@ interface ChatMessageResponse {
|
|
|
578
535
|
message: ChatMessage;
|
|
579
536
|
};
|
|
580
537
|
}
|
|
581
|
-
|
|
582
|
-
protected readonly endpoint = "/rooms";
|
|
538
|
+
interface ChatResource {
|
|
583
539
|
sendMessage(slug: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
584
540
|
getMessages(slug: string, before?: string, limit?: number): Promise<ApiResponse<ChatMessagesResponse>>;
|
|
585
541
|
deleteMessage(slug: string, messageId: string): Promise<ApiResponse<{
|
|
@@ -587,13 +543,13 @@ declare class ChatResource extends ApiResource<ChatMessage> {
|
|
|
587
543
|
data: null;
|
|
588
544
|
}>>;
|
|
589
545
|
}
|
|
590
|
-
declare const
|
|
546
|
+
declare const createChatResource: (api: Api) => ChatResource;
|
|
591
547
|
|
|
592
|
-
type MediaSource = 'youtube' | 'soundcloud';
|
|
548
|
+
type MediaSource$1 = 'youtube' | 'soundcloud';
|
|
593
549
|
interface MediaItem {
|
|
594
550
|
id: number;
|
|
595
551
|
playlistId: number;
|
|
596
|
-
source: MediaSource;
|
|
552
|
+
source: MediaSource$1;
|
|
597
553
|
sourceId: string;
|
|
598
554
|
title: string;
|
|
599
555
|
artist: string | null;
|
|
@@ -632,7 +588,7 @@ interface MediaItemResponse {
|
|
|
632
588
|
};
|
|
633
589
|
}
|
|
634
590
|
interface AddMediaData {
|
|
635
|
-
source: MediaSource;
|
|
591
|
+
source: MediaSource$1;
|
|
636
592
|
sourceId: string;
|
|
637
593
|
}
|
|
638
594
|
interface ShuffleResponse {
|
|
@@ -643,7 +599,7 @@ interface ShuffleResponse {
|
|
|
643
599
|
};
|
|
644
600
|
}
|
|
645
601
|
interface ImportPlaylistData {
|
|
646
|
-
source?: MediaSource;
|
|
602
|
+
source?: MediaSource$1;
|
|
647
603
|
url: string;
|
|
648
604
|
}
|
|
649
605
|
interface ImportResult {
|
|
@@ -657,8 +613,7 @@ interface ImportPlaylistResponse {
|
|
|
657
613
|
success: boolean;
|
|
658
614
|
data: ImportResult;
|
|
659
615
|
}
|
|
660
|
-
|
|
661
|
-
protected readonly endpoint = "/playlists";
|
|
616
|
+
interface PlaylistResource {
|
|
662
617
|
getAll(): Promise<ApiResponse<PlaylistsResponse>>;
|
|
663
618
|
getById(playlistId: number): Promise<ApiResponse<PlaylistResponse>>;
|
|
664
619
|
create(name: string): Promise<ApiResponse<PlaylistResponse>>;
|
|
@@ -675,8 +630,9 @@ declare class PlaylistResource extends ApiResource<Playlist> {
|
|
|
675
630
|
moveItem(playlistId: number, itemId: number, position: number): Promise<ApiResponse<MediaItemResponse>>;
|
|
676
631
|
importPlaylist(playlistId: number, data: ImportPlaylistData): Promise<ApiResponse<ImportPlaylistResponse>>;
|
|
677
632
|
}
|
|
678
|
-
declare const
|
|
633
|
+
declare const createPlaylistResource: (api: Api) => PlaylistResource;
|
|
679
634
|
|
|
635
|
+
type MediaSource = 'youtube' | 'soundcloud';
|
|
680
636
|
interface MediaSearchResult {
|
|
681
637
|
source: MediaSource;
|
|
682
638
|
sourceId: string;
|
|
@@ -710,8 +666,7 @@ interface SoundCloudTrackResponse {
|
|
|
710
666
|
track: MediaSearchResult;
|
|
711
667
|
};
|
|
712
668
|
}
|
|
713
|
-
|
|
714
|
-
protected readonly endpoint = "/sources";
|
|
669
|
+
interface SourceResource {
|
|
715
670
|
searchYouTube(query: string, limit?: number): Promise<ApiResponse<YouTubeSearchResponse>>;
|
|
716
671
|
getYouTubeVideo(videoId: string): Promise<ApiResponse<YouTubeVideoResponse>>;
|
|
717
672
|
searchSoundCloud(query: string, limit?: number): Promise<ApiResponse<SoundCloudSearchResponse>>;
|
|
@@ -719,16 +674,14 @@ declare class SourceResource extends ApiResource<MediaSearchResult> {
|
|
|
719
674
|
resolveSoundCloudUrl(url: string): Promise<ApiResponse<SoundCloudTrackResponse>>;
|
|
720
675
|
searchAll(query: string, limit?: number): Promise<MediaSearchResult[]>;
|
|
721
676
|
}
|
|
722
|
-
declare const
|
|
677
|
+
declare const createSourceResource: (api: Api) => SourceResource;
|
|
723
678
|
|
|
724
679
|
type AvatarUnlockType = 'free' | 'level' | 'subscription';
|
|
725
680
|
interface AvatarCatalogItem {
|
|
726
681
|
id: string;
|
|
727
682
|
unlockType: AvatarUnlockType;
|
|
728
683
|
requiredLevel: number | null;
|
|
729
|
-
/** Whether the user has unlocked (or has free access to) this avatar */
|
|
730
684
|
unlocked: boolean;
|
|
731
|
-
/** Whether the user currently meets the requirement to unlock it */
|
|
732
685
|
eligible: boolean;
|
|
733
686
|
}
|
|
734
687
|
interface AvatarCatalogResponse {
|
|
@@ -739,11 +692,7 @@ interface AvatarCatalogResponse {
|
|
|
739
692
|
xp: number;
|
|
740
693
|
};
|
|
741
694
|
}
|
|
742
|
-
interface
|
|
743
|
-
avatarId: string;
|
|
744
|
-
}
|
|
745
|
-
declare class ShopResource extends ApiResource {
|
|
746
|
-
protected readonly endpoint = "/shop";
|
|
695
|
+
interface ShopResource {
|
|
747
696
|
getAvatarCatalog(): Promise<ApiResponse<AvatarCatalogResponse>>;
|
|
748
697
|
unlockAvatar(avatarId: string): Promise<ApiResponse<{
|
|
749
698
|
success: boolean;
|
|
@@ -759,7 +708,7 @@ declare class ShopResource extends ApiResource {
|
|
|
759
708
|
};
|
|
760
709
|
}>>;
|
|
761
710
|
}
|
|
762
|
-
declare const
|
|
711
|
+
declare const createShopResource: (api: Api) => ShopResource;
|
|
763
712
|
|
|
764
713
|
type SubscriptionPlan = 'monthly' | 'yearly';
|
|
765
714
|
interface SubscriptionStatus {
|
|
@@ -782,8 +731,7 @@ interface PortalResponse {
|
|
|
782
731
|
url: string;
|
|
783
732
|
};
|
|
784
733
|
}
|
|
785
|
-
|
|
786
|
-
protected readonly endpoint = "/subscriptions";
|
|
734
|
+
interface SubscriptionResource {
|
|
787
735
|
getStatus(): Promise<ApiResponse<{
|
|
788
736
|
success: boolean;
|
|
789
737
|
data: SubscriptionStatus;
|
|
@@ -794,7 +742,7 @@ declare class SubscriptionResource extends ApiResource {
|
|
|
794
742
|
}>>;
|
|
795
743
|
createPortal(): Promise<ApiResponse<PortalResponse>>;
|
|
796
744
|
}
|
|
797
|
-
declare const
|
|
745
|
+
declare const createSubscriptionResource: (api: Api) => SubscriptionResource;
|
|
798
746
|
|
|
799
747
|
type FriendshipStatus = 'none' | 'pending_sent' | 'pending_received' | 'accepted' | 'blocked_by_me' | 'blocked_by_them';
|
|
800
748
|
interface FriendEntry {
|
|
@@ -829,8 +777,7 @@ interface FriendActionResponse {
|
|
|
829
777
|
status: FriendshipStatus;
|
|
830
778
|
} | null;
|
|
831
779
|
}
|
|
832
|
-
|
|
833
|
-
protected readonly endpoint = "/friends";
|
|
780
|
+
interface FriendResource {
|
|
834
781
|
list(): Promise<ApiResponse<FriendListResponse>>;
|
|
835
782
|
getStatus(targetUserId: number): Promise<ApiResponse<FriendStatusResponse>>;
|
|
836
783
|
sendRequest(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
@@ -839,6 +786,20 @@ declare class FriendResource extends ApiResource<FriendEntry> {
|
|
|
839
786
|
block(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
840
787
|
unblock(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
841
788
|
}
|
|
842
|
-
declare const
|
|
789
|
+
declare const createFriendResource: (api: Api) => FriendResource;
|
|
790
|
+
|
|
791
|
+
interface ApiClient {
|
|
792
|
+
api: Api;
|
|
793
|
+
auth: AuthResource;
|
|
794
|
+
user: UserResource;
|
|
795
|
+
room: RoomResource;
|
|
796
|
+
chat: ChatResource;
|
|
797
|
+
playlist: PlaylistResource;
|
|
798
|
+
source: SourceResource;
|
|
799
|
+
shop: ShopResource;
|
|
800
|
+
subscription: SubscriptionResource;
|
|
801
|
+
friend: FriendResource;
|
|
802
|
+
}
|
|
803
|
+
declare const createApiClient: (config: ApiConfig) => ApiClient;
|
|
843
804
|
|
|
844
|
-
export { type
|
|
805
|
+
export { Api, type ApiClient, type ApiConfig, ApiError, type ApiResponse, type AuthResource, type BackendErrorResponse, type ChatResource, type FriendResource, Logger, type PlaylistResource, type RoomResource, type ShopResource, type SourceResource, type SubscriptionResource, type UserResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,14 +23,10 @@ declare class ApiError extends Error {
|
|
|
23
23
|
constructor(message: string, status?: number, code?: string, response?: BackendErrorResponse);
|
|
24
24
|
}
|
|
25
25
|
declare class Api {
|
|
26
|
-
private static instance;
|
|
27
26
|
private readonly axios;
|
|
28
27
|
private readonly logger;
|
|
29
28
|
private readonly config;
|
|
30
|
-
|
|
31
|
-
static getInstance(config?: ApiConfig): Api;
|
|
32
|
-
/** Reset the singleton (useful for testing or re-initializing with a new config) */
|
|
33
|
-
static reset(): void;
|
|
29
|
+
constructor(config: ApiConfig);
|
|
34
30
|
private setupInterceptors;
|
|
35
31
|
private parseError;
|
|
36
32
|
setAuthToken(token: string | null): void;
|
|
@@ -44,11 +40,12 @@ declare class Api {
|
|
|
44
40
|
private wrapResponse;
|
|
45
41
|
get axiosInstance(): AxiosInstance;
|
|
46
42
|
}
|
|
43
|
+
declare const createApi: (config: ApiConfig) => Api;
|
|
47
44
|
|
|
48
45
|
declare class Logger {
|
|
49
46
|
private readonly name;
|
|
50
47
|
private enabled;
|
|
51
|
-
|
|
48
|
+
constructor(name: string, enabled?: boolean);
|
|
52
49
|
static create(name: string): Logger;
|
|
53
50
|
enable(): void;
|
|
54
51
|
disable(): void;
|
|
@@ -59,39 +56,6 @@ declare class Logger {
|
|
|
59
56
|
error(message: string, ...args: unknown[]): void;
|
|
60
57
|
}
|
|
61
58
|
|
|
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
59
|
interface AuthUser {
|
|
96
60
|
id: number;
|
|
97
61
|
email?: string;
|
|
@@ -144,8 +108,7 @@ interface MeResponse {
|
|
|
144
108
|
user: AuthUser;
|
|
145
109
|
};
|
|
146
110
|
}
|
|
147
|
-
|
|
148
|
-
protected readonly endpoint = "/auth";
|
|
111
|
+
interface AuthResource {
|
|
149
112
|
login(credentials: LoginCredentials): Promise<ApiResponse<AuthResponse>>;
|
|
150
113
|
register(data: RegisterData): Promise<ApiResponse<AuthResponse>>;
|
|
151
114
|
refresh(refreshToken: string): Promise<ApiResponse<RefreshResponse>>;
|
|
@@ -155,7 +118,7 @@ declare class AuthResource extends ApiResource<AuthUser> {
|
|
|
155
118
|
}>>;
|
|
156
119
|
me(): Promise<ApiResponse<MeResponse>>;
|
|
157
120
|
}
|
|
158
|
-
declare const
|
|
121
|
+
declare const createAuthResource: (api: Api) => AuthResource;
|
|
159
122
|
|
|
160
123
|
interface User extends AuthUser {
|
|
161
124
|
}
|
|
@@ -170,9 +133,8 @@ interface UserResponse {
|
|
|
170
133
|
user: User;
|
|
171
134
|
};
|
|
172
135
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
getById(id: number): Promise<ApiResponse<User>>;
|
|
136
|
+
interface UserResource {
|
|
137
|
+
getById(id: number): Promise<ApiResponse<UserResponse>>;
|
|
176
138
|
getByUsername(username: string): Promise<ApiResponse<UserResponse>>;
|
|
177
139
|
updateProfile(data: UpdateProfileData): Promise<ApiResponse<UserResponse>>;
|
|
178
140
|
deleteAccount(): Promise<ApiResponse<{
|
|
@@ -185,7 +147,7 @@ declare class UserResource extends ApiResource<User> {
|
|
|
185
147
|
data: null;
|
|
186
148
|
}>>;
|
|
187
149
|
}
|
|
188
|
-
declare const
|
|
150
|
+
declare const createUserResource: (api: Api) => UserResource;
|
|
189
151
|
|
|
190
152
|
type RoomRole = 'user' | 'resident_dj' | 'bouncer' | 'manager' | 'cohost' | 'host';
|
|
191
153
|
interface Room {
|
|
@@ -368,11 +330,8 @@ interface BoothState {
|
|
|
368
330
|
};
|
|
369
331
|
}
|
|
370
332
|
interface JoinMuteInfo {
|
|
371
|
-
/** ISO timestamp when the mute expires, or null if permanent */
|
|
372
333
|
expiresAt: string | null;
|
|
373
|
-
/** Seconds remaining until unmute, or null if permanent */
|
|
374
334
|
remainingSeconds: number | null;
|
|
375
|
-
/** Optional reason given by the moderator */
|
|
376
335
|
reason: string | null;
|
|
377
336
|
}
|
|
378
337
|
interface JoinRoomResponse {
|
|
@@ -388,7 +347,6 @@ interface JoinRoomResponse {
|
|
|
388
347
|
role: RoomRole;
|
|
389
348
|
users: RoomUserState[];
|
|
390
349
|
booth: BoothState;
|
|
391
|
-
/** Present when the joining user is currently muted in this room */
|
|
392
350
|
mute: JoinMuteInfo | null;
|
|
393
351
|
};
|
|
394
352
|
}
|
|
@@ -458,8 +416,7 @@ interface RoomHistoryResponse {
|
|
|
458
416
|
pagination: PaginationMeta;
|
|
459
417
|
};
|
|
460
418
|
}
|
|
461
|
-
|
|
462
|
-
protected readonly endpoint = "/rooms";
|
|
419
|
+
interface RoomResource {
|
|
463
420
|
list(): Promise<ApiResponse<RoomsResponse>>;
|
|
464
421
|
featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
|
|
465
422
|
getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
|
|
@@ -546,7 +503,7 @@ declare class RoomResource extends ApiResource<Room> {
|
|
|
546
503
|
grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
|
|
547
504
|
getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
|
|
548
505
|
}
|
|
549
|
-
declare const
|
|
506
|
+
declare const createRoomResource: (api: Api) => RoomResource;
|
|
550
507
|
|
|
551
508
|
interface ChatMessage {
|
|
552
509
|
id: string;
|
|
@@ -578,8 +535,7 @@ interface ChatMessageResponse {
|
|
|
578
535
|
message: ChatMessage;
|
|
579
536
|
};
|
|
580
537
|
}
|
|
581
|
-
|
|
582
|
-
protected readonly endpoint = "/rooms";
|
|
538
|
+
interface ChatResource {
|
|
583
539
|
sendMessage(slug: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
584
540
|
getMessages(slug: string, before?: string, limit?: number): Promise<ApiResponse<ChatMessagesResponse>>;
|
|
585
541
|
deleteMessage(slug: string, messageId: string): Promise<ApiResponse<{
|
|
@@ -587,13 +543,13 @@ declare class ChatResource extends ApiResource<ChatMessage> {
|
|
|
587
543
|
data: null;
|
|
588
544
|
}>>;
|
|
589
545
|
}
|
|
590
|
-
declare const
|
|
546
|
+
declare const createChatResource: (api: Api) => ChatResource;
|
|
591
547
|
|
|
592
|
-
type MediaSource = 'youtube' | 'soundcloud';
|
|
548
|
+
type MediaSource$1 = 'youtube' | 'soundcloud';
|
|
593
549
|
interface MediaItem {
|
|
594
550
|
id: number;
|
|
595
551
|
playlistId: number;
|
|
596
|
-
source: MediaSource;
|
|
552
|
+
source: MediaSource$1;
|
|
597
553
|
sourceId: string;
|
|
598
554
|
title: string;
|
|
599
555
|
artist: string | null;
|
|
@@ -632,7 +588,7 @@ interface MediaItemResponse {
|
|
|
632
588
|
};
|
|
633
589
|
}
|
|
634
590
|
interface AddMediaData {
|
|
635
|
-
source: MediaSource;
|
|
591
|
+
source: MediaSource$1;
|
|
636
592
|
sourceId: string;
|
|
637
593
|
}
|
|
638
594
|
interface ShuffleResponse {
|
|
@@ -643,7 +599,7 @@ interface ShuffleResponse {
|
|
|
643
599
|
};
|
|
644
600
|
}
|
|
645
601
|
interface ImportPlaylistData {
|
|
646
|
-
source?: MediaSource;
|
|
602
|
+
source?: MediaSource$1;
|
|
647
603
|
url: string;
|
|
648
604
|
}
|
|
649
605
|
interface ImportResult {
|
|
@@ -657,8 +613,7 @@ interface ImportPlaylistResponse {
|
|
|
657
613
|
success: boolean;
|
|
658
614
|
data: ImportResult;
|
|
659
615
|
}
|
|
660
|
-
|
|
661
|
-
protected readonly endpoint = "/playlists";
|
|
616
|
+
interface PlaylistResource {
|
|
662
617
|
getAll(): Promise<ApiResponse<PlaylistsResponse>>;
|
|
663
618
|
getById(playlistId: number): Promise<ApiResponse<PlaylistResponse>>;
|
|
664
619
|
create(name: string): Promise<ApiResponse<PlaylistResponse>>;
|
|
@@ -675,8 +630,9 @@ declare class PlaylistResource extends ApiResource<Playlist> {
|
|
|
675
630
|
moveItem(playlistId: number, itemId: number, position: number): Promise<ApiResponse<MediaItemResponse>>;
|
|
676
631
|
importPlaylist(playlistId: number, data: ImportPlaylistData): Promise<ApiResponse<ImportPlaylistResponse>>;
|
|
677
632
|
}
|
|
678
|
-
declare const
|
|
633
|
+
declare const createPlaylistResource: (api: Api) => PlaylistResource;
|
|
679
634
|
|
|
635
|
+
type MediaSource = 'youtube' | 'soundcloud';
|
|
680
636
|
interface MediaSearchResult {
|
|
681
637
|
source: MediaSource;
|
|
682
638
|
sourceId: string;
|
|
@@ -710,8 +666,7 @@ interface SoundCloudTrackResponse {
|
|
|
710
666
|
track: MediaSearchResult;
|
|
711
667
|
};
|
|
712
668
|
}
|
|
713
|
-
|
|
714
|
-
protected readonly endpoint = "/sources";
|
|
669
|
+
interface SourceResource {
|
|
715
670
|
searchYouTube(query: string, limit?: number): Promise<ApiResponse<YouTubeSearchResponse>>;
|
|
716
671
|
getYouTubeVideo(videoId: string): Promise<ApiResponse<YouTubeVideoResponse>>;
|
|
717
672
|
searchSoundCloud(query: string, limit?: number): Promise<ApiResponse<SoundCloudSearchResponse>>;
|
|
@@ -719,16 +674,14 @@ declare class SourceResource extends ApiResource<MediaSearchResult> {
|
|
|
719
674
|
resolveSoundCloudUrl(url: string): Promise<ApiResponse<SoundCloudTrackResponse>>;
|
|
720
675
|
searchAll(query: string, limit?: number): Promise<MediaSearchResult[]>;
|
|
721
676
|
}
|
|
722
|
-
declare const
|
|
677
|
+
declare const createSourceResource: (api: Api) => SourceResource;
|
|
723
678
|
|
|
724
679
|
type AvatarUnlockType = 'free' | 'level' | 'subscription';
|
|
725
680
|
interface AvatarCatalogItem {
|
|
726
681
|
id: string;
|
|
727
682
|
unlockType: AvatarUnlockType;
|
|
728
683
|
requiredLevel: number | null;
|
|
729
|
-
/** Whether the user has unlocked (or has free access to) this avatar */
|
|
730
684
|
unlocked: boolean;
|
|
731
|
-
/** Whether the user currently meets the requirement to unlock it */
|
|
732
685
|
eligible: boolean;
|
|
733
686
|
}
|
|
734
687
|
interface AvatarCatalogResponse {
|
|
@@ -739,11 +692,7 @@ interface AvatarCatalogResponse {
|
|
|
739
692
|
xp: number;
|
|
740
693
|
};
|
|
741
694
|
}
|
|
742
|
-
interface
|
|
743
|
-
avatarId: string;
|
|
744
|
-
}
|
|
745
|
-
declare class ShopResource extends ApiResource {
|
|
746
|
-
protected readonly endpoint = "/shop";
|
|
695
|
+
interface ShopResource {
|
|
747
696
|
getAvatarCatalog(): Promise<ApiResponse<AvatarCatalogResponse>>;
|
|
748
697
|
unlockAvatar(avatarId: string): Promise<ApiResponse<{
|
|
749
698
|
success: boolean;
|
|
@@ -759,7 +708,7 @@ declare class ShopResource extends ApiResource {
|
|
|
759
708
|
};
|
|
760
709
|
}>>;
|
|
761
710
|
}
|
|
762
|
-
declare const
|
|
711
|
+
declare const createShopResource: (api: Api) => ShopResource;
|
|
763
712
|
|
|
764
713
|
type SubscriptionPlan = 'monthly' | 'yearly';
|
|
765
714
|
interface SubscriptionStatus {
|
|
@@ -782,8 +731,7 @@ interface PortalResponse {
|
|
|
782
731
|
url: string;
|
|
783
732
|
};
|
|
784
733
|
}
|
|
785
|
-
|
|
786
|
-
protected readonly endpoint = "/subscriptions";
|
|
734
|
+
interface SubscriptionResource {
|
|
787
735
|
getStatus(): Promise<ApiResponse<{
|
|
788
736
|
success: boolean;
|
|
789
737
|
data: SubscriptionStatus;
|
|
@@ -794,7 +742,7 @@ declare class SubscriptionResource extends ApiResource {
|
|
|
794
742
|
}>>;
|
|
795
743
|
createPortal(): Promise<ApiResponse<PortalResponse>>;
|
|
796
744
|
}
|
|
797
|
-
declare const
|
|
745
|
+
declare const createSubscriptionResource: (api: Api) => SubscriptionResource;
|
|
798
746
|
|
|
799
747
|
type FriendshipStatus = 'none' | 'pending_sent' | 'pending_received' | 'accepted' | 'blocked_by_me' | 'blocked_by_them';
|
|
800
748
|
interface FriendEntry {
|
|
@@ -829,8 +777,7 @@ interface FriendActionResponse {
|
|
|
829
777
|
status: FriendshipStatus;
|
|
830
778
|
} | null;
|
|
831
779
|
}
|
|
832
|
-
|
|
833
|
-
protected readonly endpoint = "/friends";
|
|
780
|
+
interface FriendResource {
|
|
834
781
|
list(): Promise<ApiResponse<FriendListResponse>>;
|
|
835
782
|
getStatus(targetUserId: number): Promise<ApiResponse<FriendStatusResponse>>;
|
|
836
783
|
sendRequest(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
@@ -839,6 +786,20 @@ declare class FriendResource extends ApiResource<FriendEntry> {
|
|
|
839
786
|
block(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
840
787
|
unblock(targetUserId: number): Promise<ApiResponse<FriendActionResponse>>;
|
|
841
788
|
}
|
|
842
|
-
declare const
|
|
789
|
+
declare const createFriendResource: (api: Api) => FriendResource;
|
|
790
|
+
|
|
791
|
+
interface ApiClient {
|
|
792
|
+
api: Api;
|
|
793
|
+
auth: AuthResource;
|
|
794
|
+
user: UserResource;
|
|
795
|
+
room: RoomResource;
|
|
796
|
+
chat: ChatResource;
|
|
797
|
+
playlist: PlaylistResource;
|
|
798
|
+
source: SourceResource;
|
|
799
|
+
shop: ShopResource;
|
|
800
|
+
subscription: SubscriptionResource;
|
|
801
|
+
friend: FriendResource;
|
|
802
|
+
}
|
|
803
|
+
declare const createApiClient: (config: ApiConfig) => ApiClient;
|
|
843
804
|
|
|
844
|
-
export { type
|
|
805
|
+
export { Api, type ApiClient, type ApiConfig, ApiError, type ApiResponse, type AuthResource, type BackendErrorResponse, type ChatResource, type FriendResource, Logger, type PlaylistResource, type RoomResource, type ShopResource, type SourceResource, type SubscriptionResource, type UserResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|