@wxcc-desktop/sdk 1.2.11 → 1.2.13-dev

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 (3) hide show
  1. package/README.md +394 -18
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,412 @@
1
- # WXCC Desktop JavaScript SDK
1
+ # WxCC Agent Desktop JS-API
2
+ WxCC Agent Desktop JS API modules set
2
3
 
3
- WXCC Desktop JavaScript SDK is an npm package that allows you to request up-to-date information from the WXCC Desktop. Using the SDK, you can request information such as agent details, assigned tasks, particular task details, current browser locale, and authentication token for Single Sign-On (SSO) integration.
4
+ ## Root module (`Desktop`) includes:
5
+ - Config module
6
+ - I18N module
7
+ - Actions module
8
+ - Logger service module
9
+ - ShortcutKey service module
10
+ - AQM/Notifs **agent-contact** service layer API module for WxCC Agent Desktop.
11
+ - AQM/Notifs **agent-state** service layer API module for WxCC Agent Desktop.
12
+ - AQM/Notifs **dialer** service layer API module for WxCC Agent Desktop.
13
+ - AQM/Notifs **screenpop** service layer API module for WxCC Agent Desktop.
4
14
 
5
- The SDK package allows you to
15
+ ### `Desktop` module
16
+ Desktop module contains sub-modules:
6
17
 
7
- * request data to be passed to your widgets through properties and attributes
18
+ ```Javascript
19
+ import { Desktop } from "@wxcc-desktop/sdk";
8
20
 
9
- * perform more complex operations by consuming and manipulating the system data inside your widget
21
+ const {
22
+ config,
23
+ actions,
24
+ logger,
25
+ shortcutKey,
26
+ i18n,
10
27
 
11
- * subscribe to data arriving asynchronously
28
+ // AQM/Notifs modules
29
+ agentContact,
30
+ agentStateInfo,
31
+ dialer,
32
+ screenpop
33
+ } = Desktop;
34
+ ```
35
+
36
+ ### `Desktop.logger` sub-module
37
+ `Desktop.logger` sub-module is intended to create & maintain client-side logger's instances for third-party widgets.
38
+ ```Javascript
39
+ import { Desktop } from "@wxcc-desktop/sdk";
40
+
41
+ //...
42
+
43
+ /*
44
+ Supposing Desktop.config.init() was called
45
+ */
46
+
47
+ const logerOne = Desktop.logger.createLogger("for-service-one");
48
+ const logerTwo = Desktop.logger.createLogger("for-service-two");
49
+
50
+ logerOne.info("Info test"); // console.log => "for-service-one: Info:test"
51
+ logerTwo.warn("Warn test"); // console.log => "for-service-two: Warn:test"
52
+ logerOne.error("Error test"); // console.log => "for-service-one: Error:test"
53
+
54
+ // Start browser doanload logs as JSON for "for-service-one" prefix:
55
+ Desktop.logger.browserDownloadLogsJson("for-service-one");
56
+
57
+ // Start browser doanload logs as Test for "for-service-one" prefix:
58
+ Desktop.logger.browserDownloadLogsText("for-service-one");
59
+
60
+ // Get logs as Object's collection for "for-service-one" prefix:
61
+ Desktop.logger.getLogsCollection("for-service-one");
62
+
63
+ // Get logs as base64 encoded url ready to put into link href to initiate browser download as JSON for "for-service-one" prefix:
64
+ Desktop.logger.getLogsJsonUrl("for-service-one");
65
+
66
+ // Get logs as base64 encoded url ready to put into link href to initiate browser download as Text for "for-service-one" prefix:
67
+ Desktop.logger.getLogsTextUrl("for-service-one");
68
+
69
+ // Cleanup logs from LS for "for-service-one" prefix:
70
+ Desktop.logger.cleanupPrefixedLogs("for-service-one");
71
+
72
+ //...
73
+ ```
74
+
75
+ ### `Desktop.i18n` sub-module
76
+ `Desktop.i18n` sub-module is intended to create & maintain client-side i18n & lit-element i18nMixin instances for third-party widgets.
77
+
78
+ Desktop.i18n instantinating object is described in: https://www.i18next.com/overview/api#instance-creation
79
+
80
+ i18n instance backend configuration described in: https://github.com/i18next/i18next-http-backend
81
+
82
+ i18n instance languageDetector configuration described in: https://github.com/i18next/i18next-browser-languageDetector
83
+
84
+ i18n instance init options are described in: https://www.i18next.com/overview/configuration-options
85
+
86
+ ```Javascript
87
+ import { Desktop } from "@wxcc-desktop/sdk";
88
+ import { customElement, LitElement } from "lit-element";
89
+ import { html } from "lit-html";
90
+
91
+
92
+ //...
93
+
94
+ /*
95
+ Desktop.i18n service MAY NOT NEED to wait for Desktop.config.init({...}) was called for proper work
96
+ */
97
+
98
+ // All CreateOotions for i18n are optional
99
+ type CreateOptions = {
100
+ logger?:
101
+ | {
102
+ log(...args: any[]): void;
103
+ warn(...args: any[]): void;
104
+ error(...args: any[]): void;
105
+ }
106
+ | ReturnType<typof Desktop.createLogger>;
107
+
108
+ backend?: Backend // import Backend from "i18next-http-backend";
109
+ languageDetector?: LanguageDetector // import LanguageDetector from "i18next-browser-languagedetector";
110
+ };
111
+
112
+ const i18n = Desktop.i18n.createInstance(createOptions?: CreateOptions) // returns instance described in https://www.i18next.com/overview/api#instance-creation
113
+ const i18nMixin = Desktop.i18n.createMixin({ i18n /*Injecting i18n service instance into lit-element mixin */ })
114
+
115
+ console.log(Desktop.i18n.DEFAULT_INIT_OPTIONS); // => i18n.init options that are using by AgentX by default
116
+
117
+ // Init i18n with options to be able call "t" function translations
118
+ if (!i18n.isInitialized) {
119
+ const initOptions = Desktop.i18n.getMergedInitOptions(Desktop.i18n.DEFAULT_INIT_OPTIONS || {}, {
120
+ defaultNS: "my-ns",
121
+ ns: ["my-ns"],
122
+ fallbackLng: "en",
123
+ backend: {
124
+ loadPath: "/.../path-to-locales/.../{{lng}}/{{ns}}.json"
125
+ }
126
+ });
127
+
128
+ i18n.init(initOptions).catch(err => console.log(err));
129
+ }
130
+
131
+ @customElement("my-awesome-component")
132
+ export class MyAwesomeComponent extends i18nMixin(LitElement) {
133
+ render() {
134
+ return html`
135
+ <!-- i18nMixin will subscribe component tree updates on languages load & language change -->
136
+ <p>${i18n.t("my-ns:key1")}</p>
137
+ <!-- Component wrapped by i18nMixin can access t funcation via this.t(...) -->
138
+ <p>${this.t("my-ns:key2")}</p>`
139
+ }
140
+ }
141
+
142
+ ```
143
+
144
+ ### `Desktop.actions` sub-module
145
+ `Desktop.actions` sub-module is intended to make a calls into and/or get data from AgentX store.
146
+
147
+ ```Javascript
148
+ import { Desktop } from "@wxcc-desktop/sdk";
149
+
150
+ //...
151
+
152
+ /*
153
+ Supposing Desktop.config.init() was called
154
+ */
155
+
156
+
157
+ // AgentX General Notifications:
158
+ Desktop.actions.fireGeneralSilentNotification({...}) // => Fires silent notification in AgentX. One way
159
+
160
+ // Unlike silent notification, autodismiss and acknowledge can have controlled responses, that may reflect in status, e.g.:
161
+ const [ status, reason, mode ]: [ Notifications.ItemMeta.Status, Notifications.ItemMeta.StatusChangeEventReason, Notifications.ItemMeta.Mode ] = await Desktop.actions.fireGeneralAutoDismissNotification({...}) // => Fires autudismiss notification in AgentX. Returns notification resolved status, reason, mode. NOTE: if AgentX notifications disabled - it will be converted into silent and reflected in "mode"
162
+ const [ status, reason, mode ]: [ Notifications.ItemMeta.Status, Notifications.ItemMeta.StatusChangeEventReason, Notifications.ItemMeta.Mode ] = await Desktop.actions.fireGeneralAcknowledgeNotification({...}) // => Fires acknowledge notification in AgentX. Returns notification resolved status, reason, mode. NOTE: if AgentX notifications disabled - it will be converted into silent and reflected in "mode"
163
+
164
+
165
+ // AgentX Tasks:
166
+ Desktop.actions.addCustomTask({...}) // => Add custom task object in AgentX store
167
+
168
+
169
+ // AgentX Task Map:
170
+ const currentTaskMap = await Desktop.actions.getTaskMap() // => Get current task map from AgentX store
171
+
172
+ // AgentX Media Type Queues:
173
+ const queue = await Desktop.actions.getMediaTypeQueue("telephony" | "social" | "email" | "chat") // => Get current media queue from AgentX store
174
+
175
+ // AgentX AccessToken:
176
+ const accessToken = await Desktop.actions.getToken() // => Get current accessToken from AgentX store
177
+
178
+ // AgentX idleCodes:
179
+ const idelCodes = await Desktop.actions.getIdleCodes() // => Get current idleCodes from AgentX store
180
+
181
+ // AgentX wrapUpCodes:
182
+ const wrapUpCodes = await Desktop.actions.getWrapUpCodes() // => Get current idleCodes from AgentX store
12
183
 
13
- Some events in the WXCC Desktop happen asynchronously. To subscribe to the asynchronous events and access data within the payload, you can add a listener. A few examples for asynchronous events are:
184
+ // AgentX Maximize/Restore Dynamic Widget.
185
+ const toggle = Desktop.actions.toggleMiximizeRestore(e: Event) // => maximize/restore widgets with toggle-maximize-restore.
14
186
 
15
- * New task offered
187
+ ```
188
+
189
+ ### `Desktop.shortcutKey` sub-module
190
+ `Desktop.shortcutKey` sub-module is intended to register and call shortcut keys actions from widgets.
191
+ ```Javascript
192
+ import { Desktop } from "@wxcc-desktop/sdk";
193
+
194
+ //...
195
+
196
+ /*
197
+ Supposing Desktop.config.init() was called
198
+ */
199
+
200
+ console.log(Desktop.shortcutKey.DEFAULT_SHORTCUT_KEYS); //=> logs default shortcut keys
201
+
202
+ console.log(Desktop.shortcutKey.MODIFIERS); //=> logs keys modifiers
203
+
204
+ console.log(Desktop.shortcutKey.REGISTERED_KEYS); //=> logs registered keys
205
+
206
+ console.log(Desktop.shortcutKey.getRegisteredKeys()); //=> logs service registered keys
207
+
208
+ Desktop.shortcutKey.listenKeyPress((event) => {...}); //=> listen shortcuts key press
209
+
210
+ Desktop.shortcutKey.listenKeyConflict((event) => {...}); //=> listen shortcuts key conflict
211
+
212
+ Desktop.shortcutKey.listenConflictResolved(() => {}); //=> listen to shortcut key conflict resolved status
213
+
214
+ Desktop.shortcutKey.register([ {...}, {...}, ... ]); //=> registering shortcut keys actions
215
+
216
+ Desktop.shortcutKey.unregisterKeys('widget-one-example'); //=> used to unregister on unmount, widgetElement used for register should be provided
217
+
218
+ //...
219
+ ```
220
+
221
+ ### `Desktop.agentContact` sub-module
222
+ `Desktop.agentContact` sub-module is intended to make aqm requests and listen to notifs events related to agent-contact entity.
223
+ ```Javascript
224
+ import { Desktop } from "@wxcc-desktop/sdk";
225
+
226
+ //...
227
+
228
+ /*
229
+ Supposing Desktop.config.init() was called
230
+ */
231
+
232
+ // List of available agent-contact aqm reqs:
233
+ await Desktop.agentContact.accept({ ... });
234
+ await Desktop.agentContact.consultAccept({ ... });
235
+ await Desktop.agentContact.buddyAgents({ ... });
236
+ await Desktop.agentContact.end({ ... });
237
+ await Desktop.agentContact.consultEnd({ ... });
238
+ await Desktop.agentContact.cancelCtq({ ... });
239
+ await Desktop.agentContact.wrapup({ ... });
240
+ await Desktop.agentContact.vteamTransfer({ ... });
241
+ await Desktop.agentContact.blindTransfer({ ... });
242
+ await Desktop.agentContact.hold({ ... });
243
+ await Desktop.agentContact.unHold({ ... });
244
+ await Desktop.agentContact.consult({ ... });
245
+ await Desktop.agentContact.decline({ ... });
246
+ await Desktop.agentContact.consultTransfer({ ... });
247
+ await Desktop.agentContact.vteamList({ ... });
248
+ await Desktop.agentContact.pauseRecording({ ... });
249
+ await Desktop.agentContact.resumeRecording({ ... });
250
+
251
+ // List of available agent-contact aqm notifs events:
252
+ Desktop.agentContact.addEventListener("eAgentContact", msg => console.log(msg));
253
+ Desktop.agentContact.addEventListener("eAgentContactAssigned", msg => console.log(msg));
254
+ Desktop.agentContact.addEventListener("eAgentContactEnded", msg => console.log(msg));
255
+ Desktop.agentContact.addEventListener("eAgentContactWrappedUp", msg => console.log(msg));
256
+ Desktop.agentContact.addEventListener("eAgentOfferContact", msg => console.log(msg));
257
+ Desktop.agentContact.addEventListener("eAgentOfferContactRona", msg => console.log(msg));
258
+ Desktop.agentContact.addEventListener("eAgentOfferConsult", msg => console.log(msg));
259
+ Desktop.agentContact.addEventListener("eAgentWrapup", msg => console.log(msg));
260
+ Desktop.agentContact.addEventListener("eAgentContactHeld", msg => console.log(msg));
261
+ Desktop.agentContact.addEventListener("eAgentContactUnHeld", msg => console.log(msg));
262
+ Desktop.agentContact.addEventListener("eCallRecordingStarted", msg => console.log(msg));
263
+ Desktop.agentContact.addEventListener("eAgentConsultCreated", msg => console.log(msg));
264
+ Desktop.agentContact.addEventListener("eAgentConsultConferenced", msg => console.log(msg));
265
+ Desktop.agentContact.addEventListener("eAgentConsultEnded", msg => console.log(msg));
266
+ Desktop.agentContact.addEventListener("eAgentCtqCancelled", msg => console.log(msg));
267
+ Desktop.agentContact.addEventListener("eAgentConsulting", msg => console.log(msg));
268
+ Desktop.agentContact.addEventListener("eAgentConsultFailed", msg => console.log(msg));
269
+ Desktop.agentContact.addEventListener("eAgentConsultEndFailed", msg => console.log(msg));
270
+ Desktop.agentContact.addEventListener("eAgentCtqFailed", msg => console.log(msg));
271
+ Desktop.agentContact.addEventListener("eAgentCtqCancelFailed", msg => console.log(msg));
272
+ Desktop.agentContact.addEventListener("eAgentConsultConferenceEndFailed", msg => console.log(msg));
273
+
274
+ // Module supports removing added listeners like:
275
+ const listener = msg => console.log(msg);
276
+ Desktop.agentContact.addEventListener("eAgentContact", listener);
277
+ Desktop.agentContact.removeEventListener("eAgentContact", listener);
278
+
279
+ // Module supports one-time added listeners like:
280
+ Desktop.agentContact.addOnceEventListener("eAgentContact", listener);
281
+ Desktop.agentContact.removeOnceEventListener("eAgentContact", listener);
282
+
283
+ // Module supports removing all listeners like:
284
+ Desktop.agentContact.removeAllEventListeners();
16
285
 
17
- * New task assigned
286
+ ```
287
+
288
+ ### `Desktop.agentStateInfo` sub-module
289
+ `Desktop.agentStateInfo` sub-module is intended to listen for latest data updates for data:
290
+ ```Javascript
291
+ type LatestInfoData = {
292
+ teamId?: string;
293
+ teamName?: string;
294
+ dn?: string;
295
+ status?: string;
296
+ subStatus?: string;
297
+ idleCodes?: Service.Aqm.Configs.Entity[];
298
+ wrapupCodes?: Service.Aqm.Configs.Entity[];
299
+ outDialRegex?: string;
300
+ isOutboundEnabledForTenant?: boolean;
301
+ isOutboundEnabledForAgent?: boolean;
302
+ };
303
+ ```
18
304
 
19
- * Consult request created
305
+ ```Javascript
306
+ import { Desktop } from "@wxcc-desktop/sdk";
20
307
 
21
- * Consult ended
308
+ //...
22
309
 
23
- * Screen pop arrived and more
310
+ /*
311
+ Supposing Desktop.config.init() was called
312
+ */
24
313
 
25
- ## Get Started
314
+ // latestData inludes latest data fields
315
+ const latestData: LatestInfoData = Desktop.agentStateInfo.latestData;
26
316
 
27
- Run the following command in your project folder or using yarn:
317
+ //...
318
+ // Cumulative update event supported
319
+ Desktop.agentStateInfo.addEventListener("updated", updatedList =>
320
+ console.log(updatedList)
321
+ /* will log (in case of "dn", "status", "subStatus" fields were updated
322
+ [
323
+ {
324
+ "name": "dn",
325
+ "value": "+12580258011",
326
+ "oldValue": ""
327
+ },
328
+ {
329
+ "name": "status",
330
+ "value": "LoggedIn",
331
+ "oldValue": "DefaultState"
332
+ },
333
+ {
334
+ "name": "subStatus",
335
+ "value": "Available",
336
+ "oldValue": ""
337
+ }
338
+ ]
339
+ */
340
+ );
341
+
342
+
343
+ // List of available agent-state aqm reqs:
344
+ await Desktop.agentStateInfo.stateChange({ ... });
345
+ await Desktop.agentStateInfo.fetchAddressBooks({ ... });
28
346
 
29
347
  ```
30
- npm install @wxcc-desktop/sdk --save
31
- yarn add @wxcc-desktop/sdk
348
+
349
+ ### `Desktop.dialer` sub-module
350
+ `Desktop.dialer` sub-module is intended to make aqm requests and listen to notifs events related to dialer entity.
351
+ ```Javascript
352
+ import { Desktop } from "@wxcc-desktop/sdk";
353
+
354
+ //...
355
+
356
+ /*
357
+ Supposing Desktop.config.init() was called
358
+ */
359
+
360
+ // List of available agent-contact aqm reqs:
361
+ await Desktop.dialer.startOutdial({ ... });
362
+
363
+ // List of available agent-contact aqm notifs events:
364
+ Desktop.dialer.addEventListener("eOutdialFailed", msg => console.log(msg));
365
+
366
+ // Module supports removing added listeners like:
367
+ const listener = msg => console.log(msg);
368
+ Desktop.dialer.addEventListener("eOutdialFailed", listener);
369
+ Desktop.dialer.removeEventListener("eOutdialFailed", listener);
370
+
371
+ // Module supports one-time added listeners like:
372
+ Desktop.dialer.addOnceEventListener("eOutdialFailed", listener);
373
+ Desktop.dialer.removeOnceEventListener("eOutdialFailed", listener);
374
+
375
+ // Module supports removing all listeners like:
376
+ Desktop.dialer.removeAllEventListeners();
377
+
378
+ ```
379
+
380
+ ### `Desktop.screenpop` sub-module
381
+ `Desktop.screenpop` sub-module is intended to make aqm requests and listen to notifs events related to screenpop entity.
382
+ ```Javascript
383
+ import { Desktop } from "@wxcc-desktop/sdk";
384
+
385
+ //...
386
+
387
+ /*
388
+ Supposing Desktop.config.init() was called
389
+ */
390
+
391
+ // List of available agent-contact aqm notifs events:
392
+ Desktop.screenpop.addEventListener("eScreenPop", msg => console.log(msg));
393
+
394
+ // Module supports removing added listeners like:
395
+ const listener = msg => console.log(msg);
396
+ Desktop.screenpop.addEventListener("eScreenPop", listener);
397
+ Desktop.screenpop.removeEventListener("eScreenPop", listener);
398
+
399
+ // Module supports one-time added listeners like:
400
+ Desktop.screenpop.addOnceEventListener("eScreenPop", listener);
401
+ Desktop.screenpop.removeOnceEventListener("eScreenPop", listener);
402
+
403
+ // Module supports removing all listeners like:
404
+ Desktop.screenpop.removeAllEventListeners();
405
+
32
406
  ```
33
407
 
34
- ## For detailed Info refer the below Link
408
+ ### Publishing the wxcc-desktop/js-api
409
+ For publishing internally to Internal Cisco Repository: `yarn npm:publish:internal`
410
+ For publishing to both Internal and public Repo : `yarn publish:external`
35
411
 
36
- ### [Webex Contact Center Desktop Docs](https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cust_contact/contact_center/webexcc/developer_20/webexcc_b_20-desktop-developer-guide-/webexcc_m_30-javascript-sdk.html)
412
+ `publish:all` responsible for publishing in both first internal repository and then to the external public repository npmjs