@wxcc-desktop/sdk 1.2.6 → 1.2.10

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.
Files changed (67) hide show
  1. package/README.md +18 -391
  2. package/dist/index.js +1 -0
  3. package/dist/types/index.d.ts +21 -0
  4. package/dist/types/jsapi/actions-jsapi.d.ts +33 -0
  5. package/dist/types/jsapi/agent-contact-jsapi.d.ts +430 -0
  6. package/dist/types/jsapi/agent-state-info-jsapi.d.ts +88 -0
  7. package/dist/types/jsapi/common/_logger.d.ts +4 -0
  8. package/dist/types/jsapi/common/_service-checker.d.ts +12 -0
  9. package/dist/types/jsapi/common/_service-events.d.ts +31 -0
  10. package/dist/types/jsapi/config-jsapi.d.ts +26 -0
  11. package/dist/types/jsapi/dialer-jsapi.d.ts +73 -0
  12. package/dist/types/jsapi/i18n-jsapi.d.ts +23 -0
  13. package/dist/types/jsapi/logger-jsapi.d.ts +19 -0
  14. package/dist/types/jsapi/screenpop-jsapi.d.ts +29 -0
  15. package/dist/types/jsapi/shortcut-key-jsapi.d.ts +67 -0
  16. package/dist/types/sdk.d.ts +1 -0
  17. package/package.json +5 -60
  18. package/.eslintignore +0 -5
  19. package/.eslintrc.js +0 -22
  20. package/.prettierignore +0 -5
  21. package/.prettierrc +0 -5
  22. package/README_PUBLISH.md +0 -36
  23. package/jenkins-automation/MergePipeline.groovy +0 -143
  24. package/jest.config.js +0 -15
  25. package/sonar-project.properties +0 -17
  26. package/src/[sandbox]/README.md +0 -55
  27. package/src/[sandbox]/assets/i18n/de/app.json +0 -6
  28. package/src/[sandbox]/assets/i18n/en/app.json +0 -6
  29. package/src/[sandbox]/assets/i18n/widget-using-js-api/de/widget-using-js-api.json +0 -5
  30. package/src/[sandbox]/assets/i18n/widget-using-js-api/en/widget-using-js-api.json +0 -5
  31. package/src/[sandbox]/favicon.ico +0 -0
  32. package/src/[sandbox]/index.html +0 -9
  33. package/src/[sandbox]/sandbox-config.ts +0 -23
  34. package/src/[sandbox]/sandbox-mock.ts +0 -218
  35. package/src/[sandbox]/sandbox.ts +0 -164
  36. package/src/[sandbox]/widget-using-js-api.ts +0 -658
  37. package/src/global.d.ts +0 -5
  38. package/src/index.ts +0 -101
  39. package/src/jsapi/actions-jsapi.test.ts +0 -155
  40. package/src/jsapi/actions-jsapi.ts +0 -410
  41. package/src/jsapi/agent-contact-jsapi.test.ts +0 -217
  42. package/src/jsapi/agent-contact-jsapi.ts +0 -275
  43. package/src/jsapi/agent-state-info-jsapi.test.ts +0 -176
  44. package/src/jsapi/agent-state-info-jsapi.ts +0 -288
  45. package/src/jsapi/common/_logger.test.ts +0 -16
  46. package/src/jsapi/common/_logger.ts +0 -9
  47. package/src/jsapi/common/_service-checker.test.ts +0 -44
  48. package/src/jsapi/common/_service-checker.ts +0 -28
  49. package/src/jsapi/common/_service-events.test.ts +0 -122
  50. package/src/jsapi/common/_service-events.ts +0 -156
  51. package/src/jsapi/config-jsapi.test.ts +0 -78
  52. package/src/jsapi/config-jsapi.ts +0 -106
  53. package/src/jsapi/dialer-jsapi.test.ts +0 -101
  54. package/src/jsapi/dialer-jsapi.ts +0 -116
  55. package/src/jsapi/i18n-jsapi.test.ts +0 -62
  56. package/src/jsapi/i18n-jsapi.ts +0 -77
  57. package/src/jsapi/logger-jsapi.test.ts +0 -45
  58. package/src/jsapi/logger-jsapi.ts +0 -62
  59. package/src/jsapi/screenpop-jsapi.test.ts +0 -80
  60. package/src/jsapi/screenpop-jsapi.ts +0 -100
  61. package/src/jsapi/shortcut-key-jsapi.test.ts +0 -88
  62. package/src/jsapi/shortcut-key-jsapi.ts +0 -112
  63. package/src/sdk.ts +0 -3
  64. package/src/tsconfig.json +0 -18
  65. package/tsconfig.json +0 -13
  66. package/webpack.config.dev.server.ts +0 -12
  67. package/webpack.config.ts +0 -134
package/src/index.ts DELETED
@@ -1,101 +0,0 @@
1
- import { createActionsJsApi } from "./jsapi/actions-jsapi";
2
- import { createAgentContactJsApi } from "./jsapi/agent-contact-jsapi";
3
- import { createAgentStateInfoJsApi } from "./jsapi/agent-state-info-jsapi";
4
- import { createConfigJsApi } from "./jsapi/config-jsapi";
5
- import { createDialerJsApi } from "./jsapi/dialer-jsapi";
6
- import { createI18NJsApi } from "./jsapi/i18n-jsapi";
7
- import { createLoggerJsApi } from "./jsapi/logger-jsapi";
8
- import { createScreenPopJsApi } from "./jsapi/screenpop-jsapi";
9
- import { createShortcutKeyJsApi } from "./jsapi/shortcut-key-jsapi";
10
-
11
- import { logger as _logger } from "./sdk";
12
-
13
- export type AgentXJsApi = {
14
- config: ReturnType<typeof createConfigJsApi>;
15
- logger: ReturnType<typeof createLoggerJsApi>;
16
- shortcutKey: ReturnType<typeof createShortcutKeyJsApi>;
17
-
18
- // AQM Services
19
- agentContact: ReturnType<typeof createAgentContactJsApi>;
20
- agentStateInfo: ReturnType<typeof createAgentStateInfoJsApi>;
21
- dialer: ReturnType<typeof createDialerJsApi>;
22
- screenpop: ReturnType<typeof createScreenPopJsApi>;
23
-
24
- // Services
25
- i18n: ReturnType<typeof createI18NJsApi>;
26
- actions: ReturnType<typeof createActionsJsApi>;
27
- };
28
-
29
- // JSAPI Root factory
30
- const createAgentXJsApi = (): AgentXJsApi => {
31
- /**
32
- * WARNING! Temporary injecting SERVICE into constructor via global object
33
- */
34
- if (AGENTX_SERVICE) {
35
- _logger.info(`Found global "AGENTX_SERVICE"!`);
36
- } else {
37
- _logger.error(`Missed global "AGENTX_SERVICE"...`);
38
- }
39
-
40
- // JSAPI Modules instances
41
- // Main config
42
- const config = createConfigJsApi(AGENTX_SERVICE);
43
-
44
- const logger = createLoggerJsApi();
45
- const shortcutKey = createShortcutKeyJsApi();
46
- const actions = createActionsJsApi();
47
-
48
- // AQM Services
49
- const agentStateInfo = createAgentStateInfoJsApi();
50
-
51
- const agentContact = createAgentContactJsApi();
52
-
53
- const dialer = createDialerJsApi();
54
-
55
- const screenpop = createScreenPopJsApi();
56
-
57
- // Services
58
- const i18n = createI18NJsApi();
59
-
60
- config.addEventListener("inited", () => {
61
- // AQM/Notis dependent
62
- agentContact.init(AGENTX_SERVICE);
63
- agentStateInfo.init(AGENTX_SERVICE);
64
- dialer.init(AGENTX_SERVICE);
65
- screenpop.init(AGENTX_SERVICE);
66
-
67
- // Service dependent
68
- shortcutKey.init(AGENTX_SERVICE);
69
- actions.init(AGENTX_SERVICE);
70
- i18n.init(AGENTX_SERVICE);
71
- });
72
-
73
- config.addEventListener("cleaned", () => {
74
- // AQM/Notis dependent
75
- agentContact.cleanup();
76
- agentStateInfo.cleanup();
77
- dialer.cleanup();
78
- screenpop.cleanup();
79
-
80
- // Service dependent
81
- shortcutKey.cleanup();
82
- i18n.cleanup();
83
- actions.cleanup();
84
- });
85
-
86
- return {
87
- config,
88
- logger,
89
- shortcutKey,
90
- actions,
91
-
92
- agentContact,
93
- agentStateInfo,
94
- dialer,
95
- screenpop,
96
-
97
- i18n
98
- };
99
- };
100
-
101
- export const Desktop = createAgentXJsApi();
@@ -1,155 +0,0 @@
1
- // @typescript-eslint/no-explicit-any
2
- import { AgentxServices, SERVICE } from "@wxcc-desktop/sdk-types";
3
- import { createActionsJsApi } from "./actions-jsapi";
4
-
5
- jest.mock("@wxcc-desktop/sdk-types", () => {
6
- const agentx_services_mock = {
7
- SERVICE: {
8
- isInited: false,
9
- init: async (accessToken: string) => {
10
- agentx_services_mock.SERVICE.isInited = true;
11
- },
12
- actionsChannels: ({
13
- createSource: jest.fn(),
14
- createDestination: jest.fn()
15
- } as unknown) as AgentxServices["actionsChannels"]
16
- } as AgentxServices
17
- };
18
- return agentx_services_mock;
19
- });
20
-
21
- describe("Actions JSAPI", () => {
22
- let actions: ReturnType<typeof createActionsJsApi>;
23
-
24
- beforeEach(async () => {
25
- await (SERVICE as AgentxServices).init("fake-token");
26
-
27
- actions = createActionsJsApi();
28
-
29
- actions.init(SERVICE);
30
-
31
- actions["sourceActionsChannels"] = {
32
- // One Way
33
- fireGeneralSilentNotification: { send: jest.fn() } as any,
34
- fireGeneralAutoDismissNotification: { send: jest.fn() } as any,
35
- fireGeneralAcknowledgeNotification: { send: jest.fn() } as any,
36
- addCustomTask: { send: jest.fn() } as any,
37
-
38
- // Two Way
39
- getToken: { send: jest.fn() } as any,
40
- getTaskMap: { send: jest.fn() } as any,
41
- getMediaTypeQueue: { send: jest.fn() } as any,
42
- getIdleCodes: { send: jest.fn() } as any,
43
- getWrapUpCodes: { send: jest.fn() } as any
44
- };
45
-
46
- actions["destinationActionsChannels"] = {
47
- // Two Way
48
- fireGeneralAutoDismissNotification: { addListener: jest.fn() } as any,
49
- fireGeneralAcknowledgeNotification: { addListener: jest.fn() } as any,
50
- getToken: { addListener: jest.fn() } as any,
51
- getTaskMap: { addListener: jest.fn() } as any,
52
- getMediaTypeQueue: { addListener: jest.fn() } as any,
53
- getIdleCodes: { addListener: jest.fn() } as any,
54
- getWrapUpCodes: { addListener: jest.fn() } as any
55
- };
56
- });
57
-
58
- it("creates", () => {
59
- expect(actions).toBeDefined();
60
- expect(actions["logger"]).toBeDefined();
61
- expect(actions["serviceChecker"]).toBeDefined();
62
- });
63
-
64
- it("inits", async () => {
65
- expect(actions["checkService"]()).toBeTruthy();
66
- expect(actions["sourceActionsChannels"]).toBeDefined();
67
- expect(actions["destinationActionsChannels"]).toBeDefined();
68
- });
69
-
70
- it("cleanups", async () => {
71
- actions.cleanup();
72
- expect(actions["SERVICE"]).toBeUndefined();
73
- });
74
-
75
- it("checks service", () => {
76
- actions["serviceChecker"].check = jest.fn();
77
- actions["checkService"]();
78
-
79
- expect(actions["serviceChecker"].check).toHaveBeenCalled();
80
- });
81
-
82
- it("generates next id", () => {
83
- const reqId = actions["getNextReqId"]();
84
- expect(reqId).toContain("_");
85
- });
86
-
87
- it("fireGeneralSilentNotification", () => {
88
- actions.fireGeneralSilentNotification({ test: "A" } as any);
89
- actions.fireGeneralSilentNotification({ test: "B" } as any);
90
-
91
- expect(actions["sourceActionsChannels"].fireGeneralSilentNotification.send).toHaveBeenCalledTimes(2);
92
- expect(actions["sourceActionsChannels"].fireGeneralSilentNotification.send).toHaveBeenLastCalledWith({ test: "B" });
93
- });
94
-
95
- it("fireGeneralAutoDismissNotification", () => {
96
- actions.fireGeneralAutoDismissNotification({ test: "A" } as any);
97
-
98
- expect(actions["sourceActionsChannels"].fireGeneralAutoDismissNotification.send).toHaveBeenCalledTimes(1);
99
- expect(actions["destinationActionsChannels"].fireGeneralAutoDismissNotification.addListener).toHaveBeenCalledTimes(
100
- 1
101
- );
102
- });
103
-
104
- it("fireGeneralAcknowledgeNotification", () => {
105
- actions.fireGeneralAcknowledgeNotification({ test: "A" } as any);
106
-
107
- expect(actions["sourceActionsChannels"].fireGeneralAcknowledgeNotification.send).toHaveBeenCalledTimes(1);
108
- expect(actions["destinationActionsChannels"].fireGeneralAcknowledgeNotification.addListener).toHaveBeenCalledTimes(
109
- 1
110
- );
111
- });
112
-
113
- it("addCustomTask", () => {
114
- actions.addCustomTask({ test: "A" } as any);
115
- actions.addCustomTask({ test: "B" } as any);
116
-
117
- expect(actions["sourceActionsChannels"].addCustomTask.send).toHaveBeenCalledTimes(2);
118
- expect(actions["sourceActionsChannels"].addCustomTask.send).toHaveBeenLastCalledWith({ test: "B" });
119
- });
120
-
121
- it("getTaskMap", () => {
122
- actions.getTaskMap();
123
-
124
- expect(actions["sourceActionsChannels"].getTaskMap.send).toHaveBeenCalledTimes(1);
125
- expect(actions["destinationActionsChannels"].getTaskMap.addListener).toHaveBeenCalledTimes(1);
126
- });
127
-
128
- it("getMediaTypeQueue", () => {
129
- actions.getMediaTypeQueue({} as any);
130
-
131
- expect(actions["sourceActionsChannels"].getMediaTypeQueue.send).toHaveBeenCalledTimes(1);
132
- expect(actions["destinationActionsChannels"].getMediaTypeQueue.addListener).toHaveBeenCalledTimes(1);
133
- });
134
-
135
- it("getToken", () => {
136
- actions.getToken();
137
-
138
- expect(actions["sourceActionsChannels"].getToken.send).toHaveBeenCalledTimes(1);
139
- expect(actions["destinationActionsChannels"].getToken.addListener).toHaveBeenCalledTimes(1);
140
- });
141
-
142
- it("getIdleCodes", () => {
143
- actions.getIdleCodes();
144
-
145
- expect(actions["sourceActionsChannels"].getIdleCodes.send).toHaveBeenCalledTimes(1);
146
- expect(actions["destinationActionsChannels"].getIdleCodes.addListener).toHaveBeenCalledTimes(1);
147
- });
148
-
149
- it("getWrapUpCodes", () => {
150
- actions.getWrapUpCodes();
151
-
152
- expect(actions["sourceActionsChannels"].getWrapUpCodes.send).toHaveBeenCalledTimes(1);
153
- expect(actions["destinationActionsChannels"].getWrapUpCodes.addListener).toHaveBeenCalledTimes(1);
154
- });
155
- });
@@ -1,410 +0,0 @@
1
- import { Notifications } from "@uuip/unified-ui-platform-sdk";
2
- // eslint-disable-next-line prettier/prettier
3
- import type {
4
- AgentContactSharedActions,
5
- AgentSharedActions,
6
- AuthSharedActions,
7
- GeneralNotificationsSharedActions
8
- } from "@wxcc-desktop/sdk-types";
9
- import { AgentxService, Service } from "@wxcc-desktop/sdk-types";
10
-
11
-
12
- import { logger } from "../sdk";
13
- import { createJsApiLogger } from "./common/_logger";
14
- import { createServiceChecker } from './common/_service-checker';
15
-
16
- const MAX_RPS = 120;
17
- const NO_RPS = 0;
18
- const SOURCE_TAG = "jsapi";
19
- const defaultSyncSourceOptions: Service.ActionChannel.SourceOptions = { rps: MAX_RPS, tag: SOURCE_TAG };
20
- const defaultAsyncSourceOptions: Service.ActionChannel.SourceOptions = { rps: NO_RPS, tag: SOURCE_TAG };
21
- const defaultDestinationOptions: Service.ActionChannel.DestinationOptions = { tag: SOURCE_TAG };
22
-
23
- // FireGeneralSilentNotification
24
- const createFireGeneralSilentNotificationActionChannelSource = (SERVICE: AgentxService) => {
25
- return SERVICE!.actionsChannels.createSource<GeneralNotificationsSharedActions.FireSilent.ReqActionName,
26
- GeneralNotificationsSharedActions.FireSilent.ReqPayloadParameters>("fireGeneralSilentNotification/Req", defaultSyncSourceOptions);
27
- };
28
-
29
- // FireGeneralAutoDismissNotification
30
- const createFireGeneralAutoDismissNotificationActionChannelSource = (SERVICE: AgentxService) => {
31
- return SERVICE!.actionsChannels.createSource<GeneralNotificationsSharedActions.FireAutoDismiss.ReqActionName,
32
- GeneralNotificationsSharedActions.FireAutoDismiss.ReqPayloadParameters>("fireGeneralAutoDismissNotification/Req", defaultAsyncSourceOptions);
33
- };
34
- const createFireGeneralAutoDismissNotificationActionChannelDestination = (SERVICE: AgentxService) => {
35
- return SERVICE!.actionsChannels.createDestination<GeneralNotificationsSharedActions.FireAutoDismiss.ResActionName,
36
- GeneralNotificationsSharedActions.FireAutoDismiss.ResPayloadParameters>("fireGeneralAutoDismissNotification/Res", defaultAsyncSourceOptions);
37
- };
38
-
39
- // FireGeneralAcknowledgeNotification
40
- const createFireGeneralAcknowledgeNotificationActionChannelSource = (SERVICE: AgentxService) => {
41
- return SERVICE!.actionsChannels.createSource<GeneralNotificationsSharedActions.FireAcknowledge.ReqActionName,
42
- GeneralNotificationsSharedActions.FireAcknowledge.ReqPayloadParameters>("fireGeneralAcknowledgeNotification/Req", defaultAsyncSourceOptions);
43
- };
44
- const createFireGeneralAcknowledgeNotificationActionChannelDestination = (SERVICE: AgentxService) => {
45
- return SERVICE!.actionsChannels.createDestination<GeneralNotificationsSharedActions.FireAcknowledge.ResActionName,
46
- GeneralNotificationsSharedActions.FireAcknowledge.ResPayloadParameters>("fireGeneralAcknowledgeNotification/Res", defaultAsyncSourceOptions);
47
- };
48
-
49
- // AddCustomTask
50
- const createAddCustomTaskActionChannelSource = (SERVICE: AgentxService) => {
51
- return SERVICE!.actionsChannels.createSource<AgentContactSharedActions.AddCustomContact.ReqActionName,
52
- AgentContactSharedActions.AddCustomContact.ReqPayloadParameters>("addCustomTask", defaultSyncSourceOptions);
53
- };
54
-
55
- // GetToken
56
- const createGetTokenActionChannelSource = (SERVICE: AgentxService) => {
57
- return SERVICE!.actionsChannels.createSource<AuthSharedActions.GetToken.ReqActionName,
58
- AuthSharedActions.GetToken.ReqPayloadParameters>("getToken/Req", defaultAsyncSourceOptions);
59
- };
60
-
61
- const createGetTokenActionChannelDestination = (SERVICE: AgentxService) => {
62
- return SERVICE!.actionsChannels.createDestination<AuthSharedActions.GetToken.ResActionName,
63
- AuthSharedActions.GetToken.ResPayloadParameters>("getToken/Res", defaultDestinationOptions);
64
- };
65
-
66
-
67
- // GetTaskMap
68
- const createGetTaskMapActionChannelSource = (SERVICE: AgentxService) => {
69
- return SERVICE!.actionsChannels.createSource<AgentContactSharedActions.GetTaskMap.ReqActionName,
70
- AgentContactSharedActions.GetTaskMap.ReqPayloadParameters>("getTaskMap/Req", defaultAsyncSourceOptions);
71
- };
72
-
73
- const createGetTaskMapActionChannelDestination = (SERVICE: AgentxService) => {
74
- return SERVICE!.actionsChannels.createDestination<AgentContactSharedActions.GetTaskMap.ResActionName,
75
- AgentContactSharedActions.GetTaskMap.ResPayloadParameters>("getTaskMap/Res", defaultDestinationOptions);
76
- };
77
-
78
- // GetMediaTypeQueue
79
- const createGetMediaTypeQueueActionChannelSource = (SERVICE: AgentxService) => {
80
- return SERVICE!.actionsChannels.createSource<AgentContactSharedActions.GetMediaTypeQueue.ReqActionName,
81
- AgentContactSharedActions.GetMediaTypeQueue.ReqPayloadParameters>("getMediaTypeQueue/Req", defaultAsyncSourceOptions);
82
- };
83
-
84
- const createGetMediaTypeQueueActionChannelDestination = (SERVICE: AgentxService) => {
85
- return SERVICE!.actionsChannels.createDestination<AgentContactSharedActions.GetMediaTypeQueue.ResActionName,
86
- AgentContactSharedActions.GetMediaTypeQueue.ResPayloadParameters>("getMediaTypeQueue/Res", defaultDestinationOptions);
87
- };
88
-
89
- // GetIdleCodes
90
- const createGetIdleCodesActionChannelSource = (SERVICE: AgentxService) => {
91
- return SERVICE!.actionsChannels.createSource<AgentSharedActions.GetIdleCodes.ReqActionName,
92
- AgentSharedActions.GetIdleCodes.ReqPayloadParameters>("getIdleCodes/Req", defaultAsyncSourceOptions);
93
- };
94
-
95
- const createGetIdleCodesActionChannelDestination = (SERVICE: AgentxService) => {
96
- return SERVICE!.actionsChannels.createDestination<AgentSharedActions.GetIdleCodes.ResActionName,
97
- AgentSharedActions.GetIdleCodes.ResPayloadParameters>("getIdleCodes/Res", defaultDestinationOptions);
98
- };
99
-
100
- // GetWrapUpCodes
101
- const createGetWrapUpCodesActionChannelSource = (SERVICE: AgentxService) => {
102
- return SERVICE!.actionsChannels.createSource<AgentSharedActions.GetWrapUpCodes.ReqActionName,
103
- AgentSharedActions.GetWrapUpCodes.ReqPayloadParameters>("getWrapUpCodes/Req", defaultAsyncSourceOptions);
104
- };
105
-
106
- const createGetWrapUpCodesActionChannelDestination = (SERVICE: AgentxService) => {
107
- return SERVICE!.actionsChannels.createDestination<AgentSharedActions.GetWrapUpCodes.ResActionName,
108
- AgentSharedActions.GetWrapUpCodes.ResPayloadParameters>("getWrapUpCodes/Res", defaultDestinationOptions);
109
- };
110
-
111
-
112
- type Config = { logger: ReturnType<typeof createJsApiLogger>; serviceChecker: ReturnType<typeof createServiceChecker> };
113
-
114
- export class ActionsJsApi {
115
- private readonly logger: Config["logger"];
116
-
117
- private readonly serviceChecker: Config["serviceChecker"];
118
-
119
- private SERVICE?: AgentxService;
120
-
121
- private sourceActionsChannels!: {
122
- // One Way
123
- fireGeneralSilentNotification: ReturnType<typeof createFireGeneralSilentNotificationActionChannelSource>;
124
- fireGeneralAutoDismissNotification: ReturnType<typeof createFireGeneralAutoDismissNotificationActionChannelSource>;
125
- fireGeneralAcknowledgeNotification: ReturnType<typeof createFireGeneralAcknowledgeNotificationActionChannelSource>;
126
- addCustomTask: ReturnType<typeof createAddCustomTaskActionChannelSource>;
127
-
128
- // Two Way
129
- getToken: ReturnType<typeof createGetTokenActionChannelSource>;
130
- getTaskMap: ReturnType<typeof createGetTaskMapActionChannelSource>;
131
- getMediaTypeQueue: ReturnType<typeof createGetMediaTypeQueueActionChannelSource>;
132
- getIdleCodes: ReturnType<typeof createGetIdleCodesActionChannelSource>;
133
- getWrapUpCodes: ReturnType<typeof createGetWrapUpCodesActionChannelSource>;
134
- };
135
-
136
- private destinationActionsChannels!: {
137
- // Two Way
138
- fireGeneralAutoDismissNotification: ReturnType<typeof createFireGeneralAutoDismissNotificationActionChannelDestination>;
139
- fireGeneralAcknowledgeNotification: ReturnType<typeof createFireGeneralAcknowledgeNotificationActionChannelDestination>;
140
- getToken: ReturnType<typeof createGetTokenActionChannelDestination>;
141
- getTaskMap: ReturnType<typeof createGetTaskMapActionChannelDestination>;
142
- getMediaTypeQueue: ReturnType<typeof createGetMediaTypeQueueActionChannelDestination>;
143
- getIdleCodes: ReturnType<typeof createGetIdleCodesActionChannelDestination>;
144
- getWrapUpCodes: ReturnType<typeof createGetWrapUpCodesActionChannelDestination>;
145
- };
146
-
147
- private checkService() {
148
- return this.serviceChecker.check(this.SERVICE);
149
- }
150
-
151
- private lastReqTs: number = Date.now();
152
- private lastReqN = 0;
153
-
154
- private getNextReqId() {
155
- const now = Date.now();
156
- if (this.lastReqTs !== now) {
157
- this.lastReqTs = now;
158
- this.lastReqN = 0;
159
- } else {
160
- this.lastReqN++;
161
- }
162
-
163
- return `${this.lastReqTs}_${this.lastReqN}`;
164
- }
165
-
166
- constructor(config: Config) {
167
- this.logger = config.logger;
168
- this.serviceChecker = config.serviceChecker;
169
- }
170
-
171
- init(SERVICE?: AgentxService) {
172
- if (SERVICE) {
173
- this.SERVICE = SERVICE;
174
- }
175
-
176
- if (!this.checkService()) {
177
- return;
178
- }
179
-
180
- this.sourceActionsChannels = {
181
- // One Way
182
- fireGeneralSilentNotification: createFireGeneralSilentNotificationActionChannelSource(this.SERVICE!),
183
- fireGeneralAutoDismissNotification: createFireGeneralAutoDismissNotificationActionChannelSource(this.SERVICE!),
184
- fireGeneralAcknowledgeNotification: createFireGeneralAcknowledgeNotificationActionChannelSource(this.SERVICE!),
185
- addCustomTask: createAddCustomTaskActionChannelSource(this.SERVICE!),
186
- // Two Way
187
- getToken: createGetTokenActionChannelSource(this.SERVICE!),
188
- getTaskMap: createGetTaskMapActionChannelSource(this.SERVICE!),
189
- getMediaTypeQueue: createGetMediaTypeQueueActionChannelSource(this.SERVICE!),
190
- getIdleCodes: createGetIdleCodesActionChannelSource(this.SERVICE!),
191
- getWrapUpCodes: createGetWrapUpCodesActionChannelSource(this.SERVICE!)
192
- };
193
-
194
- this.destinationActionsChannels = {
195
- // Two Way
196
- fireGeneralAutoDismissNotification: createFireGeneralAutoDismissNotificationActionChannelDestination(this.SERVICE!),
197
- fireGeneralAcknowledgeNotification: createFireGeneralAcknowledgeNotificationActionChannelDestination(this.SERVICE!),
198
- getToken: createGetTokenActionChannelDestination(this.SERVICE!),
199
- getTaskMap: createGetTaskMapActionChannelDestination(this.SERVICE!),
200
- getMediaTypeQueue: createGetMediaTypeQueueActionChannelDestination(this.SERVICE!),
201
- getIdleCodes: createGetIdleCodesActionChannelDestination(this.SERVICE!),
202
- getWrapUpCodes: createGetWrapUpCodesActionChannelDestination(this.SERVICE!)
203
- };
204
-
205
- this.logger.info("Inited");
206
- }
207
-
208
- cleanup() {
209
- this.SERVICE = undefined;
210
-
211
- this.logger.info("Cleaned");
212
- }
213
-
214
- // GENERAL SILENT NOTIFICATION FIRE
215
- fireGeneralSilentNotification(...args: GeneralNotificationsSharedActions.FireSilent.ReqPayloadParameters) {
216
- if (!this.checkService()) {
217
- return;
218
- }
219
- this.sourceActionsChannels.fireGeneralSilentNotification.send(...args);
220
- }
221
-
222
-
223
- // GENERAL AUTODISMISS NOTIFICATION FIRE
224
- async fireGeneralAutoDismissNotification(...args: GeneralNotificationsSharedActions.FireAutoDismiss.ReqPayloadParameters) {
225
- if (!this.checkService()) {
226
- return;
227
- }
228
- return await new Promise<GeneralNotificationsSharedActions.FireAutoDismiss.ResPayloadParameters>((resolve) => {
229
-
230
- const req_id = this.getNextReqId();
231
-
232
- const listener: Service.ActionChannel.Listener<GeneralNotificationsSharedActions.FireAutoDismiss.ResPayloadParameters> = ({ args: [status, reason, mode, res_id] }) => {
233
- if (res_id === req_id) {
234
-
235
- if (mode === Notifications.ItemMeta.Mode.AutoDismiss || mode === Notifications.ItemMeta.Mode.Silent /*May change due to settings*/) {
236
- if (status === Notifications.ItemMeta.Status.Deactivated) {
237
- resolve([status, reason, mode]);
238
- this.destinationActionsChannels.fireGeneralAutoDismissNotification.removeListener(listener);
239
- }
240
-
241
- }
242
- }
243
- };
244
-
245
- this.destinationActionsChannels.fireGeneralAutoDismissNotification.addListener(listener);
246
-
247
-
248
- this.sourceActionsChannels.fireGeneralAutoDismissNotification.send(...args);
249
- });
250
- }
251
-
252
- // GENERAL ACKNOWLEDGE NOTIFICATION FIRE
253
- async fireGeneralAcknowledgeNotification(...args: GeneralNotificationsSharedActions.FireAcknowledge.ReqPayloadParameters) {
254
- if (!this.checkService()) {
255
- return;
256
- }
257
- return await new Promise<GeneralNotificationsSharedActions.FireAcknowledge.ResPayloadParameters>((resolve) => {
258
-
259
- const req_id = this.getNextReqId();
260
-
261
- const listener: Service.ActionChannel.Listener<GeneralNotificationsSharedActions.FireAcknowledge.ResPayloadParameters> = ({ args: [status, reason, mode, res_id] }) => {
262
- if (res_id === req_id) {
263
-
264
- if (mode === Notifications.ItemMeta.Mode.Acknowledge || mode === Notifications.ItemMeta.Mode.Silent /*May change due to settings*/) {
265
- if (status === Notifications.ItemMeta.Status.Deactivated) {
266
- resolve([status, reason, mode]);
267
- this.destinationActionsChannels.fireGeneralAcknowledgeNotification.removeListener(listener);
268
- }
269
-
270
- }
271
- }
272
- };
273
-
274
- this.destinationActionsChannels.fireGeneralAcknowledgeNotification.addListener(listener);
275
-
276
-
277
- this.sourceActionsChannels.fireGeneralAcknowledgeNotification.send(...args);
278
- });
279
- }
280
-
281
- // AGENT CONTACT ADD CUSTOM TASK
282
- addCustomTask(...args: AgentContactSharedActions.AddCustomContact.ReqPayloadParameters) {
283
- if (!this.checkService()) {
284
- return;
285
- }
286
-
287
- this.sourceActionsChannels.addCustomTask.send(...args);
288
- }
289
-
290
- // AGENT CONTACT GET TASK MAP
291
- async getTaskMap() {
292
- if (!this.checkService()) {
293
- return;
294
- }
295
-
296
- return await new Promise<AgentContactSharedActions.GetTaskMap.AllTaskMap>((resolve) => {
297
- const req_id = this.getNextReqId();
298
-
299
- const listener: Service.ActionChannel.Listener<AgentContactSharedActions.GetTaskMap.ResPayloadParameters> = ({ args: [task_map, res_id] }) => {
300
- if (res_id === req_id) {
301
- resolve(task_map);
302
- this.destinationActionsChannels.getTaskMap.removeListener(listener);
303
- }
304
- };
305
-
306
- this.destinationActionsChannels.getTaskMap.addListener(listener);
307
-
308
- this.sourceActionsChannels.getTaskMap.send(req_id);
309
- });
310
- }
311
-
312
- // AGENT CONTACT GET MEDIA QUEUE
313
- async getMediaTypeQueue(mediaType: string) {
314
- if (!this.checkService()) {
315
- return;
316
- }
317
-
318
- return await new Promise<AgentContactSharedActions.GetMediaTypeQueue.MediaTypeTaskMap>((resolve) => {
319
- const req_id = this.getNextReqId();
320
-
321
- const listener: Service.ActionChannel.Listener<AgentContactSharedActions.GetMediaTypeQueue.ResPayloadParameters> = ({ args: [media_type_task_map, res_id] }) => {
322
- if (res_id === req_id) {
323
- resolve(media_type_task_map);
324
- this.destinationActionsChannels.getMediaTypeQueue.removeListener(listener);
325
- }
326
- };
327
-
328
- this.destinationActionsChannels.getMediaTypeQueue.addListener(listener);
329
-
330
- this.sourceActionsChannels.getMediaTypeQueue.send(mediaType as AgentContactSharedActions.GetMediaTypeQueue.QueueMediaType, req_id);
331
- });
332
- }
333
-
334
- // AUTH GET TOKEN
335
- async getToken() {
336
- if (!this.checkService()) {
337
- return;
338
- }
339
-
340
- return await new Promise<AuthSharedActions.GetToken.AccessToken>((resolve) => {
341
- const req_id = this.getNextReqId();
342
-
343
- const listener: Service.ActionChannel.Listener<AuthSharedActions.GetToken.ResPayloadParameters> = ({ args: [token, res_id] }) => {
344
- if (res_id === req_id) {
345
- resolve(token);
346
- this.destinationActionsChannels.getToken.removeListener(listener);
347
- }
348
- };
349
-
350
- this.destinationActionsChannels.getToken.addListener(listener);
351
-
352
- this.sourceActionsChannels.getToken.send(req_id);
353
- });
354
- }
355
-
356
-
357
- // AGENT GET IDLE CODES
358
- async getIdleCodes() {
359
- if (!this.checkService()) {
360
- return;
361
- }
362
-
363
- return await new Promise<AgentSharedActions.GetIdleCodes.IdleCodes>((resolve) => {
364
- const req_id = this.getNextReqId();
365
-
366
- const listener: Service.ActionChannel.Listener<AgentSharedActions.GetIdleCodes.ResPayloadParameters> = ({ args: [idle_codes, res_id] }) => {
367
- if (res_id === req_id) {
368
- resolve(idle_codes);
369
- this.destinationActionsChannels.getIdleCodes.removeListener(listener);
370
- }
371
- };
372
- this.destinationActionsChannels.getIdleCodes.addListener(listener);
373
-
374
- this.sourceActionsChannels.getIdleCodes.send(req_id);
375
- });
376
- }
377
-
378
- // AGENT GET WRAP UP CODES
379
- async getWrapUpCodes() {
380
- if (!this.checkService()) {
381
- return;
382
- }
383
-
384
- return await new Promise<AgentSharedActions.GetWrapUpCodes.WrapUpCodes>((resolve) => {
385
- const req_id = this.getNextReqId();
386
-
387
- const listener: Service.ActionChannel.Listener<AgentSharedActions.GetWrapUpCodes.ResPayloadParameters> = ({ args: [wrap_up_codes, res_id] }) => {
388
- if (res_id === req_id) {
389
- resolve(wrap_up_codes);
390
- this.destinationActionsChannels.getWrapUpCodes.removeListener(listener);
391
- }
392
- };
393
-
394
- this.destinationActionsChannels.getWrapUpCodes.addListener(listener);
395
-
396
- this.sourceActionsChannels.getWrapUpCodes.send(req_id);
397
- });
398
- }
399
- }
400
-
401
- const actionsJsApiLogger = createJsApiLogger(logger, "[Actions JSAPI] =>");
402
-
403
- // Standalone init
404
- export const createActionsJsApi = () =>
405
- new ActionsJsApi({
406
- // LOGGER
407
- logger: actionsJsApiLogger,
408
- // CHECK
409
- serviceChecker: createServiceChecker({ logger: actionsJsApiLogger })
410
- });