@voicenter-team/events-sdk 0.0.12 → 0.0.14
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 +17 -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/index.d.ts +689 -11
- package/dist/voicenter-events-sdk.cjs.js +10 -10
- package/dist/voicenter-events-sdk.cjs.js.map +1 -1
- package/dist/voicenter-events-sdk.es.js +1856 -1818
- package/dist/voicenter-events-sdk.es.js.map +1 -1
- package/dist/voicenter-events-sdk.iife.js +17 -17
- package/dist/voicenter-events-sdk.iife.js.map +1 -1
- package/dist/voicenter-events-sdk.umd.js +16 -16
- package/dist/voicenter-events-sdk.umd.js.map +1 -1
- 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 +191 -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/interface.ts +261 -0
- package/jest.config.js +11 -0
- package/package.json +1 -4
- package/src/classes/auth/auth.class.ts +272 -0
- package/src/classes/auth/auth.urls.ts +8 -0
- package/src/classes/events-sdk/events-sdk-default-options.ts +60 -0
- package/src/classes/events-sdk/events-sdk.class.ts +250 -0
- package/src/classes/events-sdk/events-sdk.test.ts +9 -0
- package/src/classes/events-sdk/events-sdk.types.ts +71 -0
- package/src/classes/socket-io/socket-io.class.ts +172 -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/classes/storage/storage.class.ts +43 -0
- package/src/enum/auth.enum.ts +4 -0
- package/src/enum/events.enum.ts +98 -0
- package/src/index.ts +15 -0
- package/{dist → src}/types/auth.d.ts +12 -8
- package/{dist → src}/types/events.common.d.ts +1 -1
- package/{dist → src}/types/events.d.ts +1 -1
- package/{dist → src}/types/socket.d.ts +1 -1
- 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 +47 -0
- package/vite.config.ts +45 -0
- package/dist/classes/auth/auth.class.d.ts +0 -20
- package/dist/classes/auth/auth.urls.d.ts +0 -4
- package/dist/classes/events-sdk/events-sdk-default-options.d.ts +0 -2
- package/dist/classes/events-sdk/events-sdk.class.d.ts +0 -35
- package/dist/classes/events-sdk/events-sdk.test.d.ts +0 -1
- package/dist/classes/events-sdk/events-sdk.types.d.ts +0 -63
- package/dist/classes/socket-io/socket-io.class.d.ts +0 -23
- package/dist/classes/socket-io/versions/index.d.ts +0 -8
- package/dist/classes/storage/storage.class.d.ts +0 -6
- package/dist/enum/auth.enum.d.ts +0 -4
- package/dist/enum/events.enum.d.ts +0 -77
- /package/{dist → src}/classes/socket-io/socket-io.d.ts +0 -0
- /package/{dist → src}/types/listeners.d.ts +0 -0
- /package/{dist → src}/types/public-api.d.ts +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LoginSessionData } from '@/types/auth'
|
|
2
|
+
|
|
3
|
+
export class StorageClass{
|
|
4
|
+
public static async getSessionStorageDataByKey (key: string): Promise<LoginSessionData | undefined> {
|
|
5
|
+
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') {
|
|
6
|
+
const loginSessionKey = await chrome.storage.session.get(key)
|
|
7
|
+
|
|
8
|
+
if (loginSessionKey[key]) {
|
|
9
|
+
return JSON.parse(loginSessionKey[key])
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
const loginSessionKey = window.sessionStorage.getItem(key)
|
|
15
|
+
|
|
16
|
+
if (loginSessionKey) {
|
|
17
|
+
return JSON.parse(loginSessionKey)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static async updateSessionStorageKey (key: string, storageData: Partial<LoginSessionData>) {
|
|
23
|
+
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') {
|
|
24
|
+
await chrome.storage.session.set({
|
|
25
|
+
[key]: JSON.stringify(storageData)
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof window !== 'undefined') {
|
|
30
|
+
window.sessionStorage.setItem(key, JSON.stringify(storageData))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public static clearSessionStorage () {
|
|
35
|
+
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined') {
|
|
36
|
+
chrome.storage.session.clear()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof window !== 'undefined') {
|
|
40
|
+
window.sessionStorage.clear()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
DIALER_EVENT = 'DialerEvent',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* All the reasons for the extension event, e.g. a new call is ringing or dialing from an extension.
|
|
28
|
+
*/
|
|
29
|
+
export enum ExtensionEventReasonEnum {
|
|
30
|
+
// A new call is ringing or dialing from an extension.
|
|
31
|
+
NEW_CALL = 'NEWCALL',
|
|
32
|
+
// A call was answered at an extension.
|
|
33
|
+
ANSWER = 'ANSWER',
|
|
34
|
+
// A call was placed on hold.
|
|
35
|
+
HOLD = 'HOLD',
|
|
36
|
+
// A call is no longer on hold.
|
|
37
|
+
UNHOLD = 'UNHOLD',
|
|
38
|
+
// When a call was ended. It is not necessarily means that the call was answered.
|
|
39
|
+
HANGUP = 'HANGUP',
|
|
40
|
+
// When the extension online user updated his\her user status(Login, Break, Logout, etc.)
|
|
41
|
+
USER_STATUS_UPDATE = 'userStatusUpdate',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export enum QueueEventReasonEnum {
|
|
45
|
+
ANSWER = 'ANSWER',
|
|
46
|
+
ABANDONED = 'ABANDONED',
|
|
47
|
+
EXIT = 'EXIT',
|
|
48
|
+
JOIN = 'JOIN'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export enum DialerType {
|
|
52
|
+
AUTOMATIC = 'Automatic',
|
|
53
|
+
IVR = 'IVR'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* All the eventNames that can be received from the server. Exists only in EXTENSION_EVENT and QueueEvent
|
|
58
|
+
*/
|
|
59
|
+
export enum EventNameEnum {
|
|
60
|
+
EXTENSION = 'extension',
|
|
61
|
+
QUEUE = 'queue',
|
|
62
|
+
DIALER = 'dialer',
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export enum ExtensionHangupCauseEnum {
|
|
66
|
+
NORMAL_HANGUP = 'Normal hangup',
|
|
67
|
+
USER_BUSY = 'User busy',
|
|
68
|
+
CALL_REJECTED = 'Call Rejected',
|
|
69
|
+
UNALLOCATED_NUMBER = 'Unallocated (unassigned) number',
|
|
70
|
+
UNKNOWN = 'Unknown',
|
|
71
|
+
NO_USER_RESPONDING = 'No user responding',
|
|
72
|
+
USER_ALERTING = 'User alerting, no answer',
|
|
73
|
+
ANSWERED_ELSEWHERE = 'Answered elsewhere'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export enum CallStatusEnum {
|
|
77
|
+
RINGING = 'Ringing',
|
|
78
|
+
TALKING = 'Talking',
|
|
79
|
+
DIALING = 'Dialing',
|
|
80
|
+
HOLD = 'Hold',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export enum CallTypeEnum {
|
|
84
|
+
INCOMING = 'Incoming',
|
|
85
|
+
OUTGOING = 'Outgoing'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export enum DoNotCallMeStatusCodeEnum {
|
|
89
|
+
RESPONSE_FROM_API_VALID = 'RESPONSE_FROM_API_VALID',
|
|
90
|
+
RESPONSE_FROM_API_INVALID = 'RESPONSE_FROM_API_INVALID'
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export enum DirectionEnum {
|
|
94
|
+
INCOMING = 'Incoming',
|
|
95
|
+
OUTGOING = 'Outgoing',
|
|
96
|
+
SPY = 'Spy',
|
|
97
|
+
CLICK2CALL = 'Click2call'
|
|
98
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import EventsSdkClass from '@/classes/events-sdk/events-sdk.class'
|
|
2
|
+
import { EventsEnum } from '@/enum/events.enum'
|
|
3
|
+
|
|
4
|
+
// Export all types and enums
|
|
5
|
+
export type * from './types/auth'
|
|
6
|
+
export type * from './types/events.common'
|
|
7
|
+
export type * from './types/events'
|
|
8
|
+
export type * from './types/listeners'
|
|
9
|
+
export type * from './types/public-api'
|
|
10
|
+
export type * from './types/socket'
|
|
11
|
+
export type * from './classes/events-sdk/events-sdk.types'
|
|
12
|
+
|
|
13
|
+
export { EventsEnum }
|
|
14
|
+
|
|
15
|
+
export default EventsSdkClass
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Server } from '
|
|
2
|
-
import { LoginType } from '
|
|
1
|
+
import { Server } from '@/classes/events-sdk/events-sdk.types'
|
|
2
|
+
import { LoginType } from '@/enum/auth.enum'
|
|
3
3
|
|
|
4
4
|
export interface LoginSessionPayload {
|
|
5
5
|
token: string,
|
|
@@ -14,15 +14,19 @@ export interface ExternalLoginRequestBody {
|
|
|
14
14
|
token?: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
interface
|
|
17
|
+
export interface ExternalLoginResponse<T> {
|
|
18
|
+
StatusCode: number,
|
|
19
|
+
Status: string,
|
|
20
|
+
Data: T
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ExternalLoginNewStackResponseData {
|
|
18
24
|
AccessToken: string,
|
|
19
25
|
RefreshToken: string
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Status: string,
|
|
25
|
-
Data: ExternalLoginResponseData
|
|
28
|
+
interface ExternalLoginOldStackResponseData {
|
|
29
|
+
Socket: Socket,
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
export interface Socket {
|
|
@@ -46,4 +50,4 @@ export interface Settings {
|
|
|
46
50
|
MonitorList: Server[]
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
export interface LoginSessionData extends Settings,
|
|
53
|
+
export interface LoginSessionData extends Settings, ExternalLoginNewStackResponseData, Socket {}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CallStatusEnum, CallTypeEnum, DialerType, DirectionEnum, DoNotCallMeStatusCodeEnum } from '
|
|
1
|
+
import { CallStatusEnum, CallTypeEnum, DialerType, DirectionEnum, DoNotCallMeStatusCodeEnum } from '@/enum/events.enum'
|
|
2
2
|
|
|
3
3
|
export interface Dialer {
|
|
4
4
|
campaignID: number,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ExtensionHangupCauseEnum,
|
|
6
6
|
QueueEventReasonEnum
|
|
7
7
|
} from '@/enum/events.enum'
|
|
8
|
-
import { Queue, Extension, Dialer, User } from '
|
|
8
|
+
import { Queue, Extension, Dialer, User } from '@/types/events.common'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Base structure for all event types, containing common properties.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client'
|
|
2
|
-
import { EventCallbackRegistry } from '
|
|
2
|
+
import { EventCallbackRegistry } from '@/types/events'
|
|
3
3
|
import { EventsEnum } from 'enum/events.enum'
|
|
4
4
|
|
|
5
5
|
export type SocketTyped = Socket<EventCallbackRegistry, Record<EventsEnum, any>>
|
|
@@ -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))
|