botium-core 1.15.6 → 1.15.8
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/dist/botium-cjs.js +40 -5
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +40 -5
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/Capabilities.js +9 -0
- package/src/containers/plugins/SimpleRestContainer.js +30 -4
- package/test/connectors/simplerest.spec.js +78 -0
package/dist/botium-cjs.js
CHANGED
|
@@ -77,7 +77,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
77
77
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
78
78
|
|
|
79
79
|
var name = "botium-core";
|
|
80
|
-
var version$1 = "1.15.
|
|
80
|
+
var version$1 = "1.15.8";
|
|
81
81
|
var description = "The Selenium for Chatbots";
|
|
82
82
|
var main = "index.js";
|
|
83
83
|
var module$1 = "dist/botium-es.js";
|
|
@@ -322,6 +322,14 @@ var Capabilities = {
|
|
|
322
322
|
SIMPLEREST_NLP_LIST_JSONPATH: 'SIMPLEREST_NLP_LIST_JSONPATH',
|
|
323
323
|
SIMPLEREST_NLP_LIST_INTENT_JSONPATH: 'SIMPLEREST_NLP_LIST_INTENT_JSONPATH',
|
|
324
324
|
SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH: 'SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH',
|
|
325
|
+
/**
|
|
326
|
+
* Single response can contain a list of messages. This capability defines how to merge the list into a single message.
|
|
327
|
+
* It can be 'OFF' (default), 'MERGE_TEXT'
|
|
328
|
+
* @type {string}
|
|
329
|
+
* @default 'OFF'
|
|
330
|
+
* @description Merge message list into single message
|
|
331
|
+
*/
|
|
332
|
+
SIMPLEREST_MESSAGE_LIST_MERGE: 'SIMPLEREST_MESSAGE_LIST_MERGE',
|
|
325
333
|
// Script Compiler
|
|
326
334
|
SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
|
|
327
335
|
// ROW_PER_MESSAGE or QUESTION_ANSWER
|
|
@@ -507,6 +515,7 @@ Capabilities.SIMPLEREST_NLP_FALLBACK_INTENTS;
|
|
|
507
515
|
Capabilities.SIMPLEREST_NLP_LIST_JSONPATH;
|
|
508
516
|
Capabilities.SIMPLEREST_NLP_LIST_INTENT_JSONPATH;
|
|
509
517
|
Capabilities.SIMPLEREST_NLP_LIST_CONFIDENCE_JSONPATH;
|
|
518
|
+
Capabilities.SIMPLEREST_MESSAGE_LIST_MERGE;
|
|
510
519
|
Capabilities.SCRIPTING_TXT_EOL;
|
|
511
520
|
Capabilities.SCRIPTING_XLSX_MODE;
|
|
512
521
|
Capabilities.SCRIPTING_XLSX_EOL_WRITE;
|
|
@@ -8326,7 +8335,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8326
8335
|
}, true, true), 0);
|
|
8327
8336
|
return;
|
|
8328
8337
|
}
|
|
8329
|
-
|
|
8338
|
+
let result = [];
|
|
8330
8339
|
if (isFromUser) {
|
|
8331
8340
|
const _extractFrom = (root, jsonPaths, acceptFn = null) => {
|
|
8332
8341
|
const result = [];
|
|
@@ -8357,6 +8366,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8357
8366
|
} else {
|
|
8358
8367
|
jsonPathRoots.push(body);
|
|
8359
8368
|
}
|
|
8369
|
+
if (jsonPathRoots.length === 0 && !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8370
|
+
debug$4(`found empty body, and processed because of SIMPLEREST_IGNORE_EMPTY capability: ${util__default["default"].inspect(body)}`);
|
|
8371
|
+
result.push({
|
|
8372
|
+
messageText: '',
|
|
8373
|
+
sourceData: body
|
|
8374
|
+
});
|
|
8375
|
+
}
|
|
8360
8376
|
for (const jsonPathRoot of jsonPathRoots) {
|
|
8361
8377
|
const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
|
|
8362
8378
|
const retrievedMedia = [];
|
|
@@ -8548,8 +8564,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8548
8564
|
botMsgRoot: jsonPathRoot
|
|
8549
8565
|
}, this.view));
|
|
8550
8566
|
const afterHookKeys = Object.keys(botMsg);
|
|
8551
|
-
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || botMsg.nlp
|
|
8567
|
+
if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || botMsg.nlp) {
|
|
8552
8568
|
result.push(botMsg);
|
|
8569
|
+
} else if (!this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
|
|
8570
|
+
debug$4(`found empty message, and processed because of SIMPLEREST_IGNORE_EMPTY capability: ${util__default["default"].inspect(botMsg)}`);
|
|
8571
|
+
result.push(botMsg);
|
|
8572
|
+
} else {
|
|
8573
|
+
debug$4(`found empty message, and ignored because of SIMPLEREST_IGNORE_EMPTY capability: ${util__default["default"].inspect(botMsg)}`);
|
|
8553
8574
|
}
|
|
8554
8575
|
}
|
|
8555
8576
|
}
|
|
@@ -8561,6 +8582,21 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8561
8582
|
messageText: ''
|
|
8562
8583
|
}, true, true), 0);
|
|
8563
8584
|
}
|
|
8585
|
+
if (this.caps[Capabilities.SIMPLEREST_MESSAGE_LIST_MERGE] === 'MERGE_TEXT') {
|
|
8586
|
+
const isTextMsg = msg => msg.messageText && (!msg.media || msg.media.length === 0) && (!msg.buttons || msg.buttons.length === 0) && (!msg.cards || msg.cards.length === 0);
|
|
8587
|
+
result = result.reduce((acc, currentMsg) => {
|
|
8588
|
+
if (acc.length > 0) {
|
|
8589
|
+
const last = acc[acc.length - 1];
|
|
8590
|
+
if (isTextMsg(last)) {
|
|
8591
|
+
currentMsg.messageText = [last.messageText, currentMsg.messageText].filter(t => t).join('\n');
|
|
8592
|
+
acc[acc.length - 1] = currentMsg;
|
|
8593
|
+
return acc;
|
|
8594
|
+
}
|
|
8595
|
+
}
|
|
8596
|
+
acc.push(currentMsg);
|
|
8597
|
+
return acc;
|
|
8598
|
+
}, []);
|
|
8599
|
+
}
|
|
8564
8600
|
return result;
|
|
8565
8601
|
}
|
|
8566
8602
|
_doRequest(msg, isFromUser, updateContext) {
|
|
@@ -8573,8 +8609,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
|
|
|
8573
8609
|
fetch(requestOptions.uri, requestOptions).then(async bodyRaw => {
|
|
8574
8610
|
let body;
|
|
8575
8611
|
try {
|
|
8576
|
-
|
|
8577
|
-
if (contentType && contentType.includes('application/json')) {
|
|
8612
|
+
if (bodyRaw?.headers?.get('content-type') && bodyRaw.headers.get('content-type').includes('application/json')) {
|
|
8578
8613
|
try {
|
|
8579
8614
|
body = await bodyRaw.json();
|
|
8580
8615
|
} catch (err) {
|