UNPKG

@webuildbots/webuildbots-sdk

Version:
119 lines (118 loc) 3.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var block_enums_1 = require("../../const/block-enums"); var BlockBuilder = /** @class */ (function () { function BlockBuilder() { this.block = { name: BlockBuilder.DEFAULT_NAME, group: BlockBuilder.DEFAULT_GROUP, revision: BlockBuilder.VERSION, created: new Date(), content: {}, meta: {}, deleted: false }; } BlockBuilder.prototype.addTitle = function (lang, title) { var content = this.block.content; if (!content.title) { content.title = {}; } content.title[lang] = title; return this; }; BlockBuilder.prototype.name = function (s) { this.block.name = s; return this; }; BlockBuilder.prototype.group = function (s) { if (s === '') { s = 'default'; } this.block.group = s; return this; }; BlockBuilder.prototype.module = function (module) { this.block.module = module; return this; }; BlockBuilder.prototype.description = function (description) { this.block.meta.description = description; return this; }; BlockBuilder.prototype.type = function (bt) { this.block.type = bt; return this; }; BlockBuilder.prototype.next = function (blockId) { this.block.next = blockId; return this; }; BlockBuilder.prototype.addVariable = function (title, value) { if (!this.block.variables) { this.block.variables = []; } this.block.variables.push({ title: title, value: value }); return this; }; BlockBuilder.prototype.onReply = function (blockId, args) { this.block.onReply = { blockId: blockId, args: args }; return this; }; BlockBuilder.prototype.formFieldCallback = function (args) { this.block.formFieldCallback = { args: args }; return this; }; BlockBuilder.prototype.voiceAction = function (voiceAction) { this.block.voiceAction = voiceAction; return this; }; BlockBuilder.prototype.twilioVerb = function (twilioVerb) { this.block.meta.twilioVerb = twilioVerb; return this; }; BlockBuilder.prototype.twilioVerbAttributes = function (verbAttributes) { this.block.meta.twilioVerbAttributes = verbAttributes; return this; }; BlockBuilder.prototype.twilioGatherRepeats = function (numRepeats) { this.block.meta.twilioGatherRepeats = numRepeats; return this; }; BlockBuilder.prototype.jovoFollowUpState = function (state) { this.block.meta.jovoFollowUpState = state; return this; }; BlockBuilder.prototype.messengerTag = function (tag) { this.block.meta.messengerTag = tag; return this; }; BlockBuilder.prototype.addIntent = function (intentName, blockPointer) { if (!this.block.intentMap) { this.block.intentMap = {}; } this.block.intentMap[intentName] = blockPointer; return this; }; BlockBuilder.prototype.alexaPermissionRequired = function (userInfo) { this.block.meta.alexaPermissionRequired = userInfo; return this; }; /** * This function will use to build block object * @returns Block */ BlockBuilder.prototype.build = function () { return this.block; }; BlockBuilder.DEFAULT_NAME = block_enums_1.CommonGroups.BUILT_AT_RUNTIME; BlockBuilder.DEFAULT_GROUP = block_enums_1.CommonGroups.BUILT_AT_RUNTIME; BlockBuilder.VERSION = 1; return BlockBuilder; }()); exports.default = BlockBuilder;