wingbot 3.31.2 → 3.31.5-alpha.1

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.2",
3
+ "version": "3.31.5-alpha.1",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -497,15 +497,21 @@ class BuildRouter extends Router {
497
497
  nextRouteIsSameResponder = nextRoute.respondsToRouteId === route.respondsToRouteId;
498
498
  }
499
499
 
500
+ const buildInfo = {
501
+ expectedToAddResolver: !!route.expectedPath,
502
+ attachedRouter: false
503
+ };
504
+
500
505
  const resolvers = [
501
506
  ...this._buildRouteHead(route, nextRouteIsSameResponder),
502
- ...this.buildResolvers(route.resolvers, route, route.expectedPath)
507
+ ...this.buildResolvers(route.resolvers, route, buildInfo)
503
508
  ];
504
509
 
505
510
  if (route.expectedPath) {
506
511
  // attach expected before last message, if there is
507
512
  resolvers.push(expected({
508
- path: route.expectedPath
513
+ path: route.expectedPath,
514
+ attachedRouter: buildInfo.attachedRouter
509
515
  }, {
510
516
  isLastIndex: true
511
517
  }));
@@ -524,7 +530,7 @@ class BuildRouter extends Router {
524
530
  return -1;
525
531
  }
526
532
 
527
- buildResolvers (resolvers, route = {}, expectedToAddResolver = false) {
533
+ buildResolvers (resolvers, route = {}, buildInfo = {}) {
528
534
  const {
529
535
  path: ctxPath, isFallback, isResponder, expectedPath, id
530
536
  } = route;
@@ -535,7 +541,7 @@ class BuildRouter extends Router {
535
541
  return resolvers.map((resolver, i) => {
536
542
  const context = {
537
543
  ...this._context,
538
- isLastIndex: lastIndex === i && !expectedToAddResolver,
544
+ isLastIndex: lastIndex === i && !buildInfo.expectedToAddResolver,
539
545
  isLastMessage: lastMessageIndex === i,
540
546
  router: this,
541
547
  linksMap: this._linksMap,
@@ -546,11 +552,11 @@ class BuildRouter extends Router {
546
552
  routeId: id
547
553
  };
548
554
 
549
- return this._resolverFactory(resolver, context);
555
+ return this._resolverFactory(resolver, context, buildInfo);
550
556
  });
551
557
  }
552
558
 
553
- _resolverFactory (resolver, context) {
559
+ _resolverFactory (resolver, context, buildInfo) {
554
560
  const { type } = resolver;
555
561
 
556
562
  if (!this.resources.has(type)) {
@@ -561,12 +567,17 @@ class BuildRouter extends Router {
561
567
 
562
568
  const fn = factoryFn(resolver.params, context, this._plugins);
563
569
 
570
+ if (fn.reduce) {
571
+ Object.assign(buildInfo, { attachedRouter: true });
572
+ }
573
+
564
574
  if ([
565
575
  'botbuild.include',
566
576
  'botbuild.path',
567
577
  'botbuild.customCode',
568
578
  'botbuild.inlineCode',
569
- 'botbuild.plugin'
579
+ 'botbuild.plugin',
580
+ 'botbuild.postback'
570
581
  ].includes(type)) {
571
582
  return fn;
572
583
  }
package/src/Request.js CHANGED
@@ -834,7 +834,9 @@ class Request {
834
834
  * });
835
835
  */
836
836
  expectedContext (justOnce = false, includeKeywords = false) {
837
- const { _expected: expected, _expectedConfidentInput: confident } = this.state;
837
+ const ad = this.actionData();
838
+ const expected = ad._useExpected || this.state._expected;
839
+ const confident = this.state._expectedConfidentInput;
838
840
 
839
841
  const ret = {};
840
842
 
package/src/Router.js CHANGED
@@ -260,7 +260,7 @@ class Router extends ReducerWrapper {
260
260
  }
261
261
 
262
262
  // used as protected method
263
- async processReducers (reducers, req, res, postBack, path, action, doNotTrack = false) {
263
+ async processReducers (reducers, req, res, postBack, action, doNotTrack = false) {
264
264
  const routeToReduce = {
265
265
  reducers,
266
266
  path: res.routePath
package/src/RouterWrap.js CHANGED
@@ -48,8 +48,6 @@ class RouterWrap extends EventEmitter {
48
48
 
49
49
  const { items, router, params } = this;
50
50
 
51
- const { path, routePath } = res;
52
-
53
51
  // attach params
54
52
  req.params = params;
55
53
 
@@ -62,15 +60,9 @@ class RouterWrap extends EventEmitter {
62
60
  return true;
63
61
  }
64
62
 
65
- const { path: runPath, routePath: runRoutePath } = res;
66
-
67
- res.setPath(path, routePath);
68
-
69
63
  const reducers = items.get(codeBlockName);
70
64
  const result = await router
71
- .processReducers(reducers, req, res, postBack, path, useAction, true);
72
-
73
- res.setPath(runPath, runRoutePath);
65
+ .processReducers(reducers, req, res, postBack, useAction, true);
74
66
 
75
67
  return result;
76
68
  }
@@ -5,7 +5,16 @@
5
5
 
6
6
  const Router = require('../Router');
7
7
 
8
- function expected ({ path }, { isLastIndex }) {
8
+ function expected ({ path, attachedRouter }, { isLastIndex }) {
9
+
10
+ if (attachedRouter) {
11
+ return (req, res, postBack) => postBack(path, {
12
+ _useExpected: {
13
+ action: res.toAbsoluteAction(path),
14
+ data: {}
15
+ }
16
+ }, true);
17
+ }
9
18
 
10
19
  return (req, res) => {
11
20
  res.expected(path);
@@ -41,7 +41,7 @@ function wrapPluginFunction (
41
41
  return true;
42
42
  }
43
43
  const reducers = preprocessedItems.get(codeBlockName);
44
- return router.processReducers(reducers, req, res, postBack, path, action, true);
44
+ return router.processReducers(reducers, req, res, postBack, action, true);
45
45
  }
46
46
  });
47
47