webitel-sdk 0.1.103 → 0.1.106
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/bundles/index.esm.js +28 -11
- package/bundles/index.esm.js.map +1 -1
- package/bundles/index.esm.min.js +1 -1
- package/bundles/index.esm.min.js.map +1 -1
- package/bundles/index.umd.js +38 -16
- package/bundles/index.umd.js.map +1 -1
- package/bundles/index.umd.min.js +1 -1
- package/bundles/index.umd.min.js.map +1 -1
- package/esm2015/socket/call.js +7 -2
- package/esm2015/socket/call.js.map +1 -1
- package/esm2015/socket/client.js +19 -9
- package/esm2015/socket/client.js.map +1 -1
- package/esm2015/socket/errors.js +2 -0
- package/esm2015/socket/errors.js.map +1 -1
- package/esm5/socket/call.js +14 -6
- package/esm5/socket/call.js.map +1 -1
- package/esm5/socket/client.js +20 -9
- package/esm5/socket/client.js.map +1 -1
- package/esm5/socket/errors.js +4 -1
- package/esm5/socket/errors.js.map +1 -1
- package/package.json +1 -1
- package/types/socket/call.d.ts.map +1 -1
- package/types/socket/client.d.ts +2 -1
- package/types/socket/client.d.ts.map +1 -1
- package/types/socket/errors.d.ts +2 -0
- package/types/socket/errors.d.ts.map +1 -1
package/bundles/index.esm.js
CHANGED
|
@@ -23816,8 +23816,13 @@ class Call {
|
|
|
23816
23816
|
/* Call control */
|
|
23817
23817
|
async answer(req) {
|
|
23818
23818
|
if (this.sip && this.client.phone) {
|
|
23819
|
-
|
|
23820
|
-
|
|
23819
|
+
try {
|
|
23820
|
+
const params = await this.client.phone.callOption(req);
|
|
23821
|
+
await this.sip.answer(params);
|
|
23822
|
+
}
|
|
23823
|
+
catch (e) {
|
|
23824
|
+
this.client.handleError(e);
|
|
23825
|
+
}
|
|
23821
23826
|
return true;
|
|
23822
23827
|
}
|
|
23823
23828
|
return false;
|
|
@@ -24237,8 +24242,10 @@ function wrapChannelMember(m) {
|
|
|
24237
24242
|
class DeviceNotFoundError extends Error {
|
|
24238
24243
|
constructor(msg) {
|
|
24239
24244
|
super(msg);
|
|
24245
|
+
this.id = DeviceNotFoundError.id;
|
|
24240
24246
|
}
|
|
24241
24247
|
}
|
|
24248
|
+
DeviceNotFoundError.id = `device_not_found`;
|
|
24242
24249
|
|
|
24243
24250
|
const SOCKET_URL_SUFFIX = 'websocket';
|
|
24244
24251
|
const spamData = `\u0000\u0000\u0000\u0000`;
|
|
@@ -24294,6 +24301,10 @@ const WEBSOCKET_EVENT_AGENT_STATUS = 'agent_status';
|
|
|
24294
24301
|
const WEBSOCKET_EVENT_CHANNEL_STATUS = 'channel';
|
|
24295
24302
|
const TASK_EVENT = 'task';
|
|
24296
24303
|
const WEBSOCKET_EVENT_SIP = 'sip';
|
|
24304
|
+
var HandleError;
|
|
24305
|
+
(function (HandleError) {
|
|
24306
|
+
HandleError["NotFoundError"] = "NotFoundError";
|
|
24307
|
+
})(HandleError || (HandleError = {}));
|
|
24297
24308
|
var Response;
|
|
24298
24309
|
(function (Response) {
|
|
24299
24310
|
Response["STATUS_FAIL"] = "FAIL";
|
|
@@ -24553,13 +24564,7 @@ class Client extends EventEmitter {
|
|
|
24553
24564
|
await this.phone.call(req);
|
|
24554
24565
|
}
|
|
24555
24566
|
catch (e) {
|
|
24556
|
-
|
|
24557
|
-
case 'NotFoundError':
|
|
24558
|
-
this.emit('error', new DeviceNotFoundError(e));
|
|
24559
|
-
break;
|
|
24560
|
-
default:
|
|
24561
|
-
this.emit('error', e);
|
|
24562
|
-
}
|
|
24567
|
+
this.handleError(e);
|
|
24563
24568
|
}
|
|
24564
24569
|
}
|
|
24565
24570
|
else {
|
|
@@ -24598,8 +24603,9 @@ class Client extends EventEmitter {
|
|
|
24598
24603
|
return this.request(WEBSOCKET_MAKE_USER_CALL, req);
|
|
24599
24604
|
}
|
|
24600
24605
|
async answer(id, req) {
|
|
24601
|
-
|
|
24602
|
-
|
|
24606
|
+
const call = this.callById(id);
|
|
24607
|
+
if (call) {
|
|
24608
|
+
return call.answer(req);
|
|
24603
24609
|
}
|
|
24604
24610
|
}
|
|
24605
24611
|
request(action, data) {
|
|
@@ -24698,6 +24704,17 @@ class Client extends EventEmitter {
|
|
|
24698
24704
|
fileUrlStream(fileId) {
|
|
24699
24705
|
return `${this.basePath}/api/storage/file/${fileId}/stream?access_token=${this._config.token}`;
|
|
24700
24706
|
}
|
|
24707
|
+
handleError(e) {
|
|
24708
|
+
if (e) {
|
|
24709
|
+
switch (e.name) {
|
|
24710
|
+
case HandleError.NotFoundError:
|
|
24711
|
+
this.emit('error', new DeviceNotFoundError(e.message));
|
|
24712
|
+
break;
|
|
24713
|
+
default:
|
|
24714
|
+
this.emit('error', e);
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
}
|
|
24701
24718
|
async onMessage(message) {
|
|
24702
24719
|
this.log.debug('receive message: ', message);
|
|
24703
24720
|
if (message.seq_reply > 0) {
|