wingbot 3.31.5-alpha.1 → 3.31.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.31.5-alpha.1",
3
+ "version": "3.31.6",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -310,7 +310,8 @@ class BuildRouter extends Router {
310
310
  this._configTs = 0;
311
311
  }
312
312
  if (this._prebuiltGlobalIntents !== null) {
313
- this.globalIntents = new Map(this._prebuiltGlobalIntents);
313
+ this.globalIntents.clear();
314
+ this._prebuiltGlobalIntents.forEach(([k, v]) => this.globalIntents.set(k, v));
314
315
  }
315
316
  }
316
317
 
@@ -326,7 +327,8 @@ class BuildRouter extends Router {
326
327
  if (this._prebuiltGlobalIntents === null) {
327
328
  this._prebuiltGlobalIntents = Array.from(this.globalIntents.entries());
328
329
  } else {
329
- this.globalIntents = new Map(this._prebuiltGlobalIntents);
330
+ this.globalIntents.clear();
331
+ this._prebuiltGlobalIntents.forEach(([k, v]) => this.globalIntents.set(k, v));
330
332
  }
331
333
 
332
334
  if (this._prebuiltRoutesCount === null) {
@@ -524,7 +524,7 @@ class ConversationTester {
524
524
  await tester.text(textCase.text);
525
525
 
526
526
  if (textCase.action) {
527
- tester.passedAction(textCase.action);
527
+ tester.passedAction(textCase.action, true);
528
528
  }
529
529
 
530
530
  if (textCase.appId) {
package/src/Responder.js CHANGED
@@ -528,6 +528,8 @@ class Responder {
528
528
  if (prepend) Object.assign(prep, { _prepend: true });
529
529
  if (justToExisting) Object.assign(prep, { _justToExisting: true });
530
530
 
531
+ const useCa = this.currentAction();
532
+
531
533
  if (actionIsObject) {
532
534
  this._quickReplyCollector.push({
533
535
  ...prep,
@@ -535,7 +537,8 @@ class Responder {
535
537
  data: {
536
538
  ...prep.data,
537
539
  ...data
538
- }
540
+ },
541
+ useCa
539
542
  });
540
543
  } else {
541
544
  this._quickReplyCollector.push({
@@ -543,6 +546,7 @@ class Responder {
543
546
  action: this.toAbsoluteAction(action),
544
547
  title,
545
548
  data,
549
+ useCa,
546
550
  ...prep
547
551
  });
548
552
  }
package/src/RouterWrap.js CHANGED
@@ -48,6 +48,8 @@ class RouterWrap extends EventEmitter {
48
48
 
49
49
  const { items, router, params } = this;
50
50
 
51
+ const { path, routePath } = res;
52
+
51
53
  // attach params
52
54
  req.params = params;
53
55
 
@@ -60,9 +62,15 @@ class RouterWrap extends EventEmitter {
60
62
  return true;
61
63
  }
62
64
 
65
+ const { path: runPath, routePath: runRoutePath } = res;
66
+
67
+ res.setPath(path, routePath);
68
+
63
69
  const reducers = items.get(codeBlockName);
64
70
  const result = await router
65
- .processReducers(reducers, req, res, postBack, useAction, true);
71
+ .processReducers(reducers, req, res, postBack, path, useAction, true);
72
+
73
+ res.setPath(runPath, runRoutePath);
66
74
 
67
75
  return result;
68
76
  }
package/src/Tester.js CHANGED
@@ -70,8 +70,15 @@ class Tester {
70
70
  };
71
71
 
72
72
  this._listener = (senderIdentifier, action, text, req, prevAction, doNotTrack) => {
73
+ const reqAction = req.action();
74
+ if (reqAction && !this._actionMatches(action, reqAction)) {
75
+ this._actionsCollector.push({
76
+ action: reqAction, text, prevAction, doNotTrack, isReqAction: true
77
+ });
78
+ }
79
+
73
80
  this._actionsCollector.push({
74
- action, text, prevAction, doNotTrack
81
+ action, text, prevAction, doNotTrack, isReqAction: false
75
82
  });
76
83
  };
77
84
 
@@ -255,18 +262,25 @@ class Tester {
255
262
  return new ResponseAssert(this.responses[this.responses.length - 1]);
256
263
  }
257
264
 
265
+ _actionMatches (botAction, path) {
266
+ return botAction === path
267
+ || (path === '*' && botAction === '/*')
268
+ || (!botAction.match(/\*/) && actionMatches(botAction, path));
269
+ }
270
+
258
271
  /**
259
- * Checks, that app past the action
272
+ * Checks, that request passed an interaction
260
273
  *
261
274
  * @param {string} path
275
+ * @param {boolean} [matchRequestActions]
262
276
  * @returns {this}
263
277
  *
264
278
  * @memberOf Tester
265
279
  */
266
- passedAction (path) {
280
+ passedAction (path, matchRequestActions = false) {
267
281
  const ok = this.actions
268
- .some((action) => (action.action === path
269
- || (!action.action.match(/\*/) && actionMatches(action.action, path))));
282
+ .some((action) => (!action.isReqAction || matchRequestActions)
283
+ && this._actionMatches(action.action, path));
270
284
  let actual;
271
285
  if (!ok) {
272
286
  const set = new Set();
@@ -133,7 +133,8 @@ function makeQuickReplies (replies, path = '', translate = (w) => w, quickReplyC
133
133
  data = {},
134
134
  isLocation = false,
135
135
  isEmail = false,
136
- isPhone = false
136
+ isPhone = false,
137
+ useCa = currentAction
137
138
  } = reply;
138
139
  let {
139
140
  setState = null
@@ -219,7 +220,7 @@ function makeQuickReplies (replies, path = '', translate = (w) => w, quickReplyC
219
220
  payload = {
220
221
  action: absoluteAction,
221
222
  data: {
222
- _ca: currentAction,
223
+ _ca: useCa,
223
224
  ...data
224
225
  }
225
226
  };