UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

61 lines 3.58 kB
import { __awaiter } from "tslib"; import { FlowAiAgent, FlowBotAction, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowGoToFlow, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, } from './content-fields'; import { HtNodeWithContentType, } from './content-fields/hubtype-fields'; export class FlowFactory { constructor(request, cmsApi, locale) { this.currentRequest = request; this.cmsApi = cmsApi; this.locale = locale; } getFlowContent(hubtypeContent) { return __awaiter(this, void 0, void 0, function* () { switch (hubtypeContent.type) { case HtNodeWithContentType.TEXT: return FlowText.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.IMAGE: return FlowImage.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.CAROUSEL: return FlowCarousel.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.VIDEO: return FlowVideo.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.WHATSAPP_BUTTON_LIST: return FlowWhatsappButtonList.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.WHATSAPP_CTA_URL_BUTTON: return FlowWhatsappCtaUrlButtonNode.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.HANDOFF: return FlowHandoff.fromHubtypeCMS(hubtypeContent, this.locale, this.cmsApi); case HtNodeWithContentType.KNOWLEDGE_BASE: return FlowKnowledgeBase.fromHubtypeCMS(hubtypeContent); case HtNodeWithContentType.AI_AGENT: return FlowAiAgent.fromHubtypeCMS(hubtypeContent); case HtNodeWithContentType.RATING: return FlowRating.fromHubtypeCMS(hubtypeContent, this.locale); case HtNodeWithContentType.BOT_ACTION: return FlowBotAction.fromHubtypeCMS(hubtypeContent, this.cmsApi); case HtNodeWithContentType.FUNCTION: return this.resolveFlowFunctionContent(hubtypeContent); case HtNodeWithContentType.GO_TO_FLOW: return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi); default: return undefined; } }); } resolveFlowFunctionContent(hubtypeContent) { return __awaiter(this, void 0, void 0, function* () { switch (hubtypeContent.content.action) { case 'check-country': return FlowCountryConditional.fromHubtypeCMS(hubtypeContent, this.currentRequest); case 'get-channel-type': return FlowChannelConditional.fromHubtypeCMS(hubtypeContent, this.currentRequest); case 'check-queue-status': return FlowQueueStatusConditional.fromHubtypeCMS(hubtypeContent, this.locale); case 'check-bot-variable': return FlowCustomConditional.fromHubtypeCMS(hubtypeContent, this.currentRequest); default: return undefined; } }); } } //# sourceMappingURL=flow-factory.js.map