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 +1 -1
- package/src/BuildRouter.js +18 -7
- package/src/Request.js +3 -1
- package/src/Router.js +1 -1
- package/src/RouterWrap.js +1 -9
- package/src/resolvers/expected.js +10 -1
- package/src/utils/wrapPluginFunction.js +1 -1
package/package.json
CHANGED
package/src/BuildRouter.js
CHANGED
|
@@ -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,
|
|
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 = {},
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
44
|
+
return router.processReducers(reducers, req, res, postBack, action, true);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|