@botonic/core 1.0.0-dev.0 → 1.0.0-dev.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.
Files changed (258) hide show
  1. package/lib/cjs/constants.d.ts +4 -15
  2. package/lib/cjs/constants.js +5 -16
  3. package/lib/cjs/constants.js.map +1 -1
  4. package/lib/cjs/core-bot.d.ts +12 -9
  5. package/lib/cjs/core-bot.js +54 -43
  6. package/lib/cjs/core-bot.js.map +1 -1
  7. package/lib/cjs/debug/index.d.ts +1 -1
  8. package/lib/cjs/debug/index.js +2 -6
  9. package/lib/cjs/debug/index.js.map +1 -1
  10. package/lib/cjs/debug/inspector.d.ts +1 -1
  11. package/lib/cjs/handoff.d.ts +5 -5
  12. package/lib/cjs/handoff.js +13 -10
  13. package/lib/cjs/handoff.js.map +1 -1
  14. package/lib/cjs/hubtype-service.d.ts +4 -4
  15. package/lib/cjs/hubtype-service.js +1 -1
  16. package/lib/cjs/hubtype-service.js.map +1 -1
  17. package/lib/cjs/i18n.d.ts +1 -1
  18. package/lib/cjs/index.d.ts +8 -163
  19. package/lib/cjs/index.js +8 -51
  20. package/lib/cjs/index.js.map +1 -1
  21. package/lib/cjs/models/bot-state.d.ts +11 -0
  22. package/lib/cjs/models/bot-state.js +3 -0
  23. package/lib/cjs/models/bot-state.js.map +1 -0
  24. package/lib/cjs/models/channels.d.ts +9 -0
  25. package/lib/cjs/models/channels.js +14 -0
  26. package/lib/cjs/models/channels.js.map +1 -0
  27. package/lib/cjs/models/events/base-event.d.ts +20 -0
  28. package/lib/cjs/models/events/base-event.js +17 -0
  29. package/lib/cjs/models/events/base-event.js.map +1 -0
  30. package/lib/cjs/models/events/botonic-event.d.ts +4 -0
  31. package/lib/cjs/models/events/botonic-event.js +3 -0
  32. package/lib/cjs/models/events/botonic-event.js.map +1 -0
  33. package/lib/{esm/models/events/connections/index.d.ts → cjs/models/events/connection/connection-event.d.ts} +1 -1
  34. package/lib/cjs/models/events/{connections/index.js → connection/connection-event.js} +1 -1
  35. package/lib/cjs/models/events/connection/connection-event.js.map +1 -0
  36. package/lib/cjs/models/events/connection/index.d.ts +1 -0
  37. package/lib/cjs/models/events/connection/index.js +5 -0
  38. package/lib/cjs/models/events/connection/index.js.map +1 -0
  39. package/lib/cjs/models/events/index.d.ts +4 -21
  40. package/lib/cjs/models/events/index.js +5 -8
  41. package/lib/cjs/models/events/index.js.map +1 -1
  42. package/lib/cjs/models/events/integration/index.d.ts +1 -0
  43. package/lib/cjs/models/events/integration/index.js +5 -0
  44. package/lib/cjs/models/events/integration/index.js.map +1 -0
  45. package/lib/cjs/models/events/integration/integration-event.d.ts +6 -0
  46. package/lib/cjs/models/events/integration/integration-event.js +3 -0
  47. package/lib/cjs/models/events/integration/integration-event.js.map +1 -0
  48. package/lib/cjs/models/events/message/carousel.d.ts +1 -1
  49. package/lib/cjs/models/events/message/custom.d.ts +2 -2
  50. package/lib/cjs/models/events/message/index.d.ts +9 -30
  51. package/lib/cjs/models/events/message/index.js +10 -29
  52. package/lib/cjs/models/events/message/index.js.map +1 -1
  53. package/lib/cjs/models/events/message/location.d.ts +1 -1
  54. package/lib/cjs/models/events/message/media.d.ts +1 -1
  55. package/lib/cjs/models/events/message/media.js +5 -5
  56. package/lib/cjs/models/events/message/media.js.map +1 -1
  57. package/lib/cjs/models/events/message/message-event.d.ts +30 -0
  58. package/lib/cjs/models/events/message/message-event.js +32 -0
  59. package/lib/cjs/models/events/message/message-event.js.map +1 -0
  60. package/lib/cjs/models/events/message/postback.d.ts +1 -1
  61. package/lib/cjs/models/events/message/text.d.ts +1 -1
  62. package/lib/cjs/models/index.d.ts +6 -0
  63. package/lib/cjs/models/index.js +10 -0
  64. package/lib/cjs/models/index.js.map +1 -0
  65. package/lib/cjs/models/legacy-types.d.ts +184 -0
  66. package/lib/cjs/models/legacy-types.js +59 -0
  67. package/lib/cjs/models/legacy-types.js.map +1 -0
  68. package/lib/cjs/models/session.d.ts +3 -0
  69. package/lib/cjs/models/session.js +3 -0
  70. package/lib/cjs/models/session.js.map +1 -0
  71. package/lib/cjs/models/user.d.ts +8 -4
  72. package/lib/cjs/output-parser/botonic-output-parser.d.ts +16 -0
  73. package/lib/cjs/output-parser/botonic-output-parser.js +37 -0
  74. package/lib/cjs/output-parser/botonic-output-parser.js.map +1 -0
  75. package/lib/cjs/output-parser/factory.d.ts +1 -1
  76. package/lib/cjs/output-parser/factory.js +7 -8
  77. package/lib/cjs/output-parser/factory.js.map +1 -1
  78. package/lib/cjs/output-parser/index.d.ts +3 -16
  79. package/lib/cjs/output-parser/index.js +4 -34
  80. package/lib/cjs/output-parser/index.js.map +1 -1
  81. package/lib/cjs/output-parser/parsers.d.ts +3 -9
  82. package/lib/cjs/output-parser/parsers.js +21 -12
  83. package/lib/cjs/output-parser/parsers.js.map +1 -1
  84. package/lib/cjs/plugins.d.ts +2 -3
  85. package/lib/cjs/plugins.js +9 -6
  86. package/lib/cjs/plugins.js.map +1 -1
  87. package/lib/cjs/routing/index.d.ts +2 -0
  88. package/lib/cjs/routing/index.js +6 -0
  89. package/lib/cjs/routing/index.js.map +1 -0
  90. package/lib/cjs/routing/router-utils.d.ts +11 -0
  91. package/lib/cjs/routing/router-utils.js +89 -0
  92. package/lib/cjs/routing/router-utils.js.map +1 -0
  93. package/lib/cjs/routing/router.d.ts +54 -0
  94. package/lib/cjs/routing/router.js +319 -0
  95. package/lib/cjs/routing/router.js.map +1 -0
  96. package/lib/cjs/utils.d.ts +1 -0
  97. package/lib/cjs/utils.js +7 -1
  98. package/lib/cjs/utils.js.map +1 -1
  99. package/lib/esm/constants.d.ts +4 -15
  100. package/lib/esm/constants.js +4 -15
  101. package/lib/esm/constants.js.map +1 -1
  102. package/lib/esm/core-bot.d.ts +12 -9
  103. package/lib/esm/core-bot.js +52 -41
  104. package/lib/esm/core-bot.js.map +1 -1
  105. package/lib/esm/debug/index.d.ts +1 -1
  106. package/lib/esm/debug/index.js +1 -1
  107. package/lib/esm/debug/index.js.map +1 -1
  108. package/lib/esm/debug/inspector.d.ts +1 -1
  109. package/lib/esm/handoff.d.ts +5 -5
  110. package/lib/esm/handoff.js +13 -10
  111. package/lib/esm/handoff.js.map +1 -1
  112. package/lib/esm/hubtype-service.d.ts +4 -4
  113. package/lib/esm/hubtype-service.js +1 -1
  114. package/lib/esm/hubtype-service.js.map +1 -1
  115. package/lib/esm/i18n.d.ts +1 -1
  116. package/lib/esm/index.d.ts +8 -163
  117. package/lib/esm/index.js +8 -45
  118. package/lib/esm/index.js.map +1 -1
  119. package/lib/esm/models/bot-state.d.ts +11 -0
  120. package/lib/esm/models/bot-state.js +2 -0
  121. package/lib/esm/models/bot-state.js.map +1 -0
  122. package/lib/esm/models/channels.d.ts +9 -0
  123. package/lib/esm/models/channels.js +11 -0
  124. package/lib/esm/models/channels.js.map +1 -0
  125. package/lib/esm/models/events/base-event.d.ts +20 -0
  126. package/lib/esm/models/events/base-event.js +14 -0
  127. package/lib/esm/models/events/base-event.js.map +1 -0
  128. package/lib/esm/models/events/botonic-event.d.ts +4 -0
  129. package/lib/esm/models/events/botonic-event.js +2 -0
  130. package/lib/esm/models/events/botonic-event.js.map +1 -0
  131. package/lib/{cjs/models/events/connections/index.d.ts → esm/models/events/connection/connection-event.d.ts} +1 -1
  132. package/lib/esm/models/events/{connections/index.js → connection/connection-event.js} +1 -1
  133. package/lib/esm/models/events/connection/connection-event.js.map +1 -0
  134. package/lib/esm/models/events/connection/index.d.ts +1 -0
  135. package/lib/esm/models/events/connection/index.js +2 -0
  136. package/lib/esm/models/events/connection/index.js.map +1 -0
  137. package/lib/esm/models/events/index.d.ts +4 -21
  138. package/lib/esm/models/events/index.js +4 -7
  139. package/lib/esm/models/events/index.js.map +1 -1
  140. package/lib/esm/models/events/integration/index.d.ts +1 -0
  141. package/lib/esm/models/events/integration/index.js +2 -0
  142. package/lib/esm/models/events/integration/index.js.map +1 -0
  143. package/lib/esm/models/events/integration/integration-event.d.ts +6 -0
  144. package/lib/esm/models/events/integration/integration-event.js +2 -0
  145. package/lib/esm/models/events/integration/integration-event.js.map +1 -0
  146. package/lib/esm/models/events/message/carousel.d.ts +1 -1
  147. package/lib/esm/models/events/message/custom.d.ts +2 -2
  148. package/lib/esm/models/events/message/index.d.ts +9 -30
  149. package/lib/esm/models/events/message/index.js +9 -28
  150. package/lib/esm/models/events/message/index.js.map +1 -1
  151. package/lib/esm/models/events/message/location.d.ts +1 -1
  152. package/lib/esm/models/events/message/media.d.ts +1 -1
  153. package/lib/esm/models/events/message/media.js +1 -1
  154. package/lib/esm/models/events/message/media.js.map +1 -1
  155. package/lib/esm/models/events/message/message-event.d.ts +30 -0
  156. package/lib/esm/models/events/message/message-event.js +29 -0
  157. package/lib/esm/models/events/message/message-event.js.map +1 -0
  158. package/lib/esm/models/events/message/postback.d.ts +1 -1
  159. package/lib/esm/models/events/message/text.d.ts +1 -1
  160. package/lib/esm/models/index.d.ts +6 -0
  161. package/lib/esm/models/index.js +7 -0
  162. package/lib/esm/models/index.js.map +1 -0
  163. package/lib/esm/models/legacy-types.d.ts +184 -0
  164. package/lib/esm/models/legacy-types.js +56 -0
  165. package/lib/esm/models/legacy-types.js.map +1 -0
  166. package/lib/esm/models/session.d.ts +3 -0
  167. package/lib/esm/models/session.js +2 -0
  168. package/lib/esm/models/session.js.map +1 -0
  169. package/lib/esm/models/user.d.ts +8 -4
  170. package/lib/esm/output-parser/botonic-output-parser.d.ts +16 -0
  171. package/lib/esm/output-parser/botonic-output-parser.js +33 -0
  172. package/lib/esm/output-parser/botonic-output-parser.js.map +1 -0
  173. package/lib/esm/output-parser/factory.d.ts +1 -1
  174. package/lib/esm/output-parser/factory.js +1 -2
  175. package/lib/esm/output-parser/factory.js.map +1 -1
  176. package/lib/esm/output-parser/index.d.ts +3 -16
  177. package/lib/esm/output-parser/index.js +3 -32
  178. package/lib/esm/output-parser/index.js.map +1 -1
  179. package/lib/esm/output-parser/parsers.d.ts +3 -9
  180. package/lib/esm/output-parser/parsers.js +14 -7
  181. package/lib/esm/output-parser/parsers.js.map +1 -1
  182. package/lib/esm/plugins.d.ts +2 -3
  183. package/lib/esm/plugins.js +9 -6
  184. package/lib/esm/plugins.js.map +1 -1
  185. package/lib/esm/routing/index.d.ts +2 -0
  186. package/lib/esm/routing/index.js +3 -0
  187. package/lib/esm/routing/index.js.map +1 -0
  188. package/lib/esm/routing/router-utils.d.ts +11 -0
  189. package/lib/esm/routing/router-utils.js +79 -0
  190. package/lib/esm/routing/router-utils.js.map +1 -0
  191. package/lib/esm/routing/router.d.ts +54 -0
  192. package/lib/esm/routing/router.js +315 -0
  193. package/lib/esm/routing/router.js.map +1 -0
  194. package/lib/esm/utils.d.ts +1 -0
  195. package/lib/esm/utils.js +5 -0
  196. package/lib/esm/utils.js.map +1 -1
  197. package/package.json +6 -6
  198. package/src/constants.ts +6 -15
  199. package/src/core-bot.ts +84 -47
  200. package/src/debug/index.ts +1 -6
  201. package/src/debug/inspector.ts +1 -1
  202. package/src/handoff.ts +15 -12
  203. package/src/hubtype-service.ts +5 -5
  204. package/src/i18n.ts +1 -1
  205. package/src/index.ts +8 -230
  206. package/src/models/bot-state.ts +12 -0
  207. package/src/models/channels.ts +9 -0
  208. package/src/models/events/base-event.ts +22 -0
  209. package/src/models/events/botonic-event.ts +26 -0
  210. package/src/models/events/{connections/index.ts → connection/connection-event.ts} +1 -1
  211. package/src/models/events/connection/index.ts +1 -0
  212. package/src/models/events/index.ts +4 -39
  213. package/src/models/events/integration/index.ts +1 -0
  214. package/src/models/events/integration/integration-event.ts +13 -0
  215. package/src/models/events/message/carousel.ts +1 -1
  216. package/src/models/events/message/custom.ts +2 -2
  217. package/src/models/events/message/index.ts +9 -37
  218. package/src/models/events/message/location.ts +1 -1
  219. package/src/models/events/message/media.ts +1 -1
  220. package/src/models/events/message/message-event.ts +37 -0
  221. package/src/models/events/message/postback.ts +1 -1
  222. package/src/models/events/message/text.ts +1 -1
  223. package/src/models/index.ts +6 -0
  224. package/src/models/legacy-types.ts +262 -0
  225. package/src/models/session.ts +3 -0
  226. package/src/models/user.ts +10 -4
  227. package/src/output-parser/botonic-output-parser.ts +38 -0
  228. package/src/output-parser/factory.ts +1 -3
  229. package/src/output-parser/index.ts +3 -38
  230. package/src/output-parser/parsers.ts +29 -17
  231. package/src/plugins.ts +18 -8
  232. package/src/routing/index.ts +2 -0
  233. package/src/routing/router-utils.ts +100 -0
  234. package/src/routing/router.ts +415 -0
  235. package/src/utils.ts +6 -0
  236. package/lib/cjs/errors.d.ts +0 -5
  237. package/lib/cjs/errors.js +0 -11
  238. package/lib/cjs/errors.js.map +0 -1
  239. package/lib/cjs/models/events/connections/index.js.map +0 -1
  240. package/lib/cjs/output-parser/util.d.ts +0 -2
  241. package/lib/cjs/output-parser/util.js +0 -14
  242. package/lib/cjs/output-parser/util.js.map +0 -1
  243. package/lib/cjs/router.d.ts +0 -35
  244. package/lib/cjs/router.js +0 -262
  245. package/lib/cjs/router.js.map +0 -1
  246. package/lib/esm/errors.d.ts +0 -5
  247. package/lib/esm/errors.js +0 -7
  248. package/lib/esm/errors.js.map +0 -1
  249. package/lib/esm/models/events/connections/index.js.map +0 -1
  250. package/lib/esm/output-parser/util.d.ts +0 -2
  251. package/lib/esm/output-parser/util.js +0 -9
  252. package/lib/esm/output-parser/util.js.map +0 -1
  253. package/lib/esm/router.d.ts +0 -35
  254. package/lib/esm/router.js +0 -258
  255. package/lib/esm/router.js.map +0 -1
  256. package/src/errors.ts +0 -11
  257. package/src/output-parser/util.ts +0 -8
  258. package/src/router.ts +0 -316
@@ -0,0 +1,79 @@
1
+ import { EMPTY_ACTION_PATH, NOT_FOUND_PATH, PATH_PAYLOAD_IDENTIFIER, PATH_PAYLOAD_REGEXP, } from '../constants';
2
+ export class NoMatchingRouteError extends Error {
3
+ constructor(input) {
4
+ super(`No route found for input '${JSON.stringify(input)}' and no ${NOT_FOUND_PATH} route defined`);
5
+ this.input = input;
6
+ }
7
+ }
8
+ export function isPathPayload(payload) {
9
+ if (!payload)
10
+ return false;
11
+ const isPathPayload = PATH_PAYLOAD_REGEXP.exec(payload);
12
+ return Boolean(isPathPayload);
13
+ }
14
+ export function getPathParamsFromPathPayload(payload) {
15
+ const defaultPathParams = {
16
+ path: null,
17
+ params: {},
18
+ };
19
+ if (!payload)
20
+ return defaultPathParams;
21
+ if (!isPathPayload(payload))
22
+ return defaultPathParams;
23
+ try {
24
+ const pathWithParams = payload.split(PATH_PAYLOAD_IDENTIFIER)[1];
25
+ if (!pathWithParams) {
26
+ throw `${PATH_PAYLOAD_IDENTIFIER} is empty`;
27
+ }
28
+ const [path, params] = pathWithParams.split('?');
29
+ return { path: path !== null && path !== void 0 ? path : null, params: pathParamsToParams(params) };
30
+ }
31
+ catch (e) {
32
+ console.error('Error getting path and params from input.payload:', e);
33
+ return defaultPathParams;
34
+ }
35
+ }
36
+ export function pathParamsToParams(pathParams) {
37
+ if (!pathParams)
38
+ return {};
39
+ try {
40
+ const params = {};
41
+ const searchParams = new URLSearchParams(pathParams);
42
+ for (const [key, value] of searchParams) {
43
+ params[key] = value;
44
+ }
45
+ return params;
46
+ }
47
+ catch (e) {
48
+ return {};
49
+ }
50
+ }
51
+ export function getEmptyAction(childRoutes) {
52
+ if (!childRoutes)
53
+ return null;
54
+ const emptyActionRoute = childRoutes.find(r => r.path === EMPTY_ACTION_PATH);
55
+ if (!emptyActionRoute)
56
+ return null;
57
+ return emptyActionRoute.action;
58
+ }
59
+ export function getNotFoundAction(input, routes) {
60
+ const notFoundActionRoute = routes.find(r => r.path === NOT_FOUND_PATH);
61
+ if (!notFoundActionRoute)
62
+ throw new NoMatchingRouteError(input);
63
+ return notFoundActionRoute.action;
64
+ }
65
+ export async function getComputedRoutes(routes, request) {
66
+ if (routes instanceof Function) {
67
+ return await getComputedRoutes(await routes(request), request);
68
+ }
69
+ for (const [key, route] of Object.entries(routes)) {
70
+ if (route.childRoutes && route.childRoutes instanceof Function) {
71
+ routes[key].childRoutes = await getComputedRoutes(await route.childRoutes(request), request);
72
+ }
73
+ else {
74
+ routes[key] = route;
75
+ }
76
+ }
77
+ return routes;
78
+ }
79
+ //# sourceMappingURL=router-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-utils.js","sourceRoot":"","sources":["../../../src/routing/router-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAWrB,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,KAAY;QACtB,KAAK,CACH,6BAA6B,IAAI,CAAC,SAAS,CACzC,KAAK,CACN,YAAY,cAAc,gBAAgB,CAC5C,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAC1B,MAAM,aAAa,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAgB;IAC3D,MAAM,iBAAiB,GAAG;QACxB,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,EAAE;KACX,CAAA;IACD,IAAI,CAAC,OAAO;QAAE,OAAO,iBAAiB,CAAA;IACtC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;QAAE,OAAO,iBAAiB,CAAA;IACrD,IAAI;QACF,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,GAAG,uBAAuB,WAAW,CAAA;SAC5C;QACD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChD,OAAO,EAAE,IAAI,EAAE,IAAI,aAAJ,IAA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MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,OAAmB;IAEnB,IAAI,MAAM,YAAY,QAAQ,EAAE;QAC9B,OAAO,MAAM,iBAAiB,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;KAC/D;IACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAQ,EAAE;QACxD,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,YAAY,QAAQ,EAAE;YAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,GAAG,MAAM,iBAAiB,CAC/C,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,EAChC,OAAO,CACR,CAAA;SACF;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACpB;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { RouteInspector } from '../debug/inspector';
2
+ import { BotState, Input, MatchedValue, Matcher, MatchingProp, Nullable, ProcessInputResult, Route, RouteParams, RoutePath, RoutingState, Session } from '../models';
3
+ export declare class Router {
4
+ routes: Route[];
5
+ routeInspector: RouteInspector;
6
+ constructor(routes: Route[], routeInspector?: RouteInspector | undefined);
7
+ /**
8
+ * Processes an input and return a representation of the new bot state.
9
+ * The algorithm is splitted in two main parts:
10
+ * 1. Getting the current routing state.
11
+ * 2. Given a routing state, resolve the different possible scenarios and return the new bot state.
12
+ * The new bot state can return three type of actions:
13
+ * - action: an action directly resolved from a matching route
14
+ * - emptyAction: optional action that can exists or not only within childRoutes
15
+ * - fallbackAction: any other action that acts as a fallback (404, )
16
+ */
17
+ processInput(input: Input, session: Session, botState: BotState): ProcessInputResult;
18
+ /**
19
+ * 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.
20
+ * IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
21
+ * */
22
+ getRoute(input: Input | Partial<Input>, routes: Route[], session: Session, lastRoutePath: RoutePath): RouteParams | null;
23
+ /**
24
+ * Find the route that matches the given path. Path can include concatenations, e.g: 'Flow1/Subflow1.1'.
25
+ * IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
26
+ * */
27
+ getRouteByPath(path: RoutePath, routeList?: Route[]): Nullable<Route>;
28
+ /**
29
+ * Returns the matched value for a specific route.
30
+ * Matching Props: ('text' | 'payload' | 'intent' | 'type' | 'input' | 'session' | 'request' ...)
31
+ * Matchers: (string: exact match | regex: regular expression match | function: return true)
32
+ * input: user input object, e.g.: {type: 'text', data: 'Hi'}
33
+ * */
34
+ matchRoute(route: Route, prop: MatchingProp, matcher: Matcher, input: Input, session: Session, lastRoutePath: RoutePath): MatchedValue;
35
+ /**
36
+ * Runs the matcher against the given value.
37
+ * If there is a match, it will return a truthy value (true, RegExp result), o.w., it will return a falsy value.
38
+ * */
39
+ matchValue(matcher: Matcher, value: any): MatchedValue;
40
+ /**
41
+ * It resolves the current state of navigation. Two scenarios:
42
+ * 1. Given a path payload input (__PATH_PAYLOAD__somePath?someParam=someValue), we can resolve the routing state directly from it (using getRouteByPath).
43
+ * 2. Given any other type of input, we resolve the routing state with normal resolution (using getRoute).
44
+ * */
45
+ getRoutingState(input: Input, session: Session, botState: BotState): RoutingState;
46
+ /**
47
+ * 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.
48
+ * */
49
+ getRoutingStateFromInput(currentRoute: Nullable<Route>, input: Input, session: Session): RoutingState;
50
+ /**
51
+ * 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.
52
+ * */
53
+ getRoutingStateFromPathPayload(currentRoute: Nullable<Route>, pathPayload: string): RoutingState;
54
+ }
@@ -0,0 +1,315 @@
1
+ import { NOT_FOUND_PATH } from '../constants';
2
+ import { RouteInspector } from '../debug/inspector';
3
+ import { cloneObject } from '../utils';
4
+ import { getEmptyAction, getNotFoundAction, getPathParamsFromPathPayload, isPathPayload, } from './router-utils';
5
+ export class Router {
6
+ constructor(routes, routeInspector = undefined) {
7
+ this.routes = routes;
8
+ this.routeInspector = routeInspector || new RouteInspector();
9
+ }
10
+ /**
11
+ * Processes an input and return a representation of the new bot state.
12
+ * The algorithm is splitted in two main parts:
13
+ * 1. Getting the current routing state.
14
+ * 2. Given a routing state, resolve the different possible scenarios and return the new bot state.
15
+ * The new bot state can return three type of actions:
16
+ * - action: an action directly resolved from a matching route
17
+ * - emptyAction: optional action that can exists or not only within childRoutes
18
+ * - fallbackAction: any other action that acts as a fallback (404, )
19
+ */
20
+ // eslint-disable-next-line complexity
21
+ processInput(input, session, botState) {
22
+ var _a, _b, _c, _d, _e;
23
+ botState.retries = (_a = botState.retries) !== null && _a !== void 0 ? _a : 0;
24
+ // 1. Getting the current routing state.
25
+ const { currentRoute, matchedRoute, params, isFlowBroken, } = this.getRoutingState(input, session, botState);
26
+ const currentRoutePath = (_b = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) !== null && _b !== void 0 ? _b : null;
27
+ const matchedRoutePath = (_c = matchedRoute === null || matchedRoute === void 0 ? void 0 : matchedRoute.path) !== null && _c !== void 0 ? _c : null;
28
+ // 2. Given a routing state, resolve the different possible scenarios and return the new bot state.
29
+ /**
30
+ * Redirect Scenario:
31
+ * We have matched a redirect route with a given redirection path, so we try to obtain the redirectionRoute with getRouteByPath.
32
+ * 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.
33
+ * It has preference over ignoring retries.
34
+ */
35
+ if (matchedRoute && matchedRoute.redirect) {
36
+ botState.retries = 0;
37
+ const redirectionRoute = this.getRouteByPath(matchedRoute.redirect);
38
+ if (redirectionRoute) {
39
+ botState.lastRoutePath = matchedRoute.redirect;
40
+ return {
41
+ action: redirectionRoute.action,
42
+ emptyAction: getEmptyAction(redirectionRoute.childRoutes),
43
+ fallbackAction: null,
44
+ botState,
45
+ params,
46
+ };
47
+ }
48
+ botState.lastRoutePath = null;
49
+ return {
50
+ action: null,
51
+ emptyAction: null,
52
+ fallbackAction: getNotFoundAction(input, this.routes),
53
+ botState,
54
+ params,
55
+ };
56
+ }
57
+ /**
58
+ * Ignore Retry Scenario:
59
+ * 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.
60
+ */
61
+ if (matchedRoute && matchedRoute.ignoreRetry) {
62
+ botState.retries = 0;
63
+ botState.lastRoutePath = matchedRoutePath;
64
+ return {
65
+ action: matchedRoute.action,
66
+ emptyAction: getEmptyAction(matchedRoute.childRoutes),
67
+ fallbackAction: null,
68
+ botState,
69
+ params,
70
+ };
71
+ }
72
+ /**
73
+ * Retry Scenario:
74
+ * We were in a route which had retries enabled, so we check if the number of retries is exceeded.
75
+ * 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.
76
+ */
77
+ if (isFlowBroken &&
78
+ currentRoute &&
79
+ currentRoute.retry &&
80
+ botState.retries < currentRoute.retry) {
81
+ botState.retries = botState.retries !== 0 ? botState.retries + 1 : 1;
82
+ botState.lastRoutePath = currentRoutePath;
83
+ if (matchedRoute && matchedRoutePath !== NOT_FOUND_PATH) {
84
+ return {
85
+ action: currentRoute.action,
86
+ emptyAction: getEmptyAction(matchedRoute.childRoutes),
87
+ fallbackAction: matchedRoute.action,
88
+ botState,
89
+ params,
90
+ };
91
+ }
92
+ return {
93
+ action: (_d = currentRoute.action) !== null && _d !== void 0 ? _d : null,
94
+ emptyAction: getEmptyAction(currentRoute.childRoutes),
95
+ fallbackAction: getNotFoundAction(input, this.routes),
96
+ botState,
97
+ params,
98
+ };
99
+ }
100
+ /**
101
+ * Default Scenario:
102
+ * We have matched a route or not, but we don't need to execute retries logic, so retries stay to 0.
103
+ */
104
+ botState.retries = 0;
105
+ /**
106
+ * Matching Route Scenario:
107
+ * We have matched a route, so we return the new bot state.
108
+ */
109
+ if (matchedRoute && matchedRoutePath !== NOT_FOUND_PATH) {
110
+ botState.lastRoutePath = matchedRoutePath;
111
+ return {
112
+ action: (_e = matchedRoute.action) !== null && _e !== void 0 ? _e : null,
113
+ emptyAction: getEmptyAction(matchedRoute.childRoutes),
114
+ fallbackAction: null,
115
+ botState,
116
+ params,
117
+ };
118
+ }
119
+ /**
120
+ * 404 Scenario (No Route Found):
121
+ * We have not matched any route, so we return the new bot state.
122
+ */
123
+ botState.lastRoutePath = currentRoutePath;
124
+ return {
125
+ action: null,
126
+ emptyAction: null,
127
+ fallbackAction: getNotFoundAction(input, this.routes),
128
+ params,
129
+ botState,
130
+ };
131
+ }
132
+ /**
133
+ * 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.
134
+ * IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
135
+ * */
136
+ getRoute(input, routes, session, lastRoutePath) {
137
+ let params = {};
138
+ const route = routes.find(r => Object.entries(r)
139
+ .filter(([key, _]) => key !== 'action' && key !== 'childRoutes' && key !== 'path')
140
+ .some(([key, value]) => {
141
+ const match = this.matchRoute(r, key, value, input, session, lastRoutePath);
142
+ try {
143
+ if (match !== null && typeof match !== 'boolean' && match.groups) {
144
+ // Strip '[Object: null prototype]' from groups result: https://stackoverflow.com/a/62945609/6237608
145
+ params = Object.assign({}, match.groups);
146
+ }
147
+ }
148
+ catch (e) { }
149
+ return Boolean(match);
150
+ }));
151
+ if (route)
152
+ return { route: cloneObject(route), params };
153
+ return null;
154
+ }
155
+ /**
156
+ * Find the route that matches the given path. Path can include concatenations, e.g: 'Flow1/Subflow1.1'.
157
+ * IMPORTANT: It returns a cloned route instead of the route itself to avoid modifying original routes and introduce side effects
158
+ * */
159
+ getRouteByPath(path, routeList = this.routes) {
160
+ if (!path)
161
+ return null;
162
+ const [currentPath, ...childPath] = path.split('/');
163
+ for (const route of routeList) {
164
+ // iterate over all routeList
165
+ if (route.path === currentPath) {
166
+ if (route.childRoutes &&
167
+ route.childRoutes.length &&
168
+ childPath.length > 0) {
169
+ // evaluate childroute over next actions
170
+ const computedRoute = this.getRouteByPath(childPath.join('/'), route.childRoutes);
171
+ // IMPORTANT: Returning a new object to avoid modifying dev routes and introduce side effects
172
+ if (computedRoute)
173
+ return cloneObject(computedRoute);
174
+ }
175
+ else if (childPath.length === 0) {
176
+ return cloneObject(route); // last action and found route
177
+ }
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+ /**
183
+ * Returns the matched value for a specific route.
184
+ * Matching Props: ('text' | 'payload' | 'intent' | 'type' | 'input' | 'session' | 'request' ...)
185
+ * Matchers: (string: exact match | regex: regular expression match | function: return true)
186
+ * input: user input object, e.g.: {type: 'text', data: 'Hi'}
187
+ * */
188
+ matchRoute(route, prop, matcher, input, session, lastRoutePath) {
189
+ let value = null;
190
+ if (Object.keys(input).indexOf(prop) > -1)
191
+ value = input[prop];
192
+ else if (prop === 'input')
193
+ value = input;
194
+ else if (prop === 'session')
195
+ value = session;
196
+ else if (prop === 'request')
197
+ value = { input, session, lastRoutePath };
198
+ const matched = this.matchValue(matcher, value);
199
+ if (matched) {
200
+ this.routeInspector.routeMatched(route, prop, matcher, value);
201
+ }
202
+ else {
203
+ this.routeInspector.routeNotMatched(route, prop, matcher, value);
204
+ }
205
+ return matched;
206
+ }
207
+ /**
208
+ * Runs the matcher against the given value.
209
+ * If there is a match, it will return a truthy value (true, RegExp result), o.w., it will return a falsy value.
210
+ * */
211
+ matchValue(matcher, value) {
212
+ if (typeof matcher === 'string')
213
+ return value === matcher;
214
+ if (matcher instanceof RegExp) {
215
+ if (value === undefined || value === null)
216
+ return false;
217
+ return matcher.exec(value);
218
+ }
219
+ if (typeof matcher === 'function')
220
+ return matcher(value);
221
+ return false;
222
+ }
223
+ /**
224
+ * It resolves the current state of navigation. Two scenarios:
225
+ * 1. Given a path payload input (__PATH_PAYLOAD__somePath?someParam=someValue), we can resolve the routing state directly from it (using getRouteByPath).
226
+ * 2. Given any other type of input, we resolve the routing state with normal resolution (using getRoute).
227
+ * */
228
+ getRoutingState(input, session, botState) {
229
+ const currentRoute = this.getRouteByPath(botState.lastRoutePath);
230
+ if (currentRoute && botState.lastRoutePath)
231
+ currentRoute.path = botState.lastRoutePath;
232
+ if (typeof input.payload === 'string' && isPathPayload(input.payload)) {
233
+ return this.getRoutingStateFromPathPayload(currentRoute, input.payload);
234
+ }
235
+ return this.getRoutingStateFromInput(currentRoute, input, session);
236
+ }
237
+ /**
238
+ * 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.
239
+ * */
240
+ getRoutingStateFromInput(currentRoute, input, session) {
241
+ var _a, _b, _c;
242
+ // get route depending of current ChildRoutes
243
+ if (currentRoute && currentRoute.childRoutes) {
244
+ const routeParams = this.getRoute(input, currentRoute.childRoutes, session, currentRoute.path);
245
+ if (routeParams) {
246
+ return {
247
+ currentRoute,
248
+ matchedRoute: Object.assign(Object.assign({}, routeParams.route), { path: routeParams.route && currentRoute.path
249
+ ? `${currentRoute.path}/${routeParams.route.path}`
250
+ : currentRoute.path }),
251
+ params: routeParams.params,
252
+ isFlowBroken: false,
253
+ };
254
+ }
255
+ }
256
+ /**
257
+ * we couldn't find a route in the state of the currentRoute childRoutes,
258
+ * so let's find in the general routes
259
+ */
260
+ const routeParams = this.getRoute(input, this.routes, session, (_a = currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) !== null && _a !== void 0 ? _a : null);
261
+ const isFlowBroken = Boolean(currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path);
262
+ if (routeParams === null || routeParams === void 0 ? void 0 : routeParams.route) {
263
+ return {
264
+ currentRoute,
265
+ 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 }),
266
+ params: routeParams.params,
267
+ isFlowBroken,
268
+ };
269
+ }
270
+ return {
271
+ currentRoute,
272
+ matchedRoute: null,
273
+ params: {},
274
+ isFlowBroken,
275
+ };
276
+ }
277
+ /**
278
+ * 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.
279
+ * */
280
+ getRoutingStateFromPathPayload(currentRoute, pathPayload) {
281
+ const { path, params } = getPathParamsFromPathPayload(pathPayload);
282
+ /**
283
+ * shorthand function to update the matching information given a path
284
+ */
285
+ const getRoutingStateFromPath = (seekPath) => {
286
+ const matchedRoute = this.getRouteByPath(seekPath);
287
+ if (!matchedRoute) {
288
+ return {
289
+ currentRoute,
290
+ matchedRoute: null,
291
+ params: {},
292
+ isFlowBroken: true,
293
+ };
294
+ }
295
+ return {
296
+ currentRoute,
297
+ matchedRoute: Object.assign(Object.assign({}, matchedRoute), { path: seekPath }),
298
+ params,
299
+ isFlowBroken: false,
300
+ };
301
+ };
302
+ /**
303
+ * Given a valid path: 'Flow1/Subflow1' we are in one of the two scenarios below.
304
+ */
305
+ // 1. Received __PATH_PAYLOAD__Subflow2, so we need to first try to concatenate it with Flow1 (lastRoutePath)
306
+ if (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.path) {
307
+ const routingState = getRoutingStateFromPath(`${currentRoute.path}/${path}`);
308
+ if (routingState.matchedRoute)
309
+ return routingState;
310
+ }
311
+ // 2. Received __PATH_PAYLOAD__Flow1/Subflow1, so we can resolve it directly
312
+ return getRoutingStateFromPath(path);
313
+ }
314
+ }
315
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/routing/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAenD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,aAAa,GACd,MAAM,gBAAgB,CAAA;AAEvB,MAAM,OAAO,MAAM;I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,CAAC,YAAY;gBAAE,OAAO,YAAY,CAAA;SACnD;QACD,4EAA4E;QAC5E,OAAO,uBAAuB,CAAC,IAAc,CAAC,CAAA;IAChD,CAAC;CACF"}
@@ -3,6 +3,7 @@ export declare const isBrowser: () => boolean;
3
3
  export declare function getWebpackEnvVar(webpackEnvVar: string | false, name: string, defaultValue: string): string;
4
4
  export declare const isMobile: (mobileBreakpoint?: number) => boolean;
5
5
  export declare function isFunction(o: any): boolean;
6
+ export declare function cloneObject(object: any): any;
6
7
  export declare const params2queryString: (params: {
7
8
  [key: string]: string;
8
9
  }) => string;
package/lib/esm/utils.js CHANGED
@@ -33,6 +33,11 @@ export const isMobile = (mobileBreakpoint = 460) => {
33
33
  export function isFunction(o) {
34
34
  return typeof o === 'function';
35
35
  }
36
+ export function cloneObject(object) {
37
+ if (!object)
38
+ return {};
39
+ return Object.assign({}, object);
40
+ }
36
41
  export const params2queryString = (params) => Object.entries(params)
37
42
  .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
38
43
  .join('&');
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,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;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,GAAY,EAAE;IACrC,aAAa;IACb,OAAO,OAAO,UAAU,KAAK,WAAW;QACtC,CAAC,CAAC,aAAa;YACb,UAAU;QACZ,CAAC,CAAC,OAAO,MAAM,KAAK,WAAW;YAC3B,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;YACt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AC,OAAO,CAAC,EAAE,CAAC,CAAA;IACzC,uCAAuC;IACvC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAC5D,CAAC,CAAA;AAED,iDAAiD;AACjD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/core",
3
- "version": "1.0.0-dev.0",
3
+ "version": "1.0.0-dev.2",
4
4
  "license": "MIT",
5
5
  "description": "Build Chatbots using React",
6
6
  "main": "./lib/cjs/index.js",
@@ -8,11 +8,11 @@
8
8
  "scripts": {
9
9
  "test": "../../node_modules/.bin/jest --coverage",
10
10
  "prepare": "node ../../preinstall.js",
11
- "prepublish": "npm run build",
11
+ "prepublishOnly": "rm -rf lib && npm run build",
12
12
  "lint": "npm run lint_ci -- --fix",
13
13
  "lint_ci": "../../node_modules/.bin/eslint_d --cache --quiet '*.js' 'src/**/*.ts*'",
14
- "build": "rm -rf lib && ../../node_modules/.bin/tsc -p tsconfig.json && ../../node_modules/.bin/tsc -p tsconfig.esm.json",
15
- "build:watch": "../../node_modules/.bin/tsc --watch",
14
+ "build": "../../node_modules/.bin/tsc -p tsconfig.json && ../../node_modules/.bin/tsc -p tsconfig.esm.json",
15
+ "build:watch": "npm run build -- --watch",
16
16
  "cloc": "../../scripts/qa/cloc-package.sh ."
17
17
  },
18
18
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "README.md"
31
31
  ],
32
32
  "dependencies": {
33
- "axios": "^0.21.0",
33
+ "axios": "^0.24.0",
34
34
  "decode": "^0.3.0",
35
- "fast-xml-parser": "^3.19.0",
35
+ "fast-xml-parser": "^3.21.1",
36
36
  "html-entities": "^2.3.2",
37
37
  "pusher-js": "^5.1.1"
38
38
  },
package/src/constants.ts CHANGED
@@ -1,15 +1,6 @@
1
- export const Providers = Object.freeze({
2
- Messaging: {
3
- FACEBOOK: 'facebook',
4
- GENERIC: 'generic',
5
- IMBEE: 'imbee',
6
- INTERCOM: 'intercom',
7
- SMOOCH_WEB: 'smooch_web',
8
- SMOOCH: 'smooch',
9
- TELEGRAM: 'telegram',
10
- TWITTER: 'twitter',
11
- WEBCHAT: 'webchat',
12
- WECHAT: 'wechat',
13
- WHATSAPP: 'whatsapp',
14
- },
15
- })
1
+ export const NOT_FOUND_PATH = '404'
2
+ export const EMPTY_ACTION_PATH = ''
3
+ export const PATH_PAYLOAD_IDENTIFIER = '__PATH_PAYLOAD__'
4
+ export const PATH_PAYLOAD_REGEXP = new RegExp(
5
+ `\\b^${PATH_PAYLOAD_IDENTIFIER}(.*)\\b`
6
+ )