@voicenter-team/events-sdk 0.0.1
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.
- package/.eslintrc.cjs +15 -0
- package/.github/workflows/main.yml +16 -0
- package/.idea/VoicenterEventsSDK.iml +12 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/jsLinters/eslint.xml +7 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.nvmrc +1 -0
- package/TODELETE_TEMP/events.json +69122 -0
- package/TODELETE_TEMP/temphelper.cjs +101 -0
- package/dist/voicenter-events-sdk.cjs.js +48 -0
- package/dist/voicenter-events-sdk.cjs.js.map +1 -0
- package/dist/voicenter-events-sdk.d.ts +510 -0
- package/dist/voicenter-events-sdk.es.js +6350 -0
- package/dist/voicenter-events-sdk.es.js.map +1 -0
- package/dist/voicenter-events-sdk.iife.js +48 -0
- package/dist/voicenter-events-sdk.iife.js.map +1 -0
- package/dist/voicenter-events-sdk.umd.js +48 -0
- package/dist/voicenter-events-sdk.umd.js.map +1 -0
- package/docs/package-lock.json +3820 -0
- package/docs/package.json +25 -0
- package/docs/src/.vuepress/client.js +8 -0
- package/docs/src/.vuepress/components/Demo.vue +181 -0
- package/docs/src/.vuepress/config.js +60 -0
- package/docs/src/.vuepress/public/favicon.ico +0 -0
- package/docs/src/.vuepress/public/images/logo.png +0 -0
- package/docs/src/.vuepress/styles/index.scss +0 -0
- package/docs/src/.vuepress/styles/index.styl +8 -0
- package/docs/src/.vuepress/styles/palette.styl +10 -0
- package/docs/src/demo.md +7 -0
- package/docs/src/index.md +4 -0
- package/jest.config.js +11 -0
- package/package.json +54 -0
- package/src/classes/auth/auth.class.ts +196 -0
- package/src/classes/auth/auth.test.ts +14 -0
- package/src/classes/events-sdk/events-sdk-default-options.ts +52 -0
- package/src/classes/events-sdk/events-sdk.class.ts +237 -0
- package/src/classes/events-sdk/events-sdk.test.ts +9 -0
- package/src/classes/events-sdk/events-sdk.types.ts +77 -0
- package/src/classes/socket-io/socket-io.class.ts +166 -0
- package/src/classes/socket-io/socket-io.d.ts +10 -0
- package/src/classes/socket-io/versions/index.ts +52 -0
- package/src/classes/socket-io/versions/v1_3_7.js +2083 -0
- package/src/enum/events.enum.ts +96 -0
- package/src/index.ts +3 -0
- package/src/types/auth.d.ts +18 -0
- package/src/types/events.common.d.ts +110 -0
- package/src/types/events.d.ts +160 -0
- package/src/types/listeners.d.ts +37 -0
- package/src/types/public-api.d.ts +39 -0
- package/src/types/socket.d.ts +5 -0
- package/swagger/generated/Swagger.json +1 -0
- package/swagger/index.js +60 -0
- package/swagger/package.json +21 -0
- package/swagger/scripts/update-swagger-json.js +53 -0
- package/swagger/yarn.lock +2100 -0
- package/tsconfig.json +50 -0
- package/vite.config.ts +41 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All events that can be received from the server.
|
|
3
|
+
*/
|
|
4
|
+
export enum EventsEnum {
|
|
5
|
+
ALL_DIALER_STATUS = 'AllDialersStatus',
|
|
6
|
+
ALL_EXTENSION_STATUS = 'AllExtensionsStatus',
|
|
7
|
+
ALL_USERS_STATUS = 'AllUsersStatus',
|
|
8
|
+
CONNECT = 'connect',
|
|
9
|
+
DISCONNECT = 'disconnect',
|
|
10
|
+
EXTENSION_EVENT = 'ExtensionEvent',
|
|
11
|
+
KEEP_ALIVE = 'keepalive',
|
|
12
|
+
KEEP_ALIVE_RESPONSE = 'keepaliveResponse',
|
|
13
|
+
// This type of event will be sent only in case of a successful connection.
|
|
14
|
+
// The event describes the list of monitored queues on this active connection.
|
|
15
|
+
// The list of monitored queues will only be sent if the login connection was made with account credentials or account token.
|
|
16
|
+
// If the login connection type is by user credentials, only the user’s extension assigned queues will return.
|
|
17
|
+
LOGIN_STATUS = 'loginStatus',
|
|
18
|
+
// This type of event will be sent in the initial login connection request in case of a successful connection only.
|
|
19
|
+
// In case of wrong username or password or token, you will receive a 401 (“Unauthorized”) or 500 (“Unexpected token”) http error.
|
|
20
|
+
LOGIN_SUCCESS = 'loginSuccess',
|
|
21
|
+
QUEUE_EVENT = 'QueueEvent',
|
|
22
|
+
ONLINE_STATUS_EVENT = 'onlineStatusEvent'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* All the reasons for the extension event, e.g. a new call is ringing or dialing from an extension.
|
|
27
|
+
*/
|
|
28
|
+
export enum ExtensionEventReasonEnum {
|
|
29
|
+
// A new call is ringing or dialing from an extension.
|
|
30
|
+
NEW_CALL = 'NEWCALL',
|
|
31
|
+
// A call was answered at an extension.
|
|
32
|
+
ANSWER = 'ANSWER',
|
|
33
|
+
// A call was placed on hold.
|
|
34
|
+
HOLD = 'HOLD',
|
|
35
|
+
// A call is no longer on hold.
|
|
36
|
+
UNHOLD = 'UNHOLD',
|
|
37
|
+
// When a call was ended. It is not necessarily means that the call was answered.
|
|
38
|
+
HANGUP = 'HANGUP',
|
|
39
|
+
// When the extension online user updated his\her user status(Login, Break, Logout, etc.)
|
|
40
|
+
USER_STATUS_UPDATE = 'userStatusUpdate',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum QueueEventReasonEnum {
|
|
44
|
+
ANSWER = 'ANSWER',
|
|
45
|
+
ABANDONED = 'ABANDONED',
|
|
46
|
+
EXIT = 'EXIT',
|
|
47
|
+
JOIN = 'JOIN'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export enum DialerType {
|
|
51
|
+
AUTOMATIC = 'Automatic',
|
|
52
|
+
IVR = 'IVR'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* All the eventNames that can be received from the server. Exists only in EXTENSION_EVENT and QueueEvent
|
|
57
|
+
*/
|
|
58
|
+
export enum EventNameEnum {
|
|
59
|
+
EXTENSION = 'extension',
|
|
60
|
+
QUEUE = 'queue',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export enum ExtensionHangupCauseEnum {
|
|
64
|
+
NORMAL_HANGUP = 'Normal hangup',
|
|
65
|
+
USER_BUSY = 'User busy',
|
|
66
|
+
CALL_REJECTED = 'Call Rejected',
|
|
67
|
+
UNALLOCATED_NUMBER = 'Unallocated (unassigned) number',
|
|
68
|
+
UNKNOWN = 'Unknown',
|
|
69
|
+
NO_USER_RESPONDING = 'No user responding',
|
|
70
|
+
USER_ALERTING = 'User alerting, no answer',
|
|
71
|
+
ANSWERED_ELSEWHERE = 'Answered elsewhere'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export enum CallStatusEnum {
|
|
75
|
+
RINGING = 'Ringing',
|
|
76
|
+
TALKING = 'Talking',
|
|
77
|
+
DIALING = 'Dialing',
|
|
78
|
+
HOLD = 'Hold',
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export enum CallTypeEnum {
|
|
82
|
+
INCOMING = 'Incoming',
|
|
83
|
+
OUTGOING = 'Outgoing'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export enum DoNotCallMeStatusCodeEnum {
|
|
87
|
+
RESPONSE_FROM_API_VALID = 'RESPONSE_FROM_API_VALID',
|
|
88
|
+
RESPONSE_FROM_API_INVALID = 'RESPONSE_FROM_API_INVALID'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export enum DirectionEnum {
|
|
92
|
+
INCOMING = 'Incoming',
|
|
93
|
+
OUTGOING = 'Outgoing',
|
|
94
|
+
SPY = 'Spy',
|
|
95
|
+
CLICK2CALL = 'Click2call'
|
|
96
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface LoginSessionPayload {
|
|
2
|
+
token: string,
|
|
3
|
+
email: string,
|
|
4
|
+
username: string,
|
|
5
|
+
password: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface LoginSessionData {
|
|
9
|
+
Client: string,
|
|
10
|
+
PersonId: number,
|
|
11
|
+
RefreshToken: string,
|
|
12
|
+
RefreshTokenExpiry: Date,
|
|
13
|
+
Token: string,
|
|
14
|
+
TokenExpiry: Date,
|
|
15
|
+
URLList: string[],
|
|
16
|
+
Url: string,
|
|
17
|
+
Version: string
|
|
18
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { CallStatusEnum, CallTypeEnum, DialerType, DirectionEnum, DoNotCallMeStatusCodeEnum } from 'enum/events.enum'
|
|
2
|
+
|
|
3
|
+
export interface Dialer {
|
|
4
|
+
campaignID: number,
|
|
5
|
+
name: string,
|
|
6
|
+
typeID: number,
|
|
7
|
+
type: DialerType,
|
|
8
|
+
code: string,
|
|
9
|
+
calls: unknown,
|
|
10
|
+
statistics: unknown
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface User {
|
|
14
|
+
userID: number,
|
|
15
|
+
userName: string,
|
|
16
|
+
accountID: number
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Extension {
|
|
21
|
+
calls: ExtensionCall[],
|
|
22
|
+
userID: number,
|
|
23
|
+
userName: string,
|
|
24
|
+
number: number,
|
|
25
|
+
extenUser: string,
|
|
26
|
+
accountID: number,
|
|
27
|
+
topAccountID: number,
|
|
28
|
+
summery: Summery,
|
|
29
|
+
onlineUserID: number,
|
|
30
|
+
representative: number,
|
|
31
|
+
representativeStatus: number,
|
|
32
|
+
lastCallEventEpoch: number,
|
|
33
|
+
lastAnsweredCallEventEpoch: number,
|
|
34
|
+
lastHangupCallEpoch: number,
|
|
35
|
+
representativeUpdated: number,
|
|
36
|
+
peerStatus: unknown,
|
|
37
|
+
currentCall?: ExtensionCall,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface Queue {
|
|
41
|
+
QueueID: number,
|
|
42
|
+
QueueName: string,
|
|
43
|
+
Calls: QueueCall[],
|
|
44
|
+
UserId?: number,
|
|
45
|
+
DistributorID?: number,
|
|
46
|
+
IsDistributedQueue?: boolean,
|
|
47
|
+
AnsweredAgent?: string,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface ExtensionCall {
|
|
51
|
+
callStarted: number,
|
|
52
|
+
calldurationinterval: number,
|
|
53
|
+
callAnswered: number,
|
|
54
|
+
answered: number,
|
|
55
|
+
callername: string,
|
|
56
|
+
callerphone: string,
|
|
57
|
+
outgoingcallername?: string,
|
|
58
|
+
outgoingcallerphone?: string,
|
|
59
|
+
callstatus: CallStatusEnum,
|
|
60
|
+
customdata: CustomData,
|
|
61
|
+
direction: DirectionEnum,
|
|
62
|
+
ivrid: string,
|
|
63
|
+
recording: Recording,
|
|
64
|
+
did: string,
|
|
65
|
+
relatedIvrUniqueIDs?: string[],
|
|
66
|
+
callType?: CallTypeEnum,
|
|
67
|
+
ip: string,
|
|
68
|
+
isInternal: boolean
|
|
69
|
+
blcServerID: number,
|
|
70
|
+
isOpensips: boolean,
|
|
71
|
+
channel: string,
|
|
72
|
+
channel2: string,
|
|
73
|
+
queueID?: number,
|
|
74
|
+
isSpyed?: boolean,
|
|
75
|
+
blcServerId?: number,
|
|
76
|
+
originalCallerID?: string,
|
|
77
|
+
originalCallerName?: string,
|
|
78
|
+
actualDialedNumber?: number
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface QueueCall {
|
|
82
|
+
CallerID: string,
|
|
83
|
+
CallerName: string,
|
|
84
|
+
IvrUniqueID: string,
|
|
85
|
+
JoinTimeStamp: number,
|
|
86
|
+
calldurationinterval: number,
|
|
87
|
+
ivrid: string,
|
|
88
|
+
isDistributedQueue?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface Summery {
|
|
92
|
+
representative: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface CustomData {
|
|
96
|
+
DoNotCallMeStatus?: string,
|
|
97
|
+
DoNotCallMeStatusCode?: DoNotCallMeStatusCodeEnum,
|
|
98
|
+
DoNotCallMeTokenName?: string,
|
|
99
|
+
DoNotCallMetransactionId?: string,
|
|
100
|
+
IsDoNotCallMe?: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface Recording {
|
|
104
|
+
Filename: string,
|
|
105
|
+
Options: string,
|
|
106
|
+
ApproximateURL: string,
|
|
107
|
+
IsMuted: number
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EventNameEnum,
|
|
3
|
+
EventsEnum,
|
|
4
|
+
ExtensionEventReasonEnum,
|
|
5
|
+
ExtensionHangupCauseEnum,
|
|
6
|
+
QueueEventReasonEnum
|
|
7
|
+
} from '@/enum/events.enum'
|
|
8
|
+
import { Queue, Extension, Dialer, User } from '@/types/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 keep alive response event.
|
|
86
|
+
*/
|
|
87
|
+
export interface KeepAliveResponseEvent extends CommonEventProperties {
|
|
88
|
+
isOk: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface OnlineStatusEvent {
|
|
92
|
+
isSocketConnected: boolean
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Mapping of event names to their respective data structures.
|
|
97
|
+
*/
|
|
98
|
+
export interface EventDataMap {
|
|
99
|
+
[EventsEnum.ALL_EXTENSION_STATUS]: AllExtensionStatusEvent
|
|
100
|
+
[EventsEnum.ALL_DIALER_STATUS]: AllDialersStatusEvent
|
|
101
|
+
[EventsEnum.ALL_USERS_STATUS]: AllUsersStatusEvent
|
|
102
|
+
[EventsEnum.QUEUE_EVENT]: QueueEvent
|
|
103
|
+
[EventsEnum.EXTENSION_EVENT]: ExtensionEvent
|
|
104
|
+
[EventsEnum.LOGIN_SUCCESS]: LoginSuccessEvent
|
|
105
|
+
[EventsEnum.LOGIN_STATUS]: LoginStatusEvent
|
|
106
|
+
[EventsEnum.KEEP_ALIVE_RESPONSE]: KeepAliveResponseEvent
|
|
107
|
+
[EventsEnum.ONLINE_STATUS_EVENT]: OnlineStatusEvent
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Represents the set of all possible event type names as keys from the EventDataMap.
|
|
112
|
+
* This type is used to define event listeners and handlers.
|
|
113
|
+
*/
|
|
114
|
+
type EventTypeNames = keyof EventDataMap
|
|
115
|
+
|
|
116
|
+
// Generic structure for wrapped socket event data
|
|
117
|
+
type WrappedSocketEvent<T extends EventsEnum> = {
|
|
118
|
+
name: T
|
|
119
|
+
data: EventDataMap[T]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Generic type for event type data
|
|
123
|
+
export type EventTypeData<T extends EventsEnum> = EventDataMap[T]
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Defines a registry of callback functions for each event type.
|
|
127
|
+
* Each key is an event type name, and the value is a function that takes the specific event data type as an argument.
|
|
128
|
+
* This registry is used to manage and invoke event-specific callbacks.
|
|
129
|
+
*/
|
|
130
|
+
export type EventCallbackRegistry = {
|
|
131
|
+
[K in EventTypeNames]: (data: EventDataMap[K]) => void
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* This is a generic type for callback functions used in event handling.
|
|
136
|
+
* It takes a generic event name and defines a callback function that receives wrapped socket event data for that specific event.
|
|
137
|
+
*/
|
|
138
|
+
export type EventSpecificCallback<T extends EventTypeNames> = (data: WrappedSocketEvent<T>) => void
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 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.
|
|
142
|
+
* This structure is used to manage event listeners for different events
|
|
143
|
+
*/
|
|
144
|
+
export type EventCallbackListenersMap = {
|
|
145
|
+
[K in EventTypeNames]: Array<EventSpecificCallback<K>>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* This type represents a mapping of listener event names to their corresponding wrapped socket event data structures.
|
|
150
|
+
* Each key is an event name, and the value is the wrapped socket event data for that event
|
|
151
|
+
*/
|
|
152
|
+
type EventWrappedSocketDataMap = {
|
|
153
|
+
[K in EventTypeNames]: WrappedSocketEvent<K>
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A generic type that represents the structure of any event data wrapped in a socket event format.
|
|
158
|
+
* This type is used in the handling of all event types, providing a consistent structure for event data processing.
|
|
159
|
+
*/
|
|
160
|
+
export type GenericEventWrapper = EventWrappedSocketDataMap[EventTypeNames]
|
|
@@ -0,0 +1,37 @@
|
|
|
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]
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"host":"localhost:3000","info":{"title":"admin-api","contact":{},"version":"0.01","description":"irst Alpha - Hope it will wok for yall :-)","termsOfService":""},"paths":{"/Account/List/":{"post":{"tags":["Account"],"security":[{"AdminAuthentication":["Admin"]}],"responses":{"200":{"schema":{"$ref":"#/definitions/AccountListResponse"},"description":"Status 200"},"400":{"schema":{"$ref":"#/definitions/Error"},"description":"Error Response"}},"parameters":[{"in":"body","name":"RequestBody","schema":{"$ref":"#/definitions/AccountListRequest"},"description":"Searching for Account that meets the query. multiple values are support. multiple selections in same feild will be treated as OR, multiple feilds will be searched with OR between them."}],"x-AuthType":["Admin"],"operationId":"AccountList","x-serviceID":3,"x-methodName":"List","x-serviceName":"Account"}},"/Account/Update/":{"post":{"tags":["Account"],"security":[{"AdminAuthentication":["Admin"]}],"responses":{"200":{"schema":{"$ref":"#/definitions/Response"},"description":"Status 200"},"400":{"schema":{"$ref":"#/definitions/Error"},"description":"Error Response"}},"parameters":[],"x-AuthType":["Admin"],"operationId":"AccountUpdate","x-serviceID":3,"x-methodName":"Update","x-serviceName":"Account"}}},"schemes":["https"],"swagger":"2.0","basePath":"/v1","consumes":["application/json"],"produces":["application/json"],"definitions":{"Error":{"type":"object","required":["Description","Status"],"properties":{"Status":{"type":"integer","example":400,"description":"Code of the Error"},"Description":{"type":"string","example":"Not found","description":"Textual description of the error"},"ReasonPhrase":{"type":"string","example":"ID not valid","description":"Specific reason for the error"}}},"Response":{"type":"object","required":["Description","ReasonPhrase","Status"],"properties":{"Status":{"type":"integer","example":200,"description":"Code of response"},"Description":{"type":"string","example":"OK","description":"Description of response"},"ReasonPhrase":{"type":"string","description":"Data of response"}}},"AccountAdd":{"type":"object","properties":{}},"ProviderAdd":{"type":"object","properties":{}},"ProviderDisable":{"type":"object","properties":{}},"ProvidersAddList":{"type":"object","properties":{}},"ProviderPrefixAdd":{"type":"object","properties":{}},"AccountListRequest":{"type":"object","properties":{}},"AccountListResponse":{"type":"object","properties":{}},"ProviderListResponse":{"type":"object","properties":{}},"ProviderPrefixUpdate":{"type":"object","properties":{}},"ProvidersDisableList":{"type":"object","properties":{}},"ProviderPrefixAddList":{"type":"object","properties":{}},"ProviderPrefixUpdateList":{"type":"object","properties":{}},"ProviderPrefixBulkRequest":{"type":"object","properties":{}},"ProviderPrefixBulkResponse":{"type":"object","properties":{}},"ProviderPrefixListResponse":{"type":"object","properties":{}},"ProviderPrefixUpdateResponse":{"type":"object","properties":{}}},"securityDefinitions":{}}
|
package/swagger/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import fastify from 'fastify'
|
|
3
|
+
import fastifySwagger from 'fastify-swagger'
|
|
4
|
+
import openapiGlue from 'fastify-openapi-glue'
|
|
5
|
+
|
|
6
|
+
const app = fastify()
|
|
7
|
+
|
|
8
|
+
const start = async () => {
|
|
9
|
+
try {
|
|
10
|
+
if (!fs.existsSync('./generated/Swagger.json')) {
|
|
11
|
+
console.log('Swagger.json file not generated. Try to run: npm run update')
|
|
12
|
+
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const swagger = JSON.parse(fs.readFileSync('./generated/Swagger.json').toString())
|
|
17
|
+
|
|
18
|
+
const swaggerOptions = {
|
|
19
|
+
routePrefix: '/documentation',
|
|
20
|
+
exposeRoute: true,
|
|
21
|
+
swagger: {
|
|
22
|
+
...swagger,
|
|
23
|
+
schemes: [ 'https', 'http' ],
|
|
24
|
+
securityDefinitions: {
|
|
25
|
+
JWT: {
|
|
26
|
+
type: 'apiKey',
|
|
27
|
+
name: 'Authorization',
|
|
28
|
+
in: 'header'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
security: [ { JWT: [] } ]
|
|
32
|
+
},
|
|
33
|
+
uiConfig: {
|
|
34
|
+
docExpansion: 'full',
|
|
35
|
+
deepLinking: false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const openapiGlueOptions = {
|
|
40
|
+
specification: './generated/Swagger.json',
|
|
41
|
+
service: {},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
app.register(fastifySwagger, swaggerOptions)
|
|
45
|
+
|
|
46
|
+
app.register(openapiGlue, openapiGlueOptions)
|
|
47
|
+
|
|
48
|
+
await app.listen({
|
|
49
|
+
port: 3000
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
console.log('Server is running on port: 3000')
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error('Error starting server:', err)
|
|
55
|
+
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
start()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "swagger",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"update": "node scripts/update-swagger-json.js",
|
|
9
|
+
"start": "node index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@fastify/swagger": "^8.13.0",
|
|
16
|
+
"@voicenter-team/mysql-dynamic-cluster": "^3.0.5",
|
|
17
|
+
"fastify": "^3.19.1",
|
|
18
|
+
"fastify-swagger": "^4.8.3",
|
|
19
|
+
"fastify-openapi-glue": "git+https://github.com/VoicenterTeam/fastify-openapi-glue.git"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import mysql from '@voicenter-team/mysql-dynamic-cluster'
|
|
3
|
+
|
|
4
|
+
const connection = mysql.createPoolCluster({
|
|
5
|
+
clusterName: 'demo',
|
|
6
|
+
hosts: [
|
|
7
|
+
{
|
|
8
|
+
host: '192.168.187.22',
|
|
9
|
+
port: 3306,
|
|
10
|
+
name: 'lab22',
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
// Configuration for all pools
|
|
14
|
+
defaultPoolSettings: {
|
|
15
|
+
user: 'api',
|
|
16
|
+
password: 'SecretAPI35t478p3!!!',
|
|
17
|
+
database: 'voicenter_core',
|
|
18
|
+
docsDatabase: 'monitor_events_api_doc',
|
|
19
|
+
charset: 'utf8mb4',
|
|
20
|
+
port: 3313,
|
|
21
|
+
// validators: [],
|
|
22
|
+
// loadFactors: [],
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const pathToFile = 'generated/'
|
|
27
|
+
const filename = 'Swagger.json'
|
|
28
|
+
const fullPath = pathToFile + filename
|
|
29
|
+
|
|
30
|
+
const generate = async () => {
|
|
31
|
+
await connection.connect()
|
|
32
|
+
|
|
33
|
+
const results = await connection.query('SELECT monitor_events_api_doc.FN_GetSwagger(0.01) as data')
|
|
34
|
+
|
|
35
|
+
const targetResult = results[0].data
|
|
36
|
+
|
|
37
|
+
console.log(targetResult)
|
|
38
|
+
|
|
39
|
+
const targetResultString = JSON.stringify(targetResult)
|
|
40
|
+
|
|
41
|
+
if (!fs.existsSync(pathToFile)) {
|
|
42
|
+
fs.mkdirSync(pathToFile, { recursive: true })
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fs.writeFile(fullPath, targetResultString, (err) => {
|
|
46
|
+
if (err) throw err
|
|
47
|
+
console.log('Swagger.json is updated!')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
await connection.disconnect()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
generate().then(data => console.log(data))
|