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
package/dist/botium-es.js CHANGED
@@ -37,7 +37,7 @@ import express from 'express';
37
37
  import bodyParser from 'body-parser';
38
38
 
39
39
  var name = "botium-core";
40
- var version$1 = "1.13.12";
40
+ var version$1 = "1.13.15";
41
41
  var description = "The Selenium for Chatbots";
42
42
  var main = "index.js";
43
43
  var module = "dist/botium-es.js";
@@ -247,10 +247,14 @@ var Capabilities = {
247
247
  SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
248
248
  SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
249
249
  SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
250
+ SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH: 'SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH',
251
+ SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH: 'SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH',
250
252
  SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
251
253
  SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
252
254
  SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
253
255
  SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
256
+ SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH: 'SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH',
257
+ SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH: 'SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH',
254
258
  SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
255
259
  SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
256
260
  SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
@@ -409,10 +413,14 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
409
413
  Capabilities.SIMPLEREST_RESPONSE_HOOK;
410
414
  Capabilities.SIMPLEREST_MEDIA_JSONPATH;
411
415
  Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
416
+ Capabilities.SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH;
417
+ Capabilities.SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH;
412
418
  Capabilities.SIMPLEREST_CARDS_JSONPATH;
413
419
  Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
414
420
  Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
415
421
  Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
422
+ Capabilities.SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH;
423
+ Capabilities.SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH;
416
424
  Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
417
425
  Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
418
426
  Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
@@ -7786,6 +7794,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7786
7794
  await this._unsubscribeInbound();
7787
7795
  await this._stopPolling();
7788
7796
  this.view = {};
7797
+ this.cookies = {};
7789
7798
  }
7790
7799
  Clean() {
7791
7800
  return this._cleanInbound();
@@ -7852,17 +7861,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7852
7861
  }
7853
7862
  const result = [];
7854
7863
  if (isFromUser) {
7855
- const jsonPathRoots = [];
7856
- const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7857
- if (jsonPathsBody.length > 0) {
7858
- for (const jsonPathBody of jsonPathsBody) {
7859
- const rb = jsonpath.query(body, jsonPathBody);
7864
+ const _extractFrom = (root, jsonPaths) => {
7865
+ const flattened = [];
7866
+ for (const jsonPath of jsonPaths) {
7867
+ const rb = jsonpath.query(root, jsonPath);
7860
7868
  if (lodash.isArray(rb)) {
7861
- rb.forEach(r => jsonPathRoots.push(r));
7869
+ lodash.flattenDeep(rb).forEach(r => flattened.push(r));
7862
7870
  } else if (rb) {
7863
- jsonPathRoots.push(rb);
7871
+ flattened.push(rb);
7864
7872
  }
7865
7873
  }
7874
+ return flattened;
7875
+ };
7876
+ const jsonPathRoots = [];
7877
+ const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7878
+ if (jsonPathsBody.length > 0) {
7879
+ jsonPathRoots.push(..._extractFrom(body, jsonPathsBody));
7866
7880
  } else {
7867
7881
  jsonPathRoots.push(body);
7868
7882
  }
@@ -7880,16 +7894,33 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7880
7894
  });
7881
7895
  return retrievedMedia;
7882
7896
  };
7883
- const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
7897
+ const _retrieveButtons = (jsonPathButtonRoot, capPrefix) => {
7898
+ const jsonPathsButtons = getAllCapValues(`${capPrefix}_JSONPATH`, this.caps);
7899
+ const jsonPathsButtonsText = getAllCapValues(`${capPrefix}_TEXT_SUBJSONPATH`, this.caps);
7900
+ const jsonPathsButtonsPayload = getAllCapValues(`${capPrefix}_PAYLOAD_SUBJSONPATH`, this.caps);
7884
7901
  const retrievedButtons = [];
7885
- jsonPathsButtons.forEach(jsonPath => {
7886
- const responseButtons = jsonpath.query(jsonPathButtonRoot, jsonPath);
7887
- if (responseButtons) {
7888
- (lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
7889
- text: b
7890
- }));
7902
+ const responseButtons = _extractFrom(jsonPathButtonRoot, jsonPathsButtons);
7903
+ for (const responseButton of responseButtons) {
7904
+ const retrievedButton = {};
7905
+ if (lodash.isString(responseButton)) {
7906
+ retrievedButton.text = responseButton;
7907
+ } else {
7908
+ if (jsonPathsButtonsText.length > 0) {
7909
+ const possibleTexts = _extractFrom(responseButton, jsonPathsButtonsText);
7910
+ if (possibleTexts.length > 0) retrievedButton.text = possibleTexts[0];
7911
+ }
7912
+ if (jsonPathsButtonsPayload.length > 0) {
7913
+ const possiblePayloads = _extractFrom(responseButton, jsonPathsButtonsPayload);
7914
+ if (possiblePayloads.length > 0) retrievedButton.payload = possiblePayloads[0];
7915
+ }
7891
7916
  }
7892
- });
7917
+ if (Object.keys(retrievedButton).length === 0 && responseButton) {
7918
+ retrievedButton.text = JSON.stringify(responseButton);
7919
+ }
7920
+ if (Object.keys(retrievedButton).length > 0) {
7921
+ retrievedButtons.push(retrievedButton);
7922
+ }
7923
+ }
7893
7924
  return retrievedButtons;
7894
7925
  };
7895
7926
  const _getCardText = responseCardText => {
@@ -7905,7 +7936,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7905
7936
  };
7906
7937
  const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
7907
7938
  debug$4(`found response media: ${util.inspect(media)}`);
7908
- const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
7939
+ const buttons = _retrieveButtons(jsonPathRoot, 'SIMPLEREST_BUTTONS');
7909
7940
  debug$4(`found response buttons: ${util.inspect(buttons)}`);
7910
7941
  const cards = [];
7911
7942
  const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
@@ -7922,7 +7953,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7922
7953
  jsonPathsCardSubText.forEach(jsonPath => {
7923
7954
  card.subtext = _getCardText(jsonpath.query(c, jsonPath));
7924
7955
  });
7925
- card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
7956
+ card.buttons = _retrieveButtons(c, 'SIMPLEREST_CARD_BUTTONS');
7926
7957
  card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
7927
7958
  if (lodash.keys(card).length > 0) {
7928
7959
  cards.push(card);
@@ -8132,13 +8163,17 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8132
8163
  }));
8133
8164
  if (err) {
8134
8165
  debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
8135
- await timeout(pingConfig.timeout);
8166
+ if (tries <= retries) {
8167
+ await timeout(pingConfig.timeout);
8168
+ }
8136
8169
  } else if (response.statusCode >= 400) {
8137
8170
  debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
8138
8171
  if (debug$4.enabled && body) {
8139
8172
  debug$4(Utils.shortenJsonString(body));
8140
8173
  }
8141
- await timeout(pingConfig.timeout);
8174
+ if (tries <= retries) {
8175
+ await timeout(pingConfig.timeout);
8176
+ }
8142
8177
  } else {
8143
8178
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8144
8179
  this._storeCookiesFromResponse(response);
@@ -9187,43 +9222,59 @@ Plugins.PLUGIN_TYPE_LOGICHOOK;
9187
9222
  Plugins.PLUGIN_TYPE_USERINPUT;
9188
9223
  Plugins.TYPE_TO_PREFIX;
9189
9224
 
9225
+ var hasWaitForBotTimeout = transciptError => {
9226
+ if (!transciptError) {
9227
+ return false;
9228
+ }
9229
+ const str = transciptError.message || (lodash.isString(transciptError) ? transciptError : null);
9230
+ if (!str) {
9231
+ return false;
9232
+ }
9233
+ return str.indexOf(': error waiting for bot - Bot did not respond within') > 0;
9234
+ };
9235
+ var TranscriptUtils = {
9236
+ hasWaitForBotTimeout: hasWaitForBotTimeout
9237
+ };
9238
+
9190
9239
  var botiumCore = {
9191
9240
  BotDriver: BotDriver_1,
9192
- ScriptingProvider: ScriptingProvider_1,
9193
- ScriptingConstants: Constants,
9194
9241
  Capabilities: Capabilities,
9195
9242
  Defaults: Defaults$1,
9196
9243
  Enums: Enums,
9197
- Source: Source,
9198
9244
  Events: Events,
9199
9245
  Plugins: Plugins,
9246
+ Source: Source,
9247
+ InboundProxy: proxy,
9248
+ HookUtils: HookUtils,
9249
+ TranscriptUtils: TranscriptUtils,
9250
+ BotiumMockRichMessageTypes: BotiumMockRichMessageTypes,
9200
9251
  BotiumError: BotiumError_1.BotiumError,
9252
+ ScriptingConstants: Constants,
9201
9253
  ScriptingMemory: ScriptingMemory,
9202
- HookUtils: HookUtils,
9254
+ ScriptingProvider: ScriptingProvider_1,
9203
9255
  LogicHookConstants: LogicHookConsts,
9204
9256
  Lib: {
9205
- tryLoadPlugin: plugins.tryLoadPlugin,
9206
- SimpleRestContainer: SimpleRestContainer_1
9207
- },
9208
- InboundProxy: proxy,
9209
- BotiumMockRichMessageTypes: BotiumMockRichMessageTypes
9257
+ SimpleRestContainer: SimpleRestContainer_1,
9258
+ tryLoadPlugin: plugins.tryLoadPlugin
9259
+ }
9210
9260
  };
9211
9261
  var botiumCore_1 = botiumCore.BotDriver;
9212
- var botiumCore_2 = botiumCore.ScriptingProvider;
9213
- var botiumCore_3 = botiumCore.ScriptingConstants;
9214
- var botiumCore_4 = botiumCore.Capabilities;
9215
- var botiumCore_5 = botiumCore.Defaults;
9216
- var botiumCore_6 = botiumCore.Enums;
9262
+ var botiumCore_2 = botiumCore.Capabilities;
9263
+ var botiumCore_3 = botiumCore.Defaults;
9264
+ var botiumCore_4 = botiumCore.Enums;
9265
+ var botiumCore_5 = botiumCore.Events;
9266
+ var botiumCore_6 = botiumCore.Plugins;
9217
9267
  var botiumCore_7 = botiumCore.Source;
9218
- var botiumCore_8 = botiumCore.Events;
9219
- var botiumCore_9 = botiumCore.Plugins;
9220
- var botiumCore_10 = botiumCore.BotiumError;
9221
- var botiumCore_11 = botiumCore.ScriptingMemory;
9222
- var botiumCore_12 = botiumCore.HookUtils;
9223
- var botiumCore_13 = botiumCore.LogicHookConstants;
9224
- var botiumCore_14 = botiumCore.Lib;
9225
- var botiumCore_15 = botiumCore.InboundProxy;
9226
- var botiumCore_16 = botiumCore.BotiumMockRichMessageTypes;
9268
+ var botiumCore_8 = botiumCore.InboundProxy;
9269
+ var botiumCore_9 = botiumCore.HookUtils;
9270
+ var botiumCore_10 = botiumCore.TranscriptUtils;
9271
+ var botiumCore_11 = botiumCore.BotiumMockRichMessageTypes;
9272
+ var botiumCore_12 = botiumCore.BotiumError;
9273
+ var botiumCore_13 = botiumCore.ScriptingConstants;
9274
+ var botiumCore_14 = botiumCore.ScriptingMemory;
9275
+ var botiumCore_15 = botiumCore.ScriptingProvider;
9276
+ var botiumCore_16 = botiumCore.LogicHookConstants;
9277
+ var botiumCore_17 = botiumCore.Lib;
9227
9278
 
9228
- export { botiumCore_1 as BotDriver, botiumCore_10 as BotiumError, botiumCore_16 as BotiumMockRichMessageTypes, botiumCore_4 as Capabilities, botiumCore_5 as Defaults, botiumCore_6 as Enums, botiumCore_8 as Events, botiumCore_12 as HookUtils, botiumCore_15 as InboundProxy, botiumCore_14 as Lib, botiumCore_13 as LogicHookConstants, botiumCore_9 as Plugins, botiumCore_3 as ScriptingConstants, botiumCore_11 as ScriptingMemory, botiumCore_2 as ScriptingProvider, botiumCore_7 as Source, botiumCore as default };
9279
+ export { botiumCore_1 as BotDriver, botiumCore_12 as BotiumError, botiumCore_11 as BotiumMockRichMessageTypes, botiumCore_2 as Capabilities, botiumCore_3 as Defaults, botiumCore_4 as Enums, botiumCore_5 as Events, botiumCore_9 as HookUtils, botiumCore_8 as InboundProxy, botiumCore_17 as Lib, botiumCore_16 as LogicHookConstants, botiumCore_6 as Plugins, botiumCore_13 as ScriptingConstants, botiumCore_14 as ScriptingMemory, botiumCore_15 as ScriptingProvider, botiumCore_7 as Source, botiumCore_10 as TranscriptUtils, botiumCore as default };
9229
9280
  //# sourceMappingURL=botium-es.js.map