webitel-sdk 0.1.124 → 0.1.127

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 (51) hide show
  1. package/bundles/index.esm.js +78 -17
  2. package/bundles/index.esm.js.map +1 -1
  3. package/bundles/index.esm.min.js +1 -1
  4. package/bundles/index.esm.min.js.map +1 -1
  5. package/bundles/index.umd.js +100 -25
  6. package/bundles/index.umd.js.map +1 -1
  7. package/bundles/index.umd.min.js +1 -1
  8. package/bundles/index.umd.min.js.map +1 -1
  9. package/esm2015/enums/messenger-type.enum.js +1 -0
  10. package/esm2015/enums/messenger-type.enum.js.map +1 -1
  11. package/esm2015/socket/agent.js +5 -5
  12. package/esm2015/socket/agent.js.map +1 -1
  13. package/esm2015/socket/call.js +4 -0
  14. package/esm2015/socket/call.js.map +1 -1
  15. package/esm2015/socket/client.js +30 -10
  16. package/esm2015/socket/client.js.map +1 -1
  17. package/esm2015/socket/conversation.js +4 -0
  18. package/esm2015/socket/conversation.js.map +1 -1
  19. package/esm2015/socket/index.js +1 -0
  20. package/esm2015/socket/index.js.map +1 -1
  21. package/esm2015/socket/task.js +36 -3
  22. package/esm2015/socket/task.js.map +1 -1
  23. package/esm5/enums/messenger-type.enum.js +1 -0
  24. package/esm5/enums/messenger-type.enum.js.map +1 -1
  25. package/esm5/socket/agent.js +5 -5
  26. package/esm5/socket/agent.js.map +1 -1
  27. package/esm5/socket/call.js +8 -0
  28. package/esm5/socket/call.js.map +1 -1
  29. package/esm5/socket/client.js +30 -19
  30. package/esm5/socket/client.js.map +1 -1
  31. package/esm5/socket/conversation.js +8 -0
  32. package/esm5/socket/conversation.js.map +1 -1
  33. package/esm5/socket/index.js +1 -0
  34. package/esm5/socket/index.js.map +1 -1
  35. package/esm5/socket/task.js +52 -3
  36. package/esm5/socket/task.js.map +1 -1
  37. package/package.json +1 -1
  38. package/types/enums/messenger-type.enum.d.ts +2 -1
  39. package/types/enums/messenger-type.enum.d.ts.map +1 -1
  40. package/types/socket/agent.d.ts +2 -1
  41. package/types/socket/agent.d.ts.map +1 -1
  42. package/types/socket/call.d.ts +1 -0
  43. package/types/socket/call.d.ts.map +1 -1
  44. package/types/socket/client.d.ts +4 -1
  45. package/types/socket/client.d.ts.map +1 -1
  46. package/types/socket/conversation.d.ts +1 -0
  47. package/types/socket/conversation.d.ts.map +1 -1
  48. package/types/socket/index.d.ts +1 -0
  49. package/types/socket/index.d.ts.map +1 -1
  50. package/types/socket/task.d.ts +17 -2
  51. package/types/socket/task.d.ts.map +1 -1
@@ -24538,6 +24538,15 @@ async function getMediaStream(constraints) {
24538
24538
  });
24539
24539
  }
24540
24540
 
24541
+ var JobState;
24542
+ (function (JobState) {
24543
+ JobState["Distribute"] = "distribute";
24544
+ JobState["Offering"] = "offering";
24545
+ JobState["Bridged"] = "bridged";
24546
+ JobState["Missed"] = "missed";
24547
+ JobState["Processing"] = "processing";
24548
+ JobState["Destroy"] = "destroy";
24549
+ })(JobState || (JobState = {}));
24541
24550
  var ChannelName;
24542
24551
  (function (ChannelName) {
24543
24552
  ChannelName["Call"] = "call";
@@ -24549,7 +24558,8 @@ class Task {
24549
24558
  this.client = client;
24550
24559
  this.distribute = distribute;
24551
24560
  this.id = e.attempt_id;
24552
- this.state = e.status;
24561
+ this.state = JobState.Offering;
24562
+ this.setState(e.status);
24553
24563
  this.lastStatusChange = e.timestamp;
24554
24564
  this.createdAt = e.timestamp;
24555
24565
  this._processing = null;
@@ -24606,6 +24616,10 @@ class Task {
24606
24616
  get agentChannelId() {
24607
24617
  return this.distribute.agent_channel_id;
24608
24618
  }
24619
+ // todo
24620
+ setState(state) {
24621
+ this.state = state;
24622
+ }
24609
24623
  setAnswered(t) {
24610
24624
  this.answeredAt = t;
24611
24625
  this.lastStatusChange = Date.now();
@@ -24617,8 +24631,9 @@ class Task {
24617
24631
  this.form = e.form;
24618
24632
  }
24619
24633
  }
24620
- setProcessing(p) {
24621
- this.state = 'processing'; // todo
24634
+ setProcessing(now, p) {
24635
+ this.state = JobState.Processing;
24636
+ this.closedAt = now;
24622
24637
  if (!this.startProcessingAt) {
24623
24638
  this.startProcessingAt = Date.now();
24624
24639
  }
@@ -24627,10 +24642,16 @@ class Task {
24627
24642
  }
24628
24643
  this._processing = p;
24629
24644
  }
24645
+ setWaiting(now) {
24646
+ this.stopAt = now;
24647
+ }
24630
24648
  setTransferred(d) {
24631
24649
  this.distribute = d;
24632
24650
  this.history.push(d);
24633
24651
  }
24652
+ setMissed() {
24653
+ this.state = JobState.Missed;
24654
+ }
24634
24655
  get processingTimeoutAt() {
24635
24656
  if (!this._processing || !this._processing.timeout) {
24636
24657
  return null;
@@ -24643,6 +24664,18 @@ class Task {
24643
24664
  }
24644
24665
  return this._processing.sec;
24645
24666
  }
24667
+ get attempt() {
24668
+ return this;
24669
+ }
24670
+ get displayNumber() {
24671
+ return this.communication.destination;
24672
+ }
24673
+ get displayName() {
24674
+ return this.communication.display;
24675
+ }
24676
+ get display() {
24677
+ return `${this.displayNumber} (${this.displayName})`;
24678
+ }
24646
24679
  get renewalSec() {
24647
24680
  if (!this._processing || !this._processing.renewal_sec) {
24648
24681
  return null;
@@ -24728,6 +24761,7 @@ var ChannelType;
24728
24761
  ChannelType["Call"] = "call";
24729
24762
  ChannelType["Email"] = "email";
24730
24763
  ChannelType["Chat"] = "chat";
24764
+ ChannelType["Job"] = "task";
24731
24765
  })(ChannelType || (ChannelType = {}));
24732
24766
  class Agent {
24733
24767
  constructor(client, info) {
@@ -24847,6 +24881,7 @@ class Agent {
24847
24881
  if (!missedEvent) {
24848
24882
  throw new Error('bad event');
24849
24883
  }
24884
+ task.setMissed();
24850
24885
  this.setChannelStateTimeout(e.channel, e, missedEvent.missed.timeout);
24851
24886
  this.task.delete(e.attempt_id);
24852
24887
  this.client.reportingChannelTask(task);
@@ -24873,9 +24908,7 @@ class Agent {
24873
24908
  }
24874
24909
  task = this.task.get(e.attempt_id);
24875
24910
  if (task) {
24876
- task.state = e.status;
24877
- task.closedAt = e.timestamp; // todo
24878
- task.setProcessing(processingEvent.processing);
24911
+ task.setProcessing(e.timestamp, processingEvent.processing);
24879
24912
  this.setChannelStateTimeout(e.channel, e, processingEvent.processing.timeout || 0);
24880
24913
  return task;
24881
24914
  }
@@ -24886,7 +24919,7 @@ class Agent {
24886
24919
  if (e.attempt_id) {
24887
24920
  task = this.task.get(e.attempt_id);
24888
24921
  if (task) {
24889
- task.stopAt = e.timestamp;
24922
+ task.setWaiting(e.timestamp);
24890
24923
  this.task.delete(e.attempt_id);
24891
24924
  this.client.reportingChannelTask(task);
24892
24925
  }
@@ -24897,7 +24930,7 @@ class Agent {
24897
24930
  }
24898
24931
  this.setChannelState(e.channel, e);
24899
24932
  if (task) {
24900
- task.state = e.status;
24933
+ task.setState(e.status);
24901
24934
  return task;
24902
24935
  }
24903
24936
  else {
@@ -25230,6 +25263,10 @@ class Call {
25230
25263
  return ((this.queue && this.queue.queue_type === 'offline') ||
25231
25264
  (this.params && this.params.autoAnswer === true));
25232
25265
  }
25266
+ // todo task is deprecated
25267
+ get attempt() {
25268
+ return this.task;
25269
+ }
25233
25270
  /* Call control */
25234
25271
  async answer(req) {
25235
25272
  if (this.sip && this.client.phone) {
@@ -25510,6 +25547,10 @@ class Conversation {
25510
25547
  }
25511
25548
  return res;
25512
25549
  }
25550
+ // todo task is deprecated
25551
+ get attempt() {
25552
+ return this.task;
25553
+ }
25513
25554
  /*
25514
25555
  Actions
25515
25556
  */
@@ -25725,6 +25766,7 @@ const WEBSOCKET_EVENT_USER_STATE = 'user_state';
25725
25766
  const WEBSOCKET_EVENT_AGENT_STATUS = 'agent_status';
25726
25767
  const WEBSOCKET_EVENT_CHANNEL_STATUS = 'channel';
25727
25768
  const TASK_EVENT = 'task';
25769
+ const JOB_EVENT = 'job';
25728
25770
  const WEBSOCKET_EVENT_SIP = 'sip';
25729
25771
  var HandleError;
25730
25772
  (function (HandleError) {
@@ -25802,7 +25844,7 @@ class Client extends EventEmitter {
25802
25844
  call.task.form = c.task.form || null;
25803
25845
  if (c.leaving_at && c.task.processing_sec) {
25804
25846
  call.task.startProcessingAt = c.leaving_at;
25805
- call.task.setProcessing({
25847
+ call.task.setProcessing(c.leaving_at, {
25806
25848
  sec: c.task.processing_sec || 0,
25807
25849
  timeout: c.task.processing_timeout_at || null,
25808
25850
  renewal_sec: c.task.processing_renewal_sec || 0,
@@ -25834,7 +25876,7 @@ class Client extends EventEmitter {
25834
25876
  );
25835
25877
  if (conv.leaving_at && conv.task.processing_sec) {
25836
25878
  c.task.startProcessingAt = conv.leaving_at;
25837
- c.task.setProcessing({
25879
+ c.task.setProcessing(conv.leaving_at, {
25838
25880
  sec: conv.task.processing_sec || 0,
25839
25881
  timeout: conv.task.processing_timeout_at || null,
25840
25882
  renewal_sec: conv.task.processing_renewal_sec || 0,
@@ -25874,12 +25916,11 @@ class Client extends EventEmitter {
25874
25916
  subscribeTask(handler) {
25875
25917
  this.eventHandler.on(TASK_EVENT, handler);
25876
25918
  }
25919
+ subscribeJob(handler) {
25920
+ this.eventHandler.on(JOB_EVENT, handler);
25921
+ }
25877
25922
  async unSubscribe(action, handler, data) {
25878
- const res = await this.request(`un_subscribe_${action}`, data);
25879
- // this.eventHandler.listeners(action)
25880
- // this.eventHandler.removeListener(action, handler)
25881
- // this.eventHandler.off(action, handler)
25882
- return res;
25923
+ return this.request(`un_subscribe_${action}`, data);
25883
25924
  }
25884
25925
  async destroy() {
25885
25926
  await this.disconnect();
@@ -25896,12 +25937,16 @@ class Client extends EventEmitter {
25896
25937
  allConversations() {
25897
25938
  return Array.from(this.conversationStore.values());
25898
25939
  }
25940
+ // todo deprecated
25899
25941
  allTask() {
25900
25942
  if (!this.agent) {
25901
25943
  return [];
25902
25944
  }
25903
25945
  return Array.from(this.agent.task.values());
25904
25946
  }
25947
+ allJob() {
25948
+ return this.allTask().filter(isJobTask);
25949
+ }
25905
25950
  callById(id) {
25906
25951
  if (this.callStore.has(id)) {
25907
25952
  return this.callStore.get(id);
@@ -25963,7 +26008,7 @@ class Client extends EventEmitter {
25963
26008
  attempt_id: t.attempt_id,
25964
26009
  }, t);
25965
26010
  task.postProcessData = {};
25966
- task.state = t.state;
26011
+ task.setState(t.state);
25967
26012
  if (t.bridged_at) {
25968
26013
  task.bridgedAt = t.bridged_at;
25969
26014
  task.answeredAt = t.bridged_at;
@@ -26202,6 +26247,12 @@ class Client extends EventEmitter {
26202
26247
  e.timestamp = Date.now(); // bug
26203
26248
  const task = this.agent.onChannelEvent(e) || undefined;
26204
26249
  this.eventHandler.emit(TASK_EVENT, e.status, task);
26250
+ if (task && isJobTask(task)) {
26251
+ this.eventHandler.emit(JOB_EVENT, task.state, task);
26252
+ if (isDestroyJob(task.state)) {
26253
+ this.eventHandler.emit(JOB_EVENT, JobState.Destroy, task);
26254
+ }
26255
+ }
26205
26256
  }
26206
26257
  }
26207
26258
  async pingServer() {
@@ -26436,6 +26487,16 @@ class Client extends EventEmitter {
26436
26487
  this.eventHandler.emit(WEBSOCKET_EVENT_CHAT, ChatActions.Destroy, conv);
26437
26488
  }
26438
26489
  }
26490
+ function isJobTask(task) {
26491
+ return task.channel === ChannelName.Task;
26492
+ }
26493
+ function isDestroyJob(state) {
26494
+ return ([
26495
+ ChannelState.Missed.toString(),
26496
+ ChannelState.Waiting,
26497
+ ChannelState.WrapTime,
26498
+ ].indexOf(state) > -1);
26499
+ }
26439
26500
 
26440
26501
  class SipClient extends EventEmitter {
26441
26502
  }
@@ -26828,5 +26889,5 @@ class ExternalClient extends ee_3 {
26828
26889
 
26829
26890
  // tslint:disable
26830
26891
 
26831
- export { AgentPauseCauseServiceApiAxiosParamCreator, AgentPauseCauseServiceApiFp, AgentPauseCauseServiceApiFactory, AgentPauseCauseServiceApi, AgentServiceApiAxiosParamCreator, AgentServiceApiFp, AgentServiceApiFactory, AgentServiceApi, AgentSkillServiceApiAxiosParamCreator, AgentSkillServiceApiFp, AgentSkillServiceApiFactory, AgentSkillServiceApi, AgentTeamServiceApiAxiosParamCreator, AgentTeamServiceApiFp, AgentTeamServiceApiFactory, AgentTeamServiceApi, BackendProfileServiceApiAxiosParamCreator, BackendProfileServiceApiFp, BackendProfileServiceApiFactory, BackendProfileServiceApi, BucketServiceApiAxiosParamCreator, BucketServiceApiFp, BucketServiceApiFactory, BucketServiceApi, CalendarServiceApiAxiosParamCreator, CalendarServiceApiFp, CalendarServiceApiFactory, CalendarServiceApi, CallServiceApiAxiosParamCreator, CallServiceApiFp, CallServiceApiFactory, CallServiceApi, CognitiveProfileServiceApiAxiosParamCreator, CognitiveProfileServiceApiFp, CognitiveProfileServiceApiFactory, CognitiveProfileServiceApi, CommunicationTypeServiceApiAxiosParamCreator, CommunicationTypeServiceApiFp, CommunicationTypeServiceApiFactory, CommunicationTypeServiceApi, EmailProfileServiceApiAxiosParamCreator, EmailProfileServiceApiFp, EmailProfileServiceApiFactory, EmailProfileServiceApi, FileServiceApiAxiosParamCreator, FileServiceApiFp, FileServiceApiFactory, FileServiceApi, FileTranscriptServiceApiAxiosParamCreator, FileTranscriptServiceApiFp, FileTranscriptServiceApiFactory, FileTranscriptServiceApi, ListServiceApiAxiosParamCreator, ListServiceApiFp, ListServiceApiFactory, ListServiceApi, MediaFileServiceApiAxiosParamCreator, MediaFileServiceApiFp, MediaFileServiceApiFactory, MediaFileServiceApi, MemberServiceApiAxiosParamCreator, MemberServiceApiFp, MemberServiceApiFactory, MemberServiceApi, OutboundResourceGroupServiceApiAxiosParamCreator, OutboundResourceGroupServiceApiFp, OutboundResourceGroupServiceApiFactory, OutboundResourceGroupServiceApi, OutboundResourceServiceApiAxiosParamCreator, OutboundResourceServiceApiFp, OutboundResourceServiceApiFactory, OutboundResourceServiceApi, QueueBucketServiceApiAxiosParamCreator, QueueBucketServiceApiFp, QueueBucketServiceApiFactory, QueueBucketServiceApi, QueueHookServiceApiAxiosParamCreator, QueueHookServiceApiFp, QueueHookServiceApiFactory, QueueHookServiceApi, QueueResourcesServiceApiAxiosParamCreator, QueueResourcesServiceApiFp, QueueResourcesServiceApiFactory, QueueResourcesServiceApi, QueueServiceApiAxiosParamCreator, QueueServiceApiFp, QueueServiceApiFactory, QueueServiceApi, QueueSkillServiceApiAxiosParamCreator, QueueSkillServiceApiFp, QueueSkillServiceApiFactory, QueueSkillServiceApi, RegionServiceApiAxiosParamCreator, RegionServiceApiFp, RegionServiceApiFactory, RegionServiceApi, RoutingChatPlanServiceApiAxiosParamCreator, RoutingChatPlanServiceApiFp, RoutingChatPlanServiceApiFactory, RoutingChatPlanServiceApi, RoutingOutboundCallServiceApiAxiosParamCreator, RoutingOutboundCallServiceApiFp, RoutingOutboundCallServiceApiFactory, RoutingOutboundCallServiceApi, RoutingSchemaServiceApiAxiosParamCreator, RoutingSchemaServiceApiFp, RoutingSchemaServiceApiFactory, RoutingSchemaServiceApi, RoutingVariableServiceApiAxiosParamCreator, RoutingVariableServiceApiFp, RoutingVariableServiceApiFactory, RoutingVariableServiceApi, SkillServiceApiAxiosParamCreator, SkillServiceApiFp, SkillServiceApiFactory, SkillServiceApi, UserHelperServiceApiAxiosParamCreator, UserHelperServiceApiFp, UserHelperServiceApiFactory, UserHelperServiceApi, Configuration, ProtobufNullValue, StorageProviderType, StorageServiceType, StorageUploadStatusCode, Response, Client, CallReportingStatus, CallActions, CallDirection, Call, AgentStatus, ChannelState, ChannelType, Agent, ChatActions, ConversationState, Conversation, DeviceNotFoundError, DeviceNotAllowPermissionError, SipClient, ExternalClient, SipPhone, Log };
26892
+ export { AgentPauseCauseServiceApiAxiosParamCreator, AgentPauseCauseServiceApiFp, AgentPauseCauseServiceApiFactory, AgentPauseCauseServiceApi, AgentServiceApiAxiosParamCreator, AgentServiceApiFp, AgentServiceApiFactory, AgentServiceApi, AgentSkillServiceApiAxiosParamCreator, AgentSkillServiceApiFp, AgentSkillServiceApiFactory, AgentSkillServiceApi, AgentTeamServiceApiAxiosParamCreator, AgentTeamServiceApiFp, AgentTeamServiceApiFactory, AgentTeamServiceApi, BackendProfileServiceApiAxiosParamCreator, BackendProfileServiceApiFp, BackendProfileServiceApiFactory, BackendProfileServiceApi, BucketServiceApiAxiosParamCreator, BucketServiceApiFp, BucketServiceApiFactory, BucketServiceApi, CalendarServiceApiAxiosParamCreator, CalendarServiceApiFp, CalendarServiceApiFactory, CalendarServiceApi, CallServiceApiAxiosParamCreator, CallServiceApiFp, CallServiceApiFactory, CallServiceApi, CognitiveProfileServiceApiAxiosParamCreator, CognitiveProfileServiceApiFp, CognitiveProfileServiceApiFactory, CognitiveProfileServiceApi, CommunicationTypeServiceApiAxiosParamCreator, CommunicationTypeServiceApiFp, CommunicationTypeServiceApiFactory, CommunicationTypeServiceApi, EmailProfileServiceApiAxiosParamCreator, EmailProfileServiceApiFp, EmailProfileServiceApiFactory, EmailProfileServiceApi, FileServiceApiAxiosParamCreator, FileServiceApiFp, FileServiceApiFactory, FileServiceApi, FileTranscriptServiceApiAxiosParamCreator, FileTranscriptServiceApiFp, FileTranscriptServiceApiFactory, FileTranscriptServiceApi, ListServiceApiAxiosParamCreator, ListServiceApiFp, ListServiceApiFactory, ListServiceApi, MediaFileServiceApiAxiosParamCreator, MediaFileServiceApiFp, MediaFileServiceApiFactory, MediaFileServiceApi, MemberServiceApiAxiosParamCreator, MemberServiceApiFp, MemberServiceApiFactory, MemberServiceApi, OutboundResourceGroupServiceApiAxiosParamCreator, OutboundResourceGroupServiceApiFp, OutboundResourceGroupServiceApiFactory, OutboundResourceGroupServiceApi, OutboundResourceServiceApiAxiosParamCreator, OutboundResourceServiceApiFp, OutboundResourceServiceApiFactory, OutboundResourceServiceApi, QueueBucketServiceApiAxiosParamCreator, QueueBucketServiceApiFp, QueueBucketServiceApiFactory, QueueBucketServiceApi, QueueHookServiceApiAxiosParamCreator, QueueHookServiceApiFp, QueueHookServiceApiFactory, QueueHookServiceApi, QueueResourcesServiceApiAxiosParamCreator, QueueResourcesServiceApiFp, QueueResourcesServiceApiFactory, QueueResourcesServiceApi, QueueServiceApiAxiosParamCreator, QueueServiceApiFp, QueueServiceApiFactory, QueueServiceApi, QueueSkillServiceApiAxiosParamCreator, QueueSkillServiceApiFp, QueueSkillServiceApiFactory, QueueSkillServiceApi, RegionServiceApiAxiosParamCreator, RegionServiceApiFp, RegionServiceApiFactory, RegionServiceApi, RoutingChatPlanServiceApiAxiosParamCreator, RoutingChatPlanServiceApiFp, RoutingChatPlanServiceApiFactory, RoutingChatPlanServiceApi, RoutingOutboundCallServiceApiAxiosParamCreator, RoutingOutboundCallServiceApiFp, RoutingOutboundCallServiceApiFactory, RoutingOutboundCallServiceApi, RoutingSchemaServiceApiAxiosParamCreator, RoutingSchemaServiceApiFp, RoutingSchemaServiceApiFactory, RoutingSchemaServiceApi, RoutingVariableServiceApiAxiosParamCreator, RoutingVariableServiceApiFp, RoutingVariableServiceApiFactory, RoutingVariableServiceApi, SkillServiceApiAxiosParamCreator, SkillServiceApiFp, SkillServiceApiFactory, SkillServiceApi, UserHelperServiceApiAxiosParamCreator, UserHelperServiceApiFp, UserHelperServiceApiFactory, UserHelperServiceApi, Configuration, ProtobufNullValue, StorageProviderType, StorageServiceType, StorageUploadStatusCode, JobState, Response, Client, CallReportingStatus, CallActions, CallDirection, Call, AgentStatus, ChannelState, ChannelType, Agent, ChatActions, ConversationState, Conversation, DeviceNotFoundError, DeviceNotAllowPermissionError, SipClient, ExternalClient, SipPhone, Log };
26832
26893
  //# sourceMappingURL=index.esm.js.map