@unboundcx/sdk 2.8.2 → 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.
- package/package.json +1 -1
- package/services/video.js +174 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "2.8.
|
|
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
|
@@ -28,6 +28,7 @@ export class VideoService {
|
|
|
28
28
|
|
|
29
29
|
const params = {
|
|
30
30
|
body: {
|
|
31
|
+
room,
|
|
31
32
|
password,
|
|
32
33
|
email,
|
|
33
34
|
name,
|
|
@@ -151,6 +152,7 @@ export class VideoService {
|
|
|
151
152
|
startCameraMutedAfter,
|
|
152
153
|
startMicrophoneMuted,
|
|
153
154
|
startMicrophoneMutedAfter,
|
|
155
|
+
enableChat,
|
|
154
156
|
engagementSessionId,
|
|
155
157
|
}) {
|
|
156
158
|
this.sdk.validateParams(
|
|
@@ -169,6 +171,7 @@ export class VideoService {
|
|
|
169
171
|
startCameraMutedAfter,
|
|
170
172
|
startMicrophoneMuted,
|
|
171
173
|
startMicrophoneMutedAfter,
|
|
174
|
+
enableChat,
|
|
172
175
|
engagementSessionId,
|
|
173
176
|
},
|
|
174
177
|
{
|
|
@@ -186,6 +189,7 @@ export class VideoService {
|
|
|
186
189
|
startCameraMutedAfter: { type: 'number', required: false },
|
|
187
190
|
startMicrophoneMuted: { type: 'boolean', required: false },
|
|
188
191
|
startMicrophoneMutedAfter: { type: 'number', required: false },
|
|
192
|
+
enableChat: { type: 'boolean', required: false },
|
|
189
193
|
engagementSessionId: { type: 'string', required: false },
|
|
190
194
|
},
|
|
191
195
|
);
|
|
@@ -205,6 +209,7 @@ export class VideoService {
|
|
|
205
209
|
startCameraMutedAfter,
|
|
206
210
|
startMicrophoneMuted,
|
|
207
211
|
startMicrophoneMutedAfter,
|
|
212
|
+
enableChat,
|
|
208
213
|
engagementSessionId,
|
|
209
214
|
},
|
|
210
215
|
};
|
|
@@ -241,6 +246,8 @@ export class VideoService {
|
|
|
241
246
|
validationSchema.startMicrophoneMuted = { type: 'boolean' };
|
|
242
247
|
if ('startMicrophoneMutedAfter' in update)
|
|
243
248
|
validationSchema.startMicrophoneMutedAfter = { type: 'number' };
|
|
249
|
+
if ('enableChat' in update)
|
|
250
|
+
validationSchema.enableChat = { type: 'boolean' };
|
|
244
251
|
|
|
245
252
|
if (Object.keys(validationSchema).length > 0) {
|
|
246
253
|
this.sdk.validateParams(update, validationSchema);
|
|
@@ -255,6 +262,28 @@ export class VideoService {
|
|
|
255
262
|
return result;
|
|
256
263
|
}
|
|
257
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
|
+
|
|
258
287
|
async placeCall(roomId, phoneNumber, callerIdNumber) {
|
|
259
288
|
this.sdk.validateParams(
|
|
260
289
|
{ roomId, phoneNumber, callerIdNumber },
|
|
@@ -472,4 +501,149 @@ export class VideoService {
|
|
|
472
501
|
const result = await this.sdk._fetch('/video/survey', 'POST', params);
|
|
473
502
|
return result;
|
|
474
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
|
+
}
|
|
475
649
|
}
|