@botonic/core 1.0.0-dev.2 → 2.23.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/CHANGELOG.md +226 -0
- package/README.md +18 -9
- package/package.json +19 -57
- package/src/index.d.ts +4 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/core-bot/index.d.ts +33 -0
- package/src/lib/core-bot/index.js +113 -0
- package/src/lib/core-bot/index.js.map +1 -0
- package/src/lib/hubtype-service/handoff.d.ts +4 -0
- package/src/lib/hubtype-service/handoff.js +32 -0
- package/src/lib/hubtype-service/handoff.js.map +1 -0
- package/src/lib/hubtype-service/index.d.ts +10 -0
- package/src/lib/hubtype-service/index.js +96 -0
- package/src/lib/hubtype-service/index.js.map +1 -0
- package/src/lib/messages/button.d.ts +8 -0
- package/src/lib/messages/button.js +10 -0
- package/src/lib/messages/button.js.map +1 -0
- package/src/lib/plugins/index.d.ts +2 -0
- package/src/lib/plugins/index.js +23 -0
- package/src/lib/plugins/index.js.map +1 -0
- package/src/lib/routes/index.d.ts +0 -0
- package/src/lib/routes/index.js +2 -0
- package/src/lib/routes/index.js.map +1 -0
- package/src/lib/routes/router.d.ts +14 -0
- package/src/lib/routes/router.js +68 -0
- package/src/lib/routes/router.js.map +1 -0
- package/src/lib/routes/types.d.ts +15 -0
- package/src/lib/routes/types.js +2 -0
- package/src/lib/routes/types.js.map +1 -0
- package/{lib/cjs/utils.d.ts → src/lib/utils/index.d.ts} +0 -4
- package/{lib/esm/utils.js → src/lib/utils/index.js} +1 -34
- package/src/lib/utils/index.js.map +1 -0
- package/lib/cjs/constants.d.ts +0 -4
- package/lib/cjs/constants.js +0 -8
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/core-bot.d.ts +0 -36
- package/lib/cjs/core-bot.js +0 -96
- package/lib/cjs/core-bot.js.map +0 -1
- package/lib/cjs/debug/index.d.ts +0 -1
- package/lib/cjs/debug/index.js +0 -5
- package/lib/cjs/debug/index.js.map +0 -1
- package/lib/cjs/debug/inspector.d.ts +0 -24
- package/lib/cjs/debug/inspector.js +0 -72
- package/lib/cjs/debug/inspector.js.map +0 -1
- package/lib/cjs/handoff.d.ts +0 -67
- package/lib/cjs/handoff.js +0 -186
- package/lib/cjs/handoff.js.map +0 -1
- package/lib/cjs/hubtype-service.d.ts +0 -69
- package/lib/cjs/hubtype-service.js +0 -190
- package/lib/cjs/hubtype-service.js.map +0 -1
- package/lib/cjs/i18n.d.ts +0 -2
- package/lib/cjs/i18n.js +0 -11
- package/lib/cjs/i18n.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -11
- package/lib/cjs/index.js +0 -15
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/models/bot-state.d.ts +0 -11
- package/lib/cjs/models/bot-state.js +0 -3
- package/lib/cjs/models/bot-state.js.map +0 -1
- package/lib/cjs/models/channels.d.ts +0 -9
- package/lib/cjs/models/channels.js +0 -14
- package/lib/cjs/models/channels.js.map +0 -1
- package/lib/cjs/models/events/base-event.d.ts +0 -20
- package/lib/cjs/models/events/base-event.js +0 -17
- package/lib/cjs/models/events/base-event.js.map +0 -1
- package/lib/cjs/models/events/botonic-event.d.ts +0 -4
- package/lib/cjs/models/events/botonic-event.js +0 -3
- package/lib/cjs/models/events/botonic-event.js.map +0 -1
- package/lib/cjs/models/events/connection/connection-event.d.ts +0 -9
- package/lib/cjs/models/events/connection/connection-event.js +0 -9
- package/lib/cjs/models/events/connection/connection-event.js.map +0 -1
- package/lib/cjs/models/events/connection/index.d.ts +0 -1
- package/lib/cjs/models/events/connection/index.js +0 -5
- package/lib/cjs/models/events/connection/index.js.map +0 -1
- package/lib/cjs/models/events/index.d.ts +0 -4
- package/lib/cjs/models/events/index.js +0 -8
- package/lib/cjs/models/events/index.js.map +0 -1
- package/lib/cjs/models/events/integration/index.d.ts +0 -1
- package/lib/cjs/models/events/integration/index.js +0 -5
- package/lib/cjs/models/events/integration/index.js.map +0 -1
- package/lib/cjs/models/events/integration/integration-event.d.ts +0 -6
- package/lib/cjs/models/events/integration/integration-event.js +0 -3
- package/lib/cjs/models/events/integration/integration-event.js.map +0 -1
- package/lib/cjs/models/events/message/buttons.d.ts +0 -18
- package/lib/cjs/models/events/message/buttons.js +0 -3
- package/lib/cjs/models/events/message/buttons.js.map +0 -1
- package/lib/cjs/models/events/message/carousel.d.ts +0 -11
- package/lib/cjs/models/events/message/carousel.js +0 -3
- package/lib/cjs/models/events/message/carousel.js.map +0 -1
- package/lib/cjs/models/events/message/custom.d.ts +0 -6
- package/lib/cjs/models/events/message/custom.js +0 -3
- package/lib/cjs/models/events/message/custom.js.map +0 -1
- package/lib/cjs/models/events/message/index.d.ts +0 -9
- package/lib/cjs/models/events/message/index.js +0 -13
- package/lib/cjs/models/events/message/index.js.map +0 -1
- package/lib/cjs/models/events/message/location.d.ts +0 -6
- package/lib/cjs/models/events/message/location.js +0 -3
- package/lib/cjs/models/events/message/location.js.map +0 -1
- package/lib/cjs/models/events/message/media.d.ts +0 -18
- package/lib/cjs/models/events/message/media.js +0 -11
- package/lib/cjs/models/events/message/media.js.map +0 -1
- package/lib/cjs/models/events/message/message-event.d.ts +0 -30
- package/lib/cjs/models/events/message/message-event.js +0 -32
- package/lib/cjs/models/events/message/message-event.js.map +0 -1
- package/lib/cjs/models/events/message/postback.d.ts +0 -4
- package/lib/cjs/models/events/message/postback.js +0 -3
- package/lib/cjs/models/events/message/postback.js.map +0 -1
- package/lib/cjs/models/events/message/replies.d.ts +0 -7
- package/lib/cjs/models/events/message/replies.js +0 -3
- package/lib/cjs/models/events/message/replies.js.map +0 -1
- package/lib/cjs/models/events/message/text.d.ts +0 -8
- package/lib/cjs/models/events/message/text.js +0 -3
- package/lib/cjs/models/events/message/text.js.map +0 -1
- package/lib/cjs/models/index.d.ts +0 -6
- package/lib/cjs/models/index.js +0 -10
- package/lib/cjs/models/index.js.map +0 -1
- package/lib/cjs/models/legacy-types.d.ts +0 -184
- package/lib/cjs/models/legacy-types.js +0 -59
- package/lib/cjs/models/legacy-types.js.map +0 -1
- package/lib/cjs/models/session.d.ts +0 -3
- package/lib/cjs/models/session.js +0 -3
- package/lib/cjs/models/session.js.map +0 -1
- package/lib/cjs/models/user.d.ts +0 -14
- package/lib/cjs/models/user.js +0 -3
- package/lib/cjs/models/user.js.map +0 -1
- package/lib/cjs/output-parser/botonic-output-parser.d.ts +0 -16
- package/lib/cjs/output-parser/botonic-output-parser.js +0 -37
- package/lib/cjs/output-parser/botonic-output-parser.js.map +0 -1
- package/lib/cjs/output-parser/factory.d.ts +0 -4
- package/lib/cjs/output-parser/factory.js +0 -32
- package/lib/cjs/output-parser/factory.js.map +0 -1
- package/lib/cjs/output-parser/index.d.ts +0 -3
- package/lib/cjs/output-parser/index.js +0 -7
- package/lib/cjs/output-parser/index.js.map +0 -1
- package/lib/cjs/output-parser/parsers.d.ts +0 -22
- package/lib/cjs/output-parser/parsers.js +0 -147
- package/lib/cjs/output-parser/parsers.js.map +0 -1
- package/lib/cjs/plugins.d.ts +0 -6
- package/lib/cjs/plugins.js +0 -48
- package/lib/cjs/plugins.js.map +0 -1
- package/lib/cjs/routing/index.d.ts +0 -2
- package/lib/cjs/routing/index.js +0 -6
- package/lib/cjs/routing/index.js.map +0 -1
- package/lib/cjs/routing/router-utils.d.ts +0 -11
- package/lib/cjs/routing/router-utils.js +0 -89
- package/lib/cjs/routing/router-utils.js.map +0 -1
- package/lib/cjs/routing/router.d.ts +0 -54
- package/lib/cjs/routing/router.js +0 -319
- package/lib/cjs/routing/router.js.map +0 -1
- package/lib/cjs/utils.js +0 -90
- package/lib/cjs/utils.js.map +0 -1
- package/lib/esm/constants.d.ts +0 -4
- package/lib/esm/constants.js +0 -5
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/core-bot.d.ts +0 -36
- package/lib/esm/core-bot.js +0 -92
- package/lib/esm/core-bot.js.map +0 -1
- package/lib/esm/debug/index.d.ts +0 -1
- package/lib/esm/debug/index.js +0 -2
- package/lib/esm/debug/index.js.map +0 -1
- package/lib/esm/debug/inspector.d.ts +0 -24
- package/lib/esm/debug/inspector.js +0 -65
- package/lib/esm/debug/inspector.js.map +0 -1
- package/lib/esm/handoff.d.ts +0 -67
- package/lib/esm/handoff.js +0 -173
- package/lib/esm/handoff.js.map +0 -1
- package/lib/esm/hubtype-service.d.ts +0 -69
- package/lib/esm/hubtype-service.js +0 -185
- package/lib/esm/hubtype-service.js.map +0 -1
- package/lib/esm/i18n.d.ts +0 -2
- package/lib/esm/i18n.js +0 -7
- package/lib/esm/i18n.js.map +0 -1
- package/lib/esm/index.d.ts +0 -11
- package/lib/esm/index.js +0 -12
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/models/bot-state.d.ts +0 -11
- package/lib/esm/models/bot-state.js +0 -2
- package/lib/esm/models/bot-state.js.map +0 -1
- package/lib/esm/models/channels.d.ts +0 -9
- package/lib/esm/models/channels.js +0 -11
- package/lib/esm/models/channels.js.map +0 -1
- package/lib/esm/models/events/base-event.d.ts +0 -20
- package/lib/esm/models/events/base-event.js +0 -14
- package/lib/esm/models/events/base-event.js.map +0 -1
- package/lib/esm/models/events/botonic-event.d.ts +0 -4
- package/lib/esm/models/events/botonic-event.js +0 -2
- package/lib/esm/models/events/botonic-event.js.map +0 -1
- package/lib/esm/models/events/connection/connection-event.d.ts +0 -9
- package/lib/esm/models/events/connection/connection-event.js +0 -6
- package/lib/esm/models/events/connection/connection-event.js.map +0 -1
- package/lib/esm/models/events/connection/index.d.ts +0 -1
- package/lib/esm/models/events/connection/index.js +0 -2
- package/lib/esm/models/events/connection/index.js.map +0 -1
- package/lib/esm/models/events/index.d.ts +0 -4
- package/lib/esm/models/events/index.js +0 -5
- package/lib/esm/models/events/index.js.map +0 -1
- package/lib/esm/models/events/integration/index.d.ts +0 -1
- package/lib/esm/models/events/integration/index.js +0 -2
- package/lib/esm/models/events/integration/index.js.map +0 -1
- package/lib/esm/models/events/integration/integration-event.d.ts +0 -6
- package/lib/esm/models/events/integration/integration-event.js +0 -2
- package/lib/esm/models/events/integration/integration-event.js.map +0 -1
- package/lib/esm/models/events/message/buttons.d.ts +0 -18
- package/lib/esm/models/events/message/buttons.js +0 -2
- package/lib/esm/models/events/message/buttons.js.map +0 -1
- package/lib/esm/models/events/message/carousel.d.ts +0 -11
- package/lib/esm/models/events/message/carousel.js +0 -2
- package/lib/esm/models/events/message/carousel.js.map +0 -1
- package/lib/esm/models/events/message/custom.d.ts +0 -6
- package/lib/esm/models/events/message/custom.js +0 -2
- package/lib/esm/models/events/message/custom.js.map +0 -1
- package/lib/esm/models/events/message/index.d.ts +0 -9
- package/lib/esm/models/events/message/index.js +0 -10
- package/lib/esm/models/events/message/index.js.map +0 -1
- package/lib/esm/models/events/message/location.d.ts +0 -6
- package/lib/esm/models/events/message/location.js +0 -2
- package/lib/esm/models/events/message/location.js.map +0 -1
- package/lib/esm/models/events/message/media.d.ts +0 -18
- package/lib/esm/models/events/message/media.js +0 -8
- package/lib/esm/models/events/message/media.js.map +0 -1
- package/lib/esm/models/events/message/message-event.d.ts +0 -30
- package/lib/esm/models/events/message/message-event.js +0 -29
- package/lib/esm/models/events/message/message-event.js.map +0 -1
- package/lib/esm/models/events/message/postback.d.ts +0 -4
- package/lib/esm/models/events/message/postback.js +0 -2
- package/lib/esm/models/events/message/postback.js.map +0 -1
- package/lib/esm/models/events/message/replies.d.ts +0 -7
- package/lib/esm/models/events/message/replies.js +0 -2
- package/lib/esm/models/events/message/replies.js.map +0 -1
- package/lib/esm/models/events/message/text.d.ts +0 -8
- package/lib/esm/models/events/message/text.js +0 -2
- package/lib/esm/models/events/message/text.js.map +0 -1
- package/lib/esm/models/index.d.ts +0 -6
- package/lib/esm/models/index.js +0 -7
- package/lib/esm/models/index.js.map +0 -1
- package/lib/esm/models/legacy-types.d.ts +0 -184
- package/lib/esm/models/legacy-types.js +0 -56
- package/lib/esm/models/legacy-types.js.map +0 -1
- package/lib/esm/models/session.d.ts +0 -3
- package/lib/esm/models/session.js +0 -2
- package/lib/esm/models/session.js.map +0 -1
- package/lib/esm/models/user.d.ts +0 -14
- package/lib/esm/models/user.js +0 -2
- package/lib/esm/models/user.js.map +0 -1
- package/lib/esm/output-parser/botonic-output-parser.d.ts +0 -16
- package/lib/esm/output-parser/botonic-output-parser.js +0 -33
- package/lib/esm/output-parser/botonic-output-parser.js.map +0 -1
- package/lib/esm/output-parser/factory.d.ts +0 -4
- package/lib/esm/output-parser/factory.js +0 -28
- package/lib/esm/output-parser/factory.js.map +0 -1
- package/lib/esm/output-parser/index.d.ts +0 -3
- package/lib/esm/output-parser/index.js +0 -4
- package/lib/esm/output-parser/index.js.map +0 -1
- package/lib/esm/output-parser/parsers.d.ts +0 -22
- package/lib/esm/output-parser/parsers.js +0 -130
- package/lib/esm/output-parser/parsers.js.map +0 -1
- package/lib/esm/plugins.d.ts +0 -6
- package/lib/esm/plugins.js +0 -43
- package/lib/esm/plugins.js.map +0 -1
- package/lib/esm/routing/index.d.ts +0 -2
- package/lib/esm/routing/index.js +0 -3
- package/lib/esm/routing/index.js.map +0 -1
- package/lib/esm/routing/router-utils.d.ts +0 -11
- package/lib/esm/routing/router-utils.js +0 -79
- package/lib/esm/routing/router-utils.js.map +0 -1
- package/lib/esm/routing/router.d.ts +0 -54
- package/lib/esm/routing/router.js +0 -315
- package/lib/esm/routing/router.js.map +0 -1
- package/lib/esm/utils.d.ts +0 -11
- package/lib/esm/utils.js.map +0 -1
- package/src/constants.ts +0 -6
- package/src/core-bot.ts +0 -181
- package/src/debug/index.ts +0 -1
- package/src/debug/inspector.ts +0 -102
- package/src/handoff.ts +0 -271
- package/src/hubtype-service.ts +0 -266
- package/src/i18n.ts +0 -12
- package/src/index.ts +0 -11
- package/src/models/bot-state.ts +0 -12
- package/src/models/channels.ts +0 -9
- package/src/models/events/base-event.ts +0 -22
- package/src/models/events/botonic-event.ts +0 -26
- package/src/models/events/connection/connection-event.ts +0 -11
- package/src/models/events/connection/index.ts +0 -1
- package/src/models/events/index.ts +0 -4
- package/src/models/events/integration/index.ts +0 -1
- package/src/models/events/integration/integration-event.ts +0 -13
- package/src/models/events/message/buttons.ts +0 -23
- package/src/models/events/message/carousel.ts +0 -13
- package/src/models/events/message/custom.ts +0 -7
- package/src/models/events/message/index.ts +0 -9
- package/src/models/events/message/location.ts +0 -7
- package/src/models/events/message/media.ts +0 -28
- package/src/models/events/message/message-event.ts +0 -37
- package/src/models/events/message/postback.ts +0 -5
- package/src/models/events/message/replies.ts +0 -8
- package/src/models/events/message/text.ts +0 -12
- package/src/models/index.ts +0 -6
- package/src/models/legacy-types.ts +0 -262
- package/src/models/session.ts +0 -3
- package/src/models/user.ts +0 -16
- package/src/output-parser/botonic-output-parser.ts +0 -38
- package/src/output-parser/factory.ts +0 -38
- package/src/output-parser/index.ts +0 -3
- package/src/output-parser/parsers.ts +0 -202
- package/src/plugins.ts +0 -59
- package/src/routing/index.ts +0 -2
- package/src/routing/router-utils.ts +0 -100
- package/src/routing/router.ts +0 -415
- package/src/utils.ts +0 -90
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Router = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const inspector_1 = require("../debug/inspector");
|
|
6
|
-
const utils_1 = require("../utils");
|
|
7
|
-
const router_utils_1 = require("./router-utils");
|
|
8
|
-
class Router {
|
|
9
|
-
constructor(routes, routeInspector = undefined) {
|
|
10
|
-
this.routes = routes;
|
|
11
|
-
this.routeInspector = routeInspector || new inspector_1.RouteInspector();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Processes an input and return a representation of the new bot state.
|
|
15
|
-
* The algorithm is splitted in two main parts:
|
|
16
|
-
* 1. Getting the current routing state.
|
|
17
|
-
* 2. Given a routing state, resolve the different possible scenarios and return the new bot state.
|
|
18
|
-
* The new bot state can return three type of actions:
|
|
19
|
-
* - action: an action directly resolved from a matching route
|
|
20
|
-
* - emptyAction: optional action that can exists or not only within childRoutes
|
|
21
|
-
* - fallbackAction: any other action that acts as a fallback (404, )
|
|
22
|
-
*/
|
|
23
|
-
// eslint-disable-next-line complexity
|
|
24
|
-
processInput(input, session, botState) {
|
|
25
|
-
var _a, _b, _c, _d, _e;
|
|
26
|
-
botState.retries = (_a = botState.retries) !== null && _a !== void 0 ? _a : 0;
|
|
27
|
-
// 1. Getting the current routing state.
|
|
28
|
-
const { currentRoute, matchedRoute, params, isFlowBroken, } = this.getRoutingState(input, session, botState);
|
|
29
|
-
const currentRoutePath = (_b = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) !== null && _b !== void 0 ? _b : null;
|
|
30
|
-
const matchedRoutePath = (_c = matchedRoute === null || matchedRoute === void 0 ? void 0 : matchedRoute.path) !== null && _c !== void 0 ? _c : null;
|
|
31
|
-
// 2. Given a routing state, resolve the different possible scenarios and return the new bot state.
|
|
32
|
-
/**
|
|
33
|
-
* Redirect Scenario:
|
|
34
|
-
* We have matched a redirect route with a given redirection path, so we try to obtain the redirectionRoute with getRouteByPath.
|
|
35
|
-
* Independently of whether the redirectionRoute is found or not, the intent is to trigger a redirection which by definition breaks the flow, so retries are set to 0.
|
|
36
|
-
* It has preference over ignoring retries.
|
|
37
|
-
*/
|
|
38
|
-
if (matchedRoute && matchedRoute.redirect) {
|
|
39
|
-
botState.retries = 0;
|
|
40
|
-
const redirectionRoute = this.getRouteByPath(matchedRoute.redirect);
|
|
41
|
-
if (redirectionRoute) {
|
|
42
|
-
botState.lastRoutePath = matchedRoute.redirect;
|
|
43
|
-
return {
|
|
44
|
-
action: redirectionRoute.action,
|
|
45
|
-
emptyAction: router_utils_1.getEmptyAction(redirectionRoute.childRoutes),
|
|
46
|
-
fallbackAction: null,
|
|
47
|
-
botState,
|
|
48
|
-
params,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
botState.lastRoutePath = null;
|
|
52
|
-
return {
|
|
53
|
-
action: null,
|
|
54
|
-
emptyAction: null,
|
|
55
|
-
fallbackAction: router_utils_1.getNotFoundAction(input, this.routes),
|
|
56
|
-
botState,
|
|
57
|
-
params,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Ignore Retry Scenario:
|
|
62
|
-
* We have matched a route with an ignore retry, so we return directly the new bot state. The intent is to break the flow, so retries are set to 0.
|
|
63
|
-
*/
|
|
64
|
-
if (matchedRoute && matchedRoute.ignoreRetry) {
|
|
65
|
-
botState.retries = 0;
|
|
66
|
-
botState.lastRoutePath = matchedRoutePath;
|
|
67
|
-
return {
|
|
68
|
-
action: matchedRoute.action,
|
|
69
|
-
emptyAction: router_utils_1.getEmptyAction(matchedRoute.childRoutes),
|
|
70
|
-
fallbackAction: null,
|
|
71
|
-
botState,
|
|
72
|
-
params,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Retry Scenario:
|
|
77
|
-
* We were in a route which had retries enabled, so we check if the number of retries is exceeded.
|
|
78
|
-
* If we have not surpassed the limit of retries and we haven't matched an ignoreRetry route, update them, and then return the new bot state.
|
|
79
|
-
*/
|
|
80
|
-
if (isFlowBroken &&
|
|
81
|
-
currentRoute &&
|
|
82
|
-
currentRoute.retry &&
|
|
83
|
-
botState.retries < currentRoute.retry) {
|
|
84
|
-
botState.retries = botState.retries !== 0 ? botState.retries + 1 : 1;
|
|
85
|
-
botState.lastRoutePath = currentRoutePath;
|
|
86
|
-
if (matchedRoute && matchedRoutePath !== constants_1.NOT_FOUND_PATH) {
|
|
87
|
-
return {
|
|
88
|
-
action: currentRoute.action,
|
|
89
|
-
emptyAction: router_utils_1.getEmptyAction(matchedRoute.childRoutes),
|
|
90
|
-
fallbackAction: matchedRoute.action,
|
|
91
|
-
botState,
|
|
92
|
-
params,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
action: (_d = currentRoute.action) !== null && _d !== void 0 ? _d : null,
|
|
97
|
-
emptyAction: router_utils_1.getEmptyAction(currentRoute.childRoutes),
|
|
98
|
-
fallbackAction: router_utils_1.getNotFoundAction(input, this.routes),
|
|
99
|
-
botState,
|
|
100
|
-
params,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Default Scenario:
|
|
105
|
-
* We have matched a route or not, but we don't need to execute retries logic, so retries stay to 0.
|
|
106
|
-
*/
|
|
107
|
-
botState.retries = 0;
|
|
108
|
-
/**
|
|
109
|
-
* Matching Route Scenario:
|
|
110
|
-
* We have matched a route, so we return the new bot state.
|
|
111
|
-
*/
|
|
112
|
-
if (matchedRoute && matchedRoutePath !== constants_1.NOT_FOUND_PATH) {
|
|
113
|
-
botState.lastRoutePath = matchedRoutePath;
|
|
114
|
-
return {
|
|
115
|
-
action: (_e = matchedRoute.action) !== null && _e !== void 0 ? _e : null,
|
|
116
|
-
emptyAction: router_utils_1.getEmptyAction(matchedRoute.childRoutes),
|
|
117
|
-
fallbackAction: null,
|
|
118
|
-
botState,
|
|
119
|
-
params,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* 404 Scenario (No Route Found):
|
|
124
|
-
* We have not matched any route, so we return the new bot state.
|
|
125
|
-
*/
|
|
126
|
-
botState.lastRoutePath = currentRoutePath;
|
|
127
|
-
return {
|
|
128
|
-
action: null,
|
|
129
|
-
emptyAction: null,
|
|
130
|
-
fallbackAction: router_utils_1.getNotFoundAction(input, this.routes),
|
|
131
|
-
params,
|
|
132
|
-
botState,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Find the route that matches the given input, if it match with some of the entries, return the whole Route of the entry with optional params captured if matcher was a regex.
|
|
137
|
-
* IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
|
|
138
|
-
* */
|
|
139
|
-
getRoute(input, routes, session, lastRoutePath) {
|
|
140
|
-
let params = {};
|
|
141
|
-
const route = routes.find(r => Object.entries(r)
|
|
142
|
-
.filter(([key, _]) => key !== 'action' && key !== 'childRoutes' && key !== 'path')
|
|
143
|
-
.some(([key, value]) => {
|
|
144
|
-
const match = this.matchRoute(r, key, value, input, session, lastRoutePath);
|
|
145
|
-
try {
|
|
146
|
-
if (match !== null && typeof match !== 'boolean' && match.groups) {
|
|
147
|
-
// Strip '[Object: null prototype]' from groups result: https://stackoverflow.com/a/62945609/6237608
|
|
148
|
-
params = Object.assign({}, match.groups);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (e) { }
|
|
152
|
-
return Boolean(match);
|
|
153
|
-
}));
|
|
154
|
-
if (route)
|
|
155
|
-
return { route: utils_1.cloneObject(route), params };
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Find the route that matches the given path. Path can include concatenations, e.g: 'Flow1/Subflow1.1'.
|
|
160
|
-
* IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
|
|
161
|
-
* */
|
|
162
|
-
getRouteByPath(path, routeList = this.routes) {
|
|
163
|
-
if (!path)
|
|
164
|
-
return null;
|
|
165
|
-
const [currentPath, ...childPath] = path.split('/');
|
|
166
|
-
for (const route of routeList) {
|
|
167
|
-
// iterate over all routeList
|
|
168
|
-
if (route.path === currentPath) {
|
|
169
|
-
if (route.childRoutes &&
|
|
170
|
-
route.childRoutes.length &&
|
|
171
|
-
childPath.length > 0) {
|
|
172
|
-
// evaluate childroute over next actions
|
|
173
|
-
const computedRoute = this.getRouteByPath(childPath.join('/'), route.childRoutes);
|
|
174
|
-
// IMPORTANT: Returning a new object to avoid modifying dev routes and introduce side effects
|
|
175
|
-
if (computedRoute)
|
|
176
|
-
return utils_1.cloneObject(computedRoute);
|
|
177
|
-
}
|
|
178
|
-
else if (childPath.length === 0) {
|
|
179
|
-
return utils_1.cloneObject(route); // last action and found route
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Returns the matched value for a specific route.
|
|
187
|
-
* Matching Props: ('text' | 'payload' | 'intent' | 'type' | 'input' | 'session' | 'request' ...)
|
|
188
|
-
* Matchers: (string: exact match | regex: regular expression match | function: return true)
|
|
189
|
-
* input: user input object, e.g.: {type: 'text', data: 'Hi'}
|
|
190
|
-
* */
|
|
191
|
-
matchRoute(route, prop, matcher, input, session, lastRoutePath) {
|
|
192
|
-
let value = null;
|
|
193
|
-
if (Object.keys(input).indexOf(prop) > -1)
|
|
194
|
-
value = input[prop];
|
|
195
|
-
else if (prop === 'input')
|
|
196
|
-
value = input;
|
|
197
|
-
else if (prop === 'session')
|
|
198
|
-
value = session;
|
|
199
|
-
else if (prop === 'request')
|
|
200
|
-
value = { input, session, lastRoutePath };
|
|
201
|
-
const matched = this.matchValue(matcher, value);
|
|
202
|
-
if (matched) {
|
|
203
|
-
this.routeInspector.routeMatched(route, prop, matcher, value);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
this.routeInspector.routeNotMatched(route, prop, matcher, value);
|
|
207
|
-
}
|
|
208
|
-
return matched;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Runs the matcher against the given value.
|
|
212
|
-
* If there is a match, it will return a truthy value (true, RegExp result), o.w., it will return a falsy value.
|
|
213
|
-
* */
|
|
214
|
-
matchValue(matcher, value) {
|
|
215
|
-
if (typeof matcher === 'string')
|
|
216
|
-
return value === matcher;
|
|
217
|
-
if (matcher instanceof RegExp) {
|
|
218
|
-
if (value === undefined || value === null)
|
|
219
|
-
return false;
|
|
220
|
-
return matcher.exec(value);
|
|
221
|
-
}
|
|
222
|
-
if (typeof matcher === 'function')
|
|
223
|
-
return matcher(value);
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* It resolves the current state of navigation. Two scenarios:
|
|
228
|
-
* 1. Given a path payload input (__PATH_PAYLOAD__somePath?someParam=someValue), we can resolve the routing state directly from it (using getRouteByPath).
|
|
229
|
-
* 2. Given any other type of input, we resolve the routing state with normal resolution (using getRoute).
|
|
230
|
-
* */
|
|
231
|
-
getRoutingState(input, session, botState) {
|
|
232
|
-
const currentRoute = this.getRouteByPath(botState.lastRoutePath);
|
|
233
|
-
if (currentRoute && botState.lastRoutePath)
|
|
234
|
-
currentRoute.path = botState.lastRoutePath;
|
|
235
|
-
if (typeof input.payload === 'string' && router_utils_1.isPathPayload(input.payload)) {
|
|
236
|
-
return this.getRoutingStateFromPathPayload(currentRoute, input.payload);
|
|
237
|
-
}
|
|
238
|
-
return this.getRoutingStateFromInput(currentRoute, input, session);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Given a non path payload input, try to run it against the routes, update matching routes information in consequence and dictamine if the flow has been broken.
|
|
242
|
-
* */
|
|
243
|
-
getRoutingStateFromInput(currentRoute, input, session) {
|
|
244
|
-
var _a, _b, _c;
|
|
245
|
-
// get route depending of current ChildRoutes
|
|
246
|
-
if (currentRoute && currentRoute.childRoutes) {
|
|
247
|
-
const routeParams = this.getRoute(input, currentRoute.childRoutes, session, currentRoute.path);
|
|
248
|
-
if (routeParams) {
|
|
249
|
-
return {
|
|
250
|
-
currentRoute,
|
|
251
|
-
matchedRoute: Object.assign(Object.assign({}, routeParams.route), { path: routeParams.route && currentRoute.path
|
|
252
|
-
? `${currentRoute.path}/${routeParams.route.path}`
|
|
253
|
-
: currentRoute.path }),
|
|
254
|
-
params: routeParams.params,
|
|
255
|
-
isFlowBroken: false,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* we couldn't find a route in the state of the currentRoute childRoutes,
|
|
261
|
-
* so let's find in the general routes
|
|
262
|
-
*/
|
|
263
|
-
const routeParams = this.getRoute(input, this.routes, session, (_a = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) !== null && _a !== void 0 ? _a : null);
|
|
264
|
-
const isFlowBroken = Boolean(currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path);
|
|
265
|
-
if (routeParams === null || routeParams === void 0 ? void 0 : routeParams.route) {
|
|
266
|
-
return {
|
|
267
|
-
currentRoute,
|
|
268
|
-
matchedRoute: Object.assign(Object.assign({}, routeParams.route), { path: (_c = (_b = routeParams.route) === null || _b === void 0 ? void 0 : _b.path) !== null && _c !== void 0 ? _c : null }),
|
|
269
|
-
params: routeParams.params,
|
|
270
|
-
isFlowBroken,
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
return {
|
|
274
|
-
currentRoute,
|
|
275
|
-
matchedRoute: null,
|
|
276
|
-
params: {},
|
|
277
|
-
isFlowBroken,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Given a path payload input, try to run the path against the routes, update matching routes information in consequence and dictamine if the flow has been broken.
|
|
282
|
-
* */
|
|
283
|
-
getRoutingStateFromPathPayload(currentRoute, pathPayload) {
|
|
284
|
-
const { path, params } = router_utils_1.getPathParamsFromPathPayload(pathPayload);
|
|
285
|
-
/**
|
|
286
|
-
* shorthand function to update the matching information given a path
|
|
287
|
-
*/
|
|
288
|
-
const getRoutingStateFromPath = (seekPath) => {
|
|
289
|
-
const matchedRoute = this.getRouteByPath(seekPath);
|
|
290
|
-
if (!matchedRoute) {
|
|
291
|
-
return {
|
|
292
|
-
currentRoute,
|
|
293
|
-
matchedRoute: null,
|
|
294
|
-
params: {},
|
|
295
|
-
isFlowBroken: true,
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
return {
|
|
299
|
-
currentRoute,
|
|
300
|
-
matchedRoute: Object.assign(Object.assign({}, matchedRoute), { path: seekPath }),
|
|
301
|
-
params,
|
|
302
|
-
isFlowBroken: false,
|
|
303
|
-
};
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* Given a valid path: 'Flow1/Subflow1' we are in one of the two scenarios below.
|
|
307
|
-
*/
|
|
308
|
-
// 1. Received __PATH_PAYLOAD__Subflow2, so we need to first try to concatenate it with Flow1 (lastRoutePath)
|
|
309
|
-
if (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) {
|
|
310
|
-
const routingState = getRoutingStateFromPath(`${currentRoute.path}/${path}`);
|
|
311
|
-
if (routingState.matchedRoute)
|
|
312
|
-
return routingState;
|
|
313
|
-
}
|
|
314
|
-
// 2. Received __PATH_PAYLOAD__Flow1/Subflow1, so we can resolve it directly
|
|
315
|
-
return getRoutingStateFromPath(path);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
exports.Router = Router;
|
|
319
|
-
//# sourceMappingURL=router.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/routing/router.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,kDAAmD;AAenD,oCAAsC;AACtC,iDAKuB;AAEvB,MAAa,MAAM;IAIjB,YACE,MAAe,EACf,iBAA6C,SAAS;QAEtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,0BAAc,EAAE,CAAA;IAC9D,CAAC;IAED;;;;;;;;;OASG;IAEH,sCAAsC;IACtC,YAAY,CACV,KAAY,EACZ,OAAgB,EAChB,QAAkB;;QAElB,QAAQ,CAAC,OAAO,GAAG,MAAA,QAAQ,CAAC,OAAO,mCAAI,CAAC,CAAA;QAExC,wCAAwC;QACxC,MAAM,EACJ,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,YAAY,GACb,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QAElD,MAAM,gBAAgB,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,mCAAI,IAAI,CAAA;QACnD,MAAM,gBAAgB,GAAG,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,mCAAI,IAAI,CAAA;QAEnD,mGAAm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AE;YACjE,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAA;YAClD,IAAI,CAAC,YAAY,EAAE;gBACjB,OAAO;oBACL,YAAY;oBACZ,YAAY,EAAE,IAAI;oBAClB,MAAM,EAAE,EAAE;oBACV,YAAY,EAAE,IAAI;iBACnB,CAAA;aACF;YACD,OAAO;gBACL,YAAY;gBACZ,YAAY,kCAAO,YAAY,KAAE,IAAI,EAAE,QAAQ,GAAE;gBACjD,MAAM;gBACN,YAAY,EAAE,KAAK;aACpB,CAAA;QACH,CAAC,CAAA;QACD;;WAEG;QACH,8GAA8G;QAC9G,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,IAAI,EAAE;YACtB,MAAM,YAAY,GAAG,uBAAuB,CAC1C,GAAG,YAAY,CAAC,IAAI,IAAI,IAAI,EAAE,CAC/B,CAAA;YACD,IAAI,YAAY,CAAC,YAAY;gBAAE,OAAO,YAAY,CAAA;SACnD;QACD,4EAA4E;QAC5E,OAAO,uBAAuB,CAAC,IAAc,CAAC,CAAA;IAChD,CAAC;CACF;AAtYD,wBAsYC"}
|
package/lib/cjs/utils.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dirname = exports.join = exports.params2queryString = exports.cloneObject = exports.isFunction = exports.isMobile = exports.getWebpackEnvVar = exports.isBrowser = exports.isNode = void 0;
|
|
4
|
-
const isNode = () => {
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
return typeof IS_NODE !== 'undefined'
|
|
7
|
-
? // @ts-ignore
|
|
8
|
-
IS_NODE
|
|
9
|
-
: typeof process !== 'undefined' &&
|
|
10
|
-
process.versions !== null &&
|
|
11
|
-
process.versions.node !== null;
|
|
12
|
-
};
|
|
13
|
-
exports.isNode = isNode;
|
|
14
|
-
const isBrowser = () => {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
return typeof IS_BROWSER !== 'undefined'
|
|
17
|
-
? // @ts-ignore
|
|
18
|
-
IS_BROWSER
|
|
19
|
-
: typeof window !== 'undefined' &&
|
|
20
|
-
typeof window.document !== 'undefined' &&
|
|
21
|
-
!window.process;
|
|
22
|
-
};
|
|
23
|
-
exports.isBrowser = isBrowser;
|
|
24
|
-
function getWebpackEnvVar(webpackEnvVar, name, defaultValue) {
|
|
25
|
-
return (webpackEnvVar ||
|
|
26
|
-
(typeof process !== 'undefined' && process.env[name]) ||
|
|
27
|
-
defaultValue);
|
|
28
|
-
}
|
|
29
|
-
exports.getWebpackEnvVar = getWebpackEnvVar;
|
|
30
|
-
const isMobile = (mobileBreakpoint = 460) => {
|
|
31
|
-
if (exports.isBrowser()) {
|
|
32
|
-
const w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
|
33
|
-
if (w < mobileBreakpoint) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
};
|
|
39
|
-
exports.isMobile = isMobile;
|
|
40
|
-
function isFunction(o) {
|
|
41
|
-
return typeof o === 'function';
|
|
42
|
-
}
|
|
43
|
-
exports.isFunction = isFunction;
|
|
44
|
-
function cloneObject(object) {
|
|
45
|
-
if (!object)
|
|
46
|
-
return {};
|
|
47
|
-
return Object.assign({}, object);
|
|
48
|
-
}
|
|
49
|
-
exports.cloneObject = cloneObject;
|
|
50
|
-
const params2queryString = (params) => Object.entries(params)
|
|
51
|
-
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
|
|
52
|
-
.join('&');
|
|
53
|
-
exports.params2queryString = params2queryString;
|
|
54
|
-
// Joins path segments. Preserves initial "/" and resolves ".." and "."
|
|
55
|
-
// Does not support using ".." to go above/outside the root.
|
|
56
|
-
// This means that join("foo", "../../bar") will not resolve to "../bar"
|
|
57
|
-
const join = (...segments) => {
|
|
58
|
-
// Split the inputs into a list of path commands.
|
|
59
|
-
let parts = [];
|
|
60
|
-
for (let i = 0, l = segments.length; i < l; i++) {
|
|
61
|
-
parts = parts.concat(segments[i].split('/'));
|
|
62
|
-
}
|
|
63
|
-
// Interpret the path commands to get the new resolved path.
|
|
64
|
-
const newParts = [];
|
|
65
|
-
for (let i = 0, l = parts.length; i < l; i++) {
|
|
66
|
-
const part = parts[i];
|
|
67
|
-
// Remove leading and trailing slashes
|
|
68
|
-
// Also remove "." segments
|
|
69
|
-
if (!part || part === '.')
|
|
70
|
-
continue;
|
|
71
|
-
// Interpret ".." to pop the last segment
|
|
72
|
-
if (part === '..')
|
|
73
|
-
newParts.pop();
|
|
74
|
-
// Push new path segments.
|
|
75
|
-
else
|
|
76
|
-
newParts.push(part);
|
|
77
|
-
}
|
|
78
|
-
// Preserve the initial slash if there was one.
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
if (parts[0] === '')
|
|
81
|
-
newParts.unshift('');
|
|
82
|
-
// Turn back into a single string path.
|
|
83
|
-
return newParts.join('/') || (newParts.length ? '/' : '.');
|
|
84
|
-
};
|
|
85
|
-
exports.join = join;
|
|
86
|
-
// A simple function to get the dirname of a path
|
|
87
|
-
// Trailing slashes are ignored. Leading slash is preserved.
|
|
88
|
-
const dirname = (path) => exports.join(path, '..');
|
|
89
|
-
exports.dirname = dirname;
|
|
90
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/cjs/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,MAAM,GAAG,GAAY,EAAE;IAClC,aAAa;IACb,OAAO,OAAO,OAAO,KAAK,WAAW;QACnC,CAAC,CAAC,aAAa;YACb,OAAO;QACT,CAAC,CAAC,OAAO,OAAO,KAAK,WAAW;YAC5B,OAAO,CAAC,QAAQ,KAAK,IAAI;YACzB,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAA;AACtC,CAAC,CAAA;AARY,QA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AI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC5D,CAAC,CAAA;AAvBY,QAAA,IAAI,QAuBhB;AAED,iDAAiD;AACjD,4DAA4D;AACrD,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,YAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AAApD,QAAA,OAAO,WAA6C"}
|
package/lib/esm/constants.d.ts
DELETED
package/lib/esm/constants.js
DELETED
package/lib/esm/constants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAC3C,OAAO,uBAAuB,SAAS,CACxC,CAAA"}
|
package/lib/esm/core-bot.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Inspector } from './debug';
|
|
2
|
-
import { BotRequest, BotResponse, BotState, Locales, Route, Routes } from './models';
|
|
3
|
-
import { BotonicOutputParser } from './output-parser';
|
|
4
|
-
import { Router } from './routing';
|
|
5
|
-
interface CoreBotConfig {
|
|
6
|
-
appId?: string;
|
|
7
|
-
defaultDelay?: number;
|
|
8
|
-
defaultRoutes?: Route[];
|
|
9
|
-
defaultTyping?: number;
|
|
10
|
-
inspector?: Inspector;
|
|
11
|
-
locales: Locales;
|
|
12
|
-
plugins?: any;
|
|
13
|
-
renderer: any;
|
|
14
|
-
routes: Routes;
|
|
15
|
-
theme?: any;
|
|
16
|
-
}
|
|
17
|
-
export declare class CoreBot {
|
|
18
|
-
appId?: string;
|
|
19
|
-
defaultDelay?: number;
|
|
20
|
-
defaultRoutes: Route[];
|
|
21
|
-
defaultTyping?: number;
|
|
22
|
-
inspector: Inspector;
|
|
23
|
-
locales: Locales;
|
|
24
|
-
plugins?: Record<string, Plugin>;
|
|
25
|
-
renderer: any;
|
|
26
|
-
rootElement: any;
|
|
27
|
-
router: Router | null;
|
|
28
|
-
routes: Routes;
|
|
29
|
-
theme?: any;
|
|
30
|
-
botonicOutputParser: BotonicOutputParser;
|
|
31
|
-
constructor({ renderer, routes, locales, theme, plugins, appId, defaultTyping, defaultDelay, defaultRoutes, inspector, }: CoreBotConfig);
|
|
32
|
-
getString(id: string, botState: BotState): string;
|
|
33
|
-
setLocale(locale: string, botState: BotState): void;
|
|
34
|
-
input({ input, session, botState, dataProvider, }: BotRequest): Promise<BotResponse>;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
package/lib/esm/core-bot.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Inspector } from './debug';
|
|
2
|
-
import { getString } from './i18n';
|
|
3
|
-
import { BotonicOutputParser } from './output-parser';
|
|
4
|
-
import { loadPlugins, runPlugins } from './plugins';
|
|
5
|
-
import { getComputedRoutes, Router } from './routing';
|
|
6
|
-
export class CoreBot {
|
|
7
|
-
constructor({
|
|
8
|
-
// TODO: Receives dataProvider
|
|
9
|
-
renderer, routes, locales, theme, plugins, appId, defaultTyping, defaultDelay, defaultRoutes, inspector, }) {
|
|
10
|
-
this.botonicOutputParser = new BotonicOutputParser();
|
|
11
|
-
this.renderer = renderer;
|
|
12
|
-
this.plugins = loadPlugins(plugins);
|
|
13
|
-
this.theme = theme || {};
|
|
14
|
-
this.defaultTyping =
|
|
15
|
-
typeof defaultTyping !== 'undefined' ? defaultTyping : 0.6;
|
|
16
|
-
this.defaultDelay = typeof defaultDelay !== 'undefined' ? defaultDelay : 0.4;
|
|
17
|
-
this.locales = locales;
|
|
18
|
-
if (appId) {
|
|
19
|
-
this.appId = appId;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
this.rootElement = null;
|
|
23
|
-
this.inspector = inspector || new Inspector();
|
|
24
|
-
this.routes = routes;
|
|
25
|
-
this.defaultRoutes = defaultRoutes || [];
|
|
26
|
-
this.router =
|
|
27
|
-
this.routes instanceof Function
|
|
28
|
-
? null
|
|
29
|
-
: new Router([...this.routes, ...this.defaultRoutes], this.inspector.routeInspector);
|
|
30
|
-
}
|
|
31
|
-
getString(id, botState) {
|
|
32
|
-
if (!botState.locale) {
|
|
33
|
-
console.error('Locale is not defined');
|
|
34
|
-
return '';
|
|
35
|
-
}
|
|
36
|
-
return getString(this.locales, botState.locale, id);
|
|
37
|
-
}
|
|
38
|
-
setLocale(locale, botState) {
|
|
39
|
-
botState.locale = locale;
|
|
40
|
-
}
|
|
41
|
-
async input({ input, session, botState, dataProvider, }) {
|
|
42
|
-
if (!(botState === null || botState === void 0 ? void 0 : botState.locale))
|
|
43
|
-
botState.locale = 'en';
|
|
44
|
-
if (this.plugins) {
|
|
45
|
-
await runPlugins(this.plugins, 'pre', input, session, botState, undefined, undefined, dataProvider);
|
|
46
|
-
}
|
|
47
|
-
if (this.routes instanceof Function) {
|
|
48
|
-
this.router = new Router([
|
|
49
|
-
...(await getComputedRoutes(this.routes, {
|
|
50
|
-
input,
|
|
51
|
-
session,
|
|
52
|
-
botState,
|
|
53
|
-
})),
|
|
54
|
-
...this.defaultRoutes,
|
|
55
|
-
], this.inspector.routeInspector);
|
|
56
|
-
}
|
|
57
|
-
const output = this.router.processInput(input, session, botState);
|
|
58
|
-
const request = {
|
|
59
|
-
getString: stringId => this.getString(stringId, botState),
|
|
60
|
-
setLocale: locale => this.setLocale(locale, botState),
|
|
61
|
-
session: session || {},
|
|
62
|
-
params: output.params || {},
|
|
63
|
-
input: input,
|
|
64
|
-
plugins: this.plugins,
|
|
65
|
-
defaultTyping: this.defaultTyping,
|
|
66
|
-
defaultDelay: this.defaultDelay,
|
|
67
|
-
botState,
|
|
68
|
-
dataProvider,
|
|
69
|
-
};
|
|
70
|
-
const response = await this.renderer({
|
|
71
|
-
request,
|
|
72
|
-
actions: [output.fallbackAction, output.action, output.emptyAction],
|
|
73
|
-
});
|
|
74
|
-
const messageEvents = this.botonicOutputParser.xmlToMessageEvents(response);
|
|
75
|
-
botState.lastRoutePath = output.botState.lastRoutePath; // not needed if updated below
|
|
76
|
-
if (this.plugins) {
|
|
77
|
-
await runPlugins(this.plugins, 'post', input, session, // passing output.session instead
|
|
78
|
-
botState, // passing output.botState instead
|
|
79
|
-
response, messageEvents, dataProvider);
|
|
80
|
-
}
|
|
81
|
-
botState.isFirstInteraction = false;
|
|
82
|
-
return {
|
|
83
|
-
input,
|
|
84
|
-
response,
|
|
85
|
-
messageEvents,
|
|
86
|
-
session,
|
|
87
|
-
botState,
|
|
88
|
-
dataProvider, // no need to return it
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=core-bot.js.map
|
package/lib/esm/core-bot.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-bot.js","sourceRoot":"","sources":["../../src/core-bot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAWlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAcrD,MAAM,OAAO,OAAO;IAelB,YAAY;IACV,8BAA8B;IAC9B,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,EACL,OAAO,EACP,KAAK,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,SAAS,GACK;QAdhB,wBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAA;QAe7C,IAAI,CAAC,QAAQ,GAA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I,CAAC,YAAY;YAC/B,QAAQ;YACR,YAAY;SACb,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC;YACnC,OAAO;YACP,OAAO,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC;SACpE,CAAC,CAAA;QAEF,MAAM,aAAa,GAA4B,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CACxF,QAAQ,CACT,CAAA;QAED,QAAQ,CAAC,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAA,CAAC,8BAA8B;QAErF,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,UAAU,CACd,IAAI,CAAC,OAAO,EACZ,MAAM,EACN,KAAK,EACL,OAAO,EAAE,iCAAiC;YAC1C,QAAQ,EAAE,kCAAkC;YAC5C,QAAQ,EACR,aAAa,EACb,YAAY,CACb,CAAA;SACF;QAED,QAAQ,CAAC,kBAAkB,GAAG,KAAK,CAAA;QAEnC,OAAO;YACL,KAAK;YACL,QAAQ;YACR,aAAa;YACb,OAAO;YACP,QAAQ;YACR,YAAY,EAAE,uBAAuB;SACtC,CAAA;IACH,CAAC;CACF"}
|
package/lib/esm/debug/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './inspector';
|
package/lib/esm/debug/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/debug/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Route, RouteMatcher } from '../models';
|
|
2
|
-
export declare class RouteInspector {
|
|
3
|
-
routeMatched(_route: Route, _routeKey: string, _routeValue: RouteMatcher, _input: any): void;
|
|
4
|
-
routeNotMatched(_route: Route, _routeKey: string, _routeValue: RouteMatcher, _input: any): void;
|
|
5
|
-
}
|
|
6
|
-
export declare class FocusRouteInspector extends RouteInspector {
|
|
7
|
-
focusRoutePaths: string[] | null;
|
|
8
|
-
focusOnMatches: boolean;
|
|
9
|
-
constructor();
|
|
10
|
-
focusOnlyOnRoutes(focusRoutePaths: string[]): this;
|
|
11
|
-
focusOnlyOnMatches(): this;
|
|
12
|
-
_isOnFocus(route: Route): boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class LogRouteInspector extends FocusRouteInspector {
|
|
15
|
-
routeMatched(route: Route, routeKey: string, routeValue: RouteMatcher, inputValue: string): void;
|
|
16
|
-
routeNotMatched(route: Route, routeKey: string, routeValue: RouteMatcher, inputValue: string): void;
|
|
17
|
-
_routeName(obj: Route): string;
|
|
18
|
-
_log(message: string, ...optionalParams: string[]): void;
|
|
19
|
-
}
|
|
20
|
-
export declare class Inspector {
|
|
21
|
-
routeInspector: RouteInspector;
|
|
22
|
-
constructor(routeInspector?: RouteInspector | undefined);
|
|
23
|
-
getRouteInspector(): RouteInspector;
|
|
24
|
-
}
|