@borealise/api 2.0.0-alpha.8 → 2.1.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 +13 -9
- package/dist/index.d.mts +148 -22
- package/dist/index.d.ts +148 -22
- package/dist/index.js +159 -119
- package/dist/index.mjs +159 -118
- package/package.json +50 -51
package/README.md
CHANGED
|
@@ -5,15 +5,13 @@ Official JavaScript/TypeScript API client for [Borealise](https://borealise.com)
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @borealise/api
|
|
8
|
+
npm install @borealise/api
|
|
9
9
|
# or
|
|
10
|
-
yarn add @borealise/api
|
|
10
|
+
yarn add @borealise/api
|
|
11
11
|
# or
|
|
12
|
-
pnpm add @borealise/api
|
|
12
|
+
pnpm add @borealise/api
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
> `axios` is a peer dependency — you need to install it alongside this package.
|
|
16
|
-
|
|
17
15
|
---
|
|
18
16
|
|
|
19
17
|
## Quick Start
|
|
@@ -26,7 +24,7 @@ Create a client once, then use resources:
|
|
|
26
24
|
import { createApiClient } from '@borealise/api'
|
|
27
25
|
|
|
28
26
|
const client = createApiClient({
|
|
29
|
-
baseURL: 'https://prod.borealise.com',
|
|
27
|
+
baseURL: 'https://prod.borealise.com/api',
|
|
30
28
|
})
|
|
31
29
|
|
|
32
30
|
// Login
|
|
@@ -45,7 +43,7 @@ If you need more control, create the API and resources separately:
|
|
|
45
43
|
import { createApi, createAuthResource, createRoomResource } from '@borealise/api'
|
|
46
44
|
|
|
47
45
|
const api = createApi({
|
|
48
|
-
baseURL: 'https://prod.borealise.com',
|
|
46
|
+
baseURL: 'https://prod.borealise.com/api',
|
|
49
47
|
timeout: 15000,
|
|
50
48
|
logging: false,
|
|
51
49
|
})
|
|
@@ -63,7 +61,7 @@ await auth.login({ login: 'you@example.com', password: 'secret' })
|
|
|
63
61
|
|
|
64
62
|
```ts
|
|
65
63
|
createApiClient({
|
|
66
|
-
baseURL: 'https://prod.borealise.com', // required
|
|
64
|
+
baseURL: 'https://prod.borealise.com/api', // required
|
|
67
65
|
timeout: 15000, // optional, default: 30000ms
|
|
68
66
|
logging: false, // optional, disable all console output
|
|
69
67
|
headers: { 'X-Custom-Header': 'value' } // optional, custom headers
|
|
@@ -217,7 +215,7 @@ try {
|
|
|
217
215
|
if (err instanceof ApiError) {
|
|
218
216
|
console.log(err.message) // Human-readable message from backend
|
|
219
217
|
console.log(err.status) // HTTP status code, e.g. 401
|
|
220
|
-
console.log(err.code) //
|
|
218
|
+
console.log(err.code) // Error code, e.g. 'NETWORK_ERROR', 'TIMEOUT_ERROR', 'HTTP_401'
|
|
221
219
|
console.log(err.response) // Raw backend error response body
|
|
222
220
|
}
|
|
223
221
|
}
|
|
@@ -241,6 +239,12 @@ client.api.setAuthToken(null)
|
|
|
241
239
|
|
|
242
240
|
The underlying API instance is accessible via `client.api`. Use it for token management and custom headers:
|
|
243
241
|
|
|
242
|
+
## Breaking Changes in 2.1.0-alpha.1
|
|
243
|
+
|
|
244
|
+
- The `axiosInstance` getter was removed from `Api`.
|
|
245
|
+
- The HTTP transport is now handled internally with Ky.
|
|
246
|
+
- If you previously accessed raw Axios internals, migrate to `Api` public methods (`get`, `post`, `put`, `patch`, `delete`, `setAuthToken`, `setHeader`, `removeHeader`).
|
|
247
|
+
|
|
244
248
|
---
|
|
245
249
|
|
|
246
250
|
## Tree-Shaking
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URLSearchParams } from 'node:url';
|
|
2
2
|
|
|
3
3
|
interface ApiConfig {
|
|
4
4
|
baseURL: string;
|
|
5
5
|
timeout?: number;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
|
+
withCredentials?: boolean;
|
|
7
8
|
/** Set to false to suppress all log output. Defaults to true. */
|
|
8
9
|
logging?: boolean;
|
|
9
10
|
}
|
|
@@ -12,34 +13,35 @@ interface ApiResponse<T = unknown> {
|
|
|
12
13
|
status: number;
|
|
13
14
|
headers: Record<string, string>;
|
|
14
15
|
}
|
|
16
|
+
type ApiQueryParams = URLSearchParams | Record<string, unknown>;
|
|
17
|
+
interface ApiRequestConfig {
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
params?: ApiQueryParams;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
22
|
+
}
|
|
15
23
|
interface BackendErrorResponse {
|
|
16
24
|
success: false;
|
|
17
25
|
error: string;
|
|
18
26
|
}
|
|
27
|
+
interface Api {
|
|
28
|
+
setAuthToken(token: string | null): void;
|
|
29
|
+
setHeader(key: string, value: string): void;
|
|
30
|
+
removeHeader(key: string): void;
|
|
31
|
+
get<T = unknown>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
32
|
+
post<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
33
|
+
put<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
34
|
+
patch<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
35
|
+
delete<T = unknown>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
declare class ApiError extends Error {
|
|
20
39
|
readonly status?: number;
|
|
21
40
|
readonly code?: string;
|
|
22
41
|
readonly response?: BackendErrorResponse;
|
|
23
42
|
constructor(message: string, status?: number, code?: string, response?: BackendErrorResponse);
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
private readonly axios;
|
|
27
|
-
private readonly logger;
|
|
28
|
-
private readonly config;
|
|
29
|
-
constructor(config: ApiConfig);
|
|
30
|
-
private setupInterceptors;
|
|
31
|
-
private parseError;
|
|
32
|
-
setAuthToken(token: string | null): void;
|
|
33
|
-
setHeader(key: string, value: string): void;
|
|
34
|
-
removeHeader(key: string): void;
|
|
35
|
-
get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
36
|
-
post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
37
|
-
put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
38
|
-
patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
39
|
-
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
40
|
-
private wrapResponse;
|
|
41
|
-
get axiosInstance(): AxiosInstance;
|
|
42
|
-
}
|
|
44
|
+
|
|
43
45
|
declare const createApi: (config: ApiConfig) => Api;
|
|
44
46
|
|
|
45
47
|
declare class Logger {
|
|
@@ -111,7 +113,7 @@ interface MeResponse {
|
|
|
111
113
|
interface AuthResource {
|
|
112
114
|
login(credentials: LoginCredentials): Promise<ApiResponse<AuthResponse>>;
|
|
113
115
|
register(data: RegisterData): Promise<ApiResponse<AuthResponse>>;
|
|
114
|
-
refresh(refreshToken
|
|
116
|
+
refresh(refreshToken?: string): Promise<ApiResponse<RefreshResponse>>;
|
|
115
117
|
logout(): Promise<ApiResponse<{
|
|
116
118
|
success: boolean;
|
|
117
119
|
message: string;
|
|
@@ -128,6 +130,34 @@ declare const createAuthResource: (api: Api) => AuthResource;
|
|
|
128
130
|
|
|
129
131
|
interface User extends AuthUser {
|
|
130
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Public user profile — never contains private fields (email, flags, etc.)
|
|
135
|
+
*/
|
|
136
|
+
interface PublicUser {
|
|
137
|
+
id: number;
|
|
138
|
+
username: string;
|
|
139
|
+
displayName: string | null;
|
|
140
|
+
avatarId: string;
|
|
141
|
+
bio: string | null;
|
|
142
|
+
globalRole: string;
|
|
143
|
+
xp: number;
|
|
144
|
+
level: number;
|
|
145
|
+
subscriptionType?: string | null;
|
|
146
|
+
subscriptionMonths?: number | null;
|
|
147
|
+
currentRoomSlug?: string | null;
|
|
148
|
+
createdAt?: string;
|
|
149
|
+
friendsCount: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A friend entry as shown on a public profile.
|
|
153
|
+
*/
|
|
154
|
+
interface PublicProfileFriend {
|
|
155
|
+
id: number;
|
|
156
|
+
username: string;
|
|
157
|
+
displayName: string | null;
|
|
158
|
+
avatarId: string;
|
|
159
|
+
level: number;
|
|
160
|
+
}
|
|
131
161
|
interface UpdateProfileData {
|
|
132
162
|
displayName?: string;
|
|
133
163
|
bio?: string;
|
|
@@ -136,7 +166,8 @@ type GlobalRole = 'user' | 'moderator' | 'admin' | 'owner';
|
|
|
136
166
|
interface UserResponse {
|
|
137
167
|
success: boolean;
|
|
138
168
|
data: {
|
|
139
|
-
user:
|
|
169
|
+
user: PublicUser;
|
|
170
|
+
friends: PublicProfileFriend[];
|
|
140
171
|
};
|
|
141
172
|
}
|
|
142
173
|
interface MyViolation {
|
|
@@ -187,6 +218,22 @@ interface Room {
|
|
|
187
218
|
population: number;
|
|
188
219
|
totalPlays: number;
|
|
189
220
|
isFeatured: boolean;
|
|
221
|
+
verified: boolean;
|
|
222
|
+
currentDJ?: {
|
|
223
|
+
id: number;
|
|
224
|
+
username: string;
|
|
225
|
+
displayName: string | null;
|
|
226
|
+
avatarId: string;
|
|
227
|
+
} | null;
|
|
228
|
+
currentMedia?: {
|
|
229
|
+
id: number;
|
|
230
|
+
source: 'youtube' | 'soundcloud';
|
|
231
|
+
sourceId: string;
|
|
232
|
+
title: string;
|
|
233
|
+
artist: string | null;
|
|
234
|
+
thumbnail: string | null;
|
|
235
|
+
duration: number;
|
|
236
|
+
} | null;
|
|
190
237
|
createdAt: string;
|
|
191
238
|
updatedAt: string;
|
|
192
239
|
}
|
|
@@ -456,8 +503,35 @@ interface RoomAuditLogResponse {
|
|
|
456
503
|
hasMore: boolean;
|
|
457
504
|
};
|
|
458
505
|
}
|
|
506
|
+
type DashboardActivityType = 'play' | 'woot' | 'grab';
|
|
507
|
+
interface DashboardActivityItem {
|
|
508
|
+
id: string;
|
|
509
|
+
type: DashboardActivityType;
|
|
510
|
+
room: {
|
|
511
|
+
id: number;
|
|
512
|
+
slug: string;
|
|
513
|
+
name: string;
|
|
514
|
+
};
|
|
515
|
+
media: {
|
|
516
|
+
id: number;
|
|
517
|
+
source: 'youtube' | 'soundcloud';
|
|
518
|
+
sourceId: string;
|
|
519
|
+
title: string;
|
|
520
|
+
artist: string | null;
|
|
521
|
+
thumbnail: string | null;
|
|
522
|
+
};
|
|
523
|
+
count: number | null;
|
|
524
|
+
createdAt: string;
|
|
525
|
+
}
|
|
526
|
+
interface DashboardActivityResponse {
|
|
527
|
+
success: boolean;
|
|
528
|
+
data: {
|
|
529
|
+
activities: DashboardActivityItem[];
|
|
530
|
+
};
|
|
531
|
+
}
|
|
459
532
|
interface RoomResource {
|
|
460
533
|
list(): Promise<ApiResponse<RoomsResponse>>;
|
|
534
|
+
mine(limit?: number): Promise<ApiResponse<RoomsResponse>>;
|
|
461
535
|
featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
|
|
462
536
|
getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
|
|
463
537
|
create(data: CreateRoomData): Promise<ApiResponse<RoomResponse>>;
|
|
@@ -543,6 +617,7 @@ interface RoomResource {
|
|
|
543
617
|
grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
|
|
544
618
|
getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
|
|
545
619
|
getAuditLog(slug: string, limit?: number, before?: string): Promise<ApiResponse<RoomAuditLogResponse>>;
|
|
620
|
+
activity(limit?: number): Promise<ApiResponse<DashboardActivityResponse>>;
|
|
546
621
|
}
|
|
547
622
|
declare const createRoomResource: (api: Api) => RoomResource;
|
|
548
623
|
|
|
@@ -552,6 +627,7 @@ interface ChatMessage {
|
|
|
552
627
|
user_id?: number;
|
|
553
628
|
username?: string;
|
|
554
629
|
display_name?: string | null;
|
|
630
|
+
avatar_id?: string | null;
|
|
555
631
|
role?: RoomRole;
|
|
556
632
|
global_role?: string | null;
|
|
557
633
|
subscription_type?: string | null;
|
|
@@ -559,7 +635,11 @@ interface ChatMessage {
|
|
|
559
635
|
content: string;
|
|
560
636
|
timestamp: number;
|
|
561
637
|
type?: 'user' | 'system';
|
|
638
|
+
edited_at?: number | null;
|
|
639
|
+
edited_by?: number | null;
|
|
562
640
|
deleted?: boolean;
|
|
641
|
+
deleted_at?: number | null;
|
|
642
|
+
deleted_by?: number | null;
|
|
563
643
|
}
|
|
564
644
|
interface SendMessageData {
|
|
565
645
|
content: string;
|
|
@@ -579,6 +659,7 @@ interface ChatMessageResponse {
|
|
|
579
659
|
interface ChatResource {
|
|
580
660
|
sendMessage(slug: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
581
661
|
getMessages(slug: string, before?: string, limit?: number): Promise<ApiResponse<ChatMessagesResponse>>;
|
|
662
|
+
editMessage(slug: string, messageId: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
582
663
|
deleteMessage(slug: string, messageId: string): Promise<ApiResponse<{
|
|
583
664
|
success: boolean;
|
|
584
665
|
data: null;
|
|
@@ -775,6 +856,42 @@ interface PortalResponse {
|
|
|
775
856
|
url: string;
|
|
776
857
|
};
|
|
777
858
|
}
|
|
859
|
+
interface CreateGiftCheckoutResponse {
|
|
860
|
+
success: boolean;
|
|
861
|
+
data: {
|
|
862
|
+
checkoutUrl: string;
|
|
863
|
+
sessionId: string;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
interface GiftHistoryEntry {
|
|
867
|
+
giftItemId: number;
|
|
868
|
+
purchaseId: number;
|
|
869
|
+
status: string;
|
|
870
|
+
startsAt: string;
|
|
871
|
+
endsAt: string;
|
|
872
|
+
createdAt: string;
|
|
873
|
+
isAnonymous: boolean;
|
|
874
|
+
recipientUsername: string | null;
|
|
875
|
+
purchaserUsername: string | null;
|
|
876
|
+
}
|
|
877
|
+
interface GiftsHistoryResponse {
|
|
878
|
+
success: boolean;
|
|
879
|
+
data: {
|
|
880
|
+
purchased: GiftHistoryEntry[];
|
|
881
|
+
received: GiftHistoryEntry[];
|
|
882
|
+
failedPurchases: Array<{
|
|
883
|
+
purchaseId: number;
|
|
884
|
+
recipientUsername: string;
|
|
885
|
+
quantity: number;
|
|
886
|
+
createdAt: string;
|
|
887
|
+
}>;
|
|
888
|
+
supporterBadge: {
|
|
889
|
+
tier: 'none' | 'bronze' | 'silver' | 'gold';
|
|
890
|
+
giftedCount: number;
|
|
891
|
+
nextTierAt: number | null;
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
}
|
|
778
895
|
interface SubscriptionResource {
|
|
779
896
|
getStatus(): Promise<ApiResponse<{
|
|
780
897
|
success: boolean;
|
|
@@ -785,6 +902,14 @@ interface SubscriptionResource {
|
|
|
785
902
|
success: boolean;
|
|
786
903
|
}>>;
|
|
787
904
|
createPortal(): Promise<ApiResponse<PortalResponse>>;
|
|
905
|
+
createGiftCheckout(recipientUsername: string, quantity: 1 | 5 | 10 | 20, isAnonymous?: boolean): Promise<ApiResponse<CreateGiftCheckoutResponse>>;
|
|
906
|
+
getGiftsHistory(): Promise<ApiResponse<GiftsHistoryResponse>>;
|
|
907
|
+
retryGiftAssignment(purchaseId: number, recipientUsername?: string): Promise<ApiResponse<{
|
|
908
|
+
success: boolean;
|
|
909
|
+
data: {
|
|
910
|
+
ok: true;
|
|
911
|
+
};
|
|
912
|
+
}>>;
|
|
788
913
|
}
|
|
789
914
|
declare const createSubscriptionResource: (api: Api) => SubscriptionResource;
|
|
790
915
|
|
|
@@ -796,6 +921,7 @@ interface FriendEntry {
|
|
|
796
921
|
displayName: string | null;
|
|
797
922
|
avatarId: string;
|
|
798
923
|
level: number;
|
|
924
|
+
currentRoomSlug?: string | null;
|
|
799
925
|
status: 'pending' | 'accepted' | 'blocked';
|
|
800
926
|
isSender: boolean;
|
|
801
927
|
}
|
|
@@ -950,4 +1076,4 @@ interface ApiClient {
|
|
|
950
1076
|
}
|
|
951
1077
|
declare const createApiClient: (config: ApiConfig) => ApiClient;
|
|
952
1078
|
|
|
953
|
-
export { type AccountViolation, type AddMediaData, type AddViolationResponse, type AdminListUsersParams, type AdminResource, type AdminStatsResponse, type AdminStatsRoom, type AdminUserEntry, type AdminUsersResponse, Api, type ApiClient, type ApiConfig, ApiError, type ApiResponse, type AuditAction, type AuthResource, type AuthUser, type AvatarCatalogItem, type AvatarCatalogResponse, type AvatarUnlockType, type BackendErrorResponse, type BanResponse, type BoothDJ, type BoothMedia, type BoothResponse, type BoothState, type ChatMessage, type ChatMessageResponse, type ChatMessagesResponse, type ChatResource, type CreateIntentResponse, type CreateRoomData, type EquipAvatarData, type FeaturedRoomsResponse, type FriendActionResponse, type FriendEntry, type FriendList, type FriendListResponse, type FriendResource, type FriendStatusResponse, type FriendshipStatus, type GlobalRole, type GrabResponse, type ImportPlaylistData, type ImportPlaylistResponse, type ImportResult, type JoinMuteInfo, type JoinRoomResponse, Logger, type MediaItem, type MediaItemResponse, type MediaSearchResult, type MediaSource, type ModerateUserData, type MuteResponse, type MyViolation, type MyViolationsResponse, type PaginationMeta, type PlayHistoryItem, type Playlist, type PlaylistResource, type PlaylistResponse, type PlaylistsResponse, type PortalResponse, type Room, type RoomAuditLog, type RoomBan, type RoomBansResponse, type RoomHistoryResponse, type RoomMember, type RoomMute, type RoomMutesResponse, type RoomResource, type RoomResponse, type RoomRole, type RoomStaffResponse, type RoomUserState, type RoomsResponse, type SendMessageData, type ShopResource, type ShuffleResponse, type SoundCloudSearchResponse, type SoundCloudTrackResponse, type SourceResource, type SubscriptionPlan, type SubscriptionResource, type SubscriptionStatus, type UpdateProfileData, type UpdateRoomData, type User, type UserResource, type UserResponse, type UserViolationsResponse, type VoteResponse, type WaitlistResponse, type WaitlistUser, type YouTubeSearchResponse, type YouTubeVideoResponse, createAdminResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|
|
1079
|
+
export { type AccountViolation, type AddMediaData, type AddViolationResponse, type AdminListUsersParams, type AdminResource, type AdminStatsResponse, type AdminStatsRoom, type AdminUserEntry, type AdminUsersResponse, type Api, type ApiClient, type ApiConfig, ApiError, type ApiQueryParams, type ApiRequestConfig, type ApiResponse, type AuditAction, type AuthResource, type AuthUser, type AvatarCatalogItem, type AvatarCatalogResponse, type AvatarUnlockType, type BackendErrorResponse, type BanResponse, type BoothDJ, type BoothMedia, type BoothResponse, type BoothState, type ChatMessage, type ChatMessageResponse, type ChatMessagesResponse, type ChatResource, type CreateIntentResponse, type CreateRoomData, type DashboardActivityItem, type DashboardActivityResponse, type DashboardActivityType, type EquipAvatarData, type FeaturedRoomsResponse, type FriendActionResponse, type FriendEntry, type FriendList, type FriendListResponse, type FriendResource, type FriendStatusResponse, type FriendshipStatus, type GlobalRole, type GrabResponse, type ImportPlaylistData, type ImportPlaylistResponse, type ImportResult, type JoinMuteInfo, type JoinRoomResponse, Logger, type MediaItem, type MediaItemResponse, type MediaSearchResult, type MediaSource, type ModerateUserData, type MuteResponse, type MyViolation, type MyViolationsResponse, type PaginationMeta, type PlayHistoryItem, type Playlist, type PlaylistResource, type PlaylistResponse, type PlaylistsResponse, type PortalResponse, type PublicProfileFriend, type PublicUser, type Room, type RoomAuditLog, type RoomBan, type RoomBansResponse, type RoomHistoryResponse, type RoomMember, type RoomMute, type RoomMutesResponse, type RoomResource, type RoomResponse, type RoomRole, type RoomStaffResponse, type RoomUserState, type RoomsResponse, type SendMessageData, type ShopResource, type ShuffleResponse, type SoundCloudSearchResponse, type SoundCloudTrackResponse, type SourceResource, type SubscriptionPlan, type SubscriptionResource, type SubscriptionStatus, type UpdateProfileData, type UpdateRoomData, type User, type UserResource, type UserResponse, type UserViolationsResponse, type VoteResponse, type WaitlistResponse, type WaitlistUser, type YouTubeSearchResponse, type YouTubeVideoResponse, createAdminResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URLSearchParams } from 'node:url';
|
|
2
2
|
|
|
3
3
|
interface ApiConfig {
|
|
4
4
|
baseURL: string;
|
|
5
5
|
timeout?: number;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
|
+
withCredentials?: boolean;
|
|
7
8
|
/** Set to false to suppress all log output. Defaults to true. */
|
|
8
9
|
logging?: boolean;
|
|
9
10
|
}
|
|
@@ -12,34 +13,35 @@ interface ApiResponse<T = unknown> {
|
|
|
12
13
|
status: number;
|
|
13
14
|
headers: Record<string, string>;
|
|
14
15
|
}
|
|
16
|
+
type ApiQueryParams = URLSearchParams | Record<string, unknown>;
|
|
17
|
+
interface ApiRequestConfig {
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
params?: ApiQueryParams;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
22
|
+
}
|
|
15
23
|
interface BackendErrorResponse {
|
|
16
24
|
success: false;
|
|
17
25
|
error: string;
|
|
18
26
|
}
|
|
27
|
+
interface Api {
|
|
28
|
+
setAuthToken(token: string | null): void;
|
|
29
|
+
setHeader(key: string, value: string): void;
|
|
30
|
+
removeHeader(key: string): void;
|
|
31
|
+
get<T = unknown>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
32
|
+
post<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
33
|
+
put<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
34
|
+
patch<T = unknown>(url: string, data?: unknown, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
35
|
+
delete<T = unknown>(url: string, config?: ApiRequestConfig): Promise<ApiResponse<T>>;
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
declare class ApiError extends Error {
|
|
20
39
|
readonly status?: number;
|
|
21
40
|
readonly code?: string;
|
|
22
41
|
readonly response?: BackendErrorResponse;
|
|
23
42
|
constructor(message: string, status?: number, code?: string, response?: BackendErrorResponse);
|
|
24
43
|
}
|
|
25
|
-
|
|
26
|
-
private readonly axios;
|
|
27
|
-
private readonly logger;
|
|
28
|
-
private readonly config;
|
|
29
|
-
constructor(config: ApiConfig);
|
|
30
|
-
private setupInterceptors;
|
|
31
|
-
private parseError;
|
|
32
|
-
setAuthToken(token: string | null): void;
|
|
33
|
-
setHeader(key: string, value: string): void;
|
|
34
|
-
removeHeader(key: string): void;
|
|
35
|
-
get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
36
|
-
post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
37
|
-
put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
38
|
-
patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
39
|
-
delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
40
|
-
private wrapResponse;
|
|
41
|
-
get axiosInstance(): AxiosInstance;
|
|
42
|
-
}
|
|
44
|
+
|
|
43
45
|
declare const createApi: (config: ApiConfig) => Api;
|
|
44
46
|
|
|
45
47
|
declare class Logger {
|
|
@@ -111,7 +113,7 @@ interface MeResponse {
|
|
|
111
113
|
interface AuthResource {
|
|
112
114
|
login(credentials: LoginCredentials): Promise<ApiResponse<AuthResponse>>;
|
|
113
115
|
register(data: RegisterData): Promise<ApiResponse<AuthResponse>>;
|
|
114
|
-
refresh(refreshToken
|
|
116
|
+
refresh(refreshToken?: string): Promise<ApiResponse<RefreshResponse>>;
|
|
115
117
|
logout(): Promise<ApiResponse<{
|
|
116
118
|
success: boolean;
|
|
117
119
|
message: string;
|
|
@@ -128,6 +130,34 @@ declare const createAuthResource: (api: Api) => AuthResource;
|
|
|
128
130
|
|
|
129
131
|
interface User extends AuthUser {
|
|
130
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Public user profile — never contains private fields (email, flags, etc.)
|
|
135
|
+
*/
|
|
136
|
+
interface PublicUser {
|
|
137
|
+
id: number;
|
|
138
|
+
username: string;
|
|
139
|
+
displayName: string | null;
|
|
140
|
+
avatarId: string;
|
|
141
|
+
bio: string | null;
|
|
142
|
+
globalRole: string;
|
|
143
|
+
xp: number;
|
|
144
|
+
level: number;
|
|
145
|
+
subscriptionType?: string | null;
|
|
146
|
+
subscriptionMonths?: number | null;
|
|
147
|
+
currentRoomSlug?: string | null;
|
|
148
|
+
createdAt?: string;
|
|
149
|
+
friendsCount: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A friend entry as shown on a public profile.
|
|
153
|
+
*/
|
|
154
|
+
interface PublicProfileFriend {
|
|
155
|
+
id: number;
|
|
156
|
+
username: string;
|
|
157
|
+
displayName: string | null;
|
|
158
|
+
avatarId: string;
|
|
159
|
+
level: number;
|
|
160
|
+
}
|
|
131
161
|
interface UpdateProfileData {
|
|
132
162
|
displayName?: string;
|
|
133
163
|
bio?: string;
|
|
@@ -136,7 +166,8 @@ type GlobalRole = 'user' | 'moderator' | 'admin' | 'owner';
|
|
|
136
166
|
interface UserResponse {
|
|
137
167
|
success: boolean;
|
|
138
168
|
data: {
|
|
139
|
-
user:
|
|
169
|
+
user: PublicUser;
|
|
170
|
+
friends: PublicProfileFriend[];
|
|
140
171
|
};
|
|
141
172
|
}
|
|
142
173
|
interface MyViolation {
|
|
@@ -187,6 +218,22 @@ interface Room {
|
|
|
187
218
|
population: number;
|
|
188
219
|
totalPlays: number;
|
|
189
220
|
isFeatured: boolean;
|
|
221
|
+
verified: boolean;
|
|
222
|
+
currentDJ?: {
|
|
223
|
+
id: number;
|
|
224
|
+
username: string;
|
|
225
|
+
displayName: string | null;
|
|
226
|
+
avatarId: string;
|
|
227
|
+
} | null;
|
|
228
|
+
currentMedia?: {
|
|
229
|
+
id: number;
|
|
230
|
+
source: 'youtube' | 'soundcloud';
|
|
231
|
+
sourceId: string;
|
|
232
|
+
title: string;
|
|
233
|
+
artist: string | null;
|
|
234
|
+
thumbnail: string | null;
|
|
235
|
+
duration: number;
|
|
236
|
+
} | null;
|
|
190
237
|
createdAt: string;
|
|
191
238
|
updatedAt: string;
|
|
192
239
|
}
|
|
@@ -456,8 +503,35 @@ interface RoomAuditLogResponse {
|
|
|
456
503
|
hasMore: boolean;
|
|
457
504
|
};
|
|
458
505
|
}
|
|
506
|
+
type DashboardActivityType = 'play' | 'woot' | 'grab';
|
|
507
|
+
interface DashboardActivityItem {
|
|
508
|
+
id: string;
|
|
509
|
+
type: DashboardActivityType;
|
|
510
|
+
room: {
|
|
511
|
+
id: number;
|
|
512
|
+
slug: string;
|
|
513
|
+
name: string;
|
|
514
|
+
};
|
|
515
|
+
media: {
|
|
516
|
+
id: number;
|
|
517
|
+
source: 'youtube' | 'soundcloud';
|
|
518
|
+
sourceId: string;
|
|
519
|
+
title: string;
|
|
520
|
+
artist: string | null;
|
|
521
|
+
thumbnail: string | null;
|
|
522
|
+
};
|
|
523
|
+
count: number | null;
|
|
524
|
+
createdAt: string;
|
|
525
|
+
}
|
|
526
|
+
interface DashboardActivityResponse {
|
|
527
|
+
success: boolean;
|
|
528
|
+
data: {
|
|
529
|
+
activities: DashboardActivityItem[];
|
|
530
|
+
};
|
|
531
|
+
}
|
|
459
532
|
interface RoomResource {
|
|
460
533
|
list(): Promise<ApiResponse<RoomsResponse>>;
|
|
534
|
+
mine(limit?: number): Promise<ApiResponse<RoomsResponse>>;
|
|
461
535
|
featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
|
|
462
536
|
getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
|
|
463
537
|
create(data: CreateRoomData): Promise<ApiResponse<RoomResponse>>;
|
|
@@ -543,6 +617,7 @@ interface RoomResource {
|
|
|
543
617
|
grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
|
|
544
618
|
getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
|
|
545
619
|
getAuditLog(slug: string, limit?: number, before?: string): Promise<ApiResponse<RoomAuditLogResponse>>;
|
|
620
|
+
activity(limit?: number): Promise<ApiResponse<DashboardActivityResponse>>;
|
|
546
621
|
}
|
|
547
622
|
declare const createRoomResource: (api: Api) => RoomResource;
|
|
548
623
|
|
|
@@ -552,6 +627,7 @@ interface ChatMessage {
|
|
|
552
627
|
user_id?: number;
|
|
553
628
|
username?: string;
|
|
554
629
|
display_name?: string | null;
|
|
630
|
+
avatar_id?: string | null;
|
|
555
631
|
role?: RoomRole;
|
|
556
632
|
global_role?: string | null;
|
|
557
633
|
subscription_type?: string | null;
|
|
@@ -559,7 +635,11 @@ interface ChatMessage {
|
|
|
559
635
|
content: string;
|
|
560
636
|
timestamp: number;
|
|
561
637
|
type?: 'user' | 'system';
|
|
638
|
+
edited_at?: number | null;
|
|
639
|
+
edited_by?: number | null;
|
|
562
640
|
deleted?: boolean;
|
|
641
|
+
deleted_at?: number | null;
|
|
642
|
+
deleted_by?: number | null;
|
|
563
643
|
}
|
|
564
644
|
interface SendMessageData {
|
|
565
645
|
content: string;
|
|
@@ -579,6 +659,7 @@ interface ChatMessageResponse {
|
|
|
579
659
|
interface ChatResource {
|
|
580
660
|
sendMessage(slug: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
581
661
|
getMessages(slug: string, before?: string, limit?: number): Promise<ApiResponse<ChatMessagesResponse>>;
|
|
662
|
+
editMessage(slug: string, messageId: string, data: SendMessageData): Promise<ApiResponse<ChatMessageResponse>>;
|
|
582
663
|
deleteMessage(slug: string, messageId: string): Promise<ApiResponse<{
|
|
583
664
|
success: boolean;
|
|
584
665
|
data: null;
|
|
@@ -775,6 +856,42 @@ interface PortalResponse {
|
|
|
775
856
|
url: string;
|
|
776
857
|
};
|
|
777
858
|
}
|
|
859
|
+
interface CreateGiftCheckoutResponse {
|
|
860
|
+
success: boolean;
|
|
861
|
+
data: {
|
|
862
|
+
checkoutUrl: string;
|
|
863
|
+
sessionId: string;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
interface GiftHistoryEntry {
|
|
867
|
+
giftItemId: number;
|
|
868
|
+
purchaseId: number;
|
|
869
|
+
status: string;
|
|
870
|
+
startsAt: string;
|
|
871
|
+
endsAt: string;
|
|
872
|
+
createdAt: string;
|
|
873
|
+
isAnonymous: boolean;
|
|
874
|
+
recipientUsername: string | null;
|
|
875
|
+
purchaserUsername: string | null;
|
|
876
|
+
}
|
|
877
|
+
interface GiftsHistoryResponse {
|
|
878
|
+
success: boolean;
|
|
879
|
+
data: {
|
|
880
|
+
purchased: GiftHistoryEntry[];
|
|
881
|
+
received: GiftHistoryEntry[];
|
|
882
|
+
failedPurchases: Array<{
|
|
883
|
+
purchaseId: number;
|
|
884
|
+
recipientUsername: string;
|
|
885
|
+
quantity: number;
|
|
886
|
+
createdAt: string;
|
|
887
|
+
}>;
|
|
888
|
+
supporterBadge: {
|
|
889
|
+
tier: 'none' | 'bronze' | 'silver' | 'gold';
|
|
890
|
+
giftedCount: number;
|
|
891
|
+
nextTierAt: number | null;
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
}
|
|
778
895
|
interface SubscriptionResource {
|
|
779
896
|
getStatus(): Promise<ApiResponse<{
|
|
780
897
|
success: boolean;
|
|
@@ -785,6 +902,14 @@ interface SubscriptionResource {
|
|
|
785
902
|
success: boolean;
|
|
786
903
|
}>>;
|
|
787
904
|
createPortal(): Promise<ApiResponse<PortalResponse>>;
|
|
905
|
+
createGiftCheckout(recipientUsername: string, quantity: 1 | 5 | 10 | 20, isAnonymous?: boolean): Promise<ApiResponse<CreateGiftCheckoutResponse>>;
|
|
906
|
+
getGiftsHistory(): Promise<ApiResponse<GiftsHistoryResponse>>;
|
|
907
|
+
retryGiftAssignment(purchaseId: number, recipientUsername?: string): Promise<ApiResponse<{
|
|
908
|
+
success: boolean;
|
|
909
|
+
data: {
|
|
910
|
+
ok: true;
|
|
911
|
+
};
|
|
912
|
+
}>>;
|
|
788
913
|
}
|
|
789
914
|
declare const createSubscriptionResource: (api: Api) => SubscriptionResource;
|
|
790
915
|
|
|
@@ -796,6 +921,7 @@ interface FriendEntry {
|
|
|
796
921
|
displayName: string | null;
|
|
797
922
|
avatarId: string;
|
|
798
923
|
level: number;
|
|
924
|
+
currentRoomSlug?: string | null;
|
|
799
925
|
status: 'pending' | 'accepted' | 'blocked';
|
|
800
926
|
isSender: boolean;
|
|
801
927
|
}
|
|
@@ -950,4 +1076,4 @@ interface ApiClient {
|
|
|
950
1076
|
}
|
|
951
1077
|
declare const createApiClient: (config: ApiConfig) => ApiClient;
|
|
952
1078
|
|
|
953
|
-
export { type AccountViolation, type AddMediaData, type AddViolationResponse, type AdminListUsersParams, type AdminResource, type AdminStatsResponse, type AdminStatsRoom, type AdminUserEntry, type AdminUsersResponse, Api, type ApiClient, type ApiConfig, ApiError, type ApiResponse, type AuditAction, type AuthResource, type AuthUser, type AvatarCatalogItem, type AvatarCatalogResponse, type AvatarUnlockType, type BackendErrorResponse, type BanResponse, type BoothDJ, type BoothMedia, type BoothResponse, type BoothState, type ChatMessage, type ChatMessageResponse, type ChatMessagesResponse, type ChatResource, type CreateIntentResponse, type CreateRoomData, type EquipAvatarData, type FeaturedRoomsResponse, type FriendActionResponse, type FriendEntry, type FriendList, type FriendListResponse, type FriendResource, type FriendStatusResponse, type FriendshipStatus, type GlobalRole, type GrabResponse, type ImportPlaylistData, type ImportPlaylistResponse, type ImportResult, type JoinMuteInfo, type JoinRoomResponse, Logger, type MediaItem, type MediaItemResponse, type MediaSearchResult, type MediaSource, type ModerateUserData, type MuteResponse, type MyViolation, type MyViolationsResponse, type PaginationMeta, type PlayHistoryItem, type Playlist, type PlaylistResource, type PlaylistResponse, type PlaylistsResponse, type PortalResponse, type Room, type RoomAuditLog, type RoomBan, type RoomBansResponse, type RoomHistoryResponse, type RoomMember, type RoomMute, type RoomMutesResponse, type RoomResource, type RoomResponse, type RoomRole, type RoomStaffResponse, type RoomUserState, type RoomsResponse, type SendMessageData, type ShopResource, type ShuffleResponse, type SoundCloudSearchResponse, type SoundCloudTrackResponse, type SourceResource, type SubscriptionPlan, type SubscriptionResource, type SubscriptionStatus, type UpdateProfileData, type UpdateRoomData, type User, type UserResource, type UserResponse, type UserViolationsResponse, type VoteResponse, type WaitlistResponse, type WaitlistUser, type YouTubeSearchResponse, type YouTubeVideoResponse, createAdminResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|
|
1079
|
+
export { type AccountViolation, type AddMediaData, type AddViolationResponse, type AdminListUsersParams, type AdminResource, type AdminStatsResponse, type AdminStatsRoom, type AdminUserEntry, type AdminUsersResponse, type Api, type ApiClient, type ApiConfig, ApiError, type ApiQueryParams, type ApiRequestConfig, type ApiResponse, type AuditAction, type AuthResource, type AuthUser, type AvatarCatalogItem, type AvatarCatalogResponse, type AvatarUnlockType, type BackendErrorResponse, type BanResponse, type BoothDJ, type BoothMedia, type BoothResponse, type BoothState, type ChatMessage, type ChatMessageResponse, type ChatMessagesResponse, type ChatResource, type CreateIntentResponse, type CreateRoomData, type DashboardActivityItem, type DashboardActivityResponse, type DashboardActivityType, type EquipAvatarData, type FeaturedRoomsResponse, type FriendActionResponse, type FriendEntry, type FriendList, type FriendListResponse, type FriendResource, type FriendStatusResponse, type FriendshipStatus, type GlobalRole, type GrabResponse, type ImportPlaylistData, type ImportPlaylistResponse, type ImportResult, type JoinMuteInfo, type JoinRoomResponse, Logger, type MediaItem, type MediaItemResponse, type MediaSearchResult, type MediaSource, type ModerateUserData, type MuteResponse, type MyViolation, type MyViolationsResponse, type PaginationMeta, type PlayHistoryItem, type Playlist, type PlaylistResource, type PlaylistResponse, type PlaylistsResponse, type PortalResponse, type PublicProfileFriend, type PublicUser, type Room, type RoomAuditLog, type RoomBan, type RoomBansResponse, type RoomHistoryResponse, type RoomMember, type RoomMute, type RoomMutesResponse, type RoomResource, type RoomResponse, type RoomRole, type RoomStaffResponse, type RoomUserState, type RoomsResponse, type SendMessageData, type ShopResource, type ShuffleResponse, type SoundCloudSearchResponse, type SoundCloudTrackResponse, type SourceResource, type SubscriptionPlan, type SubscriptionResource, type SubscriptionStatus, type UpdateProfileData, type UpdateRoomData, type User, type UserResource, type UserResponse, type UserViolationsResponse, type VoteResponse, type WaitlistResponse, type WaitlistUser, type YouTubeSearchResponse, type YouTubeVideoResponse, createAdminResource, createApi, createApiClient, createAuthResource, createChatResource, createFriendResource, createPlaylistResource, createRoomResource, createShopResource, createSourceResource, createSubscriptionResource, createUserResource };
|