wingbot 3.31.3 → 3.31.5-alpha.2
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 +16 -6
- package/src/Request.js +3 -1
- package/src/Responder.js +5 -1
- package/src/Router.js +1 -1
- package/src/resolvers/expected.js +10 -1
- package/src/utils/quickReplies.js +3 -2
- 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,6 +567,10 @@ 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',
|
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/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/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
|
|
@@ -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);
|
|
@@ -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:
|
|
223
|
+
_ca: useCa,
|
|
223
224
|
...data
|
|
224
225
|
}
|
|
225
226
|
};
|
|
@@ -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
|
|