botium-core 1.13.12 → 1.13.15

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 (48) hide show
  1. package/dist/botium-cjs.js +109 -57
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +95 -44
  4. package/dist/botium-es.js.map +1 -1
  5. package/index.js +15 -9
  6. package/package.json +1 -1
  7. package/report.js +6 -5
  8. package/src/Capabilities.js +4 -0
  9. package/src/containers/plugins/SimpleRestContainer.js +50 -22
  10. package/src/helpers/TranscriptUtils.js +12 -0
  11. package/test/compiler/compilermarkdown.spec.js +11 -11
  12. package/test/compiler/compilertxt.spec.js +11 -11
  13. package/test/compiler/compilerxlsx.spec.js +10 -10
  14. package/test/connectors/simplerest.spec.js +53 -4
  15. package/test/helpers/convos/hello.convo.txt +6 -0
  16. package/test/helpers/transcriptutils.spec.js +71 -0
  17. /package/test/compiler/convos/md/{convos_with!.md → convos_with_exclamation.md} +0 -0
  18. /package/test/compiler/convos/md/{convos_with!_secline.md → convos_with_exclamation_secline.md} +0 -0
  19. /package/test/compiler/convos/md/{convos_with!!!!.md → convos_with_four_exclamation.md} +0 -0
  20. /package/test/compiler/convos/md/{convos_with????.md → convos_with_four_question.md} +0 -0
  21. /package/test/compiler/convos/md/{convos_with?.md → convos_with_question.md} +0 -0
  22. /package/test/compiler/convos/md/{convos_with?!.md → convos_with_question_exclamation.md} +0 -0
  23. /package/test/compiler/convos/md/{convos_with?_invalid.md → convos_with_question_invalid.md} +0 -0
  24. /package/test/compiler/convos/md/{convos_with?_secline.md → convos_with_question_secline.md} +0 -0
  25. /package/test/compiler/convos/md/{convos_with!!.md → convos_with_two_exclamation.md} +0 -0
  26. /package/test/compiler/convos/md/{convos_with??.md → convos_with_two_question.md} +0 -0
  27. /package/test/compiler/convos/md/{convos_with??!.md → convos_with_two_question_exclamation.md} +0 -0
  28. /package/test/compiler/convos/txt/{convos_with!.convo.txt → convos_with_exclamation.convo.txt} +0 -0
  29. /package/test/compiler/convos/txt/{convos_with!_secline.convo.txt → convos_with_exclamation_secline.convo.txt} +0 -0
  30. /package/test/compiler/convos/txt/{convos_with!!!!.convo.txt → convos_with_four_exclamation.convo.txt} +0 -0
  31. /package/test/compiler/convos/txt/{convos_with????.convo.txt → convos_with_four_question.convo.txt} +0 -0
  32. /package/test/compiler/convos/txt/{convos_with_#.convo.txt → convos_with_hashmark.convo.txt} +0 -0
  33. /package/test/compiler/convos/txt/{convos_with?.convo.txt → convos_with_question.convo.txt} +0 -0
  34. /package/test/compiler/convos/txt/{convos_with?!.convo.txt → convos_with_question_exclamation.convo.txt} +0 -0
  35. /package/test/compiler/convos/txt/{convos_with?_secline.convo.txt → convos_with_question_secline.convo.txt} +0 -0
  36. /package/test/compiler/convos/txt/{convos_with!!.convo.txt → convos_with_two_exclamation.convo.txt} +0 -0
  37. /package/test/compiler/convos/txt/{convos_with??.convo.txt → convos_with_two_question.convo.txt} +0 -0
  38. /package/test/compiler/convos/txt/{convos_with??!.convo.txt → convos_with_two_question_exclamation.convo.txt} +0 -0
  39. /package/test/compiler/convos/xlsx/{convos_with!.xlsx → convos_with_exclamation.xlsx} +0 -0
  40. /package/test/compiler/convos/xlsx/{convos_with!_secline.xlsx → convos_with_exclamation_secline.xlsx} +0 -0
  41. /package/test/compiler/convos/xlsx/{convos_with!!!!.xlsx → convos_with_four_exclamation.xlsx} +0 -0
  42. /package/test/compiler/convos/xlsx/{convos_with????.xlsx → convos_with_four_question.xlsx} +0 -0
  43. /package/test/compiler/convos/xlsx/{convos_with?.xlsx → convos_with_question.xlsx} +0 -0
  44. /package/test/compiler/convos/xlsx/{convos_with?!.xlsx → convos_with_question_exclamation.xlsx} +0 -0
  45. /package/test/compiler/convos/xlsx/{convos_with?_secline.xlsx → convos_with_question_secline.xlsx} +0 -0
  46. /package/test/compiler/convos/xlsx/{convos_with!!.xlsx → convos_with_two_exclamation.xlsx} +0 -0
  47. /package/test/compiler/convos/xlsx/{convos_with??.xlsx → convos_with_two_question.xlsx} +0 -0
  48. /package/test/compiler/convos/xlsx/{convos_with??!.xlsx → convos_with_two_question_exclamation.xlsx} +0 -0
@@ -81,7 +81,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
81
81
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
82
82
 
83
83
  var name = "botium-core";
84
- var version$1 = "1.13.12";
84
+ var version$1 = "1.13.15";
85
85
  var description = "The Selenium for Chatbots";
86
86
  var main = "index.js";
87
87
  var module$1 = "dist/botium-es.js";
@@ -291,10 +291,14 @@ var Capabilities = {
291
291
  SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
292
292
  SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
293
293
  SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
294
+ SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH: 'SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH',
295
+ SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH: 'SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH',
294
296
  SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
295
297
  SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
296
298
  SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
297
299
  SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
300
+ SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH: 'SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH',
301
+ SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH: 'SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH',
298
302
  SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
299
303
  SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
300
304
  SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
@@ -453,10 +457,14 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
453
457
  Capabilities.SIMPLEREST_RESPONSE_HOOK;
454
458
  Capabilities.SIMPLEREST_MEDIA_JSONPATH;
455
459
  Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
460
+ Capabilities.SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH;
461
+ Capabilities.SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH;
456
462
  Capabilities.SIMPLEREST_CARDS_JSONPATH;
457
463
  Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
458
464
  Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
459
465
  Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
466
+ Capabilities.SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH;
467
+ Capabilities.SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH;
460
468
  Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
461
469
  Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
462
470
  Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
@@ -7830,6 +7838,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7830
7838
  await this._unsubscribeInbound();
7831
7839
  await this._stopPolling();
7832
7840
  this.view = {};
7841
+ this.cookies = {};
7833
7842
  }
7834
7843
  Clean() {
7835
7844
  return this._cleanInbound();
@@ -7896,17 +7905,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7896
7905
  }
7897
7906
  const result = [];
7898
7907
  if (isFromUser) {
7899
- const jsonPathRoots = [];
7900
- const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7901
- if (jsonPathsBody.length > 0) {
7902
- for (const jsonPathBody of jsonPathsBody) {
7903
- const rb = jsonpath__default["default"].query(body, jsonPathBody);
7908
+ const _extractFrom = (root, jsonPaths) => {
7909
+ const flattened = [];
7910
+ for (const jsonPath of jsonPaths) {
7911
+ const rb = jsonpath__default["default"].query(root, jsonPath);
7904
7912
  if (lodash__default["default"].isArray(rb)) {
7905
- rb.forEach(r => jsonPathRoots.push(r));
7913
+ lodash__default["default"].flattenDeep(rb).forEach(r => flattened.push(r));
7906
7914
  } else if (rb) {
7907
- jsonPathRoots.push(rb);
7915
+ flattened.push(rb);
7908
7916
  }
7909
7917
  }
7918
+ return flattened;
7919
+ };
7920
+ const jsonPathRoots = [];
7921
+ const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7922
+ if (jsonPathsBody.length > 0) {
7923
+ jsonPathRoots.push(..._extractFrom(body, jsonPathsBody));
7910
7924
  } else {
7911
7925
  jsonPathRoots.push(body);
7912
7926
  }
@@ -7924,16 +7938,33 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7924
7938
  });
7925
7939
  return retrievedMedia;
7926
7940
  };
7927
- const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
7941
+ const _retrieveButtons = (jsonPathButtonRoot, capPrefix) => {
7942
+ const jsonPathsButtons = getAllCapValues(`${capPrefix}_JSONPATH`, this.caps);
7943
+ const jsonPathsButtonsText = getAllCapValues(`${capPrefix}_TEXT_SUBJSONPATH`, this.caps);
7944
+ const jsonPathsButtonsPayload = getAllCapValues(`${capPrefix}_PAYLOAD_SUBJSONPATH`, this.caps);
7928
7945
  const retrievedButtons = [];
7929
- jsonPathsButtons.forEach(jsonPath => {
7930
- const responseButtons = jsonpath__default["default"].query(jsonPathButtonRoot, jsonPath);
7931
- if (responseButtons) {
7932
- (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
7933
- text: b
7934
- }));
7946
+ const responseButtons = _extractFrom(jsonPathButtonRoot, jsonPathsButtons);
7947
+ for (const responseButton of responseButtons) {
7948
+ const retrievedButton = {};
7949
+ if (lodash__default["default"].isString(responseButton)) {
7950
+ retrievedButton.text = responseButton;
7951
+ } else {
7952
+ if (jsonPathsButtonsText.length > 0) {
7953
+ const possibleTexts = _extractFrom(responseButton, jsonPathsButtonsText);
7954
+ if (possibleTexts.length > 0) retrievedButton.text = possibleTexts[0];
7955
+ }
7956
+ if (jsonPathsButtonsPayload.length > 0) {
7957
+ const possiblePayloads = _extractFrom(responseButton, jsonPathsButtonsPayload);
7958
+ if (possiblePayloads.length > 0) retrievedButton.payload = possiblePayloads[0];
7959
+ }
7935
7960
  }
7936
- });
7961
+ if (Object.keys(retrievedButton).length === 0 && responseButton) {
7962
+ retrievedButton.text = JSON.stringify(responseButton);
7963
+ }
7964
+ if (Object.keys(retrievedButton).length > 0) {
7965
+ retrievedButtons.push(retrievedButton);
7966
+ }
7967
+ }
7937
7968
  return retrievedButtons;
7938
7969
  };
7939
7970
  const _getCardText = responseCardText => {
@@ -7949,7 +7980,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7949
7980
  };
7950
7981
  const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
7951
7982
  debug$4(`found response media: ${util__default["default"].inspect(media)}`);
7952
- const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
7983
+ const buttons = _retrieveButtons(jsonPathRoot, 'SIMPLEREST_BUTTONS');
7953
7984
  debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
7954
7985
  const cards = [];
7955
7986
  const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
@@ -7966,7 +7997,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7966
7997
  jsonPathsCardSubText.forEach(jsonPath => {
7967
7998
  card.subtext = _getCardText(jsonpath__default["default"].query(c, jsonPath));
7968
7999
  });
7969
- card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
8000
+ card.buttons = _retrieveButtons(c, 'SIMPLEREST_CARD_BUTTONS');
7970
8001
  card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
7971
8002
  if (lodash__default["default"].keys(card).length > 0) {
7972
8003
  cards.push(card);
@@ -8176,13 +8207,17 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8176
8207
  }));
8177
8208
  if (err) {
8178
8209
  debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
8179
- await timeout(pingConfig.timeout);
8210
+ if (tries <= retries) {
8211
+ await timeout(pingConfig.timeout);
8212
+ }
8180
8213
  } else if (response.statusCode >= 400) {
8181
8214
  debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
8182
8215
  if (debug$4.enabled && body) {
8183
8216
  debug$4(Utils.shortenJsonString(body));
8184
8217
  }
8185
- await timeout(pingConfig.timeout);
8218
+ if (tries <= retries) {
8219
+ await timeout(pingConfig.timeout);
8220
+ }
8186
8221
  } else {
8187
8222
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8188
8223
  this._storeCookiesFromResponse(response);
@@ -9231,59 +9266,76 @@ Plugins.PLUGIN_TYPE_LOGICHOOK;
9231
9266
  Plugins.PLUGIN_TYPE_USERINPUT;
9232
9267
  Plugins.TYPE_TO_PREFIX;
9233
9268
 
9269
+ var hasWaitForBotTimeout = transciptError => {
9270
+ if (!transciptError) {
9271
+ return false;
9272
+ }
9273
+ const str = transciptError.message || (lodash__default["default"].isString(transciptError) ? transciptError : null);
9274
+ if (!str) {
9275
+ return false;
9276
+ }
9277
+ return str.indexOf(': error waiting for bot - Bot did not respond within') > 0;
9278
+ };
9279
+ var TranscriptUtils = {
9280
+ hasWaitForBotTimeout: hasWaitForBotTimeout
9281
+ };
9282
+
9234
9283
  var botiumCore = {
9235
9284
  BotDriver: BotDriver_1,
9236
- ScriptingProvider: ScriptingProvider_1,
9237
- ScriptingConstants: Constants,
9238
9285
  Capabilities: Capabilities,
9239
9286
  Defaults: Defaults$1,
9240
9287
  Enums: Enums,
9241
- Source: Source,
9242
9288
  Events: Events,
9243
9289
  Plugins: Plugins,
9290
+ Source: Source,
9291
+ InboundProxy: proxy,
9292
+ HookUtils: HookUtils,
9293
+ TranscriptUtils: TranscriptUtils,
9294
+ BotiumMockRichMessageTypes: BotiumMockRichMessageTypes,
9244
9295
  BotiumError: BotiumError_1.BotiumError,
9296
+ ScriptingConstants: Constants,
9245
9297
  ScriptingMemory: ScriptingMemory,
9246
- HookUtils: HookUtils,
9298
+ ScriptingProvider: ScriptingProvider_1,
9247
9299
  LogicHookConstants: LogicHookConsts,
9248
9300
  Lib: {
9249
- tryLoadPlugin: plugins.tryLoadPlugin,
9250
- SimpleRestContainer: SimpleRestContainer_1
9251
- },
9252
- InboundProxy: proxy,
9253
- BotiumMockRichMessageTypes: BotiumMockRichMessageTypes
9301
+ SimpleRestContainer: SimpleRestContainer_1,
9302
+ tryLoadPlugin: plugins.tryLoadPlugin
9303
+ }
9254
9304
  };
9255
9305
  var botiumCore_1 = botiumCore.BotDriver;
9256
- var botiumCore_2 = botiumCore.ScriptingProvider;
9257
- var botiumCore_3 = botiumCore.ScriptingConstants;
9258
- var botiumCore_4 = botiumCore.Capabilities;
9259
- var botiumCore_5 = botiumCore.Defaults;
9260
- var botiumCore_6 = botiumCore.Enums;
9306
+ var botiumCore_2 = botiumCore.Capabilities;
9307
+ var botiumCore_3 = botiumCore.Defaults;
9308
+ var botiumCore_4 = botiumCore.Enums;
9309
+ var botiumCore_5 = botiumCore.Events;
9310
+ var botiumCore_6 = botiumCore.Plugins;
9261
9311
  var botiumCore_7 = botiumCore.Source;
9262
- var botiumCore_8 = botiumCore.Events;
9263
- var botiumCore_9 = botiumCore.Plugins;
9264
- var botiumCore_10 = botiumCore.BotiumError;
9265
- var botiumCore_11 = botiumCore.ScriptingMemory;
9266
- var botiumCore_12 = botiumCore.HookUtils;
9267
- var botiumCore_13 = botiumCore.LogicHookConstants;
9268
- var botiumCore_14 = botiumCore.Lib;
9269
- var botiumCore_15 = botiumCore.InboundProxy;
9270
- var botiumCore_16 = botiumCore.BotiumMockRichMessageTypes;
9312
+ var botiumCore_8 = botiumCore.InboundProxy;
9313
+ var botiumCore_9 = botiumCore.HookUtils;
9314
+ var botiumCore_10 = botiumCore.TranscriptUtils;
9315
+ var botiumCore_11 = botiumCore.BotiumMockRichMessageTypes;
9316
+ var botiumCore_12 = botiumCore.BotiumError;
9317
+ var botiumCore_13 = botiumCore.ScriptingConstants;
9318
+ var botiumCore_14 = botiumCore.ScriptingMemory;
9319
+ var botiumCore_15 = botiumCore.ScriptingProvider;
9320
+ var botiumCore_16 = botiumCore.LogicHookConstants;
9321
+ var botiumCore_17 = botiumCore.Lib;
9271
9322
 
9272
9323
  exports.BotDriver = botiumCore_1;
9273
- exports.BotiumError = botiumCore_10;
9274
- exports.BotiumMockRichMessageTypes = botiumCore_16;
9275
- exports.Capabilities = botiumCore_4;
9276
- exports.Defaults = botiumCore_5;
9277
- exports.Enums = botiumCore_6;
9278
- exports.Events = botiumCore_8;
9279
- exports.HookUtils = botiumCore_12;
9280
- exports.InboundProxy = botiumCore_15;
9281
- exports.Lib = botiumCore_14;
9282
- exports.LogicHookConstants = botiumCore_13;
9283
- exports.Plugins = botiumCore_9;
9284
- exports.ScriptingConstants = botiumCore_3;
9285
- exports.ScriptingMemory = botiumCore_11;
9286
- exports.ScriptingProvider = botiumCore_2;
9324
+ exports.BotiumError = botiumCore_12;
9325
+ exports.BotiumMockRichMessageTypes = botiumCore_11;
9326
+ exports.Capabilities = botiumCore_2;
9327
+ exports.Defaults = botiumCore_3;
9328
+ exports.Enums = botiumCore_4;
9329
+ exports.Events = botiumCore_5;
9330
+ exports.HookUtils = botiumCore_9;
9331
+ exports.InboundProxy = botiumCore_8;
9332
+ exports.Lib = botiumCore_17;
9333
+ exports.LogicHookConstants = botiumCore_16;
9334
+ exports.Plugins = botiumCore_6;
9335
+ exports.ScriptingConstants = botiumCore_13;
9336
+ exports.ScriptingMemory = botiumCore_14;
9337
+ exports.ScriptingProvider = botiumCore_15;
9287
9338
  exports.Source = botiumCore_7;
9339
+ exports.TranscriptUtils = botiumCore_10;
9288
9340
  exports["default"] = botiumCore;
9289
9341
  //# sourceMappingURL=botium-cjs.js.map