botium-core 1.12.2 → 1.12.3

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.
@@ -79,7 +79,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
79
79
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
80
80
 
81
81
  var name = "botium-core";
82
- var version$1 = "1.12.2";
82
+ var version$1 = "1.12.3";
83
83
  var description = "The Selenium for Chatbots";
84
84
  var main = "index.js";
85
85
  var module$1 = "dist/botium-es.js";
@@ -111,7 +111,7 @@ var bugs = {
111
111
  };
112
112
  var homepage = "https://www.botium.ai";
113
113
  var dependencies = {
114
- "@babel/runtime": "^7.16.7",
114
+ "@babel/runtime": "^7.17.2",
115
115
  async: "^3.2.3",
116
116
  "body-parser": "^1.19.1",
117
117
  boolean: "^3.1.4",
@@ -121,7 +121,7 @@ var dependencies = {
121
121
  esprima: "^4.0.1",
122
122
  express: "^4.17.2",
123
123
  globby: "11.0.4",
124
- ioredis: "^4.28.3",
124
+ ioredis: "^4.28.5",
125
125
  "is-class": "^0.0.9",
126
126
  "is-json": "^2.0.1",
127
127
  jsonpath: "^1.1.1",
@@ -144,21 +144,21 @@ var dependencies = {
144
144
  "swagger-jsdoc": "^6.1.0",
145
145
  "swagger-ui-express": "^4.3.0",
146
146
  uuid: "^8.3.2",
147
- vm2: "^3.9.5",
147
+ vm2: "^3.9.7",
148
148
  "write-yaml": "^1.0.0",
149
- xlsx: "^0.17.5",
149
+ xlsx: "^0.18.2",
150
150
  xregexp: "^5.1.0",
151
151
  yaml: "^1.10.2"
152
152
  };
153
153
  var devDependencies = {
154
- "@babel/core": "^7.16.12",
154
+ "@babel/core": "^7.17.2",
155
155
  "@babel/node": "^7.16.8",
156
- "@babel/plugin-transform-runtime": "^7.16.10",
156
+ "@babel/plugin-transform-runtime": "^7.17.0",
157
157
  "@babel/preset-env": "^7.16.11",
158
- chai: "^4.3.4",
158
+ chai: "^4.3.6",
159
159
  "chai-as-promised": "^7.1.1",
160
160
  "cross-env": "^7.0.3",
161
- eslint: "^8.7.0",
161
+ eslint: "^8.9.0",
162
162
  "eslint-config-standard": "^16.0.3",
163
163
  "eslint-plugin-import": "^2.25.4",
164
164
  "eslint-plugin-node": "^11.1.0",
@@ -167,10 +167,10 @@ var devDependencies = {
167
167
  "license-checker": "^25.0.1",
168
168
  "license-compatibility-checker": "^0.3.5",
169
169
  mocha: "^9.2.0",
170
- nock: "^13.2.2",
171
- "npm-check-updates": "^12.2.1",
170
+ nock: "^13.2.4",
171
+ "npm-check-updates": "^12.3.0",
172
172
  nyc: "^15.1.0",
173
- rollup: "^2.66.0",
173
+ rollup: "^2.67.2",
174
174
  "rollup-plugin-babel": "^4.4.0",
175
175
  "rollup-plugin-commonjs": "^10.1.0",
176
176
  "rollup-plugin-json": "^4.0.0",
@@ -287,6 +287,11 @@ var Capabilities = {
287
287
  SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
288
288
  SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
289
289
  SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
290
+ SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
291
+ SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
292
+ SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
293
+ SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
294
+ SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
290
295
  SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
291
296
  SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
292
297
  SIMPLEREST_CONVERSATION_ID_TEMPLATE: 'SIMPLEREST_CONVERSATION_ID_TEMPLATE',
@@ -433,6 +438,11 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
433
438
  Capabilities.SIMPLEREST_RESPONSE_HOOK;
434
439
  Capabilities.SIMPLEREST_MEDIA_JSONPATH;
435
440
  Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
441
+ Capabilities.SIMPLEREST_CARDS_JSONPATH;
442
+ Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
443
+ Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
444
+ Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
445
+ Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
436
446
  Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
437
447
  Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
438
448
  Capabilities.SIMPLEREST_CONVERSATION_ID_TEMPLATE;
@@ -541,7 +551,6 @@ var Defaults$1 = {
541
551
  [Capabilities.SIMPLEREST_METHOD]: 'GET',
542
552
  [Capabilities.SIMPLEREST_IGNORE_EMPTY]: true,
543
553
  [Capabilities.SIMPLEREST_TIMEOUT]: 10000,
544
- [Capabilities.SIMPLEREST_EXTRA_OPTIONS]: {},
545
554
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
546
555
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
547
556
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
@@ -8427,31 +8436,82 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8427
8436
  }
8428
8437
 
8429
8438
  for (const jsonPathRoot of jsonPathRoots) {
8430
- const media = [];
8431
- const buttons = [];
8432
- const jsonPathsMedia = getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps);
8433
- jsonPathsMedia.forEach(jsonPath => {
8434
- const responseMedia = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8435
-
8436
- if (responseMedia) {
8437
- (lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => media.push({
8438
- mediaUri: m,
8439
- mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
8440
- }));
8441
- debug$4(`found response media: ${util__default["default"].inspect(media)}`);
8439
+ const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
8440
+ const retrievedMedia = [];
8441
+ jsonPathsMedia.forEach(jsonPath => {
8442
+ const responseMedia = jsonpath__default["default"].query(jsonPathMediaRoot, jsonPath);
8443
+
8444
+ if (responseMedia) {
8445
+ (lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => retrievedMedia.push({
8446
+ mediaUri: m,
8447
+ mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
8448
+ }));
8449
+ }
8450
+ });
8451
+ return retrievedMedia;
8452
+ };
8453
+
8454
+ const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
8455
+ const retrievedButtons = [];
8456
+ jsonPathsButtons.forEach(jsonPath => {
8457
+ const responseButtons = jsonpath__default["default"].query(jsonPathButtonRoot, jsonPath);
8458
+
8459
+ if (responseButtons) {
8460
+ (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
8461
+ text: b
8462
+ }));
8463
+ }
8464
+ });
8465
+ return retrievedButtons;
8466
+ };
8467
+
8468
+ const _getCardText = responseCardText => {
8469
+ if (responseCardText) {
8470
+ const texts = lodash__default["default"].isArray(responseCardText) ? lodash__default["default"].flattenDeep(responseCardText) : [responseCardText];
8471
+
8472
+ if (texts.length > 1) {
8473
+ debug$4(`more than one text found for card: ${util__default["default"].inspect(texts)}`);
8474
+ }
8475
+
8476
+ if (texts.length > 0) {
8477
+ return texts[0];
8478
+ }
8442
8479
  }
8443
- });
8444
- const jsonPathsButtons = getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps);
8445
- jsonPathsButtons.forEach(jsonPath => {
8446
- const responseButtons = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8447
-
8448
- if (responseButtons) {
8449
- (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => buttons.push({
8450
- text: b
8451
- }));
8452
- debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
8480
+ };
8481
+
8482
+ const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
8483
+
8484
+ debug$4(`found response media: ${util__default["default"].inspect(media)}`);
8485
+
8486
+ const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
8487
+
8488
+ debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
8489
+ const cards = [];
8490
+ const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
8491
+ jsonPathsCards.forEach(jsonPath => {
8492
+ const responseCards = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8493
+
8494
+ if (responseCards) {
8495
+ (lodash__default["default"].isArray(responseCards) ? lodash__default["default"].flattenDeep(responseCards) : [responseCards]).forEach(c => {
8496
+ const card = {};
8497
+ const jsonPathsCardText = getAllCapValues(Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH, this.caps);
8498
+ jsonPathsCardText.forEach(jsonPath => {
8499
+ card.text = _getCardText(jsonpath__default["default"].query(c, jsonPath));
8500
+ });
8501
+ const jsonPathsCardSubText = getAllCapValues(Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH, this.caps);
8502
+ jsonPathsCardSubText.forEach(jsonPath => {
8503
+ card.subtext = _getCardText(jsonpath__default["default"].query(c, jsonPath));
8504
+ });
8505
+ card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
8506
+ card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
8507
+
8508
+ if (lodash__default["default"].keys(card).length > 0) {
8509
+ cards.push(card);
8510
+ }
8511
+ });
8453
8512
  }
8454
8513
  });
8514
+ debug$4(`found response cards: ${util__default["default"].inspect(cards)}`);
8455
8515
  let hasMessageText = false;
8456
8516
  const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
8457
8517
 
@@ -8468,7 +8528,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8468
8528
  sourceData: body,
8469
8529
  messageText,
8470
8530
  media,
8471
- buttons
8531
+ buttons,
8532
+ cards
8472
8533
  };
8473
8534
  await executeHook(this.caps, this.responseHook, Object.assign({
8474
8535
  botMsg,
@@ -8484,7 +8545,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8484
8545
  messageText: '',
8485
8546
  sourceData: body,
8486
8547
  media,
8487
- buttons
8548
+ buttons,
8549
+ cards
8488
8550
  };
8489
8551
  const beforeHookKeys = Object.keys(botMsg);
8490
8552
  await executeHook(this.caps, this.responseHook, Object.assign({
@@ -8493,7 +8555,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8493
8555
  }, this.view));
8494
8556
  const afterHookKeys = Object.keys(botMsg);
8495
8557
 
8496
- if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
8558
+ if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
8497
8559
  result.push(botMsg);
8498
8560
  }
8499
8561
  }
@@ -9459,9 +9521,9 @@ var BotDriver_1 = class BotDriver {
9459
9521
 
9460
9522
  Build() {
9461
9523
  debug$1(`Build - Botium Core Version: ${version}`);
9462
- debug$1(`Build - Capabilites: ${util__default["default"].inspect(this.caps)}`);
9463
- debug$1(`Build - Sources : ${util__default["default"].inspect(this.sources)}`);
9464
- debug$1(`Build - Envs : ${util__default["default"].inspect(this.envs)}`);
9524
+ debug$1(`Build - Capabilites: ${JSON.stringify(lodash__default["default"].pickBy(this.caps, (value, key) => Defaults$1.Capabilities[key] !== value), null, 2)}`);
9525
+ debug$1(`Build - Sources: ${JSON.stringify(lodash__default["default"].pickBy(this.sources, (value, key) => Defaults$1.Sources[key] !== value), null, 2)}`);
9526
+ debug$1(`Build - Envs: ${JSON.stringify(lodash__default["default"].pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9465
9527
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9466
9528
  return new Promise((resolve, reject) => {
9467
9529
  let repo = null;