@botonic/core 1.0.0-dev.2 → 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 (311) 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/{lib/cjs/utils.d.ts → src/lib/utils/index.d.ts} +0 -4
  32. package/{lib/esm/utils.js → src/lib/utils/index.js} +1 -34
  33. package/src/lib/utils/index.js.map +1 -0
  34. package/lib/cjs/constants.d.ts +0 -4
  35. package/lib/cjs/constants.js +0 -8
  36. package/lib/cjs/constants.js.map +0 -1
  37. package/lib/cjs/core-bot.d.ts +0 -36
  38. package/lib/cjs/core-bot.js +0 -96
  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 -5
  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/handoff.d.ts +0 -67
  47. package/lib/cjs/handoff.js +0 -186
  48. package/lib/cjs/handoff.js.map +0 -1
  49. package/lib/cjs/hubtype-service.d.ts +0 -69
  50. package/lib/cjs/hubtype-service.js +0 -190
  51. package/lib/cjs/hubtype-service.js.map +0 -1
  52. package/lib/cjs/i18n.d.ts +0 -2
  53. package/lib/cjs/i18n.js +0 -11
  54. package/lib/cjs/i18n.js.map +0 -1
  55. package/lib/cjs/index.d.ts +0 -11
  56. package/lib/cjs/index.js +0 -15
  57. package/lib/cjs/index.js.map +0 -1
  58. package/lib/cjs/models/bot-state.d.ts +0 -11
  59. package/lib/cjs/models/bot-state.js +0 -3
  60. package/lib/cjs/models/bot-state.js.map +0 -1
  61. package/lib/cjs/models/channels.d.ts +0 -9
  62. package/lib/cjs/models/channels.js +0 -14
  63. package/lib/cjs/models/channels.js.map +0 -1
  64. package/lib/cjs/models/events/base-event.d.ts +0 -20
  65. package/lib/cjs/models/events/base-event.js +0 -17
  66. package/lib/cjs/models/events/base-event.js.map +0 -1
  67. package/lib/cjs/models/events/botonic-event.d.ts +0 -4
  68. package/lib/cjs/models/events/botonic-event.js +0 -3
  69. package/lib/cjs/models/events/botonic-event.js.map +0 -1
  70. package/lib/cjs/models/events/connection/connection-event.d.ts +0 -9
  71. package/lib/cjs/models/events/connection/connection-event.js +0 -9
  72. package/lib/cjs/models/events/connection/connection-event.js.map +0 -1
  73. package/lib/cjs/models/events/connection/index.d.ts +0 -1
  74. package/lib/cjs/models/events/connection/index.js +0 -5
  75. package/lib/cjs/models/events/connection/index.js.map +0 -1
  76. package/lib/cjs/models/events/index.d.ts +0 -4
  77. package/lib/cjs/models/events/index.js +0 -8
  78. package/lib/cjs/models/events/index.js.map +0 -1
  79. package/lib/cjs/models/events/integration/index.d.ts +0 -1
  80. package/lib/cjs/models/events/integration/index.js +0 -5
  81. package/lib/cjs/models/events/integration/index.js.map +0 -1
  82. package/lib/cjs/models/events/integration/integration-event.d.ts +0 -6
  83. package/lib/cjs/models/events/integration/integration-event.js +0 -3
  84. package/lib/cjs/models/events/integration/integration-event.js.map +0 -1
  85. package/lib/cjs/models/events/message/buttons.d.ts +0 -18
  86. package/lib/cjs/models/events/message/buttons.js +0 -3
  87. package/lib/cjs/models/events/message/buttons.js.map +0 -1
  88. package/lib/cjs/models/events/message/carousel.d.ts +0 -11
  89. package/lib/cjs/models/events/message/carousel.js +0 -3
  90. package/lib/cjs/models/events/message/carousel.js.map +0 -1
  91. package/lib/cjs/models/events/message/custom.d.ts +0 -6
  92. package/lib/cjs/models/events/message/custom.js +0 -3
  93. package/lib/cjs/models/events/message/custom.js.map +0 -1
  94. package/lib/cjs/models/events/message/index.d.ts +0 -9
  95. package/lib/cjs/models/events/message/index.js +0 -13
  96. package/lib/cjs/models/events/message/index.js.map +0 -1
  97. package/lib/cjs/models/events/message/location.d.ts +0 -6
  98. package/lib/cjs/models/events/message/location.js +0 -3
  99. package/lib/cjs/models/events/message/location.js.map +0 -1
  100. package/lib/cjs/models/events/message/media.d.ts +0 -18
  101. package/lib/cjs/models/events/message/media.js +0 -11
  102. package/lib/cjs/models/events/message/media.js.map +0 -1
  103. package/lib/cjs/models/events/message/message-event.d.ts +0 -30
  104. package/lib/cjs/models/events/message/message-event.js +0 -32
  105. package/lib/cjs/models/events/message/message-event.js.map +0 -1
  106. package/lib/cjs/models/events/message/postback.d.ts +0 -4
  107. package/lib/cjs/models/events/message/postback.js +0 -3
  108. package/lib/cjs/models/events/message/postback.js.map +0 -1
  109. package/lib/cjs/models/events/message/replies.d.ts +0 -7
  110. package/lib/cjs/models/events/message/replies.js +0 -3
  111. package/lib/cjs/models/events/message/replies.js.map +0 -1
  112. package/lib/cjs/models/events/message/text.d.ts +0 -8
  113. package/lib/cjs/models/events/message/text.js +0 -3
  114. package/lib/cjs/models/events/message/text.js.map +0 -1
  115. package/lib/cjs/models/index.d.ts +0 -6
  116. package/lib/cjs/models/index.js +0 -10
  117. package/lib/cjs/models/index.js.map +0 -1
  118. package/lib/cjs/models/legacy-types.d.ts +0 -184
  119. package/lib/cjs/models/legacy-types.js +0 -59
  120. package/lib/cjs/models/legacy-types.js.map +0 -1
  121. package/lib/cjs/models/session.d.ts +0 -3
  122. package/lib/cjs/models/session.js +0 -3
  123. package/lib/cjs/models/session.js.map +0 -1
  124. package/lib/cjs/models/user.d.ts +0 -14
  125. package/lib/cjs/models/user.js +0 -3
  126. package/lib/cjs/models/user.js.map +0 -1
  127. package/lib/cjs/output-parser/botonic-output-parser.d.ts +0 -16
  128. package/lib/cjs/output-parser/botonic-output-parser.js +0 -37
  129. package/lib/cjs/output-parser/botonic-output-parser.js.map +0 -1
  130. package/lib/cjs/output-parser/factory.d.ts +0 -4
  131. package/lib/cjs/output-parser/factory.js +0 -32
  132. package/lib/cjs/output-parser/factory.js.map +0 -1
  133. package/lib/cjs/output-parser/index.d.ts +0 -3
  134. package/lib/cjs/output-parser/index.js +0 -7
  135. package/lib/cjs/output-parser/index.js.map +0 -1
  136. package/lib/cjs/output-parser/parsers.d.ts +0 -22
  137. package/lib/cjs/output-parser/parsers.js +0 -147
  138. package/lib/cjs/output-parser/parsers.js.map +0 -1
  139. package/lib/cjs/plugins.d.ts +0 -6
  140. package/lib/cjs/plugins.js +0 -48
  141. package/lib/cjs/plugins.js.map +0 -1
  142. package/lib/cjs/routing/index.d.ts +0 -2
  143. package/lib/cjs/routing/index.js +0 -6
  144. package/lib/cjs/routing/index.js.map +0 -1
  145. package/lib/cjs/routing/router-utils.d.ts +0 -11
  146. package/lib/cjs/routing/router-utils.js +0 -89
  147. package/lib/cjs/routing/router-utils.js.map +0 -1
  148. package/lib/cjs/routing/router.d.ts +0 -54
  149. package/lib/cjs/routing/router.js +0 -319
  150. package/lib/cjs/routing/router.js.map +0 -1
  151. package/lib/cjs/utils.js +0 -90
  152. package/lib/cjs/utils.js.map +0 -1
  153. package/lib/esm/constants.d.ts +0 -4
  154. package/lib/esm/constants.js +0 -5
  155. package/lib/esm/constants.js.map +0 -1
  156. package/lib/esm/core-bot.d.ts +0 -36
  157. package/lib/esm/core-bot.js +0 -92
  158. package/lib/esm/core-bot.js.map +0 -1
  159. package/lib/esm/debug/index.d.ts +0 -1
  160. package/lib/esm/debug/index.js +0 -2
  161. package/lib/esm/debug/index.js.map +0 -1
  162. package/lib/esm/debug/inspector.d.ts +0 -24
  163. package/lib/esm/debug/inspector.js +0 -65
  164. package/lib/esm/debug/inspector.js.map +0 -1
  165. package/lib/esm/handoff.d.ts +0 -67
  166. package/lib/esm/handoff.js +0 -173
  167. package/lib/esm/handoff.js.map +0 -1
  168. package/lib/esm/hubtype-service.d.ts +0 -69
  169. package/lib/esm/hubtype-service.js +0 -185
  170. package/lib/esm/hubtype-service.js.map +0 -1
  171. package/lib/esm/i18n.d.ts +0 -2
  172. package/lib/esm/i18n.js +0 -7
  173. package/lib/esm/i18n.js.map +0 -1
  174. package/lib/esm/index.d.ts +0 -11
  175. package/lib/esm/index.js +0 -12
  176. package/lib/esm/index.js.map +0 -1
  177. package/lib/esm/models/bot-state.d.ts +0 -11
  178. package/lib/esm/models/bot-state.js +0 -2
  179. package/lib/esm/models/bot-state.js.map +0 -1
  180. package/lib/esm/models/channels.d.ts +0 -9
  181. package/lib/esm/models/channels.js +0 -11
  182. package/lib/esm/models/channels.js.map +0 -1
  183. package/lib/esm/models/events/base-event.d.ts +0 -20
  184. package/lib/esm/models/events/base-event.js +0 -14
  185. package/lib/esm/models/events/base-event.js.map +0 -1
  186. package/lib/esm/models/events/botonic-event.d.ts +0 -4
  187. package/lib/esm/models/events/botonic-event.js +0 -2
  188. package/lib/esm/models/events/botonic-event.js.map +0 -1
  189. package/lib/esm/models/events/connection/connection-event.d.ts +0 -9
  190. package/lib/esm/models/events/connection/connection-event.js +0 -6
  191. package/lib/esm/models/events/connection/connection-event.js.map +0 -1
  192. package/lib/esm/models/events/connection/index.d.ts +0 -1
  193. package/lib/esm/models/events/connection/index.js +0 -2
  194. package/lib/esm/models/events/connection/index.js.map +0 -1
  195. package/lib/esm/models/events/index.d.ts +0 -4
  196. package/lib/esm/models/events/index.js +0 -5
  197. package/lib/esm/models/events/index.js.map +0 -1
  198. package/lib/esm/models/events/integration/index.d.ts +0 -1
  199. package/lib/esm/models/events/integration/index.js +0 -2
  200. package/lib/esm/models/events/integration/index.js.map +0 -1
  201. package/lib/esm/models/events/integration/integration-event.d.ts +0 -6
  202. package/lib/esm/models/events/integration/integration-event.js +0 -2
  203. package/lib/esm/models/events/integration/integration-event.js.map +0 -1
  204. package/lib/esm/models/events/message/buttons.d.ts +0 -18
  205. package/lib/esm/models/events/message/buttons.js +0 -2
  206. package/lib/esm/models/events/message/buttons.js.map +0 -1
  207. package/lib/esm/models/events/message/carousel.d.ts +0 -11
  208. package/lib/esm/models/events/message/carousel.js +0 -2
  209. package/lib/esm/models/events/message/carousel.js.map +0 -1
  210. package/lib/esm/models/events/message/custom.d.ts +0 -6
  211. package/lib/esm/models/events/message/custom.js +0 -2
  212. package/lib/esm/models/events/message/custom.js.map +0 -1
  213. package/lib/esm/models/events/message/index.d.ts +0 -9
  214. package/lib/esm/models/events/message/index.js +0 -10
  215. package/lib/esm/models/events/message/index.js.map +0 -1
  216. package/lib/esm/models/events/message/location.d.ts +0 -6
  217. package/lib/esm/models/events/message/location.js +0 -2
  218. package/lib/esm/models/events/message/location.js.map +0 -1
  219. package/lib/esm/models/events/message/media.d.ts +0 -18
  220. package/lib/esm/models/events/message/media.js +0 -8
  221. package/lib/esm/models/events/message/media.js.map +0 -1
  222. package/lib/esm/models/events/message/message-event.d.ts +0 -30
  223. package/lib/esm/models/events/message/message-event.js +0 -29
  224. package/lib/esm/models/events/message/message-event.js.map +0 -1
  225. package/lib/esm/models/events/message/postback.d.ts +0 -4
  226. package/lib/esm/models/events/message/postback.js +0 -2
  227. package/lib/esm/models/events/message/postback.js.map +0 -1
  228. package/lib/esm/models/events/message/replies.d.ts +0 -7
  229. package/lib/esm/models/events/message/replies.js +0 -2
  230. package/lib/esm/models/events/message/replies.js.map +0 -1
  231. package/lib/esm/models/events/message/text.d.ts +0 -8
  232. package/lib/esm/models/events/message/text.js +0 -2
  233. package/lib/esm/models/events/message/text.js.map +0 -1
  234. package/lib/esm/models/index.d.ts +0 -6
  235. package/lib/esm/models/index.js +0 -7
  236. package/lib/esm/models/index.js.map +0 -1
  237. package/lib/esm/models/legacy-types.d.ts +0 -184
  238. package/lib/esm/models/legacy-types.js +0 -56
  239. package/lib/esm/models/legacy-types.js.map +0 -1
  240. package/lib/esm/models/session.d.ts +0 -3
  241. package/lib/esm/models/session.js +0 -2
  242. package/lib/esm/models/session.js.map +0 -1
  243. package/lib/esm/models/user.d.ts +0 -14
  244. package/lib/esm/models/user.js +0 -2
  245. package/lib/esm/models/user.js.map +0 -1
  246. package/lib/esm/output-parser/botonic-output-parser.d.ts +0 -16
  247. package/lib/esm/output-parser/botonic-output-parser.js +0 -33
  248. package/lib/esm/output-parser/botonic-output-parser.js.map +0 -1
  249. package/lib/esm/output-parser/factory.d.ts +0 -4
  250. package/lib/esm/output-parser/factory.js +0 -28
  251. package/lib/esm/output-parser/factory.js.map +0 -1
  252. package/lib/esm/output-parser/index.d.ts +0 -3
  253. package/lib/esm/output-parser/index.js +0 -4
  254. package/lib/esm/output-parser/index.js.map +0 -1
  255. package/lib/esm/output-parser/parsers.d.ts +0 -22
  256. package/lib/esm/output-parser/parsers.js +0 -130
  257. package/lib/esm/output-parser/parsers.js.map +0 -1
  258. package/lib/esm/plugins.d.ts +0 -6
  259. package/lib/esm/plugins.js +0 -43
  260. package/lib/esm/plugins.js.map +0 -1
  261. package/lib/esm/routing/index.d.ts +0 -2
  262. package/lib/esm/routing/index.js +0 -3
  263. package/lib/esm/routing/index.js.map +0 -1
  264. package/lib/esm/routing/router-utils.d.ts +0 -11
  265. package/lib/esm/routing/router-utils.js +0 -79
  266. package/lib/esm/routing/router-utils.js.map +0 -1
  267. package/lib/esm/routing/router.d.ts +0 -54
  268. package/lib/esm/routing/router.js +0 -315
  269. package/lib/esm/routing/router.js.map +0 -1
  270. package/lib/esm/utils.d.ts +0 -11
  271. package/lib/esm/utils.js.map +0 -1
  272. package/src/constants.ts +0 -6
  273. package/src/core-bot.ts +0 -181
  274. package/src/debug/index.ts +0 -1
  275. package/src/debug/inspector.ts +0 -102
  276. package/src/handoff.ts +0 -271
  277. package/src/hubtype-service.ts +0 -266
  278. package/src/i18n.ts +0 -12
  279. package/src/index.ts +0 -11
  280. package/src/models/bot-state.ts +0 -12
  281. package/src/models/channels.ts +0 -9
  282. package/src/models/events/base-event.ts +0 -22
  283. package/src/models/events/botonic-event.ts +0 -26
  284. package/src/models/events/connection/connection-event.ts +0 -11
  285. package/src/models/events/connection/index.ts +0 -1
  286. package/src/models/events/index.ts +0 -4
  287. package/src/models/events/integration/index.ts +0 -1
  288. package/src/models/events/integration/integration-event.ts +0 -13
  289. package/src/models/events/message/buttons.ts +0 -23
  290. package/src/models/events/message/carousel.ts +0 -13
  291. package/src/models/events/message/custom.ts +0 -7
  292. package/src/models/events/message/index.ts +0 -9
  293. package/src/models/events/message/location.ts +0 -7
  294. package/src/models/events/message/media.ts +0 -28
  295. package/src/models/events/message/message-event.ts +0 -37
  296. package/src/models/events/message/postback.ts +0 -5
  297. package/src/models/events/message/replies.ts +0 -8
  298. package/src/models/events/message/text.ts +0 -12
  299. package/src/models/index.ts +0 -6
  300. package/src/models/legacy-types.ts +0 -262
  301. package/src/models/session.ts +0 -3
  302. package/src/models/user.ts +0 -16
  303. package/src/output-parser/botonic-output-parser.ts +0 -38
  304. package/src/output-parser/factory.ts +0 -38
  305. package/src/output-parser/index.ts +0 -3
  306. package/src/output-parser/parsers.ts +0 -202
  307. package/src/plugins.ts +0 -59
  308. package/src/routing/index.ts +0 -2
  309. package/src/routing/router-utils.ts +0 -100
  310. package/src/routing/router.ts +0 -415
  311. package/src/utils.ts +0 -90
package/CHANGELOG.md ADDED
@@ -0,0 +1,226 @@
1
+ ## 2.23.0 (2026-03-23)
2
+
3
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
4
+
5
+ ## 2.22.1 (2026-03-19)
6
+
7
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
8
+
9
+ ## 2.22.0 (2026-03-16)
10
+
11
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
12
+
13
+ ## 2.21.0 (2026-03-16)
14
+
15
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
16
+
17
+ ## 2.20.0 (2026-03-13)
18
+
19
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
20
+
21
+ ## 2.19.0 (2026-03-12)
22
+
23
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
24
+
25
+ ## 2.18.0 (2026-03-04)
26
+
27
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
28
+
29
+ ## 2.17.0 (2026-03-02)
30
+
31
+ ### 🚀 Features
32
+
33
+ - botonic working with v2 input format ([#660](https://github.com/metis-ai/hubtype-product/pull/660))
34
+
35
+ ### ❤️ Thank You
36
+
37
+ - Marc Rabat @vanbasten17
38
+
39
+ ## Unreleased
40
+
41
+ ### ✨ Features
42
+
43
+ - **Input format (BLT-2159):** Single CoreBot (v2). Lambda handler normalizes legacy → v2 with `normalizeToV2Input(mergedInput)` then calls `app.bot.input()`. Adapter: `legacyInputToInput`, `isInputLegacy`, `normalizeToV2Input` in `input-adapter.ts`. Accessors (`getText`, `getPayload`, etc.) preserved for reading/writing input. Removed `BOTONIC_INPUT_MODE`, `CoreBotLegacy`, and `libs/botonic/core/src/lib/core-bot/legacy/`.
44
+ - **CoreBot simplification:** Removed `CoreBotBase` abstraction and `v2/` folder. Single `CoreBot` class in `core-bot.ts`; `request-input.ts` and `input-accessors.ts` live in `core-bot/`. Config type renamed to `CoreBotConfig`.
45
+
46
+ ## 2.16.0 (2026-02-23)
47
+
48
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
49
+
50
+ ## 2.15.0 (2026-02-13)
51
+
52
+ ### 🚀 Features
53
+
54
+ - update types for whatsapp template ([#658](https://github.com/metis-ai/hubtype-product/pull/658))
55
+
56
+ ### ❤️ Thank You
57
+
58
+ - Oriol Raventós @Iru89
59
+
60
+ ## 2.14.0 (2026-02-05)
61
+
62
+ ### 🩹 Fixes
63
+
64
+ - **botonic:** align tsconfig outDir with Nx outputPath to fix TS6305 errors ([#594](https://github.com/metis-ai/hubtype-product/pull/594))
65
+
66
+ ### ❤️ Thank You
67
+
68
+ - Marc Rabat @vanbasten17
69
+
70
+ ## 2.13.4 (2026-02-02)
71
+
72
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
73
+
74
+ ## 2.13.3 (2026-01-30)
75
+
76
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
77
+
78
+ ## 2.13.2 (2026-01-30)
79
+
80
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
81
+
82
+ ## 2.13.1 (2026-01-30)
83
+
84
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
85
+
86
+ ## 2.13.0 (2026-01-29)
87
+
88
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
89
+
90
+ ## 2.12.0 (2026-01-28)
91
+
92
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
93
+
94
+ ## 2.11.5 (2026-01-28)
95
+
96
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
97
+
98
+ ## 2.11.4 (2026-01-28)
99
+
100
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
101
+
102
+ ## 2.11.3 (2026-01-28)
103
+
104
+ ### 🩹 Fixes
105
+
106
+ - update entrypoints to use .js and .d.ts extensions for module and types ([#552](https://github.com/metis-ai/hubtype-product/pull/552))
107
+
108
+ ### ❤️ Thank You
109
+
110
+ - David Hidalgo @Davidhidalgo
111
+
112
+ ## 2.11.2 (2026-01-21)
113
+
114
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
115
+
116
+ ## 2.11.1 (2026-01-21)
117
+
118
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
119
+
120
+ ## 2.11.0 (2026-01-21)
121
+
122
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
123
+
124
+ ## 2.10.1 (2026-01-19)
125
+
126
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
127
+
128
+ ## 2.10.0 (2026-01-18)
129
+
130
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
131
+
132
+ ## 2.9.1 (2026-01-17)
133
+
134
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
135
+
136
+ ## 2.9.0 (2026-01-17)
137
+
138
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
139
+
140
+ ## 2.8.1 (2026-01-16)
141
+
142
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
143
+
144
+ ## 2.8.0 (2026-01-16)
145
+
146
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
147
+
148
+ ## 2.7.1 (2026-01-16)
149
+
150
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
151
+
152
+ ## 2.7.0 (2026-01-15)
153
+
154
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
155
+
156
+ ## 2.6.0 (2025-12-09)
157
+
158
+ ### 🚀 Features
159
+
160
+ - plugin-flow-builder enable SmartIntents and add tests ([#469](https://github.com/metis-ai/hubtype-product/pull/469))
161
+
162
+ ### ❤️ Thank You
163
+
164
+ - Oriol Raventós @Iru89
165
+
166
+ ## 2.5.0 (2025-12-09)
167
+
168
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
169
+
170
+ ## 2.4.1 (2025-12-08)
171
+
172
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
173
+
174
+ ## 2.4.0 (2025-12-05)
175
+
176
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
177
+
178
+ ## 2.3.3 (2025-12-04)
179
+
180
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
181
+
182
+ ## 2.3.2 (2025-12-04)
183
+
184
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
185
+
186
+ ## 2.3.1 (2025-12-04)
187
+
188
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
189
+
190
+ ## 2.3.0 (2025-12-04)
191
+
192
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
193
+
194
+ ## 2.2.1 (2025-12-04)
195
+
196
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
197
+
198
+ ## 2.2.0 (2025-12-04)
199
+
200
+ ### 🚀 Features
201
+
202
+ - add custom tool and bot action ([#452](https://github.com/metis-ai/hubtype-product/pull/452))
203
+ - add support for all whatsapp outputs in domain, factories and whatsapp flow content fields ([#434](https://github.com/metis-ai/hubtype-product/pull/434))
204
+ - fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
205
+
206
+ ### ❤️ Thank You
207
+
208
+ - David Hidalgo @Davidhidalgo
209
+ - Marc Rabat @vanbasten17
210
+ - Oriol Raventós @Iru89
211
+
212
+ ## 2.1.0 (2025-12-02)
213
+
214
+ ### 🚀 Features
215
+
216
+ - add support for all whatsapp outputs in domain, factories and whatsapp flow content fields ([#434](https://github.com/metis-ai/hubtype-product/pull/434))
217
+ - fine tuning botonic release #BLT-2010 ([#428](https://github.com/metis-ai/hubtype-product/pull/428))
218
+
219
+ ### ❤️ Thank You
220
+
221
+ - David Hidalgo @Davidhidalgo
222
+ - Marc Rabat @vanbasten17
223
+
224
+ ## 2.0.1-alpha.0 (2025-11-27)
225
+
226
+ This was a version bump only for @botonic/core to align it with other projects, there were no code changes.
package/README.md CHANGED
@@ -1,13 +1,11 @@
1
- # Botonic Core
1
+ # core
2
2
 
3
- `@botonic/core` set the basis for Botonic. This package contains all the essential definitions and utilities that are used to coordinate the different packages of the framework.
3
+ This library was generated with [Nx](https://nx.dev).
4
4
 
5
- It is the main responsible for:
5
+ ## Building
6
6
 
7
- - Processing the inputs and map them into bot responses or actions
8
- - Supporting internationalization (i18n)
9
- - Operating with plugins
10
- - Managing human handoff
11
- - Communicating with Hubtype's server
7
+ Run `nx build core` to build the library.
12
8
 
13
- `@botonic/react` depends on this package to work. Check more information about `@botonic/react` [here](https://www.npmjs.com/package/@botonic/react).
9
+ ## Running unit tests
10
+
11
+ Run `nx test core` to execute the unit tests via [Vitest](https://vitest.dev/).
package/package.json CHANGED
@@ -1,64 +1,26 @@
1
1
  {
2
2
  "name": "@botonic/core",
3
- "version": "1.0.0-dev.2",
4
- "license": "MIT",
5
- "description": "Build Chatbots using React",
6
- "main": "./lib/cjs/index.js",
7
- "module": "./lib/esm/index.js",
8
- "scripts": {
9
- "test": "../../node_modules/.bin/jest --coverage",
10
- "prepare": "node ../../preinstall.js",
11
- "prepublishOnly": "rm -rf lib && npm run build",
12
- "lint": "npm run lint_ci -- --fix",
13
- "lint_ci": "../../node_modules/.bin/eslint_d --cache --quiet '*.js' 'src/**/*.ts*'",
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
- "cloc": "../../scripts/qa/cloc-package.sh ."
3
+ "version": "2.23.0",
4
+ "type": "module",
5
+ "types": "./src/index.d.ts",
6
+ "module": "./src/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "import": "./src/index.js"
11
+ }
17
12
  },
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/hubtype/botonic.git"
21
- },
22
- "author": "",
23
- "bugs": {
24
- "url": "https://github.com/hubtype/botonic/issues"
25
- },
26
- "files": [
27
- "src/**",
28
- "lib/**",
29
- "index.d.ts",
30
- "README.md"
31
- ],
32
13
  "dependencies": {
33
- "axios": "^0.24.0",
34
- "decode": "^0.3.0",
35
- "fast-xml-parser": "^3.21.1",
36
- "html-entities": "^2.3.2",
37
- "pusher-js": "^5.1.1"
38
- },
39
- "devDependencies": {
40
- "@babel/cli": "^7.11.5",
41
- "@babel/core": "^7.11.6",
42
- "@babel/plugin-proposal-object-rest-spread": "^7.9.6",
43
- "@babel/plugin-proposal-class-properties": "^7.8.3",
44
- "@babel/plugin-transform-runtime": "^7.9.6",
45
- "@babel/preset-env": "^7.9.6",
46
- "babel-plugin-add-module-exports": "^1.0.2"
47
- },
48
- "homepage": "https://github.com/hubtype/botonic#readme",
49
- "engines": {
50
- "node": ">=10.0.0"
14
+ "@botonic/shared": "2.23.0",
15
+ "tslib": "^2.3.0"
51
16
  },
52
- "keywords": [
53
- "bot-framework",
54
- "chatbot",
55
- "conversational-app",
56
- "conversational-ui",
57
- "javascript"
17
+ "references": [
18
+ {
19
+ "path": "../shared/tsconfig.lib.json"
20
+ }
58
21
  ],
59
- "eslintConfig": {
60
- "extends": "../.eslintrc.js",
61
- "root": true
22
+ "publishConfig": {
23
+ "access": "public"
62
24
  },
63
- "sideEffects": false
64
- }
25
+ "main": "./src/index.js"
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './lib/core-bot';
2
+ export * from './lib/hubtype-service';
3
+ export * from './lib/routes/types';
4
+ export * from './lib/utils';
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './lib/core-bot';
2
+ export * from './lib/hubtype-service';
3
+ export * from './lib/routes/types';
4
+ export * from './lib/utils';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/botonic/core/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { BotContext, BotonicRequest, ResolvedPlugins } from '@botonic/shared';
2
+ import { HubtypeExternalAPIService } from '../hubtype-service';
3
+ import { Route } from '../routes/types';
4
+ /** Config for CoreBot. */
5
+ export interface CoreBotConfig {
6
+ appId?: string;
7
+ defaultDelay?: number;
8
+ defaultRoutes?: (botContext: BotContext) => Route[];
9
+ defaultTyping?: number;
10
+ plugins?: ResolvedPlugins;
11
+ routes: (botContext: BotContext) => Route[];
12
+ }
13
+ /**
14
+ * CoreBot: accepts RequestInput; normalizes to Input (v2) inside input().
15
+ * Runs pipeline: input() → getBotContext → runInput (route, plugins, redirect).
16
+ */
17
+ export declare class CoreBot {
18
+ appId?: string;
19
+ defaultDelay: number;
20
+ defaultRoutes: (botContext: BotContext) => Route[];
21
+ defaultTyping: number;
22
+ plugins: ResolvedPlugins;
23
+ routes: (botContext: BotContext) => Route[];
24
+ hubtypeService: HubtypeExternalAPIService;
25
+ private readonly botonicContextFactory;
26
+ constructor({ appId, defaultDelay, defaultRoutes, defaultTyping, plugins, routes, }: CoreBotConfig);
27
+ input(botRequest: BotonicRequest): Promise<void>;
28
+ private runInput;
29
+ private runPrePlugins;
30
+ private getRoute;
31
+ private runPostPlugins;
32
+ private runRedirectAction;
33
+ }
@@ -0,0 +1,113 @@
1
+ import { __awaiter } from "tslib";
2
+ import { BotonicAction, BotonicContextFactory, MessageType, PluginMode, } from '@botonic/shared';
3
+ import { HubtypeExternalAPIService } from '../hubtype-service';
4
+ import { runPlugins } from '../plugins';
5
+ import { Router } from '../routes/router';
6
+ /**
7
+ * CoreBot: accepts RequestInput; normalizes to Input (v2) inside input().
8
+ * Runs pipeline: input() → getBotContext → runInput (route, plugins, redirect).
9
+ */
10
+ export class CoreBot {
11
+ constructor({ appId, defaultDelay = 0.4, defaultRoutes = () => [], defaultTyping = 0.6, plugins, routes, }) {
12
+ this.hubtypeService = new HubtypeExternalAPIService();
13
+ this.appId = appId;
14
+ this.defaultDelay = defaultDelay;
15
+ this.defaultRoutes = defaultRoutes;
16
+ this.defaultTyping = defaultTyping;
17
+ this.plugins = plugins || {};
18
+ this.routes = routes;
19
+ this.botonicContextFactory = new BotonicContextFactory(this.hubtypeService, this.plugins, this.defaultTyping, this.defaultDelay);
20
+ }
21
+ input(botRequest) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const botContext = this.botonicContextFactory.create(botRequest);
24
+ yield this.runInput(botContext);
25
+ if (botContext.session.isBotonicActionRedirect()) {
26
+ yield this.runRedirectAction(botContext);
27
+ }
28
+ });
29
+ }
30
+ runInput(botContext) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ var _a;
33
+ if (botContext.input.type === MessageType.TypingEvent) {
34
+ botContext.response = {
35
+ status: 200,
36
+ response: 'OK',
37
+ };
38
+ return botContext;
39
+ }
40
+ yield this.runPrePlugins(botContext);
41
+ const route = yield this.getRoute(botContext);
42
+ const actionResponse = yield ((_a = route.action) === null || _a === void 0 ? void 0 : _a.call(route, botContext));
43
+ yield this.runPostPlugins(botContext, actionResponse);
44
+ if (botContext.session.isFirstInteraction) {
45
+ yield botContext.updateBotSession({ isFirstInteraction: false });
46
+ }
47
+ botContext.response = actionResponse !== null && actionResponse !== void 0 ? actionResponse : { status: 200, response: 'OK' };
48
+ return botContext;
49
+ });
50
+ }
51
+ runPrePlugins(botContext) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ if (this.plugins) {
54
+ yield runPlugins({
55
+ botContext,
56
+ mode: PluginMode.PRE,
57
+ });
58
+ }
59
+ });
60
+ }
61
+ getRoute(botContext) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const computedRoutes = this.routes(botContext);
64
+ const router = new Router([
65
+ ...computedRoutes,
66
+ ...this.defaultRoutes(botContext),
67
+ ]);
68
+ const route = router.processInput(botContext);
69
+ return route;
70
+ });
71
+ }
72
+ runPostPlugins(botContext, response) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ if (this.plugins) {
75
+ yield runPlugins({
76
+ botContext,
77
+ mode: PluginMode.POST,
78
+ response,
79
+ });
80
+ }
81
+ });
82
+ }
83
+ runRedirectAction(botContext_1) {
84
+ return __awaiter(this, arguments, void 0, function* (botContext, numOfRedirects = 0) {
85
+ var _a;
86
+ if (numOfRedirects > 10) {
87
+ throw new Error('Maximum BotAction recursive calls reached (10)');
88
+ }
89
+ const nextPayload = botContext.session.getBotonicActionPayload(BotonicAction.Redirect);
90
+ const hadPayload = Boolean(nextPayload);
91
+ if (!hadPayload) {
92
+ yield botContext.updateBotSession({ botonicAction: null });
93
+ botContext.response = {
94
+ status: 200,
95
+ response: 'OK',
96
+ };
97
+ return botContext;
98
+ }
99
+ yield botContext.updateBotSession({ botonicAction: null });
100
+ botContext.input.setAsPostback(nextPayload);
101
+ const followUpContext = yield this.runInput(botContext);
102
+ if (botContext.session.isBotonicActionRedirect()) {
103
+ return yield this.runRedirectAction(botContext, numOfRedirects + 1);
104
+ }
105
+ followUpContext.response = (_a = followUpContext.response) !== null && _a !== void 0 ? _a : {
106
+ status: 200,
107
+ response: 'OK',
108
+ };
109
+ return followUpContext;
110
+ });
111
+ }
112
+ }
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/core-bot/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,aAAa,EACb,qBAAqB,EAErB,WAAW,EACX,UAAU,GAEX,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAazC;;;GAGG;AACH,MAAM,OAAO,OAAO;IAUlB,YAAY,EACV,KAAK,EACL,YAAY,GAAG,GAAG,EAClB,aAAa,GAAG,GAAG,EA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iBAAiB;6DAC7B,UAAsB,EACtB,cAAc,GAAG,CAAC;;YAElB,IAAI,cAAc,GAAG,EAAE,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;YACnE,CAAC;YAED,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,uBAAuB,CAC5D,aAAa,CAAC,QAAQ,CACvB,CAAA;YAED,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;YACvC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChB,MAAM,UAAU,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;gBAC1D,UAAU,CAAC,QAAQ,GAAG;oBACpB,MAAM,EAAE,GAAG;oBACX,QAAQ,EAAE,IAAI;iBACf,CAAA;gBACD,OAAO,UAAU,CAAA;YACnB,CAAC;YAED,MAAM,UAAU,CAAC,gBAAgB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;YAC1D,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,WAAY,CAAC,CAAA;YAE5C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;YAEvD,IAAI,UAAU,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;gBACjD,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,GAAG,CAAC,CAAC,CAAA;YACrE,CAAC;YAED,eAAe,CAAC,QAAQ,GAAG,MAAA,eAAe,CAAC,QAAQ,mCAAI;gBACrD,MAAM,EAAE,GAAG;gBACX,QAAQ,EAAE,IAAI;aACf,CAAA;YACD,OAAO,eAAe,CAAA;QACxB,CAAC;KAAA;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { BotonicContextSession } from '@botonic/shared';
2
+ export declare function storeCaseRating(session: BotonicContextSession, rating: number, context?: any): Promise<{
3
+ status: string;
4
+ }>;
@@ -0,0 +1,32 @@
1
+ import { __awaiter } from "tslib";
2
+ // function contextDefaults(context: any): any {
3
+ // return {
4
+ // timeoutMs: context.timeoutMs || 10000,
5
+ // }
6
+ // }
7
+ export function storeCaseRating(session_1, rating_1) {
8
+ return __awaiter(this, arguments, void 0, function* (session, rating, context = {}) {
9
+ if (session.isTestIntegration) {
10
+ return Promise.resolve({ status: 'ok' });
11
+ }
12
+ const baseUrl = session.hubtypeApi ||
13
+ // @ts-expect-error - VITE_HUBTYPE_API_URL is not defined in the environment
14
+ import.meta.env['VITE_HUBTYPE_API_URL'];
15
+ const chatId = session.user.id;
16
+ // context = contextDefaults(context)
17
+ const response = yield fetch(`${baseUrl}/v1/chats/${chatId}/store_case_rating/`, {
18
+ method: 'POST',
19
+ headers: {
20
+ Authorization: `Bearer ${session.accessToken}`,
21
+ 'Content-Type': 'application/json',
22
+ },
23
+ body: JSON.stringify({ chat_id: chatId, rating }),
24
+ // signal: AbortSignal.timeout((context as any).timeoutMs),
25
+ });
26
+ if (!response.ok) {
27
+ throw new Error(`HTTP error! status: ${response.status}`);
28
+ }
29
+ return yield response.json();
30
+ });
31
+ }
32
+ //# sourceMappingURL=handoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/hubtype-service/handoff.ts"],"names":[],"mappings":";AACA,gDAAgD;AAChD,aAAa;AACb,6CAA6C;AAC7C,MAAM;AACN,IAAI;AAEJ,MAAM,UAAgB,eAAe;yDACnC,OAA8B,EAC9B,MAAc,EACd,UAAe,EAAE;QAEjB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1C,CAAC;QACD,MAAM,OAAO,GACX,OAAO,CAAC,UAAU;YAClB,4EAA4E;YAC5E,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;QAC9B,uCAAuC;QACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,OAAO,aAAa,MAAM,qBAAqB,EAClD;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,OAAO,CAAC,WAAW,EAAE;gBAC9C,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YACjD,6DAA6D;SAC9D,CACF,CAAA;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;QAC3D,CAAC;QAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAC9B,CAAC;CAAA"}
@@ -0,0 +1,10 @@
1
+ import { BotContext, BotonicRequestSession, BotonicSessionUpdate, BotServerMessage, HandoffOptions, HubtypeServicePort, ResolvedPlugins, UserExtraData } from '@botonic/shared';
2
+ export declare class HubtypeExternalAPIService implements HubtypeServicePort {
3
+ baseUrl: string;
4
+ constructor(baseUrl?: string);
5
+ updateBotSession<TExtraData extends UserExtraData = UserExtraData>(botContext: BotContext<ResolvedPlugins, TExtraData>, updates: BotonicSessionUpdate<TExtraData>): Promise<void>;
6
+ getBotSession(botContext: BotContext): Promise<Omit<BotonicRequestSession, '_access_token'>>;
7
+ doHandoff(botContext: BotContext, handoffOptions?: HandoffOptions): Promise<any>;
8
+ sendMessage(botContext: BotContext, message: BotServerMessage): Promise<unknown>;
9
+ }
10
+ export { storeCaseRating } from './handoff';
@@ -0,0 +1,96 @@
1
+ import { __awaiter } from "tslib";
2
+ import { BotonicContextSession, sessionUpdateToPatchBody, } from '@botonic/shared';
3
+ export class HubtypeExternalAPIService {
4
+ constructor(
5
+ // @ts-expect-error - VITE_HUBTYPE_API_URL is not defined in the environment
6
+ baseUrl = import.meta.env['VITE_HUBTYPE_API_URL'] // TODO: Should this come from vite or directly taken from lambda process.env?
7
+ ) {
8
+ this.baseUrl = baseUrl;
9
+ }
10
+ updateBotSession(botContext, updates) {
11
+ return __awaiter(this, void 0, void 0, function* () {
12
+ const patchedSession = sessionUpdateToPatchBody(updates);
13
+ const sessionToUpdate = Object.assign({}, patchedSession);
14
+ delete sessionToUpdate._access_token;
15
+ delete sessionToUpdate._hubtype_api;
16
+ // When patching user, send full user so backend replacement does not drop id, provider, contact_info, etc.
17
+ // TODO: Beware this kind of unstructuring so we keep all levels of the user object
18
+ if (sessionToUpdate.user != null &&
19
+ typeof sessionToUpdate.user === 'object') {
20
+ sessionToUpdate.user = Object.assign(Object.assign({}, botContext.session.raw.user), sessionToUpdate.user);
21
+ }
22
+ const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/context/`, {
23
+ method: 'PATCH',
24
+ headers: {
25
+ 'Content-Type': 'application/json',
26
+ },
27
+ body: JSON.stringify(sessionToUpdate),
28
+ });
29
+ if (!response.ok) {
30
+ console.error('Response error', response);
31
+ throw new Error('Failed to update bot session');
32
+ }
33
+ const didUpdateBotonicAction = 'botonicAction' in updates;
34
+ const previousBotonicAction = didUpdateBotonicAction
35
+ ? undefined
36
+ : botContext.session.raw._botonic_action;
37
+ const sessionUpdated = yield response.json();
38
+ sessionUpdated._access_token = botContext.session.accessToken;
39
+ if (previousBotonicAction !== undefined) {
40
+ sessionUpdated._botonic_action = previousBotonicAction;
41
+ }
42
+ botContext.session = new BotonicContextSession(sessionUpdated);
43
+ });
44
+ }
45
+ getBotSession(botContext) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/context/`);
48
+ if (!response.ok) {
49
+ throw new Error('Failed to get bot session');
50
+ }
51
+ const sessionResponse = yield response.json();
52
+ return sessionResponse;
53
+ });
54
+ }
55
+ doHandoff(botContext, handoffOptions) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/do_handoff/`, {
58
+ method: 'POST',
59
+ headers: {
60
+ 'Content-Type': 'application/json',
61
+ Authorization: `Bearer ${botContext.session.accessToken}`,
62
+ },
63
+ body: JSON.stringify(Object.assign(Object.assign({}, handoffOptions), { bot_interaction_id: botContext.input.botInteractionId })),
64
+ });
65
+ if (!response.ok) {
66
+ throw new Error('Failed to do handoff');
67
+ }
68
+ return yield response.json();
69
+ });
70
+ }
71
+ sendMessage(botContext, message) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ var _a;
74
+ const response = yield fetch(`${this.baseUrl}/external/v2/conversational_apps/${botContext.session.bot.id}/users/${botContext.session.user.id}/send_message/`, {
75
+ method: 'POST',
76
+ headers: {
77
+ 'Content-Type': 'application/json',
78
+ Authorization: `Bearer ${botContext.session.accessToken}`,
79
+ },
80
+ body: JSON.stringify(message),
81
+ });
82
+ if (!response.ok) {
83
+ const contentType = (_a = response.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
84
+ const isJson = contentType.includes('application/json');
85
+ const responseError = isJson
86
+ ? yield response.json()
87
+ : yield response.text();
88
+ console.error('Response error', responseError);
89
+ throw new Error('Failed to post message');
90
+ }
91
+ return yield response.json();
92
+ });
93
+ }
94
+ }
95
+ export { storeCaseRating } from './handoff';
96
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../libs/botonic/core/src/lib/hubtype-service/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,qBAAqB,EAOrB,wBAAwB,GAEzB,MAAM,iBAAiB,CAAA;AAExB,MAAM,OAAO,yBAAyB;IAGpC;IACE,4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