UNPKG

botbuilder-dialogs-adaptive

Version:

Rule system for the Microsoft BotBuilder dialog system.

55 lines 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OnAssignEntity = 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 assign an entity to a property. */ class OnAssignEntity extends onDialogEvent_1.OnDialogEvent { /** * Initializes a new instance of the [OnAssignEntity](xref:botbuilder-dialogs-adaptive.OnAssignEntity) class. * * @param property Optional, property filter on event. * @param value Optional, value filter on event. * @param operation Optional, operation filter on event. * @param actions Optional, actions to add to the plan when the rule constraints are met. * @param condition Optional, condition which needs to be met for the actions to be executed. */ constructor(property, value, operation, actions = [], condition) { super(adaptiveEvents_1.AdaptiveEvents.assignEntity, 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.OnAssignEntity = OnAssignEntity; OnAssignEntity.$kind = 'Microsoft.OnAssignEntity'; //# sourceMappingURL=onAssignEntity.js.map