@botonic/plugin-flow-builder 0.22.0-beta.3 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/lib/cjs/action.d.ts +16 -2
  2. package/lib/cjs/action.js +21 -19
  3. package/lib/cjs/action.js.map +1 -1
  4. package/lib/cjs/api.d.ts +19 -0
  5. package/lib/cjs/api.js +108 -0
  6. package/lib/cjs/api.js.map +1 -0
  7. package/lib/cjs/content-fields/content-fields-base.d.ts +4 -4
  8. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  9. package/lib/cjs/content-fields/flow-button.d.ts +6 -3
  10. package/lib/cjs/content-fields/flow-button.js +28 -21
  11. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  12. package/lib/cjs/content-fields/flow-carousel.d.ts +3 -2
  13. package/lib/cjs/content-fields/flow-carousel.js +3 -10
  14. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  15. package/lib/cjs/content-fields/flow-element.d.ts +6 -3
  16. package/lib/cjs/content-fields/flow-element.js +16 -5
  17. package/lib/cjs/content-fields/flow-element.js.map +1 -1
  18. package/lib/cjs/content-fields/flow-image.d.ts +2 -2
  19. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  20. package/lib/cjs/content-fields/flow-text.d.ts +4 -3
  21. package/lib/cjs/content-fields/flow-text.js +9 -9
  22. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  23. package/lib/cjs/content-fields/flow-video.d.ts +2 -2
  24. package/lib/cjs/content-fields/flow-video.js +0 -1
  25. package/lib/cjs/content-fields/flow-video.js.map +1 -1
  26. package/lib/cjs/content-fields/hubtype-fields/button.d.ts +9 -0
  27. package/lib/cjs/content-fields/hubtype-fields/button.js +3 -0
  28. package/lib/cjs/content-fields/hubtype-fields/button.js.map +1 -0
  29. package/lib/cjs/content-fields/hubtype-fields/carousel.d.ts +16 -0
  30. package/lib/cjs/content-fields/hubtype-fields/carousel.js +3 -0
  31. package/lib/cjs/content-fields/hubtype-fields/carousel.js.map +1 -0
  32. package/lib/cjs/content-fields/hubtype-fields/common.d.ts +55 -0
  33. package/lib/cjs/content-fields/hubtype-fields/common.js +3 -0
  34. package/lib/cjs/content-fields/hubtype-fields/common.js.map +1 -0
  35. package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +9 -0
  36. package/lib/cjs/content-fields/hubtype-fields/fallback.js +3 -0
  37. package/lib/cjs/content-fields/hubtype-fields/fallback.js.map +1 -0
  38. package/lib/cjs/content-fields/hubtype-fields/function.d.ts +28 -0
  39. package/lib/cjs/content-fields/hubtype-fields/function.js +10 -0
  40. package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -0
  41. package/lib/cjs/content-fields/hubtype-fields/handoff.d.ts +10 -0
  42. package/lib/cjs/content-fields/hubtype-fields/handoff.js +3 -0
  43. package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +1 -0
  44. package/lib/cjs/content-fields/hubtype-fields/image.d.ts +8 -0
  45. package/lib/cjs/content-fields/{types.js → hubtype-fields/image.js} +1 -1
  46. package/lib/cjs/content-fields/hubtype-fields/image.js.map +1 -0
  47. package/lib/cjs/content-fields/hubtype-fields/index.d.ts +17 -0
  48. package/lib/cjs/content-fields/hubtype-fields/index.js +21 -0
  49. package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -0
  50. package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +10 -0
  51. package/lib/cjs/content-fields/hubtype-fields/intent.js +3 -0
  52. package/lib/cjs/content-fields/hubtype-fields/intent.js.map +1 -0
  53. package/lib/cjs/content-fields/hubtype-fields/keyword.d.ts +9 -0
  54. package/lib/cjs/content-fields/hubtype-fields/keyword.js +3 -0
  55. package/lib/cjs/content-fields/hubtype-fields/keyword.js.map +1 -0
  56. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +23 -0
  57. package/lib/cjs/content-fields/hubtype-fields/node-types.js +31 -0
  58. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -0
  59. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +16 -0
  60. package/lib/cjs/content-fields/hubtype-fields/nodes.js +3 -0
  61. package/lib/cjs/content-fields/hubtype-fields/nodes.js.map +1 -0
  62. package/lib/cjs/content-fields/hubtype-fields/payload.d.ts +8 -0
  63. package/lib/cjs/content-fields/hubtype-fields/payload.js +3 -0
  64. package/lib/cjs/content-fields/hubtype-fields/payload.js.map +1 -0
  65. package/lib/cjs/content-fields/hubtype-fields/start.d.ts +7 -0
  66. package/lib/cjs/content-fields/hubtype-fields/start.js +3 -0
  67. package/lib/cjs/content-fields/hubtype-fields/start.js.map +1 -0
  68. package/lib/cjs/content-fields/hubtype-fields/text.d.ts +11 -0
  69. package/lib/cjs/content-fields/hubtype-fields/text.js +3 -0
  70. package/lib/cjs/content-fields/hubtype-fields/text.js.map +1 -0
  71. package/lib/cjs/content-fields/hubtype-fields/url.d.ts +8 -0
  72. package/lib/cjs/content-fields/hubtype-fields/url.js +3 -0
  73. package/lib/cjs/content-fields/hubtype-fields/url.js.map +1 -0
  74. package/lib/cjs/content-fields/hubtype-fields/video.d.ts +8 -0
  75. package/lib/cjs/content-fields/hubtype-fields/video.js +3 -0
  76. package/lib/cjs/content-fields/hubtype-fields/video.js.map +1 -0
  77. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  78. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +3 -0
  79. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  80. package/lib/cjs/content-fields/index.d.ts +7 -5
  81. package/lib/cjs/content-fields/index.js +11 -9
  82. package/lib/cjs/content-fields/index.js.map +1 -1
  83. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  84. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +32 -0
  85. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  86. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  87. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +29 -0
  88. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  89. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  90. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +33 -0
  91. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  92. package/lib/cjs/functions/conditional-provider.d.ts +2 -2
  93. package/lib/cjs/functions/conditional-provider.js +2 -2
  94. package/lib/cjs/functions/conditional-provider.js.map +1 -1
  95. package/lib/cjs/functions/conditional-queue-status.d.ts +7 -2
  96. package/lib/cjs/functions/conditional-queue-status.js +11 -1
  97. package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
  98. package/lib/cjs/handoff.d.ts +2 -2
  99. package/lib/cjs/handoff.js +17 -9
  100. package/lib/cjs/handoff.js.map +1 -1
  101. package/lib/cjs/helpers.d.ts +2 -1
  102. package/lib/cjs/helpers.js +5 -13
  103. package/lib/cjs/helpers.js.map +1 -1
  104. package/lib/cjs/index.d.ts +10 -21
  105. package/lib/cjs/index.js +36 -151
  106. package/lib/cjs/index.js.map +1 -1
  107. package/lib/cjs/types.d.ts +8 -2
  108. package/lib/cjs/types.js.map +1 -1
  109. package/lib/esm/action.d.ts +16 -2
  110. package/lib/esm/action.js +21 -19
  111. package/lib/esm/action.js.map +1 -1
  112. package/lib/esm/api.d.ts +19 -0
  113. package/lib/esm/api.js +103 -0
  114. package/lib/esm/api.js.map +1 -0
  115. package/lib/esm/content-fields/content-fields-base.d.ts +4 -4
  116. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  117. package/lib/esm/content-fields/flow-button.d.ts +6 -3
  118. package/lib/esm/content-fields/flow-button.js +28 -21
  119. package/lib/esm/content-fields/flow-button.js.map +1 -1
  120. package/lib/esm/content-fields/flow-carousel.d.ts +3 -2
  121. package/lib/esm/content-fields/flow-carousel.js +4 -11
  122. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  123. package/lib/esm/content-fields/flow-element.d.ts +6 -3
  124. package/lib/esm/content-fields/flow-element.js +15 -5
  125. package/lib/esm/content-fields/flow-element.js.map +1 -1
  126. package/lib/esm/content-fields/flow-image.d.ts +2 -2
  127. package/lib/esm/content-fields/flow-image.js.map +1 -1
  128. package/lib/esm/content-fields/flow-text.d.ts +4 -3
  129. package/lib/esm/content-fields/flow-text.js +9 -9
  130. package/lib/esm/content-fields/flow-text.js.map +1 -1
  131. package/lib/esm/content-fields/flow-video.d.ts +2 -2
  132. package/lib/esm/content-fields/flow-video.js +0 -1
  133. package/lib/esm/content-fields/flow-video.js.map +1 -1
  134. package/lib/esm/content-fields/hubtype-fields/button.d.ts +9 -0
  135. package/lib/esm/content-fields/hubtype-fields/button.js +2 -0
  136. package/lib/esm/content-fields/hubtype-fields/button.js.map +1 -0
  137. package/lib/esm/content-fields/hubtype-fields/carousel.d.ts +16 -0
  138. package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -0
  139. package/lib/esm/content-fields/hubtype-fields/carousel.js.map +1 -0
  140. package/lib/esm/content-fields/hubtype-fields/common.d.ts +55 -0
  141. package/lib/esm/content-fields/hubtype-fields/common.js +2 -0
  142. package/lib/esm/content-fields/hubtype-fields/common.js.map +1 -0
  143. package/lib/esm/content-fields/hubtype-fields/fallback.d.ts +9 -0
  144. package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -0
  145. package/lib/esm/content-fields/hubtype-fields/fallback.js.map +1 -0
  146. package/lib/esm/content-fields/hubtype-fields/function.d.ts +28 -0
  147. package/lib/esm/content-fields/hubtype-fields/function.js +7 -0
  148. package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -0
  149. package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +10 -0
  150. package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -0
  151. package/lib/esm/content-fields/hubtype-fields/handoff.js.map +1 -0
  152. package/lib/esm/content-fields/hubtype-fields/image.d.ts +8 -0
  153. package/lib/esm/content-fields/hubtype-fields/image.js +2 -0
  154. package/lib/esm/content-fields/hubtype-fields/image.js.map +1 -0
  155. package/lib/esm/content-fields/hubtype-fields/index.d.ts +17 -0
  156. package/lib/esm/content-fields/hubtype-fields/index.js +18 -0
  157. package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -0
  158. package/lib/esm/content-fields/hubtype-fields/intent.d.ts +10 -0
  159. package/lib/esm/content-fields/hubtype-fields/intent.js +2 -0
  160. package/lib/esm/content-fields/hubtype-fields/intent.js.map +1 -0
  161. package/lib/esm/content-fields/hubtype-fields/keyword.d.ts +9 -0
  162. package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -0
  163. package/lib/esm/content-fields/hubtype-fields/keyword.js.map +1 -0
  164. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +23 -0
  165. package/lib/esm/content-fields/hubtype-fields/node-types.js +28 -0
  166. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -0
  167. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +16 -0
  168. package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -0
  169. package/lib/esm/content-fields/hubtype-fields/nodes.js.map +1 -0
  170. package/lib/esm/content-fields/hubtype-fields/payload.d.ts +8 -0
  171. package/lib/esm/content-fields/hubtype-fields/payload.js +2 -0
  172. package/lib/esm/content-fields/hubtype-fields/payload.js.map +1 -0
  173. package/lib/esm/content-fields/hubtype-fields/start.d.ts +7 -0
  174. package/lib/esm/content-fields/hubtype-fields/start.js +2 -0
  175. package/lib/esm/content-fields/hubtype-fields/start.js.map +1 -0
  176. package/lib/esm/content-fields/hubtype-fields/text.d.ts +11 -0
  177. package/lib/esm/content-fields/hubtype-fields/text.js +2 -0
  178. package/lib/esm/content-fields/hubtype-fields/text.js.map +1 -0
  179. package/lib/esm/content-fields/hubtype-fields/url.d.ts +8 -0
  180. package/lib/esm/content-fields/hubtype-fields/url.js +2 -0
  181. package/lib/esm/content-fields/hubtype-fields/url.js.map +1 -0
  182. package/lib/esm/content-fields/hubtype-fields/video.d.ts +8 -0
  183. package/lib/esm/content-fields/hubtype-fields/video.js +2 -0
  184. package/lib/esm/content-fields/hubtype-fields/video.js.map +1 -0
  185. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  186. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -0
  187. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  188. package/lib/esm/content-fields/index.d.ts +7 -5
  189. package/lib/esm/content-fields/index.js +6 -4
  190. package/lib/esm/content-fields/index.js.map +1 -1
  191. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  192. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +28 -0
  193. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  194. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  195. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +25 -0
  196. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  197. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  198. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +28 -0
  199. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  200. package/lib/esm/functions/conditional-provider.d.ts +2 -2
  201. package/lib/esm/functions/conditional-provider.js +2 -2
  202. package/lib/esm/functions/conditional-provider.js.map +1 -1
  203. package/lib/esm/functions/conditional-queue-status.d.ts +7 -2
  204. package/lib/esm/functions/conditional-queue-status.js +11 -1
  205. package/lib/esm/functions/conditional-queue-status.js.map +1 -1
  206. package/lib/esm/handoff.d.ts +2 -2
  207. package/lib/esm/handoff.js +17 -9
  208. package/lib/esm/handoff.js.map +1 -1
  209. package/lib/esm/helpers.d.ts +2 -1
  210. package/lib/esm/helpers.js +3 -11
  211. package/lib/esm/helpers.js.map +1 -1
  212. package/lib/esm/index.d.ts +10 -21
  213. package/lib/esm/index.js +38 -153
  214. package/lib/esm/index.js.map +1 -1
  215. package/lib/esm/types.d.ts +8 -2
  216. package/lib/esm/types.js.map +1 -1
  217. package/package.json +4 -5
  218. package/src/action.tsx +31 -22
  219. package/src/api.ts +162 -0
  220. package/src/content-fields/content-fields-base.ts +7 -7
  221. package/src/content-fields/flow-button.tsx +40 -19
  222. package/src/content-fields/flow-carousel.tsx +10 -18
  223. package/src/content-fields/flow-element.tsx +26 -9
  224. package/src/content-fields/flow-image.tsx +2 -2
  225. package/src/content-fields/flow-text.tsx +15 -12
  226. package/src/content-fields/flow-video.tsx +2 -3
  227. package/src/content-fields/hubtype-fields/button.ts +15 -0
  228. package/src/content-fields/hubtype-fields/carousel.ts +18 -0
  229. package/src/content-fields/hubtype-fields/common.ts +65 -0
  230. package/src/content-fields/hubtype-fields/fallback.ts +10 -0
  231. package/src/content-fields/hubtype-fields/function.ts +33 -0
  232. package/src/content-fields/hubtype-fields/handoff.ts +11 -0
  233. package/src/content-fields/hubtype-fields/image.ts +9 -0
  234. package/src/content-fields/hubtype-fields/index.ts +17 -0
  235. package/src/content-fields/hubtype-fields/intent.ts +11 -0
  236. package/src/content-fields/hubtype-fields/keyword.ts +10 -0
  237. package/src/content-fields/hubtype-fields/node-types.ts +26 -0
  238. package/src/content-fields/hubtype-fields/nodes.ts +32 -0
  239. package/src/content-fields/hubtype-fields/payload.ts +9 -0
  240. package/src/content-fields/hubtype-fields/start.ts +8 -0
  241. package/src/content-fields/hubtype-fields/text.ts +12 -0
  242. package/src/content-fields/hubtype-fields/url.ts +9 -0
  243. package/src/content-fields/hubtype-fields/video.ts +9 -0
  244. package/src/content-fields/hubtype-fields/whatsapp-button-list.ts +25 -0
  245. package/src/content-fields/index.ts +14 -5
  246. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +33 -0
  247. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +35 -0
  248. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +46 -0
  249. package/src/functions/conditional-provider.ts +2 -2
  250. package/src/functions/conditional-queue-status.ts +22 -3
  251. package/src/handoff.ts +27 -14
  252. package/src/helpers.ts +8 -19
  253. package/src/index.ts +55 -197
  254. package/src/types.ts +14 -2
  255. package/lib/cjs/content-fields/types.d.ts +0 -5
  256. package/lib/cjs/content-fields/types.js.map +0 -1
  257. package/lib/cjs/flow-builder-models.d.ts +0 -196
  258. package/lib/cjs/flow-builder-models.js +0 -24
  259. package/lib/cjs/flow-builder-models.js.map +0 -1
  260. package/lib/esm/content-fields/types.d.ts +0 -5
  261. package/lib/esm/content-fields/types.js +0 -2
  262. package/lib/esm/content-fields/types.js.map +0 -1
  263. package/lib/esm/flow-builder-models.d.ts +0 -196
  264. package/lib/esm/flow-builder-models.js +0 -21
  265. package/lib/esm/flow-builder-models.js.map +0 -1
  266. package/src/.DS_Store +0 -0
  267. package/src/content-fields/types.ts +0 -6
  268. package/src/flow-builder-models.ts +0 -249
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowWhatsappButtonListSection = void 0;
4
+ const content_fields_base_1 = require("./../content-fields-base");
5
+ const flow_whatsapp_button_list_row_1 = require("./flow-whatsapp-button-list-row");
6
+ class FlowWhatsappButtonListSection extends content_fields_base_1.ContentFieldsBase {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.title = '';
10
+ this.rows = [];
11
+ }
12
+ static fromHubtypeCMS(component, locale) {
13
+ const newButton = new FlowWhatsappButtonListSection(component.id);
14
+ newButton.title = this.getTextByLocale(locale, component.title);
15
+ newButton.rows = component.rows.map(row => flow_whatsapp_button_list_row_1.FlowWhatsappButtonListRow.fromHubtypeCMS(row, locale));
16
+ return newButton;
17
+ }
18
+ toBotonic() {
19
+ const rows = this.rows.reduce((acc, row) => {
20
+ const botonicRow = row.toBotonic();
21
+ if (botonicRow)
22
+ acc.push(botonicRow);
23
+ return acc;
24
+ }, []);
25
+ return { title: this.title, rows };
26
+ }
27
+ }
28
+ exports.FlowWhatsappButtonListSection = FlowWhatsappButtonListSection;
29
+ //# sourceMappingURL=flow-whatsapp-button-list-section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-whatsapp-button-list-section.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx"],"names":[],"mappings":";;;AAMA,kEAA4D;AAC5D,mFAA2E;AAE3E,MAAa,6BAA8B,SAAQ,uCAAiB;IAApE;;QACS,UAAK,GAAG,EAAE,CAAA;QACV,SAAI,GAAgC,EAAE,CAAA;IAuB/C,CAAC;IArBC,MAAM,CAAC,cAAc,CACnB,SAAsC,EACtC,MAAc;QAEd,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACjE,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QAC/D,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CACxC,yDAAyB,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CACtD,CAAA;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS;QACP,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAiC,EAAE,GAAG,EAAE,EAAE;YACvE,MAAM,UAAU,GAAG,GAAG,CAAC,SAAS,EAAE,CAAA;YAClC,IAAI,UAAU;gBAAE,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACpC,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;CACF;AAzBD,sEAyBC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { HtWhatsappButtonListNode } from '../hubtype-fields';
3
+ import { ContentFieldsBase } from './../content-fields-base';
4
+ import { FlowWhatsappButtonListSection } from './flow-whatsapp-button-list-section';
5
+ export declare class FlowWhatsappButtonList extends ContentFieldsBase {
6
+ code: string;
7
+ text: string;
8
+ listButtonText: string;
9
+ sections: FlowWhatsappButtonListSection[];
10
+ static fromHubtypeCMS(component: HtWhatsappButtonListNode, locale: string): FlowWhatsappButtonList;
11
+ toBotonic(id: string): JSX.Element;
12
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowWhatsappButtonList = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = require("@botonic/react");
6
+ const react_2 = tslib_1.__importDefault(require("react"));
7
+ const content_fields_base_1 = require("./../content-fields-base");
8
+ const flow_whatsapp_button_list_section_1 = require("./flow-whatsapp-button-list-section");
9
+ class FlowWhatsappButtonList extends content_fields_base_1.ContentFieldsBase {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.code = '';
13
+ this.text = '';
14
+ this.listButtonText = '';
15
+ this.sections = [];
16
+ }
17
+ static fromHubtypeCMS(component, locale) {
18
+ const newWhatsappButtonList = new FlowWhatsappButtonList(component.id);
19
+ newWhatsappButtonList.code = component.code;
20
+ newWhatsappButtonList.text = this.getTextByLocale(locale, component.content.text);
21
+ newWhatsappButtonList.listButtonText = this.getTextByLocale(locale, component.content.button_text);
22
+ newWhatsappButtonList.sections = component.content.sections.map(section => flow_whatsapp_button_list_section_1.FlowWhatsappButtonListSection.fromHubtypeCMS(section, locale));
23
+ return newWhatsappButtonList;
24
+ }
25
+ toBotonic(id) {
26
+ return (react_2.default.createElement(react_1.WhatsappButtonList, { key: id, body: this.text, action: {
27
+ button: this.listButtonText,
28
+ sections: this.sections.map(section => section.toBotonic()),
29
+ } }));
30
+ }
31
+ }
32
+ exports.FlowWhatsappButtonList = FlowWhatsappButtonList;
33
+ //# sourceMappingURL=flow-whatsapp-button-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-whatsapp-button-list.js","sourceRoot":"","sources":["../../../../src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx"],"names":[],"mappings":";;;;AAAA,0CAAmD;AACnD,0DAAyB;AAGzB,kEAA4D;AAC5D,2FAAmF;AAEnF,MAAa,sBAAuB,SAAQ,uCAAiB;IAA7D;;QACS,SAAI,GAAG,EAAE,CAAA;QACT,SAAI,GAAG,EAAE,CAAA;QACT,mBAAc,GAAG,EAAE,CAAA;QACnB,aAAQ,GAAoC,EAAE,CAAA;IAkCvD,CAAC;IAhCC,MAAM,CAAC,cAAc,CACnB,SAAmC,EACnC,MAAc;QAEd,MAAM,qBAAqB,GAAG,IAAI,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QACtE,qBAAqB,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAA;QAC3C,qBAAqB,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAC/C,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,IAAI,CACvB,CAAA;QACD,qBAAqB,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CACzD,MAAM,EACN,SAAS,CAAC,OAAO,CAAC,WAAW,CAC9B,CAAA;QACD,qBAAqB,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CACxE,iEAA6B,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAC9D,CAAA;QACD,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,SAAS,CAAC,EAAU;QAClB,OAAO,CACL,8BAAC,0BAAkB,IACjB,GAAG,EAAE,EAAE,EACP,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,MAAM,EAAE;gBACN,MAAM,EAAE,IAAI,CAAC,cAAc;gBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;aAC5D,GACmB,CACvB,CAAA;IACH,CAAC;CACF;AAtCD,wDAsCC"}
@@ -1,4 +1,4 @@
1
- export declare function conditionalProvider({ session, results }: {
2
- session: any;
1
+ export declare function conditionalProvider({ request, results }: {
2
+ request: any;
3
3
  results: any;
4
4
  }): string;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.conditionalProvider = void 0;
4
- function conditionalProvider({ session, results }) {
5
- const provider = session.user.provider;
4
+ function conditionalProvider({ request, results }) {
5
+ const provider = request.session.user.provider;
6
6
  if (results.includes(provider))
7
7
  return provider;
8
8
  return 'default';
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-provider.js","sourceRoot":"","sources":["../../../src/functions/conditional-provider.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IACtC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC/C,OAAO,SAAS,CAAA;AAClB,CAAC;AAJD,kDAIC"}
1
+ {"version":3,"file":"conditional-provider.js","sourceRoot":"","sources":["../../../src/functions/conditional-provider.ts"],"names":[],"mappings":";;;AAAA,SAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE;IACtD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC9C,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAA;IAC/C,OAAO,SAAS,CAAA;AAClB,CAAC;AAJD,kDAIC"}
@@ -1,3 +1,8 @@
1
- export declare function conditionalQueueStatus({ queue_id, }: {
1
+ import { ActionRequest } from '@botonic/react';
2
+ type ConditionalQueueStatusArgs = {
3
+ request: ActionRequest;
2
4
  queue_id: string;
3
- }): Promise<string>;
5
+ queue_name: string;
6
+ };
7
+ export declare function conditionalQueueStatus({ request, queue_id, queue_name, }: ConditionalQueueStatusArgs): Promise<string>;
8
+ export {};
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.conditionalQueueStatus = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const helpers_1 = require("../helpers");
6
7
  const utils_1 = require("../utils");
7
8
  const _HUBTYPE_API_URL_ = (0, utils_1.getWebpackEnvVar)(
8
9
  // @ts-ignore
9
10
  typeof HUBTYPE_API_URL !== 'undefined' && HUBTYPE_API_URL, 'HUBTYPE_API_URL', 'https://api.hubtype.com');
10
- async function conditionalQueueStatus({ queue_id, }) {
11
+ async function conditionalQueueStatus({ request, queue_id, queue_name, }) {
11
12
  const response = await axios_1.default.get(`${_HUBTYPE_API_URL_}/v1/queues/${queue_id}/availability/`,
12
13
  // TODO: Make it configurable in the future
13
14
  {
@@ -18,6 +19,15 @@ async function conditionalQueueStatus({ queue_id, }) {
18
19
  },
19
20
  });
20
21
  const isAvailable = response.data.available;
22
+ const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
23
+ if (flowBuilderPlugin.trackEvent) {
24
+ const eventName = `QUEUE_${isAvailable ? 'OPEN' : 'CLOSED'}`;
25
+ const args = {
26
+ queue_id,
27
+ queue_name,
28
+ };
29
+ await flowBuilderPlugin.trackEvent(request, eventName, args);
30
+ }
21
31
  return isAvailable ? 'open' : 'closed';
22
32
  }
23
33
  exports.conditionalQueueStatus = conditionalQueueStatus;
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AAEzB,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,IAAA,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GAGT;IACC,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAlBD,wDAkBC"}
1
+ {"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AACA,0DAAyB;AAEzB,wCAAiD;AACjD,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,IAAA,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAQM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,OAAO,EACP,QAAQ,EACR,UAAU,GACiB;IAC3B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAE3C,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;QAChC,MAAM,SAAS,GAAG,SAAS,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC5D,MAAM,IAAI,GAAG;YACX,QAAQ;YACR,UAAU;SACX,CAAA;QACD,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;KAC7D;IAED,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AA7BD,wDA6BC"}
@@ -1,3 +1,3 @@
1
1
  import { ActionRequest } from '@botonic/react';
2
- import { HandoffNode } from './flow-builder-models';
3
- export declare function doHandoff(request: ActionRequest, locale: string, handoffNode: HandoffNode): Promise<void>;
2
+ import { HtHandoffNode } from './content-fields/hubtype-fields';
3
+ export declare function doHandoff(request: ActionRequest, locale: string, handoffNode: HtHandoffNode): Promise<void>;
@@ -4,13 +4,14 @@ exports.doHandoff = void 0;
4
4
  const core_1 = require("@botonic/core");
5
5
  const helpers_1 = require("./helpers");
6
6
  async function doHandoff(request, locale, handoffNode) {
7
+ const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
7
8
  // @ts-ignore
8
9
  const handOffBuilder = new core_1.HandOffBuilder(request.session);
9
10
  const handoffQueues = handoffNode.content.queue;
10
11
  const queueFound = handoffQueues.find(q => q.locale === locale);
11
12
  if (queueFound)
12
13
  handOffBuilder.withQueue(queueFound.id);
13
- const onFinishPayload = await getOnFinishPayload(handoffNode, locale, request);
14
+ const onFinishPayload = await getOnFinishPayload(flowBuilderPlugin, handoffNode, locale);
14
15
  if (onFinishPayload)
15
16
  handOffBuilder.withOnFinishPayload(onFinishPayload);
16
17
  if (handoffNode.content.has_auto_assign) {
@@ -28,18 +29,25 @@ async function doHandoff(request, locale, handoffNode) {
28
29
  // handOffBuilder.withAgentEmail(handoffParams.agentEmail)
29
30
  // }
30
31
  await handOffBuilder.handOff();
32
+ if (flowBuilderPlugin.trackEvent) {
33
+ await flowBuilderPlugin.trackEvent(request, 'HANDOFF_SUCCESSFULL', {
34
+ queue_id: queueFound === null || queueFound === void 0 ? void 0 : queueFound.id,
35
+ queue_name: queueFound === null || queueFound === void 0 ? void 0 : queueFound.name,
36
+ });
37
+ }
31
38
  }
32
39
  exports.doHandoff = doHandoff;
33
- async function getOnFinishPayload(handoffNode, locale, request) {
34
- var _a, _b;
35
- const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
36
- const handoffTargetNode = await flowBuilderPlugin.getHandoffContent((_a = handoffNode.target) === null || _a === void 0 ? void 0 : _a.id);
37
- if (handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id)
38
- return handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id;
39
- const payloadId = (_b = handoffNode.content.payload.find(payload => payload.locale === locale)) === null || _b === void 0 ? void 0 : _b.id;
40
+ async function getOnFinishPayload(flowBuilderPlugin, handoffNode, locale) {
41
+ var _a, _b, _c;
42
+ if ((_a = handoffNode.target) === null || _a === void 0 ? void 0 : _a.id) {
43
+ const handoffTargetNode = flowBuilderPlugin.cmsApi.getNode((_b = handoffNode.target) === null || _b === void 0 ? void 0 : _b.id);
44
+ if (handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id)
45
+ return handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id;
46
+ }
47
+ const payloadId = (_c = handoffNode.content.payload.find(payload => payload.locale === locale)) === null || _c === void 0 ? void 0 : _c.id;
40
48
  if (!payloadId)
41
49
  return undefined;
42
- const actionPayload = await flowBuilderPlugin.getContent(payloadId);
50
+ const actionPayload = flowBuilderPlugin.cmsApi.getNode(payloadId);
43
51
  return actionPayload.content.payload;
44
52
  }
45
53
  //# sourceMappingURL=handoff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAI9C,uCAAgD;AAEzC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,MAAc,EACd,WAAwB;IAExB,aAAa;IACb,MAAM,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1D,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;IAC/C,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;IAC/D,IAAI,UAAU;QAAE,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAEvD,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9E,IAAI,eAAe;QAAE,cAAc,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAA;IACxE,IAAI,WAAW,CAAC,OAAO,CAAC,eAAe,EAAE;QACvC,cAAc,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAA;KAC7C;IAED,yCAAyC;IACzC,0BAA0B;IAC1B,kCAAkC;IAClC,4EAA4E;IAC5E,IAAI;IAEJ,4BAA4B;IAC5B,gDAAgD;IAChD,IAAI;IAEJ,kCAAkC;IAClC,4DAA4D;IAC5D,IAAI;IAEJ,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;AAChC,CAAC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AED,MAAM,SAAS,GAAG,MAAA,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAChD,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CACrC,0CAAE,EAAE,CAAA;IAEL,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAA;IAEhC,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAEjE,OAAQ,aAA+B,CAAC,OAAO,CAAC,OAAO,CAAA;AACzD,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from '@botonic/core';
2
+ import { HtHandoffNode, HtNodeWithContent } from './content-fields/hubtype-fields';
2
3
  import BotonicPluginFlowBuilder from './index';
3
4
  export declare function getFlowBuilderPlugin(plugins: {
4
5
  [id: string]: Plugin;
5
6
  }): BotonicPluginFlowBuilder;
6
- export declare function updateButtonUrls(hubtypeContent: any, contentKey: string, getContentFn: any): Promise<void>;
7
+ export declare function isHandoffNode(node: HtNodeWithContent): node is HtHandoffNode;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateButtonUrls = exports.getFlowBuilderPlugin = void 0;
3
+ exports.isHandoffNode = exports.getFlowBuilderPlugin = void 0;
4
+ const hubtype_fields_1 = require("./content-fields/hubtype-fields");
4
5
  const FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder';
5
6
  function getFlowBuilderPlugin(plugins) {
6
7
  const flowBuilderPlugin = Object.values(plugins).find(
@@ -11,17 +12,8 @@ function getFlowBuilderPlugin(plugins) {
11
12
  return flowBuilderPlugin;
12
13
  }
13
14
  exports.getFlowBuilderPlugin = getFlowBuilderPlugin;
14
- async function updateButtonUrls(hubtypeContent, contentKey, getContentFn) {
15
- if (hubtypeContent.content[contentKey]) {
16
- for (const i in hubtypeContent.content[contentKey]) {
17
- const button = hubtypeContent.content[contentKey][i].button;
18
- if (button === null || button === void 0 ? void 0 : button.url) {
19
- for (const j in button.url) {
20
- button.url[j] = Object.assign(Object.assign({}, button.url[j]), (await getContentFn(button.url[j].id)));
21
- }
22
- }
23
- }
24
- }
15
+ function isHandoffNode(node) {
16
+ return node.type === hubtype_fields_1.HtNodeWithContentType.HANDOFF;
25
17
  }
26
- exports.updateButtonUrls = updateButtonUrls;
18
+ exports.isHandoffNode = isHandoffNode;
27
19
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAIA,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,SAAgB,oBAAoB,CAAC,OAEpC;IACC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;IACnD,aAAa;IACb,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAC7B,CAAA;IAC7B,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;IACH,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAZD,oDAYC;AAEM,KAAK,UAAU,gBAAgB,CACpC,cAAmB,EACnB,UAAkB,EAClB,YAAiB;IAEjB,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACtC,KAAK,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAClD,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;YAC3D,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE;gBACf,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE;oBAC1B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,mCACR,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GACb,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAC1C,CAAA;iBACF;aACF;SACF;KACF;AACH,CAAC;AAlBD,4CAkBC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAEA,oEAIwC;AAGxC,MAAM,wBAAwB,GAAG,0BAA0B,CAAA;AAE3D,SAAgB,oBAAoB,CAAC,OAEpC;IACC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI;IACnD,aAAa;IACb,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAC7B,CAAA;IAC7B,IAAI,CAAC,iBAAiB;QACpB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;IACH,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAZD,oDAYC;AAED,SAAgB,aAAa,CAAC,IAAuB;IACnD,OAAO,IAAI,CAAC,IAAI,KAAK,sCAAqB,CAAC,OAAO,CAAA;AACpD,CAAC;AAFD,sCAEC"}
@@ -1,36 +1,25 @@
1
- import { Input, Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
1
+ import { Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
2
+ import { ActionRequest } from '@botonic/react';
3
+ import { FlowBuilderApi } from './api';
2
4
  import { FlowContent } from './content-fields';
3
- import { FlowBuilderData, FunctionNode, HandoffNode, IntentNode, KeywordNode, NodeComponent } from './flow-builder-models';
5
+ import { HtFunctionNode, HtHandoffNode, HtNodeWithContent } from './content-fields/hubtype-fields';
4
6
  import { BotonicPluginFlowBuilderOptions } from './types';
5
7
  export default class BotonicPluginFlowBuilder implements Plugin {
6
8
  readonly options: BotonicPluginFlowBuilderOptions;
7
- private flowUrl;
8
- private flow;
9
+ cmsApi: FlowBuilderApi;
9
10
  private functions;
10
11
  private currentRequest;
11
12
  private getAccessToken;
12
13
  getLocale: (session: Session) => string;
14
+ trackEvent?: (request: ActionRequest, eventName: string, args?: Record<string, any>) => Promise<void>;
13
15
  constructor(options: BotonicPluginFlowBuilderOptions);
14
- readFlowContent(session: Session): Promise<FlowBuilderData>;
15
16
  pre(request: PluginPreRequest): Promise<void>;
16
17
  post(_request: PluginPostRequest): Promise<void>;
17
- getContent(id: string): Promise<NodeComponent>;
18
- getContentByCode(code: string): Promise<NodeComponent>;
19
- getHandoffContent(handoffTargetId: string | undefined): Promise<HandoffNode | undefined>;
20
- getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
21
- getStartId(): Promise<string>;
22
- getFallbackId(alternate: boolean): Promise<string>;
23
- getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<{
18
+ getContent(nodeOrId: HtNodeWithContent | string, locale: string, prevContents?: FlowContent[]): Promise<{
24
19
  contents: FlowContent[];
25
- handoffNode: HandoffNode;
20
+ handoffNode?: HtHandoffNode;
26
21
  }>;
27
- private replaceButtonPayload;
28
- getPayloadByIntent(input: Input, locale: string): Promise<string | undefined>;
29
- hasIntent(node: IntentNode, intent: string, locale: string): boolean;
30
- hasMetConfidenceThreshold(node: IntentNode, predictedConfidence: number): boolean;
31
- getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
32
- matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
33
- containsAnyKeywords(input: string, keywords: string[]): boolean;
34
- callFunction(functionNode: FunctionNode, locale: string): Promise<string>;
22
+ private getFlowContent;
23
+ callFunction(functionNode: HtFunctionNode, locale: string): Promise<string>;
35
24
  }
36
25
  export * from './action';
package/lib/cjs/index.js CHANGED
@@ -1,180 +1,65 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const axios_1 = tslib_1.__importDefault(require("axios"));
4
+ const api_1 = require("./api");
5
5
  const content_fields_1 = require("./content-fields");
6
- const flow_builder_models_1 = require("./flow-builder-models");
6
+ const hubtype_fields_1 = require("./content-fields/hubtype-fields");
7
7
  const functions_1 = require("./functions");
8
8
  const helpers_1 = require("./helpers");
9
9
  const utils_1 = require("./utils");
10
10
  class BotonicPluginFlowBuilder {
11
11
  constructor(options) {
12
12
  this.options = options;
13
+ this.cmsApi = new api_1.FlowBuilderApi({
14
+ url: options.flowUrl,
15
+ flow: options.flow,
16
+ });
13
17
  this.getLocale = options.getLocale;
14
18
  this.getAccessToken = (0, utils_1.resolveGetAccessToken)(options);
15
- this.flowUrl = options.flowUrl;
16
- if (options.flow)
17
- this.flow = options.flow;
19
+ this.trackEvent = options.trackEvent;
18
20
  const customFunctions = options.customFunctions || {};
19
21
  this.functions = Object.assign(Object.assign({}, functions_1.DEFAULT_FUNCTIONS), customFunctions);
20
22
  }
21
- async readFlowContent(session) {
22
- const { data } = await axios_1.default.get(this.flowUrl, {
23
- headers: { Authorization: `Bearer ${this.getAccessToken(session)}` },
24
- });
25
- return data;
26
- }
27
23
  async pre(request) {
28
24
  this.currentRequest = request;
29
- this.flow = await this.readFlowContent(this.currentRequest.session);
25
+ await this.cmsApi.init(this.getAccessToken(request.session));
30
26
  }
31
27
  async post(_request) { }
32
- async getContent(id) {
33
- const flow = await this.flow;
34
- const content = flow.nodes.find(node => node.id === id);
35
- if (!content)
36
- throw Error(`Node with id: '${id}' not found`);
37
- return content;
38
- }
39
- async getContentByCode(code) {
40
- const flow = await this.flow;
41
- const content = flow.nodes.find(node => {
42
- if ('code' in node)
43
- return node.code === code;
44
- return undefined;
45
- });
46
- if (!content)
47
- throw Error(`Node with code: '${code}' not found`);
48
- return content;
49
- }
50
- async getHandoffContent(handoffTargetId) {
51
- if (!handoffTargetId)
52
- return undefined;
53
- return (await this.getContent(handoffTargetId));
54
- }
55
- getFlowContent(hubtypeContent, locale) {
56
- switch (hubtypeContent.type) {
57
- case flow_builder_models_1.NodeType.TEXT:
58
- return content_fields_1.FlowText.fromHubtypeCMS(hubtypeContent, locale);
59
- case flow_builder_models_1.NodeType.IMAGE:
60
- return content_fields_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
61
- case flow_builder_models_1.NodeType.CAROUSEL:
62
- return content_fields_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
63
- case flow_builder_models_1.NodeType.VIDEO:
64
- return content_fields_1.FlowVideo.fromHubtypeCMS(hubtypeContent, locale);
65
- default:
66
- return undefined;
67
- }
68
- }
69
- async getStartId() {
70
- const flow = await this.flow;
71
- const startNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.START_UP);
72
- if (!startNode)
73
- throw new Error('start-up id must be defined');
74
- return startNode.target.id;
75
- }
76
- async getFallbackId(alternate) {
77
- const flow = await this.flow;
78
- const fallbackNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.FALLBACK);
79
- if (!fallbackNode)
80
- throw new Error('fallback node must be defined');
81
- const fallbackFirstMessage = fallbackNode.content.first_message;
82
- const fallbackSecondMessage = fallbackNode.content.second_message;
83
- if (!fallbackSecondMessage)
84
- return fallbackFirstMessage.id;
85
- return alternate ? fallbackFirstMessage.id : fallbackSecondMessage.id;
86
- }
87
- async getContents(id, locale, prevContents) {
28
+ async getContent(nodeOrId, locale, prevContents) {
88
29
  const contents = prevContents || [];
89
- const hubtypeContent = await this.getContent(id);
90
- const isHandoff = hubtypeContent.type === flow_builder_models_1.NodeType.HANDOFF;
91
- // TODO: Create function to populate these buttons
92
- await (0, helpers_1.updateButtonUrls)(hubtypeContent, 'elements', this.getContent);
93
- await (0, helpers_1.updateButtonUrls)(hubtypeContent, 'buttons', this.getContent);
94
- const content = this.getFlowContent(hubtypeContent, locale);
95
- this.replaceButtonPayload(content);
96
- if (hubtypeContent.type === flow_builder_models_1.NodeType.FUNCTION) {
97
- const targetId = await this.callFunction(hubtypeContent, locale);
98
- return this.getContents(targetId, locale, contents);
30
+ let node = nodeOrId;
31
+ if (typeof nodeOrId === 'string') {
32
+ node = this.cmsApi.getNode(nodeOrId);
33
+ }
34
+ const content = await this.getFlowContent(node, locale);
35
+ if (node.type === hubtype_fields_1.HtNodeWithContentType.FUNCTION) {
36
+ const targetId = await this.callFunction(node, locale);
37
+ return this.getContent(targetId, locale, contents);
99
38
  }
100
39
  else {
101
40
  if (content)
102
41
  contents.push(content);
103
42
  // TODO: prevent infinite recursive calls
104
- if (hubtypeContent.follow_up)
105
- return this.getContents(hubtypeContent.follow_up.id, locale, contents);
43
+ if (node.follow_up)
44
+ return this.getContent(node.follow_up.id, locale, contents);
106
45
  }
107
- // execute function
108
- // return this.getContents(function result_mapping target, locale, contents)
109
- return { contents, handoffNode: isHandoff && hubtypeContent };
46
+ return { contents, handoffNode: (0, helpers_1.isHandoffNode)(node) ? node : undefined };
110
47
  }
111
- async replaceButtonPayload(content) {
112
- if (content && 'buttons' in content) {
113
- for (const button of content.buttons) {
114
- if (button.payload) {
115
- const contentButton = await this.getContent(button.payload);
116
- if ((contentButton === null || contentButton === void 0 ? void 0 : contentButton.type) === flow_builder_models_1.NodeType.PAYLOAD) {
117
- button.payload = contentButton.content.payload;
118
- }
119
- }
120
- }
121
- }
122
- }
123
- async getPayloadByIntent(input, locale) {
124
- var _a;
125
- try {
126
- const flow = await this.flow;
127
- const intents = flow.nodes.filter(node => node.type === flow_builder_models_1.NodeType.INTENT);
128
- const inputIntent = input.intent;
129
- const inputConfidence = input.confidence;
130
- if (inputIntent) {
131
- const matchedIntentNode = intents.find(node => inputIntent &&
132
- this.hasIntent(node, inputIntent, locale) &&
133
- inputConfidence &&
134
- this.hasMetConfidenceThreshold(node, inputConfidence));
135
- return (_a = matchedIntentNode === null || matchedIntentNode === void 0 ? void 0 : matchedIntentNode.target) === null || _a === void 0 ? void 0 : _a.id;
136
- }
137
- }
138
- catch (error) {
139
- console.error('Error getting payload by input: ', error);
140
- }
141
- return undefined;
142
- }
143
- hasIntent(node, intent, locale) {
144
- return node.content.intents.some(i => i.locale === locale && i.values.includes(intent));
145
- }
146
- hasMetConfidenceThreshold(node, predictedConfidence) {
147
- const nodeConfidence = node.content.confidence / 100;
148
- return predictedConfidence >= nodeConfidence;
149
- }
150
- async getPayloadByKeyword(input, locale) {
151
- var _a;
152
- try {
153
- const flow = await this.flow;
154
- const keywordNodes = flow.nodes.filter(node => node.type == flow_builder_models_1.NodeType.KEYWORD);
155
- const matchedKeywordNodes = keywordNodes.filter(node =>
156
- //@ts-ignore
157
- this.matchKeywords(node, input.data, locale));
158
- if (matchedKeywordNodes.length > 0) {
159
- return (_a = matchedKeywordNodes[0].target) === null || _a === void 0 ? void 0 : _a.id;
160
- }
161
- }
162
- catch (error) {
163
- console.error('Error getting payload by input: ', error);
164
- }
165
- return undefined;
166
- }
167
- matchKeywords(node, input, locale) {
168
- const result = node.content.keywords.find(i => i.locale === locale && this.containsAnyKeywords(input, i.values));
169
- return Boolean(result);
170
- }
171
- containsAnyKeywords(input, keywords) {
172
- for (let i = 0; i < keywords.length; i++) {
173
- if (input.includes(keywords[i])) {
174
- return true;
175
- }
48
+ getFlowContent(hubtypeContent, locale) {
49
+ switch (hubtypeContent.type) {
50
+ case hubtype_fields_1.HtNodeWithContentType.TEXT:
51
+ return content_fields_1.FlowText.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi);
52
+ case hubtype_fields_1.HtNodeWithContentType.IMAGE:
53
+ return content_fields_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
54
+ case hubtype_fields_1.HtNodeWithContentType.CAROUSEL:
55
+ return content_fields_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale, this.cmsApi);
56
+ case hubtype_fields_1.HtNodeWithContentType.VIDEO:
57
+ return content_fields_1.FlowVideo.fromHubtypeCMS(hubtypeContent, locale);
58
+ case hubtype_fields_1.HtNodeWithContentType.WHATSAPP_BUTTON_LIST:
59
+ return content_fields_1.FlowWhatsappButtonList.fromHubtypeCMS(hubtypeContent, locale);
60
+ default:
61
+ return undefined;
176
62
  }
177
- return false;
178
63
  }
179
64
  async callFunction(functionNode, locale) {
180
65
  var _a;
@@ -182,13 +67,13 @@ class BotonicPluginFlowBuilder {
182
67
  const nameValues = ((_a = functionNode.content.arguments
183
68
  .find(arg => arg.locale === locale)) === null || _a === void 0 ? void 0 : _a.values.map(value => ({ [value.name]: value.value }))) || [];
184
69
  const args = Object.assign({
185
- session: this.currentRequest.session,
70
+ request: this.currentRequest,
186
71
  results: [functionNode.content.result_mapping.map(r => r.result)],
187
72
  }, ...nameValues);
188
73
  const functionResult = await this.functions[functionNode.content.action](args);
189
74
  // TODO define result_mapping per locale??
190
75
  const result = functionNode.content.result_mapping.find(r => r.result === functionResult);
191
- if (!result) {
76
+ if (!(result === null || result === void 0 ? void 0 : result.target)) {
192
77
  throw new Error(`No result found for result_mapping for node with id: ${functionNodeId}`);
193
78
  }
194
79
  return result.target.id;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAOA,0DAAyB;AAEzB,qDAMyB;AACzB,+DAU8B;AAC9B,2CAA+C;AAC/C,uCAA4C;AAE5C,mCAA+C;AAE/C,MAAqB,wBAAwB;IAQ3C,YAAqB,OAAwC;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAClC,IAAI,CAAC,cAAc,GAAG,IAAA,6BAAqB,EAAC,OAAO,CAAC,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,OAAO,CAAC,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAC1C,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,SAAS,mCAAQ,6BAAiB,GAAK,eAAe,CAAE,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,MAAM,EA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EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,KAAI,EAAE,CAAA;QAEhE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB;YACE,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;SAClE,EACD,GAAG,UAAU,CACd,CAAA;QACD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CACtE,IAAI,CACL,CAAA;QACD,0CAA0C;QAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CACrD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CACjC,CAAA;QACD,IAAI,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,CAAA,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,wDAAwD,cAAc,EAAE,CACzE,CAAA;SACF;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;IACzB,CAAC;CACF;AA7GD,2CA6GC;AAED,mDAAwB"}
@@ -1,11 +1,17 @@
1
1
  import { Session } from '@botonic/core';
2
- import { FlowBuilderData } from './flow-builder-models';
2
+ import { ActionRequest } from '@botonic/react';
3
+ import { HtFlowBuilderData } from './content-fields/hubtype-fields';
3
4
  export interface BotonicPluginFlowBuilderOptions {
4
5
  flowUrl: string;
5
- flow?: FlowBuilderData;
6
+ flow?: HtFlowBuilderData;
6
7
  customFunctions?: Record<any, any>;
7
8
  getLocale: (session: Session) => string;
8
9
  getAccessToken: () => string;
10
+ trackEvent?: (request: ActionRequest, eventName: string, args?: Record<string, any>) => Promise<void>;
11
+ }
12
+ export interface FlowBuilderApiOptions {
13
+ url: string;
14
+ flow?: HtFlowBuilderData;
9
15
  }
10
16
  export declare enum ProcessEnvNodeEnvs {
11
17
  PRODUCTION = "production",
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAYA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAwBA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,iDAA2B,CAAA;AAC7B,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B"}