@wavezfm/api 0.1.6 → 0.1.7
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 +227 -150
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/roomBot.d.ts +2 -2
- package/dist/types.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,10 +17,10 @@ bun add @wavezfm/api
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import { createApiClient } from
|
|
20
|
+
import { createApiClient } from "@wavezfm/api";
|
|
21
21
|
|
|
22
22
|
const client = createApiClient({
|
|
23
|
-
baseURL:
|
|
23
|
+
baseURL: "https://api.wavez.fm",
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const rooms = await client.room.list();
|
|
@@ -31,13 +31,13 @@ console.log(rooms.data);
|
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
createApiClient({
|
|
34
|
-
baseURL:
|
|
35
|
-
timeout: 15_000,
|
|
36
|
-
logging: false,
|
|
37
|
-
headers: {
|
|
38
|
-
credentials:
|
|
39
|
-
locale:
|
|
40
|
-
})
|
|
34
|
+
baseURL: "https://api.wavez.fm",
|
|
35
|
+
timeout: 15_000,
|
|
36
|
+
logging: false,
|
|
37
|
+
headers: { "X-App-Version": "1.0.0" },
|
|
38
|
+
credentials: "include",
|
|
39
|
+
locale: "en",
|
|
40
|
+
});
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
The client accepts:
|
|
@@ -51,228 +51,217 @@ You can localize SDK-generated errors with `locale` or override specific message
|
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
53
|
const client = createApiClient({
|
|
54
|
-
baseURL:
|
|
55
|
-
locale:
|
|
54
|
+
baseURL: "https://api.wavez.fm",
|
|
55
|
+
locale: "en",
|
|
56
56
|
messages: {
|
|
57
|
-
roomBotCreatePrefixLengthInvalid:
|
|
57
|
+
roomBotCreatePrefixLengthInvalid: "Custom prefix length message.",
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
##
|
|
62
|
+
## API Surfaces
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
This SDK exposes three distinct surfaces. They do not authenticate the same way.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
const client = createApiClient({
|
|
68
|
-
baseURL: 'https://api.wavez.fm',
|
|
69
|
-
});
|
|
66
|
+
### Site / Browser API
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
email: 'user@example.com',
|
|
73
|
-
password: 'secret',
|
|
74
|
-
});
|
|
68
|
+
Use this for the normal site routes:
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
- auth
|
|
71
|
+
- settings
|
|
72
|
+
- users
|
|
73
|
+
- rooms
|
|
74
|
+
- playlists
|
|
75
|
+
- chat
|
|
76
|
+
- billing
|
|
77
|
+
- shop
|
|
81
78
|
|
|
82
|
-
|
|
79
|
+
Auth mode:
|
|
83
80
|
|
|
84
|
-
|
|
81
|
+
- browser session cookies
|
|
82
|
+
- same protections used by the site
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
const client = createApiClient({
|
|
88
|
-
baseURL: 'https://api.wavez.fm',
|
|
89
|
-
});
|
|
84
|
+
This is also where bot tokens are created with `client.room.createBotToken(...)`.
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
botName: 'Night Shift Bot',
|
|
93
|
-
commandPrefix: '!',
|
|
94
|
-
permissions: ['read_state', 'read_chat', 'send_chat', 'manage_room'],
|
|
95
|
-
});
|
|
86
|
+
### Room Bot HTTP API
|
|
96
87
|
|
|
97
|
-
|
|
88
|
+
Use this for backend automation scoped to one room:
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
- room state
|
|
91
|
+
- room event history
|
|
92
|
+
- bot chat send/read
|
|
93
|
+
- queue actions
|
|
94
|
+
- moderation and room management
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
console.log(state.data.bot);
|
|
104
|
-
```
|
|
96
|
+
Auth mode:
|
|
105
97
|
|
|
106
|
-
|
|
98
|
+
- room bot token with `client.api.setRoomBotToken(...)`
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
- it is only available in that creation response
|
|
110
|
-
- store it securely on your backend after creation
|
|
111
|
-
- later, load it back with `client.api.setRoomBotToken(...)`
|
|
100
|
+
### Room Bot Realtime API
|
|
112
101
|
|
|
113
|
-
|
|
102
|
+
Use this for low-latency bot behavior:
|
|
114
103
|
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
- chat listeners
|
|
105
|
+
- queue/playback/vote listeners
|
|
106
|
+
- command reactions
|
|
117
107
|
|
|
118
|
-
|
|
119
|
-
baseURL: 'https://api.wavez.fm',
|
|
120
|
-
botToken: process.env.WAVEZ_ROOM_BOT_TOKEN!,
|
|
121
|
-
roomId: 'room-id',
|
|
122
|
-
locale: 'en',
|
|
123
|
-
autoReconnect: true,
|
|
124
|
-
});
|
|
108
|
+
Auth mode:
|
|
125
109
|
|
|
126
|
-
bot
|
|
127
|
-
|
|
110
|
+
- room bot token over WebSocket
|
|
111
|
+
|
|
112
|
+
## Site / Browser API
|
|
113
|
+
|
|
114
|
+
WavezFM uses session cookies for most user-authenticated routes.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const client = createApiClient({
|
|
118
|
+
baseURL: "https://api.wavez.fm",
|
|
128
119
|
});
|
|
129
120
|
|
|
130
|
-
await
|
|
131
|
-
|
|
132
|
-
|
|
121
|
+
await client.auth.login({
|
|
122
|
+
email: "user@example.com",
|
|
123
|
+
password: "secret",
|
|
133
124
|
});
|
|
125
|
+
|
|
126
|
+
const me = await client.auth.me();
|
|
127
|
+
if (me.data) {
|
|
128
|
+
console.log(me.data.displayUsername ?? me.data.username);
|
|
129
|
+
}
|
|
134
130
|
```
|
|
135
131
|
|
|
136
|
-
|
|
132
|
+
For server-side integrations, prefer the room-bot surfaces below. Regular user routes are browser-first.
|
|
137
133
|
|
|
138
|
-
|
|
134
|
+
### Site Resources
|
|
139
135
|
|
|
140
|
-
All resources are exposed from the pre-configured client:
|
|
136
|
+
All site resources are exposed from the pre-configured client:
|
|
141
137
|
|
|
142
138
|
```ts
|
|
143
|
-
const client = createApiClient({ baseURL:
|
|
139
|
+
const client = createApiClient({ baseURL: "https://api.wavez.fm" });
|
|
144
140
|
```
|
|
145
141
|
|
|
146
|
-
|
|
142
|
+
#### Auth
|
|
147
143
|
|
|
148
144
|
```ts
|
|
149
145
|
await client.auth.login({ email, password });
|
|
150
146
|
await client.auth.register({ email, password, name, username });
|
|
151
|
-
const me = await client.auth.me();
|
|
147
|
+
const me = await client.auth.me();
|
|
152
148
|
await client.auth.getPendingTwoFactor();
|
|
153
149
|
await client.auth.sendPendingTwoFactorCode();
|
|
154
|
-
await client.auth.verifyPendingTwoFactor({ code:
|
|
150
|
+
await client.auth.verifyPendingTwoFactor({ code: "123456" });
|
|
155
151
|
```
|
|
156
152
|
|
|
157
|
-
|
|
153
|
+
#### Settings
|
|
158
154
|
|
|
159
155
|
```ts
|
|
160
156
|
await client.settings.get();
|
|
161
157
|
await client.settings.update({
|
|
162
|
-
bio:
|
|
163
|
-
presenceStatus:
|
|
158
|
+
bio: "Late-night selector",
|
|
159
|
+
presenceStatus: "busy",
|
|
164
160
|
showChatBadge: true,
|
|
165
161
|
});
|
|
166
162
|
await client.settings.getTwoFactor();
|
|
167
|
-
await client.settings.startEmailTwoFactor({ password:
|
|
168
|
-
await client.settings.startAuthenticatorTwoFactor({ password:
|
|
169
|
-
await client.settings.disableTwoFactor({ password:
|
|
163
|
+
await client.settings.startEmailTwoFactor({ password: "secret" });
|
|
164
|
+
await client.settings.startAuthenticatorTwoFactor({ password: "secret" });
|
|
165
|
+
await client.settings.disableTwoFactor({ password: "secret" });
|
|
170
166
|
```
|
|
171
167
|
|
|
172
|
-
|
|
168
|
+
#### Users
|
|
173
169
|
|
|
174
170
|
```ts
|
|
175
|
-
await client.user.getById(
|
|
176
|
-
await client.user.getByUsername(
|
|
177
|
-
await client.user.getBadges(
|
|
171
|
+
await client.user.getById("user-id");
|
|
172
|
+
await client.user.getByUsername("haru");
|
|
173
|
+
await client.user.getBadges("user-id");
|
|
178
174
|
await client.user.listAllBadges();
|
|
179
175
|
```
|
|
180
176
|
|
|
181
|
-
|
|
177
|
+
#### Rooms
|
|
182
178
|
|
|
183
179
|
```ts
|
|
184
180
|
await client.room.list();
|
|
185
181
|
await client.room.featured();
|
|
186
|
-
await client.room.getBySlug(
|
|
187
|
-
await client.room.getWaitlist(
|
|
188
|
-
await client.room.create({ slug:
|
|
189
|
-
await client.room.join(
|
|
190
|
-
await client.room.favorite(
|
|
191
|
-
await client.room.getManagement(
|
|
192
|
-
const createdBot = await client.room.createBotToken('room-id', {
|
|
193
|
-
botName: 'Night Shift Bot',
|
|
194
|
-
commandPrefix: '!',
|
|
195
|
-
permissions: ['read_state', 'read_chat', 'send_chat', 'manage_room'],
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
client.api.setRoomBotToken(createdBot.data.token);
|
|
182
|
+
await client.room.getBySlug("wavezfm-lounge");
|
|
183
|
+
await client.room.getWaitlist("wavezfm-lounge");
|
|
184
|
+
await client.room.create({ slug: "my-room", name: "My Room" });
|
|
185
|
+
await client.room.join("wavezfm-lounge");
|
|
186
|
+
await client.room.favorite("room-id");
|
|
187
|
+
await client.room.getManagement("room-id");
|
|
199
188
|
```
|
|
200
189
|
|
|
201
|
-
|
|
190
|
+
#### Playlists
|
|
202
191
|
|
|
203
192
|
```ts
|
|
204
193
|
await client.playlist.list();
|
|
205
|
-
await client.playlist.create(
|
|
206
|
-
await client.playlist.update(
|
|
207
|
-
await client.playlist.getTracks(
|
|
208
|
-
await client.playlist.previewUrl(
|
|
209
|
-
await client.playlist.addTrack(
|
|
210
|
-
source:
|
|
211
|
-
sourceId:
|
|
194
|
+
await client.playlist.create("My Playlist");
|
|
195
|
+
await client.playlist.update("playlist-id", { name: "Late Night Set" });
|
|
196
|
+
await client.playlist.getTracks("playlist-id");
|
|
197
|
+
await client.playlist.previewUrl("https://youtube.com/watch?v=dQw4w9WgXcQ");
|
|
198
|
+
await client.playlist.addTrack("playlist-id", {
|
|
199
|
+
source: "youtube",
|
|
200
|
+
sourceId: "dQw4w9WgXcQ",
|
|
212
201
|
});
|
|
213
|
-
await client.playlist.reorderTracks(
|
|
202
|
+
await client.playlist.reorderTracks("playlist-id", ["track-a", "track-b"]);
|
|
214
203
|
await client.playlist.startSpotifyImport({
|
|
215
|
-
playlistId:
|
|
216
|
-
url:
|
|
204
|
+
playlistId: "playlist-id",
|
|
205
|
+
url: "https://open.spotify.com/playlist/...",
|
|
217
206
|
});
|
|
218
207
|
```
|
|
219
208
|
|
|
220
|
-
|
|
209
|
+
#### Sources
|
|
221
210
|
|
|
222
211
|
```ts
|
|
223
|
-
await client.source.searchYouTube(
|
|
224
|
-
await client.source.searchSoundCloud(
|
|
225
|
-
await client.source.searchAll(
|
|
212
|
+
await client.source.searchYouTube("lofi hip hop", 10);
|
|
213
|
+
await client.source.searchSoundCloud("nightcore", 10);
|
|
214
|
+
await client.source.searchAll("ambient");
|
|
226
215
|
```
|
|
227
216
|
|
|
228
|
-
|
|
217
|
+
#### Chat
|
|
229
218
|
|
|
230
219
|
```ts
|
|
231
|
-
await client.chat.getMessages(
|
|
232
|
-
await client.chat.getMessagesBySlug(
|
|
233
|
-
await client.chat.updateMessage(
|
|
234
|
-
content:
|
|
220
|
+
await client.chat.getMessages("room-id", 0, 50);
|
|
221
|
+
await client.chat.getMessagesBySlug("wavezfm-lounge", 0, 50);
|
|
222
|
+
await client.chat.updateMessage("room-id", "message-id", {
|
|
223
|
+
content: "edited message",
|
|
235
224
|
});
|
|
236
|
-
await client.chat.pinMessage(
|
|
237
|
-
await client.chat.clearChat(
|
|
225
|
+
await client.chat.pinMessage("room-id", "message-id");
|
|
226
|
+
await client.chat.clearChat("room-id");
|
|
238
227
|
```
|
|
239
228
|
|
|
240
|
-
|
|
229
|
+
#### Friends / Fans
|
|
241
230
|
|
|
242
231
|
```ts
|
|
243
232
|
await client.friend.list();
|
|
244
233
|
await client.friend.pending();
|
|
245
|
-
await client.friend.sendRequest(
|
|
246
|
-
await client.friend.acceptRequest(
|
|
247
|
-
await client.friend.follow(
|
|
234
|
+
await client.friend.sendRequest("user-id");
|
|
235
|
+
await client.friend.acceptRequest("request-id");
|
|
236
|
+
await client.friend.follow("user-id");
|
|
248
237
|
await client.friend.followers();
|
|
249
238
|
```
|
|
250
239
|
|
|
251
|
-
|
|
240
|
+
#### Shop
|
|
252
241
|
|
|
253
242
|
```ts
|
|
254
243
|
await client.shop.getCatalog();
|
|
255
244
|
await client.shop.getWallet();
|
|
256
|
-
await client.shop.purchase({ itemId:
|
|
257
|
-
await client.shop.equip(
|
|
245
|
+
await client.shop.purchase({ itemId: "badge-id" });
|
|
246
|
+
await client.shop.equip("avatar-id");
|
|
258
247
|
await client.shop.getInventory();
|
|
259
248
|
```
|
|
260
249
|
|
|
261
|
-
|
|
250
|
+
#### Billing
|
|
262
251
|
|
|
263
252
|
```ts
|
|
264
|
-
await client.billing.createSubscriptionCheckout({ cycle:
|
|
253
|
+
await client.billing.createSubscriptionCheckout({ cycle: "monthly" });
|
|
265
254
|
await client.billing.createDiamondCheckout({ quantity: 1000 });
|
|
266
|
-
await client.billing.createRoomDonationCheckout(
|
|
255
|
+
await client.billing.createRoomDonationCheckout("room-id", { amountCents: 500 });
|
|
267
256
|
await client.billing.createGlobalDonationCheckout({ amountCents: 1000 });
|
|
268
257
|
await client.billing.createDiamondGiftCheckout({
|
|
269
|
-
recipientUsername:
|
|
258
|
+
recipientUsername: "haru",
|
|
270
259
|
quantity: 500,
|
|
271
260
|
});
|
|
272
261
|
await client.billing.listPendingGifts();
|
|
273
262
|
```
|
|
274
263
|
|
|
275
|
-
|
|
264
|
+
#### System
|
|
276
265
|
|
|
277
266
|
```ts
|
|
278
267
|
await client.system.status();
|
|
@@ -280,37 +269,122 @@ await client.system.publicStats();
|
|
|
280
269
|
await client.system.health();
|
|
281
270
|
```
|
|
282
271
|
|
|
283
|
-
|
|
272
|
+
## Room Bot HTTP API
|
|
273
|
+
|
|
274
|
+
Room bot tokens are created from the site/session surface, then used on the bot surface.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
const client = createApiClient({
|
|
278
|
+
baseURL: "https://api.wavez.fm",
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const created = await client.room.createBotToken("room-id", {
|
|
282
|
+
botName: "Night Shift Bot",
|
|
283
|
+
commandPrefix: "!",
|
|
284
|
+
permissions: ["read_state", "read_chat", "send_chat", "manage_room"],
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const roomBotToken = created.data.token;
|
|
288
|
+
|
|
289
|
+
// Store this in your backend or environment store.
|
|
290
|
+
client.api.setRoomBotToken(roomBotToken);
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Important:
|
|
294
|
+
|
|
295
|
+
- the plain bot token is returned by `client.room.createBotToken(...)`
|
|
296
|
+
- it is only available in that creation response
|
|
297
|
+
- store it securely on your backend after creation
|
|
298
|
+
- later, load it back with `client.api.setRoomBotToken(...)`
|
|
299
|
+
|
|
300
|
+
### Bot Resources
|
|
284
301
|
|
|
285
302
|
```ts
|
|
286
303
|
client.api.setRoomBotToken(process.env.WAVEZ_ROOM_BOT_TOKEN!);
|
|
287
304
|
|
|
288
|
-
await client.roomBot.getState(
|
|
289
|
-
await client.roomBot.
|
|
305
|
+
await client.roomBot.getState("room-id");
|
|
306
|
+
await client.roomBot.getQueueStatus("room-id");
|
|
307
|
+
await client.roomBot.getMessages("room-id");
|
|
308
|
+
await client.roomBot.getEvents("room-id", {
|
|
290
309
|
limit: 25,
|
|
291
|
-
types: [
|
|
310
|
+
types: ["user_joined", "waitlist_join", "left"],
|
|
311
|
+
});
|
|
312
|
+
await client.roomBot.addToQueue("room-id", "user-id");
|
|
313
|
+
await client.roomBot.sendMessage("room-id", {
|
|
314
|
+
content: "!lockqueue",
|
|
292
315
|
});
|
|
293
|
-
await client.roomBot.
|
|
294
|
-
await client.roomBot.addToQueue('room-id', 'user-id');
|
|
295
|
-
await client.roomBot.sendMessage('room-id', { content: '!lockqueue' });
|
|
296
|
-
await client.roomBot.updateSettings('room-id', {
|
|
316
|
+
await client.roomBot.updateSettings("room-id", {
|
|
297
317
|
queueLocked: true,
|
|
298
318
|
commandAnnouncement: {
|
|
299
|
-
commandId:
|
|
300
|
-
actorUsername:
|
|
319
|
+
commandId: "lockqueue",
|
|
320
|
+
actorUsername: "Night Shift Bot",
|
|
301
321
|
},
|
|
302
322
|
});
|
|
303
323
|
```
|
|
304
324
|
|
|
325
|
+
`roomBot.getEvents()` is the normalized HTTP history surface.
|
|
326
|
+
|
|
327
|
+
Returned `event` values:
|
|
328
|
+
|
|
329
|
+
- `user_joined`
|
|
330
|
+
- `waitlist_join`
|
|
331
|
+
- `left`
|
|
332
|
+
|
|
333
|
+
Accepted filter aliases in `types` for backward compatibility:
|
|
334
|
+
|
|
335
|
+
- `queue_joined` -> `waitlist_join`
|
|
336
|
+
- `user_left` -> `left`
|
|
337
|
+
|
|
338
|
+
## Room Bot Realtime API
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
import {
|
|
342
|
+
createRoomBotRealtimeClient,
|
|
343
|
+
formatMentionText,
|
|
344
|
+
} from "@wavezfm/api";
|
|
345
|
+
|
|
346
|
+
const bot = createRoomBotRealtimeClient({
|
|
347
|
+
baseURL: "https://api.wavez.fm",
|
|
348
|
+
botToken: process.env.WAVEZ_ROOM_BOT_TOKEN!,
|
|
349
|
+
roomId: "room-id",
|
|
350
|
+
locale: "en",
|
|
351
|
+
autoReconnect: true,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
bot.on("message_created", (packet) => {
|
|
355
|
+
console.log(packet.payload);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
bot.on("queue_joined", (packet) => {
|
|
359
|
+
console.log(packet.payload);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
await bot.connect();
|
|
363
|
+
bot.sendChat({
|
|
364
|
+
content: `${formatMentionText("Agente MIB")} estou em modo AFK agora.`,
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
The realtime helper automatically retries abnormal disconnects such as WebSocket close code `1006` by default. Fatal closes like revoked or invalid auth are not retried.
|
|
369
|
+
|
|
370
|
+
Important:
|
|
371
|
+
|
|
372
|
+
- realtime packet names are the raw WebSocket event names
|
|
373
|
+
- examples: `message_created`, `user_left`, `queue_joined`, `track_started`
|
|
374
|
+
- they are not normalized to the HTTP history names
|
|
375
|
+
|
|
305
376
|
## Error Handling
|
|
306
377
|
|
|
307
378
|
All methods throw `ApiError` on failure.
|
|
308
379
|
|
|
309
380
|
```ts
|
|
310
|
-
import { ApiError } from
|
|
381
|
+
import { ApiError } from "@wavezfm/api";
|
|
311
382
|
|
|
312
383
|
try {
|
|
313
|
-
await client.auth.login({
|
|
384
|
+
await client.auth.login({
|
|
385
|
+
email: "bad@example.com",
|
|
386
|
+
password: "bad",
|
|
387
|
+
});
|
|
314
388
|
} catch (error) {
|
|
315
389
|
if (error instanceof ApiError) {
|
|
316
390
|
console.log(error.message);
|
|
@@ -324,9 +398,9 @@ try {
|
|
|
324
398
|
## Token Management
|
|
325
399
|
|
|
326
400
|
```ts
|
|
327
|
-
const client = createApiClient({ baseURL:
|
|
401
|
+
const client = createApiClient({ baseURL: "https://api.wavez.fm" });
|
|
328
402
|
|
|
329
|
-
client.api.setAuthToken(
|
|
403
|
+
client.api.setAuthToken("optional-bearer-token");
|
|
330
404
|
client.api.setRoomBotToken(process.env.WAVEZ_ROOM_BOT_TOKEN!);
|
|
331
405
|
|
|
332
406
|
client.api.getAuthToken();
|
|
@@ -338,11 +412,11 @@ client.api.getRoomBotToken();
|
|
|
338
412
|
For maximum tree-shaking, import only what you need:
|
|
339
413
|
|
|
340
414
|
```ts
|
|
341
|
-
import { createApi } from
|
|
342
|
-
import { createRoomResource } from
|
|
343
|
-
import { createRoomBotResource } from
|
|
415
|
+
import { createApi } from "@wavezfm/api";
|
|
416
|
+
import { createRoomResource } from "@wavezfm/api/resources/room";
|
|
417
|
+
import { createRoomBotResource } from "@wavezfm/api/resources/room-bot";
|
|
344
418
|
|
|
345
|
-
const api = createApi({ baseURL:
|
|
419
|
+
const api = createApi({ baseURL: "https://api.wavez.fm" });
|
|
346
420
|
const room = createRoomResource(api);
|
|
347
421
|
const roomBot = createRoomBotResource(api);
|
|
348
422
|
```
|
|
@@ -357,13 +431,16 @@ import type {
|
|
|
357
431
|
MediaSearchResult,
|
|
358
432
|
ChatMessage,
|
|
359
433
|
RoomBotState,
|
|
434
|
+
RoomPresenceEventType,
|
|
435
|
+
RoomPresenceEventFilterType,
|
|
360
436
|
WsPacket,
|
|
361
|
-
} from
|
|
437
|
+
} from "@wavezfm/api";
|
|
362
438
|
```
|
|
363
439
|
|
|
364
440
|
## Notes
|
|
365
441
|
|
|
366
|
-
-
|
|
367
|
-
- room-bot routes are
|
|
442
|
+
- site/session routes are browser-first because the backend uses cookies and same-origin protections
|
|
443
|
+
- room-bot HTTP routes are backend-first and scoped to one room
|
|
444
|
+
- room-bot realtime uses raw WebSocket packet names
|
|
368
445
|
- the package is tree-shakable through factory exports in `resources/*`
|
|
369
446
|
- the realtime helper expects native `WebSocket` or a custom `websocketFactory`
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { createRoomBotResource } from "./resources/roomBot.js";
|
|
|
15
15
|
export { parseRoomQueueSnapshot } from "./utils/roomQueue.js";
|
|
16
16
|
export { formatMentionText } from "./utils/chat.js";
|
|
17
17
|
export { createRoomBotRealtimeClient } from "./realtime/roomBot.js";
|
|
18
|
-
export type { ApiClientConfig, ApiLike, ApiQuery, ApiQueryValue, ApiRequestOptions, ApiSuccessResponse, AuthMode, AuthUser, BadgeAssignment, ChatMessage, CheckoutSessionResponse, InventoryResponse, InventoryCatalogEntry, InventoryCatalogItem, MediaSearchResult, PlaylistSummary, PlaylistTrack, RoomBotPermission, RoomQueueEntry, RoomQueuePlayback, RoomQueueSnapshot, RoomQueueStatusResponse, RoomQueueUser, RoomQueueViewerStatus, RoomBotMessageReplyInput, RoomBotEventsResponse, RoomBotQueueAddResponse, RoomBotRealtimeClient, RoomBotRealtimeOptions, RoomBotSendMessageInput, RoomBotState, RoomBotToken, RoomPresenceEvent, RoomPresenceEventType, RoomSummary, WavezApiLocale, WavezApiMessageKey, WavezApiMessages, WavezApiMessageValues, StoreCatalogResponse, StoreCatalogItem, StoreCatalogSection, SystemDonationGoal, SystemPublicStats, SystemStatus, TwoFactorStatus, UserSettings, UserProfile, WalletBalance, WebSocketLike, WsPacket, } from "./types.js";
|
|
18
|
+
export type { ApiClientConfig, ApiLike, ApiQuery, ApiQueryValue, ApiRequestOptions, ApiSuccessResponse, AuthMode, AuthUser, BadgeAssignment, ChatMessage, CheckoutSessionResponse, InventoryResponse, InventoryCatalogEntry, InventoryCatalogItem, MediaSearchResult, PlaylistSummary, PlaylistTrack, RoomBotPermission, RoomQueueEntry, RoomQueuePlayback, RoomQueueSnapshot, RoomQueueStatusResponse, RoomQueueUser, RoomQueueViewerStatus, RoomBotMessageReplyInput, RoomBotEventsResponse, RoomPresenceEventFilterType, RoomBotQueueAddResponse, RoomBotRealtimeClient, RoomBotRealtimeOptions, RoomBotSendMessageInput, RoomBotState, RoomBotToken, RoomPresenceEvent, RoomPresenceEventType, RoomSummary, WavezApiLocale, WavezApiMessageKey, WavezApiMessages, WavezApiMessageValues, StoreCatalogResponse, StoreCatalogItem, StoreCatalogSection, SystemDonationGoal, SystemPublicStats, SystemStatus, TwoFactorStatus, UserSettings, UserProfile, WalletBalance, WebSocketLike, WsPacket, } from "./types.js";
|
|
19
19
|
import type { ApiClientConfig } from "./types.js";
|
|
20
20
|
export declare function createApiClient(config: ApiClientConfig): {
|
|
21
21
|
api: import("./core/api.js").WavezApi;
|
|
@@ -352,7 +352,7 @@ export declare function createApiClient(config: ApiClientConfig): {
|
|
|
352
352
|
getEvents(roomId: string, options?: {
|
|
353
353
|
limit?: number;
|
|
354
354
|
since?: string | null;
|
|
355
|
-
types?: import("./types.js").
|
|
355
|
+
types?: import("./types.js").RoomPresenceEventFilterType[];
|
|
356
356
|
}): Promise<import("./types.js").ApiSuccessResponse<import("./types.js").RoomBotEventsResponse>>;
|
|
357
357
|
sendMessage(roomId: string, input: import("./types.js").RoomBotSendMessageInput): Promise<import("./types.js").ApiSuccessResponse<Record<string, unknown>>>;
|
|
358
358
|
addToQueue(roomId: string, userId: string): Promise<import("./types.js").ApiSuccessResponse<import("./types.js").RoomBotQueueAddResponse>>;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,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AC,GAAG,CAAC;QAC7B,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC;QACnC,MAAM,EAAE,oBAAoB,CAAC,GAAG,CAAC;QACjC,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC;KACtC,CAAC;AACN,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiLike, ApiSuccessResponse, RoomBotEventsResponse, RoomBotQueueAddResponse, RoomQueueSnapshot, RoomBotSendMessageInput,
|
|
1
|
+
import type { ApiLike, ApiSuccessResponse, RoomBotEventsResponse, RoomBotQueueAddResponse, RoomQueueSnapshot, RoomBotSendMessageInput, RoomPresenceEventFilterType, RoomBotState } from "../types.js";
|
|
2
2
|
export declare function createRoomBotResource(api: ApiLike): {
|
|
3
3
|
getState(roomId: string): Promise<ApiSuccessResponse<RoomBotState>>;
|
|
4
4
|
getQueueStatus(roomId: string, options?: {
|
|
@@ -13,7 +13,7 @@ export declare function createRoomBotResource(api: ApiLike): {
|
|
|
13
13
|
getEvents(roomId: string, options?: {
|
|
14
14
|
limit?: number;
|
|
15
15
|
since?: string | null;
|
|
16
|
-
types?:
|
|
16
|
+
types?: RoomPresenceEventFilterType[];
|
|
17
17
|
}): Promise<ApiSuccessResponse<RoomBotEventsResponse>>;
|
|
18
18
|
sendMessage(roomId: string, input: RoomBotSendMessageInput): Promise<ApiSuccessResponse<Record<string, unknown>>>;
|
|
19
19
|
addToQueue(roomId: string, userId: string): Promise<ApiSuccessResponse<RoomBotQueueAddResponse>>;
|
package/dist/types.d.ts
CHANGED
|
@@ -339,7 +339,8 @@ export interface RoomBotState {
|
|
|
339
339
|
snapshot: Record<string, unknown>;
|
|
340
340
|
customEmojis: unknown[];
|
|
341
341
|
}
|
|
342
|
-
export type RoomPresenceEventType = "user_joined" | "
|
|
342
|
+
export type RoomPresenceEventType = "user_joined" | "left" | "waitlist_join";
|
|
343
|
+
export type RoomPresenceEventFilterType = RoomPresenceEventType | "user_left" | "queue_joined";
|
|
343
344
|
export interface RoomPresenceEvent {
|
|
344
345
|
id: string;
|
|
345
346
|
roomId: string;
|