From 207e17d4eba08fca97b8d7347ccf7b0767b898ee Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Thu, 26 Apr 2018 04:24:26 -0700 Subject: [PATCH 1/8] renamed Control and CompositeControl classes --- libraries/botbuilder-dialogs/lib/dialog.d.ts | 74 +++++++-- libraries/botbuilder-dialogs/lib/dialog.js | 70 +++++++++ .../botbuilder-dialogs/lib/dialog.js.map | 2 +- .../lib/dialogContainer.d.ts | 134 ++++++++++++++++ .../botbuilder-dialogs/lib/dialogContainer.js | 148 ++++++++++++++++++ .../lib/dialogContainer.js.map | 1 + libraries/botbuilder-dialogs/lib/index.d.ts | 3 +- libraries/botbuilder-dialogs/lib/index.js | 4 +- libraries/botbuilder-dialogs/lib/index.js.map | 2 +- .../lib/prompts/oauthPrompt.d.ts | 4 +- .../lib/prompts/oauthPrompt.js | 4 +- .../lib/prompts/oauthPrompt.js.map | 2 +- .../lib/prompts/prompt.d.ts | 4 +- .../botbuilder-dialogs/lib/prompts/prompt.js | 4 +- .../lib/prompts/prompt.js.map | 2 +- .../botbuilder-dialogs/lib/waterfall.d.ts | 2 +- libraries/botbuilder-dialogs/lib/waterfall.js | 4 +- .../botbuilder-dialogs/lib/waterfall.js.map | 2 +- libraries/botbuilder-dialogs/src/control.ts | 93 ----------- libraries/botbuilder-dialogs/src/dialog.ts | 99 +++++++++--- ...compositeControl.ts => dialogContainer.ts} | 73 ++------- libraries/botbuilder-dialogs/src/index.ts | 3 +- .../src/prompts/oauthPrompt.ts | 4 +- .../botbuilder-dialogs/src/prompts/prompt.ts | 4 +- libraries/botbuilder-dialogs/src/waterfall.ts | 3 +- 25 files changed, 532 insertions(+), 213 deletions(-) create mode 100644 libraries/botbuilder-dialogs/lib/dialogContainer.d.ts create mode 100644 libraries/botbuilder-dialogs/lib/dialogContainer.js create mode 100644 libraries/botbuilder-dialogs/lib/dialogContainer.js.map delete mode 100644 libraries/botbuilder-dialogs/src/control.ts rename libraries/botbuilder-dialogs/src/{compositeControl.ts => dialogContainer.ts} (66%) diff --git a/libraries/botbuilder-dialogs/lib/dialog.d.ts b/libraries/botbuilder-dialogs/lib/dialog.d.ts index a467df44b2..9c261aca9b 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialog.d.ts @@ -6,22 +6,74 @@ * Licensed under the MIT License. */ import { TurnContext, Promiseable } from 'botbuilder'; -import { DialogContext } from './dialogContext'; +import { DialogContext, DialogResult } from './dialogContext'; +/** + * Tracking information for a dialog on the stack. + * @param T (Optional) type of state being persisted for dialog. + */ +export interface DialogInstance { + /** ID of the dialog this instance is for. */ + id: string; + /** The instances persisted state. */ + state: T; +} /** * :package: **botbuilder-dialogs** * - * Interface of Dialog objects that can be added to a `DialogSet`. The dialog should generally - * be a singleton and added to a dialog set using `DialogSet.add()` at which point it will be - * assigned a unique ID. + * Base class for all dialogs. + * + * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` + * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * primary difference between the two classes is that the `CompositeControl` class is designed to + * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can + * be used in complete isolation without the need for any other supporting dialogs. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. + * @param R (Optional) type of result that's expected to be returned by the control. + * @param O (Optional) options that can be passed into the [begin()](#begin) method. */ -export interface Dialog { +export declare abstract class Dialog { + /** + * Starts the control. Depending on the control, its possible for the control to finish + * immediately so it's advised to check the result object returned by `begin()` and ensure that + * the control is still active before continuing. + * + * **Usage Example:** + * + * ```JavaScript + * const state = {}; + * const result = await control.begin(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. + * @param options (Optional) additional options supported by the control. + */ + begin(context: C, state: object, options?: O): Promise>; + /** + * Passes a users reply to the control for further processing. The bot should keep calling + * `continue()` for future turns until the control returns a result with `Active == false`. + * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * + * **Usage Example:** + * + * ```JavaScript + * const result = await control.continue(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that was previously initialized by a call to [begin()](#begin). + */ + continue(context: C, state: object): Promise>; /** * Method called when a new dialog has been pushed onto the stack and is being activated. * @param dc The dialog context for the current turn of conversation. * @param dialogArgs (Optional) arguments that were passed to the dialog during `begin()` call that started the instance. */ - dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; + abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; /** * (Optional) method called when an instance of the dialog is the "current" dialog and the * user replies with a new activity. The dialog will generally continue to receive the users @@ -44,13 +96,3 @@ export interface Dialog { */ dialogResume?(dc: DialogContext, result?: any): Promiseable; } -/** - * Tracking information for a dialog on the stack. - * @param T (Optional) type of state being persisted for dialog. - */ -export interface DialogInstance { - /** ID of the dialog this instance is for. */ - id: string; - /** The instances persisted state. */ - state: T; -} diff --git a/libraries/botbuilder-dialogs/lib/dialog.js b/libraries/botbuilder-dialogs/lib/dialog.js index 2af8b44cfe..bfc86f030e 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js +++ b/libraries/botbuilder-dialogs/lib/dialog.js @@ -1,3 +1,73 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const dialogSet_1 = require("./dialogSet"); +/** + * :package: **botbuilder-dialogs** + * + * Base class for all dialogs. + * + * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` + * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * primary difference between the two classes is that the `CompositeControl` class is designed to + * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can + * be used in complete isolation without the need for any other supporting dialogs. + * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. + * @param R (Optional) type of result that's expected to be returned by the control. + * @param O (Optional) options that can be passed into the [begin()](#begin) method. + */ +class Dialog { + /** + * Starts the control. Depending on the control, its possible for the control to finish + * immediately so it's advised to check the result object returned by `begin()` and ensure that + * the control is still active before continuing. + * + * **Usage Example:** + * + * ```JavaScript + * const state = {}; + * const result = await control.begin(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. + * @param options (Optional) additional options supported by the control. + */ + begin(context, state, options) { + // Create empty dialog set and ourselves to it + const dialogs = new dialogSet_1.DialogSet(); + dialogs.add('dialog', this); + // Start the control + const cdc = dialogs.createContext(context, state); + return cdc.begin('dialog', options) + .then(() => cdc.dialogResult); + } + /** + * Passes a users reply to the control for further processing. The bot should keep calling + * `continue()` for future turns until the control returns a result with `Active == false`. + * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * + * **Usage Example:** + * + * ```JavaScript + * const result = await control.continue(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that was previously initialized by a call to [begin()](#begin). + */ + continue(context, state) { + // Create empty dialog set and ourselves to it + const dialogs = new dialogSet_1.DialogSet(); + dialogs.add('dialog', this); + // Continue the control + const cdc = dialogs.createContext(context, state); + return cdc.continue() + .then(() => cdc.dialogResult); + } +} +exports.Dialog = Dialog; //# sourceMappingURL=dialog.js.map \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialog.js.map b/libraries/botbuilder-dialogs/lib/dialog.js.map index 54918375b5..4f62366240 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js.map +++ b/libraries/botbuilder-dialogs/lib/dialog.js.map @@ -1 +1 @@ -{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":";;AASA,2CAAwC;AAcxC;;;;;;;;;;;;;GAaG;AACH;IACI;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,OAAU,EAAE,KAAa,EAAE,OAAW;QAC/C,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE5B,oBAAoB;QACpB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;aACxB,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,QAAQ,CAAC,OAAU,EAAE,KAAa;QACrC,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE5B,uBAAuB;QACvB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;aACV,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;CA+BJ;AAtFD,wBAsFC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts b/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts new file mode 100644 index 0000000000..8efb4b79f3 --- /dev/null +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts @@ -0,0 +1,134 @@ +/** + * @module botbuilder-dialogs + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ +import { TurnContext } from 'botbuilder'; +import { Dialog } from './dialog'; +import { DialogContext } from './dialogContext'; +import { DialogSet } from './dialogSet'; +/** + * :package: **botbuilder-dialogs** + * + * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a + * control that can be used within another bot. The control can be used either as a dialog added + * to the other bots `DialogSet` or on its own for bots that are using some other conversation + * management system. + * + * ### Control Packaging + * + * You'll typically want to package your control as a new class derived from `DialogContainer`. + * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs + * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. + * + * If your control needs to be configured then you can pass through the configuration settings as + * a set of `defaultOptions` which will be merged with any options passed in by the caller when + * they call `begin()`. These will then be passed as arguments to the initial dialog that gets + * started. + * + * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to + * enter their name and phone number which it will return as a JSON object to the caller: + * + * ```JavaScript + * const { DialogContainer, TextPrompt } = require('botbuilder-dialogs'); + * + * class ProfileDialog extends DialogContainer { + * constructor() { + * super('fillProfile'); + * + * this.dialogs.add('fillProfile', [ + * async function (dc, options) { + * dc.instance.state = {}; + * await dc.prompt('textPrompt', `What's your name?`); + * }, + * async function (dc, name) { + * dc.instance.state.name = name; + * await dc.prompt('textPrompt', `What's your phone number?`); + * }, + * async function (dc, phone) { + * dc.instance.state.phone = phone; + * + * // Return completed profile + * await dc.end(dc.instance.state); + * } + * ]); + * + * this.dialogs.add('textPrompt', new TextPrompt()); + * } + * } + * module.exports.ProfileDialog = ProfileDialog; + * ``` + * + * ### Consume as Dialog + * + * On the consumption side the control we created can be used by a bot in much the same way they + * would use any other prompt. They can add a new instance of the control as a named dialog to + * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the + * control accepts options these can be passed in to the `begin()` call as well. + * + * ```JavaScript + * const { DialogSet } = require('botbuilder-dialogs'); + * const { ProfileDialog } = require('./profileControl'); + * + * const dialogs = new DialogSet(); + * + * dialogs.add('getProfile', new ProfileDialog()); + * + * dialogs.add('firstrun', [ + * async function (dc) { + * await dc.context.sendActivity(`Welcome! We need to ask a few questions to get started.`); + * await dc.begin('getProfile'); + * }, + * async function (dc, profile) { + * await dc.context.sendActivity(`Thanks ${profile.name}!`); + * await dc.end(); + * } + * ]); + * ``` + * + * ### Consume as Control + * + * If the consuming bot isn't dialog based they can still use your control. They will just need + * start the control from somewhere within their bots logic by calling the controls `begin()` + * method: + * + * ```JavaScript + * const state = {}; + * const control = new ProfileDialog(); + * await prompt.begin(context, state); + * ``` + * + * The control will populate the `state` object passed in with information it needs to process + * the users response. This should be saved off with the bots conversation state as it needs to be + * passed into the controls `continue()` method on the next turn of conversation with the user: + * + * ```JavaScript + * const control = new ProfileDialog(); + * const result = await control.continue(context, state); + * if (!result.active) { + * const profile = result.result; + * } + * ``` + * + * The `continue()` method returns a `DialogResult` object which can be used to determine when + * the control is finished and then to access any results it might have returned. To interrupt or + * cancel the control simply delete the `state` object the bot has been persisting. + * @param R (Optional) type of result that's expected to be returned by the control. + * @param O (Optional) options that can be passed into the begin() method. + * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. + */ +export declare class DialogContainer extends Dialog { + protected dialogId: string; + /** The controls dialog set. */ + protected dialogs: DialogSet; + /** + * Creates a new `DialogContainer` instance. + * @param dialogId ID of the root dialog that should be started anytime the control is started. + * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. + */ + constructor(dialogId: string, dialogs?: DialogSet); + dialogBegin(dc: DialogContext, dialogArgs?: any): Promise; + dialogContinue(dc: DialogContext): Promise; +} diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js b/libraries/botbuilder-dialogs/lib/dialogContainer.js new file mode 100644 index 0000000000..032b1c12e9 --- /dev/null +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.js @@ -0,0 +1,148 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const dialog_1 = require("./dialog"); +const dialogSet_1 = require("./dialogSet"); +/** + * :package: **botbuilder-dialogs** + * + * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a + * control that can be used within another bot. The control can be used either as a dialog added + * to the other bots `DialogSet` or on its own for bots that are using some other conversation + * management system. + * + * ### Control Packaging + * + * You'll typically want to package your control as a new class derived from `DialogContainer`. + * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs + * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. + * + * If your control needs to be configured then you can pass through the configuration settings as + * a set of `defaultOptions` which will be merged with any options passed in by the caller when + * they call `begin()`. These will then be passed as arguments to the initial dialog that gets + * started. + * + * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to + * enter their name and phone number which it will return as a JSON object to the caller: + * + * ```JavaScript + * const { DialogContainer, TextPrompt } = require('botbuilder-dialogs'); + * + * class ProfileDialog extends DialogContainer { + * constructor() { + * super('fillProfile'); + * + * this.dialogs.add('fillProfile', [ + * async function (dc, options) { + * dc.instance.state = {}; + * await dc.prompt('textPrompt', `What's your name?`); + * }, + * async function (dc, name) { + * dc.instance.state.name = name; + * await dc.prompt('textPrompt', `What's your phone number?`); + * }, + * async function (dc, phone) { + * dc.instance.state.phone = phone; + * + * // Return completed profile + * await dc.end(dc.instance.state); + * } + * ]); + * + * this.dialogs.add('textPrompt', new TextPrompt()); + * } + * } + * module.exports.ProfileDialog = ProfileDialog; + * ``` + * + * ### Consume as Dialog + * + * On the consumption side the control we created can be used by a bot in much the same way they + * would use any other prompt. They can add a new instance of the control as a named dialog to + * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the + * control accepts options these can be passed in to the `begin()` call as well. + * + * ```JavaScript + * const { DialogSet } = require('botbuilder-dialogs'); + * const { ProfileDialog } = require('./profileControl'); + * + * const dialogs = new DialogSet(); + * + * dialogs.add('getProfile', new ProfileDialog()); + * + * dialogs.add('firstrun', [ + * async function (dc) { + * await dc.context.sendActivity(`Welcome! We need to ask a few questions to get started.`); + * await dc.begin('getProfile'); + * }, + * async function (dc, profile) { + * await dc.context.sendActivity(`Thanks ${profile.name}!`); + * await dc.end(); + * } + * ]); + * ``` + * + * ### Consume as Control + * + * If the consuming bot isn't dialog based they can still use your control. They will just need + * start the control from somewhere within their bots logic by calling the controls `begin()` + * method: + * + * ```JavaScript + * const state = {}; + * const control = new ProfileDialog(); + * await prompt.begin(context, state); + * ``` + * + * The control will populate the `state` object passed in with information it needs to process + * the users response. This should be saved off with the bots conversation state as it needs to be + * passed into the controls `continue()` method on the next turn of conversation with the user: + * + * ```JavaScript + * const control = new ProfileDialog(); + * const result = await control.continue(context, state); + * if (!result.active) { + * const profile = result.result; + * } + * ``` + * + * The `continue()` method returns a `DialogResult` object which can be used to determine when + * the control is finished and then to access any results it might have returned. To interrupt or + * cancel the control simply delete the `state` object the bot has been persisting. + * @param R (Optional) type of result that's expected to be returned by the control. + * @param O (Optional) options that can be passed into the begin() method. + * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. + */ +class DialogContainer extends dialog_1.Dialog { + /** + * Creates a new `DialogContainer` instance. + * @param dialogId ID of the root dialog that should be started anytime the control is started. + * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. + */ + constructor(dialogId, dialogs) { + super(); + this.dialogId = dialogId; + this.dialogs = dialogs || new dialogSet_1.DialogSet(); + } + dialogBegin(dc, dialogArgs) { + // Start the controls entry point dialog. + const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { + // End if the controls dialog ends. + if (!cdc.dialogResult.active) { + return dc.end(cdc.dialogResult.result); + } + }); + } + dialogContinue(dc) { + // Continue controls dialog stack. + const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + return cdc.continue().then(() => { + // End if the controls dialog ends. + if (!cdc.dialogResult.active) { + return dc.end(cdc.dialogResult.result); + } + }); + } +} +exports.DialogContainer = DialogContainer; +//# sourceMappingURL=dialogContainer.js.map \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js.map b/libraries/botbuilder-dialogs/lib/dialogContainer.js.map new file mode 100644 index 0000000000..bd27df3bde --- /dev/null +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.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C,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,mCAAmC;YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAnCD,0CAmCC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/index.d.ts b/libraries/botbuilder-dialogs/lib/index.d.ts index cd17f493a3..f7ba560f11 100644 --- a/libraries/botbuilder-dialogs/lib/index.d.ts +++ b/libraries/botbuilder-dialogs/lib/index.d.ts @@ -3,9 +3,8 @@ */ /** Licensed under the MIT License. */ export * from './prompts/index'; -export * from './compositeControl'; -export * from './control'; export * from './dialog'; +export * from './dialogContainer'; export * from './dialogContext'; export * from './dialogSet'; export * from './waterfall'; diff --git a/libraries/botbuilder-dialogs/lib/index.js b/libraries/botbuilder-dialogs/lib/index.js index c9bf767e7a..2c1c899d1e 100644 --- a/libraries/botbuilder-dialogs/lib/index.js +++ b/libraries/botbuilder-dialogs/lib/index.js @@ -8,8 +8,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); */ /** Licensed under the MIT License. */ __export(require("./prompts/index")); -__export(require("./compositeControl")); -__export(require("./control")); +__export(require("./dialog")); +__export(require("./dialogContainer")); __export(require("./dialogContext")); __export(require("./dialogSet")); __export(require("./waterfall")); diff --git a/libraries/botbuilder-dialogs/lib/index.js.map b/libraries/botbuilder-dialogs/lib/index.js.map index 29133e259a..3f0387d101 100644 --- a/libraries/botbuilder-dialogs/lib/index.js.map +++ b/libraries/botbuilder-dialogs/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,sCAAsC;AACtC,qCAAgC;AAChC,wCAAmC;AACnC,+BAA0B;AAE1B,qCAAgC;AAChC,iCAA4B;AAC5B,iCAA4B;AAE5B,2FAA2F;AAC3F,kEAAkE;AAClE,yDAA8I;AAAvD,yCAAA,SAAS,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,sCAAsC;AACtC,qCAAgC;AAChC,8BAAyB;AACzB,uCAAkC;AAClC,qCAAgC;AAChC,iCAA4B;AAC5B,iCAA4B;AAE5B,2FAA2F;AAC3F,kEAAkE;AAClE,yDAA8I;AAAvD,yCAAA,SAAS,CAAA"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts index 1eb4b2829b..8bbf6bfb6c 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts @@ -8,7 +8,7 @@ import { TurnContext } from 'botbuilder'; import * as prompts from 'botbuilder-prompts'; import { DialogContext } from '../dialogContext'; -import { Control } from '../control'; +import { Dialog } from '../dialog'; import { PromptOptions } from './prompt'; /** * :package: **botbuilder-dialogs** @@ -121,7 +121,7 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -export declare class OAuthPrompt extends Control { +export declare class OAuthPrompt extends Dialog { private settings; private prompt; /** diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js index 4b796bbfb3..337caa3661 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js @@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); */ const botbuilder_1 = require("botbuilder"); const prompts = require("botbuilder-prompts"); -const control_1 = require("../control"); +const dialog_1 = require("../dialog"); /** * :package: **botbuilder-dialogs** * @@ -108,7 +108,7 @@ const control_1 = require("../control"); * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -class OAuthPrompt extends control_1.Control { +class OAuthPrompt extends dialog_1.Dialog { /** * Creates a new `OAuthPrompt` instance. * @param settings Settings used to configure the prompt. diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map index 1ff7ae15aa..6f41b7ad88 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"oauthPrompt.js","sourceRoot":"","sources":["../../src/prompts/oauthPrompt.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAA2F;AAC3F,8CAA8C;AAE9C,wCAAqC;AAiBrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,iBAAgD,SAAQ,iBAAU;IAG9D;;;;OAIG;IACH,YAAoB,QAAwC,EAAE,SAA6C;QACvG,KAAK,EAAE,CAAC;QADQ,aAAQ,GAAR,QAAQ,CAAgC;QAExD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACjE,CAAC;IAEM,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC3D,4BAA4B;QAC5B,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC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ts b/libraries/botbuilder-dialogs/lib/prompts/prompt.d.ts index 33d698ed75..5396263930 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.d.ts @@ -8,7 +8,7 @@ import { TurnContext, Activity } from 'botbuilder'; import { PromptValidator } from 'botbuilder-prompts'; import { DialogContext } from '../dialogContext'; -import { Control } from '../control'; +import { Dialog } from '../dialog'; /** * :package: **botbuilder-dialogs** * @@ -30,7 +30,7 @@ export interface PromptOptions { * Base class for all prompts. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -export declare abstract class Prompt extends Control { +export declare abstract class Prompt extends Dialog { private validator; constructor(validator?: PromptValidator); protected abstract onPrompt(dc: DialogContext, options: PromptOptions, isRetry: boolean): Promise; diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js b/libraries/botbuilder-dialogs/lib/prompts/prompt.js index 555133beed..dcff322216 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js @@ -8,14 +8,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); * Licensed under the MIT License. */ const botbuilder_1 = require("botbuilder"); -const control_1 = require("../control"); +const dialog_1 = require("../dialog"); /** * :package: **botbuilder-dialogs** * * Base class for all prompts. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -class Prompt extends control_1.Control { +class Prompt extends dialog_1.Dialog { constructor(validator) { super(); this.validator = validator; diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map index 71953149a2..b217215459 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map @@ -1 +1 @@ -{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompts/prompt.ts"],"names":[],"mapp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AE,CAAC,QAAQ,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC;aACtC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YACjB,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBACjB,iBAAiB;gBACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YACnE,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,gCAAgC;gBAChC,MAAM,CAAC,UAAU,CAAC;YACtB,CAAC;QACL,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,EAAE,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC;gBACvB,0BAA0B;gBAC1B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC/B,oBAAoB;gBACpB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA7CD,wBA6CC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/waterfall.d.ts b/libraries/botbuilder-dialogs/lib/waterfall.d.ts index d06acf59b1..e3ef18e534 100644 --- a/libraries/botbuilder-dialogs/lib/waterfall.d.ts +++ b/libraries/botbuilder-dialogs/lib/waterfall.d.ts @@ -127,7 +127,7 @@ export declare type SkipStepFunction = (args?: any) => Promise; * to do that the dialog will be automatically ended for you on the users next reply. The users * response will be passed to the calling dialogs next waterfall step if there is one. */ -export declare class Waterfall implements Dialog { +export declare class Waterfall extends Dialog { private readonly steps; /** * Creates a new waterfall dialog containing the given array of steps. diff --git a/libraries/botbuilder-dialogs/lib/waterfall.js b/libraries/botbuilder-dialogs/lib/waterfall.js index d63d566c54..9fdfbeed35 100644 --- a/libraries/botbuilder-dialogs/lib/waterfall.js +++ b/libraries/botbuilder-dialogs/lib/waterfall.js @@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); * Licensed under the MIT License. */ const botbuilder_1 = require("botbuilder"); +const dialog_1 = require("./dialog"); /** * :package: **botbuilder-dialogs** * @@ -78,12 +79,13 @@ const botbuilder_1 = require("botbuilder"); * to do that the dialog will be automatically ended for you on the users next reply. The users * response will be passed to the calling dialogs next waterfall step if there is one. */ -class Waterfall { +class Waterfall extends dialog_1.Dialog { /** * Creates a new waterfall dialog containing the given array of steps. * @param steps Array of waterfall steps. */ constructor(steps) { + super(); this.steps = steps.slice(0); } dialogBegin(dc, args) { diff --git a/libraries/botbuilder-dialogs/lib/waterfall.js.map b/libraries/botbuilder-dialogs/lib/waterfall.js.map index 144e85ac6b..388714052a 100644 --- a/libraries/botbuilder-dialogs/lib/waterfall.js.map +++ b/libraries/botbuilder-dialogs/lib/waterfall.js.map @@ -1 +1 @@ -{"version":3,"file":"waterfall.js","sourceRoot":"","sources":["../src/waterfall.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAAqE;AAuDrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH;IAGI;;;OAGG;IACH,YAAY,KAAyB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAEM,WAAW,CAAC,EAAoB,EAAE,IAAU;QAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAkC,CAAC;QACvD,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;QAClB,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AO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ;AAtDD,8BAsDC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/control.ts b/libraries/botbuilder-dialogs/src/control.ts deleted file mode 100644 index 91deb6f8ae..0000000000 --- a/libraries/botbuilder-dialogs/src/control.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @module botbuilder-dialogs - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { Promiseable, TurnContext } from 'botbuilder'; -import { Dialog, DialogInstance } from './dialog'; -import { DialogContext, DialogResult } from './dialogContext'; -import { DialogSet } from './dialogSet'; - -/** - * :package: **botbuilder-dialogs** - * - * Base class for any dialog that wants to support being used as a dialog within a bots `DialogSet` - * or on its own as a control within a bot that uses an alternate conversation management system. - * - * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The - * primary difference between the two classes is that the `CompositeControl` class is designed to - * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can - * be used in complete isolation without the need for any other supporting dialogs. - * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. - * @param O (Optional) options that can be passed into the [begin()](#begin) method. - */ -export abstract class Control implements Dialog { - - /** - * Creates a new Control instance. - * @param defaultOptions (Optional) set of default options that should be passed to controls `dialogBegin()` method. These will be merged with arguments passed in by the caller. - */ - constructor(protected defaultOptions?: O) { } - - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - public begin(context: C, state: object, options?: O): Promise> { - // Create empty dialog set and ourselves to it - const dialogs = new DialogSet(); - dialogs.add('control', this); - - // Start the control - const cdc = dialogs.createContext(context, state); - return cdc.begin('control', Object.assign({}, this.defaultOptions, options)) - .then(() => cdc.dialogResult); - } - - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - public continue(context: C, state: object): Promise> { - // Create empty dialog set and ourselves to it - const dialogs = new DialogSet(); - dialogs.add('control', this); - - // Continue the control - const cdc = dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); - } - - abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promise; -} diff --git a/libraries/botbuilder-dialogs/src/dialog.ts b/libraries/botbuilder-dialogs/src/dialog.ts index 28ea59644b..826490fcdd 100644 --- a/libraries/botbuilder-dialogs/src/dialog.ts +++ b/libraries/botbuilder-dialogs/src/dialog.ts @@ -6,23 +6,98 @@ * Licensed under the MIT License. */ import { TurnContext, Promiseable } from 'botbuilder'; -import { DialogContext } from './dialogContext'; +import { DialogContext, DialogResult } from './dialogContext'; +import { DialogSet } from './dialogSet'; + +/** + * Tracking information for a dialog on the stack. + * @param T (Optional) type of state being persisted for dialog. + */ +export interface DialogInstance { + /** ID of the dialog this instance is for. */ + id: string; + + /** The instances persisted state. */ + state: T; +} /** * :package: **botbuilder-dialogs** * - * Interface of Dialog objects that can be added to a `DialogSet`. The dialog should generally - * be a singleton and added to a dialog set using `DialogSet.add()` at which point it will be - * assigned a unique ID. + * Base class for all dialogs. + * + * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` + * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * primary difference between the two classes is that the `CompositeControl` class is designed to + * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can + * be used in complete isolation without the need for any other supporting dialogs. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. + * @param R (Optional) type of result that's expected to be returned by the control. + * @param O (Optional) options that can be passed into the [begin()](#begin) method. */ -export interface Dialog { +export abstract class Dialog { + /** + * Starts the control. Depending on the control, its possible for the control to finish + * immediately so it's advised to check the result object returned by `begin()` and ensure that + * the control is still active before continuing. + * + * **Usage Example:** + * + * ```JavaScript + * const state = {}; + * const result = await control.begin(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. + * @param options (Optional) additional options supported by the control. + */ + public begin(context: C, state: object, options?: O): Promise> { + // Create empty dialog set and ourselves to it + const dialogs = new DialogSet(); + dialogs.add('dialog', this); + + // Start the control + const cdc = dialogs.createContext(context, state); + return cdc.begin('dialog', options) + .then(() => cdc.dialogResult); + } + + /** + * Passes a users reply to the control for further processing. The bot should keep calling + * `continue()` for future turns until the control returns a result with `Active == false`. + * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * + * **Usage Example:** + * + * ```JavaScript + * const result = await control.continue(context, state); + * if (!result.active) { + * const value = result.result; + * } + * ``` + * @param context Context for the current turn of the conversation with the user. + * @param state A state object that was previously initialized by a call to [begin()](#begin). + */ + public continue(context: C, state: object): Promise> { + // Create empty dialog set and ourselves to it + const dialogs = new DialogSet(); + dialogs.add('dialog', this); + + // Continue the control + const cdc = dialogs.createContext(context, state); + return cdc.continue() + .then(() => cdc.dialogResult); + } + /** * Method called when a new dialog has been pushed onto the stack and is being activated. * @param dc The dialog context for the current turn of conversation. * @param dialogArgs (Optional) arguments that were passed to the dialog during `begin()` call that started the instance. */ - dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; + abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; /** * (Optional) method called when an instance of the dialog is the "current" dialog and the @@ -47,15 +122,3 @@ export interface Dialog { */ dialogResume?(dc: DialogContext, result?: any): Promiseable; } - -/** - * Tracking information for a dialog on the stack. - * @param T (Optional) type of state being persisted for dialog. - */ -export interface DialogInstance { - /** ID of the dialog this instance is for. */ - id: string; - - /** The instances persisted state. */ - state: T; -} diff --git a/libraries/botbuilder-dialogs/src/compositeControl.ts b/libraries/botbuilder-dialogs/src/dialogContainer.ts similarity index 66% rename from libraries/botbuilder-dialogs/src/compositeControl.ts rename to libraries/botbuilder-dialogs/src/dialogContainer.ts index 968071b600..64186b3f93 100644 --- a/libraries/botbuilder-dialogs/src/compositeControl.ts +++ b/libraries/botbuilder-dialogs/src/dialogContainer.ts @@ -14,14 +14,14 @@ import { DialogSet } from './dialogSet'; /** * :package: **botbuilder-dialogs** * - * A `CompositeControl` makes it easy to take an existing set of dialogs and package them up as a + * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a * control that can be used within another bot. The control can be used either as a dialog added * to the other bots `DialogSet` or on its own for bots that are using some other conversation * management system. * * ### Control Packaging * - * You'll typically want to package your control as a new class derived from `CompositeControl`. + * You'll typically want to package your control as a new class derived from `DialogContainer`. * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. * @@ -30,15 +30,13 @@ import { DialogSet } from './dialogSet'; * they call `begin()`. These will then be passed as arguments to the initial dialog that gets * started. * - * Here's a fairly simple example of a `ProfileControl` that's designed to prompt the user to + * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to * enter their name and phone number which it will return as a JSON object to the caller: * * ```JavaScript - * const { CompositeControl, DialogSet, TextPrompt } = require('botbuilder-dialogs'); + * const { DialogContainer, TextPrompt } = require('botbuilder-dialogs'); * - * const dialogs = new DialogSet(); - * - * class ProfileControl extends CompositeControl { + * class ProfileDialog extends DialogContainer { * constructor() { * super('fillProfile'); * @@ -62,7 +60,7 @@ import { DialogSet } from './dialogSet'; * this.dialogs.add('textPrompt', new TextPrompt()); * } * } - * module.exports.ProfileControl = ProfileControl; + * module.exports.ProfileDialog = ProfileDialog; * ``` * * ### Consume as Dialog @@ -74,11 +72,11 @@ import { DialogSet } from './dialogSet'; * * ```JavaScript * const { DialogSet } = require('botbuilder-dialogs'); - * const { ProfileControl } = require('./profileControl'); + * const { ProfileDialog } = require('./profileControl'); * * const dialogs = new DialogSet(); * - * dialogs.add('getProfile', new ProfileControl()); + * dialogs.add('getProfile', new ProfileDialog()); * * dialogs.add('firstrun', [ * async function (dc) { @@ -100,7 +98,7 @@ import { DialogSet } from './dialogSet'; * * ```JavaScript * const state = {}; - * const control = new ProfileControl(); + * const control = new ProfileDialog(); * await prompt.begin(context, state); * ``` * @@ -109,7 +107,7 @@ import { DialogSet } from './dialogSet'; * passed into the controls `continue()` method on the next turn of conversation with the user: * * ```JavaScript - * const control = new ProfileControl(); + * const control = new ProfileDialog(); * const result = await control.continue(context, state); * if (!result.active) { * const profile = result.result; @@ -123,65 +121,20 @@ import { DialogSet } from './dialogSet'; * @param O (Optional) options that can be passed into the begin() method. * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. */ -export class CompositeControl implements Dialog { +export class DialogContainer extends Dialog { /** The controls dialog set. */ protected dialogs: DialogSet; /** - * Creates a new `CompositeControl` instance. + * Creates a new `DialogContainer` instance. * @param dialogId ID of the root dialog that should be started anytime the control is started. * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. */ constructor(protected dialogId: string, dialogs?: DialogSet) { + super(); this.dialogs = dialogs || new DialogSet(); } - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - public begin(context: C, state: object, options?: O): Promise> { - const cdc = this.dialogs.createContext(context, state); - return cdc.begin(this.dialogId, options) - .then(() => cdc.dialogResult); - } - - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - public continue(context: C, state: object): Promise> { - const cdc = this.dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); - } - public dialogBegin(dc: DialogContext, dialogArgs?: any): Promise { // Start the controls entry point dialog. const cdc = this.dialogs.createContext(dc.context, dc.instance.state); diff --git a/libraries/botbuilder-dialogs/src/index.ts b/libraries/botbuilder-dialogs/src/index.ts index 6a17a3d7a9..e05adcd5d9 100644 --- a/libraries/botbuilder-dialogs/src/index.ts +++ b/libraries/botbuilder-dialogs/src/index.ts @@ -3,9 +3,8 @@ */ /** Licensed under the MIT License. */ export * from './prompts/index'; -export * from './compositeControl'; -export * from './control'; export * from './dialog'; +export * from './dialogContainer'; export * from './dialogContext'; export * from './dialogSet'; export * from './waterfall'; diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index b1b76dff7c..de7c49adb3 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -8,7 +8,7 @@ import { TurnContext, Activity, Promiseable, ActivityTypes, InputHints } from 'botbuilder'; import * as prompts from 'botbuilder-prompts'; import { DialogContext } from '../dialogContext'; -import { Control } from '../control'; +import { Dialog } from '../dialog'; import { PromptOptions } from './prompt'; /** @@ -123,7 +123,7 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -export class OAuthPrompt extends Control { +export class OAuthPrompt extends Dialog { private prompt: prompts.OAuthPrompt; /** diff --git a/libraries/botbuilder-dialogs/src/prompts/prompt.ts b/libraries/botbuilder-dialogs/src/prompts/prompt.ts index 000bc100c8..d31e9c357e 100644 --- a/libraries/botbuilder-dialogs/src/prompts/prompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/prompt.ts @@ -8,7 +8,7 @@ import { TurnContext, Activity, Promiseable, ActivityTypes } from 'botbuilder'; import { PromptValidator } from 'botbuilder-prompts'; import { DialogContext } from '../dialogContext'; -import { Control } from '../control'; +import { Dialog } from '../dialog'; /** * :package: **botbuilder-dialogs** @@ -35,7 +35,7 @@ export interface PromptOptions { * Base class for all prompts. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ -export abstract class Prompt extends Control { +export abstract class Prompt extends Dialog { constructor(private validator?: PromptValidator) { super(); } diff --git a/libraries/botbuilder-dialogs/src/waterfall.ts b/libraries/botbuilder-dialogs/src/waterfall.ts index 3246745aa6..abc15e4477 100644 --- a/libraries/botbuilder-dialogs/src/waterfall.ts +++ b/libraries/botbuilder-dialogs/src/waterfall.ts @@ -130,7 +130,7 @@ export type SkipStepFunction = (args?: any) => Promise; * to do that the dialog will be automatically ended for you on the users next reply. The users * response will be passed to the calling dialogs next waterfall step if there is one. */ -export class Waterfall implements Dialog { +export class Waterfall extends Dialog { private readonly steps: WaterfallStep[]; /** @@ -138,6 +138,7 @@ export class Waterfall implements Dialog { * @param steps Array of waterfall steps. */ constructor(steps: WaterfallStep[]) { + super(); this.steps = steps.slice(0); } From b97f58d3839237d5d3bcfbd894192cc48262699a Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Thu, 26 Apr 2018 04:27:11 -0700 Subject: [PATCH 2/8] Renamed DialogContext.instance to DialogContext.currentDialog --- libraries/botbuilder-dialogs/lib/dialogContainer.js | 4 ++-- libraries/botbuilder-dialogs/lib/dialogContainer.js.map | 2 +- libraries/botbuilder-dialogs/lib/dialogContext.d.ts | 2 +- libraries/botbuilder-dialogs/lib/dialogContext.js | 6 +++--- libraries/botbuilder-dialogs/lib/dialogContext.js.map | 2 +- libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js | 4 ++-- .../botbuilder-dialogs/lib/prompts/oauthPrompt.js.map | 2 +- libraries/botbuilder-dialogs/lib/prompts/prompt.js | 4 ++-- libraries/botbuilder-dialogs/lib/prompts/prompt.js.map | 2 +- libraries/botbuilder-dialogs/lib/waterfall.js | 8 ++++---- libraries/botbuilder-dialogs/lib/waterfall.js.map | 2 +- libraries/botbuilder-dialogs/src/dialogContainer.ts | 4 ++-- libraries/botbuilder-dialogs/src/dialogContext.ts | 6 +++--- libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts | 4 ++-- libraries/botbuilder-dialogs/src/prompts/prompt.ts | 4 ++-- libraries/botbuilder-dialogs/src/waterfall.ts | 8 ++++---- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js b/libraries/botbuilder-dialogs/lib/dialogContainer.js index 032b1c12e9..828d4498bb 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContainer.js +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.js @@ -125,7 +125,7 @@ class DialogContainer extends dialog_1.Dialog { } dialogBegin(dc, dialogArgs) { // Start the controls entry point dialog. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { // End if the controls dialog ends. if (!cdc.dialogResult.active) { @@ -135,7 +135,7 @@ class DialogContainer extends dialog_1.Dialog { } dialogContinue(dc) { // Continue controls dialog stack. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); return cdc.continue().then(() => { // End if the controls dialog ends. if (!cdc.dialogResult.active) { diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js.map b/libraries/botbuilder-dialogs/lib/dialogContainer.js.map index bd27df3bde..8ec353dcb6 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContainer.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogContainer.js","sourceRoot":"","sources":["../src/dialogContainer.ts"],"names":[],"mappings":";;AAQA,qCAAkD;AAElD,2CAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AACH,qBAAmF,SAAQ,eAAS;IAIhG;;;;OAIG;IACH,YAAsB,QAAgB,EAAE,OAAsB;QAC1D,KAAK,EAAE,CAAC;QADU,aAAQ,GAAR,QAAQ,CAAQ;QAElC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,qBAAS,EAAK,CAAC;IACjD,CAAC;IAEM,WAAW,CAAC,EAAoB,EAAE,UAAgB;QACrD,0CAA0C;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACrE,mCAAmC;YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CA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CAAC,KAAK,CAAC,CAAC;QAC3E,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACrE,mCAAmC;YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,cAAc,CAAC,EAAoB;QACtC,kCAAkC;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3E,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,mCAAmC;YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAnCD,0CAmCC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.d.ts b/libraries/botbuilder-dialogs/lib/dialogContext.d.ts index 88986eea2f..c5d3dc5db0 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialogContext.d.ts @@ -49,7 +49,7 @@ export declare class DialogContext { */ constructor(dialogs: DialogSet, context: C, stack: DialogInstance[]); /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - readonly instance: DialogInstance | undefined; + readonly currentDialog: DialogInstance | undefined; /** * Returns a structure that indicates whether there is still an active dialog on the stack * along with the result returned by a dialog that just ended. diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.js b/libraries/botbuilder-dialogs/lib/dialogContext.js index 9ec64096f4..57d478c5e6 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.js +++ b/libraries/botbuilder-dialogs/lib/dialogContext.js @@ -20,7 +20,7 @@ class DialogContext { this.finalResult = undefined; } /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - get instance() { + get currentDialog() { return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined; } /** @@ -106,7 +106,7 @@ class DialogContext { continue() { try { // Check for a dialog on the stack - const instance = this.instance; + const instance = this.currentDialog; if (instance) { // Lookup dialog const dialog = this.dialogs.find(instance.id); @@ -162,7 +162,7 @@ class DialogContext { this.stack.pop(); } // Resume previous dialog - const instance = this.instance; + const instance = this.currentDialog; if (instance) { // Lookup dialog const dialog = this.dialogs.find(instance.id); diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.js.map b/libraries/botbuilder-dialogs/lib/dialogContext.js.map index 3ea73c1c2d..152636e750 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogContext.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogContext.js","sourceRoot":"","sources":["../src/dialogContext.ts"],"names":[],"mappings":";;AAmCA;;;;;GAKG;AACH;IAGK;;;;;OAKG;IACJ,YAA4B,OAAqB,EAAkB,OAAU,EAAkB,KAAuB;QAA1F,YAAO,GAAP,OAAO,CAAc;QAAkB,YAAO,GAAP,OAAO,CAAG;QAAkB,UAAK,GAAL,KAAK,CAAkB;QAR9G,gBAAW,GAAQ,SAAS,CAAC;IAQqF,CAAC;IAE3H,qHAAqH;IACrH,IAAW,QAAQ;QACf,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAA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AM,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,OAAO,CAAC,QAAgB,EAAE,UAAgB;QAC7C,YAAY;QACZ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;QAAC,CAAC;QAE/C,2BAA2B;QAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;CACJ;AA9ND,sCA8NC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js index 337caa3661..e15ab00488 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js @@ -122,7 +122,7 @@ class OAuthPrompt extends dialog_1.Dialog { dialogBegin(dc, options) { // Persist options and state const timeout = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000; - const instance = dc.instance; + const instance = dc.currentDialog; instance.state = Object.assign({ expires: new Date().getTime() + timeout }, options); @@ -147,7 +147,7 @@ class OAuthPrompt extends dialog_1.Dialog { // Recognize token return this.prompt.recognize(dc.context).then((output) => { // Check for timeout - const state = dc.instance.state; + const state = dc.currentDialog.state; const isMessage = dc.context.activity.type === botbuilder_1.ActivityTypes.Message; const hasTimedOut = isMessage && (new Date().getTime() > state.expires); // Process output diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map index 6f41b7ad88..459c67865b 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map +++ b/libraries/botbu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ACrE,MAAM,WAAW,GAAG,SAAS,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;YAExE,iBAAiB;YACjB,EAAE,CAAC,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC;gBACxB,uCAAuC;gBACvC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBACxC,oBAAoB;gBACpB,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,EAAE,uBAAU,CAAC,cAAc,CAAC,CAAC;YACnG,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,WAAW,CAAC,OAAoB;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACJ;AAzED,kCAyEC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js b/libraries/botbuilder-dialogs/lib/prompts/prompt.js index dcff322216..a638ff8ae9 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js @@ -22,7 +22,7 @@ class Prompt extends dialog_1.Dialog { } dialogBegin(dc, options) { // Persist options - const instance = dc.instance; + const instance = dc.currentDialog; instance.state = options || {}; // Send initial prompt return this.onPrompt(dc, instance.state, false); @@ -33,7 +33,7 @@ class Prompt extends dialog_1.Dialog { return Promise.resolve(); } // Recognize value - const instance = dc.instance; + const instance = dc.currentDialog; return this.onRecognize(dc, instance.state) .then((recognized) => { if (this.validator) { diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map index b217215459..cb9e1a30a9 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map @@ -1 +1 @@ -{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompts/prompt.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAA+E;AAG/E,sCAAmC;AAqBnC;;;;;GAKG;AACH,YAAoD,SAAQ,eAAS;IACjE,YAAoB,SAAqC;QACrD,KAAK,EAAE,CAAC;QADQ,cAAS,GAAT,SAAS,CAA4B;IAEzD,CAAC;IAMM,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC3D,kBAAkB;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;QAC7B,QAAQ,CAAC,KAAK,GAAG,OAAO,IAAI,EAAE,CAAC;QAE/B,sBAAsB;QACtB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,EAAoB;QACtC,+CAA+C;QAC/C,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,0BAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YACrD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAED,kBAAkB;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC;aACtC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YACjB,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBACjB,iBAAiB;gBACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CA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,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,0BAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YACrD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAED,kBAAkB;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC,aAAa,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC;aACtC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;YACjB,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;gBACjB,iBAAiB;gBACjB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YACnE,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,gCAAgC;gBAChC,MAAM,CAAC,UAAU,CAAC;YACtB,CAAC;QACL,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,EAAE,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC;gBACvB,0BAA0B;gBAC1B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC/B,oBAAoB;gBACpB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA7CD,wBA6CC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/waterfall.js b/libraries/botbuilder-dialogs/lib/waterfall.js index 9fdfbeed35..33f2a45eca 100644 --- a/libraries/botbuilder-dialogs/lib/waterfall.js +++ b/libraries/botbuilder-dialogs/lib/waterfall.js @@ -89,14 +89,14 @@ class Waterfall extends dialog_1.Dialog { this.steps = steps.slice(0); } dialogBegin(dc, args) { - const instance = dc.instance; + const instance = dc.currentDialog; instance.step = 0; return this.runStep(dc, args); } dialogContinue(dc) { // Don't do anything for non-message activities if (dc.context.activity.type === botbuilder_1.ActivityTypes.Message) { - const instance = dc.instance; + const instance = dc.currentDialog; instance.step += 1; return this.runStep(dc, dc.context.activity.text); } @@ -105,13 +105,13 @@ class Waterfall extends dialog_1.Dialog { } } dialogResume(dc, result) { - const instance = dc.instance; + const instance = dc.currentDialog; instance.step += 1; return this.runStep(dc, result); } runStep(dc, result) { try { - const instance = dc.instance; + const instance = dc.currentDialog; const step = instance.step; if (step >= 0 && step < this.steps.length) { // Execute step diff --git a/libraries/botbuilder-dialogs/lib/waterfall.js.map b/libraries/botbuilder-dialogs/lib/waterfall.js.map index 388714052a..775da43717 100644 --- a/libraries/botbuilder-dialogs/lib/waterfall.js.map +++ b/libraries/botbuilder-dialogs/lib/waterfall.js.map @@ -1 +1 @@ -{"version":3,"file":"waterfall.js","sourceRoot":"","sources":["../src/waterfall.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAAqE;AACrE,qCAAkD;AAsDlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,eAA8C,SAAQ,eAAS;IAG3D;;;OAGG;IACH,YAAY,KAAyB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAEM,WAAW,CAAC,EAAoB,EAAE,IAAU;QAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAkC,CAAC;QACvD,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;QAClB,MAAM,CAAC,IAAI,CA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,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ;AAtDD,8BAsDC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/dialogContainer.ts b/libraries/botbuilder-dialogs/src/dialogContainer.ts index 64186b3f93..a167cc9951 100644 --- a/libraries/botbuilder-dialogs/src/dialogContainer.ts +++ b/libraries/botbuilder-dialogs/src/dialogContainer.ts @@ -137,7 +137,7 @@ export class DialogContainer, dialogArgs?: any): Promise { // Start the controls entry point dialog. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { // End if the controls dialog ends. if (!cdc.dialogResult.active) { @@ -148,7 +148,7 @@ export class DialogContainer): Promise { // Continue controls dialog stack. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); + const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); return cdc.continue().then(() => { // End if the controls dialog ends. if (!cdc.dialogResult.active) { diff --git a/libraries/botbuilder-dialogs/src/dialogContext.ts b/libraries/botbuilder-dialogs/src/dialogContext.ts index 7d4954838c..cd956a1ab6 100644 --- a/libraries/botbuilder-dialogs/src/dialogContext.ts +++ b/libraries/botbuilder-dialogs/src/dialogContext.ts @@ -51,7 +51,7 @@ export class DialogContext { constructor(public readonly dialogs: DialogSet, public readonly context: C, public readonly stack: DialogInstance[]) { } /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - public get instance(): DialogInstance|undefined { + public get currentDialog(): DialogInstance|undefined { return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined; } @@ -138,7 +138,7 @@ export class DialogContext { public continue(): Promise { try { // Check for a dialog on the stack - const instance = this.instance; + const instance = this.currentDialog; if (instance) { // Lookup dialog @@ -191,7 +191,7 @@ export class DialogContext { if (this.stack.length > 0) { this.stack.pop() } // Resume previous dialog - const instance = this.instance; + const instance = this.currentDialog; if (instance) { // Lookup dialog diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index de7c49adb3..13bc466fcc 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -139,7 +139,7 @@ export class OAuthPrompt extends Dialog { public dialogBegin(dc: DialogContext, options: PromptOptions): Promise { // Persist options and state const timeout = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000; - const instance = dc.instance; + const instance = dc.currentDialog; instance.state = Object.assign({ expires: new Date().getTime() + timeout } as OAuthPromptState, options); @@ -164,7 +164,7 @@ export class OAuthPrompt extends Dialog { // Recognize token return this.prompt.recognize(dc.context).then((output) => { // Check for timeout - const state = dc.instance.state as OAuthPromptState; + const state = dc.currentDialog.state as OAuthPromptState; const isMessage = dc.context.activity.type === ActivityTypes.Message; const hasTimedOut = isMessage && (new Date().getTime() > state.expires); diff --git a/libraries/botbuilder-dialogs/src/prompts/prompt.ts b/libraries/botbuilder-dialogs/src/prompts/prompt.ts index d31e9c357e..fca4af98a8 100644 --- a/libraries/botbuilder-dialogs/src/prompts/prompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/prompt.ts @@ -46,7 +46,7 @@ export abstract class Prompt extends Dialog { public dialogBegin(dc: DialogContext, options: PromptOptions): Promise { // Persist options - const instance = dc.instance; + const instance = dc.currentDialog; instance.state = options || {}; // Send initial prompt @@ -60,7 +60,7 @@ export abstract class Prompt extends Dialog { } // Recognize value - const instance = dc.instance; + const instance = dc.currentDialog; return this.onRecognize(dc, instance.state) .then((recognized) => { if (this.validator) { diff --git a/libraries/botbuilder-dialogs/src/waterfall.ts b/libraries/botbuilder-dialogs/src/waterfall.ts index abc15e4477..50577060a9 100644 --- a/libraries/botbuilder-dialogs/src/waterfall.ts +++ b/libraries/botbuilder-dialogs/src/waterfall.ts @@ -143,7 +143,7 @@ export class Waterfall extends Dialog { } public dialogBegin(dc: DialogContext, args?: any): Promiseable { - const instance = dc.instance as WaterfallInstance; + const instance = dc.currentDialog as WaterfallInstance; instance.step = 0; return this.runStep(dc, args); } @@ -151,7 +151,7 @@ export class Waterfall extends Dialog { public dialogContinue(dc: DialogContext): Promise { // Don't do anything for non-message activities if (dc.context.activity.type === ActivityTypes.Message) { - const instance = dc.instance as WaterfallInstance; + const instance = dc.currentDialog as WaterfallInstance; instance.step += 1 return this.runStep(dc, dc.context.activity.text); } else { @@ -160,14 +160,14 @@ export class Waterfall extends Dialog { } public dialogResume(dc: DialogContext, result?: any): Promiseable { - const instance = dc.instance as WaterfallInstance; + const instance = dc.currentDialog as WaterfallInstance; instance.step += 1 return this.runStep(dc, result); } private runStep(dc: DialogContext, result?: any): Promise { try { - const instance = dc.instance as WaterfallInstance; + const instance = dc.currentDialog as WaterfallInstance; const step = instance.step; if (step >= 0 && step < this.steps.length) { // Execute step From 6d7dadc07945834d03d41e0529d62769109189cf Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Thu, 26 Apr 2018 12:29:08 -0700 Subject: [PATCH 3/8] Fixed circular dependency and updated unit tests --- .../lib/compositeControl.d.ts | 172 ---------------- .../lib/compositeControl.js | 192 ------------------ .../lib/compositeControl.js.map | 1 - libraries/botbuilder-dialogs/lib/control.d.ts | 70 ------- libraries/botbuilder-dialogs/lib/control.js | 81 -------- .../botbuilder-dialogs/lib/control.js.map | 1 - libraries/botbuilder-dialogs/lib/dialog.d.ts | 131 ++++++++++++ libraries/botbuilder-dialogs/lib/dialog.js | 131 ++++++++++++ .../botbuilder-dialogs/lib/dialog.js.map | 2 +- .../botbuilder-dialogs/lib/dialogSet.d.ts | 3 +- libraries/botbuilder-dialogs/lib/dialogSet.js | 4 +- .../botbuilder-dialogs/lib/dialogSet.js.map | 2 +- libraries/botbuilder-dialogs/lib/index.d.ts | 1 - libraries/botbuilder-dialogs/lib/index.js | 1 - libraries/botbuilder-dialogs/lib/index.js.map | 2 +- libraries/botbuilder-dialogs/src/dialog.ts | 186 ++++++++++++++++- libraries/botbuilder-dialogs/src/dialogSet.ts | 5 +- libraries/botbuilder-dialogs/src/index.ts | 1 - libraries/botbuilder-dialogs/src/waterfall.ts | 191 ----------------- .../botbuilder-dialogs/tests/control.test.js | 88 -------- .../botbuilder-dialogs/tests/dialog.test.js | 141 +++++++++++++ ...ontrol.test.js => dialogContainer.test.js} | 14 +- .../tests/waterfall.test.js | 69 ------- 23 files changed, 603 insertions(+), 886 deletions(-) delete mode 100644 libraries/botbuilder-dialogs/lib/compositeControl.d.ts delete mode 100644 libraries/botbuilder-dialogs/lib/compositeControl.js delete mode 100644 libraries/botbuilder-dialogs/lib/compositeControl.js.map delete mode 100644 libraries/botbuilder-dialogs/lib/control.d.ts delete mode 100644 libraries/botbuilder-dialogs/lib/control.js delete mode 100644 libraries/botbuilder-dialogs/lib/control.js.map delete mode 100644 libraries/botbuilder-dialogs/src/waterfall.ts delete mode 100644 libraries/botbuilder-dialogs/tests/control.test.js create mode 100644 libraries/botbuilder-dialogs/tests/dialog.test.js rename libraries/botbuilder-dialogs/tests/{compositeControl.test.js => dialogContainer.test.js} (91%) delete mode 100644 libraries/botbuilder-dialogs/tests/waterfall.test.js diff --git a/libraries/botbuilder-dialogs/lib/compositeControl.d.ts b/libraries/botbuilder-dialogs/lib/compositeControl.d.ts deleted file mode 100644 index dbfdfaf48f..0000000000 --- a/libraries/botbuilder-dialogs/lib/compositeControl.d.ts +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @module botbuilder-dialogs - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { TurnContext } from 'botbuilder'; -import { Dialog } from './dialog'; -import { DialogContext, DialogResult } from './dialogContext'; -import { DialogSet } from './dialogSet'; -/** - * :package: **botbuilder-dialogs** - * - * A `CompositeControl` makes it easy to take an existing set of dialogs and package them up as a - * control that can be used within another bot. The control can be used either as a dialog added - * to the other bots `DialogSet` or on its own for bots that are using some other conversation - * management system. - * - * ### Control Packaging - * - * You'll typically want to package your control as a new class derived from `CompositeControl`. - * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs - * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. - * - * If your control needs to be configured then you can pass through the configuration settings as - * a set of `defaultOptions` which will be merged with any options passed in by the caller when - * they call `begin()`. These will then be passed as arguments to the initial dialog that gets - * started. - * - * Here's a fairly simple example of a `ProfileControl` that's designed to prompt the user to - * enter their name and phone number which it will return as a JSON object to the caller: - * - * ```JavaScript - * const { CompositeControl, DialogSet, TextPrompt } = require('botbuilder-dialogs'); - * - * const dialogs = new DialogSet(); - * - * class ProfileControl extends CompositeControl { - * constructor() { - * super('fillProfile'); - * - * this.dialogs.add('fillProfile', [ - * async function (dc, options) { - * dc.instance.state = {}; - * await dc.prompt('textPrompt', `What's your name?`); - * }, - * async function (dc, name) { - * dc.instance.state.name = name; - * await dc.prompt('textPrompt', `What's your phone number?`); - * }, - * async function (dc, phone) { - * dc.instance.state.phone = phone; - * - * // Return completed profile - * await dc.end(dc.instance.state); - * } - * ]); - * - * this.dialogs.add('textPrompt', new TextPrompt()); - * } - * } - * module.exports.ProfileControl = ProfileControl; - * ``` - * - * ### Consume as Dialog - * - * On the consumption side the control we created can be used by a bot in much the same way they - * would use any other prompt. They can add a new instance of the control as a named dialog to - * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the - * control accepts options these can be passed in to the `begin()` call as well. - * - * ```JavaScript - * const { DialogSet } = require('botbuilder-dialogs'); - * const { ProfileControl } = require('./profileControl'); - * - * const dialogs = new DialogSet(); - * - * dialogs.add('getProfile', new ProfileControl()); - * - * dialogs.add('firstrun', [ - * async function (dc) { - * await dc.context.sendActivity(`Welcome! We need to ask a few questions to get started.`); - * await dc.begin('getProfile'); - * }, - * async function (dc, profile) { - * await dc.context.sendActivity(`Thanks ${profile.name}!`); - * await dc.end(); - * } - * ]); - * ``` - * - * ### Consume as Control - * - * If the consuming bot isn't dialog based they can still use your control. They will just need - * start the control from somewhere within their bots logic by calling the controls `begin()` - * method: - * - * ```JavaScript - * const state = {}; - * const control = new ProfileControl(); - * await prompt.begin(context, state); - * ``` - * - * The control will populate the `state` object passed in with information it needs to process - * the users response. This should be saved off with the bots conversation state as it needs to be - * passed into the controls `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const control = new ProfileControl(); - * const result = await control.continue(context, state); - * if (!result.active) { - * const profile = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the control is finished and then to access any results it might have returned. To interrupt or - * cancel the control simply delete the `state` object the bot has been persisting. - * @param R (Optional) type of result that's expected to be returned by the control. - * @param O (Optional) options that can be passed into the begin() method. - * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. - */ -export declare class CompositeControl implements Dialog { - protected dialogId: string; - /** The controls dialog set. */ - protected dialogs: DialogSet; - /** - * Creates a new `CompositeControl` instance. - * @param dialogId ID of the root dialog that should be started anytime the control is started. - * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. - */ - constructor(dialogId: string, dialogs?: DialogSet); - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - begin(context: C, state: object, options?: O): Promise>; - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - continue(context: C, state: object): Promise>; - dialogBegin(dc: DialogContext, dialogArgs?: any): Promise; - dialogContinue(dc: DialogContext): Promise; -} diff --git a/libraries/botbuilder-dialogs/lib/compositeControl.js b/libraries/botbuilder-dialogs/lib/compositeControl.js deleted file mode 100644 index e9a69d1aa1..0000000000 --- a/libraries/botbuilder-dialogs/lib/compositeControl.js +++ /dev/null @@ -1,192 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const dialogSet_1 = require("./dialogSet"); -/** - * :package: **botbuilder-dialogs** - * - * A `CompositeControl` makes it easy to take an existing set of dialogs and package them up as a - * control that can be used within another bot. The control can be used either as a dialog added - * to the other bots `DialogSet` or on its own for bots that are using some other conversation - * management system. - * - * ### Control Packaging - * - * You'll typically want to package your control as a new class derived from `CompositeControl`. - * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs - * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. - * - * If your control needs to be configured then you can pass through the configuration settings as - * a set of `defaultOptions` which will be merged with any options passed in by the caller when - * they call `begin()`. These will then be passed as arguments to the initial dialog that gets - * started. - * - * Here's a fairly simple example of a `ProfileControl` that's designed to prompt the user to - * enter their name and phone number which it will return as a JSON object to the caller: - * - * ```JavaScript - * const { CompositeControl, DialogSet, TextPrompt } = require('botbuilder-dialogs'); - * - * const dialogs = new DialogSet(); - * - * class ProfileControl extends CompositeControl { - * constructor() { - * super('fillProfile'); - * - * this.dialogs.add('fillProfile', [ - * async function (dc, options) { - * dc.instance.state = {}; - * await dc.prompt('textPrompt', `What's your name?`); - * }, - * async function (dc, name) { - * dc.instance.state.name = name; - * await dc.prompt('textPrompt', `What's your phone number?`); - * }, - * async function (dc, phone) { - * dc.instance.state.phone = phone; - * - * // Return completed profile - * await dc.end(dc.instance.state); - * } - * ]); - * - * this.dialogs.add('textPrompt', new TextPrompt()); - * } - * } - * module.exports.ProfileControl = ProfileControl; - * ``` - * - * ### Consume as Dialog - * - * On the consumption side the control we created can be used by a bot in much the same way they - * would use any other prompt. They can add a new instance of the control as a named dialog to - * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the - * control accepts options these can be passed in to the `begin()` call as well. - * - * ```JavaScript - * const { DialogSet } = require('botbuilder-dialogs'); - * const { ProfileControl } = require('./profileControl'); - * - * const dialogs = new DialogSet(); - * - * dialogs.add('getProfile', new ProfileControl()); - * - * dialogs.add('firstrun', [ - * async function (dc) { - * await dc.context.sendActivity(`Welcome! We need to ask a few questions to get started.`); - * await dc.begin('getProfile'); - * }, - * async function (dc, profile) { - * await dc.context.sendActivity(`Thanks ${profile.name}!`); - * await dc.end(); - * } - * ]); - * ``` - * - * ### Consume as Control - * - * If the consuming bot isn't dialog based they can still use your control. They will just need - * start the control from somewhere within their bots logic by calling the controls `begin()` - * method: - * - * ```JavaScript - * const state = {}; - * const control = new ProfileControl(); - * await prompt.begin(context, state); - * ``` - * - * The control will populate the `state` object passed in with information it needs to process - * the users response. This should be saved off with the bots conversation state as it needs to be - * passed into the controls `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const control = new ProfileControl(); - * const result = await control.continue(context, state); - * if (!result.active) { - * const profile = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the control is finished and then to access any results it might have returned. To interrupt or - * cancel the control simply delete the `state` object the bot has been persisting. - * @param R (Optional) type of result that's expected to be returned by the control. - * @param O (Optional) options that can be passed into the begin() method. - * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. - */ -class CompositeControl { - /** - * Creates a new `CompositeControl` instance. - * @param dialogId ID of the root dialog that should be started anytime the control is started. - * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. - */ - constructor(dialogId, dialogs) { - this.dialogId = dialogId; - this.dialogs = dialogs || new dialogSet_1.DialogSet(); - } - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - begin(context, state, options) { - const cdc = this.dialogs.createContext(context, state); - return cdc.begin(this.dialogId, options) - .then(() => cdc.dialogResult); - } - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - continue(context, state) { - const cdc = this.dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); - } - dialogBegin(dc, dialogArgs) { - // Start the controls entry point dialog. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); - return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); - } - }); - } - dialogContinue(dc) { - // Continue controls dialog stack. - const cdc = this.dialogs.createContext(dc.context, dc.instance.state); - return cdc.continue().then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); - } - }); - } -} -exports.CompositeControl = CompositeControl; -//# sourceMappingURL=compositeControl.js.map \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/compositeControl.js.map b/libraries/botbuilder-dialogs/lib/compositeControl.js.map deleted file mode 100644 index df94337aee..0000000000 --- a/libraries/botbuilder-dialogs/lib/compositeControl.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"compositeControl.js","sourceRoot":"","sources":["../src/compositeControl.ts"],"names":[],"mappings":";;AAUA,2CAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;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YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,cAAc,CAAC,EAAoB;QACtC,kCAAkC;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,mCAAmC;YACnC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAhFD,4CAgFC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/control.d.ts b/libraries/botbuilder-dialogs/lib/control.d.ts deleted file mode 100644 index 48c8e1c03e..0000000000 --- a/libraries/botbuilder-dialogs/lib/control.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @module botbuilder-dialogs - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { TurnContext } from 'botbuilder'; -import { Dialog } from './dialog'; -import { DialogContext, DialogResult } from './dialogContext'; -/** - * :package: **botbuilder-dialogs** - * - * Base class for any dialog that wants to support being used as a dialog within a bots `DialogSet` - * or on its own as a control within a bot that uses an alternate conversation management system. - * - * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The - * primary difference between the two classes is that the `CompositeControl` class is designed to - * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can - * be used in complete isolation without the need for any other supporting dialogs. - * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. - * @param O (Optional) options that can be passed into the [begin()](#begin) method. - */ -export declare abstract class Control implements Dialog { - protected defaultOptions: O; - /** - * Creates a new Control instance. - * @param defaultOptions (Optional) set of default options that should be passed to controls `dialogBegin()` method. These will be merged with arguments passed in by the caller. - */ - constructor(defaultOptions?: O); - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - begin(context: C, state: object, options?: O): Promise>; - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - continue(context: C, state: object): Promise>; - abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promise; -} diff --git a/libraries/botbuilder-dialogs/lib/control.js b/libraries/botbuilder-dialogs/lib/control.js deleted file mode 100644 index d461411b02..0000000000 --- a/libraries/botbuilder-dialogs/lib/control.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const dialogSet_1 = require("./dialogSet"); -/** - * :package: **botbuilder-dialogs** - * - * Base class for any dialog that wants to support being used as a dialog within a bots `DialogSet` - * or on its own as a control within a bot that uses an alternate conversation management system. - * - * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The - * primary difference between the two classes is that the `CompositeControl` class is designed to - * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can - * be used in complete isolation without the need for any other supporting dialogs. - * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. - * @param O (Optional) options that can be passed into the [begin()](#begin) method. - */ -class Control { - /** - * Creates a new Control instance. - * @param defaultOptions (Optional) set of default options that should be passed to controls `dialogBegin()` method. These will be merged with arguments passed in by the caller. - */ - constructor(defaultOptions) { - this.defaultOptions = defaultOptions; - } - /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. - * - * **Usage Example:** - * - * ```JavaScript - * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. - */ - begin(context, state, options) { - // Create empty dialog set and ourselves to it - const dialogs = new dialogSet_1.DialogSet(); - dialogs.add('control', this); - // Start the control - const cdc = dialogs.createContext(context, state); - return cdc.begin('control', Object.assign({}, this.defaultOptions, options)) - .then(() => cdc.dialogResult); - } - /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. - * - * **Usage Example:** - * - * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; - * } - * ``` - * @param context Context for the current turn of the conversation with the user. - * @param state A state object that was previously initialized by a call to [begin()](#begin). - */ - continue(context, state) { - // Create empty dialog set and ourselves to it - const dialogs = new dialogSet_1.DialogSet(); - dialogs.add('control', this); - // Continue the control - const cdc = dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); - } -} -exports.Control = Control; -//# sourceMappingURL=control.js.map \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/control.js.map b/libraries/botbuilder-dialogs/lib/control.js.map deleted file mode 100644 index 64a8c98d8a..0000000000 --- a/libraries/botbuilder-dialogs/lib/control.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"control.js","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":";;AAUA,2CAAwC;AAExC;;;;;;;;;;;;;;GAcG;AACH;IAEI;;;OAGG;IACH,YAAsB,cAAkB;QAAlB,mBAAc,GAAd,cAAc,CAAI;IAAI,CAAC;IAE7C;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,OAAU,EAAE,KAAa,EAAE,OAAW;QAC/C,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE7B,oBAAoB;QACpB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;aACjE,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,QAAQ,CAAC,OAAU,EAAE,KAAa;QACrC,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE7B,uBAAuB;QACvB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;aACV,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;CAGJ;AAjED,0BAiEC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialog.d.ts b/libraries/botbuilder-dialogs/lib/dialog.d.ts index 9c261aca9b..8c74125ae6 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialog.d.ts @@ -96,3 +96,134 @@ export declare abstract class Dialog { */ dialogResume?(dc: DialogContext, result?: any): Promiseable; } +/** + * :package: **botbuilder-dialogs** + * + * Function signature of a waterfall step. + * + * **Example usage:** + * + * ```JavaScript + * dialogs.add('addAlarm', [ + * function (context, alarm, next) { + * dialogs.getInstance(context).state = Object.assign({}, alarm); + * if (!alarm.title) { + * return dialogs.prompt(context, 'titlePrompt', `What would you like to call your alarm?`); + * } else { + * return next(alarm.title); + * } + * }, + * function (context, title, next) { + * const alarm = dialogs.getInstance(context).state; + * alarm.title = title; + * if (!alarm.time) { + * return dialogs.prompt(context, 'timePrompt', `What time would you like to set it for?`); + * } else { + * return next(alarm.time); + * } + * }, + * function (context, time) { + * const alarm = dialogs.getInstance(context).state; + * alarm.time = time; + * + * // ... set alarm ... + * + * context.reply(`Alarm set.`); + * return dialogs.end(context); + * } + * ]); + * ``` + * @param WaterfallStep.context The dialog context for the current turn of conversation. + * @param WaterfallStep.args Argument(s) passed into the dialog for the first step and then the results from calling a prompt or other dialog for subsequent steps. + * @param WaterfallStep.next Function passed into the step to let you manually skip to the next step in the waterfall. + */ +export declare type WaterfallStep = (dc: DialogContext, args?: any, next?: SkipStepFunction) => Promiseable; +/** + * :package: **botbuilder-dialogs** + * + * When called, control will skip to the next waterfall step. + * @param SkipStepFunction.args (Optional) additional argument(s) to pass into the next step. + */ +export declare type SkipStepFunction = (args?: any) => Promise; +/** + * :package: **botbuilder-dialogs** + * + * Dialog optimized for prompting a user with a series of questions. Waterfalls accept a stack of + * functions which will be executed in sequence. Each waterfall step can ask a question of the user + * and the users response will be passed as an argument to the next waterfall step. + * + * For simple text questions you can send the user a message and then process their answer in the + * next step: + * + * ```JS + * dialogs.add('namePrompt', [ + * async function (dc) { + * dc.instance.state = { first: '', last: '', full: '' }; + * await dc.context.sendActivity(`What's your first name?`); + * }, + * async function (dc, firstName) { + * dc.instance.state.first = firstName; + * await dc.context.sendActivity(`Great ${firstName}! What's your last name?`); + * }, + * async function (dc, lastName) { + * const name = dc.instance.state; + * name.last = lastName; + * name.full = name.first + ' ' + name.last; + * await dc.end(name); + * } + * ]); + * ``` + * + * For more complex sequences you can call other dialogs from within a step and the result returned + * by the dialog will be passed to the next step: + * + * ```JS + * dialogs.add('survey', [ + * async function (dc) { + * dc.instance.state = { name: undefined, languages: '', years: 0 }; + * await dc.begin('namePrompt'); + * }, + * async function (dc, name) { + * dc.instance.state.name = name; + * await dc.context.sendActivity(`Ok ${name.full}... What programming languages do you know?`); + * }, + * async function (dc, languages) { + * dc.instance.state.languages = languages; + * await dc.prompt('yearsPrompt', `Great. So how many years have you been programming?`); + * }, + * async function (dc, years) { + * dc.instance.state.years = years; + * await dc.context.sendActivity(`Thank you for taking our survey.`); + * await dc.end(dc.instance.state); + * } + * ]); + * + * dialogs.add('yearsPrompt', new NumberPrompt(async (dc, value) => { + * if (value === undefined || value < 0 || value > 110) { + * await dc.context.sendActivity(`Enter a number from 0 to 110.`); + * } else { + * return value; + * } + * })); + * ``` + * + * The example builds on the previous `namePrompt` sample and shows how you can call another dialog + * which will ask its own sequence of questions. The dialogs library provides a built-in set of + * prompt classes which can be used to recognize things like dates and numbers in the users response. + * + * You should generally call `dc.end()` or `dc.replace()` from your last waterfall step but if you fail + * to do that the dialog will be automatically ended for you on the users next reply. The users + * response will be passed to the calling dialogs next waterfall step if there is one. + */ +export declare class Waterfall extends Dialog { + private readonly steps; + /** + * Creates a new waterfall dialog containing the given array of steps. + * @param steps Array of waterfall steps. + */ + constructor(steps: WaterfallStep[]); + dialogBegin(dc: DialogContext, args?: any): Promiseable; + dialogContinue(dc: DialogContext): Promise; + dialogResume(dc: DialogContext, result?: any): Promiseable; + private runStep(dc, result?); +} diff --git a/libraries/botbuilder-dialogs/lib/dialog.js b/libraries/botbuilder-dialogs/lib/dialog.js index bfc86f030e..57933f52ec 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js +++ b/libraries/botbuilder-dialogs/lib/dialog.js @@ -1,5 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +/** + * @module botbuilder-dialogs + */ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + */ +const botbuilder_1 = require("botbuilder"); const dialogSet_1 = require("./dialogSet"); /** * :package: **botbuilder-dialogs** @@ -70,4 +78,127 @@ class Dialog { } } exports.Dialog = Dialog; +/** + * :package: **botbuilder-dialogs** + * + * Dialog optimized for prompting a user with a series of questions. Waterfalls accept a stack of + * functions which will be executed in sequence. Each waterfall step can ask a question of the user + * and the users response will be passed as an argument to the next waterfall step. + * + * For simple text questions you can send the user a message and then process their answer in the + * next step: + * + * ```JS + * dialogs.add('namePrompt', [ + * async function (dc) { + * dc.instance.state = { first: '', last: '', full: '' }; + * await dc.context.sendActivity(`What's your first name?`); + * }, + * async function (dc, firstName) { + * dc.instance.state.first = firstName; + * await dc.context.sendActivity(`Great ${firstName}! What's your last name?`); + * }, + * async function (dc, lastName) { + * const name = dc.instance.state; + * name.last = lastName; + * name.full = name.first + ' ' + name.last; + * await dc.end(name); + * } + * ]); + * ``` + * + * For more complex sequences you can call other dialogs from within a step and the result returned + * by the dialog will be passed to the next step: + * + * ```JS + * dialogs.add('survey', [ + * async function (dc) { + * dc.instance.state = { name: undefined, languages: '', years: 0 }; + * await dc.begin('namePrompt'); + * }, + * async function (dc, name) { + * dc.instance.state.name = name; + * await dc.context.sendActivity(`Ok ${name.full}... What programming languages do you know?`); + * }, + * async function (dc, languages) { + * dc.instance.state.languages = languages; + * await dc.prompt('yearsPrompt', `Great. So how many years have you been programming?`); + * }, + * async function (dc, years) { + * dc.instance.state.years = years; + * await dc.context.sendActivity(`Thank you for taking our survey.`); + * await dc.end(dc.instance.state); + * } + * ]); + * + * dialogs.add('yearsPrompt', new NumberPrompt(async (dc, value) => { + * if (value === undefined || value < 0 || value > 110) { + * await dc.context.sendActivity(`Enter a number from 0 to 110.`); + * } else { + * return value; + * } + * })); + * ``` + * + * The example builds on the previous `namePrompt` sample and shows how you can call another dialog + * which will ask its own sequence of questions. The dialogs library provides a built-in set of + * prompt classes which can be used to recognize things like dates and numbers in the users response. + * + * You should generally call `dc.end()` or `dc.replace()` from your last waterfall step but if you fail + * to do that the dialog will be automatically ended for you on the users next reply. The users + * response will be passed to the calling dialogs next waterfall step if there is one. + */ +class Waterfall extends Dialog { + /** + * Creates a new waterfall dialog containing the given array of steps. + * @param steps Array of waterfall steps. + */ + constructor(steps) { + super(); + this.steps = steps.slice(0); + } + dialogBegin(dc, args) { + const instance = dc.currentDialog; + instance.step = 0; + return this.runStep(dc, args); + } + dialogContinue(dc) { + // Don't do anything for non-message activities + if (dc.context.activity.type === botbuilder_1.ActivityTypes.Message) { + const instance = dc.currentDialog; + instance.step += 1; + return this.runStep(dc, dc.context.activity.text); + } + else { + return Promise.resolve(); + } + } + dialogResume(dc, result) { + const instance = dc.currentDialog; + instance.step += 1; + return this.runStep(dc, result); + } + runStep(dc, result) { + try { + const instance = dc.currentDialog; + const step = instance.step; + if (step >= 0 && step < this.steps.length) { + // Execute step + return Promise.resolve(this.steps[step](dc, result, (r) => { + // Skip to next step + instance.step += 1; + return this.runStep(dc, r); + })); + } + else { + // End of waterfall so just return to parent + return dc.end(result); + } + } + catch (err) { + return Promise.reject(err); + } + } +} +exports.Waterfall = Waterfall; //# sourceMappingURL=dialog.js.map \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialog.js.map b/libraries/botbuilder-dialogs/lib/dialog.js.map index 4f62366240..7103d6fc6b 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js.map +++ b/libraries/botbuilder-dialogs/lib/dialog.js.map @@ -1 +1 @@ -{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":";;AASA,2CAAwC;AAcxC;;;;;;;;;;;;;GAaG;AACH;IACI;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,OAAU,EAAE,KAAa,EAAE,OAAW;QAC/C,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE5B,oBAAoB;QACpB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;aACxB,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,QAAQ,CAAC,OAAU,EAAE,KAAa;QACrC,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE5B,uBAAuB;QACvB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE;aACV,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;CA+BJ;AAtFD,wBAsFC"} \ No newline at end of file +{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAAqE;AAErE,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,CAAC,CAAO,EAAE,EAAE;oBAC5D,oBAAoB;oBACpB,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;oBACnB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,CAAC,CAAC;YACR,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,4CAA4C;gBAC5C,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC;QAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ;AAtDD,8BAsDC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialogSet.d.ts b/libraries/botbuilder-dialogs/lib/dialogSet.d.ts index 9dbf39aebc..432bc26897 100644 --- a/libraries/botbuilder-dialogs/lib/dialogSet.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialogSet.d.ts @@ -6,8 +6,7 @@ * Licensed under the MIT License. */ import { TurnContext } from 'botbuilder'; -import { Dialog } from './dialog'; -import { Waterfall, WaterfallStep } from './waterfall'; +import { Dialog, Waterfall, WaterfallStep } from './dialog'; import { DialogContext } from './dialogContext'; /** * :package: **botbuilder-dialogs** diff --git a/libraries/botbuilder-dialogs/lib/dialogSet.js b/libraries/botbuilder-dialogs/lib/dialogSet.js index 051ce65e38..83a4f3ff81 100644 --- a/libraries/botbuilder-dialogs/lib/dialogSet.js +++ b/libraries/botbuilder-dialogs/lib/dialogSet.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const waterfall_1 = require("./waterfall"); +const dialog_1 = require("./dialog"); const dialogContext_1 = require("./dialogContext"); /** * :package: **botbuilder-dialogs** @@ -101,7 +101,7 @@ class DialogSet { if (this.dialogs.hasOwnProperty(dialogId)) { throw new Error(`DialogSet.add(): A dialog with an id of '${dialogId}' already added.`); } - return this.dialogs[dialogId] = Array.isArray(dialogOrSteps) ? new waterfall_1.Waterfall(dialogOrSteps) : dialogOrSteps; + return this.dialogs[dialogId] = Array.isArray(dialogOrSteps) ? new dialog_1.Waterfall(dialogOrSteps) : dialogOrSteps; } createContext(context, state) { if (!Array.isArray(state['dialogStack'])) { diff --git a/libraries/botbuilder-dialogs/lib/dialogSet.js.map b/libraries/botbuilder-dialogs/lib/dialogSet.js.map index 5f9def65e1..72bbf88188 100644 --- a/libraries/botbuilder-dialogs/lib/dialogSet.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogSet.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogSet.js","sourceRoot":"","sources":["../src/dialogSet.ts"],"names":[],"mappings":";;AASA,2CAAuD;AACvD,mDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH;IAAA;QACqB,YAAO,GAAgC,EAAE,CAAC;IA4C/D,CAAC;IAxBU,GAAG,CAAC,QAAgB,EAAE,aAA2C;QACpE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAAC,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,kBAAkB,CAAC,CAAA;QAAC,CAAC;QACtI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,qBAAS,CAAC,aAAoB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IACvH,CAAC;IAEM,aAAa,CAAC,OAAU,EAAE,KAAa;QAC1C,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CA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AC;YAAC,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,CAAA;QAAC,CAAC;QACvE,MAAM,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;OAUG;IACI,IAAI,CAAkC,QAAgB;QACzD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,CAAC;CACJ;AA7CD,8BA6CC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/index.d.ts b/libraries/botbuilder-dialogs/lib/index.d.ts index f7ba560f11..ef67f9209d 100644 --- a/libraries/botbuilder-dialogs/lib/index.d.ts +++ b/libraries/botbuilder-dialogs/lib/index.d.ts @@ -7,5 +7,4 @@ export * from './dialog'; export * from './dialogContainer'; export * from './dialogContext'; export * from './dialogSet'; -export * from './waterfall'; export { FoundChoice, Choice, ChoiceFactoryOptions, FoundDatetime, FindChoicesOptions, ListStyle, PromptValidator } from 'botbuilder-prompts'; diff --git a/libraries/botbuilder-dialogs/lib/index.js b/libraries/botbuilder-dialogs/lib/index.js index 2c1c899d1e..71f3981f9f 100644 --- a/libraries/botbuilder-dialogs/lib/index.js +++ b/libraries/botbuilder-dialogs/lib/index.js @@ -12,7 +12,6 @@ __export(require("./dialog")); __export(require("./dialogContainer")); __export(require("./dialogContext")); __export(require("./dialogSet")); -__export(require("./waterfall")); // Re-exporting choice related interfaces used just to avoid TS developers from needing to // import interfaces from two libraries when working with dialogs. var botbuilder_prompts_1 = require("botbuilder-prompts"); diff --git a/libraries/botbuilder-dialogs/lib/index.js.map b/libraries/botbuilder-dialogs/lib/index.js.map index 3f0387d101..ad6dcb4957 100644 --- a/libraries/botbuilder-dialogs/lib/index.js.map +++ b/libraries/botbuilder-dialogs/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,sCAAsC;AACtC,qCAAgC;AAChC,8BAAyB;AACzB,uCAAkC;AAClC,qCAAgC;AAChC,iCAA4B;AAC5B,iCAA4B;AAE5B,2FAA2F;AAC3F,kEAAkE;AAClE,yDAA8I;AAAvD,yCAAA,SAAS,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA;;GAEG;AACH,sCAAsC;AACtC,qCAAgC;AAChC,8BAAyB;AACzB,uCAAkC;AAClC,qCAAgC;AAChC,iCAA4B;AAE5B,2FAA2F;AAC3F,kEAAkE;AAClE,yDAA8I;AAAvD,yCAAA,SAAS,CAAA"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/dialog.ts b/libraries/botbuilder-dialogs/src/dialog.ts index 826490fcdd..388af0c4df 100644 --- a/libraries/botbuilder-dialogs/src/dialog.ts +++ b/libraries/botbuilder-dialogs/src/dialog.ts @@ -5,10 +5,12 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { TurnContext, Promiseable } from 'botbuilder'; +import { TurnContext, Promiseable, ActivityTypes } from 'botbuilder'; import { DialogContext, DialogResult } from './dialogContext'; import { DialogSet } from './dialogSet'; +// NOTE: unfortunately the Waterfall class needs to be in this file to avoid a circular dependency. + /** * Tracking information for a dialog on the stack. * @param T (Optional) type of state being persisted for dialog. @@ -122,3 +124,185 @@ export abstract class Dialog { */ dialogResume?(dc: DialogContext, result?: any): Promiseable; } + + +/** + * :package: **botbuilder-dialogs** + * + * Function signature of a waterfall step. + * + * **Example usage:** + * + * ```JavaScript + * dialogs.add('addAlarm', [ + * function (context, alarm, next) { + * dialogs.getInstance(context).state = Object.assign({}, alarm); + * if (!alarm.title) { + * return dialogs.prompt(context, 'titlePrompt', `What would you like to call your alarm?`); + * } else { + * return next(alarm.title); + * } + * }, + * function (context, title, next) { + * const alarm = dialogs.getInstance(context).state; + * alarm.title = title; + * if (!alarm.time) { + * return dialogs.prompt(context, 'timePrompt', `What time would you like to set it for?`); + * } else { + * return next(alarm.time); + * } + * }, + * function (context, time) { + * const alarm = dialogs.getInstance(context).state; + * alarm.time = time; + * + * // ... set alarm ... + * + * context.reply(`Alarm set.`); + * return dialogs.end(context); + * } + * ]); + * ``` + * @param WaterfallStep.context The dialog context for the current turn of conversation. + * @param WaterfallStep.args Argument(s) passed into the dialog for the first step and then the results from calling a prompt or other dialog for subsequent steps. + * @param WaterfallStep.next Function passed into the step to let you manually skip to the next step in the waterfall. + */ +export type WaterfallStep = (dc: DialogContext, args?: any, next?: SkipStepFunction) => Promiseable; + +/** + * :package: **botbuilder-dialogs** + * + * When called, control will skip to the next waterfall step. + * @param SkipStepFunction.args (Optional) additional argument(s) to pass into the next step. + */ +export type SkipStepFunction = (args?: any) => Promise; + +/** + * :package: **botbuilder-dialogs** + * + * Dialog optimized for prompting a user with a series of questions. Waterfalls accept a stack of + * functions which will be executed in sequence. Each waterfall step can ask a question of the user + * and the users response will be passed as an argument to the next waterfall step. + * + * For simple text questions you can send the user a message and then process their answer in the + * next step: + * + * ```JS + * dialogs.add('namePrompt', [ + * async function (dc) { + * dc.instance.state = { first: '', last: '', full: '' }; + * await dc.context.sendActivity(`What's your first name?`); + * }, + * async function (dc, firstName) { + * dc.instance.state.first = firstName; + * await dc.context.sendActivity(`Great ${firstName}! What's your last name?`); + * }, + * async function (dc, lastName) { + * const name = dc.instance.state; + * name.last = lastName; + * name.full = name.first + ' ' + name.last; + * await dc.end(name); + * } + * ]); + * ``` + * + * For more complex sequences you can call other dialogs from within a step and the result returned + * by the dialog will be passed to the next step: + * + * ```JS + * dialogs.add('survey', [ + * async function (dc) { + * dc.instance.state = { name: undefined, languages: '', years: 0 }; + * await dc.begin('namePrompt'); + * }, + * async function (dc, name) { + * dc.instance.state.name = name; + * await dc.context.sendActivity(`Ok ${name.full}... What programming languages do you know?`); + * }, + * async function (dc, languages) { + * dc.instance.state.languages = languages; + * await dc.prompt('yearsPrompt', `Great. So how many years have you been programming?`); + * }, + * async function (dc, years) { + * dc.instance.state.years = years; + * await dc.context.sendActivity(`Thank you for taking our survey.`); + * await dc.end(dc.instance.state); + * } + * ]); + * + * dialogs.add('yearsPrompt', new NumberPrompt(async (dc, value) => { + * if (value === undefined || value < 0 || value > 110) { + * await dc.context.sendActivity(`Enter a number from 0 to 110.`); + * } else { + * return value; + * } + * })); + * ``` + * + * The example builds on the previous `namePrompt` sample and shows how you can call another dialog + * which will ask its own sequence of questions. The dialogs library provides a built-in set of + * prompt classes which can be used to recognize things like dates and numbers in the users response. + * + * You should generally call `dc.end()` or `dc.replace()` from your last waterfall step but if you fail + * to do that the dialog will be automatically ended for you on the users next reply. The users + * response will be passed to the calling dialogs next waterfall step if there is one. + */ +export class Waterfall extends Dialog { + private readonly steps: WaterfallStep[]; + + /** + * Creates a new waterfall dialog containing the given array of steps. + * @param steps Array of waterfall steps. + */ + constructor(steps: WaterfallStep[]) { + super(); + this.steps = steps.slice(0); + } + + public dialogBegin(dc: DialogContext, args?: any): Promiseable { + const instance = dc.currentDialog as WaterfallInstance; + instance.step = 0; + return this.runStep(dc, args); + } + + public dialogContinue(dc: DialogContext): Promise { + // Don't do anything for non-message activities + if (dc.context.activity.type === ActivityTypes.Message) { + const instance = dc.currentDialog as WaterfallInstance; + instance.step += 1 + return this.runStep(dc, dc.context.activity.text); + } else { + return Promise.resolve(); + } + } + + public dialogResume(dc: DialogContext, result?: any): Promiseable { + const instance = dc.currentDialog as WaterfallInstance; + instance.step += 1 + return this.runStep(dc, result); + } + + private runStep(dc: DialogContext, result?: any): Promise { + try { + const instance = dc.currentDialog as WaterfallInstance; + const step = instance.step; + if (step >= 0 && step < this.steps.length) { + // Execute step + return Promise.resolve(this.steps[step](dc, result, (r?: any) => { + // Skip to next step + instance.step += 1; + return this.runStep(dc, r); + })); + } else { + // End of waterfall so just return to parent + return dc.end(result); + } + } catch (err) { + return Promise.reject(err); + } + } +} + +interface WaterfallInstance extends DialogInstance { + step: number; +} diff --git a/libraries/botbuilder-dialogs/src/dialogSet.ts b/libraries/botbuilder-dialogs/src/dialogSet.ts index 66c71067bc..2a1ce1151c 100644 --- a/libraries/botbuilder-dialogs/src/dialogSet.ts +++ b/libraries/botbuilder-dialogs/src/dialogSet.ts @@ -5,9 +5,8 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { TurnContext, BotState, StoreItem, Activity } from 'botbuilder'; -import { Dialog, DialogInstance } from './dialog'; -import { Waterfall, WaterfallStep } from './waterfall'; +import { TurnContext, BotState, StoreItem, Activity, Promiseable } from 'botbuilder'; +import { Dialog, Waterfall, WaterfallStep } from './dialog'; import { DialogContext } from './dialogContext'; /** diff --git a/libraries/botbuilder-dialogs/src/index.ts b/libraries/botbuilder-dialogs/src/index.ts index e05adcd5d9..34d579dd3e 100644 --- a/libraries/botbuilder-dialogs/src/index.ts +++ b/libraries/botbuilder-dialogs/src/index.ts @@ -7,7 +7,6 @@ export * from './dialog'; export * from './dialogContainer'; export * from './dialogContext'; export * from './dialogSet'; -export * from './waterfall'; // Re-exporting choice related interfaces used just to avoid TS developers from needing to // import interfaces from two libraries when working with dialogs. diff --git a/libraries/botbuilder-dialogs/src/waterfall.ts b/libraries/botbuilder-dialogs/src/waterfall.ts deleted file mode 100644 index 50577060a9..0000000000 --- a/libraries/botbuilder-dialogs/src/waterfall.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @module botbuilder-dialogs - */ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. - */ -import { Promiseable, TurnContext, ActivityTypes } from 'botbuilder'; -import { Dialog, DialogInstance } from './dialog'; -import { DialogContext } from './dialogContext'; - -/** - * :package: **botbuilder-dialogs** - * - * Function signature of a waterfall step. - * - * **Example usage:** - * - * ```JavaScript - * dialogs.add('addAlarm', [ - * function (context, alarm, next) { - * dialogs.getInstance(context).state = Object.assign({}, alarm); - * if (!alarm.title) { - * return dialogs.prompt(context, 'titlePrompt', `What would you like to call your alarm?`); - * } else { - * return next(alarm.title); - * } - * }, - * function (context, title, next) { - * const alarm = dialogs.getInstance(context).state; - * alarm.title = title; - * if (!alarm.time) { - * return dialogs.prompt(context, 'timePrompt', `What time would you like to set it for?`); - * } else { - * return next(alarm.time); - * } - * }, - * function (context, time) { - * const alarm = dialogs.getInstance(context).state; - * alarm.time = time; - * - * // ... set alarm ... - * - * context.reply(`Alarm set.`); - * return dialogs.end(context); - * } - * ]); - * ``` - * @param WaterfallStep.context The dialog context for the current turn of conversation. - * @param WaterfallStep.args Argument(s) passed into the dialog for the first step and then the results from calling a prompt or other dialog for subsequent steps. - * @param WaterfallStep.next Function passed into the step to let you manually skip to the next step in the waterfall. - */ -export type WaterfallStep = (dc: DialogContext, args?: any, next?: SkipStepFunction) => Promiseable; - -/** - * :package: **botbuilder-dialogs** - * - * When called, control will skip to the next waterfall step. - * @param SkipStepFunction.args (Optional) additional argument(s) to pass into the next step. - */ -export type SkipStepFunction = (args?: any) => Promise; - -/** - * :package: **botbuilder-dialogs** - * - * Dialog optimized for prompting a user with a series of questions. Waterfalls accept a stack of - * functions which will be executed in sequence. Each waterfall step can ask a question of the user - * and the users response will be passed as an argument to the next waterfall step. - * - * For simple text questions you can send the user a message and then process their answer in the - * next step: - * - * ```JS - * dialogs.add('namePrompt', [ - * async function (dc) { - * dc.instance.state = { first: '', last: '', full: '' }; - * await dc.context.sendActivity(`What's your first name?`); - * }, - * async function (dc, firstName) { - * dc.instance.state.first = firstName; - * await dc.context.sendActivity(`Great ${firstName}! What's your last name?`); - * }, - * async function (dc, lastName) { - * const name = dc.instance.state; - * name.last = lastName; - * name.full = name.first + ' ' + name.last; - * await dc.end(name); - * } - * ]); - * ``` - * - * For more complex sequences you can call other dialogs from within a step and the result returned - * by the dialog will be passed to the next step: - * - * ```JS - * dialogs.add('survey', [ - * async function (dc) { - * dc.instance.state = { name: undefined, languages: '', years: 0 }; - * await dc.begin('namePrompt'); - * }, - * async function (dc, name) { - * dc.instance.state.name = name; - * await dc.context.sendActivity(`Ok ${name.full}... What programming languages do you know?`); - * }, - * async function (dc, languages) { - * dc.instance.state.languages = languages; - * await dc.prompt('yearsPrompt', `Great. So how many years have you been programming?`); - * }, - * async function (dc, years) { - * dc.instance.state.years = years; - * await dc.context.sendActivity(`Thank you for taking our survey.`); - * await dc.end(dc.instance.state); - * } - * ]); - * - * dialogs.add('yearsPrompt', new NumberPrompt(async (dc, value) => { - * if (value === undefined || value < 0 || value > 110) { - * await dc.context.sendActivity(`Enter a number from 0 to 110.`); - * } else { - * return value; - * } - * })); - * ``` - * - * The example builds on the previous `namePrompt` sample and shows how you can call another dialog - * which will ask its own sequence of questions. The dialogs library provides a built-in set of - * prompt classes which can be used to recognize things like dates and numbers in the users response. - * - * You should generally call `dc.end()` or `dc.replace()` from your last waterfall step but if you fail - * to do that the dialog will be automatically ended for you on the users next reply. The users - * response will be passed to the calling dialogs next waterfall step if there is one. - */ -export class Waterfall extends Dialog { - private readonly steps: WaterfallStep[]; - - /** - * Creates a new waterfall dialog containing the given array of steps. - * @param steps Array of waterfall steps. - */ - constructor(steps: WaterfallStep[]) { - super(); - this.steps = steps.slice(0); - } - - public dialogBegin(dc: DialogContext, args?: any): Promiseable { - const instance = dc.currentDialog as WaterfallInstance; - instance.step = 0; - return this.runStep(dc, args); - } - - public dialogContinue(dc: DialogContext): Promise { - // Don't do anything for non-message activities - if (dc.context.activity.type === ActivityTypes.Message) { - const instance = dc.currentDialog as WaterfallInstance; - instance.step += 1 - return this.runStep(dc, dc.context.activity.text); - } else { - return Promise.resolve(); - } - } - - public dialogResume(dc: DialogContext, result?: any): Promiseable { - const instance = dc.currentDialog as WaterfallInstance; - instance.step += 1 - return this.runStep(dc, result); - } - - private runStep(dc: DialogContext, result?: any): Promise { - try { - const instance = dc.currentDialog as WaterfallInstance; - const step = instance.step; - if (step >= 0 && step < this.steps.length) { - // Execute step - return Promise.resolve(this.steps[step](dc, result, (r?: any) => { - // Skip to next step - instance.step += 1; - return this.runStep(dc, r); - })); - } else { - // End of waterfall so just return to parent - return dc.end(result); - } - } catch (err) { - return Promise.reject(err); - } - } -} - -interface WaterfallInstance extends DialogInstance { - step: number; -} diff --git a/libraries/botbuilder-dialogs/tests/control.test.js b/libraries/botbuilder-dialogs/tests/control.test.js deleted file mode 100644 index b93437562e..0000000000 --- a/libraries/botbuilder-dialogs/tests/control.test.js +++ /dev/null @@ -1,88 +0,0 @@ -const { TestAdapter, TurnContext } = require('botbuilder'); -const { DialogSet, Control } = require('../'); -const assert = require('assert'); - -const beginMessage = { text: `begin`, type: 'message' }; -const continueMessage = { text: `continue`, type: 'message' }; - -class TestContext extends TurnContext { - constructor(request) { - super(new TestAdapter(), request); - this.sent = undefined; - this.onSendActivities((context, activities, next) => { - this.sent = activities; - context.responded = true; - }); - } -} - -class TestControl extends Control { - constructor(options) { - super(options); - this.beginCalled = false; - this.beginArgs = undefined; - this.continueCalled = false; - } - - dialogBegin(dc, args) { - this.beginCalled = true; - this.beginArgs = args; - return dc.context.sendActivity(`begin called`); - } - - dialogContinue(dc) { - this.continueCalled = true; - return dc.end(120); - } -} - -describe('Control', function() { - this.timeout(5000); - - it('should call control from a dialog set.', function (done) { - const control = new TestControl(); - - const dialogs = new DialogSet(); - dialogs.add('control', control); - - const state = {}; - const context = new TestContext(beginMessage); - const dc = dialogs.createContext(context, state); - dc.begin('control', { foo: 'bar' }).then(() => { - const result = dc.dialogResult; - assert(result && result.active); - assert(control.beginCalled); - assert(control.beginArgs && control.beginArgs.foo === 'bar'); - done(); - }); - }); - - it('should call control using begin().', function (done) { - const control = new TestControl(); - - const state = {}; - const context = new TestContext(beginMessage); - control.begin(context, state, { foo: 'bar' }).then((result) => { - assert(result && result.active); - assert(control.beginCalled); - assert(control.beginArgs && control.beginArgs.foo === 'bar'); - done(); - }); - }); - - it('should continue() a multi-turn control.', function (done) { - const control = new TestControl(); - - const state = {}; - const context = new TestContext(beginMessage); - control.begin(context, state, { foo: 'bar' }).then((result) => { - assert(result && result.active); - control.continue(context, state).then((result) => { - assert(control.continueCalled); - assert(result && !result.active); - assert(result.result === 120); - done(); - }); - }); - }); -}); diff --git a/libraries/botbuilder-dialogs/tests/dialog.test.js b/libraries/botbuilder-dialogs/tests/dialog.test.js new file mode 100644 index 0000000000..9cfea48d62 --- /dev/null +++ b/libraries/botbuilder-dialogs/tests/dialog.test.js @@ -0,0 +1,141 @@ +const { TestAdapter, TurnContext } = require('botbuilder'); +const { DialogSet, Dialog } = require('../'); +const assert = require('assert'); + +const beginMessage = { text: `begin`, type: 'message' }; +const continueMessage = { text: `continue`, type: 'message' }; + +class TestContext extends TurnContext { + constructor(request) { + super(new TestAdapter(), request); + this.sent = undefined; + this.onSendActivities((context, activities, next) => { + this.sent = activities; + context.responded = true; + }); + } +} + +class TestDialog extends Dialog { + constructor(options) { + super(options); + this.beginCalled = false; + this.beginArgs = undefined; + this.continueCalled = false; + } + + dialogBegin(dc, args) { + this.beginCalled = true; + this.beginArgs = args; + return dc.context.sendActivity(`begin called`); + } + + dialogContinue(dc) { + this.continueCalled = true; + return dc.end(120); + } +} + +describe('Dialog', function() { + this.timeout(5000); + + it('should call dialog from a dialog set.', function (done) { + const dialog = new TestDialog(); + + const dialogs = new DialogSet(); + dialogs.add('dialog', dialog); + + const state = {}; + const context = new TestContext(beginMessage); + const dc = dialogs.createContext(context, state); + dc.begin('dialog', { foo: 'bar' }).then(() => { + const result = dc.dialogResult; + assert(result && result.active); + assert(dialog.beginCalled); + assert(dialog.beginArgs && dialog.beginArgs.foo === 'bar'); + done(); + }); + }); + + it('should call dialog using begin().', function (done) { + const dialog = new TestDialog(); + + const state = {}; + const context = new TestContext(beginMessage); + dialog.begin(context, state, { foo: 'bar' }).then((result) => { + assert(result && result.active); + assert(dialog.beginCalled); + assert(dialog.beginArgs && dialog.beginArgs.foo === 'bar'); + done(); + }); + }); + + it('should continue() a multi-turn dialog.', function (done) { + const dialog = new TestDialog(); + + const state = {}; + const context = new TestContext(beginMessage); + dialog.begin(context, state, { foo: 'bar' }).then((result) => { + assert(result && result.active); + dialog.continue(context, state).then((result) => { + assert(dialog.continueCalled); + assert(result && !result.active); + assert(result.result === 120); + done(); + }); + }); + }); +}); + + +describe('Waterfall', function() { + this.timeout(5000); + + it('should execute a sequence of waterfall steps.', function (done) { + const dialogs = new DialogSet(); + dialogs.add('a', [ + function (dc) { + assert(dc); + return dc.context.sendActivity(`foo`); + }, + function (dc) { + assert(dc); + done(); + } + ]); + + const state = {}; + const context = new TestContext(beginMessage); + const dc = dialogs.createContext(context, state); + dc.begin('a').then(() => { + const dc2 = dialogs.createContext(context, state); + return dc2.continue(); + }); + }); + + it('should support calling next() to move to next steps.', function (done) { + const dialogs = new DialogSet(); + dialogs.add('a', [ + function (dc, args, next) { + assert(dc); + assert(args === 'z'); + return next(args); + }, + function (dc, args) { + assert(dc); + assert(args === 'z'); + return dc.end(args); + } + ]); + + const state = {}; + const context = new TestContext(beginMessage); + const dc = dialogs.createContext(context, state); + dc.begin('a', 'z').then(() => { + const result = dc.dialogResult; + assert(result && !result.active); + assert(result.result === 'z'); + done(); + }); + }); +}); diff --git a/libraries/botbuilder-dialogs/tests/compositeControl.test.js b/libraries/botbuilder-dialogs/tests/dialogContainer.test.js similarity index 91% rename from libraries/botbuilder-dialogs/tests/compositeControl.test.js rename to libraries/botbuilder-dialogs/tests/dialogContainer.test.js index dea156d405..2339ddd7bb 100644 --- a/libraries/botbuilder-dialogs/tests/compositeControl.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogContainer.test.js @@ -1,5 +1,5 @@ const { TestAdapter, TurnContext } = require('botbuilder'); -const { DialogSet, CompositeControl } = require('../'); +const { DialogSet, DialogContainer } = require('../'); const assert = require('assert'); const beginMessage = { text: `begin`, type: 'message' }; @@ -16,7 +16,7 @@ class TestContext extends TurnContext { } } -describe('CompositeControl', function() { +describe('DialogContainer', function() { this.timeout(5000); it('should call composite control from another dialog set.', function (done) { @@ -29,7 +29,7 @@ describe('CompositeControl', function() { done(); } ]); - const control = new CompositeControl('start', cDialogs); + const control = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); dialogs.add('control', control); @@ -47,7 +47,7 @@ describe('CompositeControl', function() { return dc.end(120); } ]); - const control = new CompositeControl('start', cDialogs); + const control = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); dialogs.add('control', control); @@ -76,7 +76,7 @@ describe('CompositeControl', function() { return dc.end(120); } ]); - const control = new CompositeControl('start', cDialogs); + const control = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); dialogs.add('control', control); @@ -110,7 +110,7 @@ describe('CompositeControl', function() { done(); } ]); - const control = new CompositeControl('start', cDialogs); + const control = new DialogContainer('start', cDialogs); const state = {}; const context = new TestContext(beginMessage); @@ -130,7 +130,7 @@ describe('CompositeControl', function() { return dc.end(120); } ]); - const control = new CompositeControl('start', cDialogs); + const control = new DialogContainer('start', cDialogs); const state = {}; const context = new TestContext(beginMessage); diff --git a/libraries/botbuilder-dialogs/tests/waterfall.test.js b/libraries/botbuilder-dialogs/tests/waterfall.test.js deleted file mode 100644 index c56795be1d..0000000000 --- a/libraries/botbuilder-dialogs/tests/waterfall.test.js +++ /dev/null @@ -1,69 +0,0 @@ -const { TestAdapter, TurnContext } = require('botbuilder'); -const { DialogSet } = require('../'); -const assert = require('assert'); - -const beginMessage = { text: `begin`, type: 'message' }; -const continueMessage = { text: `continue`, type: 'message' }; - -class TestContext extends TurnContext { - constructor(request) { - super(new TestAdapter(), request); - this.sent = undefined; - this.onSendActivities((context, activities, next) => { - this.sent = activities; - context.responded = true; - }); - } -} - -describe('Waterfall', function() { - this.timeout(5000); - - it('should execute a sequence of waterfall steps.', function (done) { - const dialogs = new DialogSet(); - dialogs.add('a', [ - function (dc) { - assert(dc); - return dc.context.sendActivity(`foo`); - }, - function (dc) { - assert(dc); - done(); - } - ]); - - const state = {}; - const context = new TestContext(beginMessage); - const dc = dialogs.createContext(context, state); - dc.begin('a').then(() => { - const dc2 = dialogs.createContext(context, state); - return dc2.continue(); - }); - }); - - it('should support calling next() to move to next steps.', function (done) { - const dialogs = new DialogSet(); - dialogs.add('a', [ - function (dc, args, next) { - assert(dc); - assert(args === 'z'); - return next(args); - }, - function (dc, args) { - assert(dc); - assert(args === 'z'); - return dc.end(args); - } - ]); - - const state = {}; - const context = new TestContext(beginMessage); - const dc = dialogs.createContext(context, state); - dc.begin('a', 'z').then(() => { - const result = dc.dialogResult; - assert(result && !result.active); - assert(result.result === 'z'); - done(); - }); - }); -}); From e36b8f1cc0f13f831999f5adbc839485fe1d7788 Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Thu, 26 Apr 2018 13:58:44 -0700 Subject: [PATCH 4/8] Updated samples to use new dialog constructs --- .../dialogs/alarmbot-ts/lib/addAlarmDialog.js | 77 +++++++ .../alarmbot-ts/lib/addAlarmDialog.js.map | 1 + samples/dialogs/alarmbot-ts/lib/app.js | 195 +++--------------- samples/dialogs/alarmbot-ts/lib/app.js.map | 2 +- .../alarmbot-ts/lib/deleteAlarmDialog.js | 83 ++++++++ .../alarmbot-ts/lib/deleteAlarmDialog.js.map | 1 + samples/dialogs/alarmbot-ts/lib/models.js | 3 + samples/dialogs/alarmbot-ts/lib/models.js.map | 1 + .../alarmbot-ts/lib/showAlarmsDialog.js | 37 ++++ .../alarmbot-ts/lib/showAlarmsDialog.js.map | 1 + .../dialogs/alarmbot-ts/src/addAlarmDialog.ts | 59 ++++++ samples/dialogs/alarmbot-ts/src/app.ts | 195 ++++-------------- .../alarmbot-ts/src/botStateManager.ts | 37 ---- .../alarmbot-ts/src/deleteAlarmDialog.ts | 65 ++++++ samples/dialogs/alarmbot-ts/src/models.ts | 9 + .../alarmbot-ts/src/showAlarmsDialog.ts | 27 +++ samples/dialogs/controls-ts/lib/app.js | 10 +- samples/dialogs/controls-ts/lib/app.js.map | 1 + samples/dialogs/controls-ts/lib/language.js | 62 +++--- .../dialogs/controls-ts/lib/language.js.map | 1 + samples/dialogs/controls-ts/src/app.ts | 11 +- samples/dialogs/controls-ts/src/language.ts | 72 +++---- samples/dialogs/controls-ts/tsconfig.json | 2 +- samples/dialogs/list-ts/lib/listControl.js | 8 +- samples/dialogs/list-ts/src/listControl.ts | 10 +- samples/dialogs/prompts-ts/lib/app.js | 4 +- samples/dialogs/prompts-ts/lib/app.js.map | 2 +- samples/dialogs/prompts-ts/src/app.ts | 4 +- 28 files changed, 522 insertions(+), 458 deletions(-) create mode 100644 samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js create mode 100644 samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map create mode 100644 samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js create mode 100644 samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js.map create mode 100644 samples/dialogs/alarmbot-ts/lib/models.js create mode 100644 samples/dialogs/alarmbot-ts/lib/models.js.map create mode 100644 samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js create mode 100644 samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js.map create mode 100644 samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts delete mode 100644 samples/dialogs/alarmbot-ts/src/botStateManager.ts create mode 100644 samples/dialogs/alarmbot-ts/src/deleteAlarmDialog.ts create mode 100644 samples/dialogs/alarmbot-ts/src/models.ts create mode 100644 samples/dialogs/alarmbot-ts/src/showAlarmsDialog.ts create mode 100644 samples/dialogs/controls-ts/lib/app.js.map create mode 100644 samples/dialogs/controls-ts/lib/language.js.map diff --git a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js new file mode 100644 index 0000000000..a17cd27afc --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js @@ -0,0 +1,77 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const botbuilder_dialogs_1 = require("botbuilder-dialogs"); +const moment = require("moment"); +class AddAlarmDialog extends botbuilder_dialogs_1.DialogContainer { + constructor(userState) { + super('addAlarm'); + this.dialogs.add('addAlarm', [ + function (dc) { + return __awaiter(this, void 0, void 0, function* () { + // Initialize temp alarm and prompt for title + dc.currentDialog.state = {}; + yield dc.prompt('titlePrompt', `What would you like to call your alarm?`); + }); + }, + function (dc, title) { + return __awaiter(this, void 0, void 0, function* () { + // Save alarm title and prompt for time + const alarm = dc.currentDialog.state; + alarm.title = title; + yield dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); + }); + }, + function (dc, time) { + return __awaiter(this, void 0, void 0, function* () { + // Save alarm time + const alarm = dc.currentDialog.state; + alarm.time = time.toISOString(); + // Alarm completed so set alarm. + const user = userState.get(dc.context); + user.alarms.push(alarm); + // Confirm to user + yield dc.context.sendActivity(`Your alarm named "${alarm.title}" is set for "${moment(alarm.time).format("ddd, MMM Do, h:mm a")}".`); + yield dc.end(); + }); + } + ]); + this.dialogs.add('titlePrompt', new botbuilder_dialogs_1.TextPrompt((context, value) => __awaiter(this, void 0, void 0, function* () { + if (!value || value.length < 3) { + yield context.sendActivity(`Title should be at least 3 characters long.`); + return undefined; + } + else { + return value.trim(); + } + }))); + this.dialogs.add('timePrompt', new botbuilder_dialogs_1.DatetimePrompt((context, values) => __awaiter(this, void 0, void 0, function* () { + try { + if (!Array.isArray(values) || values.length < 0) { + throw new Error('missing time'); + } + if (values[0].type !== 'datetime') { + throw new Error('unsupported type'); + } + const value = new Date(values[0].value); + if (value.getTime() < new Date().getTime()) { + throw new Error('in the past'); + } + return value; + } + catch (err) { + yield context.sendActivity(`Please enter a valid time in the future like "tomorrow at 9am" or say "cancel".`); + return undefined; + } + }))); + } +} +exports.AddAlarmDialog = AddAlarmDialog; +//# sourceMappingURL=addAlarmDialog.js.map \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map new file mode 100644 index 0000000000..fca7aeef5c --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map @@ -0,0 +1 @@ +{"version":3,"file":"addAlarmDialog.js","sourceRoot":"","sources":["../src/addAlarmDialog.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2DAAiF;AAGjF,iCAAiC;AAEjC,oBAA4B,SAAQ,oCAAe;IAC/C,YAAY,SAAoB;QAC5B,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;YACzB,UAAgB,EAAE;;oBACd,6CAA6C;oBAC7C,EAAE,CAAC,aAAa,CAAC,KAAK,GAAG,EAAW,CAAC;oBACrC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC,CAAC;gBAC9E,CAAC;aAAA;YACD,UAAgB,EAAE,EAAE,KAAa;;oBAC7B,uCAAuC;oBACvC,MAAM,KAAK,GAAG,EAAE,CAAC,aAAa,CAAC,KAAc,CAAC;oBAC9C,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;oBACpB,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,wCAAwC,KAAK,CAAC,KAAK,cAAc,CAAC,CAAC;gBACrG,CAAC;aAAA;YACD,UAAgB,EAAE,EAAE,IAAU;;oBAC1B,kBAAkB;oBAClB,MAAM,KAAK,GAAG,EAAE,CAAC,aAAa,CAAC,KAAc,CAAC;oBAC9C,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CA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AAU,CAAC,CAAC,CAAC;oBAAC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;gBAAC,CAAC;gBAC1E,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACxC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;oBAAC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;gBAAC,CAAC;gBAC9E,MAAM,CAAC,KAAK,CAAC;YACjB,CAAC;YAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACX,MAAM,OAAO,CAAC,YAAY,CAAC,iFAAiF,CAAC,CAAC;gBAC9G,MAAM,CAAC,SAAS,CAAC;YACrB,CAAC;QACL,CAAC,CAAA,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AArDD,wCAqDC"} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/app.js b/samples/dialogs/alarmbot-ts/lib/app.js index 2cf8afc6d0..af20549219 100644 --- a/samples/dialogs/alarmbot-ts/lib/app.js +++ b/samples/dialogs/alarmbot-ts/lib/app.js @@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); const botbuilder_1 = require("botbuilder"); const botbuilder_dialogs_1 = require("botbuilder-dialogs"); -const botStateManager_1 = require("./botStateManager"); const restify = require("restify"); -const moment = require("moment"); // Create server let server = restify.createServer(); server.listen(process.env.port || process.env.PORT || 3978, function () { @@ -24,16 +22,26 @@ const adapter = new botbuilder_1.BotFrameworkAdapter({ appPassword: process.env.MICROSOFT_APP_PASSWORD }); // Add state middleware -const state = new botStateManager_1.BotStateManager(new botbuilder_1.MemoryStorage()); -adapter.use(state); +const storage = new botbuilder_1.MemoryStorage(); +const convoState = new botbuilder_1.ConversationState(storage); +const userState = new botbuilder_1.UserState(storage); +adapter.use(new botbuilder_1.BotStateSet(convoState, userState)); // Listen for incoming requests server.post('/api/messages', (req, res) => { // Route received request to adapter for processing adapter.processActivity(req, res, (context) => __awaiter(this, void 0, void 0, function* () { - if (context.activity.type === 'message') { + // Ensure user properly initialized + const user = userState.get(context); + if (!user.alarms) { + user.alarms = []; + } + // Create dialog context + const convo = convoState.get(context); + const dc = dialogs.createContext(context, convo); + // Check for interruptions + const isMessage = context.activity.type === 'message'; + if (isMessage) { const utterance = (context.activity.text || '').trim().toLowerCase(); - // Create dialog context - const dc = dialogs.createContext(context, state.conversation(context)); // Start addAlarm dialog if (utterance.includes('add alarm')) { yield dc.begin('addAlarm'); @@ -48,174 +56,31 @@ server.post('/api/messages', (req, res) => { // Check for cancel } else if (utterance === 'cancel') { - if (dc.instance) { + if (dc.currentDialog) { yield dc.context.sendActivity(`Ok... Cancelled.`); yield dc.endAll(); } else { yield dc.context.sendActivity(`Nothing to cancel.`); } - // Continue current dialog } - else { - yield dc.continue(); - // Return default message if nothing replied. - if (!context.responded) { - yield dc.context.sendActivity(`Hi! I'm a simple alarm bot. Say "add alarm", "delete alarm", or "show alarms".`); - } + } + // Route activity to current dialog if not interrupted + if (!context.responded) { + yield dc.continue(); + if (!context.responded && isMessage) { + // Return default reply message + yield dc.context.sendActivity(`Hi! I'm a simple alarm bot. Say "add alarm", "delete alarm", or "show alarms".`); } } })); }); +// Setup Dialogs +const addAlarmDialog_1 = require("./addAlarmDialog"); +const deleteAlarmDialog_1 = require("./deleteAlarmDialog"); +const showAlarmsDialog_1 = require("./showAlarmsDialog"); const dialogs = new botbuilder_dialogs_1.DialogSet(); -//----------------------------------------------- -// Add Alarm -//----------------------------------------------- -dialogs.add('addAlarm', [ - function (dc) { - return __awaiter(this, void 0, void 0, function* () { - // Initialize temp alarm and prompt for title - dc.instance.state = {}; - yield dc.prompt('titlePrompt', `What would you like to call your alarm?`); - }); - }, - function (dc, title) { - return __awaiter(this, void 0, void 0, function* () { - // Save alarm title and prompt for time - const alarm = dc.instance.state; - alarm.title = title; - yield dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); - }); - }, - function (dc, time) { - return __awaiter(this, void 0, void 0, function* () { - // Save alarm time - const alarm = dc.instance.state; - alarm.time = time.toISOString(); - // Alarm completed so set alarm. - const user = state.user(dc.context); - user.alarms.push(alarm); - // Confirm to user - yield dc.context.sendActivity(`Your alarm named "${alarm.title}" is set for "${moment(alarm.time).format("ddd, MMM Do, h:mm a")}".`); - yield dc.end(); - }); - } -]); -dialogs.add('titlePrompt', new botbuilder_dialogs_1.TextPrompt((context, value) => __awaiter(this, void 0, void 0, function* () { - if (!value || value.length < 3) { - yield context.sendActivity(`Title should be at least 3 characters long.`); - return undefined; - } - else { - return value.trim(); - } -}))); -dialogs.add('timePrompt', new botbuilder_dialogs_1.DatetimePrompt((context, values) => __awaiter(this, void 0, void 0, function* () { - try { - if (!Array.isArray(values) || values.length < 0) { - throw new Error('missing time'); - } - if (values[0].type !== 'datetime') { - throw new Error('unsupported type'); - } - const value = new Date(values[0].value); - if (value.getTime() < new Date().getTime()) { - throw new Error('in the past'); - } - return value; - } - catch (err) { - yield context.sendActivity(`Please enter a valid time in the future like "tomorrow at 9am" or say "cancel".`); - return undefined; - } -}))); -//----------------------------------------------- -// Delete Alarm -//----------------------------------------------- -dialogs.add('deleteAlarm', [ - function (dc) { - return __awaiter(this, void 0, void 0, function* () { - // Divert to appropriate dialog - const user = state.user(dc.context); - if (user.alarms.length > 1) { - yield dc.begin('deleteAlarmMulti'); - } - else if (user.alarms.length === 1) { - yield dc.begin('deleteAlarmSingle'); - } - else { - yield dc.context.sendActivity(`No alarms set to delete.`); - yield dc.end(); - } - }); - } -]); -dialogs.add('deleteAlarmMulti', [ - function (dc) { - return __awaiter(this, void 0, void 0, function* () { - // Compute list of choices based on alarm titles - const user = state.user(dc.context); - const choices = user.alarms.map((value) => value.title); - // Prompt user for choice (force use of "list" style) - const prompt = `Which alarm would you like to delete? Say "cancel" to quit.`; - yield dc.prompt('choicePrompt', prompt, choices); - }); - }, - function (dc, choice) { - return __awaiter(this, void 0, void 0, function* () { - // Delete alarm by position - const user = state.user(dc.context); - if (choice.index < user.alarms.length) { - user.alarms.splice(choice.index, 1); - } - // Notify user of delete - yield dc.context.sendActivity(`Deleted "${choice.value}" alarm.`); - yield dc.end(); - }); - } -]); -dialogs.add('deleteAlarmSingle', [ - function (dc) { - return __awaiter(this, void 0, void 0, function* () { - const user = state.user(dc.context); - const alarm = user.alarms[0]; - yield dc.prompt('confirmPrompt', `Are you sure you want to delete the "${alarm.title}" alarm?`); - }); - }, - function (dc, confirm) { - return __awaiter(this, void 0, void 0, function* () { - if (confirm) { - const user = state.user(dc.context); - user.alarms = []; - yield dc.context.sendActivity(`alarm deleted...`); - } - else { - yield dc.context.sendActivity(`ok...`); - } - }); - } -]); -dialogs.add('choicePrompt', new botbuilder_dialogs_1.ChoicePrompt()); -dialogs.add('confirmPrompt', new botbuilder_dialogs_1.ConfirmPrompt()); -//----------------------------------------------- -// Show Alarms -//----------------------------------------------- -dialogs.add('showAlarms', [ - function (dc) { - return __awaiter(this, void 0, void 0, function* () { - let msg = `No alarms found.`; - const user = state.user(dc.context); - if (user.alarms.length > 0) { - msg = `**Current Alarms**\n\n`; - let connector = ''; - user.alarms.forEach((alarm) => { - msg += connector + `- ${alarm.title} (${moment(alarm.time).format("ddd, MMM Do, h:mm a")})`; - connector = '\n'; - }); - } - yield dc.context.sendActivity(msg); - yield dc.end(); - }); - } -]); +dialogs.add('addAlarm', new addAlarmDialog_1.AddAlarmDialog(userState)); +dialogs.add('deleteAlarm', new deleteAlarmDialog_1.DeleteAlarmDialog(userState)); +dialogs.add('showAlarms', new showAlarmsDialog_1.ShowAlarmsDialog(userState)); //# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/app.js.map b/samples/dialogs/alarmbot-ts/lib/app.js.map index 9907259da1..70efe5e891 100644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AC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YACrB,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;YACpB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;gBAClC,+BAA+B;gBAC/B,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,gFAAgF,CAAC,CAAA;YACnH,CAAC;QACL,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,gBAAgB;AAEhB,qDAAkD;AAClD,2DAAwD;AACxD,yDAAsD;AAEtD,MAAM,OAAO,GAAG,IAAI,8BAAS,EAAE,CAAC;AAChC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,+BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;AACvD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7D,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,mCAAgB,CAAC,SAAS,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js b/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js new file mode 100644 index 0000000000..0cfe02bcde --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js @@ -0,0 +1,83 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const botbuilder_dialogs_1 = require("botbuilder-dialogs"); +class DeleteAlarmDialog extends botbuilder_dialogs_1.DialogContainer { + constructor(userState) { + super('deleteAlarm'); + this.dialogs.add('deleteAlarm', [ + function (dc) { + return __awaiter(this, void 0, void 0, function* () { + // Divert to appropriate dialog + const user = userState.get(dc.context); + if (user.alarms.length > 1) { + yield dc.begin('deleteAlarmMulti'); + } + else if (user.alarms.length === 1) { + yield dc.begin('deleteAlarmSingle'); + } + else { + yield dc.context.sendActivity(`No alarms set to delete.`); + yield dc.end(); + } + }); + } + ]); + this.dialogs.add('deleteAlarmMulti', [ + function (dc) { + return __awaiter(this, void 0, void 0, function* () { + // Compute list of choices based on alarm titles + const user = userState.get(dc.context); + const choices = user.alarms.map((value) => value.title); + // Prompt user for choice (force use of "list" style) + const prompt = `Which alarm would you like to delete? Say "cancel" to quit.`; + yield dc.prompt('choicePrompt', prompt, choices); + }); + }, + function (dc, choice) { + return __awaiter(this, void 0, void 0, function* () { + // Delete alarm by position + const user = userState.get(dc.context); + if (choice.index < user.alarms.length) { + user.alarms.splice(choice.index, 1); + } + // Notify user of delete + yield dc.context.sendActivity(`Deleted "${choice.value}" alarm.`); + yield dc.end(); + }); + } + ]); + this.dialogs.add('deleteAlarmSingle', [ + function (dc) { + return __awaiter(this, void 0, void 0, function* () { + const user = userState.get(dc.context); + const alarm = user.alarms[0]; + yield dc.prompt('confirmPrompt', `Are you sure you want to delete the "${alarm.title}" alarm?`); + }); + }, + function (dc, confirm) { + return __awaiter(this, void 0, void 0, function* () { + if (confirm) { + const user = userState.get(dc.context); + user.alarms = []; + yield dc.context.sendActivity(`alarm deleted...`); + } + else { + yield dc.context.sendActivity(`ok...`); + } + }); + } + ]); + this.dialogs.add('choicePrompt', new botbuilder_dialogs_1.ChoicePrompt()); + this.dialogs.add('confirmPrompt', new botbuilder_dialogs_1.ConfirmPrompt()); + } +} +exports.DeleteAlarmDialog = DeleteAlarmDialog; +//# sourceMappingURL=deleteAlarmDialog.js.map \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js.map b/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js.map new file mode 100644 index 0000000000..7adebbcc21 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/deleteAlarmDialog.js.map @@ -0,0 +1 @@ +{"version":3,"file":"deleteAlarmDialog.js","sourceRoot":"","sources":["../src/deleteAlarmDialog.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2DAA+F;AAI/F,uBAA+B,SAAQ,oCAAe;IAClD,YAAY,SAAoB;QAC5B,KAAK,CAAC,aAAa,CAAC,CAAC;QAErB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE;YAC5B,UAAgB,EAAE;;oBACd,+BAA+B;oBAC/B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAc,CAAC;oBACpD,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;wBACzB,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;oBACvC,CAAC;oBAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;wBAClC,MAAM,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;oBACxC,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;wBAC1D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC;gBACL,CAAC;aAAA;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE;YACjC,UAAgB,EAAE;;oBACd,gDAAgD;oBAChD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAc,CAAC;oBACpD,MAAM,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GAAG,CAAC,EAAE,CAAC,OAAO,CAAc,CAAC;wBACpD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;wBACjB,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;oBACtD,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;oBAC3C,CAAC;gBACL,CAAC;aAAA;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,iCAAY,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,kCAAa,EAAE,CAAC,CAAC;IAC3D,CAAC;CACJ;AA5DD,8CA4DC"} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/models.js b/samples/dialogs/alarmbot-ts/lib/models.js new file mode 100644 index 0000000000..b2dccd6836 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/models.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=models.js.map \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/models.js.map b/samples/dialogs/alarmbot-ts/lib/models.js.map new file mode 100644 index 0000000000..a8f3541909 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/models.js.map @@ -0,0 +1 @@ +{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js b/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js new file mode 100644 index 0000000000..9e1e8e431e --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js @@ -0,0 +1,37 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const botbuilder_dialogs_1 = require("botbuilder-dialogs"); +const moment = require("moment"); +class ShowAlarmsDialog extends botbuilder_dialogs_1.DialogContainer { + constructor(userState) { + super('showAlarms'); + this.dialogs.add('showAlarms', [ + function (dc) { + return __awaiter(this, void 0, void 0, function* () { + let msg = `No alarms found.`; + const user = userState.get(dc.context); + if (user.alarms.length > 0) { + msg = `**Current Alarms**\n\n`; + let connector = ''; + user.alarms.forEach((alarm) => { + msg += connector + `- ${alarm.title} (${moment(alarm.time).format("ddd, MMM Do, h:mm a")})`; + connector = '\n'; + }); + } + yield dc.context.sendActivity(msg); + yield dc.end(); + }); + } + ]); + } +} +exports.ShowAlarmsDialog = ShowAlarmsDialog; +//# sourceMappingURL=showAlarmsDialog.js.map \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js.map b/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js.map new file mode 100644 index 0000000000..22ec81c170 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/lib/showAlarmsDialog.js.map @@ -0,0 +1 @@ +{"version":3,"file":"showAlarmsDialog.js","sourceRoot":"","sources":["../src/showAlarmsDialog.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2DAAqD;AAGrD,iCAAiC;AAEjC,sBAA8B,SAAQ,oCAAe;IACjD,YAAY,SAAoB;QAC5B,KAAK,CAAC,YAAY,CAAC,CAAC;QAEpB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YAC3B,UAAgB,EAAE;;oBACd,IAAI,GAAG,GAAG,kBAAkB,CAAC;oBAC7B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAc,CAAC;oBACpD,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;wBACzB,GAAG,GAAG,wBAAwB,CAAC;wBAC/B,IAAI,SAAS,GAAG,EAAE,CAAC;wBACnB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;4BAC1B,GAAG,IAAI,SAAS,GAAG,KAAK,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC;4BAC5F,SAAS,GAAG,IAAI,CAAC;wBACrB,CAAC,CAAC,CAAC;oBACP,CAAC;oBACD,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;oBACnC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;gBACnB,CAAC;aAAA;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AArBD,4CAqBC"} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts b/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts new file mode 100644 index 0000000000..b726f66b5c --- /dev/null +++ b/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts @@ -0,0 +1,59 @@ +import { DialogContainer, TextPrompt, DatetimePrompt } from 'botbuilder-dialogs'; +import { UserState } from 'botbuilder'; +import { Alarm, AlarmUser } from './models'; +import * as moment from 'moment'; + +export class AddAlarmDialog extends DialogContainer { + constructor(userState: UserState) { + super('addAlarm'); + + this.dialogs.add('addAlarm', [ + async function (dc) { + // Initialize temp alarm and prompt for title + dc.currentDialog.state = {} as Alarm; + await dc.prompt('titlePrompt', `What would you like to call your alarm?`); + }, + async function (dc, title: string) { + // Save alarm title and prompt for time + const alarm = dc.currentDialog.state as Alarm; + alarm.title = title; + await dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); + }, + async function (dc, time: Date) { + // Save alarm time + const alarm = dc.currentDialog.state as Alarm; + alarm.time = time.toISOString(); + + // Alarm completed so set alarm. + const user = userState.get(dc.context) as AlarmUser; + user.alarms.push(alarm); + + // Confirm to user + await dc.context.sendActivity(`Your alarm named "${alarm.title}" is set for "${moment(alarm.time).format("ddd, MMM Do, h:mm a")}".`); + await dc.end(); + } + ]); + + this.dialogs.add('titlePrompt', new TextPrompt(async (context, value) => { + if (!value || value.length < 3) { + await context.sendActivity(`Title should be at least 3 characters long.`); + return undefined; + } else { + return value.trim(); + } + })); + + this.dialogs.add('timePrompt', new DatetimePrompt(async (context, values) => { + try { + if (!Array.isArray(values) || values.length < 0) { throw new Error('missing time') } + if (values[0].type !== 'datetime') { throw new Error('unsupported type') } + const value = new Date(values[0].value); + if (value.getTime() < new Date().getTime()) { throw new Error('in the past') } + return value; + } catch (err) { + await context.sendActivity(`Please enter a valid time in the future like "tomorrow at 9am" or say "cancel".`); + return undefined; + } + })); + } +} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/src/app.ts b/samples/dialogs/alarmbot-ts/src/app.ts index 253701f396..5e469d345e 100644 --- a/samples/dialogs/alarmbot-ts/src/app.ts +++ b/samples/dialogs/alarmbot-ts/src/app.ts @@ -1,11 +1,6 @@ -import { BotFrameworkAdapter, MemoryStorage,TurnContext } from 'botbuilder'; -import { - DialogSet, TextPrompt, ChoicePrompt, ConfirmPrompt, DatetimePrompt, - FoundChoice, FoundDatetime, ListStyle -} from 'botbuilder-dialogs'; -import { BotStateManager, Alarm } from './botStateManager'; +import { BotFrameworkAdapter, ConversationState, UserState, BotStateSet, MemoryStorage,TurnContext } from 'botbuilder'; +import { DialogSet } from 'botbuilder-dialogs'; import * as restify from 'restify'; -import * as moment from 'moment'; // Create server let server = restify.createServer(); @@ -20,18 +15,27 @@ const adapter = new BotFrameworkAdapter( { }); // Add state middleware -const state = new BotStateManager(new MemoryStorage()); -adapter.use(state); +const storage = new MemoryStorage(); +const convoState = new ConversationState(storage); +const userState = new UserState(storage); +adapter.use(new BotStateSet(convoState, userState)); // Listen for incoming requests server.post('/api/messages', (req, res) => { // Route received request to adapter for processing adapter.processActivity(req, res, async (context) => { - if (context.activity.type === 'message') { - const utterance = (context.activity.text || '').trim().toLowerCase(); + // Ensure user properly initialized + const user = userState.get(context); + if (!user.alarms) { user.alarms = [] } + + // Create dialog context + const convo = convoState.get(context); + const dc = dialogs.createContext(context, convo); - // Create dialog context - const dc = dialogs.createContext(context, state.conversation(context)); + // Check for interruptions + const isMessage = context.activity.type === 'message'; + if (isMessage) { + const utterance = (context.activity.text || '').trim().toLowerCase(); // Start addAlarm dialog if (utterance.includes('add alarm')) { @@ -47,162 +51,33 @@ server.post('/api/messages', (req, res) => { // Check for cancel } else if (utterance === 'cancel') { - if (dc.instance) { + if (dc.currentDialog) { await dc.context.sendActivity(`Ok... Cancelled.`); await dc.endAll(); } else { await dc.context.sendActivity(`Nothing to cancel.`); } - - // Continue current dialog - } else { - await dc.continue(); - - // Return default message if nothing replied. - if (!context.responded) { - await dc.context.sendActivity(`Hi! I'm a simple alarm bot. Say "add alarm", "delete alarm", or "show alarms".`) - } } } + + // Route activity to current dialog if not interrupted + if (!context.responded) { + await dc.continue(); + if (!context.responded && isMessage) { + // Return default reply message + await dc.context.sendActivity(`Hi! I'm a simple alarm bot. Say "add alarm", "delete alarm", or "show alarms".`) + } + } }); }); +// Setup Dialogs -const dialogs = new DialogSet(); - -//----------------------------------------------- -// Add Alarm -//----------------------------------------------- - -dialogs.add('addAlarm', [ - async function (dc) { - // Initialize temp alarm and prompt for title - dc.instance.state = {} as Alarm; - await dc.prompt('titlePrompt', `What would you like to call your alarm?`); - }, - async function (dc, title: string) { - // Save alarm title and prompt for time - const alarm = dc.instance.state as Alarm; - alarm.title = title; - await dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); - }, - async function (dc, time: Date) { - // Save alarm time - const alarm = dc.instance.state as Alarm; - alarm.time = time.toISOString(); - - // Alarm completed so set alarm. - const user = state.user(dc.context); - user.alarms.push(alarm); - - // Confirm to user - await dc.context.sendActivity(`Your alarm named "${alarm.title}" is set for "${moment(alarm.time).format("ddd, MMM Do, h:mm a")}".`); - await dc.end(); - } -]); - -dialogs.add('titlePrompt', new TextPrompt(async (context, value) => { - if (!value || value.length < 3) { - await context.sendActivity(`Title should be at least 3 characters long.`); - return undefined; - } else { - return value.trim(); - } -})); - -dialogs.add('timePrompt', new DatetimePrompt(async (context, values) => { - try { - if (!Array.isArray(values) || values.length < 0) { throw new Error('missing time') } - if (values[0].type !== 'datetime') { throw new Error('unsupported type') } - const value = new Date(values[0].value); - if (value.getTime() < new Date().getTime()) { throw new Error('in the past') } - return value; - } catch (err) { - await context.sendActivity(`Please enter a valid time in the future like "tomorrow at 9am" or say "cancel".`); - return undefined; - } -})); - - -//----------------------------------------------- -// Delete Alarm -//----------------------------------------------- - -dialogs.add('deleteAlarm', [ - async function (dc) { - // Divert to appropriate dialog - const user = state.user(dc.context); - if (user.alarms.length > 1) { - await dc.begin('deleteAlarmMulti'); - } else if (user.alarms.length === 1) { - await dc.begin('deleteAlarmSingle'); - } else { - await dc.context.sendActivity(`No alarms set to delete.`); - await dc.end(); - } - } -]); - -dialogs.add('deleteAlarmMulti', [ - async function (dc) { - // Compute list of choices based on alarm titles - const user = state.user(dc.context); - const choices = user.alarms.map((value) => value.title); - - // Prompt user for choice (force use of "list" style) - const prompt = `Which alarm would you like to delete? Say "cancel" to quit.`; - await dc.prompt('choicePrompt', prompt, choices); - }, - async function (dc, choice: FoundChoice) { - // Delete alarm by position - const user = state.user(dc.context); - if (choice.index < user.alarms.length) { user.alarms.splice(choice.index, 1) } - - // Notify user of delete - await dc.context.sendActivity(`Deleted "${choice.value}" alarm.`); - await dc.end(); - } -]); - -dialogs.add('deleteAlarmSingle', [ - async function (dc) { - const user = state.user(dc.context); - const alarm = user.alarms[0]; - await dc.prompt('confirmPrompt', `Are you sure you want to delete the "${alarm.title}" alarm?`); - }, - async function (dc, confirm: boolean) { - if (confirm) { - const user = state.user(dc.context); - user.alarms = []; - await dc.context.sendActivity(`alarm deleted...`); - } else { - await dc.context.sendActivity(`ok...`); - } - } -]); - -dialogs.add('choicePrompt', new ChoicePrompt()); -dialogs.add('confirmPrompt', new ConfirmPrompt()); - - -//----------------------------------------------- -// Show Alarms -//----------------------------------------------- - -dialogs.add('showAlarms', [ - async function (dc) { - let msg = `No alarms found.`; - const user = state.user(dc.context); - if (user.alarms.length > 0) { - msg = `**Current Alarms**\n\n`; - let connector = ''; - user.alarms.forEach((alarm) => { - msg += connector + `- ${alarm.title} (${moment(alarm.time).format("ddd, MMM Do, h:mm a")})`; - connector = '\n'; - }); - } - await dc.context.sendActivity(msg); - await dc.end(); - } -]); +import { AddAlarmDialog } from './addAlarmDialog'; +import { DeleteAlarmDialog } from './deleteAlarmDialog'; +import { ShowAlarmsDialog } from './showAlarmsDialog'; +const dialogs = new DialogSet(); +dialogs.add('addAlarm', new AddAlarmDialog(userState)); +dialogs.add('deleteAlarm', new DeleteAlarmDialog(userState)); +dialogs.add('showAlarms', new ShowAlarmsDialog(userState)); diff --git a/samples/dialogs/alarmbot-ts/src/botStateManager.ts b/samples/dialogs/alarmbot-ts/src/botStateManager.ts deleted file mode 100644 index a25a8536e6..0000000000 --- a/samples/dialogs/alarmbot-ts/src/botStateManager.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { ConversationState, UserState, BotStateSet, TurnContext, Storage } from 'botbuilder'; - -export interface Alarm { - title: string; - time: string; -} - -export interface AlarmConversation { -} - -export interface AlarmUser { - alarms: Alarm[]; -} - -export class BotStateManager extends BotStateSet { - private _conversation: ConversationState; - private _user: UserState; - - constructor(storage: Storage) { - super(); - this._conversation = new ConversationState(storage); - this._user = new UserState(storage); - this.use(this._conversation, this._user); - } - - public user(context: TurnContext): AlarmUser { - // Get cached user state and ensure initialized - const user = this._user.get(context); - if (!user.alarms) { user.alarms = [] } - return user; - } - - public conversation(context: TurnContext): AlarmConversation { - // Get cached conversation state - return this._conversation.get(context); - } -} diff --git a/samples/dialogs/alarmbot-ts/src/deleteAlarmDialog.ts b/samples/dialogs/alarmbot-ts/src/deleteAlarmDialog.ts new file mode 100644 index 0000000000..cbf7e76441 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/src/deleteAlarmDialog.ts @@ -0,0 +1,65 @@ +import { DialogContainer, ChoicePrompt, ConfirmPrompt, FoundChoice } from 'botbuilder-dialogs'; +import { UserState } from 'botbuilder'; +import { Alarm, AlarmUser } from './models'; + +export class DeleteAlarmDialog extends DialogContainer { + constructor(userState: UserState) { + super('deleteAlarm'); + + this.dialogs.add('deleteAlarm', [ + async function (dc) { + // Divert to appropriate dialog + const user = userState.get(dc.context) as AlarmUser; + if (user.alarms.length > 1) { + await dc.begin('deleteAlarmMulti'); + } else if (user.alarms.length === 1) { + await dc.begin('deleteAlarmSingle'); + } else { + await dc.context.sendActivity(`No alarms set to delete.`); + await dc.end(); + } + } + ]); + + this.dialogs.add('deleteAlarmMulti', [ + async function (dc) { + // Compute list of choices based on alarm titles + const user = userState.get(dc.context) as AlarmUser; + const choices = user.alarms.map((value) => value.title); + + // Prompt user for choice (force use of "list" style) + const prompt = `Which alarm would you like to delete? Say "cancel" to quit.`; + await dc.prompt('choicePrompt', prompt, choices); + }, + async function (dc, choice: FoundChoice) { + // Delete alarm by position + const user = userState.get(dc.context); + if (choice.index < user.alarms.length) { user.alarms.splice(choice.index, 1) } + + // Notify user of delete + await dc.context.sendActivity(`Deleted "${choice.value}" alarm.`); + await dc.end(); + } + ]); + + this.dialogs.add('deleteAlarmSingle', [ + async function (dc) { + const user = userState.get(dc.context) as AlarmUser; + const alarm = user.alarms[0]; + await dc.prompt('confirmPrompt', `Are you sure you want to delete the "${alarm.title}" alarm?`); + }, + async function (dc, confirm: boolean) { + if (confirm) { + const user = userState.get(dc.context) as AlarmUser; + user.alarms = []; + await dc.context.sendActivity(`alarm deleted...`); + } else { + await dc.context.sendActivity(`ok...`); + } + } + ]); + + this.dialogs.add('choicePrompt', new ChoicePrompt()); + this.dialogs.add('confirmPrompt', new ConfirmPrompt()); + } +} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/src/models.ts b/samples/dialogs/alarmbot-ts/src/models.ts new file mode 100644 index 0000000000..dd5de224bd --- /dev/null +++ b/samples/dialogs/alarmbot-ts/src/models.ts @@ -0,0 +1,9 @@ + +export interface Alarm { + title: string; + time: string; +} + +export interface AlarmUser { + alarms: Alarm[]; +} diff --git a/samples/dialogs/alarmbot-ts/src/showAlarmsDialog.ts b/samples/dialogs/alarmbot-ts/src/showAlarmsDialog.ts new file mode 100644 index 0000000000..450fa67b20 --- /dev/null +++ b/samples/dialogs/alarmbot-ts/src/showAlarmsDialog.ts @@ -0,0 +1,27 @@ +import { DialogContainer } from 'botbuilder-dialogs'; +import { UserState } from 'botbuilder'; +import { AlarmUser } from './models'; +import * as moment from 'moment'; + +export class ShowAlarmsDialog extends DialogContainer { + constructor(userState: UserState) { + super('showAlarms'); + + this.dialogs.add('showAlarms', [ + async function (dc) { + let msg = `No alarms found.`; + const user = userState.get(dc.context) as AlarmUser; + if (user.alarms.length > 0) { + msg = `**Current Alarms**\n\n`; + let connector = ''; + user.alarms.forEach((alarm) => { + msg += connector + `- ${alarm.title} (${moment(alarm.time).format("ddd, MMM Do, h:mm a")})`; + connector = '\n'; + }); + } + await dc.context.sendActivity(msg); + await dc.end(); + } + ]); + } +} \ No newline at end of file diff --git a/samples/dialogs/controls-ts/lib/app.js b/samples/dialogs/controls-ts/lib/app.js index 2c4e2858a8..88b9b07e25 100644 --- a/samples/dialogs/controls-ts/lib/app.js +++ b/samples/dialogs/controls-ts/lib/app.js @@ -62,11 +62,10 @@ async function beginDialogDemo(context, state) { } async function continueDialogDemo(context, state) { const dc = dialogs.createContext(context, state.demoState); - const result = await dc.continue(); - if (!result.active) { + await dc.continue(); + if (!dc.currentDialog) { state.demo = undefined; state.demoState = undefined; - state.currentLocale = result.result; } } const dialogs = new botbuilder_dialogs_1.DialogSet(); @@ -76,7 +75,9 @@ dialogs.add('demo', [ }, async function (dc, locale) { await dc.context.sendActivity(`Switching locale to "${locale}".`); - return await dc.end(locale); + const state = conversationState.get(dc.context); + state.currentLocale = locale; + return await dc.end(); } ]); dialogs.add('localePicker', new language_1.LanguagePicker({ defaultLocale: 'en' })); @@ -98,3 +99,4 @@ async function continueTopicDemo(context, state) { await context.sendActivity(`Switching locale to "${state.currentLocale}".`); } } +//# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/samples/dialogs/controls-ts/lib/app.js.map b/samples/dialogs/controls-ts/lib/app.js.map new file mode 100644 index 0000000000..91e2bb2ce9 --- /dev/null +++ b/samples/dialogs/controls-ts/lib/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;AAAA,2CAAgG;AAChG,2DAA+C;AAC/C,mCAAmC;AAEnC,gBAAgB;AAChB,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,iBAAiB;AACjB,MAAM,OAAO,GAAG,IAAI,gCAAmB,CAAE;IACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;CAClD,CAAC,CAAC;AAQH,MAAM,iBAAiB,GAAG,IAAI,8BAAiB,CAAY,IAAI,0BAAa,EAAE,CAAC,CAAC;AAChF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAE/B,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;QAElE,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAChD,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QAE7B,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;IAC1B,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,yBAAc,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAGzE,2DAA2D;AAC3D,oBAAoB;AACpB,2DAA2D;AAE3D,MAAM,YAAY,GAAG,IAAI,yBAAc,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;AAEjE,KAAK,yBAAyB,OAAoB,EAAE,KAAgB;IAChE,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC;IACrB,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;AACvD,CAAC;AAED,KAAK,4BAA4B,OAAoB,EAAE,KAAgB;IACnE,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACrE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACjB,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QACvB,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;QACpC,MAAM,OAAO,CAAC,YAAY,CAAC,wBAAwB,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC;IAChF,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/controls-ts/lib/language.js b/samples/dialogs/controls-ts/lib/language.js index 82a6db1795..447a93fe22 100644 --- a/samples/dialogs/controls-ts/lib/language.js +++ b/samples/dialogs/controls-ts/lib/language.js @@ -1,42 +1,37 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const botbuilder_dialogs_1 = require("botbuilder-dialogs"); -class LanguagePicker extends botbuilder_dialogs_1.CompositeControl { - constructor(defaultOptions) { - super(dialogs, 'chooseLanguage', defaultOptions); - } -} -exports.LanguagePicker = LanguagePicker; -//--------------------------------------------------------- -// LanguagePicker Implementation -//--------------------------------------------------------- -const dialogs = new botbuilder_dialogs_1.DialogSet(); -dialogs.add('chooseLanguage', [ - async function (dc, args) { - // Merge options - const options = Object.assign({ +class LanguagePicker extends botbuilder_dialogs_1.DialogContainer { + constructor(settings) { + super('chooseLanguage'); + settings = Object.assign({ defaultLocale: 'en', supportedLocales: allLocales - }, args); - // Find the current local (split on '-' for root LCID) - let locale = (dc.context.activity.locale || options.defaultLocale).split('-')[0]; - // Ensure that the users current locale is one we support. - if (!localeToPrompt.hasOwnProperty(locale)) { - locale = options.defaultLocale; - } - ; - // Prompt user for choice - const prompt = localeToPrompt[locale]; - const choices = options.supportedLocales.map((lcid) => localeToChoice[lcid]); - return await dc.prompt('choicePrompt', prompt, choices); - }, - async function (dc, choice) { - // Map choice to locale and return - const locale = choiceToLocale[choice.value]; - return await dc.end(locale); + }, settings); + this.dialogs.add('chooseLanguage', [ + async function (dc) { + // Find the current local (split on '-' for root LCID) + let locale = (dc.context.activity.locale || settings.defaultLocale).split('-')[0]; + // Ensure that the users current locale is one we support. + if (!localeToPrompt.hasOwnProperty(locale)) { + locale = settings.defaultLocale; + } + ; + // Prompt user for choice + const prompt = localeToPrompt[locale]; + const choices = settings.supportedLocales.map((lcid) => localeToChoice[lcid]); + return await dc.prompt('choicePrompt', prompt, choices); + }, + async function (dc, choice) { + // Map choice to locale and return + const locale = choiceToLocale[choice.value]; + return await dc.end(locale); + } + ]); + this.dialogs.add('choicePrompt', new botbuilder_dialogs_1.ChoicePrompt()); } -]); -dialogs.add('choicePrompt', new botbuilder_dialogs_1.ChoicePrompt()); +} +exports.LanguagePicker = LanguagePicker; const allLocales = ['en', 'es', 'fr', 'it', 'ja']; const localeToPrompt = { 'en': `Select your preferred language.`, @@ -59,3 +54,4 @@ const choiceToLocale = { 'Italiano': 'it', '日本語': 'ja' }; +//# sourceMappingURL=language.js.map \ No newline at end of file diff --git a/samples/dialogs/controls-ts/lib/language.js.map b/samples/dialogs/controls-ts/lib/language.js.map new file mode 100644 index 0000000000..046f8c49ff --- /dev/null +++ b/samples/dialogs/controls-ts/lib/language.js.map @@ -0,0 +1 @@ +{"version":3,"file":"language.js","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":";;AAAA,2DAAyG;AAQzG,oBAA4B,SAAQ,oCAAuB;IACvD,YAAY,QAAiC;QACzC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;YACrB,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,UAAU;SACL,EAAE,QAAQ,CAAC,CAAC;QAGvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YAC/B,KAAK,WAAW,EAAE;gBAEd,sDAAsD;gBACtD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAElF,0DAA0D;gBAC1D,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;oBAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAA;gBAAC,CAAC;gBAAA,CAAC;gBAEhF,yBAAyB;gBACzB,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9E,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC5D,CAAC;YACD,KAAK,WAAW,EAAE,EAAE,MAAmB;gBACnC,kCAAkC;gBAClC,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5C,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,iCAAY,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ;AAhCD,wCAgCC;AAED,MAAM,UAAU,GAAG,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAE,CAAC;AAEpD,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,cAAc,GAAG;IACnB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,KAAK,EAAE,IAAI;CACd,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/controls-ts/src/app.ts b/samples/dialogs/controls-ts/src/app.ts index c6ff802733..c9963afee6 100644 --- a/samples/dialogs/controls-ts/src/app.ts +++ b/samples/dialogs/controls-ts/src/app.ts @@ -70,11 +70,10 @@ async function beginDialogDemo(context: TurnContext, state: DemoState) { async function continueDialogDemo(context: TurnContext, state: DemoState) { const dc = dialogs.createContext(context, state.demoState); - const result = await dc.continue(); - if (!result.active) { + await dc.continue(); + if (!dc.currentDialog) { state.demo = undefined; state.demoState = undefined; - state.currentLocale = result.result; } } @@ -86,7 +85,11 @@ dialogs.add('demo', [ }, async function (dc, locale: string) { await dc.context.sendActivity(`Switching locale to "${locale}".`); - return await dc.end(locale); + + const state = conversationState.get(dc.context); + state.currentLocale = locale; + + return await dc.end(); } ]); diff --git a/samples/dialogs/controls-ts/src/language.ts b/samples/dialogs/controls-ts/src/language.ts index d6618a314e..3298897426 100644 --- a/samples/dialogs/controls-ts/src/language.ts +++ b/samples/dialogs/controls-ts/src/language.ts @@ -1,53 +1,47 @@ -import { DialogSet, CompositeControl, ChoicePrompt, DialogResult, FoundChoice } from 'botbuilder-dialogs'; +import { DialogSet, DialogContainer, ChoicePrompt, DialogResult, FoundChoice } from 'botbuilder-dialogs'; import { TurnContext } from 'botbuilder'; -export interface LanguagePickerOptions { +export interface LanguagePickerSettings { defaultLocale?: string; supportedLocales?: string[]; } -export class LanguagePicker extends CompositeControl { - constructor(defaultOptions?: LanguagePickerOptions) { - super(dialogs, 'chooseLanguage', defaultOptions) - } -} - -//--------------------------------------------------------- -// LanguagePicker Implementation -//--------------------------------------------------------- - -const dialogs = new DialogSet(); - -dialogs.add('chooseLanguage', [ - async function (dc, args?: LanguagePickerOptions) { - // Merge options - const options = Object.assign({ +export class LanguagePicker extends DialogContainer { + constructor(settings?: LanguagePickerSettings) { + super('chooseLanguage'); + settings = Object.assign({ defaultLocale: 'en', supportedLocales: allLocales - } as LanguagePickerOptions, args); - - // Find the current local (split on '-' for root LCID) - let locale = (dc.context.activity.locale || options.defaultLocale).split('-')[0]; - - // Ensure that the users current locale is one we support. - if (!localeToPrompt.hasOwnProperty(locale)) { locale = options.defaultLocale }; + } as LanguagePickerSettings, settings); - // Prompt user for choice - const prompt = localeToPrompt[locale]; - const choices = options.supportedLocales.map((lcid) => localeToChoice[lcid]); - return await dc.prompt('choicePrompt', prompt, choices); - }, - async function (dc, choice: FoundChoice) { - // Map choice to locale and return - const locale = choiceToLocale[choice.value]; - return await dc.end(locale); - } -]); -dialogs.add('choicePrompt', new ChoicePrompt()); + this.dialogs.add('chooseLanguage', [ + async function (dc) { + + // Find the current local (split on '-' for root LCID) + let locale = (dc.context.activity.locale || settings.defaultLocale).split('-')[0]; + + // Ensure that the users current locale is one we support. + if (!localeToPrompt.hasOwnProperty(locale)) { locale = settings.defaultLocale }; + + // Prompt user for choice + const prompt = localeToPrompt[locale]; + const choices = settings.supportedLocales.map((lcid) => localeToChoice[lcid]); + return await dc.prompt('choicePrompt', prompt, choices); + }, + async function (dc, choice: FoundChoice) { + // Map choice to locale and return + const locale = choiceToLocale[choice.value]; + return await dc.end(locale); + } + ]); + + this.dialogs.add('choicePrompt', new ChoicePrompt()); + } +} const allLocales = [ 'en', 'es', 'fr', 'it', 'ja' ]; - + const localeToPrompt = { 'en': `Select your preferred language.`, 'es': `Seleccione su idioma preferido.`, @@ -70,4 +64,4 @@ const choiceToLocale = { 'Français': 'fr', 'Italiano': 'it', '日本語': 'ja' -}; \ No newline at end of file +}; diff --git a/samples/dialogs/controls-ts/tsconfig.json b/samples/dialogs/controls-ts/tsconfig.json index 00bcbc7f28..6298eaa788 100644 --- a/samples/dialogs/controls-ts/tsconfig.json +++ b/samples/dialogs/controls-ts/tsconfig.json @@ -8,7 +8,7 @@ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ + "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ "outDir": "./lib", /* Redirect output structure to the directory. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ diff --git a/samples/dialogs/list-ts/lib/listControl.js b/samples/dialogs/list-ts/lib/listControl.js index d95d8b2e75..562934fa8d 100644 --- a/samples/dialogs/list-ts/lib/listControl.js +++ b/samples/dialogs/list-ts/lib/listControl.js @@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); const botbuilder_dialogs_1 = require("botbuilder-dialogs"); const botbuilder_choices_1 = require("botbuilder-choices"); const botbuilder_1 = require("botbuilder"); -class ListControl extends botbuilder_dialogs_1.Control { +class ListControl extends botbuilder_dialogs_1.Dialog { constructor(pager, actions) { super(); this.pager = pager; this.actions = actions || [{ type: 'imBack', title: 'Show More', value: 'more' }]; } dialogBegin(dc, args) { - dc.instance.state = Object.assign({}, args); + dc.currentDialog.state = Object.assign({}, args); return this.showMore(dc); } dialogContinue(dc) { @@ -26,13 +26,13 @@ class ListControl extends botbuilder_dialogs_1.Control { return this.showMore(dc); } else { - const state = dc.instance.state; + const state = dc.currentDialog.state; return dc.end({ action: action, continueToken: state.continueToken }); } } showMore(dc) { try { - const state = dc.instance.state; + const state = dc.currentDialog.state; return Promise.resolve(this.pager(dc, state.filter, state.continueToken)).then((result) => { if (result.continueToken) { // Save continuation token diff --git a/samples/dialogs/list-ts/src/listControl.ts b/samples/dialogs/list-ts/src/listControl.ts index 9cb2c0e3aa..3e86c589fe 100644 --- a/samples/dialogs/list-ts/src/listControl.ts +++ b/samples/dialogs/list-ts/src/listControl.ts @@ -1,4 +1,4 @@ -import { Control, DialogContext } from 'botbuilder-dialogs'; +import { Dialog, DialogContext } from 'botbuilder-dialogs'; import { Choice, findChoices } from 'botbuilder-choices'; import { TurnContext, Promiseable, Activity, CardAction, MessageFactory } from 'botbuilder'; @@ -20,7 +20,7 @@ export interface ListControlResult { continueToken?: any; } -export class ListControl extends Control { +export class ListControl extends Dialog { private readonly actions: (string|CardAction)[]; constructor(protected pager: ListPager, actions?: (string|CardAction)[]) { @@ -29,7 +29,7 @@ export class ListControl extends Control, args?: ListControlOptions): Promise { - dc.instance.state = Object.assign({}, args); + dc.currentDialog.state = Object.assign({}, args); return this.showMore(dc); } @@ -46,14 +46,14 @@ export class ListControl extends Control): Promise { try { - const state = dc.instance.state as ListControlOptions; + const state = dc.currentDialog.state as ListControlOptions; return Promise.resolve(this.pager(dc, state.filter, state.continueToken)).then((result) => { if (result.continueToken) { // Save continuation token diff --git a/samples/dialogs/prompts-ts/lib/app.js b/samples/dialogs/prompts-ts/lib/app.js index e92dbf90af..79f3e9c4b8 100644 --- a/samples/dialogs/prompts-ts/lib/app.js +++ b/samples/dialogs/prompts-ts/lib/app.js @@ -92,13 +92,13 @@ dialogs.add('mainMenu', [ dialogs.add('loop', [ function (dc, args) { return __awaiter(this, void 0, void 0, function* () { - dc.instance.state = args; + dc.currentDialog.state = args; yield dc.begin(args.dialogId); }); }, function (dc) { return __awaiter(this, void 0, void 0, function* () { - const args = dc.instance.state; + const args = dc.currentDialog.state; yield dc.replace('loop', args); }); } diff --git a/samples/dialogs/prompts-ts/lib/app.js.map b/samples/dialogs/prompts-ts/lib/app.js.map index 578d7c55f3..6c8b63ef22 100644 --- a/samples/dialogs/prompts-ts/lib/app.js.map +++ b/samples/dialogs/prompts-ts/lib/app.js.map @@ -1 +1 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAGoB;AACpB,2DAG4B;AAC5B,mCAAmC;AAEnC,gBAAgB;AAChB,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,iBAAiB;AACjB,MAAM,OAAO,GAAG,IAAI,gCAAmB,CAAC;IACpC,KAAK,EAAE,OAA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AAGH,iDAAiD;AACjD,YAAY;AACZ,iDAAiD;AAEjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;IACpB,UAAe,EAAE;;YACb,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC;QAC3D,CAAC;KAAA;IACD,UAAe,EAAE,EAAE,KAAa;;YAC5B,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC;YAC5D,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;KAAA;CACJ,CAAC,CAAC;AAGH,iDAAiD;AACjD,kBAAkB;AAClB,iDAAiD;AAEjD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;IAC1B,UAAe,EAAE;;YACb,MAAM,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;QACvE,CAAC;KAAA;IACD,UAAe,EAAE,EAAE,MAAoB;;YACnC,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,2BAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC;YAC1G,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;KAAA;CACJ,CAAC,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/prompts-ts/src/app.ts b/samples/dialogs/prompts-ts/src/app.ts index 9b1c2e5ee2..ad0b7f3ff7 100644 --- a/samples/dialogs/prompts-ts/src/app.ts +++ b/samples/dialogs/prompts-ts/src/app.ts @@ -95,11 +95,11 @@ dialogs.add('mainMenu', [ dialogs.add('loop', [ async function(dc, args: { dialogId: string; }) { - dc.instance.state = args; + dc.currentDialog.state = args; await dc.begin(args.dialogId); }, async function(dc) { - const args = dc.instance.state; + const args = dc.currentDialog.state; await dc.replace('loop', args); } ]); From 332f54a70d2a86fbe15ff453c37e80be40c88395 Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Thu, 26 Apr 2018 14:23:37 -0700 Subject: [PATCH 5/8] published updated bits --- libraries/botbuilder-ai/package.json | 6 +++--- libraries/botbuilder-azure/package.json | 4 ++-- libraries/botbuilder-choices/package.json | 4 ++-- libraries/botbuilder-core-extensions/package.json | 4 ++-- libraries/botbuilder-core/package.json | 4 ++-- libraries/botbuilder-dialogs/package.json | 6 +++--- libraries/botbuilder-prompts/package.json | 6 +++--- libraries/botbuilder/package.json | 8 ++++---- libraries/botframework-connector/package.json | 4 ++-- libraries/botframework-luis/package.json | 2 +- libraries/botframework-schema/package.json | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libraries/botbuilder-ai/package.json b/libraries/botbuilder-ai/package.json index f5573561e4..c374651650 100644 --- a/libraries/botbuilder-ai/package.json +++ b/libraries/botbuilder-ai/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-ai", "author": "Microsoft Corp.", "description": "Cognitive services extensions for Microsoft BotBuilder.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -24,8 +24,8 @@ "@types/node": "^9.3.0", "@types/request-promise-native": "^1.0.10", "@types/xmldom": "^0.1.29", - "botbuilder": "4.0.0-m3.0", - "botframework-luis": "4.0.0-m3.0", + "botbuilder": "4.0.0-m4.0", + "botframework-luis": "4.0.0-m4.0", "html-entities": "^1.2.1", "mstranslator": "^3.0.0", "request": "2.83.0", diff --git a/libraries/botbuilder-azure/package.json b/libraries/botbuilder-azure/package.json index 7809a2cce8..63ea3a3222 100644 --- a/libraries/botbuilder-azure/package.json +++ b/libraries/botbuilder-azure/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-azure", "author": "Microsoft Corp.", "description": "Azure extensions for Microsoft BotBuilder.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -23,7 +23,7 @@ "dependencies": { "@types/node": "^9.3.0", "azure-storage": "^2.3.0", - "botbuilder": "4.0.0-m3.0", + "botbuilder": "4.0.0-m4.0", "documentdb": "^1.14.2", "flat": "^4.0.0" }, diff --git a/libraries/botbuilder-choices/package.json b/libraries/botbuilder-choices/package.json index aef426971d..ca1ebea115 100644 --- a/libraries/botbuilder-choices/package.json +++ b/libraries/botbuilder-choices/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-choices", "author": "Microsoft Corp.", "description": "Microsoft BotBuilder tools for working with choices.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -21,7 +21,7 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botbuilder": "4.0.0-m3.0", + "botbuilder": "4.0.0-m4.0", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder-core-extensions/package.json b/libraries/botbuilder-core-extensions/package.json index 27c3631c8b..d46a1832ee 100644 --- a/libraries/botbuilder-core-extensions/package.json +++ b/libraries/botbuilder-core-extensions/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-core-extensions", "author": "Microsoft Corp.", "description": "Common middleware and related abstractions for the Bot Builder core library.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -23,7 +23,7 @@ "@types/node": "^9.3.0", "assert": "^1.4.1", "async-file": "^2.0.2", - "botbuilder-core": "4.0.0-m3.0", + "botbuilder-core": "4.0.0-m4.0", "filenamify": "^2.0.0", "rimraf": "^2.6.2" }, diff --git a/libraries/botbuilder-core/package.json b/libraries/botbuilder-core/package.json index ff717f4123..5d10350a6e 100644 --- a/libraries/botbuilder-core/package.json +++ b/libraries/botbuilder-core/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-core", "author": "Microsoft Corp.", "description": "Bot Builder core library. Bot Builder is a toolkit for building rich bots on virtually any platform.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -21,7 +21,7 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botframework-schema": "4.0.0-m3.0", + "botframework-schema": "4.0.0-m4.0", "assert": "^1.4.1" }, "devDependencies": { diff --git a/libraries/botbuilder-dialogs/package.json b/libraries/botbuilder-dialogs/package.json index 6b7239a903..d645dfc0ac 100644 --- a/libraries/botbuilder-dialogs/package.json +++ b/libraries/botbuilder-dialogs/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-dialogs", "author": "Microsoft Corp.", "description": "A dialog stack based conversation manager for Microsoft Bot Builder.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -21,8 +21,8 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botbuilder": "4.0.0-m3.0", - "botbuilder-prompts": "4.0.0-m3.0", + "botbuilder": "4.0.0-m4.0", + "botbuilder-prompts": "4.0.0-m4.0", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder-prompts/package.json b/libraries/botbuilder-prompts/package.json index 4f02114843..8092b4092e 100644 --- a/libraries/botbuilder-prompts/package.json +++ b/libraries/botbuilder-prompts/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-prompts", "author": "stevenic@microsoft.com", "description": "Lightweight prompt system for Bot Builder v4.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -18,8 +18,8 @@ "main": "./lib/index.js", "typings": "./lib/index.d.ts", "dependencies": { - "botbuilder": "4.0.0-m3.0", - "botbuilder-choices": "4.0.0-m3.0", + "botbuilder": "4.0.0-m4.0", + "botbuilder-choices": "4.0.0-m4.0", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index fc4721466b..e685b9b0f1 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -2,7 +2,7 @@ "name": "botbuilder", "author": "Microsoft Corp.", "description": "Services for Microsoft BotBuilder.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botbuilder", @@ -23,9 +23,9 @@ "@types/node": "^9.3.0", "@types/filenamify": "^2.0.1", "async-file": "^2.0.2", - "botbuilder-core": "4.0.0-m3.0", - "botbuilder-core-extensions": "4.0.0-m3.0", - "botframework-connector": "4.0.0-m3.0", + "botbuilder-core": "4.0.0-m4.0", + "botbuilder-core-extensions": "4.0.0-m4.0", + "botframework-connector": "4.0.0-m4.0", "filenamify": "^2.0.0", "readline": "^1.3.0" }, diff --git a/libraries/botframework-connector/package.json b/libraries/botframework-connector/package.json index 62f81ecc04..82c4f959a2 100644 --- a/libraries/botframework-connector/package.json +++ b/libraries/botframework-connector/package.json @@ -2,7 +2,7 @@ "name": "botframework-connector", "author": "Microsoft Corp.", "description": "Bot Connector is autorest generated connector client.", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "botconnector", @@ -23,7 +23,7 @@ "@types/request": "^2.47.0", "@types/node": "^9.3.0", "base64url": "^2.0.0", - "botframework-schema": "4.0.0-m3.0", + "botframework-schema": "4.0.0-m4.0", "jsonwebtoken": "8.0.1", "ms-rest-js": "^0.2.5", "request": "2.83.0", diff --git a/libraries/botframework-luis/package.json b/libraries/botframework-luis/package.json index dcf21f578f..af0ab90782 100644 --- a/libraries/botframework-luis/package.json +++ b/libraries/botframework-luis/package.json @@ -2,7 +2,7 @@ "name": "botframework-luis", "author": "Microsoft Corp.", "description": "Luis client package for Luis query API", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "license": "MIT", "keywords": [ "luis" diff --git a/libraries/botframework-schema/package.json b/libraries/botframework-schema/package.json index e777832bc1..3d54d00bce 100644 --- a/libraries/botframework-schema/package.json +++ b/libraries/botframework-schema/package.json @@ -1,6 +1,6 @@ { "name": "botframework-schema", - "version": "4.0.0-m3.0", + "version": "4.0.0-m4.0", "keywords": [ "botconnector", "bots", From 262eae1b7d01c57df8badfee9c01b6204a83d898 Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Fri, 27 Apr 2018 15:21:00 -0700 Subject: [PATCH 6/8] Changed DialogResult to DialogCompletion --- libraries/botbuilder-dialogs/lib/dialog.d.ts | 66 ++++++----- libraries/botbuilder-dialogs/lib/dialog.js | 69 +++++++----- .../botbuilder-dialogs/lib/dialog.js.map | 2 +- .../lib/dialogContainer.d.ts | 78 +++++-------- .../botbuilder-dialogs/lib/dialogContainer.js | 101 +++++++---------- .../lib/dialogContainer.js.map | 2 +- .../botbuilder-dialogs/lib/dialogContext.d.ts | 36 ++---- .../botbuilder-dialogs/lib/dialogContext.js | 35 +++--- .../lib/dialogContext.js.map | 2 +- .../lib/prompts/attachmentPrompt.d.ts | 36 +----- .../lib/prompts/attachmentPrompt.js | 36 +----- .../lib/prompts/attachmentPrompt.js.map | 2 +- .../lib/prompts/choicePrompt.d.ts | 37 +------ .../lib/prompts/choicePrompt.js | 37 +------ .../lib/prompts/choicePrompt.js.map | 2 +- .../lib/prompts/confirmPrompt.d.ts | 36 +----- .../lib/prompts/confirmPrompt.js | 36 +----- .../lib/prompts/confirmPrompt.js.map | 2 +- .../lib/prompts/datetimePrompt.d.ts | 33 +----- .../lib/prompts/datetimePrompt.js | 33 +----- .../lib/prompts/datetimePrompt.js.map | 2 +- .../lib/prompts/numberPrompt.d.ts | 36 +----- .../lib/prompts/numberPrompt.js | 36 +----- .../lib/prompts/numberPrompt.js.map | 2 +- .../lib/prompts/oauthPrompt.d.ts | 48 +------- .../lib/prompts/oauthPrompt.js | 52 +-------- .../lib/prompts/oauthPrompt.js.map | 2 +- .../botbuilder-dialogs/lib/prompts/prompt.js | 4 +- .../lib/prompts/prompt.js.map | 2 +- .../lib/prompts/textPrompt.d.ts | 33 +----- .../lib/prompts/textPrompt.js | 33 +----- .../lib/prompts/textPrompt.js.map | 2 +- libraries/botbuilder-dialogs/src/dialog.ts | 103 +++++++++++------- .../botbuilder-dialogs/src/dialogContainer.ts | 102 +++++++---------- .../botbuilder-dialogs/src/dialogContext.ts | 59 +++------- .../src/prompts/attachmentPrompt.ts | 36 +----- .../src/prompts/choicePrompt.ts | 37 +------ .../src/prompts/confirmPrompt.ts | 36 +----- .../src/prompts/datetimePrompt.ts | 33 +----- .../src/prompts/numberPrompt.ts | 36 +----- .../src/prompts/oauthPrompt.ts | 52 +-------- .../botbuilder-dialogs/src/prompts/prompt.ts | 4 +- .../src/prompts/textPrompt.ts | 33 +----- .../botbuilder-dialogs/tests/dialog.test.js | 24 ++-- .../tests/dialogContainer.test.js | 77 ++++++------- .../tests/dialogContext.test.js | 37 ++----- .../tests/dialogSet.test.js | 29 ----- .../tests/prompts_attachmentPrompt.test.js | 63 ++++------- .../tests/prompts_choicePrompt.test.js | 47 +++----- .../tests/prompts_confirmPrompt.test.js | 62 ++++------- .../tests/prompts_datetimePrompt.test.js | 62 ++++------- .../tests/prompts_numberPrompt.test.js | 62 ++++------- .../tests/prompts_textPrompt.test.js | 62 ++++------- 53 files changed, 499 insertions(+), 1490 deletions(-) diff --git a/libraries/botbuilder-dialogs/lib/dialog.d.ts b/libraries/botbuilder-dialogs/lib/dialog.d.ts index 8c74125ae6..2710c9cff2 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialog.d.ts @@ -6,68 +6,77 @@ * Licensed under the MIT License. */ import { TurnContext, Promiseable } from 'botbuilder'; -import { DialogContext, DialogResult } from './dialogContext'; +import { DialogContext } from './dialogContext'; /** * Tracking information for a dialog on the stack. * @param T (Optional) type of state being persisted for dialog. */ -export interface DialogInstance { +export interface DialogInstance { /** ID of the dialog this instance is for. */ id: string; /** The instances persisted state. */ state: T; } +export interface DialogCompletion { + /** If `true` the dialog is still active. */ + isActive: boolean; + /** If `true` the dialog just completed and the final [result](#result) can be retrieved. */ + isCompleted: boolean; + /** Final result returned by a dialog that just completed. */ + result?: T; +} /** * :package: **botbuilder-dialogs** * * Base class for all dialogs. * * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * and `continue()` methods which simplify consuming the dialog from a non-dialog based bot. The * primary difference between the two classes is that the `CompositeControl` class is designed to * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can * be used in complete isolation without the need for any other supporting dialogs. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the [begin()](#begin) method. */ export declare abstract class Dialog { /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. + * Starts the dialog. Depending on the dialog, its possible for the dialog to finish + * immediately so it's advised to check the completion object returned by `begin()` and ensure + * that the dialog is still active before continuing. * * **Usage Example:** * * ```JavaScript * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.begin(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. + * @param state A state object that the dialog will use to persist its current state. This should be an empty object which the dialog will populate. The bot should persist this with its other conversation state for as long as the dialog is still active. + * @param options (Optional) additional options supported by the dialog. */ - begin(context: C, state: object, options?: O): Promise>; + begin(context: C, state: object, options?: O): Promise>; /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * Passes a users reply to the dialog for further processing. The bot should keep calling + * `continue()` for future turns until the dialog returns a completion object with + * `isCompleted == true`. To cancel or interrupt the prompt simply delete the `state` object + * being persisted. * * **Usage Example:** * * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.continue(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. * @param state A state object that was previously initialized by a call to [begin()](#begin). */ - continue(context: C, state: object): Promise>; + continue(context: C, state: object): Promise>; /** * Method called when a new dialog has been pushed onto the stack and is being activated. * @param dc The dialog context for the current turn of conversation. @@ -75,22 +84,23 @@ export declare abstract class Dialog { */ abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; /** - * (Optional) method called when an instance of the dialog is the "current" dialog and the - * user replies with a new activity. The dialog will generally continue to receive the users - * replies until it calls either `DialogSet.end()` or `DialogSet.begin()`. + * (Optional) method called when an instance of the dialog is the active dialog and the user + * replies with a new activity. The dialog will generally continue to receive the users replies + * until it calls `DialogContext.end()`, `DialogContext.begin()`, or `DialogContext.prompt()`. * - * If this method is NOT implemented then the dialog will automatically be ended when the user + * If this method is NOT implemented then the dialog will be automatically ended when the user * replies. * @param dc The dialog context for the current turn of conversation. */ dialogContinue?(dc: DialogContext): Promiseable; /** * (Optional) method called when an instance of the dialog is being returned to from another - * dialog that was started by the current instance using `DialogSet.begin()`. + * dialog that was started by the current instance using `DialogContext.begin()` or + * `DialogContext.prompt()`. * * If this method is NOT implemented then the dialog will be automatically ended with a call - * to `DialogSet.endDialogWithResult()`. Any result passed from the called dialog will be passed - * to the current dialogs parent. + * to `DialogContext.end()`. Any result passed from the called dialog will be passed to the + * active dialogs parent. * @param dc The dialog context for the current turn of conversation. * @param result (Optional) value returned from the dialog that was called. The type of the value returned is dependant on the dialog that was called. */ @@ -141,7 +151,7 @@ export declare type WaterfallStep = (dc: DialogContext /** * :package: **botbuilder-dialogs** * - * When called, control will skip to the next waterfall step. + * When called, dialog will skip to the next waterfall step. * @param SkipStepFunction.args (Optional) additional argument(s) to pass into the next step. */ export declare type SkipStepFunction = (args?: any) => Promise; diff --git a/libraries/botbuilder-dialogs/lib/dialog.js b/libraries/botbuilder-dialogs/lib/dialog.js index 57933f52ec..96c43ef3b7 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js +++ b/libraries/botbuilder-dialogs/lib/dialog.js @@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); * Licensed under the MIT License. */ const botbuilder_1 = require("botbuilder"); +const dialogContext_1 = require("./dialogContext"); const dialogSet_1 = require("./dialogSet"); /** * :package: **botbuilder-dialogs** @@ -15,66 +16,74 @@ const dialogSet_1 = require("./dialogSet"); * Base class for all dialogs. * * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * and `continue()` methods which simplify consuming the dialog from a non-dialog based bot. The * primary difference between the two classes is that the `CompositeControl` class is designed to * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can * be used in complete isolation without the need for any other supporting dialogs. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the [begin()](#begin) method. */ class Dialog { /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. + * Starts the dialog. Depending on the dialog, its possible for the dialog to finish + * immediately so it's advised to check the completion object returned by `begin()` and ensure + * that the dialog is still active before continuing. * * **Usage Example:** * * ```JavaScript * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.begin(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. + * @param state A state object that the dialog will use to persist its current state. This should be an empty object which the dialog will populate. The bot should persist this with its other conversation state for as long as the dialog is still active. + * @param options (Optional) additional options supported by the dialog. */ begin(context, state, options) { - // Create empty dialog set and ourselves to it + // Create empty dialog set and add ourselves to it const dialogs = new dialogSet_1.DialogSet(); dialogs.add('dialog', this); - // Start the control - const cdc = dialogs.createContext(context, state); - return cdc.begin('dialog', options) - .then(() => cdc.dialogResult); + // Start the dialog + let result; + const dc = new dialogContext_1.DialogContext(dialogs, context, state, (r) => { result = r; }); + return dc.begin('dialog', options) + .then(() => dc.activeDialog ? { isActive: true, isCompleted: false } : { isActive: false, isCompleted: true, result: result }); } /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * Passes a users reply to the dialog for further processing. The bot should keep calling + * `continue()` for future turns until the dialog returns a completion object with + * `isCompleted == true`. To cancel or interrupt the prompt simply delete the `state` object + * being persisted. * * **Usage Example:** * * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.continue(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. * @param state A state object that was previously initialized by a call to [begin()](#begin). */ continue(context, state) { - // Create empty dialog set and ourselves to it + // Create empty dialog set and add ourselves to it const dialogs = new dialogSet_1.DialogSet(); dialogs.add('dialog', this); - // Continue the control - const cdc = dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); + // Continue the dialog + let result; + const dc = new dialogContext_1.DialogContext(dialogs, context, state, (r) => { result = r; }); + if (dc.activeDialog) { + return dc.continue() + .then(() => dc.activeDialog ? { isActive: true, isCompleted: false } : { isActive: false, isCompleted: true, result: result }); + } + else { + return Promise.resolve({ isActive: false, isCompleted: false }); + } } } exports.Dialog = Dialog; @@ -158,14 +167,14 @@ class Waterfall extends Dialog { this.steps = steps.slice(0); } dialogBegin(dc, args) { - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.step = 0; return this.runStep(dc, args); } dialogContinue(dc) { // Don't do anything for non-message activities if (dc.context.activity.type === botbuilder_1.ActivityTypes.Message) { - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.step += 1; return this.runStep(dc, dc.context.activity.text); } @@ -174,13 +183,13 @@ class Waterfall extends Dialog { } } dialogResume(dc, result) { - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.step += 1; return this.runStep(dc, result); } runStep(dc, result) { try { - const instance = dc.currentDialog; + const instance = dc.activeDialog; const step = instance.step; if (step >= 0 && step < this.steps.length) { // Execute step diff --git a/libraries/botbuilder-dialogs/lib/dialog.js.map b/libraries/botbuilder-dialogs/lib/dialog.js.map index 7103d6fc6b..1b2f6fb3e3 100644 --- a/libraries/botbuilder-dialogs/lib/dialog.js.map +++ b/libraries/botbuilder-dialogs/lib/dialog.js.map @@ -1 +1 @@ -{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../src/dialog.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAAqE;AAErE,2CAAwC;AAcxC;;;;;;;;;;;;;GAaG;AACH;IACI;;;;;;;;;;;;;;;;;OAiBG;IACI,KAAK,CAAC,OAAU,EAAE,KAAa,EAAE,OAAW;QAC/C,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE5B,oBAAoB;QACpB,MAAM,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC;aACxB,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,QAAQ,CAAC,OAAU,EAAE,KAAa;QACrC,8CAA8C;QAC9C,MAAM,OAAO,GAAG,IAAI,qBAAS,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE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libraries/botbuilder-dialogs/lib/dialogContainer.d.ts b/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts index 8efb4b79f3..a44eeabe8d 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.d.ts @@ -12,21 +12,19 @@ import { DialogSet } from './dialogSet'; /** * :package: **botbuilder-dialogs** * - * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a - * control that can be used within another bot. The control can be used either as a dialog added - * to the other bots `DialogSet` or on its own for bots that are using some other conversation - * management system. + * The `DialogContainer` class lets you break your bots logic up into components that can be added + * as a dialog to other dialog sets within your bots project. They can even be exported and used + * in other bot projects, allowing for the creation of libraries of reusable dialog components. * - * ### Control Packaging + * ### Component Creation * - * You'll typically want to package your control as a new class derived from `DialogContainer`. - * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs - * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. + * To create a reusable dialog component you'll want to define a new class derived from + * `DialogContainer`. Your component has its own `DialogSet` which you can add dialogs to from + * within your classes constructor. You can add as many dialogs as you like and the dialogs can + * be waterfalls, prompts, or even other component dialogs. * - * If your control needs to be configured then you can pass through the configuration settings as - * a set of `defaultOptions` which will be merged with any options passed in by the caller when - * they call `begin()`. These will then be passed as arguments to the initial dialog that gets - * started. + * Since developers will add instances of your component to their bots as other named dialogs, the + * DialogContainer needs to know the ID of the initial dialog it should start anytime it's started. * * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to * enter their name and phone number which it will return as a JSON object to the caller: @@ -61,12 +59,18 @@ import { DialogSet } from './dialogSet'; * module.exports.ProfileDialog = ProfileDialog; * ``` * - * ### Consume as Dialog + * We've added two dialogs to our component, a waterfall and a prompt. And we've told the + * DialogContainer that it should start the 'fillProfile' dialog anytime an instance of the + * `ProfileDialog` is started. The DialogContainer will manager persisting the controls dialog + * stack to the callers dialog stack. * - * On the consumption side the control we created can be used by a bot in much the same way they - * would use any other prompt. They can add a new instance of the control as a named dialog to - * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the - * control accepts options these can be passed in to the `begin()` call as well. + * ### Component Usage + * + * On the consumption side the dialog we created can be used by a bot in much the same way they + * would use any other prompt. They can add a new instance of the component as a named dialog to + * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the + * dialog accepts options these can be passed in to the `begin()` call and the `DialogContainer` + * will pass them through as args to the initial dialog it starts. * * ```JavaScript * const { DialogSet } = require('botbuilder-dialogs'); @@ -87,48 +91,20 @@ import { DialogSet } from './dialogSet'; * } * ]); * ``` - * - * ### Consume as Control - * - * If the consuming bot isn't dialog based they can still use your control. They will just need - * start the control from somewhere within their bots logic by calling the controls `begin()` - * method: - * - * ```JavaScript - * const state = {}; - * const control = new ProfileDialog(); - * await prompt.begin(context, state); - * ``` - * - * The control will populate the `state` object passed in with information it needs to process - * the users response. This should be saved off with the bots conversation state as it needs to be - * passed into the controls `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const control = new ProfileDialog(); - * const result = await control.continue(context, state); - * if (!result.active) { - * const profile = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the control is finished and then to access any results it might have returned. To interrupt or - * cancel the control simply delete the `state` object the bot has been persisting. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the begin() method. * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. */ export declare class DialogContainer extends Dialog { - protected dialogId: string; - /** The controls dialog set. */ + protected initialDialogId: string; + /** The containers dialog set. */ protected dialogs: DialogSet; /** * Creates a new `DialogContainer` instance. - * @param dialogId ID of the root dialog that should be started anytime the control is started. - * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. + * @param initialDialogId ID of the dialog, within the containers dialog set, that should be started anytime an instance of the `DialogContainer` is started. + * @param dialogs (Optional) set of existing dialogs the container should use. If omitted an empty set will be created. */ - constructor(dialogId: string, dialogs?: DialogSet); + constructor(initialDialogId: string, dialogs?: DialogSet); dialogBegin(dc: DialogContext, dialogArgs?: any): Promise; dialogContinue(dc: DialogContext): Promise; } diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js b/libraries/botbuilder-dialogs/lib/dialogContainer.js index 828d4498bb..59cd1c800a 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContainer.js +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.js @@ -1,25 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dialog_1 = require("./dialog"); +const dialogContext_1 = require("./dialogContext"); const dialogSet_1 = require("./dialogSet"); /** * :package: **botbuilder-dialogs** * - * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a - * control that can be used within another bot. The control can be used either as a dialog added - * to the other bots `DialogSet` or on its own for bots that are using some other conversation - * management system. + * The `DialogContainer` class lets you break your bots logic up into components that can be added + * as a dialog to other dialog sets within your bots project. They can even be exported and used + * in other bot projects, allowing for the creation of libraries of reusable dialog components. * - * ### Control Packaging + * ### Component Creation * - * You'll typically want to package your control as a new class derived from `DialogContainer`. - * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs - * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. + * To create a reusable dialog component you'll want to define a new class derived from + * `DialogContainer`. Your component has its own `DialogSet` which you can add dialogs to from + * within your classes constructor. You can add as many dialogs as you like and the dialogs can + * be waterfalls, prompts, or even other component dialogs. * - * If your control needs to be configured then you can pass through the configuration settings as - * a set of `defaultOptions` which will be merged with any options passed in by the caller when - * they call `begin()`. These will then be passed as arguments to the initial dialog that gets - * started. + * Since developers will add instances of your component to their bots as other named dialogs, the + * DialogContainer needs to know the ID of the initial dialog it should start anytime it's started. * * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to * enter their name and phone number which it will return as a JSON object to the caller: @@ -54,12 +53,18 @@ const dialogSet_1 = require("./dialogSet"); * module.exports.ProfileDialog = ProfileDialog; * ``` * - * ### Consume as Dialog + * We've added two dialogs to our component, a waterfall and a prompt. And we've told the + * DialogContainer that it should start the 'fillProfile' dialog anytime an instance of the + * `ProfileDialog` is started. The DialogContainer will manager persisting the controls dialog + * stack to the callers dialog stack. * - * On the consumption side the control we created can be used by a bot in much the same way they - * would use any other prompt. They can add a new instance of the control as a named dialog to - * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the - * control accepts options these can be passed in to the `begin()` call as well. + * ### Component Usage + * + * On the consumption side the dialog we created can be used by a bot in much the same way they + * would use any other prompt. They can add a new instance of the component as a named dialog to + * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the + * dialog accepts options these can be passed in to the `begin()` call and the `DialogContainer` + * will pass them through as args to the initial dialog it starts. * * ```JavaScript * const { DialogSet } = require('botbuilder-dialogs'); @@ -80,66 +85,40 @@ const dialogSet_1 = require("./dialogSet"); * } * ]); * ``` - * - * ### Consume as Control - * - * If the consuming bot isn't dialog based they can still use your control. They will just need - * start the control from somewhere within their bots logic by calling the controls `begin()` - * method: - * - * ```JavaScript - * const state = {}; - * const control = new ProfileDialog(); - * await prompt.begin(context, state); - * ``` - * - * The control will populate the `state` object passed in with information it needs to process - * the users response. This should be saved off with the bots conversation state as it needs to be - * passed into the controls `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const control = new ProfileDialog(); - * const result = await control.continue(context, state); - * if (!result.active) { - * const profile = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the control is finished and then to access any results it might have returned. To interrupt or - * cancel the control simply delete the `state` object the bot has been persisting. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the begin() method. * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. */ class DialogContainer extends dialog_1.Dialog { /** * Creates a new `DialogContainer` instance. - * @param dialogId ID of the root dialog that should be started anytime the control is started. - * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. + * @param initialDialogId ID of the dialog, within the containers dialog set, that should be started anytime an instance of the `DialogContainer` is started. + * @param dialogs (Optional) set of existing dialogs the container should use. If omitted an empty set will be created. */ - constructor(dialogId, dialogs) { + constructor(initialDialogId, dialogs) { super(); - this.dialogId = dialogId; + this.initialDialogId = initialDialogId; this.dialogs = dialogs || new dialogSet_1.DialogSet(); } dialogBegin(dc, dialogArgs) { - // Start the controls entry point dialog. - const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); - return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); + // Start the dialogs entry point dialog. + let result; + const cdc = new dialogContext_1.DialogContext(this.dialogs, dc.context, dc.activeDialog.state, (r) => { result = r; }); + return cdc.begin(this.initialDialogId, dialogArgs).then(() => { + // End if the dialogs dialog ends. + if (!cdc.activeDialog) { + return dc.end(result); } }); } dialogContinue(dc) { - // Continue controls dialog stack. - const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); + // Continue dialogs dialog stack. + let result; + const cdc = new dialogContext_1.DialogContext(this.dialogs, dc.context, dc.activeDialog.state, (r) => { result = r; }); return cdc.continue().then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); + // End if the dialogs dialog ends. + if (!cdc.activeDialog) { + return dc.end(result); } }); } diff --git a/libraries/botbuilder-dialogs/lib/dialogContainer.js.map b/libraries/botbuilder-dialogs/lib/dialogContainer.js.map index 8ec353dcb6..f9035ef75e 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContainer.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogContainer.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogContainer.js","sourceRoot":"","sources":["../src/dialogContainer.ts"],"names":[],"mappings":";;AAQA,qCAAkD;AAElD,2CAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AY,CAAC,MAAM,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAnCD,0CAmCC"} \ No newline at end of file +{"version":3,"file":"dialogContainer.js","sourceRoot":"","sources":["../src/dialogContainer.ts"],"names":[],"mappings":";;AAQA,qCAAkD;AAClD,mDAAgD;AAChD,2CAAwC;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqFG;AACH,qBAAmF,SAAQ,eAAS;IAIhG;;;;OAIG;IACH,YAAsB,eAAuB,EAAE,OAAsB;QACjE,KAAK,EAAE,CAAC;QADU,oBAAe,GAAf,eAAe,CAAQ;QAEzC,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,IAAI,qBAAS,EAAK,CAAC;IACjD,CAAC;IAEM,WAAW,CAAC,EAAoB,EAAE,UAAgB;QACrD,wCAAwC;QACxC,IAAI,MAAW,CAAC;QAChB,MAAM,GAAG,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;QACtG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACzD,kCAAkC;YAClC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;gBACpB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,cAAc,CAAC,EAAoB;QACtC,iCAAiC;QACjC,IAAI,MAAW,CAAC;QAChB,MAAM,GAAG,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,CAAC;QACtG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC5B,kCAAkC;YAClC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;gBACpB,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AArCD,0CAqCC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.d.ts b/libraries/botbuilder-dialogs/lib/dialogContext.d.ts index c5d3dc5db0..0aba4e1a62 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.d.ts +++ b/libraries/botbuilder-dialogs/lib/dialogContext.d.ts @@ -10,26 +10,6 @@ import { DialogInstance } from './dialog'; import { DialogSet } from './dialogSet'; import { PromptOptions } from './prompts/index'; import { Choice } from 'botbuilder-prompts'; -/** - * :package: **botbuilder-dialogs** - * - * Result returned to the caller of one of the various stack manipulation methods and used to - * return the result from a final call to `DialogContext.end()` to the bots logic. - */ -export interface DialogResult { - /** This will be `true` if there is still an active dialog on the stack. */ - active: boolean; - /** - * Result returned by a dialog that was just ended. This will only be populated in certain - * cases: - * - * - The bot calls `dc.begin()` to start a new dialog and the dialog ends immediately. - * - The bot calls `dc.continue()` and a dialog that was active ends. - * - * In all cases where it's populated, [active](#active) will be `false`. - */ - result: T | undefined; -} /** * :package: **botbuilder-dialogs** * @@ -39,22 +19,20 @@ export interface DialogResult { export declare class DialogContext { readonly dialogs: DialogSet; readonly context: C; + private onCompleted; + /** Current dialog stack. */ readonly stack: DialogInstance[]; - private finalResult; /** * Creates a new DialogContext instance. * @param dialogs Parent dialog set. * @param context Context for the current turn of conversation with the user. - * @param stack Current dialog stack. + * @param state State object being used to persist the dialog stack. + * @param onCompleted (Optional) handler to call when the the last dialog on the stack completes. + * @param onCompleted.result The result returned by the dialog that just completed. */ - constructor(dialogs: DialogSet, context: C, stack: DialogInstance[]); + constructor(dialogs: DialogSet, context: C, state: object, onCompleted?: (result: any) => void); /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - readonly currentDialog: DialogInstance | undefined; - /** - * Returns a structure that indicates whether there is still an active dialog on the stack - * along with the result returned by a dialog that just ended. - */ - readonly dialogResult: DialogResult; + readonly activeDialog: DialogInstance | undefined; /** * Pushes a new dialog onto the dialog stack. * diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.js b/libraries/botbuilder-dialogs/lib/dialogContext.js index 57d478c5e6..4bfa85b401 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.js +++ b/libraries/botbuilder-dialogs/lib/dialogContext.js @@ -11,28 +11,23 @@ class DialogContext { * Creates a new DialogContext instance. * @param dialogs Parent dialog set. * @param context Context for the current turn of conversation with the user. - * @param stack Current dialog stack. + * @param state State object being used to persist the dialog stack. + * @param onCompleted (Optional) handler to call when the the last dialog on the stack completes. + * @param onCompleted.result The result returned by the dialog that just completed. */ - constructor(dialogs, context, stack) { + constructor(dialogs, context, state, onCompleted) { this.dialogs = dialogs; this.context = context; - this.stack = stack; - this.finalResult = undefined; + this.onCompleted = onCompleted; + if (!Array.isArray(state['dialogStack'])) { + state['dialogStack'] = []; + } + this.stack = state['dialogStack']; } /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - get currentDialog() { + get activeDialog() { return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined; } - /** - * Returns a structure that indicates whether there is still an active dialog on the stack - * along with the result returned by a dialog that just ended. - */ - get dialogResult() { - return { - active: this.stack.length > 0, - result: this.finalResult - }; - } /** * Pushes a new dialog onto the dialog stack. * @@ -106,7 +101,7 @@ class DialogContext { continue() { try { // Check for a dialog on the stack - const instance = this.currentDialog; + const instance = this.activeDialog; if (instance) { // Lookup dialog const dialog = this.dialogs.find(instance.id); @@ -162,7 +157,7 @@ class DialogContext { this.stack.pop(); } // Resume previous dialog - const instance = this.currentDialog; + const instance = this.activeDialog; if (instance) { // Lookup dialog const dialog = this.dialogs.find(instance.id); @@ -180,8 +175,10 @@ class DialogContext { } } else { - // Remember final result - this.finalResult = result; + // Signal completion + if (this.onCompleted) { + this.onCompleted(result); + } return Promise.resolve(); } } diff --git a/libraries/botbuilder-dialogs/lib/dialogContext.js.map b/libraries/botbuilder-dialogs/lib/dialogContext.js.map index 152636e750..f833558abc 100644 --- a/libraries/botbuilder-dialogs/lib/dialogContext.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogContext.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogContext.js","sourceRoot":"","sources":["../src/dialogContext.ts"],"names":[],"mappings":";;AAmCA;;;;;GAKG;AACH;IAGK;;;;;OAKG;IACJ,YAA4B,OAAqB,EAAkB,OAAU,EAAkB,KAAuB;QAA1F,YAAO,GAAP,OAAO,CAAc;QAAkB,YAAO,GAAP,OAAO,CAAG;QAAkB,UAAK,GAAL,KAAK,CAAkB;QAR9G,gBAAW,GAAQ,SAAS,CAAC;IAQqF,CAAC;IAE3H,qHAAqH;IACrH,IAAW,aAAa;QACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,CAAC;IAED;;;OAGG;IACH,IAAW,YAAY;QACnB,MAAM,CAAC;YACH,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YAC7B,MAAM,EAAE,IAAI,CAAC,WAAW;SAC3B,CAAC;IACN,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAA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AY;QACZ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;QAAC,CAAC;QAE/C,2BAA2B;QAC3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;CACJ;AA3ND,sCA2NC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.d.ts index f9fa6ef81e..897194ec3a 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.d.ts @@ -15,10 +15,7 @@ import { Prompt, PromptOptions } from './prompt'; * Prompts a user to upload attachments like images. By default the prompt will return to the * calling dialog a `Attachment[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -69,37 +66,6 @@ import { Prompt, PromptOptions } from './prompt'; * return values; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new AttachmentPrompt(); - * await prompt.begin(context, state, { - * prompt: `Send me image(s)`, - * retryPrompt: `I didn't get anything. Send me an image.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new AttachmentPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const attachments = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an `Attachment[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js index 2347557ba6..64b7b40de0 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to upload attachments like images. By default the prompt will return to the * calling dialog a `Attachment[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -62,37 +59,6 @@ const prompts = require("botbuilder-prompts"); * return values; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new AttachmentPrompt(); - * await prompt.begin(context, state, { - * prompt: `Send me image(s)`, - * retryPrompt: `I didn't get anything. Send me an image.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new AttachmentPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const attachments = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an `Attachment[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js.map index eea4f71ad2..d5a18ebff7 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/attachmentPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"attachmentPrompt.js","sourceRoot":"","sources":["../../src/prompts/attachmentPrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,sBAAuE,SAAQ,eAAS;IAGpF;;;OAGG;IACH,YAAY,SAA4C;QACpD,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnD,CAAC;IAES,QAAQ,CAAC,EAAoB,EAAE,OAAsB,EAAE,OAAgB;QAC7E,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACnF,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OA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AE,OAAsB;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ;AAxBD,4CAwBC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.d.ts index aa34b49ff5..9590e9bc89 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.d.ts @@ -25,10 +25,7 @@ export interface ChoicePromptOptions extends PromptOptions { * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -61,38 +58,6 @@ export interface ChoicePromptOptions extends PromptOptions { * ```JavaScript * await dc.prompt('choicePrompt', `Select a color`, ['red', 'green', 'blue'], { retryPrompt: `I didn't catch that. Select a color from the list.` }); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ChoicePrompt(); - * await prompt.begin(context, state, { - * choices: ['red', 'green', 'blue'], - * prompt: `Select a color`, - * retryPrompt: `I didn't catch that. Select a color from the list.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ChoicePrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const color = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an instance of `FoundChoice` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js index 73aa3a498c..7320b9200e 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -44,38 +41,6 @@ const prompts = require("botbuilder-prompts"); * ```JavaScript * await dc.prompt('choicePrompt', `Select a color`, ['red', 'green', 'blue'], { retryPrompt: `I didn't catch that. Select a color from the list.` }); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ChoicePrompt(); - * await prompt.begin(context, state, { - * choices: ['red', 'green', 'blue'], - * prompt: `Select a color`, - * retryPrompt: `I didn't catch that. Select a color from the list.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ChoicePrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const color = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an instance of `FoundChoice` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js.map index 944d0a025b..edf7eae42e 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/choicePrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"choicePrompt.js","sourceRoot":"","sources":["../../src/prompts/choicePrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C;AAY9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,kBAA0E,SAAQ,eAAS;IAGvF;;;;OAIG;IACH,YAAY,SAAmD,EAAE,aAAsB;QACnF,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;IAED;;;;OAIG;IACI,aAAa,CAAC,OAAqC;QACtD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,iBAAiB,CAAC,OAAmC;QACxD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,SAA4B;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK,GA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AC;QAClD,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,iBAAiB,CAAC,OAAmC;QACxD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,SAA4B;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAES,QAAQ,CAAC,EAAoB,EAAE,OAA4B,EAAE,OAAgB;QACnF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QAC5F,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAClF,CAAC;IAES,WAAW,CAAC,EAAoB,EAAE,OAA4B;QACpE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;CACJ;AApDD,oCAoDC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.d.ts index 4ee3f511eb..f1fab33392 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.d.ts @@ -16,10 +16,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -66,37 +63,6 @@ import * as prompts from 'botbuilder-prompts'; * return confirmed; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ConfirmPrompt(); - * await prompt.begin(context, state, { - * prompt: `This will cancel your order. Are you sure?`, - * retryPrompt: `Please answer "yes" or "no".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const cancelOrder = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a boolean `true` or `false` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js index 7457af4d26..606fb7a37b 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -58,37 +55,6 @@ const prompts = require("botbuilder-prompts"); * return confirmed; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ConfirmPrompt(); - * await prompt.begin(context, state, { - * prompt: `This will cancel your order. Are you sure?`, - * retryPrompt: `Please answer "yes" or "no".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const cancelOrder = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a boolean `true` or `false` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js.map index c99cf95426..d33a3dbace 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/confirmPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"confirmPrompt.js","sourceRoot":"","sources":["../../src/prompts/confirmPrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C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AC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACnF,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAES,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;;AA9DD;;;;;;;;;;;;;;;;;;GAkBG;AACI,qBAAO,GAA2B,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;AAtBpE,sCAkEC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.d.ts index 9a5da6a133..4d6ec62b56 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.d.ts @@ -16,10 +16,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to enter a datetime expression. By default the prompt will return to the * calling dialog a `FoundDatetime[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -57,34 +54,6 @@ import * as prompts from 'botbuilder-prompts'; * } * } * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new DatetimePrompt(AlarmTimeValidator); - * await prompt.begin(context, state, { prompt: `What time should I set your alarm for?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const time = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `FoundDatetime[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js index 852892fb01..d2de7b783d 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to enter a datetime expression. By default the prompt will return to the * calling dialog a `FoundDatetime[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -49,34 +46,6 @@ const prompts = require("botbuilder-prompts"); * } * } * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new DatetimePrompt(AlarmTimeValidator); - * await prompt.begin(context, state, { prompt: `What time should I set your alarm for?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const time = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `FoundDatetime[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js.map index 670764e9eb..f4abc0823e 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/datetimePrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"datetimePrompt.js","sourceRoot":"","sources":["../../src/prompts/datetimePrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,oBAAgF,SAAQ,eAAS;IAG7F;;;;OAIG;IACH,YAAY,SAAuD,EAAE,aAAsB;QACvF,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;IAES,QAAQ,CAAC,EAAoB,EAAE,OAAsB,EAAE,OAAgB;QAC7E,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,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E,OAAO,CAAC,UAAU,CAAC,CAAC;QACnF,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAES,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ;AAzBD,wCAyBC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.d.ts index 86a392fd4e..0c48ecbf30 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.d.ts @@ -15,10 +15,7 @@ import { Prompt, PromptOptions } from './prompt'; * Prompts a user to enter a number. By default the prompt will return to the calling dialog * a `number` representing the users input. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -62,37 +59,6 @@ import { Prompt, PromptOptions } from './prompt'; * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new NumberPrompt(); - * await prompt.begin(context, state, { - * prompt: `How old are you?`, - * retryPrompt: `Please reply with a valid number like "23".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const age = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `number` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js index 0d1ffa6d5e..7f550380da 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to enter a number. By default the prompt will return to the calling dialog * a `number` representing the users input. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -55,37 +52,6 @@ const prompts = require("botbuilder-prompts"); * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new NumberPrompt(); - * await prompt.begin(context, state, { - * prompt: `How old are you?`, - * retryPrompt: `Please reply with a valid number like "23".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const age = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `number` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js.map index 928e4d08ab..ddab9b2ecb 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/numberPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"numberPrompt.js","sourceRoot":"","sources":["../../src/prompts/numberPrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,kBAA6D,SAAQ,eAAS;IAG1E;;;;OAIG;IACH,YAAY,SAAsC,EAAE,aAAsB;QACtE,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;IAES,QAAQ,CAAC,EAAoB,EAAE,OAAsB,EAAE,OAAgB;QAC7E,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACnF,CAAC;QAAC,IAAI,CAAC,EAAE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E,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAES,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ;AAzBD,oCAyBC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts index 8bbf6bfb6c..9f74686181 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.d.ts @@ -41,11 +41,7 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * careful of is that you don't block the `event` and `invoke` activities that the prompt might * be waiting on. * - * Like other prompts, the `OAuthPrompt` can be used either as a dialog added to your bots - * `DialogSet` or on its own as a control if your bot is using some other conversation management - * system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -77,48 +73,6 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * } * ]); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.begin(context, state); - * if (!result.active) { - * const token = result.result; - * } - * ``` - * - * If the user is already signed into the service we will get a token back immediately. We - * therefore need to check to see if the prompt is still active after the call to `begin()`. - * - * If the prompt is still active that means the user was sent an `OAuthCard` prompting the user to - * signin and we need to pass any additional activities we receive to the `continue()` method. We - * can't be certain which auth flow is being used so it's best to route *all* activities, regardless - * of type, to the `continue()` method for processing. - * - * ```JavaScript - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const token = result.result; - * if (token) { - * // User has successfully signed in - * } else { - * // The signin has timed out - * } - * } - * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ export declare class OAuthPrompt extends Dialog { diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js index e15ab00488..522dbd552e 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js @@ -28,11 +28,7 @@ const dialog_1 = require("../dialog"); * careful of is that you don't block the `event` and `invoke` activities that the prompt might * be waiting on. * - * Like other prompts, the `OAuthPrompt` can be used either as a dialog added to your bots - * `DialogSet` or on its own as a control if your bot is using some other conversation management - * system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -64,48 +60,6 @@ const dialog_1 = require("../dialog"); * } * ]); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.begin(context, state); - * if (!result.active) { - * const token = result.result; - * } - * ``` - * - * If the user is already signed into the service we will get a token back immediately. We - * therefore need to check to see if the prompt is still active after the call to `begin()`. - * - * If the prompt is still active that means the user was sent an `OAuthCard` prompting the user to - * signin and we need to pass any additional activities we receive to the `continue()` method. We - * can't be certain which auth flow is being used so it's best to route *all* activities, regardless - * of type, to the `continue()` method for processing. - * - * ```JavaScript - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const token = result.result; - * if (token) { - * // User has successfully signed in - * } else { - * // The signin has timed out - * } - * } - * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ class OAuthPrompt extends dialog_1.Dialog { @@ -122,7 +76,7 @@ class OAuthPrompt extends dialog_1.Dialog { dialogBegin(dc, options) { // Persist options and state const timeout = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000; - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.state = Object.assign({ expires: new Date().getTime() + timeout }, options); @@ -147,7 +101,7 @@ class OAuthPrompt extends dialog_1.Dialog { // Recognize token return this.prompt.recognize(dc.context).then((output) => { // Check for timeout - const state = dc.currentDialog.state; + const state = dc.activeDialog.state; const isMessage = dc.context.activity.type === botbuilder_1.ActivityTypes.Message; const hasTimedOut = isMessage && (new Date().getTime() > state.expires); // Process output diff --git a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map index 459c67865b..2b9d559d6a 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/oauthPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"oauthPrompt.js","sourceRoot":"","sources":["../../src/prompts/oauthPrompt.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAA2F;AAC3F,8CAA8C;AAE9C,sCAAmC;AAiBnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,iBAAgD,SAAQ,eAAS;IAG7D;;;;OAIG;IACH,Y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AK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,EAAE,uBAAU,CAAC,cAAc,CAAC,CAAC;YACnG,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,WAAW,CAAC,OAAoB;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACJ;AAzED,kCAyEC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js b/libraries/botbuilder-dialogs/lib/prompts/prompt.js index a638ff8ae9..7f4a65d7be 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js @@ -22,7 +22,7 @@ class Prompt extends dialog_1.Dialog { } dialogBegin(dc, options) { // Persist options - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.state = options || {}; // Send initial prompt return this.onPrompt(dc, instance.state, false); @@ -33,7 +33,7 @@ class Prompt extends dialog_1.Dialog { return Promise.resolve(); } // Recognize value - const instance = dc.currentDialog; + const instance = dc.activeDialog; return this.onRecognize(dc, instance.state) .then((recognized) => { if (this.validator) { diff --git a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map index cb9e1a30a9..ff633749f3 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/prompt.js.map @@ -1 +1 @@ -{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/prompts/prompt.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;;;GAGG;AACH,2CAA+E;AAG/E,sCAAmC;AAqBnC;;;;;GAKG;AACH,YAAoD,SAAQ,eAAS;IACjE,YAAoB,SAAqC;QACrD,KAAK,EAAE,CAAC;QADQ,cAAS,GAAT,SAAS,CAA4B;IAEzD,CAAC;IAMM,WAAW,CAAC,EAAoB,EAA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,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YACnE,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,gCAAgC;gBAChC,MAAM,CAAC,UAAU,CAAC;YACtB,CAAC;QACL,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,EAAE,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC;gBACvB,0BAA0B;gBAC1B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;YAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC/B,oBAAoB;gBACpB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACnD,CAAC;QACL,CAAC,CAAC,CAAC;IACX,CAAC;CACJ;AA7CD,wBA6CC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.d.ts b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.d.ts index bbde7e5be5..90195b2dda 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.d.ts +++ b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.d.ts @@ -15,10 +15,7 @@ import { Prompt, PromptOptions } from './prompt'; * Prompts a user to enter some text. By default the prompt will return to the calling * dialog a `string` representing the users reply. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -54,34 +51,6 @@ import { Prompt, PromptOptions } from './prompt'; * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new TextPrompt(); - * await prompt.begin(context, state, { prompt: `What's your name?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new TextPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const name = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `string` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js index 1e002201a7..06cef526ef 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js +++ b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js @@ -8,10 +8,7 @@ const prompts = require("botbuilder-prompts"); * Prompts a user to enter some text. By default the prompt will return to the calling * dialog a `string` representing the users reply. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -47,34 +44,6 @@ const prompts = require("botbuilder-prompts"); * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new TextPrompt(); - * await prompt.begin(context, state, { prompt: `What's your name?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new TextPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const name = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `string` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js.map b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js.map index 1139e77e16..65a0572aaa 100644 --- a/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js.map +++ b/libraries/botbuilder-dialogs/lib/prompts/textPrompt.js.map @@ -1 +1 @@ -{"version":3,"file":"textPrompt.js","sourceRoot":"","sources":["../../src/prompts/textPrompt.ts"],"names":[],"mappings":";;AAUA,qCAAiD;AACjD,8CAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,gBAA2D,SAAQ,eAAS;IAGxE;;;OAGG;IACH,YAAY,SAAsC;QAC9C,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC7C,CAAC;IAES,QAAQ,CAAC,EAAoB,EAAE,OAAsB,EAAE,OAAgB;QAC7E,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,UA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AAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAES,WAAW,CAAC,EAAoB,EAAE,OAAsB;QAC9D,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ;AAxBD,gCAwBC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/dialog.ts b/libraries/botbuilder-dialogs/src/dialog.ts index 388af0c4df..d0f4520f7f 100644 --- a/libraries/botbuilder-dialogs/src/dialog.ts +++ b/libraries/botbuilder-dialogs/src/dialog.ts @@ -6,7 +6,7 @@ * Licensed under the MIT License. */ import { TurnContext, Promiseable, ActivityTypes } from 'botbuilder'; -import { DialogContext, DialogResult } from './dialogContext'; +import { DialogContext } from './dialogContext'; import { DialogSet } from './dialogSet'; // NOTE: unfortunately the Waterfall class needs to be in this file to avoid a circular dependency. @@ -15,7 +15,7 @@ import { DialogSet } from './dialogSet'; * Tracking information for a dialog on the stack. * @param T (Optional) type of state being persisted for dialog. */ -export interface DialogInstance { +export interface DialogInstance { /** ID of the dialog this instance is for. */ id: string; @@ -23,75 +23,93 @@ export interface DialogInstance { state: T; } +export interface DialogCompletion { + /** If `true` the dialog is still active. */ + isActive: boolean; + + /** If `true` the dialog just completed and the final [result](#result) can be retrieved. */ + isCompleted: boolean; + + /** Final result returned by a dialog that just completed. */ + result?: T; +} + /** * :package: **botbuilder-dialogs** * * Base class for all dialogs. * * The `Control` and `CompositeControl` classes are very similar in that they both add `begin()` - * and `continue()` methods which simplify consuming the control from a non-dialog based bot. The + * and `continue()` methods which simplify consuming the dialog from a non-dialog based bot. The * primary difference between the two classes is that the `CompositeControl` class is designed to * bridge one `DialogSet` to another where the `Control` class assumes that the derived dialog can * be used in complete isolation without the need for any other supporting dialogs. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the [begin()](#begin) method. */ export abstract class Dialog { /** - * Starts the control. Depending on the control, its possible for the control to finish - * immediately so it's advised to check the result object returned by `begin()` and ensure that - * the control is still active before continuing. + * Starts the dialog. Depending on the dialog, its possible for the dialog to finish + * immediately so it's advised to check the completion object returned by `begin()` and ensure + * that the dialog is still active before continuing. * * **Usage Example:** * * ```JavaScript * const state = {}; - * const result = await control.begin(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.begin(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. - * @param state A state object that the control will use to persist its current state. This should be an empty object which the control will populate. The bot should persist this with its other conversation state for as long as the control is still active. - * @param options (Optional) additional options supported by the control. + * @param state A state object that the dialog will use to persist its current state. This should be an empty object which the dialog will populate. The bot should persist this with its other conversation state for as long as the dialog is still active. + * @param options (Optional) additional options supported by the dialog. */ - public begin(context: C, state: object, options?: O): Promise> { - // Create empty dialog set and ourselves to it + public begin(context: C, state: object, options?: O): Promise> { + // Create empty dialog set and add ourselves to it const dialogs = new DialogSet(); dialogs.add('dialog', this); - // Start the control - const cdc = dialogs.createContext(context, state); - return cdc.begin('dialog', options) - .then(() => cdc.dialogResult); + // Start the dialog + let result: any; + const dc = new DialogContext(dialogs, context, state, (r) => { result = r }); + return dc.begin('dialog', options) + .then(() => dc.activeDialog ? { isActive: true, isCompleted: false } as DialogCompletion: { isActive: false, isCompleted: true, result: result }); } /** - * Passes a users reply to the control for further processing. The bot should keep calling - * `continue()` for future turns until the control returns a result with `Active == false`. - * To cancel or interrupt the prompt simply delete the `state` object being persisted. + * Passes a users reply to the dialog for further processing. The bot should keep calling + * `continue()` for future turns until the dialog returns a completion object with + * `isCompleted == true`. To cancel or interrupt the prompt simply delete the `state` object + * being persisted. * * **Usage Example:** * * ```JavaScript - * const result = await control.continue(context, state); - * if (!result.active) { - * const value = result.result; + * const completion = await dialog.continue(context, state); + * if (completion.isCompleted) { + * const value = completion.result; * } * ``` * @param context Context for the current turn of the conversation with the user. * @param state A state object that was previously initialized by a call to [begin()](#begin). */ - public continue(context: C, state: object): Promise> { - // Create empty dialog set and ourselves to it + public continue(context: C, state: object): Promise> { + // Create empty dialog set and add ourselves to it const dialogs = new DialogSet(); dialogs.add('dialog', this); - // Continue the control - const cdc = dialogs.createContext(context, state); - return cdc.continue() - .then(() => cdc.dialogResult); + // Continue the dialog + let result: any; + const dc = new DialogContext(dialogs, context, state, (r) => { result = r }); + if (dc.activeDialog) { + return dc.continue() + .then(() => dc.activeDialog ? { isActive: true, isCompleted: false } as DialogCompletion: { isActive: false, isCompleted: true, result: result }); + } else { + return Promise.resolve({ isActive: false, isCompleted: false }); + } } /** @@ -102,11 +120,11 @@ export abstract class Dialog { abstract dialogBegin(dc: DialogContext, dialogArgs?: any): Promiseable; /** - * (Optional) method called when an instance of the dialog is the "current" dialog and the - * user replies with a new activity. The dialog will generally continue to receive the users - * replies until it calls either `DialogSet.end()` or `DialogSet.begin()`. + * (Optional) method called when an instance of the dialog is the active dialog and the user + * replies with a new activity. The dialog will generally continue to receive the users replies + * until it calls `DialogContext.end()`, `DialogContext.begin()`, or `DialogContext.prompt()`. * - * If this method is NOT implemented then the dialog will automatically be ended when the user + * If this method is NOT implemented then the dialog will be automatically ended when the user * replies. * @param dc The dialog context for the current turn of conversation. */ @@ -114,11 +132,12 @@ export abstract class Dialog { /** * (Optional) method called when an instance of the dialog is being returned to from another - * dialog that was started by the current instance using `DialogSet.begin()`. + * dialog that was started by the current instance using `DialogContext.begin()` or + * `DialogContext.prompt()`. * * If this method is NOT implemented then the dialog will be automatically ended with a call - * to `DialogSet.endDialogWithResult()`. Any result passed from the called dialog will be passed - * to the current dialogs parent. + * to `DialogContext.end()`. Any result passed from the called dialog will be passed to the + * active dialogs parent. * @param dc The dialog context for the current turn of conversation. * @param result (Optional) value returned from the dialog that was called. The type of the value returned is dependant on the dialog that was called. */ @@ -172,7 +191,7 @@ export type WaterfallStep = (dc: DialogContext, args?: /** * :package: **botbuilder-dialogs** * - * When called, control will skip to the next waterfall step. + * When called, dialog will skip to the next waterfall step. * @param SkipStepFunction.args (Optional) additional argument(s) to pass into the next step. */ export type SkipStepFunction = (args?: any) => Promise; @@ -260,7 +279,7 @@ export class Waterfall extends Dialog { } public dialogBegin(dc: DialogContext, args?: any): Promiseable { - const instance = dc.currentDialog as WaterfallInstance; + const instance = dc.activeDialog as WaterfallInstance; instance.step = 0; return this.runStep(dc, args); } @@ -268,7 +287,7 @@ export class Waterfall extends Dialog { public dialogContinue(dc: DialogContext): Promise { // Don't do anything for non-message activities if (dc.context.activity.type === ActivityTypes.Message) { - const instance = dc.currentDialog as WaterfallInstance; + const instance = dc.activeDialog as WaterfallInstance; instance.step += 1 return this.runStep(dc, dc.context.activity.text); } else { @@ -277,14 +296,14 @@ export class Waterfall extends Dialog { } public dialogResume(dc: DialogContext, result?: any): Promiseable { - const instance = dc.currentDialog as WaterfallInstance; + const instance = dc.activeDialog as WaterfallInstance; instance.step += 1 return this.runStep(dc, result); } private runStep(dc: DialogContext, result?: any): Promise { try { - const instance = dc.currentDialog as WaterfallInstance; + const instance = dc.activeDialog as WaterfallInstance; const step = instance.step; if (step >= 0 && step < this.steps.length) { // Execute step diff --git a/libraries/botbuilder-dialogs/src/dialogContainer.ts b/libraries/botbuilder-dialogs/src/dialogContainer.ts index a167cc9951..e36dcf0bc1 100644 --- a/libraries/botbuilder-dialogs/src/dialogContainer.ts +++ b/libraries/botbuilder-dialogs/src/dialogContainer.ts @@ -7,28 +7,26 @@ */ import { Promiseable, TurnContext } from 'botbuilder'; import { Dialog, DialogInstance } from './dialog'; -import { DialogContext, DialogResult } from './dialogContext'; +import { DialogContext } from './dialogContext'; import { DialogSet } from './dialogSet'; /** * :package: **botbuilder-dialogs** * - * A `DialogContainer` makes it easy to take an existing set of dialogs and package them up as a - * control that can be used within another bot. The control can be used either as a dialog added - * to the other bots `DialogSet` or on its own for bots that are using some other conversation - * management system. + * The `DialogContainer` class lets you break your bots logic up into components that can be added + * as a dialog to other dialog sets within your bots project. They can even be exported and used + * in other bot projects, allowing for the creation of libraries of reusable dialog components. * - * ### Control Packaging + * ### Component Creation * - * You'll typically want to package your control as a new class derived from `DialogContainer`. - * Within your controls constructor you'll pass the `DialogSet` containing your controls dialogs - * and the `ID` of the initial dialog that should be started anytime a caller calls the dialog. + * To create a reusable dialog component you'll want to define a new class derived from + * `DialogContainer`. Your component has its own `DialogSet` which you can add dialogs to from + * within your classes constructor. You can add as many dialogs as you like and the dialogs can + * be waterfalls, prompts, or even other component dialogs. * - * If your control needs to be configured then you can pass through the configuration settings as - * a set of `defaultOptions` which will be merged with any options passed in by the caller when - * they call `begin()`. These will then be passed as arguments to the initial dialog that gets - * started. + * Since developers will add instances of your component to their bots as other named dialogs, the + * DialogContainer needs to know the ID of the initial dialog it should start anytime it's started. * * Here's a fairly simple example of a `ProfileDialog` that's designed to prompt the user to * enter their name and phone number which it will return as a JSON object to the caller: @@ -63,12 +61,18 @@ import { DialogSet } from './dialogSet'; * module.exports.ProfileDialog = ProfileDialog; * ``` * - * ### Consume as Dialog + * We've added two dialogs to our component, a waterfall and a prompt. And we've told the + * DialogContainer that it should start the 'fillProfile' dialog anytime an instance of the + * `ProfileDialog` is started. The DialogContainer will manager persisting the controls dialog + * stack to the callers dialog stack. * - * On the consumption side the control we created can be used by a bot in much the same way they - * would use any other prompt. They can add a new instance of the control as a named dialog to - * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the - * control accepts options these can be passed in to the `begin()` call as well. + * ### Component Usage + * + * On the consumption side the dialog we created can be used by a bot in much the same way they + * would use any other prompt. They can add a new instance of the component as a named dialog to + * their bots `DialogSet` and then start it using a call to `DialogContext.begin()`. If the + * dialog accepts options these can be passed in to the `begin()` call and the `DialogContainer` + * will pass them through as args to the initial dialog it starts. * * ```JavaScript * const { DialogSet } = require('botbuilder-dialogs'); @@ -89,70 +93,44 @@ import { DialogSet } from './dialogSet'; * } * ]); * ``` - * - * ### Consume as Control - * - * If the consuming bot isn't dialog based they can still use your control. They will just need - * start the control from somewhere within their bots logic by calling the controls `begin()` - * method: - * - * ```JavaScript - * const state = {}; - * const control = new ProfileDialog(); - * await prompt.begin(context, state); - * ``` - * - * The control will populate the `state` object passed in with information it needs to process - * the users response. This should be saved off with the bots conversation state as it needs to be - * passed into the controls `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const control = new ProfileDialog(); - * const result = await control.continue(context, state); - * if (!result.active) { - * const profile = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the control is finished and then to access any results it might have returned. To interrupt or - * cancel the control simply delete the `state` object the bot has been persisting. - * @param R (Optional) type of result that's expected to be returned by the control. + * @param R (Optional) type of result that's expected to be returned by the dialog. * @param O (Optional) options that can be passed into the begin() method. * @param C (Optional) type of `TurnContext` being passed to dialogs in the set. */ export class DialogContainer extends Dialog { - /** The controls dialog set. */ + /** The containers dialog set. */ protected dialogs: DialogSet; /** * Creates a new `DialogContainer` instance. - * @param dialogId ID of the root dialog that should be started anytime the control is started. - * @param dialogs (Optional) set of existing dialogs the control should use. If omitted an empty set will be created. + * @param initialDialogId ID of the dialog, within the containers dialog set, that should be started anytime an instance of the `DialogContainer` is started. + * @param dialogs (Optional) set of existing dialogs the container should use. If omitted an empty set will be created. */ - constructor(protected dialogId: string, dialogs?: DialogSet) { + constructor(protected initialDialogId: string, dialogs?: DialogSet) { super(); this.dialogs = dialogs || new DialogSet(); } public dialogBegin(dc: DialogContext, dialogArgs?: any): Promise { - // Start the controls entry point dialog. - const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); - return cdc.begin(this.dialogId, Object.assign({}, dialogArgs)).then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); + // Start the dialogs entry point dialog. + let result: any; + const cdc = new DialogContext(this.dialogs, dc.context, dc.activeDialog.state, (r) => { result = r }); + return cdc.begin(this.initialDialogId, dialogArgs).then(() => { + // End if the dialogs dialog ends. + if (!cdc.activeDialog) { + return dc.end(result); } }); } public dialogContinue(dc: DialogContext): Promise { - // Continue controls dialog stack. - const cdc = this.dialogs.createContext(dc.context, dc.currentDialog.state); + // Continue dialogs dialog stack. + let result: any; + const cdc = new DialogContext(this.dialogs, dc.context, dc.activeDialog.state, (r) => { result = r }); return cdc.continue().then(() => { - // End if the controls dialog ends. - if (!cdc.dialogResult.active) { - return dc.end(cdc.dialogResult.result); + // End if the dialogs dialog ends. + if (!cdc.activeDialog) { + return dc.end(result); } }); } diff --git a/libraries/botbuilder-dialogs/src/dialogContext.ts b/libraries/botbuilder-dialogs/src/dialogContext.ts index cd956a1ab6..d224d1a537 100644 --- a/libraries/botbuilder-dialogs/src/dialogContext.ts +++ b/libraries/botbuilder-dialogs/src/dialogContext.ts @@ -11,28 +11,6 @@ import { DialogSet } from './dialogSet'; import { PromptOptions, ChoicePromptOptions } from './prompts/index'; import { Choice } from 'botbuilder-prompts'; -/** - * :package: **botbuilder-dialogs** - * - * Result returned to the caller of one of the various stack manipulation methods and used to - * return the result from a final call to `DialogContext.end()` to the bots logic. - */ -export interface DialogResult { - /** This will be `true` if there is still an active dialog on the stack. */ - active: boolean; - - /** - * Result returned by a dialog that was just ended. This will only be populated in certain - * cases: - * - * - The bot calls `dc.begin()` to start a new dialog and the dialog ends immediately. - * - The bot calls `dc.continue()` and a dialog that was active ends. - * - * In all cases where it's populated, [active](#active) will be `false`. - */ - result: T|undefined; -} - /** * :package: **botbuilder-dialogs** * @@ -40,32 +18,27 @@ export interface DialogResult { * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ export class DialogContext { - private finalResult: any = undefined; - + /** Current dialog stack. */ + public readonly stack: DialogInstance[]; + /** * Creates a new DialogContext instance. * @param dialogs Parent dialog set. * @param context Context for the current turn of conversation with the user. - * @param stack Current dialog stack. + * @param state State object being used to persist the dialog stack. + * @param onCompleted (Optional) handler to call when the the last dialog on the stack completes. + * @param onCompleted.result The result returned by the dialog that just completed. */ - constructor(public readonly dialogs: DialogSet, public readonly context: C, public readonly stack: DialogInstance[]) { } + constructor(public readonly dialogs: DialogSet, public readonly context: C, state: object, private onCompleted?: (result: any) => void) { + if (!Array.isArray(state['dialogStack'])) { state['dialogStack'] = [] } + this.stack = state['dialogStack']; + } /** Returns the cached instance of the active dialog on the top of the stack or `undefined` if the stack is empty. */ - public get currentDialog(): DialogInstance|undefined { + public get activeDialog(): DialogInstance|undefined { return this.stack.length > 0 ? this.stack[this.stack.length - 1] : undefined; } - /** - * Returns a structure that indicates whether there is still an active dialog on the stack - * along with the result returned by a dialog that just ended. - */ - public get dialogResult(): DialogResult { - return { - active: this.stack.length > 0, - result: this.finalResult - }; - } - /** * Pushes a new dialog onto the dialog stack. * @@ -138,7 +111,7 @@ export class DialogContext { public continue(): Promise { try { // Check for a dialog on the stack - const instance = this.currentDialog; + const instance = this.activeDialog; if (instance) { // Lookup dialog @@ -191,7 +164,7 @@ export class DialogContext { if (this.stack.length > 0) { this.stack.pop() } // Resume previous dialog - const instance = this.currentDialog; + const instance = this.activeDialog; if (instance) { // Lookup dialog @@ -207,8 +180,10 @@ export class DialogContext { return this.end(result); } } else { - // Remember final result - this.finalResult = result; + // Signal completion + if (this.onCompleted) { + this.onCompleted(result); + } return Promise.resolve(); } } catch(err) { diff --git a/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts index 8b16047fce..b2f0938b4b 100644 --- a/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/attachmentPrompt.ts @@ -17,10 +17,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to upload attachments like images. By default the prompt will return to the * calling dialog a `Attachment[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -71,37 +68,6 @@ import * as prompts from 'botbuilder-prompts'; * return values; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new AttachmentPrompt(); - * await prompt.begin(context, state, { - * prompt: `Send me image(s)`, - * retryPrompt: `I didn't get anything. Send me an image.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new AttachmentPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const attachments = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an `Attachment[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts index 6ce8f91c8f..924a754b6c 100644 --- a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts @@ -27,10 +27,7 @@ export interface ChoicePromptOptions extends PromptOptions { * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -63,38 +60,6 @@ export interface ChoicePromptOptions extends PromptOptions { * ```JavaScript * await dc.prompt('choicePrompt', `Select a color`, ['red', 'green', 'blue'], { retryPrompt: `I didn't catch that. Select a color from the list.` }); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ChoicePrompt(); - * await prompt.begin(context, state, { - * choices: ['red', 'green', 'blue'], - * prompt: `Select a color`, - * retryPrompt: `I didn't catch that. Select a color from the list.` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ChoicePrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const color = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to an instance of `FoundChoice` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts index 172ede6b41..07a2cafd0d 100644 --- a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts @@ -17,10 +17,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to confirm something with a yes/no response. By default the prompt will return * to the calling dialog a `boolean` representing the users selection. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -67,37 +64,6 @@ import * as prompts from 'botbuilder-prompts'; * return confirmed; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new ConfirmPrompt(); - * await prompt.begin(context, state, { - * prompt: `This will cancel your order. Are you sure?`, - * retryPrompt: `Please answer "yes" or "no".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const cancelOrder = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a boolean `true` or `false` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts index 0d85694b18..42d76a5474 100644 --- a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts @@ -17,10 +17,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to enter a datetime expression. By default the prompt will return to the * calling dialog a `FoundDatetime[]` but this can be overridden using a custom `PromptValidator`. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -58,34 +55,6 @@ import * as prompts from 'botbuilder-prompts'; * } * } * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new DatetimePrompt(AlarmTimeValidator); - * await prompt.begin(context, state, { prompt: `What time should I set your alarm for?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const time = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `FoundDatetime[]` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts index a9ee08dfda..07ba0683ab 100644 --- a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts @@ -17,10 +17,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to enter a number. By default the prompt will return to the calling dialog * a `number` representing the users input. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -64,37 +61,6 @@ import * as prompts from 'botbuilder-prompts'; * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new NumberPrompt(); - * await prompt.begin(context, state, { - * prompt: `How old are you?`, - * retryPrompt: `Please reply with a valid number like "23".` - * }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new ConfirmPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const age = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `number` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index 13bc466fcc..95c8fec2f0 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -43,11 +43,7 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * careful of is that you don't block the `event` and `invoke` activities that the prompt might * be waiting on. * - * Like other prompts, the `OAuthPrompt` can be used either as a dialog added to your bots - * `DialogSet` or on its own as a control if your bot is using some other conversation management - * system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -79,48 +75,6 @@ export interface OAuthPromptSettingsWithTimeout extends prompts.OAuthPromptSetti * } * ]); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.begin(context, state); - * if (!result.active) { - * const token = result.result; - * } - * ``` - * - * If the user is already signed into the service we will get a token back immediately. We - * therefore need to check to see if the prompt is still active after the call to `begin()`. - * - * If the prompt is still active that means the user was sent an `OAuthCard` prompting the user to - * signin and we need to pass any additional activities we receive to the `continue()` method. We - * can't be certain which auth flow is being used so it's best to route *all* activities, regardless - * of type, to the `continue()` method for processing. - * - * ```JavaScript - * const prompt = new OAuthPrompt({ - * connectionName: 'GitConnection', - * title: 'Login To GitHub' - * }); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const token = result.result; - * if (token) { - * // User has successfully signed in - * } else { - * // The signin has timed out - * } - * } - * ``` * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. */ export class OAuthPrompt extends Dialog { @@ -139,7 +93,7 @@ export class OAuthPrompt extends Dialog { public dialogBegin(dc: DialogContext, options: PromptOptions): Promise { // Persist options and state const timeout = typeof this.settings.timeout === 'number' ? this.settings.timeout : 54000000; - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.state = Object.assign({ expires: new Date().getTime() + timeout } as OAuthPromptState, options); @@ -164,7 +118,7 @@ export class OAuthPrompt extends Dialog { // Recognize token return this.prompt.recognize(dc.context).then((output) => { // Check for timeout - const state = dc.currentDialog.state as OAuthPromptState; + const state = dc.activeDialog.state as OAuthPromptState; const isMessage = dc.context.activity.type === ActivityTypes.Message; const hasTimedOut = isMessage && (new Date().getTime() > state.expires); diff --git a/libraries/botbuilder-dialogs/src/prompts/prompt.ts b/libraries/botbuilder-dialogs/src/prompts/prompt.ts index fca4af98a8..ddf73b2597 100644 --- a/libraries/botbuilder-dialogs/src/prompts/prompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/prompt.ts @@ -46,7 +46,7 @@ export abstract class Prompt extends Dialog { public dialogBegin(dc: DialogContext, options: PromptOptions): Promise { // Persist options - const instance = dc.currentDialog; + const instance = dc.activeDialog; instance.state = options || {}; // Send initial prompt @@ -60,7 +60,7 @@ export abstract class Prompt extends Dialog { } // Recognize value - const instance = dc.currentDialog; + const instance = dc.activeDialog; return this.onRecognize(dc, instance.state) .then((recognized) => { if (this.validator) { diff --git a/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts index 496b64c788..69f72e3737 100644 --- a/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/textPrompt.ts @@ -17,10 +17,7 @@ import * as prompts from 'botbuilder-prompts'; * Prompts a user to enter some text. By default the prompt will return to the calling * dialog a `string` representing the users reply. * - * The prompt can be used either as a dialog added to your bots `DialogSet` or on its own as a - * control if your bot is using some other conversation management system. - * - * ### Dialog Usage + * ### Prompt Usage * * When used with your bots `DialogSet` you can simply add a new instance of the prompt as a named * dialog using `DialogSet.add()`. You can then start the prompt from a waterfall step using either @@ -56,34 +53,6 @@ import * as prompts from 'botbuilder-prompts'; * return undefined; * })); * ``` - * - * ### Control Usage - * - * If your bot isn't dialog based you can still use the prompt on its own as a control. You will - * just need start the prompt from somewhere within your bots logic by calling the prompts - * `begin()` method: - * - * ```JavaScript - * const state = {}; - * const prompt = new TextPrompt(); - * await prompt.begin(context, state, { prompt: `What's your name?` }); - * ``` - * - * The prompt will populate the `state` object you passed in with information it needs to process - * the users response. You should save this off to your bots conversation state as you'll need to - * pass it to the prompts `continue()` method on the next turn of conversation with the user: - * - * ```JavaScript - * const prompt = new TextPrompt(); - * const result = await prompt.continue(context, state); - * if (!result.active) { - * const name = result.result; - * } - * ``` - * - * The `continue()` method returns a `DialogResult` object which can be used to determine when - * the prompt is finished and then to access the results of the prompt. To interrupt or cancel - * the prompt simply delete the `state` object your bot is persisting. * @param C The type of `TurnContext` being passed around. This simply lets the typing information for any context extensions flow through to dialogs and waterfall steps. * @param O (Optional) output type returned by prompt. This defaults to a `string` but can be changed by a custom validator passed to the prompt. */ diff --git a/libraries/botbuilder-dialogs/tests/dialog.test.js b/libraries/botbuilder-dialogs/tests/dialog.test.js index 9cfea48d62..5a87200275 100644 --- a/libraries/botbuilder-dialogs/tests/dialog.test.js +++ b/libraries/botbuilder-dialogs/tests/dialog.test.js @@ -49,8 +49,6 @@ describe('Dialog', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('dialog', { foo: 'bar' }).then(() => { - const result = dc.dialogResult; - assert(result && result.active); assert(dialog.beginCalled); assert(dialog.beginArgs && dialog.beginArgs.foo === 'bar'); done(); @@ -62,8 +60,8 @@ describe('Dialog', function() { const state = {}; const context = new TestContext(beginMessage); - dialog.begin(context, state, { foo: 'bar' }).then((result) => { - assert(result && result.active); + dialog.begin(context, state, { foo: 'bar' }).then((completion) => { + assert(completion && completion.isActive); assert(dialog.beginCalled); assert(dialog.beginArgs && dialog.beginArgs.foo === 'bar'); done(); @@ -75,12 +73,12 @@ describe('Dialog', function() { const state = {}; const context = new TestContext(beginMessage); - dialog.begin(context, state, { foo: 'bar' }).then((result) => { - assert(result && result.active); - dialog.continue(context, state).then((result) => { + dialog.begin(context, state, { foo: 'bar' }).then((completion) => { + assert(completion && completion.isActive); + dialog.continue(context, state).then((completion) => { assert(dialog.continueCalled); - assert(result && !result.active); - assert(result.result === 120); + assert(completion && !completion.isActive && completion.isCompleted); + assert(completion.result === 120); done(); }); }); @@ -114,6 +112,7 @@ describe('Waterfall', function() { }); it('should support calling next() to move to next steps.', function (done) { + let calledNext = false; const dialogs = new DialogSet(); dialogs.add('a', [ function (dc, args, next) { @@ -124,7 +123,8 @@ describe('Waterfall', function() { function (dc, args) { assert(dc); assert(args === 'z'); - return dc.end(args); + calledNext = true; + return dc.end(); } ]); @@ -132,9 +132,7 @@ describe('Waterfall', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a', 'z').then(() => { - const result = dc.dialogResult; - assert(result && !result.active); - assert(result.result === 'z'); + assert(calledNext); done(); }); }); diff --git a/libraries/botbuilder-dialogs/tests/dialogContainer.test.js b/libraries/botbuilder-dialogs/tests/dialogContainer.test.js index 2339ddd7bb..30d4d26e32 100644 --- a/libraries/botbuilder-dialogs/tests/dialogContainer.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogContainer.test.js @@ -19,7 +19,7 @@ class TestContext extends TurnContext { describe('DialogContainer', function() { this.timeout(5000); - it('should call composite control from another dialog set.', function (done) { + it('should call composite dialog from another dialog set.', function (done) { const cDialogs = new DialogSet(); cDialogs.add('start', [ function (dc, args) { @@ -29,41 +29,46 @@ describe('DialogContainer', function() { done(); } ]); - const control = new DialogContainer('start', cDialogs); + const composite = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); - dialogs.add('control', control); + dialogs.add('composite', composite); const state = {}; const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); - dc.begin('control', { foo: 'bar' }); + dc.begin('composite', { foo: 'bar' }); }); - it('should return result from DialogContext.begin() when control ends immediately.', function (done) { + it('should return result from DialogContext.begin() when composite ends immediately.', function (done) { const cDialogs = new DialogSet(); cDialogs.add('start', [ function (dc) { return dc.end(120); } ]); - const control = new DialogContainer('start', cDialogs); + const composite = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); - dialogs.add('control', control); + dialogs.add('composite', composite); + dialogs.add('test', [ + function (dc) { + return dc.begin('composite'); + }, + function (dc, result) { + assert(result === 120); + done(); + } + ]) const state = {}; const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); - dc.begin('control').then(() => { - const result = dc.dialogResult; - assert(result && !result.active); - assert(result.result === 120); - done(); - }); + dc.begin('test'); }); - it('should DialogContext.continue() execution of a multi-turn control.', function (done) { + it('should DialogContext.continue() execution of a multi-turn composite.', function (done) { + let finished = false; const cDialogs = new DialogSet(); cDialogs.add('start', [ function (dc) { @@ -73,34 +78,32 @@ describe('DialogContainer', function() { return dc.context.sendActivity('bar'); }, function (dc) { - return dc.end(120); + finished = true; + return dc.end(); } ]); - const control = new DialogContainer('start', cDialogs); + const composite = new DialogContainer('start', cDialogs); const dialogs = new DialogSet(); - dialogs.add('control', control); + dialogs.add('composite', composite); const state = {}; const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); - dc.begin('control').then(() => { - const result = dc.dialogResult; - assert(result && result.active); + dc.begin('composite').then(() => { + assert(dc.activeDialog); dc.continue().then(() => { - const result = dc.dialogResult; - assert(result && result.active); + assert(dc.activeDialog); dc.continue().then(() => { - const result = dc.dialogResult; - assert(result && !result.active); - assert(result.result === 120); + assert(dc.activeDialog === undefined); + assert(finished); done(); }); }); }); }); - it('should call composite control using begin().', function (done) { + it('should call composite composite using begin().', function (done) { const cDialogs = new DialogSet(); cDialogs.add('start', [ function (dc, args) { @@ -110,14 +113,14 @@ describe('DialogContainer', function() { done(); } ]); - const control = new DialogContainer('start', cDialogs); + const composite = new DialogContainer('start', cDialogs); const state = {}; const context = new TestContext(beginMessage); - control.begin(context, state, { foo: 'bar' }); + composite.begin(context, state, { foo: 'bar' }); }); - it('should continue() execution of a multi-turn control.', function (done) { + it('should continue() execution of a multi-turn composite.', function (done) { const cDialogs = new DialogSet(); cDialogs.add('start', [ function (dc) { @@ -130,17 +133,17 @@ describe('DialogContainer', function() { return dc.end(120); } ]); - const control = new DialogContainer('start', cDialogs); + const composite = new DialogContainer('start', cDialogs); const state = {}; const context = new TestContext(beginMessage); - control.begin(context, state).then((result) => { - assert(result && result.active); - control.continue(context, state).then((result) => { - assert(result && result.active); - control.continue(context, state).then((result) => { - assert(result && !result.active); - assert(result.result === 120); + composite.begin(context, state).then((completion) => { + assert(completion && completion.isActive); + composite.continue(context, state).then((completion) => { + assert(completion && completion.isActive); + composite.continue(context, state).then((completion) => { + assert(completion && !completion.isActive && completion.isCompleted); + assert(completion.result === 120); done(); }); }); diff --git a/libraries/botbuilder-dialogs/tests/dialogContext.test.js b/libraries/botbuilder-dialogs/tests/dialogContext.test.js index 0c4f2b1a48..f064961367 100644 --- a/libraries/botbuilder-dialogs/tests/dialogContext.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogContext.test.js @@ -144,8 +144,8 @@ describe('DialogContext', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - assert(state.dialogStack && state.dialogStack[0] && state.dialogStack[0].id === 'a'); - state.dialogStack[0].id = 'b'; + assert(dc.activeDialog && dc.activeDialog.id === 'a'); + dc.activeDialog.id = 'b'; const dc2 = dialogs.createContext(context, state); return dc2.continue().catch((err) => { assert(err); @@ -168,8 +168,7 @@ describe('DialogContext', function() { dc.begin('a').then(() => { const dc2 = dialogs.createContext(context, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && !result.active); + assert(dc2.activeDialog === undefined); done(); }); }); @@ -221,25 +220,6 @@ describe('DialogContext', function() { const dc = dialogs.createContext(context, state); dc.begin('a'); }); - - it('should return a value from begin() when end() called with a value on root dialog.', function (done) { - const dialogs = new DialogSet(); - dialogs.add('a', [ - function (dc) { - return dc.end(120); - } - ]); - - const state = {}; - const context = new TestContext(beginMessage); - const dc = dialogs.createContext(context, state); - dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && !result.active); - assert(result.result === 120); - done(); - }); - }); it(`should return to parents parent when end() called and parent doesn't support Dialog.dialogResume().`, function (done) { const dialogs = new DialogSet(); @@ -259,8 +239,7 @@ describe('DialogContext', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && !result.active); + assert(dc.activeDialog === undefined); done(); }); }); @@ -289,9 +268,8 @@ describe('DialogContext', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(state.dialogStack && state.dialogStack[0] && state.dialogStack[0].id === 'a'); - state.dialogStack[0].id = 'c'; + assert(dc.activeDialog && dc.activeDialog.id === 'b'); + dc.activeDialog.id = 'c'; const dc2 = dialogs.createContext(context, state); return dc2.continue().catch((err) => { assert(err); @@ -306,8 +284,7 @@ describe('DialogContext', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.end().then(() => { - const result = dc.dialogResult; - assert(result && !result.active); + assert(dc.activeDialog === undefined); done(); }); }); diff --git a/libraries/botbuilder-dialogs/tests/dialogSet.test.js b/libraries/botbuilder-dialogs/tests/dialogSet.test.js index f1c675be09..448868e229 100644 --- a/libraries/botbuilder-dialogs/tests/dialogSet.test.js +++ b/libraries/botbuilder-dialogs/tests/dialogSet.test.js @@ -19,35 +19,6 @@ class TestContext extends TurnContext { describe('DialogSet', function() { this.timeout(5000); - it('should call Dialog.begin() and Dialog.continue().', function (done) { - const dialogs = new DialogSet(); - dialogs.add('a', { - dialogBegin: (dc, args) => { - assert(dc, 'Missing dialog context in begin()'); - assert(args === 'z', 'Args not passed'); - return dc.context.sendActivity(beginMessage); - }, - dialogContinue: (dc) => { - assert(dc, 'Missing dialog context in continue()'); - return dc.context.sendActivity(continueMessage); - } - }); - - const state = {}; - const context = new TestContext(beginMessage); - const dc = dialogs.createContext(context, state); - dc.continue().then(() => { - if (!context.responded) { - return dc.begin('a', 'z'); - } - }).then(() => { - assert(context.responded, `no reply sent`); - assert(Array.isArray(state.dialogStack), `no dialog stack persisted.`); - assert(state.dialogStack.length === 1, `invalid number of entries on stack.`) - done(); - }); - }); - it('should throw an exception when trying to add the same dialog twice.', function (done) { const dialogs = new DialogSet(); dialogs.add('a', [ diff --git a/libraries/botbuilder-dialogs/tests/prompts_attachmentPrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_attachmentPrompt.test.js index 9c31bb914b..ce5e72c9bd 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_attachmentPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_attachmentPrompt.test.js @@ -37,8 +37,7 @@ describe('prompts/AttachmentPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); + assert(dc.activeDialog); const dc2 = dialogs.createContext(new TestContext(answerMessage), state); return dc2.continue(); }); @@ -53,6 +52,10 @@ describe('prompts/AttachmentPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo'); + }, + function (dc, result) { + assert(Array.isArray(result)); + done(); } ]); @@ -60,21 +63,12 @@ describe('prompts/AttachmentPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(Array.isArray(result.result)); - done(); - }); + return dc3.continue(); }); }); }); @@ -88,6 +82,10 @@ describe('prompts/AttachmentPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(Array.isArray(result)); + done(); } ]); @@ -95,21 +93,12 @@ describe('prompts/AttachmentPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(Array.isArray(result.result)); - done(); - }); + return dc3.continue(); }); }); }); @@ -126,6 +115,10 @@ describe('prompts/AttachmentPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(Array.isArray(result)); + done(); } ]); @@ -133,21 +126,12 @@ describe('prompts/AttachmentPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bad input'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(Array.isArray(result.result)); - done(); - }); + return dc3.continue(); }); }); }); @@ -161,6 +145,10 @@ describe('prompts/AttachmentPrompt', function() { dialogs.add('a', [ function (dc) { return dc.begin('prompt'); + }, + function (dc, result) { + assert(Array.isArray(result)); + done(); } ]); @@ -168,21 +156,12 @@ describe('prompts/AttachmentPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(!context2.sent); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(Array.isArray(result.result)); - done(); - }); + return dc3.continue(); }); }); }); diff --git a/libraries/botbuilder-dialogs/tests/prompts_choicePrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_choicePrompt.test.js index 11789f4a1d..a894066c48 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_choicePrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_choicePrompt.test.js @@ -39,8 +39,6 @@ describe('prompts/ChoicePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const dc2 = dialogs.createContext(new TestContext(answerMessage), state); return dc2.continue(); }); @@ -55,6 +53,10 @@ describe('prompts/ChoicePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', choices); + }, + function (dc, result) { + assert(result && result.value === 'red'); + done(); } ]); @@ -62,21 +64,12 @@ describe('prompts/ChoicePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result && result.result.value === 'red'); - done(); - }); + return dc3.continue(); }); }); }); @@ -90,6 +83,10 @@ describe('prompts/ChoicePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar', choices: choices }); + }, + function (dc, result) { + assert(result && result.value === 'red'); + done(); } ]); @@ -97,21 +94,12 @@ describe('prompts/ChoicePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result && result.result.value === 'red'); - done(); - }); + return dc3.continue(); }); }); }); @@ -128,6 +116,10 @@ describe('prompts/ChoicePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar', choices: choices }); + }, + function (dc, result) { + assert(result && result.value === 'red'); + done(); } ]); @@ -135,21 +127,12 @@ describe('prompts/ChoicePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bad input'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result && result.result.value === 'red'); - done(); - }); + return dc3.continue(); }); }); }); diff --git a/libraries/botbuilder-dialogs/tests/prompts_confirmPrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_confirmPrompt.test.js index b489242dc0..c24717bfc6 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_confirmPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_confirmPrompt.test.js @@ -37,8 +37,6 @@ describe('prompts/ConfirmPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const dc2 = dialogs.createContext(new TestContext(answerMessage), state); return dc2.continue(); }); @@ -53,6 +51,10 @@ describe('prompts/ConfirmPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo'); + }, + function (dc, result) { + assert(result === true); + done(); } ]); @@ -60,21 +62,12 @@ describe('prompts/ConfirmPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === true); - done(); - }); + return dc3.continue(); }); }); }); @@ -88,6 +81,10 @@ describe('prompts/ConfirmPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === true); + done(); } ]); @@ -95,21 +92,12 @@ describe('prompts/ConfirmPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === true); - done(); - }); + return dc3.continue(); }); }); }); @@ -126,6 +114,10 @@ describe('prompts/ConfirmPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === true); + done(); } ]); @@ -133,21 +125,12 @@ describe('prompts/ConfirmPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bad input'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === true); - done(); - }); + return dc3.continue(); }); }); }); @@ -161,6 +144,10 @@ describe('prompts/ConfirmPrompt', function() { dialogs.add('a', [ function (dc) { return dc.begin('prompt'); + }, + function (dc, result) { + assert(result === true); + done(); } ]); @@ -168,21 +155,12 @@ describe('prompts/ConfirmPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(!context2.sent); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === true); - done(); - }); + return dc3.continue(); }); }); }); diff --git a/libraries/botbuilder-dialogs/tests/prompts_datetimePrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_datetimePrompt.test.js index 3e3873a570..a4aa5572b6 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_datetimePrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_datetimePrompt.test.js @@ -37,8 +37,6 @@ describe('prompts/DatetimePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const dc2 = dialogs.createContext(new TestContext(answerMessage), state); return dc2.continue(); }); @@ -53,6 +51,10 @@ describe('prompts/DatetimePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo'); + }, + function (dc, result) { + assert(typeof result === 'object'); + done(); } ]); @@ -60,21 +62,12 @@ describe('prompts/DatetimePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(typeof result.result === 'object'); - done(); - }); + return dc3.continue(); }); }); }); @@ -88,6 +81,10 @@ describe('prompts/DatetimePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(typeof result === 'object'); + done(); } ]); @@ -95,21 +92,12 @@ describe('prompts/DatetimePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(typeof result.result === 'object'); - done(); - }); + return dc3.continue(); }); }); }); @@ -126,6 +114,10 @@ describe('prompts/DatetimePrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(typeof result === 'object'); + done(); } ]); @@ -133,21 +125,12 @@ describe('prompts/DatetimePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bad date'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(typeof result.result === 'object'); - done(); - }); + return dc3.continue(); }); }); }); @@ -161,6 +144,10 @@ describe('prompts/DatetimePrompt', function() { dialogs.add('a', [ function (dc) { return dc.begin('prompt'); + }, + function (dc, result) { + assert(typeof result === 'object'); + done(); } ]); @@ -168,21 +155,12 @@ describe('prompts/DatetimePrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(!context2.sent); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(typeof result.result === 'object'); - done(); - }); + return dc3.continue(); }); }); }); diff --git a/libraries/botbuilder-dialogs/tests/prompts_numberPrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_numberPrompt.test.js index 0d23d1ae3a..ecaf616984 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_numberPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_numberPrompt.test.js @@ -37,8 +37,6 @@ describe('prompts/NumberPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const dc2 = dialogs.createContext(new TestContext(answerMessage), state); return dc2.continue(); }); @@ -54,6 +52,10 @@ describe('prompts/NumberPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo'); + }, + function (dc, result) { + assert(result === 35); + done(); } ]); @@ -61,21 +63,12 @@ describe('prompts/NumberPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === 35); - done(); - }); + return dc3.continue(); }); }); }); @@ -90,6 +83,10 @@ describe('prompts/NumberPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === 35); + done(); } ]); @@ -97,21 +94,12 @@ describe('prompts/NumberPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === 35); - done(); - }); + return dc3.continue(); }); }); }); @@ -129,6 +117,10 @@ describe('prompts/NumberPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === 35); + done(); } ]); @@ -136,21 +128,12 @@ describe('prompts/NumberPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'out of range'); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === 35); - done(); - }); + return dc3.continue(); }); }); }); @@ -165,6 +148,10 @@ describe('prompts/NumberPrompt', function() { dialogs.add('a', [ function (dc) { return dc.begin('prompt'); + }, + function (dc, result) { + assert(result === 35); + done(); } ]); @@ -172,21 +159,12 @@ describe('prompts/NumberPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(invalidMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(!context2.sent); const dc3 = dialogs.createContext(new TestContext(answerMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === 35); - done(); - }); + return dc3.continue(); }); }); }); diff --git a/libraries/botbuilder-dialogs/tests/prompts_textPrompt.test.js b/libraries/botbuilder-dialogs/tests/prompts_textPrompt.test.js index a8bf75b6e9..066f1a2b0f 100644 --- a/libraries/botbuilder-dialogs/tests/prompts_textPrompt.test.js +++ b/libraries/botbuilder-dialogs/tests/prompts_textPrompt.test.js @@ -38,8 +38,6 @@ describe('prompts/TextPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const dc2 = dialogs.createContext(new TestContext(continueMessage), state); return dc2.continue(); }); @@ -54,6 +52,10 @@ describe('prompts/TextPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo'); + }, + function (dc, result) { + assert(result === 'abcdefg'); + done(); } ]); @@ -61,21 +63,12 @@ describe('prompts/TextPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(shortMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'foo'); const dc3 = dialogs.createContext(new TestContext(longMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === longMessage.text); - done(); - }); + return dc3.continue(); }); }); }); @@ -89,6 +82,10 @@ describe('prompts/TextPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === 'abcdefg'); + done(); } ]); @@ -96,21 +93,12 @@ describe('prompts/TextPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(shortMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'bar'); const dc3 = dialogs.createContext(new TestContext(longMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === longMessage.text); - done(); - }); + return dc3.continue(); }); }); }); @@ -127,6 +115,10 @@ describe('prompts/TextPrompt', function() { dialogs.add('a', [ function (dc) { return dc.prompt('prompt', 'foo', { retryPrompt: 'bar' }); + }, + function (dc, result) { + assert(result === 'abcdefg'); + done(); } ]); @@ -134,21 +126,12 @@ describe('prompts/TextPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(shortMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(context2.sent && context2.sent[0].text === 'too short'); const dc3 = dialogs.createContext(new TestContext(longMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === longMessage.text); - done(); - }); + return dc3.continue(); }); }); }); @@ -162,6 +145,10 @@ describe('prompts/TextPrompt', function() { dialogs.add('a', [ function (dc) { return dc.begin('prompt'); + }, + function (dc, result) { + assert(result === 'abcdefg'); + done(); } ]); @@ -169,21 +156,12 @@ describe('prompts/TextPrompt', function() { const context = new TestContext(beginMessage); const dc = dialogs.createContext(context, state); dc.begin('a').then(() => { - const result = dc.dialogResult; - assert(result && result.active); const context2 = new TestContext(shortMessage); const dc2 = dialogs.createContext(context2, state); return dc2.continue().then(() => { - const result = dc2.dialogResult; - assert(result && result.active); assert(!context2.sent); const dc3 = dialogs.createContext(new TestContext(longMessage), state); - return dc3.continue().then(() => { - const result = dc3.dialogResult; - assert(result && !result.active); - assert(result.result === longMessage.text); - done(); - }); + return dc3.continue(); }); }); }); From 4ca0f030cb1ba5d3d0faf574cc1676dbf62b2337 Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Fri, 27 Apr 2018 15:43:06 -0700 Subject: [PATCH 7/8] Updated samples Fixed a bug in DialogSet.createContext() --- libraries/botbuilder-dialogs/lib/dialogSet.js | 5 +---- libraries/botbuilder-dialogs/lib/dialogSet.js.map | 2 +- libraries/botbuilder-dialogs/src/dialogSet.ts | 3 +-- samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js | 6 +++--- samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map | 2 +- samples/dialogs/alarmbot-ts/lib/app.js | 2 +- samples/dialogs/alarmbot-ts/lib/app.js.map | 2 +- samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts | 6 +++--- samples/dialogs/alarmbot-ts/src/app.ts | 2 +- samples/dialogs/{controls-ts => component-ts}/README.md | 0 samples/dialogs/{controls-ts => component-ts}/lib/app.js | 8 ++++---- .../dialogs/{controls-ts => component-ts}/lib/app.js.map | 2 +- .../dialogs/{controls-ts => component-ts}/lib/language.js | 0 .../{controls-ts => component-ts}/lib/language.js.map | 2 +- .../{controls-ts => component-ts}/package-lock.json | 0 .../dialogs/{controls-ts => component-ts}/package.json | 2 +- samples/dialogs/{controls-ts => component-ts}/src/app.ts | 8 ++++---- .../dialogs/{controls-ts => component-ts}/src/language.ts | 2 +- .../dialogs/{controls-ts => component-ts}/tsconfig.json | 0 samples/dialogs/list-ts/lib/listControl.js | 6 +++--- samples/dialogs/list-ts/src/listControl.ts | 6 +++--- samples/dialogs/prompts-ts/lib/app.js | 4 ++-- samples/dialogs/prompts-ts/lib/app.js.map | 2 +- samples/dialogs/prompts-ts/src/app.ts | 4 ++-- 24 files changed, 36 insertions(+), 40 deletions(-) rename samples/dialogs/{controls-ts => component-ts}/README.md (100%) rename samples/dialogs/{controls-ts => component-ts}/lib/app.js (95%) rename samples/dialogs/{controls-ts => component-ts}/lib/app.js.map (86%) rename samples/dialogs/{controls-ts => component-ts}/lib/language.js (100%) rename samples/dialogs/{controls-ts => component-ts}/lib/language.js.map (96%) rename samples/dialogs/{controls-ts => component-ts}/package-lock.json (100%) rename samples/dialogs/{controls-ts => component-ts}/package.json (92%) rename samples/dialogs/{controls-ts => component-ts}/src/app.ts (95%) rename samples/dialogs/{controls-ts => component-ts}/src/language.ts (95%) rename samples/dialogs/{controls-ts => component-ts}/tsconfig.json (100%) diff --git a/libraries/botbuilder-dialogs/lib/dialogSet.js b/libraries/botbuilder-dialogs/lib/dialogSet.js index 83a4f3ff81..ac5b275ddd 100644 --- a/libraries/botbuilder-dialogs/lib/dialogSet.js +++ b/libraries/botbuilder-dialogs/lib/dialogSet.js @@ -104,10 +104,7 @@ class DialogSet { return this.dialogs[dialogId] = Array.isArray(dialogOrSteps) ? new dialog_1.Waterfall(dialogOrSteps) : dialogOrSteps; } createContext(context, state) { - if (!Array.isArray(state['dialogStack'])) { - state['dialogStack'] = []; - } - return new dialogContext_1.DialogContext(this, context, state['dialogStack']); + return new dialogContext_1.DialogContext(this, context, state); } /** * Finds a dialog that was previously added to the set using [add()](#add). diff --git a/libraries/botbuilder-dialogs/lib/dialogSet.js.map b/libraries/botbuilder-dialogs/lib/dialogSet.js.map index 72bbf88188..535dd86340 100644 --- a/libraries/botbuilder-dialogs/lib/dialogSet.js.map +++ b/libraries/botbuilder-dialogs/lib/dialogSet.js.map @@ -1 +1 @@ -{"version":3,"file":"dialogSet.js","sourceRoot":"","sources":["../src/dialogSet.ts"],"names":[],"mappings":";;AAQA,qCAA4D;AAC5D,mDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH;IAAA;QACqB,YAAO,GAAgC,EAAE,CAAC;IA4C/D,CAAC;IAxBU,GAAG,CAAC,QAAgB,EAAE,aAA2C;QACpE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAAC,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,kBAAkB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,CAAC,CAAA;QAAC,CAAC;QACtI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,kBAAS,CAAC,aAAoB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IACvH,CAAC;IAEM,aAAa,CAAC,OAAU,EAAE,KAAa;QAC1C,MAAM,CAAC,IAAI,6BAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACnD,CAAC;IAED;;;;;;;;;;OAUG;IACI,IAAI,CAAkC,QAAgB;QACzD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,CAAC;CACJ;AA5CD,8BA4CC"} \ No newline at end of file diff --git a/libraries/botbuilder-dialogs/src/dialogSet.ts b/libraries/botbuilder-dialogs/src/dialogSet.ts index 2a1ce1151c..38bbf1f74b 100644 --- a/libraries/botbuilder-dialogs/src/dialogSet.ts +++ b/libraries/botbuilder-dialogs/src/dialogSet.ts @@ -127,8 +127,7 @@ export class DialogSet { } public createContext(context: C, state: object): DialogContext { - if (!Array.isArray(state['dialogStack'])) { state['dialogStack'] = [] } - return new DialogContext(this, context, state['dialogStack']); + return new DialogContext(this, context, state); } /** diff --git a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js index a17cd27afc..80d941ab12 100644 --- a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js +++ b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js @@ -17,14 +17,14 @@ class AddAlarmDialog extends botbuilder_dialogs_1.DialogContainer { function (dc) { return __awaiter(this, void 0, void 0, function* () { // Initialize temp alarm and prompt for title - dc.currentDialog.state = {}; + dc.activeDialog.state = {}; yield dc.prompt('titlePrompt', `What would you like to call your alarm?`); }); }, function (dc, title) { return __awaiter(this, void 0, void 0, function* () { // Save alarm title and prompt for time - const alarm = dc.currentDialog.state; + const alarm = dc.activeDialog.state; alarm.title = title; yield dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); }); @@ -32,7 +32,7 @@ class AddAlarmDialog extends botbuilder_dialogs_1.DialogContainer { function (dc, time) { return __awaiter(this, void 0, void 0, function* () { // Save alarm time - const alarm = dc.currentDialog.state; + const alarm = dc.activeDialog.state; alarm.time = time.toISOString(); // Alarm completed so set alarm. const user = userState.get(dc.context); diff --git a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map index fca7aeef5c..c95123f369 100644 --- a/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map +++ b/samples/dialogs/alarmbot-ts/lib/addAlarmDialog.js.map @@ -1 +1 @@ -{"version":3,"file":"addAlarmDialog.js","sourceRoot":"","sources":["../src/addAlarmDialog.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2DAAiF;AAGjF,iCAAiC;AAEjC,oBAA4B,SAAQ,oCAAe;IAC/C,YAAY,SAAoB;QAC5B,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE;YACzB,UAAgB,EAAE;;oBACd,6CAA6C;oBAC7C,EAAE,CAAC,aAAa,CAAC,KAAK,GAAG,EAAW,CAAC;oBACrC,MAAM,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC,CAAC;gBAC9E,CAAC;aAAA;YACD,UAAgB,EAAE,EAAE,KAAa;;oBAC7B,uCAAuC;oBACvC,MAAM,KAAK,GAAG,EAAE,CAAC,aAAa,CAAC,KAAc,CAAC;oBAC9C,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;oBACpB,MAAM,EAAE,CAAC,MAAM,CAAC,YAA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/alarmbot-ts/lib/app.js +++ b/samples/dialogs/alarmbot-ts/lib/app.js @@ -56,7 +56,7 @@ server.post('/api/messages', (req, res) => { // Check for cancel } else if (utterance === 'cancel') { - if (dc.currentDialog) { + if (dc.activeDialog) { yield dc.context.sendActivity(`Ok... Cancelled.`); yield dc.endAll(); } diff --git a/samples/dialogs/alarmbot-ts/lib/app.js.map b/samples/dialogs/alarmbot-ts/lib/app.js.map index 70efe5e891..0b1e3070f1 100644 --- a/samples/dialogs/alarmbot-ts/lib/app.js.map +++ b/samples/dialogs/alarmbot-ts/lib/app.js.map @@ -1 +1 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuH;AACvH,2DAA+C;AAC/C,mCAAmC;AAEnC,gBAAgB;AAChB,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,iBAAiB;AACjB,MAAM,OAAO,GAAG,IAAI,gCAAmB,CAAE;IACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;CAClD,CAAC,CAAC;AAEH,uBAAuB;AACvB,MAAM,OAAO,GAAG,IAAI,0BAAa,EAAE,CAAC;AACpC,MAAM,UAAU,GAAG,IAAI,8BAAiB,CAAC,OAAO,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,CAAC;AACzC,OAAO,CAAC,GAAG,CAAC,IAAI,wBAAW,CAAC,UAAU,EAAE,SAAS,CA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C,MAAM,EAAE,CAAC;gBACtB,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;gBACxD,CAAC;YACL,CAAC;QACL,CAAC;QAED,sDAAsD;QACtD,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;YACrB,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;YACpB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;gBAClC,+BAA+B;gBAC/B,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,gFAAgF,CAAC,CAAA;YACnH,CAAC;QACL,CAAC;IACL,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,gBAAgB;AAEhB,qDAAkD;AAClD,2DAAwD;AACxD,yDAAsD;AAEtD,MAAM,OAAO,GAAG,IAAI,8BAAS,EAAE,CAAC;AAChC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,+BAAc,CAAC,SAAS,CAAC,CAAC,CAAC;AACvD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,qCAAiB,CAAC,SAAS,CAAC,CAAC,CAAC;AAC7D,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,mCAAgB,CAAC,SAAS,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts b/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts index b726f66b5c..85daa30e0d 100644 --- a/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts +++ b/samples/dialogs/alarmbot-ts/src/addAlarmDialog.ts @@ -10,18 +10,18 @@ export class AddAlarmDialog extends DialogContainer { this.dialogs.add('addAlarm', [ async function (dc) { // Initialize temp alarm and prompt for title - dc.currentDialog.state = {} as Alarm; + dc.activeDialog.state = {} as Alarm; await dc.prompt('titlePrompt', `What would you like to call your alarm?`); }, async function (dc, title: string) { // Save alarm title and prompt for time - const alarm = dc.currentDialog.state as Alarm; + const alarm = dc.activeDialog.state as Alarm; alarm.title = title; await dc.prompt('timePrompt', `What time would you like to set the "${alarm.title}" alarm for?`); }, async function (dc, time: Date) { // Save alarm time - const alarm = dc.currentDialog.state as Alarm; + const alarm = dc.activeDialog.state as Alarm; alarm.time = time.toISOString(); // Alarm completed so set alarm. diff --git a/samples/dialogs/alarmbot-ts/src/app.ts b/samples/dialogs/alarmbot-ts/src/app.ts index 5e469d345e..41e313acac 100644 --- a/samples/dialogs/alarmbot-ts/src/app.ts +++ b/samples/dialogs/alarmbot-ts/src/app.ts @@ -51,7 +51,7 @@ server.post('/api/messages', (req, res) => { // Check for cancel } else if (utterance === 'cancel') { - if (dc.currentDialog) { + if (dc.activeDialog) { await dc.context.sendActivity(`Ok... Cancelled.`); await dc.endAll(); } else { diff --git a/samples/dialogs/controls-ts/README.md b/samples/dialogs/component-ts/README.md similarity index 100% rename from samples/dialogs/controls-ts/README.md rename to samples/dialogs/component-ts/README.md diff --git a/samples/dialogs/controls-ts/lib/app.js b/samples/dialogs/component-ts/lib/app.js similarity index 95% rename from samples/dialogs/controls-ts/lib/app.js rename to samples/dialogs/component-ts/lib/app.js index 88b9b07e25..9776b87b34 100644 --- a/samples/dialogs/controls-ts/lib/app.js +++ b/samples/dialogs/component-ts/lib/app.js @@ -63,7 +63,7 @@ async function beginDialogDemo(context, state) { async function continueDialogDemo(context, state) { const dc = dialogs.createContext(context, state.demoState); await dc.continue(); - if (!dc.currentDialog) { + if (!dc.activeDialog) { state.demo = undefined; state.demoState = undefined; } @@ -91,11 +91,11 @@ async function beginTopicDemo(context, state) { await localePicker.begin(context, state.demoState); } async function continueTopicDemo(context, state) { - const result = await localePicker.continue(context, state.demoState); - if (!result.active) { + const completion = await localePicker.continue(context, state.demoState); + if (completion.isCompleted) { state.demo = undefined; state.demoState = undefined; - state.currentLocale = result.result; + state.currentLocale = completion.result; await context.sendActivity(`Switching locale to "${state.currentLocale}".`); } } diff --git a/samples/dialogs/controls-ts/lib/app.js.map b/samples/dialogs/component-ts/lib/app.js.map similarity index 86% rename from samples/dialogs/controls-ts/lib/app.js.map rename to samples/dialogs/component-ts/lib/app.js.map index 91e2bb2ce9..a6440b61f3 100644 --- a/samples/dialogs/controls-ts/lib/app.js.map +++ b/samples/dialogs/component-ts/lib/app.js.map @@ -1 +1 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;AAAA,2CAAgG;AAChG,2DAA+C;AAC/C,mCAAmC;AAEnC,gBAAgB;AAChB,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,iBAAiB;AACjB,MAAM,OAAO,GAAG,IAAI,gCAAmB,CAAE;IACrC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;CAClD,CAAC,CAAC;AAQH,MAAM,iBAAiB,GAAG,IAAI,8BAAiB,CAAY,IAAI,0BAAa,EAAE,CAAC,CAAC;AAChF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAE/B,gCAAgC;AAChC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACtC,OAAO,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChD,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,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AAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;QACzB,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QACvB,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC;QACxC,MAAM,OAAO,CAAC,YAAY,CAAC,wBAAwB,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC;IAChF,CAAC;AACL,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/controls-ts/lib/language.js b/samples/dialogs/component-ts/lib/language.js similarity index 100% rename from samples/dialogs/controls-ts/lib/language.js rename to samples/dialogs/component-ts/lib/language.js diff --git a/samples/dialogs/controls-ts/lib/language.js.map b/samples/dialogs/component-ts/lib/language.js.map similarity index 96% rename from samples/dialogs/controls-ts/lib/language.js.map rename to samples/dialogs/component-ts/lib/language.js.map index 046f8c49ff..4447fc7cf3 100644 --- a/samples/dialogs/controls-ts/lib/language.js.map +++ b/samples/dialogs/component-ts/lib/language.js.map @@ -1 +1 @@ -{"version":3,"file":"language.js","sourceRoot":"","sources":["../src/language.ts"],"names":[],"mappings":";;AAAA,2DAAyG;AAQzG,oBAA4B,SAAQ,oCAAuB;IACvD,YAAY,QAAiC;QACzC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACxB,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;YACrB,aAAa,EAAE,IAAI;YACnB,gBAAgB,EAAE,UAAU;SACL,EAAE,QAAQ,CAAC,CAAC;QAGvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE;YAC/B,KAAK,WAAW,EAAE;gBAEd,sDAAsD;gBACtD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAElF,0DAA0D;gBAC1D,EAAE,CAAC,CAA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AG,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5C,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,iCAAY,EAAE,CAAC,CAAC;IACzD,CAAC;CACJ;AAhCD,wCAgCC;AAED,MAAM,UAAU,GAAG,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAE,CAAC;AAEpD,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,iCAAiC;IACvC,IAAI,EAAE,qCAAqC;IAC3C,IAAI,EAAE,mCAAmC;IACzC,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,cAAc,GAAG;IACnB,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,KAAK;CACd,CAAC;AAEF,MAAM,cAAc,GAAG;IACnB,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,IAAI;IAChB,KAAK,EAAE,IAAI;CACd,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/controls-ts/package-lock.json b/samples/dialogs/component-ts/package-lock.json similarity index 100% rename from samples/dialogs/controls-ts/package-lock.json rename to samples/dialogs/component-ts/package-lock.json diff --git a/samples/dialogs/controls-ts/package.json b/samples/dialogs/component-ts/package.json similarity index 92% rename from samples/dialogs/controls-ts/package.json rename to samples/dialogs/component-ts/package.json index 3a374510ad..dde2a1a79d 100644 --- a/samples/dialogs/controls-ts/package.json +++ b/samples/dialogs/component-ts/package.json @@ -1,5 +1,5 @@ { - "name": "dialogs-controls-ts", + "name": "dialogs-component-ts", "version": "1.0.0", "description": "Bot Builder example showing how to build a reusable control using dialogs.", "main": "./lib/app.js", diff --git a/samples/dialogs/controls-ts/src/app.ts b/samples/dialogs/component-ts/src/app.ts similarity index 95% rename from samples/dialogs/controls-ts/src/app.ts rename to samples/dialogs/component-ts/src/app.ts index c9963afee6..64de621c96 100644 --- a/samples/dialogs/controls-ts/src/app.ts +++ b/samples/dialogs/component-ts/src/app.ts @@ -71,7 +71,7 @@ async function beginDialogDemo(context: TurnContext, state: DemoState) { async function continueDialogDemo(context: TurnContext, state: DemoState) { const dc = dialogs.createContext(context, state.demoState); await dc.continue(); - if (!dc.currentDialog) { + if (!dc.activeDialog) { state.demo = undefined; state.demoState = undefined; } @@ -109,11 +109,11 @@ async function beginTopicDemo(context: TurnContext, state: DemoState) { } async function continueTopicDemo(context: TurnContext, state: DemoState) { - const result = await localePicker.continue(context, state.demoState); - if (!result.active) { + const completion = await localePicker.continue(context, state.demoState); + if (completion.isCompleted) { state.demo = undefined; state.demoState = undefined; - state.currentLocale = result.result; + state.currentLocale = completion.result; await context.sendActivity(`Switching locale to "${state.currentLocale}".`); } } diff --git a/samples/dialogs/controls-ts/src/language.ts b/samples/dialogs/component-ts/src/language.ts similarity index 95% rename from samples/dialogs/controls-ts/src/language.ts rename to samples/dialogs/component-ts/src/language.ts index 3298897426..5b518c9064 100644 --- a/samples/dialogs/controls-ts/src/language.ts +++ b/samples/dialogs/component-ts/src/language.ts @@ -1,4 +1,4 @@ -import { DialogSet, DialogContainer, ChoicePrompt, DialogResult, FoundChoice } from 'botbuilder-dialogs'; +import { DialogSet, DialogContainer, ChoicePrompt, FoundChoice } from 'botbuilder-dialogs'; import { TurnContext } from 'botbuilder'; export interface LanguagePickerSettings { diff --git a/samples/dialogs/controls-ts/tsconfig.json b/samples/dialogs/component-ts/tsconfig.json similarity index 100% rename from samples/dialogs/controls-ts/tsconfig.json rename to samples/dialogs/component-ts/tsconfig.json diff --git a/samples/dialogs/list-ts/lib/listControl.js b/samples/dialogs/list-ts/lib/listControl.js index 562934fa8d..94e1e4e343 100644 --- a/samples/dialogs/list-ts/lib/listControl.js +++ b/samples/dialogs/list-ts/lib/listControl.js @@ -10,7 +10,7 @@ class ListControl extends botbuilder_dialogs_1.Dialog { this.actions = actions || [{ type: 'imBack', title: 'Show More', value: 'more' }]; } dialogBegin(dc, args) { - dc.currentDialog.state = Object.assign({}, args); + dc.activeDialog.state = Object.assign({}, args); return this.showMore(dc); } dialogContinue(dc) { @@ -26,13 +26,13 @@ class ListControl extends botbuilder_dialogs_1.Dialog { return this.showMore(dc); } else { - const state = dc.currentDialog.state; + const state = dc.activeDialog.state; return dc.end({ action: action, continueToken: state.continueToken }); } } showMore(dc) { try { - const state = dc.currentDialog.state; + const state = dc.activeDialog.state; return Promise.resolve(this.pager(dc, state.filter, state.continueToken)).then((result) => { if (result.continueToken) { // Save continuation token diff --git a/samples/dialogs/list-ts/src/listControl.ts b/samples/dialogs/list-ts/src/listControl.ts index 3e86c589fe..6869c2bffa 100644 --- a/samples/dialogs/list-ts/src/listControl.ts +++ b/samples/dialogs/list-ts/src/listControl.ts @@ -29,7 +29,7 @@ export class ListControl extends Dialog, args?: ListControlOptions): Promise { - dc.currentDialog.state = Object.assign({}, args); + dc.activeDialog.state = Object.assign({}, args); return this.showMore(dc); } @@ -46,14 +46,14 @@ export class ListControl extends Dialog): Promise { try { - const state = dc.currentDialog.state as ListControlOptions; + const state = dc.activeDialog.state as ListControlOptions; return Promise.resolve(this.pager(dc, state.filter, state.continueToken)).then((result) => { if (result.continueToken) { // Save continuation token diff --git a/samples/dialogs/prompts-ts/lib/app.js b/samples/dialogs/prompts-ts/lib/app.js index 79f3e9c4b8..0714be1174 100644 --- a/samples/dialogs/prompts-ts/lib/app.js +++ b/samples/dialogs/prompts-ts/lib/app.js @@ -92,13 +92,13 @@ dialogs.add('mainMenu', [ dialogs.add('loop', [ function (dc, args) { return __awaiter(this, void 0, void 0, function* () { - dc.currentDialog.state = args; + dc.activeDialog.state = args; yield dc.begin(args.dialogId); }); }, function (dc) { return __awaiter(this, void 0, void 0, function* () { - const args = dc.currentDialog.state; + const args = dc.activeDialog.state; yield dc.replace('loop', args); }); } diff --git a/samples/dialogs/prompts-ts/lib/app.js.map b/samples/dialogs/prompts-ts/lib/app.js.map index 6c8b63ef22..a95f03cac1 100644 --- a/samples/dialogs/prompts-ts/lib/app.js.map +++ b/samples/dialogs/prompts-ts/lib/app.js.map @@ -1 +1 @@ -{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAGoB;AACpB,2DAG4B;AAC5B,mCAAmC;AAEnC,gBAAgB;AAChB,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,EAAE;IACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,iBAAiB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,iBAAiB;AACjB,MAAM,OAAO,GAAG,IAAI,gCAAmB,CAAC;IACpC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;IACnC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;CAClD,CAAC,CAAC;AAEH,oCAAoC;AACpC,MAAM,iBAAiB,GAAG,IAAI,8BAAiB,CAAC,IAAI,0BAAa,EAAE,CAAC,CAAC;AACrE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAE/B,gCAAgC;AAChC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACtC,mDAAmD;IACnD,OAAO,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,CAAO,OAAO,EAAE,EAAE;QAChD,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,I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Ae,EAAE;;YACb,MAAM,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE,6BAA6B,CAAC,CAAC;QACvE,CAAC;KAAA;IACD,UAAe,EAAE,EAAE,MAAoB;;YACnC,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,2BAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC;YAC1G,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;KAAA;CACJ,CAAC,CAAC"} \ No newline at end of file diff --git a/samples/dialogs/prompts-ts/src/app.ts b/samples/dialogs/prompts-ts/src/app.ts index ad0b7f3ff7..c238818c8f 100644 --- a/samples/dialogs/prompts-ts/src/app.ts +++ b/samples/dialogs/prompts-ts/src/app.ts @@ -95,11 +95,11 @@ dialogs.add('mainMenu', [ dialogs.add('loop', [ async function(dc, args: { dialogId: string; }) { - dc.currentDialog.state = args; + dc.activeDialog.state = args; await dc.begin(args.dialogId); }, async function(dc) { - const args = dc.currentDialog.state; + const args = dc.activeDialog.state; await dc.replace('loop', args); } ]); From eda9660559dde0848f10dca0035d46704b6367f2 Mon Sep 17 00:00:00 2001 From: Steven Ickman Date: Fri, 27 Apr 2018 16:52:38 -0700 Subject: [PATCH 8/8] published new bits --- libraries/botbuilder-ai/package.json | 6 +++--- libraries/botbuilder-azure/package.json | 4 ++-- libraries/botbuilder-choices/package.json | 4 ++-- libraries/botbuilder-core-extensions/package.json | 4 ++-- libraries/botbuilder-core/package.json | 4 ++-- libraries/botbuilder-dialogs/package.json | 6 +++--- libraries/botbuilder-prompts/package.json | 6 +++--- libraries/botbuilder/package.json | 8 ++++---- libraries/botframework-connector/package.json | 4 ++-- libraries/botframework-luis/package.json | 2 +- libraries/botframework-schema/package.json | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libraries/botbuilder-ai/package.json b/libraries/botbuilder-ai/package.json index c374651650..f6563267d6 100644 --- a/libraries/botbuilder-ai/package.json +++ b/libraries/botbuilder-ai/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-ai", "author": "Microsoft Corp.", "description": "Cognitive services extensions for Microsoft BotBuilder.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -24,8 +24,8 @@ "@types/node": "^9.3.0", "@types/request-promise-native": "^1.0.10", "@types/xmldom": "^0.1.29", - "botbuilder": "4.0.0-m4.0", - "botframework-luis": "4.0.0-m4.0", + "botbuilder": "4.0.0-m4.1", + "botframework-luis": "4.0.0-m4.1", "html-entities": "^1.2.1", "mstranslator": "^3.0.0", "request": "2.83.0", diff --git a/libraries/botbuilder-azure/package.json b/libraries/botbuilder-azure/package.json index 63ea3a3222..57a64e1d97 100644 --- a/libraries/botbuilder-azure/package.json +++ b/libraries/botbuilder-azure/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-azure", "author": "Microsoft Corp.", "description": "Azure extensions for Microsoft BotBuilder.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -23,7 +23,7 @@ "dependencies": { "@types/node": "^9.3.0", "azure-storage": "^2.3.0", - "botbuilder": "4.0.0-m4.0", + "botbuilder": "4.0.0-m4.1", "documentdb": "^1.14.2", "flat": "^4.0.0" }, diff --git a/libraries/botbuilder-choices/package.json b/libraries/botbuilder-choices/package.json index ca1ebea115..70378077c6 100644 --- a/libraries/botbuilder-choices/package.json +++ b/libraries/botbuilder-choices/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-choices", "author": "Microsoft Corp.", "description": "Microsoft BotBuilder tools for working with choices.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -21,7 +21,7 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botbuilder": "4.0.0-m4.0", + "botbuilder": "4.0.0-m4.1", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder-core-extensions/package.json b/libraries/botbuilder-core-extensions/package.json index d46a1832ee..2e7b9554d1 100644 --- a/libraries/botbuilder-core-extensions/package.json +++ b/libraries/botbuilder-core-extensions/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-core-extensions", "author": "Microsoft Corp.", "description": "Common middleware and related abstractions for the Bot Builder core library.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -23,7 +23,7 @@ "@types/node": "^9.3.0", "assert": "^1.4.1", "async-file": "^2.0.2", - "botbuilder-core": "4.0.0-m4.0", + "botbuilder-core": "4.0.0-m4.1", "filenamify": "^2.0.0", "rimraf": "^2.6.2" }, diff --git a/libraries/botbuilder-core/package.json b/libraries/botbuilder-core/package.json index 5d10350a6e..dc603854af 100644 --- a/libraries/botbuilder-core/package.json +++ b/libraries/botbuilder-core/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-core", "author": "Microsoft Corp.", "description": "Bot Builder core library. Bot Builder is a toolkit for building rich bots on virtually any platform.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -21,7 +21,7 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botframework-schema": "4.0.0-m4.0", + "botframework-schema": "4.0.0-m4.1", "assert": "^1.4.1" }, "devDependencies": { diff --git a/libraries/botbuilder-dialogs/package.json b/libraries/botbuilder-dialogs/package.json index d645dfc0ac..a48600cd98 100644 --- a/libraries/botbuilder-dialogs/package.json +++ b/libraries/botbuilder-dialogs/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-dialogs", "author": "Microsoft Corp.", "description": "A dialog stack based conversation manager for Microsoft Bot Builder.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -21,8 +21,8 @@ "typings": "./lib/index.d.ts", "dependencies": { "@types/node": "^9.3.0", - "botbuilder": "4.0.0-m4.0", - "botbuilder-prompts": "4.0.0-m4.0", + "botbuilder": "4.0.0-m4.1", + "botbuilder-prompts": "4.0.0-m4.1", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder-prompts/package.json b/libraries/botbuilder-prompts/package.json index 8092b4092e..3a5b344b80 100644 --- a/libraries/botbuilder-prompts/package.json +++ b/libraries/botbuilder-prompts/package.json @@ -2,7 +2,7 @@ "name": "botbuilder-prompts", "author": "stevenic@microsoft.com", "description": "Lightweight prompt system for Bot Builder v4.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -18,8 +18,8 @@ "main": "./lib/index.js", "typings": "./lib/index.d.ts", "dependencies": { - "botbuilder": "4.0.0-m4.0", - "botbuilder-choices": "4.0.0-m4.0", + "botbuilder": "4.0.0-m4.1", + "botbuilder-choices": "4.0.0-m4.1", "@microsoft/recognizers-text-suite": "^1.0.0" }, "devDependencies": { diff --git a/libraries/botbuilder/package.json b/libraries/botbuilder/package.json index e685b9b0f1..9b4dbc2a8d 100644 --- a/libraries/botbuilder/package.json +++ b/libraries/botbuilder/package.json @@ -2,7 +2,7 @@ "name": "botbuilder", "author": "Microsoft Corp.", "description": "Services for Microsoft BotBuilder.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botbuilder", @@ -23,9 +23,9 @@ "@types/node": "^9.3.0", "@types/filenamify": "^2.0.1", "async-file": "^2.0.2", - "botbuilder-core": "4.0.0-m4.0", - "botbuilder-core-extensions": "4.0.0-m4.0", - "botframework-connector": "4.0.0-m4.0", + "botbuilder-core": "4.0.0-m4.1", + "botbuilder-core-extensions": "4.0.0-m4.1", + "botframework-connector": "4.0.0-m4.1", "filenamify": "^2.0.0", "readline": "^1.3.0" }, diff --git a/libraries/botframework-connector/package.json b/libraries/botframework-connector/package.json index 82c4f959a2..33418af53c 100644 --- a/libraries/botframework-connector/package.json +++ b/libraries/botframework-connector/package.json @@ -2,7 +2,7 @@ "name": "botframework-connector", "author": "Microsoft Corp.", "description": "Bot Connector is autorest generated connector client.", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "botconnector", @@ -23,7 +23,7 @@ "@types/request": "^2.47.0", "@types/node": "^9.3.0", "base64url": "^2.0.0", - "botframework-schema": "4.0.0-m4.0", + "botframework-schema": "4.0.0-m4.1", "jsonwebtoken": "8.0.1", "ms-rest-js": "^0.2.5", "request": "2.83.0", diff --git a/libraries/botframework-luis/package.json b/libraries/botframework-luis/package.json index af0ab90782..bf72355cf9 100644 --- a/libraries/botframework-luis/package.json +++ b/libraries/botframework-luis/package.json @@ -2,7 +2,7 @@ "name": "botframework-luis", "author": "Microsoft Corp.", "description": "Luis client package for Luis query API", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "license": "MIT", "keywords": [ "luis" diff --git a/libraries/botframework-schema/package.json b/libraries/botframework-schema/package.json index 3d54d00bce..a066f9da10 100644 --- a/libraries/botframework-schema/package.json +++ b/libraries/botframework-schema/package.json @@ -1,6 +1,6 @@ { "name": "botframework-schema", - "version": "4.0.0-m4.0", + "version": "4.0.0-m4.1", "keywords": [ "botconnector", "bots",