@voicenter-team/events-sdk 0.0.11 → 0.0.13

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,175 +0,0 @@
1
- import {
2
- EventNameEnum,
3
- EventsEnum,
4
- ExtensionEventReasonEnum,
5
- ExtensionHangupCauseEnum,
6
- QueueEventReasonEnum
7
- } from '@/enum/events.enum'
8
- import { Queue, Extension, Dialer, User } from './events.common'
9
-
10
- /**
11
- * Base structure for all event types, containing common properties.
12
- */
13
- interface CommonEventProperties {
14
- // Error code, 0 indicates no error
15
- errorCode?: number
16
- // Description of the error, "Ok" indicates successful connection
17
- errorDesc?: string
18
- // Server time at the moment of the event
19
- serverTime: number
20
- // Difference in time between server and client
21
- serverTimeOffset: number
22
- }
23
-
24
- // Inherits properties from CommonEventProperties
25
- type LoginSuccessEvent = CommonEventProperties
26
-
27
- /**
28
- * Data structure for login status event.
29
- */
30
- export interface LoginStatusEvent extends CommonEventProperties {
31
- // Array of Queue objects
32
- queues: Queue[]
33
- }
34
-
35
- /**
36
- * Data structure for all extension status event.
37
- */
38
- export interface AllExtensionStatusEvent extends CommonEventProperties {
39
- // Array of Extension objects
40
- extensions: Extension[]
41
- }
42
-
43
- /**
44
- * Data structure for all dialers status event.
45
- */
46
- export interface AllDialersStatusEvent extends CommonEventProperties {
47
- // Array of Dialer objects
48
- dialers: Dialer[]
49
- }
50
-
51
- /**
52
- * Data structure for all users status event.
53
- */
54
- export interface AllUsersStatusEvent extends CommonEventProperties {
55
- // Array of User objects
56
- users: User[]
57
- }
58
-
59
- /**
60
- * Data structure for queue event.
61
- */
62
- export interface QueueEvent extends CommonEventProperties {
63
- eventName: EventNameEnum.QUEUE,
64
- reason: QueueEventReasonEnum,
65
- telephonyServerTime: number,
66
- ivrUniqueId: string,
67
- data: Queue
68
- }
69
-
70
- /**
71
- * Data structure for extension event.
72
- */
73
- export interface ExtensionEvent extends CommonEventProperties {
74
- data: Extension
75
- eventName: EventNameEnum.EXTENSION
76
- reason: ExtensionEventReasonEnum
77
- telephonyServerTime?: number
78
- callerID?: string
79
- ivrUniqueId?: string
80
- dialStatus?: string
81
- cause?: ExtensionHangupCauseEnum
82
- }
83
-
84
- /**
85
- * Data structure for dialer event.
86
- */
87
- export interface DialerEvent extends CommonEventProperties {
88
- data: Dialer
89
- eventName: EventNameEnum.DIALER
90
- //reason: ExtensionEventReasonEnum // TODO: do research for dialer 'reason' prop
91
- telephonyServerTime?: number
92
- callerID?: string
93
- ivrUniqueId?: string
94
- dialStatus?: string
95
- //cause?: ExtensionHangupCauseEnum // TODO: do research for dialer 'cause' prop
96
- }
97
-
98
- /**
99
- * Data structure for keep alive response event.
100
- */
101
- export interface KeepAliveResponseEvent extends CommonEventProperties {
102
- isOk: boolean
103
- }
104
-
105
- export interface OnlineStatusEvent {
106
- isSocketConnected: boolean
107
- }
108
-
109
- /**
110
- * Mapping of event names to their respective data structures.
111
- */
112
- export interface EventDataMap {
113
- [EventsEnum.ALL_EXTENSION_STATUS]: AllExtensionStatusEvent
114
- [EventsEnum.ALL_DIALER_STATUS]: AllDialersStatusEvent
115
- [EventsEnum.ALL_USERS_STATUS]: AllUsersStatusEvent
116
- [EventsEnum.QUEUE_EVENT]: QueueEvent
117
- [EventsEnum.EXTENSION_EVENT]: ExtensionEvent
118
- [EventsEnum.DIALER_EVENT]: DialerEvent
119
- [EventsEnum.LOGIN_SUCCESS]: LoginSuccessEvent
120
- [EventsEnum.LOGIN_STATUS]: LoginStatusEvent
121
- [EventsEnum.KEEP_ALIVE_RESPONSE]: KeepAliveResponseEvent
122
- [EventsEnum.ONLINE_STATUS_EVENT]: OnlineStatusEvent
123
- }
124
-
125
- /**
126
- * Represents the set of all possible event type names as keys from the EventDataMap.
127
- * This type is used to define event listeners and handlers.
128
- */
129
- type EventTypeNames = keyof EventDataMap
130
-
131
- // Generic structure for wrapped socket event data
132
- type WrappedSocketEvent<T extends EventsEnum> = {
133
- name: T
134
- data: EventDataMap[T]
135
- }
136
-
137
- // Generic type for event type data
138
- export type EventTypeData<T extends EventsEnum> = EventDataMap[T]
139
-
140
- /**
141
- * Defines a registry of callback functions for each event type.
142
- * Each key is an event type name, and the value is a function that takes the specific event data type as an argument.
143
- * This registry is used to manage and invoke event-specific callbacks.
144
- */
145
- export type EventCallbackRegistry = {
146
- [K in EventTypeNames]: (data: EventDataMap[K]) => void
147
- }
148
-
149
- /**
150
- * This is a generic type for callback functions used in event handling.
151
- * It takes a generic event name and defines a callback function that receives wrapped socket event data for that specific event.
152
- */
153
- export type EventSpecificCallback<T extends EventTypeNames> = (data: WrappedSocketEvent<T>) => void
154
-
155
- /**
156
- * This type defines a map where each key is an event name, and the value is an array of callback functions associated with that event.
157
- * This structure is used to manage event listeners for different events
158
- */
159
- export type EventCallbackListenersMap = {
160
- [K in EventTypeNames]: Array<EventSpecificCallback<K>>
161
- }
162
-
163
- /**
164
- * This type represents a mapping of listener event names to their corresponding wrapped socket event data structures.
165
- * Each key is an event name, and the value is the wrapped socket event data for that event
166
- */
167
- type EventWrappedSocketDataMap = {
168
- [K in EventTypeNames]: WrappedSocketEvent<K>
169
- }
170
-
171
- /**
172
- * A generic type that represents the structure of any event data wrapped in a socket event format.
173
- * This type is used in the handling of all event types, providing a consistent structure for event data processing.
174
- */
175
- export type GenericEventWrapper = EventWrappedSocketDataMap[EventTypeNames]
@@ -1,37 +0,0 @@
1
- export type readyListener = (value: boolean) => void
2
- export type changeActiveCallsListener = (event: { [key: string]: string }) => void
3
- export type TestEventListener = (event: { test: string }) => void
4
- export type ActiveRoomListener = (event: number | undefined) => void
5
- export type CallAddingProgressListener = (callId: string | undefined) => void
6
- export type RoomDeletedListener = (roomId: number) => void
7
- export type changeActiveInputMediaDeviceListener = (event: string) => void
8
- export type changeActiveOutputMediaDeviceListener = (event: string) => void
9
- export type changeMuteWhenJoinListener = (value: boolean) => void
10
- export type changeIsDNDListener = (value: boolean) => void
11
- export type changeIsMutedListener = (value: boolean) => void
12
- export type addRoomListener = (value: string) => void
13
- export type updateRoomListener = (value: string) => void
14
- export type removeRoomListener = (value: string) => void
15
- export type changeCallStatusListener = (event: { [key: string]: number }) => void
16
-
17
- export interface OpenSIPSEventMap {
18
- ready: readyListener
19
- changeActiveCalls: changeActiveCallsListener
20
- callConfirmed: TestEventListener
21
- currentActiveRoomChanged: ActiveRoomListener
22
- callAddingInProgressChanged: CallAddingProgressListener
23
- roomDeleted: RoomDeletedListener
24
- changeActiveInputMediaDevice: changeActiveInputMediaDeviceListener
25
- changeActiveOutputMediaDevice: changeActiveOutputMediaDeviceListener
26
- changeMuteWhenJoin: changeMuteWhenJoinListener
27
- changeIsDND: changeIsDNDListener
28
- changeIsMuted: changeIsMutedListener
29
- addRoom: addRoomListener
30
- updateRoom: updateRoomListener
31
- removeRoom: removeRoomListener
32
- changeCallStatus: changeCallStatusListener
33
- }
34
-
35
- export type ListenersKeyType = keyof OpenSIPSEventMap
36
- export type ListenersCallbackFnType = OpenSIPSEventMap[ListenersKeyType]
37
- export type ListenerCallbackFnType<T extends ListenersKeyType> = OpenSIPSEventMap[T]
@@ -1,39 +0,0 @@
1
- /**
2
- * Represents Event Types in Enum
3
- */
4
- export enum EventTypesEnum {
5
- ALL_DIALERS_STATUS = 'AllDialersStatus',
6
- ALL_EXTENSION_STATUS = 'AllExtensionsStatus',
7
- CLOSE = 'closeme',
8
- CONNECT = 'connect',
9
- CONNECT_ERROR = 'connect_error',
10
- CONNECT_TIMEOUT = 'connect_timeout',
11
- DISCONNECT = 'disconnect',
12
- DIALER_EVENT = 'DialerEvent',
13
- DIALERS_UPDATED = 'DialersUpdated',
14
- ERROR = 'error',
15
- EXTENSION_EVENT = 'ExtensionEvent',
16
- EXTENSION_UPDATED = 'ExtensionsUpdated',
17
- KEEP_ALIVE = 'keepalive',
18
- KEEP_ALIVE_RESPONSE = 'keepaliveResponse',
19
- LOGIN = 'login',
20
- LOGIN_ACCOUNT = 'loginAccount',
21
- LOGIN_CODE = 'loginUserCode',
22
- LOGIN_RESPONSE = 'loginResponse',
23
- LOGIN_STATUS = 'loginStatus',
24
- LOGIN_USER = 'loginUser',
25
- PONG = 'pong',
26
- QUEUE_EVENT = 'QueueEvent',
27
- QUEUES_UPDATED = 'QueuesUpdated',
28
- RECONNECT = 'reconnect',
29
- RECONNECT_ATTEMPT = 'reconnect_attempt',
30
- RECONNECT_ERROR = 'reconnect_error',
31
- RECONNECT_FAILED = 'reconnect_failed',
32
- RECONNECTING = 'reconnecting',
33
- RESYNC = 'resync'
34
- }
35
-
36
- export enum ServerTypesEnum {
37
- DEFAULT = 1,
38
- CHROME_EXTENSION = 2
39
- }
@@ -1,5 +0,0 @@
1
- import { Socket } from 'socket.io-client'
2
- import { EventCallbackRegistry } from './events'
3
- import { EventsEnum } from 'enum/events.enum'
4
-
5
- export type SocketTyped = Socket<EventCallbackRegistry, Record<EventsEnum, any>>