botium-core 1.13.1 → 1.13.4

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 (56) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +291 -86
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +290 -86
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +3 -1
  7. package/src/Capabilities.js +4 -1
  8. package/src/Defaults.js +4 -0
  9. package/src/containers/plugins/SimpleRestContainer.js +23 -16
  10. package/src/grid/inbound/proxy.js +2 -1
  11. package/src/mocks/BotiumMockScripting.js +1 -0
  12. package/src/scripting/Convo.js +16 -10
  13. package/src/scripting/MatchFunctions.js +10 -0
  14. package/src/scripting/ScriptingProvider.js +162 -69
  15. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  16. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  17. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  18. package/test/compiler/compilercsv.spec.js +104 -3
  19. package/test/compiler/compilerjson.spec.js +0 -2
  20. package/test/compiler/compilerxlsx.spec.js +1 -1
  21. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  22. package/test/connectors/simplerest.spec.js +1012 -969
  23. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  24. package/test/convo/partialconvo.spec.js +345 -339
  25. package/test/driver/capabilities.spec.js +156 -151
  26. package/test/logichooks/hookfromsrc.spec.js +79 -73
  27. package/test/plugins/plugins.spec.js +44 -42
  28. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  29. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  30. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  31. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  32. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  33. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  34. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  35. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  36. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  37. package/test/scripting/matching/matchingmode.spec.js +306 -258
  38. package/test/scripting/scriptingProvider.spec.js +720 -630
  39. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  40. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  41. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  42. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  43. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  44. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  45. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  46. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  47. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  53. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  54. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  55. package/test/security/allowUnsafe.spec.js +274 -268
  56. package/test/utils.spec.js +40 -38
@@ -24,6 +24,7 @@ var promise = require('promise.allsettled');
24
24
  var uuid = require('uuid');
25
25
  var jsonpath = require('jsonpath');
26
26
  var isJson$1 = require('is-json');
27
+ var wordErrorRate = require('word-error-rate');
27
28
  var esprima = require('esprima');
28
29
  var markdownIt = require('markdown-it');
29
30
  var xlsx = require('xlsx');
@@ -63,6 +64,7 @@ var promise__default = /*#__PURE__*/_interopDefaultLegacy(promise);
63
64
  var uuid__default = /*#__PURE__*/_interopDefaultLegacy(uuid);
64
65
  var jsonpath__default = /*#__PURE__*/_interopDefaultLegacy(jsonpath);
65
66
  var isJson__default = /*#__PURE__*/_interopDefaultLegacy(isJson$1);
67
+ var wordErrorRate__default = /*#__PURE__*/_interopDefaultLegacy(wordErrorRate);
66
68
  var esprima__default = /*#__PURE__*/_interopDefaultLegacy(esprima);
67
69
  var markdownIt__default = /*#__PURE__*/_interopDefaultLegacy(markdownIt);
68
70
  var xlsx__default = /*#__PURE__*/_interopDefaultLegacy(xlsx);
@@ -79,7 +81,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
79
81
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
80
82
 
81
83
  var name = "botium-core";
82
- var version$1 = "1.13.1";
84
+ var version$1 = "1.13.4";
83
85
  var description = "The Selenium for Chatbots";
84
86
  var main = "index.js";
85
87
  var module$1 = "dist/botium-es.js";
@@ -145,6 +147,7 @@ var dependencies = {
145
147
  "swagger-ui-express": "^4.4.0",
146
148
  uuid: "^8.3.2",
147
149
  vm2: "^3.9.10",
150
+ "word-error-rate": "0.0.7",
148
151
  "write-yaml": "^1.0.0",
149
152
  xlsx: "^0.18.5",
150
153
  xregexp: "^5.1.1",
@@ -161,6 +164,7 @@ var devDependencies = {
161
164
  eslint: "^8.19.0",
162
165
  "eslint-config-standard": "^17.0.0",
163
166
  "eslint-plugin-import": "^2.26.0",
167
+ "eslint-plugin-mocha": "^10.1.0",
164
168
  "eslint-plugin-n": "^15.2.4",
165
169
  "eslint-plugin-promise": "^6.0.0",
166
170
  "eslint-plugin-standard": "^4.1.0",
@@ -340,12 +344,15 @@ var Capabilities = {
340
344
  SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS: 'SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS',
341
345
  SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS: 'SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS',
342
346
  SCRIPTING_FORCE_BOT_CONSUMED: 'SCRIPTING_FORCE_BOT_CONSUMED',
343
- // regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase
347
+ // regexp, regexpIgnoreCase, wildcard, wildcardIgnoreCase, wildcardExact, wildcardExactIgnoreCase, include, includeIgnoreCase, equals, equalsIgnoreCase, wer
344
348
  SCRIPTING_MATCHING_MODE: 'SCRIPTING_MATCHING_MODE',
349
+ SCRIPTING_MATCHING_MODE_ARGS: 'SCRIPTING_MATCHING_MODE_ARGS',
345
350
  // all, first, random
346
351
  SCRIPTING_UTTEXPANSION_MODE: 'SCRIPTING_UTTEXPANSION_MODE',
347
352
  SCRIPTING_UTTEXPANSION_RANDOM_COUNT: 'SCRIPTING_UTTEXPANSION_RANDOM_COUNT',
348
353
  SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSION',
354
+ SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS',
355
+ SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS: 'SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS',
349
356
  SCRIPTING_UTTEXPANSION_USENAMEASINTENT: 'SCRIPTING_UTTEXPANSION_USENAMEASINTENT',
350
357
  // justLineTag, utterance
351
358
  SCRIPTING_UTTEXPANSION_NAMING_MODE: 'SCRIPTING_UTTEXPANSION_NAMING_MODE',
@@ -495,9 +502,12 @@ Capabilities.SCRIPTING_ENABLE_MULTIPLE_ASSERT_ERRORS;
495
502
  Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS;
496
503
  Capabilities.SCRIPTING_FORCE_BOT_CONSUMED;
497
504
  Capabilities.SCRIPTING_MATCHING_MODE;
505
+ Capabilities.SCRIPTING_MATCHING_MODE_ARGS;
498
506
  Capabilities.SCRIPTING_UTTEXPANSION_MODE;
499
507
  Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT;
500
508
  Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION;
509
+ Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS;
510
+ Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS;
501
511
  Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT;
502
512
  Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE;
503
513
  Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX;
@@ -582,6 +592,10 @@ var Defaults$1 = {
582
592
  [Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]: 1,
583
593
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'justLineTag',
584
594
  [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: '16',
595
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION]: null,
596
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS]: [],
597
+ [Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS]: [],
598
+ [Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT]: false,
585
599
  [Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false,
586
600
  [Capabilities.SCRIPTING_ENABLE_SKIP_ASSERT_ERRORS]: false,
587
601
  [Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: false,
@@ -1180,6 +1194,9 @@ var LogicHookConsts = {
1180
1194
  }, {
1181
1195
  name: 'TEXT_IC',
1182
1196
  className: 'TextEqualsAnyICAsserter'
1197
+ }, {
1198
+ name: 'TEXT_WER',
1199
+ className: 'WerAsserter'
1183
1200
  }, {
1184
1201
  name: 'BOT_CONSUMED',
1185
1202
  className: 'BotRepliesConsumedAsserter'
@@ -1716,6 +1733,7 @@ class BotiumMockAsserter$1 {
1716
1733
  constructor(fromJson = {}) {
1717
1734
  this.name = fromJson.name;
1718
1735
  this.args = lodash__default["default"].cloneDeep(fromJson.args);
1736
+ this.not = fromJson.not;
1719
1737
  }
1720
1738
 
1721
1739
  }
@@ -2882,7 +2900,7 @@ class ConvoStep$1 {
2882
2900
  }
2883
2901
 
2884
2902
  toString() {
2885
- return (this.stepTag ? this.stepTag + ': ' : '') + '#' + this.sender + ' - ' + (this.optional ? '?' : '') + (this.not ? '!' : '') + (this.messageText || '') + (this.asserters && this.asserters.length > 0 ? ' ' + this.asserters.map(a => a.toString()).join(' ASS: ') : '') + (this.logicHooks && this.logicHooks.length > 0 ? ' ' + this.logicHooks.map(l => l.toString()).join(' LH: ') : '') + (this.userInputs && this.userInputs.length > 0 ? ' ' + this.userInputs.map(u => u.toString()).join(' UI: ') : '');
2903
+ return (this.stepTag ? this.stepTag + ': ' : '') + '#' + this.sender + ' - ' + (this.optional ? '?' : '') + (this.not ? '!' : '') + (this.messageText || '') + (this.asserters && this.asserters.length > 0 ? ' ' + this.asserters.map(a => a.toString()).join(' ') : '') + (this.logicHooks && this.logicHooks.length > 0 ? ' ' + this.logicHooks.map(l => l.toString()).join(' ') : '') + (this.userInputs && this.userInputs.length > 0 ? ' ' + this.userInputs.map(u => u.toString()).join(' ') : '');
2886
2904
  }
2887
2905
 
2888
2906
  }
@@ -2917,6 +2935,16 @@ class Transcript {
2917
2935
 
2918
2936
  }
2919
2937
 
2938
+ class TranscriptAttachment {
2939
+ constructor(fromJson = {}) {
2940
+ this.name = fromJson.name;
2941
+ this.mimeType = fromJson.mimeType;
2942
+ this.base64 = fromJson.base64;
2943
+ this.href = fromJson.href;
2944
+ }
2945
+
2946
+ }
2947
+
2920
2948
  class TranscriptStep {
2921
2949
  constructor({
2922
2950
  expected,
@@ -3697,9 +3725,16 @@ class Convo$6 {
3697
3725
  }
3698
3726
 
3699
3727
  var Convo_1 = {
3700
- ConvoHeader: ConvoHeader$1,
3701
3728
  Convo: Convo$6,
3702
- ConvoStep: ConvoStep$1
3729
+ ConvoHeader: ConvoHeader$1,
3730
+ ConvoStep: ConvoStep$1,
3731
+ ConvoStepAssert,
3732
+ ConvoStepLogicHook,
3733
+ ConvoStepUserInput,
3734
+ Transcript,
3735
+ TranscriptAttachment,
3736
+ TranscriptStep,
3737
+ TranscriptError
3703
3738
  };
3704
3739
 
3705
3740
  const {
@@ -3787,6 +3822,12 @@ const equals = ignoreCase => (botresponse, utterance) => {
3787
3822
  return botresponse === utterance;
3788
3823
  };
3789
3824
 
3825
+ const wer = () => (botresponse, utterance, args) => {
3826
+ botresponse = _normalize(botresponse || '');
3827
+ utterance = toString(utterance || '');
3828
+ return wordErrorRate__default["default"].wordErrorRate(botresponse, utterance) <= args[0];
3829
+ };
3830
+
3790
3831
  const getMatchFunction$1 = matchingMode => {
3791
3832
  if (matchingMode === 'regexp' || matchingMode === 'regexpIgnoreCase') {
3792
3833
  return regexp(matchingMode === 'regexpIgnoreCase');
@@ -3798,6 +3839,8 @@ const getMatchFunction$1 = matchingMode => {
3798
3839
  return include(matchingMode === 'includeIgnoreCase' || matchingMode === 'includeLowerCase');
3799
3840
  } else if (matchingMode === 'equals' || matchingMode === 'equalsIgnoreCase') {
3800
3841
  return equals(matchingMode === 'equalsIgnoreCase');
3842
+ } else if (matchingMode === 'wer') {
3843
+ return wer();
3801
3844
  } else {
3802
3845
  return equals(false);
3803
3846
  }
@@ -3809,6 +3852,7 @@ var MatchFunctions = {
3809
3852
  wildcardExact,
3810
3853
  include,
3811
3854
  equals,
3855
+ wer,
3812
3856
  getMatchFunction: getMatchFunction$1
3813
3857
  };
3814
3858
 
@@ -6173,7 +6217,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
6173
6217
 
6174
6218
  debug$9(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`);
6175
6219
 
6176
- const found = lodash__default["default"].find(tomatch, utt => this.matchFn(botresponse, utt));
6220
+ const found = lodash__default["default"].find(tomatch, utt => this.matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
6221
+
6222
+ const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'WerAsserter' : 'TextMatchAsserter';
6177
6223
 
6178
6224
  if (lodash__default["default"].isNil(found)) {
6179
6225
  let message = `${stepTag}: Bot response `;
@@ -6184,7 +6230,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6184
6230
  message += `${tomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
6185
6231
  throw new BotiumError$2(message, {
6186
6232
  type: 'asserter',
6187
- source: 'TextMatchAsserter',
6233
+ source: asserterType,
6188
6234
  context: {
6189
6235
  stepTag
6190
6236
  },
@@ -6203,7 +6249,9 @@ var ScriptingProvider_1 = class ScriptingProvider {
6203
6249
 
6204
6250
  debug$9(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`);
6205
6251
 
6206
- const found = lodash__default["default"].find(nottomatch, utt => this.matchFn(botresponse, utt));
6252
+ const found = lodash__default["default"].find(nottomatch, utt => this.matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]));
6253
+
6254
+ const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'WerAsserter' : 'TextMatchAsserter';
6207
6255
 
6208
6256
  if (!lodash__default["default"].isNil(found)) {
6209
6257
  let message = `${stepTag}: Bot response `;
@@ -6214,7 +6262,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6214
6262
  message += `${nottomatch.map(e => e ? '"' + e + '"' : '<any response>').join(', ')}`;
6215
6263
  throw new BotiumError$2(message, {
6216
6264
  type: 'asserter',
6217
- source: 'TextMatchAsserter',
6265
+ source: asserterType,
6218
6266
  context: {
6219
6267
  stepTag
6220
6268
  },
@@ -6461,7 +6509,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6461
6509
  }
6462
6510
 
6463
6511
  Match(botresponse, utterance) {
6464
- return this.matchFn(botresponse, utterance);
6512
+ return this.matchFn(botresponse, utterance, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]);
6465
6513
  }
6466
6514
 
6467
6515
  Compile(scriptBuffer, scriptFormat, scriptType) {
@@ -6893,6 +6941,8 @@ var ScriptingProvider_1 = class ScriptingProvider {
6893
6941
 
6894
6942
  ExpandUtterancesToConvos({
6895
6943
  useNameAsIntent,
6944
+ incomprehensionIntents,
6945
+ incomprehensionUtts,
6896
6946
  incomprehensionUtt
6897
6947
  } = {}) {
6898
6948
  const expandedConvos = [];
@@ -6901,26 +6951,81 @@ var ScriptingProvider_1 = class ScriptingProvider {
6901
6951
  useNameAsIntent = !!this.caps[Capabilities.SCRIPTING_UTTEXPANSION_USENAMEASINTENT];
6902
6952
  }
6903
6953
 
6954
+ if (lodash__default["default"].isUndefined(incomprehensionIntents)) {
6955
+ incomprehensionIntents = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONINTENTS];
6956
+ }
6957
+
6958
+ if (lodash__default["default"].isUndefined(incomprehensionUtts)) {
6959
+ incomprehensionUtts = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSIONUTTS];
6960
+ }
6961
+
6904
6962
  if (lodash__default["default"].isUndefined(incomprehensionUtt)) {
6905
6963
  incomprehensionUtt = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_INCOMPREHENSION];
6906
6964
  }
6907
6965
 
6908
- if (useNameAsIntent && incomprehensionUtt) {
6909
- throw new Error('ExpandUtterancesToConvos - SCRIPTING_UTTEXPANSION_USENAMEASINTENT and SCRIPTING_UTTEXPANSION_INCOMPREHENSION are incompatible');
6966
+ if (incomprehensionUtt && (!incomprehensionUtts || incomprehensionUtts.length === 0) && !this.utterances[incomprehensionUtt]) {
6967
+ throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined (and no user examples given)`);
6910
6968
  }
6911
6969
 
6912
- if (incomprehensionUtt && !this.utterances[incomprehensionUtt]) {
6913
- throw new Error(`ExpandUtterancesToConvos - incomprehension utterance '${incomprehensionUtt}' undefined`);
6970
+ if (incomprehensionUtts && incomprehensionUtts.length > 0) {
6971
+ if (!incomprehensionUtt) {
6972
+ incomprehensionUtt = 'UTT_INCOMPREHENSION';
6973
+ }
6974
+
6975
+ if (this.utterances[incomprehensionUtt]) {
6976
+ this.utterances[incomprehensionUtt].utterances.push(...incomprehensionUtts);
6977
+ } else {
6978
+ this.utterances[incomprehensionUtt] = {
6979
+ name: incomprehensionUtt,
6980
+ utterances: [...incomprehensionUtts]
6981
+ };
6982
+ }
6914
6983
  }
6915
6984
 
6916
6985
  if (useNameAsIntent) {
6917
6986
  debug$9('ExpandUtterancesToConvos - Using utterance name as NLU intent');
6918
- } else if (incomprehensionUtt) {
6919
- debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}`);
6987
+ }
6988
+
6989
+ if (incomprehensionIntents && incomprehensionIntents.length > 0) {
6990
+ debug$9(`ExpandUtterancesToConvos - Using ${incomprehensionIntents.length} incomprehension NLU intent(s)`);
6991
+ }
6992
+
6993
+ if (incomprehensionUtt) {
6994
+ debug$9(`ExpandUtterancesToConvos - Using incomprehension utterance expansion mode: ${incomprehensionUtt}, ${this.utterances[incomprehensionUtt].utterances.length} user example(s)`);
6920
6995
  }
6921
6996
 
6922
6997
  lodash__default["default"].keys(this.utterances).filter(u => u !== incomprehensionUtt).forEach(uttName => {
6923
6998
  const utt = this.utterances[uttName];
6999
+ const responseStep = {
7000
+ sender: 'bot',
7001
+ messageText: '',
7002
+ asserters: [],
7003
+ stepTag: 'Step 2 - check bot response',
7004
+ not: false
7005
+ };
7006
+
7007
+ if (useNameAsIntent) {
7008
+ responseStep.asserters.push({
7009
+ name: 'INTENT',
7010
+ args: [utt.name]
7011
+ });
7012
+ }
7013
+
7014
+ if (incomprehensionIntents && incomprehensionIntents.length > 0) {
7015
+ incomprehensionIntents.forEach(ii => {
7016
+ responseStep.asserters.push({
7017
+ name: 'INTENT',
7018
+ args: [ii],
7019
+ not: true
7020
+ });
7021
+ });
7022
+ }
7023
+
7024
+ if (incomprehensionUtt) {
7025
+ responseStep.messageText = incomprehensionUtt;
7026
+ responseStep.not = true;
7027
+ }
7028
+
6924
7029
  expandedConvos.push(new Convo(this._buildScriptContext(), {
6925
7030
  header: {
6926
7031
  name: utt.name,
@@ -6933,25 +7038,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
6933
7038
  }],
6934
7039
  messageText: utt.name,
6935
7040
  stepTag: 'Step 1 - tell utterance'
6936
- }, useNameAsIntent ? {
6937
- sender: 'bot',
6938
- asserters: [{
6939
- name: 'INTENT',
6940
- args: [utt.name]
6941
- }],
6942
- stepTag: 'Step 2 - check intent',
6943
- not: false
6944
- } : incomprehensionUtt ? {
6945
- sender: 'bot',
6946
- messageText: incomprehensionUtt,
6947
- stepTag: 'Step 2 - check incomprehension',
6948
- not: true
6949
- } : {
6950
- sender: 'bot',
6951
- messageText: '',
6952
- stepTag: 'Step 2 - check bot response',
6953
- not: false
6954
- }],
7041
+ }, responseStep],
6955
7042
  sourceTag: Object.assign({}, utt.sourceTag, {
6956
7043
  origUttName: utt.name
6957
7044
  })
@@ -6981,11 +7068,12 @@ var ScriptingProvider_1 = class ScriptingProvider {
6981
7068
  * @param currentConvo
6982
7069
  * @param convoStepIndex
6983
7070
  * @param convoStepsStack list of ConvoSteps
7071
+ * @param context {width: }
6984
7072
  * @private
6985
7073
  */
6986
7074
 
6987
7075
 
6988
- _expandConvo(expandedConvos, currentConvo, convoStepIndex = 0, convoStepsStack = []) {
7076
+ _expandConvo(expandedConvos, currentConvo, convoStepIndex = 0, convoStepsStack = [], context = {}) {
6989
7077
  const utterancePostfix = (lineTag, uttOrUserInput) => {
6990
7078
  const naming = this.caps[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE] || Defaults$1.capabilities[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE];
6991
7079
 
@@ -7012,7 +7100,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7012
7100
  const currentStepsStack = convoStepsStack.slice();
7013
7101
  currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
7014
7102
 
7015
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
7103
+ this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7016
7104
  } else if (currentStep.sender === 'me') {
7017
7105
  let useUnexpanded = true;
7018
7106
 
@@ -7033,39 +7121,87 @@ var ScriptingProvider_1 = class ScriptingProvider {
7033
7121
 
7034
7122
  if (this.utterances[uttName]) {
7035
7123
  const allutterances = this.utterances[uttName].utterances;
7036
- let sampleutterances = allutterances;
7037
-
7038
- if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7039
- sampleutterances = [allutterances[0]];
7040
- } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7041
- sampleutterances = allutterances.map(x => ({
7042
- x,
7043
- r: Math.random()
7044
- })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]);
7045
- }
7046
7124
 
7047
- sampleutterances.forEach((utt, index) => {
7048
- const lineTag = `${index + 1}`.padStart(`${sampleutterances.length}`.length, '0');
7125
+ const processSampleUtterances = (sampleutterances, myContext) => {
7126
+ sampleutterances.forEach((utt, index) => {
7127
+ processSampleUtterance(utt, sampleutterances.length, index, Object.assign({
7128
+ indexExpansionModeIndex: index
7129
+ }, myContext || context));
7130
+ });
7131
+ };
7132
+
7133
+ const processSampleUtterance = (sampleutterance, length, index, myContext) => {
7134
+ const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7049
7135
  const currentStepsStack = convoStepsStack.slice();
7050
7136
 
7051
7137
  if (uttArgs) {
7052
- utt = util__default["default"].format(utt, ...uttArgs);
7138
+ sampleutterance = util__default["default"].format(sampleutterance, ...uttArgs);
7053
7139
  }
7054
7140
 
7055
7141
  currentStepsStack.push(Object.assign(lodash__default["default"].cloneDeep(currentStep), {
7056
- messageText: utt
7142
+ messageText: sampleutterance
7057
7143
  }));
7058
7144
 
7059
7145
  const currentConvoLabeled = lodash__default["default"].cloneDeep(currentConvo);
7060
7146
 
7061
7147
  Object.assign(currentConvoLabeled.header, {
7062
- name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, utt)}`
7148
+ name: `${currentConvo.header.name}/${uttName}-${utterancePostfix(lineTag, sampleutterance)}`
7063
7149
  });
7064
7150
  if (!currentConvoLabeled.sourceTag) currentConvoLabeled.sourceTag = {};
7065
7151
  if (!currentConvoLabeled.sourceTag.origConvoName) currentConvoLabeled.sourceTag.origConvoName = currentConvo.header.name;
7066
7152
 
7067
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack);
7068
- });
7153
+ this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7154
+ };
7155
+
7156
+ if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7157
+ if (lodash__default["default"].isNil(context.indexExpansionModeWidth)) {
7158
+ // executed for the first found utterance
7159
+ processSampleUtterances(allutterances, Object.assign({}, context, {
7160
+ indexExpansionModeWidth: allutterances.length
7161
+ }));
7162
+ } else {
7163
+ if (lodash__default["default"].isNil(context.indexExpansionModeIndex)) {
7164
+ throw new Error('indexExpansionModeIndex must be set!');
7165
+ } // executing the current 'thread', if current utterance has no example to current index, fallback to the last one
7166
+
7167
+
7168
+ const localIndex = Math.min(context.indexExpansionModeIndex, allutterances.length - 1);
7169
+
7170
+ if (localIndex < context.indexExpansionModeIndex && context.indexExpansionModeIndex === context.indexExpansionModeWidth - 1) {
7171
+ debug$9(`While expanding convos by index found in utterance "${uttName}" less examples (${allutterances.length}) as expected (${context.indexExpansionModeWidth})`);
7172
+ }
7173
+
7174
+ const myContext = Object.assign({}, context, {
7175
+ indexExpansionModeWidth: Math.max(allutterances.length, context.indexExpansionModeWidth)
7176
+ });
7177
+ processSampleUtterance(allutterances[localIndex], allutterances.length, localIndex, myContext);
7178
+
7179
+ if (allutterances.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7180
+ debug$9(`While expanding convos by index found in utterance "${uttName}" more examples (${allutterances.length}) as expected (${context.indexExpansionModeWidth})`);
7181
+
7182
+ for (let i = context.indexExpansionModeWidth; i < allutterances.length; i++) {
7183
+ // if we found a utterance with more examples as any utterances before, we have to start new 'thread'
7184
+ const myContext = Object.assign({}, context, {
7185
+ indexExpansionModeWidth: allutterances.length,
7186
+ indexExpansionModeIndex: i
7187
+ });
7188
+ processSampleUtterance(allutterances[i], allutterances.length, i, myContext);
7189
+ }
7190
+ }
7191
+ }
7192
+ } else {
7193
+ if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7194
+ processSampleUtterances([allutterances[0]]);
7195
+ } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7196
+ processSampleUtterances(allutterances.map(x => ({
7197
+ x,
7198
+ r: Math.random()
7199
+ })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]));
7200
+ } else {
7201
+ processSampleUtterances(allutterances);
7202
+ }
7203
+ }
7204
+
7069
7205
  useUnexpanded = false;
7070
7206
  }
7071
7207
  }
@@ -7082,19 +7218,17 @@ var ScriptingProvider_1 = class ScriptingProvider {
7082
7218
  });
7083
7219
 
7084
7220
  if (expandedUserInputs && expandedUserInputs.length > 0) {
7085
- let sampleinputs = expandedUserInputs;
7086
-
7087
- if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7088
- sampleinputs = [expandedUserInputs[0]];
7089
- } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7090
- sampleinputs = expandedUserInputs.map(x => ({
7091
- x,
7092
- r: Math.random()
7093
- })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]);
7094
- }
7221
+ // let sampleinputs = expandedUserInputs
7222
+ const processSampleInputs = (sampleinputs, myContext, uiIndex) => {
7223
+ sampleinputs.forEach((input, index) => {
7224
+ processSampleInput(input, sampleinputs.length, index, Object.assign({
7225
+ indexExpansionModeIndex: index
7226
+ }, myContext || context), uiIndex);
7227
+ });
7228
+ };
7095
7229
 
7096
- sampleinputs.forEach((sampleinput, index) => {
7097
- const lineTag = `${index + 1}`.padStart(`${sampleinputs.length}`.length, '0');
7230
+ const processSampleInput = (sampleinput, length, index, myContext, uiIndex) => {
7231
+ const lineTag = `${index + 1}`.padStart(`${length}`.length, '0');
7098
7232
  const currentStepsStack = convoStepsStack.slice();
7099
7233
 
7100
7234
  const currentStepMod = lodash__default["default"].cloneDeep(currentStep);
@@ -7108,8 +7242,56 @@ var ScriptingProvider_1 = class ScriptingProvider {
7108
7242
  name: `${currentConvo.header.name}/${ui.name}-${utterancePostfix(lineTag, sampleinput.args && sampleinput.args.length ? sampleinput.args.join(', ') : 'no-args')}`
7109
7243
  });
7110
7244
 
7111
- this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack);
7112
- });
7245
+ this._expandConvo(expandedConvos, currentConvoLabeled, convoStepIndex + 1, currentStepsStack, myContext || context);
7246
+ };
7247
+
7248
+ if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'index') {
7249
+ if (lodash__default["default"].isNil(context.indexExpansionModeWidth)) {
7250
+ processSampleInputs(expandedUserInputs, Object.assign({}, context, {
7251
+ indexExpansionModeWidth: expandedUserInputs.length
7252
+ }), uiIndex);
7253
+ } else {
7254
+ if (lodash__default["default"].isNil(context.indexExpansionModeIndex)) {
7255
+ throw new Error('indexExpansionModeIndex must be set!');
7256
+ } // executing the current 'thread', if current utterance has no example to current index, fallback to the last one
7257
+
7258
+
7259
+ const localIndex = Math.min(context.indexExpansionModeIndex, expandedUserInputs.length - 1);
7260
+
7261
+ if (localIndex < context.indexExpansionModeIndex && context.indexExpansionModeIndex === context.indexExpansionModeWidth - 1) {
7262
+ debug$9(`While expanding convos by index found user input "${ui.name}, ${ui.args}" less examples (${expandedUserInputs.length}) as expected (${context.indexExpansionModeWidth})`);
7263
+ }
7264
+
7265
+ const myContext = Object.assign({}, context, {
7266
+ indexExpansionModeWidth: Math.max(expandedUserInputs.length, context.indexExpansionModeWidth)
7267
+ });
7268
+ processSampleInput(expandedUserInputs[localIndex], expandedUserInputs.length, localIndex, myContext, uiIndex);
7269
+
7270
+ if (expandedUserInputs.length > context.indexExpansionModeWidth && context.indexExpansionModeIndex + 1 === context.indexExpansionModeWidth) {
7271
+ debug$9(`While expanding convos by index found user input "${ui.name}, ${ui.args}" more examples (${expandedUserInputs.length}) as expected (${context.indexExpansionModeWidth})`);
7272
+
7273
+ for (let i = context.indexExpansionModeWidth; i < expandedUserInputs.length; i++) {
7274
+ const myContext = Object.assign({}, context, {
7275
+ indexExpansionModeWidth: expandedUserInputs.length,
7276
+ indexExpansionModeIndex: i
7277
+ });
7278
+ processSampleInput(expandedUserInputs[i], expandedUserInputs.length, i, myContext, uiIndex);
7279
+ }
7280
+ }
7281
+ }
7282
+ } else {
7283
+ if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'first') {
7284
+ processSampleInputs([expandedUserInputs[0]], context, uiIndex);
7285
+ } else if (this.caps[Capabilities.SCRIPTING_UTTEXPANSION_MODE] === 'random') {
7286
+ processSampleInputs(expandedUserInputs.map(x => ({
7287
+ x,
7288
+ r: Math.random()
7289
+ })).sort((a, b) => a.r - b.r).map(a => a.x).slice(0, this.caps[Capabilities.SCRIPTING_UTTEXPANSION_RANDOM_COUNT]), context, uiIndex);
7290
+ } else {
7291
+ processSampleInputs(expandedUserInputs, context, uiIndex);
7292
+ }
7293
+ }
7294
+
7113
7295
  useUnexpanded = false;
7114
7296
  }
7115
7297
  }
@@ -7120,7 +7302,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7120
7302
  const currentStepsStack = convoStepsStack.slice();
7121
7303
  currentStepsStack.push(lodash__default["default"].cloneDeep(currentStep));
7122
7304
 
7123
- this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack);
7305
+ this._expandConvo(expandedConvos, currentConvo, convoStepIndex + 1, currentStepsStack, context);
7124
7306
  }
7125
7307
  }
7126
7308
  } else {
@@ -8176,7 +8358,8 @@ const setupEndpoints = ({
8176
8358
  processEvent({
8177
8359
  originalUrl: req.originalUrl,
8178
8360
  originalMethod: req.method,
8179
- body: req.body
8361
+ body: req.body,
8362
+ headers: req.headers
8180
8363
  });
8181
8364
  res.status(200).json({}).end();
8182
8365
  } else {
@@ -8281,7 +8464,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8281
8464
  });
8282
8465
 
8283
8466
  for (const event of sortedEvents) {
8284
- setTimeout(() => this._processBodyAsync(event.body, true, !!this.caps[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]), 0);
8467
+ setTimeout(() => this._processBodyAsync(event.body, event.headers, true, !!this.caps[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]), 0);
8285
8468
  }
8286
8469
  }, debounceTimeout);
8287
8470
  }
@@ -8376,12 +8559,15 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8376
8559
  this._startPolling().then(() => startPollingComplete()).catch(startPollingComplete);
8377
8560
  }, pingComplete => {
8378
8561
  if (this.caps[Capabilities.SIMPLEREST_PING_URL]) {
8379
- this._makeCall('SIMPLEREST_PING').then(body => {
8562
+ this._makeCall('SIMPLEREST_PING').then(({
8563
+ body,
8564
+ headers
8565
+ }) => {
8380
8566
  if (this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]) {
8381
8567
  return this._parseResponseBody(body).then(body => {
8382
8568
  if (body) {
8383
8569
  debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
8384
- return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]);
8570
+ return this._processBodyAsync(body, headers, !!this.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_PING_UPDATE_CONTEXT]);
8385
8571
  } else {
8386
8572
  debug$4(`Ping Uri ${this.caps[Capabilities.SIMPLEREST_PING_URL]} didn't return JSON response, ignoring it.`);
8387
8573
  }
@@ -8409,12 +8595,15 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8409
8595
  this.processInbound = true;
8410
8596
 
8411
8597
  if (this.caps[Capabilities.SIMPLEREST_START_URL]) {
8412
- this._makeCall('SIMPLEREST_START').then(body => {
8598
+ this._makeCall('SIMPLEREST_START').then(({
8599
+ body,
8600
+ headers
8601
+ }) => {
8413
8602
  if (this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT] || this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE]) {
8414
8603
  return this._parseResponseBody(body).then(body => {
8415
8604
  if (body) {
8416
8605
  debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} returned JSON response: ${Utils.shortenJsonString(body)}`);
8417
- return this._processBodyAsync(body, !!this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT]);
8606
+ return this._processBodyAsync(body, headers, !!this.caps[Capabilities.SIMPLEREST_START_PROCESS_RESPONSE], !!this.caps[Capabilities.SIMPLEREST_START_UPDATE_CONTEXT]);
8418
8607
  } else {
8419
8608
  debug$4(`Start Uri ${this.caps[Capabilities.SIMPLEREST_START_URL]} didn't return JSON response, ignoring it.`);
8420
8609
  }
@@ -8466,10 +8655,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8466
8655
  } // Separated just for better module testing
8467
8656
 
8468
8657
 
8469
- async _processBodyAsync(body, isFromUser, updateContext) {
8658
+ async _processBodyAsync(body, headers, isFromUser, updateContext) {
8470
8659
  const p = async () => {
8471
8660
  try {
8472
- const results = await this._processBodyAsyncImpl(body, isFromUser, updateContext);
8661
+ const results = await this._processBodyAsyncImpl(body, headers, isFromUser, updateContext);
8473
8662
 
8474
8663
  if (results) {
8475
8664
  for (const result of results) {
@@ -8500,7 +8689,12 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8500
8689
  } // Separated just for better module testing
8501
8690
 
8502
8691
 
8503
- async _processBodyAsyncImpl(body, isFromUser, updateContext) {
8692
+ async _processBodyAsyncImpl(body, headers, isFromUser, updateContext) {
8693
+ this.view.response = {
8694
+ body,
8695
+ headers
8696
+ };
8697
+
8504
8698
  if (updateContext) {
8505
8699
  const mergeMode = this.caps[Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE];
8506
8700
  const jsonPathsContext = getAllCapValues(Capabilities.SIMPLEREST_CONTEXT_JSONPATH, this.caps);
@@ -8710,7 +8904,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8710
8904
  }
8711
8905
 
8712
8906
  if (body) {
8713
- debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8907
+ debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}, headers: ${Utils.shortenJsonString(response.headers)}`);
8714
8908
 
8715
8909
  this._storeCookiesFromResponse(response);
8716
8910
 
@@ -8726,7 +8920,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8726
8920
  }
8727
8921
 
8728
8922
  if (body) {
8729
- this._processBodyAsync(body, isFromUser, updateContext).then(() => resolve(this)).then(() => this._emptyWaitProcessQueue());
8923
+ this._processBodyAsync(body, response.headers, isFromUser, updateContext).then(() => resolve(this)).then(() => this._emptyWaitProcessQueue());
8730
8924
  } else {
8731
8925
  debug$4('ignoring response body (no string and no JSON object)');
8732
8926
  resolve(this);
@@ -8788,6 +8982,10 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8788
8982
  try {
8789
8983
  requestOptions.body = this._getMustachedCap(Capabilities.SIMPLEREST_BODY_TEMPLATE, !bodyRaw);
8790
8984
  requestOptions.json = !bodyRaw;
8985
+
8986
+ if (requestOptions.json && (!requestOptions.body || Object.keys(requestOptions.body).length === 0)) {
8987
+ debug$4(`warning: requestOptions.body content seems to be empty - ${requestOptions.body} - capability: "${this.caps[Capabilities.SIMPLEREST_BODY_TEMPLATE]}"`);
8988
+ }
8791
8989
  } catch (err) {
8792
8990
  throw new Error(`composing body from SIMPLEREST_BODY_TEMPLATE failed (${err.message})`);
8793
8991
  }
@@ -8886,10 +9084,13 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8886
9084
  this._storeCookiesFromResponse(response);
8887
9085
 
8888
9086
  if (debug$4.enabled && body) {
8889
- debug$4(Utils.shortenJsonString(body));
9087
+ debug$4(`body: ${Utils.shortenJsonString(body)}, headers: ${Utils.shortenJsonString(response.headers)}`);
8890
9088
  }
8891
9089
 
8892
- return body;
9090
+ return {
9091
+ body,
9092
+ headers: response.headers
9093
+ };
8893
9094
  }
8894
9095
  }
8895
9096
  }
@@ -8933,7 +9134,11 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8933
9134
  try {
8934
9135
  return JSON.parse(raw);
8935
9136
  } catch (err) {
8936
- return new Error(`JSON parsing failed - try to use {{#fnc.jsonify}}{{xxx}}{{/fnc.jsonify}} to escape JSON special characters (ERR: ${err.message})`);
9137
+ if (debug$4.enabled) {
9138
+ debug$4(`JSON parsing failed (${err.message}) for: ${Utils.shortenJsonString(raw)}`);
9139
+ }
9140
+
9141
+ throw new Error(`JSON parsing failed - try to use {{#fnc.jsonify}}{{xxx}}{{/fnc.jsonify}} to escape JSON special characters (ERR: ${err.message})`);
8937
9142
  }
8938
9143
  } else {
8939
9144
  return raw;
@@ -8978,7 +9183,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8978
9183
 
8979
9184
  this._processOrderedInboundEventsArrayAsync();
8980
9185
  } else {
8981
- setTimeout(() => this._processBodyAsync(event.body, true, !!this.caps[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]), 0);
9186
+ setTimeout(() => this._processBodyAsync(event.body, event.headers, true, !!this.caps[Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]), 0);
8982
9187
  }
8983
9188
  }
8984
9189
 
@@ -9119,7 +9324,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9119
9324
  debug$4(Utils.shortenJsonString(body));
9120
9325
  }
9121
9326
  } else if (body) {
9122
- debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
9327
+ debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}, headers: ${Utils.shortenJsonString(response.headers)}`);
9123
9328
 
9124
9329
  this._storeCookiesFromResponse(response);
9125
9330
 
@@ -9131,7 +9336,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9131
9336
  }
9132
9337
 
9133
9338
  if (body) {
9134
- setTimeout(() => this._processBodyAsync(body, true, !!this.caps[Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT]), 0);
9339
+ setTimeout(() => this._processBodyAsync(body, response.headers, true, !!this.caps[Capabilities.SIMPLEREST_POLL_UPDATE_CONTEXT]), 0);
9135
9340
  } else {
9136
9341
  debug$4('_runPolling: ignoring response body (no string and no JSON object)');
9137
9342
  }