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
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.11";
40
+ var version$1 = "1.13.14";
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;
@@ -508,7 +516,6 @@ var Defaults$1 = {
508
516
  [Capabilities.TEMPDIR]: 'botiumwork',
509
517
  [Capabilities.CLEANUPTEMPDIR]: true,
510
518
  [Capabilities.WAITFORBOTTIMEOUT]: 10000,
511
- [Capabilities.SIMULATE_WRITING_SPEED]: false,
512
519
  [Capabilities.SIMPLEREST_PING_RETRIES]: 6,
513
520
  [Capabilities.SIMPLEREST_PING_TIMEOUT]: 10000,
514
521
  [Capabilities.SIMPLEREST_PING_VERB]: 'GET',
@@ -7787,6 +7794,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7787
7794
  await this._unsubscribeInbound();
7788
7795
  await this._stopPolling();
7789
7796
  this.view = {};
7797
+ this.cookies = {};
7790
7798
  }
7791
7799
  Clean() {
7792
7800
  return this._cleanInbound();
@@ -7853,17 +7861,22 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7853
7861
  }
7854
7862
  const result = [];
7855
7863
  if (isFromUser) {
7856
- const jsonPathRoots = [];
7857
- const jsonPathsBody = getAllCapValues(Capabilities.SIMPLEREST_BODY_JSONPATH, this.caps);
7858
- if (jsonPathsBody.length > 0) {
7859
- for (const jsonPathBody of jsonPathsBody) {
7860
- 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);
7861
7868
  if (lodash.isArray(rb)) {
7862
- rb.forEach(r => jsonPathRoots.push(r));
7869
+ lodash.flattenDeep(rb).forEach(r => flattened.push(r));
7863
7870
  } else if (rb) {
7864
- jsonPathRoots.push(rb);
7871
+ flattened.push(rb);
7865
7872
  }
7866
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));
7867
7880
  } else {
7868
7881
  jsonPathRoots.push(body);
7869
7882
  }
@@ -7881,16 +7894,33 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7881
7894
  });
7882
7895
  return retrievedMedia;
7883
7896
  };
7884
- 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);
7885
7901
  const retrievedButtons = [];
7886
- jsonPathsButtons.forEach(jsonPath => {
7887
- const responseButtons = jsonpath.query(jsonPathButtonRoot, jsonPath);
7888
- if (responseButtons) {
7889
- (lodash.isArray(responseButtons) ? lodash.flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
7890
- text: b
7891
- }));
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
+ }
7892
7916
  }
7893
- });
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
+ }
7894
7924
  return retrievedButtons;
7895
7925
  };
7896
7926
  const _getCardText = responseCardText => {
@@ -7906,7 +7936,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7906
7936
  };
7907
7937
  const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
7908
7938
  debug$4(`found response media: ${util.inspect(media)}`);
7909
- const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
7939
+ const buttons = _retrieveButtons(jsonPathRoot, 'SIMPLEREST_BUTTONS');
7910
7940
  debug$4(`found response buttons: ${util.inspect(buttons)}`);
7911
7941
  const cards = [];
7912
7942
  const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
@@ -7923,7 +7953,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
7923
7953
  jsonPathsCardSubText.forEach(jsonPath => {
7924
7954
  card.subtext = _getCardText(jsonpath.query(c, jsonPath));
7925
7955
  });
7926
- card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
7956
+ card.buttons = _retrieveButtons(c, 'SIMPLEREST_CARD_BUTTONS');
7927
7957
  card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
7928
7958
  if (lodash.keys(card).length > 0) {
7929
7959
  cards.push(card);
@@ -8133,13 +8163,17 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8133
8163
  }));
8134
8164
  if (err) {
8135
8165
  debug$4(`_waitForUrlResponse error on url check ${pingConfig.uri}: ${err}`);
8136
- await timeout(pingConfig.timeout);
8166
+ if (tries <= retries) {
8167
+ await timeout(pingConfig.timeout);
8168
+ }
8137
8169
  } else if (response.statusCode >= 400) {
8138
8170
  debug$4(`_waitForUrlResponse on url check ${pingConfig.uri} got error response: ${response.statusCode}/${response.statusMessage}`);
8139
8171
  if (debug$4.enabled && body) {
8140
8172
  debug$4(Utils.shortenJsonString(body));
8141
8173
  }
8142
- await timeout(pingConfig.timeout);
8174
+ if (tries <= retries) {
8175
+ await timeout(pingConfig.timeout);
8176
+ }
8143
8177
  } else {
8144
8178
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8145
8179
  this._storeCookiesFromResponse(response);
@@ -9188,43 +9222,59 @@ Plugins.PLUGIN_TYPE_LOGICHOOK;
9188
9222
  Plugins.PLUGIN_TYPE_USERINPUT;
9189
9223
  Plugins.TYPE_TO_PREFIX;
9190
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
+
9191
9239
  var botiumCore = {
9192
9240
  BotDriver: BotDriver_1,
9193
- ScriptingProvider: ScriptingProvider_1,
9194
- ScriptingConstants: Constants,
9195
9241
  Capabilities: Capabilities,
9196
9242
  Defaults: Defaults$1,
9197
9243
  Enums: Enums,
9198
- Source: Source,
9199
9244
  Events: Events,
9200
9245
  Plugins: Plugins,
9246
+ Source: Source,
9247
+ InboundProxy: proxy,
9248
+ HookUtils: HookUtils,
9249
+ TranscriptUtils: TranscriptUtils,
9250
+ BotiumMockRichMessageTypes: BotiumMockRichMessageTypes,
9201
9251
  BotiumError: BotiumError_1.BotiumError,
9252
+ ScriptingConstants: Constants,
9202
9253
  ScriptingMemory: ScriptingMemory,
9203
- HookUtils: HookUtils,
9254
+ ScriptingProvider: ScriptingProvider_1,
9204
9255
  LogicHookConstants: LogicHookConsts,
9205
9256
  Lib: {
9206
- tryLoadPlugin: plugins.tryLoadPlugin,
9207
- SimpleRestContainer: SimpleRestContainer_1
9208
- },
9209
- InboundProxy: proxy,
9210
- BotiumMockRichMessageTypes: BotiumMockRichMessageTypes
9257
+ SimpleRestContainer: SimpleRestContainer_1,
9258
+ tryLoadPlugin: plugins.tryLoadPlugin
9259
+ }
9211
9260
  };
9212
9261
  var botiumCore_1 = botiumCore.BotDriver;
9213
- var botiumCore_2 = botiumCore.ScriptingProvider;
9214
- var botiumCore_3 = botiumCore.ScriptingConstants;
9215
- var botiumCore_4 = botiumCore.Capabilities;
9216
- var botiumCore_5 = botiumCore.Defaults;
9217
- 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;
9218
9267
  var botiumCore_7 = botiumCore.Source;
9219
- var botiumCore_8 = botiumCore.Events;
9220
- var botiumCore_9 = botiumCore.Plugins;
9221
- var botiumCore_10 = botiumCore.BotiumError;
9222
- var botiumCore_11 = botiumCore.ScriptingMemory;
9223
- var botiumCore_12 = botiumCore.HookUtils;
9224
- var botiumCore_13 = botiumCore.LogicHookConstants;
9225
- var botiumCore_14 = botiumCore.Lib;
9226
- var botiumCore_15 = botiumCore.InboundProxy;
9227
- 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;
9228
9278
 
9229
- 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 };
9230
9280
  //# sourceMappingURL=botium-es.js.map