@botonic/plugin-flow-builder 0.22.0-alpha.2 → 0.22.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 (256) hide show
  1. package/lib/cjs/action.js +14 -12
  2. package/lib/cjs/action.js.map +1 -1
  3. package/lib/cjs/api.d.ts +19 -0
  4. package/lib/cjs/api.js +108 -0
  5. package/lib/cjs/api.js.map +1 -0
  6. package/lib/cjs/content-fields/content-fields-base.d.ts +4 -4
  7. package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
  8. package/lib/cjs/content-fields/flow-button.d.ts +6 -3
  9. package/lib/cjs/content-fields/flow-button.js +28 -21
  10. package/lib/cjs/content-fields/flow-button.js.map +1 -1
  11. package/lib/cjs/content-fields/flow-carousel.d.ts +3 -2
  12. package/lib/cjs/content-fields/flow-carousel.js +3 -10
  13. package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
  14. package/lib/cjs/content-fields/flow-element.d.ts +6 -3
  15. package/lib/cjs/content-fields/flow-element.js +16 -5
  16. package/lib/cjs/content-fields/flow-element.js.map +1 -1
  17. package/lib/cjs/content-fields/flow-image.d.ts +2 -2
  18. package/lib/cjs/content-fields/flow-image.js.map +1 -1
  19. package/lib/cjs/content-fields/flow-text.d.ts +4 -3
  20. package/lib/cjs/content-fields/flow-text.js +9 -9
  21. package/lib/cjs/content-fields/flow-text.js.map +1 -1
  22. package/lib/cjs/content-fields/flow-video.d.ts +2 -2
  23. package/lib/cjs/content-fields/flow-video.js +0 -1
  24. package/lib/cjs/content-fields/flow-video.js.map +1 -1
  25. package/lib/cjs/content-fields/hubtype-fields/button.d.ts +9 -0
  26. package/lib/cjs/content-fields/hubtype-fields/button.js +3 -0
  27. package/lib/cjs/content-fields/hubtype-fields/button.js.map +1 -0
  28. package/lib/cjs/content-fields/hubtype-fields/carousel.d.ts +16 -0
  29. package/lib/cjs/content-fields/hubtype-fields/carousel.js +3 -0
  30. package/lib/cjs/content-fields/hubtype-fields/carousel.js.map +1 -0
  31. package/lib/cjs/content-fields/hubtype-fields/common.d.ts +55 -0
  32. package/lib/cjs/content-fields/hubtype-fields/common.js +3 -0
  33. package/lib/cjs/content-fields/hubtype-fields/common.js.map +1 -0
  34. package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +9 -0
  35. package/lib/cjs/content-fields/hubtype-fields/fallback.js +3 -0
  36. package/lib/cjs/content-fields/hubtype-fields/fallback.js.map +1 -0
  37. package/lib/cjs/content-fields/hubtype-fields/function.d.ts +28 -0
  38. package/lib/cjs/content-fields/hubtype-fields/function.js +10 -0
  39. package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -0
  40. package/lib/cjs/content-fields/hubtype-fields/handoff.d.ts +10 -0
  41. package/lib/cjs/content-fields/hubtype-fields/handoff.js +3 -0
  42. package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +1 -0
  43. package/lib/cjs/content-fields/hubtype-fields/image.d.ts +8 -0
  44. package/lib/cjs/content-fields/{types.js → hubtype-fields/image.js} +1 -1
  45. package/lib/cjs/content-fields/hubtype-fields/image.js.map +1 -0
  46. package/lib/cjs/content-fields/hubtype-fields/index.d.ts +17 -0
  47. package/lib/cjs/content-fields/hubtype-fields/index.js +21 -0
  48. package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -0
  49. package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +10 -0
  50. package/lib/cjs/content-fields/hubtype-fields/intent.js +3 -0
  51. package/lib/cjs/content-fields/hubtype-fields/intent.js.map +1 -0
  52. package/lib/cjs/content-fields/hubtype-fields/keyword.d.ts +9 -0
  53. package/lib/cjs/content-fields/hubtype-fields/keyword.js +3 -0
  54. package/lib/cjs/content-fields/hubtype-fields/keyword.js.map +1 -0
  55. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +23 -0
  56. package/lib/cjs/content-fields/hubtype-fields/node-types.js +31 -0
  57. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -0
  58. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +16 -0
  59. package/lib/cjs/content-fields/hubtype-fields/nodes.js +3 -0
  60. package/lib/cjs/content-fields/hubtype-fields/nodes.js.map +1 -0
  61. package/lib/cjs/content-fields/hubtype-fields/payload.d.ts +8 -0
  62. package/lib/cjs/content-fields/hubtype-fields/payload.js +3 -0
  63. package/lib/cjs/content-fields/hubtype-fields/payload.js.map +1 -0
  64. package/lib/cjs/content-fields/hubtype-fields/start.d.ts +7 -0
  65. package/lib/cjs/content-fields/hubtype-fields/start.js +3 -0
  66. package/lib/cjs/content-fields/hubtype-fields/start.js.map +1 -0
  67. package/lib/cjs/content-fields/hubtype-fields/text.d.ts +11 -0
  68. package/lib/cjs/content-fields/hubtype-fields/text.js +3 -0
  69. package/lib/cjs/content-fields/hubtype-fields/text.js.map +1 -0
  70. package/lib/cjs/content-fields/hubtype-fields/url.d.ts +8 -0
  71. package/lib/cjs/content-fields/hubtype-fields/url.js +3 -0
  72. package/lib/cjs/content-fields/hubtype-fields/url.js.map +1 -0
  73. package/lib/cjs/content-fields/hubtype-fields/video.d.ts +8 -0
  74. package/lib/cjs/content-fields/hubtype-fields/video.js +3 -0
  75. package/lib/cjs/content-fields/hubtype-fields/video.js.map +1 -0
  76. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  77. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +3 -0
  78. package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  79. package/lib/cjs/content-fields/index.d.ts +7 -5
  80. package/lib/cjs/content-fields/index.js +11 -9
  81. package/lib/cjs/content-fields/index.js.map +1 -1
  82. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  83. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +32 -0
  84. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  85. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  86. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +29 -0
  87. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  88. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  89. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +33 -0
  90. package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  91. package/lib/cjs/functions/conditional-queue-status.js +1 -3
  92. package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
  93. package/lib/cjs/handoff.d.ts +2 -2
  94. package/lib/cjs/handoff.js +13 -7
  95. package/lib/cjs/handoff.js.map +1 -1
  96. package/lib/cjs/helpers.d.ts +2 -1
  97. package/lib/cjs/helpers.js +5 -13
  98. package/lib/cjs/helpers.js.map +1 -1
  99. package/lib/cjs/index.d.ts +8 -21
  100. package/lib/cjs/index.js +34 -150
  101. package/lib/cjs/index.js.map +1 -1
  102. package/lib/cjs/types.d.ts +6 -2
  103. package/lib/cjs/types.js.map +1 -1
  104. package/lib/esm/action.js +14 -12
  105. package/lib/esm/action.js.map +1 -1
  106. package/lib/esm/api.d.ts +19 -0
  107. package/lib/esm/api.js +103 -0
  108. package/lib/esm/api.js.map +1 -0
  109. package/lib/esm/content-fields/content-fields-base.d.ts +4 -4
  110. package/lib/esm/content-fields/content-fields-base.js.map +1 -1
  111. package/lib/esm/content-fields/flow-button.d.ts +6 -3
  112. package/lib/esm/content-fields/flow-button.js +28 -21
  113. package/lib/esm/content-fields/flow-button.js.map +1 -1
  114. package/lib/esm/content-fields/flow-carousel.d.ts +3 -2
  115. package/lib/esm/content-fields/flow-carousel.js +4 -11
  116. package/lib/esm/content-fields/flow-carousel.js.map +1 -1
  117. package/lib/esm/content-fields/flow-element.d.ts +6 -3
  118. package/lib/esm/content-fields/flow-element.js +15 -5
  119. package/lib/esm/content-fields/flow-element.js.map +1 -1
  120. package/lib/esm/content-fields/flow-image.d.ts +2 -2
  121. package/lib/esm/content-fields/flow-image.js.map +1 -1
  122. package/lib/esm/content-fields/flow-text.d.ts +4 -3
  123. package/lib/esm/content-fields/flow-text.js +9 -9
  124. package/lib/esm/content-fields/flow-text.js.map +1 -1
  125. package/lib/esm/content-fields/flow-video.d.ts +2 -2
  126. package/lib/esm/content-fields/flow-video.js +0 -1
  127. package/lib/esm/content-fields/flow-video.js.map +1 -1
  128. package/lib/esm/content-fields/hubtype-fields/button.d.ts +9 -0
  129. package/lib/esm/content-fields/hubtype-fields/button.js +2 -0
  130. package/lib/esm/content-fields/hubtype-fields/button.js.map +1 -0
  131. package/lib/esm/content-fields/hubtype-fields/carousel.d.ts +16 -0
  132. package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -0
  133. package/lib/esm/content-fields/hubtype-fields/carousel.js.map +1 -0
  134. package/lib/esm/content-fields/hubtype-fields/common.d.ts +55 -0
  135. package/lib/esm/content-fields/hubtype-fields/common.js +2 -0
  136. package/lib/esm/content-fields/hubtype-fields/common.js.map +1 -0
  137. package/lib/esm/content-fields/hubtype-fields/fallback.d.ts +9 -0
  138. package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -0
  139. package/lib/esm/content-fields/hubtype-fields/fallback.js.map +1 -0
  140. package/lib/esm/content-fields/hubtype-fields/function.d.ts +28 -0
  141. package/lib/esm/content-fields/hubtype-fields/function.js +7 -0
  142. package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -0
  143. package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +10 -0
  144. package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -0
  145. package/lib/esm/content-fields/hubtype-fields/handoff.js.map +1 -0
  146. package/lib/esm/content-fields/hubtype-fields/image.d.ts +8 -0
  147. package/lib/esm/content-fields/hubtype-fields/image.js +2 -0
  148. package/lib/esm/content-fields/hubtype-fields/image.js.map +1 -0
  149. package/lib/esm/content-fields/hubtype-fields/index.d.ts +17 -0
  150. package/lib/esm/content-fields/hubtype-fields/index.js +18 -0
  151. package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -0
  152. package/lib/esm/content-fields/hubtype-fields/intent.d.ts +10 -0
  153. package/lib/esm/content-fields/hubtype-fields/intent.js +2 -0
  154. package/lib/esm/content-fields/hubtype-fields/intent.js.map +1 -0
  155. package/lib/esm/content-fields/hubtype-fields/keyword.d.ts +9 -0
  156. package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -0
  157. package/lib/esm/content-fields/hubtype-fields/keyword.js.map +1 -0
  158. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +23 -0
  159. package/lib/esm/content-fields/hubtype-fields/node-types.js +28 -0
  160. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -0
  161. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +16 -0
  162. package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -0
  163. package/lib/esm/content-fields/hubtype-fields/nodes.js.map +1 -0
  164. package/lib/esm/content-fields/hubtype-fields/payload.d.ts +8 -0
  165. package/lib/esm/content-fields/hubtype-fields/payload.js +2 -0
  166. package/lib/esm/content-fields/hubtype-fields/payload.js.map +1 -0
  167. package/lib/esm/content-fields/hubtype-fields/start.d.ts +7 -0
  168. package/lib/esm/content-fields/hubtype-fields/start.js +2 -0
  169. package/lib/esm/content-fields/hubtype-fields/start.js.map +1 -0
  170. package/lib/esm/content-fields/hubtype-fields/text.d.ts +11 -0
  171. package/lib/esm/content-fields/hubtype-fields/text.js +2 -0
  172. package/lib/esm/content-fields/hubtype-fields/text.js.map +1 -0
  173. package/lib/esm/content-fields/hubtype-fields/url.d.ts +8 -0
  174. package/lib/esm/content-fields/hubtype-fields/url.js +2 -0
  175. package/lib/esm/content-fields/hubtype-fields/url.js.map +1 -0
  176. package/lib/esm/content-fields/hubtype-fields/video.d.ts +8 -0
  177. package/lib/esm/content-fields/hubtype-fields/video.js +2 -0
  178. package/lib/esm/content-fields/hubtype-fields/video.js.map +1 -0
  179. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
  180. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -0
  181. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  182. package/lib/esm/content-fields/index.d.ts +7 -5
  183. package/lib/esm/content-fields/index.js +6 -4
  184. package/lib/esm/content-fields/index.js.map +1 -1
  185. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
  186. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +28 -0
  187. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  188. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
  189. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +25 -0
  190. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  191. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
  192. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +28 -0
  193. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  194. package/lib/esm/functions/conditional-queue-status.js +1 -3
  195. package/lib/esm/functions/conditional-queue-status.js.map +1 -1
  196. package/lib/esm/handoff.d.ts +2 -2
  197. package/lib/esm/handoff.js +13 -7
  198. package/lib/esm/handoff.js.map +1 -1
  199. package/lib/esm/helpers.d.ts +2 -1
  200. package/lib/esm/helpers.js +3 -11
  201. package/lib/esm/helpers.js.map +1 -1
  202. package/lib/esm/index.d.ts +8 -21
  203. package/lib/esm/index.js +36 -152
  204. package/lib/esm/index.js.map +1 -1
  205. package/lib/esm/types.d.ts +6 -2
  206. package/lib/esm/types.js.map +1 -1
  207. package/package.json +4 -5
  208. package/src/action.tsx +19 -12
  209. package/src/api.ts +162 -0
  210. package/src/content-fields/content-fields-base.ts +7 -7
  211. package/src/content-fields/flow-button.tsx +40 -19
  212. package/src/content-fields/flow-carousel.tsx +10 -18
  213. package/src/content-fields/flow-element.tsx +26 -9
  214. package/src/content-fields/flow-image.tsx +2 -2
  215. package/src/content-fields/flow-text.tsx +15 -12
  216. package/src/content-fields/flow-video.tsx +2 -3
  217. package/src/content-fields/hubtype-fields/button.ts +15 -0
  218. package/src/content-fields/hubtype-fields/carousel.ts +18 -0
  219. package/src/content-fields/hubtype-fields/common.ts +65 -0
  220. package/src/content-fields/hubtype-fields/fallback.ts +10 -0
  221. package/src/content-fields/hubtype-fields/function.ts +33 -0
  222. package/src/content-fields/hubtype-fields/handoff.ts +11 -0
  223. package/src/content-fields/hubtype-fields/image.ts +9 -0
  224. package/src/content-fields/hubtype-fields/index.ts +17 -0
  225. package/src/content-fields/hubtype-fields/intent.ts +11 -0
  226. package/src/content-fields/hubtype-fields/keyword.ts +10 -0
  227. package/src/content-fields/hubtype-fields/node-types.ts +26 -0
  228. package/src/content-fields/hubtype-fields/nodes.ts +32 -0
  229. package/src/content-fields/hubtype-fields/payload.ts +9 -0
  230. package/src/content-fields/hubtype-fields/start.ts +8 -0
  231. package/src/content-fields/hubtype-fields/text.ts +12 -0
  232. package/src/content-fields/hubtype-fields/url.ts +9 -0
  233. package/src/content-fields/hubtype-fields/video.ts +9 -0
  234. package/src/content-fields/hubtype-fields/whatsapp-button-list.ts +25 -0
  235. package/src/content-fields/index.ts +14 -5
  236. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +33 -0
  237. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +35 -0
  238. package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +46 -0
  239. package/src/functions/conditional-queue-status.ts +1 -3
  240. package/src/handoff.ts +16 -10
  241. package/src/helpers.ts +8 -19
  242. package/src/index.ts +47 -196
  243. package/src/types.ts +8 -2
  244. package/lib/cjs/content-fields/types.d.ts +0 -5
  245. package/lib/cjs/content-fields/types.js.map +0 -1
  246. package/lib/cjs/flow-builder-models.d.ts +0 -197
  247. package/lib/cjs/flow-builder-models.js +0 -24
  248. package/lib/cjs/flow-builder-models.js.map +0 -1
  249. package/lib/esm/content-fields/types.d.ts +0 -5
  250. package/lib/esm/content-fields/types.js +0 -2
  251. package/lib/esm/content-fields/types.js.map +0 -1
  252. package/lib/esm/flow-builder-models.d.ts +0 -197
  253. package/lib/esm/flow-builder-models.js +0 -21
  254. package/lib/esm/flow-builder-models.js.map +0 -1
  255. package/src/content-fields/types.ts +0 -6
  256. package/src/flow-builder-models.ts +0 -249
@@ -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"}
@@ -19,14 +19,12 @@ async function conditionalQueueStatus({ request, queue_id, queue_name, }) {
19
19
  },
20
20
  });
21
21
  const isAvailable = response.data.available;
22
- console.log('conditionalQueueStatus', { data: response.data });
23
22
  const flowBuilderPlugin = (0, helpers_1.getFlowBuilderPlugin)(request.plugins);
24
23
  if (flowBuilderPlugin.trackEvent) {
25
- const eventName = 'QUEUE_STATUS';
24
+ const eventName = `QUEUE_${isAvailable ? 'OPEN' : 'CLOSED'}`;
26
25
  const args = {
27
26
  queue_id,
28
27
  queue_name,
29
- status: isAvailable ? 'open' : 'closed',
30
28
  };
31
29
  await flowBuilderPlugin.trackEvent(request, eventName, args);
32
30
  }
@@ -1 +1 @@
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,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAC9D,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,iBAAiB,CAAC,UAAU,EAAE;QAChC,MAAM,SAAS,GAAG,cAAc,CAAA;QAChC,MAAM,IAAI,GAAG;YACX,QAAQ;YACR,UAAU;YACV,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;SACxC,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;AA/BD,wDA+BC"}
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>;
@@ -14,6 +14,9 @@ async function doHandoff(request, locale, handoffNode) {
14
14
  const onFinishPayload = await getOnFinishPayload(flowBuilderPlugin, handoffNode, locale);
15
15
  if (onFinishPayload)
16
16
  handOffBuilder.withOnFinishPayload(onFinishPayload);
17
+ if (handoffNode.content.has_auto_assign) {
18
+ handOffBuilder.withAutoAssignOnWaiting(true);
19
+ }
17
20
  // TODO: Retrieve params from FlowBuilder
18
21
  // const handoffParams = {
19
22
  // agentEmail: 'test@gmail.com',
@@ -28,20 +31,23 @@ async function doHandoff(request, locale, handoffNode) {
28
31
  await handOffBuilder.handOff();
29
32
  if (flowBuilderPlugin.trackEvent) {
30
33
  await flowBuilderPlugin.trackEvent(request, 'HANDOFF_SUCCESSFULL', {
31
- queueName: queueFound === null || queueFound === void 0 ? void 0 : queueFound.name,
34
+ queue_id: queueFound === null || queueFound === void 0 ? void 0 : queueFound.id,
35
+ queue_name: queueFound === null || queueFound === void 0 ? void 0 : queueFound.name,
32
36
  });
33
37
  }
34
38
  }
35
39
  exports.doHandoff = doHandoff;
36
40
  async function getOnFinishPayload(flowBuilderPlugin, handoffNode, locale) {
37
- var _a, _b;
38
- const handoffTargetNode = await flowBuilderPlugin.getHandoffContent((_a = handoffNode.target) === null || _a === void 0 ? void 0 : _a.id);
39
- if (handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id)
40
- return handoffTargetNode === null || handoffTargetNode === void 0 ? void 0 : handoffTargetNode.id;
41
- const payloadId = (_b = handoffNode.content.payload.find(payload => payload.locale === locale)) === null || _b === void 0 ? void 0 : _b.id;
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;
42
48
  if (!payloadId)
43
49
  return undefined;
44
- const actionPayload = await flowBuilderPlugin.getContent(payloadId);
50
+ const actionPayload = flowBuilderPlugin.cmsApi.getNode(payloadId);
45
51
  return actionPayload.content.payload;
46
52
  }
47
53
  //# sourceMappingURL=handoff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAI9C,uCAAgD;AAGzC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,MAAc,EACd,WAAwB;IAExB,MAAM,iBAAiB,GAAG,IAAA,8BAAoB,EAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,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,CAC9C,iBAAiB,EACjB,WAAW,EACX,MAAM,CACP,CAAA;IACD,IAAI,eAAe;QAAE,cAAc,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAA;IAExE,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;IAE9B,IAAI,iBAAiB,CAAC,UAAU,EAAE;QAChC,MAAM,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE;YACjE,SAAS,EAAE,UAAU,aAAV,UAAU,uBAAV,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AA,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,38 +1,25 @@
1
- import { Input, Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
1
+ import { Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
2
2
  import { ActionRequest } from '@botonic/react';
3
+ import { FlowBuilderApi } from './api';
3
4
  import { FlowContent } from './content-fields';
4
- import { FlowBuilderData, FunctionNode, HandoffNode, IntentNode, KeywordNode, NodeComponent } from './flow-builder-models';
5
+ import { HtFunctionNode, HtHandoffNode, HtNodeWithContent } from './content-fields/hubtype-fields';
5
6
  import { BotonicPluginFlowBuilderOptions } from './types';
6
7
  export default class BotonicPluginFlowBuilder implements Plugin {
7
8
  readonly options: BotonicPluginFlowBuilderOptions;
8
- private flowUrl;
9
- private flow;
9
+ cmsApi: FlowBuilderApi;
10
10
  private functions;
11
11
  private currentRequest;
12
12
  private getAccessToken;
13
13
  getLocale: (session: Session) => string;
14
14
  trackEvent?: (request: ActionRequest, eventName: string, args?: Record<string, any>) => Promise<void>;
15
15
  constructor(options: BotonicPluginFlowBuilderOptions);
16
- readFlowContent(session: Session): Promise<FlowBuilderData>;
17
16
  pre(request: PluginPreRequest): Promise<void>;
18
17
  post(_request: PluginPostRequest): Promise<void>;
19
- getContent(id: string): Promise<NodeComponent>;
20
- getContentByCode(code: string): Promise<NodeComponent>;
21
- getHandoffContent(handoffTargetId: string | undefined): Promise<HandoffNode | undefined>;
22
- getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
23
- getStartId(): Promise<string>;
24
- getFallbackId(alternate: boolean): Promise<string>;
25
- getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<{
18
+ getContent(nodeOrId: HtNodeWithContent | string, locale: string, prevContents?: FlowContent[]): Promise<{
26
19
  contents: FlowContent[];
27
- handoffNode: HandoffNode;
20
+ handoffNode?: HtHandoffNode;
28
21
  }>;
29
- private replaceButtonPayload;
30
- getPayloadByIntent(input: Input, locale: string): Promise<string | undefined>;
31
- hasIntent(node: IntentNode, intent: string, locale: string): boolean;
32
- hasMetConfidenceThreshold(node: IntentNode, predictedConfidence: number): boolean;
33
- getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
34
- matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
35
- containsAnyKeywords(input: string, keywords: string[]): boolean;
36
- callFunction(functionNode: FunctionNode, locale: string): Promise<string>;
22
+ private getFlowContent;
23
+ callFunction(functionNode: HtFunctionNode, locale: string): Promise<string>;
37
24
  }
38
25
  export * from './action';
package/lib/cjs/index.js CHANGED
@@ -1,181 +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
19
  this.trackEvent = options.trackEvent;
16
- this.flowUrl = options.flowUrl;
17
- if (options.flow)
18
- this.flow = options.flow;
19
20
  const customFunctions = options.customFunctions || {};
20
21
  this.functions = Object.assign(Object.assign({}, functions_1.DEFAULT_FUNCTIONS), customFunctions);
21
22
  }
22
- async readFlowContent(session) {
23
- const { data } = await axios_1.default.get(this.flowUrl, {
24
- headers: { Authorization: `Bearer ${this.getAccessToken(session)}` },
25
- });
26
- return data;
27
- }
28
23
  async pre(request) {
29
24
  this.currentRequest = request;
30
- this.flow = await this.readFlowContent(this.currentRequest.session);
25
+ await this.cmsApi.init(this.getAccessToken(request.session));
31
26
  }
32
27
  async post(_request) { }
33
- async getContent(id) {
34
- const flow = await this.flow;
35
- const content = flow.nodes.find(node => node.id === id);
36
- if (!content)
37
- throw Error(`Node with id: '${id}' not found`);
38
- return content;
39
- }
40
- async getContentByCode(code) {
41
- const flow = await this.flow;
42
- const content = flow.nodes.find(node => {
43
- if ('code' in node)
44
- return node.code === code;
45
- return undefined;
46
- });
47
- if (!content)
48
- throw Error(`Node with code: '${code}' not found`);
49
- return content;
50
- }
51
- async getHandoffContent(handoffTargetId) {
52
- if (!handoffTargetId)
53
- return undefined;
54
- return (await this.getContent(handoffTargetId));
55
- }
56
- getFlowContent(hubtypeContent, locale) {
57
- switch (hubtypeContent.type) {
58
- case flow_builder_models_1.NodeType.TEXT:
59
- return content_fields_1.FlowText.fromHubtypeCMS(hubtypeContent, locale);
60
- case flow_builder_models_1.NodeType.IMAGE:
61
- return content_fields_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
62
- case flow_builder_models_1.NodeType.CAROUSEL:
63
- return content_fields_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
64
- case flow_builder_models_1.NodeType.VIDEO:
65
- return content_fields_1.FlowVideo.fromHubtypeCMS(hubtypeContent, locale);
66
- default:
67
- return undefined;
68
- }
69
- }
70
- async getStartId() {
71
- const flow = await this.flow;
72
- const startNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.START_UP);
73
- if (!startNode)
74
- throw new Error('start-up id must be defined');
75
- return startNode.target.id;
76
- }
77
- async getFallbackId(alternate) {
78
- const flow = await this.flow;
79
- const fallbackNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.FALLBACK);
80
- if (!fallbackNode)
81
- throw new Error('fallback node must be defined');
82
- const fallbackFirstMessage = fallbackNode.content.first_message;
83
- const fallbackSecondMessage = fallbackNode.content.second_message;
84
- if (!fallbackSecondMessage)
85
- return fallbackFirstMessage.id;
86
- return alternate ? fallbackFirstMessage.id : fallbackSecondMessage.id;
87
- }
88
- async getContents(id, locale, prevContents) {
28
+ async getContent(nodeOrId, locale, prevContents) {
89
29
  const contents = prevContents || [];
90
- const hubtypeContent = await this.getContent(id);
91
- const isHandoff = hubtypeContent.type === flow_builder_models_1.NodeType.HANDOFF;
92
- // TODO: Create function to populate these buttons
93
- await (0, helpers_1.updateButtonUrls)(hubtypeContent, 'elements', this.getContent);
94
- await (0, helpers_1.updateButtonUrls)(hubtypeContent, 'buttons', this.getContent);
95
- const content = this.getFlowContent(hubtypeContent, locale);
96
- this.replaceButtonPayload(content);
97
- if (hubtypeContent.type === flow_builder_models_1.NodeType.FUNCTION) {
98
- const targetId = await this.callFunction(hubtypeContent, locale);
99
- 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);
100
38
  }
101
39
  else {
102
40
  if (content)
103
41
  contents.push(content);
104
42
  // TODO: prevent infinite recursive calls
105
- if (hubtypeContent.follow_up)
106
- return this.getContents(hubtypeContent.follow_up.id, locale, contents);
43
+ if (node.follow_up)
44
+ return this.getContent(node.follow_up.id, locale, contents);
107
45
  }
108
- // execute function
109
- // return this.getContents(function result_mapping target, locale, contents)
110
- return { contents, handoffNode: isHandoff && hubtypeContent };
46
+ return { contents, handoffNode: (0, helpers_1.isHandoffNode)(node) ? node : undefined };
111
47
  }
112
- async replaceButtonPayload(content) {
113
- if (content && 'buttons' in content) {
114
- for (const button of content.buttons) {
115
- if (button.payload) {
116
- const contentButton = await this.getContent(button.payload);
117
- if ((contentButton === null || contentButton === void 0 ? void 0 : contentButton.type) === flow_builder_models_1.NodeType.PAYLOAD) {
118
- button.payload = contentButton.content.payload;
119
- }
120
- }
121
- }
122
- }
123
- }
124
- async getPayloadByIntent(input, locale) {
125
- var _a;
126
- try {
127
- const flow = await this.flow;
128
- const intents = flow.nodes.filter(node => node.type === flow_builder_models_1.NodeType.INTENT);
129
- const inputIntent = input.intent;
130
- const inputConfidence = input.confidence;
131
- if (inputIntent) {
132
- const matchedIntentNode = intents.find(node => inputIntent &&
133
- this.hasIntent(node, inputIntent, locale) &&
134
- inputConfidence &&
135
- this.hasMetConfidenceThreshold(node, inputConfidence));
136
- return (_a = matchedIntentNode === null || matchedIntentNode === void 0 ? void 0 : matchedIntentNode.target) === null || _a === void 0 ? void 0 : _a.id;
137
- }
138
- }
139
- catch (error) {
140
- console.error('Error getting payload by input: ', error);
141
- }
142
- return undefined;
143
- }
144
- hasIntent(node, intent, locale) {
145
- return node.content.intents.some(i => i.locale === locale && i.values.includes(intent));
146
- }
147
- hasMetConfidenceThreshold(node, predictedConfidence) {
148
- const nodeConfidence = node.content.confidence / 100;
149
- return predictedConfidence >= nodeConfidence;
150
- }
151
- async getPayloadByKeyword(input, locale) {
152
- var _a;
153
- try {
154
- const flow = await this.flow;
155
- const keywordNodes = flow.nodes.filter(node => node.type == flow_builder_models_1.NodeType.KEYWORD);
156
- const matchedKeywordNodes = keywordNodes.filter(node =>
157
- //@ts-ignore
158
- this.matchKeywords(node, input.data, locale));
159
- if (matchedKeywordNodes.length > 0) {
160
- return (_a = matchedKeywordNodes[0].target) === null || _a === void 0 ? void 0 : _a.id;
161
- }
162
- }
163
- catch (error) {
164
- console.error('Error getting payload by input: ', error);
165
- }
166
- return undefined;
167
- }
168
- matchKeywords(node, input, locale) {
169
- const result = node.content.keywords.find(i => i.locale === locale && this.containsAnyKeywords(input, i.values));
170
- return Boolean(result);
171
- }
172
- containsAnyKeywords(input, keywords) {
173
- for (let i = 0; i < keywords.length; i++) {
174
- if (input.includes(keywords[i])) {
175
- return true;
176
- }
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;
177
62
  }
178
- return false;
179
63
  }
180
64
  async callFunction(functionNode, locale) {
181
65
  var _a;
@@ -189,7 +73,7 @@ class BotonicPluginFlowBuilder {
189
73
  const functionResult = await this.functions[functionNode.content.action](args);
190
74
  // TODO define result_mapping per locale??
191
75
  const result = functionNode.content.result_mapping.find(r => r.result === functionResult);
192
- if (!result) {
76
+ if (!(result === null || result === void 0 ? void 0 : result.target)) {
193
77
  throw new Error(`No result found for result_mapping for node with id: ${functionNodeId}`);
194
78
  }
195
79
  return result.target.id;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAQA,0DAAyB;AAEzB,qDAMyB;AACzB,+DAU8B;AAC9B,2CAA+C;AAC/C,uCAA4C;AAE5C,mCAA+C;AAE/C,MAAqB,wBAAwB;IAa3C,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,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QACpC,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,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;YAC7C,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,EAAE;SACrE,CAAC,CAAA;QACF,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AAC,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,14 +1,18 @@
1
1
  import { Session } from '@botonic/core';
2
2
  import { ActionRequest } from '@botonic/react';
3
- import { FlowBuilderData } from './flow-builder-models';
3
+ import { HtFlowBuilderData } from './content-fields/hubtype-fields';
4
4
  export interface BotonicPluginFlowBuilderOptions {
5
5
  flowUrl: string;
6
- flow?: FlowBuilderData;
6
+ flow?: HtFlowBuilderData;
7
7
  customFunctions?: Record<any, any>;
8
8
  getLocale: (session: Session) => string;
9
9
  getAccessToken: () => string;
10
10
  trackEvent?: (request: ActionRequest, eventName: string, args?: Record<string, any>) => Promise<void>;
11
11
  }
12
+ export interface FlowBuilderApiOptions {
13
+ url: string;
14
+ flow?: HtFlowBuilderData;
15
+ }
12
16
  export declare enum ProcessEnvNodeEnvs {
13
17
  PRODUCTION = "production",
14
18
  DEVELOPMENT = "development"
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAkBA,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"}
package/lib/esm/action.js CHANGED
@@ -8,23 +8,25 @@ export class FlowBuilderAction extends React.Component {
8
8
  const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins);
9
9
  const locale = flowBuilderPlugin.getLocale(request.session);
10
10
  const payload = request.input.payload;
11
- let targetContentId = payload;
11
+ let targetNode = payload;
12
12
  if (!payload && request.session.is_first_interaction) {
13
- targetContentId = await flowBuilderPlugin.getStartId();
13
+ targetNode = flowBuilderPlugin.cmsApi.getStartNode();
14
14
  }
15
- if (!payload) {
16
- const intentPayload = await flowBuilderPlugin.getPayloadByIntent(request.input, locale);
17
- if (intentPayload)
18
- targetContentId = intentPayload;
19
- const keywordPayload = await flowBuilderPlugin.getPayloadByKeyword(request.input, locale);
20
- if (keywordPayload)
21
- targetContentId = keywordPayload;
15
+ if (!payload && request.input.data) {
16
+ const intentNode = flowBuilderPlugin.cmsApi.getNodeByIntent(request.input, locale);
17
+ const keywordNode = flowBuilderPlugin.cmsApi.getNodeByKeyword(request.input.data, locale);
18
+ if (intentNode) {
19
+ targetNode = intentNode;
20
+ }
21
+ else if (keywordNode) {
22
+ targetNode = keywordNode;
23
+ }
22
24
  }
23
- if (!targetContentId) {
24
- targetContentId = await flowBuilderPlugin.getFallbackId(alternateFallbackMessage);
25
+ if (!targetNode) {
26
+ targetNode = flowBuilderPlugin.cmsApi.getFallbackNode(alternateFallbackMessage);
25
27
  alternateFallbackMessage = !alternateFallbackMessage;
26
28
  }
27
- const { contents, handoffNode } = await flowBuilderPlugin.getContents(targetContentId, locale);
29
+ const { contents, handoffNode } = await flowBuilderPlugin.getContent(targetNode, locale);
28
30
  if (flowBuilderPlugin.trackEvent) {
29
31
  // TODO: track all targets nodes?
30
32
  await flowBuilderPlugin.trackEvent(request, contents[0].code);
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAOhD,IAAI,wBAAwB,GAAG,KAAK,CAAA;AACpC,MAAM,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAiC;IAG5E,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAsB;QAC7C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAA;QACrC,IAAI,eAAe,GAAuB,OAAO,CAAA;QACjD,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACpD,eAAe,GAAG,MAAM,iBAAiB,CAAC,UAAU,EAAE,CAAA;SACvD;QACD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,aAAa,GAAG,MAAM,iBAAiB,CAAC,kBAAkB,CAC9D,OAAO,CAAC,KAAK,EACb,MAAM,CACP,CAAA;YACD,IAAI,aAAa;gBAAE,eAAe,GAAG,aAAa,CAAA;YAClD,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,mBAAmB,CACh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ype-fields';
3
+ import { FlowBuilderApiOptions } from './types';
4
+ export declare class FlowBuilderApi {
5
+ private readonly url;
6
+ flow: HtFlowBuilderData;
7
+ constructor(options: FlowBuilderApiOptions);
8
+ init(token: string): Promise<void>;
9
+ getNode<T extends HtNodeComponent>(id: string): T;
10
+ getNodeByCode(code: string): HtNodeComponent;
11
+ getStartNode(): HtNodeWithContent;
12
+ getFallbackNode(alternate: boolean): HtNodeWithContent;
13
+ getNodeByIntent(input: Input, locale: string): HtNodeWithContent | undefined;
14
+ private hasIntent;
15
+ private hasMetConfidenceThreshold;
16
+ getNodeByKeyword(userInput: string, locale: string): HtNodeWithContent | undefined;
17
+ private matchKeywords;
18
+ private containsAnyKeywords;
19
+ }