From 377cc89cbcf6917d1625b73db510b8f35b1169b6 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Tue, 2 Oct 2018 14:41:05 -0500 Subject: [PATCH 1/2] automatic fixes from tslint --- libraries/botbuilder-azure/src/blobStorage.ts | 2 +- .../src/autoSaveStateMiddleware.ts | 18 ++-- libraries/botbuilder-core/src/botAdapter.ts | 20 ++--- libraries/botbuilder-core/src/botState.ts | 24 ++--- .../src/botStatePropertyAccessor.ts | 30 +++---- libraries/botbuilder-core/src/botStateSet.ts | 10 +-- libraries/botbuilder-core/src/cardFactory.ts | 24 ++--- libraries/botbuilder-core/src/index.ts | 1 - .../botbuilder-core/src/memoryStorage.ts | 2 +- .../src/memoryTranscriptStore.ts | 4 +- .../botbuilder-core/src/messageFactory.ts | 2 +- .../botbuilder-core/src/middlewareSet.ts | 10 +-- .../botbuilder-core/src/propertyManager.ts | 6 +- .../botbuilder-core/src/recognizerResult.ts | 2 +- libraries/botbuilder-core/src/testAdapter.ts | 4 +- libraries/botbuilder-core/src/turnContext.ts | 4 +- .../botbuilder-dialogs/src/componentDialog.ts | 60 ++++++------- libraries/botbuilder-dialogs/src/dialog.ts | 36 ++++---- .../botbuilder-dialogs/src/dialogContext.ts | 36 ++++---- libraries/botbuilder-dialogs/src/dialogSet.ts | 38 ++++---- .../src/prompts/activityPrompt.ts | 4 +- .../src/prompts/choicePrompt.ts | 28 +++--- .../src/prompts/confirmPrompt.ts | 31 ++++--- .../src/prompts/datetimePrompt.ts | 10 +-- .../src/prompts/numberPrompt.ts | 10 +-- .../src/prompts/oauthPrompt.ts | 6 +- .../botbuilder-dialogs/src/prompts/prompt.ts | 22 ++--- .../botbuilder-dialogs/src/waterfallDialog.ts | 44 ++++----- .../src/waterfallStepContext.ts | 14 +-- .../botbuilder/src/botFrameworkAdapter.ts | 2 +- .../src/botConfiguration.ts | 90 +++++++++---------- .../src/botConfigurationBase.ts | 7 +- .../botframework-config/src/botRecipe.ts | 8 +- libraries/botframework-config/src/encrypt.ts | 4 +- libraries/botframework-config/src/index.ts | 1 - .../src/models/azureService.ts | 6 +- .../src/models/connectedService.ts | 2 +- .../src/models/cosmosDbService.ts | 2 +- .../src/models/luisService.ts | 2 +- libraries/botframework-config/src/schema.ts | 24 ++--- libraries/botframework-config/src/utils.ts | 2 +- .../src/auth/channelValidation.ts | 4 +- .../src/auth/enterpriseChannelValidation.ts | 2 +- .../src/auth/governmentChannelValidation.ts | 6 +- .../src/auth/jwtTokenValidation.ts | 6 +- .../src/oAuthApiClient.ts | 2 +- 46 files changed, 332 insertions(+), 340 deletions(-) diff --git a/libraries/botbuilder-azure/src/blobStorage.ts b/libraries/botbuilder-azure/src/blobStorage.ts index 10d4968d41..feddcf0d59 100644 --- a/libraries/botbuilder-azure/src/blobStorage.ts +++ b/libraries/botbuilder-azure/src/blobStorage.ts @@ -36,7 +36,7 @@ export interface BlobStorageSettings { */ storageAccountOrConnectionString: string; - /** + /** * The storage access key. */ storageAccessKey?: string; diff --git a/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts b/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts index 063ecdc123..042389672b 100644 --- a/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts +++ b/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts @@ -14,11 +14,11 @@ import { TurnContext } from './turnContext'; * Middleware that will automatically save any state changes at the end of the turn. * * @remarks - * The `AutoSaveStateMiddleware` class should be added towards the top of your bot's middleware - * stack, before any other components that use state. Any `BotState` plugins passed to the + * The `AutoSaveStateMiddleware` class should be added towards the top of your bot's middleware + * stack, before any other components that use state. Any `BotState` plugins passed to the * constructor will have their `BotState.saveChanges()` method called upon successful completion - * of the turn. - * + * of the turn. + * * This example shows boilerplate code for reading and writing conversation and user state within * a bot: * @@ -44,6 +44,11 @@ import { TurnContext } from './turnContext'; * ``` */ export class AutoSaveStateMiddleware implements Middleware { + + /** + * Set of `BotState` plugins being automatically saved. + */ + public botStateSet: BotStateSet; /** * Creates a new AutoSaveStateiMiddleware instance. * @param botStates One or more BotState plugins to automatically save at the end of the turn. @@ -53,11 +58,6 @@ export class AutoSaveStateMiddleware implements Middleware { BotStateSet.prototype.add.apply(this.botStateSet, botStates); } - /** - * Set of `BotState` plugins being automatically saved. - */ - public botStateSet: BotStateSet; - public async onTurn(context: TurnContext, next: () => Promise): Promise { await next(); await this.botStateSet.saveAllChanges(context, true); diff --git a/libraries/botbuilder-core/src/botAdapter.ts b/libraries/botbuilder-core/src/botAdapter.ts index 4821715642..90ab6a6f98 100644 --- a/libraries/botbuilder-core/src/botAdapter.ts +++ b/libraries/botbuilder-core/src/botAdapter.ts @@ -12,9 +12,9 @@ import { TurnContext } from './turnContext'; /** * Abstract base class for all adapter plugins. - * + * * @remarks - * Adapters manage the communication between the bot and a user over a specific channel, or set + * Adapters manage the communication between the bot and a user over a specific channel, or set * of channels. */ export abstract class BotAdapter { @@ -22,8 +22,8 @@ export abstract class BotAdapter { private turnError: (context: TurnContext, error: Error) => Promise; /** - * Sends a set of activities to the user. - * + * Sends a set of activities to the user. + * * @remarks * An array of responses from the server will be returned. * @param context Context for the current turn of conversation with the user. @@ -79,14 +79,14 @@ export abstract class BotAdapter { /** * Executes the adapters middleware chain. - * + * * @remarks - * This should be be called by the parent class to run the adapters middleware chain. The + * This should be be called by the parent class to run the adapters middleware chain. The * `next()` handler passed to the method will be called at the end of the chain. - * - * While the context object is passed in from the caller is created by the caller, what gets - * passed to the `next()` handler is a wrapped version of the context which will automatically - * be revoked upon completion of the turn. This causes the bots logic to throw an error if it + * + * While the context object is passed in from the caller is created by the caller, what gets + * passed to the `next()` handler is a wrapped version of the context which will automatically + * be revoked upon completion of the turn. This causes the bots logic to throw an error if it * tries to use the context object after the turn completes. * @param context Context for the current turn of conversation with the user. * @param next Function to call at the end of the middleware chain. diff --git a/libraries/botbuilder-core/src/botState.ts b/libraries/botbuilder-core/src/botState.ts index d62f1b2960..7f4200268d 100644 --- a/libraries/botbuilder-core/src/botState.ts +++ b/libraries/botbuilder-core/src/botState.ts @@ -29,14 +29,19 @@ export interface CachedBotState { * Base class for the frameworks state persistance scopes. * * @remarks - * This class will read and write state, to a provided storage provider, for each turn of - * conversation with a user. Derived classes, like `ConversationState` and `UserState`, provide a + * This class will read and write state, to a provided storage provider, for each turn of + * conversation with a user. Derived classes, like `ConversationState` and `UserState`, provide a * `StorageKeyFactory` which is used to determine the key used to persist a given storage object. - * - * The state object thats loaded will be automatically cached on the context object for the + * + * The state object thats loaded will be automatically cached on the context object for the * lifetime of the turn and will only be written to storage if it has been modified. */ export class BotState implements PropertyManager { + + /** + * Collection of state property accessors added through [createProperty()](#createproperty). + */ + public readonly properties: Map = new Map(); private stateKey: symbol = Symbol('state'); /** @@ -47,12 +52,7 @@ export class BotState implements PropertyManager { constructor(protected storage: Storage, protected storageKey: StorageKeyFactory) { } /** - * Collection of state property accessors added through [createProperty()](#createproperty). - */ - public readonly properties: Map = new Map(); - - /** - * Creates a new property accessor for reading and writing an individual property to the bot + * Creates a new property accessor for reading and writing an individual property to the bot * states storage object. * @param T (Optional) type of property to create. Defaults to `any` type. * @param name Name of the property to add. Must be unique within the set. @@ -71,7 +71,7 @@ export class BotState implements PropertyManager { * @remarks * Subsequent reads will return the cached object unless the `force` flag is passed in which * will force the state object to be re-read. - * + * * This method is automatically called on first access of any of created property accessors. * * ```JavaScript @@ -135,7 +135,7 @@ export class BotState implements PropertyManager { * Clears the current state object for a turn. * * @remarks - * The cleared state object will not be persisted until [saveChanges()](#savechanges) has + * The cleared state object will not be persisted until [saveChanges()](#savechanges) has * been called. * * ```JavaScript diff --git a/libraries/botbuilder-core/src/botStatePropertyAccessor.ts b/libraries/botbuilder-core/src/botStatePropertyAccessor.ts index bf7e303a3c..4a61ad64fa 100644 --- a/libraries/botbuilder-core/src/botStatePropertyAccessor.ts +++ b/libraries/botbuilder-core/src/botStatePropertyAccessor.ts @@ -9,17 +9,17 @@ import { BotState } from './botState'; import { TurnContext } from './turnContext'; /** - * An interface components can use to read and write individual properties to the bot's state + * An interface components can use to read and write individual properties to the bot's state * management system. * @param T (Optional) type of property being persisted. Defaults to `any` type. */ export interface StatePropertyAccessor { /** * Deletes the persisted property from its backing storage object. - * + * * @remarks - * The properties backing storage object SHOULD be loaded into memory on first access. - * + * The properties backing storage object SHOULD be loaded into memory on first access. + * * ```JavaScript * await myProperty.delete(context); * ``` @@ -29,31 +29,31 @@ export interface StatePropertyAccessor { /** * Reads a persisted property from its backing storage object. - * + * * @remarks - * The properties backing storage object SHOULD be loaded into memory on first access. - * + * The properties backing storage object SHOULD be loaded into memory on first access. + * * If the property does not currently exist on the storage object and a `defaultValue` has been * specified, a clone of the `defaultValue` SHOULD be copied to the storage object. If a * `defaultValue` has not been specified then a value of `undefined` SHOULD be returned. - * + * * ```JavaScript * const value = await myProperty.get(context, { count: 0 }); * ``` * @param context Context for the current turn of conversation with the user. - * @param defaultValue (Optional) default value to copy to the backing storage object if the property isn't found. + * @param defaultValue (Optional) default value to copy to the backing storage object if the property isn't found. */ get(context: TurnContext, defaultValue?: T): Promise; /** * Assigns a new value to the properties backing storage object. - * + * * @remarks * The properties backing storage object SHOULD be loaded into memory on first access. - * - * Depending on the state systems implementation, an additional step may be required to + * + * Depending on the state systems implementation, an additional step may be required to * persist the actual changes to disk. - * + * * ```JavaScript * await myProperty.set(context, value); * ``` @@ -65,10 +65,10 @@ export interface StatePropertyAccessor { /** * A `BotState` specific implementation of the `StatePropertyAccessor` interface. - * + * * @remarks * Properties can be defined for a given `BotState` instance using `createProperty()`. - * + * * ```JavaScript * const dialogStateProperty = ConversationState.createProperty('dialogState'); * const dialogs = new DialogSet(dialogStateProperty); diff --git a/libraries/botbuilder-core/src/botStateSet.ts b/libraries/botbuilder-core/src/botStateSet.ts index 2f670c115e..56498b9b36 100644 --- a/libraries/botbuilder-core/src/botStateSet.ts +++ b/libraries/botbuilder-core/src/botStateSet.ts @@ -14,6 +14,11 @@ import { TurnContext } from './turnContext'; */ export class BotStateSet { + /** + * Array of the sets `BotState` plugins. + */ + public readonly botStates: BotState[] = []; + /** * Creates a new BotStateSet instance. * @param botStates One or more BotState plugins to register. @@ -22,11 +27,6 @@ export class BotStateSet { BotStateSet.prototype.add.apply(this, botStates); } - /** - * Array of the sets `BotState` plugins. - */ - public readonly botStates: BotState[] = []; - /** * Registers One or more `BotState` plugins with the set. * @param botStates One or more BotState plugins to register. diff --git a/libraries/botbuilder-core/src/cardFactory.ts b/libraries/botbuilder-core/src/cardFactory.ts index 9fabe7b7f8..e1b3b08852 100644 --- a/libraries/botbuilder-core/src/cardFactory.ts +++ b/libraries/botbuilder-core/src/cardFactory.ts @@ -28,12 +28,12 @@ import { * @remarks * All of these functions return an `Attachment` which can be added to an `Activity` directly or * passed as input to a `MessageFactory` method. - * + * * The following example shows sending a message containing a single hero card: - * + * * ```javascript * const { MessageFactory, CardFactory } = require('botbuilder'); - * + * * const card = CardFactory.heroCard( * 'White T-Shirt', * ['https://example.com/whiteShirt.jpg'], @@ -60,7 +60,7 @@ export class CardFactory { }; /** - * Returns an attachment for an adaptive card. + * Returns an attachment for an adaptive card. * * @remarks * Adaptive Cards are a new way for bots to send interactive and immersive card content to @@ -204,9 +204,9 @@ export class CardFactory { /** * Returns an attachment for a signin card. - * + * * @remarks - * For channels that don't natively support signin cards an alternative message will be + * For channels that don't natively support signin cards an alternative message will be * rendered. * @param title Title of the cards signin button. * @param url The link to the signin page the user needs to visit. @@ -220,12 +220,12 @@ export class CardFactory { } /** - * Returns an attachment for a thumbnail card. - * + * Returns an attachment for a thumbnail card. + * * @remarks * Thumbnail cards are similar to [hero cards](#herocard) but instead of a full width image, - * they're typically rendered with a smaller thumbnail version of the image on either side - * and the text will be rendered in column next to the image. Any buttons will typically + * they're typically rendered with a smaller thumbnail version of the image on either side + * and the text will be rendered in column next to the image. Any buttons will typically * show up under the card. * @param title The cards title. * @param text (Optional) text field for the card. @@ -286,9 +286,9 @@ export class CardFactory { /** * Returns a properly formatted array of actions. - * + * * @remarks - * Supports converting strings to `messageBack` actions (note: using 'imBack' for now as + * Supports converting strings to `messageBack` actions (note: using 'imBack' for now as * 'messageBack' doesn't work properly in emulator.) * @param actions Array of card actions or strings. Strings will be converted to `messageBack` actions. */ diff --git a/libraries/botbuilder-core/src/index.ts b/libraries/botbuilder-core/src/index.ts index 716fece3b6..b538b0972c 100644 --- a/libraries/botbuilder-core/src/index.ts +++ b/libraries/botbuilder-core/src/index.ts @@ -27,4 +27,3 @@ export * from './testAdapter'; export * from './transcriptLogger'; export * from './turnContext'; export * from './userState'; - diff --git a/libraries/botbuilder-core/src/memoryStorage.ts b/libraries/botbuilder-core/src/memoryStorage.ts index 7a78449cfb..978892bc72 100644 --- a/libraries/botbuilder-core/src/memoryStorage.ts +++ b/libraries/botbuilder-core/src/memoryStorage.ts @@ -18,7 +18,7 @@ import { Storage, StoreItems } from './storage'; * - Anything written to the store will be forgotten when the process exits. * - Objects that are read and written to the store are cloned to properly simulate network based * storage providers. - * - Cloned objects are serialized using `JSON.stringify()` to catch any possible serialization + * - Cloned objects are serialized using `JSON.stringify()` to catch any possible serialization * related issues that might occur when using a network based storage provider. * * ```JavaScript diff --git a/libraries/botbuilder-core/src/memoryTranscriptStore.ts b/libraries/botbuilder-core/src/memoryTranscriptStore.ts index 7f8523401f..7c4f7508f1 100644 --- a/libraries/botbuilder-core/src/memoryTranscriptStore.ts +++ b/libraries/botbuilder-core/src/memoryTranscriptStore.ts @@ -11,9 +11,9 @@ import { PagedResult, TranscriptInfo, TranscriptStore } from './transcriptLogger /** * The memory transcript store stores transcripts in volatile memory in a Map. - * + * * @remarks - * Because this uses an unbounded volatile dictionary this should only be used for unit tests or + * Because this uses an unbounded volatile dictionary this should only be used for unit tests or * non-production environments. */ export class MemoryTranscriptStore implements TranscriptStore { diff --git a/libraries/botbuilder-core/src/messageFactory.ts b/libraries/botbuilder-core/src/messageFactory.ts index db38857fcb..b21ca1afa7 100644 --- a/libraries/botbuilder-core/src/messageFactory.ts +++ b/libraries/botbuilder-core/src/messageFactory.ts @@ -17,7 +17,7 @@ import { CardFactory } from './cardFactory'; * * ```javascript * const { MessageFactory, CardFactory } = require('botbuilder'); - * + * * const card = CardFactory.heroCard( * 'White T-Shirt', * ['https://example.com/whiteShirt.jpg'], diff --git a/libraries/botbuilder-core/src/middlewareSet.ts b/libraries/botbuilder-core/src/middlewareSet.ts index dea5e7a87a..f005e28895 100644 --- a/libraries/botbuilder-core/src/middlewareSet.ts +++ b/libraries/botbuilder-core/src/middlewareSet.ts @@ -13,16 +13,16 @@ import { TurnContext } from './turnContext'; export interface Middleware { /** * Called each time the bot receives a new request. - * + * * @remarks - * Calling `await next();` will cause execution to continue to either the next piece of + * Calling `await next();` will cause execution to continue to either the next piece of * middleware in the chain or the bots main logic if you are the last piece of middleware. - * + * * Your middleware should perform its business logic before and/or after the call to `next()`. * You can short-circuit further execution of the turn by omitting the call to `next()`. - * + * * The following example shows a simple piece of logging middleware: - * + * * ```JavaScript * class MyLogger { * async onTurn(context, next) { diff --git a/libraries/botbuilder-core/src/propertyManager.ts b/libraries/botbuilder-core/src/propertyManager.ts index 25656bd63a..6c89021a11 100644 --- a/libraries/botbuilder-core/src/propertyManager.ts +++ b/libraries/botbuilder-core/src/propertyManager.ts @@ -5,17 +5,17 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { StatePropertyAccessor } from "./botStatePropertyAccessor"; +import { StatePropertyAccessor } from './botStatePropertyAccessor'; /** * Interface implemented by classes capable of factoring property accessors. */ export interface PropertyManager { /** - * Creates a new property accessor for reading and writing an individual property to the bots + * Creates a new property accessor for reading and writing an individual property to the bots * state management system. * @param T (Optional) type of property to create. Defaults to `any` type. * @param name Name of the property being created. */ createProperty(name: string): StatePropertyAccessor; -} \ No newline at end of file +} diff --git a/libraries/botbuilder-core/src/recognizerResult.ts b/libraries/botbuilder-core/src/recognizerResult.ts index a9d5bb4da2..187c91192b 100644 --- a/libraries/botbuilder-core/src/recognizerResult.ts +++ b/libraries/botbuilder-core/src/recognizerResult.ts @@ -22,7 +22,7 @@ export interface RecognizerResult { /** * Intents recognized for the utterance. - * + * * @remarks * A map of intent names to an object with score is returned. */ diff --git a/libraries/botbuilder-core/src/testAdapter.ts b/libraries/botbuilder-core/src/testAdapter.ts index 5a64b11768..906e6726b6 100644 --- a/libraries/botbuilder-core/src/testAdapter.ts +++ b/libraries/botbuilder-core/src/testAdapter.ts @@ -235,9 +235,9 @@ export class TestAdapter extends BotAdapter { /** * Test a list of activities. - * + * * @remarks - * Each activity with the "bot" role will be processed with assertReply() and every other + * Each activity with the "bot" role will be processed with assertReply() and every other * activity will be processed as a user message with send(). * @param activities Array of activities. * @param description (Optional) Description of the test case. If not provided one will be generated. diff --git a/libraries/botbuilder-core/src/turnContext.ts b/libraries/botbuilder-core/src/turnContext.ts index 6d82bbe3a0..a9b8d78393 100644 --- a/libraries/botbuilder-core/src/turnContext.ts +++ b/libraries/botbuilder-core/src/turnContext.ts @@ -326,8 +326,8 @@ export class TurnContext { /** * Called when this TurnContext instance is passed into the constructor of a new TurnContext - * instance. - * + * instance. + * * @remarks * Can be overridden in derived classes to add additional fields that should be cloned. * @param context The context object to copy private members to. Everything should be copied by reference. diff --git a/libraries/botbuilder-dialogs/src/componentDialog.ts b/libraries/botbuilder-dialogs/src/componentDialog.ts index bb0850baae..5f8c3858bc 100644 --- a/libraries/botbuilder-dialogs/src/componentDialog.ts +++ b/libraries/botbuilder-dialogs/src/componentDialog.ts @@ -14,22 +14,22 @@ const PERSISTED_DIALOG_STATE: string = 'dialogs'; /** * Base class for a dialog that contains other child dialogs. - * + * * @remarks * Component dialogs let you break your bot's logic up into components that can themselves be added * as a dialog to another `ComponentDialog` or `DialogSet`. Components can also be exported as part - * of a node package and used within other bots. - * - * To define a new component derive a class from ComponentDialog and add your child dialogs within + * of a node package and used within other bots. + * + * To define a new component derive a class from ComponentDialog and add your child dialogs within * the classes constructor: - * + * * ```JavaScript * const { ComponentDialog, WaterfallDialog, TextPrompt, NumberPrompt } = require('botbuilder-dialogs); - * + * * class FillProfileDialog extends ComponentDialog { * constructor(dialogId) { * super(dialogId); - * + * * // Add control flow dialogs * this.addDialog(new WaterfallDialog('start', [ * async (step) => { @@ -39,19 +39,19 @@ const PERSISTED_DIALOG_STATE: string = 'dialogs'; * async (step) => { * // Remember the users answer * step.values['name'] = step.result; - * + * * // Ask user their age. * return await step.prompt('agePrompt', `Hi ${step.values['name']}. How old are you?`); * }, * async (step) => { * // Remember the users answer * step.values['age'] = step.result; - * + * * // End the component and return the completed profile. * return await step.endDialog(step.values); * } * ])); - * + * * // Add prompts * this.addDialog(new TextPrompt('namePrompt')); * this.addDialog(new NumberPrompt('agePrompt')) @@ -59,9 +59,9 @@ const PERSISTED_DIALOG_STATE: string = 'dialogs'; * } * module.exports.FillProfileDialog = FillProfileDialog; * ``` - * + * * You can then add new instances of your component to another `DialogSet` or `ComponentDialog`: - * + * * ```JavaScript * const dialogs = new DialogSet(dialogState); * dialogs.add(new FillProfileDialog('fillProfile')); @@ -69,15 +69,15 @@ const PERSISTED_DIALOG_STATE: string = 'dialogs'; * @param O (Optional) options that can be passed into the `DialogContext.beginDialog()` method. */ export class ComponentDialog extends Dialog { - private dialogs: DialogSet = new DialogSet(null); /** * ID of the child dialog that should be started anytime the component is started. - * + * * @remarks - * This defaults to the ID of the first child dialog added using [addDialog()](#adddialog). + * This defaults to the ID of the first child dialog added using [addDialog()](#adddialog). */ protected initialDialogId: string; + private dialogs: DialogSet = new DialogSet(null); public async beginDialog(outerDC: DialogContext, options?: O): Promise { // Start the inner dialog. @@ -147,7 +147,7 @@ export class ComponentDialog extends Dialog { /** * Adds a child dialog or prompt to the components internal `DialogSet`. - * + * * @remarks * The `Dialog.id` of the first child added to the component will be assigned to the [initialDialogId](#initialdialogid) * property. @@ -161,7 +161,7 @@ export class ComponentDialog extends Dialog { } /** - * Finds a child dialog that was previously added to the component using + * Finds a child dialog that was previously added to the component using * [addDialog()](#adddialog). * @param dialogId ID of the dialog or prompt to lookup. */ @@ -171,11 +171,11 @@ export class ComponentDialog extends Dialog { /** * Called anytime an instance of the component has been started. - * + * * @remarks - * SHOULD be overridden by components that wish to perform custom interruption logic. The - * default implementation calls `innerDC.beginDialog()` with the dialog assigned to - * [initialDialogId](#initialdialogid). + * SHOULD be overridden by components that wish to perform custom interruption logic. The + * default implementation calls `innerDC.beginDialog()` with the dialog assigned to + * [initialDialogId](#initialdialogid). * @param innerDC Dialog context for the components internal `DialogSet`. * @param options (Optional) options that were passed to the component by its parent. */ @@ -185,10 +185,10 @@ export class ComponentDialog extends Dialog { /** * Called anytime a multi-turn component receives additional activities. - * + * * @remarks - * SHOULD be overridden by components that wish to perform custom interruption logic. The - * default implementation calls `innerDC.continueDialog()`. + * SHOULD be overridden by components that wish to perform custom interruption logic. The + * default implementation calls `innerDC.continueDialog()`. * @param innerDC Dialog context for the components internal `DialogSet`. */ protected onContinueDialog(innerDC: DialogContext): Promise { @@ -197,10 +197,10 @@ export class ComponentDialog extends Dialog { /** * Called when the component is ending. - * + * * @remarks - * If the `reason` code is equal to `DialogReason.cancelCalled`, then any active child dialogs - * will be cancelled before this method is called. + * If the `reason` code is equal to `DialogReason.cancelCalled`, then any active child dialogs + * will be cancelled before this method is called. * @param context Context for the current turn of conversation. * @param instance The components instance data within its parents dialog stack. * @param reason The reason the component is ending. @@ -211,7 +211,7 @@ export class ComponentDialog extends Dialog { /** * Called when the component has been requested to re-prompt the user for input. - * + * * @remarks * The active child dialog will have already been asked to reprompt before this method is called. * @param context Context for the current turn of conversation. @@ -223,11 +223,11 @@ export class ComponentDialog extends Dialog { /** * Called when the components last active child dialog ends and the component is ending. - * + * * @remarks * SHOULD be overridden by components that wish to perform custom logic before the component * ends. The default implementation calls `outerDC.endDialog()` with the `result` returned - * from the last active child dialog. + * from the last active child dialog. * @param outerDC Dialog context for the parents `DialogSet`. * @param result Result returned by the last active child dialog. Can be a value of `undefined`. */ diff --git a/libraries/botbuilder-dialogs/src/dialog.ts b/libraries/botbuilder-dialogs/src/dialog.ts index 850e36af5c..313d16572c 100644 --- a/libraries/botbuilder-dialogs/src/dialog.ts +++ b/libraries/botbuilder-dialogs/src/dialog.ts @@ -87,25 +87,25 @@ export enum DialogTurnStatus { } /** - * Returned by `Dialog.continueDialog()` and `DialogContext.beginDialog()` to indicate whether a + * Returned by `Dialog.continueDialog()` and `DialogContext.beginDialog()` to indicate whether a * dialog is still active after the turn has been processed by the dialog. - * + * * @remarks * This can be used to determine if the dialog stack is empty: - * + * * ```JavaScript * const result = await dialogContext.continueDialog(); - * + * * if (result.status == DialogTurnStatus.empty) { * await dialogContext.beginDialog('helpDialog'); * } * ``` - * + * * Or to access the result of a dialog that just completed: - * + * * ```JavaScript * const result = await dialogContext.continueDialog(); - * + * * if (result.status == DialogTurnStatus.completed) { * const survey = result.result; * await submitSurvey(survey); @@ -150,11 +150,11 @@ export abstract class Dialog { } /** - * Called when a new instance of the dialog has been pushed onto the stack and is being + * Called when a new instance of the dialog has been pushed onto the stack and is being * activated. - * + * * @remarks - * MUST be overridden by derived class. Dialogs that only support single-turn conversations + * MUST be overridden by derived class. Dialogs that only support single-turn conversations * should call `return await DialogContext.endDialog();` at the end of their implementation. * @param dc The dialog context for the current turn of conversation. * @param options (Optional) arguments that were passed to the dialog in the call to `DialogContext.beginDialog()`. @@ -162,11 +162,11 @@ export abstract class Dialog { public abstract beginDialog(dc: DialogContext, options?: O): Promise; /** - * Called when an instance of the dialog is the active dialog and a new activity is received. - * + * Called when an instance of the dialog is the active dialog and a new activity is received. + * * @remarks - * SHOULD be overridden by dialogs that support multi-turn conversations. The default - * implementation calls `DialogContext.endDialog()`. + * SHOULD be overridden by dialogs that support multi-turn conversations. The default + * implementation calls `DialogContext.endDialog()`. * @param dc The dialog context for the current turn of conversation. */ public async continueDialog(dc: DialogContext): Promise { @@ -176,9 +176,9 @@ export abstract class Dialog { /** * Called when an instance of the dialog is being returned to from another dialog. - * + * * @remarks - * SHOULD be overridden by multi-turn dialogs that start other dialogs using + * SHOULD be overridden by multi-turn dialogs that start other dialogs using * `DialogContext.beginDialog()` or `DialogContext.prompt()`. The default implementation calls * `DialogContext.endDialog()` with any results returned from the ending dialog. * @param dc The dialog context for the current turn of conversation. @@ -192,7 +192,7 @@ export abstract class Dialog { /** * Called when the dialog has been requested to re-prompt the user for input. - * + * * @remarks * SHOULD be overridden by multi-turn dialogs that wish to provide custom re-prompt logic. The * default implementation performs no action. @@ -205,7 +205,7 @@ export abstract class Dialog { /** * Called when the dialog is ending. - * + * * @remarks * SHOULD be overridden by dialogs that wish to perform some logging or cleanup action anytime * the dialog ends. diff --git a/libraries/botbuilder-dialogs/src/dialogContext.ts b/libraries/botbuilder-dialogs/src/dialogContext.ts index 762c78c864..33f60d99fd 100644 --- a/libraries/botbuilder-dialogs/src/dialogContext.ts +++ b/libraries/botbuilder-dialogs/src/dialogContext.ts @@ -82,11 +82,11 @@ export class DialogContext { * @remarks * If there's already an active dialog on the stack, that dialog will be paused until the new * dialog calls [endDialog()](#enddialog). - * + * * ```JavaScript * return await dc.beginDialog('greeting', { name: user.name }); * ``` - * + * * The `DialogTurnResult.status` returned can be: * - `DialogTurnStatus.active` if the dialog started was a multi-turn dialog. * - `DialogTurnStatus.completed` if the dialog started was a single-turn dialog. @@ -111,16 +111,16 @@ export class DialogContext { /** * Cancels any dialogs on the stack resulting in an empty stack. - * + * * @remarks - * The dialogs being cancelled will have their `Dialog.endDialog()` method called before being + * The dialogs being cancelled will have their `Dialog.endDialog()` method called before being * removed from the stack. - * + * * ```JavaScript * await dc.cancelAllDialogs(); * return await dc.beginDialog('bookFlight'); * ``` - * + * * The `DialogTurnResult.status` returned can be: * - `DialogTurnStatus.cancelled` if one or more dialogs were cancelled. * - `DialogTurnStatus.empty` if the stack was empty. @@ -141,7 +141,7 @@ export class DialogContext { * Helper function to simplify formatting the options for calling a `Prompt` based dialog. * * @remarks - * This is a lightweight wrapper abound [beginDialog()](#begindialog). It fills in a + * This is a lightweight wrapper abound [beginDialog()](#begindialog). It fills in a * `PromptOptions` structure and then passes it through to `dc.beginDialog(dialogId, options)`. * * ```JavaScript @@ -176,7 +176,7 @@ export class DialogContext { * * @remarks * The stack will be inspected and the active dialog will be retrieved using `DialogSet.find()`. - * The dialog will then have its `Dialog.continueDialog()` method called. + * The dialog will then have its `Dialog.continueDialog()` method called. * * ```JavaScript * const result = await dc.continueDialog(); @@ -185,7 +185,7 @@ export class DialogContext { * await dc.context.sendActivity(`I'm sorry. I didn't understand.`); * } * ``` - * + * * The `DialogTurnResult.status` returned can be: * - `DialogTurnStatus.active` if there's still one or more dialogs on the stack. * - `DialogTurnStatus.completed` if the last dialog on the stack just ended. @@ -214,15 +214,15 @@ export class DialogContext { * * @remarks * The parent dialog is the dialog the started the one being ended via a call to either - * [beginDialog()](#begindialog) or [prompt()](#prompt). The parent dialog will have its + * [beginDialog()](#begindialog) or [prompt()](#prompt). The parent dialog will have its * `Dialog.resumeDialog()` method called with any returned `result`. If there is no parent - * dialog then turn will end and the result will be passed to the bot via + * dialog then turn will end and the result will be passed to the bot via * `DialogTurnResult.result`. - * + * * ```JavaScript * return await dc.endDialog(); * ``` - * + * * The `DialogTurnResult.status` returned can be: * - `DialogTurnStatus.active` the parent dialog was resumed and is still active. * - `DialogTurnStatus.completed` the parent dialog completed or there was no parent dialog to resume. @@ -253,12 +253,12 @@ export class DialogContext { * Ends the active dialog and starts a new dialog in its place. * * @remarks - * This method is conceptually equivalent to calling [endDialog()](#enddialog) and then + * This method is conceptually equivalent to calling [endDialog()](#enddialog) and then * immediately calling [beginDialog()](#begindialog). The difference is that the parent * dialog is not resumed or otherwise notified that the dialog it started has been replaced. - * + * * This method is particularly useful for creating conversational loops within your bot: - * + * * ```JavaScript * this.addDialog(new WaterfallDialog('randomNumber', [ * async (step) => { @@ -274,7 +274,7 @@ export class DialogContext { * } * } * ])); - * + * * this.addDialog(new ConfirmPrompt('continuePrompt')); * ``` * @param dialogId ID of the new dialog to start. @@ -293,7 +293,7 @@ export class DialogContext { * * @remarks * The active dialogs `Dialog.repromptDialog()` method will be called. - * + * * ```JavaScript * await dc.repromptDialog(); * ``` diff --git a/libraries/botbuilder-dialogs/src/dialogSet.ts b/libraries/botbuilder-dialogs/src/dialogSet.ts index 666fda73c5..e4cfb40fb9 100644 --- a/libraries/botbuilder-dialogs/src/dialogSet.ts +++ b/libraries/botbuilder-dialogs/src/dialogSet.ts @@ -13,20 +13,20 @@ import { DialogContext, DialogState } from './dialogContext'; * A related set of dialogs that can all call each other. * * @remarks - * The constructor for the dialog set should be passed a state property that will be used to + * The constructor for the dialog set should be passed a state property that will be used to * persist the dialog stack for the set: - * + * * ```JavaScript * const { ConversationState, MemoryStorage, ActivityTypes } = require('botbuilder'); * const { DialogSet, Dialog, DialogTurnStatus } = require('botbuilder-dialogs'); - * + * * const convoState = new ConversationState(new MemoryStorage()); * const dialogState = convoState.createProperty('dialogState'); * const dialogs = new DialogSet(dialogState); * ``` - * + * * The bot can add dialogs or prompts to the set using the [add()](#add) method: - * + * * ```JavaScript * class GreetingDialog extends Dialog { * async beginDialog(dc, options) { @@ -34,25 +34,25 @@ import { DialogContext, DialogState } from './dialogContext'; * return await dc.endDialog(); * } * } - * + * * dialogs.add(new GreetingDialog('greeting')); * ``` - * - * To interact with the sets dialogs you can call [createContext()](#createcontext) with the + * + * To interact with the sets dialogs you can call [createContext()](#createcontext) with the * current `TurnContext`. That will create a `DialogContext` that can be used to start or continue * execution of the sets dialogs: - * + * * ```JavaScript * // Create DialogContext for the current turn * const dc = await dialogs.createContext(turnContext); - * + * * // Try to continue executing an active multi-turn dialog * const result = await dc.continueDialog(); - * + * * // Send greeting if no other dialogs active * if (result.status == DialogTurnStatus.empty && dc.context.activity.type == ActivityTypes.Message) { * await dc.beginDialog('greeting'); - * } + * } * ``` */ export class DialogSet { @@ -61,24 +61,24 @@ export class DialogSet { /** * Creates a new DialogSet instance. - * + * * @remarks * If the `dialogState` property is not passed in, calls to [createContext()](#createcontext) - * will return an error. You will need to create a `DialogContext` for the set manually and + * will return an error. You will need to create a `DialogContext` for the set manually and * pass in your own state object for persisting the sets dialog stack: - * + * * ```JavaScript * const dc = new DialogContext(dialogs, turnContext, state); * ``` * @param dialogState (Optional) state property used to persist the sets dialog stack. */ - constructor(dialogState?: StatePropertyAccessor) { + constructor(dialogState?: StatePropertyAccessor) { this.dialogState = dialogState; } /** * Adds a new dialog or prompt to the set. - * + * * @remarks * The `Dialog.id` of all dialogs or prompts added to the set need to be unique within the set. * @param dialog The dialog or prompt to add. @@ -92,8 +92,8 @@ export class DialogSet { throw new Error(`DialogSet.add(): A dialog with an id of '${dialog.id}' already added.`); } - this.dialogs[dialog.id] = dialog; - return this; + this.dialogs[dialog.id] = dialog; + return this; } /** diff --git a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts index ebed4294ef..7fd7a4681a 100644 --- a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts @@ -14,7 +14,7 @@ import { PromptOptions, PromptRecognizerResult, PromptValidator } from './prompt * Waits for an activity to be received. * * @remarks - * This prompt requires a validator be passed in and is useful when waiting for non-message + * This prompt requires a validator be passed in and is useful when waiting for non-message * activities like an event to be received. The validator can ignore received events until the * expected activity is received. */ @@ -57,7 +57,7 @@ export abstract class ActivityPrompt extends Dialog { // Validate the return value // - Unlike the other prompts a validator is required for an ActivityPrompt so we don't - // need to check for its existence before calling it. + // need to check for its existence before calling it. const isValid = await this.validator({ context: dc.context, recognized: recognized, diff --git a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts index 606feec363..a7921b14fb 100644 --- a/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/choicePrompt.ts @@ -33,19 +33,7 @@ export class ChoicePrompt extends Prompt { }; /** - * Creates a new `ChoicePrompt` instance. - * @param dialogId Unique ID of the dialog within its parent `DialogSet`. - * @param validator (Optional) validator that will be called each time the user responds to the prompt. If the validator replies with a message no additional retry prompt will be sent. - * @param defaultLocale (Optional) locale to use if `dc.context.activity.locale` not specified. Defaults to a value of `en-us`. - */ - constructor(dialogId: string, validator?: PromptValidator, defaultLocale?: string) { - super(dialogId, validator); - this.style = ListStyle.auto; - this.defaultLocale = defaultLocale; - } - - /** - * The prompts default locale that should be recognized. + * The prompts default locale that should be recognized. */ public defaultLocale: string|undefined; @@ -58,7 +46,7 @@ export class ChoicePrompt extends Prompt { public style: ListStyle; /** - * Additional options passed to the `ChoiceFactory` and used to tweak the style of choices + * Additional options passed to the `ChoiceFactory` and used to tweak the style of choices * rendered to the user. */ public choiceOptions: ChoiceFactoryOptions|undefined; @@ -68,6 +56,18 @@ export class ChoicePrompt extends Prompt { */ public recognizerOptions: FindChoicesOptions|undefined; + /** + * Creates a new `ChoicePrompt` instance. + * @param dialogId Unique ID of the dialog within its parent `DialogSet`. + * @param validator (Optional) validator that will be called each time the user responds to the prompt. If the validator replies with a message no additional retry prompt will be sent. + * @param defaultLocale (Optional) locale to use if `dc.context.activity.locale` not specified. Defaults to a value of `en-us`. + */ + constructor(dialogId: string, validator?: PromptValidator, defaultLocale?: string) { + super(dialogId, validator); + this.style = ListStyle.auto; + this.defaultLocale = defaultLocale; + } + protected async onPrompt(context: TurnContext, state: any, options: PromptOptions, isRetry: boolean): Promise { // Determine locale let locale: string = context.activity.locale || this.defaultLocale; diff --git a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts index e45658cdca..17f023462f 100644 --- a/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/confirmPrompt.ts @@ -46,21 +46,8 @@ export class ConfirmPrompt extends Prompt { 'pt-br': { inlineSeparator: ', ', inlineOr: ' ou ', inlineOrMore: ', ou ', includeNumbers: true }, 'zh-cn': { inlineSeparator: ', ', inlineOr: ' 要么 ', inlineOrMore: ', 要么 ', includeNumbers: true } }; - - - /** - * Creates a new ConfirmPrompt instance. - * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`. - * @param validator (Optional) validator that will be called each time the user responds to the prompt. - * @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`. - */ - constructor(dialogId: string, validator?: PromptValidator, defaultLocale?: string) { - super(dialogId, validator); - this.style = ListStyle.auto; - this.defaultLocale = defaultLocale; - } /** - * The prompts default locale that should be recognized. + * The prompts default locale that should be recognized. */ public defaultLocale: string|undefined; @@ -73,16 +60,28 @@ export class ConfirmPrompt extends Prompt { public style: ListStyle; /** - * Additional options passed to the `ChoiceFactory` and used to tweak the style of choices + * Additional options passed to the `ChoiceFactory` and used to tweak the style of choices * rendered to the user. */ public choiceOptions: ChoiceFactoryOptions|undefined; /** - * Custom list of choices to send for the prompt. + * Custom list of choices to send for the prompt. */ public confirmChoices: (string|Choice)[]|undefined; + /** + * Creates a new ConfirmPrompt instance. + * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`. + * @param validator (Optional) validator that will be called each time the user responds to the prompt. + * @param defaultLocale (Optional) locale to use if `TurnContext.activity.locale` is not specified. Defaults to a value of `en-us`. + */ + constructor(dialogId: string, validator?: PromptValidator, defaultLocale?: string) { + super(dialogId, validator); + this.style = ListStyle.auto; + this.defaultLocale = defaultLocale; + } + protected async onPrompt(context: TurnContext, state: any, options: PromptOptions, isRetry: boolean): Promise { // Determine locale let locale: string = context.activity.locale || this.defaultLocale; diff --git a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts index c056788b22..59d005b18b 100644 --- a/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/datetimePrompt.ts @@ -39,6 +39,11 @@ export interface DateTimeResolution { */ export class DateTimePrompt extends Prompt { + /** + * The prompts default locale that should be recognized. + */ + public defaultLocale: string|undefined; + /** * Creates a new DateTimePrompt instance. * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`. @@ -50,11 +55,6 @@ export class DateTimePrompt extends Prompt { this.defaultLocale = defaultLocale; } - /** - * The prompts default locale that should be recognized. - */ - public defaultLocale: string|undefined; - protected async onPrompt(context: TurnContext, state: any, options: PromptOptions, isRetry: boolean): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); diff --git a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts index 80fcbeb3df..53c3156663 100644 --- a/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/numberPrompt.ts @@ -17,6 +17,11 @@ import { Prompt, PromptOptions, PromptRecognizerResult, PromptValidator } from ' */ export class NumberPrompt extends Prompt { + /** + * The prompts default locale that should be recognized. + */ + public defaultLocale: string|undefined; + /** * Creates a new NumberPrompt instance. * @param dialogId Unique ID of the dialog within its parent `DialogSet` or `ComponentDialog`. @@ -28,11 +33,6 @@ export class NumberPrompt extends Prompt { this.defaultLocale = defaultLocale; } - /** - * The prompts default locale that should be recognized. - */ - public defaultLocale: string|undefined; - protected async onPrompt(context: TurnContext, state: any, options: PromptOptions, isRetry: boolean): Promise { if (isRetry && options.retryPrompt) { await context.sendActivity(options.retryPrompt, undefined, InputHints.ExpectingInput); diff --git a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts index 308a40db8b..87f9bf1bf2 100644 --- a/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/oauthPrompt.ts @@ -90,11 +90,11 @@ export interface OAuthPromptSettings { * return await step.beginDialog('loginPrompt'); * }, * async (step) => { - * const token = step.result; + * const token = step.result; * if (token) { - * + * * // ... continue with task needing access token ... - * + * * } else { * await step.context.sendActivity(`Sorry... We couldn't log you in. Try again later.`); * return await step.endDialog(); diff --git a/libraries/botbuilder-dialogs/src/prompts/prompt.ts b/libraries/botbuilder-dialogs/src/prompts/prompt.ts index a0d7f2b7eb..2c01ec8be7 100644 --- a/libraries/botbuilder-dialogs/src/prompts/prompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/prompt.ts @@ -85,7 +85,7 @@ export interface PromptRecognizerResult { /** * Function signature for providing a custom prompt validator. - * + * * ```TypeScript * type PromptValidator = (prompt: PromptValidatorContext) => Promise; * ``` @@ -93,7 +93,7 @@ export interface PromptRecognizerResult { * @remarks * The validator should be an asynchronous function that returns `true` if * `prompt.recognized.value` is valid and the prompt should end. - * + * * > [!NOTE] * > If the validator returns `false` the prompts default re-prompt logic will be run unless the * > validator sends a custom re-prompt to the user using `prompt.context.sendActivity()`. In that @@ -110,7 +110,7 @@ export type PromptValidator = (prompt: PromptValidatorContext) => Promise< export interface PromptValidatorContext { /** * The context for the current turn of conversation with the user. - * + * * @remarks * The validator can use this to re-prompt the user. */ @@ -118,7 +118,7 @@ export interface PromptValidatorContext { /** * Result returned from the prompts recognizer function. - * + * * @remarks * The `prompt.recognized.succeeded` field can be checked to determine of the recognizer found * anything and then the value can be retrieved from `prompt.recognized.value`. @@ -127,7 +127,7 @@ export interface PromptValidatorContext { /** * A dictionary of values persisted for each conversational turn while the prompt is active. - * + * * @remarks * The validator can use this to persist things like turn counts or other state information. */ @@ -135,9 +135,9 @@ export interface PromptValidatorContext { /** * Original set of options passed to the prompt by the calling dialog. - * + * * @remarks - * The validator can extend this interface to support additional prompt options. + * The validator can extend this interface to support additional prompt options. */ readonly options: PromptOptions; } @@ -229,7 +229,7 @@ export abstract class Prompt extends Dialog { } /** - * Called anytime the derived class should send the user a prompt. + * Called anytime the derived class should send the user a prompt. * @param context Context for the current turn of conversation with the user. * @param state Additional state being persisted for the prompt. * @param options Options that the prompt was started with in the call to `DialogContext.prompt()`. @@ -239,10 +239,10 @@ export abstract class Prompt extends Dialog { /** * Called to recognize an utterance received from the user. - * + * * @remarks * The Prompt class filters out non-message activities so its safe to assume that the users - * utterance can be retrieved from `context.activity.text`. + * utterance can be retrieved from `context.activity.text`. * @param context Context for the current turn of conversation with the user. * @param state Additional state being persisted for the prompt. * @param options Options that the prompt was started with in the call to `DialogContext.prompt()`. @@ -318,4 +318,4 @@ export abstract class Prompt extends Dialog { interface PromptState { state: object; options: PromptOptions; -} \ No newline at end of file +} diff --git a/libraries/botbuilder-dialogs/src/waterfallDialog.ts b/libraries/botbuilder-dialogs/src/waterfallDialog.ts index b18a449332..ee3d49bf91 100644 --- a/libraries/botbuilder-dialogs/src/waterfallDialog.ts +++ b/libraries/botbuilder-dialogs/src/waterfallDialog.ts @@ -26,17 +26,17 @@ export type WaterfallStep = (step: WaterfallStepContext { @@ -46,19 +46,19 @@ export type WaterfallStep = (step: WaterfallStepContext { * // Remember the users answer * step.values['name'] = step.result; - * + * * // Ask user their age. * return await step.prompt('agePrompt', `Hi ${step.values['name']}. How old are you?`); * }, * async (step) => { * // Remember the users answer * step.values['age'] = step.result; - * + * * // End the component and return the completed profile. * return await step.endDialog(step.values); * } * ])); - * + * * // Add prompts * this.addDialog(new TextPrompt('namePrompt')); * this.addDialog(new NumberPrompt('agePrompt')) @@ -72,9 +72,9 @@ export class WaterfallDialog extends Dialog { /** * Creates a new waterfall dialog containing the given array of steps. - * + * * @remarks - * See the [addStep()](#addstep) function for details on creating a valid step function. + * See the [addStep()](#addstep) function for details on creating a valid step function. * @param dialogId Unique ID of the dialog within the component or set its being added to. * @param steps (Optional) array of asynchronous waterfall step functions. */ @@ -88,37 +88,37 @@ export class WaterfallDialog extends Dialog { /** * Adds a new step to the waterfall. - * + * * @remarks - * All step functions should be asynchronous and return a `DialogTurnResult`. The + * All step functions should be asynchronous and return a `DialogTurnResult`. The * `WaterfallStepContext` passed into your function derives from `DialogContext` and contains - * numerous stack manipulation methods which return a `DialogTurnResult` so you can typically + * numerous stack manipulation methods which return a `DialogTurnResult` so you can typically * just return the result from the DialogContext method you call. - * + * * The step function itself can be either an asynchronous closure: - * + * * ```JavaScript * const helloDialog = new WaterfallDialog('hello'); - * + * * helloDialog.addStep(async (step) => { * await step.context.sendActivity(`Hello World!`); * return await step.endDialog(); * }); * ``` - * + * * A named async function: - * + * * ```JavaScript * async function helloWorldStep(step) { * await step.context.sendActivity(`Hello World!`); * return await step.endDialog(); * } - * + * * helloDialog.addStep(helloWorldStep); * ``` - * + * * Or a class method that's been bound to its `this` pointer: - * + * * ```JavaScript * helloDialog.addStep(this.helloWorldStep.bind(this)); * ``` @@ -158,10 +158,10 @@ export class WaterfallDialog extends Dialog { /** * Called when an individual waterfall step is being executed. - * + * * @remarks * SHOULD be overridden by derived class that want to add custom logging semantics. - * + * * ```JavaScript * class LoggedWaterfallDialog extends WaterfallDialog { * async onStep(step) { diff --git a/libraries/botbuilder-dialogs/src/waterfallStepContext.ts b/libraries/botbuilder-dialogs/src/waterfallStepContext.ts index 889d246902..f4a2e4cd45 100644 --- a/libraries/botbuilder-dialogs/src/waterfallStepContext.ts +++ b/libraries/botbuilder-dialogs/src/waterfallStepContext.ts @@ -5,8 +5,8 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ -import { DialogContext } from './dialogContext'; import { DialogReason, DialogTurnResult } from './dialog'; +import { DialogContext } from './dialogContext'; /** * Values passed to the `WaterfallStepContext` constructor. @@ -18,7 +18,7 @@ export interface WaterfallStepInfo { index: number; /** - * Any options passed to the steps waterfall dialog when it was started with + * Any options passed to the steps waterfall dialog when it was started with * `DialogContext.beginDialog()`. */ options: O; @@ -42,7 +42,7 @@ export interface WaterfallStepInfo { * Called to skip to the next waterfall step. * @param result (Optional) result to pass to the next step. */ - onNext: (result?: any) => Promise; + onNext(result?: any): Promise; } @@ -71,7 +71,7 @@ export class WaterfallStepContext extends DialogContext { } /** - * Any options passed to the steps waterfall dialog when it was started with + * Any options passed to the steps waterfall dialog when it was started with * `DialogContext.beginDialog()`. */ public get options(): O { @@ -101,9 +101,9 @@ export class WaterfallStepContext extends DialogContext { /** * Skips to the next waterfall step. - * + * * @remarks - * + * * ```JavaScript * return await step.skip(); * ``` @@ -112,4 +112,4 @@ export class WaterfallStepContext extends DialogContext { public async next(result?: any): Promise { return await this._info.onNext(result); } -} \ No newline at end of file +} diff --git a/libraries/botbuilder/src/botFrameworkAdapter.ts b/libraries/botbuilder/src/botFrameworkAdapter.ts index 646524f0dd..5655311d1a 100644 --- a/libraries/botbuilder/src/botFrameworkAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkAdapter.ts @@ -590,7 +590,7 @@ export class BotFrameworkAdapter extends BotAdapter { * The activities will be sent one after another in the order in which they're received. A response object will be returned for each * sent activity. For `message` activities this will contain the id of the delivered message. * - * Instead of calling these methods directly on the adapter, calling `TurnContext.sendActivities()` or `TurnContext.sendActivity()` + * Instead of calling these methods directly on the adapter, calling `TurnContext.sendActivities()` or `TurnContext.sendActivity()` * is the preferred way of sending activities as that will ensure that outgoing activities have been properly addressed * and that any interested middleware has been notified. * diff --git a/libraries/botframework-config/src/botConfiguration.ts b/libraries/botframework-config/src/botConfiguration.ts index 6db5b17d17..f10ac97027 100644 --- a/libraries/botframework-config/src/botConfiguration.ts +++ b/libraries/botframework-config/src/botConfiguration.ts @@ -19,7 +19,7 @@ import * as encrypt from './encrypt'; */ import { ConnectedService } from './models'; import { IBotConfiguration, IConnectedService, IDispatchService, ServiceTypes } from './schema'; -let exec = util.promisify(require('child_process').exec); +const exec = util.promisify(require('child_process').exec); /** * @private @@ -28,11 +28,9 @@ interface InternalBotConfig { location?: string; } - - /** * BotConfiguration represents configuration information for a bot. - * + * * @remarks * It is typically loaded from a .bot file on disk. This class implements methods for encrypting * and manipulating the in-memory representation of the configuration. @@ -51,7 +49,7 @@ export class BotConfiguration extends BotConfigurationBase { const botConfig: BotConfiguration = new BotConfiguration(); Object.assign(botConfig, source); - // back compat for secretKey rename + // back compat for secretKey rename if (!botConfig.padlock && (botConfig).secretKey) { botConfig.padlock = (botConfig).secretKey; delete (botConfig).secretKey; @@ -80,7 +78,7 @@ export class BotConfiguration extends BotConfigurationBase { } /** - * Load the bot configuration by looking in a folder and loading the first .bot file in the + * Load the bot configuration by looking in a folder and loading the first .bot file in the * folder. (blocking) * @param folder (Optional) folder to look for bot files. If not specified the current working directory is used. * @param secret (Optional) secret used to decrypt the bot file. @@ -123,6 +121,24 @@ export class BotConfiguration extends BotConfigurationBase { return bot; } + /** + * Generate a new key suitable for encrypting. + */ + public static generateKey(): string { + return encrypt.generateKey(); + } + + private static internalLoad(json: string, secret?: string): BotConfiguration { + const bot: BotConfiguration = BotConfiguration.fromJSON(JSON.parse(json)); + + const hasSecret: boolean = !!bot.padlock; + if (hasSecret) { + bot.decrypt(secret); + } + + return bot; + } + /** * Save the configuration to a .bot file. * @param botpath Path to bot file. @@ -191,46 +207,6 @@ export class BotConfiguration extends BotConfigurationBase { return this.saveAsSync(this.internal.location, secret); } - private savePrep(secret?: string): void { - if (!!secret) { - this.validateSecret(secret); - } - - // make sure that all dispatch serviceIds still match services that are in the bot - for (const service of this.services) { - if (service.type === ServiceTypes.Dispatch) { - const dispatchService: IDispatchService = service; - const validServices: string[] = []; - for (const dispatchServiceId of dispatchService.serviceIds) { - for (const this_service of this.services) { - if (this_service.id === dispatchServiceId) { - validServices.push(dispatchServiceId); - } - } - } - dispatchService.serviceIds = validServices; - } - } - } - - private static internalLoad(json: string, secret?: string): BotConfiguration { - const bot: BotConfiguration = BotConfiguration.fromJSON(JSON.parse(json)); - - const hasSecret: boolean = !!bot.padlock; - if (hasSecret) { - bot.decrypt(secret); - } - - return bot; - } - - /** - * Generate a new key suitable for encrypting. - */ - public static generateKey(): string { - return encrypt.generateKey(); - } - /** * Clear secret. */ @@ -342,6 +318,28 @@ export class BotConfiguration extends BotConfigurationBase { throw new Error('You are attempting to perform an operation which needs access to the secret and --secret is incorrect.'); } } + + private savePrep(secret?: string): void { + if (!!secret) { + this.validateSecret(secret); + } + + // make sure that all dispatch serviceIds still match services that are in the bot + for (const service of this.services) { + if (service.type === ServiceTypes.Dispatch) { + const dispatchService: IDispatchService = service; + const validServices: string[] = []; + for (const dispatchServiceId of dispatchService.serviceIds) { + for (const this_service of this.services) { + if (this_service.id === dispatchServiceId) { + validServices.push(dispatchServiceId); + } + } + } + dispatchService.serviceIds = validServices; + } + } + } } // Make sure the internal field is not included in JSON representation. diff --git a/libraries/botframework-config/src/botConfigurationBase.ts b/libraries/botframework-config/src/botConfigurationBase.ts index 8571d38e11..f7915a6d94 100644 --- a/libraries/botframework-config/src/botConfigurationBase.ts +++ b/libraries/botframework-config/src/botConfigurationBase.ts @@ -186,7 +186,6 @@ export class BotConfigurationBase implements Partial { } } - /** * Migrate old formated data into new format. */ @@ -195,11 +194,11 @@ export class BotConfigurationBase implements Partial { switch (service.type) { case ServiceTypes.Bot: { - let botService = service; + const botService = service; // old bot service records may not have the appId on the bot, but we probably have it already on an endpoint if (!botService.appId) { - for(const s of this.services){ + for (const s of this.services) { if (s.type == ServiceTypes.Endpoint) { const endpoint = s; if (endpoint.appId) { @@ -219,6 +218,6 @@ export class BotConfigurationBase implements Partial { } // this is now a 2.0 version of the schema - this.version = "2.0"; + this.version = '2.0'; } } diff --git a/libraries/botframework-config/src/botRecipe.ts b/libraries/botframework-config/src/botRecipe.ts index 9bc8079b1e..bce1c6f560 100644 --- a/libraries/botframework-config/src/botRecipe.ts +++ b/libraries/botframework-config/src/botRecipe.ts @@ -14,7 +14,7 @@ export interface IResource { // ServiceType of the service (LUIS, QnA, etc.) readonly type: ServiceTypes; - // unique Id for the service in the bot + // unique Id for the service in the bot id?: string; // Friendly name for the service @@ -76,7 +76,7 @@ export class BotRecipe { public version = '1.0'; /** - * + * */ public resources: IResource[] = []; @@ -86,10 +86,9 @@ export class BotRecipe { constructor() { } - public static fromJSON(source: Partial = {}): BotRecipe { const botRecipe = new BotRecipe(); - let { version, resources } = source; + const { version, resources } = source; botRecipe.resources = resources ? resources : botRecipe.resources; botRecipe.version = version ? version : botRecipe.version; return botRecipe; @@ -100,4 +99,3 @@ export class BotRecipe { return { version, resources }; } } - diff --git a/libraries/botframework-config/src/encrypt.ts b/libraries/botframework-config/src/encrypt.ts index dfd6b043cf..c4fccad5ea 100644 --- a/libraries/botframework-config/src/encrypt.ts +++ b/libraries/botframework-config/src/encrypt.ts @@ -93,8 +93,8 @@ export function decryptString(encryptedValue: string, secret: string): string { /** * @private - * @param encryptedValue - * @param secret + * @param encryptedValue + * @param secret */ export function legacyDecrypt(encryptedValue: string, secret: string): string { // LEGACY for pre standardized SHA256 encryption, this uses some undocumented nodejs MD5 hash internally and is deprecated diff --git a/libraries/botframework-config/src/index.ts b/libraries/botframework-config/src/index.ts index 772e5dd0d9..3b9f1c9718 100644 --- a/libraries/botframework-config/src/index.ts +++ b/libraries/botframework-config/src/index.ts @@ -10,4 +10,3 @@ export { BotConfigurationBase } from './botConfigurationBase'; export { BotRecipe, IBlobResource, ICosmosDBResource, IDispatchResource, IFileResource, IGenericResource, IResource, IUrlResource } from './botRecipe'; export * from './models'; export * from './schema'; - diff --git a/libraries/botframework-config/src/models/azureService.ts b/libraries/botframework-config/src/models/azureService.ts index 1e4d4011da..a6ebc87bd0 100644 --- a/libraries/botframework-config/src/models/azureService.ts +++ b/libraries/botframework-config/src/models/azureService.ts @@ -16,17 +16,17 @@ export class AzureService extends ConnectedService implements IAzureService { * Tenant ID for azure. */ public tenantId: string; - + /** * Subscription ID for azure. */ public subscriptionId: string; - + /** * Resource group for azure. */ public resourceGroup: string; - + /** * Name of the service. */ diff --git a/libraries/botframework-config/src/models/connectedService.ts b/libraries/botframework-config/src/models/connectedService.ts index 8356e404fe..dbbb854131 100644 --- a/libraries/botframework-config/src/models/connectedService.ts +++ b/libraries/botframework-config/src/models/connectedService.ts @@ -15,7 +15,7 @@ export class ConnectedService implements IConnectedService { * Unique Id for the service. */ public id: string; - + /** * Friendly name for the service. */ diff --git a/libraries/botframework-config/src/models/cosmosDbService.ts b/libraries/botframework-config/src/models/cosmosDbService.ts index 495966a6c3..6ee949cfdf 100644 --- a/libraries/botframework-config/src/models/cosmosDbService.ts +++ b/libraries/botframework-config/src/models/cosmosDbService.ts @@ -16,7 +16,7 @@ export class CosmosDbService extends AzureService implements ICosmosDBService { * Endpoint/uri for CosmosDB. */ public endpoint: string; - + /** * Key for accessing CosmosDB. */ diff --git a/libraries/botframework-config/src/models/luisService.ts b/libraries/botframework-config/src/models/luisService.ts index c8a66ae0e8..c42952282d 100644 --- a/libraries/botframework-config/src/models/luisService.ts +++ b/libraries/botframework-config/src/models/luisService.ts @@ -47,7 +47,7 @@ export class LuisService extends ConnectedService implements ILuisService { } // get endpoint for the luis service - public getEndpoint() { + public getEndpoint() { return `https://${this.region}.api.cognitive.microsoft.com`; } diff --git a/libraries/botframework-config/src/schema.ts b/libraries/botframework-config/src/schema.ts index 0367c70efd..3d701fd705 100644 --- a/libraries/botframework-config/src/schema.ts +++ b/libraries/botframework-config/src/schema.ts @@ -44,7 +44,7 @@ export interface IConnectedService { /** * JSON description of an endpoint service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.Endpoint`. * - [id](#id) SHOULD be set to the bots ID. @@ -93,7 +93,7 @@ export interface IAzureService extends IConnectedService { /** * JSON description of an Azure Bot Service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.Bot`. */ @@ -106,7 +106,7 @@ export interface IBotService extends IAzureService { /** * JSON description of an App Insights service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.AppInsights`. */ @@ -129,7 +129,7 @@ export interface IAppInsightsService extends IAzureService { /** * JSON description of a blob storage service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.BlobStorage`. */ @@ -147,7 +147,7 @@ export interface IBlobStorageService extends IAzureService { /** * JSON description of a CosmosDB service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.CosmosDB`. */ @@ -156,7 +156,7 @@ export interface ICosmosDBService extends IAzureService { * Endpoint/uri for CosmosDB. */ endpoint: string; - + /** * Key for accessing CosmosDB. */ @@ -175,7 +175,7 @@ export interface ICosmosDBService extends IAzureService { /** * JSON description of a LUIS service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.Luis`. * - [id](#id) SHOULD be set to the LUIS appid. @@ -209,7 +209,7 @@ export interface ILuisService extends IConnectedService { /** * JSON description of a dispatch service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.Dispatch`. */ @@ -222,7 +222,7 @@ export interface IDispatchService extends ILuisService { /** * JSON description of a generic service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.Generic`. */ @@ -240,7 +240,7 @@ export interface IGenericService extends IConnectedService { /** * JSON description of a QnA Maker service. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.QnA`. */ @@ -268,7 +268,7 @@ export interface IQnAService extends IConnectedService { /** * JSON description of a file. - * + * * @remarks * - [type](#type) SHOULD be set to `ServiceTypes.File`. */ @@ -295,7 +295,7 @@ export interface IBotConfiguration { /** * Encrypted GUID used to validate password is the same. - * + * * @remarks * You need to be able to decrypt this key with a passed in secret before we will use the * secret to encrypt new values. diff --git a/libraries/botframework-config/src/utils.ts b/libraries/botframework-config/src/utils.ts index 95bc61595c..0d7959311c 100644 --- a/libraries/botframework-config/src/utils.ts +++ b/libraries/botframework-config/src/utils.ts @@ -8,7 +8,7 @@ /** * @private - * @param value + * @param value */ export function uuidValidate(value: string): boolean { return /^[0-9a-f]{8}-?[0-9a-f]{4}-?[1-5][0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$/.test(value); diff --git a/libraries/botframework-connector/src/auth/channelValidation.ts b/libraries/botframework-connector/src/auth/channelValidation.ts index 6452bc8487..f6dc3700de 100644 --- a/libraries/botframework-connector/src/auth/channelValidation.ts +++ b/libraries/botframework-connector/src/auth/channelValidation.ts @@ -13,7 +13,7 @@ import { JwtTokenExtractor } from './jwtTokenExtractor'; export module ChannelValidation { - export var OpenIdMetadataEndpoint : string = undefined; + export let OpenIdMetadataEndpoint : string; /** * TO BOT FROM CHANNEL: Token validation parameters when connecting to a bot @@ -70,7 +70,7 @@ export module ChannelValidation { Constants.AllowedSigningAlgorithms); const identity: ClaimsIdentity = await tokenExtractor.getIdentityFromAuthHeader(authHeader, channelId); - + return await validateIdentity(identity, credentials); } diff --git a/libraries/botframework-connector/src/auth/enterpriseChannelValidation.ts b/libraries/botframework-connector/src/auth/enterpriseChannelValidation.ts index b0636249a7..6f9f1aba3c 100644 --- a/libraries/botframework-connector/src/auth/enterpriseChannelValidation.ts +++ b/libraries/botframework-connector/src/auth/enterpriseChannelValidation.ts @@ -6,8 +6,8 @@ * Licensed under the MIT License. */ import { VerifyOptions } from 'jsonwebtoken'; -import { ClaimsIdentity } from './claimsIdentity'; import { ChannelValidation } from './channelValidation'; +import { ClaimsIdentity } from './claimsIdentity'; import { Constants } from './constants'; import { ICredentialProvider } from './credentialProvider'; import { JwtTokenExtractor } from './jwtTokenExtractor'; diff --git a/libraries/botframework-connector/src/auth/governmentChannelValidation.ts b/libraries/botframework-connector/src/auth/governmentChannelValidation.ts index 92e81a5120..5f86e75ecb 100644 --- a/libraries/botframework-connector/src/auth/governmentChannelValidation.ts +++ b/libraries/botframework-connector/src/auth/governmentChannelValidation.ts @@ -6,11 +6,11 @@ * Licensed under the MIT License. */ import { VerifyOptions } from 'jsonwebtoken'; +import { ChannelValidation } from './channelValidation'; import { ClaimsIdentity } from './claimsIdentity'; import { Constants } from './constants'; -import { GovernmentConstants } from './governmentConstants'; -import { ChannelValidation } from './channelValidation'; import { ICredentialProvider } from './credentialProvider'; +import { GovernmentConstants } from './governmentConstants'; import { JwtTokenExtractor } from './jwtTokenExtractor'; export module GovernmentChannelValidation { @@ -82,7 +82,7 @@ export module GovernmentChannelValidation { */ export async function validateIdentity( identity: ClaimsIdentity, - credentials: ICredentialProvider, + credentials: ICredentialProvider ): Promise { if (!identity) { // No valid identity. Not Authorized. diff --git a/libraries/botframework-connector/src/auth/jwtTokenValidation.ts b/libraries/botframework-connector/src/auth/jwtTokenValidation.ts index a250e23a06..036f96a8a4 100644 --- a/libraries/botframework-connector/src/auth/jwtTokenValidation.ts +++ b/libraries/botframework-connector/src/auth/jwtTokenValidation.ts @@ -7,12 +7,12 @@ */ import { Activity } from 'botframework-schema'; import { ChannelValidation } from './channelValidation'; -import { GovernmentChannelValidation } from './governmentChannelValidation'; -import { EnterpriseChannelValidation } from './enterpriseChannelValidation'; -import { GovernmentConstants } from './governmentConstants'; import { ClaimsIdentity } from './claimsIdentity'; import { ICredentialProvider } from './credentialProvider'; import { EmulatorValidation } from './emulatorValidation'; +import { EnterpriseChannelValidation } from './enterpriseChannelValidation'; +import { GovernmentChannelValidation } from './governmentChannelValidation'; +import { GovernmentConstants } from './governmentConstants'; import { MicrosoftAppCredentials } from './microsoftAppCredentials'; export module JwtTokenValidation { diff --git a/libraries/botframework-connector/src/oAuthApiClient.ts b/libraries/botframework-connector/src/oAuthApiClient.ts index f4574ed65c..7ed7499562 100644 --- a/libraries/botframework-connector/src/oAuthApiClient.ts +++ b/libraries/botframework-connector/src/oAuthApiClient.ts @@ -368,7 +368,7 @@ export class OAuthApiClient { requestContent = JSON.stringify(resourceUrls); } } catch (error) { - let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + const serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + `payload - ${JSON.stringify(resourceUrls, null, 2)}.`); return Promise.reject(serializationError); } From 15ac78bb558aebb13fa83acb24a56726d776e70b Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Tue, 2 Oct 2018 14:56:37 -0500 Subject: [PATCH 2/2] manual linter fixes --- libraries/botbuilder-ai/src/luisRecognizer.ts | 2 +- .../botbuilder-azure/src/cosmosDbStorage.ts | 5 +- .../src/autoSaveStateMiddleware.ts | 5 +- libraries/botbuilder-core/src/botStateSet.ts | 2 + .../src/privateConversationState.ts | 2 + libraries/botbuilder-core/src/turnContext.ts | 1 + libraries/botbuilder-dialogs/src/dialogSet.ts | 1 + .../src/prompts/activityPrompt.ts | 2 +- .../botbuilder-dialogs/src/waterfallDialog.ts | 3 +- .../botbuilder/src/botFrameworkAdapter.ts | 1 + .../src/botConfiguration.ts | 4 +- .../src/botConfigurationBase.ts | 20 +++++--- .../botframework-config/src/botRecipe.ts | 7 ++- libraries/botframework-config/src/index.ts | 11 +++- .../src/models/connectedService.ts | 4 +- .../src/models/luisService.ts | 2 +- .../src/auth/constants.ts | 3 +- .../src/auth/governmentChannelValidation.ts | 13 ++--- .../src/auth/jwtTokenExtractor.ts | 6 ++- .../src/auth/jwtTokenValidation.ts | 22 ++++++-- .../src/auth/microsoftAppCredentials.ts | 1 + .../src/auth/openIdMetadata.ts | 2 + .../src/oAuthApiClient.ts | 51 +++++++++++-------- 23 files changed, 114 insertions(+), 56 deletions(-) diff --git a/libraries/botbuilder-ai/src/luisRecognizer.ts b/libraries/botbuilder-ai/src/luisRecognizer.ts index 8f5aa324a2..8f0120d79f 100644 --- a/libraries/botbuilder-ai/src/luisRecognizer.ts +++ b/libraries/botbuilder-ai/src/luisRecognizer.ts @@ -103,7 +103,7 @@ export interface LuisPredictionOptions { * @remarks * This class is used to recognize intents and extract entities from incoming messages. * See this class in action [in this sample application](https://github.com/Microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/12.nlp-with-luis). - + * * This component can be used within your bots logic by calling [recognize()](#recognize). */ export class LuisRecognizer { diff --git a/libraries/botbuilder-azure/src/cosmosDbStorage.ts b/libraries/botbuilder-azure/src/cosmosDbStorage.ts index 411eadc2ef..5d72bab73a 100644 --- a/libraries/botbuilder-azure/src/cosmosDbStorage.ts +++ b/libraries/botbuilder-azure/src/cosmosDbStorage.ts @@ -70,7 +70,10 @@ export class CosmosDbStorage implements Storage { * @param settings Setting to configure the provider. * @param connectionPolicyConfigurator (Optional) An optional delegate that accepts a ConnectionPolicy for customizing policies. More information at http://azure.github.io/azure-documentdb-node/global.html#ConnectionPolicy */ - public constructor(settings: CosmosDbStorageSettings, connectionPolicyConfigurator: (policy: DocumentBase.ConnectionPolicy) => void = null) { + public constructor( + settings: CosmosDbStorageSettings, + connectionPolicyConfigurator: (policy: DocumentBase.ConnectionPolicy) => void = null + ) { if (!settings) { throw new Error('The settings parameter is required.'); } diff --git a/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts b/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts index 042389672b..a646ccf5b5 100644 --- a/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts +++ b/libraries/botbuilder-core/src/autoSaveStateMiddleware.ts @@ -37,8 +37,8 @@ import { TurnContext } from './turnContext'; * const user = await userState.load(turnContext); * * // ... route activity ... - * // ...make changes to state objects... - * // ... no need to call userState.saveChanges() or conversationState.saveChanges() anymore! + * // ...make changes to state objects... + * // ... no need to call userState.saveChanges() or conversationState.saveChanges() anymore! * }); * }); * ``` @@ -69,6 +69,7 @@ export class AutoSaveStateMiddleware implements Middleware { */ public add(...botStates: BotState[]): this { BotStateSet.prototype.add.apply(this.botStateSet, botStates); + return this; } diff --git a/libraries/botbuilder-core/src/botStateSet.ts b/libraries/botbuilder-core/src/botStateSet.ts index 56498b9b36..ede14549b6 100644 --- a/libraries/botbuilder-core/src/botStateSet.ts +++ b/libraries/botbuilder-core/src/botStateSet.ts @@ -59,6 +59,7 @@ export class BotStateSet { const promises: Promise[] = this.botStates.map((botstate: BotState) => botstate.load(context, force)); await Promise.all(promises); + return; } @@ -78,6 +79,7 @@ export class BotStateSet { const promises: Promise[] = this.botStates.map((botstate: BotState) => botstate.saveChanges(context, force)); await Promise.all(promises); + return; } } diff --git a/libraries/botbuilder-core/src/privateConversationState.ts b/libraries/botbuilder-core/src/privateConversationState.ts index e1e8b169df..f67168ce8d 100644 --- a/libraries/botbuilder-core/src/privateConversationState.ts +++ b/libraries/botbuilder-core/src/privateConversationState.ts @@ -36,6 +36,7 @@ export class PrivateConversationState extends BotState { super(storage, (context: TurnContext) => { // Calculate storage key const key: string = this.getStorageKey(context); + return key ? Promise.resolve(key) : Promise.reject(new Error(NO_KEY)); }); } @@ -61,6 +62,7 @@ export class PrivateConversationState extends BotState { if (!userId) { throw new Error('missing activity.from.id'); } + return `${channelId}/conversations/${conversationId}/users/${userId}/${this.namespace}`; } } diff --git a/libraries/botbuilder-core/src/turnContext.ts b/libraries/botbuilder-core/src/turnContext.ts index a9b8d78393..6a92dca151 100644 --- a/libraries/botbuilder-core/src/turnContext.ts +++ b/libraries/botbuilder-core/src/turnContext.ts @@ -44,6 +44,7 @@ export type DeleteActivityHandler = ( next: () => Promise ) => Promise; +// tslint:disable-next-line:no-empty-interface export interface TurnContext {} /** diff --git a/libraries/botbuilder-dialogs/src/dialogSet.ts b/libraries/botbuilder-dialogs/src/dialogSet.ts index e4cfb40fb9..7616c0a7ae 100644 --- a/libraries/botbuilder-dialogs/src/dialogSet.ts +++ b/libraries/botbuilder-dialogs/src/dialogSet.ts @@ -93,6 +93,7 @@ export class DialogSet { } this.dialogs[dialog.id] = dialog; + return this; } diff --git a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts index 7fd7a4681a..33d3371e68 100644 --- a/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts +++ b/libraries/botbuilder-dialogs/src/prompts/activityPrompt.ts @@ -58,7 +58,7 @@ export abstract class ActivityPrompt extends Dialog { // Validate the return value // - Unlike the other prompts a validator is required for an ActivityPrompt so we don't // need to check for its existence before calling it. - const isValid = await this.validator({ + const isValid: boolean = await this.validator({ context: dc.context, recognized: recognized, state: state.state, diff --git a/libraries/botbuilder-dialogs/src/waterfallDialog.ts b/libraries/botbuilder-dialogs/src/waterfallDialog.ts index ee3d49bf91..a51ac1ebb4 100644 --- a/libraries/botbuilder-dialogs/src/waterfallDialog.ts +++ b/libraries/botbuilder-dialogs/src/waterfallDialog.ts @@ -126,6 +126,7 @@ export class WaterfallDialog extends Dialog { */ public addStep(step: WaterfallStep): this { this.steps.push(step); + return this; } @@ -184,7 +185,7 @@ export class WaterfallDialog extends Dialog { // Create step context const nextCalled: boolean = false; - const step = new WaterfallStepContext(dc, { + const step: WaterfallStepContext = new WaterfallStepContext(dc, { index: index, options: state.options, reason: reason, diff --git a/libraries/botbuilder/src/botFrameworkAdapter.ts b/libraries/botbuilder/src/botFrameworkAdapter.ts index 5655311d1a..edc8103869 100644 --- a/libraries/botbuilder/src/botFrameworkAdapter.ts +++ b/libraries/botbuilder/src/botFrameworkAdapter.ts @@ -549,6 +549,7 @@ export class BotFrameworkAdapter extends BotAdapter { // Authenticate the incoming request errorCode = 401; const authHeader: string = req.headers.authorization || req.headers.Authorization || ''; + return this.authenticateRequest(request, authHeader).then(() => { // Process received activity errorCode = 500; diff --git a/libraries/botframework-config/src/botConfiguration.ts b/libraries/botframework-config/src/botConfiguration.ts index f10ac97027..c0d11287cc 100644 --- a/libraries/botframework-config/src/botConfiguration.ts +++ b/libraries/botframework-config/src/botConfiguration.ts @@ -19,7 +19,8 @@ import * as encrypt from './encrypt'; */ import { ConnectedService } from './models'; import { IBotConfiguration, IConnectedService, IDispatchService, ServiceTypes } from './schema'; -const exec = util.promisify(require('child_process').exec); +// tslint:disable-next-line:no-var-requires no-require-imports +const exec: Function = util.promisify(require('child_process').exec); /** * @private @@ -56,6 +57,7 @@ export class BotConfiguration extends BotConfigurationBase { } botConfig.services = services; botConfig.migrateData(); + return botConfig; } diff --git a/libraries/botframework-config/src/botConfigurationBase.ts b/libraries/botframework-config/src/botConfigurationBase.ts index f7915a6d94..c1146fbe19 100644 --- a/libraries/botframework-config/src/botConfigurationBase.ts +++ b/libraries/botframework-config/src/botConfigurationBase.ts @@ -5,8 +5,12 @@ * Copyright(c) Microsoft Corporation.All rights reserved. * Licensed under the MIT License. */ -import { AppInsightsService, BlobStorageService, BotService, ConnectedService, CosmosDbService, DispatchService, EndpointService, FileService, GenericService, LuisService, QnaMakerService } from './models'; -import { IAppInsightsService, IBlobStorageService, IBotConfiguration, IBotService, IConnectedService, ICosmosDBService, IDispatchService, IEndpointService, IFileService, IGenericService, ILuisService, IQnAService, ServiceTypes } from './schema'; +import { + AppInsightsService, BlobStorageService, BotService, ConnectedService, CosmosDbService, DispatchService, + EndpointService, FileService, GenericService, LuisService, QnaMakerService } from './models'; +import { IAppInsightsService, IBlobStorageService, IBotConfiguration, IBotService, IConnectedService, + ICosmosDBService, IDispatchService, IEndpointService, IFileService, IGenericService, ILuisService, + IQnAService, ServiceTypes } from './schema'; /** * This is class which allows you to manipulate in memory representations of bot configuration with @@ -79,6 +83,7 @@ export class BotConfigurationBase implements Partial { Object.assign(botConfig, source); botConfig.services = services; botConfig.migrateData(); + return botConfig; } @@ -86,10 +91,11 @@ export class BotConfigurationBase implements Partial { * Returns a JSON based version of the current bot. */ public toJSON(): IBotConfiguration { - const newConfig = {}; + const newConfig: IBotConfiguration = {}; Object.assign(newConfig, this); delete (newConfig).internal; - newConfig.services = this.services.slice().map((service) => (service).toJSON()); + newConfig.services = this.services.slice().map((service: IConnectedService) => (service).toJSON()); + return newConfig; } @@ -194,13 +200,13 @@ export class BotConfigurationBase implements Partial { switch (service.type) { case ServiceTypes.Bot: { - const botService = service; + const botService: IBotService = service; // old bot service records may not have the appId on the bot, but we probably have it already on an endpoint if (!botService.appId) { for (const s of this.services) { - if (s.type == ServiceTypes.Endpoint) { - const endpoint = s; + if (s.type === ServiceTypes.Endpoint) { + const endpoint: IEndpointService = s; if (endpoint.appId) { botService.appId = endpoint.appId; break; diff --git a/libraries/botframework-config/src/botRecipe.ts b/libraries/botframework-config/src/botRecipe.ts index bce1c6f560..3ede3a9f36 100644 --- a/libraries/botframework-config/src/botRecipe.ts +++ b/libraries/botframework-config/src/botRecipe.ts @@ -73,7 +73,7 @@ export class BotRecipe { /** * Version of the recipe. */ - public version = '1.0'; + public version: string = '1.0'; /** * @@ -84,18 +84,21 @@ export class BotRecipe { * Creates a new BotRecipe instance. */ constructor() { + // noop } public static fromJSON(source: Partial = {}): BotRecipe { - const botRecipe = new BotRecipe(); + const botRecipe: BotRecipe = new BotRecipe(); const { version, resources } = source; botRecipe.resources = resources ? resources : botRecipe.resources; botRecipe.version = version ? version : botRecipe.version; + return botRecipe; } public toJSON(): Partial { const { version, resources } = this; + return { version, resources }; } } diff --git a/libraries/botframework-config/src/index.ts b/libraries/botframework-config/src/index.ts index 3b9f1c9718..c166d4ace9 100644 --- a/libraries/botframework-config/src/index.ts +++ b/libraries/botframework-config/src/index.ts @@ -7,6 +7,15 @@ */ export { BotConfiguration } from './botConfiguration'; export { BotConfigurationBase } from './botConfigurationBase'; -export { BotRecipe, IBlobResource, ICosmosDBResource, IDispatchResource, IFileResource, IGenericResource, IResource, IUrlResource } from './botRecipe'; +export { + BotRecipe, + IBlobResource, + ICosmosDBResource, + IDispatchResource, + IFileResource, + IGenericResource, + IResource, + IUrlResource +} from './botRecipe'; export * from './models'; export * from './schema'; diff --git a/libraries/botframework-config/src/models/connectedService.ts b/libraries/botframework-config/src/models/connectedService.ts index dbbb854131..9099e27d43 100644 --- a/libraries/botframework-config/src/models/connectedService.ts +++ b/libraries/botframework-config/src/models/connectedService.ts @@ -46,7 +46,7 @@ export class ConnectedService implements IConnectedService { * @param encryptString Function called to encrypt an individual value. */ public encrypt(secret: string, encryptString: (value: string, secret: string) => string): void { - + // noop } /** @@ -55,6 +55,6 @@ export class ConnectedService implements IConnectedService { * @param decryptString Function called to decrypt an individual value. */ public decrypt(secret: string, decryptString: (value: string, secret: string) => string): void { - + // noop } } diff --git a/libraries/botframework-config/src/models/luisService.ts b/libraries/botframework-config/src/models/luisService.ts index c42952282d..a5cd90bdb2 100644 --- a/libraries/botframework-config/src/models/luisService.ts +++ b/libraries/botframework-config/src/models/luisService.ts @@ -47,7 +47,7 @@ export class LuisService extends ConnectedService implements ILuisService { } // get endpoint for the luis service - public getEndpoint() { + public getEndpoint(): string { return `https://${this.region}.api.cognitive.microsoft.com`; } diff --git a/libraries/botframework-connector/src/auth/constants.ts b/libraries/botframework-connector/src/auth/constants.ts index 42c2c577d0..242063c4a9 100644 --- a/libraries/botframework-connector/src/auth/constants.ts +++ b/libraries/botframework-connector/src/auth/constants.ts @@ -29,7 +29,8 @@ export module Constants { /** * TO BOT FROM ENTERPRISE CHANNEL: OpenID metadata document for tokens coming from MSA */ - export const ToBotFromEnterpriseChannelOpenIdMetadataUrlFormat = 'https://{channelService}.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration'; + export const ToBotFromEnterpriseChannelOpenIdMetadataUrlFormat: string = + 'https://{channelService}.enterprisechannel.botframework.com/v1/.well-known/openidconfiguration'; /** * TO BOT FROM EMULATOR: OpenID metadata document for tokens coming from MSA diff --git a/libraries/botframework-connector/src/auth/governmentChannelValidation.ts b/libraries/botframework-connector/src/auth/governmentChannelValidation.ts index 5f86e75ecb..c9b7d3befe 100644 --- a/libraries/botframework-connector/src/auth/governmentChannelValidation.ts +++ b/libraries/botframework-connector/src/auth/governmentChannelValidation.ts @@ -66,7 +66,8 @@ export module GovernmentChannelValidation { const tokenExtractor: JwtTokenExtractor = new JwtTokenExtractor( ToBotFromGovernmentChannelTokenValidationParameters, - ChannelValidation.OpenIdMetadataEndpoint ? ChannelValidation.OpenIdMetadataEndpoint : GovernmentConstants.ToBotFromChannelOpenIdMetadataUrl, + ChannelValidation.OpenIdMetadataEndpoint ? + ChannelValidation.OpenIdMetadataEndpoint : GovernmentConstants.ToBotFromChannelOpenIdMetadataUrl, Constants.AllowedSigningAlgorithms); const identity: ClaimsIdentity = await tokenExtractor.getIdentityFromAuthHeader(authHeader, channelId); @@ -75,11 +76,11 @@ export module GovernmentChannelValidation { } /** - * Validate the ClaimsIdentity to ensure it came from the channel service. - * @param {ClaimsIdentity} identity The identity to validate - * @param {ICredentialProvider} credentials The user defined set of valid credentials, such as the AppId. - * @returns {Promise} A valid ClaimsIdentity. - */ + * Validate the ClaimsIdentity to ensure it came from the channel service. + * @param {ClaimsIdentity} identity The identity to validate + * @param {ICredentialProvider} credentials The user defined set of valid credentials, such as the AppId. + * @returns {Promise} A valid ClaimsIdentity. + */ export async function validateIdentity( identity: ClaimsIdentity, credentials: ICredentialProvider diff --git a/libraries/botframework-connector/src/auth/jwtTokenExtractor.ts b/libraries/botframework-connector/src/auth/jwtTokenExtractor.ts index b79047fc76..62ab7ad018 100644 --- a/libraries/botframework-connector/src/auth/jwtTokenExtractor.ts +++ b/libraries/botframework-connector/src/auth/jwtTokenExtractor.ts @@ -65,7 +65,8 @@ export class JwtTokenExtractor { try { return await this.validateToken(parameter, channelId); } catch (err) { - console.log('JwtTokenExtractor.getIdentity:err!', err); + // tslint:disable-next-line:no-console + console.error('JwtTokenExtractor.getIdentity:err!', err); throw err; } } @@ -127,7 +128,8 @@ export class JwtTokenExtractor { return new ClaimsIdentity(claims, true); } catch (err) { - console.log(`Error finding key for token. Available keys: ${metadata.key}`); + // tslint:disable-next-line:no-console + console.error(`Error finding key for token. Available keys: ${metadata.key}`); throw err; } } diff --git a/libraries/botframework-connector/src/auth/jwtTokenValidation.ts b/libraries/botframework-connector/src/auth/jwtTokenValidation.ts index 036f96a8a4..ef06189de3 100644 --- a/libraries/botframework-connector/src/auth/jwtTokenValidation.ts +++ b/libraries/botframework-connector/src/auth/jwtTokenValidation.ts @@ -40,7 +40,8 @@ export module JwtTokenValidation { throw new Error('Unauthorized Access. Request is not authorized'); } - const claimsIdentity: ClaimsIdentity = await validateAuthHeader(authHeader, credentials, channelService, activity.channelId, activity.serviceUrl); + const claimsIdentity: ClaimsIdentity = + await validateAuthHeader(authHeader, credentials, channelService, activity.channelId, activity.serviceUrl); MicrosoftAppCredentials.trustServiceUrl(activity.serviceUrl); @@ -72,7 +73,12 @@ export module JwtTokenValidation { if (isGovernment(channelService)) { if (serviceUrl.trim()) { - return await GovernmentChannelValidation.authenticateChannelTokenWithServiceUrl(authHeader, credentials, serviceUrl, channelId); + return await GovernmentChannelValidation.authenticateChannelTokenWithServiceUrl( + authHeader, + credentials, + serviceUrl, + channelId + ); } return await GovernmentChannelValidation.authenticateChannelToken(authHeader, credentials, channelId); @@ -80,17 +86,23 @@ export module JwtTokenValidation { // Otherwise use Enterprise Channel Validation if (serviceUrl.trim()) { - return await EnterpriseChannelValidation.authenticateChannelTokenWithServiceUrl(authHeader, credentials, serviceUrl, channelId, channelService); + return await EnterpriseChannelValidation.authenticateChannelTokenWithServiceUrl( + authHeader, + credentials, + serviceUrl, + channelId, + channelService + ); } return await EnterpriseChannelValidation.authenticateChannelToken(authHeader, credentials, channelId, channelService); } - function isPublicAzure(channelService: string) { + function isPublicAzure(channelService: string): boolean { return !channelService || channelService.length === 0; } - function isGovernment(channelService: string) { + function isGovernment(channelService: string): boolean { return channelService && channelService.toLowerCase() === GovernmentConstants.ChannelService; } } diff --git a/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts b/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts index b1160dd984..01b92c23de 100644 --- a/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts +++ b/libraries/botframework-connector/src/auth/microsoftAppCredentials.ts @@ -65,6 +65,7 @@ export class MicrosoftAppCredentials implements msrest.ServiceClientCredentials return MicrosoftAppCredentials.isTrustedUrl(uri.host); } } catch (e) { + // tslint:disable-next-line:no-console console.error('Error in isTrustedServiceUrl', e); } diff --git a/libraries/botframework-connector/src/auth/openIdMetadata.ts b/libraries/botframework-connector/src/auth/openIdMetadata.ts index 6ccd3ce81d..d3101ecd13 100644 --- a/libraries/botframework-connector/src/auth/openIdMetadata.ts +++ b/libraries/botframework-connector/src/auth/openIdMetadata.ts @@ -6,7 +6,9 @@ * Licensed under the MIT License. */ import * as request from 'request'; +// tslint:disable-next-line:no-var-requires no-require-imports const getPem: any = require('rsa-pem-from-mod-exp'); +// tslint:disable-next-line:no-var-requires no-require-imports const base64url: any = require('base64url'); export class OpenIdMetadata { diff --git a/libraries/botframework-connector/src/oAuthApiClient.ts b/libraries/botframework-connector/src/oAuthApiClient.ts index 7ed7499562..89826d3995 100644 --- a/libraries/botframework-connector/src/oAuthApiClient.ts +++ b/libraries/botframework-connector/src/oAuthApiClient.ts @@ -362,14 +362,15 @@ export class OAuthApiClient { } // Serialize Request - let requestContent = null; + let requestContent: any = null; try { if (resourceUrls !== null && resourceUrls !== undefined) { requestContent = JSON.stringify(resourceUrls); } } catch (error) { - const serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + const serializationError: Error = new Error(`Error "${error.message}" occurred in serializing the ` + `payload - ${JSON.stringify(resourceUrls, null, 2)}.`); + return Promise.reject(serializationError); } httpRequest.body = requestContent; @@ -575,26 +576,32 @@ export class OAuthApiClient { } /** - * @summary GetAadTokens - * Gets Azure Active Directory tokens for specific resource URLs - * once the user has looged into a particure AAD connection. - * - * @param {string} userId Id of the user. - * - * @param {string} connectionName Name of the auth connection to use. - * - * @param {string[]} resourceUrls The resource URLs for which to get tokens. - * - * @param {RequestOptionsBase} [options] Optional Parameters. - * - * @returns {Promise} A promise is returned - */ - public async getAadTokens(userId: string, connectionName: string, resourceUrls: Models.AadResourceUrls, options?: msRest.RequestOptionsBase): Promise { - return this.getAadTokensWithHttpOperationResponse(userId, connectionName, resourceUrls, options).then((operationRes: msRest.HttpOperationResponse) => { - return Promise.resolve(operationRes.bodyAsJson as Models.TokenResponseMap); - }).catch((err: Error) => { - return Promise.reject(err); - }); + * @summary GetAadTokens + * Gets Azure Active Directory tokens for specific resource URLs + * once the user has looged into a particure AAD connection. + * + * @param {string} userId Id of the user. + * + * @param {string} connectionName Name of the auth connection to use. + * + * @param {string[]} resourceUrls The resource URLs for which to get tokens. + * + * @param {RequestOptionsBase} [options] Optional Parameters. + * + * @returns {Promise} A promise is returned + */ + public async getAadTokens( + userId: string, + connectionName: string, + resourceUrls: Models.AadResourceUrls, + options?: msRest.RequestOptionsBase + ): Promise { + return this.getAadTokensWithHttpOperationResponse(userId, connectionName, resourceUrls, options) + .then((operationRes: msRest.HttpOperationResponse) => { + return Promise.resolve(operationRes.bodyAsJson as Models.TokenResponseMap); + }).catch((err: Error) => { + return Promise.reject(err); + }); } /**