@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.
- package/lib/cjs/action.js +14 -12
- package/lib/cjs/action.js.map +1 -1
- package/lib/cjs/api.d.ts +19 -0
- package/lib/cjs/api.js +108 -0
- package/lib/cjs/api.js.map +1 -0
- package/lib/cjs/content-fields/content-fields-base.d.ts +4 -4
- package/lib/cjs/content-fields/content-fields-base.js.map +1 -1
- package/lib/cjs/content-fields/flow-button.d.ts +6 -3
- package/lib/cjs/content-fields/flow-button.js +28 -21
- package/lib/cjs/content-fields/flow-button.js.map +1 -1
- package/lib/cjs/content-fields/flow-carousel.d.ts +3 -2
- package/lib/cjs/content-fields/flow-carousel.js +3 -10
- package/lib/cjs/content-fields/flow-carousel.js.map +1 -1
- package/lib/cjs/content-fields/flow-element.d.ts +6 -3
- package/lib/cjs/content-fields/flow-element.js +16 -5
- package/lib/cjs/content-fields/flow-element.js.map +1 -1
- package/lib/cjs/content-fields/flow-image.d.ts +2 -2
- package/lib/cjs/content-fields/flow-image.js.map +1 -1
- package/lib/cjs/content-fields/flow-text.d.ts +4 -3
- package/lib/cjs/content-fields/flow-text.js +9 -9
- package/lib/cjs/content-fields/flow-text.js.map +1 -1
- package/lib/cjs/content-fields/flow-video.d.ts +2 -2
- package/lib/cjs/content-fields/flow-video.js +0 -1
- package/lib/cjs/content-fields/flow-video.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/button.d.ts +9 -0
- package/lib/cjs/content-fields/hubtype-fields/button.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/button.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/carousel.d.ts +16 -0
- package/lib/cjs/content-fields/hubtype-fields/carousel.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/carousel.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/common.d.ts +55 -0
- package/lib/cjs/content-fields/hubtype-fields/common.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/common.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +9 -0
- package/lib/cjs/content-fields/hubtype-fields/fallback.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/fallback.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/function.d.ts +28 -0
- package/lib/cjs/content-fields/hubtype-fields/function.js +10 -0
- package/lib/cjs/content-fields/hubtype-fields/function.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/handoff.d.ts +10 -0
- package/lib/cjs/content-fields/hubtype-fields/handoff.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/image.d.ts +8 -0
- package/lib/cjs/content-fields/{types.js → hubtype-fields/image.js} +1 -1
- package/lib/cjs/content-fields/hubtype-fields/image.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +17 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js +21 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/intent.d.ts +10 -0
- package/lib/cjs/content-fields/hubtype-fields/intent.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/intent.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/keyword.d.ts +9 -0
- package/lib/cjs/content-fields/hubtype-fields/keyword.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/keyword.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +23 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +31 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +16 -0
- package/lib/cjs/content-fields/hubtype-fields/nodes.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/nodes.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/payload.d.ts +8 -0
- package/lib/cjs/content-fields/hubtype-fields/payload.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/payload.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/start.d.ts +7 -0
- package/lib/cjs/content-fields/hubtype-fields/start.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/start.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/text.d.ts +11 -0
- package/lib/cjs/content-fields/hubtype-fields/text.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/text.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/url.d.ts +8 -0
- package/lib/cjs/content-fields/hubtype-fields/url.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/url.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/video.d.ts +8 -0
- package/lib/cjs/content-fields/hubtype-fields/video.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/video.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +3 -0
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
- package/lib/cjs/content-fields/index.d.ts +7 -5
- package/lib/cjs/content-fields/index.js +11 -9
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +32 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +29 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +33 -0
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
- package/lib/cjs/functions/conditional-queue-status.js +1 -3
- package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
- package/lib/cjs/handoff.d.ts +2 -2
- package/lib/cjs/handoff.js +13 -7
- package/lib/cjs/handoff.js.map +1 -1
- package/lib/cjs/helpers.d.ts +2 -1
- package/lib/cjs/helpers.js +5 -13
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/index.d.ts +8 -21
- package/lib/cjs/index.js +34 -150
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.d.ts +6 -2
- package/lib/cjs/types.js.map +1 -1
- package/lib/esm/action.js +14 -12
- package/lib/esm/action.js.map +1 -1
- package/lib/esm/api.d.ts +19 -0
- package/lib/esm/api.js +103 -0
- package/lib/esm/api.js.map +1 -0
- package/lib/esm/content-fields/content-fields-base.d.ts +4 -4
- package/lib/esm/content-fields/content-fields-base.js.map +1 -1
- package/lib/esm/content-fields/flow-button.d.ts +6 -3
- package/lib/esm/content-fields/flow-button.js +28 -21
- package/lib/esm/content-fields/flow-button.js.map +1 -1
- package/lib/esm/content-fields/flow-carousel.d.ts +3 -2
- package/lib/esm/content-fields/flow-carousel.js +4 -11
- package/lib/esm/content-fields/flow-carousel.js.map +1 -1
- package/lib/esm/content-fields/flow-element.d.ts +6 -3
- package/lib/esm/content-fields/flow-element.js +15 -5
- package/lib/esm/content-fields/flow-element.js.map +1 -1
- package/lib/esm/content-fields/flow-image.d.ts +2 -2
- package/lib/esm/content-fields/flow-image.js.map +1 -1
- package/lib/esm/content-fields/flow-text.d.ts +4 -3
- package/lib/esm/content-fields/flow-text.js +9 -9
- package/lib/esm/content-fields/flow-text.js.map +1 -1
- package/lib/esm/content-fields/flow-video.d.ts +2 -2
- package/lib/esm/content-fields/flow-video.js +0 -1
- package/lib/esm/content-fields/flow-video.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/button.d.ts +9 -0
- package/lib/esm/content-fields/hubtype-fields/button.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/button.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/carousel.d.ts +16 -0
- package/lib/esm/content-fields/hubtype-fields/carousel.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/carousel.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/common.d.ts +55 -0
- package/lib/esm/content-fields/hubtype-fields/common.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/common.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/fallback.d.ts +9 -0
- package/lib/esm/content-fields/hubtype-fields/fallback.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/fallback.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/function.d.ts +28 -0
- package/lib/esm/content-fields/hubtype-fields/function.js +7 -0
- package/lib/esm/content-fields/hubtype-fields/function.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +10 -0
- package/lib/esm/content-fields/hubtype-fields/handoff.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/handoff.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/image.d.ts +8 -0
- package/lib/esm/content-fields/hubtype-fields/image.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/image.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +17 -0
- package/lib/esm/content-fields/hubtype-fields/index.js +18 -0
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/intent.d.ts +10 -0
- package/lib/esm/content-fields/hubtype-fields/intent.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/intent.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/keyword.d.ts +9 -0
- package/lib/esm/content-fields/hubtype-fields/keyword.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/keyword.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +23 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js +28 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +16 -0
- package/lib/esm/content-fields/hubtype-fields/nodes.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/nodes.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/payload.d.ts +8 -0
- package/lib/esm/content-fields/hubtype-fields/payload.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/payload.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/start.d.ts +7 -0
- package/lib/esm/content-fields/hubtype-fields/start.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/start.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/text.d.ts +11 -0
- package/lib/esm/content-fields/hubtype-fields/text.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/text.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/url.d.ts +8 -0
- package/lib/esm/content-fields/hubtype-fields/url.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/url.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/video.d.ts +8 -0
- package/lib/esm/content-fields/hubtype-fields/video.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/video.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.d.ts +21 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +2 -0
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
- package/lib/esm/content-fields/index.d.ts +7 -5
- package/lib/esm/content-fields/index.js +6 -4
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +10 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +28 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +10 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +25 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +12 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +28 -0
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
- package/lib/esm/functions/conditional-queue-status.js +1 -3
- package/lib/esm/functions/conditional-queue-status.js.map +1 -1
- package/lib/esm/handoff.d.ts +2 -2
- package/lib/esm/handoff.js +13 -7
- package/lib/esm/handoff.js.map +1 -1
- package/lib/esm/helpers.d.ts +2 -1
- package/lib/esm/helpers.js +3 -11
- package/lib/esm/helpers.js.map +1 -1
- package/lib/esm/index.d.ts +8 -21
- package/lib/esm/index.js +36 -152
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.d.ts +6 -2
- package/lib/esm/types.js.map +1 -1
- package/package.json +4 -5
- package/src/action.tsx +19 -12
- package/src/api.ts +162 -0
- package/src/content-fields/content-fields-base.ts +7 -7
- package/src/content-fields/flow-button.tsx +40 -19
- package/src/content-fields/flow-carousel.tsx +10 -18
- package/src/content-fields/flow-element.tsx +26 -9
- package/src/content-fields/flow-image.tsx +2 -2
- package/src/content-fields/flow-text.tsx +15 -12
- package/src/content-fields/flow-video.tsx +2 -3
- package/src/content-fields/hubtype-fields/button.ts +15 -0
- package/src/content-fields/hubtype-fields/carousel.ts +18 -0
- package/src/content-fields/hubtype-fields/common.ts +65 -0
- package/src/content-fields/hubtype-fields/fallback.ts +10 -0
- package/src/content-fields/hubtype-fields/function.ts +33 -0
- package/src/content-fields/hubtype-fields/handoff.ts +11 -0
- package/src/content-fields/hubtype-fields/image.ts +9 -0
- package/src/content-fields/hubtype-fields/index.ts +17 -0
- package/src/content-fields/hubtype-fields/intent.ts +11 -0
- package/src/content-fields/hubtype-fields/keyword.ts +10 -0
- package/src/content-fields/hubtype-fields/node-types.ts +26 -0
- package/src/content-fields/hubtype-fields/nodes.ts +32 -0
- package/src/content-fields/hubtype-fields/payload.ts +9 -0
- package/src/content-fields/hubtype-fields/start.ts +8 -0
- package/src/content-fields/hubtype-fields/text.ts +12 -0
- package/src/content-fields/hubtype-fields/url.ts +9 -0
- package/src/content-fields/hubtype-fields/video.ts +9 -0
- package/src/content-fields/hubtype-fields/whatsapp-button-list.ts +25 -0
- package/src/content-fields/index.ts +14 -5
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.tsx +33 -0
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.tsx +35 -0
- package/src/content-fields/whatsapp-button-list/flow-whatsapp-button-list.tsx +46 -0
- package/src/functions/conditional-queue-status.ts +1 -3
- package/src/handoff.ts +16 -10
- package/src/helpers.ts +8 -19
- package/src/index.ts +47 -196
- package/src/types.ts +8 -2
- package/lib/cjs/content-fields/types.d.ts +0 -5
- package/lib/cjs/content-fields/types.js.map +0 -1
- package/lib/cjs/flow-builder-models.d.ts +0 -197
- package/lib/cjs/flow-builder-models.js +0 -24
- package/lib/cjs/flow-builder-models.js.map +0 -1
- package/lib/esm/content-fields/types.d.ts +0 -5
- package/lib/esm/content-fields/types.js +0 -2
- package/lib/esm/content-fields/types.js.map +0 -1
- package/lib/esm/flow-builder-models.d.ts +0 -197
- package/lib/esm/flow-builder-models.js +0 -21
- package/lib/esm/flow-builder-models.js.map +0 -1
- package/src/content-fields/types.ts +0 -6
- package/src/flow-builder-models.ts +0 -249
|
@@ -1,42 +1,63 @@
|
|
|
1
1
|
import { Button, Reply } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { FlowBuilderApi } from '../api'
|
|
5
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
6
|
+
import {
|
|
7
|
+
HtButton,
|
|
8
|
+
HtButtonStyle,
|
|
9
|
+
HtPayloadNode,
|
|
10
|
+
HtUrlNode,
|
|
11
|
+
} from './hubtype-fields'
|
|
6
12
|
|
|
7
13
|
export class FlowButton extends ContentFieldsBase {
|
|
8
14
|
public text = ''
|
|
9
15
|
public url?: string
|
|
10
16
|
public payload?: string
|
|
11
17
|
|
|
12
|
-
static fromHubtypeCMS(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
static fromHubtypeCMS(
|
|
19
|
+
cmsButton: HtButton,
|
|
20
|
+
locale: string,
|
|
21
|
+
cmsApi: FlowBuilderApi
|
|
22
|
+
): FlowButton {
|
|
23
|
+
const payloadId = this.getPayloadId(cmsButton, locale)
|
|
24
|
+
const urlId = this.getUrlId(cmsButton, locale)
|
|
25
|
+
|
|
26
|
+
const newButton = new FlowButton(cmsButton.id)
|
|
27
|
+
newButton.text = this.getTextByLocale(locale, cmsButton.text)
|
|
28
|
+
if (cmsButton.target) {
|
|
29
|
+
newButton.payload = cmsButton.target.id
|
|
30
|
+
}
|
|
31
|
+
if (cmsButton.payload && payloadId) {
|
|
32
|
+
const payloadNode = cmsApi.getNode(payloadId) as HtPayloadNode
|
|
33
|
+
newButton.payload = payloadNode.content.payload
|
|
23
34
|
}
|
|
35
|
+
if (cmsButton.url && urlId) {
|
|
36
|
+
const payloadNode = cmsApi.getNode(urlId) as HtUrlNode
|
|
37
|
+
newButton.url = payloadNode.content.url
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
return newButton
|
|
25
41
|
}
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
static getPayloadId(cmsButton, locale): string | undefined {
|
|
44
|
+
return cmsButton.payload.find(payload => payload.locale === locale)?.id
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static getUrlId(cmsButton, locale): string | undefined {
|
|
48
|
+
return cmsButton.url.find(url => url.locale === locale)?.id
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
renderButton(buttonStyle?: HtButtonStyle): JSX.Element {
|
|
52
|
+
if (buttonStyle === HtButtonStyle.QUICK_REPLY) {
|
|
29
53
|
return (
|
|
30
|
-
<Reply key={id} payload={this.payload}>
|
|
54
|
+
<Reply key={this.id} payload={this.payload}>
|
|
31
55
|
{this.text}
|
|
32
56
|
</Reply>
|
|
33
57
|
)
|
|
34
58
|
}
|
|
35
|
-
let props = {}
|
|
36
|
-
if (this.url) props = { url: this.url }
|
|
37
59
|
return (
|
|
38
|
-
|
|
39
|
-
<Button key={id} payload={this.payload} {...props}>
|
|
60
|
+
<Button key={this.id} payload={this.payload} url={this.url}>
|
|
40
61
|
{this.text}
|
|
41
62
|
</Button>
|
|
42
63
|
)
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Carousel } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { FlowBuilderApi } from '../api'
|
|
5
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
6
6
|
import { FlowElement } from './flow-element'
|
|
7
|
+
import { HtCarouselNode } from './hubtype-fields'
|
|
7
8
|
|
|
8
9
|
export class FlowCarousel extends ContentFieldsBase {
|
|
9
10
|
public code = ''
|
|
10
11
|
public elements: FlowElement[] = []
|
|
11
12
|
|
|
12
|
-
static fromHubtypeCMS(
|
|
13
|
+
static fromHubtypeCMS(
|
|
14
|
+
component: HtCarouselNode,
|
|
15
|
+
locale: string,
|
|
16
|
+
cmsApi: FlowBuilderApi
|
|
17
|
+
): FlowCarousel {
|
|
13
18
|
const newCarousel = new FlowCarousel(component.id)
|
|
14
19
|
newCarousel.code = component.code
|
|
15
20
|
newCarousel.elements = component.content.elements.map(element =>
|
|
16
|
-
FlowElement.fromHubtypeCMS(element, locale)
|
|
21
|
+
FlowElement.fromHubtypeCMS(element, locale, cmsApi)
|
|
17
22
|
)
|
|
18
23
|
return newCarousel
|
|
19
24
|
}
|
|
@@ -21,20 +26,7 @@ export class FlowCarousel extends ContentFieldsBase {
|
|
|
21
26
|
toBotonic(id: string): JSX.Element {
|
|
22
27
|
return (
|
|
23
28
|
<Carousel key={id}>
|
|
24
|
-
{this.elements.map(element => (
|
|
25
|
-
<Element key={`${id}-${element.id}`}>
|
|
26
|
-
<Pic src={element.image} />
|
|
27
|
-
<Title style=''>{element.title}</Title>
|
|
28
|
-
<Subtitle style=''>{element.subtitle}</Subtitle>
|
|
29
|
-
{/* @ts-ignore */}
|
|
30
|
-
<Button
|
|
31
|
-
payload={element.buttons?.payload}
|
|
32
|
-
url={element.buttons?.url}
|
|
33
|
-
>
|
|
34
|
-
{element.buttons?.text}
|
|
35
|
-
</Button>
|
|
36
|
-
</Element>
|
|
37
|
-
))}
|
|
29
|
+
{this.elements.map(element => element.toBotonic(id))}
|
|
38
30
|
</Carousel>
|
|
39
31
|
)
|
|
40
32
|
}
|
|
@@ -1,26 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Element, Pic, Subtitle, Title } from '@botonic/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { FlowBuilderApi } from '../api'
|
|
2
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
3
6
|
import { FlowButton } from './flow-button'
|
|
7
|
+
import { HtCarouselElement } from './hubtype-fields'
|
|
4
8
|
|
|
5
9
|
export class FlowElement extends ContentFieldsBase {
|
|
6
10
|
public title = ''
|
|
7
11
|
public subtitle = ''
|
|
8
|
-
public
|
|
12
|
+
public button: FlowButton | undefined
|
|
9
13
|
public image = ''
|
|
10
14
|
public hidden = false
|
|
11
15
|
|
|
12
16
|
static fromHubtypeCMS(
|
|
13
|
-
component:
|
|
14
|
-
locale: string
|
|
17
|
+
component: HtCarouselElement,
|
|
18
|
+
locale: string,
|
|
19
|
+
cmsApi: FlowBuilderApi
|
|
15
20
|
): FlowElement {
|
|
16
21
|
const newElement = new FlowElement(component.id)
|
|
17
|
-
newElement.title =
|
|
18
|
-
newElement.subtitle =
|
|
22
|
+
newElement.title = this.getTextByLocale(locale, component.title)
|
|
23
|
+
newElement.subtitle = this.getTextByLocale(locale, component.subtitle)
|
|
24
|
+
newElement.image = this.getImageByLocale(locale, component.image)
|
|
25
|
+
newElement.button = FlowButton.fromHubtypeCMS(
|
|
26
|
+
component.button,
|
|
19
27
|
locale,
|
|
20
|
-
|
|
28
|
+
cmsApi
|
|
21
29
|
)
|
|
22
|
-
newElement.image = FlowElement.getImageByLocale(locale, component.image)
|
|
23
|
-
newElement.buttons = FlowButton.fromHubtypeCMS(component.button, locale)
|
|
24
30
|
return newElement
|
|
25
31
|
}
|
|
32
|
+
|
|
33
|
+
toBotonic(parentId: string): JSX.Element {
|
|
34
|
+
return (
|
|
35
|
+
<Element key={`${parentId}-${this.id}`}>
|
|
36
|
+
<Pic src={this.image} />
|
|
37
|
+
<Title>{this.title}</Title>
|
|
38
|
+
<Subtitle>{this.subtitle}</Subtitle>
|
|
39
|
+
{this.button?.renderButton()}
|
|
40
|
+
</Element>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
26
43
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Image } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
import { ImageNode } from '../flow-builder-models'
|
|
5
4
|
import { ContentFieldsBase } from './content-fields-base'
|
|
5
|
+
import { HtImageNode } from './hubtype-fields'
|
|
6
6
|
|
|
7
7
|
export class FlowImage extends ContentFieldsBase {
|
|
8
8
|
public src = ''
|
|
9
9
|
public code = ''
|
|
10
10
|
|
|
11
|
-
static fromHubtypeCMS(component:
|
|
11
|
+
static fromHubtypeCMS(component: HtImageNode, locale: string): FlowImage {
|
|
12
12
|
const newImage = new FlowImage(component.id)
|
|
13
13
|
newImage.code = component.code
|
|
14
14
|
newImage.src = this.getImageByLocale(locale, component.content.image)
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { Text } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { FlowBuilderApi } from '../api'
|
|
5
5
|
import { ContentFieldsBase } from './content-fields-base'
|
|
6
6
|
import { FlowButton } from './flow-button'
|
|
7
|
+
import { HtButtonStyle, HtTextNode } from './hubtype-fields'
|
|
7
8
|
|
|
8
9
|
export class FlowText extends ContentFieldsBase {
|
|
9
10
|
public text = ''
|
|
10
11
|
public code = ''
|
|
11
12
|
public buttons: FlowButton[] = []
|
|
12
|
-
public buttonStyle =
|
|
13
|
+
public buttonStyle = HtButtonStyle.BUTTON
|
|
13
14
|
|
|
14
|
-
static fromHubtypeCMS(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
newText
|
|
20
|
-
|
|
15
|
+
static fromHubtypeCMS(
|
|
16
|
+
cmsText: HtTextNode,
|
|
17
|
+
locale: string,
|
|
18
|
+
cmsApi: FlowBuilderApi
|
|
19
|
+
): FlowText {
|
|
20
|
+
const newText = new FlowText(cmsText.id)
|
|
21
|
+
newText.code = cmsText.code
|
|
22
|
+
newText.buttonStyle = cmsText.content.buttons_style || HtButtonStyle.BUTTON
|
|
23
|
+
newText.text = this.getTextByLocale(locale, cmsText.content.text)
|
|
24
|
+
newText.buttons = cmsText.content.buttons.map(button =>
|
|
25
|
+
FlowButton.fromHubtypeCMS(button, locale, cmsApi)
|
|
21
26
|
)
|
|
22
27
|
return newText
|
|
23
28
|
}
|
|
@@ -26,9 +31,7 @@ export class FlowText extends ContentFieldsBase {
|
|
|
26
31
|
return (
|
|
27
32
|
<Text key={id}>
|
|
28
33
|
{this.text}
|
|
29
|
-
{this.buttons.map(button =>
|
|
30
|
-
button.renderButton(button.id, this.buttonStyle)
|
|
31
|
-
)}
|
|
34
|
+
{this.buttons.map(button => button.renderButton(this.buttonStyle))}
|
|
32
35
|
</Text>
|
|
33
36
|
)
|
|
34
37
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Video } from '@botonic/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
|
-
import { VideoNode } from '../flow-builder-models'
|
|
5
4
|
import { ContentFieldsBase } from './content-fields-base'
|
|
5
|
+
import { HtVideoNode } from './hubtype-fields'
|
|
6
6
|
|
|
7
7
|
export class FlowVideo extends ContentFieldsBase {
|
|
8
8
|
public src = ''
|
|
9
9
|
public code = ''
|
|
10
10
|
|
|
11
|
-
static fromHubtypeCMS(component:
|
|
11
|
+
static fromHubtypeCMS(component: HtVideoNode, locale: string): FlowVideo {
|
|
12
12
|
const newVideo = new FlowVideo(component.id)
|
|
13
13
|
newVideo.code = component.code
|
|
14
14
|
newVideo.src = this.getVideoByLocale(locale, component.content.video)
|
|
@@ -16,7 +16,6 @@ export class FlowVideo extends ContentFieldsBase {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
toBotonic(id: string): JSX.Element {
|
|
19
|
-
// @ts-ignore
|
|
20
19
|
return <Video key={id} src={this.src} />
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HtNodeLink,
|
|
3
|
+
HtPayloadLocale,
|
|
4
|
+
HtTextLocale,
|
|
5
|
+
HtUrlLocale,
|
|
6
|
+
} from './common'
|
|
7
|
+
|
|
8
|
+
export interface HtButton {
|
|
9
|
+
id: string
|
|
10
|
+
text: HtTextLocale[]
|
|
11
|
+
url: HtUrlLocale[]
|
|
12
|
+
payload: HtPayloadLocale[]
|
|
13
|
+
target?: HtNodeLink
|
|
14
|
+
hidden: string[]
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HtButton } from './button'
|
|
2
|
+
import { HtBaseNode, HtMediaFileLocale, HtTextLocale } from './common'
|
|
3
|
+
import { HtNodeWithContentType } from './node-types'
|
|
4
|
+
|
|
5
|
+
export interface HtCarouselElement {
|
|
6
|
+
id: string
|
|
7
|
+
title: HtTextLocale[]
|
|
8
|
+
subtitle: HtTextLocale[]
|
|
9
|
+
image: HtMediaFileLocale[]
|
|
10
|
+
button: HtButton
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface HtCarouselNode extends HtBaseNode {
|
|
14
|
+
type: HtNodeWithContentType.CAROUSEL
|
|
15
|
+
content: {
|
|
16
|
+
elements: HtCarouselElement[]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { HtNodeWithContentType, HtNodeWithoutContentType } from './node-types'
|
|
2
|
+
import { HtNodeComponent } from './nodes'
|
|
3
|
+
|
|
4
|
+
export interface HtFlowBuilderData {
|
|
5
|
+
version: string
|
|
6
|
+
name: string
|
|
7
|
+
locales: string[]
|
|
8
|
+
start_node_id?: string
|
|
9
|
+
ai_model_id?: string
|
|
10
|
+
nodes: HtNodeComponent[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface HtNodeLink {
|
|
14
|
+
id: string
|
|
15
|
+
type: HtNodeWithContentType | HtNodeWithoutContentType
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HtBaseNode {
|
|
19
|
+
id: string
|
|
20
|
+
code: string
|
|
21
|
+
meta: {
|
|
22
|
+
x: number
|
|
23
|
+
y: number
|
|
24
|
+
}
|
|
25
|
+
follow_up?: HtNodeLink
|
|
26
|
+
target?: HtNodeLink
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface HtTextLocale {
|
|
30
|
+
message: string
|
|
31
|
+
locale: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HtMediaFileLocale {
|
|
35
|
+
id: string
|
|
36
|
+
file: string
|
|
37
|
+
locale: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface HtVideoLocale {
|
|
41
|
+
url: string
|
|
42
|
+
is_embedded: boolean
|
|
43
|
+
locale: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface HtQueueLocale {
|
|
47
|
+
id: string
|
|
48
|
+
name: string
|
|
49
|
+
locale: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface HtInputLocale {
|
|
53
|
+
values: string[]
|
|
54
|
+
locale: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface HtUrlLocale {
|
|
58
|
+
id: string
|
|
59
|
+
locale: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface HtPayloadLocale {
|
|
63
|
+
id: string
|
|
64
|
+
locale: string
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HtBaseNode, HtNodeLink } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export interface HtFallbackNode extends HtBaseNode {
|
|
5
|
+
type: HtNodeWithContentType.FALLBACK
|
|
6
|
+
content: {
|
|
7
|
+
first_message?: HtNodeLink
|
|
8
|
+
second_message?: HtNodeLink
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HtBaseNode, HtNodeLink } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export enum HtArgumentType {
|
|
5
|
+
NUMBER = 'number',
|
|
6
|
+
STRING = 'string',
|
|
7
|
+
JSON = 'json',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HtFunctionArgument {
|
|
11
|
+
type: HtArgumentType
|
|
12
|
+
name: string
|
|
13
|
+
value: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface HtFunctionArgumentLocale {
|
|
17
|
+
locale: string
|
|
18
|
+
values: HtFunctionArgument[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface HtFunctionResult {
|
|
22
|
+
result: string
|
|
23
|
+
target?: HtNodeLink
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface HtFunctionNode extends HtBaseNode {
|
|
27
|
+
type: HtNodeWithContentType.FUNCTION
|
|
28
|
+
content: {
|
|
29
|
+
action: string
|
|
30
|
+
arguments: HtFunctionArgumentLocale[]
|
|
31
|
+
result_mapping: HtFunctionResult[]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HtBaseNode, HtPayloadLocale, HtQueueLocale } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export interface HtHandoffNode extends HtBaseNode {
|
|
5
|
+
type: HtNodeWithContentType.HANDOFF
|
|
6
|
+
content: {
|
|
7
|
+
queue: HtQueueLocale[]
|
|
8
|
+
payload: HtPayloadLocale[]
|
|
9
|
+
has_auto_assign: boolean
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './button'
|
|
2
|
+
export * from './carousel'
|
|
3
|
+
export * from './common'
|
|
4
|
+
export * from './fallback'
|
|
5
|
+
export * from './function'
|
|
6
|
+
export * from './handoff'
|
|
7
|
+
export * from './image'
|
|
8
|
+
export * from './intent'
|
|
9
|
+
export * from './keyword'
|
|
10
|
+
export * from './node-types'
|
|
11
|
+
export * from './nodes'
|
|
12
|
+
export * from './payload'
|
|
13
|
+
export * from './start'
|
|
14
|
+
export * from './text'
|
|
15
|
+
export * from './url'
|
|
16
|
+
export * from './video'
|
|
17
|
+
export * from './whatsapp-button-list'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HtBaseNode, HtInputLocale, HtTextLocale } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export interface HtIntentNode extends HtBaseNode {
|
|
5
|
+
type: HtNodeWithContentType.INTENT
|
|
6
|
+
content: {
|
|
7
|
+
title: HtTextLocale[]
|
|
8
|
+
intents: HtInputLocale[]
|
|
9
|
+
confidence: number
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HtBaseNode, HtInputLocale, HtTextLocale } from './common'
|
|
2
|
+
import { HtNodeWithContentType } from './node-types'
|
|
3
|
+
|
|
4
|
+
export interface HtKeywordNode extends HtBaseNode {
|
|
5
|
+
type: HtNodeWithContentType.KEYWORD
|
|
6
|
+
content: {
|
|
7
|
+
title: HtTextLocale[]
|
|
8
|
+
keywords: HtInputLocale[]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export enum HtNodeWithContentType {
|
|
2
|
+
CAROUSEL = 'carousel',
|
|
3
|
+
HANDOFF = 'handoff',
|
|
4
|
+
IMAGE = 'image',
|
|
5
|
+
TEXT = 'text',
|
|
6
|
+
KEYWORD = 'keyword',
|
|
7
|
+
INTENT = 'intent',
|
|
8
|
+
FUNCTION = 'function',
|
|
9
|
+
FALLBACK = 'fallback',
|
|
10
|
+
VIDEO = 'video',
|
|
11
|
+
WHATSAPP_BUTTON_LIST = 'whatsapp-button-list',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export enum HtNodeStartType {
|
|
15
|
+
STARTUP = 'start-up',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum HtNodeWithoutContentType {
|
|
19
|
+
URL = 'url',
|
|
20
|
+
PAYLOAD = 'payload',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum HtButtonStyle {
|
|
24
|
+
BUTTON = 'button',
|
|
25
|
+
QUICK_REPLY = 'quick-reply',
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HtCarouselNode } from './carousel'
|
|
2
|
+
import { HtFallbackNode } from './fallback'
|
|
3
|
+
import { HtFunctionNode } from './function'
|
|
4
|
+
import { HtHandoffNode } from './handoff'
|
|
5
|
+
import { HtImageNode } from './image'
|
|
6
|
+
import { HtIntentNode } from './intent'
|
|
7
|
+
import { HtKeywordNode } from './keyword'
|
|
8
|
+
import { HtPayloadNode } from './payload'
|
|
9
|
+
import { HtStartNode } from './start'
|
|
10
|
+
import { HtTextNode } from './text'
|
|
11
|
+
import { HtUrlNode } from './url'
|
|
12
|
+
import { HtVideoNode } from './video'
|
|
13
|
+
import { HtWhatsappButtonListNode } from './whatsapp-button-list'
|
|
14
|
+
|
|
15
|
+
export type HtNodeWithContent =
|
|
16
|
+
| HtTextNode
|
|
17
|
+
| HtImageNode
|
|
18
|
+
| HtVideoNode
|
|
19
|
+
| HtCarouselNode
|
|
20
|
+
| HtHandoffNode
|
|
21
|
+
| HtKeywordNode
|
|
22
|
+
| HtIntentNode
|
|
23
|
+
| HtFunctionNode
|
|
24
|
+
| HtFallbackNode
|
|
25
|
+
| HtWhatsappButtonListNode
|
|
26
|
+
|
|
27
|
+
export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode
|
|
28
|
+
|
|
29
|
+
export type HtNodeComponent =
|
|
30
|
+
| HtNodeWithContent
|
|
31
|
+
| HtNodeWithoutContent
|
|
32
|
+
| HtStartNode
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HtButton } from './button'
|
|
2
|
+
import { HtBaseNode, HtTextLocale } from './common'
|
|
3
|
+
import { HtButtonStyle, HtNodeWithContentType } from './node-types'
|
|
4
|
+
|
|
5
|
+
export interface HtTextNode extends HtBaseNode {
|
|
6
|
+
type: HtNodeWithContentType.TEXT
|
|
7
|
+
content: {
|
|
8
|
+
text: HtTextLocale[]
|
|
9
|
+
buttons_style?: HtButtonStyle
|
|
10
|
+
buttons: HtButton[]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { HtBaseNode, HtNodeLink, HtTextLocale } from './common'
|
|
3
|
+
import { HtNodeWithContentType } from './node-types'
|
|
4
|
+
|
|
5
|
+
export interface HtWhatsappButtonListRow {
|
|
6
|
+
id: string
|
|
7
|
+
text: HtTextLocale[]
|
|
8
|
+
description: HtTextLocale[]
|
|
9
|
+
target?: HtNodeLink
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface HtWhatsappButtonListSection {
|
|
13
|
+
id: string
|
|
14
|
+
title: HtTextLocale[]
|
|
15
|
+
rows: HtWhatsappButtonListRow[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface HtWhatsappButtonListNode extends HtBaseNode {
|
|
19
|
+
type: HtNodeWithContentType.WHATSAPP_BUTTON_LIST
|
|
20
|
+
content: {
|
|
21
|
+
text: HtTextLocale[]
|
|
22
|
+
button_text: HtTextLocale[]
|
|
23
|
+
sections: HtWhatsappButtonListSection[]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { FlowCarousel } from './flow-carousel'
|
|
2
|
+
import { FlowImage } from './flow-image'
|
|
3
|
+
import { FlowText } from './flow-text'
|
|
4
|
+
import { FlowVideo } from './flow-video'
|
|
5
|
+
import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-button-list'
|
|
6
|
+
|
|
1
7
|
export { ContentFieldsBase } from './content-fields-base'
|
|
2
8
|
export { FlowButton } from './flow-button'
|
|
3
|
-
export { FlowCarousel } from './flow-carousel'
|
|
4
9
|
export { FlowElement } from './flow-element'
|
|
5
|
-
export { FlowImage
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
10
|
+
export { FlowCarousel, FlowImage, FlowText, FlowVideo, FlowWhatsappButtonList }
|
|
11
|
+
|
|
12
|
+
export type FlowContent =
|
|
13
|
+
| FlowCarousel
|
|
14
|
+
| FlowImage
|
|
15
|
+
| FlowText
|
|
16
|
+
| FlowVideo
|
|
17
|
+
| FlowWhatsappButtonList
|