UNPKG

botbuilder-dialogs-adaptive

Version:

Rule system for the Microsoft BotBuilder dialog system.

123 lines 4.53 kB
/** * @module botbuilder-dialogs-adaptive */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { ActionChangeList } from '../actionChangeList'; import { ActionContext } from '../actionContext'; import { ActionScope } from '../actions/actionScope'; import { BoolProperty, NumberProperty } from '../properties'; import { BoolExpression, Expression, NumberExpression } from 'adaptive-expressions'; import { Configurable, Converter, ConverterFactory, Dialog, DialogDependencies } from 'botbuilder-dialogs'; export interface OnConditionConfiguration { condition?: BoolProperty; actions?: string[] | Dialog[]; priority?: NumberProperty; runOnce?: boolean; id?: string; } /** * Actions triggered when condition is true. */ export declare class OnCondition extends Configurable implements DialogDependencies, OnConditionConfiguration { static $kind: string; /** * Evaluates the rule and returns a predicted set of changes that should be applied to the * current plan. * * @param planning Planning context object for the current conversation. * @param event The current event being evaluated. * @param preBubble If `true`, the leading edge of the event is being evaluated. */ private _actionScope; private _extraConstraints; private _fullConstraint; /** * Gets or sets the condition which needs to be met for the actions to be executed (OPTIONAL). */ condition: BoolExpression; /** * Gets or sets the actions to add to the plan when the rule constraints are met. */ actions: Dialog[]; /** * Get or sets the rule priority expression where 0 is the highest and less than 0 is ignored. */ priority: NumberExpression; /** * A value indicating whether rule should only run once per unique set of memory paths. */ runOnce: boolean; /** * Id for condition. */ id: string; /** * @protected * Gets the action scope. * * @returns The scope obtained from the action. */ protected get actionScope(): ActionScope; /** * Create a new `OnCondition` instance. * * @param condition (Optional) The condition which needs to be met for the actions to be executed. * @param actions (Optional) The actions to add to the plan when the rule constraints are met. */ constructor(condition?: string, actions?: Dialog[]); /** * @param property The key of the conditional selector configuration. * @returns The converter for the selector configuration. */ getConverter(property: keyof OnConditionConfiguration): Converter | ConverterFactory; /** * Get the cached expression for this condition. * * @returns Cached expression used to evaluate this condition. */ getExpression(): Expression; /** * Compute the current value of the priority expression and return it. * * @param actionContext Context to use for evaluation. * @returns Computed priority. */ currentPriority(actionContext: ActionContext): number; /** * Add external condition to the OnCondition * * @param condition External constraint to add, it will be AND'ed to all other constraints. */ addExternalCondition(condition: string): void; /** * Method called to execute the condition's actions. * * @param actionContext Context. * @returns A promise with plan change list. */ execute(actionContext: ActionContext): Promise<ActionChangeList[]>; /** * Get child dialog dependencies so they can be added to the containers dialogset. * * @returns A list of [Dialog](xref:botbuilder-dialogs.Dialog). */ getDependencies(): Dialog[]; /** * Create the expression for this condition. * * @returns {Expression} Expression used to evaluate this rule. */ protected createExpression(): Expression; /** * @protected * Called when a change list is created. * @param actionContext [ActionContext](xref:botbuilder-dialogs-adaptive.ActionContext) to use for evaluation. * @param dialogOptions Optional. Object with dialog options. * @returns An [ActionChangeList](xref:botbuilder-dialogs-adaptive.ActionChangeList) with the list of actions. */ protected onCreateChangeList(actionContext: ActionContext, dialogOptions?: any): ActionChangeList; } //# sourceMappingURL=onCondition.d.ts.map