@telia-ace/knowledge-widget-bot-provider 0.0.1-alpha.49 → 0.0.1-alpha.51
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/LICENSE.txt +5 -5
- package/README.md +12 -12
- package/dist/client/chat.client.d.ts +13 -16
- package/dist/client/contact-method.client.d.ts +35 -34
- package/dist/client/http.client.d.ts +26 -26
- package/dist/client/middleware.client.d.ts +14 -14
- package/dist/contact-method.js +14 -4
- package/dist/contact-method.js.map +1 -1
- package/dist/contract/custom-component/contact-method-item.d.ts +11 -9
- package/dist/contract/custom-component/contact-method-list.d.ts +8 -7
- package/dist/contract/custom-component/contact-method.d.ts +3 -3
- package/dist/contract/custom-component/entry-context.d.ts +5 -5
- package/dist/contract/enum/server-entry-type.enum.d.ts +7 -7
- package/dist/contract/model/conversation-api-model/list.model.d.ts +5 -5
- package/dist/contract/model/conversation-api-model/message.model.d.ts +7 -7
- package/dist/contract/model/http/action.model.d.ts +3 -3
- package/dist/contract/model/http/client-action.model.d.ts +4 -4
- package/dist/contract/model/http/client-envelope.model.d.ts +9 -9
- package/dist/contract/model/http/connect-options.model.d.ts +5 -5
- package/dist/contract/model/http/global-state.model.d.ts +8 -8
- package/dist/contract/model/http/http-client-options.model.d.ts +5 -5
- package/dist/contract/model/http/server-entry.model.d.ts +11 -11
- package/dist/contract/model/http/server-envelope.model.d.ts +10 -10
- package/dist/contract/model/middleware/aggregator-state.model.d.ts +4 -4
- package/dist/contract/model/shared/loose-object.model.d.ts +3 -3
- package/dist/feedback-list.js +4 -1
- package/dist/feedback-list.js.map +1 -1
- package/dist/helper/chat.helper.d.ts +8 -8
- package/dist/helper/http.helper.d.ts +13 -13
- package/dist/helper/middleware.helper.d.ts +12 -12
- package/dist/helper/store.helper.d.ts +23 -23
- package/dist/index.d.ts +2 -2
- package/dist/index.js +171 -149
- package/dist/index.js.map +1 -1
- package/dist/interface/entry.interface.d.ts +23 -20
- package/dist/interface/middleware/paging.interface.d.ts +4 -4
- package/dist/interface/middleware/processor.interface.d.ts +10 -10
- package/dist/no-good-alternative.js.map +1 -1
- package/dist/plugin.d.ts +3 -3
- package/dist/ui/feedback-list.d.ts +8 -8
- package/dist/ui/no-good-alternative.d.ts +6 -6
- package/dist/utils.d.ts +2 -2
- package/package.json +8 -8
- package/dist/components/feedback-list.d.ts +0 -8
- package/dist/components/no-good-alternative.d.ts +0 -6
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare class HttpHelper {
|
|
2
|
-
static fetchOptions: {
|
|
3
|
-
method: string;
|
|
4
|
-
headers: {
|
|
5
|
-
Accept: string;
|
|
6
|
-
'Content-Type': string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
static combineUrl(basePath: string, path: string): string;
|
|
10
|
-
static managedSubdomainSuffixes: string[];
|
|
11
|
-
static parseSubdomain: (input: string) => string;
|
|
12
|
-
static getCredentials(): string | undefined;
|
|
13
|
-
}
|
|
1
|
+
export declare class HttpHelper {
|
|
2
|
+
static fetchOptions: {
|
|
3
|
+
method: string;
|
|
4
|
+
headers: {
|
|
5
|
+
Accept: string;
|
|
6
|
+
'Content-Type': string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
static combineUrl(basePath: string, path: string): string;
|
|
10
|
+
static managedSubdomainSuffixes: string[];
|
|
11
|
+
static parseSubdomain: (input: string) => string;
|
|
12
|
+
static getCredentials(): string | undefined;
|
|
13
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
|
-
export declare class MiddlewareHelper {
|
|
3
|
-
private static sessionMessageStorageVariable;
|
|
4
|
-
private static container;
|
|
5
|
-
private static widget;
|
|
6
|
-
static setContainer(container: any): void;
|
|
7
|
-
static setWidget(widget: any): void;
|
|
8
|
-
static getContainer(): any;
|
|
9
|
-
static getWidget(): any;
|
|
10
|
-
static setEntrySessionStorage: (messages: Message[]) => Promise<void>;
|
|
11
|
-
static getEntrySessionStorage(): Promise<any>;
|
|
12
|
-
}
|
|
1
|
+
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
|
+
export declare class MiddlewareHelper {
|
|
3
|
+
private static sessionMessageStorageVariable;
|
|
4
|
+
private static container;
|
|
5
|
+
private static widget;
|
|
6
|
+
static setContainer(container: any): void;
|
|
7
|
+
static setWidget(widget: any): void;
|
|
8
|
+
static getContainer(): any;
|
|
9
|
+
static getWidget(): any;
|
|
10
|
+
static setEntrySessionStorage: (messages: Message[]) => Promise<void>;
|
|
11
|
+
static getEntrySessionStorage(): Promise<any>;
|
|
12
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
|
-
import { ClientAction } from '../contract/model/http/client-action.model';
|
|
3
|
-
import { GlobalState } from '../contract/model/http/global-state.model';
|
|
4
|
-
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
5
|
-
import { LooseObject } from '../contract/model/shared/loose-object.model';
|
|
6
|
-
export declare class StoreHelper {
|
|
7
|
-
private static messageStore;
|
|
8
|
-
private static globalState;
|
|
9
|
-
constructor();
|
|
10
|
-
static insertOrUpdateMessageArrayStore(messageArray: Message[], entry?: any): Promise<void>;
|
|
11
|
-
static insertMessageToStore(message: Message): void;
|
|
12
|
-
private static updateMessageInStore;
|
|
13
|
-
static checkIdInMessageStore(id: string): boolean;
|
|
14
|
-
static getLocalState(action: string): LooseObject | undefined;
|
|
15
|
-
static getGlobalState(): GlobalState;
|
|
16
|
-
static setGlobalState(state: GlobalState): Promise<void>;
|
|
17
|
-
static getAction(action: string): ClientAction;
|
|
18
|
-
static getCommand(text: string): LooseObject;
|
|
19
|
-
static getEntry(action: string): ServerEntry | undefined;
|
|
20
|
-
static getMessage(id: string): Message | undefined;
|
|
21
|
-
static getEntryStore(): ServerEntry[];
|
|
22
|
-
static rehydrateState(): Promise<void>;
|
|
23
|
-
}
|
|
1
|
+
import { Message } from '../contract/model/conversation-api-model/message.model';
|
|
2
|
+
import { ClientAction } from '../contract/model/http/client-action.model';
|
|
3
|
+
import { GlobalState } from '../contract/model/http/global-state.model';
|
|
4
|
+
import { ServerEntry } from '../contract/model/http/server-entry.model';
|
|
5
|
+
import { LooseObject } from '../contract/model/shared/loose-object.model';
|
|
6
|
+
export declare class StoreHelper {
|
|
7
|
+
private static messageStore;
|
|
8
|
+
private static globalState;
|
|
9
|
+
constructor();
|
|
10
|
+
static insertOrUpdateMessageArrayStore(messageArray: Message[], entry?: any): Promise<void>;
|
|
11
|
+
static insertMessageToStore(message: Message): void;
|
|
12
|
+
private static updateMessageInStore;
|
|
13
|
+
static checkIdInMessageStore(id: string): boolean;
|
|
14
|
+
static getLocalState(action: string): LooseObject | undefined;
|
|
15
|
+
static getGlobalState(): GlobalState;
|
|
16
|
+
static setGlobalState(state: GlobalState): Promise<void>;
|
|
17
|
+
static getAction(action: string): ClientAction;
|
|
18
|
+
static getCommand(text: string): LooseObject;
|
|
19
|
+
static getEntry(action: string): ServerEntry | undefined;
|
|
20
|
+
static getMessage(id: string): Message | undefined;
|
|
21
|
+
static getEntryStore(): ServerEntry[];
|
|
22
|
+
static rehydrateState(): Promise<void>;
|
|
23
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import ConversationPlugin from './plugin';
|
|
2
|
-
export { ConversationPlugin };
|
|
1
|
+
import ConversationPlugin from './plugin';
|
|
2
|
+
export { ConversationPlugin };
|
package/dist/index.js
CHANGED
|
@@ -173,6 +173,72 @@ const _StoreHelper = class {
|
|
|
173
173
|
};
|
|
174
174
|
let StoreHelper = _StoreHelper;
|
|
175
175
|
StoreHelper.messageStore = [];
|
|
176
|
+
class ChatClient {
|
|
177
|
+
constructor() {
|
|
178
|
+
}
|
|
179
|
+
static initialize(user, agent) {
|
|
180
|
+
ChatHelper.setUser(user);
|
|
181
|
+
ChatHelper.setAgent(agent);
|
|
182
|
+
}
|
|
183
|
+
processMessageArrayAndStoreIt(messages) {
|
|
184
|
+
return __async(this, null, function* () {
|
|
185
|
+
for (const message of messages.filter((o) => o && o != null && !!o.message)) {
|
|
186
|
+
if (message.isUser)
|
|
187
|
+
this.postUserMessage(message);
|
|
188
|
+
else
|
|
189
|
+
this.postAgentMessage(message);
|
|
190
|
+
}
|
|
191
|
+
yield StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
updateMessageArrayAndStoreIt(messages) {
|
|
195
|
+
let conversationEntry = void 0;
|
|
196
|
+
messages.forEach((o) => {
|
|
197
|
+
let message = StoreHelper.getMessage(o.id);
|
|
198
|
+
message == null ? void 0 : message.conversationEntry.update(o.message);
|
|
199
|
+
conversationEntry = message == null ? void 0 : message.conversationEntry;
|
|
200
|
+
});
|
|
201
|
+
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
202
|
+
}
|
|
203
|
+
printUserMessageAndStoreIt(action) {
|
|
204
|
+
if (action == "next" || action == "help")
|
|
205
|
+
return;
|
|
206
|
+
let entry = StoreHelper.getEntry(action);
|
|
207
|
+
let message = {
|
|
208
|
+
id: v4(),
|
|
209
|
+
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
210
|
+
isUser: true
|
|
211
|
+
};
|
|
212
|
+
this.postUserMessage(message);
|
|
213
|
+
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
214
|
+
}
|
|
215
|
+
postUserMessage(message) {
|
|
216
|
+
ChatHelper.getUser().print(message.message);
|
|
217
|
+
}
|
|
218
|
+
postAgentMessage(message) {
|
|
219
|
+
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
220
|
+
}
|
|
221
|
+
getTitleFromEntry(entry, action) {
|
|
222
|
+
const entryType = ServerEntryTypeEnum[entry.type];
|
|
223
|
+
switch (entryType) {
|
|
224
|
+
case ServerEntryTypeEnum.List:
|
|
225
|
+
return this.getTitleFromList(entry, action);
|
|
226
|
+
case ServerEntryTypeEnum.Text:
|
|
227
|
+
return this.getTitleFromText(entry, action);
|
|
228
|
+
default:
|
|
229
|
+
return "";
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getTitleFromText(entry, action) {
|
|
233
|
+
if (!!entry.content.items)
|
|
234
|
+
return this.getTitleFromList(entry, action);
|
|
235
|
+
else
|
|
236
|
+
return entry.content.html;
|
|
237
|
+
}
|
|
238
|
+
getTitleFromList(entry, action) {
|
|
239
|
+
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
176
242
|
const _ContactMethodClient = class {
|
|
177
243
|
constructor(container) {
|
|
178
244
|
this.handleNewForm = (errors, entry) => __async(this, null, function* () {
|
|
@@ -225,7 +291,7 @@ const _ContactMethodClient = class {
|
|
|
225
291
|
}
|
|
226
292
|
return (contactMethod == null ? void 0 : contactMethod.body) || {};
|
|
227
293
|
};
|
|
228
|
-
this.chatClient = new ChatClient(
|
|
294
|
+
this.chatClient = new ChatClient();
|
|
229
295
|
}
|
|
230
296
|
static initialize(container, dataClient, contactMethodPlatform, agent) {
|
|
231
297
|
this.dataClient = dataClient;
|
|
@@ -267,10 +333,7 @@ const _ContactMethodClient = class {
|
|
|
267
333
|
if (messageItemIndex > -1) {
|
|
268
334
|
const [messageItemType, messageItemContent] = message.message[messageItemIndex];
|
|
269
335
|
const updatedMessageItemContent = __spreadProps(__spreadValues({}, messageItemContent), {
|
|
270
|
-
contactMethods: messageItemContent.contactMethods
|
|
271
|
-
cm.expanded = true;
|
|
272
|
-
return cm;
|
|
273
|
-
})
|
|
336
|
+
contactMethods: this.getNewContactMethods(messageItemContent.contactMethods)
|
|
274
337
|
});
|
|
275
338
|
const updatedMessageItems = [
|
|
276
339
|
...message.message.slice(0, messageItemIndex),
|
|
@@ -281,6 +344,17 @@ const _ContactMethodClient = class {
|
|
|
281
344
|
}
|
|
282
345
|
}
|
|
283
346
|
}
|
|
347
|
+
getNewContactMethods(contactMethods) {
|
|
348
|
+
if (Array.isArray(contactMethods)) {
|
|
349
|
+
return contactMethods.map((cm) => {
|
|
350
|
+
cm.expanded = true;
|
|
351
|
+
return cm;
|
|
352
|
+
});
|
|
353
|
+
} else {
|
|
354
|
+
contactMethods.expanded = true;
|
|
355
|
+
return contactMethods;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
284
358
|
handleContactMethodList(input, contactMethods) {
|
|
285
359
|
let title = input.split("/")[2];
|
|
286
360
|
let newGuid = v4();
|
|
@@ -355,7 +429,7 @@ const _ContactMethodClient = class {
|
|
|
355
429
|
return message;
|
|
356
430
|
}
|
|
357
431
|
}
|
|
358
|
-
loadContactMethods(dataType, id = void 0) {
|
|
432
|
+
loadContactMethods(dataType, id = void 0, guideId = void 0) {
|
|
359
433
|
switch (dataType) {
|
|
360
434
|
case DataType.ContactMethodCategories: {
|
|
361
435
|
return _ContactMethodClient.container.getAsync("matchingClient").then((matchingClient) => {
|
|
@@ -365,7 +439,9 @@ const _ContactMethodClient = class {
|
|
|
365
439
|
});
|
|
366
440
|
}
|
|
367
441
|
case DataType.ContactMethods: {
|
|
368
|
-
if (!!id) {
|
|
442
|
+
if (!!id && !!guideId) {
|
|
443
|
+
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethod, { contactMethodId: id, guideId }).then((contactMethods) => contactMethods);
|
|
444
|
+
} else if (!!id) {
|
|
369
445
|
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethod, { contactMethodId: id }).then((contactMethods) => contactMethods);
|
|
370
446
|
} else {
|
|
371
447
|
return _ContactMethodClient.dataClient.fetch(DataType.ContactMethods, {}).then((contactMethods) => contactMethods);
|
|
@@ -382,6 +458,31 @@ const _ContactMethodClient = class {
|
|
|
382
458
|
};
|
|
383
459
|
let ContactMethodClient = _ContactMethodClient;
|
|
384
460
|
ContactMethodClient.contactMessageEntryArray = [];
|
|
461
|
+
const _HttpHelper = class {
|
|
462
|
+
static combineUrl(basePath, path) {
|
|
463
|
+
return basePath + path;
|
|
464
|
+
}
|
|
465
|
+
static getCredentials() {
|
|
466
|
+
return "same-origin";
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
let HttpHelper = _HttpHelper;
|
|
470
|
+
HttpHelper.fetchOptions = {
|
|
471
|
+
method: "POST",
|
|
472
|
+
headers: {
|
|
473
|
+
Accept: "application/json",
|
|
474
|
+
"Content-Type": "application/json"
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
|
|
478
|
+
HttpHelper.parseSubdomain = (input) => {
|
|
479
|
+
const index = input.lastIndexOf("-");
|
|
480
|
+
const lastPart = input.substr(index + 1);
|
|
481
|
+
if (_HttpHelper.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
482
|
+
return input.substr(0, index);
|
|
483
|
+
}
|
|
484
|
+
return input;
|
|
485
|
+
};
|
|
385
486
|
const getContactMethodEntry = (contactMethodId) => {
|
|
386
487
|
const entries = StoreHelper.getEntryStore();
|
|
387
488
|
return entries.find((e) => e.content.id === +contactMethodId);
|
|
@@ -448,11 +549,13 @@ const contactMethodFromLegacy = ({
|
|
|
448
549
|
}
|
|
449
550
|
return settings;
|
|
450
551
|
};
|
|
451
|
-
class
|
|
552
|
+
const _EntryInterface = class {
|
|
452
553
|
constructor(container) {
|
|
453
554
|
this.container = container;
|
|
454
555
|
this.helpActionKey = "help";
|
|
455
556
|
this.nextActionKey = "next";
|
|
557
|
+
this.contactMethodClient = void 0;
|
|
558
|
+
this.contactMethodClient = new ContactMethodClient(container);
|
|
456
559
|
}
|
|
457
560
|
transform(entry, feedbackEntry) {
|
|
458
561
|
return __async(this, null, function* () {
|
|
@@ -468,7 +571,7 @@ class EntryInterface {
|
|
|
468
571
|
case ServerEntryTypeEnum.Text:
|
|
469
572
|
return {
|
|
470
573
|
id: entry.id,
|
|
471
|
-
message: this.textTransform(entry, feedbackEntry),
|
|
574
|
+
message: yield this.textTransform(entry, feedbackEntry),
|
|
472
575
|
entry,
|
|
473
576
|
isUser: false
|
|
474
577
|
};
|
|
@@ -484,12 +587,12 @@ class EntryInterface {
|
|
|
484
587
|
}
|
|
485
588
|
transformContactMethod(entry) {
|
|
486
589
|
return __async(this, null, function* () {
|
|
590
|
+
var _a;
|
|
487
591
|
const dataClient = yield this.container.getAsync("dataClient");
|
|
488
592
|
const contactMethod = yield dataClient.fetch(DataType.ContactMethod, {
|
|
489
593
|
contactMethodId: entry.content.id
|
|
490
594
|
});
|
|
491
|
-
|
|
492
|
-
cmClient.addContactMethod(contactMethod);
|
|
595
|
+
(_a = this.contactMethodClient) == null ? void 0 : _a.addContactMethod(contactMethod);
|
|
493
596
|
});
|
|
494
597
|
}
|
|
495
598
|
transformArray(entryArray) {
|
|
@@ -505,26 +608,17 @@ class EntryInterface {
|
|
|
505
608
|
});
|
|
506
609
|
}
|
|
507
610
|
getUserMessage(action) {
|
|
508
|
-
|
|
509
|
-
|
|
611
|
+
return __async(this, null, function* () {
|
|
612
|
+
let entry = StoreHelper.getEntry(action);
|
|
613
|
+
return yield this.getTitleFromEntry(entry, action);
|
|
614
|
+
});
|
|
510
615
|
}
|
|
511
616
|
listTransform(entry, feedbackEntry) {
|
|
512
|
-
if (entry.type === "Contact")
|
|
617
|
+
if (entry.type === "Contact" || !entry.content)
|
|
513
618
|
return;
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
return;
|
|
517
|
-
let object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState);
|
|
518
|
-
if (!!feedbackEntry) {
|
|
519
|
-
let feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState);
|
|
520
|
-
StoreHelper.insertMessageToStore({
|
|
521
|
-
id: feedbackEntry.id,
|
|
522
|
-
message: void 0,
|
|
523
|
-
entry: feedbackEntry,
|
|
524
|
-
isUser: false
|
|
525
|
-
});
|
|
526
|
-
return object.concat(feedbackObject);
|
|
527
|
-
}
|
|
619
|
+
let object = this.getListActions(entry.content.items, this.getContentText(entry), entry.actions, entry.localState, entry.id);
|
|
620
|
+
if (!!feedbackEntry)
|
|
621
|
+
return this.addFeedbackToEntry(object, feedbackEntry);
|
|
528
622
|
return object;
|
|
529
623
|
}
|
|
530
624
|
getContentText(entry) {
|
|
@@ -534,26 +628,30 @@ class EntryInterface {
|
|
|
534
628
|
return { title: entry.content.header };
|
|
535
629
|
}
|
|
536
630
|
textTransform(entry, feedbackEntry) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
631
|
+
return __async(this, null, function* () {
|
|
632
|
+
var _a;
|
|
633
|
+
if (!!entry.content.items)
|
|
634
|
+
return this.listTransform(entry, feedbackEntry);
|
|
635
|
+
let returnObj = [
|
|
636
|
+
[ConversationMessageListItemType.HTML, { body: entry.content.html.replace("\n", "") }]
|
|
637
|
+
];
|
|
638
|
+
if (!!entry.actions.submitted) {
|
|
639
|
+
let contactMethod = yield (_a = this.contactMethodClient) == null ? void 0 : _a.loadContactMethods(DataType.ContactMethods, entry.actions.submitted.id.toString(), entry.actions.submitted.guideId.toString());
|
|
640
|
+
returnObj.push([
|
|
641
|
+
"ace-knowledge-contact-method",
|
|
642
|
+
{
|
|
643
|
+
contactMethods: contactMethod,
|
|
644
|
+
entry: { entryId: entry.id },
|
|
645
|
+
guideId: entry.actions.submitted.guideId
|
|
646
|
+
}
|
|
647
|
+
]);
|
|
648
|
+
}
|
|
649
|
+
if (!!feedbackEntry)
|
|
650
|
+
return this.addFeedbackToEntry(returnObj, feedbackEntry);
|
|
651
|
+
return returnObj;
|
|
652
|
+
});
|
|
555
653
|
}
|
|
556
|
-
getListActions(items, text, actions, state) {
|
|
654
|
+
getListActions(items, text, actions, state, id) {
|
|
557
655
|
let list = [];
|
|
558
656
|
const mainListType = this.getListType(state);
|
|
559
657
|
const createMainList = (type) => {
|
|
@@ -571,7 +669,7 @@ class EntryInterface {
|
|
|
571
669
|
return formatted;
|
|
572
670
|
}),
|
|
573
671
|
entry: {
|
|
574
|
-
entryId:
|
|
672
|
+
entryId: id
|
|
575
673
|
}
|
|
576
674
|
});
|
|
577
675
|
}
|
|
@@ -590,7 +688,9 @@ class EntryInterface {
|
|
|
590
688
|
break;
|
|
591
689
|
}
|
|
592
690
|
case this.nextActionKey: {
|
|
593
|
-
if (
|
|
691
|
+
if (!_EntryInterface.pagingAmount)
|
|
692
|
+
_EntryInterface.pagingAmount = actions["next"].take - items.filter((o2) => o2.actionKey !== "help" && o2.actionKey !== "next").length;
|
|
693
|
+
if (!!actions["next"] && actions["next"].take === items.filter((o2) => o2.actionKey !== "help" && o2.actionKey !== "next").length + _EntryInterface.pagingAmount) {
|
|
594
694
|
if (Array.isArray(mainListContent)) {
|
|
595
695
|
mainListContent.push({
|
|
596
696
|
label: o.title,
|
|
@@ -628,112 +728,34 @@ class EntryInterface {
|
|
|
628
728
|
return ConversationMessageListItemType.ButtonList;
|
|
629
729
|
}
|
|
630
730
|
getTitleFromEntry(entry, action) {
|
|
631
|
-
if (!!entry) {
|
|
632
|
-
const entryType = ServerEntryTypeEnum[entry.type];
|
|
633
|
-
switch (entryType) {
|
|
634
|
-
case ServerEntryTypeEnum.List:
|
|
635
|
-
return this.getTitleFromList(entry, action);
|
|
636
|
-
case ServerEntryTypeEnum.Text:
|
|
637
|
-
return this.textTransform(entry);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
getTitleFromList(entry, action) {
|
|
642
|
-
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
class ChatClient {
|
|
646
|
-
constructor(container) {
|
|
647
|
-
this.entryInterface = new EntryInterface(container);
|
|
648
|
-
}
|
|
649
|
-
static initialize(user, agent) {
|
|
650
|
-
ChatHelper.setUser(user);
|
|
651
|
-
ChatHelper.setAgent(agent);
|
|
652
|
-
}
|
|
653
|
-
processMessageArrayAndStoreIt(messages) {
|
|
654
731
|
return __async(this, null, function* () {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
732
|
+
if (!!entry) {
|
|
733
|
+
const entryType = ServerEntryTypeEnum[entry.type];
|
|
734
|
+
switch (entryType) {
|
|
735
|
+
case ServerEntryTypeEnum.List:
|
|
736
|
+
return this.getTitleFromList(entry, action);
|
|
737
|
+
case ServerEntryTypeEnum.Text:
|
|
738
|
+
return yield this.textTransform(entry);
|
|
739
|
+
}
|
|
660
740
|
}
|
|
661
|
-
yield StoreHelper.insertOrUpdateMessageArrayStore(messages);
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
updateMessageArrayAndStoreIt(messages) {
|
|
665
|
-
let conversationEntry = void 0;
|
|
666
|
-
messages.forEach((o) => {
|
|
667
|
-
let message = StoreHelper.getMessage(o.id);
|
|
668
|
-
message == null ? void 0 : message.conversationEntry.update(o.message);
|
|
669
|
-
conversationEntry = message == null ? void 0 : message.conversationEntry;
|
|
670
741
|
});
|
|
671
|
-
StoreHelper.insertOrUpdateMessageArrayStore(messages, conversationEntry);
|
|
672
|
-
}
|
|
673
|
-
printUserMessageAndStoreIt(action) {
|
|
674
|
-
if (action == "next" || action == "help")
|
|
675
|
-
return;
|
|
676
|
-
let entry = StoreHelper.getEntry(action);
|
|
677
|
-
let message = {
|
|
678
|
-
id: v4(),
|
|
679
|
-
message: !entry ? action : this.getTitleFromEntry(entry, action),
|
|
680
|
-
isUser: true
|
|
681
|
-
};
|
|
682
|
-
this.postUserMessage(message);
|
|
683
|
-
StoreHelper.insertOrUpdateMessageArrayStore([message]);
|
|
684
|
-
}
|
|
685
|
-
postUserMessage(message) {
|
|
686
|
-
ChatHelper.getUser().print(message.message);
|
|
687
|
-
}
|
|
688
|
-
postAgentMessage(message) {
|
|
689
|
-
message.conversationEntry = ChatHelper.getAgent().print(message.message);
|
|
690
|
-
}
|
|
691
|
-
getTitleFromEntry(entry, action) {
|
|
692
|
-
const entryType = ServerEntryTypeEnum[entry.type];
|
|
693
|
-
switch (entryType) {
|
|
694
|
-
case ServerEntryTypeEnum.List:
|
|
695
|
-
return this.getTitleFromList(entry, action);
|
|
696
|
-
case ServerEntryTypeEnum.Text:
|
|
697
|
-
return this.getTitleFromText(entry, action);
|
|
698
|
-
default:
|
|
699
|
-
return "";
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
getTitleFromText(entry, action) {
|
|
703
|
-
if (!!entry.content.items)
|
|
704
|
-
return this.getTitleFromList(entry, action);
|
|
705
|
-
else
|
|
706
|
-
return entry.content.html;
|
|
707
742
|
}
|
|
708
743
|
getTitleFromList(entry, action) {
|
|
709
744
|
return entry.content.items.find((o) => o.actionKey == action).title;
|
|
710
745
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
let HttpHelper = _HttpHelper;
|
|
721
|
-
HttpHelper.fetchOptions = {
|
|
722
|
-
method: "POST",
|
|
723
|
-
headers: {
|
|
724
|
-
Accept: "application/json",
|
|
725
|
-
"Content-Type": "application/json"
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
HttpHelper.managedSubdomainSuffixes = ["stage", "alpha", "beta", "gamma"];
|
|
729
|
-
HttpHelper.parseSubdomain = (input) => {
|
|
730
|
-
const index = input.lastIndexOf("-");
|
|
731
|
-
const lastPart = input.substr(index + 1);
|
|
732
|
-
if (_HttpHelper.managedSubdomainSuffixes.indexOf(lastPart) > -1) {
|
|
733
|
-
return input.substr(0, index);
|
|
746
|
+
addFeedbackToEntry(current, feedbackEntry) {
|
|
747
|
+
let feedbackObject = this.getListActions(feedbackEntry.content.items, this.getContentText(feedbackEntry), feedbackEntry.actions, feedbackEntry.localState, feedbackEntry.id);
|
|
748
|
+
StoreHelper.insertMessageToStore({
|
|
749
|
+
id: feedbackEntry.id,
|
|
750
|
+
message: void 0,
|
|
751
|
+
entry: feedbackEntry,
|
|
752
|
+
isUser: false
|
|
753
|
+
});
|
|
754
|
+
return current.concat(feedbackObject);
|
|
734
755
|
}
|
|
735
|
-
return input;
|
|
736
756
|
};
|
|
757
|
+
let EntryInterface = _EntryInterface;
|
|
758
|
+
EntryInterface.pagingAmount = void 0;
|
|
737
759
|
class PagingInterface {
|
|
738
760
|
process(entries) {
|
|
739
761
|
const pagingEntry = entries.find((e) => e.tags.indexOf("paging") > -1);
|
|
@@ -876,7 +898,7 @@ class MiddlewareClient {
|
|
|
876
898
|
this.paging = new PagingInterface();
|
|
877
899
|
this.processor = new ProcessorInterface();
|
|
878
900
|
this.entryInterface = new EntryInterface(container);
|
|
879
|
-
this.chatClient = new ChatClient(
|
|
901
|
+
this.chatClient = new ChatClient();
|
|
880
902
|
}
|
|
881
903
|
static initialize(container, widget) {
|
|
882
904
|
MiddlewareHelper.setContainer(container);
|
|
@@ -937,7 +959,7 @@ class HttpClient {
|
|
|
937
959
|
this.endpointUrl = HttpHelper.combineUrl(this.projectionPath, "conversations");
|
|
938
960
|
this.clientId = this.options.clientId;
|
|
939
961
|
this.middlewareClient = new MiddlewareClient(container);
|
|
940
|
-
this.chatClient = new ChatClient(
|
|
962
|
+
this.chatClient = new ChatClient();
|
|
941
963
|
this.container = container;
|
|
942
964
|
}
|
|
943
965
|
firstHit() {
|
|
@@ -1125,7 +1147,7 @@ const KnowledgeBotProviderPlugin = (container) => __async(this, null, function*
|
|
|
1125
1147
|
return next(input);
|
|
1126
1148
|
});
|
|
1127
1149
|
component.actions.watch("conversation.action", (input, next) => {
|
|
1128
|
-
const chatClient = new ChatClient(
|
|
1150
|
+
const chatClient = new ChatClient();
|
|
1129
1151
|
const cmClient = new ContactMethodClient(container);
|
|
1130
1152
|
const loader = conversation.loading();
|
|
1131
1153
|
if (input.split("/").length > 1) {
|