@voicenter-team/events-sdk 0.0.121 → 0.0.123

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.
@@ -78,6 +78,34 @@ export declare type AllUsersStatusEvent = {
78
78
 
79
79
  export declare type AllUsersStatusEventSDK = EventTypeData<EventsEnum.ALL_USERS_STATUS>
80
80
 
81
+ export declare type AllVoicebotsStatus = {
82
+ /**
83
+ * 0 - Connection was establishing successfully.
84
+ */
85
+ errorCode?: number;
86
+ /**
87
+ * “Ok” - Connection was establishing successfully.
88
+ */
89
+ errorDesc?: string;
90
+ voicebots: Array<Voicebot>;
91
+ /**
92
+ * Server time at the moment of the event
93
+ */
94
+ servertime: number;
95
+
96
+
97
+ /**
98
+ * Difference in time between server and client
99
+ */
100
+ servertimeoffset: number;
101
+ };
102
+
103
+ export declare type AllVoiceBotsStatusEventSDK = EventTypeData<EventsEnum.ALL_VOICEBOTS_STATUS>
104
+
105
+ export declare interface AllVoicebotStatusExtended extends Omit<AllVoicebotsStatus, 'voicebots'> {
106
+ voicebots: Array<VoicebotExtended>
107
+ }
108
+
81
109
  declare class AuthClass {
82
110
  private readonly eventsSdkClass;
83
111
  constructor(eventsSdkClass: EventsSdkClass);
@@ -137,7 +165,7 @@ declare interface CurrentCallEnded extends CurrentCallUTCExtended {
137
165
  duration: number
138
166
  }
139
167
 
140
- declare interface CurrentCallUTCExtended extends ExtensionCall {
168
+ export declare interface CurrentCallUTCExtended extends ExtensionCall {
141
169
  callStarted_UTC: number
142
170
  callStarted_UTC_CLIENT: number
143
171
  callAnswered_UTC: number
@@ -280,6 +308,7 @@ export declare interface EventDataMap {
280
308
  [EventsEnum.ALL_EXTENSION_STATUS]: AllExtensionStatusEvent
281
309
  [EventsEnum.ALL_DIALER_STATUS]: AllDialersStatusEvent
282
310
  [EventsEnum.ALL_USERS_STATUS]: AllUsersStatusEvent
311
+ [EventsEnum.ALL_VOICEBOTS_STATUS]: AllVoicebotsStatus
283
312
  [EventsEnum.QUEUE_EVENT]: QueueEvent
284
313
  [EventsEnum.EXTENSION_EVENT]: ExtensionEvent
285
314
  [EventsEnum.DIALER_EVENT]: DialerEvent
@@ -288,6 +317,11 @@ export declare interface EventDataMap {
288
317
  [EventsEnum.KEEP_ALIVE_RESPONSE]: KeepAliveResponseEvent
289
318
  [EventsEnum.ONLINE_STATUS_EVENT]: OnlineStatusEvent
290
319
  [EventsEnum.EXTENSIONS_UPDATED]: ExtensionsUpdated
320
+ [EventsEnum.VOICEBOT_SUBSCRIBED_TO_CALL]: SubscribedToVoicebotCall
321
+ [EventsEnum.VOICEBOT_SUBSCRIBE_TO_CALL_FAILED]: SubscribeToVoicebotCallFailed
322
+ [EventsEnum.VOICEBOT_INITIAL_CALL_HISTORY]: InitialVoicebotCallHistory
323
+ [EventsEnum.VOICEBOT_UNSUBSCRIBED_FROM_CALL]: UnsubscribedFromVoicebotCall
324
+ [EventsEnum.VOICEBOT_EVENT]: VoicebotEvent
291
325
  }
292
326
 
293
327
  /**
@@ -299,6 +333,9 @@ export declare interface EventDataMapExtended extends EventDataMap {
299
333
  [EventsEnum.ALL_EXTENSION_STATUS]: AllExtensionStatusEventExtended
300
334
  [EventsEnum.QUEUE_EVENT]: QueueEventUTCExtended
301
335
  [EventsEnum.LOGIN_STATUS]: LoginStatusEventUTCExtended
336
+ [EventsEnum.ALL_VOICEBOTS_STATUS]: AllVoicebotStatusExtended
337
+ [EventsEnum.VOICEBOT_EVENT]: VoicebotEventExtended
338
+ [EventsEnum.VOICEBOT_INITIAL_CALL_HISTORY]: InitialVoicebotCallHistoryExtended
302
339
  }
303
340
 
304
341
  declare class EventEmitterClass {
@@ -328,6 +365,12 @@ export declare enum EventsEnum {
328
365
  ONLINE_STATUS_EVENT = 'onlineStatusEvent',
329
366
  DIALER_EVENT = 'DialerEvent',
330
367
  EXTENSIONS_UPDATED = 'ExtensionsUpdated',
368
+ ALL_VOICEBOTS_STATUS = 'AllVoicebotsStatus',
369
+ VOICEBOT_SUBSCRIBE_TO_CALL_FAILED = 'subscribeToCallFailed',
370
+ VOICEBOT_SUBSCRIBED_TO_CALL = 'subscribedToCall',
371
+ VOICEBOT_INITIAL_CALL_HISTORY = 'initialCallHistory',
372
+ VOICEBOT_UNSUBSCRIBED_FROM_CALL = 'unsubscribedFromCall',
373
+ VOICEBOT_EVENT = 'VoicebotEvent',
331
374
  }
332
375
 
333
376
  /**
@@ -576,6 +619,10 @@ export declare type ExtensionCall = {
576
619
  */
577
620
  callername: string;
578
621
  callstatus: CallStatusEnum;
622
+ /**
623
+ * cam id
624
+ */
625
+ campaignID?: string;
579
626
  customdata: CustomData;
580
627
  /**
581
628
  * Is internal
@@ -760,6 +807,22 @@ export declare interface ExternalLoginResponse<T> {
760
807
  */
761
808
  export declare type GenericEventWrapper = EventWrappedSocketDataMap[EventTypeNames]
762
809
 
810
+ export declare type InitialVoicebotCallHistory = {
811
+ history: Array<VoicebotEventDataCall>;
812
+ /**
813
+ * Voicebot id
814
+ */
815
+ voicebotID: number;
816
+ /**
817
+ * Ivr unique id
818
+ */
819
+ IvrUniqueID: string;
820
+ };
821
+
822
+ export declare interface InitialVoicebotCallHistoryExtended extends Omit<InitialVoicebotCallHistory, 'history'> {
823
+ history: Array<VoicebotCallUTCExtended>
824
+ }
825
+
763
826
  export declare type KeepAliveResponseEvent = {
764
827
  /**
765
828
  * Is ok
@@ -809,6 +872,7 @@ declare class LoggerClass {
809
872
  keepAliveEmit(): void;
810
873
  keepAliveResponse(data: KeepAliveResponseEvent): void;
811
874
  eventLog<T extends EventTypeNames>(eventName: T, data: EventDataMap[T]): void;
875
+ private getStaticData;
812
876
  }
813
877
 
814
878
  export declare interface LoggerConfig {
@@ -887,7 +951,8 @@ export declare type LoginSuccessEventSDK = EventTypeData<EventsEnum.LOGIN_SUCCES
887
951
 
888
952
  export declare enum LoginType {
889
953
  USER = "User",
890
- TOKEN = "Token"
954
+ TOKEN = "Token",
955
+ JWT = "Jwt"
891
956
  }
892
957
 
893
958
  export declare type OnlineStatusEvent = {
@@ -1091,7 +1156,9 @@ export declare type ServerEmitEventCallbackRegistry = {
1091
1156
  */
1092
1157
  export declare interface ServerEmitEventDataMap {
1093
1158
  [ServerListenerEventsEnum.UPDATE_MONITORED_EXTENSIONS]: UpdateMonitoredExtensionsPayload
1094
- [ServerListenerEventsEnum.KEEP_ALIVE]: string
1159
+ [ServerListenerEventsEnum.KEEP_ALIVE]: string,
1160
+ [ServerListenerEventsEnum.SUBSCRIBE_VOICEBOT_CALL_UPDATES]: SubscriptionVoicebotCallUpdatesPayload,
1161
+ [ServerListenerEventsEnum.UNSUBSCRIBE_VOICEBOT_CALL_UPDATES]: SubscriptionVoicebotCallUpdatesPayload
1095
1162
  }
1096
1163
 
1097
1164
  /**
@@ -1102,7 +1169,9 @@ export declare type ServerEmitEventTypeNames = keyof ServerEmitEventDataMap
1102
1169
 
1103
1170
  export declare enum ServerListenerEventsEnum {
1104
1171
  UPDATE_MONITORED_EXTENSIONS = "updateMonitoredExtensions",
1105
- KEEP_ALIVE = "keepalive"
1172
+ KEEP_ALIVE = "keepalive",
1173
+ SUBSCRIBE_VOICEBOT_CALL_UPDATES = "subscribeVoicebotCallUpdates",
1174
+ UNSUBSCRIBE_VOICEBOT_CALL_UPDATES = "unsubscribeVoicebotCallUpdates"
1106
1175
  }
1107
1176
 
1108
1177
  export declare enum ServerParameter {
@@ -1136,40 +1205,147 @@ export declare interface Socket {
1136
1205
  Version: string
1137
1206
  }
1138
1207
 
1208
+ /**
1209
+ * SocketIoClass handles WebSocket connections and real-time event management.
1210
+ * Prevents duplicate connections and events with robust state management.
1211
+ */
1139
1212
  declare class SocketIoClass {
1140
1213
  private readonly eventsSdkClass;
1141
- constructor(eventsSdkClass: EventsSdkClass);
1214
+ /** The active Socket.IO connection instance */
1142
1215
  io: SocketTyped | undefined;
1216
+ /** The Socket.IO function used to create connections based on version */
1143
1217
  ioFunction: TypedSocketIo | undefined;
1218
+ /** Timestamp of the last received event, used for keep-alive calculations */
1144
1219
  lastEventTimestamp: number;
1220
+ /** Flag indicating whether automatic reconnection should be attempted */
1145
1221
  doReconnect: boolean;
1222
+ /** Current connection state */
1223
+ private connectionState;
1224
+ /** Keep-alive interval handle */
1146
1225
  private keepAliveInterval;
1147
- private keepReconnectInterval;
1148
- private keepReconnectTimeout;
1149
- private connected;
1226
+ /** Reconnection timeout handle */
1227
+ private reconnectTimeout;
1228
+ /** Network reconnect timeout handle (debounced) */
1229
+ private networkReconnectTimeout;
1230
+ /** Current reconnection delay in seconds */
1150
1231
  private reconnectionTime;
1232
+ /** Maximum reconnection delay in seconds */
1233
+ private readonly maxReconnectionDelay;
1234
+ /** Network event cleanup functions */
1235
+ private networkCleanup;
1236
+ /**
1237
+ * Creates an instance of SocketIoClass and sets up network event listeners.
1238
+ */
1239
+ constructor(eventsSdkClass: EventsSdkClass);
1240
+ /**
1241
+ * Sets up network event listeners
1242
+ */
1243
+ private setupNetworkListeners;
1244
+ /**
1245
+ * Handles network online with debouncing to prevent rapid reconnects
1246
+ */
1247
+ private handleNetworkOnline;
1248
+ /**
1249
+ * Determines and sets the appropriate Socket.IO function based on client version.
1250
+ */
1151
1251
  getSocketIoFunction(Client: string): void;
1252
+ /**
1253
+ * Initializes a new Socket.IO connection. Prevents multiple simultaneous connections.
1254
+ */
1152
1255
  initSocketConnection(): void;
1256
+ /**
1257
+ * Clears the keep-alive interval
1258
+ */
1153
1259
  clearKeepAliveInterval(): void;
1260
+ /**
1261
+ * Initializes the keep-alive mechanism
1262
+ */
1154
1263
  initKeepAlive(): void;
1155
- closeAllConnections(): void;
1264
+ /**
1265
+ * Closes all active connections and cleans up resources properly
1266
+ */
1267
+ closeAllConnections(): Promise<void>;
1268
+ /**
1269
+ * Sets up event listeners for all Socket.IO events
1270
+ */
1156
1271
  initSocketEvents(): void;
1272
+ /**
1273
+ * Updates timestamp on every event to prevent unnecessary keep-alives
1274
+ */
1275
+ private updateEventTimestamp;
1157
1276
  private onLoginSuccessEvent;
1158
1277
  private onQueueEvent;
1159
1278
  private onExtensionEvent;
1160
1279
  private onDialerEvent;
1280
+ private onVoicebotEvent;
1281
+ private onAllVoicebotsStatus;
1282
+ private onVoicebotSubscribedToCall;
1283
+ private onVoicebotSubscribeToCallFailed;
1284
+ private onVoicebotInitialCallHistory;
1285
+ private onVoicebotUnsubscribedFromCall;
1161
1286
  private onLoginStatusEvent;
1162
1287
  private onAllExtensionStatus;
1163
1288
  private onAllDialerStatus;
1289
+ /**
1290
+ * Handles keep-alive response - fixed to prevent multiple connections
1291
+ */
1164
1292
  private onKeepAliveResponse;
1165
1293
  private onExtensionsUpdatedEvent;
1294
+ /**
1295
+ * Handles successful connection
1296
+ */
1166
1297
  private onConnect;
1298
+ /**
1299
+ * Schedules reconnection with exponential backoff
1300
+ */
1301
+ private scheduleReconnect;
1302
+ /**
1303
+ * Handles disconnection
1304
+ */
1167
1305
  private onDisconnect;
1306
+ /**
1307
+ * Handles connection errors
1308
+ */
1168
1309
  private onConnectError;
1310
+ /**
1311
+ * Cleanup when shutting down
1312
+ */
1313
+ destroy(): Promise<void>;
1169
1314
  }
1170
1315
 
1171
1316
  export declare type SocketTyped = Socket_2<EventCallbackRegistry, ServerEmitEventCallbackRegistry>
1172
1317
 
1318
+ export declare type SubscribedToVoicebotCall = {
1319
+ /**
1320
+ * subscribe success?
1321
+ */
1322
+ success: boolean;
1323
+ /**
1324
+ * voicebot id
1325
+ */
1326
+ voicebotID: number;
1327
+ /**
1328
+ * ivr id
1329
+ */
1330
+ IvrUniqueID: string;
1331
+ };
1332
+
1333
+ export declare type SubscribeToVoicebotCallFailed = {
1334
+ /**
1335
+ * error
1336
+ */
1337
+ error: string;
1338
+ /**
1339
+ * success
1340
+ */
1341
+ success: boolean;
1342
+ };
1343
+
1344
+ export declare interface SubscriptionVoicebotCallUpdatesPayload {
1345
+ voicebotID: number,
1346
+ IvrUniqueID: string
1347
+ }
1348
+
1173
1349
  export declare type Summery = {
1174
1350
  /**
1175
1351
  * Representative
@@ -1183,6 +1359,9 @@ export declare type TestEventListener = (event: { test: string }) => void
1183
1359
 
1184
1360
  declare type TypedSocketIo = (...args: Parameters<typeof io>) => SocketTyped;
1185
1361
 
1362
+ export declare type UnsubscribedFromVoicebotCall = {
1363
+ };
1364
+
1186
1365
  export declare interface UpdateMonitoredExtensionsPayload {
1187
1366
  extensionsString: string
1188
1367
  }
@@ -1206,6 +1385,174 @@ export declare type User = {
1206
1385
 
1207
1386
  export declare type UserSDK = User
1208
1387
 
1388
+ export declare type Voicebot = {
1389
+ Calls: Array<VoicebotEventDataCall>;
1390
+ /**
1391
+ * Acc id
1392
+ */
1393
+ AccountID: string;
1394
+ /**
1395
+ * Voicebot id
1396
+ */
1397
+ VoicebotID: number;
1398
+ /**
1399
+ * Voicebot name
1400
+ */
1401
+ VoicebotName: string;
1402
+ };
1403
+
1404
+ export declare type VoicebotCall = {
1405
+ };
1406
+
1407
+ export declare type VoicebotCallHistory = {
1408
+ };
1409
+
1410
+ export declare interface VoicebotCallUTCExtended extends Omit<VoicebotEventDataCall, 'eventsData'>{
1411
+ callStarted_UTC: number
1412
+ callStarted_UTC_CLIENT: number
1413
+ eventsData: Array<VoicebotEventDataCallEventsDataExtended>
1414
+ }
1415
+
1416
+ export declare type VoicebotEvent = {
1417
+ data: VoicebotEventData;
1418
+ type: VoicebotEventTypeEnum;
1419
+ reason: VoicebotEventReasonEnum;
1420
+ /**
1421
+ * Event name (voicebot)
1422
+ */
1423
+ eventName: string;
1424
+ /**
1425
+ * servertime
1426
+ */
1427
+ servertime: number;
1428
+ /**
1429
+ * servertimeoffset
1430
+ */
1431
+ servertimeoffset: number;
1432
+ /**
1433
+ * telephonyservertime
1434
+ */
1435
+ telephonyservertime: number;
1436
+ };
1437
+
1438
+ export declare type VoicebotEventData = {
1439
+ Call: VoicebotEventDataCall;
1440
+ /**
1441
+ * account id
1442
+ */
1443
+ AccountID: number;
1444
+ /**
1445
+ * voicebot id
1446
+ */
1447
+ VoicebotID: number;
1448
+ /**
1449
+ * ivr id
1450
+ */
1451
+ IvrUniqueID: string;
1452
+ /**
1453
+ * voicebot name
1454
+ */
1455
+ VoicebotName: string;
1456
+ };
1457
+
1458
+ export declare type VoicebotEventDataCall = {
1459
+ /**
1460
+ * did
1461
+ */
1462
+ did: string;
1463
+ /**
1464
+ * ivrid
1465
+ */
1466
+ ivrid: string;
1467
+ /**
1468
+ * CallerID
1469
+ */
1470
+ CallerID: string;
1471
+ /**
1472
+ * callType
1473
+ */
1474
+ callType: string;
1475
+ /**
1476
+ * aiSummary
1477
+ */
1478
+ aiSummary: string;
1479
+ direction: VoicebotEventDataCallDirectionEnum;
1480
+ callStatus: VoicebotEventDataCallStatusEnum;
1481
+ /**
1482
+ * callername
1483
+ */
1484
+ callername?: string;
1485
+ customData: any;
1486
+ eventsData: Array<VoicebotEventDataCallEventsData>;
1487
+ /**
1488
+ * IvrUniqueID
1489
+ */
1490
+ IvrUniqueID: string;
1491
+ /**
1492
+ * callStarted
1493
+ */
1494
+ callStarted: number;
1495
+ };
1496
+
1497
+ export declare enum VoicebotEventDataCallDirectionEnum {
1498
+ INCOMING = 'INCOMING',
1499
+ OUTGOING = 'OUTGOING',
1500
+ }
1501
+
1502
+ export declare type VoicebotEventDataCallEventsData = {
1503
+ Role: VoicebotEventDataCallEventsDataRoleEnum;
1504
+ Type: VoicebotEventDataCallEventsDataTypeEnum;
1505
+ ToolName?: string;
1506
+ Timestamp: number;
1507
+ Transcript?: string;
1508
+ };
1509
+
1510
+ export declare interface VoicebotEventDataCallEventsDataExtended extends VoicebotEventDataCallEventsData {
1511
+ Timestamp_UTC: number
1512
+ Timestamp_UTC_CLIENT: number
1513
+ }
1514
+
1515
+ export declare type VoicebotEventDataCallEventsDataRoleEnum = {
1516
+ };
1517
+
1518
+ export declare enum VoicebotEventDataCallEventsDataTypeEnum {
1519
+ CALLSTARTED = 'CallStarted',
1520
+ TRANSCRIPT = 'Transcript',
1521
+ TOOL_EXECUTED = 'ToolExecuted',
1522
+ TOOL_RESPONSE = 'ToolResponse',
1523
+ CALL_ENDED = 'CallEnded',
1524
+ }
1525
+
1526
+ export declare enum VoicebotEventDataCallStatusEnum {
1527
+ TALKING = 'Talking',
1528
+ ENDED = 'Ended',
1529
+ }
1530
+
1531
+ export declare interface VoicebotEventDataExtended extends Omit<VoicebotEventData, 'Call'> {
1532
+ Call: VoicebotCallUTCExtended
1533
+ }
1534
+
1535
+ export declare interface VoicebotEventExtended extends Omit<VoicebotEvent, 'data'> {
1536
+ data: VoicebotEventDataExtended
1537
+ }
1538
+
1539
+ export declare enum VoicebotEventReasonEnum {
1540
+ CALLSTARTED = 'CALLSTARTED',
1541
+ }
1542
+
1543
+ export declare type VoiceBotEventSDK = EventTypeData<EventsEnum.VOICEBOT_EVENT>
1544
+
1545
+ export declare enum VoicebotEventTypeEnum {
1546
+ UNKNOWN = 'UNKNOWN',
1547
+ }
1548
+
1549
+ export declare interface VoicebotExtended extends Omit<Voicebot, 'Calls'> {
1550
+ Calls: Array<VoicebotCallUTCExtended>
1551
+
1552
+ }
1553
+
1554
+ export declare type VoiceBotInitialCallHistoryEventSDK = EventTypeData<EventsEnum.VOICEBOT_INITIAL_CALL_HISTORY>
1555
+
1209
1556
  /**
1210
1557
  * The structure of received socket events.
1211
1558
  */
@@ -2733,6 +2733,11 @@ class te {
2733
2733
  {
2734
2734
  key: "callStarted",
2735
2735
  format: "sec"
2736
+ },
2737
+ {
2738
+ key: "holdStarted",
2739
+ // TODO: should add the holdStarted in TS definitions
2740
+ format: "sec"
2736
2741
  }
2737
2742
  ],
2738
2743
  t.servertime,