@voicenter-team/events-sdk 0.0.14 → 0.0.18

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.
@@ -1,5 +1,5 @@
1
+ import { AsyncStorageLoggerConfig } from '@voicenter-team/socketio-storage-logger/build/interfaces/AsyncStorageLoggerConfig';
1
2
  import { DebouncedFuncLeading } from 'lodash';
2
- import { EventsEnum as EventsEnum_3 } from 'enum/events.enum';
3
3
  import { io } from 'socket.io-client';
4
4
  import { Socket as Socket_2 } from 'socket.io-client';
5
5
 
@@ -161,25 +161,25 @@ export declare type EventCallbackRegistry = {
161
161
  * Mapping of event names to their respective data structures.
162
162
  */
163
163
  export declare interface EventDataMap {
164
- [EventsEnum_2.ALL_EXTENSION_STATUS]: AllExtensionStatusEvent
165
- [EventsEnum_2.ALL_DIALER_STATUS]: AllDialersStatusEvent
166
- [EventsEnum_2.ALL_USERS_STATUS]: AllUsersStatusEvent
167
- [EventsEnum_2.QUEUE_EVENT]: QueueEvent
168
- [EventsEnum_2.EXTENSION_EVENT]: ExtensionEvent
169
- [EventsEnum_2.DIALER_EVENT]: DialerEvent
170
- [EventsEnum_2.LOGIN_SUCCESS]: LoginSuccessEvent
171
- [EventsEnum_2.LOGIN_STATUS]: LoginStatusEvent
172
- [EventsEnum_2.KEEP_ALIVE_RESPONSE]: KeepAliveResponseEvent
173
- [EventsEnum_2.ONLINE_STATUS_EVENT]: OnlineStatusEvent
164
+ [EventsEnum.ALL_EXTENSION_STATUS]: AllExtensionStatusEvent
165
+ [EventsEnum.ALL_DIALER_STATUS]: AllDialersStatusEvent
166
+ [EventsEnum.ALL_USERS_STATUS]: AllUsersStatusEvent
167
+ [EventsEnum.QUEUE_EVENT]: QueueEvent
168
+ [EventsEnum.EXTENSION_EVENT]: ExtensionEvent
169
+ [EventsEnum.DIALER_EVENT]: DialerEvent
170
+ [EventsEnum.LOGIN_SUCCESS]: LoginSuccessEvent
171
+ [EventsEnum.LOGIN_STATUS]: LoginStatusEvent
172
+ [EventsEnum.KEEP_ALIVE_RESPONSE]: KeepAliveResponseEvent
173
+ [EventsEnum.ONLINE_STATUS_EVENT]: OnlineStatusEvent
174
174
  }
175
175
 
176
176
  /**
177
177
  * All the eventNames that can be received from the server. Exists only in EXTENSION_EVENT and QueueEvent
178
178
  */
179
179
  declare enum EventNameEnum {
180
- EXTENSION = 'extension',
181
- QUEUE = 'queue',
182
- DIALER = 'dialer',
180
+ EXTENSION = "extension",
181
+ QUEUE = "queue",
182
+ DIALER = "dialer"
183
183
  }
184
184
 
185
185
  /**
@@ -201,31 +201,6 @@ export declare enum EventsEnum {
201
201
  DIALER_EVENT = "DialerEvent"
202
202
  }
203
203
 
204
- /**
205
- * All events that can be received from the server.
206
- */
207
- declare enum EventsEnum_2 {
208
- ALL_DIALER_STATUS = 'AllDialersStatus',
209
- ALL_EXTENSION_STATUS = 'AllExtensionsStatus',
210
- ALL_USERS_STATUS = 'AllUsersStatus',
211
- CONNECT = 'connect',
212
- DISCONNECT = 'disconnect',
213
- EXTENSION_EVENT = 'ExtensionEvent',
214
- KEEP_ALIVE = 'keepalive',
215
- KEEP_ALIVE_RESPONSE = 'keepaliveResponse',
216
- // This type of event will be sent only in case of a successful connection.
217
- // The event describes the list of monitored queues on this active connection.
218
- // The list of monitored queues will only be sent if the login connection was made with account credentials or account token.
219
- // If the login connection type is by user credentials, only the user’s extension assigned queues will return.
220
- LOGIN_STATUS = 'loginStatus',
221
- // This type of event will be sent in the initial login connection request in case of a successful connection only.
222
- // In case of wrong username or password or token, you will receive a 401 (“Unauthorized”) or 500 (“Unexpected token”) http error.
223
- LOGIN_SUCCESS = 'loginSuccess',
224
- QUEUE_EVENT = 'QueueEvent',
225
- ONLINE_STATUS_EVENT = 'onlineStatusEvent',
226
- DIALER_EVENT = 'DialerEvent',
227
- }
228
-
229
204
  /**
230
205
  * This is a generic type for callback functions used in event handling.
231
206
  * It takes a generic event name and defines a callback function that receives wrapped socket event data for that specific event.
@@ -241,6 +216,7 @@ declare class EventsSdkClass {
241
216
  socket: SocketTyped | undefined;
242
217
  authClass: AuthClass;
243
218
  socketIoClass: SocketIoClass;
219
+ loggerClass: LoggerClass;
244
220
  reconnectOptions: ReconnectOptions;
245
221
  retryConnection: DebouncedFuncLeading<(server?: ServerParameter, skipLogin?: boolean) => void>;
246
222
  private listeners;
@@ -267,6 +243,7 @@ export declare interface EventsSdkOptions {
267
243
  isNewStack?: boolean;
268
244
  servers: Server[];
269
245
  loginUrl: string;
246
+ getSettingsUrl?: string;
270
247
  fallbackServer: Server;
271
248
  refreshTokenUrl: string;
272
249
  refreshToken?: string;
@@ -286,16 +263,16 @@ export declare interface EventsSdkOptions {
286
263
  serverFetchStrategy?: string;
287
264
  serverType?: number;
288
265
  useLogger?: boolean;
289
- loggerSocketConnection?: string;
290
- loggerServer?: string;
291
- loggerConfig?: LoggerConfig;
266
+ loggerSocketConnection?: Socket_2;
267
+ loggerServer: string;
268
+ loggerConfig: Partial<AsyncStorageLoggerConfig>;
292
269
  loggerConnectOptions?: LoggerConnectOptions;
293
270
  email: string;
294
271
  password: string;
295
272
  username: string;
296
273
  }
297
274
 
298
- export declare type EventTypeData<T extends EventsEnum_2> = EventDataMap[T]
275
+ export declare type EventTypeData<T extends EventsEnum> = EventDataMap[T]
299
276
 
300
277
  /**
301
278
  * Represents the set of all possible event type names as keys from the EventDataMap.
@@ -415,29 +392,23 @@ export declare interface ExtensionEvent extends CommonEventProperties {
415
392
  * All the reasons for the extension event, e.g. a new call is ringing or dialing from an extension.
416
393
  */
417
394
  declare enum ExtensionEventReasonEnum {
418
- // A new call is ringing or dialing from an extension.
419
- NEW_CALL = 'NEWCALL',
420
- // A call was answered at an extension.
421
- ANSWER = 'ANSWER',
422
- // A call was placed on hold.
423
- HOLD = 'HOLD',
424
- // A call is no longer on hold.
425
- UNHOLD = 'UNHOLD',
426
- // When a call was ended. It is not necessarily means that the call was answered.
427
- HANGUP = 'HANGUP',
428
- // When the extension online user updated his\her user status(Login, Break, Logout, etc.)
429
- USER_STATUS_UPDATE = 'userStatusUpdate',
395
+ NEW_CALL = "NEWCALL",
396
+ ANSWER = "ANSWER",
397
+ HOLD = "HOLD",
398
+ UNHOLD = "UNHOLD",
399
+ HANGUP = "HANGUP",
400
+ USER_STATUS_UPDATE = "userStatusUpdate"
430
401
  }
431
402
 
432
403
  declare enum ExtensionHangupCauseEnum {
433
- NORMAL_HANGUP = 'Normal hangup',
434
- USER_BUSY = 'User busy',
435
- CALL_REJECTED = 'Call Rejected',
436
- UNALLOCATED_NUMBER = 'Unallocated (unassigned) number',
437
- UNKNOWN = 'Unknown',
438
- NO_USER_RESPONDING = 'No user responding',
439
- USER_ALERTING = 'User alerting, no answer',
440
- ANSWERED_ELSEWHERE = 'Answered elsewhere'
404
+ NORMAL_HANGUP = "Normal hangup",
405
+ USER_BUSY = "User busy",
406
+ CALL_REJECTED = "Call Rejected",
407
+ UNALLOCATED_NUMBER = "Unallocated (unassigned) number",
408
+ UNKNOWN = "Unknown",
409
+ NO_USER_RESPONDING = "No user responding",
410
+ USER_ALERTING = "User alerting, no answer",
411
+ ANSWERED_ELSEWHERE = "Answered elsewhere"
441
412
  }
442
413
 
443
414
  export declare interface ExternalLoginNewStackResponseData {
@@ -481,6 +452,15 @@ export declare type ListenersCallbackFnType = OpenSIPSEventMap[ListenersKeyType]
481
452
 
482
453
  export declare type ListenersKeyType = keyof OpenSIPSEventMap
483
454
 
455
+ declare class LoggerClass {
456
+ private readonly eventsSdkClass;
457
+ constructor(eventsSdkClass: EventsSdkClass);
458
+ io: Socket_2 | undefined;
459
+ private storageLogger;
460
+ init(): void;
461
+ log(type: LoggerTypeEnum, event: EventsEnum, ...data: unknown[]): void;
462
+ }
463
+
484
464
  export declare interface LoggerConfig {
485
465
  logToConsole?: boolean;
486
466
  overloadGlobalConsole?: boolean;
@@ -492,12 +472,20 @@ export declare interface LoggerConnectOptions {
492
472
  reconnection?: boolean;
493
473
  reconnectionDelay?: number;
494
474
  reconnectionAttempts?: number;
495
- perMessageDeflate?: boolean;
475
+ perMessageDeflate?: {
476
+ threshold: number;
477
+ };
496
478
  upgrade?: boolean;
497
479
  transports?: string[];
498
480
  debug?: boolean;
499
481
  }
500
482
 
483
+ declare enum LoggerTypeEnum {
484
+ INFO = "INFO",
485
+ WARN = "WARN",
486
+ ERROR = "ERROR"
487
+ }
488
+
501
489
  export declare interface LoginSessionData extends Settings, ExternalLoginNewStackResponseData, Socket {}
502
490
 
503
491
  export declare interface LoginSessionPayload {
@@ -575,10 +563,10 @@ export declare interface QueueEvent extends CommonEventProperties {
575
563
  }
576
564
 
577
565
  declare enum QueueEventReasonEnum {
578
- ANSWER = 'ANSWER',
579
- ABANDONED = 'ABANDONED',
580
- EXIT = 'EXIT',
581
- JOIN = 'JOIN'
566
+ ANSWER = "ANSWER",
567
+ ABANDONED = "ABANDONED",
568
+ EXIT = "EXIT",
569
+ JOIN = "JOIN"
582
570
  }
583
571
 
584
572
  export declare type readyListener = (value: boolean) => void
@@ -662,7 +650,7 @@ declare class SocketIoClass {
662
650
  private onDisconnect;
663
651
  }
664
652
 
665
- export declare type SocketTyped = Socket_2<EventCallbackRegistry, Record<EventsEnum_3, any>>
653
+ export declare type SocketTyped = Socket_2<EventCallbackRegistry, Record<EventsEnum, any>>
666
654
 
667
655
  export declare interface Summery {
668
656
  representative: string
@@ -681,7 +669,7 @@ export declare interface User {
681
669
 
682
670
  }
683
671
 
684
- export declare type WrappedSocketEvent<T extends EventsEnum_2> = {
672
+ export declare type WrappedSocketEvent<T extends EventsEnum> = {
685
673
  name: T
686
674
  data: EventDataMap[T]
687
675
  }