@wavezfm/api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +338 -0
  2. package/dist/core/ApiError.d.ts +14 -0
  3. package/dist/core/ApiError.js +20 -0
  4. package/dist/core/ApiError.js.map +1 -0
  5. package/dist/core/api.d.ts +27 -0
  6. package/dist/core/api.js +327 -0
  7. package/dist/core/api.js.map +1 -0
  8. package/dist/core/i18n.d.ts +3 -0
  9. package/dist/core/i18n.js +97 -0
  10. package/dist/core/i18n.js.map +1 -0
  11. package/dist/index.d.ts +379 -0
  12. package/dist/index.js +47 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/realtime/roomBot.d.ts +2 -0
  15. package/dist/realtime/roomBot.js +215 -0
  16. package/dist/realtime/roomBot.js.map +1 -0
  17. package/dist/resources/auth.d.ts +35 -0
  18. package/dist/resources/auth.js +30 -0
  19. package/dist/resources/auth.js.map +1 -0
  20. package/dist/resources/billing.d.ts +45 -0
  21. package/dist/resources/billing.js +29 -0
  22. package/dist/resources/billing.js.map +1 -0
  23. package/dist/resources/chat.d.ts +27 -0
  24. package/dist/resources/chat.js +38 -0
  25. package/dist/resources/chat.js.map +1 -0
  26. package/dist/resources/friend.d.ts +23 -0
  27. package/dist/resources/friend.js +35 -0
  28. package/dist/resources/friend.js.map +1 -0
  29. package/dist/resources/playlist.d.ts +64 -0
  30. package/dist/resources/playlist.js +61 -0
  31. package/dist/resources/playlist.js.map +1 -0
  32. package/dist/resources/room.d.ts +50 -0
  33. package/dist/resources/room.js +152 -0
  34. package/dist/resources/room.js.map +1 -0
  35. package/dist/resources/roomBot.d.ts +45 -0
  36. package/dist/resources/roomBot.js +75 -0
  37. package/dist/resources/roomBot.js.map +1 -0
  38. package/dist/resources/settings.d.ts +43 -0
  39. package/dist/resources/settings.js +38 -0
  40. package/dist/resources/settings.js.map +1 -0
  41. package/dist/resources/shop.d.ts +11 -0
  42. package/dist/resources/shop.js +22 -0
  43. package/dist/resources/shop.js.map +1 -0
  44. package/dist/resources/source.d.ts +14 -0
  45. package/dist/resources/source.js +50 -0
  46. package/dist/resources/source.js.map +1 -0
  47. package/dist/resources/system.d.ts +6 -0
  48. package/dist/resources/system.js +20 -0
  49. package/dist/resources/system.js.map +1 -0
  50. package/dist/resources/user.d.ts +7 -0
  51. package/dist/resources/user.js +19 -0
  52. package/dist/resources/user.js.map +1 -0
  53. package/dist/types.d.ts +374 -0
  54. package/dist/types.js +2 -0
  55. package/dist/types.js.map +1 -0
  56. package/package.json +97 -0
@@ -0,0 +1,374 @@
1
+ export type ApiPrimitive = string | number | boolean | null;
2
+ export type ApiQueryValue = ApiPrimitive | readonly ApiPrimitive[] | undefined;
3
+ export type ApiQuery = Record<string, ApiQueryValue>;
4
+ export type AuthMode = "session" | "auth-token" | "room-bot" | "none";
5
+ export type ApiParseMode = "json" | "text" | "void";
6
+ export type FetchImplementation = typeof fetch;
7
+ export type WavezApiLocale = "en" | "pt-BR";
8
+ export type WavezApiMessageKey = "fetchUnavailable" | "baseUrlRequired" | "requestTimedOut" | "roomPermissionManageRoom" | "roomNotFound" | "roomBotInvalid" | "roomBotScopeMismatch" | "roomBotOwnerMissing" | "roomBotOwnerBanned" | "roomBotPermissionDenied" | "roomBotForbidden" | "roomBotTokenRequired" | "roomBotMuted" | "roomBotWebsocketFactoryRequired" | "roomBotWebsocketListenerUnsupported" | "roomBotWebsocketNotConnected" | "roomBotWebsocketCreateFailed" | "roomBotWebsocketConnectFailed" | "roomBotCreateNameLengthInvalid" | "roomBotCreateAvatarUrlInvalid" | "roomBotCreateAvatarUrlDirectImageRequired" | "roomBotCreatePermissionsArrayRequired" | "roomBotCreatePermissionInvalid" | "roomBotCreatePermissionRequired" | "roomBotCreatePrefixLengthInvalid" | "roomBotCreatePrefixWhitespaceInvalid" | "roomBotCreateExpiryNumberInvalid" | "roomBotCreateExpiryRangeInvalid";
9
+ export type WavezApiMessageValues = Record<string, string | number | boolean | null | undefined>;
10
+ export type WavezApiMessages = Partial<Record<WavezApiMessageKey, string>>;
11
+ export interface ApiSuccessResponse<T> {
12
+ data: T;
13
+ status: number;
14
+ headers: Headers;
15
+ }
16
+ export interface ApiRequestOptions<TBody = unknown> {
17
+ path: string;
18
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
19
+ query?: ApiQuery;
20
+ body?: TBody;
21
+ headers?: HeadersInit;
22
+ credentials?: RequestCredentials;
23
+ cache?: RequestCache;
24
+ signal?: AbortSignal;
25
+ authMode?: AuthMode;
26
+ parseAs?: ApiParseMode;
27
+ }
28
+ export interface ApiClientConfig {
29
+ baseURL: string;
30
+ timeout?: number;
31
+ logging?: boolean;
32
+ headers?: HeadersInit;
33
+ credentials?: RequestCredentials;
34
+ fetch?: FetchImplementation;
35
+ authToken?: string | null;
36
+ roomBotToken?: string | null;
37
+ locale?: WavezApiLocale;
38
+ messages?: WavezApiMessages;
39
+ }
40
+ export interface ApiLike {
41
+ request<T, TBody = unknown>(options: ApiRequestOptions<TBody>): Promise<ApiSuccessResponse<T>>;
42
+ get<T>(path: string, options?: Omit<ApiRequestOptions<never>, "path" | "method" | "body">): Promise<ApiSuccessResponse<T>>;
43
+ post<T, TBody = unknown>(path: string, body?: TBody, options?: Omit<ApiRequestOptions<TBody>, "path" | "method" | "body">): Promise<ApiSuccessResponse<T>>;
44
+ put<T, TBody = unknown>(path: string, body?: TBody, options?: Omit<ApiRequestOptions<TBody>, "path" | "method" | "body">): Promise<ApiSuccessResponse<T>>;
45
+ patch<T, TBody = unknown>(path: string, body?: TBody, options?: Omit<ApiRequestOptions<TBody>, "path" | "method" | "body">): Promise<ApiSuccessResponse<T>>;
46
+ delete<T, TBody = unknown>(path: string, options?: Omit<ApiRequestOptions<TBody>, "path" | "method">): Promise<ApiSuccessResponse<T>>;
47
+ getBaseURL(): string;
48
+ getSiteURL(path?: string): string;
49
+ formatMessage(key: WavezApiMessageKey, values?: WavezApiMessageValues): string;
50
+ setAuthToken(token: string | null): void;
51
+ getAuthToken(): string | null;
52
+ setRoomBotToken(token: string | null): void;
53
+ getRoomBotToken(): string | null;
54
+ }
55
+ export interface AuthUser {
56
+ id: string;
57
+ userId?: string;
58
+ email?: string | null;
59
+ emailVerified?: boolean;
60
+ username: string;
61
+ displayUsername?: string | null;
62
+ /**
63
+ * @deprecated Use `displayUsername`.
64
+ */
65
+ displayName?: string | null;
66
+ name?: string | null;
67
+ bio?: string | null;
68
+ image?: string | null;
69
+ avatar?: string | null;
70
+ avatarId?: string | null;
71
+ avatarDjUrl?: string | null;
72
+ avatarFrameCount?: number;
73
+ platformRole?: string | null;
74
+ platformRoles?: string[];
75
+ infiniteLevel?: boolean;
76
+ level?: number;
77
+ xp?: number;
78
+ xpRequired?: number;
79
+ totalXp?: number;
80
+ fanCount?: number;
81
+ fans?: number;
82
+ isBanned?: boolean;
83
+ banReason?: string | null;
84
+ colorTheme?: string | null;
85
+ timeFormat?: "12h" | "24h" | string | null;
86
+ notifyChatMentions?: boolean;
87
+ playMentionSound?: boolean;
88
+ presenceStatus?: string | null;
89
+ selectedBadgeIds?: string[];
90
+ selectedBadges?: BadgeAssignment[];
91
+ showChatBadge?: boolean;
92
+ subscriptionStatus?: string | null;
93
+ subscriptionCycle?: string | null;
94
+ subscriptionCurrentPeriodStartAt?: string | null;
95
+ subscriptionCurrentPeriodEndAt?: string | null;
96
+ subscriptionCancelAtPeriodEnd?: boolean;
97
+ canClearAdminLogs?: boolean;
98
+ [key: string]: unknown;
99
+ }
100
+ export interface UserProfile extends AuthUser {
101
+ numericId?: number;
102
+ badges?: BadgeAssignment[];
103
+ }
104
+ export interface BadgeAssignment {
105
+ id: string;
106
+ name?: string;
107
+ title?: string;
108
+ iconKey?: string | null;
109
+ imageUrl?: string | null;
110
+ [key: string]: unknown;
111
+ }
112
+ export interface RoomSummary {
113
+ id: string;
114
+ slug: string;
115
+ name: string;
116
+ description?: string;
117
+ activeUsersCount?: number;
118
+ population?: number;
119
+ queueCount?: number;
120
+ isFeatured?: boolean;
121
+ isFavorited?: boolean;
122
+ verified?: boolean;
123
+ ownerUsername?: string | null;
124
+ currentPlayback?: {
125
+ title?: string;
126
+ artist?: string;
127
+ thumbnailUrl?: string | null;
128
+ [key: string]: unknown;
129
+ } | null;
130
+ [key: string]: unknown;
131
+ }
132
+ export interface PlaylistSummary {
133
+ id: string;
134
+ name: string;
135
+ isActive?: boolean;
136
+ totalTracks?: number;
137
+ itemCount?: number;
138
+ [key: string]: unknown;
139
+ }
140
+ export interface PlaylistTrack {
141
+ id: string;
142
+ source: string;
143
+ sourceId: string;
144
+ title: string;
145
+ artist?: string;
146
+ durationMs?: number;
147
+ thumbnailUrl?: string | null;
148
+ [key: string]: unknown;
149
+ }
150
+ export interface MediaSearchResult {
151
+ source: string;
152
+ sourceId: string;
153
+ title: string;
154
+ artist?: string;
155
+ thumbnailUrl?: string | null;
156
+ [key: string]: unknown;
157
+ }
158
+ export interface ChatMessage {
159
+ id: string;
160
+ userId: string;
161
+ username: string;
162
+ content: string;
163
+ timestamp?: string | number;
164
+ editedAt?: string | null;
165
+ avatar?: string | null;
166
+ role?: string;
167
+ platformRole?: string | null;
168
+ [key: string]: unknown;
169
+ }
170
+ export interface WalletBalance {
171
+ coins: number;
172
+ diamonds: number;
173
+ [key: string]: unknown;
174
+ }
175
+ export interface InventoryResponse {
176
+ ownedAvatarIds?: string[];
177
+ ownedBackgroundIds?: string[];
178
+ ownedBadgeIds?: string[];
179
+ ownedVideoFrameIds?: string[];
180
+ avatarId?: string | null;
181
+ equippedAvatarId?: string | null;
182
+ items?: InventoryCatalogEntry[];
183
+ avatars?: InventoryCatalogItem[];
184
+ badges?: InventoryCatalogItem[];
185
+ backgrounds?: InventoryCatalogItem[];
186
+ videoFrames?: InventoryCatalogItem[];
187
+ [key: string]: unknown;
188
+ }
189
+ export interface StoreCatalogResponse {
190
+ sections?: StoreCatalogSection[];
191
+ backgroundSections?: StoreCatalogSection[];
192
+ badgeSections?: StoreCatalogSection[];
193
+ videoFrameSections?: StoreCatalogSection[];
194
+ premiumShopEnabled?: boolean;
195
+ badgeShopEnabled?: boolean;
196
+ videoFrameShopEnabled?: boolean;
197
+ backgroundShopEnabled?: boolean;
198
+ [key: string]: unknown;
199
+ }
200
+ export interface StoreCatalogSection {
201
+ id: string;
202
+ label?: string;
203
+ items: StoreCatalogItem[];
204
+ [key: string]: unknown;
205
+ }
206
+ export interface StoreCatalogItem {
207
+ id: string;
208
+ name: string;
209
+ collection?: string;
210
+ type?: string;
211
+ price?: number;
212
+ currency?: string;
213
+ unlockLevel?: number | null;
214
+ url?: string | null;
215
+ djUrl?: string | null;
216
+ imageUrl?: string | null;
217
+ description?: string;
218
+ renderMode?: string;
219
+ iconKey?: string | null;
220
+ colorHex?: string | null;
221
+ isVisible?: boolean;
222
+ startAt?: string | null;
223
+ endAt?: string | null;
224
+ [key: string]: unknown;
225
+ }
226
+ export interface InventoryCatalogItem extends StoreCatalogItem {
227
+ purchasedAt?: string | null;
228
+ equippedAt?: string | null;
229
+ }
230
+ export interface InventoryCatalogEntry {
231
+ storeItemId: string;
232
+ category: "avatar" | "background" | "badge" | "videoframe" | string;
233
+ purchasedAt?: string | null;
234
+ equippedAt?: string | null;
235
+ [key: string]: unknown;
236
+ }
237
+ export interface RoomBotToken {
238
+ token: string;
239
+ tokenId: string;
240
+ roomId: string;
241
+ botUserId: string;
242
+ botName: string;
243
+ botAvatarUrl?: string | null;
244
+ commandPrefix: string;
245
+ permissions: string[];
246
+ issuedAt: string;
247
+ expiresAt: string;
248
+ actorRole?: string;
249
+ [key: string]: unknown;
250
+ }
251
+ export type RoomBotPermission = "read_state" | "read_chat" | "send_chat" | "manage_room";
252
+ export interface RoomBotState {
253
+ bot: {
254
+ id: string;
255
+ tokenId: string;
256
+ roomId: string;
257
+ actorUserId: string;
258
+ roomRole?: string;
259
+ name: string;
260
+ avatarUrl?: string | null;
261
+ commandPrefix: string;
262
+ permissions: string[];
263
+ issuedAt?: string;
264
+ expiresAt?: string;
265
+ [key: string]: unknown;
266
+ };
267
+ snapshot: Record<string, unknown>;
268
+ customEmojis: unknown[];
269
+ }
270
+ export interface SystemPublicStats {
271
+ rooms?: number;
272
+ onlineUsers?: number;
273
+ tracksPlayed?: number;
274
+ users?: number;
275
+ [key: string]: unknown;
276
+ }
277
+ export interface SystemDonationGoal {
278
+ enabled: boolean;
279
+ title: string;
280
+ titlePtBr?: string;
281
+ titleEnUs?: string;
282
+ description: string;
283
+ descriptionPtBr?: string;
284
+ descriptionEnUs?: string;
285
+ localizedCurrencyEnabled?: boolean;
286
+ currency: string;
287
+ targetCents: number;
288
+ raisedCents: number;
289
+ [key: string]: unknown;
290
+ }
291
+ export interface SystemStatus {
292
+ maintenanceMode: boolean;
293
+ premiumShopEnabled: boolean;
294
+ badgeShopEnabled: boolean;
295
+ videoFrameShopEnabled: boolean;
296
+ backgroundShopEnabled: boolean;
297
+ spotifyEnabled: boolean;
298
+ soundcloudEnabled: boolean;
299
+ globalDonationGoal: SystemDonationGoal | null;
300
+ updatedAt?: string | null;
301
+ updatedByUserId?: string | null;
302
+ updatedByUsername?: string | null;
303
+ canBypass?: boolean;
304
+ [key: string]: unknown;
305
+ }
306
+ export interface CheckoutSessionResponse {
307
+ checkoutUrl: string;
308
+ [key: string]: unknown;
309
+ }
310
+ export interface UserSettings {
311
+ bio?: string | null;
312
+ colorTheme?: string | null;
313
+ timeFormat?: "12h" | "24h" | string | null;
314
+ notifyChatMentions?: boolean;
315
+ playMentionSound?: boolean;
316
+ presenceStatus?: "online" | "busy" | "away" | string | null;
317
+ selectedBadgeIds?: string[];
318
+ showChatBadge?: boolean;
319
+ [key: string]: unknown;
320
+ }
321
+ export interface TwoFactorStatus {
322
+ email: string;
323
+ emailVerified: boolean;
324
+ phoneNumber?: string | null;
325
+ phoneNumberMasked?: string | null;
326
+ phoneNumberVerified?: boolean;
327
+ twoFactorEnabled: boolean;
328
+ twoFactorMethod: "none" | "email" | "sms" | "authy";
329
+ twoFactorPendingMethod?: "email" | "sms" | "authy" | null;
330
+ smsEnabled?: boolean;
331
+ authyEnabled?: boolean;
332
+ smsAvailable?: boolean;
333
+ [key: string]: unknown;
334
+ }
335
+ export interface WsPacket<TPayload = Record<string, unknown>> {
336
+ type: "command" | "event" | "ack" | "error";
337
+ event: string;
338
+ requestId?: string;
339
+ version: "v1";
340
+ timestamp: string;
341
+ payload: TPayload;
342
+ }
343
+ export interface RoomBotRealtimeOptions {
344
+ baseURL: string;
345
+ botToken: string;
346
+ roomId: string;
347
+ autoJoinRoom?: boolean;
348
+ logging?: boolean;
349
+ protocols?: string | string[];
350
+ locale?: WavezApiLocale;
351
+ messages?: WavezApiMessages;
352
+ websocketFactory?: (url: string, protocols?: string | string[]) => WebSocketLike;
353
+ }
354
+ export interface WebSocketLike {
355
+ readonly readyState: number;
356
+ send(data: string): void;
357
+ close(code?: number, reason?: string): void;
358
+ addEventListener?: (type: string, listener: (event: unknown) => void) => void;
359
+ removeEventListener?: (type: string, listener: (event: unknown) => void) => void;
360
+ on?: (type: string, listener: (event: unknown) => void) => void;
361
+ off?: (type: string, listener: (event: unknown) => void) => void;
362
+ }
363
+ export interface RoomBotRealtimeClient {
364
+ connect(): Promise<void>;
365
+ disconnect(code?: number, reason?: string): void;
366
+ send<TPayload extends Record<string, unknown>>(event: string, payload?: TPayload, requestId?: string): void;
367
+ joinRoom(roomId?: string): void;
368
+ leaveRoom(roomId?: string): void;
369
+ ping(): void;
370
+ on(event: string, handler: (packet: WsPacket<Record<string, unknown>>) => void): () => void;
371
+ off(event: string, handler: (packet: WsPacket<Record<string, unknown>>) => void): void;
372
+ once(event: string, handler: (packet: WsPacket<Record<string, unknown>>) => void): () => void;
373
+ getSocket(): WebSocketLike | null;
374
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "@wavezfm/api",
3
+ "version": "0.1.0",
4
+ "description": "Official JavaScript/TypeScript API client for Wavez.",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.json",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "devDependencies": {
26
+ "typescript": "^5.8.3"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./resources/auth": {
34
+ "types": "./dist/resources/auth.d.ts",
35
+ "import": "./dist/resources/auth.js"
36
+ },
37
+ "./resources/settings": {
38
+ "types": "./dist/resources/settings.d.ts",
39
+ "import": "./dist/resources/settings.js"
40
+ },
41
+ "./resources/user": {
42
+ "types": "./dist/resources/user.d.ts",
43
+ "import": "./dist/resources/user.js"
44
+ },
45
+ "./resources/room": {
46
+ "types": "./dist/resources/room.d.ts",
47
+ "import": "./dist/resources/room.js"
48
+ },
49
+ "./resources/playlist": {
50
+ "types": "./dist/resources/playlist.d.ts",
51
+ "import": "./dist/resources/playlist.js"
52
+ },
53
+ "./resources/source": {
54
+ "types": "./dist/resources/source.d.ts",
55
+ "import": "./dist/resources/source.js"
56
+ },
57
+ "./resources/chat": {
58
+ "types": "./dist/resources/chat.d.ts",
59
+ "import": "./dist/resources/chat.js"
60
+ },
61
+ "./resources/friend": {
62
+ "types": "./dist/resources/friend.d.ts",
63
+ "import": "./dist/resources/friend.js"
64
+ },
65
+ "./resources/shop": {
66
+ "types": "./dist/resources/shop.d.ts",
67
+ "import": "./dist/resources/shop.js"
68
+ },
69
+ "./resources/billing": {
70
+ "types": "./dist/resources/billing.d.ts",
71
+ "import": "./dist/resources/billing.js"
72
+ },
73
+ "./resources/system": {
74
+ "types": "./dist/resources/system.d.ts",
75
+ "import": "./dist/resources/system.js"
76
+ },
77
+ "./resources/room-bot": {
78
+ "types": "./dist/resources/roomBot.d.ts",
79
+ "import": "./dist/resources/roomBot.js"
80
+ },
81
+ "./realtime/room-bot": {
82
+ "types": "./dist/realtime/roomBot.d.ts",
83
+ "import": "./dist/realtime/roomBot.js"
84
+ },
85
+ "./types": {
86
+ "types": "./dist/types.d.ts",
87
+ "import": "./dist/types.js"
88
+ }
89
+ },
90
+ "keywords": [
91
+ "wavez",
92
+ "api",
93
+ "sdk",
94
+ "typescript",
95
+ "bots"
96
+ ]
97
+ }