From 8b3fdbe372eade1cc33ba0facee7b1aed048510f Mon Sep 17 00:00:00 2001 From: Matt Mazzola Date: Mon, 20 Aug 2018 10:11:19 -0700 Subject: [PATCH] style: remove trailing white space There is current bug with syntax highlighting on TypeScripot files which have trailing white space. https://github.com/Microsoft/TypeScript-TmLanguage/issues/654 https://github.com/Microsoft/vscode/issues/56706#issuecomment-414385756 --- src/AzureFunctions.ts | 4 +- src/CLClient.ts | 24 ++++----- src/CLDebug.ts | 2 +- src/CLMemory.ts | 6 +-- src/CLOptions.ts | 2 +- src/CLRecognizeResult.ts | 2 +- src/CLRunner.ts | 88 +++++++++++++++---------------- src/ConversationLearner.ts | 10 ++-- src/FileStorage.ts | 8 +-- src/Memory/BotMemory.ts | 2 +- src/Memory/BotState.ts | 36 ++++++------- src/Memory/BrowserSlot.ts | 6 +-- src/Memory/ClientMemoryManager.ts | 12 ++--- src/Memory/InputQueue.ts | 8 +-- src/RedisStorage.ts | 4 +- src/TemplateProvider.ts | 4 +- src/Utils.ts | 10 ++-- src/clUi.ts | 4 +- src/clUiRunner.ts | 2 +- src/constants.ts | 2 +- src/http/router.test.ts | 2 +- src/http/router.ts | 22 ++++---- src/index.ts | 2 +- src/utils.test.ts | 2 +- 24 files changed, 132 insertions(+), 132 deletions(-) diff --git a/src/AzureFunctions.ts b/src/AzureFunctions.ts index c34331fe..785cceae 100644 --- a/src/AzureFunctions.ts +++ b/src/AzureFunctions.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as Request from 'request' @@ -19,7 +19,7 @@ export class AzureFunctions { return new Promise((resolve, reject) => { const requestData = { url: azureFunctionsUrl + funcName + '/' + args, - /* TODO - auth + /* TODO - auth headers: { 'Cookie' : this.credentials.Cookiestring(), },*/ diff --git a/src/CLClient.ts b/src/CLClient.ts index 21b11b3e..50fbf023 100644 --- a/src/CLClient.ts +++ b/src/CLClient.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as models from '@conversationlearner/models' @@ -67,25 +67,25 @@ export class CLClient { // check if request is bypassing cognitive services APIM if(!this.options.CONVERSATION_LEARNER_SERVICE_URI.includes('api.cognitive.microsoft.com')) { - // In this case we are not chaning the serviceUrl and it stays the same, + // In this case we are not chaning the serviceUrl and it stays the same, // for example: https://localhost:37936/api/v1/ -> https://localhost:37936/api/v1/ return this.MakeURL(apiPath, query) } - + // The base uri for session API in cognitive services APIM is in the form of '/conversationlearner/session/v1.0/' - // Session API are the following api: + // Session API are the following api: // 1) POST /app//session // 2) PUT /app//session/extract // 3) PUT /app//session/score // 4) DELETE /app//session - let baseUri = this.options.CONVERSATION_LEARNER_SERVICE_URI.endsWith('/') ? - this.options.CONVERSATION_LEARNER_SERVICE_URI : + let baseUri = this.options.CONVERSATION_LEARNER_SERVICE_URI.endsWith('/') ? + this.options.CONVERSATION_LEARNER_SERVICE_URI : `${this.options.CONVERSATION_LEARNER_SERVICE_URI}/` const apimVersionSuffix = '/v1.0/' if(baseUri.endsWith(apimVersionSuffix)) { // In this case, serviceurl has api version information in it; "session" will be inserted before /v1.0 - // this means that https://westus.api.cognitive.microsoft.com/conversationlearner/v1.0/ becomes + // this means that https://westus.api.cognitive.microsoft.com/conversationlearner/v1.0/ becomes // https://westus.api.cognitive.microsoft.com/conversationlearner/session/v1.0/ baseUri = `${baseUri.substring(0, baseUri.lastIndexOf(apimVersionSuffix))}/session${apimVersionSuffix}` } @@ -118,7 +118,7 @@ export class CLClient { if(!requestMethod) { throw new Error(`Request method not found for http verb: ${method}`) } - + requestMethod(requestData, (error, response, responseBody) => { if (error) { reject(error) @@ -134,7 +134,7 @@ export class CLClient { //============================================================================== // App //============================================================================= - /** + /** * Retrieve information about a specific application * If the app ID isn't found in the set of (non-archived) apps, * returns 404 error ("not found") @@ -161,7 +161,7 @@ export class CLClient { return this.send('POST', this.MakeURL(apiPath)) } - /** + /** * Archive an existing application * Note: "deleting" an application doesn't destroy it, but rather archives * it for a period (eg 30 days). During the archive period, the application @@ -173,7 +173,7 @@ export class CLClient { return this.send('DELETE', this.MakeURL(apiPath)) } - /** + /** * Create a new application */ // TODO: Fix API to return full object @@ -278,7 +278,7 @@ export class CLClient { /** End a session. */ public EndSession(appId: string, sessionId: string): Promise { let apiPath = `app/${appId}/session/${sessionId}` - //TODO: remove this when redundant query parameter is removed + //TODO: remove this when redundant query parameter is removed let query = 'saveDialog=false' return this.send('DELETE', this.MakeSessionURL(apiPath, query)) } diff --git a/src/CLDebug.ts b/src/CLDebug.ts index 225548b5..232d11fc 100644 --- a/src/CLDebug.ts +++ b/src/CLDebug.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { Utils } from './Utils' diff --git a/src/CLMemory.ts b/src/CLMemory.ts index 35b0796d..adff4ebe 100644 --- a/src/CLMemory.ts +++ b/src/CLMemory.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -38,7 +38,7 @@ export class CLMemory { if (!user.id) { throw new Error(`Attempted to initialize memory, but user.id was not provided which is required for use as memory key.`) } - + let memory = new CLMemory(user.id) await memory.BotState.SetConversationReference(conversationReference) return memory @@ -52,7 +52,7 @@ export class CLMemory { if (!CLMemory.memoryStorage) { throw new Error('Memory storage not found') } - + let key = this.Key(datakey) let cacheData = this.memCache[key] if (cacheData) { diff --git a/src/CLOptions.ts b/src/CLOptions.ts index 4d3c92c4..270758d7 100644 --- a/src/CLOptions.ts +++ b/src/CLOptions.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ export interface ICLOptions { diff --git a/src/CLRecognizeResult.ts b/src/CLRecognizeResult.ts index 9123ec2d..8c54bb31 100644 --- a/src/CLRecognizeResult.ts +++ b/src/CLRecognizeResult.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { CLMemory } from './CLMemory' diff --git a/src/CLRunner.ts b/src/CLRunner.ts index 0eb3030f..8f30350c 100644 --- a/src/CLRunner.ts +++ b/src/CLRunner.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -111,7 +111,7 @@ export class CLRunner { public static Create(configModelId: string | undefined, maxTimeout: number | undefined, client: CLClient): CLRunner { - // Ok to not provide modelId when just running in training UI. + // Ok to not provide modelId when just running in training UI. // If not, Use UI_RUNNER_APPID const as lookup value let newRunner = new CLRunner(configModelId, maxTimeout, client); CLRunner.Runners[configModelId || UI_RUNNER_APPID] = newRunner; @@ -161,7 +161,7 @@ export class CLRunner { public async InTrainingUI(turnContext: BB.TurnContext): Promise { if (turnContext.activity.from && turnContext.activity.from.name === CL_DEVELOPER) { let clMemory = CLMemory.GetMemory(turnContext.activity.from.id) - let app = await clMemory.BotState.GetApp() + let app = await clMemory.BotState.GetApp() // If no app selected in UI or no app set in config, or they match return true if (!app || !this.configModelId || app.appId === this.configModelId) { return true @@ -169,7 +169,7 @@ export class CLRunner { } return false } - + // Allows Bot developer to start a new Session with initial parameters (never in Teach) public async BotStartSession(turnContext: BB.TurnContext): Promise { @@ -185,7 +185,7 @@ export class CLRunner { try { let app = await this.GetRunningApp(activity.from.id, false); let clMemory = await CLMemory.InitMemory(activity.from, conversationReference) - + if (app) { let packageId = (app.livePackageId || app.devPackageId) if (packageId) { @@ -194,7 +194,7 @@ export class CLRunner { } } catch (error) { - CLDebug.Error(error) + CLDebug.Error(error) } } @@ -234,13 +234,13 @@ export class CLRunner { else { let addInputPromise = util.promisify(InputQueue.AddInput); let isReady = await addInputPromise(botState, turnContext.activity, conversationReference); - + if (isReady) { let intents = await this.ProcessInput(turnContext.activity, conversationReference); return intents; } - // Message has expired + // Message has expired return null; } } @@ -261,8 +261,8 @@ export class CLRunner { let clMemory = CLMemory.GetMemory(key) let app = await clMemory.BotState.GetApp() - if (app) { - // If I'm not in the editing UI, always use app specified by options + if (app) { + // If I'm not in the editing UI, always use app specified by options if (!inEditingUI && this.configModelId && this.configModelId != app.appId) { // Use config value @@ -281,12 +281,12 @@ export class CLRunner { } - // Initialize a log or teach session + // Initialize a log or teach session public async InitSessionAsync(clMemory: CLMemory, sessionId: string, logDialogId: string | null, conversationId: string | null, sessionStartFlags: SessionStartFlags): Promise { - + let app = await clMemory.BotState.GetApp() - // If not continuing an edited session, call endSession + // If not continuing an edited session, call endSession if (!(sessionStartFlags && SessionStartFlags.IS_EDIT_CONTINUE)) { // Default callback will clear the bot memory. // END_SESSION action was never triggered, so SessionEndState.OPEN @@ -318,8 +318,8 @@ export class CLRunner { } try { - - let inEditingUI = + + let inEditingUI = conversationReference.user && conversationReference.user.name === CL_DEVELOPER || false; @@ -354,7 +354,7 @@ export class CLRunner { const currentTicks = new Date().getTime(); let lastActive = await clMemory.BotState.GetLastActive() let passedTicks = currentTicks - lastActive; - if (passedTicks > this.maxTimeout!) { + if (passedTicks > this.maxTimeout!) { // End the current session, clear the memory await this.clClient.EndSession(app.appId, sessionId) @@ -373,17 +373,17 @@ export class CLRunner { app = await this.clClient.GetApp(this.configModelId) await clMemory.SetAppAsync(app) - + if (!app) { let error = "ERROR: Failed to find Model specified by CONVERSATION_LEARNER_MODEL_ID" await this.SendMessage(clMemory, error, activity.id) return null } } - - // Start a new session + + // Start a new session let sessionResponse = await this.clClient.StartSession(app.appId, {saveToLog: app.metadata.isLoggingOn}) - + // Update Memory, passing in original sessionId for reference let conversationId = await clMemory.BotState.GetConversationId() @@ -418,7 +418,7 @@ export class CLRunner { // Check if StartSession call is required await this.CheckSessionStartCallback(clMemory, app ? app.appId : null); - + // Process any form data let buttonResponse = await this.ProcessFormData(activity, clMemory, app.appId) @@ -650,7 +650,7 @@ export class CLRunner { if (appId && this.onSessionStartCallback && this.adapter) { let entityList = await this.clClient.GetEntities(appId) let memoryManager = await this.CreateMemoryManagerAsync(clMemory, entityList.entities) - + // Get conversation ref, so I can generate context and send it back to bot dev let conversationReference = await clMemory.BotState.GetConversationReverence() if (!conversationReference) { @@ -682,7 +682,7 @@ export class CLRunner { let needEndSession = await clMemory.BotState.GetNeedSessionEndCall(); if (needEndSession) { - + // If bot has callback, call it to determine which entities to clear / edit if (appId && this.onSessionEndCallback && this.adapter) { let entityList = await this.clClient.GetEntities(appId) @@ -710,7 +710,7 @@ export class CLRunner { this.SendMessage(clMemory, errMsg); } }) - } + } // Otherwise just clear the memory else { await clMemory.BotMemory.ClearAsync() @@ -754,7 +754,7 @@ export class CLRunner { apiAction, filledEntityMap, clRecognizeResult.memory, - clRecognizeResult.clEntities, + clRecognizeResult.clEntities, inTeach, { skipLogic: false @@ -841,7 +841,7 @@ export class CLRunner { } const actionResult = await this.RenderTemplateAsync(conversationReference, intent, inTeach) - + if (actionResult.response != null) { await this.adapter.continueConversation(conversationReference, async (context) => { // Need to repeat null check as compiler is catching one above for explicit null @@ -860,7 +860,7 @@ export class CLRunner { if (incomingActivityId) { await InputQueue.MessageHandled(memory.BotState, incomingActivityId); } - + let conversationReference = await memory.BotState.GetConversationReverence() if (!conversationReference) { CLDebug.Error('Missing ConversationReference') @@ -941,7 +941,7 @@ export class CLRunner { if (!response && inTeach) { response = this.APICard(callback) } - + return { logicResult, response @@ -993,10 +993,10 @@ export class CLRunner { } public async TakeSessionAction(sessionAction: CLM.SessionAction, filledEntityMap: CLM.FilledEntityMap, inTeach: boolean, userId: string, sessionId: string | null): Promise | null> { - + // Get any context from the action let content = sessionAction.renderValue(CLM.getEntityDisplayValueMap(filledEntityMap)) - + // Send original session Id. Used for continuing sessions await this.EndSessionAsync(userId, CLM.SessionEndState.COMPLETED, sessionId, content); @@ -1106,7 +1106,7 @@ export class CLRunner { } /** - * Identify any validation issues + * Identify any validation issues * Missing Entities * Missing Actions * Unavailable Actions @@ -1167,7 +1167,7 @@ export class CLRunner { private PopulatePrebuilts(predictedEntities: CLM.PredictedEntity[], filledEntities: CLM.FilledEntity[]) { for (let pe of predictedEntities) { let filledEnt = filledEntities.find(fe => fe.entityId === pe.entityId); - if (filledEnt) { + if (filledEnt) { let value = filledEnt.values.find(v => v.userText === pe.entityText) if (value) { pe.resolution = value.resolution; @@ -1179,8 +1179,8 @@ export class CLRunner { } } - /** - * Get Activities generated by trainDialog. + /** + * Get Activities generated by trainDialog. * NOTE: Will set bot memory to state at end of history */ public async GetHistory( @@ -1235,12 +1235,12 @@ export class CLRunner { let userActivity = { id: generateGUID(), from: { id: userId, name: userName }, - channelData: { - senderType: CLM.SenderType.User, - roundIndex: roundNum, - scoreIndex: 0, + channelData: { + senderType: CLM.SenderType.User, + roundIndex: roundNum, + scoreIndex: 0, clientActivityId: generateGUID(), - highlight: chatHighlight}, + highlight: chatHighlight}, type: 'message', text: userText } as BB.Activity @@ -1290,9 +1290,9 @@ export class CLRunner { } } - let channelData = { - senderType: CLM.SenderType.Bot, - roundIndex: roundNum, + let channelData = { + senderType: CLM.SenderType.Bot, + roundIndex: roundNum, scoreIndex: scoreNum, highlight: chatHighlight } @@ -1372,7 +1372,7 @@ export class CLRunner { let hasRounds = trainDialog.rounds.length > 0; let hasScorerRound = (hasRounds && trainDialog.rounds[trainDialog.rounds.length-1].scorerSteps.length > 0) let dialogMode = CLM.DialogMode.Scorer; - + // If I have no rounds, I'm waiting for input if (!hasRounds) { dialogMode = CLM.DialogMode.Wait; @@ -1404,7 +1404,7 @@ export class CLRunner { } - // Make errors unique using Set operator + // Make errors unique using Set operator replayErrors = [...new Set(replayErrors)] let teachWithHistory: CLM.TeachWithHistory = { diff --git a/src/ConversationLearner.ts b/src/ConversationLearner.ts index 80478736..ef6b9f4d 100644 --- a/src/ConversationLearner.ts +++ b/src/ConversationLearner.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -27,7 +27,7 @@ export class ConversationLearner { } catch (error) { CLDebug.Error(error, 'Conversation Learner Initialization') } - + return getRouter(this.clClient, options) } @@ -49,7 +49,7 @@ export class ConversationLearner { /** * OPTIONAL: Sessions are started automatically, StartSession call is only needed if bot needs - * to start Conversation Learner Session with initial entity values. + * to start Conversation Learner Session with initial entity values. * Results in clearing of existing Entity values, and a call to the OnSessionStartCallback * @param turnContext BotBuilder Context */ @@ -64,7 +64,7 @@ export class ConversationLearner { public OnSessionStartCallback(target: OnSessionStartCallback) { this.clRunner.onSessionStartCallback = target } - + /** * Provide a callback that will be invoked whenever a Session ends. Sessions * can end because of a timeout or the selection of an EndSession activity @@ -86,7 +86,7 @@ export class ConversationLearner { return await this.clRunner.InTrainingUI(turnContext) } - /** + /** * Define an API callback that can be used by the Model * @param callback Object with callback name, optional logic function, and optional render function. */ diff --git a/src/FileStorage.ts b/src/FileStorage.ts index 7d5585fc..73d231c6 100644 --- a/src/FileStorage.ts +++ b/src/FileStorage.ts @@ -1,12 +1,12 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ /** * @module botbuilder-node */ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { Storage, StoreItems, StoreItem } from 'botbuilder'; @@ -17,7 +17,7 @@ import * as filenamify from 'filenamify'; /** * :package: **botbuilder** - * + * * A file based storage provider. Items will be persisted to a folder on disk. * * **Usage Example** @@ -25,7 +25,7 @@ import * as filenamify from 'filenamify'; * ```JavaScript * const { FileStorage } = require('botbuilder'); * const path = require('path'); - * + * * const storage = new FileStorage(path.join(__dirname, './state')); * ``` */ diff --git a/src/Memory/BotMemory.ts b/src/Memory/BotMemory.ts index 236ebe56..4699903a 100644 --- a/src/Memory/BotMemory.ts +++ b/src/Memory/BotMemory.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { CLMemory } from '../CLMemory' diff --git a/src/Memory/BotState.ts b/src/Memory/BotState.ts index 80664d9c..7564b5fe 100644 --- a/src/Memory/BotState.ts +++ b/src/Memory/BotState.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -22,14 +22,14 @@ export interface SessionInfo { // TODO - move to models export interface ActiveApps { - [appId: string]: string + [appId: string]: string } export enum BotStateType { // Currently running application APP = 'APP', //public app: AppBase | null = null - + // Conversation Id associated with this session CONVERSATION_ID = 'CONVERSATION_ID', @@ -38,30 +38,30 @@ export enum BotStateType { // Which packages are active for editing EDITING_PACKAGE = 'EDITING_PACKAGE', - + // Is current session a teach session - IN_TEACH = 'IN_TEACH', + IN_TEACH = 'IN_TEACH', // Last time active session was used (in ticks) - LAST_ACTIVE = 'LAST_ACTIVE', + LAST_ACTIVE = 'LAST_ACTIVE', // If session is a chat session what is logDialogId - LOG_DIALOG_ID = 'LOG_DIALOG_ID', + LOG_DIALOG_ID = 'LOG_DIALOG_ID', // Current message being processed MESSAGE_MUTEX = 'MESSAGE_MUTEX', // True if onStartSession needs to be called - NEED_SESSIONSTART_CALL = 'ON_STARTSESSION_CALLED', + NEED_SESSIONSTART_CALL = 'ON_STARTSESSION_CALLED', // True if onEndSession needs to be called - NEED_SESSIONEND_CALL = 'ON_ENDSESSION_CALLED', + NEED_SESSIONEND_CALL = 'ON_ENDSESSION_CALLED', // If session is continuation of times out session, what was the original sessionId ORIG_SESSION = 'ORIG_SESSION', // Currently active session - SESSION_ID = 'SESSION_ID' + SESSION_ID = 'SESSION_ID' } export class BotState { @@ -84,7 +84,7 @@ export class BotState { if (!this.memory) { throw new Error('BotState called without initializing memory') } - + try { let data = await this.memory.GetAsync(botStateType); return JSON.parse(data) as T; @@ -101,7 +101,7 @@ export class BotState { if (!this.memory) { throw new Error('BotState called without initializing memory') } - const json = JSON.stringify(value) + const json = JSON.stringify(value) await this.memory.SetAsync(botStateType, json) } @@ -139,7 +139,7 @@ export class BotState { else { // Store only needed data let smallApp = { - appId: app.appId, + appId: app.appId, appName: app.appName, livePackageId: app.livePackageId, devPackageId: app.devPackageId, @@ -254,7 +254,7 @@ export class BotState { if (!existingConversationId) { await this.SetConversationId(conversationId) return await this.GetStateAsync(BotStateType.SESSION_ID) - } + } // If conversation Id matches return the sessionId else if (existingConversationId == conversationId) { return await this.GetStateAsync(BotStateType.SESSION_ID) @@ -281,12 +281,12 @@ export class BotState { await this.SetConversationId(conversationId) await this.SetLastActive(new Date().getTime()) await this.SetInTeach((sessionStartFlags & SessionStartFlags.IN_TEACH) > 0) - await this.SetMessageProcessing(null) + await this.SetMessageProcessing(null) + - } - // End a session. + // End a session. // originalSessionId is sent when session terminated from EndSession action or expiration public async EndSessionAsync(originalSessionId: string | null = null): Promise { await this.SetSessionId(null); @@ -344,7 +344,7 @@ export class BotState { } as Partial this.SetConversationReference(conversationReference) } - + // ------------------------------------------------ // LOG_DIALOG_ID // ------------------------------------------------ diff --git a/src/Memory/BrowserSlot.ts b/src/Memory/BrowserSlot.ts index dfdc8594..111b2e07 100644 --- a/src/Memory/BrowserSlot.ts +++ b/src/Memory/BrowserSlot.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { CLMemory } from '../CLMemory' @@ -22,7 +22,7 @@ export class BrowserSlot { this.lastUsed = new Date().getTime(); this.id = String.fromCharCode(offset + 65) } - + public static async GetSlot(browserId: string) : Promise { let browserSlots = await this.BrowserSlots(); @@ -47,7 +47,7 @@ export class BrowserSlot { if (!oldestSlot) { throw new Error("Slot not found. This should never happen.") } - + // Claim this slot oldestSlot.lastUsed = new Date().getTime(); oldestSlot.browserId = browserId; diff --git a/src/Memory/ClientMemoryManager.ts b/src/Memory/ClientMemoryManager.ts index 5a4b801b..ab21e168 100644 --- a/src/Memory/ClientMemoryManager.ts +++ b/src/Memory/ClientMemoryManager.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { SessionInfo } from '../Memory/BotState' @@ -35,7 +35,7 @@ export class ReadOnlyClientMemoryManager { } /** - * Get value of entity + * Get value of entity * @param entityName Name of Entity */ public EntityValue(entityName: string): string | null { @@ -51,7 +51,7 @@ export class ReadOnlyClientMemoryManager { } /** - * Get value of entity as a Prebuilt Entity + * Get value of entity as a Prebuilt Entity * @param entityName Name of Entity */ public EntityValueAsPrebuilt(entityName: string): MemoryValue[] { @@ -59,7 +59,7 @@ export class ReadOnlyClientMemoryManager { } /** - * Get value of entity before most recent input as a Prebuilt Entity + * Get value of entity before most recent input as a Prebuilt Entity * @param entityName Name of Entity */ public PrevEntityValueAsPrebuilt(entityName: string): MemoryValue[] { @@ -146,7 +146,7 @@ export class ClientMemoryManager extends ReadOnlyClientMemoryManager { public AsReadOnly(): ReadOnlyClientMemoryManager { return this } - + public RememberEntity(entityName: string, entityValue: string | number | object): void { if (this.__expired) { CLDebug.Error(`ClientMemoryManager: RememberEntity "${entityName}" ${errMsg}`) @@ -216,7 +216,7 @@ export class ClientMemoryManager extends ReadOnlyClientMemoryManager { this.curMemories.Forget(entity.entityName, value, entity.isMultivalue) } - /** Clear all entity values apart from any included in the list of saveEntityNames + /** Clear all entity values apart from any included in the list of saveEntityNames * @param saveEntityNames Array of entity names not to forget */ public ForgetAllEntities(saveEntityNames: string[]): void { diff --git a/src/Memory/InputQueue.ts b/src/Memory/InputQueue.ts index 330961a5..896be723 100644 --- a/src/Memory/InputQueue.ts +++ b/src/Memory/InputQueue.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -21,7 +21,7 @@ export class InputQueue { public static async AddInput(botState: BotState, request: BB.Activity, conversationReference: Partial, callback: Function) : Promise { if (!request.id) { - return null; + return null; } // Add to queue @@ -34,9 +34,9 @@ export class InputQueue { // Add message to queue private static async InputQueueAdd(conversationId: string, callback: Function): Promise { const now = new Date().getTime(); - const queuedInput = + const queuedInput = { - conversationId: conversationId, + conversationId: conversationId, timestamp: now, callback: callback } as QueuedInput diff --git a/src/RedisStorage.ts b/src/RedisStorage.ts index 14ebb42a..02bf1039 100644 --- a/src/RedisStorage.ts +++ b/src/RedisStorage.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { Storage, StoreItems, StoreItem } from 'botbuilder' @@ -80,7 +80,7 @@ export class RedisStorage implements Storage { await this._del(key) } } - + private promisify(func: Function) { return (...args: any[]) => new Promise((resolve, reject) => { diff --git a/src/TemplateProvider.ts b/src/TemplateProvider.ts index 04c01ab0..c9ee7a0a 100644 --- a/src/TemplateProvider.ts +++ b/src/TemplateProvider.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as fs from 'fs' @@ -113,7 +113,7 @@ export class TemplateProvider { public static GetTemplate(templateName: string): any { const filename = path.join(this.TemplateDirectory(), `${templateName}.json`); - + try { const templateString = fs.readFileSync(filename, 'utf-8') diff --git a/src/Utils.ts b/src/Utils.ts index ad406b84..11e9f15e 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as BB from 'botbuilder' @@ -39,7 +39,7 @@ export class Utils { try { if (!error) { return prefix + 'Unknown' - } + } // Special message for 403 as it's like a bad ModelId else if (error.statusCode === 403) { return `403 Forbidden: Please check you have set a valid CONVERSATION_LEARNER_MODEL_ID` @@ -106,7 +106,7 @@ export const addEntitiesById = (valuesByName: FilledEntityMap): FilledEntityMap ...valuesByName.map, ...valuesById.map } - + return new FilledEntityMap({ map }) } @@ -122,10 +122,10 @@ export function replace(xs: T[], updatedX: T, getId: (x: T) => any): T[] { /* Returns true is SDK version in package is less than passed in version */ const packageJsonPath = path.join(__dirname, '..', 'package.json') export async function isSDKOld(curVersion: string): Promise { - const packageJson = await fs.readJson(packageJsonPath) + const packageJson = await fs.readJson(packageJsonPath) if (packageJson.version === "0.0.0-development") { return false - } + } return semver.lt(packageJson.version, curVersion) } diff --git a/src/clUi.ts b/src/clUi.ts index be531c4a..20e177c5 100644 --- a/src/clUi.ts +++ b/src/clUi.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as express from 'express' @@ -20,7 +20,7 @@ export default function(port: number = 5050): { app: express.Express; listener: console.log(`ERROR: The UI is already running or the port (${port}) is in use by another process`) return } - + throw error }); diff --git a/src/clUiRunner.ts b/src/clUiRunner.ts index 26dd7885..1886917f 100644 --- a/src/clUiRunner.ts +++ b/src/clUiRunner.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ /** diff --git a/src/constants.ts b/src/constants.ts index d8733ef5..96c6a344 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ export const apimSubscriptionKeyHeader = 'Ocp-Apim-Subscription-Key' diff --git a/src/http/router.test.ts b/src/http/router.test.ts index f74e6293..c3c3349c 100644 --- a/src/http/router.test.ts +++ b/src/http/router.test.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as supertest from 'supertest' diff --git a/src/http/router.ts b/src/http/router.ts index 4d7df518..571b084f 100644 --- a/src/http/router.ts +++ b/src/http/router.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as express from 'express' @@ -82,7 +82,7 @@ const getBanner = (source: string) : Promise => { const options = { method: 'GET', uri: source, - json: true + json: true } ​ // Never fail this request @@ -170,7 +170,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. // Retrieve any status message let banner = await getBanner(statusEndpoint); - + // If no status message, check if version update message is needed if (!banner) { // Display version banner if SDK is obsolete @@ -217,7 +217,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. const appId = await client.AddApp(newApp, query) const app = await client.GetApp(appId) res.send(app) - + // Initialize memory await CLMemory.GetMemory(key).SetAppAsync(app) } catch (error) { @@ -395,7 +395,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. const entity: models.EntityBase = req.body const { packageId } = getQuery(req) const appDefinition = await client.GetAppSource(appId, packageId) - + // Replace the entity with new one appDefinition.entities = replace(appDefinition.entities, entity, e => e.entityId) @@ -445,7 +445,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. //======================================================== // TrainDialogs //======================================================== - /** + /** * RUN EXTRACTOR: Runs entity extraction on a train dialog */ router.put('/app/:appId/traindialog/:trainDialogId/extractor/:turnIndex', async (req, res, next) => { @@ -517,7 +517,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. const clRunner = CLRunner.GetRunnerForUI(appId); const memory = CLMemory.GetMemory(key) memory.BotMemory.ClearAsync() - + clRunner.InitSessionAsync(memory, sessionResponse.sessionId, sessionResponse.logDialogId, null, SessionStartFlags.NONE) } catch (error) { HandleError(res, error) @@ -565,7 +565,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. let response : string if (!originalSessionId) { - // This can happen when a LogDialog End_Session Action is called and the + // This can happen when a LogDialog End_Session Action is called and the // user subsequently presses the DONE button response = await client.EndSession(appId, sessionId) @@ -868,7 +868,7 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. // Clear bot memory generated with this memory.BotMemory.ClearAsync(); - + if (teachWithHistory) { res.send(teachWithHistory) } @@ -946,9 +946,9 @@ export const getRouter = (client: CLClient, options: ICLClientOptions): express. * Currently there is conflict of interest. For the custom routes we define, we want the body parsed * so we need bodyParser.json() middleware above it in the pipeline; however, when bodyParser is above/before * the http-proxy-middleware then it can't properly stream the body through. - * + * * This code explicitly re-streams the data by calling .write() - * + * * Ideally we could find a way to only use bodyParser.json() on our custom routes so it's no in the pipeline above * the proxy */ diff --git a/src/index.ts b/src/index.ts index da9d1773..33a365e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { ConversationLearner } from './ConversationLearner' diff --git a/src/utils.test.ts b/src/utils.test.ts index 35be5522..9258e31d 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. + * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import * as utils from './Utils'