@borealise/api 2.0.0-alpha.1 → 2.0.0-alpha.11

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 CHANGED
@@ -26,7 +26,7 @@ Create a client once, then use resources:
26
26
  import { createApiClient } from '@borealise/api'
27
27
 
28
28
  const client = createApiClient({
29
- baseURL: 'https://prod.borealise.com',
29
+ baseURL: 'https://prod.borealise.com/api',
30
30
  })
31
31
 
32
32
  // Login
@@ -45,7 +45,7 @@ If you need more control, create the API and resources separately:
45
45
  import { createApi, createAuthResource, createRoomResource } from '@borealise/api'
46
46
 
47
47
  const api = createApi({
48
- baseURL: 'https://prod.borealise.com',
48
+ baseURL: 'https://prod.borealise.com/api',
49
49
  timeout: 15000,
50
50
  logging: false,
51
51
  })
@@ -63,7 +63,7 @@ await auth.login({ login: 'you@example.com', password: 'secret' })
63
63
 
64
64
  ```ts
65
65
  createApiClient({
66
- baseURL: 'https://prod.borealise.com', // required
66
+ baseURL: 'https://prod.borealise.com/api', // required
67
67
  timeout: 15000, // optional, default: 30000ms
68
68
  logging: false, // optional, disable all console output
69
69
  headers: { 'X-Custom-Header': 'value' } // optional, custom headers
package/dist/index.d.mts CHANGED
@@ -117,6 +117,12 @@ interface AuthResource {
117
117
  message: string;
118
118
  }>>;
119
119
  me(): Promise<ApiResponse<MeResponse>>;
120
+ forgotPassword(email: string): Promise<ApiResponse<{
121
+ success: boolean;
122
+ }>>;
123
+ resetPassword(token: string, password: string): Promise<ApiResponse<{
124
+ success: boolean;
125
+ }>>;
120
126
  }
121
127
  declare const createAuthResource: (api: Api) => AuthResource;
122
128
 
@@ -133,6 +139,21 @@ interface UserResponse {
133
139
  user: User;
134
140
  };
135
141
  }
142
+ interface MyViolation {
143
+ id: number;
144
+ adminUsername: string;
145
+ reason: string;
146
+ revoked: boolean;
147
+ revokedAt: string | null;
148
+ createdAt: string;
149
+ }
150
+ interface MyViolationsResponse {
151
+ success: boolean;
152
+ data: {
153
+ violations: MyViolation[];
154
+ permanentBan: boolean;
155
+ };
156
+ }
136
157
  interface UserResource {
137
158
  getById(id: number): Promise<ApiResponse<UserResponse>>;
138
159
  getByUsername(username: string): Promise<ApiResponse<UserResponse>>;
@@ -146,6 +167,7 @@ interface UserResource {
146
167
  success: boolean;
147
168
  data: null;
148
169
  }>>;
170
+ getMyViolations(): Promise<ApiResponse<MyViolationsResponse>>;
149
171
  }
150
172
  declare const createUserResource: (api: Api) => UserResource;
151
173
 
@@ -416,8 +438,53 @@ interface RoomHistoryResponse {
416
438
  pagination: PaginationMeta;
417
439
  };
418
440
  }
441
+ type AuditAction = 'kick' | 'ban' | 'unban' | 'mute' | 'unmute' | 'role_change' | 'waitlist_move' | 'waitlist_remove' | 'track_skip';
442
+ interface RoomAuditLog {
443
+ id: number;
444
+ actorId: number;
445
+ actorUsername: string;
446
+ targetId: number | null;
447
+ targetUsername: string | null;
448
+ action: AuditAction;
449
+ metadata: string | null;
450
+ createdAt: string;
451
+ }
452
+ interface RoomAuditLogResponse {
453
+ success: boolean;
454
+ data: {
455
+ logs: RoomAuditLog[];
456
+ hasMore: boolean;
457
+ };
458
+ }
459
+ type DashboardActivityType = 'play' | 'woot' | 'grab';
460
+ interface DashboardActivityItem {
461
+ id: string;
462
+ type: DashboardActivityType;
463
+ room: {
464
+ id: number;
465
+ slug: string;
466
+ name: string;
467
+ };
468
+ media: {
469
+ id: number;
470
+ source: 'youtube' | 'soundcloud';
471
+ sourceId: string;
472
+ title: string;
473
+ artist: string | null;
474
+ thumbnail: string | null;
475
+ };
476
+ count: number | null;
477
+ createdAt: string;
478
+ }
479
+ interface DashboardActivityResponse {
480
+ success: boolean;
481
+ data: {
482
+ activities: DashboardActivityItem[];
483
+ };
484
+ }
419
485
  interface RoomResource {
420
486
  list(): Promise<ApiResponse<RoomsResponse>>;
487
+ mine(limit?: number): Promise<ApiResponse<RoomsResponse>>;
421
488
  featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
422
489
  getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
423
490
  create(data: CreateRoomData): Promise<ApiResponse<RoomResponse>>;
@@ -502,6 +569,8 @@ interface RoomResource {
502
569
  vote(slug: string, type: 'woot' | 'meh'): Promise<ApiResponse<VoteResponse>>;
503
570
  grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
504
571
  getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
572
+ getAuditLog(slug: string, limit?: number, before?: string): Promise<ApiResponse<RoomAuditLogResponse>>;
573
+ activity(limit?: number): Promise<ApiResponse<DashboardActivityResponse>>;
505
574
  }
506
575
  declare const createRoomResource: (api: Api) => RoomResource;
507
576
 
@@ -692,6 +761,9 @@ interface AvatarCatalogResponse {
692
761
  xp: number;
693
762
  };
694
763
  }
764
+ interface EquipAvatarData {
765
+ avatarId: string;
766
+ }
695
767
  interface ShopResource {
696
768
  getAvatarCatalog(): Promise<ApiResponse<AvatarCatalogResponse>>;
697
769
  unlockAvatar(avatarId: string): Promise<ApiResponse<{
@@ -788,6 +860,109 @@ interface FriendResource {
788
860
  }
789
861
  declare const createFriendResource: (api: Api) => FriendResource;
790
862
 
863
+ interface AdminUserEntry {
864
+ id: number;
865
+ username: string;
866
+ displayName: string | null;
867
+ email?: string;
868
+ avatarId: string;
869
+ globalRole: GlobalRole;
870
+ disabled: boolean;
871
+ permanentBan: boolean;
872
+ emailVerified: boolean;
873
+ xp: number;
874
+ createdAt: string;
875
+ }
876
+ interface AdminUsersResponse {
877
+ success: boolean;
878
+ data: {
879
+ users: AdminUserEntry[];
880
+ total: number;
881
+ };
882
+ }
883
+ interface AdminStatsRoom {
884
+ slug: string;
885
+ name: string;
886
+ population: number;
887
+ }
888
+ interface AdminStatsResponse {
889
+ success: boolean;
890
+ data: {
891
+ activeRooms: number;
892
+ totalOnlineUsers: number;
893
+ rooms: AdminStatsRoom[];
894
+ };
895
+ }
896
+ interface AdminListUsersParams {
897
+ search?: string;
898
+ role?: GlobalRole | '';
899
+ disabled?: boolean;
900
+ page?: number;
901
+ limit?: number;
902
+ sortBy?: 'id' | 'username' | 'createdAt';
903
+ sortDir?: 'asc' | 'desc';
904
+ }
905
+ interface AccountViolation {
906
+ id: number;
907
+ adminId: number;
908
+ adminUsername: string;
909
+ reason: string;
910
+ revoked: boolean;
911
+ revokedAt: string | null;
912
+ revokerId: number | null;
913
+ createdAt: string;
914
+ }
915
+ interface UserViolationsResponse {
916
+ success: boolean;
917
+ data: {
918
+ violations: AccountViolation[];
919
+ permanentBan: boolean;
920
+ };
921
+ }
922
+ interface AddViolationResponse {
923
+ success: boolean;
924
+ data: {
925
+ violation: AccountViolation;
926
+ permanentlyBanned: boolean;
927
+ activeViolations: number;
928
+ };
929
+ }
930
+ interface AdminResource {
931
+ listUsers(params?: AdminListUsersParams): Promise<ApiResponse<AdminUsersResponse>>;
932
+ enableUser(id: number): Promise<ApiResponse<{
933
+ success: boolean;
934
+ data: null;
935
+ }>>;
936
+ disableUser(id: number): Promise<ApiResponse<{
937
+ success: boolean;
938
+ data: null;
939
+ }>>;
940
+ updateRole(id: number, role: GlobalRole): Promise<ApiResponse<{
941
+ success: boolean;
942
+ data: null;
943
+ }>>;
944
+ broadcast(message: string): Promise<ApiResponse<{
945
+ success: boolean;
946
+ data: {
947
+ sent_to_rooms: number;
948
+ };
949
+ }>>;
950
+ setMaintenance(active: boolean, message?: string, endsAt?: number | null): Promise<ApiResponse<{
951
+ success: boolean;
952
+ data: {
953
+ active: boolean;
954
+ };
955
+ }>>;
956
+ getStats(): Promise<ApiResponse<AdminStatsResponse>>;
957
+ addViolation(userId: number, reason: string): Promise<ApiResponse<AddViolationResponse>>;
958
+ revokeViolation(violationId: number): Promise<ApiResponse<{
959
+ success: boolean;
960
+ data: null;
961
+ }>>;
962
+ getUserViolations(userId: number): Promise<ApiResponse<UserViolationsResponse>>;
963
+ }
964
+ declare const createAdminResource: (api: Api) => AdminResource;
965
+
791
966
  interface ApiClient {
792
967
  api: Api;
793
968
  auth: AuthResource;
@@ -799,7 +974,8 @@ interface ApiClient {
799
974
  shop: ShopResource;
800
975
  subscription: SubscriptionResource;
801
976
  friend: FriendResource;
977
+ admin: AdminResource;
802
978
  }
803
979
  declare const createApiClient: (config: ApiConfig) => ApiClient;
804
980
 
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 };
981
+ 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 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 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
@@ -117,6 +117,12 @@ interface AuthResource {
117
117
  message: string;
118
118
  }>>;
119
119
  me(): Promise<ApiResponse<MeResponse>>;
120
+ forgotPassword(email: string): Promise<ApiResponse<{
121
+ success: boolean;
122
+ }>>;
123
+ resetPassword(token: string, password: string): Promise<ApiResponse<{
124
+ success: boolean;
125
+ }>>;
120
126
  }
121
127
  declare const createAuthResource: (api: Api) => AuthResource;
122
128
 
@@ -133,6 +139,21 @@ interface UserResponse {
133
139
  user: User;
134
140
  };
135
141
  }
142
+ interface MyViolation {
143
+ id: number;
144
+ adminUsername: string;
145
+ reason: string;
146
+ revoked: boolean;
147
+ revokedAt: string | null;
148
+ createdAt: string;
149
+ }
150
+ interface MyViolationsResponse {
151
+ success: boolean;
152
+ data: {
153
+ violations: MyViolation[];
154
+ permanentBan: boolean;
155
+ };
156
+ }
136
157
  interface UserResource {
137
158
  getById(id: number): Promise<ApiResponse<UserResponse>>;
138
159
  getByUsername(username: string): Promise<ApiResponse<UserResponse>>;
@@ -146,6 +167,7 @@ interface UserResource {
146
167
  success: boolean;
147
168
  data: null;
148
169
  }>>;
170
+ getMyViolations(): Promise<ApiResponse<MyViolationsResponse>>;
149
171
  }
150
172
  declare const createUserResource: (api: Api) => UserResource;
151
173
 
@@ -416,8 +438,53 @@ interface RoomHistoryResponse {
416
438
  pagination: PaginationMeta;
417
439
  };
418
440
  }
441
+ type AuditAction = 'kick' | 'ban' | 'unban' | 'mute' | 'unmute' | 'role_change' | 'waitlist_move' | 'waitlist_remove' | 'track_skip';
442
+ interface RoomAuditLog {
443
+ id: number;
444
+ actorId: number;
445
+ actorUsername: string;
446
+ targetId: number | null;
447
+ targetUsername: string | null;
448
+ action: AuditAction;
449
+ metadata: string | null;
450
+ createdAt: string;
451
+ }
452
+ interface RoomAuditLogResponse {
453
+ success: boolean;
454
+ data: {
455
+ logs: RoomAuditLog[];
456
+ hasMore: boolean;
457
+ };
458
+ }
459
+ type DashboardActivityType = 'play' | 'woot' | 'grab';
460
+ interface DashboardActivityItem {
461
+ id: string;
462
+ type: DashboardActivityType;
463
+ room: {
464
+ id: number;
465
+ slug: string;
466
+ name: string;
467
+ };
468
+ media: {
469
+ id: number;
470
+ source: 'youtube' | 'soundcloud';
471
+ sourceId: string;
472
+ title: string;
473
+ artist: string | null;
474
+ thumbnail: string | null;
475
+ };
476
+ count: number | null;
477
+ createdAt: string;
478
+ }
479
+ interface DashboardActivityResponse {
480
+ success: boolean;
481
+ data: {
482
+ activities: DashboardActivityItem[];
483
+ };
484
+ }
419
485
  interface RoomResource {
420
486
  list(): Promise<ApiResponse<RoomsResponse>>;
487
+ mine(limit?: number): Promise<ApiResponse<RoomsResponse>>;
421
488
  featured(): Promise<ApiResponse<FeaturedRoomsResponse>>;
422
489
  getBySlug(slug: string): Promise<ApiResponse<RoomResponse>>;
423
490
  create(data: CreateRoomData): Promise<ApiResponse<RoomResponse>>;
@@ -502,6 +569,8 @@ interface RoomResource {
502
569
  vote(slug: string, type: 'woot' | 'meh'): Promise<ApiResponse<VoteResponse>>;
503
570
  grabTrack(slug: string, playlistId?: number): Promise<ApiResponse<GrabResponse>>;
504
571
  getHistory(slug: string, page?: number, limit?: number): Promise<ApiResponse<RoomHistoryResponse>>;
572
+ getAuditLog(slug: string, limit?: number, before?: string): Promise<ApiResponse<RoomAuditLogResponse>>;
573
+ activity(limit?: number): Promise<ApiResponse<DashboardActivityResponse>>;
505
574
  }
506
575
  declare const createRoomResource: (api: Api) => RoomResource;
507
576
 
@@ -692,6 +761,9 @@ interface AvatarCatalogResponse {
692
761
  xp: number;
693
762
  };
694
763
  }
764
+ interface EquipAvatarData {
765
+ avatarId: string;
766
+ }
695
767
  interface ShopResource {
696
768
  getAvatarCatalog(): Promise<ApiResponse<AvatarCatalogResponse>>;
697
769
  unlockAvatar(avatarId: string): Promise<ApiResponse<{
@@ -788,6 +860,109 @@ interface FriendResource {
788
860
  }
789
861
  declare const createFriendResource: (api: Api) => FriendResource;
790
862
 
863
+ interface AdminUserEntry {
864
+ id: number;
865
+ username: string;
866
+ displayName: string | null;
867
+ email?: string;
868
+ avatarId: string;
869
+ globalRole: GlobalRole;
870
+ disabled: boolean;
871
+ permanentBan: boolean;
872
+ emailVerified: boolean;
873
+ xp: number;
874
+ createdAt: string;
875
+ }
876
+ interface AdminUsersResponse {
877
+ success: boolean;
878
+ data: {
879
+ users: AdminUserEntry[];
880
+ total: number;
881
+ };
882
+ }
883
+ interface AdminStatsRoom {
884
+ slug: string;
885
+ name: string;
886
+ population: number;
887
+ }
888
+ interface AdminStatsResponse {
889
+ success: boolean;
890
+ data: {
891
+ activeRooms: number;
892
+ totalOnlineUsers: number;
893
+ rooms: AdminStatsRoom[];
894
+ };
895
+ }
896
+ interface AdminListUsersParams {
897
+ search?: string;
898
+ role?: GlobalRole | '';
899
+ disabled?: boolean;
900
+ page?: number;
901
+ limit?: number;
902
+ sortBy?: 'id' | 'username' | 'createdAt';
903
+ sortDir?: 'asc' | 'desc';
904
+ }
905
+ interface AccountViolation {
906
+ id: number;
907
+ adminId: number;
908
+ adminUsername: string;
909
+ reason: string;
910
+ revoked: boolean;
911
+ revokedAt: string | null;
912
+ revokerId: number | null;
913
+ createdAt: string;
914
+ }
915
+ interface UserViolationsResponse {
916
+ success: boolean;
917
+ data: {
918
+ violations: AccountViolation[];
919
+ permanentBan: boolean;
920
+ };
921
+ }
922
+ interface AddViolationResponse {
923
+ success: boolean;
924
+ data: {
925
+ violation: AccountViolation;
926
+ permanentlyBanned: boolean;
927
+ activeViolations: number;
928
+ };
929
+ }
930
+ interface AdminResource {
931
+ listUsers(params?: AdminListUsersParams): Promise<ApiResponse<AdminUsersResponse>>;
932
+ enableUser(id: number): Promise<ApiResponse<{
933
+ success: boolean;
934
+ data: null;
935
+ }>>;
936
+ disableUser(id: number): Promise<ApiResponse<{
937
+ success: boolean;
938
+ data: null;
939
+ }>>;
940
+ updateRole(id: number, role: GlobalRole): Promise<ApiResponse<{
941
+ success: boolean;
942
+ data: null;
943
+ }>>;
944
+ broadcast(message: string): Promise<ApiResponse<{
945
+ success: boolean;
946
+ data: {
947
+ sent_to_rooms: number;
948
+ };
949
+ }>>;
950
+ setMaintenance(active: boolean, message?: string, endsAt?: number | null): Promise<ApiResponse<{
951
+ success: boolean;
952
+ data: {
953
+ active: boolean;
954
+ };
955
+ }>>;
956
+ getStats(): Promise<ApiResponse<AdminStatsResponse>>;
957
+ addViolation(userId: number, reason: string): Promise<ApiResponse<AddViolationResponse>>;
958
+ revokeViolation(violationId: number): Promise<ApiResponse<{
959
+ success: boolean;
960
+ data: null;
961
+ }>>;
962
+ getUserViolations(userId: number): Promise<ApiResponse<UserViolationsResponse>>;
963
+ }
964
+ declare const createAdminResource: (api: Api) => AdminResource;
965
+
791
966
  interface ApiClient {
792
967
  api: Api;
793
968
  auth: AuthResource;
@@ -799,7 +974,8 @@ interface ApiClient {
799
974
  shop: ShopResource;
800
975
  subscription: SubscriptionResource;
801
976
  friend: FriendResource;
977
+ admin: AdminResource;
802
978
  }
803
979
  declare const createApiClient: (config: ApiConfig) => ApiClient;
804
980
 
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 };
981
+ 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 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 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.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  Api: () => Api,
34
34
  ApiError: () => ApiError,
35
35
  Logger: () => Logger,
36
+ createAdminResource: () => createAdminResource,
36
37
  createApi: () => createApi,
37
38
  createApiClient: () => createApiClient,
38
39
  createAuthResource: () => createAuthResource,
@@ -153,13 +154,16 @@ var Api = class {
153
154
  parseError(error) {
154
155
  if (error.response) {
155
156
  const responseData = error.response.data;
157
+ const isObjectResponse = typeof responseData === "object" && responseData !== null;
156
158
  let message;
157
159
  let backendResponse;
158
- if (responseData && "error" in responseData && responseData.error) {
160
+ if (isObjectResponse && "error" in responseData && responseData.error) {
159
161
  message = responseData.error;
160
162
  backendResponse = responseData;
161
- } else if (responseData && "message" in responseData && responseData.message) {
163
+ } else if (isObjectResponse && "message" in responseData && responseData.message) {
162
164
  message = responseData.message;
165
+ } else if (typeof responseData === "string" && responseData) {
166
+ message = responseData;
163
167
  } else {
164
168
  message = error.message;
165
169
  }
@@ -225,7 +229,9 @@ var createAuthResource = (api) => ({
225
229
  register: (data) => api.post(`${endpoint}/register`, data),
226
230
  refresh: (refreshToken) => api.post(`${endpoint}/refresh`, { refreshToken }),
227
231
  logout: () => api.post(`${endpoint}/logout`),
228
- me: () => api.get(`${endpoint}/me`)
232
+ me: () => api.get(`${endpoint}/me`),
233
+ forgotPassword: (email) => api.post(`${endpoint}/forgot-password`, { email }),
234
+ resetPassword: (token, password) => api.post(`${endpoint}/reset-password`, { token, password })
229
235
  });
230
236
 
231
237
  // src/resources/user.ts
@@ -236,13 +242,15 @@ var createUserResource = (api) => ({
236
242
  updateProfile: (data) => api.patch(`${endpoint2}/me`, data),
237
243
  deleteAccount: () => api.delete(`${endpoint2}/me`),
238
244
  updateRole: (id, role) => api.patch(`/api/admin/users/${id}/role`, { role }),
239
- disable: (id) => api.post(`/api/admin/users/${id}/disable`)
245
+ disable: (id) => api.post(`/api/admin/users/${id}/disable`),
246
+ getMyViolations: () => api.get(`${endpoint2}/me/violations`)
240
247
  });
241
248
 
242
249
  // src/resources/room.ts
243
250
  var endpoint3 = "/rooms";
244
251
  var createRoomResource = (api) => ({
245
252
  list: () => api.get(endpoint3),
253
+ mine: (limit = 20) => api.get(`${endpoint3}/mine`, { params: { limit } }),
246
254
  featured: () => api.get(`${endpoint3}/featured`),
247
255
  getBySlug: (slug) => api.get(`${endpoint3}/${slug}`),
248
256
  create: (data) => api.post(endpoint3, data),
@@ -279,7 +287,9 @@ var createRoomResource = (api) => ({
279
287
  ),
280
288
  vote: (slug, type) => api.post(`${endpoint3}/${slug}/booth/vote`, { type }),
281
289
  grabTrack: (slug, playlistId) => api.post(`${endpoint3}/${slug}/booth/grab`, playlistId ? { playlistId } : {}),
282
- getHistory: (slug, page = 1, limit = 20) => api.get(`${endpoint3}/${slug}/history`, { params: { page, limit } })
290
+ getHistory: (slug, page = 1, limit = 20) => api.get(`${endpoint3}/${slug}/history`, { params: { page, limit } }),
291
+ getAuditLog: (slug, limit = 50, before) => api.get(`${endpoint3}/${slug}/audit`, { params: before ? { limit, before } : { limit } }),
292
+ activity: (limit = 12) => api.get(`${endpoint3}/activity`, { params: { limit } })
283
293
  });
284
294
 
285
295
  // src/resources/chat.ts
@@ -374,6 +384,32 @@ var createFriendResource = (api) => ({
374
384
  unblock: (targetUserId) => api.delete(`${endpoint9}/${targetUserId}/block`)
375
385
  });
376
386
 
387
+ // src/resources/admin.ts
388
+ var endpoint10 = "/admin";
389
+ var createAdminResource = (api) => ({
390
+ listUsers: (params = {}) => {
391
+ const query = new URLSearchParams();
392
+ if (params.search) query.set("search", params.search);
393
+ if (params.role) query.set("role", params.role);
394
+ if (params.disabled !== void 0) query.set("disabled", String(params.disabled));
395
+ if (params.page) query.set("page", String(params.page));
396
+ if (params.limit) query.set("limit", String(params.limit));
397
+ if (params.sortBy) query.set("sortBy", params.sortBy);
398
+ if (params.sortDir) query.set("sortDir", params.sortDir);
399
+ const qs = query.toString();
400
+ return api.get(`${endpoint10}/users${qs ? `?${qs}` : ""}`);
401
+ },
402
+ enableUser: (id) => api.post(`${endpoint10}/users/${id}/enable`),
403
+ disableUser: (id) => api.post(`${endpoint10}/users/${id}/disable`),
404
+ updateRole: (id, role) => api.patch(`${endpoint10}/users/${id}/role`, { role }),
405
+ broadcast: (message) => api.post(`${endpoint10}/broadcast`, { message }),
406
+ setMaintenance: (active, message, endsAt) => api.post(`${endpoint10}/maintenance`, { active, message, endsAt }),
407
+ getStats: () => api.get(`${endpoint10}/stats`),
408
+ addViolation: (userId, reason) => api.post(`${endpoint10}/users/${userId}/violations`, { reason }),
409
+ revokeViolation: (violationId) => api.delete(`${endpoint10}/violations/${violationId}`),
410
+ getUserViolations: (userId) => api.get(`${endpoint10}/users/${userId}/violations`)
411
+ });
412
+
377
413
  // src/resources/index.ts
378
414
  var createApiClient = (config) => {
379
415
  const api = createApi(config);
@@ -387,7 +423,8 @@ var createApiClient = (config) => {
387
423
  source: createSourceResource(api),
388
424
  shop: createShopResource(api),
389
425
  subscription: createSubscriptionResource(api),
390
- friend: createFriendResource(api)
426
+ friend: createFriendResource(api),
427
+ admin: createAdminResource(api)
391
428
  };
392
429
  };
393
430
  // Annotate the CommonJS export names for ESM import in node:
@@ -395,6 +432,7 @@ var createApiClient = (config) => {
395
432
  Api,
396
433
  ApiError,
397
434
  Logger,
435
+ createAdminResource,
398
436
  createApi,
399
437
  createApiClient,
400
438
  createAuthResource,
package/dist/index.mjs CHANGED
@@ -104,13 +104,16 @@ var Api = class {
104
104
  parseError(error) {
105
105
  if (error.response) {
106
106
  const responseData = error.response.data;
107
+ const isObjectResponse = typeof responseData === "object" && responseData !== null;
107
108
  let message;
108
109
  let backendResponse;
109
- if (responseData && "error" in responseData && responseData.error) {
110
+ if (isObjectResponse && "error" in responseData && responseData.error) {
110
111
  message = responseData.error;
111
112
  backendResponse = responseData;
112
- } else if (responseData && "message" in responseData && responseData.message) {
113
+ } else if (isObjectResponse && "message" in responseData && responseData.message) {
113
114
  message = responseData.message;
115
+ } else if (typeof responseData === "string" && responseData) {
116
+ message = responseData;
114
117
  } else {
115
118
  message = error.message;
116
119
  }
@@ -176,7 +179,9 @@ var createAuthResource = (api) => ({
176
179
  register: (data) => api.post(`${endpoint}/register`, data),
177
180
  refresh: (refreshToken) => api.post(`${endpoint}/refresh`, { refreshToken }),
178
181
  logout: () => api.post(`${endpoint}/logout`),
179
- me: () => api.get(`${endpoint}/me`)
182
+ me: () => api.get(`${endpoint}/me`),
183
+ forgotPassword: (email) => api.post(`${endpoint}/forgot-password`, { email }),
184
+ resetPassword: (token, password) => api.post(`${endpoint}/reset-password`, { token, password })
180
185
  });
181
186
 
182
187
  // src/resources/user.ts
@@ -187,13 +192,15 @@ var createUserResource = (api) => ({
187
192
  updateProfile: (data) => api.patch(`${endpoint2}/me`, data),
188
193
  deleteAccount: () => api.delete(`${endpoint2}/me`),
189
194
  updateRole: (id, role) => api.patch(`/api/admin/users/${id}/role`, { role }),
190
- disable: (id) => api.post(`/api/admin/users/${id}/disable`)
195
+ disable: (id) => api.post(`/api/admin/users/${id}/disable`),
196
+ getMyViolations: () => api.get(`${endpoint2}/me/violations`)
191
197
  });
192
198
 
193
199
  // src/resources/room.ts
194
200
  var endpoint3 = "/rooms";
195
201
  var createRoomResource = (api) => ({
196
202
  list: () => api.get(endpoint3),
203
+ mine: (limit = 20) => api.get(`${endpoint3}/mine`, { params: { limit } }),
197
204
  featured: () => api.get(`${endpoint3}/featured`),
198
205
  getBySlug: (slug) => api.get(`${endpoint3}/${slug}`),
199
206
  create: (data) => api.post(endpoint3, data),
@@ -230,7 +237,9 @@ var createRoomResource = (api) => ({
230
237
  ),
231
238
  vote: (slug, type) => api.post(`${endpoint3}/${slug}/booth/vote`, { type }),
232
239
  grabTrack: (slug, playlistId) => api.post(`${endpoint3}/${slug}/booth/grab`, playlistId ? { playlistId } : {}),
233
- getHistory: (slug, page = 1, limit = 20) => api.get(`${endpoint3}/${slug}/history`, { params: { page, limit } })
240
+ getHistory: (slug, page = 1, limit = 20) => api.get(`${endpoint3}/${slug}/history`, { params: { page, limit } }),
241
+ getAuditLog: (slug, limit = 50, before) => api.get(`${endpoint3}/${slug}/audit`, { params: before ? { limit, before } : { limit } }),
242
+ activity: (limit = 12) => api.get(`${endpoint3}/activity`, { params: { limit } })
234
243
  });
235
244
 
236
245
  // src/resources/chat.ts
@@ -325,6 +334,32 @@ var createFriendResource = (api) => ({
325
334
  unblock: (targetUserId) => api.delete(`${endpoint9}/${targetUserId}/block`)
326
335
  });
327
336
 
337
+ // src/resources/admin.ts
338
+ var endpoint10 = "/admin";
339
+ var createAdminResource = (api) => ({
340
+ listUsers: (params = {}) => {
341
+ const query = new URLSearchParams();
342
+ if (params.search) query.set("search", params.search);
343
+ if (params.role) query.set("role", params.role);
344
+ if (params.disabled !== void 0) query.set("disabled", String(params.disabled));
345
+ if (params.page) query.set("page", String(params.page));
346
+ if (params.limit) query.set("limit", String(params.limit));
347
+ if (params.sortBy) query.set("sortBy", params.sortBy);
348
+ if (params.sortDir) query.set("sortDir", params.sortDir);
349
+ const qs = query.toString();
350
+ return api.get(`${endpoint10}/users${qs ? `?${qs}` : ""}`);
351
+ },
352
+ enableUser: (id) => api.post(`${endpoint10}/users/${id}/enable`),
353
+ disableUser: (id) => api.post(`${endpoint10}/users/${id}/disable`),
354
+ updateRole: (id, role) => api.patch(`${endpoint10}/users/${id}/role`, { role }),
355
+ broadcast: (message) => api.post(`${endpoint10}/broadcast`, { message }),
356
+ setMaintenance: (active, message, endsAt) => api.post(`${endpoint10}/maintenance`, { active, message, endsAt }),
357
+ getStats: () => api.get(`${endpoint10}/stats`),
358
+ addViolation: (userId, reason) => api.post(`${endpoint10}/users/${userId}/violations`, { reason }),
359
+ revokeViolation: (violationId) => api.delete(`${endpoint10}/violations/${violationId}`),
360
+ getUserViolations: (userId) => api.get(`${endpoint10}/users/${userId}/violations`)
361
+ });
362
+
328
363
  // src/resources/index.ts
329
364
  var createApiClient = (config) => {
330
365
  const api = createApi(config);
@@ -338,13 +373,15 @@ var createApiClient = (config) => {
338
373
  source: createSourceResource(api),
339
374
  shop: createShopResource(api),
340
375
  subscription: createSubscriptionResource(api),
341
- friend: createFriendResource(api)
376
+ friend: createFriendResource(api),
377
+ admin: createAdminResource(api)
342
378
  };
343
379
  };
344
380
  export {
345
381
  Api,
346
382
  ApiError,
347
383
  Logger,
384
+ createAdminResource,
348
385
  createApi,
349
386
  createApiClient,
350
387
  createAuthResource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borealise/api",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.11",
4
4
  "description": "Official API client for Borealise",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",