@voicenter-team/events-sdk 0.0.121 → 0.0.122

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