botium-core 1.13.11 → 1.13.14

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 (49) hide show
  1. package/dist/botium-cjs.js +109 -58
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +95 -45
  4. package/dist/botium-es.js.map +1 -1
  5. package/index.js +15 -9
  6. package/package.json +1 -1
  7. package/src/Capabilities.js +4 -0
  8. package/src/Defaults.js +0 -1
  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/compiler/convos/md/{convos_with!.md → convos_with_exclamation.md} +0 -0
  15. package/test/compiler/convos/md/{convos_with!_secline.md → convos_with_exclamation_secline.md} +0 -0
  16. package/test/compiler/convos/md/{convos_with!!!!.md → convos_with_four_exclamation.md} +0 -0
  17. package/test/compiler/convos/md/{convos_with????.md → convos_with_four_question.md} +0 -0
  18. package/test/compiler/convos/md/{convos_with?.md → convos_with_question.md} +0 -0
  19. package/test/compiler/convos/md/{convos_with?!.md → convos_with_question_exclamation.md} +0 -0
  20. package/test/compiler/convos/md/{convos_with?_invalid.md → convos_with_question_invalid.md} +0 -0
  21. package/test/compiler/convos/md/{convos_with?_secline.md → convos_with_question_secline.md} +0 -0
  22. package/test/compiler/convos/md/{convos_with!!.md → convos_with_two_exclamation.md} +0 -0
  23. package/test/compiler/convos/md/{convos_with??.md → convos_with_two_question.md} +0 -0
  24. package/test/compiler/convos/md/{convos_with??!.md → convos_with_two_question_exclamation.md} +0 -0
  25. package/test/compiler/convos/txt/{convos_with!.convo.txt → convos_with_exclamation.convo.txt} +0 -0
  26. package/test/compiler/convos/txt/{convos_with!_secline.convo.txt → convos_with_exclamation_secline.convo.txt} +0 -0
  27. package/test/compiler/convos/txt/{convos_with!!!!.convo.txt → convos_with_four_exclamation.convo.txt} +0 -0
  28. package/test/compiler/convos/txt/{convos_with????.convo.txt → convos_with_four_question.convo.txt} +0 -0
  29. package/test/compiler/convos/txt/{convos_with_#.convo.txt → convos_with_hashmark.convo.txt} +0 -0
  30. package/test/compiler/convos/txt/{convos_with?.convo.txt → convos_with_question.convo.txt} +0 -0
  31. package/test/compiler/convos/txt/{convos_with?!.convo.txt → convos_with_question_exclamation.convo.txt} +0 -0
  32. package/test/compiler/convos/txt/{convos_with?_secline.convo.txt → convos_with_question_secline.convo.txt} +0 -0
  33. package/test/compiler/convos/txt/{convos_with!!.convo.txt → convos_with_two_exclamation.convo.txt} +0 -0
  34. package/test/compiler/convos/txt/{convos_with??.convo.txt → convos_with_two_question.convo.txt} +0 -0
  35. package/test/compiler/convos/txt/{convos_with??!.convo.txt → convos_with_two_question_exclamation.convo.txt} +0 -0
  36. package/test/compiler/convos/xlsx/{convos_with!.xlsx → convos_with_exclamation.xlsx} +0 -0
  37. package/test/compiler/convos/xlsx/{convos_with!_secline.xlsx → convos_with_exclamation_secline.xlsx} +0 -0
  38. package/test/compiler/convos/xlsx/{convos_with!!!!.xlsx → convos_with_four_exclamation.xlsx} +0 -0
  39. package/test/compiler/convos/xlsx/{convos_with????.xlsx → convos_with_four_question.xlsx} +0 -0
  40. package/test/compiler/convos/xlsx/{convos_with?.xlsx → convos_with_question.xlsx} +0 -0
  41. package/test/compiler/convos/xlsx/{convos_with?!.xlsx → convos_with_question_exclamation.xlsx} +0 -0
  42. package/test/compiler/convos/xlsx/{convos_with?_secline.xlsx → convos_with_question_secline.xlsx} +0 -0
  43. package/test/compiler/convos/xlsx/{convos_with!!.xlsx → convos_with_two_exclamation.xlsx} +0 -0
  44. package/test/compiler/convos/xlsx/{convos_with??.xlsx → convos_with_two_question.xlsx} +0 -0
  45. package/test/compiler/convos/xlsx/{convos_with??!.xlsx → convos_with_two_question_exclamation.xlsx} +0 -0
  46. package/test/connectors/simplerest.spec.js +53 -4
  47. package/test/driver/capabilities.spec.js +7 -7
  48. package/test/helpers/convos/hello.convo.txt +6 -0
  49. package/test/helpers/transcriptutils.spec.js +71 -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.11";
84
+ var version$1 = "1.13.14";
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;
@@ -552,7 +560,6 @@ var Defaults$1 = {
552
560
  [Capabilities.TEMPDIR]: 'botiumwork',
553
561
  [Capabilities.CLEANUPTEMPDIR]: true,
554
562
  [Capabilities.WAITFORBOTTIMEOUT]: 10000,
555
- [Capabilities.SIMULATE_WRITING_SPEED]: false,
556
563
  [Capabilities.SIMPLEREST_PING_RETRIES]: 6,
557
564
  [Capabilities.SIMPLEREST_PING_TIMEOUT]: 10000,
558
565
  [Capabilities.SIMPLEREST_PING_VERB]: 'GET',
@@ -7831,6 +7838,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7831
7838
  await this._unsubscribeInbound();
7832
7839
  await this._stopPolling();
7833
7840
  this.view = {};
7841
+ this.cookies = {};
7834
7842
  }
7835
7843
  Clean() {
7836
7844
  return this._cleanInbound();
@@ -7897,17 +7905,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7897
7905
  }
7898
7906
  const result = [];
7899
7907
  if (isFromUser) {
7900
- const jsonPathRoots = [];
7901
- const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7902
- if (jsonPathsBody.length > 0) {
7903
- for (const jsonPathBody of jsonPathsBody) {
7904
- 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);
7905
7912
  if (lodash__default["default"].isArray(rb)) {
7906
- rb.forEach(r => jsonPathRoots.push(r));
7913
+ lodash__default["default"].flattenDeep(rb).forEach(r => flattened.push(r));
7907
7914
  } else if (rb) {
7908
- jsonPathRoots.push(rb);
7915
+ flattened.push(rb);
7909
7916
  }
7910
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));
7911
7924
  } else {
7912
7925
  jsonPathRoots.push(body);
7913
7926
  }
@@ -7925,16 +7938,33 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7925
7938
  });
7926
7939
  return retrievedMedia;
7927
7940
  };
7928
- 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);
7929
7945
  const retrievedButtons = [];
7930
- jsonPathsButtons.forEach(jsonPath => {
7931
- const responseButtons = jsonpath__default["default"].query(jsonPathButtonRoot, jsonPath);
7932
- if (responseButtons) {
7933
- (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
7934
- text: b
7935
- }));
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
+ }
7936
7960
  }
7937
- });
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
+ }
7938
7968
  return retrievedButtons;
7939
7969
  };
7940
7970
  const _getCardText = responseCardText => {
@@ -7950,7 +7980,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7950
7980
  };
7951
7981
  const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
7952
7982
  debug$4(`found response media: ${util__default["default"].inspect(media)}`);
7953
- const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
7983
+ const buttons = _retrieveButtons(jsonPathRoot, 'SIMPLEREST_BUTTONS');
7954
7984
  debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
7955
7985
  const cards = [];
7956
7986
  const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
@@ -7967,7 +7997,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7967
7997
  jsonPathsCardSubText.forEach(jsonPath => {
7968
7998
  card.subtext = _getCardText(jsonpath__default["default"].query(c, jsonPath));
7969
7999
  });
7970
- card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
8000
+ card.buttons = _retrieveButtons(c, 'SIMPLEREST_CARD_BUTTONS');
7971
8001
  card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
7972
8002
  if (lodash__default["default"].keys(card).length > 0) {
7973
8003
  cards.push(card);
@@ -8177,13 +8207,17 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8177
8207
  }));
8178
8208
  if (err) {
8179
8209
  debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
8180
- await timeout(pingConfig.timeout);
8210
+ if (tries <= retries) {
8211
+ await timeout(pingConfig.timeout);
8212
+ }
8181
8213
  } else if (response.statusCode >= 400) {
8182
8214
  debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
8183
8215
  if (debug$4.enabled && body) {
8184
8216
  debug$4(Utils.shortenJsonString(body));
8185
8217
  }
8186
- await timeout(pingConfig.timeout);
8218
+ if (tries <= retries) {
8219
+ await timeout(pingConfig.timeout);
8220
+ }
8187
8221
  } else {
8188
8222
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8189
8223
  this._storeCookiesFromResponse(response);
@@ -9232,59 +9266,76 @@ Plugins.PLUGIN_TYPE_LOGICHOOK;
9232
9266
  Plugins.PLUGIN_TYPE_USERINPUT;
9233
9267
  Plugins.TYPE_TO_PREFIX;
9234
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
+
9235
9283
  var botiumCore = {
9236
9284
  BotDriver: BotDriver_1,
9237
- ScriptingProvider: ScriptingProvider_1,
9238
- ScriptingConstants: Constants,
9239
9285
  Capabilities: Capabilities,
9240
9286
  Defaults: Defaults$1,
9241
9287
  Enums: Enums,
9242
- Source: Source,
9243
9288
  Events: Events,
9244
9289
  Plugins: Plugins,
9290
+ Source: Source,
9291
+ InboundProxy: proxy,
9292
+ HookUtils: HookUtils,
9293
+ TranscriptUtils: TranscriptUtils,
9294
+ BotiumMockRichMessageTypes: BotiumMockRichMessageTypes,
9245
9295
  BotiumError: BotiumError_1.BotiumError,
9296
+ ScriptingConstants: Constants,
9246
9297
  ScriptingMemory: ScriptingMemory,
9247
- HookUtils: HookUtils,
9298
+ ScriptingProvider: ScriptingProvider_1,
9248
9299
  LogicHookConstants: LogicHookConsts,
9249
9300
  Lib: {
9250
- tryLoadPlugin: plugins.tryLoadPlugin,
9251
- SimpleRestContainer: SimpleRestContainer_1
9252
- },
9253
- InboundProxy: proxy,
9254
- BotiumMockRichMessageTypes: BotiumMockRichMessageTypes
9301
+ SimpleRestContainer: SimpleRestContainer_1,
9302
+ tryLoadPlugin: plugins.tryLoadPlugin
9303
+ }
9255
9304
  };
9256
9305
  var botiumCore_1 = botiumCore.BotDriver;
9257
- var botiumCore_2 = botiumCore.ScriptingProvider;
9258
- var botiumCore_3 = botiumCore.ScriptingConstants;
9259
- var botiumCore_4 = botiumCore.Capabilities;
9260
- var botiumCore_5 = botiumCore.Defaults;
9261
- 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;
9262
9311
  var botiumCore_7 = botiumCore.Source;
9263
- var botiumCore_8 = botiumCore.Events;
9264
- var botiumCore_9 = botiumCore.Plugins;
9265
- var botiumCore_10 = botiumCore.BotiumError;
9266
- var botiumCore_11 = botiumCore.ScriptingMemory;
9267
- var botiumCore_12 = botiumCore.HookUtils;
9268
- var botiumCore_13 = botiumCore.LogicHookConstants;
9269
- var botiumCore_14 = botiumCore.Lib;
9270
- var botiumCore_15 = botiumCore.InboundProxy;
9271
- 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;
9272
9322
 
9273
9323
  exports.BotDriver = botiumCore_1;
9274
- exports.BotiumError = botiumCore_10;
9275
- exports.BotiumMockRichMessageTypes = botiumCore_16;
9276
- exports.Capabilities = botiumCore_4;
9277
- exports.Defaults = botiumCore_5;
9278
- exports.Enums = botiumCore_6;
9279
- exports.Events = botiumCore_8;
9280
- exports.HookUtils = botiumCore_12;
9281
- exports.InboundProxy = botiumCore_15;
9282
- exports.Lib = botiumCore_14;
9283
- exports.LogicHookConstants = botiumCore_13;
9284
- exports.Plugins = botiumCore_9;
9285
- exports.ScriptingConstants = botiumCore_3;
9286
- exports.ScriptingMemory = botiumCore_11;
9287
- 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;
9288
9338
  exports.Source = botiumCore_7;
9339
+ exports.TranscriptUtils = botiumCore_10;
9289
9340
  exports["default"] = botiumCore;
9290
9341
  //# sourceMappingURL=botium-cjs.js.map