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.
package/dist/botium-es.js CHANGED
@@ -36,7 +36,7 @@ import express from 'express';
36
36
  import bodyParser from 'body-parser';
37
37
 
38
38
  var name = "botium-core";
39
- var version$1 = "1.12.2";
39
+ var version$1 = "1.12.3";
40
40
  var description = "The Selenium for Chatbots";
41
41
  var main = "index.js";
42
42
  var module = "dist/botium-es.js";
@@ -68,7 +68,7 @@ var bugs = {
68
68
  };
69
69
  var homepage = "https://www.botium.ai";
70
70
  var dependencies = {
71
- "@babel/runtime": "^7.16.7",
71
+ "@babel/runtime": "^7.17.2",
72
72
  async: "^3.2.3",
73
73
  "body-parser": "^1.19.1",
74
74
  boolean: "^3.1.4",
@@ -78,7 +78,7 @@ var dependencies = {
78
78
  esprima: "^4.0.1",
79
79
  express: "^4.17.2",
80
80
  globby: "11.0.4",
81
- ioredis: "^4.28.3",
81
+ ioredis: "^4.28.5",
82
82
  "is-class": "^0.0.9",
83
83
  "is-json": "^2.0.1",
84
84
  jsonpath: "^1.1.1",
@@ -101,21 +101,21 @@ var dependencies = {
101
101
  "swagger-jsdoc": "^6.1.0",
102
102
  "swagger-ui-express": "^4.3.0",
103
103
  uuid: "^8.3.2",
104
- vm2: "^3.9.5",
104
+ vm2: "^3.9.7",
105
105
  "write-yaml": "^1.0.0",
106
- xlsx: "^0.17.5",
106
+ xlsx: "^0.18.2",
107
107
  xregexp: "^5.1.0",
108
108
  yaml: "^1.10.2"
109
109
  };
110
110
  var devDependencies = {
111
- "@babel/core": "^7.16.12",
111
+ "@babel/core": "^7.17.2",
112
112
  "@babel/node": "^7.16.8",
113
- "@babel/plugin-transform-runtime": "^7.16.10",
113
+ "@babel/plugin-transform-runtime": "^7.17.0",
114
114
  "@babel/preset-env": "^7.16.11",
115
- chai: "^4.3.4",
115
+ chai: "^4.3.6",
116
116
  "chai-as-promised": "^7.1.1",
117
117
  "cross-env": "^7.0.3",
118
- eslint: "^8.7.0",
118
+ eslint: "^8.9.0",
119
119
  "eslint-config-standard": "^16.0.3",
120
120
  "eslint-plugin-import": "^2.25.4",
121
121
  "eslint-plugin-node": "^11.1.0",
@@ -124,10 +124,10 @@ var devDependencies = {
124
124
  "license-checker": "^25.0.1",
125
125
  "license-compatibility-checker": "^0.3.5",
126
126
  mocha: "^9.2.0",
127
- nock: "^13.2.2",
128
- "npm-check-updates": "^12.2.1",
127
+ nock: "^13.2.4",
128
+ "npm-check-updates": "^12.3.0",
129
129
  nyc: "^15.1.0",
130
- rollup: "^2.66.0",
130
+ rollup: "^2.67.2",
131
131
  "rollup-plugin-babel": "^4.4.0",
132
132
  "rollup-plugin-commonjs": "^10.1.0",
133
133
  "rollup-plugin-json": "^4.0.0",
@@ -244,6 +244,11 @@ var Capabilities = {
244
244
  SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
245
245
  SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
246
246
  SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
247
+ SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
248
+ SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
249
+ SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
250
+ SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
251
+ SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
247
252
  SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
248
253
  SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
249
254
  SIMPLEREST_CONVERSATION_ID_TEMPLATE: 'SIMPLEREST_CONVERSATION_ID_TEMPLATE',
@@ -390,6 +395,11 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
390
395
  Capabilities.SIMPLEREST_RESPONSE_HOOK;
391
396
  Capabilities.SIMPLEREST_MEDIA_JSONPATH;
392
397
  Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
398
+ Capabilities.SIMPLEREST_CARDS_JSONPATH;
399
+ Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
400
+ Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
401
+ Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
402
+ Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
393
403
  Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
394
404
  Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
395
405
  Capabilities.SIMPLEREST_CONVERSATION_ID_TEMPLATE;
@@ -498,7 +508,6 @@ var Defaults$1 = {
498
508
  [Capabilities.SIMPLEREST_METHOD]: 'GET',
499
509
  [Capabilities.SIMPLEREST_IGNORE_EMPTY]: true,
500
510
  [Capabilities.SIMPLEREST_TIMEOUT]: 10000,
501
- [Capabilities.SIMPLEREST_EXTRA_OPTIONS]: {},
502
511
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
503
512
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
504
513
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
@@ -8384,31 +8393,82 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8384
8393
  }
8385
8394
 
8386
8395
  for (const jsonPathRoot of jsonPathRoots) {
8387
- const media = [];
8388
- const buttons = [];
8389
- const jsonPathsMedia = getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps);
8390
- jsonPathsMedia.forEach(jsonPath => {
8391
- const responseMedia = jsonpath.query(jsonPathRoot, jsonPath);
8392
-
8393
- if (responseMedia) {
8394
- (lodash.isArray(responseMedia) ? lodash.flattenDeep(responseMedia) : [responseMedia]).forEach(m => media.push({
8395
- mediaUri: m,
8396
- mimeType: mimeTypes.lookup(m) || 'application/unknown'
8397
- }));
8398
- debug$4(`found response media: ${util.inspect(media)}`);
8396
+ const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
8397
+ const retrievedMedia = [];
8398
+ jsonPathsMedia.forEach(jsonPath => {
8399
+ const responseMedia = jsonpath.query(jsonPathMediaRoot, jsonPath);
8400
+
8401
+ if (responseMedia) {
8402
+ (lodash.isArray(responseMedia) ? lodash.flattenDeep(responseMedia) : [responseMedia]).forEach(m => retrievedMedia.push({
8403
+ mediaUri: m,
8404
+ mimeType: mimeTypes.lookup(m) || 'application/unknown'
8405
+ }));
8406
+ }
8407
+ });
8408
+ return retrievedMedia;
8409
+ };
8410
+
8411
+ const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
8412
+ const retrievedButtons = [];
8413
+ jsonPathsButtons.forEach(jsonPath => {
8414
+ const responseButtons = jsonpath.query(jsonPathButtonRoot, jsonPath);
8415
+
8416
+ if (responseButtons) {
8417
+ (lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
8418
+ text: b
8419
+ }));
8420
+ }
8421
+ });
8422
+ return retrievedButtons;
8423
+ };
8424
+
8425
+ const _getCardText = responseCardText => {
8426
+ if (responseCardText) {
8427
+ const texts = lodash.isArray(responseCardText) ? lodash.flattenDeep(responseCardText) : [responseCardText];
8428
+
8429
+ if (texts.length > 1) {
8430
+ debug$4(`more than one text found for card: ${util.inspect(texts)}`);
8431
+ }
8432
+
8433
+ if (texts.length > 0) {
8434
+ return texts[0];
8435
+ }
8399
8436
  }
8400
- });
8401
- const jsonPathsButtons = getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps);
8402
- jsonPathsButtons.forEach(jsonPath => {
8403
- const responseButtons = jsonpath.query(jsonPathRoot, jsonPath);
8404
-
8405
- if (responseButtons) {
8406
- (lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => buttons.push({
8407
- text: b
8408
- }));
8409
- debug$4(`found response buttons: ${util.inspect(buttons)}`);
8437
+ };
8438
+
8439
+ const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
8440
+
8441
+ debug$4(`found response media: ${util.inspect(media)}`);
8442
+
8443
+ const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
8444
+
8445
+ debug$4(`found response buttons: ${util.inspect(buttons)}`);
8446
+ const cards = [];
8447
+ const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
8448
+ jsonPathsCards.forEach(jsonPath => {
8449
+ const responseCards = jsonpath.query(jsonPathRoot, jsonPath);
8450
+
8451
+ if (responseCards) {
8452
+ (lodash.isArray(responseCards) ? lodash.flattenDeep(responseCards) : [responseCards]).forEach(c => {
8453
+ const card = {};
8454
+ const jsonPathsCardText = getAllCapValues(Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH, this.caps);
8455
+ jsonPathsCardText.forEach(jsonPath => {
8456
+ card.text = _getCardText(jsonpath.query(c, jsonPath));
8457
+ });
8458
+ const jsonPathsCardSubText = getAllCapValues(Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH, this.caps);
8459
+ jsonPathsCardSubText.forEach(jsonPath => {
8460
+ card.subtext = _getCardText(jsonpath.query(c, jsonPath));
8461
+ });
8462
+ card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
8463
+ card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
8464
+
8465
+ if (lodash.keys(card).length > 0) {
8466
+ cards.push(card);
8467
+ }
8468
+ });
8410
8469
  }
8411
8470
  });
8471
+ debug$4(`found response cards: ${util.inspect(cards)}`);
8412
8472
  let hasMessageText = false;
8413
8473
  const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
8414
8474
 
@@ -8425,7 +8485,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8425
8485
  sourceData: body,
8426
8486
  messageText,
8427
8487
  media,
8428
- buttons
8488
+ buttons,
8489
+ cards
8429
8490
  };
8430
8491
  await executeHook(this.caps, this.responseHook, Object.assign({
8431
8492
  botMsg,
@@ -8441,7 +8502,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8441
8502
  messageText: '',
8442
8503
  sourceData: body,
8443
8504
  media,
8444
- buttons
8505
+ buttons,
8506
+ cards
8445
8507
  };
8446
8508
  const beforeHookKeys = Object.keys(botMsg);
8447
8509
  await executeHook(this.caps, this.responseHook, Object.assign({
@@ -8450,7 +8512,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8450
8512
  }, this.view));
8451
8513
  const afterHookKeys = Object.keys(botMsg);
8452
8514
 
8453
- 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]) {
8515
+ 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]) {
8454
8516
  result.push(botMsg);
8455
8517
  }
8456
8518
  }
@@ -9416,9 +9478,9 @@ var BotDriver_1 = class BotDriver {
9416
9478
 
9417
9479
  Build() {
9418
9480
  debug$1(`Build - Botium Core Version: ${version}`);
9419
- debug$1(`Build - Capabilites: ${util.inspect(this.caps)}`);
9420
- debug$1(`Build - Sources : ${util.inspect(this.sources)}`);
9421
- debug$1(`Build - Envs : ${util.inspect(this.envs)}`);
9481
+ debug$1(`Build - Capabilites: ${JSON.stringify(lodash.pickBy(this.caps, (value, key) => Defaults$1.Capabilities[key] !== value), null, 2)}`);
9482
+ debug$1(`Build - Sources: ${JSON.stringify(lodash.pickBy(this.sources, (value, key) => Defaults$1.Sources[key] !== value), null, 2)}`);
9483
+ debug$1(`Build - Envs: ${JSON.stringify(lodash.pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9422
9484
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9423
9485
  return new Promise((resolve, reject) => {
9424
9486
  let repo = null;