UNPKG

botbuilder-dialogs

Version:

A dialog stack based conversation manager for Microsoft BotBuilder.

90 lines 3.17 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaterfallStepContext = void 0; const dialogContext_1 = require("./dialogContext"); /** * Context object passed in to a `WaterfallStep`. * * @param O (Optional) type of options passed to the steps waterfall dialog in the call to `DialogContext.beginDialog()`. */ class WaterfallStepContext extends dialogContext_1.DialogContext { /** * Creates a new WaterfallStepContext instance. * * @param dc The dialog context for the current turn of conversation. * @param info Values to initialize the step context with. */ constructor(dc, info) { super(dc.dialogs, dc, { dialogStack: dc.stack }); this._info = info; this.parent = dc.parent; } /** * The index of the current waterfall step being executed. * * @returns The index of the current waterfall step being executed. */ get index() { return this._info.index; } /** * Any options passed to the steps waterfall dialog when it was started with * `DialogContext.beginDialog()`. * * @returns Any options the waterfall dialog was called with. */ get options() { return this._info.options; } /** * The reason the waterfall step is being executed. * * @returns The reason the waterfall step is being executed. */ get reason() { return this._info.reason; } /** * Results returned by a dialog or prompt that was called in the previous waterfall step. * * @returns The result from the previous waterfall step. */ get result() { return this._info.result; } /** * A dictionary of values which will be persisted across all waterfall steps. * * @returns A dictionary of values which will be persisted across all waterfall steps. */ get values() { return this._info.values; } /** * Skips to the next waterfall step. * * @remarks * * ```JavaScript * return await step.skip(); * ``` * @param result (Optional) result to pass to the next step. * @returns A promise with the DialogTurnResult. */ next(result) { return __awaiter(this, void 0, void 0, function* () { return yield this._info.onNext(result); }); } } exports.WaterfallStepContext = WaterfallStepContext; //# sourceMappingURL=waterfallStepContext.js.map