@unboundcx/sdk 2.8.6 → 2.8.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.
@@ -0,0 +1,394 @@
1
+ export class WorkerService {
2
+ constructor(sdk) {
3
+ this.sdk = sdk;
4
+ }
5
+
6
+ /**
7
+ * Create a worker in the task router system
8
+ * Creates a new worker for handling tasks such as phone calls, chat, or email.
9
+ * If userId is not provided, it will use the authenticated user's ID from the session.
10
+ *
11
+ * @param {Object} [options] - Optional parameters
12
+ * @param {string} [options.userId] - The user ID to create a worker for. If not provided, uses the authenticated user's ID
13
+ * @returns {Promise<Object>} Object containing the created worker ID
14
+ * @returns {string} result.workerId - The unique identifier for the created worker
15
+ *
16
+ * @example
17
+ * // Create worker for authenticated user
18
+ * const result = await sdk.taskRouter.worker.create();
19
+ * console.log(result.workerId); // "0860002026012400000006665842155429980"
20
+ *
21
+ * @example
22
+ * // Create worker for specific user
23
+ * const result = await sdk.taskRouter.worker.create({ userId: '123456' });
24
+ * console.log(result.workerId); // "0860002026012400000006665842155429980"
25
+ */
26
+ async create(options = {}) {
27
+ const { userId } = options;
28
+
29
+ this.sdk.validateParams(
30
+ { userId },
31
+ {
32
+ userId: { type: 'string', required: false },
33
+ },
34
+ );
35
+
36
+ const params = {
37
+ body: {},
38
+ };
39
+
40
+ if (userId) {
41
+ params.body.userId = userId;
42
+ }
43
+
44
+ const result = await this.sdk._fetch('/taskRouter/worker', 'POST', params);
45
+ return result;
46
+ }
47
+
48
+ /**
49
+ * Get worker information from the task router system
50
+ * Retrieves the worker details for a specific user.
51
+ * If userId is not provided, it will use the authenticated user's ID from the session.
52
+ *
53
+ * @param {Object} [options] - Optional parameters
54
+ * @param {string} [options.userId] - The user ID to get worker information for. If not provided, uses the authenticated user's ID
55
+ * @returns {Promise<Object>} Object containing the worker information
56
+ *
57
+ * @example
58
+ * // Get worker for authenticated user
59
+ * const worker = await sdk.taskRouter.worker.get();
60
+ * console.log(worker);
61
+ *
62
+ * @example
63
+ * // Get worker for specific user
64
+ * const worker = await sdk.taskRouter.worker.get({ userId: '123456' });
65
+ * console.log(worker);
66
+ */
67
+ async get(options = {}) {
68
+ const { userId } = options;
69
+
70
+ this.sdk.validateParams(
71
+ { userId },
72
+ {
73
+ userId: { type: 'string', required: false },
74
+ },
75
+ );
76
+
77
+ const params = {};
78
+
79
+ if (userId) {
80
+ params.query = { userId };
81
+ }
82
+
83
+ const result = await this.sdk._fetch('/taskRouter/worker', 'GET', params);
84
+ return result;
85
+ }
86
+
87
+ /**
88
+ * Set worker status to available in the task router system
89
+ * Makes a worker available to receive tasks such as phone calls, chat, or email.
90
+ * You can specify either workerId or userId. If neither is provided, it will use the authenticated user's ID.
91
+ *
92
+ * @param {Object} [options] - Optional parameters
93
+ * @param {string} [options.workerId] - The worker ID to set as available
94
+ * @param {string} [options.userId] - The user ID to set as available. If not provided, uses the authenticated user's ID
95
+ * @returns {Promise<Object>} Object containing the worker ID
96
+ * @returns {string} result.workerId - The unique identifier for the worker
97
+ *
98
+ * @example
99
+ * // Set authenticated user's worker to available
100
+ * const result = await sdk.taskRouter.worker.setAvailable();
101
+ * console.log(result.workerId);
102
+ *
103
+ * @example
104
+ * // Set specific worker to available by workerId
105
+ * const result = await sdk.taskRouter.worker.setAvailable({ workerId: '0860002026012400000006665842155429980' });
106
+ *
107
+ * @example
108
+ * // Set specific user's worker to available by userId
109
+ * const result = await sdk.taskRouter.worker.setAvailable({ userId: '123456' });
110
+ */
111
+ async setAvailable(options = {}) {
112
+ const { workerId, userId } = options;
113
+
114
+ this.sdk.validateParams(
115
+ { workerId, userId },
116
+ {
117
+ workerId: { type: 'string', required: false },
118
+ userId: { type: 'string', required: false },
119
+ },
120
+ );
121
+
122
+ const params = {
123
+ body: {},
124
+ };
125
+
126
+ if (workerId) {
127
+ params.body.workerId = workerId;
128
+ }
129
+
130
+ if (userId) {
131
+ params.body.userId = userId;
132
+ }
133
+
134
+ const result = await this.sdk._fetch(
135
+ '/taskRouter/worker/avaliable',
136
+ 'PUT',
137
+ params,
138
+ );
139
+ return result;
140
+ }
141
+
142
+ /**
143
+ * Set worker status to offline in the task router system
144
+ * Makes a worker offline and unavailable to receive tasks.
145
+ * You can specify either workerId or userId. If neither is provided, it will use the authenticated user's ID.
146
+ *
147
+ * @param {Object} [options] - Optional parameters
148
+ * @param {string} [options.workerId] - The worker ID to set as offline
149
+ * @param {string} [options.userId] - The user ID to set as offline. If not provided, uses the authenticated user's ID
150
+ * @returns {Promise<Object>} Object containing the worker ID
151
+ * @returns {string} result.workerId - The unique identifier for the worker
152
+ *
153
+ * @example
154
+ * // Set authenticated user's worker to offline
155
+ * const result = await sdk.taskRouter.worker.setOffline();
156
+ * console.log(result.workerId);
157
+ *
158
+ * @example
159
+ * // Set specific worker to offline by workerId
160
+ * const result = await sdk.taskRouter.worker.setOffline({ workerId: '0860002026012400000006665842155429980' });
161
+ *
162
+ * @example
163
+ * // Set specific user's worker to offline by userId
164
+ * const result = await sdk.taskRouter.worker.setOffline({ userId: '123456' });
165
+ */
166
+ async setOffline(options = {}) {
167
+ const { workerId, userId } = options;
168
+
169
+ this.sdk.validateParams(
170
+ { workerId, userId },
171
+ {
172
+ workerId: { type: 'string', required: false },
173
+ userId: { type: 'string', required: false },
174
+ },
175
+ );
176
+
177
+ const params = {
178
+ body: {},
179
+ };
180
+
181
+ if (workerId) {
182
+ params.body.workerId = workerId;
183
+ }
184
+
185
+ if (userId) {
186
+ params.body.userId = userId;
187
+ }
188
+
189
+ const result = await this.sdk._fetch(
190
+ '/taskRouter/worker/offline',
191
+ 'PUT',
192
+ params,
193
+ );
194
+ return result;
195
+ }
196
+
197
+ /**
198
+ * Automatically login all auto-login queues for a worker
199
+ * When a worker goes available, this logs them into all queues marked with autoLogin = true.
200
+ * If userId is not provided, it will use the authenticated user's ID from the session.
201
+ *
202
+ * @param {Object} [options] - Optional parameters
203
+ * @param {string} [options.userId] - The user ID to auto-login queues for. If not provided, uses the authenticated user's ID
204
+ * @returns {Promise<Object>} Object containing the userId that was processed
205
+ * @returns {string} result.userId - The user ID that had auto-login queues processed
206
+ *
207
+ * @example
208
+ * // Auto-login queues for authenticated user
209
+ * const result = await sdk.taskRouter.worker.queueAutoLogin();
210
+ * console.log(result.userId);
211
+ *
212
+ * @example
213
+ * // Auto-login queues for specific user
214
+ * const result = await sdk.taskRouter.worker.queueAutoLogin({ userId: '123456' });
215
+ * console.log(result.userId);
216
+ */
217
+ async queueAutoLogin(options = {}) {
218
+ const { userId } = options;
219
+
220
+ this.sdk.validateParams(
221
+ { userId },
222
+ {
223
+ userId: { type: 'string', required: false },
224
+ },
225
+ );
226
+
227
+ const params = {
228
+ body: {},
229
+ };
230
+
231
+ if (userId) {
232
+ params.body.userId = userId;
233
+ }
234
+
235
+ const result = await this.sdk._fetch(
236
+ '/taskRouter/worker/queueAutoLogin',
237
+ 'PUT',
238
+ params,
239
+ );
240
+ return result;
241
+ }
242
+
243
+ /**
244
+ * Logout from all queues for a worker
245
+ * Logs the worker out of all queues they are currently logged into.
246
+ * If userId is not provided, it will use the authenticated user's ID from the session.
247
+ *
248
+ * @param {Object} [options] - Optional parameters
249
+ * @param {string} [options.userId] - The user ID to logout from all queues. If not provided, uses the authenticated user's ID
250
+ * @returns {Promise<Object>} Object containing the userId that was processed
251
+ * @returns {string} result.userId - The user ID that had all queues logged out
252
+ *
253
+ * @example
254
+ * // Logout from all queues for authenticated user
255
+ * const result = await sdk.taskRouter.worker.queueLogoutAll();
256
+ * console.log(result.userId);
257
+ *
258
+ * @example
259
+ * // Logout from all queues for specific user
260
+ * const result = await sdk.taskRouter.worker.queueLogoutAll({ userId: '123456' });
261
+ * console.log(result.userId);
262
+ */
263
+ async queueLogoutAll(options = {}) {
264
+ const { userId } = options;
265
+
266
+ this.sdk.validateParams(
267
+ { userId },
268
+ {
269
+ userId: { type: 'string', required: false },
270
+ },
271
+ );
272
+
273
+ const params = {
274
+ body: {},
275
+ };
276
+
277
+ if (userId) {
278
+ params.body.userId = userId;
279
+ }
280
+
281
+ const result = await this.sdk._fetch(
282
+ '/taskRouter/worker/queueLogoutAll',
283
+ 'PUT',
284
+ params,
285
+ );
286
+ return result;
287
+ }
288
+
289
+ /**
290
+ * Login to a specific queue
291
+ * Logs the worker into a specific queue by queueId.
292
+ * If userId is not provided, it will use the authenticated user's ID from the session.
293
+ *
294
+ * @param {Object} options - Parameters
295
+ * @param {string} options.queueId - The queue ID to login to (required)
296
+ * @param {string} [options.userId] - The user ID to login. If not provided, uses the authenticated user's ID
297
+ * @returns {Promise<Object>} Object containing the userId that was processed
298
+ * @returns {string} result.userId - The user ID that logged into the queue
299
+ *
300
+ * @example
301
+ * // Login to a queue for authenticated user
302
+ * const result = await sdk.taskRouter.worker.queueLogin({ queueId: 'queue123' });
303
+ * console.log(result.userId);
304
+ *
305
+ * @example
306
+ * // Login to a queue for specific user
307
+ * const result = await sdk.taskRouter.worker.queueLogin({
308
+ * queueId: 'queue123',
309
+ * userId: '123456'
310
+ * });
311
+ * console.log(result.userId);
312
+ */
313
+ async queueLogin(options = {}) {
314
+ const { queueId, userId } = options;
315
+
316
+ this.sdk.validateParams(
317
+ { queueId, userId },
318
+ {
319
+ queueId: { type: 'string', required: true },
320
+ userId: { type: 'string', required: false },
321
+ },
322
+ );
323
+
324
+ const params = {
325
+ body: {
326
+ queueId,
327
+ },
328
+ };
329
+
330
+ if (userId) {
331
+ params.body.userId = userId;
332
+ }
333
+
334
+ const result = await this.sdk._fetch(
335
+ '/taskRouter/worker/queueLogin',
336
+ 'PUT',
337
+ params,
338
+ );
339
+ return result;
340
+ }
341
+
342
+ /**
343
+ * Logout from a specific queue
344
+ * Logs the worker out of a specific queue by queueId.
345
+ * If userId is not provided, it will use the authenticated user's ID from the session.
346
+ *
347
+ * @param {Object} options - Parameters
348
+ * @param {string} options.queueId - The queue ID to logout from (required)
349
+ * @param {string} [options.userId] - The user ID to logout. If not provided, uses the authenticated user's ID
350
+ * @returns {Promise<Object>} Object containing the userId that was processed
351
+ * @returns {string} result.userId - The user ID that logged out of the queue
352
+ *
353
+ * @example
354
+ * // Logout from a queue for authenticated user
355
+ * const result = await sdk.taskRouter.worker.queueLogout({ queueId: 'queue123' });
356
+ * console.log(result.userId);
357
+ *
358
+ * @example
359
+ * // Logout from a queue for specific user
360
+ * const result = await sdk.taskRouter.worker.queueLogout({
361
+ * queueId: 'queue123',
362
+ * userId: '123456'
363
+ * });
364
+ * console.log(result.userId);
365
+ */
366
+ async queueLogout(options = {}) {
367
+ const { queueId, userId } = options;
368
+
369
+ this.sdk.validateParams(
370
+ { queueId, userId },
371
+ {
372
+ queueId: { type: 'string', required: true },
373
+ userId: { type: 'string', required: false },
374
+ },
375
+ );
376
+
377
+ const params = {
378
+ body: {
379
+ queueId,
380
+ },
381
+ };
382
+
383
+ if (userId) {
384
+ params.body.userId = userId;
385
+ }
386
+
387
+ const result = await this.sdk._fetch(
388
+ '/taskRouter/worker/queueLogout',
389
+ 'PUT',
390
+ params,
391
+ );
392
+ return result;
393
+ }
394
+ }
@@ -0,0 +1,6 @@
1
+ // Import all task router services
2
+ import { TaskRouterService } from './taskRouter/TaskRouterService.js';
3
+ import { WorkerService } from './taskRouter/WorkerService.js';
4
+
5
+ // Re-export all services
6
+ export { TaskRouterService, WorkerService };
package/services/video.js CHANGED
@@ -316,6 +316,10 @@ export class VideoService {
316
316
  validationSchema.startMicrophoneMuted = { type: 'boolean' };
317
317
  if ('startMicrophoneMutedAfter' in update)
318
318
  validationSchema.startMicrophoneMutedAfter = { type: 'number' };
319
+ if ('startRecordingOn' in update)
320
+ validationSchema.startRecordingOn = { type: 'boolean' };
321
+ if ('startTranscribingOn' in update)
322
+ validationSchema.startTranscribingOn = { type: 'boolean' };
319
323
  if ('enableChat' in update)
320
324
  validationSchema.enableChat = { type: 'boolean' };
321
325
 
@@ -378,18 +382,22 @@ export class VideoService {
378
382
  return result;
379
383
  }
380
384
 
381
- async describe(roomId) {
385
+ async describe(roomId, { includeParticipants = false }) {
382
386
  this.sdk.validateParams(
383
- { roomId },
387
+ { roomId, includeParticipants },
384
388
  {
385
389
  roomId: { type: 'string', required: true },
390
+ includeParticipants: { type: 'boolean', required: false },
386
391
  },
387
392
  );
388
393
 
389
- const params = {};
394
+ const params = {
395
+ query: {
396
+ includeParticipants,
397
+ },
398
+ };
390
399
 
391
- const result = await this.sdk._fetch(`/video/${roomId}`, 'GET', params);
392
- return result;
400
+ return await this.sdk._fetch(`/video/${roomId}`, 'GET', params);
393
401
  }
394
402
 
395
403
  async listMeetings(options = {}) {
@@ -730,4 +738,136 @@ export class VideoService {
730
738
  );
731
739
  return result;
732
740
  }
741
+
742
+ /**
743
+ * Create or update user's default video room settings
744
+ * @param {Object} settings - Video room settings
745
+ * @param {string} [settings.userId] - Optional userId to update settings for another user
746
+ * @param {boolean} [settings.waitingRoom] - Enable waiting room by default
747
+ * @param {boolean} [settings.enableChat] - Enable chat by default
748
+ * @param {number} [settings.maxVideoResolution] - Max video resolution (1080 or 720)
749
+ * @param {boolean} [settings.startCameraMuted] - Start with camera muted
750
+ * @param {number} [settings.startCameraMutedAfter] - Auto-mute cameras after N participants
751
+ * @param {boolean} [settings.startMicrophoneMuted] - Start with microphone muted
752
+ * @param {number} [settings.startMicrophoneMutedAfter] - Auto-mute mics after N participants
753
+ * @param {number} [settings.endMeetingWithoutHostTimeLimit] - Time limit to end meeting without host (seconds)
754
+ * @param {boolean} [settings.startRecordingOn] - Start recording automatically
755
+ * @param {boolean} [settings.startTranscribingOn] - Start transcribing automatically
756
+ * @param {Array<string>} [settings.hosts] - Default hosts to add to every meeting
757
+ * @param {Array<string>} [settings.participants] - Default participants to add to every meeting
758
+ * @returns {Promise} Created/updated settings
759
+ */
760
+ async createUserSettings(settings = {}) {
761
+ // Validate optional parameters
762
+ const validationSchema = {};
763
+ if ('userId' in settings) validationSchema.userId = { type: 'string' };
764
+ if ('waitingRoom' in settings)
765
+ validationSchema.waitingRoom = { type: 'boolean' };
766
+ if ('enableChat' in settings)
767
+ validationSchema.enableChat = { type: 'boolean' };
768
+ if ('maxVideoResolution' in settings)
769
+ validationSchema.maxVideoResolution = { type: 'number' };
770
+ if ('startCameraMuted' in settings)
771
+ validationSchema.startCameraMuted = { type: 'boolean' };
772
+ if ('startCameraMutedAfter' in settings)
773
+ validationSchema.startCameraMutedAfter = { type: 'number' };
774
+ if ('startMicrophoneMuted' in settings)
775
+ validationSchema.startMicrophoneMuted = { type: 'boolean' };
776
+ if ('startMicrophoneMutedAfter' in settings)
777
+ validationSchema.startMicrophoneMutedAfter = { type: 'number' };
778
+ if ('endMeetingWithoutHostTimeLimit' in settings)
779
+ validationSchema.endMeetingWithoutHostTimeLimit = { type: 'number' };
780
+ if ('startRecordingOn' in settings)
781
+ validationSchema.startRecordingOn = { type: 'boolean' };
782
+ if ('startTranscribingOn' in settings)
783
+ validationSchema.startTranscribingOn = { type: 'boolean' };
784
+ if ('hosts' in settings) validationSchema.hosts = { type: 'array' };
785
+ if ('participants' in settings)
786
+ validationSchema.participants = { type: 'array' };
787
+
788
+ if (Object.keys(validationSchema).length > 0) {
789
+ this.sdk.validateParams(settings, validationSchema);
790
+ }
791
+
792
+ const params = {
793
+ body: settings,
794
+ };
795
+
796
+ const result = await this.sdk._fetch(
797
+ '/video/settings/user',
798
+ 'POST',
799
+ params,
800
+ );
801
+ return result;
802
+ }
803
+
804
+ /**
805
+ * Update user's default video room settings
806
+ * This is an alias for createOrUpdateUserSettings
807
+ * @param {Object} settings - Video room settings to update
808
+ * @returns {Promise} Updated settings
809
+ */
810
+ async updateUserSettings(settings = {}) {
811
+ // Validate optional parameters (same as createOrUpdateUserSettings)
812
+ const validationSchema = {};
813
+ if ('userId' in settings) validationSchema.userId = { type: 'string' };
814
+ if ('waitingRoom' in settings)
815
+ validationSchema.waitingRoom = { type: 'boolean' };
816
+ if ('enableChat' in settings)
817
+ validationSchema.enableChat = { type: 'boolean' };
818
+ if ('maxVideoResolution' in settings)
819
+ validationSchema.maxVideoResolution = { type: 'number' };
820
+ if ('startCameraMuted' in settings)
821
+ validationSchema.startCameraMuted = { type: 'boolean' };
822
+ if ('startCameraMutedAfter' in settings)
823
+ validationSchema.startCameraMutedAfter = { type: 'number' };
824
+ if ('startMicrophoneMuted' in settings)
825
+ validationSchema.startMicrophoneMuted = { type: 'boolean' };
826
+ if ('startMicrophoneMutedAfter' in settings)
827
+ validationSchema.startMicrophoneMutedAfter = { type: 'number' };
828
+ if ('endMeetingWithoutHostTimeLimit' in settings)
829
+ validationSchema.endMeetingWithoutHostTimeLimit = { type: 'number' };
830
+ if ('startRecordingOn' in settings)
831
+ validationSchema.startRecordingOn = { type: 'boolean' };
832
+ if ('startTranscribingOn' in settings)
833
+ validationSchema.startTranscribingOn = { type: 'boolean' };
834
+ if ('hosts' in settings) validationSchema.hosts = { type: 'array' };
835
+ if ('participants' in settings)
836
+ validationSchema.participants = { type: 'array' };
837
+
838
+ if (Object.keys(validationSchema).length > 0) {
839
+ this.sdk.validateParams(settings, validationSchema);
840
+ }
841
+
842
+ const params = {
843
+ body: settings,
844
+ };
845
+
846
+ const result = await this.sdk._fetch('/video/settings/user', 'PUT', params);
847
+ return result;
848
+ }
849
+
850
+ /**
851
+ * Get user's default video room settings
852
+ * @param {string} [userId] - Optional userId to get settings for another user
853
+ * @returns {Promise} User's video room settings
854
+ */
855
+ async getUserSettings(userId = null) {
856
+ const params = {
857
+ query: {},
858
+ };
859
+
860
+ if (userId) {
861
+ this.sdk.validateParams(
862
+ { userId },
863
+ {
864
+ userId: { type: 'string', required: true },
865
+ },
866
+ );
867
+ params.query.userId = userId;
868
+ }
869
+
870
+ const result = await this.sdk._fetch('/video/settings/user', 'GET', params);
871
+ return result;
872
+ }
733
873
  }