@unboundcx/sdk 2.8.1 → 2.8.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/services/video.js +180 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/services/video.js CHANGED
@@ -14,21 +14,25 @@ export class VideoService {
14
14
  return result;
15
15
  }
16
16
 
17
- async joinRoom(room, password, email) {
17
+ async joinRoom(room, password, email, name, tokenType = 'cookie') {
18
18
  this.sdk.validateParams(
19
- { room, password, email },
19
+ { room, password, email, name, tokenType },
20
20
  {
21
21
  room: { type: 'string', required: true },
22
22
  password: { type: 'string', required: false },
23
23
  email: { type: 'string', required: false },
24
+ name: { type: 'string', required: false },
25
+ tokenType: { type: 'string', required: true },
24
26
  },
25
27
  );
26
28
 
27
29
  const params = {
28
30
  body: {
31
+ room,
29
32
  password,
30
33
  email,
31
- tokenType: 'cookie',
34
+ name,
35
+ tokenType,
32
36
  },
33
37
  };
34
38
  const result = await this.sdk._fetch(
@@ -148,6 +152,7 @@ export class VideoService {
148
152
  startCameraMutedAfter,
149
153
  startMicrophoneMuted,
150
154
  startMicrophoneMutedAfter,
155
+ enableChat,
151
156
  engagementSessionId,
152
157
  }) {
153
158
  this.sdk.validateParams(
@@ -166,6 +171,7 @@ export class VideoService {
166
171
  startCameraMutedAfter,
167
172
  startMicrophoneMuted,
168
173
  startMicrophoneMutedAfter,
174
+ enableChat,
169
175
  engagementSessionId,
170
176
  },
171
177
  {
@@ -183,6 +189,7 @@ export class VideoService {
183
189
  startCameraMutedAfter: { type: 'number', required: false },
184
190
  startMicrophoneMuted: { type: 'boolean', required: false },
185
191
  startMicrophoneMutedAfter: { type: 'number', required: false },
192
+ enableChat: { type: 'boolean', required: false },
186
193
  engagementSessionId: { type: 'string', required: false },
187
194
  },
188
195
  );
@@ -202,6 +209,7 @@ export class VideoService {
202
209
  startCameraMutedAfter,
203
210
  startMicrophoneMuted,
204
211
  startMicrophoneMutedAfter,
212
+ enableChat,
205
213
  engagementSessionId,
206
214
  },
207
215
  };
@@ -238,6 +246,8 @@ export class VideoService {
238
246
  validationSchema.startMicrophoneMuted = { type: 'boolean' };
239
247
  if ('startMicrophoneMutedAfter' in update)
240
248
  validationSchema.startMicrophoneMutedAfter = { type: 'number' };
249
+ if ('enableChat' in update)
250
+ validationSchema.enableChat = { type: 'boolean' };
241
251
 
242
252
  if (Object.keys(validationSchema).length > 0) {
243
253
  this.sdk.validateParams(update, validationSchema);
@@ -252,6 +262,28 @@ export class VideoService {
252
262
  return result;
253
263
  }
254
264
 
265
+ async updateRoomBot(roomId, { isRecording, isTranscribing }) {
266
+ this.sdk.validateParams(
267
+ { roomId, isRecording, isTranscribing },
268
+ {
269
+ roomId: { type: 'string', required: true },
270
+ isRecording: { type: 'boolean', required: false },
271
+ isTranscribing: { type: 'boolean', required: false },
272
+ },
273
+ );
274
+ const update = {
275
+ isRecording,
276
+ isTranscribing,
277
+ };
278
+ const params = {
279
+ body: {
280
+ ...update,
281
+ },
282
+ };
283
+ const result = await this.sdk._fetch(`/video/${roomId}/bot`, 'PUT', params);
284
+ return result;
285
+ }
286
+
255
287
  async placeCall(roomId, phoneNumber, callerIdNumber) {
256
288
  this.sdk.validateParams(
257
289
  { roomId, phoneNumber, callerIdNumber },
@@ -469,4 +501,149 @@ export class VideoService {
469
501
  const result = await this.sdk._fetch('/video/survey', 'POST', params);
470
502
  return result;
471
503
  }
504
+
505
+ /**
506
+ * Post a chat message to a video room
507
+ * @param {string} roomId - The video room ID
508
+ * @param {Array} content - Message content as JSON array (TipTap format)
509
+ * @param {string} [storageId] - Optional storage ID for attachments
510
+ * @returns {Promise} Created feed message
511
+ */
512
+ async postChatMessage(roomId, content, storageId = null) {
513
+ this.sdk.validateParams(
514
+ { roomId, content },
515
+ {
516
+ roomId: { type: 'string', required: true },
517
+ content: { type: 'array', required: true },
518
+ },
519
+ );
520
+
521
+ const body = {
522
+ content,
523
+ };
524
+
525
+ if (storageId) {
526
+ body.storageId = storageId;
527
+ }
528
+
529
+ const params = { body };
530
+
531
+ const result = await this.sdk._fetch(
532
+ `/video/${roomId}/chat`,
533
+ 'POST',
534
+ params,
535
+ );
536
+ return result;
537
+ }
538
+
539
+ /**
540
+ * Get chat messages from a video room
541
+ * @param {string} roomId - The video room ID
542
+ * @param {Object} [options={}] - Query options
543
+ * @param {string} [options.select] - Fields to select
544
+ * @param {number} [options.limit] - Limit number of results
545
+ * @param {string} [options.nextId] - Cursor for next page
546
+ * @param {string} [options.previousId] - Cursor for previous page
547
+ * @param {string} [options.orderByDirection] - 'ASC' or 'DESC'
548
+ * @param {boolean} [options.expandDetails] - Whether to expand details
549
+ * @returns {Promise} Chat messages with participant info
550
+ */
551
+ async getChatMessages(roomId, options = {}) {
552
+ this.sdk.validateParams(
553
+ { roomId },
554
+ {
555
+ roomId: { type: 'string', required: true },
556
+ },
557
+ );
558
+
559
+ // Validate optional parameters
560
+ const validationSchema = {};
561
+ if ('select' in options) validationSchema.select = { type: 'string' };
562
+ if ('limit' in options) validationSchema.limit = { type: 'number' };
563
+ if ('nextId' in options) validationSchema.nextId = { type: 'string' };
564
+ if ('previousId' in options)
565
+ validationSchema.previousId = { type: 'string' };
566
+ if ('orderByDirection' in options)
567
+ validationSchema.orderByDirection = { type: 'string' };
568
+ if ('expandDetails' in options)
569
+ validationSchema.expandDetails = { type: 'boolean' };
570
+
571
+ if (Object.keys(validationSchema).length > 0) {
572
+ this.sdk.validateParams(options, validationSchema);
573
+ }
574
+
575
+ const params = {
576
+ query: options,
577
+ };
578
+
579
+ const result = await this.sdk._fetch(
580
+ `/video/${roomId}/chat`,
581
+ 'GET',
582
+ params,
583
+ );
584
+ return result;
585
+ }
586
+
587
+ /**
588
+ * Edit a chat message in a video room
589
+ * Only the participant who created the message can edit it
590
+ * @param {string} roomId - The video room ID
591
+ * @param {string} messageId - The message ID to edit
592
+ * @param {Array} content - Updated message content as JSON array (TipTap format)
593
+ * @param {string} [storageId] - Optional storage ID for attachments
594
+ * @returns {Promise} Updated feed message
595
+ */
596
+ async editChatMessage(roomId, messageId, content, storageId = null) {
597
+ this.sdk.validateParams(
598
+ { roomId, messageId, content },
599
+ {
600
+ roomId: { type: 'string', required: true },
601
+ messageId: { type: 'string', required: true },
602
+ content: { type: 'array', required: true },
603
+ },
604
+ );
605
+
606
+ const body = {
607
+ content,
608
+ };
609
+
610
+ if (storageId) {
611
+ body.storageId = storageId;
612
+ }
613
+
614
+ const params = { body };
615
+
616
+ const result = await this.sdk._fetch(
617
+ `/video/${roomId}/chat/${messageId}`,
618
+ 'PUT',
619
+ params,
620
+ );
621
+ return result;
622
+ }
623
+
624
+ /**
625
+ * Delete a chat message from a video room
626
+ * Hosts can delete any message, participants can only delete their own
627
+ * @param {string} roomId - The video room ID
628
+ * @param {string} messageId - The message ID to delete
629
+ * @returns {Promise} Deletion result
630
+ */
631
+ async deleteChatMessage(roomId, messageId) {
632
+ this.sdk.validateParams(
633
+ { roomId, messageId },
634
+ {
635
+ roomId: { type: 'string', required: true },
636
+ messageId: { type: 'string', required: true },
637
+ },
638
+ );
639
+
640
+ const params = {};
641
+
642
+ const result = await this.sdk._fetch(
643
+ `/video/${roomId}/chat/${messageId}`,
644
+ 'DELETE',
645
+ params,
646
+ );
647
+ return result;
648
+ }
472
649
  }