@botonic/core 1.0.0-dev.0 → 2.23.0

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 (228) hide show
  1. package/CHANGELOG.md +226 -0
  2. package/README.md +7 -9
  3. package/package.json +19 -57
  4. package/src/index.d.ts +4 -0
  5. package/src/index.js +5 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/core-bot/index.d.ts +33 -0
  8. package/src/lib/core-bot/index.js +113 -0
  9. package/src/lib/core-bot/index.js.map +1 -0
  10. package/src/lib/hubtype-service/handoff.d.ts +4 -0
  11. package/src/lib/hubtype-service/handoff.js +32 -0
  12. package/src/lib/hubtype-service/handoff.js.map +1 -0
  13. package/src/lib/hubtype-service/index.d.ts +10 -0
  14. package/src/lib/hubtype-service/index.js +96 -0
  15. package/src/lib/hubtype-service/index.js.map +1 -0
  16. package/src/lib/messages/button.d.ts +8 -0
  17. package/src/lib/messages/button.js +10 -0
  18. package/src/lib/messages/button.js.map +1 -0
  19. package/src/lib/plugins/index.d.ts +2 -0
  20. package/src/lib/plugins/index.js +23 -0
  21. package/src/lib/plugins/index.js.map +1 -0
  22. package/src/lib/routes/index.d.ts +0 -0
  23. package/src/lib/routes/index.js +2 -0
  24. package/src/lib/routes/index.js.map +1 -0
  25. package/src/lib/routes/router.d.ts +14 -0
  26. package/src/lib/routes/router.js +68 -0
  27. package/src/lib/routes/router.js.map +1 -0
  28. package/src/lib/routes/types.d.ts +15 -0
  29. package/src/lib/routes/types.js +2 -0
  30. package/src/lib/routes/types.js.map +1 -0
  31. package/src/lib/utils/index.d.ts +7 -0
  32. package/{lib/esm/utils.js → src/lib/utils/index.js} +6 -34
  33. package/src/lib/utils/index.js.map +1 -0
  34. package/lib/cjs/constants.d.ts +0 -15
  35. package/lib/cjs/constants.js +0 -19
  36. package/lib/cjs/constants.js.map +0 -1
  37. package/lib/cjs/core-bot.d.ts +0 -33
  38. package/lib/cjs/core-bot.js +0 -85
  39. package/lib/cjs/core-bot.js.map +0 -1
  40. package/lib/cjs/debug/index.d.ts +0 -1
  41. package/lib/cjs/debug/index.js +0 -9
  42. package/lib/cjs/debug/index.js.map +0 -1
  43. package/lib/cjs/debug/inspector.d.ts +0 -24
  44. package/lib/cjs/debug/inspector.js +0 -72
  45. package/lib/cjs/debug/inspector.js.map +0 -1
  46. package/lib/cjs/errors.d.ts +0 -5
  47. package/lib/cjs/errors.js +0 -11
  48. package/lib/cjs/errors.js.map +0 -1
  49. package/lib/cjs/handoff.d.ts +0 -67
  50. package/lib/cjs/handoff.js +0 -183
  51. package/lib/cjs/handoff.js.map +0 -1
  52. package/lib/cjs/hubtype-service.d.ts +0 -69
  53. package/lib/cjs/hubtype-service.js +0 -190
  54. package/lib/cjs/hubtype-service.js.map +0 -1
  55. package/lib/cjs/i18n.d.ts +0 -2
  56. package/lib/cjs/i18n.js +0 -11
  57. package/lib/cjs/i18n.js.map +0 -1
  58. package/lib/cjs/index.d.ts +0 -166
  59. package/lib/cjs/index.js +0 -58
  60. package/lib/cjs/index.js.map +0 -1
  61. package/lib/cjs/models/events/connections/index.d.ts +0 -9
  62. package/lib/cjs/models/events/connections/index.js +0 -9
  63. package/lib/cjs/models/events/connections/index.js.map +0 -1
  64. package/lib/cjs/models/events/index.d.ts +0 -21
  65. package/lib/cjs/models/events/index.js +0 -11
  66. package/lib/cjs/models/events/index.js.map +0 -1
  67. package/lib/cjs/models/events/message/buttons.d.ts +0 -18
  68. package/lib/cjs/models/events/message/buttons.js +0 -3
  69. package/lib/cjs/models/events/message/buttons.js.map +0 -1
  70. package/lib/cjs/models/events/message/carousel.d.ts +0 -11
  71. package/lib/cjs/models/events/message/carousel.js +0 -3
  72. package/lib/cjs/models/events/message/carousel.js.map +0 -1
  73. package/lib/cjs/models/events/message/custom.d.ts +0 -6
  74. package/lib/cjs/models/events/message/custom.js +0 -3
  75. package/lib/cjs/models/events/message/custom.js.map +0 -1
  76. package/lib/cjs/models/events/message/index.d.ts +0 -30
  77. package/lib/cjs/models/events/message/index.js +0 -32
  78. package/lib/cjs/models/events/message/index.js.map +0 -1
  79. package/lib/cjs/models/events/message/location.d.ts +0 -6
  80. package/lib/cjs/models/events/message/location.js +0 -3
  81. package/lib/cjs/models/events/message/location.js.map +0 -1
  82. package/lib/cjs/models/events/message/media.d.ts +0 -18
  83. package/lib/cjs/models/events/message/media.js +0 -11
  84. package/lib/cjs/models/events/message/media.js.map +0 -1
  85. package/lib/cjs/models/events/message/postback.d.ts +0 -4
  86. package/lib/cjs/models/events/message/postback.js +0 -3
  87. package/lib/cjs/models/events/message/postback.js.map +0 -1
  88. package/lib/cjs/models/events/message/replies.d.ts +0 -7
  89. package/lib/cjs/models/events/message/replies.js +0 -3
  90. package/lib/cjs/models/events/message/replies.js.map +0 -1
  91. package/lib/cjs/models/events/message/text.d.ts +0 -8
  92. package/lib/cjs/models/events/message/text.js +0 -3
  93. package/lib/cjs/models/events/message/text.js.map +0 -1
  94. package/lib/cjs/models/user.d.ts +0 -10
  95. package/lib/cjs/models/user.js +0 -3
  96. package/lib/cjs/models/user.js.map +0 -1
  97. package/lib/cjs/output-parser/factory.d.ts +0 -4
  98. package/lib/cjs/output-parser/factory.js +0 -33
  99. package/lib/cjs/output-parser/factory.js.map +0 -1
  100. package/lib/cjs/output-parser/index.d.ts +0 -16
  101. package/lib/cjs/output-parser/index.js +0 -37
  102. package/lib/cjs/output-parser/index.js.map +0 -1
  103. package/lib/cjs/output-parser/parsers.d.ts +0 -28
  104. package/lib/cjs/output-parser/parsers.js +0 -138
  105. package/lib/cjs/output-parser/parsers.js.map +0 -1
  106. package/lib/cjs/output-parser/util.d.ts +0 -2
  107. package/lib/cjs/output-parser/util.js +0 -14
  108. package/lib/cjs/output-parser/util.js.map +0 -1
  109. package/lib/cjs/plugins.d.ts +0 -7
  110. package/lib/cjs/plugins.js +0 -45
  111. package/lib/cjs/plugins.js.map +0 -1
  112. package/lib/cjs/router.d.ts +0 -35
  113. package/lib/cjs/router.js +0 -262
  114. package/lib/cjs/router.js.map +0 -1
  115. package/lib/cjs/utils.d.ts +0 -10
  116. package/lib/cjs/utils.js +0 -84
  117. package/lib/cjs/utils.js.map +0 -1
  118. package/lib/esm/constants.d.ts +0 -15
  119. package/lib/esm/constants.js +0 -16
  120. package/lib/esm/constants.js.map +0 -1
  121. package/lib/esm/core-bot.d.ts +0 -33
  122. package/lib/esm/core-bot.js +0 -81
  123. package/lib/esm/core-bot.js.map +0 -1
  124. package/lib/esm/debug/index.d.ts +0 -1
  125. package/lib/esm/debug/index.js +0 -2
  126. package/lib/esm/debug/index.js.map +0 -1
  127. package/lib/esm/debug/inspector.d.ts +0 -24
  128. package/lib/esm/debug/inspector.js +0 -65
  129. package/lib/esm/debug/inspector.js.map +0 -1
  130. package/lib/esm/errors.d.ts +0 -5
  131. package/lib/esm/errors.js +0 -7
  132. package/lib/esm/errors.js.map +0 -1
  133. package/lib/esm/handoff.d.ts +0 -67
  134. package/lib/esm/handoff.js +0 -170
  135. package/lib/esm/handoff.js.map +0 -1
  136. package/lib/esm/hubtype-service.d.ts +0 -69
  137. package/lib/esm/hubtype-service.js +0 -185
  138. package/lib/esm/hubtype-service.js.map +0 -1
  139. package/lib/esm/i18n.d.ts +0 -2
  140. package/lib/esm/i18n.js +0 -7
  141. package/lib/esm/i18n.js.map +0 -1
  142. package/lib/esm/index.d.ts +0 -166
  143. package/lib/esm/index.js +0 -49
  144. package/lib/esm/index.js.map +0 -1
  145. package/lib/esm/models/events/connections/index.d.ts +0 -9
  146. package/lib/esm/models/events/connections/index.js +0 -6
  147. package/lib/esm/models/events/connections/index.js.map +0 -1
  148. package/lib/esm/models/events/index.d.ts +0 -21
  149. package/lib/esm/models/events/index.js +0 -8
  150. package/lib/esm/models/events/index.js.map +0 -1
  151. package/lib/esm/models/events/message/buttons.d.ts +0 -18
  152. package/lib/esm/models/events/message/buttons.js +0 -2
  153. package/lib/esm/models/events/message/buttons.js.map +0 -1
  154. package/lib/esm/models/events/message/carousel.d.ts +0 -11
  155. package/lib/esm/models/events/message/carousel.js +0 -2
  156. package/lib/esm/models/events/message/carousel.js.map +0 -1
  157. package/lib/esm/models/events/message/custom.d.ts +0 -6
  158. package/lib/esm/models/events/message/custom.js +0 -2
  159. package/lib/esm/models/events/message/custom.js.map +0 -1
  160. package/lib/esm/models/events/message/index.d.ts +0 -30
  161. package/lib/esm/models/events/message/index.js +0 -29
  162. package/lib/esm/models/events/message/index.js.map +0 -1
  163. package/lib/esm/models/events/message/location.d.ts +0 -6
  164. package/lib/esm/models/events/message/location.js +0 -2
  165. package/lib/esm/models/events/message/location.js.map +0 -1
  166. package/lib/esm/models/events/message/media.d.ts +0 -18
  167. package/lib/esm/models/events/message/media.js +0 -8
  168. package/lib/esm/models/events/message/media.js.map +0 -1
  169. package/lib/esm/models/events/message/postback.d.ts +0 -4
  170. package/lib/esm/models/events/message/postback.js +0 -2
  171. package/lib/esm/models/events/message/postback.js.map +0 -1
  172. package/lib/esm/models/events/message/replies.d.ts +0 -7
  173. package/lib/esm/models/events/message/replies.js +0 -2
  174. package/lib/esm/models/events/message/replies.js.map +0 -1
  175. package/lib/esm/models/events/message/text.d.ts +0 -8
  176. package/lib/esm/models/events/message/text.js +0 -2
  177. package/lib/esm/models/events/message/text.js.map +0 -1
  178. package/lib/esm/models/user.d.ts +0 -10
  179. package/lib/esm/models/user.js +0 -2
  180. package/lib/esm/models/user.js.map +0 -1
  181. package/lib/esm/output-parser/factory.d.ts +0 -4
  182. package/lib/esm/output-parser/factory.js +0 -29
  183. package/lib/esm/output-parser/factory.js.map +0 -1
  184. package/lib/esm/output-parser/index.d.ts +0 -16
  185. package/lib/esm/output-parser/index.js +0 -33
  186. package/lib/esm/output-parser/index.js.map +0 -1
  187. package/lib/esm/output-parser/parsers.d.ts +0 -28
  188. package/lib/esm/output-parser/parsers.js +0 -123
  189. package/lib/esm/output-parser/parsers.js.map +0 -1
  190. package/lib/esm/output-parser/util.d.ts +0 -2
  191. package/lib/esm/output-parser/util.js +0 -9
  192. package/lib/esm/output-parser/util.js.map +0 -1
  193. package/lib/esm/plugins.d.ts +0 -7
  194. package/lib/esm/plugins.js +0 -40
  195. package/lib/esm/plugins.js.map +0 -1
  196. package/lib/esm/router.d.ts +0 -35
  197. package/lib/esm/router.js +0 -258
  198. package/lib/esm/router.js.map +0 -1
  199. package/lib/esm/utils.d.ts +0 -10
  200. package/lib/esm/utils.js.map +0 -1
  201. package/src/constants.ts +0 -15
  202. package/src/core-bot.ts +0 -144
  203. package/src/debug/index.ts +0 -6
  204. package/src/debug/inspector.ts +0 -102
  205. package/src/errors.ts +0 -11
  206. package/src/handoff.ts +0 -268
  207. package/src/hubtype-service.ts +0 -266
  208. package/src/i18n.ts +0 -12
  209. package/src/index.ts +0 -233
  210. package/src/models/events/connections/index.ts +0 -11
  211. package/src/models/events/index.ts +0 -39
  212. package/src/models/events/message/buttons.ts +0 -23
  213. package/src/models/events/message/carousel.ts +0 -13
  214. package/src/models/events/message/custom.ts +0 -7
  215. package/src/models/events/message/index.ts +0 -37
  216. package/src/models/events/message/location.ts +0 -7
  217. package/src/models/events/message/media.ts +0 -28
  218. package/src/models/events/message/postback.ts +0 -5
  219. package/src/models/events/message/replies.ts +0 -8
  220. package/src/models/events/message/text.ts +0 -12
  221. package/src/models/user.ts +0 -10
  222. package/src/output-parser/factory.ts +0 -40
  223. package/src/output-parser/index.ts +0 -38
  224. package/src/output-parser/parsers.ts +0 -190
  225. package/src/output-parser/util.ts +0 -8
  226. package/src/plugins.ts +0 -49
  227. package/src/router.ts +0 -316
  228. package/src/utils.ts +0 -84
@@ -0,0 +1,8 @@
1
+ import { BotonicButtonContent } from '@botonic/shared';
2
+ export declare class Button {
3
+ text: string;
4
+ payload?: string;
5
+ url?: string;
6
+ webview?: string;
7
+ constructor({ title, payload, url, webview }: BotonicButtonContent);
8
+ }
@@ -0,0 +1,10 @@
1
+ export class Button {
2
+ constructor({ title, payload, url, webview }) {
3
+ // this.messageId = messageId
4
+ this.text = title;
5
+ this.payload = payload;
6
+ this.url = url;
7
+ this.webview = webview;
8
+ }
9
+ }
10
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/messages/button.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAM;IAOjB,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAwB;QAChE,6BAA6B;QAC7B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAA;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ import { RunPluginArgs } from '@botonic/shared';
2
+ export declare function runPlugins({ botContext, mode, response, }: RunPluginArgs): Promise<void>;
@@ -0,0 +1,23 @@
1
+ import { __awaiter } from "tslib";
2
+ import { PluginMode } from '@botonic/shared';
3
+ export function runPlugins(_a) {
4
+ return __awaiter(this, arguments, void 0, function* ({ botContext, mode, response = { status: 200, response: 'OK' }, }) {
5
+ const plugins = botContext.plugins;
6
+ for (const key in plugins) {
7
+ const plugin = plugins[key];
8
+ try {
9
+ if (mode === PluginMode.PRE && typeof plugin.pre === 'function') {
10
+ yield plugin.pre(botContext);
11
+ }
12
+ if (mode === PluginMode.POST && typeof plugin.post === 'function') {
13
+ botContext.response = response;
14
+ yield plugin.post(botContext);
15
+ }
16
+ }
17
+ catch (e) {
18
+ console.log(e);
19
+ }
20
+ }
21
+ });
22
+ }
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/plugins/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,UAAU,EAAiB,MAAM,iBAAiB,CAAA;AAEnE,MAAM,UAAgB,UAAU;yDAAC,EAC/B,UAAU,EACV,IAAI,EACJ,QAAQ,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GAC5B;QACd,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;QAClC,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAW,OAAO,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,CAAC;gBACH,IAAI,IAAI,KAAK,UAAU,CAAC,GAAG,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;oBAChE,MAAM,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;gBAC9B,CAAC;gBACD,IAAI,IAAI,KAAK,UAAU,CAAC,IAAI,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;oBAClE,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAA;oBAC9B,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBAC/B,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YAChB,CAAC;QACH,CAAC;IACH,CAAC;CAAA"}
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/routes/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { BotContext } from '@botonic/shared';
2
+ import { Route } from './types';
3
+ export declare const NOT_FOUND_PATH = "404";
4
+ export declare class NoMatchingRouteError extends Error {
5
+ botContext: BotContext;
6
+ constructor(botContext: BotContext);
7
+ }
8
+ export declare class Router {
9
+ private routes;
10
+ constructor(routes: Route[]);
11
+ processInput(botContext: BotContext): Route;
12
+ private routeMatches;
13
+ private matchesStringValue;
14
+ }
@@ -0,0 +1,68 @@
1
+ export const NOT_FOUND_PATH = '404';
2
+ export class NoMatchingRouteError extends Error {
3
+ constructor(botContext) {
4
+ super(`No route found for input '${JSON.stringify(botContext.input)}' and no ${NOT_FOUND_PATH} route defined`);
5
+ this.botContext = botContext;
6
+ }
7
+ }
8
+ export class Router {
9
+ constructor(routes) {
10
+ this.routes = routes;
11
+ }
12
+ processInput(botContext) {
13
+ for (const route of this.routes) {
14
+ if (this.routeMatches(route, botContext)) {
15
+ return route;
16
+ }
17
+ }
18
+ throw new NoMatchingRouteError(botContext);
19
+ }
20
+ routeMatches(route, botContext) {
21
+ var _a, _b, _c;
22
+ const hasMatchers = !!(route.text ||
23
+ route.payload ||
24
+ route.type ||
25
+ route.input ||
26
+ route.session ||
27
+ route.context);
28
+ if (!hasMatchers) {
29
+ return route.path === NOT_FOUND_PATH;
30
+ }
31
+ const textValue = botContext.input.text;
32
+ const payloadValue = botContext.input.payload;
33
+ const typeValue = botContext.input.type;
34
+ const stringMatcherChecks = [
35
+ { matcher: route.text, value: textValue },
36
+ { matcher: route.payload, value: payloadValue },
37
+ { matcher: route.type, value: typeValue },
38
+ ];
39
+ for (const { matcher, value } of stringMatcherChecks) {
40
+ if (matcher && value && this.matchesStringValue(matcher, value)) {
41
+ return true;
42
+ }
43
+ }
44
+ if ((_a = route.input) === null || _a === void 0 ? void 0 : _a.call(route, botContext.input)) {
45
+ return true;
46
+ }
47
+ if ((_b = route.session) === null || _b === void 0 ? void 0 : _b.call(route, botContext.session)) {
48
+ return true;
49
+ }
50
+ if ((_c = route.context) === null || _c === void 0 ? void 0 : _c.call(route, botContext)) {
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+ matchesStringValue(matcher, value) {
56
+ if (typeof matcher === 'string') {
57
+ return matcher === value;
58
+ }
59
+ else if (matcher instanceof RegExp) {
60
+ return matcher.test(value);
61
+ }
62
+ else if (typeof matcher === 'function') {
63
+ return matcher(value);
64
+ }
65
+ return false;
66
+ }
67
+ }
68
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/routes/router.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AAEnC,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,UAAsB;QAChC,KAAK,CACH,6BAA6B,IAAI,CAAC,SAAS,CACzC,UAAU,CAAC,KAAK,CACjB,YAAY,cAAc,gBAAgB,CAC5C,CAAA;QACD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,MAAM;IACjB,YAAoB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAEvC,YAAY,CAAC,UAAsB;QACjC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;gBACzC,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QAED,MAAM,IAAI,oBAAoB,CAAC,UAAU,CAAC,CAAA;IAC5C,CAAC;IAEO,YAAY,CAAC,KAAY,EAAE,UAAsB;;QACvD,MAAM,WAAW,GAAG,CAAC,CAAC,CACpB,KAAK,CAAC,IAAI;YACV,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,IAAI;YACV,KAAK,CAAC,KAAK;YACX,KAAK,CAAC,OAAO;YACb,KAAK,CAAC,OAAO,CACd,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC,IAAI,KAAK,cAAc,CAAA;QACtC,CAAC;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAA;QACvC,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAA;QAC7C,MAAM,SAAS,GAAG,UAAU,CAAC,KA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AA;IACd,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { Action, BotContext, BotonicContextInput, BotonicContextSession } from '@botonic/shared';
2
+ export interface Route {
3
+ action?: Action;
4
+ path?: string;
5
+ text?: StringMatcher;
6
+ payload?: StringMatcher;
7
+ type?: StringMatcher;
8
+ input?: InputMatcher;
9
+ session?: SessionMatcher;
10
+ context?: ContextMatcher;
11
+ }
12
+ export type StringMatcher = RegExp | string | ((data: string) => boolean);
13
+ export type InputMatcher = (input: BotonicContextInput) => boolean | Promise<boolean>;
14
+ export type SessionMatcher = (session: BotonicContextSession) => boolean | Promise<boolean>;
15
+ export type ContextMatcher = (botContext: BotContext) => boolean | Promise<boolean>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/routes/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export declare function isFunction(o: any): boolean;
2
+ export declare function cloneObject(object: any): any;
3
+ export declare const params2queryString: (params: {
4
+ [key: string]: string;
5
+ }) => string;
6
+ export declare const join: (...segments: string[]) => string;
7
+ export declare const dirname: (path: string) => string;
@@ -1,38 +1,11 @@
1
- export const isNode = () => {
2
- // @ts-ignore
3
- return typeof IS_NODE !== 'undefined'
4
- ? // @ts-ignore
5
- IS_NODE
6
- : typeof process !== 'undefined' &&
7
- process.versions !== null &&
8
- process.versions.node !== null;
9
- };
10
- export const isBrowser = () => {
11
- // @ts-ignore
12
- return typeof IS_BROWSER !== 'undefined'
13
- ? // @ts-ignore
14
- IS_BROWSER
15
- : typeof window !== 'undefined' &&
16
- typeof window.document !== 'undefined' &&
17
- !window.process;
18
- };
19
- export function getWebpackEnvVar(webpackEnvVar, name, defaultValue) {
20
- return (webpackEnvVar ||
21
- (typeof process !== 'undefined' && process.env[name]) ||
22
- defaultValue);
23
- }
24
- export const isMobile = (mobileBreakpoint = 460) => {
25
- if (isBrowser()) {
26
- const w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
27
- if (w < mobileBreakpoint) {
28
- return true;
29
- }
30
- }
31
- return false;
32
- };
33
1
  export function isFunction(o) {
34
2
  return typeof o === 'function';
35
3
  }
4
+ export function cloneObject(object) {
5
+ if (!object)
6
+ return {};
7
+ return Object.assign({}, object);
8
+ }
36
9
  export const params2queryString = (params) => Object.entries(params)
37
10
  .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
38
11
  .join('&');
@@ -61,7 +34,6 @@ export const join = (...segments) => {
61
34
  newParts.push(part);
62
35
  }
63
36
  // Preserve the initial slash if there was one.
64
- // @ts-ignore
65
37
  if (parts[0] === '')
66
38
  newParts.unshift('');
67
39
  // Turn back into a single string path.
@@ -70,4 +42,4 @@ export const join = (...segments) => {
70
42
  // A simple function to get the dirname of a path
71
43
  // Trailing slashes are ignored. Leading slash is preserved.
72
44
  export const dirname = (path) => join(path, '..');
73
- //# sourceMappingURL=utils.js.map
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,CAAM;IAC/B,OAAO,OAAO,CAAC,KAAK,UAAU,CAAA;AAChC,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAAW;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,yBAAY,MAAM,EAAE;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAiC,EAAU,EAAE,CAC9E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;KACnB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC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iD;AACjD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA"}
@@ -1,15 +0,0 @@
1
- export declare const Providers: Readonly<{
2
- Messaging: {
3
- FACEBOOK: string;
4
- GENERIC: string;
5
- IMBEE: string;
6
- INTERCOM: string;
7
- SMOOCH_WEB: string;
8
- SMOOCH: string;
9
- TELEGRAM: string;
10
- TWITTER: string;
11
- WEBCHAT: string;
12
- WECHAT: string;
13
- WHATSAPP: string;
14
- };
15
- }>;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Providers = void 0;
4
- exports.Providers = Object.freeze({
5
- Messaging: {
6
- FACEBOOK: 'facebook',
7
- GENERIC: 'generic',
8
- IMBEE: 'imbee',
9
- INTERCOM: 'intercom',
10
- SMOOCH_WEB: 'smooch_web',
11
- SMOOCH: 'smooch',
12
- TELEGRAM: 'telegram',
13
- TWITTER: 'twitter',
14
- WEBCHAT: 'webchat',
15
- WECHAT: 'wechat',
16
- WHATSAPP: 'whatsapp',
17
- },
18
- });
19
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;QACpB,OAAO,EAAE,SAAS;QAClB,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAA"}
@@ -1,33 +0,0 @@
1
- import { Inspector } from './debug/inspector';
2
- import { BotRequest, BotResponse, Locales, Routes, Session } from './index';
3
- interface CoreBotConfig {
4
- appId?: string;
5
- defaultDelay?: number;
6
- defaultRoutes?: Routes;
7
- defaultTyping?: number;
8
- inspector?: Inspector;
9
- locales: Locales;
10
- plugins?: any;
11
- renderer: any;
12
- routes: Routes;
13
- theme?: any;
14
- }
15
- export declare class CoreBot {
16
- appId?: string;
17
- defaultDelay?: number;
18
- defaultRoutes?: Routes;
19
- defaultTyping?: number;
20
- inspector?: Inspector;
21
- locales: Locales;
22
- plugins?: Record<string, Plugin>;
23
- renderer: any;
24
- rootElement: any;
25
- router: any;
26
- routes: Routes;
27
- theme?: any;
28
- constructor({ renderer, routes, locales, theme, plugins, appId, defaultTyping, defaultDelay, defaultRoutes, inspector, }: CoreBotConfig);
29
- getString(id: string, session: Session): string;
30
- setLocale(locale: string, session: Session): void;
31
- input({ input, session, lastRoutePath, }: BotRequest): Promise<BotResponse>;
32
- }
33
- export {};
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoreBot = void 0;
4
- const inspector_1 = require("./debug/inspector");
5
- const i18n_1 = require("./i18n");
6
- const output_parser_1 = require("./output-parser");
7
- const plugins_1 = require("./plugins");
8
- const router_1 = require("./router");
9
- const utils_1 = require("./utils");
10
- class CoreBot {
11
- constructor({ renderer, routes, locales, theme, plugins, appId, defaultTyping, defaultDelay, defaultRoutes, inspector, }) {
12
- this.renderer = renderer;
13
- this.plugins = plugins_1.loadPlugins(plugins);
14
- this.theme = theme || {};
15
- this.defaultTyping =
16
- typeof defaultTyping !== 'undefined' ? defaultTyping : 0.6;
17
- this.defaultDelay = typeof defaultDelay !== 'undefined' ? defaultDelay : 0.4;
18
- this.locales = locales;
19
- if (appId) {
20
- this.appId = appId;
21
- return;
22
- }
23
- this.rootElement = null;
24
- this.inspector = inspector || new inspector_1.Inspector();
25
- this.routes = routes;
26
- this.defaultRoutes = defaultRoutes || [];
27
- this.router = utils_1.isFunction(this.routes)
28
- ? null
29
- : new router_1.Router(
30
- // @ts-ignore
31
- [...this.routes, ...this.defaultRoutes], this.inspector.routeInspector);
32
- }
33
- getString(id, session) {
34
- // @ts-ignore
35
- return i18n_1.getString(this.locales, session.__locale, id);
36
- }
37
- setLocale(locale, session) {
38
- session.__locale = locale;
39
- }
40
- async input({ input, session, lastRoutePath, }) {
41
- session = session || {};
42
- if (!session.__locale)
43
- session.__locale = 'en';
44
- if (this.plugins) {
45
- await plugins_1.runPlugins(this.plugins, 'pre', input, session, lastRoutePath);
46
- }
47
- if (utils_1.isFunction(this.routes)) {
48
- this.router = new router_1.Router([
49
- // @ts-ignore
50
- ...(await this.routes({ input, session, lastRoutePath })),
51
- // @ts-ignore
52
- ...this.defaultRoutes,
53
- ],
54
- // @ts-ignore
55
- this.inspector.routeInspector);
56
- }
57
- const output = this.router.processInput(input, session, lastRoutePath);
58
- const request = {
59
- getString: stringId => this.getString(stringId, session),
60
- setLocale: locale => this.setLocale(locale, session),
61
- session: session || {},
62
- params: output.params || {},
63
- input: input,
64
- plugins: this.plugins,
65
- defaultTyping: this.defaultTyping,
66
- defaultDelay: this.defaultDelay,
67
- lastRoutePath,
68
- };
69
- const actions = [output.action, output.retryAction, output.defaultAction];
70
- const response = await this.renderer({ request, actions });
71
- let parsedResponse = null;
72
- try {
73
- parsedResponse = new output_parser_1.BotonicOutputParser().xmlToMessageEvents(response);
74
- }
75
- catch (e) { }
76
- lastRoutePath = output.lastRoutePath;
77
- if (this.plugins) {
78
- await plugins_1.runPlugins(this.plugins, 'post', input, session, lastRoutePath, response, parsedResponse);
79
- }
80
- session.is_first_interaction = false;
81
- return { input, response, parsedResponse, session, lastRoutePath };
82
- }
83
- }
84
- exports.CoreBot = CoreBot;
85
- //# sourceMappingURL=core-bot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-bot.js","sourceRoot":"","sources":["../../src/core-bot.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;A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AM,CAAC,MAAM,IAAI,EAAE;YAC3B,KAAK,EAAE,KAAK;YACZ,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,aAAa;SACd,CAAA;QAED,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC,CAAA;QAEzE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;QAC1D,IAAI,cAAc,GAAmC,IAAI,CAAA;QACzD,IAAI;YACF,cAAc,GAAG,IAAI,mCAAmB,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;SACxE;QAAC,OAAO,CAAC,EAAE,GAAE;QAEd,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACpC,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,oBAAU,CACd,IAAI,CAAC,OAAO,EACZ,MAAM,EACN,KAAK,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EACR,cAAc,CACf,CAAA;SACF;QAED,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAA;QACpC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;IACpE,CAAC;CACF;AA1HD,0BA0HC"}
@@ -1 +0,0 @@
1
- export { FocusRouteInspector, Inspector, LogRouteInspector, RouteInspector, } from './inspector';
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RouteInspector = exports.LogRouteInspector = exports.Inspector = exports.FocusRouteInspector = void 0;
4
- var inspector_1 = require("./inspector");
5
- Object.defineProperty(exports, "FocusRouteInspector", { enumerable: true, get: function () { return inspector_1.FocusRouteInspector; } });
6
- Object.defineProperty(exports, "Inspector", { enumerable: true, get: function () { return inspector_1.Inspector; } });
7
- Object.defineProperty(exports, "LogRouteInspector", { enumerable: true, get: function () { return inspector_1.LogRouteInspector; } });
8
- Object.defineProperty(exports, "RouteInspector", { enumerable: true, get: function () { return inspector_1.RouteInspector; } });
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/debug/index.ts"],"names":[],"mappings":";;;AAAA,yCAKoB;AAJlB,gHAAA,mBAAmB,OAAA;AACnB,sGAAA,SAAS,OAAA;AACT,8GAAA,iBAAiB,OAAA;AACjB,2GAAA,cAAc,OAAA"}
@@ -1,24 +0,0 @@
1
- import { Route, RouteMatcher } from '../index';
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
- }
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Inspector = exports.LogRouteInspector = exports.FocusRouteInspector = exports.RouteInspector = void 0;
4
- class RouteInspector {
5
- routeMatched(_route, _routeKey, _routeValue, _input) { }
6
- routeNotMatched(_route, _routeKey, _routeValue, _input) { }
7
- }
8
- exports.RouteInspector = RouteInspector;
9
- class FocusRouteInspector extends RouteInspector {
10
- constructor() {
11
- super();
12
- this.focusRoutePaths = null;
13
- this.focusOnMatches = false;
14
- }
15
- focusOnlyOnRoutes(focusRoutePaths) {
16
- this.focusRoutePaths = focusRoutePaths;
17
- return this;
18
- }
19
- focusOnlyOnMatches() {
20
- this.focusOnMatches = true;
21
- return this;
22
- }
23
- _isOnFocus(route) {
24
- if (this.focusRoutePaths === null) {
25
- return true;
26
- }
27
- // @ts-ignore
28
- return this.focusRoutePaths.includes(route.path);
29
- }
30
- }
31
- exports.FocusRouteInspector = FocusRouteInspector;
32
- class LogRouteInspector extends FocusRouteInspector {
33
- routeMatched(route, routeKey, routeValue, inputValue) {
34
- if (!this._isOnFocus(route)) {
35
- return;
36
- }
37
- this._log(`Route ${this._routeName(route)} selected ` +
38
- `because Input.${routeKey} (${inputValue}) matched '${routeValue}'`);
39
- }
40
- // @ts-ignore
41
- routeNotMatched(route, routeKey, routeValue, inputValue) {
42
- if (!this._isOnFocus(route) || this.focusOnMatches) {
43
- return;
44
- }
45
- this._log(`Route ${this._routeName(route)} not selected ` +
46
- `because Input.${routeKey} (${inputValue}) did not match '${routeValue}'`);
47
- }
48
- _routeName(obj) {
49
- let name = obj.path || '<<no path defined>>';
50
- if (obj.action) {
51
- name = `'${name}' (to action '${obj.action.name}')`;
52
- }
53
- if (obj.redirect) {
54
- name = `'${name}' (with redirect to '${obj.redirect}')`;
55
- }
56
- return name;
57
- }
58
- _log(message, ...optionalParams) {
59
- console.log(message, ...optionalParams);
60
- }
61
- }
62
- exports.LogRouteInspector = LogRouteInspector;
63
- class Inspector {
64
- constructor(routeInspector = undefined) {
65
- this.routeInspector = routeInspector || new RouteInspector();
66
- }
67
- getRouteInspector() {
68
- return this.routeInspector;
69
- }
70
- }
71
- exports.Inspector = Inspector;
72
- //# sourceMappingURL=inspector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../../src/debug/inspector.ts"],"names":[],"mappings":";;;AACA,MAAa,cAAc;IACzB,YAAY,CACV,MAAa,EACb,SAAiB,EACjB,WAAyB,EACzB,MAAW,IACJ,CAAC;IACV,eAAe,CACb,MAAa,EACb,SAAiB,EACjB,WAAyB,EACzB,MAAW,IACJ,CAAC;CACX;AAbD,wCAaC;AAED,MAAa,mBAAoB,SAAQ,cAAc;IAGrD;QACE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC3B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAA;IAC7B,CAAC;IAED,iBAAiB,CAAC,eAAyB;QACzC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,KAAY;QACrB,IAAI,IAAI,CAAC,eAAe,KAAK,IAAI,EAAE;YACjC,OAAO,IAAI,CAAA;SACZ;QACD,aAAa;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAClD,CAAC;CACF;AA1BD,kDA0BC;AAED,MAAa,iBAAkB,SAAQ,mBAAmB;IACxD,YAAY,CACV,KAAY,EACZ,QAAgB,EAChB,UAAwB,EACxB,UAAkB;QAElB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAM;SACP;QACD,IAAI,CAAC,IAAI,CACP,SAAS,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY;YACzC,iBAAiB,QAAQ,KAAK,UAAU,cAAc,UAAU,GAAG,CACtE,CAAA;IACH,CAAC;IAED,aAAa;IACb,eAAe,CACb,KAAY,EACZ,QAAgB,EAChB,UAAwB,EACxB,UAAkB;QAElB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YAClD,OAAM;SACP;QACD,IAAI,CAAC,IAAI,CACP,SAAS,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,gBAAgB;YAC7C,iBAAiB,QAAQ,KAAK,UAAU,oBAAoB,UAAU,GAAG,CAC5E,CAAA;IACH,CAAC;IAED,UAAU,CAAC,GAAU;QACnB,IAAI,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,qBAAqB,CAAA;QAC5C,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,IAAI,GAAG,IAAI,IAAI,iBAAiB,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAA;SACpD;QACD,IAAI,GAAG,CAAC,QAAQ,EAAE;YAChB,IAAI,GAAG,IAAI,IAAI,wBAAwB,GAAG,CAAC,QAAQ,IAAI,CAAA;SACxD;QACD,OAAO,IAAc,CAAA;IACvB,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,cAAwB;QAC/C,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,CAAA;IACzC,CAAC;CACF;AA9CD,8CA8CC;AAED,MAAa,SAAS;IAEpB,YAAY,iBAA6C,SAAS;QAChE,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,cAAc,EAAE,CAAA;IAC9D,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;CACF;AATD,8BASC"}
@@ -1,5 +0,0 @@
1
- import { Input } from './index';
2
- export declare class NoMatchingRouteError extends Error {
3
- input: Input;
4
- constructor(input: Input);
5
- }
package/lib/cjs/errors.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoMatchingRouteError = void 0;
4
- class NoMatchingRouteError extends Error {
5
- constructor(input) {
6
- super(`No route found for input '${String(input)}' and no 404 route defined`);
7
- this.input = input;
8
- }
9
- }
10
- exports.NoMatchingRouteError = NoMatchingRouteError;
11
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,oBAAqB,SAAQ,KAAK;IAE7C,YAAY,KAAY;QACtB,KAAK,CACH,6BAA6B,MAAM,CAAC,KAAK,CAAC,4BAA4B,CACvE,CAAA;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AARD,oDAQC"}
@@ -1,67 +0,0 @@
1
- import { Session } from './index';
2
- export interface HubtypeAgentsInfo {
3
- attending_count: number;
4
- email: string;
5
- idle_count: number;
6
- last_message_sent: string;
7
- status: string;
8
- }
9
- export interface HubtypeSession extends Session {
10
- _hubtype_api?: string;
11
- _access_token: string;
12
- }
13
- export interface SessionWithBotonicAction extends Session {
14
- _botonic_action: string;
15
- }
16
- export interface BackendContext {
17
- timeoutMs: number;
18
- }
19
- export interface VacationRange {
20
- end_date: number;
21
- id: number;
22
- start_date: number;
23
- }
24
- export declare function getOpenQueues(session: HubtypeSession, context?: {}): Promise<{
25
- queues: string[];
26
- }>;
27
- export declare class HandOffBuilder {
28
- _session: SessionWithBotonicAction;
29
- _queue: string;
30
- _onFinish: string;
31
- _email: string;
32
- _agentId: string;
33
- _note: string;
34
- _caseInfo: string;
35
- _shadowing: boolean;
36
- constructor(session: SessionWithBotonicAction);
37
- withQueue(queueNameOrId: string): this;
38
- withOnFinishPayload(payload: string): this;
39
- withOnFinishPath(path: string): this;
40
- withAgentEmail(email: string): this;
41
- withAgentId(agentId: string): this;
42
- withNote(note: string): this;
43
- withCaseInfo(caseInfo: string): this;
44
- withShadowing(shadowing?: boolean): this;
45
- handOff(): Promise<void>;
46
- }
47
- /**
48
- * @deprecated use {@link HandOffBuilder} class instead
49
- */
50
- export declare function humanHandOff(session: any, queueNameOrId: string | undefined, onFinish: any): Promise<void>;
51
- export declare function storeCaseRating(session: HubtypeSession, rating: number, context?: any): Promise<{
52
- status: string;
53
- }>;
54
- export declare function getAvailableAgentsByQueue(session: HubtypeSession, queueId: string): Promise<{
55
- agents: string[];
56
- }>;
57
- export declare function getAvailableAgents(session: HubtypeSession): Promise<{
58
- agents: HubtypeAgentsInfo[];
59
- }>;
60
- export declare function getAgentVacationRanges(session: HubtypeSession, { agentId, agentEmail }: {
61
- agentId?: string;
62
- agentEmail?: string;
63
- }): Promise<{
64
- vacation_ranges: VacationRange[];
65
- }>;
66
- export declare function cancelHandoff(session: SessionWithBotonicAction, typification?: string | null): void;
67
- export declare function deleteUser(session: SessionWithBotonicAction): void;