@botonic/plugin-flow-builder 0.56.0-alpha.0 → 0.57.0-rslib-esm.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.
- package/README.md +1 -1
- package/lib/{cjs/action → action}/ai-agent-from-user-input.d.ts +2 -2
- package/lib/{cjs/action → action}/ai-agent-from-user-input.js +9 -6
- package/lib/action/ai-agent-from-user-input.js.map +1 -0
- package/lib/{esm/action → action}/context.d.ts +2 -2
- package/lib/action/context.js +20 -0
- package/lib/action/context.js.map +1 -0
- package/lib/{cjs/action → action}/fallback.d.ts +2 -2
- package/lib/{cjs/action → action}/fallback.js +16 -11
- package/lib/action/fallback.js.map +1 -0
- package/lib/action/first-interaction.d.ts +3 -0
- package/lib/{cjs/action → action}/first-interaction.js +39 -27
- package/lib/action/first-interaction.js.map +1 -0
- package/lib/{cjs/action → action}/get-contents.d.ts +1 -1
- package/lib/action/get-contents.js +56 -0
- package/lib/action/get-contents.js.map +1 -0
- package/lib/{esm/action → action}/index.d.ts +1 -1
- package/lib/{esm/action → action}/index.js +68 -32
- package/lib/action/index.js.map +1 -0
- package/lib/action/payload.d.ts +3 -0
- package/lib/{cjs/action → action}/payload.js +27 -23
- package/lib/action/payload.js.map +1 -0
- package/lib/{cjs/api.d.ts → api.d.ts} +2 -2
- package/lib/{esm/api.js → api.js} +55 -44
- package/lib/api.js.map +1 -0
- package/lib/constants.js +17 -0
- package/lib/constants.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/content-fields-base.d.ts +2 -2
- package/lib/content-fields/content-fields-base.js +78 -0
- package/lib/content-fields/content-fields-base.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.d.ts +1 -1
- package/lib/content-fields/custom-conditional/custom-conditional-v2-evaluators.js +73 -0
- package/lib/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.d.ts +1 -1
- package/lib/{cjs/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.js +15 -15
- package/lib/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.d.ts +3 -3
- package/lib/content-fields/custom-conditional/flow-custom-condition-v2.js +94 -0
- package/lib/content-fields/custom-conditional/flow-custom-condition-v2.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.d.ts +4 -4
- package/lib/content-fields/flow-ai-agent-base.js +100 -0
- package/lib/content-fields/flow-ai-agent-base.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.d.ts +5 -5
- package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.js +57 -46
- package/lib/content-fields/flow-ai-agent-router.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-ai-agent.d.ts +4 -4
- package/lib/{cjs/content-fields → content-fields}/flow-ai-agent.js +33 -22
- package/lib/content-fields/flow-ai-agent.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-bot-action.d.ts +3 -3
- package/lib/{esm/content-fields → content-fields}/flow-bot-action.js +23 -15
- package/lib/content-fields/flow-bot-action.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-button.d.ts +5 -5
- package/lib/{esm/content-fields → content-fields}/flow-button.js +48 -29
- package/lib/content-fields/flow-button.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-capture-user-input.d.ts +2 -2
- package/lib/content-fields/flow-capture-user-input.js +46 -0
- package/lib/content-fields/flow-capture-user-input.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-carousel.d.ts +4 -4
- package/lib/content-fields/flow-carousel.js +193 -0
- package/lib/content-fields/flow-carousel.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.d.ts +3 -3
- package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.js +26 -22
- package/lib/content-fields/flow-channel-conditional.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-country-conditional.d.ts +3 -3
- package/lib/{esm/content-fields → content-fields}/flow-country-conditional.js +26 -21
- package/lib/content-fields/flow-country-conditional.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-custom-conditional.d.ts +4 -4
- package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.js +31 -33
- package/lib/content-fields/flow-custom-conditional.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-element.d.ts +4 -4
- package/lib/content-fields/flow-element.js +67 -0
- package/lib/content-fields/flow-element.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.d.ts +3 -3
- package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.js +25 -20
- package/lib/content-fields/flow-go-to-flow.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-handoff.d.ts +3 -3
- package/lib/{cjs/content-fields → content-fields}/flow-handoff.js +30 -19
- package/lib/content-fields/flow-handoff.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-image.d.ts +2 -2
- package/lib/content-fields/flow-image.js +42 -0
- package/lib/content-fields/flow-image.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-queue-status-conditional.d.ts +3 -3
- package/lib/{cjs/content-fields → content-fields}/flow-queue-status-conditional.js +45 -40
- package/lib/content-fields/flow-queue-status-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-rating.d.ts +3 -3
- package/lib/content-fields/flow-rating.js +88 -0
- package/lib/content-fields/flow-rating.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-text.d.ts +4 -4
- package/lib/content-fields/flow-text.js +82 -0
- package/lib/content-fields/flow-text.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-video.d.ts +2 -2
- package/lib/content-fields/flow-video.js +42 -0
- package/lib/content-fields/flow-video.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-webview.d.ts +2 -2
- package/lib/{cjs/content-fields → content-fields}/flow-webview.js +31 -28
- package/lib/content-fields/flow-webview.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.d.ts +3 -3
- package/lib/content-fields/flow-whatsapp-cta-url-button.js +131 -0
- package/lib/content-fields/flow-whatsapp-cta-url-button.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.d.ts +3 -4
- package/lib/content-fields/flow-whatsapp-request-contact-info.js +51 -0
- package/lib/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/flow-whatsapp-template.d.ts +2 -2
- package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.js +119 -102
- package/lib/content-fields/flow-whatsapp-template.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/ai-agent-router.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/ai-agent-router.js +4 -0
- package/lib/content-fields/hubtype-fields/ai-agent-router.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/ai-agent.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/ai-agent.js +4 -0
- package/lib/content-fields/hubtype-fields/ai-agent.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/bot-action.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/bot-action.js +4 -0
- package/lib/content-fields/hubtype-fields/bot-action.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/button.d.ts +1 -1
- package/lib/content-fields/hubtype-fields/button.js +4 -0
- package/lib/content-fields/hubtype-fields/button.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/capture-user-input.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/capture-user-input.js +12 -0
- package/lib/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/carousel.js +4 -0
- package/lib/content-fields/hubtype-fields/carousel.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/channel-conditional.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/channel-conditional.js +4 -0
- package/lib/content-fields/hubtype-fields/channel-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/common.js +4 -0
- package/lib/content-fields/hubtype-fields/common.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/country-conditional.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/country-conditional.js +4 -0
- package/lib/content-fields/hubtype-fields/country-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.d.ts +2 -2
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.js +15 -15
- package/lib/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/custom-conditional.js +4 -0
- package/lib/content-fields/hubtype-fields/custom-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/fallback.js +4 -0
- package/lib/content-fields/hubtype-fields/fallback.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/function.js +11 -0
- package/lib/content-fields/hubtype-fields/function.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/go-to-flow.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/go-to-flow.js +4 -0
- package/lib/content-fields/hubtype-fields/go-to-flow.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/handoff.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/handoff.js +4 -0
- package/lib/content-fields/hubtype-fields/handoff.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/image.js +4 -0
- package/lib/content-fields/hubtype-fields/image.js.map +1 -0
- package/lib/content-fields/hubtype-fields/index.d.ts +27 -0
- package/lib/content-fields/hubtype-fields/index.js +57 -0
- package/lib/content-fields/hubtype-fields/index.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/keyword.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/keyword.js +4 -0
- package/lib/content-fields/hubtype-fields/keyword.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/node-types.js +12 -12
- package/lib/content-fields/hubtype-fields/node-types.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/nodes.d.ts +23 -23
- package/lib/content-fields/hubtype-fields/nodes.js +4 -0
- package/lib/content-fields/hubtype-fields/nodes.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.d.ts +1 -1
- package/lib/content-fields/hubtype-fields/payload.js +4 -0
- package/lib/content-fields/hubtype-fields/payload.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/queue-status-conditional.js +4 -0
- package/lib/content-fields/hubtype-fields/queue-status-conditional.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/rating.js +9 -0
- package/lib/content-fields/hubtype-fields/rating.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/smart-intent.js +4 -0
- package/lib/content-fields/hubtype-fields/smart-intent.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/text.js +4 -0
- package/lib/content-fields/hubtype-fields/text.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/url.d.ts +1 -1
- package/lib/content-fields/hubtype-fields/url.js +4 -0
- package/lib/content-fields/hubtype-fields/url.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/video.js +4 -0
- package/lib/content-fields/hubtype-fields/video.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/webview.js +4 -0
- package/lib/content-fields/hubtype-fields/webview.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/whatsapp-button-list.js +4 -0
- package/lib/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/whatsapp-cta-url-button.js +4 -0
- package/lib/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.d.ts +2 -2
- package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js +4 -0
- package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/hubtype-fields/whatsapp-template.d.ts +3 -3
- package/lib/content-fields/hubtype-fields/whatsapp-template.js +9 -0
- package/lib/content-fields/hubtype-fields/whatsapp-template.js.map +1 -0
- package/lib/content-fields/index.d.ts +25 -0
- package/lib/content-fields/index.js +73 -0
- package/lib/content-fields/index.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +3 -3
- package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.js +16 -14
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
- package/lib/{cjs/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +4 -4
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +41 -0
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.d.ts +4 -4
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +66 -0
- package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
- package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.d.ts +3 -3
- package/lib/content-fields/whatsapp-button-list/index.js +12 -0
- package/lib/content-fields/whatsapp-button-list/index.js.map +1 -0
- package/lib/{cjs/filters → filters}/index.d.ts +2 -2
- package/lib/filters/index.js +16 -0
- package/lib/filters/index.js.map +1 -0
- package/lib/{cjs/flow-factory.d.ts → flow-factory.d.ts} +3 -3
- package/lib/flow-factory.js +75 -0
- package/lib/flow-factory.js.map +1 -0
- package/lib/{esm/functions → functions}/index.d.ts +1 -1
- package/lib/{cjs/functions → functions}/index.js +25 -19
- package/lib/functions/index.js.map +1 -0
- package/lib/{cjs/index.d.ts → index.d.ts} +12 -12
- package/lib/{esm/index.js → index.js} +94 -77
- package/lib/index.js.map +1 -0
- package/lib/services/hubtype-queues-api.js +26 -0
- package/lib/services/hubtype-queues-api.js.map +1 -0
- package/lib/structured-output/flow-builder-content.js +16 -0
- package/lib/structured-output/flow-builder-content.js.map +1 -0
- package/lib/{cjs/tracking.d.ts → tracking.d.ts} +2 -2
- package/lib/{cjs/tracking.js → tracking.js} +27 -21
- package/lib/tracking.js.map +1 -0
- package/lib/{esm/types.d.ts → types.d.ts} +5 -5
- package/lib/types.js +14 -0
- package/lib/types.js.map +1 -0
- package/lib/{esm/user-input → user-input}/capture-user-input-api.d.ts +2 -2
- package/lib/{cjs/user-input → user-input}/capture-user-input-api.js +44 -33
- package/lib/user-input/capture-user-input-api.js.map +1 -0
- package/lib/{esm/user-input → user-input}/index.d.ts +2 -2
- package/lib/user-input/index.js +46 -0
- package/lib/user-input/index.js.map +1 -0
- package/lib/{esm/user-input → user-input}/keyword.d.ts +2 -2
- package/lib/{esm/user-input → user-input}/keyword.js +31 -26
- package/lib/user-input/keyword.js.map +1 -0
- package/lib/{cjs/user-input → user-input}/smart-intent.d.ts +2 -2
- package/lib/{cjs/user-input → user-input}/smart-intent.js +36 -32
- package/lib/user-input/smart-intent.js.map +1 -0
- package/lib/{cjs/utils → utils}/ai-agent.d.ts +3 -3
- package/lib/utils/ai-agent.js +33 -0
- package/lib/utils/ai-agent.js.map +1 -0
- package/lib/{cjs/utils → utils}/authentication.js +10 -7
- package/lib/utils/authentication.js.map +1 -0
- package/lib/{cjs/utils → utils}/flow-locale.js +14 -18
- package/lib/utils/flow-locale.js.map +1 -0
- package/lib/{cjs/utils → utils}/get-flow-builder-plugin.d.ts +1 -1
- package/lib/{cjs/utils → utils}/get-flow-builder-plugin.js +4 -4
- package/lib/utils/get-flow-builder-plugin.js.map +1 -0
- package/lib/{cjs/utils → utils}/hubtype-assistant-content.d.ts +1 -2
- package/lib/{cjs/utils → utils}/hubtype-assistant-content.js +57 -54
- package/lib/utils/hubtype-assistant-content.js.map +1 -0
- package/lib/utils/input.js +37 -0
- package/lib/utils/input.js.map +1 -0
- package/lib/{cjs/webview → webview}/contents-context.d.ts +1 -1
- package/lib/webview/contents-context.js +14 -0
- package/lib/webview/contents-context.js.map +1 -0
- package/lib/webview/index.d.ts +3 -0
- package/lib/webview/index.js +11 -0
- package/lib/webview/index.js.map +1 -0
- package/lib/{esm/webview → webview}/types.d.ts +1 -1
- package/lib/webview/types.js +9 -0
- package/lib/webview/types.js.map +1 -0
- package/lib/{cjs/webview → webview}/use-webview-contents.d.ts +1 -1
- package/lib/webview/use-webview-contents.js +90 -0
- package/lib/webview/use-webview-contents.js.map +1 -0
- package/package.json +10 -8
- package/src/content-fields/flow-ai-agent-base.tsx +0 -11
- package/src/content-fields/flow-whatsapp-request-contact-info.tsx +1 -17
- package/src/content-fields/index.ts +2 -2
- package/src/index.ts +5 -5
- package/src/types.ts +6 -6
- package/src/utils/hubtype-assistant-content.ts +0 -14
- package/lib/cjs/action/ai-agent-from-user-input.js.map +0 -1
- package/lib/cjs/action/context.d.ts +0 -11
- package/lib/cjs/action/context.js +0 -17
- package/lib/cjs/action/context.js.map +0 -1
- package/lib/cjs/action/fallback.js.map +0 -1
- package/lib/cjs/action/first-interaction.d.ts +0 -3
- package/lib/cjs/action/first-interaction.js.map +0 -1
- package/lib/cjs/action/get-contents.js +0 -39
- package/lib/cjs/action/get-contents.js.map +0 -1
- package/lib/cjs/action/index.d.ts +0 -25
- package/lib/cjs/action/index.js +0 -90
- package/lib/cjs/action/index.js.map +0 -1
- package/lib/cjs/action/payload.d.ts +0 -3
- package/lib/cjs/action/payload.js.map +0 -1
- package/lib/cjs/api.js +0 -205
- package/lib/cjs/api.js.map +0 -1
- package/lib/cjs/constants.js +0 -19
- package/lib/cjs/constants.js.map +0 -1
- package/lib/cjs/content-fields/content-fields-base.d.ts +0 -20
- package/lib/cjs/content-fields/content-fields-base.js +0 -74
- package/lib/cjs/content-fields/content-fields-base.js.map +0 -1
- package/lib/cjs/content-fields/custom-conditional/custom-conditional-v2-evaluators.d.ts +0 -15
- package/lib/cjs/content-fields/custom-conditional/custom-conditional-v2-evaluators.js +0 -71
- package/lib/cjs/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +0 -1
- package/lib/cjs/content-fields/custom-conditional/custom-conditional-v2-resolver.d.ts +0 -9
- package/lib/cjs/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +0 -1
- package/lib/cjs/content-fields/custom-conditional/flow-custom-condition-v2.js +0 -79
- package/lib/cjs/content-fields/custom-conditional/flow-custom-condition-v2.js.map +0 -1
- package/lib/cjs/content-fields/flow-ai-agent-base.d.ts +0 -25
- package/lib/cjs/content-fields/flow-ai-agent-base.js +0 -97
- package/lib/cjs/content-fields/flow-ai-agent-base.js.map +0 -1
- package/lib/cjs/content-fields/flow-ai-agent-router.d.ts +0 -21
- package/lib/cjs/content-fields/flow-ai-agent-router.js +0 -125
- package/lib/cjs/content-fields/flow-ai-agent-router.js.map +0 -1
- package/lib/cjs/content-fields/flow-ai-agent.js.map +0 -1
- package/lib/cjs/content-fields/flow-bot-action.d.ts +0 -14
- package/lib/cjs/content-fields/flow-bot-action.js +0 -45
- package/lib/cjs/content-fields/flow-bot-action.js.map +0 -1
- package/lib/cjs/content-fields/flow-button.d.ts +0 -31
- package/lib/cjs/content-fields/flow-button.js +0 -86
- package/lib/cjs/content-fields/flow-button.js.map +0 -1
- package/lib/cjs/content-fields/flow-capture-user-input.js +0 -45
- package/lib/cjs/content-fields/flow-capture-user-input.js.map +0 -1
- package/lib/cjs/content-fields/flow-carousel.d.ts +0 -22
- package/lib/cjs/content-fields/flow-carousel.js +0 -152
- package/lib/cjs/content-fields/flow-carousel.js.map +0 -1
- package/lib/cjs/content-fields/flow-channel-conditional.d.ts +0 -14
- package/lib/cjs/content-fields/flow-channel-conditional.js +0 -57
- package/lib/cjs/content-fields/flow-channel-conditional.js.map +0 -1
- package/lib/cjs/content-fields/flow-country-conditional.js +0 -59
- package/lib/cjs/content-fields/flow-country-conditional.js.map +0 -1
- package/lib/cjs/content-fields/flow-custom-conditional.js +0 -89
- package/lib/cjs/content-fields/flow-custom-conditional.js.map +0 -1
- package/lib/cjs/content-fields/flow-element.js +0 -50
- package/lib/cjs/content-fields/flow-element.js.map +0 -1
- package/lib/cjs/content-fields/flow-go-to-flow.d.ts +0 -13
- package/lib/cjs/content-fields/flow-go-to-flow.js +0 -51
- package/lib/cjs/content-fields/flow-go-to-flow.js.map +0 -1
- package/lib/cjs/content-fields/flow-handoff.js.map +0 -1
- package/lib/cjs/content-fields/flow-image.js +0 -33
- package/lib/cjs/content-fields/flow-image.js.map +0 -1
- package/lib/cjs/content-fields/flow-queue-status-conditional.js.map +0 -1
- package/lib/cjs/content-fields/flow-rating.d.ts +0 -15
- package/lib/cjs/content-fields/flow-rating.js +0 -66
- package/lib/cjs/content-fields/flow-rating.js.map +0 -1
- package/lib/cjs/content-fields/flow-text.js +0 -60
- package/lib/cjs/content-fields/flow-text.js.map +0 -1
- package/lib/cjs/content-fields/flow-video.d.ts +0 -10
- package/lib/cjs/content-fields/flow-video.js +0 -33
- package/lib/cjs/content-fields/flow-video.js.map +0 -1
- package/lib/cjs/content-fields/flow-webview.d.ts +0 -16
- package/lib/cjs/content-fields/flow-webview.js.map +0 -1
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.d.ts +0 -21
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js +0 -92
- package/lib/cjs/content-fields/flow-whatsapp-cta-url-button.js.map +0 -1
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.d.ts +0 -11
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.js +0 -45
- package/lib/cjs/content-fields/flow-whatsapp-request-contact-info.js.map +0 -1
- package/lib/cjs/content-fields/flow-whatsapp-template.js +0 -264
- package/lib/cjs/content-fields/flow-whatsapp-template.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/ai-agent-router.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/ai-agent-router.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/ai-agent.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/ai-agent.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/bot-action.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/bot-action.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/button.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/button.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js +0 -12
- package/lib/cjs/content-fields/hubtype-fields/capture-user-input.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/carousel.d.ts +0 -17
- package/lib/cjs/content-fields/hubtype-fields/carousel.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/carousel.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/channel-conditional.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/channel-conditional.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/common.d.ts +0 -83
- package/lib/cjs/content-fields/hubtype-fields/common.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/common.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/country-conditional.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/country-conditional.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.d.ts +0 -56
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.js +0 -36
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional.d.ts +0 -11
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/fallback.d.ts +0 -9
- package/lib/cjs/content-fields/hubtype-fields/fallback.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/fallback.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/function.d.ts +0 -30
- package/lib/cjs/content-fields/hubtype-fields/function.js +0 -11
- package/lib/cjs/content-fields/hubtype-fields/function.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/go-to-flow.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/go-to-flow.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/handoff.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/handoff.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/image.d.ts +0 -8
- package/lib/cjs/content-fields/hubtype-fields/image.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/image.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +0 -27
- package/lib/cjs/content-fields/hubtype-fields/index.js +0 -31
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/keyword.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/keyword.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/nodes.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/payload.d.ts +0 -8
- package/lib/cjs/content-fields/hubtype-fields/payload.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/payload.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/queue-status-conditional.d.ts +0 -25
- package/lib/cjs/content-fields/hubtype-fields/queue-status-conditional.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/queue-status-conditional.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/rating.d.ts +0 -23
- package/lib/cjs/content-fields/hubtype-fields/rating.js +0 -9
- package/lib/cjs/content-fields/hubtype-fields/rating.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.d.ts +0 -12
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/smart-intent.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/text.d.ts +0 -11
- package/lib/cjs/content-fields/hubtype-fields/text.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/text.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/url.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/url.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/video.d.ts +0 -8
- package/lib/cjs/content-fields/hubtype-fields/video.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/video.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/webview.d.ts +0 -17
- package/lib/cjs/content-fields/hubtype-fields/webview.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/webview.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.d.ts +0 -21
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-button-list.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-cta-url-button.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-request-contact-info.js +0 -3
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +0 -1
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-template.js +0 -9
- package/lib/cjs/content-fields/hubtype-fields/whatsapp-template.js.map +0 -1
- package/lib/cjs/content-fields/index.d.ts +0 -25
- package/lib/cjs/content-fields/index.js +0 -52
- package/lib/cjs/content-fields/index.js.map +0 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js +0 -41
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +0 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +0 -36
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +0 -1
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -14
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +0 -46
- package/lib/cjs/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +0 -1
- package/lib/cjs/content-fields/whatsapp-button-list/index.d.ts +0 -3
- package/lib/cjs/content-fields/whatsapp-button-list/index.js +0 -10
- package/lib/cjs/content-fields/whatsapp-button-list/index.js.map +0 -1
- package/lib/cjs/filters/index.js +0 -17
- package/lib/cjs/filters/index.js.map +0 -1
- package/lib/cjs/flow-factory.js +0 -69
- package/lib/cjs/flow-factory.js.map +0 -1
- package/lib/cjs/functions/index.d.ts +0 -11
- package/lib/cjs/functions/index.js.map +0 -1
- package/lib/cjs/index.js +0 -178
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/services/hubtype-queues-api.js +0 -26
- package/lib/cjs/services/hubtype-queues-api.js.map +0 -1
- package/lib/cjs/structured-output/flow-builder-content.js +0 -15
- package/lib/cjs/structured-output/flow-builder-content.js.map +0 -1
- package/lib/cjs/tracking.js.map +0 -1
- package/lib/cjs/types.d.ts +0 -62
- package/lib/cjs/types.js +0 -14
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/user-input/capture-user-input-api.d.ts +0 -21
- package/lib/cjs/user-input/capture-user-input-api.js.map +0 -1
- package/lib/cjs/user-input/index.d.ts +0 -4
- package/lib/cjs/user-input/index.js +0 -37
- package/lib/cjs/user-input/index.js.map +0 -1
- package/lib/cjs/user-input/keyword.d.ts +0 -27
- package/lib/cjs/user-input/keyword.js +0 -84
- package/lib/cjs/user-input/keyword.js.map +0 -1
- package/lib/cjs/user-input/smart-intent.js.map +0 -1
- package/lib/cjs/utils/ai-agent.js +0 -28
- package/lib/cjs/utils/ai-agent.js.map +0 -1
- package/lib/cjs/utils/authentication.js.map +0 -1
- package/lib/cjs/utils/flow-locale.js.map +0 -1
- package/lib/cjs/utils/get-flow-builder-plugin.js.map +0 -1
- package/lib/cjs/utils/hubtype-assistant-content.js.map +0 -1
- package/lib/cjs/utils/input.js +0 -35
- package/lib/cjs/utils/input.js.map +0 -1
- package/lib/cjs/webview/contents-context.js +0 -12
- package/lib/cjs/webview/contents-context.js.map +0 -1
- package/lib/cjs/webview/index.d.ts +0 -3
- package/lib/cjs/webview/index.js +0 -10
- package/lib/cjs/webview/index.js.map +0 -1
- package/lib/cjs/webview/types.d.ts +0 -47
- package/lib/cjs/webview/types.js +0 -9
- package/lib/cjs/webview/types.js.map +0 -1
- package/lib/cjs/webview/use-webview-contents.js +0 -83
- package/lib/cjs/webview/use-webview-contents.js.map +0 -1
- package/lib/esm/action/ai-agent-from-user-input.d.ts +0 -3
- package/lib/esm/action/ai-agent-from-user-input.js +0 -32
- package/lib/esm/action/ai-agent-from-user-input.js.map +0 -1
- package/lib/esm/action/context.js +0 -17
- package/lib/esm/action/context.js.map +0 -1
- package/lib/esm/action/fallback.d.ts +0 -3
- package/lib/esm/action/fallback.js +0 -36
- package/lib/esm/action/fallback.js.map +0 -1
- package/lib/esm/action/first-interaction.d.ts +0 -3
- package/lib/esm/action/first-interaction.js +0 -88
- package/lib/esm/action/first-interaction.js.map +0 -1
- package/lib/esm/action/get-contents.d.ts +0 -3
- package/lib/esm/action/get-contents.js +0 -39
- package/lib/esm/action/get-contents.js.map +0 -1
- package/lib/esm/action/index.js.map +0 -1
- package/lib/esm/action/payload.d.ts +0 -3
- package/lib/esm/action/payload.js +0 -74
- package/lib/esm/action/payload.js.map +0 -1
- package/lib/esm/api.d.ts +0 -40
- package/lib/esm/api.js.map +0 -1
- package/lib/esm/constants.d.ts +0 -13
- package/lib/esm/constants.js +0 -19
- package/lib/esm/constants.js.map +0 -1
- package/lib/esm/content-fields/content-fields-base.js +0 -74
- package/lib/esm/content-fields/content-fields-base.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-evaluators.js +0 -71
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-resolver.js +0 -58
- package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +0 -1
- package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.d.ts +0 -17
- package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.js +0 -79
- package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent-base.js +0 -97
- package/lib/esm/content-fields/flow-ai-agent-base.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent-router.js.map +0 -1
- package/lib/esm/content-fields/flow-ai-agent.d.ts +0 -17
- package/lib/esm/content-fields/flow-ai-agent.js +0 -64
- package/lib/esm/content-fields/flow-ai-agent.js.map +0 -1
- package/lib/esm/content-fields/flow-bot-action.js.map +0 -1
- package/lib/esm/content-fields/flow-button.js.map +0 -1
- package/lib/esm/content-fields/flow-capture-user-input.d.ts +0 -14
- package/lib/esm/content-fields/flow-capture-user-input.js +0 -45
- package/lib/esm/content-fields/flow-capture-user-input.js.map +0 -1
- package/lib/esm/content-fields/flow-carousel.js +0 -152
- package/lib/esm/content-fields/flow-carousel.js.map +0 -1
- package/lib/esm/content-fields/flow-channel-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-country-conditional.d.ts +0 -13
- package/lib/esm/content-fields/flow-country-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-custom-conditional.d.ts +0 -17
- package/lib/esm/content-fields/flow-custom-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-element.d.ts +0 -22
- package/lib/esm/content-fields/flow-element.js +0 -50
- package/lib/esm/content-fields/flow-element.js.map +0 -1
- package/lib/esm/content-fields/flow-go-to-flow.js.map +0 -1
- package/lib/esm/content-fields/flow-handoff.d.ts +0 -17
- package/lib/esm/content-fields/flow-handoff.js +0 -68
- package/lib/esm/content-fields/flow-handoff.js.map +0 -1
- package/lib/esm/content-fields/flow-image.d.ts +0 -10
- package/lib/esm/content-fields/flow-image.js +0 -33
- package/lib/esm/content-fields/flow-image.js.map +0 -1
- package/lib/esm/content-fields/flow-queue-status-conditional.d.ts +0 -30
- package/lib/esm/content-fields/flow-queue-status-conditional.js +0 -95
- package/lib/esm/content-fields/flow-queue-status-conditional.js.map +0 -1
- package/lib/esm/content-fields/flow-rating.js +0 -66
- package/lib/esm/content-fields/flow-rating.js.map +0 -1
- package/lib/esm/content-fields/flow-text.d.ts +0 -15
- package/lib/esm/content-fields/flow-text.js +0 -60
- package/lib/esm/content-fields/flow-text.js.map +0 -1
- package/lib/esm/content-fields/flow-video.js +0 -33
- package/lib/esm/content-fields/flow-video.js.map +0 -1
- package/lib/esm/content-fields/flow-webview.js +0 -78
- package/lib/esm/content-fields/flow-webview.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js +0 -92
- package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js +0 -45
- package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js.map +0 -1
- package/lib/esm/content-fields/flow-whatsapp-template.d.ts +0 -37
- package/lib/esm/content-fields/flow-whatsapp-template.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent-router.d.ts +0 -21
- package/lib/esm/content-fields/hubtype-fields/ai-agent-router.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/ai-agent-router.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/ai-agent.d.ts +0 -25
- package/lib/esm/content-fields/hubtype-fields/ai-agent.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/ai-agent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/bot-action.d.ts +0 -10
- package/lib/esm/content-fields/hubtype-fields/bot-action.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/bot-action.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/button.d.ts +0 -8
- package/lib/esm/content-fields/hubtype-fields/button.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/button.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.d.ts +0 -19
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.js +0 -12
- package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/carousel.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/carousel.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/channel-conditional.d.ts +0 -10
- package/lib/esm/content-fields/hubtype-fields/channel-conditional.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/channel-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/common.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/common.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/country-conditional.d.ts +0 -10
- package/lib/esm/content-fields/hubtype-fields/country-conditional.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/country-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/custom-conditional.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/custom-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/fallback.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/fallback.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/function.js +0 -11
- package/lib/esm/content-fields/hubtype-fields/function.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.d.ts +0 -9
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/go-to-flow.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/handoff.d.ts +0 -11
- package/lib/esm/content-fields/hubtype-fields/handoff.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/handoff.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/image.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/image.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +0 -27
- package/lib/esm/content-fields/hubtype-fields/index.js +0 -31
- package/lib/esm/content-fields/hubtype-fields/index.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/keyword.d.ts +0 -9
- package/lib/esm/content-fields/hubtype-fields/keyword.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/keyword.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +0 -31
- package/lib/esm/content-fields/hubtype-fields/node-types.js +0 -38
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +0 -26
- package/lib/esm/content-fields/hubtype-fields/nodes.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/nodes.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/payload.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/payload.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/rating.js +0 -9
- package/lib/esm/content-fields/hubtype-fields/rating.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/smart-intent.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/text.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/text.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/url.d.ts +0 -8
- package/lib/esm/content-fields/hubtype-fields/url.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/url.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/video.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/video.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/webview.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/webview.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.d.ts +0 -17
- package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.d.ts +0 -8
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js +0 -3
- package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +0 -1
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.d.ts +0 -96
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js +0 -9
- package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js.map +0 -1
- package/lib/esm/content-fields/index.d.ts +0 -25
- package/lib/esm/content-fields/index.js +0 -52
- package/lib/esm/content-fields/index.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +0 -14
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +0 -13
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js +0 -36
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js +0 -46
- package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +0 -1
- package/lib/esm/content-fields/whatsapp-button-list/index.js +0 -10
- package/lib/esm/content-fields/whatsapp-button-list/index.js.map +0 -1
- package/lib/esm/filters/index.d.ts +0 -12
- package/lib/esm/filters/index.js +0 -17
- package/lib/esm/filters/index.js.map +0 -1
- package/lib/esm/flow-factory.d.ts +0 -12
- package/lib/esm/flow-factory.js +0 -69
- package/lib/esm/flow-factory.js.map +0 -1
- package/lib/esm/functions/index.js +0 -49
- package/lib/esm/functions/index.js.map +0 -1
- package/lib/esm/index.d.ts +0 -45
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/services/hubtype-queues-api.d.ts +0 -14
- package/lib/esm/services/hubtype-queues-api.js +0 -26
- package/lib/esm/services/hubtype-queues-api.js.map +0 -1
- package/lib/esm/structured-output/flow-builder-content.d.ts +0 -13
- package/lib/esm/structured-output/flow-builder-content.js +0 -15
- package/lib/esm/structured-output/flow-builder-content.js.map +0 -1
- package/lib/esm/tracking.d.ts +0 -16
- package/lib/esm/tracking.js +0 -71
- package/lib/esm/tracking.js.map +0 -1
- package/lib/esm/types.js +0 -14
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/user-input/capture-user-input-api.js +0 -88
- package/lib/esm/user-input/capture-user-input-api.js.map +0 -1
- package/lib/esm/user-input/index.js +0 -37
- package/lib/esm/user-input/index.js.map +0 -1
- package/lib/esm/user-input/keyword.js.map +0 -1
- package/lib/esm/user-input/smart-intent.d.ts +0 -24
- package/lib/esm/user-input/smart-intent.js +0 -89
- package/lib/esm/user-input/smart-intent.js.map +0 -1
- package/lib/esm/utils/ai-agent.d.ts +0 -11
- package/lib/esm/utils/ai-agent.js +0 -28
- package/lib/esm/utils/ai-agent.js.map +0 -1
- package/lib/esm/utils/authentication.d.ts +0 -2
- package/lib/esm/utils/authentication.js +0 -21
- package/lib/esm/utils/authentication.js.map +0 -1
- package/lib/esm/utils/flow-locale.d.ts +0 -22
- package/lib/esm/utils/flow-locale.js +0 -79
- package/lib/esm/utils/flow-locale.js.map +0 -1
- package/lib/esm/utils/get-flow-builder-plugin.d.ts +0 -3
- package/lib/esm/utils/get-flow-builder-plugin.js +0 -16
- package/lib/esm/utils/get-flow-builder-plugin.js.map +0 -1
- package/lib/esm/utils/hubtype-assistant-content.d.ts +0 -13
- package/lib/esm/utils/hubtype-assistant-content.js +0 -184
- package/lib/esm/utils/hubtype-assistant-content.js.map +0 -1
- package/lib/esm/utils/input.d.ts +0 -6
- package/lib/esm/utils/input.js +0 -35
- package/lib/esm/utils/input.js.map +0 -1
- package/lib/esm/webview/contents-context.d.ts +0 -2
- package/lib/esm/webview/contents-context.js +0 -12
- package/lib/esm/webview/contents-context.js.map +0 -1
- package/lib/esm/webview/index.d.ts +0 -3
- package/lib/esm/webview/index.js +0 -10
- package/lib/esm/webview/index.js.map +0 -1
- package/lib/esm/webview/types.js +0 -9
- package/lib/esm/webview/types.js.map +0 -1
- package/lib/esm/webview/use-webview-contents.d.ts +0 -2
- package/lib/esm/webview/use-webview-contents.js +0 -83
- package/lib/esm/webview/use-webview-contents.js.map +0 -1
- /package/lib/{cjs/constants.d.ts → constants.d.ts} +0 -0
- /package/lib/{cjs/content-fields → content-fields}/hubtype-fields/node-types.d.ts +0 -0
- /package/lib/{cjs/services → services}/hubtype-queues-api.d.ts +0 -0
- /package/lib/{cjs/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
- /package/lib/{cjs/utils → utils}/authentication.d.ts +0 -0
- /package/lib/{cjs/utils → utils}/flow-locale.d.ts +0 -0
- /package/lib/{cjs/utils → utils}/input.d.ts +0 -0
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { EventAction, storeCaseRating } from "@botonic/core";
|
|
2
|
+
import { v7 } from "uuid";
|
|
3
|
+
import { AGENT_RATING_PAYLOAD, PUSH_FLOW_PAYLOAD, SEPARATOR } from "../constants.js";
|
|
4
|
+
import { trackEvent } from "../tracking.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
8
14
|
async function getContentsByPayload(context) {
|
|
9
15
|
const { cmsApi, flowBuilderPlugin, request, contentID } = context;
|
|
10
|
-
if (request.input.payload?.startsWith(
|
|
16
|
+
if (request.input.payload?.startsWith(AGENT_RATING_PAYLOAD)) {
|
|
11
17
|
return await resolveRatingPayload(context);
|
|
12
18
|
}
|
|
13
|
-
if (request.input.payload?.startsWith(
|
|
19
|
+
if (request.input.payload?.startsWith(PUSH_FLOW_PAYLOAD)) {
|
|
14
20
|
return await resolvePushFlowPayload(context);
|
|
15
21
|
}
|
|
16
|
-
const id = contentID
|
|
17
|
-
? cmsApi.getNodeByContentID(contentID)?.id
|
|
18
|
-
: request.input.payload;
|
|
22
|
+
const id = contentID ? cmsApi.getNodeByContentID(contentID)?.id : request.input.payload;
|
|
19
23
|
const targetNode = id ? cmsApi.getNodeById(id) : undefined;
|
|
20
24
|
if (targetNode) {
|
|
21
25
|
return await flowBuilderPlugin.getContentsByNode(targetNode);
|
|
@@ -30,20 +34,18 @@ async function resolveRatingPayload(context) {
|
|
|
30
34
|
const { target, text, value, possibleOptions, possibleValues } = flowBuilderPlugin.getRatingSubmittedInfo(request.input.payload);
|
|
31
35
|
if (request.session._hubtype_case_id) {
|
|
32
36
|
const event = {
|
|
33
|
-
action:
|
|
37
|
+
action: EventAction.FeedbackCase,
|
|
34
38
|
feedbackTargetId: request.session._hubtype_case_id,
|
|
35
|
-
feedbackGroupId:
|
|
39
|
+
feedbackGroupId: v7().toString(),
|
|
36
40
|
possibleOptions,
|
|
37
41
|
possibleValues,
|
|
38
42
|
option: text,
|
|
39
|
-
value
|
|
43
|
+
value
|
|
40
44
|
};
|
|
41
|
-
await
|
|
42
|
-
await
|
|
45
|
+
await storeCaseRating(request.session, value);
|
|
46
|
+
await trackEvent(request, EventAction.FeedbackCase, event);
|
|
43
47
|
}
|
|
44
|
-
const targetNode = target
|
|
45
|
-
? cmsApi.getNodeById(target.id)
|
|
46
|
-
: undefined;
|
|
48
|
+
const targetNode = target ? cmsApi.getNodeById(target.id) : undefined;
|
|
47
49
|
if (targetNode) {
|
|
48
50
|
return await flowBuilderPlugin.getContentsByNode(targetNode);
|
|
49
51
|
}
|
|
@@ -54,7 +56,7 @@ async function resolvePushFlowPayload(context) {
|
|
|
54
56
|
if (!request.input.payload) {
|
|
55
57
|
return [];
|
|
56
58
|
}
|
|
57
|
-
const parts = request.input.payload.split(
|
|
59
|
+
const parts = request.input.payload.split(SEPARATOR);
|
|
58
60
|
const pushFlowId = parts.length > 1 ? parts[1] : '';
|
|
59
61
|
if (!pushFlowId) {
|
|
60
62
|
return [];
|
|
@@ -65,10 +67,12 @@ async function resolvePushFlowPayload(context) {
|
|
|
65
67
|
return [];
|
|
66
68
|
}
|
|
67
69
|
return await flowBuilderPlugin.getContentsByNode(pushFlowNode);
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
+
} catch {
|
|
70
71
|
// Campaign not found - return empty to trigger fallback
|
|
71
72
|
return [];
|
|
72
73
|
}
|
|
73
74
|
}
|
|
75
|
+
|
|
76
|
+
export { getContentsByPayload };
|
|
77
|
+
|
|
74
78
|
//# sourceMappingURL=payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action/payload.js","sources":["../../src/action/payload.ts"],"sourcesContent":["import { EventAction, type EventFeedback, storeCaseRating } from '@botonic/core'\nimport { v7 as uuid } from 'uuid'\n\nimport {\n AGENT_RATING_PAYLOAD,\n PUSH_FLOW_PAYLOAD,\n SEPARATOR,\n} from '../constants'\nimport type { FlowContent } from '../content-fields'\nimport type { HtNodeWithContent } from '../content-fields/hubtype-fields'\nimport { trackEvent } from '../tracking'\nimport type { FlowBuilderContext } from './context'\n\nexport async function getContentsByPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request, contentID } = context\n if (request.input.payload?.startsWith(AGENT_RATING_PAYLOAD)) {\n return await resolveRatingPayload(context)\n }\n if (request.input.payload?.startsWith(PUSH_FLOW_PAYLOAD)) {\n return await resolvePushFlowPayload(context)\n }\n\n const id = contentID\n ? cmsApi.getNodeByContentID(contentID)?.id\n : request.input.payload\n const targetNode = id ? cmsApi.getNodeById<HtNodeWithContent>(id) : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolveRatingPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const { target, text, value, possibleOptions, possibleValues } =\n flowBuilderPlugin.getRatingSubmittedInfo(request.input.payload)\n\n if (request.session._hubtype_case_id) {\n const event: EventFeedback = {\n action: EventAction.FeedbackCase,\n feedbackTargetId: request.session._hubtype_case_id,\n feedbackGroupId: uuid().toString(),\n possibleOptions,\n possibleValues,\n option: text,\n value,\n }\n\n await storeCaseRating(request.session, value)\n await trackEvent(request, EventAction.FeedbackCase, event)\n }\n\n const targetNode = target\n ? cmsApi.getNodeById<HtNodeWithContent>(target.id)\n : undefined\n\n if (targetNode) {\n return await flowBuilderPlugin.getContentsByNode(targetNode)\n }\n\n return []\n}\n\nasync function resolvePushFlowPayload(\n context: FlowBuilderContext\n): Promise<FlowContent[]> {\n const { cmsApi, flowBuilderPlugin, request } = context\n\n if (!request.input.payload) {\n return []\n }\n\n const parts = request.input.payload.split(SEPARATOR)\n const pushFlowId = parts.length > 1 ? parts[1] : ''\n\n if (!pushFlowId) {\n return []\n }\n\n try {\n const pushFlowNode =\n cmsApi.getNodeByCampaignId<HtNodeWithContent>(pushFlowId)\n\n if (!pushFlowNode) {\n return []\n }\n\n return await flowBuilderPlugin.getContentsByNode(pushFlowNode)\n } catch {\n // Campaign not found - return empty to trigger fallback\n return []\n }\n}\n"],"names":["EventAction","storeCaseRating","v7","uuid","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","SEPARATOR","trackEvent","getContentsByPayload","context","cmsApi","flowBuilderPlugin","request","contentID","resolveRatingPayload","resolvePushFlowPayload","id","targetNode","undefined","target","text","value","possibleOptions","possibleValues","event","parts","pushFlowId","pushFlowNode"],"mappings":";;;;;;;;;AAAgF;AAC/C;AAMZ;AAGmB;AAGjC,eAAeQ,oBAAoBA,CACxCC,OAA2B;IAE3B,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;IAC1D,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWR,oBAAoBA,GAAG;QAC3D,OAAO,MAAMU,oBAAoBA,CAACL;IACpC;IACA,IAAIG,QAAQ,KAAK,CAAC,OAAO,EAAE,WAAWP,iBAAiBA,GAAG;QACxD,OAAO,MAAMU,sBAAsBA,CAACN;IACtC;IAEA,MAAMO,KAAKH,YACPH,OAAO,kBAA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;IACnD,MAAMoB,aAAaD,MAAM,MAAM,GAAG,IAAIA,KAAK,CAAC,EAAE,GAAG;IAEjD,IAAI,CAACC,YAAY;QACf,OAAO,EAAE;IACX;IAEA,IAAI;QACF,MAAMC,eACJjB,OAAO,mBAAmB,CAAoBgB;QAEhD,IAAI,CAACC,cAAc;YACjB,OAAO,EAAE;QACX;QAEA,OAAO,MAAMhB,kBAAkB,iBAAiB,CAACgB;IACnD,EAAE,OAAM;QACN,wDAAwD;QACxD,OAAO,EAAE;IACX;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginPreRequest } from '@botonic/core';
|
|
2
|
-
import { type HtBotActionNode, type HtCaptureUserInputNode, type HtFlowBuilderData, type HtFlowWebview, type HtKeywordNode, type HtNodeComponent, type HtNodeLink, type HtNodeWithContent, type HtRatingButton, type HtRatingNode, type HtSmartIntentNode } from './content-fields/hubtype-fields';
|
|
3
|
-
import { type FlowBuilderApiOptions } from './types';
|
|
2
|
+
import { type HtBotActionNode, type HtCaptureUserInputNode, type HtFlowBuilderData, type HtFlowWebview, type HtKeywordNode, type HtNodeComponent, type HtNodeLink, type HtNodeWithContent, type HtRatingButton, type HtRatingNode, type HtSmartIntentNode } from './content-fields/hubtype-fields/index.js';
|
|
3
|
+
import { type FlowBuilderApiOptions } from './types.js';
|
|
4
4
|
export declare class FlowBuilderApi {
|
|
5
5
|
url: string;
|
|
6
6
|
flowUrl: string;
|
|
@@ -1,79 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { AI_AGENTS_FLOW_NAME, SEPARATOR, UUID_REGEXP } from "./constants.js";
|
|
3
|
+
import { HtNodeWithContentType } from "./content-fields/hubtype-fields/index.js";
|
|
4
|
+
import { ProcessEnvNodeEnvs } from "./types.js";
|
|
5
|
+
import { FlowLocale } from "./utils/flow-locale.js";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
10
17
|
class FlowBuilderApi {
|
|
11
|
-
constructor() { }
|
|
12
18
|
static async create(options) {
|
|
13
19
|
const newApi = new FlowBuilderApi();
|
|
14
20
|
newApi.url = options.url;
|
|
15
21
|
newApi.request = options.request;
|
|
16
22
|
// TODO: Refactor later to combine logic from `FlowBuilderApi.create`, `resolveFlowUrl` and `getAccessToken` to be in one place
|
|
17
|
-
if (process.env.NODE_ENV ===
|
|
23
|
+
if (process.env.NODE_ENV === ProcessEnvNodeEnvs.DEVELOPMENT) {
|
|
18
24
|
await newApi.updateSessionWithUserInfo(options.accessToken);
|
|
19
25
|
}
|
|
20
26
|
const updatedRequest = newApi.request;
|
|
21
27
|
newApi.flowUrl = options.flowUrl.replace('{bot_id}', updatedRequest.session.bot.id);
|
|
22
|
-
newApi.flow = options.flow ??
|
|
28
|
+
newApi.flow = options.flow ?? await newApi.getFlow(options.accessToken);
|
|
23
29
|
return newApi;
|
|
24
30
|
}
|
|
25
31
|
async getFlow(token) {
|
|
26
|
-
const { data } = await
|
|
27
|
-
headers: {
|
|
32
|
+
const { data } = await axios.get(this.flowUrl, {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${token}`
|
|
35
|
+
}
|
|
28
36
|
});
|
|
29
37
|
return data;
|
|
30
38
|
}
|
|
31
39
|
async updateSessionWithUserInfo(token) {
|
|
32
40
|
const url = `${this.url}/v1/flow_builder/user_info/`;
|
|
33
|
-
const response = await
|
|
34
|
-
headers: {
|
|
41
|
+
const response = await axios.get(url, {
|
|
42
|
+
headers: {
|
|
43
|
+
Authorization: `Bearer ${token}`
|
|
44
|
+
}
|
|
35
45
|
});
|
|
36
46
|
this.request.session.organization_id = response.data.organization_id;
|
|
37
47
|
this.request.session.bot.id = response.data.bot_id;
|
|
38
48
|
}
|
|
39
49
|
getNodeByFlowId(id) {
|
|
40
|
-
const subFlow = this.flow.flows.find(subFlow
|
|
50
|
+
const subFlow = this.flow.flows.find((subFlow)=>subFlow.id === id);
|
|
41
51
|
if (!subFlow) {
|
|
42
52
|
throw Error(`SubFlow with id: '${id}' not found`);
|
|
43
53
|
}
|
|
44
54
|
return this.getNodeById(subFlow.start_node_id);
|
|
45
55
|
}
|
|
46
56
|
getNodeByCampaignId(id) {
|
|
47
|
-
const campaign = this.flow.campaigns.find(campaign
|
|
57
|
+
const campaign = this.flow.campaigns.find((campaign)=>campaign.id === id);
|
|
48
58
|
if (!campaign) {
|
|
49
59
|
throw Error(`Campaign with id: '${id}' not found`);
|
|
50
60
|
}
|
|
51
61
|
return this.getNodeById(campaign.start_node_id);
|
|
52
62
|
}
|
|
53
63
|
getNodeById(id) {
|
|
54
|
-
const node = this.flow.nodes.find(node
|
|
64
|
+
const node = this.flow.nodes.find((node)=>node.id === id);
|
|
55
65
|
if (!node) {
|
|
56
66
|
console.error(`Node with id: '${id}' not found`);
|
|
57
67
|
}
|
|
58
68
|
return node;
|
|
59
69
|
}
|
|
60
70
|
getRatingNodeByButtonId(id) {
|
|
61
|
-
const ratingNodes = this.flow.nodes.filter(node
|
|
62
|
-
const ratingNode = ratingNodes.find(node
|
|
71
|
+
const ratingNodes = this.flow.nodes.filter((node)=>node.type === HtNodeWithContentType.RATING);
|
|
72
|
+
const ratingNode = ratingNodes.find((node)=>node.content.buttons.some((button)=>button.id === id));
|
|
63
73
|
if (!ratingNode) {
|
|
64
74
|
throw Error(`Rating node with button id: '${id}' not found`);
|
|
65
75
|
}
|
|
66
76
|
return ratingNode;
|
|
67
77
|
}
|
|
68
78
|
getRatingButtonById(ratingNode, id) {
|
|
69
|
-
const ratingButton = ratingNode.content.buttons.find(button
|
|
79
|
+
const ratingButton = ratingNode.content.buttons.find((button)=>button.id === id);
|
|
70
80
|
if (!ratingButton) {
|
|
71
81
|
throw Error(`Rating button with id: '${id}' not found`);
|
|
72
82
|
}
|
|
73
83
|
return ratingButton;
|
|
74
84
|
}
|
|
75
85
|
getNodeByContentID(contentID) {
|
|
76
|
-
const content = this.flow.nodes.find(node
|
|
86
|
+
const content = this.flow.nodes.find((node)=>'code' in node ? node.code === contentID : false);
|
|
77
87
|
if (!content) {
|
|
78
88
|
throw Error(`Node with contentID: '${contentID}' not found`);
|
|
79
89
|
}
|
|
@@ -87,7 +97,7 @@ class FlowBuilderApi {
|
|
|
87
97
|
return this.getNodeById(startNodeId);
|
|
88
98
|
}
|
|
89
99
|
getFallbackNode(alternate) {
|
|
90
|
-
const fallbackNode = this.flow.nodes.find(node
|
|
100
|
+
const fallbackNode = this.flow.nodes.find((node)=>node.type === HtNodeWithContentType.FALLBACK);
|
|
91
101
|
if (!fallbackNode) {
|
|
92
102
|
throw new Error('Fallback node must be defined');
|
|
93
103
|
}
|
|
@@ -99,15 +109,13 @@ class FlowBuilderApi {
|
|
|
99
109
|
if (!fallbackSecondMessage) {
|
|
100
110
|
return this.getNodeById(fallbackFirstMessage.id);
|
|
101
111
|
}
|
|
102
|
-
return alternate
|
|
103
|
-
? this.getNodeById(fallbackFirstMessage.id)
|
|
104
|
-
: this.getNodeById(fallbackSecondMessage.id);
|
|
112
|
+
return alternate ? this.getNodeById(fallbackFirstMessage.id) : this.getNodeById(fallbackSecondMessage.id);
|
|
105
113
|
}
|
|
106
114
|
getSmartIntentNodes() {
|
|
107
|
-
return this.flow.nodes.filter(node
|
|
115
|
+
return this.flow.nodes.filter((node)=>node.type === HtNodeWithContentType.SMART_INTENT);
|
|
108
116
|
}
|
|
109
117
|
getKeywordNodes() {
|
|
110
|
-
return this.flow.nodes.filter(node
|
|
118
|
+
return this.flow.nodes.filter((node)=>node.type === HtNodeWithContentType.KEYWORD);
|
|
111
119
|
}
|
|
112
120
|
getPayload(target) {
|
|
113
121
|
if (!target) {
|
|
@@ -120,10 +128,10 @@ class FlowBuilderApi {
|
|
|
120
128
|
return false;
|
|
121
129
|
}
|
|
122
130
|
const node = this.getNodeById(id);
|
|
123
|
-
return node?.type ===
|
|
131
|
+
return node?.type === HtNodeWithContentType.BOT_ACTION;
|
|
124
132
|
}
|
|
125
133
|
isUUID(str) {
|
|
126
|
-
return
|
|
134
|
+
return UUID_REGEXP.test(str);
|
|
127
135
|
}
|
|
128
136
|
createPayloadWithParams(botActionNode) {
|
|
129
137
|
const payloadId = botActionNode.content.payload_id;
|
|
@@ -133,30 +141,28 @@ class FlowBuilderApi {
|
|
|
133
141
|
const followUpContentID = this.getFollowUpContentID(botActionNode.follow_up?.id);
|
|
134
142
|
const payloadParams = {
|
|
135
143
|
contentID,
|
|
136
|
-
followUpContentID
|
|
144
|
+
followUpContentID
|
|
137
145
|
};
|
|
138
146
|
const payloadJson = JSON.stringify({
|
|
139
147
|
...customParams,
|
|
140
|
-
...payloadParams
|
|
148
|
+
...payloadParams
|
|
141
149
|
});
|
|
142
|
-
return `${payloadNode.content.payload}${
|
|
150
|
+
return `${payloadNode.content.payload}${SEPARATOR}${payloadJson}`;
|
|
143
151
|
}
|
|
144
152
|
getFollowUpContentID(id) {
|
|
145
|
-
const followUpNode = id
|
|
146
|
-
? this.getNodeById(id)
|
|
147
|
-
: undefined;
|
|
153
|
+
const followUpNode = id ? this.getNodeById(id) : undefined;
|
|
148
154
|
return followUpNode?.code;
|
|
149
155
|
}
|
|
150
156
|
getFlowName(flowId) {
|
|
151
|
-
const flow = this.flow.flows.find(flow
|
|
157
|
+
const flow = this.flow.flows.find((flow)=>flow.id === flowId);
|
|
152
158
|
return flow ? flow.name : this.getCampaignFlowName(flowId);
|
|
153
159
|
}
|
|
154
160
|
getCampaignFlowName(campaignId) {
|
|
155
|
-
const campaign = this.flow.campaigns.find(campaign
|
|
161
|
+
const campaign = this.flow.campaigns.find((campaign)=>campaign.id === campaignId);
|
|
156
162
|
return campaign ? campaign.name : '';
|
|
157
163
|
}
|
|
158
164
|
getStartNodeAiAgentFlow() {
|
|
159
|
-
const aiAgentFlow = this.flow.flows.find(flow
|
|
165
|
+
const aiAgentFlow = this.flow.flows.find((flow)=>flow.name === AI_AGENTS_FLOW_NAME);
|
|
160
166
|
if (!aiAgentFlow) {
|
|
161
167
|
return undefined;
|
|
162
168
|
}
|
|
@@ -166,7 +172,7 @@ class FlowBuilderApi {
|
|
|
166
172
|
return this.flow.is_ai_agent_active || false;
|
|
167
173
|
}
|
|
168
174
|
getWebviewById(id) {
|
|
169
|
-
return this.flow.webviews.find(webview
|
|
175
|
+
return this.flow.webviews.find((webview)=>webview.id === id);
|
|
170
176
|
}
|
|
171
177
|
shouldCaptureUserInput() {
|
|
172
178
|
return !!this.getCaptureUserInputId();
|
|
@@ -178,7 +184,9 @@ class FlowBuilderApi {
|
|
|
178
184
|
if (this.request.session.capture_user_input) {
|
|
179
185
|
this.request.session.capture_user_input.node_id = id;
|
|
180
186
|
}
|
|
181
|
-
this.request.session.capture_user_input = {
|
|
187
|
+
this.request.session.capture_user_input = {
|
|
188
|
+
node_id: id
|
|
189
|
+
};
|
|
182
190
|
}
|
|
183
191
|
removeCaptureUserInputId() {
|
|
184
192
|
this.request.session.capture_user_input = undefined;
|
|
@@ -198,8 +206,11 @@ class FlowBuilderApi {
|
|
|
198
206
|
getResolvedLocale() {
|
|
199
207
|
const flowLocales = this.flow.locales;
|
|
200
208
|
const defaultLocaleCode = this.flow.default_locale_code;
|
|
201
|
-
return new
|
|
209
|
+
return new FlowLocale(this.request, flowLocales, defaultLocaleCode).resolve();
|
|
202
210
|
}
|
|
211
|
+
constructor(){}
|
|
203
212
|
}
|
|
204
|
-
|
|
213
|
+
|
|
214
|
+
export { FlowBuilderApi };
|
|
215
|
+
|
|
205
216
|
//# sourceMappingURL=api.js.map
|
package/lib/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../src/api.ts"],"sourcesContent":["import type { PluginPreRequest } from '@botonic/core'\nimport axios from 'axios'\n\nimport { AI_AGENTS_FLOW_NAME, SEPARATOR, UUID_REGEXP } from './constants'\nimport {\n type HtBotActionNode,\n type HtCaptureUserInputNode,\n type HtFallbackNode,\n type HtFlowBuilderData,\n type HtFlowWebview,\n type HtGoToFlow,\n type HtKeywordNode,\n type HtNodeComponent,\n type HtNodeLink,\n type HtNodeWithContent,\n HtNodeWithContentType,\n type HtPayloadNode,\n type HtRatingButton,\n type HtRatingNode,\n type HtSmartIntentNode,\n} from './content-fields/hubtype-fields'\nimport {\n type FlowBuilderApiOptions,\n type PayloadParamsBase,\n ProcessEnvNodeEnvs,\n} from './types'\nimport { FlowLocale } from './utils/flow-locale'\n\nexport class FlowBuilderApi {\n url: string\n flowUrl: string\n flow: HtFlowBuilderData\n request: PluginPreRequest\n\n private constructor() {}\n\n static async create(options: FlowBuilderApiOptions): Promise<FlowBuilderApi> {\n const newApi = new FlowBuilderApi()\n\n newApi.url = options.url\n newApi.request = options.request\n // TODO: Refactor later to combine logic from `FlowBuilderApi.create`, `resolveFlowUrl` and `getAccessToken` to be in one place\n if (process.env.NODE_ENV === ProcessEnvNodeEnvs.DEVELOPMENT) {\n await newApi.updateSessionWithUserInfo(options.accessToken)\n }\n const updatedRequest = newApi.request\n newApi.flowUrl = options.flowUrl.replace(\n '{bot_id}',\n updatedRequest.session.bot.id\n )\n newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken))\n return newApi\n }\n\n private async getFlow(token: string): Promise<HtFlowBuilderData> {\n const { data } = await axios.get(this.flowUrl, {\n headers: { Authorization: `Bearer ${token}` },\n })\n return data as HtFlowBuilderData\n }\n\n private async updateSessionWithUserInfo(token: string) {\n const url = `${this.url}/v1/flow_builder/user_info/`\n const response = await axios.get(url, {\n headers: { Authorization: `Bearer ${token}` },\n })\n this.request.session.organization_id = response.data.organization_id\n this.request.session.bot.id = response.data.bot_id\n }\n\n getNodeByFlowId(id: string): HtNodeWithContent {\n const subFlow = this.flow.flows.find(subFlow => subFlow.id === id)\n if (!subFlow) {\n throw Error(`SubFlow with id: '${id}' not found`)\n }\n return this.getNodeById<HtNodeWithContent>(subFlow.start_node_id)\n }\n\n getNodeByCampaignId<T extends HtNodeComponent>(id: string): T {\n const campaign = this.flow.campaigns.find(campaign => campaign.id === id)\n if (!campaign) {\n throw Error(`Campaign with id: '${id}' not found`)\n }\n return this.getNodeById<T>(campaign.start_node_id)\n }\n\n getNodeById<T extends HtNodeComponent>(id: string): T {\n const node = this.flow.nodes.find(node => node.id === id)\n if (!node) {\n console.error(`Node with id: '${id}' not found`)\n }\n\n return node as T\n }\n\n getRatingNodeByButtonId(id: string): HtRatingNode {\n const ratingNodes = this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.RATING\n ) as HtRatingNode[]\n const ratingNode = ratingNodes.find(node =>\n node.content.buttons.some(button => button.id === id)\n ) as HtRatingNode | undefined\n\n if (!ratingNode) {\n throw Error(`Rating node with button id: '${id}' not found`)\n }\n\n return ratingNode\n }\n\n getRatingButtonById(ratingNode: HtRatingNode, id: string): HtRatingButton {\n const ratingButton = ratingNode.content.buttons.find(\n button => button.id === id\n ) as HtRatingButton | undefined\n if (!ratingButton) {\n throw Error(`Rating button with id: '${id}' not found`)\n }\n\n return ratingButton\n }\n\n getNodeByContentID(contentID: string): HtNodeComponent {\n const content = this.flow.nodes.find(node =>\n 'code' in node ? node.code === contentID : false\n )\n if (!content) {\n throw Error(`Node with contentID: '${contentID}' not found`)\n }\n return content\n }\n\n getStartNode(): HtNodeWithContent {\n const startNodeId = this.flow.start_node_id\n if (!startNodeId) {\n throw new Error('Start node id must be defined')\n }\n return this.getNodeById(startNodeId)\n }\n\n getFallbackNode(alternate: boolean): HtNodeWithContent {\n const fallbackNode = this.flow.nodes.find(\n node => node.type === HtNodeWithContentType.FALLBACK\n ) as HtFallbackNode | undefined\n if (!fallbackNode) {\n throw new Error('Fallback node must be defined')\n }\n const fallbackFirstMessage = fallbackNode.content.first_message\n if (!fallbackFirstMessage) {\n throw new Error('Fallback 1st message must be defined')\n }\n const fallbackSecondMessage = fallbackNode.content.second_message\n if (!fallbackSecondMessage) {\n return this.getNodeById(fallbackFirstMessage.id)\n }\n return alternate\n ? this.getNodeById(fallbackFirstMessage.id)\n : this.getNodeById(fallbackSecondMessage.id)\n }\n\n getSmartIntentNodes(): HtSmartIntentNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.SMART_INTENT\n ) as HtSmartIntentNode[]\n }\n\n getKeywordNodes(): HtKeywordNode[] {\n return this.flow.nodes.filter(\n node => node.type === HtNodeWithContentType.KEYWORD\n ) as HtKeywordNode[]\n }\n\n getPayload(target?: HtNodeLink): string | undefined {\n if (!target) {\n return undefined\n }\n\n return target.id\n }\n\n isBotAction(id: string): boolean {\n if (!this.isUUID(id)) {\n return false\n }\n const node = this.getNodeById(id)\n return node?.type === HtNodeWithContentType.BOT_ACTION\n }\n\n private isUUID(str: string): boolean {\n return UUID_REGEXP.test(str)\n }\n\n createPayloadWithParams(botActionNode: HtBotActionNode): string {\n const payloadId = botActionNode.content.payload_id\n const payloadNode = this.getNodeById<HtPayloadNode>(payloadId)\n const customParams = JSON.parse(\n botActionNode.content.payload_params || '{}'\n )\n\n const contentID = botActionNode.code\n\n const followUpContentID = this.getFollowUpContentID(\n botActionNode.follow_up?.id\n )\n\n const payloadParams: PayloadParamsBase = {\n contentID,\n followUpContentID,\n }\n\n const payloadJson = JSON.stringify({\n ...customParams,\n ...payloadParams,\n })\n return `${payloadNode.content.payload}${SEPARATOR}${payloadJson}`\n }\n\n private getFollowUpContentID(id?: string): string | undefined {\n const followUpNode = id\n ? this.getNodeById<HtNodeWithContent | HtGoToFlow>(id)\n : undefined\n\n return followUpNode?.code\n }\n\n getFlowName(flowId: string): string {\n const flow = this.flow.flows.find(flow => flow.id === flowId)\n return flow ? flow.name : this.getCampaignFlowName(flowId)\n }\n\n getCampaignFlowName(campaignId: string): string {\n const campaign = this.flow.campaigns.find(\n campaign => campaign.id === campaignId\n )\n return campaign ? campaign.name : ''\n }\n\n getStartNodeAiAgentFlow(): HtNodeWithContent | undefined {\n const aiAgentFlow = this.flow.flows.find(\n flow => flow.name === AI_AGENTS_FLOW_NAME\n )\n\n if (!aiAgentFlow) {\n return undefined\n }\n\n return this.getNodeById<HtNodeWithContent>(aiAgentFlow.start_node_id)\n }\n\n isAiAgentEnabled(): boolean {\n return this.flow.is_ai_agent_active || false\n }\n\n getWebviewById(id: string): HtFlowWebview | undefined {\n return this.flow.webviews.find(webview => webview.id === id)\n }\n\n shouldCaptureUserInput(): boolean {\n return !!this.getCaptureUserInputId()\n }\n\n getCaptureUserInputId(): string | undefined {\n return this.request.session.capture_user_input?.node_id\n }\n\n setCaptureUserInputId(id: string): void {\n if (this.request.session.capture_user_input) {\n this.request.session.capture_user_input.node_id = id\n }\n this.request.session.capture_user_input = { node_id: id }\n }\n\n removeCaptureUserInputId(): void {\n this.request.session.capture_user_input = undefined\n }\n\n setUserExtraDataVariable(key: string, value: string): void {\n if (this.request.session.user.extra_data) {\n this.request.session.user.extra_data[key] = value\n }\n }\n\n getCaptureUserInputNode(): HtCaptureUserInputNode | undefined {\n const captureUserInputId = this.getCaptureUserInputId()\n if (!captureUserInputId) {\n return undefined\n }\n return this.getNodeById<HtCaptureUserInputNode>(captureUserInputId)\n }\n\n getResolvedLocale(): string {\n const flowLocales = this.flow.locales\n const defaultLocaleCode = this.flow.default_locale_code\n\n return new FlowLocale(\n this.request,\n flowLocales,\n defaultLocaleCode\n ).resolve()\n }\n}\n"],"names":["axios","AI_AGENTS_FLOW_NAME","SEPARATOR","UUID_REGEXP","HtNodeWithContentType","ProcessEnvNodeEnvs","FlowLocale","FlowBuilderApi","options","newApi","process","updatedRequest","token","data","url","response","id","subFlow","Error","campaign","node","console","ratingNodes","ratingNode","button","ratingButton","contentID","content","startNodeId","alternate","fallbackNode","fallbackFirstMessage","fallbackSecondMessage","target","undefined","str","botActionNode","payloadId","payloadNode","customParams","JSON","followUpContentID","payloadParams","payloadJson","followUpNode","flowId","flow","campaignId","aiAgentF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OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE;YACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAACD,IAAI,GAAGC;QAC9C;IACF;IAEA,0BAA8D;QAC5D,MAAMC,qBAAqB,IAAI,CAAC,qBAAqB;QACrD,IAAI,CAACA,oBAAoB;YACvB,OAAOlB;QACT;QACA,OAAO,IAAI,CAAC,WAAW,CAAyBkB;IAClD;IAEA,oBAA4B;QAC1B,MAAMC,cAAc,IAAI,CAAC,IAAI,CAAC,OAAO;QACrC,MAAMC,oBAAoB,IAAI,CAAC,IAAI,CAAC,mBAAmB;QAEvD,OAAO,IAAIhD,UAAUA,CACnB,IAAI,CAAC,OAAO,EACZ+C,aACAC,mBACA,OAAO;IACX;IAxQA,aAAsB,CAAC;AAyQzB"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const FLOW_BUILDER_API_URL_PROD = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com';
|
|
2
|
+
const SEPARATOR = '|';
|
|
3
|
+
const SOURCE_INFO_SEPARATOR = `${SEPARATOR}source_`;
|
|
4
|
+
const EMPTY_PAYLOAD = 'fb-empty-payload';
|
|
5
|
+
const VARIABLE_PATTERN_GLOBAL = /{([^{}]+)}/g;
|
|
6
|
+
const ACCESS_TOKEN_VARIABLE_KEY = '_access_token';
|
|
7
|
+
const REG_EXP_PATTERN = /^\/(.*)\/([gimyus]*)$/;
|
|
8
|
+
const UUID_REGEXP = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9
|
+
/* ********** PAYLOADS ********** */ const AGENT_RATING_PAYLOAD = 'agent-rating';
|
|
10
|
+
const PUSH_FLOW_PAYLOAD = 'push-flow';
|
|
11
|
+
/* ********** FLOW NAMES ********** */ const MAIN_FLOW_NAME = 'Main';
|
|
12
|
+
const AI_AGENTS_FLOW_NAME = 'AI Agents';
|
|
13
|
+
const FALLBACK_FLOW_NAME = 'Fallback';
|
|
14
|
+
|
|
15
|
+
export { ACCESS_TOKEN_VARIABLE_KEY, AGENT_RATING_PAYLOAD, AI_AGENTS_FLOW_NAME, EMPTY_PAYLOAD, FALLBACK_FLOW_NAME, FLOW_BUILDER_API_URL_PROD, MAIN_FLOW_NAME, PUSH_FLOW_PAYLOAD, REG_EXP_PATTERN, SEPARATOR, SOURCE_INFO_SEPARATOR, UUID_REGEXP, VARIABLE_PATTERN_GLOBAL };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const FLOW_BUILDER_API_URL_PROD =\n process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'\nexport const SEPARATOR = '|'\nexport const SOURCE_INFO_SEPARATOR = `${SEPARATOR}source_`\nexport const EMPTY_PAYLOAD = 'fb-empty-payload'\nexport const VARIABLE_PATTERN_GLOBAL = /{([^{}]+)}/g\nexport const ACCESS_TOKEN_VARIABLE_KEY = '_access_token'\nexport const REG_EXP_PATTERN = /^\\/(.*)\\/([gimyus]*)$/\nexport const UUID_REGEXP =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/* ********** PAYLOADS ********** */\nexport const AGENT_RATING_PAYLOAD = 'agent-rating'\nexport const PUSH_FLOW_PAYLOAD = 'push-flow'\n\n/* ********** FLOW NAMES ********** */\nexport const MAIN_FLOW_NAME = 'Main'\nexport const AI_AGENTS_FLOW_NAME = 'AI Agents'\nexport const FALLBACK_FLOW_NAME = 'Fallback'\n"],"names":["FLOW_BUILDER_API_URL_PROD","process","SEPARATOR","SOURCE_INFO_SEPARATOR","EMPTY_PAYLOAD","VARIABLE_PATTERN_GLOBAL","ACCESS_TOKEN_VARIABLE_KEY","REG_EXP_PATTERN","UUID_REGEXP","AGENT_RATING_PAYLOAD","PUSH_FLOW_PAYLOAD","MAIN_FLOW_NAME","AI_AGENTS_FLOW_NAME","FALLBACK_FLOW_NAME"],"mappings":"AAAO,MAAMA,yBAAyBA,GACpCC,QAAQ,GAAG,CAAC,eAAe,IAAI,0BAAyB;AACnD,MAAMC,SAASA,GAAG,IAAG;AACrB,MAAMC,qBAAqBA,GAAG,GAAGD,SAASA,CAAC,OAAO,CAAC;AACnD,MAAME,aAAaA,GAAG,mBAAkB;AACxC,MAAMC,uBAAuBA,GAAG,cAAa;AAC7C,MAAMC,yBAAyBA,GAAG,gBAAe;AACjD,MAAMC,eAAeA,GAAG,wBAAuB;AAC/C,MAAMC,WAAWA,GACtB,kEAAiE;AAEnE,kCAAkC,GAC3B,MAAMC,oBAAoBA,GAAG,eAAc;AAC3C,MAAMC,iBAAiBA,GAAG,YAAW;AAE5C,oCAAoC,GAC7B,MAAMC,cAAcA,GAAG,OAAM;AAC7B,MAAMC,mBAAmBA,GAAG,YAAW;AACvC,MAAMC,kBAAkBA,GAAG,WAAU"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BotContext } from '@botonic/core';
|
|
2
|
-
import type { HtMediaFileLocale, HtNodeLink, HtQueueLocale, HtTextLocale, HtVideoLocale } from './hubtype-fields';
|
|
3
|
-
import type { FlowContent } from './index';
|
|
2
|
+
import type { HtMediaFileLocale, HtNodeLink, HtQueueLocale, HtTextLocale, HtVideoLocale } from './hubtype-fields/index.js';
|
|
3
|
+
import type { FlowContent } from './index.js';
|
|
4
4
|
export declare abstract class ContentFieldsBase {
|
|
5
5
|
readonly id: string;
|
|
6
6
|
code: string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ACCESS_TOKEN_VARIABLE_KEY, VARIABLE_PATTERN_GLOBAL } from "../constants.js";
|
|
2
|
+
import { ContentFilterExecutor } from "../filters/index.js";
|
|
3
|
+
import { getFlowBuilderPlugin } from "../utils/get-flow-builder-plugin.js";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ContentFieldsBase {
|
|
12
|
+
async filterContent(botContext, content) {
|
|
13
|
+
const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins);
|
|
14
|
+
const contentFilters = flowBuilderPlugin.contentFilters;
|
|
15
|
+
const contentFilterExecutor = new ContentFilterExecutor({
|
|
16
|
+
filters: contentFilters
|
|
17
|
+
});
|
|
18
|
+
const filteredContent = await contentFilterExecutor.filter(botContext, content);
|
|
19
|
+
return filteredContent;
|
|
20
|
+
}
|
|
21
|
+
static getTextByLocale(locale, text) {
|
|
22
|
+
const result = text.find((t)=>t.locale === locale);
|
|
23
|
+
return result?.message ?? '';
|
|
24
|
+
}
|
|
25
|
+
static getAssetByLocale(locale, asset) {
|
|
26
|
+
const result = asset.find((i)=>i.locale === locale);
|
|
27
|
+
return result?.file ?? '';
|
|
28
|
+
}
|
|
29
|
+
static getVideoByLocale(locale, video) {
|
|
30
|
+
const result = video.find((v)=>v.locale === locale);
|
|
31
|
+
return result?.url ?? '';
|
|
32
|
+
}
|
|
33
|
+
static getQueueByLocale(locale, queues) {
|
|
34
|
+
return queues.find((queue)=>queue.locale === locale);
|
|
35
|
+
}
|
|
36
|
+
replaceVariables(text, botContext) {
|
|
37
|
+
if (!botContext) {
|
|
38
|
+
return text;
|
|
39
|
+
}
|
|
40
|
+
return text.replace(VARIABLE_PATTERN_GLOBAL, (match)=>{
|
|
41
|
+
// remove \\ ( escape for _ ) added by text node with markdown
|
|
42
|
+
const keyPath = match.slice(1, -1).replaceAll('\\', '');
|
|
43
|
+
const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY) ? match : this.getValueFromKeyPath(botContext, keyPath);
|
|
44
|
+
return this.isValidType(botVariable) ? String(botVariable) : match;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
getValueFromKeyPath(botContext, keyPath) {
|
|
48
|
+
if (keyPath.startsWith('session.user.contact_info.')) {
|
|
49
|
+
const name = keyPath.split('.').at(-1);
|
|
50
|
+
return botContext.session.user.contact_info?.find((contact)=>contact.name === name)?.value;
|
|
51
|
+
}
|
|
52
|
+
if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {
|
|
53
|
+
return keyPath.split('.').reduce((object, key)=>this.resolveObjectKey(object, key), botContext);
|
|
54
|
+
}
|
|
55
|
+
return keyPath.split('.').reduce((object, key)=>this.resolveObjectKey(object, key), botContext.session.user.extra_data);
|
|
56
|
+
}
|
|
57
|
+
resolveObjectKey(object, key) {
|
|
58
|
+
if (object && object[key] !== undefined) {
|
|
59
|
+
return object[key];
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
isValidType(botVariable) {
|
|
64
|
+
const validTypes = [
|
|
65
|
+
'boolean',
|
|
66
|
+
'string',
|
|
67
|
+
'number'
|
|
68
|
+
];
|
|
69
|
+
return validTypes.includes(typeof botVariable);
|
|
70
|
+
}
|
|
71
|
+
constructor(id){
|
|
72
|
+
this.id = id;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { ContentFieldsBase };
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=content-fields-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/content-fields-base.js","sources":["../../src/content-fields/content-fields-base.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\nimport {\n ACCESS_TOKEN_VARIABLE_KEY,\n VARIABLE_PATTERN_GLOBAL,\n} from '../constants'\nimport { ContentFilterExecutor } from '../filters'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport type {\n HtMediaFileLocale,\n HtNodeLink,\n HtQueueLocale,\n HtTextLocale,\n HtVideoLocale,\n} from './hubtype-fields'\nimport type { FlowContent } from './index'\n\nexport abstract class ContentFieldsBase {\n public code: string\n public followUp?: HtNodeLink\n\n constructor(public readonly id: string) {}\n\n abstract trackFlow(botContext: BotContext): Promise<void>\n\n abstract processContent(botContext: BotContext): Promise<void>\n\n async filterContent(\n botContext: BotContext,\n content: FlowContent\n ): Promise<FlowContent> {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const contentFilters = flowBuilderPlugin.contentFilters\n const contentFilterExecutor = new ContentFilterExecutor({\n filters: contentFilters,\n })\n const filteredContent = await contentFilterExecutor.filter(\n botContext,\n content\n )\n return filteredContent\n }\n\n static getTextByLocale(locale: string, text: HtTextLocale[]): string {\n const result = text.find(t => t.locale === locale)\n return result?.message ?? ''\n }\n\n static getAssetByLocale(locale: string, asset: HtMediaFileLocale[]): string {\n const result = asset.find(i => i.locale === locale)\n return result?.file ?? ''\n }\n\n static getVideoByLocale(locale: string, video: HtVideoLocale[]): string {\n const result = video.find(v => v.locale === locale)\n return result?.url ?? ''\n }\n\n static getQueueByLocale(\n locale: string,\n queues: HtQueueLocale[]\n ): HtQueueLocale | undefined {\n return queues.find(queue => queue.locale === locale)\n }\n\n replaceVariables(text: string, botContext: BotContext): string {\n if (!botContext) {\n return text\n }\n\n return text.replace(VARIABLE_PATTERN_GLOBAL, match => {\n // remove \\\\ ( escape for _ ) added by text node with markdown\n const keyPath = match.slice(1, -1).replaceAll('\\\\', '')\n\n const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)\n ? match\n : this.getValueFromKeyPath(botContext, keyPath)\n\n return this.isValidType(botVariable) ? String(botVariable) : match\n })\n }\n\n getValueFromKeyPath(botContext: BotContext, keyPath: string): any {\n if (keyPath.startsWith('session.user.contact_info.')) {\n const name = keyPath.split('.').at(-1)\n return botContext.session.user.contact_info?.find(\n contact => contact.name === name\n )?.value\n }\n\n if (keyPath.startsWith('input.') || keyPath.startsWith('session.')) {\n return keyPath\n .split('.')\n .reduce((object, key) => this.resolveObjectKey(object, key), botContext)\n }\n\n return keyPath\n .split('.')\n .reduce(\n (object, key) => this.resolveObjectKey(object, key),\n botContext.session.user.extra_data\n )\n }\n\n private resolveObjectKey(object: any, key: string): any {\n if (object && object[key] !== undefined) {\n return object[key]\n }\n return undefined\n }\n\n private isValidType(botVariable: any): boolean {\n const validTypes = ['boolean', 'string', 'number']\n return validTypes.includes(typeof botVariable)\n }\n}\n"],"names":["ACCESS_TOKEN_VARIABLE_KEY","VARIABLE_PATTERN_GLOBAL","ContentFilterExecutor","getFlowBuilderPlugin","ContentFieldsBase","botContext","content","flowBuilderPlugin","contentFilters","contentFilterExecutor","filteredContent","locale","text","result","t","asset","i","video","v","queues","queue","match","keyPath","botVariable","String","name","contact","object","key","undefined","validTypes","id"],"mappings":";;;;;;;AAIqB;AAC6B;AACqB;AAUhE,MAAeI,iBAAiBA;IAUrC,MAAM,cACJC,UAAsB,EACtBC,OAAoB,EACE;QACtB,MAAMC,oBAAoBJ,oBAAoBA,CAACE,WAAW,OAAO;QACjE,MAAMG,iBAAiBD,kBAAkB,cAAc;QACvD,MAAME,wBAAwB,IAAIP,qBAAqBA,CAAC;YACtD,SAASM;QACX;QACA,MAAME,kBAAkB,MAAMD,sBAAsB,MAAM,CACxDJ,YACAC;QAEF,OAAOI;IACT;IAEA,OAAO,gBAAgBC,MAAc,EAAEC,IAAoB,EAAU;QACnE,MAAMC,SAASD,KAAK,IAAI,CAACE,CAAAA,IAAKA,EAAE,MAAM,KAAKH;QAC3C,OAAOE,QAAQ,WAAW;IAC5B;IAEA,OAAO,iBAAiBF,MAAc,EAAEI,KAA0B,EAAU;QAC1E,MAAMF,SAASE,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,MAAM,KAAKL;QAC5C,OAAOE,QAAQ,QAAQ;IACzB;IAEA,OAAO,iBAAiBF,MAAc,EAAEM,KAAsB,EAAU;QACtE,MAAMJ,SAASI,MAAM,IAAI,CAACC,CAAAA,IAAKA,EAAE,MAAM,KAAKP;QAC5C,OAAOE,QAAQ,OAAO;IACxB;IAEA,OAAO,iBACLF,MAAc,EACdQ,MAAuB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EQ,YAAYN,WAAgB,EAAW;QAC7C,MAAMO,aAAa;YAAC;YAAW;YAAU;SAAS;QAClD,OAAOA,WAAW,QAAQ,CAAC,OAAOP;IACpC;IA7FA,YAA4BQ,EAAU,CAAE;aAAZA,KAAAA;IAAa;AA8F3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BooleanConditionOperator, type HtBooleanCondition, type HtNumberCondition, type HtStringCondition, NumberConditionOperator, StringConditionOperator } from '../hubtype-fields';
|
|
1
|
+
import { BooleanConditionOperator, type HtBooleanCondition, type HtNumberCondition, type HtStringCondition, NumberConditionOperator, StringConditionOperator } from '../hubtype-fields/index.js';
|
|
2
2
|
type StringEvaluator = (variable: string, value: string) => boolean;
|
|
3
3
|
type NumberEvaluator = (variable: number, value: number, condition: HtNumberCondition) => boolean;
|
|
4
4
|
type BooleanEvaluator = (variable: boolean) => boolean;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BooleanConditionOperator, NumberConditionOperator, StringConditionOperator } from "../hubtype-fields/index.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function getMinAndMax(condition) {
|
|
6
|
+
if (condition.min !== undefined && condition.max !== undefined) {
|
|
7
|
+
return {
|
|
8
|
+
min: condition.min,
|
|
9
|
+
max: condition.max
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
throw new Error(`Min or max not found for number condition ${condition.operator}`);
|
|
13
|
+
}
|
|
14
|
+
const STRING_CONDITION_EVALUATORS = {
|
|
15
|
+
[StringConditionOperator.Contains]: (variable, value)=>variable.includes(value),
|
|
16
|
+
[StringConditionOperator.NotContains]: (variable, value)=>!variable.includes(value),
|
|
17
|
+
[StringConditionOperator.EqualsTo]: (variable, value)=>variable === value,
|
|
18
|
+
[StringConditionOperator.NotEqualsTo]: (variable, value)=>variable !== value,
|
|
19
|
+
[StringConditionOperator.StartsWith]: (variable, value)=>variable.startsWith(value),
|
|
20
|
+
[StringConditionOperator.NotStartsWith]: (variable, value)=>!variable.startsWith(value),
|
|
21
|
+
[StringConditionOperator.EndsWith]: (variable, value)=>variable.endsWith(value),
|
|
22
|
+
[StringConditionOperator.NotEndsWith]: (variable, value)=>!variable.endsWith(value)
|
|
23
|
+
};
|
|
24
|
+
const NUMBER_CONDITION_EVALUATORS = {
|
|
25
|
+
[NumberConditionOperator.EqualsTo]: (variable, value)=>variable === value,
|
|
26
|
+
[NumberConditionOperator.NotEqualsTo]: (variable, value)=>variable !== value,
|
|
27
|
+
[NumberConditionOperator.GreaterThan]: (variable, value)=>variable > value,
|
|
28
|
+
[NumberConditionOperator.LessThan]: (variable, value)=>variable < value,
|
|
29
|
+
[NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value)=>variable >= value,
|
|
30
|
+
[NumberConditionOperator.LessThanOrEqualTo]: (variable, value)=>variable <= value,
|
|
31
|
+
[NumberConditionOperator.Between]: (variable, _value, condition)=>{
|
|
32
|
+
const { min, max } = getMinAndMax(condition);
|
|
33
|
+
return variable >= min && variable <= max;
|
|
34
|
+
},
|
|
35
|
+
[NumberConditionOperator.NotBetween]: (variable, _value, condition)=>{
|
|
36
|
+
const { min, max } = getMinAndMax(condition);
|
|
37
|
+
return variable < min || variable > max;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const BOOLEAN_CONDITION_EVALUATORS = {
|
|
41
|
+
[BooleanConditionOperator.IsTruthy]: (variable)=>!!variable
|
|
42
|
+
};
|
|
43
|
+
function evaluateStringCondition(variable, condition) {
|
|
44
|
+
if (condition.value === undefined) {
|
|
45
|
+
throw new Error(`Value not found for string condition ${condition.operator}`);
|
|
46
|
+
}
|
|
47
|
+
const evaluator = STRING_CONDITION_EVALUATORS[condition.operator];
|
|
48
|
+
if (!evaluator) {
|
|
49
|
+
throw new Error(`Invalid string condition operator ${condition.operator}`);
|
|
50
|
+
}
|
|
51
|
+
return evaluator(variable, condition.value);
|
|
52
|
+
}
|
|
53
|
+
function evaluateNumberCondition(variable, condition) {
|
|
54
|
+
if (condition.value === undefined) {
|
|
55
|
+
throw new Error(`Value not found for number condition ${condition.operator}`);
|
|
56
|
+
}
|
|
57
|
+
const evaluator = NUMBER_CONDITION_EVALUATORS[condition.operator];
|
|
58
|
+
if (!evaluator) {
|
|
59
|
+
throw new Error(`Invalid number condition operator ${condition.operator}`);
|
|
60
|
+
}
|
|
61
|
+
return evaluator(variable, condition.value, condition);
|
|
62
|
+
}
|
|
63
|
+
function evaluateBooleanCondition(variable, condition) {
|
|
64
|
+
const evaluator = BOOLEAN_CONDITION_EVALUATORS[condition.operator];
|
|
65
|
+
if (!evaluator) {
|
|
66
|
+
throw new Error(`Invalid boolean condition operator ${condition.operator}`);
|
|
67
|
+
}
|
|
68
|
+
return evaluator(variable);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { BOOLEAN_CONDITION_EVALUATORS, NUMBER_CONDITION_EVALUATORS, STRING_CONDITION_EVALUATORS, evaluateBooleanCondition, evaluateNumberCondition, evaluateStringCondition, getMinAndMax };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=custom-conditional-v2-evaluators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-fields/custom-conditional/custom-conditional-v2-evaluators.js","sources":["../../../src/content-fields/custom-conditional/custom-conditional-v2-evaluators.ts"],"sourcesContent":["import {\n BooleanConditionOperator,\n type HtBooleanCondition,\n type HtNumberCondition,\n type HtStringCondition,\n NumberConditionOperator,\n StringConditionOperator,\n} from '../hubtype-fields'\n\ntype StringEvaluator = (variable: string, value: string) => boolean\n\ntype NumberEvaluator = (\n variable: number,\n value: number,\n condition: HtNumberCondition\n) => boolean\n\ntype BooleanEvaluator = (variable: boolean) => boolean\n\nexport function getMinAndMax(condition: HtNumberCondition): {\n min: number\n max: number\n} {\n if (condition.min !== undefined && condition.max !== undefined) {\n return { min: condition.min, max: condition.max }\n }\n throw new Error(\n `Min or max not found for number condition ${condition.operator}`\n )\n}\n\nexport const STRING_CONDITION_EVALUATORS: Record<\n StringConditionOperator,\n StringEvaluator\n> = {\n [StringConditionOperator.Contains]: (variable, value) =>\n variable.includes(value),\n [StringConditionOperator.NotContains]: (variable, value) =>\n !variable.includes(value),\n [StringConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [StringConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [StringConditionOperator.StartsWith]: (variable, value) =>\n variable.startsWith(value),\n [StringConditionOperator.NotStartsWith]: (variable, value) =>\n !variable.startsWith(value),\n [StringConditionOperator.EndsWith]: (variable, value) =>\n variable.endsWith(value),\n [StringConditionOperator.NotEndsWith]: (variable, value) =>\n !variable.endsWith(value),\n}\n\nexport const NUMBER_CONDITION_EVALUATORS: Record<\n NumberConditionOperator,\n NumberEvaluator\n> = {\n [NumberConditionOperator.EqualsTo]: (variable, value) => variable === value,\n [NumberConditionOperator.NotEqualsTo]: (variable, value) =>\n variable !== value,\n [NumberConditionOperator.GreaterThan]: (variable, value) => variable > value,\n [NumberConditionOperator.LessThan]: (variable, value) => variable < value,\n [NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value) =>\n variable >= value,\n [NumberConditionOperator.LessThanOrEqualTo]: (variable, value) =>\n variable <= value,\n [NumberConditionOperator.Between]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable >= min && variable <= max\n },\n [NumberConditionOperator.NotBetween]: (variable, _value, condition) => {\n const { min, max } = getMinAndMax(condition)\n return variable < min || variable > max\n },\n}\n\nexport const BOOLEAN_CONDITION_EVALUATORS: Record<\n BooleanConditionOperator,\n BooleanEvaluator\n> = {\n [BooleanConditionOperator.IsTruthy]: variable => !!variable,\n}\n\nexport function evaluateStringCondition(\n variable: string,\n condition: HtStringCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for string condition ${condition.operator}`\n )\n }\n const evaluator = STRING_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid string condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value)\n}\n\nexport function evaluateNumberCondition(\n variable: number,\n condition: HtNumberCondition\n): boolean {\n if (condition.value === undefined) {\n throw new Error(\n `Value not found for number condition ${condition.operator}`\n )\n }\n const evaluator = NUMBER_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid number condition operator ${condition.operator}`)\n }\n return evaluator(variable, condition.value, condition)\n}\n\nexport function evaluateBooleanCondition(\n variable: boolean,\n condition: HtBooleanCondition\n): boolean {\n const evaluator = BOOLEAN_CONDITION_EVALUATORS[condition.operator]\n if (!evaluator) {\n throw new Error(`Invalid boolean condition operator ${condition.operator}`)\n }\n return evaluator(variable)\n}\n"],"names":["BooleanConditionOperator","NumberConditionOperator","StringConditionOperator","getMinAndMax","condition","undefined","Error","STRING_CONDITION_EVALUATORS","variable","value","NUMBER_CONDITION_EVALUATORS","_value","min","max","BOOLEAN_CONDITION_EVALUATORS","evaluateStringCondition","evaluator","evaluateNumberCondition","evaluateBooleanCondition"],"mappings":";;;AAO0B;AAYnB,SAASG,YAAYA,CAACC,SAA4B;IAIvD,IAAIA,UAAU,GAAG,KAAKC,aAAaD,UAAU,GAAG,KAAKC,WAAW;QAC9D,OAAO;YAAE,KAAKD,UAAU,GAAG;YAAE,KAAKA,UAAU,GAAG;QAAC;IAClD;IACA,MAAM,IAAIE,MACR,CAAC,0CAA0C,EAAEF,UAAU,QAAQ,EAAE;AAErE;AAEO,MAAMG,2BAA2BA,GAGpC;IACF,CAACL,gCAAgC,CAAC,EAAE,CAACM,UAAUC,QAC7CD,SAAS,QAAQ,CAACC;IACpB,CAACP,mCAAmC,CAAC,EAAE,CAACM,UAAUC,QAChD,CAACD,SAAS,QAAQ,CAACC;IACrB,CAACP,gCAAgC,CAAC,EAAE,CAACM,UAAUC,QAAUD,aAAaC;IACtE,CAACP,mCAAmC,CAAC,EAAE,CAACM,UAAUC,QAChDD,aAAaC;IACf,CAACP,kCAAkC,CAAC,EAAE,CAACM,UAAUC,QAC/C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