UNPKG

botbuilder-dialogs-adaptive

Version:

Rule system for the Microsoft BotBuilder dialog system.

55 lines 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OnChooseEntity = void 0; /** * @module botbuilder-dialogs-adaptive */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ const adaptive_expressions_1 = require("adaptive-expressions"); const botbuilder_dialogs_1 = require("botbuilder-dialogs"); const adaptiveEvents_1 = require("../adaptiveEvents"); const onDialogEvent_1 = require("./onDialogEvent"); /** * Triggered to choose between different possible entity resolutions. */ class OnChooseEntity extends onDialogEvent_1.OnDialogEvent { /** * Initializes a new instance of the [OnChooseEntity](xref:botbuilder-dialogs-adaptive.OnChooseEntity) class. * * @param {string} property Optional, property for filtering events. * @param {string} value Optional, value filtering events. * @param {string} operation Optional, operation for filtering events. * @param {Dialog[]} actions Optional, actions to add to the plan when the rule constraints are met. * @param {string} condition Optional, condition which needs to be met for the actions to be executed. */ constructor(property, value, operation, actions = [], condition) { super(adaptiveEvents_1.AdaptiveEvents.chooseEntity, actions, condition); this.property = property; this.value = value; this.operation = operation; } /** * Create the expression for this condition. * * @returns [Expression](xref:adaptive-expressions.Expression) used to evaluate this rule. */ createExpression() { const expressions = [super.createExpression()]; if (this.property) { expressions.push(adaptive_expressions_1.Expression.parse(`${botbuilder_dialogs_1.TurnPath.dialogEvent}.value.property == '${this.property}'`)); } if (this.value) { expressions.push(adaptive_expressions_1.Expression.parse(`${botbuilder_dialogs_1.TurnPath.dialogEvent}.value.value.name == '${this.value}'`)); } if (this.operation) { expressions.push(adaptive_expressions_1.Expression.parse(`${botbuilder_dialogs_1.TurnPath.dialogEvent}.value.operation == '${this.operation}'`)); } return adaptive_expressions_1.Expression.andExpression(...expressions); } } exports.OnChooseEntity = OnChooseEntity; OnChooseEntity.$kind = 'Microsoft.OnChooseEntity'; //# sourceMappingURL=onChooseEntity.js.map