webitel-sdk 0.1.99 → 0.1.103

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.
@@ -27120,9 +27120,15 @@
27120
27120
  this.state = exports.ConversationState.Invite;
27121
27121
  this.variables = {};
27122
27122
  this._hasReporting = !!(variables && variables.cc_reporting === 'true');
27123
+ this._autoAnswer = false;
27123
27124
  for (var k in variables) {
27124
27125
  if (!k.startsWith('cc_') && variables.hasOwnProperty(k)) {
27125
- this.variables[k] = variables[k];
27126
+ if (k === 'wbt_auto_answer') {
27127
+ this._autoAnswer = variables.wbt_auto_answer === 'true';
27128
+ }
27129
+ else {
27130
+ this.variables[k] = variables[k];
27131
+ }
27126
27132
  }
27127
27133
  }
27128
27134
  if (variables &&
@@ -27132,8 +27138,14 @@
27132
27138
  }
27133
27139
  }
27134
27140
  Conversation.prototype.setInvite = function (inviteId, timestamp) {
27141
+ var _this = this;
27135
27142
  this.inviteId = inviteId;
27136
27143
  this.invitedAt = timestamp;
27144
+ if (this._autoAnswer) {
27145
+ this.join().catch(function (e) {
27146
+ _this.client.emit('error', e);
27147
+ });
27148
+ }
27137
27149
  };
27138
27150
  Conversation.prototype.setAnswered = function (channelId, timestamp, member) {
27139
27151
  this.state = exports.ConversationState.Active;
@@ -27174,6 +27186,7 @@
27174
27186
  };
27175
27187
  if (i.hasOwnProperty('file')) {
27176
27188
  i.file.url = _this.client.fileUrlDownload(i.file.id);
27189
+ i.file.streamUrl = _this.client.fileUrlStream(i.file.id);
27177
27190
  msg.file = i.file;
27178
27191
  }
27179
27192
  if (i.hasOwnProperty('text')) {
@@ -27472,6 +27485,14 @@
27472
27485
  return m;
27473
27486
  }
27474
27487
 
27488
+ var DeviceNotFoundError = /** @class */ (function (_super) {
27489
+ tslib.__extends(DeviceNotFoundError, _super);
27490
+ function DeviceNotFoundError(msg) {
27491
+ return _super.call(this, msg) || this;
27492
+ }
27493
+ return DeviceNotFoundError;
27494
+ }(Error));
27495
+
27475
27496
  var SOCKET_URL_SUFFIX = 'websocket';
27476
27497
  var spamData = "\0\0\0\0";
27477
27498
  var Socket = /** @class */ (function (_super) {
@@ -27900,19 +27921,34 @@
27900
27921
  };
27901
27922
  Client.prototype.call = function (req) {
27902
27923
  return tslib.__awaiter(this, void 0, void 0, function () {
27924
+ var e_1;
27903
27925
  return tslib.__generator(this, function (_a) {
27904
27926
  switch (_a.label) {
27905
27927
  case 0:
27906
- if (!this.phone) return [3 /*break*/, 2];
27907
- return [4 /*yield*/, this.phone.call(req)];
27928
+ if (!this.phone) return [3 /*break*/, 5];
27929
+ _a.label = 1;
27908
27930
  case 1:
27931
+ _a.trys.push([1, 3, , 4]);
27932
+ return [4 /*yield*/, this.phone.call(req)];
27933
+ case 2:
27909
27934
  _a.sent();
27910
27935
  return [3 /*break*/, 4];
27911
- case 2: return [4 /*yield*/, this.invite(req)];
27912
27936
  case 3:
27937
+ e_1 = _a.sent();
27938
+ switch (e_1.name) {
27939
+ case 'NotFoundError':
27940
+ this.emit('error', new DeviceNotFoundError(e_1));
27941
+ break;
27942
+ default:
27943
+ this.emit('error', e_1);
27944
+ }
27945
+ return [3 /*break*/, 4];
27946
+ case 4: return [3 /*break*/, 7];
27947
+ case 5: return [4 /*yield*/, this.invite(req)];
27948
+ case 6:
27913
27949
  _a.sent();
27914
- _a.label = 4;
27915
- case 4: return [2 /*return*/];
27950
+ _a.label = 7;
27951
+ case 7: return [2 /*return*/];
27916
27952
  }
27917
27953
  });
27918
27954
  });
@@ -28027,7 +28063,7 @@
28027
28063
  };
28028
28064
  Client.prototype.registerCallClient = function (phone) {
28029
28065
  return tslib.__awaiter(this, void 0, void 0, function () {
28030
- var conf, e_1;
28066
+ var conf, e_2;
28031
28067
  var _this = this;
28032
28068
  return tslib.__generator(this, function (_a) {
28033
28069
  switch (_a.label) {
@@ -28059,9 +28095,9 @@
28059
28095
  _a.sent();
28060
28096
  return [3 /*break*/, 5];
28061
28097
  case 4:
28062
- e_1 = _a.sent();
28098
+ e_2 = _a.sent();
28063
28099
  // FIXME add handle error
28064
- this.log.error(e_1);
28100
+ this.log.error(e_2);
28065
28101
  return [3 /*break*/, 5];
28066
28102
  case 5: return [2 /*return*/];
28067
28103
  }
@@ -29003,6 +29039,7 @@
29003
29039
  exports.Call = Call;
29004
29040
  exports.Agent = Agent;
29005
29041
  exports.Conversation = Conversation;
29042
+ exports.DeviceNotFoundError = DeviceNotFoundError;
29006
29043
  exports.SipClient = SipClient;
29007
29044
  exports.ExternalClient = ExternalClient;
29008
29045
  exports.SipPhone = SipPhone;