UNPKG

@botonic/plugin-flow-builder

Version:

Use Flow Builder to show your contents

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